@contentstack/cli-variants 0.0.1-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/lib/export/attributes.d.ts +15 -0
  2. package/lib/export/attributes.js +62 -0
  3. package/lib/export/audiences.d.ts +15 -0
  4. package/lib/export/audiences.js +63 -0
  5. package/lib/export/events.d.ts +15 -0
  6. package/lib/export/events.js +63 -0
  7. package/lib/export/experiences.d.ts +9 -0
  8. package/lib/export/experiences.js +99 -0
  9. package/lib/export/index.d.ts +9 -0
  10. package/lib/export/index.js +21 -0
  11. package/lib/export/projects.d.ts +9 -0
  12. package/lib/export/projects.js +73 -0
  13. package/lib/export/variant-entries.d.ts +18 -0
  14. package/lib/export/variant-entries.js +109 -0
  15. package/lib/import/attribute.d.ts +17 -0
  16. package/lib/import/attribute.js +64 -0
  17. package/lib/import/audiences.d.ts +19 -0
  18. package/lib/import/audiences.js +71 -0
  19. package/lib/import/events.d.ts +17 -0
  20. package/lib/import/events.js +62 -0
  21. package/lib/import/experiences.d.ts +46 -0
  22. package/lib/import/experiences.js +214 -0
  23. package/lib/import/index.d.ts +14 -0
  24. package/lib/import/index.js +21 -0
  25. package/lib/import/project.d.ts +13 -0
  26. package/lib/import/project.js +74 -0
  27. package/lib/import/variant-entries.d.ts +98 -0
  28. package/lib/import/variant-entries.js +407 -0
  29. package/lib/index.d.ts +5 -0
  30. package/lib/index.js +21 -0
  31. package/lib/messages/index.d.ts +35 -0
  32. package/lib/messages/index.js +55 -0
  33. package/lib/types/adapter-helper.d.ts +8 -0
  34. package/lib/types/adapter-helper.js +2 -0
  35. package/lib/types/content-types.d.ts +19 -0
  36. package/lib/types/content-types.js +2 -0
  37. package/lib/types/export-config.d.ts +264 -0
  38. package/lib/types/export-config.js +2 -0
  39. package/lib/types/import-config.d.ts +92 -0
  40. package/lib/types/import-config.js +2 -0
  41. package/lib/types/index.d.ts +8 -0
  42. package/lib/types/index.js +24 -0
  43. package/lib/types/personalization-api-adapter.d.ts +152 -0
  44. package/lib/types/personalization-api-adapter.js +2 -0
  45. package/lib/types/utils.d.ts +7 -0
  46. package/lib/types/utils.js +2 -0
  47. package/lib/types/variant-api-adapter.d.ts +49 -0
  48. package/lib/types/variant-api-adapter.js +2 -0
  49. package/lib/types/variant-entry.d.ts +47 -0
  50. package/lib/types/variant-entry.js +2 -0
  51. package/lib/utils/adapter-helper.d.ts +30 -0
  52. package/lib/utils/adapter-helper.js +95 -0
  53. package/lib/utils/attributes-helper.d.ts +7 -0
  54. package/lib/utils/attributes-helper.js +37 -0
  55. package/lib/utils/audiences-helper.d.ts +8 -0
  56. package/lib/utils/audiences-helper.js +49 -0
  57. package/lib/utils/error-helper.d.ts +6 -0
  58. package/lib/utils/error-helper.js +27 -0
  59. package/lib/utils/events-helper.d.ts +8 -0
  60. package/lib/utils/events-helper.js +27 -0
  61. package/lib/utils/helper.d.ts +4 -0
  62. package/lib/utils/helper.js +51 -0
  63. package/lib/utils/index.d.ts +9 -0
  64. package/lib/utils/index.js +25 -0
  65. package/lib/utils/logger.d.ts +3 -0
  66. package/lib/utils/logger.js +175 -0
  67. package/lib/utils/personalization-api-adapter.d.ts +73 -0
  68. package/lib/utils/personalization-api-adapter.js +184 -0
  69. package/lib/utils/variant-api-adapter.d.ts +79 -0
  70. package/lib/utils/variant-api-adapter.js +263 -0
  71. package/package.json +38 -0
  72. package/src/export/attributes.ts +55 -0
  73. package/src/export/audiences.ts +57 -0
  74. package/src/export/events.ts +57 -0
  75. package/src/export/experiences.ts +80 -0
  76. package/src/export/index.ts +11 -0
  77. package/src/export/projects.ts +45 -0
  78. package/src/export/variant-entries.ts +88 -0
  79. package/src/import/attribute.ts +60 -0
  80. package/src/import/audiences.ts +69 -0
  81. package/src/import/events.ts +58 -0
  82. package/src/import/experiences.ts +224 -0
  83. package/src/import/index.ts +16 -0
  84. package/src/import/project.ts +71 -0
  85. package/src/import/variant-entries.ts +483 -0
  86. package/src/index.ts +5 -0
  87. package/src/messages/index.ts +63 -0
  88. package/src/types/adapter-helper.ts +10 -0
  89. package/src/types/content-types.ts +41 -0
  90. package/src/types/export-config.ts +292 -0
  91. package/src/types/import-config.ts +95 -0
  92. package/src/types/index.ts +8 -0
  93. package/src/types/personalization-api-adapter.ts +197 -0
  94. package/src/types/utils.ts +8 -0
  95. package/src/types/variant-api-adapter.ts +56 -0
  96. package/src/types/variant-entry.ts +61 -0
  97. package/src/utils/adapter-helper.ts +79 -0
  98. package/src/utils/attributes-helper.ts +31 -0
  99. package/src/utils/audiences-helper.ts +50 -0
  100. package/src/utils/error-helper.ts +26 -0
  101. package/src/utils/events-helper.ts +26 -0
  102. package/src/utils/helper.ts +34 -0
  103. package/src/utils/index.ts +9 -0
  104. package/src/utils/logger.ts +160 -0
  105. package/src/utils/personalization-api-adapter.ts +188 -0
  106. package/src/utils/variant-api-adapter.ts +326 -0
  107. package/test/unit/export/variant-entries.test.ts +80 -0
  108. package/test/unit/import/variant-entries.test.ts +200 -0
  109. package/test/unit/mock/contents/content_types/CT-1.json +7 -0
  110. package/test/unit/mock/contents/entries/CT-1/en-us/variants/E-1/9b0da6xd7et72y-6gv7he23.json +12 -0
  111. package/test/unit/mock/contents/entries/CT-1/en-us/variants/E-1/index.json +3 -0
  112. package/test/unit/mock/contents/entries/CT-1/en-us/variants/E-2/9b0da6xd7et72y-6gv7he23.json +12 -0
  113. package/test/unit/mock/contents/entries/CT-1/en-us/variants/E-2/index.json +3 -0
  114. package/test/unit/mock/contents/mapper/assets/uid-mapping.json +6 -0
  115. package/test/unit/mock/contents/mapper/assets/url-mapping.json +6 -0
  116. package/test/unit/mock/contents/mapper/entries/data-for-variant-entry.json +6 -0
  117. package/test/unit/mock/contents/mapper/entries/empty-data/data-for-variant-entry.json +1 -0
  118. package/test/unit/mock/contents/mapper/entries/uid-mapping.json +6 -0
  119. package/test/unit/mock/contents/mapper/marketplace_apps/uid-mapping.json +3 -0
  120. package/test/unit/mock/contents/mapper/personalization/experiences/variants-uid-mapping.json +5 -0
  121. package/test/unit/mock/contents/mapper/taxonomies/terms/success.json +1 -0
  122. package/test/unit/mock/export-config.json +48 -0
  123. package/test/unit/mock/import-config.json +63 -0
  124. package/tsconfig.json +19 -0
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,264 @@
1
+ /**
2
+ * NOTE: Accessing ExportConfig from the export package is not possible
3
+ * because it will create a circular dependency and cause the prepack/build command to fail.
4
+ * Therefore, we are duplicating the following types from the export.
5
+ */
6
+ import { AnyProperty } from './utils';
7
+ export type Modules = 'stack' | 'assets' | 'locales' | 'environments' | 'extensions' | 'webhooks' | 'global-fields' | 'entries' | 'content-types' | 'custom-roles' | 'workflows' | 'labels' | 'marketplace-apps' | 'taxonomies' | 'personalization';
8
+ export type branch = {
9
+ uid: string;
10
+ source: string;
11
+ };
12
+ export type masterLocale = {
13
+ code: string;
14
+ };
15
+ export interface DefaultConfig {
16
+ contentVersion: number;
17
+ versioning: boolean;
18
+ host: string;
19
+ cdn?: string;
20
+ developerHubUrls: any;
21
+ modules: {
22
+ types: Modules[];
23
+ locales: {
24
+ dirName: string;
25
+ fileName: string;
26
+ requiredKeys: string[];
27
+ dependencies?: Modules[];
28
+ };
29
+ customRoles: {
30
+ dirName: string;
31
+ fileName: string;
32
+ customRolesLocalesFileName: string;
33
+ dependencies?: Modules[];
34
+ };
35
+ 'custom-roles': {
36
+ dirName: string;
37
+ fileName: string;
38
+ customRolesLocalesFileName: string;
39
+ dependencies?: Modules[];
40
+ };
41
+ environments: {
42
+ dirName: string;
43
+ fileName: string;
44
+ dependencies?: Modules[];
45
+ };
46
+ labels: {
47
+ dirName: string;
48
+ fileName: string;
49
+ invalidKeys: string[];
50
+ dependencies?: Modules[];
51
+ };
52
+ webhooks: {
53
+ dirName: string;
54
+ fileName: string;
55
+ dependencies?: Modules[];
56
+ };
57
+ releases: {
58
+ dirName: string;
59
+ fileName: string;
60
+ releasesList: string;
61
+ invalidKeys: string[];
62
+ dependencies?: Modules[];
63
+ };
64
+ workflows: {
65
+ dirName: string;
66
+ fileName: string;
67
+ invalidKeys: string[];
68
+ dependencies?: Modules[];
69
+ };
70
+ globalfields: {
71
+ dirName: string;
72
+ fileName: string;
73
+ validKeys: string[];
74
+ dependencies?: Modules[];
75
+ };
76
+ 'global-fields': {
77
+ dirName: string;
78
+ fileName: string;
79
+ validKeys: string[];
80
+ dependencies?: Modules[];
81
+ };
82
+ assets: {
83
+ dirName: string;
84
+ fileName: string;
85
+ batchLimit: number;
86
+ host: string;
87
+ invalidKeys: string[];
88
+ chunkFileSize: number;
89
+ downloadLimit: number;
90
+ fetchConcurrency: number;
91
+ assetsMetaKeys: string[];
92
+ securedAssets: boolean;
93
+ displayExecutionTime: boolean;
94
+ enableDownloadStatus: boolean;
95
+ includeVersionedAssets: boolean;
96
+ dependencies?: Modules[];
97
+ };
98
+ content_types: {
99
+ dirName: string;
100
+ fileName: string;
101
+ validKeys: string[];
102
+ limit: number;
103
+ dependencies?: Modules[];
104
+ };
105
+ 'content-types': {
106
+ dirName: string;
107
+ fileName: string;
108
+ validKeys: string[];
109
+ limit: number;
110
+ dependencies?: Modules[];
111
+ };
112
+ entries: {
113
+ dirName: string;
114
+ fileName: string;
115
+ invalidKeys: string[];
116
+ batchLimit: number;
117
+ downloadLimit: number;
118
+ limit: number;
119
+ dependencies?: Modules[];
120
+ exportVersions: boolean;
121
+ };
122
+ variantEntry: {
123
+ dirName: string;
124
+ fileName: string;
125
+ chunkFileSize: number;
126
+ query: {
127
+ skip: number;
128
+ limit: number;
129
+ include_variant: boolean;
130
+ include_count: boolean;
131
+ include_publish_details: boolean;
132
+ } & AnyProperty;
133
+ } & AnyProperty;
134
+ personalization: {
135
+ dirName: string;
136
+ baseURL: Record<string, string>;
137
+ } & AnyProperty;
138
+ extensions: {
139
+ dirName: string;
140
+ fileName: string;
141
+ dependencies?: Modules[];
142
+ };
143
+ stack: {
144
+ dirName: string;
145
+ fileName: string;
146
+ dependencies?: Modules[];
147
+ };
148
+ dependency: {
149
+ entries: string[];
150
+ };
151
+ marketplace_apps: {
152
+ dirName: string;
153
+ fileName: string;
154
+ dependencies?: Modules[];
155
+ };
156
+ 'marketplace-apps': {
157
+ dirName: string;
158
+ fileName: string;
159
+ dependencies?: Modules[];
160
+ };
161
+ masterLocale: {
162
+ dirName: string;
163
+ fileName: string;
164
+ requiredKeys: string[];
165
+ };
166
+ taxonomies: {
167
+ dirName: string;
168
+ fileName: string;
169
+ invalidKeys: string[];
170
+ dependencies?: Modules[];
171
+ };
172
+ events: {
173
+ dirName: string;
174
+ fileName: string;
175
+ invalidKeys: string[];
176
+ dependencies?: Modules[];
177
+ };
178
+ audiences: {
179
+ dirName: string;
180
+ fileName: string;
181
+ invalidKeys: string[];
182
+ dependencies?: Modules[];
183
+ };
184
+ attributes: {
185
+ dirName: string;
186
+ fileName: string;
187
+ invalidKeys: string[];
188
+ dependencies?: Modules[];
189
+ };
190
+ };
191
+ languagesCode: string[];
192
+ apis: {
193
+ userSession: string;
194
+ globalfields: string;
195
+ locales: string;
196
+ labels: string;
197
+ environments: string;
198
+ assets: string;
199
+ content_types: string;
200
+ entries: string;
201
+ users: string;
202
+ extension: string;
203
+ webhooks: string;
204
+ stacks: string;
205
+ };
206
+ preserveStackVersion: boolean;
207
+ fetchConcurrency: number;
208
+ writeConcurrency: number;
209
+ developerHubBaseUrl: string;
210
+ marketplaceAppEncryptionKey: string;
211
+ onlyTSModules: string[];
212
+ }
213
+ export interface ExportConfig extends DefaultConfig {
214
+ exportDir: string;
215
+ data: string;
216
+ management_token?: string;
217
+ apiKey: string;
218
+ forceStopMarketplaceAppsPrompt: boolean;
219
+ auth_token?: string;
220
+ branchName?: string;
221
+ securedAssets?: boolean;
222
+ contentTypes?: string[];
223
+ branches?: branch[];
224
+ branchEnabled?: boolean;
225
+ branchDir?: string;
226
+ singleModuleExport?: boolean;
227
+ moduleName?: Modules;
228
+ master_locale: masterLocale;
229
+ headers?: {
230
+ api_key?: string;
231
+ access_token?: string;
232
+ authtoken?: string;
233
+ 'X-User-Agent': string;
234
+ organization_uid?: string;
235
+ 'X-Project-Uid'?: string;
236
+ };
237
+ project_id?: string;
238
+ access_token?: string;
239
+ org_uid?: string;
240
+ source_stack?: string;
241
+ sourceStackName?: string;
242
+ personalizationEnabled: boolean;
243
+ personalizationHost?: string;
244
+ region: any;
245
+ }
246
+ export interface PersonalizationConfig {
247
+ dirName: string;
248
+ baseURL: Record<string, string>;
249
+ }
250
+ export interface EventsConfig {
251
+ dirName: string;
252
+ fileName: string;
253
+ invalidKeys: string[];
254
+ }
255
+ export interface AudiencesConfig {
256
+ dirName: string;
257
+ fileName: string;
258
+ invalidKeys: string[];
259
+ }
260
+ export interface AttributesConfig {
261
+ dirName: string;
262
+ fileName: string;
263
+ invalidKeys: string[];
264
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,92 @@
1
+ import { AnyProperty } from './utils';
2
+ export interface ImportDefaultConfig extends AnyProperty {
3
+ modules: {
4
+ 'content-types': {
5
+ dirName: string;
6
+ fileName: string;
7
+ validKeys: string[];
8
+ limit: number;
9
+ };
10
+ entries: {
11
+ dirName: string;
12
+ fileName: string;
13
+ };
14
+ personalization: {
15
+ baseURL: Record<string, string>;
16
+ dirName: string;
17
+ importData: boolean;
18
+ importOrder: string[];
19
+ project_id?: string;
20
+ projects: {
21
+ dirName: string;
22
+ fileName: string;
23
+ };
24
+ attributes: {
25
+ dirName: string;
26
+ fileName: string;
27
+ };
28
+ audiences: {
29
+ dirName: string;
30
+ fileName: string;
31
+ };
32
+ events: {
33
+ dirName: string;
34
+ fileName: string;
35
+ };
36
+ experiences: {
37
+ dirName: string;
38
+ fileName: string;
39
+ thresholdTimer: number;
40
+ checkIntervalDuration: number;
41
+ };
42
+ };
43
+ variantEntry: {
44
+ dirName: string;
45
+ fileName: string;
46
+ apiConcurrency: number;
47
+ query: {
48
+ locale: string;
49
+ } & AnyProperty;
50
+ } & AnyProperty;
51
+ } & AnyProperty;
52
+ }
53
+ export interface ImportConfig extends ImportDefaultConfig, AnyProperty {
54
+ contentDir: string;
55
+ data: string;
56
+ management_token?: string;
57
+ apiKey: string;
58
+ auth_token?: string;
59
+ branchName?: string;
60
+ branches?: branch[];
61
+ branchEnabled?: boolean;
62
+ branchDir?: string;
63
+ master_locale: masterLocale;
64
+ headers?: {
65
+ api_key: string;
66
+ access_token?: string;
67
+ authtoken?: string;
68
+ 'X-User-Agent': string;
69
+ 'X-Project-Uid'?: string;
70
+ };
71
+ access_token?: string;
72
+ isAuthenticated?: boolean;
73
+ target_stack?: string;
74
+ singleModuleImport?: boolean;
75
+ masterLocale: masterLocale;
76
+ backupDir: string;
77
+ authtoken?: string;
78
+ destinationStackName?: string;
79
+ org_uid?: string;
80
+ contentVersion: number;
81
+ replaceExisting?: boolean;
82
+ skipExisting?: boolean;
83
+ stackName?: string;
84
+ }
85
+ type branch = {
86
+ uid: string;
87
+ source: string;
88
+ };
89
+ type masterLocale = {
90
+ code: string;
91
+ };
92
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ export * from './utils';
2
+ export * from './export-config';
3
+ export * from './import-config';
4
+ export * from './variant-entry';
5
+ export * from './content-types';
6
+ export * from './adapter-helper';
7
+ export * from './variant-api-adapter';
8
+ export * from './personalization-api-adapter';
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./utils"), exports);
18
+ __exportStar(require("./export-config"), exports);
19
+ __exportStar(require("./import-config"), exports);
20
+ __exportStar(require("./variant-entry"), exports);
21
+ __exportStar(require("./content-types"), exports);
22
+ __exportStar(require("./adapter-helper"), exports);
23
+ __exportStar(require("./variant-api-adapter"), exports);
24
+ __exportStar(require("./personalization-api-adapter"), exports);
@@ -0,0 +1,152 @@
1
+ import { HttpClient } from '@contentstack/cli-utilities';
2
+ import { AnyProperty } from './utils';
3
+ import { AdapterHelperInterface } from './adapter-helper';
4
+ export type ProjectStruct = {
5
+ _id: string;
6
+ uid: string;
7
+ name: string;
8
+ description: string;
9
+ audienceCount: number;
10
+ organizationUid: string;
11
+ activeExperienceCount: number;
12
+ } & AnyProperty;
13
+ export type GetProjectsParams = {
14
+ connectedStackApiKey: string;
15
+ includeAudienceCount?: boolean;
16
+ includeActiveExperienceCount?: boolean;
17
+ callback?: (value: ProjectStruct[]) => void;
18
+ } & AnyProperty;
19
+ export interface CreateProjectInput {
20
+ name: string;
21
+ description: string;
22
+ connectedStackApiKey?: string;
23
+ }
24
+ export type GetVariantGroupInput = {
25
+ experienceUid: string;
26
+ };
27
+ export type VariantGroup = {
28
+ uid: string;
29
+ name: string;
30
+ content_types: string[];
31
+ description: string;
32
+ } & AnyProperty;
33
+ export type VariantGroupStruct = {
34
+ variant_groups: Array<VariantGroup>;
35
+ } & AnyProperty;
36
+ export type EventStruct = {
37
+ _id: string;
38
+ uid: string;
39
+ key: string;
40
+ name: string;
41
+ description: string;
42
+ project: string;
43
+ } & AnyProperty;
44
+ export type AudienceStruct = {
45
+ _id: string;
46
+ uid: string;
47
+ definition: {
48
+ _type: string;
49
+ combinationType: string;
50
+ rules: Record<string, any>[];
51
+ };
52
+ name: string;
53
+ description: string;
54
+ project: string;
55
+ } & AnyProperty;
56
+ export type AttributeStruct = {
57
+ _id: string;
58
+ uid: string;
59
+ key: string;
60
+ name: string;
61
+ project: string;
62
+ description: string;
63
+ } & AnyProperty;
64
+ export interface CreateAttributeInput {
65
+ name: string;
66
+ key: string;
67
+ description: string;
68
+ }
69
+ export interface CreateEventInput {
70
+ key: string;
71
+ description: string;
72
+ }
73
+ export interface CreateAudienceInput {
74
+ name: string;
75
+ definition: object;
76
+ description: string;
77
+ }
78
+ type ExpVariations = {
79
+ name: string;
80
+ __type: string;
81
+ audiences?: string[];
82
+ audienceCombinationType?: string;
83
+ shortUid?: string;
84
+ trafficDistribution?: string;
85
+ } & AnyProperty;
86
+ type ExpTargeting = {
87
+ audience?: {
88
+ audiences?: string[];
89
+ audienceCombinationType?: string;
90
+ } & AnyProperty;
91
+ };
92
+ export type ExpMetric = {
93
+ event: string;
94
+ name: string;
95
+ __type: string;
96
+ } & AnyProperty;
97
+ export type ExperienceStruct = {
98
+ _id: string;
99
+ uid: string;
100
+ name: string;
101
+ __type: string;
102
+ description: string;
103
+ targeting?: ExpTargeting;
104
+ variations: ExpVariations[];
105
+ variationSplit?: string;
106
+ metrics?: ExpMetric[];
107
+ status: string;
108
+ metadata?: object;
109
+ _cms?: {
110
+ variantGroup: object;
111
+ variants: Record<string, string>;
112
+ };
113
+ content_types?: string[];
114
+ } & AnyProperty;
115
+ export interface CreateExperienceInput {
116
+ name: string;
117
+ __type: string;
118
+ description: string;
119
+ targeting?: ExpTargeting;
120
+ variations: ExpVariations[];
121
+ variationSplit?: string;
122
+ metrics?: ExpMetric[];
123
+ status: string;
124
+ metadata?: object;
125
+ }
126
+ export interface UpdateExperienceInput {
127
+ contentTypes: string[];
128
+ }
129
+ export interface CMSExperienceStruct {
130
+ uid: string;
131
+ contentTypes: string[];
132
+ content_types?: string[];
133
+ }
134
+ export type VariantAPIRes = ProjectStruct[] | ProjectStruct | AttributeStruct[] | AttributeStruct | ExperienceStruct[] | EventStruct[] | AudienceStruct[] | ExperienceStruct | EventStruct | AudienceStruct | CMSExperienceStruct | VariantGroupStruct | Error;
135
+ export interface APIResponse {
136
+ status: number;
137
+ data: any;
138
+ }
139
+ export interface Personalization<T> extends AdapterHelperInterface<T, HttpClient> {
140
+ projects(options: GetProjectsParams): Promise<ProjectStruct[] | void>;
141
+ createProject(project: CreateProjectInput): Promise<ProjectStruct | void>;
142
+ getEvents(): Promise<EventStruct[] | void>;
143
+ getAudiences(): Promise<AudienceStruct[] | void>;
144
+ getAttributes(): Promise<AttributeStruct[] | void>;
145
+ createAttribute(attribute: CreateAttributeInput): Promise<AttributeStruct | void>;
146
+ createAudience(attribute: CreateAudienceInput): Promise<AudienceStruct | void>;
147
+ createExperience(experience: CreateExperienceInput): Promise<ExperienceStruct | void>;
148
+ getCTsFromExperience(experienceUid: string): Promise<CMSExperienceStruct | void>;
149
+ updateCTsInExperience(experience: UpdateExperienceInput, experienceUid: string): Promise<CMSExperienceStruct | void>;
150
+ handleVariantAPIRes(res: any): VariantAPIRes;
151
+ }
152
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export interface AnyProperty {
2
+ [propName: string]: any;
3
+ }
4
+ export interface LogType {
5
+ (message: any): void;
6
+ (config: any, message: any, type: 'info' | 'error' | 'success'): void;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,49 @@
1
+ import { HttpClientOptions, HttpRequestConfig } from '@contentstack/cli-utilities';
2
+ import { APIResponse } from '../types';
3
+ import { AnyProperty } from './utils';
4
+ import { ExportConfig } from './export-config';
5
+ import { AdapterHelperInterface } from './adapter-helper';
6
+ import { CreateVariantEntryDto, CreateVariantEntryOptions, VariantEntryStruct } from './variant-entry';
7
+ export type APIConfig = HttpRequestConfig & {
8
+ httpClient?: boolean;
9
+ sharedConfig?: ExportConfig | Record<string, any> | undefined;
10
+ personalizationURL?: string;
11
+ config: ExportConfig | Record<string, any> | undefined;
12
+ baseURL?: string;
13
+ cmaConfig?: HttpRequestConfig;
14
+ };
15
+ export interface AdapterConstructor<T, C> {
16
+ new (config: C, options?: HttpClientOptions): T;
17
+ }
18
+ export type AdapterType<T, C> = {
19
+ Adapter: AdapterConstructor<T, C>;
20
+ };
21
+ export type VariantsOption = {
22
+ skip?: number;
23
+ limit?: number;
24
+ locale?: string;
25
+ entry_uid: string;
26
+ getAllData?: boolean;
27
+ returnResult?: boolean;
28
+ content_type_uid: string;
29
+ include_variant?: boolean;
30
+ include_count?: boolean;
31
+ include_publish_details?: boolean;
32
+ callback?: (value: Record<string, any>[]) => void;
33
+ } & AnyProperty;
34
+ export type VariantOptions = VariantsOption & {
35
+ variant_uid: string;
36
+ };
37
+ export interface VariantInterface<T, ApiClient> extends AdapterHelperInterface<T, ApiClient> {
38
+ variantEntry(options: VariantOptions): Promise<{
39
+ entry: Record<string, any>;
40
+ }>;
41
+ variantEntries(options: VariantsOption): Promise<{
42
+ entries?: Record<string, any>[] | unknown[];
43
+ } | void>;
44
+ createVariantEntry(input: CreateVariantEntryDto, options: CreateVariantEntryOptions, apiParams: Record<string, any>): Promise<VariantEntryStruct | string | void>;
45
+ handleVariantAPIRes(res: APIResponse): VariantEntryStruct | {
46
+ entries: VariantEntryStruct[];
47
+ count: number;
48
+ } | string;
49
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,47 @@
1
+ import { AnyProperty } from './utils';
2
+ export type VariantEntryStruct = {
3
+ uid: string;
4
+ title: string;
5
+ variant_id: string;
6
+ locale: string;
7
+ _version: number;
8
+ _variant: {
9
+ uid: string;
10
+ _change_set: string[];
11
+ _base_entry_version: number;
12
+ };
13
+ publish_details: Record<string, any>[];
14
+ } & AnyProperty;
15
+ export type EntryDataForVariantEntries = {
16
+ content_type: string;
17
+ locale: string;
18
+ entry_uid: string;
19
+ };
20
+ export type CreateVariantEntryDto = {
21
+ _variant: {
22
+ _change_set: string[];
23
+ };
24
+ } & AnyProperty;
25
+ export type CreateVariantEntryOptions = {
26
+ locale?: string;
27
+ entry_uid: string;
28
+ variant_id: string;
29
+ content_type_uid: string;
30
+ };
31
+ export type PublishVariantEntryOptions = {
32
+ entry_uid: string;
33
+ content_type_uid: string;
34
+ };
35
+ export type PublishVariantEntryDto = {
36
+ entry: {
37
+ environments: string[];
38
+ locales: string[];
39
+ publish_with_base_entry: boolean;
40
+ variants: {
41
+ uid: string;
42
+ version?: number;
43
+ }[];
44
+ };
45
+ locale: string;
46
+ version?: number;
47
+ } & AnyProperty;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });