diff --git a/Sources/Skyflow/ProcessMarkdown.swift b/Sources/Skyflow/ProcessMarkdown.swift new file mode 100644 index 00000000..d9fce2ef --- /dev/null +++ b/Sources/Skyflow/ProcessMarkdown.swift @@ -0,0 +1,200 @@ +import Foundation + +func processMarkdownFiles(at directoryPath: String, fileNamesToDelete: [String]) { + let fileManager = FileManager.default + let directoryURL = URL(fileURLWithPath: directoryPath) + + // Check if directory exists + if !fileManager.fileExists(atPath: directoryPath) { + print("Directory does not exist: \(directoryPath)") + return + } + + do { + let fileURLs = try fileManager.contentsOfDirectory(at: directoryURL, includingPropertiesForKeys: nil) + + for fileName in fileNamesToDelete { + let filesToDelete = fileURLs.filter { $0.pathExtension == "md" && $0.lastPathComponent == fileName } + + for fileURL in filesToDelete { + try fileManager.removeItem(at: fileURL) + } + } + + let filesToProcess = try fileManager.contentsOfDirectory(at: directoryURL, includingPropertiesForKeys: nil) + + for fileURL in filesToProcess { + convertParamsToTable(at: fileURL) + } + + } catch { + print("Error while processing files: \(error.localizedDescription)") + } +} + +// Function to read markdown file, convert params to table, and update markdown +func convertParamsToTable(at fileURL: URL) { + guard var markdown = try? String(contentsOf: fileURL) else { + print("Failed to read markdown file: \(fileURL.path)") + return + } + + markdown = extractHeadings(from: markdown) + + // Array to store the updated lines of markdown + var updatedMarkdownLines: [String] = [] + + // Flag to indicate if a parameter list is being processed + var isProcessingParameters = false + + // Array to store the lines of the current parameter list + var parameterList: [String] = [] + + var emptyLineCount = 0 + + updatedMarkdownLines.append("{% env enable=\"iosSdkRef\" %}") + updatedMarkdownLines.append("") + + // Iterate over each line in the markdown + for line in markdown.components(separatedBy: .newlines) { + let startsWithParameters = line.range( + of: #"^#{2,4}\s*Parameters"#, + options: .regularExpression + ) != nil + if startsWithParameters { + // Start of a new parameter list + isProcessingParameters = true + } else if isProcessingParameters && emptyLineCount == 2{ + // End of the current parameter list + + // Convert parameters list to a table + updatedMarkdownLines.append("") + let parameterTable = convertToTable(parameterList) + updatedMarkdownLines.append(contentsOf: parameterTable) + updatedMarkdownLines.append("") + + // Reset the parameter list + parameterList = [] + isProcessingParameters = false + emptyLineCount = 0 + } + + // Append the line to the updated markdown + if isProcessingParameters && !startsWithParameters{ + if(line.isEmpty) + { + emptyLineCount = emptyLineCount + 1 + } + parameterList.append(line) + } else { + if(line.starts(with: "``` swift")) + { + updatedMarkdownLines.append(line.replacingOccurrences(of: " ", with: "")) + } + else { + updatedMarkdownLines.append(line) + } + } + } + + if isProcessingParameters && emptyLineCount == 2{ + // For parameter list at the end of file + + // Convert parameters list to a table + updatedMarkdownLines.append("") + let parameterTable = convertToTable(parameterList) + + updatedMarkdownLines.append(contentsOf: parameterTable) + updatedMarkdownLines.append("") + + // Reset the parameter list + parameterList = [] + isProcessingParameters = false + emptyLineCount = 0 + } + + updatedMarkdownLines.append("{% /env %}") + updatedMarkdownLines.append("") + // Join the updated markdown lines + let updatedMarkdown = updatedMarkdownLines.joined(separator: "\n") + + // print("Updated markdown: \(updatedMarkdown)") + // Write the updated markdown back to the file + do { + try updatedMarkdown.write(to: fileURL, atomically: true, encoding: .utf8) + print("Updated markdown written to: \(fileURL.path)") + } catch { + print("Error writing updated markdown: \(error)") + } +} + +// Function to convert parameters to a table +func convertToTable(_ parameters: [String]) -> [String] { + var table: [String] = [] + table.append("| Name | Description |") + table.append("| ---- | ----------- |") + for line in parameters { + if(!line.isEmpty) + { + let arr = line.split(separator: ":") + let name = arr[0].split(separator: "-")[1].trimmingCharacters(in: .whitespaces) + let description = arr[1].trimmingCharacters(in: .whitespaces) + table.append("| \(name) | \(description) |") + } + } + return table +} + +func extractHeadings(from markdown: String) -> String { + var modifiedMarkdown = "" + + let lines = markdown.components(separatedBy: .newlines) + var isInsideCodeBlock = false + + for line in lines { + if line.starts(with: "```") { + isInsideCodeBlock.toggle() + } + + if isInsideCodeBlock || !line.starts(with: "###") { + modifiedMarkdown += line + "\n" + } else if let methodName = extractMethodName(from: line) { + let hashes = line.components(separatedBy: " ")[0] + modifiedMarkdown += "\(hashes) \(methodName)\n" + } + } + + return modifiedMarkdown +} + +func extractMethodName(from line: String) -> String? { + let components = line.components(separatedBy: " ") + guard components.count > 1 else { + return nil + } + + let methodName = components[1] + let sanitizedMethodName = sanitizeMethodName(methodName) + return sanitizedMethodName +} + +func sanitizeMethodName(_ methodName: String) -> String { + let pattern = "\\([^()]*\\)" + let regex = try! NSRegularExpression(pattern: pattern, options: []) + let range = NSRange(location: 0, length: methodName.utf16.count) + + var sanitizedMethodName = regex.stringByReplacingMatches( + in: methodName, + options: [], + range: range, + withTemplate: "()" + ) + sanitizedMethodName = sanitizedMethodName.replacingOccurrences(of: "`", with: "") + // print("heading: \(sanitizedMethodName)") + return sanitizedMethodName +} +// Usage example +let path = "docs/markdown" +let filesToDelete = ["_Footer.md", "_Sidebar.md", "ContainerOptions.md", "Callback.md", "TokenProvider.md", "Label.md", "UILabel.md", "SkyflowLabelView.md", "Home.md", "RevealOptions.md", "FormatLabel.md"] + +processMarkdownFiles(at: path, fileNamesToDelete: filesToDelete) \ No newline at end of file diff --git a/Sources/Skyflow/collect/CollectContainer.swift b/Sources/Skyflow/collect/CollectContainer.swift index cb05adb3..9cc850f6 100644 --- a/Sources/Skyflow/collect/CollectContainer.swift +++ b/Sources/Skyflow/collect/CollectContainer.swift @@ -7,9 +7,20 @@ import Foundation import UIKit +/// Wraps all Collect Elements. public class CollectContainer: ContainerProtocol {} public extension Container { + + /** + Creates a Collect Element. + + - Parameters: + - input: Collect Element input. + - options: Collect Element options. + + - Returns: Returns the Collect Element. + */ func create(input: CollectElementInput, options: CollectElementOptions? = CollectElementOptions()) -> TextField where T: CollectContainer { var tempContextOptions = self.skyflow.contextOptions tempContextOptions.interface = .COLLECT_CONTAINER @@ -22,6 +33,13 @@ public extension Container { return skyflowElement } + /** + Collects the data and sends it to the vault. + + - Parameters: + - callback: Implementation of Skyflow.Callback. + - options: Collects the data and sends it to the vault. + */ func collect(callback: Callback, options: CollectOptions? = CollectOptions()) where T: CollectContainer { var tempContextOptions = self.skyflow.contextOptions tempContextOptions.interface = .COLLECT_CONTAINER diff --git a/Sources/Skyflow/collect/CollectOptions.swift b/Sources/Skyflow/collect/CollectOptions.swift index 369961bb..1bba71b6 100644 --- a/Sources/Skyflow/collect/CollectOptions.swift +++ b/Sources/Skyflow/collect/CollectOptions.swift @@ -6,10 +6,20 @@ import Foundation +/// Options for a Collect Element. public struct CollectOptions { var tokens: Bool var additionalFields: [String: Any]? var upsert: [[String: Any]]? + + /** + Initializes the Collect options. + + - Parameters: + - tokens: If `true`, returns tokens for the collected data. Defaults to `true`. + - additionalFields: Additional, non-sensitive data to insert into the vault. + - upsert: Upsert configuration for the element. + */ public init(tokens: Bool = true, additionalFields: [String: Any]? = nil, upsert: [[String: Any]]? = nil) { self.tokens = tokens self.additionalFields = additionalFields diff --git a/Sources/Skyflow/collect/InsertOptions.swift b/Sources/Skyflow/collect/InsertOptions.swift index e57737df..4324475e 100644 --- a/Sources/Skyflow/collect/InsertOptions.swift +++ b/Sources/Skyflow/collect/InsertOptions.swift @@ -6,9 +6,18 @@ import Foundation +/// Contains additional parameters for the insert method. public struct InsertOptions { var tokens: Bool var upsert: [[String: Any]]? + + /** + Initializes the Insert options. + + - Parameters: + - tokens: If `true`, returns tokens for the collected data. Defaults to `false`. + - upsert: If specified, upserts data. If not specified, inserts data. + */ public init(tokens: Bool = true, upsert: [[String: Any]]? = nil) { self.tokens = tokens self.upsert = upsert diff --git a/Sources/Skyflow/core/Client.swift b/Sources/Skyflow/core/Client.swift index 03662656..2109d69b 100644 --- a/Sources/Skyflow/core/Client.swift +++ b/Sources/Skyflow/core/Client.swift @@ -7,6 +7,7 @@ import Foundation import AEXML +/// Client for interacting with Skyflow. public class Client { var vaultID: String var apiClient: APIClient @@ -14,6 +15,12 @@ public class Client { var contextOptions: ContextOptions var elementLookup: [String: Any] = [:] + /** + Initializes the Skyflow client. + + - Parameters: + - skyflowConfig: Configuration for the Skyflow client. + */ public init(_ skyflowConfig: Configuration) { self.vaultID = skyflowConfig.vaultID self.vaultURL = skyflowConfig.vaultURL.hasSuffix("/") ? skyflowConfig.vaultURL + "v1/vaults/" : skyflowConfig.vaultURL + "/v1/vaults/" @@ -22,6 +29,14 @@ public class Client { Log.info(message: .CLIENT_INITIALIZED, contextOptions: self.contextOptions) } + /** + Inserts data into the vault. + + - Parameters: + - records: Records to insert. + - options: Options for the insertion. + - callback: Implementation of Skyflow.Callback. + */ public func insert(records: [String: Any], options: InsertOptions = InsertOptions(), callback: Callback) { var tempContextOptions = self.contextOptions tempContextOptions.interface = .INSERT @@ -95,6 +110,15 @@ public class Client { } } + /** + Creates a container. + + - Parameters: + - type: Type of the container. + - options: Options for the container. + + - Returns: Returns a container of the specified type. + */ public func container(type: T.Type, options: ContainerOptions? = ContainerOptions()) -> Container? { if options != nil { // Set options @@ -113,6 +137,14 @@ public class Client { return nil } + /** + Returns values that correspond to the specified tokens. + + - Parameters: + - records: Records to fetch. + - options: Additional options for the reveal method. + - callback: Implementation of Skyflow.Callback. + */ public func detokenize(records: [String: Any], options: RevealOptions? = RevealOptions(), callback: Callback) { var tempContextOptions = self.contextOptions tempContextOptions.interface = .DETOKENIZE @@ -177,6 +209,13 @@ public class Client { } } + /** + Reveal records by Skyflow ID. + + - Parameters: + - records: Records to fetch. + - callback: Implementation of Skyflow.Callback. + */ public func getById(records: [String: Any], callback: Callback) { var tempContextOptions = self.contextOptions tempContextOptions.interface = .GETBYID diff --git a/Sources/Skyflow/core/Configuration.swift b/Sources/Skyflow/core/Configuration.swift index 13adbf04..37e26dc4 100644 --- a/Sources/Skyflow/core/Configuration.swift +++ b/Sources/Skyflow/core/Configuration.swift @@ -6,12 +6,22 @@ import Foundation +/// Configuration for the Skyflow client. public struct Configuration { var vaultID: String var vaultURL: String var tokenProvider: TokenProvider var options: Options? + /** + Configuration for the Skyflow client. + + - Parameters: + - vaultID: ID of the vault to connect to. + - vaultURL: URL of the vault to connect to. + - tokenProvider: An implementation of the token provider interface. + - options: Additional options for configuration. + */ public init(vaultID: String = "", vaultURL: String = "", tokenProvider: TokenProvider, options: Options? = Options()) { self.vaultID = vaultID self.vaultURL = vaultURL diff --git a/Sources/Skyflow/core/Env.swift b/Sources/Skyflow/core/Env.swift index a933d744..a0890742 100644 --- a/Sources/Skyflow/core/Env.swift +++ b/Sources/Skyflow/core/Env.swift @@ -6,6 +6,7 @@ import Foundation +/// Supported environments. public enum Env { case DEV case PROD diff --git a/Sources/Skyflow/core/EventName.swift b/Sources/Skyflow/core/EventName.swift index 9cfb3ed5..c141bf76 100644 --- a/Sources/Skyflow/core/EventName.swift +++ b/Sources/Skyflow/core/EventName.swift @@ -6,6 +6,7 @@ import Foundation +/// Supported event names. public enum EventName: String { case CHANGE = "CHANGE" case READY = "READY" diff --git a/Sources/Skyflow/core/Init.swift b/Sources/Skyflow/core/Init.swift index 365bb9c2..d68747ba 100644 --- a/Sources/Skyflow/core/Init.swift +++ b/Sources/Skyflow/core/Init.swift @@ -6,6 +6,14 @@ import Foundation +/** +Initializes the Skyflow client. + +- Parameters: + - skyflowConfig: Configuration for the Skyflow client. + +- Returns: Returns an instance of the Skyflow client. +*/ public func initialize(_ skyflowConfig: Configuration) -> Client { return Client(skyflowConfig) } diff --git a/Sources/Skyflow/core/LogLevel.swift b/Sources/Skyflow/core/LogLevel.swift index 5f05b1b2..acd42342 100644 --- a/Sources/Skyflow/core/LogLevel.swift +++ b/Sources/Skyflow/core/LogLevel.swift @@ -6,6 +6,7 @@ import Foundation +/// Supported log levels. public enum LogLevel: Int { case DEBUG = 0 case INFO = 1 diff --git a/Sources/Skyflow/core/Options.swift b/Sources/Skyflow/core/Options.swift index 862efe4e..3297dbd6 100644 --- a/Sources/Skyflow/core/Options.swift +++ b/Sources/Skyflow/core/Options.swift @@ -2,12 +2,21 @@ * Copyright (c) 2022 Skyflow */ -// Object that describes the options parameter +/// Additional configuration for the Skyflow client. public struct Options { + /// Log level to apply. var logLevel: LogLevel + /// Type of environment. var env: Env + /** + Initializes the Skyflow client. + + - Parameters: + - logLevel: Log level to apply. + - env: Type of environment. + */ public init(logLevel: LogLevel = .ERROR, env: Env = .PROD) { self.logLevel = logLevel self.env = env diff --git a/Sources/Skyflow/core/container/Container.swift b/Sources/Skyflow/core/container/Container.swift index 2429c2b5..2904dccf 100644 --- a/Sources/Skyflow/core/container/Container.swift +++ b/Sources/Skyflow/core/container/Container.swift @@ -11,6 +11,7 @@ import Foundation +/// Creates a container. public class Container { internal var skyflow: Client internal var elements: [TextField] = [] diff --git a/Sources/Skyflow/core/container/ContainerProtocol.swift b/Sources/Skyflow/core/container/ContainerProtocol.swift index 11d4e470..0420331f 100644 --- a/Sources/Skyflow/core/container/ContainerProtocol.swift +++ b/Sources/Skyflow/core/container/ContainerProtocol.swift @@ -11,5 +11,6 @@ import Foundation +/// Protocol for container-related functionality. public protocol ContainerProtocol { } diff --git a/Sources/Skyflow/core/container/ContainerType.swift b/Sources/Skyflow/core/container/ContainerType.swift index 6c4962ed..46ca2fcb 100644 --- a/Sources/Skyflow/core/container/ContainerType.swift +++ b/Sources/Skyflow/core/container/ContainerType.swift @@ -6,6 +6,7 @@ import Foundation +/// Class that describes different type of containers. public class ContainerType { public static var COLLECT = CollectContainer.self public static var REVEAL = RevealContainer.self diff --git a/Sources/Skyflow/elements/core/CollectElementInput.swift b/Sources/Skyflow/elements/core/CollectElementInput.swift index 1ea7eba7..4b38bdb8 100644 --- a/Sources/Skyflow/elements/core/CollectElementInput.swift +++ b/Sources/Skyflow/elements/core/CollectElementInput.swift @@ -6,6 +6,7 @@ import Foundation +/// Configuration for a Collect Element. public struct CollectElementInput { var table: String var column: String @@ -17,6 +18,22 @@ public struct CollectElementInput { var placeholder: String var type: ElementType var validations: ValidationSet + + /** + Initializes the Collect element input. + + - Parameters: + - table: Table that the data belongs to. + - column: Column that the data belongs to. + - inputStyles: Styles for the element. + - labelStyles: Styles for the element's label. + - errorTextStyles: Styles for the element's error text. + - iconStyles: Styles for the element's icon. + - label: Label for the element. + - placeholder: Placeholder text for the element. + - type: Type of the element. + - validations: Input validation rules for the element. + */ public init(table: String = "", column: String = "", inputStyles: Styles? = Styles(), labelStyles: Styles? = Styles(), errorTextStyles: Styles? = Styles(), iconStyles: Styles? = Styles(), label: String? = "", placeholder: String? = "", type: ElementType, validations: ValidationSet=ValidationSet()) { diff --git a/Sources/Skyflow/elements/core/CollectElementOptions.swift b/Sources/Skyflow/elements/core/CollectElementOptions.swift index 6f324fba..0fb09e3a 100644 --- a/Sources/Skyflow/elements/core/CollectElementOptions.swift +++ b/Sources/Skyflow/elements/core/CollectElementOptions.swift @@ -9,13 +9,22 @@ import Foundation import UIKit #endif +/// Additional options for a Collect Element. public struct CollectElementOptions { var required: Bool var enableCardIcon: Bool var format: String var translation: [ Character: String ]? - + /** + Initializes the Collect element options. + + - Parameters: + - required: Indicates whether the field is marked as required. Defaults to `false`. + - enableCardIcon: Indicates whether card icon should be enabled (only for CARD_NUMBER inputs). + - format: Format of the Collect Element. + - translation: Allowed data type values for format. + */ public init(required: Bool? = false, enableCardIcon: Bool = true, format: String = "mm/yy", translation: [ Character: String ]? = nil) { self.required = required! self.enableCardIcon = enableCardIcon diff --git a/Sources/Skyflow/elements/core/styles/Style.swift b/Sources/Skyflow/elements/core/styles/Style.swift index b1af9e3a..40eb9974 100644 --- a/Sources/Skyflow/elements/core/styles/Style.swift +++ b/Sources/Skyflow/elements/core/styles/Style.swift @@ -9,6 +9,7 @@ import Foundation import UIKit #endif +/// Various styles for Skyflow elements. public struct Style { var borderColor: UIColor? var cornerRadius: CGFloat? @@ -18,6 +19,18 @@ public struct Style { var textAlignment: NSTextAlignment? var textColor: UIColor? + /** + Initializes the styles for Skyflow elements. + + - Parameters: + - borderColor: Color of the border. + - cornerRadius: Radius applied to the corners. + - padding: Padding for the element. + - borderWidth: Width of the border. + - font: Type of font used. + - textAlignment: Alignment of the text. + - textColor: Color of the text. + */ public init(borderColor: UIColor? = nil, cornerRadius: CGFloat? = nil, padding: UIEdgeInsets? = nil, diff --git a/Sources/Skyflow/elements/core/styles/Styles.swift b/Sources/Skyflow/elements/core/styles/Styles.swift index ad880456..0ef41785 100644 --- a/Sources/Skyflow/elements/core/styles/Styles.swift +++ b/Sources/Skyflow/elements/core/styles/Styles.swift @@ -6,6 +6,7 @@ import Foundation +/// Different styles to apply to a Skyflow element. public struct Styles { var base: Style? var complete: Style? @@ -14,6 +15,17 @@ public struct Styles { var invalid: Style? var requiredAstrisk: Style? + /** + Initializes the styles to apply on a Skyflow element. + + - Parameters: + - base: Styles applied on skyflow elements in its base form. + - complete: Styles applied when value is valid. + - empty: Styles applied when skyflow element is empty. + - focus: Styles applied when skyflow element is focused. + - invalid: Styles applied when value is invalid. + - requiredAstrisk: Styles applied on the required asterisk. + */ public init(base: Style? = Style(), complete: Style? = Style(), empty: Style? = Style(), diff --git a/Sources/Skyflow/elements/validations/ElementValueMatchRule.swift b/Sources/Skyflow/elements/validations/ElementValueMatchRule.swift index e9e7057b..033848f9 100644 --- a/Sources/Skyflow/elements/validations/ElementValueMatchRule.swift +++ b/Sources/Skyflow/elements/validations/ElementValueMatchRule.swift @@ -15,6 +15,13 @@ public struct ElementValueMatchRule: ValidationRule { /// Validation Error public let error: SkyflowValidationError + /** + Initializes the rule to match the value of one element with another. + + - Parameters: + - element: Element whose value needs to be matched. + - error: Custom validation error. + */ public init(element: TextField, error: SkyflowValidationError? = nil) { self.element = element if error != nil { @@ -26,7 +33,14 @@ public struct ElementValueMatchRule: ValidationRule { } extension ElementValueMatchRule: SkyflowInternalValidationProtocol { - /// validate element value + /** + Validates the element's value against the specified text. + + - Parameters: + - text: Text that needs to be validated. + + - Returns: Returns `true` if the text matches the value of the element, else `false`. + */ public func validate(_ text: String?) -> Bool { guard text != nil else { return false diff --git a/Sources/Skyflow/elements/validations/LengthMatchRule.swift b/Sources/Skyflow/elements/validations/LengthMatchRule.swift index e8d50298..9b836b2c 100644 --- a/Sources/Skyflow/elements/validations/LengthMatchRule.swift +++ b/Sources/Skyflow/elements/validations/LengthMatchRule.swift @@ -4,18 +4,18 @@ import Foundation -// Validate input in scope of length. - +/// Validate input in scope of length. public struct LengthMatchRule: ValidationRule { - /// input string minimum length + /// Minimum length of input string. public let minLength: Int - /// input string maximum length + /// Maximum length of input string. public let maxLength: Int /// Validation Error public let error: SkyflowValidationError + /// Initializes the rule to set the minimum and maximum permissible length of the textfield value. public init(minLength: Int = 0, maxLength: Int = Int.max, error: SkyflowValidationError? = nil) { self.minLength = minLength self.maxLength = maxLength @@ -28,7 +28,14 @@ public struct LengthMatchRule: ValidationRule { } extension LengthMatchRule: SkyflowInternalValidationProtocol { - /// validate length of text + /** + Validates the length of the input text within the specified range. + + - Parameters: + - text: Text that needs to be validated. + + - Returns: Returns `true` if the text length is within the specified range, else `false`. + */ public func validate(_ text: String?) -> Bool { guard text != nil else { diff --git a/Sources/Skyflow/elements/validations/RegexMatchRule.swift b/Sources/Skyflow/elements/validations/RegexMatchRule.swift index 27470066..8710b342 100644 --- a/Sources/Skyflow/elements/validations/RegexMatchRule.swift +++ b/Sources/Skyflow/elements/validations/RegexMatchRule.swift @@ -14,6 +14,7 @@ public struct RegexMatchRule: ValidationRule { /// Validation Error public let error: SkyflowValidationError + /// Initializes the rule to specify any Regular Expression to be matched with the text field value. public init(regex: String, error: SkyflowValidationError?=nil) { self.regex = regex if error != nil { @@ -25,7 +26,14 @@ public struct RegexMatchRule: ValidationRule { } extension RegexMatchRule: SkyflowInternalValidationProtocol { - /// validate the text with specified regex + /** + Validate the text using the specified regular expression. + + - Parameters: + - text: Text that needs to be validated. + + - Returns: Returns `true` if the text matches the regular expression, else `false`. + */ public func validate(_ text: String?) -> Bool { if text!.isEmpty { return true diff --git a/Sources/Skyflow/elements/validations/SkyflowValidationError.swift b/Sources/Skyflow/elements/validations/SkyflowValidationError.swift index a9b611d1..71e3afc7 100644 --- a/Sources/Skyflow/elements/validations/SkyflowValidationError.swift +++ b/Sources/Skyflow/elements/validations/SkyflowValidationError.swift @@ -4,7 +4,7 @@ import Foundation -/// Skyflow Validation Error object type +/// Type of Skyflow Validation Error object. public typealias SkyflowValidationError = String /// Default validation error types diff --git a/Sources/Skyflow/elements/validations/ValidationRule.swift b/Sources/Skyflow/elements/validations/ValidationRule.swift index 733079d0..bf01b20e 100644 --- a/Sources/Skyflow/elements/validations/ValidationRule.swift +++ b/Sources/Skyflow/elements/validations/ValidationRule.swift @@ -11,6 +11,7 @@ import Foundation +/// Defines a validation rule for input validation. public protocol ValidationRule { var error: String { get } } diff --git a/Sources/Skyflow/elements/validations/ValidationSet.swift b/Sources/Skyflow/elements/validations/ValidationSet.swift index 3a0a8fb9..07b5c77f 100644 --- a/Sources/Skyflow/elements/validations/ValidationSet.swift +++ b/Sources/Skyflow/elements/validations/ValidationSet.swift @@ -6,17 +6,28 @@ import Foundation - +/// Set of validation rules. public struct ValidationSet { internal var rules = [ValidationRule]() public init() { } + /** + Initializes the validation set with an array of validation rules. + + - Parameters: + - rules: Validation rules to be included in the set. + */ public init(rules: [ValidationRule]) { self.rules = rules } - /// Add validation rule + /** + Adds a validation rule to the set. + + - Parameters: + - rule: Validation rule that is added to the set. + */ public mutating func add(rule: ValidationRule) { rules.append(rule) } diff --git a/Sources/Skyflow/reveal/RedactionType.swift b/Sources/Skyflow/reveal/RedactionType.swift index 8e86a3e3..e97075db 100644 --- a/Sources/Skyflow/reveal/RedactionType.swift +++ b/Sources/Skyflow/reveal/RedactionType.swift @@ -6,6 +6,7 @@ import Foundation +/// Supported redaction types. public enum RedactionType: String { case PLAIN_TEXT = "PLAIN_TEXT" case DEFAULT = "DEFAULT" diff --git a/Sources/Skyflow/reveal/RevealContainer.swift b/Sources/Skyflow/reveal/RevealContainer.swift index 57f97bc9..a06fbfdc 100644 --- a/Sources/Skyflow/reveal/RevealContainer.swift +++ b/Sources/Skyflow/reveal/RevealContainer.swift @@ -9,10 +9,20 @@ import Foundation +/// Container for all Reveal Elements. public class RevealContainer: ContainerProtocol { } public extension Container { + /** + Creates a Reveal Element. + + - Parameters: + - input: Input configuration for a Reveal Element. + - options: Additional options for a Reveal Element. + + - Returns: Returns the Reveal Element. + */ func create(input: RevealElementInput, options: RevealElementOptions? = RevealElementOptions()) -> Label where T: RevealContainer { var tempContextOptions = self.skyflow.contextOptions tempContextOptions.interface = .REVEAL_CONTAINER @@ -25,6 +35,15 @@ public extension Container { return revealElement } + /** + Reveals data in the container. + + - Parameters: + - callback: Implementation of Skyflow.Callback. + - options: This is the description for options parameter. + + - Returns: Additional options for the reveal method. + */ func reveal(callback: Callback, options: RevealOptions? = RevealOptions()) where T: RevealContainer { var tempContextOptions = self.skyflow.contextOptions tempContextOptions.interface = .REVEAL_CONTAINER diff --git a/Sources/Skyflow/reveal/RevealElementInput.swift b/Sources/Skyflow/reveal/RevealElementInput.swift index d0da3195..91064d69 100644 --- a/Sources/Skyflow/reveal/RevealElementInput.swift +++ b/Sources/Skyflow/reveal/RevealElementInput.swift @@ -6,6 +6,7 @@ import Foundation +/// Configuration for Reveal Elements. public struct RevealElementInput { internal var token: String internal var inputStyles: Styles? @@ -25,6 +26,17 @@ public struct RevealElementInput { self.altText = altText } + /** + Initializes the Reveal Element input. + + - Parameters: + - token: A token to retrieve the value of. + - inputStyles: Input styles for the Reveal Element. + - labelStyles: Styles for the Reveal Element's label. + - errorTextStyles: Styles for the Reveal Element's error text. + - label: Label for the Reveal Element. + - altText: Alternative text for the Reveal Element. + */ public init(token: String = "", inputStyles: Styles = Styles(), labelStyles: Styles = Styles(), errorTextStyles: Styles = Styles(), label: String, altText: String = "") { self.token = token self.inputStyles = inputStyles diff --git a/Sources/Skyflow/reveal/RevealElementOptions.swift b/Sources/Skyflow/reveal/RevealElementOptions.swift index d7e28e20..76e5e0f9 100644 --- a/Sources/Skyflow/reveal/RevealElementOptions.swift +++ b/Sources/Skyflow/reveal/RevealElementOptions.swift @@ -4,11 +4,18 @@ import Foundation +/// Configuration options for a Reveal Element. public struct RevealElementOptions { var format: String? var translation: [ Character: String ]? + /** + Initializes the Reveal Element options. + - Parameters: + - format: Format of the Reveal Element. + - translation: Custom allowed substitutions and regex patterns for `format`. + */ public init(format: String? = nil, translation: [ Character: String ]? = nil) { self.format = format self.translation = translation