diff --git a/Package.swift b/Package.swift index b77ae820..1cdee1c9 100644 --- a/Package.swift +++ b/Package.swift @@ -10,6 +10,9 @@ let package = Package( .library( name: "Skyflow", targets: ["Skyflow"]), + .library( + name: "SkyflowFlowVault", + targets: ["SkyflowFlowVault"]), ], dependencies: [ // Dependencies declare other packages that this package depends on. @@ -19,29 +22,35 @@ let package = Package( // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( - name: "Skyflow", + name: "SkyflowCore", dependencies: [], resources: [ .process("Resources") ] ), + .target( + name: "Skyflow", + dependencies: ["SkyflowCore"]), + .target( + name: "SkyflowFlowVault", + dependencies: ["SkyflowCore"]), .testTarget( name: "skyflow-iOS-collectTests", - dependencies: ["Skyflow"]), + dependencies: ["Skyflow", "SkyflowCore"]), .testTarget(name: "skyflow-iOS-revealTests", - dependencies: ["Skyflow"]), + dependencies: ["Skyflow", "SkyflowCore"]), .testTarget(name: "skyflow-iOS-errorTests", - dependencies: ["Skyflow"]), + dependencies: ["Skyflow", "SkyflowCore"]), .testTarget(name: "skyflow-iOS-getByIdTests", - dependencies: ["Skyflow"]), + dependencies: ["Skyflow", "SkyflowCore"]), .testTarget(name: "skyflow-iOS-elementTests", - dependencies: ["Skyflow"]), + dependencies: ["Skyflow", "SkyflowCore"]), .testTarget(name: "skyflow-iOS-utilTests", - dependencies: ["Skyflow"]), + dependencies: ["Skyflow", "SkyflowCore"]), .testTarget(name: "skyflow-iOS-scenarioTests", - dependencies: ["Skyflow"]), + dependencies: ["Skyflow", "SkyflowCore"]), .testTarget(name: "skyflow-iOS-getTests", - dependencies: ["Skyflow"]), - .testTarget(name: "skyflow-iOS-composableTests", dependencies: ["Skyflow"]) + dependencies: ["Skyflow", "SkyflowCore"]), + .testTarget(name: "skyflow-iOS-composableTests", dependencies: ["Skyflow", "SkyflowCore"]) ] ) diff --git a/Skyflow.podspec b/Skyflow.podspec index 88887bb6..4c56c43f 100644 --- a/Skyflow.podspec +++ b/Skyflow.podspec @@ -22,9 +22,9 @@ Pod::Spec.new do |spec| spec.source = { :git => "https://github.com/skyflowapi/skyflow-iOS.git", :tag => "1.25.1" } - spec.source_files = "Sources/Skyflow/**/*.{swift}" + spec.source_files = "Sources/SkyflowCore/**/*.{swift}", "Sources/Skyflow/**/*.{swift}" - spec.resource_bundles = {'Skyflow' => ['Sources/Skyflow/Resources/**/*.{xcassets}'] } + spec.resource_bundles = {'Skyflow' => ['Sources/SkyflowCore/Resources/**/*.{xcassets}'] } end diff --git a/SkyflowFlowVault.podspec b/SkyflowFlowVault.podspec new file mode 100644 index 00000000..9fa7af59 --- /dev/null +++ b/SkyflowFlowVault.podspec @@ -0,0 +1,31 @@ +Pod::Spec.new do |spec| + + spec.name = "SkyflowFlowVault" + + spec.version = "3.0.0" + + spec.summary = "skyflow-iOS-flowvault" + + spec.description = "Skyflow iOS SDK for FlowDB-backed vaults" + + spec.homepage = "https://github.com/skyflowapi/skyflow-iOS.git" + + spec.license = { :type => "MIT", :file => "LICENSE" } + + spec.author = { "Skyflow" => "service-ops@skyflow.com" } + + spec.swift_version = '5.0' + + spec.platform = :ios, "13.0" + + spec.ios.deployment_target = "13.0" + + # NOTE: this tag does not exist yet - create it (or update this field) when + # the first SkyflowFlowVault release is actually cut. + spec.source = { :git => "https://github.com/skyflowapi/skyflow-iOS.git", :tag => "flowvault-3.0.0" } + + spec.source_files = "Sources/SkyflowCore/**/*.{swift}", "Sources/SkyflowFlowVault/**/*.{swift}" + + spec.resource_bundles = {'SkyflowFlowVault' => ['Sources/SkyflowCore/Resources/**/*.{xcassets}'] } + +end diff --git a/Sources/Skyflow/collect/CollectAPICallback.swift b/Sources/Skyflow/collect/CollectAPICallback.swift index 74cae186..9b2a8405 100644 --- a/Sources/Skyflow/collect/CollectAPICallback.swift +++ b/Sources/Skyflow/collect/CollectAPICallback.swift @@ -5,6 +5,7 @@ // Callback used while API callback for Collect the elements import Foundation +import SkyflowCore import UIKit internal class CollectAPICallback: Callback { diff --git a/Sources/Skyflow/collect/CollectContainer.swift b/Sources/Skyflow/collect/CollectContainer.swift index 16bb9035..380bd63f 100644 --- a/Sources/Skyflow/collect/CollectContainer.swift +++ b/Sources/Skyflow/collect/CollectContainer.swift @@ -5,10 +5,9 @@ // Implementation of Container Interface for Collect the records import Foundation +import SkyflowCore import UIKit -public class CollectContainer: ContainerProtocol {} - public extension Container { func create(input: CollectElementInput, options: CollectElementOptions? = CollectElementOptions()) -> TextField where T: CollectContainer { var tempContextOptions = self.skyflow.contextOptions @@ -33,30 +32,13 @@ public extension Container { let errorCode = ErrorCodes.EMPTY_VAULT_URL() return callback.onFailure(errorCode.getErrorObject(contextOptions: tempContextOptions)) } - var errors = "" var errorCode: ErrorCodes? Log.info(message: .VALIDATE_COLLECT_RECORDS, contextOptions: tempContextOptions) - for element in self.elements { - errorCode = checkElement(element: element) - if errorCode != nil { - callback.onFailure(errorCode!.getErrorObject(contextOptions: tempContextOptions)) - return - } - - - let state = element.getState() - let error = state["validationError"] - if (state["isRequired"] as! Bool) && (state["isEmpty"] as! Bool) { - errors += element.columnName + " is empty" + "\n" - element.updateErrorMessage() - } - if !(state["isValid"] as! Bool) { - errors += "for " + element.columnName + " " + (error as! String) + "\n" - } - if element.isFirstResponder { - element.resignFirstResponder() - } + let (elementError, errors) = CollectValidation.validateElements(self.elements) + if let elementError = elementError { + callback.onFailure(elementError.getErrorObject(contextOptions: tempContextOptions)) + return } if errors != "" { callback.onFailure(NSError(domain: "", code: 400, userInfo: [NSLocalizedDescriptionKey: errors])) @@ -103,20 +85,6 @@ public extension Container { } } - private func checkElement(element: TextField) -> ErrorCodes? { - if element.collectInput.table.isEmpty { - return .EMPTY_TABLE_NAME_IN_COLLECT() - } - if element.collectInput.column.isEmpty { - return .EMPTY_COLUMN_NAME_IN_COLLECT() - } - if !element.isMounted() { - return .UNMOUNTED_COLLECT_ELEMENT(value: element.collectInput.column) - } - - return nil - } - private func checkRecord(record: [String: Any], index: Int) -> ErrorCodes? { if record["table"] == nil { return .TABLE_KEY_ERROR(value: "\(index)") diff --git a/Sources/Skyflow/collect/CollectRequestBody.swift b/Sources/Skyflow/collect/CollectRequestBody.swift index b687f141..85d70d41 100644 --- a/Sources/Skyflow/collect/CollectRequestBody.swift +++ b/Sources/Skyflow/collect/CollectRequestBody.swift @@ -5,6 +5,7 @@ // Class for formatting the request body for collecting the data import Foundation +import SkyflowCore internal class CollectRequestBody { static var tableSet: Set = Set() diff --git a/Sources/Skyflow/collect/ICOptions.swift b/Sources/Skyflow/collect/ICOptions.swift index 1b2562df..b2ab9cd1 100644 --- a/Sources/Skyflow/collect/ICOptions.swift +++ b/Sources/Skyflow/collect/ICOptions.swift @@ -10,6 +10,7 @@ // import Foundation +import SkyflowCore internal struct ICOptions { var tokens: Bool diff --git a/Sources/Skyflow/collect/InsertAPICallback.swift b/Sources/Skyflow/collect/InsertAPICallback.swift index f2fe26f2..0d19a42a 100644 --- a/Sources/Skyflow/collect/InsertAPICallback.swift +++ b/Sources/Skyflow/collect/InsertAPICallback.swift @@ -5,6 +5,7 @@ // Callback used while API callback for Collect the elements import Foundation +import SkyflowCore import UIKit internal class InsertAPICallback: Callback { diff --git a/Sources/Skyflow/collect/InsertOptions.swift b/Sources/Skyflow/collect/InsertOptions.swift index e57737df..9a292861 100644 --- a/Sources/Skyflow/collect/InsertOptions.swift +++ b/Sources/Skyflow/collect/InsertOptions.swift @@ -5,6 +5,7 @@ // Object that describes the Options for Insert import Foundation +import SkyflowCore public struct InsertOptions { var tokens: Bool diff --git a/Sources/Skyflow/collect/TokenAPICallback.swift b/Sources/Skyflow/collect/TokenAPICallback.swift index 61413529..0e5215ef 100644 --- a/Sources/Skyflow/collect/TokenAPICallback.swift +++ b/Sources/Skyflow/collect/TokenAPICallback.swift @@ -10,6 +10,7 @@ // import Foundation +import SkyflowCore internal class TokenAPICallback: Callback { var callback: Callback diff --git a/Sources/Skyflow/composable/ComposableContainer.swift b/Sources/Skyflow/composable/ComposableContainer.swift index 5da7784c..e4527b64 100644 --- a/Sources/Skyflow/composable/ComposableContainer.swift +++ b/Sources/Skyflow/composable/ComposableContainer.swift @@ -5,12 +5,11 @@ // Implementation of Composable Container Interface for Collect the records import Foundation +import SkyflowCore import UIKit -public class ComposableContainer: ContainerProtocol {} - public extension Container { - + func create(input: CollectElementInput, options: CollectElementOptions? = CollectElementOptions()) -> TextField where T: ComposableContainer { var tempContextOptions = self.skyflow.contextOptions tempContextOptions.interface = .COMPOSABLE_CONTAINER @@ -23,7 +22,7 @@ public extension Container { Log.info(message: .CREATED_ELEMENT, values: [input.label == "" ? "composable" : input.label], contextOptions: tempContextOptions) return skyflowElement } - + func on(eventName: EventName, handler: @escaping () -> Void) { if (eventName == EventName.SUBMIT){ for element in elements { @@ -32,298 +31,108 @@ public extension Container { } } - internal func createRows(from elements: [Int], numberOfRows: Int) -> [[Int]] { - var number = Array(repeating: 0, count: elements.count) - var result = [[Int]]() - - for i in 0.. 0 { - number[i] = elements[i] + number[i-1] - } else { - number[i] = elements[i] - } - } - for i in 0.. [UILabel]{ - let labelArray = labelArray - for j in 0.. String { - guard startIndex >= 0, startIndex < array.count, - endIndex >= 0, endIndex < array.count, startIndex <= endIndex else { - return "" - } - let subarray = array[startIndex...endIndex] - - let concatenatedString = subarray.joined(separator: "") - - return concatenatedString + func getComposableView() throws -> UIView { + return try ComposableLayout.getComposableView(elements: elements, containerOptions: containerOptions) } - internal func createDynamicViews(layout: [Int]) -> UIView { - var errorList = Array(repeating: "", count: elements.count) - let parentView = UIView() - var previousChildView: UIView? = nil - var previousLabel: UILabel? = nil - var labelArray: [UILabel] = (0.. 1 && elementCount >= 1 && j > 0 { - - elements[elementCount].leadingAnchor.constraint(equalTo: elements[elementCount-1].trailingAnchor, constant: 20.0).isActive = true - elements[elementCount].centerYAnchor.constraint(equalTo: childView.centerYAnchor).isActive = true - - } else if j == 0 { - elements[elementCount].centerYAnchor.constraint(equalTo: childView.centerYAnchor).isActive = true - elements[elementCount].leftAnchor.constraint(equalTo: childView.leftAnchor, constant: 6.0).isActive = true - elements[elementCount].leadingAnchor.constraint(equalTo: childView.leadingAnchor, constant: 6.0).isActive = true - } - elements[elementCount].topAnchor.constraint(equalTo: childView.topAnchor).isActive = true - elements[elementCount].bottomAnchor.constraint(equalTo: childView.bottomAnchor).isActive = true - for element in elements { - element.onFocusIsTrue = { - errorList[element.elements.count] = "" - labelArray = self.updateErrorMessageInLabel(errorList: errorList, layout: layout, labelArray: labelArray, result: rowWiseError) - labelArray[i].textColor = self.containerOptions?.errorTextStyles?.focus?.textColor ?? self.containerOptions?.errorTextStyles?.base?.textColor ?? .none - labelArray[i].font = self.containerOptions?.errorTextStyles?.focus?.font ?? self.containerOptions?.errorTextStyles?.base?.font ?? .none - labelArray[i].textAlignment = self.containerOptions?.errorTextStyles?.focus?.textAlignment ?? self.containerOptions?.errorTextStyles?.base?.textAlignment ?? .left - } - - element.onEndEditing = { - if element.errorMessage.text == "" { - errorList[element.elements.count] = "" - } else { - errorList[element.elements.count] = element.errorMessage.text! + ". " - } - labelArray = self.updateErrorMessageInLabel(errorList: errorList, layout: layout, labelArray: labelArray, result: rowWiseError) - } - element.onBeginEditing = { - errorList[element.elements.count] = "" - labelArray = self.updateErrorMessageInLabel(errorList: errorList, layout: layout, labelArray: labelArray, result: rowWiseError) - if( element.elements.count + 1 < self.elements.count ){ - if ALLOWED_FOCUS_AUTO_SHIFT_ELEMENT_TYPES.contains(element.fieldType) && element.textField.isFirstResponder && (element.state.getState()["isValid"] as! Bool) { - if(element.elements.count + 1 < self.elements.count){ - self.elements[element.elements.count + 1].textField.becomeFirstResponder() - } - } - } - } - } - elementCount += 1 - } + internal func createRows(from elements: [Int], numberOfRows: Int) -> [[Int]] { + return ComposableLayout.createRows(from: elements, numberOfRows: numberOfRows) + } - childView.translatesAutoresizingMaskIntoConstraints = false - childView.topAnchor.constraint(equalTo: previousLabel?.bottomAnchor ?? previousChildView?.bottomAnchor ?? parentView.topAnchor, constant: 10.0).isActive = true - childView.leadingAnchor.constraint(equalTo: parentView.leadingAnchor).isActive = true - childView.trailingAnchor.constraint(equalTo: parentView.trailingAnchor).isActive = true - - labelArray[i].translatesAutoresizingMaskIntoConstraints = false - labelArray[i].leadingAnchor.constraint(equalTo: parentView.leadingAnchor, constant: 6.0).isActive = true - labelArray[i].trailingAnchor.constraint(equalTo: parentView.trailingAnchor, constant: -6.0).isActive = true - labelArray[i].topAnchor.constraint(equalTo: childView.bottomAnchor, constant: 5.0).isActive = true - - previousChildView = childView - previousLabel = labelArray[i] - - } - previousChildView?.trailingAnchor.constraint(equalTo: parentView.trailingAnchor).isActive = true - parentView.bottomAnchor.constraint(equalTo: previousLabel?.bottomAnchor ?? previousChildView?.bottomAnchor ?? parentView.bottomAnchor, constant: 10.0).isActive = true + internal func updateErrorMessageInLabel(errorList: [String], layout: [Int], labelArray: [UILabel], result: [[Int]]) -> [UILabel] { + return ComposableLayout.updateErrorMessageInLabel(errorList: errorList, layout: layout, labelArray: labelArray, result: result) + } - return parentView + internal func concatenateStringArray(_ array: [String], from startIndex: Int, to endIndex: Int) -> String { + return ComposableLayout.concatenateStringArray(array, from: startIndex, to: endIndex) } - - func getComposableView() throws -> UIView { + func collect(callback: Callback, options: CollectOptions? = CollectOptions()) where T: ComposableContainer { var tempContextOptions = self.skyflow.contextOptions tempContextOptions.interface = .COMPOSABLE_CONTAINER - var totalCount = 0 - - if let options = containerOptions { - if (options.layout.count == 0) { - throw SkyflowError(domain: "", code: 400, userInfo: [NSLocalizedDescriptionKey: "\(ErrorCodes.EMPTY_COMPOSABLE_LAYOUT_ARRAY().description)" ]) - } - - for i in 0..<(options.layout.count) { - totalCount += (options.layout[i]) - } - } else { - throw SkyflowError(domain: "", code: 400, userInfo: [NSLocalizedDescriptionKey: "\(ErrorCodes.MISSING_COMPOSABLE_CONTAINER_OPTIONS().description)" ]) + if self.skyflow.vaultID.isEmpty { + let errorCode = ErrorCodes.EMPTY_VAULT_ID() + return callback.onFailure(errorCode.getErrorObject(contextOptions: tempContextOptions)) } - if (elements.count < totalCount || totalCount < elements.count){ - throw SkyflowError(domain: "", code: 400, userInfo: [NSLocalizedDescriptionKey: "\(ErrorCodes.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM().description)" ]) + if self.skyflow.vaultURL == "/v1/vaults/" { + let errorCode = ErrorCodes.EMPTY_VAULT_URL() + return callback.onFailure(errorCode.getErrorObject(contextOptions: tempContextOptions)) } + var errorCode: ErrorCodes? + Log.info(message: .VALIDATE_COMPOSABLE_RECORDS, contextOptions: tempContextOptions) - let view = createDynamicViews(layout: (containerOptions?.layout)!) - return view - } - - - func collect(callback: Callback, options: CollectOptions? = CollectOptions()) where T: ComposableContainer { - var tempContextOptions = self.skyflow.contextOptions - tempContextOptions.interface = .COMPOSABLE_CONTAINER - if self.skyflow.vaultID.isEmpty { - let errorCode = ErrorCodes.EMPTY_VAULT_ID() - return callback.onFailure(errorCode.getErrorObject(contextOptions: tempContextOptions)) - } - if self.skyflow.vaultURL == "/v1/vaults/" { - let errorCode = ErrorCodes.EMPTY_VAULT_URL() - return callback.onFailure(errorCode.getErrorObject(contextOptions: tempContextOptions)) - } - var errors = "" - var errorCode: ErrorCodes? - Log.info(message: .VALIDATE_COMPOSABLE_RECORDS, contextOptions: tempContextOptions) - - for element in self.elements { - errorCode = checkElement(element: element) - if errorCode != nil { - callback.onFailure(errorCode!.getErrorObject(contextOptions: tempContextOptions)) - return - } - - - let state = element.getState() - let error = state["validationError"] - if (state["isRequired"] as! Bool) && (state["isEmpty"] as! Bool) { - errors += element.columnName + " is empty" + "\n" - element.updateErrorMessage() - } - if !(state["isValid"] as! Bool) { - errors += "for " + element.columnName + " " + (error as! String) + "\n" - } - if element.isFirstResponder { - element.resignFirstResponder() - } - } - - if errors != "" { - callback.onFailure(NSError(domain: "", code: 400, userInfo: [NSLocalizedDescriptionKey: errors])) - - return - } - if options?.additionalFields != nil { - if options?.additionalFields!["records"] == nil { - errorCode = .MISSING_RECORDS_IN_ADDITIONAL_FIELDS() + let (elementError, errors) = CollectValidation.validateElements(self.elements) + if let elementError = elementError { + callback.onFailure(elementError.getErrorObject(contextOptions: tempContextOptions)) + return + } + if errors != "" { + callback.onFailure(NSError(domain: "", code: 400, userInfo: [NSLocalizedDescriptionKey: errors])) + return + } + if options?.additionalFields != nil { + if options?.additionalFields!["records"] == nil { + errorCode = .MISSING_RECORDS_IN_ADDITIONAL_FIELDS() + return callback.onFailure(errorCode!.getErrorObject(contextOptions: tempContextOptions)) + } + if let additionalFieldEntries = options?.additionalFields!["records"] as? [[String: Any]] { + if additionalFieldEntries.isEmpty { + errorCode = .EMPTY_RECORDS_OBJECT() return callback.onFailure(errorCode!.getErrorObject(contextOptions: tempContextOptions)) } - if let additionalFieldEntries = options?.additionalFields!["records"] as? [[String: Any]] { - if additionalFieldEntries.isEmpty { - errorCode = .EMPTY_RECORDS_OBJECT() + for (index, record) in additionalFieldEntries.enumerated() { + errorCode = checkRecord(record: record, index: index) + if errorCode != nil { return callback.onFailure(errorCode!.getErrorObject(contextOptions: tempContextOptions)) } - for (index, record) in additionalFieldEntries.enumerated() { - errorCode = checkRecord(record: record, index: index) - if errorCode != nil { - return callback.onFailure(errorCode!.getErrorObject(contextOptions: tempContextOptions)) - } - } - } else { - errorCode = .INVALID_RECORDS_TYPE() - callback.onFailure(errorCode!.getErrorObject(contextOptions: tempContextOptions)) - return } + } else { + errorCode = .INVALID_RECORDS_TYPE() + callback.onFailure(errorCode!.getErrorObject(contextOptions: tempContextOptions)) + return } - let records = CollectRequestBody.createRequestBody(elements: self.elements, additionalFields: options?.additionalFields, callback: callback, contextOptions: tempContextOptions) - let icOptions = ICOptions(tokens: options!.tokens, additionalFields: options?.additionalFields, upsert: options?.upsert, callback: callback, contextOptions: tempContextOptions) - if options?.upsert != nil { - if icOptions.validateUpsert() { - return; - } - } - if records != nil { - let logCallback = LogCallback(clientCallback: callback, contextOptions: self.skyflow.contextOptions, - onSuccessHandler: { - Log.info(message: .COLLECT_SUBMIT_SUCCESS, contextOptions: tempContextOptions) - }, - onFailureHandler: { - } - ) - self.skyflow.apiClient.postAndUpdate(records: records!, callback: logCallback, options: icOptions, contextOptions: tempContextOptions) - } - } - - private func checkElement(element: TextField) -> ErrorCodes? { - if element.collectInput.table.isEmpty { - return .EMPTY_TABLE_NAME_IN_COLLECT() - } - if element.collectInput.column.isEmpty { - return .EMPTY_COLUMN_NAME_IN_COLLECT() - } - if !element.isMounted() { - return .UNMOUNTED_COLLECT_ELEMENT(value: element.collectInput.column) + } + let records = CollectRequestBody.createRequestBody(elements: self.elements, additionalFields: options?.additionalFields, callback: callback, contextOptions: tempContextOptions) + let icOptions = ICOptions(tokens: options!.tokens, additionalFields: options?.additionalFields, upsert: options?.upsert, callback: callback, contextOptions: tempContextOptions) + if options?.upsert != nil { + if icOptions.validateUpsert() { + return; } - - return nil } - + if records != nil { + let logCallback = LogCallback(clientCallback: callback, contextOptions: self.skyflow.contextOptions, + onSuccessHandler: { + Log.info(message: .COLLECT_SUBMIT_SUCCESS, contextOptions: tempContextOptions) + }, + onFailureHandler: { + } + ) + self.skyflow.apiClient.postAndUpdate(records: records!, callback: logCallback, options: icOptions, contextOptions: tempContextOptions) + } + } + private func checkRecord(record: [String: Any], index: Int) -> ErrorCodes? { - if record["table"] == nil { - return .TABLE_KEY_ERROR(value: "\(index)") - } - if !(record["table"] is String) { - return .INVALID_TABLE_NAME_TYPE(value: "\(index)") - } - if (record["table"] as? String == "") { - return .EMPTY_TABLE_NAME() - } - if record["fields"] == nil { - return .FIELDS_KEY_ERROR(value: "\(index)") - } - if !(record["fields"] is [String: Any]) { - return .INVALID_FIELDS_TYPE(value: "\(index)") - } - let fields = record["fields"] as! [String: Any] - if (fields.isEmpty){ - return .EMPTY_FIELDS_KEY(value: "\(index)") - } - - return nil + if record["table"] == nil { + return .TABLE_KEY_ERROR(value: "\(index)") } - -} + if !(record["table"] is String) { + return .INVALID_TABLE_NAME_TYPE(value: "\(index)") + } + if (record["table"] as? String == "") { + return .EMPTY_TABLE_NAME() + } + if record["fields"] == nil { + return .FIELDS_KEY_ERROR(value: "\(index)") + } + if !(record["fields"] is [String: Any]) { + return .INVALID_FIELDS_TYPE(value: "\(index)") + } + let fields = record["fields"] as! [String: Any] + if (fields.isEmpty){ + return .EMPTY_FIELDS_KEY(value: "\(index)") + } + + return nil + } +} diff --git a/Sources/Skyflow/core/APIClient.swift b/Sources/Skyflow/core/APIClient.swift index 3cfd6ef9..b8767179 100644 --- a/Sources/Skyflow/core/APIClient.swift +++ b/Sources/Skyflow/core/APIClient.swift @@ -6,6 +6,7 @@ // Class used for generating different type of requests, req body etc for API making an API call import Foundation +import SkyflowCore internal class APIClient { var vaultID: String diff --git a/Sources/Skyflow/core/Client.swift b/Sources/Skyflow/core/Client.swift index c9e51761..c2c57060 100644 --- a/Sources/Skyflow/core/Client.swift +++ b/Sources/Skyflow/core/Client.swift @@ -5,6 +5,7 @@ // Implementation of Skyflow Client class import Foundation +import SkyflowCore public class Client { var vaultID: String diff --git a/Sources/Skyflow/core/Configuration.swift b/Sources/Skyflow/core/Configuration.swift index 13adbf04..86b7f494 100644 --- a/Sources/Skyflow/core/Configuration.swift +++ b/Sources/Skyflow/core/Configuration.swift @@ -5,6 +5,7 @@ // Configure Skyflow, implementation for Skyflow.Configuration import Foundation +import SkyflowCore public struct Configuration { var vaultID: String diff --git a/Sources/Skyflow/core/Init.swift b/Sources/Skyflow/core/Init.swift index 365bb9c2..a9727240 100644 --- a/Sources/Skyflow/core/Init.swift +++ b/Sources/Skyflow/core/Init.swift @@ -5,6 +5,7 @@ // Initialize Skyflow, Skyflow.initialize import Foundation +import SkyflowCore public func initialize(_ skyflowConfig: Configuration) -> Client { return Client(skyflowConfig) diff --git a/Sources/Skyflow/core/container/Container.swift b/Sources/Skyflow/core/container/Container.swift index 53158c5b..2367c4ec 100644 --- a/Sources/Skyflow/core/container/Container.swift +++ b/Sources/Skyflow/core/container/Container.swift @@ -10,6 +10,7 @@ // import Foundation +import SkyflowCore public class Container { internal var skyflow: Client diff --git a/Sources/Skyflow/reveal/GetAPICallback.swift b/Sources/Skyflow/reveal/GetAPICallback.swift index e0e67606..93ac5f81 100644 --- a/Sources/Skyflow/reveal/GetAPICallback.swift +++ b/Sources/Skyflow/reveal/GetAPICallback.swift @@ -5,6 +5,7 @@ // Implementation of Callback used in API for revealing data by get method import Foundation +import SkyflowCore class GetAPICallback: Callback { var apiClient: APIClient diff --git a/Sources/Skyflow/reveal/GetByIdRecord.swift b/Sources/Skyflow/reveal/GetByIdRecord.swift index 1dae151f..10ef5a10 100644 --- a/Sources/Skyflow/reveal/GetByIdRecord.swift +++ b/Sources/Skyflow/reveal/GetByIdRecord.swift @@ -10,6 +10,7 @@ // import Foundation +import SkyflowCore struct GetByIdRecord { var ids: [String] diff --git a/Sources/Skyflow/reveal/GetOptions.swift b/Sources/Skyflow/reveal/GetOptions.swift index 942f2f98..cfd9ee51 100644 --- a/Sources/Skyflow/reveal/GetOptions.swift +++ b/Sources/Skyflow/reveal/GetOptions.swift @@ -5,6 +5,7 @@ // Object that describes the Options for Get import Foundation +import SkyflowCore public struct GetOptions { var tokens: Bool diff --git a/Sources/Skyflow/reveal/GetRecord.swift b/Sources/Skyflow/reveal/GetRecord.swift index 72b71c16..d1dde9fb 100644 --- a/Sources/Skyflow/reveal/GetRecord.swift +++ b/Sources/Skyflow/reveal/GetRecord.swift @@ -6,6 +6,7 @@ // import Foundation +import SkyflowCore struct GetRecord { var ids: [String]? diff --git a/Sources/Skyflow/reveal/RevealApiCallback.swift b/Sources/Skyflow/reveal/RevealApiCallback.swift index 424ea0f6..d018c0de 100644 --- a/Sources/Skyflow/reveal/RevealApiCallback.swift +++ b/Sources/Skyflow/reveal/RevealApiCallback.swift @@ -5,6 +5,7 @@ // Implementation of callback for Reveal api import Foundation +import SkyflowCore class RevealAPICallback: Callback { var apiClient: APIClient diff --git a/Sources/Skyflow/reveal/RevealByIDAPICallback.swift b/Sources/Skyflow/reveal/RevealByIDAPICallback.swift index 020e4d7e..d323b977 100644 --- a/Sources/Skyflow/reveal/RevealByIDAPICallback.swift +++ b/Sources/Skyflow/reveal/RevealByIDAPICallback.swift @@ -5,6 +5,7 @@ // Implementation of Callback used in API for revealing redacted data using id import Foundation +import SkyflowCore class RevealByIDAPICallback: Callback { var apiClient: APIClient diff --git a/Sources/Skyflow/reveal/RevealContainer.swift b/Sources/Skyflow/reveal/RevealContainer.swift index 57f97bc9..f7ba4ed1 100644 --- a/Sources/Skyflow/reveal/RevealContainer.swift +++ b/Sources/Skyflow/reveal/RevealContainer.swift @@ -8,9 +8,7 @@ */ import Foundation - -public class RevealContainer: ContainerProtocol { -} +import SkyflowCore public extension Container { func create(input: RevealElementInput, options: RevealElementOptions? = RevealElementOptions()) -> Label where T: RevealContainer { @@ -36,25 +34,11 @@ public extension Container { let errorCode = ErrorCodes.EMPTY_VAULT_URL() return callback.onFailure(errorCode.getErrorObject(contextOptions: tempContextOptions)) } - var errorCode: ErrorCodes? Log.info(message: .VALIDATE_REVEAL_RECORDS, contextOptions: tempContextOptions) - if let element = ConversionHelpers.checkElementsAreMounted(elements: self.revealElements) as? Label { - errorCode = .UNMOUNTED_REVEAL_ELEMENT(value: element.revealInput.token) - callback.onFailure(errorCode!.getErrorObject(contextOptions: tempContextOptions)) + if let errorCode = RevealValidation.validateElements(self.revealElements) { + callback.onFailure(errorCode.getErrorObject(contextOptions: tempContextOptions)) return } - for element in self.revealElements { - if element.errorTriggered { - errorCode = .ERROR_TRIGGERED(value: element.triggeredErrorMessage) - callback.onFailure(errorCode!.getErrorObject(contextOptions: tempContextOptions)) - return - } - if element.getToken().isEmpty { - errorCode = .EMPTY_TOKEN_ID() - callback.onFailure(errorCode!.getErrorObject(contextOptions: tempContextOptions)) - return - } - } let revealValueCallback = RevealValueCallback(callback: callback, revealElements: self.revealElements, contextOptions: tempContextOptions) let records = RevealRequestBody.createRequestBody(elements: self.revealElements) diff --git a/Sources/Skyflow/reveal/RevealErrorRecord.swift b/Sources/Skyflow/reveal/RevealErrorRecord.swift index 8e51c9b4..a20f4d85 100644 --- a/Sources/Skyflow/reveal/RevealErrorRecord.swift +++ b/Sources/Skyflow/reveal/RevealErrorRecord.swift @@ -5,6 +5,7 @@ // Object that signifies error for reveal element import Foundation +import SkyflowCore class RevealErrorRecord { var id: String diff --git a/Sources/Skyflow/reveal/RevealRequestBody.swift b/Sources/Skyflow/reveal/RevealRequestBody.swift index 72d6d919..1441be5e 100644 --- a/Sources/Skyflow/reveal/RevealRequestBody.swift +++ b/Sources/Skyflow/reveal/RevealRequestBody.swift @@ -5,6 +5,7 @@ // Used for generating request body for reveal api call import Foundation +import SkyflowCore internal class RevealRequestBody { internal static func createRequestBody(elements: [Label]) -> [String: Any] { diff --git a/Sources/Skyflow/reveal/RevealRequestRecord.swift b/Sources/Skyflow/reveal/RevealRequestRecord.swift index 6b1b0b01..4876de2d 100644 --- a/Sources/Skyflow/reveal/RevealRequestRecord.swift +++ b/Sources/Skyflow/reveal/RevealRequestRecord.swift @@ -5,6 +5,7 @@ // Object that describes the reveal record in request body import Foundation +import SkyflowCore struct RevealRequestRecord { var token: String diff --git a/Sources/Skyflow/reveal/RevealSuccessRecord.swift b/Sources/Skyflow/reveal/RevealSuccessRecord.swift index 3a3cf8ad..8451307a 100644 --- a/Sources/Skyflow/reveal/RevealSuccessRecord.swift +++ b/Sources/Skyflow/reveal/RevealSuccessRecord.swift @@ -5,6 +5,7 @@ // Object that describes the response of reveal record import Foundation +import SkyflowCore struct RevealSuccessRecord { var token_id: String diff --git a/Sources/Skyflow/reveal/RevealValueCallback.swift b/Sources/Skyflow/reveal/RevealValueCallback.swift index a32438fc..3890daa2 100644 --- a/Sources/Skyflow/reveal/RevealValueCallback.swift +++ b/Sources/Skyflow/reveal/RevealValueCallback.swift @@ -3,6 +3,7 @@ */ import Foundation +import SkyflowCore internal class RevealValueCallback: Callback { var clientCallback: Callback diff --git a/Sources/Skyflow/BaseElement.swift b/Sources/SkyflowCore/BaseElement.swift similarity index 100% rename from Sources/Skyflow/BaseElement.swift rename to Sources/SkyflowCore/BaseElement.swift diff --git a/Sources/Skyflow/collect/CollectOptions.swift b/Sources/SkyflowCore/Collect/CollectOptions.swift similarity index 75% rename from Sources/Skyflow/collect/CollectOptions.swift rename to Sources/SkyflowCore/Collect/CollectOptions.swift index 369961bb..fac740c3 100644 --- a/Sources/Skyflow/collect/CollectOptions.swift +++ b/Sources/SkyflowCore/Collect/CollectOptions.swift @@ -7,9 +7,9 @@ import Foundation public struct CollectOptions { - var tokens: Bool - var additionalFields: [String: Any]? - var upsert: [[String: Any]]? + public var tokens: Bool + public var additionalFields: [String: Any]? + public var upsert: [[String: Any]]? public init(tokens: Bool = true, additionalFields: [String: Any]? = nil, upsert: [[String: Any]]? = nil) { self.tokens = tokens self.additionalFields = additionalFields diff --git a/Sources/SkyflowCore/Collect/CollectValidation.swift b/Sources/SkyflowCore/Collect/CollectValidation.swift new file mode 100644 index 00000000..5d40b2e1 --- /dev/null +++ b/Sources/SkyflowCore/Collect/CollectValidation.swift @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2026 Skyflow +*/ + +// Shared element-level validation used by both Collect and Composable +// containers, across all backends - identical regardless of which vault +// API the elements will eventually be submitted to. + +import Foundation + +public enum CollectValidation { + public static func checkElement(_ element: TextField) -> ErrorCodes? { + if element.collectInput.table.isEmpty { + return .EMPTY_TABLE_NAME_IN_COLLECT() + } + if element.collectInput.column.isEmpty { + return .EMPTY_COLUMN_NAME_IN_COLLECT() + } + if !element.isMounted() { + return .UNMOUNTED_COLLECT_ELEMENT(value: element.collectInput.column) + } + return nil + } + + // Returns the first element-level ErrorCodes failure (if any), plus the + // accumulated per-element validation error string. Mirrors the original + // inline loop exactly: an element-level error returns immediately, an + // empty errors string means every element passed input validation. + public static func validateElements(_ elements: [TextField]) -> (elementError: ErrorCodes?, errors: String) { + var errors = "" + for element in elements { + if let errorCode = checkElement(element) { + return (errorCode, "") + } + + let state = element.getState() + let error = state["validationError"] + if (state["isRequired"] as! Bool) && (state["isEmpty"] as! Bool) { + errors += element.columnName + " is empty" + "\n" + element.updateErrorMessage() + } + if !(state["isValid"] as! Bool) { + errors += "for " + element.columnName + " " + (error as! String) + "\n" + } + if element.isFirstResponder { + element.resignFirstResponder() + } + } + return (nil, errors) + } +} diff --git a/Sources/Skyflow/composable/AutoshiftAllowed.swift b/Sources/SkyflowCore/Composable/AutoshiftAllowed.swift similarity index 56% rename from Sources/Skyflow/composable/AutoshiftAllowed.swift rename to Sources/SkyflowCore/Composable/AutoshiftAllowed.swift index 747d4c4f..bd9297de 100644 --- a/Sources/Skyflow/composable/AutoshiftAllowed.swift +++ b/Sources/SkyflowCore/Composable/AutoshiftAllowed.swift @@ -1,13 +1,10 @@ /* * Copyright (c) 2022 Skyflow */ -// -// Created by Bharti Sagar on 19/07/23. -// import Foundation -let ALLOWED_FOCUS_AUTO_SHIFT_ELEMENT_TYPES: [ElementType] = [ +public let ALLOWED_FOCUS_AUTO_SHIFT_ELEMENT_TYPES: [ElementType] = [ .CARD_NUMBER, .EXPIRATION_DATE, .EXPIRATION_YEAR, diff --git a/Sources/SkyflowCore/Composable/ComposableLayout.swift b/Sources/SkyflowCore/Composable/ComposableLayout.swift new file mode 100644 index 00000000..c7de2cbe --- /dev/null +++ b/Sources/SkyflowCore/Composable/ComposableLayout.swift @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2026 Skyflow +*/ + +// Shared dynamic-layout logic for Composable containers - pure UI layout, +// identical regardless of which vault API the elements will eventually be +// submitted to. + +import Foundation +import UIKit + +public enum ComposableLayout { + public static func createRows(from elements: [Int], numberOfRows: Int) -> [[Int]] { + var number = Array(repeating: 0, count: elements.count) + var result = [[Int]]() + + for i in 0.. 0 { + number[i] = elements[i] + number[i-1] + } else { + number[i] = elements[i] + } + } + for i in 0.. [UILabel] { + let labelArray = labelArray + for j in 0.. String { + guard startIndex >= 0, startIndex < array.count, + endIndex >= 0, endIndex < array.count, startIndex <= endIndex else { + return "" + } + let subarray = array[startIndex...endIndex] + + let concatenatedString = subarray.joined(separator: "") + + return concatenatedString + } + + public static func createDynamicViews(elements: [TextField], containerOptions: ContainerOptions?, layout: [Int]) -> UIView { + var errorList = Array(repeating: "", count: elements.count) + let parentView = UIView() + var previousChildView: UIView? = nil + var previousLabel: UILabel? = nil + var labelArray: [UILabel] = (0.. 1 && elementCount >= 1 && j > 0 { + + elements[elementCount].leadingAnchor.constraint(equalTo: elements[elementCount-1].trailingAnchor, constant: 20.0).isActive = true + elements[elementCount].centerYAnchor.constraint(equalTo: childView.centerYAnchor).isActive = true + + } else if j == 0 { + elements[elementCount].centerYAnchor.constraint(equalTo: childView.centerYAnchor).isActive = true + elements[elementCount].leftAnchor.constraint(equalTo: childView.leftAnchor, constant: 6.0).isActive = true + elements[elementCount].leadingAnchor.constraint(equalTo: childView.leadingAnchor, constant: 6.0).isActive = true + } + elements[elementCount].topAnchor.constraint(equalTo: childView.topAnchor).isActive = true + elements[elementCount].bottomAnchor.constraint(equalTo: childView.bottomAnchor).isActive = true + + for element in elements { + element.onFocusIsTrue = { + errorList[element.elements.count] = "" + labelArray = updateErrorMessageInLabel(errorList: errorList, layout: layout, labelArray: labelArray, result: rowWiseError) + labelArray[i].textColor = containerOptions?.errorTextStyles?.focus?.textColor ?? containerOptions?.errorTextStyles?.base?.textColor ?? .none + labelArray[i].font = containerOptions?.errorTextStyles?.focus?.font ?? containerOptions?.errorTextStyles?.base?.font ?? .none + labelArray[i].textAlignment = containerOptions?.errorTextStyles?.focus?.textAlignment ?? containerOptions?.errorTextStyles?.base?.textAlignment ?? .left + } + + element.onEndEditing = { + if element.errorMessage.text == "" { + errorList[element.elements.count] = "" + } else { + errorList[element.elements.count] = element.errorMessage.text! + ". " + } + labelArray = updateErrorMessageInLabel(errorList: errorList, layout: layout, labelArray: labelArray, result: rowWiseError) + } + element.onBeginEditing = { + errorList[element.elements.count] = "" + labelArray = updateErrorMessageInLabel(errorList: errorList, layout: layout, labelArray: labelArray, result: rowWiseError) + if element.elements.count + 1 < elements.count { + if ALLOWED_FOCUS_AUTO_SHIFT_ELEMENT_TYPES.contains(element.fieldType) && element.textField.isFirstResponder && (element.state.getState()["isValid"] as! Bool) { + if element.elements.count + 1 < elements.count { + elements[element.elements.count + 1].textField.becomeFirstResponder() + } + } + } + } + } + elementCount += 1 + } + + childView.translatesAutoresizingMaskIntoConstraints = false + childView.topAnchor.constraint(equalTo: previousLabel?.bottomAnchor ?? previousChildView?.bottomAnchor ?? parentView.topAnchor, constant: 10.0).isActive = true + childView.leadingAnchor.constraint(equalTo: parentView.leadingAnchor).isActive = true + childView.trailingAnchor.constraint(equalTo: parentView.trailingAnchor).isActive = true + + labelArray[i].translatesAutoresizingMaskIntoConstraints = false + labelArray[i].leadingAnchor.constraint(equalTo: parentView.leadingAnchor, constant: 6.0).isActive = true + labelArray[i].trailingAnchor.constraint(equalTo: parentView.trailingAnchor, constant: -6.0).isActive = true + labelArray[i].topAnchor.constraint(equalTo: childView.bottomAnchor, constant: 5.0).isActive = true + + previousChildView = childView + previousLabel = labelArray[i] + + } + previousChildView?.trailingAnchor.constraint(equalTo: parentView.trailingAnchor).isActive = true + parentView.bottomAnchor.constraint(equalTo: previousLabel?.bottomAnchor ?? previousChildView?.bottomAnchor ?? parentView.bottomAnchor, constant: 10.0).isActive = true + + return parentView + } + + public static func getComposableView(elements: [TextField], containerOptions: ContainerOptions?) throws -> UIView { + var totalCount = 0 + + if let options = containerOptions { + if (options.layout.count == 0) { + throw SkyflowError(domain: "", code: 400, userInfo: [NSLocalizedDescriptionKey: "\(ErrorCodes.EMPTY_COMPOSABLE_LAYOUT_ARRAY().description)" ]) + } + + for i in 0..<(options.layout.count) { + totalCount += (options.layout[i]) + } + } else { + throw SkyflowError(domain: "", code: 400, userInfo: [NSLocalizedDescriptionKey: "\(ErrorCodes.MISSING_COMPOSABLE_CONTAINER_OPTIONS().description)" ]) + } + if (elements.count < totalCount || totalCount < elements.count){ + throw SkyflowError(domain: "", code: 400, userInfo: [NSLocalizedDescriptionKey: "\(ErrorCodes.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM().description)" ]) + } + + return createDynamicViews(elements: elements, containerOptions: containerOptions, layout: (containerOptions?.layout)!) + } +} diff --git a/Sources/Skyflow/core/container/ContainerOptions.swift b/Sources/SkyflowCore/Core/Container/ContainerOptions.swift similarity index 69% rename from Sources/Skyflow/core/container/ContainerOptions.swift rename to Sources/SkyflowCore/Core/Container/ContainerOptions.swift index ead33e98..7e86126f 100644 --- a/Sources/Skyflow/core/container/ContainerOptions.swift +++ b/Sources/SkyflowCore/Core/Container/ContainerOptions.swift @@ -2,19 +2,12 @@ * Copyright (c) 2022 Skyflow */ -// -// File.swift -// -// -// Created by Akhil Anil Mangala on 27/07/21. -// - import Foundation public struct ContainerOptions { - var layout: [Int] - var styles: Styles? - var errorTextStyles: Styles? + public var layout: [Int] + public var styles: Styles? + public var errorTextStyles: Styles? public init(){ layout = [0] diff --git a/Sources/Skyflow/core/container/ContainerProtocol.swift b/Sources/SkyflowCore/Core/Container/ContainerProtocol.swift similarity index 54% rename from Sources/Skyflow/core/container/ContainerProtocol.swift rename to Sources/SkyflowCore/Core/Container/ContainerProtocol.swift index 11d4e470..82a45cca 100644 --- a/Sources/Skyflow/core/container/ContainerProtocol.swift +++ b/Sources/SkyflowCore/Core/Container/ContainerProtocol.swift @@ -2,13 +2,6 @@ * Copyright (c) 2022 Skyflow */ -// -// File.swift -// -// -// Created by Akhil Anil Mangala on 02/08/21. -// - import Foundation public protocol ContainerProtocol { diff --git a/Sources/Skyflow/core/container/ContainerType.swift b/Sources/SkyflowCore/Core/Container/ContainerType.swift similarity index 65% rename from Sources/Skyflow/core/container/ContainerType.swift rename to Sources/SkyflowCore/Core/Container/ContainerType.swift index a971ee4b..acd0f47a 100644 --- a/Sources/Skyflow/core/container/ContainerType.swift +++ b/Sources/SkyflowCore/Core/Container/ContainerType.swift @@ -6,6 +6,10 @@ import Foundation +public class CollectContainer: ContainerProtocol {} +public class RevealContainer: ContainerProtocol {} +public class ComposableContainer: ContainerProtocol {} + public class ContainerType { public static var COLLECT = CollectContainer.self public static var REVEAL = RevealContainer.self diff --git a/Sources/Skyflow/core/ContextOptions.swift b/Sources/SkyflowCore/Core/ContextOptions.swift similarity index 50% rename from Sources/Skyflow/core/ContextOptions.swift rename to Sources/SkyflowCore/Core/ContextOptions.swift index b8d2174a..445b02e3 100644 --- a/Sources/Skyflow/core/ContextOptions.swift +++ b/Sources/SkyflowCore/Core/ContextOptions.swift @@ -11,12 +11,12 @@ import Foundation -internal struct ContextOptions { - var logLevel: LogLevel - var env: Env - var interface: InterfaceName +public struct ContextOptions { + public var logLevel: LogLevel + public var env: Env + public var interface: InterfaceName - internal init(logLevel: LogLevel = .ERROR, env: Env = .PROD, interface: InterfaceName = .EMPTY) { + public init(logLevel: LogLevel = .ERROR, env: Env = .PROD, interface: InterfaceName = .EMPTY) { self.logLevel = logLevel self.env = env self.interface = interface diff --git a/Sources/Skyflow/core/Element.swift b/Sources/SkyflowCore/Core/Element.swift similarity index 85% rename from Sources/Skyflow/core/Element.swift rename to Sources/SkyflowCore/Core/Element.swift index b70d7565..c6442081 100644 --- a/Sources/Skyflow/core/Element.swift +++ b/Sources/SkyflowCore/Core/Element.swift @@ -11,6 +11,6 @@ import Foundation -internal protocol Element { +public protocol Element { func getValue() -> String } diff --git a/Sources/Skyflow/core/Env.swift b/Sources/SkyflowCore/Core/Env.swift similarity index 100% rename from Sources/Skyflow/core/Env.swift rename to Sources/SkyflowCore/Core/Env.swift diff --git a/Sources/Skyflow/core/EventName.swift b/Sources/SkyflowCore/Core/EventName.swift similarity index 100% rename from Sources/Skyflow/core/EventName.swift rename to Sources/SkyflowCore/Core/EventName.swift diff --git a/Sources/Skyflow/core/InterfaceName.swift b/Sources/SkyflowCore/Core/InterfaceName.swift similarity index 96% rename from Sources/Skyflow/core/InterfaceName.swift rename to Sources/SkyflowCore/Core/InterfaceName.swift index 54534af7..efcf3f0e 100644 --- a/Sources/Skyflow/core/InterfaceName.swift +++ b/Sources/SkyflowCore/Core/InterfaceName.swift @@ -11,7 +11,7 @@ import Foundation -internal enum InterfaceName { +public enum InterfaceName { case COLLECT_CONTAINER case REVEAL_CONTAINER case COMPOSABLE_CONTAINER diff --git a/Sources/Skyflow/core/Log.swift b/Sources/SkyflowCore/Core/Log.swift similarity index 63% rename from Sources/Skyflow/core/Log.swift rename to Sources/SkyflowCore/Core/Log.swift index feb47db1..55a96c14 100644 --- a/Sources/Skyflow/core/Log.swift +++ b/Sources/SkyflowCore/Core/Log.swift @@ -6,23 +6,23 @@ import Foundation -internal class Log { - internal static func debug(message: Message, values: [String] = [], contextOptions: ContextOptions) { +public class Log { + public static func debug(message: Message, values: [String] = [], contextOptions: ContextOptions) { if contextOptions.logLevel.rawValue < 1 { print("DEBUG: [Skyflow] Interface: \(contextOptions.interface.description) - \(message.getDescription(values: values))") } } - internal static func info(message: Message, values: [String] = [], contextOptions: ContextOptions) { + public static func info(message: Message, values: [String] = [], contextOptions: ContextOptions) { if contextOptions.logLevel.rawValue < 2 { print("INFO: [Skyflow] Interface: \(contextOptions.interface.description) - \(message.getDescription(values: values))") } } - internal static func warn(message: Message, values: [String] = [], contextOptions: ContextOptions) { + public static func warn(message: Message, values: [String] = [], contextOptions: ContextOptions) { if contextOptions.logLevel.rawValue < 3 { print("WARN: [Skyflow] Interface: \(contextOptions.interface.description) - \(message.getDescription(values: values))") } } - internal static func error(message: String, values: [String] = [], contextOptions: ContextOptions) { + public static func error(message: String, values: [String] = [], contextOptions: ContextOptions) { print("ERROR: [Skyflow]: \(message)") } } diff --git a/Sources/Skyflow/core/LogLevel.swift b/Sources/SkyflowCore/Core/LogLevel.swift similarity index 100% rename from Sources/Skyflow/core/LogLevel.swift rename to Sources/SkyflowCore/Core/LogLevel.swift diff --git a/Sources/Skyflow/core/Message.swift b/Sources/SkyflowCore/Core/Message.swift similarity index 96% rename from Sources/Skyflow/core/Message.swift rename to Sources/SkyflowCore/Core/Message.swift index e7c7b918..dbaf8c94 100644 --- a/Sources/Skyflow/core/Message.swift +++ b/Sources/SkyflowCore/Core/Message.swift @@ -11,7 +11,7 @@ import Foundation -internal enum Message { +public enum Message { case CLIENT_INITIALIZED case COLLECT_CONTAINER_CREATED case REVEAL_CONTAINER_CREATED @@ -96,11 +96,11 @@ internal enum Message { } } - internal func getDescription(values: [String]) -> String { + public func getDescription(values: [String]) -> String { return formatMessage(self.description, values) } - internal func formatMessage(_ message: String, _ values: [String]) -> String { + public func formatMessage(_ message: String, _ values: [String]) -> String { let words = message.split(separator: " ") var valuesIndex = 0 var result = "" diff --git a/Sources/Skyflow/core/Options.swift b/Sources/SkyflowCore/Core/Options.swift similarity index 80% rename from Sources/Skyflow/core/Options.swift rename to Sources/SkyflowCore/Core/Options.swift index 862efe4e..b2d8a555 100644 --- a/Sources/Skyflow/core/Options.swift +++ b/Sources/SkyflowCore/Core/Options.swift @@ -5,8 +5,8 @@ // Object that describes the options parameter public struct Options { - var logLevel: LogLevel - var env: Env + public var logLevel: LogLevel + public var env: Env public init(logLevel: LogLevel = .ERROR, env: Env = .PROD) { self.logLevel = logLevel diff --git a/Sources/Skyflow/Version.swift b/Sources/SkyflowCore/Core/Version.swift similarity index 59% rename from Sources/Skyflow/Version.swift rename to Sources/SkyflowCore/Core/Version.swift index a89bf081..03edf20d 100644 --- a/Sources/Skyflow/Version.swift +++ b/Sources/SkyflowCore/Core/Version.swift @@ -11,6 +11,6 @@ import Foundation -var LangAndVersion = "iOS SDK v\(SDK_VERSION)" +public var LangAndVersion = "iOS SDK v\(SDK_VERSION)" -var SDK_VERSION = "1.25.1" +public var SDK_VERSION = "1.25.1" diff --git a/Sources/Skyflow/elements/core/CollectElementInput.swift b/Sources/SkyflowCore/Elements/Core/CollectElementInput.swift similarity index 86% rename from Sources/Skyflow/elements/core/CollectElementInput.swift rename to Sources/SkyflowCore/Elements/Core/CollectElementInput.swift index 419d6b8d..b4b7a4de 100644 --- a/Sources/Skyflow/elements/core/CollectElementInput.swift +++ b/Sources/SkyflowCore/Elements/Core/CollectElementInput.swift @@ -7,17 +7,17 @@ import Foundation public struct CollectElementInput { - var table: String - var column: String - var inputStyles: Styles - var labelStyles: Styles - var errorTextStyles: Styles - var iconStyles: Styles - var label: String - var placeholder: String - var type: ElementType? - var validations: ValidationSet - var skyflowID: String + public var table: String + public var column: String + public var inputStyles: Styles + public var labelStyles: Styles + public var errorTextStyles: Styles + public var iconStyles: Styles + public var label: String + public var placeholder: String + public var type: ElementType? + public var validations: ValidationSet + public var skyflowID: String public init(table: String = "", column: String = "", inputStyles: Styles? = Styles(), labelStyles: Styles? = Styles(), errorTextStyles: Styles? = Styles(), iconStyles: Styles? = Styles(), label: String? = "", diff --git a/Sources/Skyflow/elements/core/CollectElementOptions.swift b/Sources/SkyflowCore/Elements/Core/CollectElementOptions.swift similarity index 100% rename from Sources/Skyflow/elements/core/CollectElementOptions.swift rename to Sources/SkyflowCore/Elements/Core/CollectElementOptions.swift diff --git a/Sources/Skyflow/elements/core/ElementType.swift b/Sources/SkyflowCore/Elements/Core/ElementType.swift similarity index 98% rename from Sources/Skyflow/elements/core/ElementType.swift rename to Sources/SkyflowCore/Elements/Core/ElementType.swift index 87f0d820..4ef45aae 100644 --- a/Sources/Skyflow/elements/core/ElementType.swift +++ b/Sources/SkyflowCore/Elements/Core/ElementType.swift @@ -7,7 +7,7 @@ import UIKit #endif -internal class Type +public class Type { var formatPattern: String var regex: String @@ -17,7 +17,7 @@ internal class Type var acceptableCharacters: CharacterSet? var maxLength: Int? - internal required init( formatPattern: String, regex: String, + public required init( formatPattern: String, regex: String, validation: ValidationSet, keyboardType: UIKeyboardType, acceptableCharacters: CharacterSet?=nil, maxLength: Int?=nil) { self.formatPattern = formatPattern self.regex = regex diff --git a/Sources/Skyflow/elements/core/state/State.swift b/Sources/SkyflowCore/Elements/Core/State/State.swift similarity index 85% rename from Sources/Skyflow/elements/core/state/State.swift rename to Sources/SkyflowCore/Elements/Core/State/State.swift index 706913c3..d503e3d4 100644 --- a/Sources/Skyflow/elements/core/state/State.swift +++ b/Sources/SkyflowCore/Elements/Core/State/State.swift @@ -10,15 +10,15 @@ import UIKit /// An object that describes `SkyflowTextField` state. /// State attributes are read-only. -internal class State { +public class State { /// `CollectElementOptions.columnName` associated with `SkyflowTextField` - internal(set) open var columnName: String! + public(set) open var columnName: String! /// set as true if `SkyflowTextField` input is required to fill - internal(set) open var isRequired = false + public(set) open var isRequired = false /// true if `SkyflowTextField` input in valid - // internal(set) open var isValid: Bool = false + // public(set) open var isValid: Bool = false init(columnName: String, isRequired: Bool) { self.columnName = columnName diff --git a/Sources/Skyflow/elements/core/state/StateforText.swift b/Sources/SkyflowCore/Elements/Core/State/StateforText.swift similarity index 81% rename from Sources/Skyflow/elements/core/state/StateforText.swift rename to Sources/SkyflowCore/Elements/Core/State/StateforText.swift index 75782683..b9b18e32 100644 --- a/Sources/Skyflow/elements/core/state/StateforText.swift +++ b/Sources/SkyflowCore/Elements/Core/State/StateforText.swift @@ -7,33 +7,33 @@ import Foundation import UIKit #endif -internal class StateforText: State +public class StateforText: State { /// true if `SkyflowTextField` input in valid - internal(set) open var isValid = false + public(set) open var isValid = false /// true if `SkyflowTextField` input is empty - internal(set) open var isEmpty = false + public(set) open var isEmpty = false /// true if `SkyflowTextField` was edited - internal(set) open var isDirty = false + public(set) open var isDirty = false /// represents length of SkyflowTextField - internal(set) open var inputLength: Int = 0 + public(set) open var inputLength: Int = 0 -// internal(set) open var isComplete = false +// public(set) open var isComplete = false - internal(set) open var isFocused = false + public(set) open var isFocused = false - internal(set) open var elementType: ElementType! + public(set) open var elementType: ElementType! - internal(set) open var value: String? + public(set) open var value: String? /// Array of `SkyflowValidationError`. Should be empty when textfield input is valid. - internal(set) open var validationError = SkyflowValidationError() + public(set) open var validationError = SkyflowValidationError() - internal(set) open var isCustomRuleFailed = false - internal(set) open var isDefaultRuleFailed = false - internal(set) open var selectedCardScheme: CardType? + public(set) open var isCustomRuleFailed = false + public(set) open var isDefaultRuleFailed = false + public(set) open var selectedCardScheme: CardType? init(tf: TextField) { super.init(columnName: tf.columnName, isRequired: tf.isRequired) diff --git a/Sources/Skyflow/elements/core/styles/Style.swift b/Sources/SkyflowCore/Elements/Core/Styles/Style.swift similarity index 71% rename from Sources/Skyflow/elements/core/styles/Style.swift rename to Sources/SkyflowCore/Elements/Core/Styles/Style.swift index a9a146e6..7be3cef9 100644 --- a/Sources/Skyflow/elements/core/styles/Style.swift +++ b/Sources/SkyflowCore/Elements/Core/Styles/Style.swift @@ -10,25 +10,25 @@ import UIKit #endif public struct Style { - var borderColor: UIColor? - var cornerRadius: CGFloat? - var padding: UIEdgeInsets? - var borderWidth: CGFloat? - var font: UIFont? - var textAlignment: NSTextAlignment? - var textColor: UIColor? - var boxShadow: CALayer? - var backgroundColor: UIColor? - var minWidth: CGFloat? - var maxWidth: CGFloat? - var minHeight: CGFloat? - var maxHeight: CGFloat? - var cursorColor: UIColor? - var width: CGFloat? - var height: CGFloat? - var placeholderColor: UIColor? - var cardIconAlignment: CardIconAlignment? -// var margin: UIEdgeInsets? + public var borderColor: UIColor? + public var cornerRadius: CGFloat? + public var padding: UIEdgeInsets? + public var borderWidth: CGFloat? + public var font: UIFont? + public var textAlignment: NSTextAlignment? + public var textColor: UIColor? + public var boxShadow: CALayer? + public var backgroundColor: UIColor? + public var minWidth: CGFloat? + public var maxWidth: CGFloat? + public var minHeight: CGFloat? + public var maxHeight: CGFloat? + public var cursorColor: UIColor? + public var width: CGFloat? + public var height: CGFloat? + public var placeholderColor: UIColor? + public var cardIconAlignment: CardIconAlignment? +// public var margin: UIEdgeInsets? public init(borderColor: UIColor? = nil, cornerRadius: CGFloat? = nil, diff --git a/Sources/Skyflow/elements/core/styles/Styles.swift b/Sources/SkyflowCore/Elements/Core/Styles/Styles.swift similarity index 77% rename from Sources/Skyflow/elements/core/styles/Styles.swift rename to Sources/SkyflowCore/Elements/Core/Styles/Styles.swift index ad880456..c6a889d9 100644 --- a/Sources/Skyflow/elements/core/styles/Styles.swift +++ b/Sources/SkyflowCore/Elements/Core/Styles/Styles.swift @@ -7,12 +7,12 @@ import Foundation public struct Styles { - var base: Style? - var complete: Style? - var empty: Style? - var focus: Style? - var invalid: Style? - var requiredAstrisk: Style? + public var base: Style? + public var complete: Style? + public var empty: Style? + public var focus: Style? + public var invalid: Style? + public var requiredAstrisk: Style? public init(base: Style? = Style(), complete: Style? = Style(), diff --git a/Sources/Skyflow/elements/FormatTextField.swift b/Sources/SkyflowCore/Elements/FormatTextField.swift similarity index 93% rename from Sources/Skyflow/elements/FormatTextField.swift rename to Sources/SkyflowCore/Elements/FormatTextField.swift index 0337357a..379c3411 100644 --- a/Sources/Skyflow/elements/FormatTextField.swift +++ b/Sources/SkyflowCore/Elements/FormatTextField.swift @@ -7,7 +7,7 @@ import UIKit #endif /// textfield used in SkyflowTextField -internal class FormatTextField: UITextField { +public class FormatTextField: UITextField { enum FormatPatternChar: String, CaseIterable { case lettersAndDigit = "*" case anyLetter = "@" @@ -37,7 +37,7 @@ internal class FormatTextField: UITextField { set { } } - override func leftViewRect(forBounds bounds: CGRect) -> CGRect { + override public func leftViewRect(forBounds bounds: CGRect) -> CGRect { var textRect = super.leftViewRect(forBounds: bounds) textRect.origin.x += 2 return textRect @@ -49,15 +49,15 @@ internal class FormatTextField: UITextField { is applied programmatically by calling formatText */ @available(*, deprecated, message: "Don't use this method.") - override var text: String? { + override public var text: String? { set { secureText = newValue } get { return nil } } - /// text just for internal using - internal var secureText: String? { + /// text just for public using + public var secureText: String? { set { super.text = newValue self.updateTextFormat() @@ -68,16 +68,16 @@ internal class FormatTextField: UITextField { } /** returns textfield text without translation (format pattern) */ - internal var getSecureRawText: String? { + public var getSecureRawText: String? { return getRawText() } /** returns text with format pattern*/ - internal var getTextwithFormatPattern: String? { + public var getTextwithFormatPattern: String? { return formatPattern.isEmpty ? secureText : textwithFormatPattern } - internal var padding = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) + public var padding = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) override open func textRect(forBounds bounds: CGRect) -> CGRect { if super.rightViewMode == .always { @@ -240,7 +240,7 @@ internal class FormatTextField: UITextField { } extension FormatTextField { - override var description: String { + override public var description: String { return NSStringFromClass(self.classForCoder) } } @@ -255,10 +255,10 @@ extension FormatTextField { } -internal struct FormatResult { - internal var formattedText: String - internal var isSuccess: Bool - internal var numOfSeperatorsAdded: Int +public struct FormatResult { + public var formattedText: String + public var isSuccess: Bool + public var numOfSeperatorsAdded: Int public init(formattedText: String, numOfSeperatorsAdded: Int, isSuccess: Bool = true) { self.formattedText = formattedText diff --git a/Sources/Skyflow/elements/PaddingLabel.swift b/Sources/SkyflowCore/Elements/PaddingLabel.swift similarity index 70% rename from Sources/Skyflow/elements/PaddingLabel.swift rename to Sources/SkyflowCore/Elements/PaddingLabel.swift index 015be7ac..bc7be67b 100644 --- a/Sources/Skyflow/elements/PaddingLabel.swift +++ b/Sources/SkyflowCore/Elements/PaddingLabel.swift @@ -8,20 +8,20 @@ import Foundation import UIKit -internal class PaddingLabel: UILabel { - internal var insets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) +public class PaddingLabel: UILabel { + public var insets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) - override func drawText(in rect: CGRect) { + override public func drawText(in rect: CGRect) { super.drawText(in: rect.inset(by: insets)) } - override var intrinsicContentSize: CGSize { + override public var intrinsicContentSize: CGSize { let size = super.intrinsicContentSize return CGSize(width: size.width + insets.left + insets.right, height: size.height + insets.top + insets.bottom) } - override var bounds: CGRect { + override public var bounds: CGRect { didSet { // ensures this works within stack views if multi-line preferredMaxLayoutWidth = bounds.width - (insets.left + insets.right) diff --git a/Sources/Skyflow/elements/SkyflowElement.swift b/Sources/SkyflowCore/Elements/SkyflowElement.swift similarity index 64% rename from Sources/Skyflow/elements/SkyflowElement.swift rename to Sources/SkyflowCore/Elements/SkyflowElement.swift index 0ac78fef..4d16474d 100644 --- a/Sources/Skyflow/elements/SkyflowElement.swift +++ b/Sources/SkyflowCore/Elements/SkyflowElement.swift @@ -12,33 +12,33 @@ import UIKit public class SkyflowElement: UIView { - internal var isRequired = false - internal var fieldType: ElementType! - internal var columnName: String! - internal var tableName: String? - internal var skyflowID: String? - internal var horizontalConstraints = [NSLayoutConstraint]() - internal var verticalConstraint = [NSLayoutConstraint]() - internal var collectInput: CollectElementInput! - internal var options: CollectElementOptions! - internal var contextOptions: ContextOptions! - internal var elements: [TextField] = [] + public var isRequired = false + public var fieldType: ElementType! + public var columnName: String! + public var tableName: String? + public var skyflowID: String? + public var horizontalConstraints = [NSLayoutConstraint]() + public var verticalConstraint = [NSLayoutConstraint]() + public var collectInput: CollectElementInput! + public var options: CollectElementOptions! + public var contextOptions: ContextOptions! + public var elements: [TextField] = [] /// Describes `SkyflowElement` input State` - internal var state: State { + public var state: State { return State(columnName: self.columnName, isRequired: self.isRequired) } - internal func getState() -> [String: Any] { + public func getState() -> [String: Any] { return state.getState() } - override internal init(frame: CGRect) { + override public init(frame: CGRect) { super.init(frame: frame) initialization() } - internal init(input: CollectElementInput, options: CollectElementOptions, contextOptions: ContextOptions, elements: [TextField]) { + public init(input: CollectElementInput, options: CollectElementOptions, contextOptions: ContextOptions, elements: [TextField]) { super.init(frame: CGRect()) self.elements = elements collectInput = input @@ -48,7 +48,7 @@ public class SkyflowElement: UIView { initialization() } - required internal init?(coder aDecoder: NSCoder) { + required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) initialization() } @@ -59,7 +59,7 @@ public class SkyflowElement: UIView { } /// Field Configuration - internal func setupField() { + public func setupField() { tableName = collectInput.table columnName = collectInput.column fieldType = collectInput.type @@ -67,21 +67,21 @@ public class SkyflowElement: UIView { skyflowID = collectInput.skyflowID } - internal func getOutput() -> String? { + public func getOutput() -> String? { return "" } - internal func validate() -> SkyflowValidationError { + public func validate() -> SkyflowValidationError { return SkyflowValidationError() } - internal var padding = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) { + public var padding = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) { didSet { setMainPaddings() } } } public extension SkyflowElement { - internal var cornerRadius: CGFloat { + public var cornerRadius: CGFloat { get { return layer.cornerRadius } @@ -91,7 +91,7 @@ public extension SkyflowElement { } } - internal var borderWidth: CGFloat { + public var borderWidth: CGFloat { get { return layer.borderWidth } @@ -100,7 +100,7 @@ public extension SkyflowElement { } } - internal var borderColor: UIColor? { + public var borderColor: UIColor? { get { guard let cgcolor = layer.borderColor else { return nil @@ -117,7 +117,7 @@ public extension SkyflowElement { } } -internal extension SkyflowElement { +public extension SkyflowElement { @objc func initialization() { mainStyle() diff --git a/Sources/Skyflow/elements/TextField.swift b/Sources/SkyflowCore/Elements/TextField.swift similarity index 93% rename from Sources/Skyflow/elements/TextField.swift rename to Sources/SkyflowCore/Elements/TextField.swift index 4401b4bf..575557d7 100644 --- a/Sources/Skyflow/elements/TextField.swift +++ b/Sources/SkyflowCore/Elements/TextField.swift @@ -16,38 +16,38 @@ import UIKit public class TextField: SkyflowElement, Element, BaseElement { - var onBeginEditing: (() -> Void)? - var onEndEditing: (() -> Void)? - var onFocusIsTrue: (() -> Void)? - internal var textField = FormatTextField(frame: .zero) - internal var errorMessage = PaddingLabel(frame: .zero) - internal var isDirty = false - internal var validationRules = ValidationSet() - internal var userValidationRules = ValidationSet() - internal var stackView = UIStackView() - internal var textFieldLabel = PaddingLabel(frame: .zero) - internal var hasBecomeResponder: Bool = false - internal var copyIconImageView: UIImageView? - internal var cardIconAlignment: CardIconAlignment = .left - internal var rightViewForIcons = UIView() - internal var copyContainerView = UIView() - internal var cardIconContainerView = UIView() + public var onBeginEditing: (() -> Void)? + public var onEndEditing: (() -> Void)? + public var onFocusIsTrue: (() -> Void)? + public var textField = FormatTextField(frame: .zero) + public var errorMessage = PaddingLabel(frame: .zero) + public var isDirty = false + public var validationRules = ValidationSet() + public var userValidationRules = ValidationSet() + public var stackView = UIStackView() + public var textFieldLabel = PaddingLabel(frame: .zero) + public var hasBecomeResponder: Bool = false + public var copyIconImageView: UIImageView? + public var cardIconAlignment: CardIconAlignment = .left + public var rightViewForIcons = UIView() + public var copyContainerView = UIView() + public var cardIconContainerView = UIView() - internal var textFieldDelegate: UITextFieldDelegate? = nil + public var textFieldDelegate: UITextFieldDelegate? = nil - internal var errorTriggered: Bool = false + public var errorTriggered: Bool = false - internal var isErrorMessageShowing: Bool { + public var isErrorMessageShowing: Bool { return self.errorMessage.alpha == 1.0 } - internal var listCardTypes: [CardType]? - internal var dropdownButton = UIButton() - internal var selectedCardBrand: CardType? = nil + public var listCardTypes: [CardType]? + public var dropdownButton = UIButton() + public var selectedCardBrand: CardType? = nil - internal var uuid: String = "" + public var uuid: String = "" - internal var textFieldCornerRadius: CGFloat { + public var textFieldCornerRadius: CGFloat { get { return textField.layer.cornerRadius } @@ -57,7 +57,7 @@ public class TextField: SkyflowElement, Element, BaseElement { } } - internal var textFieldBorderWidth: CGFloat { + public var textFieldBorderWidth: CGFloat { get { return textField.layer.borderWidth } @@ -66,7 +66,7 @@ public class TextField: SkyflowElement, Element, BaseElement { } } - internal var textFieldBorderColor: UIColor? { + public var textFieldBorderColor: UIColor? { get { guard let cgcolor = textField.layer.borderColor else { return nil @@ -78,15 +78,15 @@ public class TextField: SkyflowElement, Element, BaseElement { } } - internal var textFieldPadding = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) { + public var textFieldPadding = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) { didSet { setMainPaddings() } } - internal override var state: State { + public override var state: State { return StateforText(tf: self) } - override init(input: CollectElementInput, options: CollectElementOptions, contextOptions: ContextOptions, elements: [TextField]? = nil) { + override public init(input: CollectElementInput, options: CollectElementOptions, contextOptions: ContextOptions, elements: [TextField]? = nil) { super.init(input: input, options: options, contextOptions: contextOptions, elements: elements ?? []) self.userValidationRules.append(input.validations) self.textFieldDelegate = TextFieldValidationDelegate(collectField: self) @@ -104,7 +104,7 @@ public class TextField: SkyflowElement, Element, BaseElement { } } - internal func addValidations() { + public func addValidations() { if self.fieldType == .EXPIRATION_DATE { self.addDateValidations() } else if self.fieldType == .EXPIRATION_YEAR { @@ -114,7 +114,7 @@ public class TextField: SkyflowElement, Element, BaseElement { } } - internal func addDateValidations() { + public func addDateValidations() { let defaultFormat = "mm/yy" let supportedFormats = [defaultFormat, "mm/yyyy", "yy/mm", "yyyy/mm"] if !supportedFormats.contains(self.options.format.lowercased()) { @@ -127,12 +127,12 @@ public class TextField: SkyflowElement, Element, BaseElement { self.validationRules.append(ValidationSet(rules: [expiryDateRule])) } - internal func addMonthValidations() { + public func addMonthValidations() { let monthRule = SkyflowValidateExpirationMonth(error: SkyflowValidationErrorType.expirationMonth.rawValue) self.validationRules.append(ValidationSet(rules: [monthRule])) } - internal func addYearValidations() { + public func addYearValidations() { var format = "yyyy" if self.options.format.lowercased() == "yy" { format = "yy" @@ -142,7 +142,7 @@ public class TextField: SkyflowElement, Element, BaseElement { self.validationRules.append(ValidationSet(rules: [yearRule])) } - internal func setFormatPattern() { + public func setFormatPattern() { switch fieldType { case .CARD_NUMBER: let cardType = CardType.forCardNumber(cardNumber: self.actualValue).instance @@ -161,12 +161,12 @@ public class TextField: SkyflowElement, Element, BaseElement { } } - required internal init?(coder aDecoder: NSCoder) { + required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } - internal func isMounted() -> Bool { + public func isMounted() -> Bool { var flag = false if Thread.isMainThread { flag = self.window != nil @@ -179,27 +179,27 @@ public class TextField: SkyflowElement, Element, BaseElement { } - internal var hasFocus = false + public var hasFocus = false - internal var onChangeHandler: (([String: Any]) -> Void)? - internal var onBlurHandler: (([String: Any]) -> Void)? - internal var onReadyHandler: (([String: Any]) -> Void)? - internal var onFocusHandler: (([String: Any]) -> Void)? - internal var onSubmitHandler: (() -> Void)? + public var onChangeHandler: (([String: Any]) -> Void)? + public var onBlurHandler: (([String: Any]) -> Void)? + public var onReadyHandler: (([String: Any]) -> Void)? + public var onFocusHandler: (([String: Any]) -> Void)? + public var onSubmitHandler: (() -> Void)? - override func getOutput() -> String? { + override public func getOutput() -> String? { return textField.getTextwithFormatPattern } - internal var actualValue: String = "" + public var actualValue: String = "" - internal func getValue() -> String { + public func getValue() -> String { return actualValue } - internal func getOutputTextwithoutFormatPattern() -> String? { + public func getOutputTextwithoutFormatPattern() -> String? { return textField.getSecureRawText } @@ -254,7 +254,7 @@ public class TextField: SkyflowElement, Element, BaseElement { if(updateOptions.cardMetaData != nil && self.fieldType == .CARD_NUMBER){ self.options.cardMetaData = updateOptions.cardMetaData - if let schemes = self.options.cardMetaData?["scheme"] as? [Skyflow.CardType] { + if let schemes = self.options.cardMetaData?["scheme"] as? [CardType] { if schemes.isEmpty { selectedCardBrand = nil listCardTypes = nil @@ -358,7 +358,7 @@ public class TextField: SkyflowElement, Element, BaseElement { } } - override func setupField() { + override public func setupField() { super.setupField() self.cardIconAlignment = collectInput.iconStyles.base?.cardIconAlignment ?? .left self.textField.placeholder = collectInput.placeholder @@ -524,7 +524,7 @@ public class TextField: SkyflowElement, Element, BaseElement { } } - internal func updateImage(name: String, cardNumber: String){ + public func updateImage(name: String, cardNumber: String){ var name = name if self.options.enableCardIcon == false { return @@ -635,7 +635,7 @@ public class TextField: SkyflowElement, Element, BaseElement { } } @available(iOS 14.0, *) - internal func setUpMenuView() { + public func setUpMenuView() { let actionClosure: (UIAction) -> Void = { [weak self] action in guard let self = self else { return } @@ -667,7 +667,7 @@ public class TextField: SkyflowElement, Element, BaseElement { } @available(iOS 14.0, *) - internal func updateMenuView() { + public func updateMenuView() { var updatedMenuChildren: [UIMenuElement] = [] if let cardTypes = listCardTypes { @@ -693,7 +693,7 @@ public class TextField: SkyflowElement, Element, BaseElement { dropdownButton.menu = UIMenu(options: .displayInline, children: updatedMenuChildren) } - override func validate() -> SkyflowValidationError { + override public func validate() -> SkyflowValidationError { let str = actualValue if self.errorTriggered { return self.errorMessage.text! @@ -709,7 +709,7 @@ public class TextField: SkyflowElement, Element, BaseElement { return SkyflowValidator.validate(input: str, rules: userValidationRules) } - internal func isValid() -> Bool { + public func isValid() -> Bool { let state = self.state.getState() if (state["isRequired"] as! Bool) && (state["isEmpty"] as! Bool || self.actualValue.isEmpty) { return false @@ -766,7 +766,7 @@ extension TextField { extension TextField { - internal func updateInputStyle(_ style: Style? = nil) { + public func updateInputStyle(_ style: Style? = nil) { self.textField.translatesAutoresizingMaskIntoConstraints = false let fallbackStyle = self.collectInput.inputStyles.base self.textField.font = style?.font ?? fallbackStyle?.font ?? .none @@ -839,7 +839,7 @@ extension TextField { } } - internal func updateLabelStyle(_ style: Style? = nil) { + public func updateLabelStyle(_ style: Style? = nil) { let fallbackStyle = self.collectInput!.labelStyles.base self.textFieldLabel.textColor = style?.textColor ?? fallbackStyle?.textColor ?? .none self.textFieldLabel.font = style?.font ?? fallbackStyle?.font ?? .none @@ -847,7 +847,7 @@ extension TextField { self.textFieldLabel.insets = style?.padding ?? fallbackStyle?.padding ?? UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) } - internal func textFieldDidEndEditing(_ textField: UITextField) { + public func textFieldDidEndEditing(_ textField: UITextField) { self.textField.delegate?.textFieldDidEndEditing?(textField) } @@ -883,7 +883,7 @@ extension TextField { } } - func updateErrorMessage() { + public func updateErrorMessage() { var isRequiredCheckFailed = false @@ -935,7 +935,7 @@ extension TextField { } } -internal extension TextField { +public extension TextField { @objc override func initialization() { diff --git a/Sources/Skyflow/elements/TextFieldValidationDelegate.swift b/Sources/SkyflowCore/Elements/TextFieldValidationDelegate.swift similarity index 98% rename from Sources/Skyflow/elements/TextFieldValidationDelegate.swift rename to Sources/SkyflowCore/Elements/TextFieldValidationDelegate.swift index 611ae41b..3f958c38 100644 --- a/Sources/Skyflow/elements/TextFieldValidationDelegate.swift +++ b/Sources/SkyflowCore/Elements/TextFieldValidationDelegate.swift @@ -7,11 +7,11 @@ import UIKit -internal class TextFieldValidationDelegate: NSObject, UITextFieldDelegate { +public class TextFieldValidationDelegate: NSObject, UITextFieldDelegate { var collectField: TextField - internal init(collectField: TextField) { + public init(collectField: TextField) { self.collectField = collectField } public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { diff --git a/Sources/Skyflow/elements/utils/CardBin.swift b/Sources/SkyflowCore/Elements/Utils/CardBin.swift similarity index 86% rename from Sources/Skyflow/elements/utils/CardBin.swift rename to Sources/SkyflowCore/Elements/Utils/CardBin.swift index 4a5af01d..df9fd782 100644 --- a/Sources/Skyflow/elements/utils/CardBin.swift +++ b/Sources/SkyflowCore/Elements/Utils/CardBin.swift @@ -7,7 +7,7 @@ import Foundation extension Card { /// Get the BIN of a cardNumber, /// binCount is the number of characters that aren't masked - internal class func getBIN(_ cardNumber: String, _ binCount: Int = 8) -> String { + public class func getBIN(_ cardNumber: String, _ binCount: Int = 8) -> String { var result = "" var numbers = 0 diff --git a/Sources/Skyflow/elements/utils/CardType.swift b/Sources/SkyflowCore/Elements/Utils/CardType.swift similarity index 98% rename from Sources/Skyflow/elements/utils/CardType.swift rename to Sources/SkyflowCore/Elements/Utils/CardType.swift index 5e195ea1..90588ae6 100644 --- a/Sources/Skyflow/elements/utils/CardType.swift +++ b/Sources/SkyflowCore/Elements/Utils/CardType.swift @@ -11,7 +11,7 @@ import Foundation -internal class Card { +public class Card { var defaultName: String var regex: String var cardLengths: [Int] @@ -136,7 +136,7 @@ public enum CardType: CaseIterable { } -internal enum SecurityCode: String { +public enum SecurityCode: String { case cvv = "cvv" case cvc = "cvc" case cvn = "cvn" diff --git a/Sources/Skyflow/elements/utils/CharacterSet.swift b/Sources/SkyflowCore/Elements/Utils/CharacterSet.swift similarity index 100% rename from Sources/Skyflow/elements/utils/CharacterSet.swift rename to Sources/SkyflowCore/Elements/Utils/CharacterSet.swift diff --git a/Sources/Skyflow/elements/validations/ElementValueMatchRule.swift b/Sources/SkyflowCore/Elements/Validations/ElementValueMatchRule.swift similarity index 100% rename from Sources/Skyflow/elements/validations/ElementValueMatchRule.swift rename to Sources/SkyflowCore/Elements/Validations/ElementValueMatchRule.swift diff --git a/Sources/Skyflow/elements/validations/LengthMatchRule.swift b/Sources/SkyflowCore/Elements/Validations/LengthMatchRule.swift similarity index 100% rename from Sources/Skyflow/elements/validations/LengthMatchRule.swift rename to Sources/SkyflowCore/Elements/Validations/LengthMatchRule.swift diff --git a/Sources/Skyflow/elements/validations/RegexMatchRule.swift b/Sources/SkyflowCore/Elements/Validations/RegexMatchRule.swift similarity index 100% rename from Sources/Skyflow/elements/validations/RegexMatchRule.swift rename to Sources/SkyflowCore/Elements/Validations/RegexMatchRule.swift diff --git a/Sources/Skyflow/elements/validations/SkyflowInternalValidatorProtocol.swift b/Sources/SkyflowCore/Elements/Validations/SkyflowInternalValidatorProtocol.swift similarity index 66% rename from Sources/Skyflow/elements/validations/SkyflowInternalValidatorProtocol.swift rename to Sources/SkyflowCore/Elements/Validations/SkyflowInternalValidatorProtocol.swift index 27331145..9ab97753 100644 --- a/Sources/Skyflow/elements/validations/SkyflowInternalValidatorProtocol.swift +++ b/Sources/SkyflowCore/Elements/Validations/SkyflowInternalValidatorProtocol.swift @@ -4,7 +4,7 @@ import Foundation -internal protocol SkyflowInternalValidationProtocol { +public protocol SkyflowInternalValidationProtocol { func validate(_ input: String?) -> Bool } diff --git a/Sources/Skyflow/elements/validations/SkyflowValidateCardExpirationDate.swift b/Sources/SkyflowCore/Elements/Validations/SkyflowValidateCardExpirationDate.swift similarity index 94% rename from Sources/Skyflow/elements/validations/SkyflowValidateCardExpirationDate.swift rename to Sources/SkyflowCore/Elements/Validations/SkyflowValidateCardExpirationDate.swift index 9def0065..a6ef9c1a 100644 --- a/Sources/Skyflow/elements/validations/SkyflowValidateCardExpirationDate.swift +++ b/Sources/SkyflowCore/Elements/Validations/SkyflowValidateCardExpirationDate.swift @@ -8,7 +8,7 @@ import Foundation Validate input in scope of Card Expiration Month/Year, e.x.: [01/22, 12/29]. */ -internal enum SkyflowCardExpirationDateFormat { +public enum SkyflowCardExpirationDateFormat { /// Exp.Date in format mm/yy: 01/22 case shortYear @@ -28,7 +28,7 @@ internal enum SkyflowCardExpirationDateFormat { return 2 } - internal var dateYearFormat: String { + public var dateYearFormat: String { switch self { case .shortYear: return "yy" @@ -38,7 +38,7 @@ internal enum SkyflowCardExpirationDateFormat { } } -internal struct SkyflowValidateCardExpirationDate: ValidationRule { +public struct SkyflowValidateCardExpirationDate: ValidationRule { /// Validation Error public let error: SkyflowValidationError public let format: String diff --git a/Sources/Skyflow/elements/validations/SkyflowValidateCardNumber.swift b/Sources/SkyflowCore/Elements/Validations/SkyflowValidateCardNumber.swift similarity index 92% rename from Sources/Skyflow/elements/validations/SkyflowValidateCardNumber.swift rename to Sources/SkyflowCore/Elements/Validations/SkyflowValidateCardNumber.swift index b2108260..f1219606 100644 --- a/Sources/Skyflow/elements/validations/SkyflowValidateCardNumber.swift +++ b/Sources/SkyflowCore/Elements/Validations/SkyflowValidateCardNumber.swift @@ -8,9 +8,9 @@ import Foundation -internal struct SkyflowValidateCardNumber: ValidationRule { - var error: String - internal let regex: String +public struct SkyflowValidateCardNumber: ValidationRule { + public var error: String + public let regex: String public init(error: SkyflowValidationError, regex: String) { self.error = error @@ -21,7 +21,7 @@ internal struct SkyflowValidateCardNumber: ValidationRule { extension SkyflowValidateCardNumber: SkyflowInternalValidationProtocol { /// Validate the text (returns true if it is valid card number) - func validate(_ text: String?) -> Bool { + public func validate(_ text: String?) -> Bool { if text!.isEmpty { return true } diff --git a/Sources/Skyflow/elements/validations/SkyflowValidateExpirationMonth.swift b/Sources/SkyflowCore/Elements/Validations/SkyflowValidateExpirationMonth.swift similarity index 93% rename from Sources/Skyflow/elements/validations/SkyflowValidateExpirationMonth.swift rename to Sources/SkyflowCore/Elements/Validations/SkyflowValidateExpirationMonth.swift index 2c953d5a..377cc6de 100644 --- a/Sources/Skyflow/elements/validations/SkyflowValidateExpirationMonth.swift +++ b/Sources/SkyflowCore/Elements/Validations/SkyflowValidateExpirationMonth.swift @@ -8,7 +8,7 @@ import Foundation -internal struct SkyflowValidateExpirationMonth: ValidationRule { +public struct SkyflowValidateExpirationMonth: ValidationRule { /// Validation Error public let error: SkyflowValidationError diff --git a/Sources/Skyflow/elements/validations/SkyflowValidateExpirationYear.swift b/Sources/SkyflowCore/Elements/Validations/SkyflowValidateExpirationYear.swift similarity index 94% rename from Sources/Skyflow/elements/validations/SkyflowValidateExpirationYear.swift rename to Sources/SkyflowCore/Elements/Validations/SkyflowValidateExpirationYear.swift index 3a3b7f35..e7736c15 100644 --- a/Sources/Skyflow/elements/validations/SkyflowValidateExpirationYear.swift +++ b/Sources/SkyflowCore/Elements/Validations/SkyflowValidateExpirationYear.swift @@ -8,7 +8,7 @@ import Foundation -internal struct SkyflowValidateExpirationYear: ValidationRule { +public struct SkyflowValidateExpirationYear: ValidationRule { /// Validation Error public let error: SkyflowValidationError public let format: String diff --git a/Sources/Skyflow/elements/validations/SkyflowValidateLengthMatch.swift b/Sources/SkyflowCore/Elements/Validations/SkyflowValidateLengthMatch.swift similarity index 92% rename from Sources/Skyflow/elements/validations/SkyflowValidateLengthMatch.swift rename to Sources/SkyflowCore/Elements/Validations/SkyflowValidateLengthMatch.swift index 47b1bebe..27a4cb19 100644 --- a/Sources/Skyflow/elements/validations/SkyflowValidateLengthMatch.swift +++ b/Sources/SkyflowCore/Elements/Validations/SkyflowValidateLengthMatch.swift @@ -8,7 +8,7 @@ import Foundation Validate input in scope of multiple lengths, e.x.: [10, 15]. */ -internal struct SkyflowValidateLengthMatch: ValidationRule { +public struct SkyflowValidateLengthMatch: ValidationRule { /// Array of valid length ranges public let lengths: [Int] diff --git a/Sources/Skyflow/elements/validations/SkyflowValidationError.swift b/Sources/SkyflowCore/Elements/Validations/SkyflowValidationError.swift similarity index 95% rename from Sources/Skyflow/elements/validations/SkyflowValidationError.swift rename to Sources/SkyflowCore/Elements/Validations/SkyflowValidationError.swift index a9b611d1..34e1aa79 100644 --- a/Sources/Skyflow/elements/validations/SkyflowValidationError.swift +++ b/Sources/SkyflowCore/Elements/Validations/SkyflowValidationError.swift @@ -8,7 +8,7 @@ import Foundation public typealias SkyflowValidationError = String /// Default validation error types -internal enum SkyflowValidationErrorType: String { +public enum SkyflowValidationErrorType: String { /// Default Validation error for `SkyflowValidateCardNumber` case cardNumber = "INVALID_CARD_NUMBER" diff --git a/Sources/Skyflow/elements/validations/SkyflowValidator.swift b/Sources/SkyflowCore/Elements/Validations/SkyflowValidator.swift similarity index 67% rename from Sources/Skyflow/elements/validations/SkyflowValidator.swift rename to Sources/SkyflowCore/Elements/Validations/SkyflowValidator.swift index f3e93811..4e3fd537 100644 --- a/Sources/Skyflow/elements/validations/SkyflowValidator.swift +++ b/Sources/SkyflowCore/Elements/Validations/SkyflowValidator.swift @@ -4,10 +4,10 @@ import Foundation -internal struct SkyflowValidator { +public struct SkyflowValidator { - internal static func validate(input: String?, rules: ValidationSet) -> SkyflowValidationError { + public static func validate(input: String?, rules: ValidationSet) -> SkyflowValidationError { let errors = rules.rules .filter { !($0 as! SkyflowInternalValidationProtocol).validate(input) } .map { $0.error } diff --git a/Sources/Skyflow/elements/validations/ValidationRule.swift b/Sources/SkyflowCore/Elements/Validations/ValidationRule.swift similarity index 100% rename from Sources/Skyflow/elements/validations/ValidationRule.swift rename to Sources/SkyflowCore/Elements/Validations/ValidationRule.swift diff --git a/Sources/Skyflow/elements/validations/ValidationSet.swift b/Sources/SkyflowCore/Elements/Validations/ValidationSet.swift similarity index 80% rename from Sources/Skyflow/elements/validations/ValidationSet.swift rename to Sources/SkyflowCore/Elements/Validations/ValidationSet.swift index 3a0a8fb9..a4ebdad7 100644 --- a/Sources/Skyflow/elements/validations/ValidationSet.swift +++ b/Sources/SkyflowCore/Elements/Validations/ValidationSet.swift @@ -8,7 +8,7 @@ import Foundation public struct ValidationSet { - internal var rules = [ValidationRule]() + public var rules = [ValidationRule]() public init() { } @@ -21,7 +21,7 @@ public struct ValidationSet { rules.append(rule) } - internal mutating func append(_ ruleSet: ValidationSet) { + public mutating func append(_ ruleSet: ValidationSet) { for rule in ruleSet.rules { self.rules.append(rule) } diff --git a/Sources/Skyflow/errors/ErrorCodes.swift b/Sources/SkyflowCore/Errors/ErrorCodes.swift similarity index 98% rename from Sources/Skyflow/errors/ErrorCodes.swift rename to Sources/SkyflowCore/Errors/ErrorCodes.swift index d117f4bc..ed30e247 100644 --- a/Sources/Skyflow/errors/ErrorCodes.swift +++ b/Sources/SkyflowCore/Errors/ErrorCodes.swift @@ -6,7 +6,7 @@ import Foundation -internal enum ErrorCodes: CustomStringConvertible { +public enum ErrorCodes: CustomStringConvertible { // No message values case EMPTY_TABLE_NAME(code: Int = 400, message: String = "\(LangAndVersion) Validation error. Invalid type for 'table' key value in collect element. Specify a value of type string instead.") case EMPTY_COMPOSABLE_LAYOUT_ARRAY(code: Int = 400, message: String = "\(LangAndVersion) Mount failed. Layout array is empty in composable container options. Specify a valid layout array.") @@ -86,7 +86,7 @@ internal enum ErrorCodes: CustomStringConvertible { } } - internal var description: String { + public var description: String { switch self { // No Formatting required // swiftlint:disable:next line_length @@ -101,16 +101,16 @@ internal enum ErrorCodes: CustomStringConvertible { return formatMessage(message, values) } } - internal var errorObject: NSError { + public var errorObject: NSError { NSError(domain: "", code: self.code, userInfo: [NSLocalizedDescriptionKey: self.description]) } - internal func getErrorObject(contextOptions: ContextOptions) -> NSError { + public func getErrorObject(contextOptions: ContextOptions) -> NSError { Log.error(message: self.description, contextOptions: contextOptions) return SkyflowError(domain: "", code: self.code, userInfo: [NSLocalizedDescriptionKey: "\(self.description)" ]) } - internal func formatMessage(_ message: String, _ values: [String]) -> String { + public func formatMessage(_ message: String, _ values: [String]) -> String { let words = message.split(separator: " ") var valuesIndex = 0 var result = "" diff --git a/Sources/Skyflow/core/protocols/Callback.swift b/Sources/SkyflowCore/Protocols/Callback.swift similarity index 100% rename from Sources/Skyflow/core/protocols/Callback.swift rename to Sources/SkyflowCore/Protocols/Callback.swift diff --git a/Sources/Skyflow/core/protocols/TokenProvider.swift b/Sources/SkyflowCore/Protocols/TokenProvider.swift similarity index 100% rename from Sources/Skyflow/core/protocols/TokenProvider.swift rename to Sources/SkyflowCore/Protocols/TokenProvider.swift diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Amex-Card.imageset/Amex-Card@3x.png b/Sources/SkyflowCore/Resources/Assets.xcassets/Amex-Card.imageset/Amex-Card@3x.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Amex-Card.imageset/Amex-Card@3x.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/Amex-Card.imageset/Amex-Card@3x.png diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Amex-Card.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/Amex-Card.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Amex-Card.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/Amex-Card.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Cartes-Bancaires-Card.imageset/Cartes-Bancaires-Card.png b/Sources/SkyflowCore/Resources/Assets.xcassets/Cartes-Bancaires-Card.imageset/Cartes-Bancaires-Card.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Cartes-Bancaires-Card.imageset/Cartes-Bancaires-Card.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/Cartes-Bancaires-Card.imageset/Cartes-Bancaires-Card.png diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Cartes-Bancaires-Card.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/Cartes-Bancaires-Card.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Cartes-Bancaires-Card.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/Cartes-Bancaires-Card.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Copy-Icon.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/Copy-Icon.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Copy-Icon.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/Copy-Icon.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Copy-Icon.imageset/Copy-Icon.png b/Sources/SkyflowCore/Resources/Assets.xcassets/Copy-Icon.imageset/Copy-Icon.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Copy-Icon.imageset/Copy-Icon.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/Copy-Icon.imageset/Copy-Icon.png diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Diners-Card.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/Diners-Card.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Diners-Card.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/Diners-Card.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Diners-Card.imageset/Diners-Card@3x.png b/Sources/SkyflowCore/Resources/Assets.xcassets/Diners-Card.imageset/Diners-Card@3x.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Diners-Card.imageset/Diners-Card@3x.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/Diners-Card.imageset/Diners-Card@3x.png diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Discover-Card.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/Discover-Card.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Discover-Card.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/Discover-Card.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Discover-Card.imageset/Discover-Card@3x.png b/Sources/SkyflowCore/Resources/Assets.xcassets/Discover-Card.imageset/Discover-Card@3x.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Discover-Card.imageset/Discover-Card@3x.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/Discover-Card.imageset/Discover-Card@3x.png diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Hipercard-Card.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/Hipercard-Card.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Hipercard-Card.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/Hipercard-Card.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Hipercard-Card.imageset/Hipercard-Card@3x.png b/Sources/SkyflowCore/Resources/Assets.xcassets/Hipercard-Card.imageset/Hipercard-Card@3x.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Hipercard-Card.imageset/Hipercard-Card@3x.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/Hipercard-Card.imageset/Hipercard-Card@3x.png diff --git a/Sources/Skyflow/Resources/Assets.xcassets/JCB-Card.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/JCB-Card.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/JCB-Card.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/JCB-Card.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/JCB-Card.imageset/JCB-Card@3x.png b/Sources/SkyflowCore/Resources/Assets.xcassets/JCB-Card.imageset/JCB-Card@3x.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/JCB-Card.imageset/JCB-Card@3x.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/JCB-Card.imageset/JCB-Card@3x.png diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Maestro-Card.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/Maestro-Card.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Maestro-Card.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/Maestro-Card.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Maestro-Card.imageset/Maestro-Card@3x.png b/Sources/SkyflowCore/Resources/Assets.xcassets/Maestro-Card.imageset/Maestro-Card@3x.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Maestro-Card.imageset/Maestro-Card@3x.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/Maestro-Card.imageset/Maestro-Card@3x.png diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Mastercard-Card.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/Mastercard-Card.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Mastercard-Card.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/Mastercard-Card.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Mastercard-Card.imageset/Mastercard-Card@3x.png b/Sources/SkyflowCore/Resources/Assets.xcassets/Mastercard-Card.imageset/Mastercard-Card@3x.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Mastercard-Card.imageset/Mastercard-Card@3x.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/Mastercard-Card.imageset/Mastercard-Card@3x.png diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Success-Icon.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/Success-Icon.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Success-Icon.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/Success-Icon.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Success-Icon.imageset/Success-Icon.png b/Sources/SkyflowCore/Resources/Assets.xcassets/Success-Icon.imageset/Success-Icon.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Success-Icon.imageset/Success-Icon.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/Success-Icon.imageset/Success-Icon.png diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Unionpay-Card.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/Unionpay-Card.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Unionpay-Card.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/Unionpay-Card.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Unionpay-Card.imageset/Unionpay-Card@3x.png b/Sources/SkyflowCore/Resources/Assets.xcassets/Unionpay-Card.imageset/Unionpay-Card@3x.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Unionpay-Card.imageset/Unionpay-Card@3x.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/Unionpay-Card.imageset/Unionpay-Card@3x.png diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Unknown-Card.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/Unknown-Card.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Unknown-Card.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/Unknown-Card.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Unknown-Card.imageset/Unknown-Card@3x.png b/Sources/SkyflowCore/Resources/Assets.xcassets/Unknown-Card.imageset/Unknown-Card@3x.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Unknown-Card.imageset/Unknown-Card@3x.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/Unknown-Card.imageset/Unknown-Card@3x.png diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Visa-Card.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/Visa-Card.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Visa-Card.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/Visa-Card.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/Visa-Card.imageset/Group 82.png b/Sources/SkyflowCore/Resources/Assets.xcassets/Visa-Card.imageset/Group 82.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/Visa-Card.imageset/Group 82.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/Visa-Card.imageset/Group 82.png diff --git a/Sources/Skyflow/Resources/Assets.xcassets/checkmark.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/checkmark.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/checkmark.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/checkmark.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/checkmark.imageset/checkmark.png b/Sources/SkyflowCore/Resources/Assets.xcassets/checkmark.imageset/checkmark.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/checkmark.imageset/checkmark.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/checkmark.imageset/checkmark.png diff --git a/Sources/Skyflow/Resources/Assets.xcassets/dropdown.imageset/Contents.json b/Sources/SkyflowCore/Resources/Assets.xcassets/dropdown.imageset/Contents.json similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/dropdown.imageset/Contents.json rename to Sources/SkyflowCore/Resources/Assets.xcassets/dropdown.imageset/Contents.json diff --git a/Sources/Skyflow/Resources/Assets.xcassets/dropdown.imageset/dropdown.png b/Sources/SkyflowCore/Resources/Assets.xcassets/dropdown.imageset/dropdown.png similarity index 100% rename from Sources/Skyflow/Resources/Assets.xcassets/dropdown.imageset/dropdown.png rename to Sources/SkyflowCore/Resources/Assets.xcassets/dropdown.imageset/dropdown.png diff --git a/Sources/Skyflow/reveal/ConversionHelpers.swift b/Sources/SkyflowCore/Reveal/ConversionHelpers.swift similarity index 79% rename from Sources/Skyflow/reveal/ConversionHelpers.swift rename to Sources/SkyflowCore/Reveal/ConversionHelpers.swift index a70d8134..10685f5b 100644 --- a/Sources/Skyflow/reveal/ConversionHelpers.swift +++ b/Sources/SkyflowCore/Reveal/ConversionHelpers.swift @@ -7,8 +7,8 @@ import Foundation -class ConversionHelpers { - static func checkElementsAreMounted(elements: [Any]) -> Any? { +public class ConversionHelpers { + public static func checkElementsAreMounted(elements: [Any]) -> Any? { for element in elements { if let label = element as? Label, !label.isMounted() { return label diff --git a/Sources/Skyflow/reveal/FormatLabel.swift b/Sources/SkyflowCore/Reveal/FormatLabel.swift similarity index 87% rename from Sources/Skyflow/reveal/FormatLabel.swift rename to Sources/SkyflowCore/Reveal/FormatLabel.swift index fa48b42e..70058f98 100644 --- a/Sources/Skyflow/reveal/FormatLabel.swift +++ b/Sources/SkyflowCore/Reveal/FormatLabel.swift @@ -8,7 +8,7 @@ import Foundation import UIKit public class FormatLabel: UILabel { - internal var secureText: String? { + public var secureText: String? { set { super.text = newValue } diff --git a/Sources/Skyflow/reveal/Label.swift b/Sources/SkyflowCore/Reveal/Label.swift similarity index 87% rename from Sources/Skyflow/reveal/Label.swift rename to Sources/SkyflowCore/Reveal/Label.swift index 5b4fe241..908a56b1 100644 --- a/Sources/Skyflow/reveal/Label.swift +++ b/Sources/SkyflowCore/Reveal/Label.swift @@ -11,24 +11,24 @@ import Foundation import UIKit public class Label: UIView, Element, BaseElement { - internal var skyflowLabelView: SkyflowLabelView! - internal var revealInput: RevealElementInput! - internal var options: RevealElementOptions! - internal var stackView = UIStackView() - internal var labelField = PaddingLabel(frame: .zero) - internal var errorMessage = PaddingLabel(frame: .zero) + public var skyflowLabelView: SkyflowLabelView! + public var revealInput: RevealElementInput! + public var options: RevealElementOptions! + public var stackView = UIStackView() + public var labelField = PaddingLabel(frame: .zero) + public var errorMessage = PaddingLabel(frame: .zero) - internal var errorTriggered: Bool = false - internal var triggeredErrorMessage: String = "" - internal var uuid: String = "" + public var errorTriggered: Bool = false + public var triggeredErrorMessage: String = "" + public var uuid: String = "" - internal var actualValue: String? = nil + public var actualValue: String? = nil - internal var horizontalConstraints = [NSLayoutConstraint]() + public var horizontalConstraints = [NSLayoutConstraint]() - internal var verticalConstraint = [NSLayoutConstraint]() + public var verticalConstraint = [NSLayoutConstraint]() - internal init(input: RevealElementInput, options: RevealElementOptions) { + public init(input: RevealElementInput, options: RevealElementOptions) { self.skyflowLabelView = SkyflowLabelView(input: input, options: options) super.init(frame: CGRect()) self.revealInput = input @@ -37,11 +37,11 @@ public class Label: UIView, Element, BaseElement { } - override internal init(frame: CGRect) { + override public init(frame: CGRect) { super.init(frame: frame) } - required internal init?(coder aDecoder: NSCoder) { + required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } func formatInput(input: String, format: String, translation: [Character: String]) -> String { @@ -96,7 +96,7 @@ public class Label: UIView, Element, BaseElement { return output } - internal func updateVal(value: String) { + public func updateVal(value: String) { if let format = self.options?.format { if format != "" { if(self.options.translation == nil){ @@ -122,7 +122,7 @@ public class Label: UIView, Element, BaseElement { } } - internal func isMounted() -> Bool { + public func isMounted() -> Bool { var flag = false if Thread.isMainThread { flag = self.window != nil @@ -134,7 +134,7 @@ public class Label: UIView, Element, BaseElement { return flag } - internal func buildLabel() { + public func buildLabel() { self.translatesAutoresizingMaskIntoConstraints = false // Set label base styles @@ -184,19 +184,19 @@ public class Label: UIView, Element, BaseElement { NSLayoutConstraint.activate(verticalConstraint) } - func showError(message: String) { + public func showError(message: String) { self.errorMessage.text = message self.skyflowLabelView.updateStyle() self.errorMessage.alpha = 1.0 } - func hideError() { + public func hideError() { if !self.errorTriggered { self.errorMessage.alpha = 0.0 } } - internal func getValue() -> String { + public func getValue() -> String { return self.actualValue ?? "" } @@ -232,11 +232,11 @@ public class Label: UIView, Element, BaseElement { self.skyflowLabelView.updateVal(value: actualValue == nil ? revealInput.token : actualValue!, actualValue: nil) } - internal func getToken() -> String{ + public func getToken() -> String{ return self.revealInput.token } - internal func getValueForConnections() -> String { + public func getValueForConnections() -> String { if actualValue != nil { return getValue() } else { diff --git a/Sources/Skyflow/reveal/RedactionType.swift b/Sources/SkyflowCore/Reveal/RedactionType.swift similarity index 100% rename from Sources/Skyflow/reveal/RedactionType.swift rename to Sources/SkyflowCore/Reveal/RedactionType.swift diff --git a/Sources/Skyflow/reveal/RevealElementInput.swift b/Sources/SkyflowCore/Reveal/RevealElementInput.swift similarity index 79% rename from Sources/Skyflow/reveal/RevealElementInput.swift rename to Sources/SkyflowCore/Reveal/RevealElementInput.swift index d0da3195..c1319559 100644 --- a/Sources/Skyflow/reveal/RevealElementInput.swift +++ b/Sources/SkyflowCore/Reveal/RevealElementInput.swift @@ -7,13 +7,13 @@ import Foundation public struct RevealElementInput { - internal var token: String - internal var inputStyles: Styles? - internal var labelStyles: Styles? - internal var errorTextStyles: Styles? - internal var label: String - internal var redaction: RedactionType - internal var altText: String + public var token: String + public var inputStyles: Styles? + public var labelStyles: Styles? + public var errorTextStyles: Styles? + public var label: String + public var redaction: RedactionType + public var altText: String public init(token: String = "", inputStyles: Styles = Styles(), labelStyles: Styles = Styles(), errorTextStyles: Styles = Styles(), label: String, redaction: RedactionType = .PLAIN_TEXT, altText: String = "") { self.token = token diff --git a/Sources/Skyflow/reveal/RevealElementOptions.swift b/Sources/SkyflowCore/Reveal/RevealElementOptions.swift similarity index 100% rename from Sources/Skyflow/reveal/RevealElementOptions.swift rename to Sources/SkyflowCore/Reveal/RevealElementOptions.swift diff --git a/Sources/Skyflow/reveal/RevealOptions.swift b/Sources/SkyflowCore/Reveal/RevealOptions.swift similarity index 58% rename from Sources/Skyflow/reveal/RevealOptions.swift rename to Sources/SkyflowCore/Reveal/RevealOptions.swift index 0857e940..a55aa28a 100644 --- a/Sources/Skyflow/reveal/RevealOptions.swift +++ b/Sources/SkyflowCore/Reveal/RevealOptions.swift @@ -2,13 +2,6 @@ * Copyright (c) 2022 Skyflow */ -// -// File.swift -// -// -// Created by Akhil Anil Mangala on 11/08/21. -// - import Foundation public struct RevealOptions { diff --git a/Sources/SkyflowCore/Reveal/RevealValidation.swift b/Sources/SkyflowCore/Reveal/RevealValidation.swift new file mode 100644 index 00000000..13bd38a4 --- /dev/null +++ b/Sources/SkyflowCore/Reveal/RevealValidation.swift @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2026 Skyflow +*/ + +// Shared element-level validation used by Reveal containers, across all +// backends - identical regardless of which vault API the elements will +// eventually be revealed against. + +import Foundation + +public enum RevealValidation { + public static func validateElements(_ elements: [Label]) -> ErrorCodes? { + if let element = ConversionHelpers.checkElementsAreMounted(elements: elements) as? Label { + return .UNMOUNTED_REVEAL_ELEMENT(value: element.revealInput.token) + } + for element in elements { + if element.errorTriggered { + return .ERROR_TRIGGERED(value: element.triggeredErrorMessage) + } + if element.getToken().isEmpty { + return .EMPTY_TOKEN_ID() + } + } + return nil + } +} diff --git a/Sources/Skyflow/reveal/SkyflowLabelView.swift b/Sources/SkyflowCore/Reveal/SkyflowLabelView.swift similarity index 81% rename from Sources/Skyflow/reveal/SkyflowLabelView.swift rename to Sources/SkyflowCore/Reveal/SkyflowLabelView.swift index 9cebc71d..e9f01234 100644 --- a/Sources/Skyflow/reveal/SkyflowLabelView.swift +++ b/Sources/SkyflowCore/Reveal/SkyflowLabelView.swift @@ -8,14 +8,14 @@ import Foundation import UIKit public class SkyflowLabelView: UIView { - internal var label = FormatLabel(frame: .zero) - internal var revealInput: RevealElementInput! - internal var options: RevealElementOptions! - internal var horizontalConstraints = [NSLayoutConstraint]() + public var label = FormatLabel(frame: .zero) + public var revealInput: RevealElementInput! + public var options: RevealElementOptions! + public var horizontalConstraints = [NSLayoutConstraint]() - internal var verticalConstraint = [NSLayoutConstraint]() + public var verticalConstraint = [NSLayoutConstraint]() - internal func setTextPaddings() { + public func setTextPaddings() { NSLayoutConstraint.deactivate(verticalConstraint) NSLayoutConstraint.deactivate(horizontalConstraints) @@ -35,13 +35,13 @@ public class SkyflowLabelView: UIView { self.layoutIfNeeded() } - internal var padding = UIEdgeInsets.zero { + public var padding = UIEdgeInsets.zero { didSet { setTextPaddings() } } - internal var font: UIFont? { + public var font: UIFont? { get { return label.font } @@ -50,7 +50,7 @@ public class SkyflowLabelView: UIView { } } - internal var textColor: UIColor? { + public var textColor: UIColor? { get { return label.textColor } @@ -59,7 +59,7 @@ public class SkyflowLabelView: UIView { } } - internal var textAlignment: NSTextAlignment { + public var textAlignment: NSTextAlignment { get { return label.textAlignment } @@ -68,7 +68,7 @@ public class SkyflowLabelView: UIView { } } - internal var cornerRadius: CGFloat { + public var cornerRadius: CGFloat { get { return layer.cornerRadius } @@ -78,7 +78,7 @@ public class SkyflowLabelView: UIView { } } - internal var borderWidth: CGFloat { + public var borderWidth: CGFloat { get { return layer.borderWidth } @@ -87,7 +87,7 @@ public class SkyflowLabelView: UIView { } } - internal var borderColor: UIColor? { + public var borderColor: UIColor? { get { guard let cgcolor = layer.borderColor else { return nil @@ -99,22 +99,22 @@ public class SkyflowLabelView: UIView { } } - internal init(input: RevealElementInput, options: RevealElementOptions) { + public init(input: RevealElementInput, options: RevealElementOptions) { super.init(frame: CGRect()) self.revealInput = input self.options = options buildLabel() } - override internal init(frame: CGRect) { + override public init(frame: CGRect) { super.init(frame: frame) } - required internal init?(coder aDecoder: NSCoder) { + required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } - internal func updateVal(value: String, actualValue: String?) { + public func updateVal(value: String, actualValue: String?) { self.label.secureText = value if options.enableCopy == true && actualValue != nil { self.label.copyAfterReveal = true @@ -122,7 +122,7 @@ public class SkyflowLabelView: UIView { } } - internal func buildLabel() { + public func buildLabel() { self.label.isCopyingEnabled = true self.label.shouldUseLongPressGestureRecognizer = true self.label.secureText = self.revealInput.altText.isEmpty ? self.revealInput.token : self.revealInput.altText @@ -137,7 +137,7 @@ public class SkyflowLabelView: UIView { self.padding = revealInput.inputStyles?.base?.padding ?? .zero } - internal func updateStyle() { + public func updateStyle() { let style = revealInput.inputStyles?.invalid let fallbackStyle = revealInput.inputStyles?.base @@ -148,7 +148,7 @@ public class SkyflowLabelView: UIView { self.borderWidth = style?.borderWidth ?? fallbackStyle?.borderWidth ?? 0 } - internal func getValue() -> String { + public func getValue() -> String { return self.revealInput.token } diff --git a/Sources/Skyflow/reveal/UILabel+Copyable.swift b/Sources/SkyflowCore/Reveal/UILabel+Copyable.swift similarity index 96% rename from Sources/Skyflow/reveal/UILabel+Copyable.swift rename to Sources/SkyflowCore/Reveal/UILabel+Copyable.swift index 95e67dcf..2a247f47 100644 --- a/Sources/Skyflow/reveal/UILabel+Copyable.swift +++ b/Sources/SkyflowCore/Reveal/UILabel+Copyable.swift @@ -57,7 +57,7 @@ public extension UILabel { } } - /// Used to enable/disable the internal long press gesture recognizer. Defaults to `true`. + /// Used to enable/disable the public long press gesture recognizer. Defaults to `true`. @IBInspectable var shouldUseLongPressGestureRecognizer: Bool { set { objc_setAssociatedObject(self, &AssociatedKeys.shouldUseLongPressGestureRecognizer, newValue, .OBJC_ASSOCIATION_ASSIGN) @@ -161,12 +161,12 @@ public extension UILabel { } } - @objc internal func copyIconTapped(_ sender: UITapGestureRecognizer) { + @objc public func copyIconTapped(_ sender: UITapGestureRecognizer) { // Copy text when the copy icon is tapped copy(sender) } - @objc internal func longPressGestureRecognized(gestureRecognizer: UIGestureRecognizer) { + @objc public func longPressGestureRecognized(gestureRecognizer: UIGestureRecognizer) { if gestureRecognizer === longPressGestureRecognizer && gestureRecognizer.state == .began { becomeFirstResponder() diff --git a/Sources/Skyflow/utils/DictionaryExtension.swift b/Sources/SkyflowCore/Utils/DictionaryExtension.swift similarity index 96% rename from Sources/Skyflow/utils/DictionaryExtension.swift rename to Sources/SkyflowCore/Utils/DictionaryExtension.swift index 2612e79d..8949e86d 100644 --- a/Sources/Skyflow/utils/DictionaryExtension.swift +++ b/Sources/SkyflowCore/Utils/DictionaryExtension.swift @@ -12,7 +12,7 @@ import Foundation extension Dictionary { - subscript(keyPath keyPath: String) -> Any? { + public subscript(keyPath keyPath: String) -> Any? { get { guard let keyPath = Dictionary.keyPathKeys(forKeyPath: keyPath) else { return nil } diff --git a/Sources/Skyflow/utils/FetchMetrices.swift b/Sources/SkyflowCore/Utils/FetchMetrices.swift similarity index 87% rename from Sources/Skyflow/utils/FetchMetrices.swift rename to Sources/SkyflowCore/Utils/FetchMetrices.swift index 82cd9990..015cd02f 100644 --- a/Sources/Skyflow/utils/FetchMetrices.swift +++ b/Sources/SkyflowCore/Utils/FetchMetrices.swift @@ -8,9 +8,11 @@ import Foundation import UIKit -internal class FetchMetrices { - - internal func getDeviceDetails() -> [String: Any] { +public class FetchMetrices { + + public init() {} + + public func getDeviceDetails() -> [String: Any] { var deviceDetails: [String: Any] = [:] do { let currentDevice = UIDevice.current @@ -31,7 +33,7 @@ internal class FetchMetrices { } - internal func getMetrices() -> [String: Any]{ + public func getMetrices() -> [String: Any]{ let details = getDeviceDetails() let deviceDetails = [ "sdk_name_version": details["sdk_name_version"] , diff --git a/Sources/Skyflow/utils/StringExtension.swift b/Sources/SkyflowCore/Utils/StringExtension.swift similarity index 100% rename from Sources/Skyflow/utils/StringExtension.swift rename to Sources/SkyflowCore/Utils/StringExtension.swift diff --git a/Sources/SkyflowFlowVault/Client.swift b/Sources/SkyflowFlowVault/Client.swift new file mode 100644 index 00000000..1913fd8a --- /dev/null +++ b/Sources/SkyflowFlowVault/Client.swift @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2026 Skyflow +*/ + +// Implementation of SkyflowFlowVault Client class + +import Foundation +import SkyflowCore + +public class Client { + var vaultID: String + var vaultURL: String + var tokenProvider: TokenProvider + var contextOptions: ContextOptions + + public init(_ skyflowConfig: Configuration) { + self.vaultID = skyflowConfig.vaultID + self.vaultURL = skyflowConfig.vaultURL + self.tokenProvider = skyflowConfig.tokenProvider + self.contextOptions = ContextOptions(logLevel: skyflowConfig.options!.logLevel, env: skyflowConfig.options!.env, interface: .CLIENT) + Log.info(message: .CLIENT_INITIALIZED, contextOptions: self.contextOptions) + } + + public func container(type: T.Type, options: ContainerOptions? = nil) -> Container? { + if T.self == CollectContainer.self { + Log.info(message: .COLLECT_CONTAINER_CREATED, contextOptions: self.contextOptions) + return Container(skyflow: self) + } + if T.self == RevealContainer.self { + Log.info(message: .REVEAL_CONTAINER_CREATED, contextOptions: self.contextOptions) + return Container(skyflow: self) + } + if T.self == ComposableContainer.self { + return Container(skyflow: self, options: options) + } + return nil + } + + // insert/get/getById/detokenize will be implemented against FlowDB's + // actual REST contract once it's available. +} diff --git a/Sources/SkyflowFlowVault/Collect/CollectContainer.swift b/Sources/SkyflowFlowVault/Collect/CollectContainer.swift new file mode 100644 index 00000000..6dca00c4 --- /dev/null +++ b/Sources/SkyflowFlowVault/Collect/CollectContainer.swift @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2026 Skyflow +*/ + +// Implementation of Container Interface for Collect the records + +import Foundation +import SkyflowCore +import UIKit + +public extension Container { + func create(input: CollectElementInput, options: CollectElementOptions? = CollectElementOptions()) -> TextField where T: CollectContainer { + var tempContextOptions = self.skyflow.contextOptions + tempContextOptions.interface = .COLLECT_CONTAINER + let skyflowElement = TextField(input: input, options: options!, contextOptions: tempContextOptions, elements: elements) + elements.append(skyflowElement) + let uuid = NSUUID().uuidString + skyflowElement.uuid = uuid + Log.info(message: .CREATED_ELEMENT, values: [input.label == "" ? "collect" : input.label], contextOptions: tempContextOptions) + return skyflowElement + } + + func collect(callback: Callback, options: CollectOptions? = CollectOptions()) where T: CollectContainer { + var tempContextOptions = self.skyflow.contextOptions + tempContextOptions.interface = .COLLECT_CONTAINER + if self.skyflow.vaultID.isEmpty { + let errorCode = ErrorCodes.EMPTY_VAULT_ID() + return callback.onFailure(errorCode.getErrorObject(contextOptions: tempContextOptions)) + } + if self.skyflow.vaultURL.isEmpty { + let errorCode = ErrorCodes.EMPTY_VAULT_URL() + return callback.onFailure(errorCode.getErrorObject(contextOptions: tempContextOptions)) + } + Log.info(message: .VALIDATE_COLLECT_RECORDS, contextOptions: tempContextOptions) + + let (elementError, errors) = CollectValidation.validateElements(self.elements) + if let elementError = elementError { + callback.onFailure(elementError.getErrorObject(contextOptions: tempContextOptions)) + return + } + if errors != "" { + callback.onFailure(NSError(domain: "", code: 400, userInfo: [NSLocalizedDescriptionKey: errors])) + return + } + + // TODO: build the FlowDB request payload and submit it via FlowDB's + // vault API once that contract is available. + callback.onFailure(notImplementedError("collect()")) + } +} diff --git a/Sources/SkyflowFlowVault/Composable/ComposableContainer.swift b/Sources/SkyflowFlowVault/Composable/ComposableContainer.swift new file mode 100644 index 00000000..c9b04db5 --- /dev/null +++ b/Sources/SkyflowFlowVault/Composable/ComposableContainer.swift @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2026 Skyflow +*/ + +// Implementation of Composable Container Interface for Collect the records + +import Foundation +import SkyflowCore +import UIKit + +public extension Container { + + func create(input: CollectElementInput, options: CollectElementOptions? = CollectElementOptions()) -> TextField where T: ComposableContainer { + var tempContextOptions = self.skyflow.contextOptions + tempContextOptions.interface = .COMPOSABLE_CONTAINER + + let skyflowElement = TextField(input: input, options: options!, contextOptions: tempContextOptions, elements: elements) + elements.append(skyflowElement) + let uuid = NSUUID().uuidString + skyflowElement.uuid = uuid + Log.info(message: .CREATED_ELEMENT, values: [input.label == "" ? "composable" : input.label], contextOptions: tempContextOptions) + return skyflowElement + } + + func on(eventName: EventName, handler: @escaping () -> Void) { + if (eventName == EventName.SUBMIT){ + for element in elements { + element.onSubmitHandler = handler + } + } + } + + func getComposableView() throws -> UIView { + return try ComposableLayout.getComposableView(elements: elements, containerOptions: containerOptions) + } + + func collect(callback: Callback, options: CollectOptions? = CollectOptions()) where T: ComposableContainer { + var tempContextOptions = self.skyflow.contextOptions + tempContextOptions.interface = .COMPOSABLE_CONTAINER + if self.skyflow.vaultID.isEmpty { + let errorCode = ErrorCodes.EMPTY_VAULT_ID() + return callback.onFailure(errorCode.getErrorObject(contextOptions: tempContextOptions)) + } + if self.skyflow.vaultURL.isEmpty { + let errorCode = ErrorCodes.EMPTY_VAULT_URL() + return callback.onFailure(errorCode.getErrorObject(contextOptions: tempContextOptions)) + } + Log.info(message: .VALIDATE_COMPOSABLE_RECORDS, contextOptions: tempContextOptions) + + let (elementError, errors) = CollectValidation.validateElements(self.elements) + if let elementError = elementError { + callback.onFailure(elementError.getErrorObject(contextOptions: tempContextOptions)) + return + } + if errors != "" { + callback.onFailure(NSError(domain: "", code: 400, userInfo: [NSLocalizedDescriptionKey: errors])) + return + } + + // TODO: build the FlowDB request payload and submit it via FlowDB's + // vault API once that contract is available. + callback.onFailure(notImplementedError("collect()")) + } + +} diff --git a/Sources/SkyflowFlowVault/Configuration.swift b/Sources/SkyflowFlowVault/Configuration.swift new file mode 100644 index 00000000..8848ae9b --- /dev/null +++ b/Sources/SkyflowFlowVault/Configuration.swift @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2026 Skyflow +*/ + +// Configure SkyflowFlowVault, implementation for SkyflowFlowVault.Configuration + +import Foundation +import SkyflowCore + +public struct Configuration { + var vaultID: String + var vaultURL: String + var tokenProvider: TokenProvider + var options: Options? + + public init(vaultID: String = "", vaultURL: String = "", tokenProvider: TokenProvider, options: Options? = Options()) { + self.vaultID = vaultID + self.vaultURL = vaultURL + self.tokenProvider = tokenProvider + self.options = options + } +} diff --git a/Sources/SkyflowFlowVault/Core/Container/Container.swift b/Sources/SkyflowFlowVault/Core/Container/Container.swift new file mode 100644 index 00000000..12d35d7b --- /dev/null +++ b/Sources/SkyflowFlowVault/Core/Container/Container.swift @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2026 Skyflow +*/ + +import Foundation +import SkyflowCore + +public class Container { + internal var skyflow: Client + internal var elements: [TextField] = [] + internal var revealElements: [Label] = [] + internal var containerOptions: ContainerOptions? = nil + + internal init(skyflow: Client) { + self.skyflow = skyflow + } + internal init(skyflow: Client, options: ContainerOptions? = nil){ + self.containerOptions = options + self.skyflow = skyflow + } +} diff --git a/Sources/SkyflowFlowVault/Core/NotImplemented.swift b/Sources/SkyflowFlowVault/Core/NotImplemented.swift new file mode 100644 index 00000000..a55ea499 --- /dev/null +++ b/Sources/SkyflowFlowVault/Core/NotImplemented.swift @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2026 Skyflow +*/ + +// Placeholder used by collect()/reveal() until they're implemented against +// FlowDB's actual REST contract. + +import Foundation + +func notImplementedError(_ operation: String) -> NSError { + return NSError(domain: "SkyflowFlowVault", code: 501, userInfo: [ + NSLocalizedDescriptionKey: "\(operation) is not yet implemented for FlowDB." + ]) +} diff --git a/Sources/SkyflowFlowVault/Init.swift b/Sources/SkyflowFlowVault/Init.swift new file mode 100644 index 00000000..7b572c3a --- /dev/null +++ b/Sources/SkyflowFlowVault/Init.swift @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2026 Skyflow +*/ + +// Initialize SkyflowFlowVault, SkyflowFlowVault.initialize + +import Foundation +import SkyflowCore + +public func initialize(_ skyflowConfig: Configuration) -> Client { + return Client(skyflowConfig) +} diff --git a/Sources/SkyflowFlowVault/Reveal/RevealContainer.swift b/Sources/SkyflowFlowVault/Reveal/RevealContainer.swift new file mode 100644 index 00000000..b0e1940a --- /dev/null +++ b/Sources/SkyflowFlowVault/Reveal/RevealContainer.swift @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2026 Skyflow +*/ + +/* + * Implementation of Reveal container which helps in creating + * the reveal element, revealing the tokenized or redacted text + */ + +import Foundation +import SkyflowCore + +public extension Container { + func create(input: RevealElementInput, options: RevealElementOptions? = RevealElementOptions()) -> Label where T: RevealContainer { + var tempContextOptions = self.skyflow.contextOptions + tempContextOptions.interface = .REVEAL_CONTAINER + let revealElement = Label(input: input, options: options!) + revealElements.append(revealElement) + let uuid = NSUUID().uuidString + revealElement.uuid = uuid + Log.info(message: .CREATED_ELEMENT, values: [input.label == "" ? "reveal" : input.label], contextOptions: tempContextOptions) + return revealElement + } + + func reveal(callback: Callback, options: RevealOptions? = RevealOptions()) where T: RevealContainer { + var tempContextOptions = self.skyflow.contextOptions + tempContextOptions.interface = .REVEAL_CONTAINER + if self.skyflow.vaultID.isEmpty { + let errorCode = ErrorCodes.EMPTY_VAULT_ID() + return callback.onFailure(errorCode.getErrorObject(contextOptions: tempContextOptions)) + } + if self.skyflow.vaultURL.isEmpty { + let errorCode = ErrorCodes.EMPTY_VAULT_URL() + return callback.onFailure(errorCode.getErrorObject(contextOptions: tempContextOptions)) + } + Log.info(message: .VALIDATE_REVEAL_RECORDS, contextOptions: tempContextOptions) + if let errorCode = RevealValidation.validateElements(self.revealElements) { + callback.onFailure(errorCode.getErrorObject(contextOptions: tempContextOptions)) + return + } + + // TODO: build the FlowDB detokenize request and submit it via + // FlowDB's vault API once that contract is available. + callback.onFailure(notImplementedError("reveal()")) + } +} diff --git a/Tests/skyflow-iOS-collectTests/DemoImpl.swift b/Tests/skyflow-iOS-collectTests/DemoImpl.swift index 7d3e3f85..b6063e08 100644 --- a/Tests/skyflow-iOS-collectTests/DemoImpl.swift +++ b/Tests/skyflow-iOS-collectTests/DemoImpl.swift @@ -12,6 +12,7 @@ import Foundation import XCTest import Skyflow +import SkyflowCore public class DemoTokenProvider: TokenProvider { public func getBearerToken(_ apiCallback: Callback) { diff --git a/Tests/skyflow-iOS-collectTests/skyflow_iOS_collectTests.swift b/Tests/skyflow-iOS-collectTests/skyflow_iOS_collectTests.swift index 78e42f2c..46f81672 100644 --- a/Tests/skyflow-iOS-collectTests/skyflow_iOS_collectTests.swift +++ b/Tests/skyflow-iOS-collectTests/skyflow_iOS_collectTests.swift @@ -4,6 +4,7 @@ import XCTest @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length final class skyflow_iOS_collectTests: XCTestCase { @@ -198,16 +199,16 @@ final class skyflow_iOS_collectTests: XCTestCase { let collectElement = container?.create(input: collectInput, options: options) - collectElement?.on(eventName: Skyflow.EventName.CHANGE) { state in + collectElement?.on(eventName: EventName.CHANGE) { state in print("state", state) } - collectElement?.on(eventName: Skyflow.EventName.BLUR) { state in + collectElement?.on(eventName: EventName.BLUR) { state in print("state", state) } - collectElement?.on(eventName: Skyflow.EventName.FOCUS) { state in + collectElement?.on(eventName: EventName.FOCUS) { state in print("state", state) } - collectElement?.on(eventName: Skyflow.EventName.READY) { _ in + collectElement?.on(eventName: EventName.READY) { _ in onReadyCalled = true } sleep(1) @@ -611,8 +612,8 @@ final class skyflow_iOS_collectTests: XCTestCase { func testCollectElementSetValueAndClearValueWithCustomFormatting(){ let container = skyflow.container(type: ContainerType.COLLECT, options: nil) - let collectInputfieldInput = Skyflow.CollectElementInput(table: "pii_fields", column: "cardholder_name", label: "input field", placeholder: "card input field", type: Skyflow.ElementType.INPUT_FIELD ) - let requiredOption = Skyflow.CollectElementOptions(required: true, format: "+91 YYYY-YYYY-YYYY YYYY", translation: ["Y": "[0-9]"]) + let collectInputfieldInput = CollectElementInput(table: "pii_fields", column: "cardholder_name", label: "input field", placeholder: "card input field", type: ElementType.INPUT_FIELD ) + let requiredOption = CollectElementOptions(required: true, format: "+91 YYYY-YYYY-YYYY YYYY", translation: ["Y": "[0-9]"]) let collectInputField = container?.create(input: collectInputfieldInput, options: requiredOption ) @@ -633,8 +634,8 @@ final class skyflow_iOS_collectTests: XCTestCase { func testCollectElementSetValueAndClearValueWithCustomFormattingWithEmptyTsanslation(){ let container = skyflow.container(type: ContainerType.COLLECT, options: nil) - let collectInputfieldInput = Skyflow.CollectElementInput(table: "pii_fields", column: "cardholder_name", label: "input field", placeholder: "card input field", type: Skyflow.ElementType.INPUT_FIELD ) - let requiredOption = Skyflow.CollectElementOptions(required: true, format: "+91 YYYY-YYYY-YYYY YYYY", translation: ["Y": ""]) + let collectInputfieldInput = CollectElementInput(table: "pii_fields", column: "cardholder_name", label: "input field", placeholder: "card input field", type: ElementType.INPUT_FIELD ) + let requiredOption = CollectElementOptions(required: true, format: "+91 YYYY-YYYY-YYYY YYYY", translation: ["Y": ""]) let collectInputField = container?.create(input: collectInputfieldInput, options: requiredOption ) @@ -655,8 +656,8 @@ final class skyflow_iOS_collectTests: XCTestCase { func testCollectElementSetValueAndClearValueWithCustomFormattingWithoutTranslation(){ let container = skyflow.container(type: ContainerType.COLLECT, options: nil) - let collectInputfieldInput = Skyflow.CollectElementInput(table: "pii_fields", column: "cardholder_name", label: "input field", placeholder: "card input field", type: Skyflow.ElementType.INPUT_FIELD ) - let requiredOption = Skyflow.CollectElementOptions(required: true, format: "+91 YYYY-YYYY-YYYY YYYY") + let collectInputfieldInput = CollectElementInput(table: "pii_fields", column: "cardholder_name", label: "input field", placeholder: "card input field", type: ElementType.INPUT_FIELD ) + let requiredOption = CollectElementOptions(required: true, format: "+91 YYYY-YYYY-YYYY YYYY") let collectInputField = container?.create(input: collectInputfieldInput, options: requiredOption ) @@ -677,8 +678,8 @@ final class skyflow_iOS_collectTests: XCTestCase { func testCollectElementSetValueAndClearValueWithoutCustomFormatting(){ let container = skyflow.container(type: ContainerType.COLLECT, options: nil) - let collectInputfieldInput = Skyflow.CollectElementInput(table: "pii_fields", column: "cardholder_name", label: "input field", placeholder: "card input field", type: Skyflow.ElementType.INPUT_FIELD ) - let requiredOption = Skyflow.CollectElementOptions(required: true) + let collectInputfieldInput = CollectElementInput(table: "pii_fields", column: "cardholder_name", label: "input field", placeholder: "card input field", type: ElementType.INPUT_FIELD ) + let requiredOption = CollectElementOptions(required: true) let collectInputField = container?.create(input: collectInputfieldInput, options: requiredOption ) @@ -699,8 +700,8 @@ final class skyflow_iOS_collectTests: XCTestCase { func testCollectElementSetValueAndClearValueWithoutCustomFormattingForCardNumber(){ let container = skyflow.container(type: ContainerType.COLLECT, options: nil) - let collectInputfieldInput = Skyflow.CollectElementInput(table: "pii_fields", column: "cardholder_name", label: "input field", placeholder: "card input field", type: Skyflow.ElementType.CARD_NUMBER ) - let requiredOption = Skyflow.CollectElementOptions(required: true, format: "XXXX-XXXX-XXXX-XXXX") + let collectInputfieldInput = CollectElementInput(table: "pii_fields", column: "cardholder_name", label: "input field", placeholder: "card input field", type: ElementType.CARD_NUMBER ) + let requiredOption = CollectElementOptions(required: true, format: "XXXX-XXXX-XXXX-XXXX") let collectInputField = container?.create(input: collectInputfieldInput, options: requiredOption ) diff --git a/Tests/skyflow-iOS-composableTests/DemoImpl.swift b/Tests/skyflow-iOS-composableTests/DemoImpl.swift index 281305b8..d12bca0b 100644 --- a/Tests/skyflow-iOS-composableTests/DemoImpl.swift +++ b/Tests/skyflow-iOS-composableTests/DemoImpl.swift @@ -8,6 +8,7 @@ import Foundation import XCTest import Skyflow +import SkyflowCore public class DemoTokenProvider: TokenProvider { public func getBearerToken(_ apiCallback: Callback) { diff --git a/Tests/skyflow-iOS-composableTests/skyflow_iOS_composableEelementsTests.swift b/Tests/skyflow-iOS-composableTests/skyflow_iOS_composableEelementsTests.swift index a94cd297..27b2c0c3 100644 --- a/Tests/skyflow-iOS-composableTests/skyflow_iOS_composableEelementsTests.swift +++ b/Tests/skyflow-iOS-composableTests/skyflow_iOS_composableEelementsTests.swift @@ -7,6 +7,7 @@ import XCTest @testable import Skyflow +@testable import SkyflowCore final class skyflow_iOS_composableEelementsTests: XCTestCase { var skyflow: Client! @@ -142,20 +143,20 @@ final class skyflow_iOS_composableEelementsTests: XCTestCase { let collectElement = container?.create(input: collectInput, options: options) - collectElement?.on(eventName: Skyflow.EventName.CHANGE) { state in + collectElement?.on(eventName: EventName.CHANGE) { state in print("state", state) onChangeCalled = true } - collectElement?.on(eventName: Skyflow.EventName.BLUR) { state in + collectElement?.on(eventName: EventName.BLUR) { state in print("state", state) onBlurCalled = true } - collectElement?.on(eventName: Skyflow.EventName.FOCUS) { state in + collectElement?.on(eventName: EventName.FOCUS) { state in print("state", state) onFocusCalled = true } - collectElement?.on(eventName: Skyflow.EventName.READY) { _ in + collectElement?.on(eventName: EventName.READY) { _ in onReadyCalled = true } sleep(1) diff --git a/Tests/skyflow-iOS-elementTests/CollectElementOptionsTests.swift b/Tests/skyflow-iOS-elementTests/CollectElementOptionsTests.swift index cde1fe96..e9864e2d 100644 --- a/Tests/skyflow-iOS-elementTests/CollectElementOptionsTests.swift +++ b/Tests/skyflow-iOS-elementTests/CollectElementOptionsTests.swift @@ -7,6 +7,7 @@ import XCTest @testable import Skyflow +@testable import SkyflowCore class CollectElementOptionsTests: XCTestCase { diff --git a/Tests/skyflow-iOS-elementTests/DemoImpl.swift b/Tests/skyflow-iOS-elementTests/DemoImpl.swift index 71cb4d32..c859ff4e 100644 --- a/Tests/skyflow-iOS-elementTests/DemoImpl.swift +++ b/Tests/skyflow-iOS-elementTests/DemoImpl.swift @@ -5,6 +5,7 @@ import Foundation import XCTest import Skyflow +import SkyflowCore public class DemoTokenProvider: TokenProvider { public func getBearerToken(_ apiCallback: Callback) { diff --git a/Tests/skyflow-iOS-elementTests/InputFormattingTests.swift b/Tests/skyflow-iOS-elementTests/InputFormattingTests.swift index 0975792f..e71d01c3 100644 --- a/Tests/skyflow-iOS-elementTests/InputFormattingTests.swift +++ b/Tests/skyflow-iOS-elementTests/InputFormattingTests.swift @@ -5,6 +5,7 @@ import XCTest import Foundation @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length class InputFormattingTests: XCTestCase { diff --git a/Tests/skyflow-iOS-elementTests/TextFieldDelegateTests.swift b/Tests/skyflow-iOS-elementTests/TextFieldDelegateTests.swift index 03bb05c1..e99f6283 100644 --- a/Tests/skyflow-iOS-elementTests/TextFieldDelegateTests.swift +++ b/Tests/skyflow-iOS-elementTests/TextFieldDelegateTests.swift @@ -8,6 +8,7 @@ import XCTest import Foundation @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length diff --git a/Tests/skyflow-iOS-elementTests/skyflow_iOS_containerTests.swift b/Tests/skyflow-iOS-elementTests/skyflow_iOS_containerTests.swift index 8a68e011..0ffe5e23 100644 --- a/Tests/skyflow-iOS-elementTests/skyflow_iOS_containerTests.swift +++ b/Tests/skyflow-iOS-elementTests/skyflow_iOS_containerTests.swift @@ -5,6 +5,7 @@ import XCTest @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length class skyflow_iOS_containerTests: XCTestCase { diff --git a/Tests/skyflow-iOS-elementTests/skyflow_iOS_elementTests.swift b/Tests/skyflow-iOS-elementTests/skyflow_iOS_elementTests.swift index b6e84385..419ac117 100644 --- a/Tests/skyflow-iOS-elementTests/skyflow_iOS_elementTests.swift +++ b/Tests/skyflow-iOS-elementTests/skyflow_iOS_elementTests.swift @@ -6,6 +6,7 @@ import XCTest import UIKit @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length class skyflow_iOS_elementTests: XCTestCase { diff --git a/Tests/skyflow-iOS-errorTests/DemoImpl.swift b/Tests/skyflow-iOS-errorTests/DemoImpl.swift index 71cb4d32..c859ff4e 100644 --- a/Tests/skyflow-iOS-errorTests/DemoImpl.swift +++ b/Tests/skyflow-iOS-errorTests/DemoImpl.swift @@ -5,6 +5,7 @@ import Foundation import XCTest import Skyflow +import SkyflowCore public class DemoTokenProvider: TokenProvider { public func getBearerToken(_ apiCallback: Callback) { diff --git a/Tests/skyflow-iOS-errorTests/GatewayImpl.swift b/Tests/skyflow-iOS-errorTests/GatewayImpl.swift index c163759e..ef02b539 100644 --- a/Tests/skyflow-iOS-errorTests/GatewayImpl.swift +++ b/Tests/skyflow-iOS-errorTests/GatewayImpl.swift @@ -5,6 +5,7 @@ import Foundation import XCTest import Skyflow +import SkyflowCore public class ConnectionTokenProvider: TokenProvider { public func getBearerToken(_ apiCallback: Callback) { diff --git a/Tests/skyflow-iOS-errorTests/Skyflow_iOS_collectErrorTests.swift b/Tests/skyflow-iOS-errorTests/Skyflow_iOS_collectErrorTests.swift index 3df67f16..d4a1fe37 100644 --- a/Tests/skyflow-iOS-errorTests/Skyflow_iOS_collectErrorTests.swift +++ b/Tests/skyflow-iOS-errorTests/Skyflow_iOS_collectErrorTests.swift @@ -13,6 +13,7 @@ import XCTest import XCTest @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length final class Skyflow_iOS_collectErrorTests: XCTestCase { diff --git a/Tests/skyflow-iOS-errorTests/Skyflow_iOS_generalErrorTests.swift b/Tests/skyflow-iOS-errorTests/Skyflow_iOS_generalErrorTests.swift index c5dfc98d..3ccafcf4 100644 --- a/Tests/skyflow-iOS-errorTests/Skyflow_iOS_generalErrorTests.swift +++ b/Tests/skyflow-iOS-errorTests/Skyflow_iOS_generalErrorTests.swift @@ -11,6 +11,7 @@ import XCTest @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length class Skyflow_iOS_generalErrorTests: XCTestCase { @@ -104,7 +105,7 @@ class Skyflow_iOS_generalErrorTests: XCTestCase { XCTAssert(textRect.contains(CGPoint(x: 1, y: 2))) XCTAssert(placeholderRect.contains(CGPoint(x: 4, y: 3))) XCTAssert(editingRect.contains(CGPoint(x: 2, y: 4))) - XCTAssertEqual(textfield.description, "Skyflow.FormatTextField") + XCTAssertEqual(textfield.description, "SkyflowCore.FormatTextField") } func testState() { diff --git a/Tests/skyflow-iOS-errorTests/Skyflow_iOS_revealErrorTests.swift b/Tests/skyflow-iOS-errorTests/Skyflow_iOS_revealErrorTests.swift index 038716e6..87977a4c 100644 --- a/Tests/skyflow-iOS-errorTests/Skyflow_iOS_revealErrorTests.swift +++ b/Tests/skyflow-iOS-errorTests/Skyflow_iOS_revealErrorTests.swift @@ -12,6 +12,7 @@ import Foundation import XCTest @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length class Skyflow_iOS_revealErrorTests: XCTestCase { diff --git a/Tests/skyflow-iOS-getByIdTests/DemoImpl.swift b/Tests/skyflow-iOS-getByIdTests/DemoImpl.swift index 4b656b88..698dc696 100644 --- a/Tests/skyflow-iOS-getByIdTests/DemoImpl.swift +++ b/Tests/skyflow-iOS-getByIdTests/DemoImpl.swift @@ -5,6 +5,7 @@ import Foundation import XCTest import Skyflow +import SkyflowCore public class DemoTokenProvider: TokenProvider { public func getBearerToken(_ apiCallback: Callback) { diff --git a/Tests/skyflow-iOS-getByIdTests/skyflow_iOS_getByIdTests.swift b/Tests/skyflow-iOS-getByIdTests/skyflow_iOS_getByIdTests.swift index 315d8832..568b5a5a 100644 --- a/Tests/skyflow-iOS-getByIdTests/skyflow_iOS_getByIdTests.swift +++ b/Tests/skyflow-iOS-getByIdTests/skyflow_iOS_getByIdTests.swift @@ -12,6 +12,7 @@ import Foundation import XCTest @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length class skyflow_iOS_getByIdTests: XCTestCase { @@ -49,14 +50,14 @@ class skyflow_iOS_getByIdTests: XCTestCase { ProcessInfo.processInfo.environment["TEST_SKYFLOW_ID3"]! ], "table": "persons", - "redaction": Skyflow.RedactionType.PLAIN_TEXT + "redaction": RedactionType.PLAIN_TEXT ], [ "ids": [ ProcessInfo.processInfo.environment["TEST_SKYFLOW_ID3"]! ], "table": "persons", - "redaction": Skyflow.RedactionType.PLAIN_TEXT + "redaction": RedactionType.PLAIN_TEXT ] ] ] diff --git a/Tests/skyflow-iOS-getTests/DemoImpl.swift b/Tests/skyflow-iOS-getTests/DemoImpl.swift index 47e94797..997f488f 100644 --- a/Tests/skyflow-iOS-getTests/DemoImpl.swift +++ b/Tests/skyflow-iOS-getTests/DemoImpl.swift @@ -5,6 +5,7 @@ import Foundation import XCTest import Skyflow +import SkyflowCore public class DemoTokenProvider: TokenProvider { public func getBearerToken(_ apiCallback: Callback) { diff --git a/Tests/skyflow-iOS-getTests/skyflow_iOS_getTests.swift b/Tests/skyflow-iOS-getTests/skyflow_iOS_getTests.swift index eabf5a0b..9d083354 100644 --- a/Tests/skyflow-iOS-getTests/skyflow_iOS_getTests.swift +++ b/Tests/skyflow-iOS-getTests/skyflow_iOS_getTests.swift @@ -8,6 +8,7 @@ import Foundation import XCTest @testable import Skyflow +@testable import SkyflowCore class skyflow_iOS_getTests: XCTestCase { var skyflow: Client! @@ -44,14 +45,14 @@ class skyflow_iOS_getTests: XCTestCase { "3" ], "table": "persons", - "redaction": Skyflow.RedactionType.PLAIN_TEXT + "redaction": RedactionType.PLAIN_TEXT ], [ "ids": [ "1" ], "table": "persons", - "redaction": Skyflow.RedactionType.PLAIN_TEXT + "redaction": RedactionType.PLAIN_TEXT ] ] ] @@ -88,14 +89,14 @@ class skyflow_iOS_getTests: XCTestCase { "3" ], "table": "persons", - "redaction": Skyflow.RedactionType.PLAIN_TEXT + "redaction": RedactionType.PLAIN_TEXT ], [ "ids": [ "1" ], "table": "persons", - "redaction": Skyflow.RedactionType.PLAIN_TEXT + "redaction": RedactionType.PLAIN_TEXT ] ] ] diff --git a/Tests/skyflow-iOS-getTests/skyflow_iOS_validateGetRecordTest.swift b/Tests/skyflow-iOS-getTests/skyflow_iOS_validateGetRecordTest.swift index 29d9157a..1f887851 100644 --- a/Tests/skyflow-iOS-getTests/skyflow_iOS_validateGetRecordTest.swift +++ b/Tests/skyflow-iOS-getTests/skyflow_iOS_validateGetRecordTest.swift @@ -8,6 +8,7 @@ import Foundation import XCTest @testable import Skyflow +@testable import SkyflowCore class skyflow_iOS_ValidateGetRecordTest: XCTestCase { var skyflow: Client! diff --git a/Tests/skyflow-iOS-revealTests/DemoImpl.swift b/Tests/skyflow-iOS-revealTests/DemoImpl.swift index 73208cc0..65818ba4 100644 --- a/Tests/skyflow-iOS-revealTests/DemoImpl.swift +++ b/Tests/skyflow-iOS-revealTests/DemoImpl.swift @@ -5,6 +5,7 @@ import Foundation import XCTest import Skyflow +import SkyflowCore public class DemoTokenProvider: TokenProvider { public func getBearerToken(_ apiCallback: Callback) { diff --git a/Tests/skyflow-iOS-revealTests/RevealElementOptionsTests.swift b/Tests/skyflow-iOS-revealTests/RevealElementOptionsTests.swift index 32d6688b..27d706e3 100644 --- a/Tests/skyflow-iOS-revealTests/RevealElementOptionsTests.swift +++ b/Tests/skyflow-iOS-revealTests/RevealElementOptionsTests.swift @@ -9,6 +9,7 @@ import Foundation import XCTest @testable import Skyflow +@testable import SkyflowCore class RevealElementOptionsTests: XCTestCase { diff --git a/Tests/skyflow-iOS-revealTests/RevealSkyflowLabelViewTests.swift b/Tests/skyflow-iOS-revealTests/RevealSkyflowLabelViewTests.swift index 5bc478bb..5b637e77 100644 --- a/Tests/skyflow-iOS-revealTests/RevealSkyflowLabelViewTests.swift +++ b/Tests/skyflow-iOS-revealTests/RevealSkyflowLabelViewTests.swift @@ -9,6 +9,7 @@ import Foundation import XCTest @testable import Skyflow +@testable import SkyflowCore class RevealSkyflowLabelViewTests: XCTestCase { @@ -25,15 +26,15 @@ class RevealSkyflowLabelViewTests: XCTestCase { } func testSkyflowLabelViewUpdateValMethodWithFormatEmptyTranslation(){ - let config = Skyflow.Configuration(vaultID: "vault id", vaultURL:"vault url", tokenProvider: DemoTokenProvider(), options: Skyflow.Options(env: Skyflow.Env.DEV)) + let config = Skyflow.Configuration(vaultID: "vault id", vaultURL:"vault url", tokenProvider: DemoTokenProvider(), options: Options(env: Env.DEV)) // Initialize skyflow client let skyflowClient = Skyflow.initialize(config) // Create a Reveal Container - let container = skyflowClient.container(type: Skyflow.ContainerType.REVEAL) + let container = skyflowClient.container(type: ContainerType.REVEAL) // Create Reveal Elements - let cardNumberInput = Skyflow.RevealElementInput( + let cardNumberInput = RevealElementInput( token: "b63ec4e0-bbad-4e43-96e6-6bd50f483f75", label: "cardnumber", altText: "XXXX XXXX XXXX XXXX" diff --git a/Tests/skyflow-iOS-revealTests/skyflow_iOS_revealTests.swift b/Tests/skyflow-iOS-revealTests/skyflow_iOS_revealTests.swift index 101264b8..4ad7b6f6 100644 --- a/Tests/skyflow-iOS-revealTests/skyflow_iOS_revealTests.swift +++ b/Tests/skyflow-iOS-revealTests/skyflow_iOS_revealTests.swift @@ -6,6 +6,7 @@ import Foundation import XCTest @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length class skyflow_iOS_revealTests: XCTestCase { diff --git a/Tests/skyflow-iOS-scenarioTests/ClientScenario.swift b/Tests/skyflow-iOS-scenarioTests/ClientScenario.swift index a0189fdb..7ca3d311 100644 --- a/Tests/skyflow-iOS-scenarioTests/ClientScenario.swift +++ b/Tests/skyflow-iOS-scenarioTests/ClientScenario.swift @@ -4,6 +4,7 @@ import Foundation @testable import Skyflow +@testable import SkyflowCore enum MethodsUnderTest { case PUREINSERT diff --git a/Tests/skyflow-iOS-scenarioTests/DemoImpl.swift b/Tests/skyflow-iOS-scenarioTests/DemoImpl.swift index 29e985e0..b0c4a9cc 100644 --- a/Tests/skyflow-iOS-scenarioTests/DemoImpl.swift +++ b/Tests/skyflow-iOS-scenarioTests/DemoImpl.swift @@ -5,6 +5,7 @@ import Foundation import XCTest import Skyflow +import SkyflowCore public class DemoTokenProvider: TokenProvider { public func getBearerToken(_ apiCallback: Callback) { diff --git a/Tests/skyflow-iOS-scenarioTests/DetokenizeScenario.swift b/Tests/skyflow-iOS-scenarioTests/DetokenizeScenario.swift index 27fab3d2..885b7022 100644 --- a/Tests/skyflow-iOS-scenarioTests/DetokenizeScenario.swift +++ b/Tests/skyflow-iOS-scenarioTests/DetokenizeScenario.swift @@ -4,6 +4,7 @@ import Foundation @testable import Skyflow +@testable import SkyflowCore class DetokenizeScenario { private var tokens: [String] = [] diff --git a/Tests/skyflow-iOS-scenarioTests/GetByIdScenario.swift b/Tests/skyflow-iOS-scenarioTests/GetByIdScenario.swift index aec14d48..aee0b8a4 100644 --- a/Tests/skyflow-iOS-scenarioTests/GetByIdScenario.swift +++ b/Tests/skyflow-iOS-scenarioTests/GetByIdScenario.swift @@ -4,6 +4,7 @@ import Foundation @testable import Skyflow +@testable import SkyflowCore class GetByIdScenario { private var records: [String: [[String: Any]]] = [:] diff --git a/Tests/skyflow-iOS-scenarioTests/InsertScenario.swift b/Tests/skyflow-iOS-scenarioTests/InsertScenario.swift index 1c77d40f..148a6e18 100644 --- a/Tests/skyflow-iOS-scenarioTests/InsertScenario.swift +++ b/Tests/skyflow-iOS-scenarioTests/InsertScenario.swift @@ -5,6 +5,7 @@ import Foundation @testable import Skyflow +@testable import SkyflowCore class InsertScenario { private var records: [String: [[String: Any]]] = [:] diff --git a/Tests/skyflow-iOS-scenarioTests/skyflow_iOS_detokenizeScenarioTests.swift b/Tests/skyflow-iOS-scenarioTests/skyflow_iOS_detokenizeScenarioTests.swift index 5534cdf6..e2277ac5 100644 --- a/Tests/skyflow-iOS-scenarioTests/skyflow_iOS_detokenizeScenarioTests.swift +++ b/Tests/skyflow-iOS-scenarioTests/skyflow_iOS_detokenizeScenarioTests.swift @@ -5,6 +5,7 @@ // swiftlint:disable file_length import XCTest @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length final class skyflow_iOS_detokenizeScenarioTests: XCTestCase { diff --git a/Tests/skyflow-iOS-scenarioTests/skyflow_iOS_getByIdScenarioTests.swift b/Tests/skyflow-iOS-scenarioTests/skyflow_iOS_getByIdScenarioTests.swift index 2b5e9a7b..856f7431 100644 --- a/Tests/skyflow-iOS-scenarioTests/skyflow_iOS_getByIdScenarioTests.swift +++ b/Tests/skyflow-iOS-scenarioTests/skyflow_iOS_getByIdScenarioTests.swift @@ -5,6 +5,7 @@ // swiftlint:disable file_length import XCTest @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length final class skyflow_iOS_getByIdScenarioTests: XCTestCase { diff --git a/Tests/skyflow-iOS-scenarioTests/skyflow_iOS_insertScenarioTests.swift b/Tests/skyflow-iOS-scenarioTests/skyflow_iOS_insertScenarioTests.swift index 5c9cf739..fe95350d 100644 --- a/Tests/skyflow-iOS-scenarioTests/skyflow_iOS_insertScenarioTests.swift +++ b/Tests/skyflow-iOS-scenarioTests/skyflow_iOS_insertScenarioTests.swift @@ -5,6 +5,7 @@ // swiftlint:disable file_length import XCTest @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length final class skyflow_iOS_insertScenarioTests: XCTestCase { diff --git a/Tests/skyflow-iOS-utilTests/DemoImpl.swift b/Tests/skyflow-iOS-utilTests/DemoImpl.swift index e93c1169..dcdc8965 100644 --- a/Tests/skyflow-iOS-utilTests/DemoImpl.swift +++ b/Tests/skyflow-iOS-utilTests/DemoImpl.swift @@ -5,6 +5,7 @@ import Foundation import XCTest import Skyflow +import SkyflowCore public class DemoTokenProvider: TokenProvider { public func getBearerToken(_ apiCallback: Callback) { diff --git a/Tests/skyflow-iOS-utilTests/skyflow_iOS_collectUtilTests.swift b/Tests/skyflow-iOS-utilTests/skyflow_iOS_collectUtilTests.swift index 40bbe132..d9f2f1e9 100644 --- a/Tests/skyflow-iOS-utilTests/skyflow_iOS_collectUtilTests.swift +++ b/Tests/skyflow-iOS-utilTests/skyflow_iOS_collectUtilTests.swift @@ -4,6 +4,7 @@ import XCTest @testable import Skyflow +@testable import SkyflowCore final class skyflow_iOS_collectUtilTests: XCTestCase { diff --git a/Tests/skyflow-iOS-utilTests/skyflow_iOS_getByIdUtilTests.swift b/Tests/skyflow-iOS-utilTests/skyflow_iOS_getByIdUtilTests.swift index 77c97572..26933df9 100644 --- a/Tests/skyflow-iOS-utilTests/skyflow_iOS_getByIdUtilTests.swift +++ b/Tests/skyflow-iOS-utilTests/skyflow_iOS_getByIdUtilTests.swift @@ -5,6 +5,7 @@ // swiftlint:disable file_length import XCTest @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length final class skyflow_iOS_getByIdUtilTests: XCTestCase { diff --git a/Tests/skyflow-iOS-utilTests/skyflow_iOS_getUtilTests.swift b/Tests/skyflow-iOS-utilTests/skyflow_iOS_getUtilTests.swift index bffc6d45..6c73edc3 100644 --- a/Tests/skyflow-iOS-utilTests/skyflow_iOS_getUtilTests.swift +++ b/Tests/skyflow-iOS-utilTests/skyflow_iOS_getUtilTests.swift @@ -7,6 +7,7 @@ import XCTest @testable import Skyflow +@testable import SkyflowCore final class skyflow_iOS_getUtilTests: XCTestCase { diff --git a/Tests/skyflow-iOS-utilTests/skyflow_iOS_insertUtilTests 2.swift b/Tests/skyflow-iOS-utilTests/skyflow_iOS_insertUtilTests 2.swift index e3becb93..8cd45583 100644 --- a/Tests/skyflow-iOS-utilTests/skyflow_iOS_insertUtilTests 2.swift +++ b/Tests/skyflow-iOS-utilTests/skyflow_iOS_insertUtilTests 2.swift @@ -4,6 +4,7 @@ import XCTest @testable import Skyflow +@testable import SkyflowCore final class skyflow_iOS_insertUtilTests: XCTestCase { diff --git a/Tests/skyflow-iOS-utilTests/skyflow_iOS_revealUtilTests.swift b/Tests/skyflow-iOS-utilTests/skyflow_iOS_revealUtilTests.swift index f09f9108..76da7bfa 100644 --- a/Tests/skyflow-iOS-utilTests/skyflow_iOS_revealUtilTests.swift +++ b/Tests/skyflow-iOS-utilTests/skyflow_iOS_revealUtilTests.swift @@ -5,6 +5,7 @@ // swiftlint:disable file_length import XCTest @testable import Skyflow +@testable import SkyflowCore // swiftlint:disable:next type_body_length final class skyflow_iOS_revealUtilTests: XCTestCase { diff --git a/Tests/skyflow-iOS-utilTests/skyflow_iOS_utilTests.swift b/Tests/skyflow-iOS-utilTests/skyflow_iOS_utilTests.swift index 6e872245..7ffab2f4 100644 --- a/Tests/skyflow-iOS-utilTests/skyflow_iOS_utilTests.swift +++ b/Tests/skyflow-iOS-utilTests/skyflow_iOS_utilTests.swift @@ -4,6 +4,7 @@ import XCTest @testable import Skyflow +@testable import SkyflowCore final class skyflow_iOS_utilTests: XCTestCase { override func setUp() {