Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new Connector types #22

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 74 additions & 2 deletions Davinci/Davinci.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@
A51D4CFA2C6BA75000FE09E0 /* CallbackFactoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51D4CF92C6BA75000FE09E0 /* CallbackFactoryTests.swift */; };
A5A712482CAC527200B7DD58 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = A5A712472CAC527200B7DD58 /* PrivacyInfo.xcprivacy */; };
A5CCE5E72C85E96B00349A5E /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5CCE5E62C85E96B00349A5E /* Constants.swift */; };
A5E9AEB22D2F1F93000533ED /* SingleValueCollector.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E9AEB12D2F1F91000533ED /* SingleValueCollector.swift */; };
A5E9AEB42D2F2256000533ED /* LabelCollector.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E9AEB32D2F2252000533ED /* LabelCollector.swift */; };
A5E9AEB62D2F243E000533ED /* SingleSelectCollector.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E9AEB52D2F243C000533ED /* SingleSelectCollector.swift */; };
A5E9AEB82D2F2689000533ED /* ValidationError.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E9AEB72D2F2687000533ED /* ValidationError.swift */; };
A5E9AEBA2D2F2731000533ED /* ValidatedCollector.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E9AEB92D2F272F000533ED /* ValidatedCollector.swift */; };
A5E9AEBC2D2F2B26000533ED /* Option.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E9AEBB2D2F2B23000533ED /* Option.swift */; };
A5E9AEBE2D2F2DAE000533ED /* MultiSelectCollector.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E9AEBD2D2F2DAC000533ED /* MultiSelectCollector.swift */; };
A5E9AEC02D2F44CD000533ED /* PasswordPolicy.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E9AEBF2D2F44CB000533ED /* PasswordPolicy.swift */; };
A5EFA9D12D38B4CF00F771FE /* ContinueNodeAware.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EFA9D02D38B4C900F771FE /* ContinueNodeAware.swift */; };
A5EFAA062D3F304500F771FE /* FlowCollectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EFAA052D3F303900F771FE /* FlowCollectorTests.swift */; };
A5EFAA082D3F30E600F771FE /* LabelCollectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EFAA072D3F30E200F771FE /* LabelCollectorTests.swift */; };
A5EFAA0A2D3F325B00F771FE /* MultiSelectCollectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EFAA092D3F325800F771FE /* MultiSelectCollectorTests.swift */; };
A5EFAA0C2D3F441400F771FE /* PasswordCollectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EFAA0B2D3F441200F771FE /* PasswordCollectorTests.swift */; };
A5EFAA0E2D3F484100F771FE /* PasswordPolicyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EFAA0D2D3F483900F771FE /* PasswordPolicyTests.swift */; };
A5EFAA102D3F50A700F771FE /* SingleSelectCollectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EFAA0F2D3F50A500F771FE /* SingleSelectCollectorTests.swift */; };
A5EFAA122D3F518B00F771FE /* SubmitCollectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EFAA112D3F518800F771FE /* SubmitCollectorTests.swift */; };
A5EFAA142D3F51CC00F771FE /* TextCollectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EFAA132D3F51CA00F771FE /* TextCollectorTests.swift */; };
A5EFAA162D3F52F500F771FE /* ValidatedCollectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EFAA152D3F52F300F771FE /* ValidatedCollectorTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -94,6 +112,24 @@
A51D4CF92C6BA75000FE09E0 /* CallbackFactoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallbackFactoryTests.swift; sourceTree = "<group>"; };
A5A712472CAC527200B7DD58 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
A5CCE5E62C85E96B00349A5E /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
A5E9AEB12D2F1F91000533ED /* SingleValueCollector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SingleValueCollector.swift; sourceTree = "<group>"; };
A5E9AEB32D2F2252000533ED /* LabelCollector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelCollector.swift; sourceTree = "<group>"; };
A5E9AEB52D2F243C000533ED /* SingleSelectCollector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SingleSelectCollector.swift; sourceTree = "<group>"; };
A5E9AEB72D2F2687000533ED /* ValidationError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValidationError.swift; sourceTree = "<group>"; };
A5E9AEB92D2F272F000533ED /* ValidatedCollector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValidatedCollector.swift; sourceTree = "<group>"; };
A5E9AEBB2D2F2B23000533ED /* Option.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Option.swift; sourceTree = "<group>"; };
A5E9AEBD2D2F2DAC000533ED /* MultiSelectCollector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiSelectCollector.swift; sourceTree = "<group>"; };
A5E9AEBF2D2F44CB000533ED /* PasswordPolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordPolicy.swift; sourceTree = "<group>"; };
A5EFA9D02D38B4C900F771FE /* ContinueNodeAware.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContinueNodeAware.swift; sourceTree = "<group>"; };
A5EFAA052D3F303900F771FE /* FlowCollectorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlowCollectorTests.swift; sourceTree = "<group>"; };
A5EFAA072D3F30E200F771FE /* LabelCollectorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelCollectorTests.swift; sourceTree = "<group>"; };
A5EFAA092D3F325800F771FE /* MultiSelectCollectorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiSelectCollectorTests.swift; sourceTree = "<group>"; };
A5EFAA0B2D3F441200F771FE /* PasswordCollectorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordCollectorTests.swift; sourceTree = "<group>"; };
A5EFAA0D2D3F483900F771FE /* PasswordPolicyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordPolicyTests.swift; sourceTree = "<group>"; };
A5EFAA0F2D3F50A500F771FE /* SingleSelectCollectorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SingleSelectCollectorTests.swift; sourceTree = "<group>"; };
A5EFAA112D3F518800F771FE /* SubmitCollectorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubmitCollectorTests.swift; sourceTree = "<group>"; };
A5EFAA132D3F51CA00F771FE /* TextCollectorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextCollectorTests.swift; sourceTree = "<group>"; };
A5EFAA152D3F52F300F771FE /* ValidatedCollectorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValidatedCollectorTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -168,6 +204,15 @@
A51D4CF12C65729A00FE09E0 /* DaVinciErrorTests.swift */,
3A5441AE2BCDF20700385131 /* DaVinciTests.swift */,
A51D4CED2C656EE100FE09E0 /* FieldCollectorTests.swift */,
A5EFAA052D3F303900F771FE /* FlowCollectorTests.swift */,
A5EFAA072D3F30E200F771FE /* LabelCollectorTests.swift */,
A5EFAA092D3F325800F771FE /* MultiSelectCollectorTests.swift */,
A5EFAA0B2D3F441200F771FE /* PasswordCollectorTests.swift */,
A5EFAA0D2D3F483900F771FE /* PasswordPolicyTests.swift */,
A5EFAA0F2D3F50A500F771FE /* SingleSelectCollectorTests.swift */,
A5EFAA112D3F518800F771FE /* SubmitCollectorTests.swift */,
A5EFAA132D3F51CA00F771FE /* TextCollectorTests.swift */,
A5EFAA152D3F52F300F771FE /* ValidatedCollectorTests.swift */,
);
path = DavinciTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -195,12 +240,21 @@
children = (
3AC13E302C3FFF1000DEF23A /* Collector.swift */,
3AC13E2F2C3FFF1000DEF23A /* CollectorFactory.swift */,
A5EFA9D02D38B4C900F771FE /* ContinueNodeAware.swift */,
A51D4CD02C585B4500FE09E0 /* FieldCollector.swift */,
A51D4CD22C585D7C00FE09E0 /* FlowCollector.swift */,
3AC13E322C3FFF1000DEF23A /* Form.swift */,
A5E9AEB32D2F2252000533ED /* LabelCollector.swift */,
A5E9AEBD2D2F2DAC000533ED /* MultiSelectCollector.swift */,
A5E9AEBB2D2F2B23000533ED /* Option.swift */,
A51D4CD42C585DCD00FE09E0 /* PasswordCollector.swift */,
A5E9AEBF2D2F44CB000533ED /* PasswordPolicy.swift */,
A5E9AEB52D2F243C000533ED /* SingleSelectCollector.swift */,
A5E9AEB12D2F1F91000533ED /* SingleValueCollector.swift */,
A51D4CD62C585E2D00FE09E0 /* SubmitCollector.swift */,
A51D4CD82C585E5700FE09E0 /* TextCollector.swift */,
A5E9AEB92D2F272F000533ED /* ValidatedCollector.swift */,
A5E9AEB72D2F2687000533ED /* ValidationError.swift */,
);
path = collector;
sourceTree = "<group>";
Expand Down Expand Up @@ -329,20 +383,29 @@
buildActionMask = 2147483647;
files = (
A51D4CD12C585B4500FE09E0 /* FieldCollector.swift in Sources */,
A5E9AEB82D2F2689000533ED /* ValidationError.swift in Sources */,
A5E9AEC02D2F44CD000533ED /* PasswordPolicy.swift in Sources */,
A51D4CDF2C599BFF00FE09E0 /* Request.swift in Sources */,
A51D4CD32C585D7C00FE09E0 /* FlowCollector.swift in Sources */,
A51D4CD72C585E2D00FE09E0 /* SubmitCollector.swift in Sources */,
A5E9AEBE2D2F2DAE000533ED /* MultiSelectCollector.swift in Sources */,
3A292C822BF58462006977EF /* Agent.swift in Sources */,
A5E9AEB62D2F243E000533ED /* SingleSelectCollector.swift in Sources */,
3A203D972BDB2CD70020C995 /* Oidc.swift in Sources */,
3A203D9B2BDE155D0020C995 /* Transform.swift in Sources */,
A5CCE5E72C85E96B00349A5E /* Constants.swift in Sources */,
3AC13E332C3FFF1000DEF23A /* CollectorFactory.swift in Sources */,
3AC13E342C3FFF1000DEF23A /* Collector.swift in Sources */,
A51D4CD52C585DCD00FE09E0 /* PasswordCollector.swift in Sources */,
A5E9AEB22D2F1F93000533ED /* SingleValueCollector.swift in Sources */,
A5E9AEBC2D2F2B26000533ED /* Option.swift in Sources */,
3AC13E352C3FFF1000DEF23A /* Form.swift in Sources */,
3AC13E362C3FFF1000DEF23A /* Connector.swift in Sources */,
A51D4CD92C585E5700FE09E0 /* TextCollector.swift in Sources */,
3A57CB622C44D68C001EC9A0 /* User.swift in Sources */,
A5E9AEB42D2F2256000533ED /* LabelCollector.swift in Sources */,
A5EFA9D12D38B4CF00F771FE /* ContinueNodeAware.swift in Sources */,
A5E9AEBA2D2F2731000533ED /* ValidatedCollector.swift in Sources */,
3A203D7F2BDB136C0020C995 /* DaVinci.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -353,13 +416,22 @@
files = (
A51D4CEE2C656EE100FE09E0 /* FieldCollectorTests.swift in Sources */,
A51D4CFA2C6BA75000FE09E0 /* CallbackFactoryTests.swift in Sources */,
A5EFAA082D3F30E600F771FE /* LabelCollectorTests.swift in Sources */,
A5EFAA142D3F51CC00F771FE /* TextCollectorTests.swift in Sources */,
A5EFAA122D3F518B00F771FE /* SubmitCollectorTests.swift in Sources */,
A51D4CF62C65743100FE09E0 /* MockAPIEndpoint.swift in Sources */,
A5EFAA0E2D3F484100F771FE /* PasswordPolicyTests.swift in Sources */,
A51D4CE52C656A0C00FE09E0 /* CollectorRegistryTests.swift in Sources */,
A5EFAA0C2D3F441400F771FE /* PasswordCollectorTests.swift in Sources */,
A51D4CF02C656FC600FE09E0 /* MockResponse.swift in Sources */,
A5EFAA162D3F52F500F771FE /* ValidatedCollectorTests.swift in Sources */,
A5EFAA062D3F304500F771FE /* FlowCollectorTests.swift in Sources */,
A5EFAA0A2D3F325B00F771FE /* MultiSelectCollectorTests.swift in Sources */,
A51D4CF42C6572E600FE09E0 /* MockURLProtocol.swift in Sources */,
A51D4CF82C65978300FE09E0 /* DaVinciIntegrationTests.swift in Sources */,
3A5441AF2BCDF20700385131 /* DaVinciTests.swift in Sources */,
A51D4CF22C65729A00FE09E0 /* DaVinciErrorTests.swift in Sources */,
A5EFAA102D3F50A700F771FE /* SingleSelectCollectorTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -521,7 +593,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = "1.0.0";
MARKETING_VERSION = 1.0.0;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20";
OTHER_SWIFT_FLAGS = "-no-verify-emitted-module-interface";
Expand Down Expand Up @@ -557,7 +629,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = "1.0.0";
MARKETING_VERSION = 1.0.0;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20";
OTHER_SWIFT_FLAGS = "-no-verify-emitted-module-interface";
Expand Down
17 changes: 16 additions & 1 deletion Davinci/Davinci/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Constants.swift
// PingDavinci
//
// Copyright (c) 2024 Ping Identity. All rights reserved.
// Copyright (c) 2024 - 2025 Ping Identity. All rights reserved.
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
Expand All @@ -15,6 +15,7 @@ enum Constants {
static let type = "type"
static let key = "key"
static let label = "label"
static let value = "value"
static let form = "form"
static let components = "components"
static let fields = "fields"
Expand All @@ -37,8 +38,15 @@ enum Constants {
static let FAILED = "FAILED"
static let TEXT = "TEXT"
static let PASSWORD = "PASSWORD"
static let PASSWORD_VERIFY = "PASSWORD_VERIFY"
static let SUBMIT_BUTTON = "SUBMIT_BUTTON"
static let FLOW_BUTTON = "FLOW_BUTTON"
static let FLOW_LINK = "FLOW_LINK"
static let LABEL = "LABEL"
static let DROPDOWN = "DROPDOWN"
static let RADIO = "RADIO"
static let COMBOBOX = "COMBOBOX"
static let CHECKBOX = "CHECKBOX"
static let error = "error"
static let connectorId = "connectorId"
static let capabilityName = "capabilityName"
Expand All @@ -47,4 +55,11 @@ enum Constants {
static let returnSuccessResponseRedirect = "returnSuccessResponseRedirect"
static let setSession = "setSession"
static let location = "Location"
static let content = "content"
static let required = "required"
static let options = "options"
static let passwordPolicy = "passwordPolicy"
static let validation = "validation"
static let regex = "regex"
static let errorMessage = "errorMessage"
}
90 changes: 86 additions & 4 deletions Davinci/Davinci/collector/Collector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// FlowCollector.swift
// PingDavinci
//
// Copyright (c) 2024 Ping Identity. All rights reserved.
// Copyright (c) 2024 - 2025 Ping Identity. All rights reserved.
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
Expand Down Expand Up @@ -64,14 +64,96 @@ extension Collectors {
var formData: [String: Any] = [:]
for collector in self {
if let textCollector = collector as? TextCollector, !textCollector.value.isEmpty {
formData[textCollector.key] = textCollector.value
//TODO: Revert this when the nested key is removed.
//formData[textCollector.key] = textCollector.value
toMap(map: &formData, key: textCollector.key, value: textCollector.value)
}
if let passwordCollector = collector as? PasswordCollector, !passwordCollector.value.isEmpty {
formData[passwordCollector.key] = passwordCollector.value
//TODO: Revert this when the nested key is removed.
//formData[passwordCollector.key] = passwordCollector.value
toMap(map: &formData, key: passwordCollector.key, value: passwordCollector.value)
}
if let singleSelectCollector = collector as? SingleSelectCollector, !singleSelectCollector.value.isEmpty {
//TODO: Revert this when the nested key is removed.
//formData[singleSelectCollector.key] = singleSelectCollector.value
toMap(map: &formData, key: singleSelectCollector.key, value: singleSelectCollector.value)
}
if let multiSelectCollector = collector as? MultiSelectCollector, !multiSelectCollector.value.isEmpty {
//TODO: Revert this when the nested key is removed.
//formData[multiSelectCollector.key] = multiSelectCollector.value
toMap(map: &formData, key: multiSelectCollector.key, value: multiSelectCollector.value)
}
}

//TODO: Revert this when the nested key is removed.
// jsonObject[Constants.formData] = formData
jsonObject[Constants.formData] = Helper.mapToJsonObject(map: formData)
return jsonObject
}

//TODO: Remove this when the nested key is removed.
private func toMap(map: inout [String: Any], key: String, value: Any) {
let parts = key.components(separatedBy: ".")
Helper.setNestedValue(&map, parts: parts, value: value)
}

}

//TODO: Remove this when the nested key is removed.
struct Helper {
//TODO: Remove this when the nested key is removed.
static func setNestedValue(_ map: inout [String: Any],
parts: [String],
value: Any) {
guard !parts.isEmpty else { return }

let head = parts[0]
let x = parts.dropFirst()
let tail = Array(x)
if tail.isEmpty {
// We've reached the final key—set the value
map[head] = value
} else {
// If the sub-dictionary at `head` does not exist or is not a dictionary, create a new one
if map[head] == nil || !(map[head] is [String: Any]) {
map[head] = [String: Any]()
}

// Descend into the nested dictionary
var child = map[head] as! [String: Any]
setNestedValue(&child, parts: tail, value: value)

// Write the updated child back
map[head] = child
}
}

//TODO: Remove this when the nested key is removed.
static func mapToJsonObject(map: [String: Any]) -> [String: Any] {
var jsonObject: [String: Any] = [:]

for (key, value) in map {
switch value {
case let nestedMap as [String: Any]:
jsonObject[key] = mapToJsonObject(map: nestedMap)

case let array as [Any]:
jsonObject[key] = array.map { String(describing: $0) }

case let string as String:
jsonObject[key] = string

case let bool as Bool:
jsonObject[key] = bool

case let number as NSNumber:
jsonObject[key] = number

default:
jsonObject[key] = String(describing: value)
}
}

jsonObject[Constants.formData] = formData
return jsonObject
}
}
Loading
Loading