Skip to content

Commit f0e8544

Browse files
authored
Merge pull request #38 from contentstack/feat/DX-201
feat: added support for taxonomy
2 parents a3fee41 + bc349c4 commit f0e8544

34 files changed

+932
-398
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: "Contentstack CI"
22

33
on:
44
push:
5-
branches: [ master, development ]
5+
branches: [ master, next ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ master, next ]
88

99
jobs:
1010
macOS:

.github/workflows/sca-scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
- name: Run Snyk to check for vulnerabilities
1212
run: snyk test --all-projects --fail-on=all
1313
env:
14-
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
14+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,7 @@ fastlane/screenshots/**/*.png
7373
fastlane/test_output
7474

7575
TestCase
76-
docs
76+
docs
77+
78+
fastlane/
79+
Gemfile
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
6+
<true/>
7+
</dict>
8+
</plist>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1500"
4+
version = "2.2">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "NO"
13+
buildForArchiving = "NO"
14+
buildForAnalyzing = "YES">
15+
<AutocreatedTestPlanReference>
16+
</AutocreatedTestPlanReference>
17+
</BuildActionEntry>
18+
</BuildActionEntries>
19+
</BuildAction>
20+
<TestAction
21+
buildConfiguration = "Debug"
22+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
23+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
24+
shouldUseLaunchSchemeArgsEnv = "YES"
25+
shouldAutocreateTestPlan = "YES">
26+
<Testables>
27+
<TestableReference
28+
skipped = "NO">
29+
<BuildableReference
30+
BuildableIdentifier = "primary"
31+
BlueprintIdentifier = "ContentstackTests"
32+
BuildableName = "ContentstackTests"
33+
BlueprintName = "ContentstackTests"
34+
ReferencedContainer = "container:">
35+
</BuildableReference>
36+
</TestableReference>
37+
</Testables>
38+
</TestAction>
39+
<LaunchAction
40+
buildConfiguration = "Debug"
41+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
42+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43+
launchStyle = "0"
44+
useCustomWorkingDirectory = "NO"
45+
ignoresPersistentStateOnLaunch = "NO"
46+
debugDocumentVersioning = "YES"
47+
debugServiceExtension = "internal"
48+
allowLocationSimulation = "YES">
49+
</LaunchAction>
50+
<ProfileAction
51+
buildConfiguration = "Release"
52+
shouldUseLaunchSchemeArgsEnv = "YES"
53+
savedToolIdentifier = ""
54+
useCustomWorkingDirectory = "NO"
55+
debugDocumentVersioning = "YES">
56+
<MacroExpansion>
57+
<BuildableReference
58+
BuildableIdentifier = "primary"
59+
BlueprintIdentifier = "ContentstackTests"
60+
BuildableName = "ContentstackTests"
61+
BlueprintName = "ContentstackTests"
62+
ReferencedContainer = "container:">
63+
</BuildableReference>
64+
</MacroExpansion>
65+
</ProfileAction>
66+
<AnalyzeAction
67+
buildConfiguration = "Debug">
68+
</AnalyzeAction>
69+
<ArchiveAction
70+
buildConfiguration = "Release"
71+
revealArchiveInOrganizer = "YES">
72+
</ArchiveAction>
73+
</Scheme>

.talismanrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ fileignoreconfig:
1717
checksum: a1c17f932d0b00df127851f50456923546ee912ba9b4d60d1f244768d61b858d
1818
- filename: Tests/DVRRecordings/SyncTest.json
1919
checksum: e5148d9f58da7689f249969c25a0c36d6d9f26be062a2c6bd9aaf389118f0039
20+
- filename: Contentstack.xcodeproj/xcshareddata/xcschemes/Contentstack iOS.xcscheme
21+
checksum: 10ca4b0b986ae6166f69d7f985ca5b06238ac70dac3dd378fbf3dbdfd966afff
22+
- filename: Contentstack.xcodeproj/xcshareddata/xcschemes/Contentstack iOS Tests.xcscheme
23+
checksum: c439f6d268ae2ea0af023daeffdff2af5928d0610f90fa14c9e6e6ce7e4b3fad
24+
version: ""
2025

2126

2227

Contentstack.xcodeproj/project.pbxproj

Lines changed: 173 additions & 118 deletions
Large diffs are not rendered by default.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1520"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
</BuildAction>
9+
<TestAction
10+
buildConfiguration = "Debug"
11+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
12+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
13+
shouldUseLaunchSchemeArgsEnv = "YES"
14+
shouldAutocreateTestPlan = "YES">
15+
<Testables>
16+
<TestableReference
17+
skipped = "NO">
18+
<BuildableReference
19+
BuildableIdentifier = "primary"
20+
BlueprintIdentifier = "0F4A75D2241BAC4300E3A024"
21+
BuildableName = "Contentstack iOS Tests.xctest"
22+
BlueprintName = "Contentstack iOS Tests"
23+
ReferencedContainer = "container:Contentstack.xcodeproj">
24+
</BuildableReference>
25+
</TestableReference>
26+
</Testables>
27+
</TestAction>
28+
<LaunchAction
29+
buildConfiguration = "Debug"
30+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
31+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
32+
launchStyle = "0"
33+
useCustomWorkingDirectory = "NO"
34+
ignoresPersistentStateOnLaunch = "NO"
35+
debugDocumentVersioning = "YES"
36+
debugServiceExtension = "internal"
37+
allowLocationSimulation = "YES"
38+
consoleMode = "0"
39+
structuredConsoleMode = "1">
40+
<LocationScenarioReference
41+
identifier = "com.apple.dt.IDEFoundation.CurrentLocationScenarioIdentifier"
42+
referenceType = "1">
43+
</LocationScenarioReference>
44+
</LaunchAction>
45+
<ProfileAction
46+
buildConfiguration = "Release"
47+
shouldUseLaunchSchemeArgsEnv = "YES"
48+
savedToolIdentifier = ""
49+
useCustomWorkingDirectory = "NO"
50+
debugDocumentVersioning = "YES">
51+
</ProfileAction>
52+
<AnalyzeAction
53+
buildConfiguration = "Debug">
54+
</AnalyzeAction>
55+
<ArchiveAction
56+
buildConfiguration = "Release"
57+
revealArchiveInOrganizer = "YES">
58+
</ArchiveAction>
59+
</Scheme>

Contentstack.xcworkspace/xcshareddata/xcschemes/Contentstack iOS.xcscheme

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
</BuildAction>
2525
<TestAction
2626
buildConfiguration = "Debug"
27-
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28-
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
27+
selectedDebuggerIdentifier = ""
28+
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
2929
shouldUseLaunchSchemeArgsEnv = "YES"
3030
codeCoverageEnabled = "YES">
3131
<Testables>

Package.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import PackageDescription
77

88
let package = Package(
99
name: "ContentstackSwift",
10-
platforms: [.macOS(.v10_13),
11-
.iOS(.v11),
12-
.tvOS(.v11),
13-
.watchOS(.v4)],
10+
platforms: [.macOS(.v10_15),
11+
.iOS(.v13),
12+
.tvOS(.v13),
13+
.watchOS(.v6)],
1414

1515
products: [
1616
// Products define the executables and libraries produced by a package, and make them visible to other packages.

Sources/ContentstackResponse.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ where ItemType: EndpointAccessible & Decodable {
8181
}
8282
self.items = [entry]
8383
}
84+
case .taxnomies:
85+
if let taxonomies = try container.decodeIfPresent([ItemType].self, forKey: .entries) {
86+
let containerFields = try decoder.container(keyedBy: JSONCodingKeys.self)
87+
let response = try containerFields.decode(Dictionary<String, Any>.self)
88+
if let contentType = response["content_type"] as? ContentTypeModel {
89+
fields = ["content_type": contentType]
90+
}
91+
self.items = taxonomies
92+
}
8493
default:
8594
print("sync")
8695
}

