Skip to content

Commit 2053af0

Browse files
authored
Merge pull request #39 from contentstack/feat/DX-200_clone
feat: added support for taxonomy
2 parents 9154ab2 + 84b9800 commit 2053af0

20 files changed

Lines changed: 602 additions & 199 deletions

File tree

.github/workflows/sca-scan.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

Contentstack.xcodeproj/project.pbxproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@
9595
23A53F501E277BBE001DBE35 /* NSObject+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 23A53F331E276BA5001DBE35 /* NSObject+Extensions.m */; };
9696
23A53F5A1E277CD3001DBE35 /* Contentstack.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 230B38C01C16E98B00444A14 /* Contentstack.framework */; };
9797
23B6F12A1B5662EE00A9E983 /* ISO8601DateFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 23B6F1281B5662EE00A9E983 /* ISO8601DateFormatter.m */; };
98+
4714B7D42C5EAFCC004E941E /* Taxonomy.m in Sources */ = {isa = PBXBuildFile; fileRef = 4714B7D32C5EAFCC004E941E /* Taxonomy.m */; };
99+
479EC6642C5FCBDC00C5630B /* Taxonomy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4714B7D52C5EAFF5004E941E /* Taxonomy.h */; settings = {ATTRIBUTES = (Public, ); }; };
98100
565E11BB1BD76654005AD47F /* MMDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 565E11AA1BD76654005AD47F /* MMDocument.m */; };
99101
565E11BC1BD76654005AD47F /* MMElement.m in Sources */ = {isa = PBXBuildFile; fileRef = 565E11AD1BD76654005AD47F /* MMElement.m */; };
100102
565E11BD1BD76654005AD47F /* MMGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 565E11AF1BD76654005AD47F /* MMGenerator.m */; };
@@ -207,6 +209,8 @@
207209
23B6F1281B5662EE00A9E983 /* ISO8601DateFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ISO8601DateFormatter.m; sourceTree = "<group>"; };
208210
23C545FB1C1976FE007BBD27 /* ios-build-framework-script.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "ios-build-framework-script.sh"; sourceTree = "<group>"; };
209211
3CF581B9F7526EDA48ED5C6F /* Pods-ContentstackTest.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ContentstackTest.debug.xcconfig"; path = "Target Support Files/Pods-ContentstackTest/Pods-ContentstackTest.debug.xcconfig"; sourceTree = "<group>"; };
212+
4714B7D32C5EAFCC004E941E /* Taxonomy.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Taxonomy.m; sourceTree = "<group>"; };
213+
4714B7D52C5EAFF5004E941E /* Taxonomy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Taxonomy.h; sourceTree = "<group>"; };
210214
565E11A91BD76654005AD47F /* MMDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDocument.h; sourceTree = "<group>"; };
211215
565E11AA1BD76654005AD47F /* MMDocument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDocument.m; sourceTree = "<group>"; };
212216
565E11AB1BD76654005AD47F /* MMDocument_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDocument_Private.h; sourceTree = "<group>"; };
@@ -315,6 +319,8 @@
315319
0FD6BAEE29CD6E73001A0930 /* CSURLSessionDelegate.h */,
316320
0F9C0FAF221ADAC90091205A /* ThirdPartyNamespaceHeader */,
317321
230B38C41C16E98B00444A14 /* Info.plist */,
322+
4714B7D32C5EAFCC004E941E /* Taxonomy.m */,
323+
4714B7D52C5EAFF5004E941E /* Taxonomy.h */,
318324
);
319325
path = Contentstack;
320326
sourceTree = "<group>";
@@ -492,6 +498,7 @@
492498
isa = PBXHeadersBuildPhase;
493499
buildActionMask = 2147483647;
494500
files = (
501+
479EC6642C5FCBDC00C5630B /* Taxonomy.h in Headers */,
495502
0F9C0FC8221ADAC90091205A /* NamespacedDependencies.h in Headers */,
496503
23A53F3C1E276C83001DBE35 /* CSIOAPIURLs.h in Headers */,
497504
23A53F3E1E276C83001DBE35 /* CSIOCoreHTTPNetworking.h in Headers */,
@@ -769,6 +776,7 @@
769776
230B38EA1C16EB4400444A14 /* MMScanner.m in Sources */,
770777
230B38E81C16EB4400444A14 /* MMMarkdown.m in Sources */,
771778
230B38E91C16EB4400444A14 /* MMParser.m in Sources */,
779+
4714B7D42C5EAFCC004E941E /* Taxonomy.m in Sources */,
772780
230B38E51C16EB4400444A14 /* MMElement.m in Sources */,
773781
230B39021C16EB8F00444A14 /* ISO8601DateFormatter.m in Sources */,
774782
230B38E61C16EB4400444A14 /* MMGenerator.m in Sources */,
@@ -839,7 +847,7 @@
839847
ENABLE_TESTABILITY = YES;
840848
FRAMEWORK_SEARCH_PATHS = (
841849
"$(inherited)",
842-
"$(PROJECT_DIR)/ThirdPartyExtension",
850+
"$(PROJECT_DIR)/ThirdPartyExtension/**",
843851
);
844852
GCC_PREFIX_HEADER = ./Contentstack/ThirdPartyNamespaceHeader/NamespacedDependencies.h;
845853
INFOPLIST_FILE = Contentstack/Info.plist;
@@ -868,7 +876,7 @@
868876
DYLIB_INSTALL_NAME_BASE = "@rpath";
869877
FRAMEWORK_SEARCH_PATHS = (
870878
"$(inherited)",
871-
"$(PROJECT_DIR)/ThirdPartyExtension",
879+
"$(PROJECT_DIR)/ThirdPartyExtension/**",
872880
);
873881
GCC_PREFIX_HEADER = ./Contentstack/ThirdPartyNamespaceHeader/NamespacedDependencies.h;
874882
INFOPLIST_FILE = Contentstack/Info.plist;
@@ -917,7 +925,7 @@
917925
23A0F86A1B3801D1003334E9 /* Debug */ = {
918926
isa = XCBuildConfiguration;
919927
buildSettings = {
920-
ALWAYS_SEARCH_USER_PATHS = NO;
928+
ALWAYS_SEARCH_USER_PATHS = YES;
921929
BITCODE_GENERATION_MODE = marker;
922930
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
923931
CLANG_CXX_LIBRARY = "libc++";
@@ -972,7 +980,7 @@
972980
23A0F86B1B3801D1003334E9 /* Release */ = {
973981
isa = XCBuildConfiguration;
974982
buildSettings = {
975-
ALWAYS_SEARCH_USER_PATHS = NO;
983+
ALWAYS_SEARCH_USER_PATHS = YES;
976984
BITCODE_GENERATION_MODE = bitcode;
977985
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
978986
CLANG_CXX_LIBRARY = "libc++";
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>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Contentstack.xcodeproj/xcshareddata/xcschemes/Contentstack.xcscheme

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<MacroExpansion>
31+
<BuildableReference
32+
BuildableIdentifier = "primary"
33+
BlueprintIdentifier = "230B38BF1C16E98B00444A14"
34+
BuildableName = "Contentstack.framework"
35+
BlueprintName = "Contentstack"
36+
ReferencedContainer = "container:Contentstack.xcodeproj">
37+
</BuildableReference>
38+
</MacroExpansion>
3039
<Testables>
3140
<TestableReference
3241
skipped = "NO">
@@ -39,20 +48,9 @@
3948
</BuildableReference>
4049
</TestableReference>
4150
</Testables>
42-
<MacroExpansion>
43-
<BuildableReference
44-
BuildableIdentifier = "primary"
45-
BlueprintIdentifier = "230B38BF1C16E98B00444A14"
46-
BuildableName = "Contentstack.framework"
47-
BlueprintName = "Contentstack"
48-
ReferencedContainer = "container:Contentstack.xcodeproj">
49-
</BuildableReference>
50-
</MacroExpansion>
51-
<AdditionalOptions>
52-
</AdditionalOptions>
5351
</TestAction>
5452
<LaunchAction
55-
buildConfiguration = "Release"
53+
buildConfiguration = "Debug"
5654
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5755
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
5856
launchStyle = "0"
@@ -70,11 +68,9 @@
7068
ReferencedContainer = "container:Contentstack.xcodeproj">
7169
</BuildableReference>
7270
</MacroExpansion>
73-
<AdditionalOptions>
74-
</AdditionalOptions>
7571
</LaunchAction>
7672
<ProfileAction
77-
buildConfiguration = "Release"
73+
buildConfiguration = "Debug"
7874
shouldUseLaunchSchemeArgsEnv = "YES"
7975
savedToolIdentifier = ""
8076
useCustomWorkingDirectory = "NO"
@@ -93,7 +89,7 @@
9389
buildConfiguration = "Debug">
9490
</AnalyzeAction>
9591
<ArchiveAction
96-
buildConfiguration = "Release"
92+
buildConfiguration = "Debug"
9793
revealArchiveInOrganizer = "YES">
9894
</ArchiveAction>
9995
</Scheme>

Contentstack/Contentstack.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import <Contentstack/Config.h>
1313
#import <Contentstack/Stack.h>
1414
#import <Contentstack/ContentType.h>
15+
#import <Contentstack/Taxonomy.h>
1516
#import <Contentstack/Entry.h>
1617
#import <Contentstack/Query.h>
1718
#import <Contentstack/Asset.h>

Contentstack/Entry.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ - (instancetype)initWithContentType:(ContentType*)contentType withEntryUID:(NSSt
4949
return self;
5050
}
5151

52+
- (instancetype)initWithTaxonomy:(Taxonomy *)taxonomy {
53+
if (self = [super init]) {
54+
_taxonomy = taxonomy;
55+
_localHeaders = [NSMutableDictionary dictionary];
56+
_objectProperties = [NSMutableDictionary dictionary];
57+
_postParamDictionary = [NSMutableDictionary dictionary];
58+
}
59+
return self;
60+
}
61+
5262
-(void)setLanguage:(Language)language {
5363
_language = language;
5464
[self setLocale:[self localeCode:language]];
@@ -63,6 +73,9 @@ - (instancetype)initWithContentType:(ContentType*)contentType {
6373
return [self initWithContentType:contentType withEntryUID:nil];
6474
}
6575

76+
//- (instancetype)initWithTaxonomy:(Taxonomy*)taxonomy {
77+
// return [self initWithTaxonomy:taxonomy];
78+
//}
6679
//MARK: - Headers -
6780

6881
- (void)setHeader:(NSString *)headerValue forKey:(NSString *)headerKey {

Contentstack/Query.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ This method provides all the entries for the specified language in the response.
130130
*/
131131
- (void)search:(NSString *)searchString;
132132

133+
- (void)query:(NSDictionary *)queryString;
134+
133135
//MARK: - Tags -
134136
/**---------------------------------------------------------------------------------------
135137
* @name Tags
@@ -759,6 +761,9 @@ This method provides all the entries from a specified contenttype.
759761
*/
760762
- (void)find:(void (^) (ResponseType type,QueryResult * BUILT_NULLABLE_P result,NSError * BUILT_NULLABLE_P error))completionBlock;
761763

764+
765+
- (void)findTaxonomy:(void (^) (ResponseType type,QueryResult * BUILT_NULLABLE_P result,NSError * BUILT_NULLABLE_P error))completionBlock;
766+
762767
/**
763768
This method provides the first entry from a specified contenttype.
764769

Contentstack/Query.m

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import "CSIOAPIURLs.h"
1313
#import "QueryResult.h"
1414
#import "ContentType.h"
15+
#import "Taxonomy.h"
1516
#import "CSIOInternalHeaders.h"
1617
#import "NSObject+Extensions.h"
1718

@@ -39,6 +40,16 @@ - (instancetype)initWithContentType:(ContentType*)contentType {
3940
return self;
4041
}
4142

43+
- (instancetype)initWithTaxonomy:(Taxonomy*)taxonomy {
44+
if (self = [super init]) {
45+
_taxonomy = taxonomy;
46+
_localHeaders = [NSMutableDictionary dictionary];
47+
_queryDictionary = [NSMutableDictionary dictionary];
48+
_requestOperationSet = [NSMutableSet set];
49+
}
50+
return self;
51+
}
52+
4253
//MARK: - Headers
4354

4455
- (void)setHeader:(NSString *)headerValue forKey:(NSString *)headerKey {
@@ -84,6 +95,11 @@ - (void)tags:(NSArray*)tagsArray {
8495
[self.queryDictionary setObject:[tagsArray componentsJoinedByString:@","] forKey:kCSIO_Tags];
8596
}
8697

98+
//MARK: - Query -
99+
- (void)query:(NSDictionary *)query {
100+
[self.queryDictionary setObject:query forKey:kCSIO_Queryable];
101+
}
102+
87103
////MARK: - Before/After UID -
88104
//- (void)beforeUID:(NSString *)uid {
89105
// [self.queryDictionary setObject:uid forKey:kCSIO_BeforeUID];
@@ -501,6 +517,35 @@ - (void)find:(void (^) (ResponseType type,QueryResult * BUILT_NULLABLE_P result,
501517
}
502518
}
503519

520+
//MARK: Execute Query -
521+
522+
- (void)findTaxonomy:(void (^) (ResponseType type,QueryResult * BUILT_NULLABLE_P result,NSError * BUILT_NULLABLE_P error))completionBlock {
523+
524+
[self.queryDictionary setObject:self.taxonomy.stack.environment forKey:kCSIO_Environment];
525+
526+
NSMutableDictionary *paramDictionary = [NSMutableDictionary dictionaryWithDictionary:self.queryDictionary];
527+
528+
NSMutableDictionary *headers = [NSMutableDictionary dictionaryWithDictionary:self.taxonomy.headers];
529+
530+
[headers addEntriesFromDictionary:self.localHeaders];
531+
532+
NSString *path = [CSIOAPIURLs fetchTaxonomyWithVersion:self.taxonomy.stack.version];
533+
534+
NSURLSessionDataTask *op = [self.taxonomy.stack.network requestForStack:self.taxonomy.stack withURLPath:path requestType:CSIOCoreNetworkingRequestTypeGET params:paramDictionary additionalHeaders:headers cachePolicy:self.cachePolicy completion:^(ResponseType responseType, id responseJSON, NSError *error) {
535+
536+
if (error) {
537+
completionBlock(responseType, nil, error);
538+
}else {
539+
QueryResult *queryResult = [[QueryResult alloc] initWithTaxonomy:self.taxonomy objectDictionary:responseJSON];
540+
541+
completionBlock(responseType, queryResult, nil);
542+
}
543+
}];
544+
if (op && ![op isKindOfClass:[NSNull class]]) {
545+
[self.requestOperationSet addObject:op];
546+
}
547+
}
548+
504549
- (void)findOne:(void (^) (ResponseType type,Entry * BUILT_NULLABLE_P entry,NSError * BUILT_NULLABLE_P error))completionBlock {
505550
[self.queryDictionary setObject:@(1) forKey:kCSIO_Limit];
506551

Contentstack/QueryResult.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212
BUILT_ASSUME_NONNULL_BEGIN
1313

1414
@class ContentType;
15+
@class Taxonomy;
1516
@class Entry;
1617
@interface QueryResult : NSObject
1718

1819

1920
- (instancetype)init UNAVAILABLE_ATTRIBUTE;
2021

22+
//- (BUILT_NULLABLE NSArray<Entry *> *)getResult;
23+
- (instancetype)initWithTaxonomy:(Taxonomy*)taxonomy objectDictionary:(NSDictionary*)dictionary;
24+
2125
//MARK: Result -
2226
/**---------------------------------------------------------------------------------------
2327
* @name Result

Contentstack/QueryResult.m

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#import "CSIOInternalHeaders.h"
1111
#import "CSIOConstants.h"
1212
#import "ContentType.h"
13+
#import "Taxonomy.h"
1314
#import "Entry.h"
1415

1516
@interface QueryResult ()
@@ -30,6 +31,17 @@ - (instancetype)initWithContentType:(ContentType*)contentType objectDictionary:(
3031
return self;
3132
}
3233

34+
- (instancetype)initWithTaxonomy:(Taxonomy*)taxonomy objectDictionary:(NSDictionary*)dictionary{
35+
if (self = [super init]) {
36+
self.taxonomy = taxonomy;
37+
self.resultsDictionary = [NSMutableDictionary dictionary];
38+
if (dictionary) {
39+
[self.resultsDictionary addEntriesFromDictionary:dictionary];
40+
}
41+
}
42+
return self;
43+
}
44+
3345
- (NSInteger)totalCount {
3446

3547
if ([self.resultsDictionary objectForKey:kCSIO_Count]) {
@@ -55,7 +67,13 @@ - (NSInteger)totalCount {
5567
NSArray *objectsArray = (NSArray*)[self.resultsDictionary objectForKey:kCSIO_Entries];
5668
NSMutableArray *entryObjects = [NSMutableArray array];
5769
// if condition is fix for value of "entries" key ie.array inside array in response JSON
58-
if (objectsArray.firstObject && [objectsArray.firstObject isKindOfClass:[NSArray class]]) {
70+
if (objectsArray.firstObject && [objectsArray.firstObject isKindOfClass:[NSDictionary class]]) {
71+
[objectsArray enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL * _Nonnull stop) {
72+
Entry *formEntry = [self.taxonomy entry];
73+
[formEntry configureWithDictionary:obj];
74+
[entryObjects addObject:formEntry];
75+
}];
76+
} else if (objectsArray.firstObject && [objectsArray.firstObject isKindOfClass:[NSArray class]]) {
5977
[objectsArray enumerateObjectsUsingBlock:^(NSArray *obj, NSUInteger idx, BOOL * _Nonnull stop) {
6078
[obj enumerateObjectsUsingBlock:^(NSDictionary *objDict, NSUInteger idx, BOOL * _Nonnull stop) {
6179
Entry *formEntry = [self.contentType entry];

0 commit comments

Comments
 (0)