Sources/EndPoint.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public enum Endpoint: String {
2020
case assets
2121
/// The synchronization endpoint.
2222
case sync = "stacks/sync"
23+
24+
case taxnomies = "taxonomies"
2325
/// The path component string for the current endpoint.
2426
public var pathComponent: String {
2527
return rawValue

Sources/Query.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class Query: BaseQuery, EntryQueryable {
1212

1313
public typealias ResourceType = EntryModel
1414

15-
internal var contentTypeUid: String
15+
internal var contentTypeUid: String?
1616
/// Stack instance for Entry to be fetched
1717
public var stack: Stack
1818
/// URI Parameters
@@ -23,11 +23,16 @@ public class Query: BaseQuery, EntryQueryable {
2323
public var cachePolicy: CachePolicy
2424

2525

26-
internal required init(contentType: ContentType) {
27-
self.stack = contentType.stack
28-
self.contentTypeUid = contentType.uid!
29-
self.cachePolicy = contentType.cachePolicy
30-
self.parameters[QueryParameter.contentType] = contentTypeUid
26+
internal required init(contentType: ContentType?, stack: Stack? = nil, cachePolicy: CachePolicy? = nil) {
27+
if let contentType = contentType {
28+
self.stack = contentType.stack
29+
self.contentTypeUid = contentType.uid!
30+
self.cachePolicy = contentType.cachePolicy
31+
self.parameters[QueryParameter.contentType] = contentTypeUid
32+
} else {
33+
self.stack = stack!
34+
self.cachePolicy = cachePolicy!
35+
}
3136
}
3237

3338
/// Use this method to do a search on `Entries` which enables

Sources/QueryOperation.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ extension Query {
8585
case exists(Bool)
8686
/// Search on a field by Regex. <https://www.contentstack.com/docs/developers/apis/content-delivery-api/#search-by-regex>
8787
case matches(String)
88+
case eqBelow(String)
89+
case below(String)
90+
case eqAbove(String)
91+
case above(String)
8892

8993
internal var string: String {
9094
switch self {
@@ -98,6 +102,10 @@ extension Query {
98102
case .isGreaterThanOrEqual: return "$gte"
99103
case .exists: return "$exists"
100104
case .matches: return "$regex"
105+
case .eqBelow: return "$eq_below"
106+
case .below: return "$below"
107+
case .eqAbove: return "$eq_above"
108+
case .above: return "$above"
101109
}
102110
}
103111

@@ -137,6 +145,10 @@ extension Query {
137145
return value.stringValue
138146
case .exists(let value): return value
139147
case .matches(let value): return value
148+
case .eqBelow(let value): return value
149+
case .below(let value): return value
150+
case .eqAbove(let value): return value
151+
case .above(let value): return value
140152
}
141153
}
142154
internal var query: Any {

Sources/QueryParameter.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ internal enum QueryParameter {
3131
internal static let tags = "tags"
3232

3333
internal static let contentType = "content_type"
34+
35+
internal static let taxonomies = "taxonomies"
3436

3537
internal static let uid = "uid"
3638

Sources/QueryProtocols.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,20 @@ extension BaseQuery {
6565
/// }
6666
/// }
6767
/// ```
68+
///
6869
public func find<ResourceType>(_ completion: @escaping ResultsHandler<ContentstackResponse<ResourceType>>)
69-
where ResourceType: Decodable & EndpointAccessible {
70-
if self.queryParameter.count > 0,
71-
let query = self.queryParameter.jsonString {
72-
self.parameters[QueryParameter.query] = query
73-
}
74-
self.stack.fetch(endpoint: ResourceType.endpoint,
75-
cachePolicy: self.cachePolicy, parameters: parameters, headers: headers, then: completion)
70+
where ResourceType: Decodable & EndpointAccessible {
71+
if self.queryParameter.count > 0,
72+
let query = self.queryParameter.jsonString {
73+
self.parameters[QueryParameter.query] = query
74+
}
75+
self.stack.fetch(endpoint: ResourceType.endpoint,
76+
cachePolicy: self.cachePolicy, parameters: parameters, headers: headers, then: completion)
7677
}
7778
}
7879
/// A concrete implementation of BaseQuery which serves as the base class for `Query`,
7980
/// `ContentTypeQuery` and `AssetQuery`.
80-
public protocol BaseQuery: QueryProtocol, Queryable {}
81+
public protocol BaseQuery: QueryProtocol {}
8182
extension BaseQuery {
8283
/// Method to adding Query.Operation to a Query/
8384
/// - Parameters:

0 commit comments

Comments
 (0)