@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,3 @@
1
+ {
2
+ "extension_uid": {}
3
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "OLD-UID-1": "NEW-UID-1",
3
+ "OLD-UID-2": "NEW-UID-2",
4
+ "OLD-UID-3": "NEW-UID-3"
5
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "data": "./",
3
+ "exportDir": "./",
4
+ "apiKey": "TEST-STACK-API-KEY",
5
+ "master_locale": { "code": "en-us" },
6
+ "host": "https://test.abc.com",
7
+ "modules": {
8
+ "entries": {
9
+ "dirName": "entries",
10
+ "fileName": "entries.json",
11
+ "invalidKeys": [
12
+ "stackHeaders",
13
+ "content_type_uid",
14
+ "urlPath",
15
+ "created_at",
16
+ "updated_at",
17
+ "created_by",
18
+ "updated_by",
19
+ "_metadata",
20
+ "published"
21
+ ],
22
+ "batchLimit": 20,
23
+ "downloadLimit": 5,
24
+ "limit": 100,
25
+ "dependencies": ["locales", "content-types"],
26
+ "exportVersions": false
27
+ },
28
+ "personalization": {
29
+ "dirName": "personalization",
30
+ "baseURL": "https://test-api.abc.com",
31
+ "exportOrder": ["attributes", "audiences", "events", "experiences"],
32
+ "projects": { "dirName": "projects", "fileName": "projects.json" },
33
+ "attributes": { "dirName": "attributes", "fileName": "attributes.json" },
34
+ "audiences": { "dirName": "audiences", "fileName": "audiences.json" },
35
+ "events": { "dirName": "events", "fileName": "events.json" },
36
+ "experiences": { "dirName": "experiences", "fileName": "experiences.json" }
37
+ },
38
+ "variantEntry": {
39
+ "serveMockData": false,
40
+ "dirName": "variants",
41
+ "fileName": "index.json",
42
+ "chunkFileSize": 1,
43
+ "query": { "skip": 0, "limit": 100, "locale": "en-us", "include_variant": false },
44
+ "mockDataPath": "./variant-mock-data.json"
45
+ }
46
+ },
47
+ "personalizationEnabled": true
48
+ }
@@ -0,0 +1,63 @@
1
+ {
2
+ "data": "./test/unit/mock/contents",
3
+ "contentDir": "./test/unit/mock/contents",
4
+ "backupDir": "./test/unit/mock/contents",
5
+ "apiKey": "TEST-STACK-API-KEY",
6
+ "master_locale": { "code": "en-us" },
7
+ "host": "https://test.abc.com",
8
+ "modules": {
9
+ "entries": {
10
+ "dirName": "entries",
11
+ "fileName": "entries.json",
12
+ "invalidKeys": [
13
+ "stackHeaders",
14
+ "content_type_uid",
15
+ "urlPath",
16
+ "created_at",
17
+ "updated_at",
18
+ "created_by",
19
+ "updated_by",
20
+ "_metadata",
21
+ "published"
22
+ ],
23
+ "batchLimit": 20,
24
+ "downloadLimit": 5,
25
+ "limit": 100,
26
+ "dependencies": ["locales", "content-types"],
27
+ "exportVersions": false
28
+ },
29
+ "content-types": {
30
+ "dirName": "content_types",
31
+ "fileName": "content_types.json",
32
+ "validKeys": ["title", "uid", "schema", "options", "singleton", "description"],
33
+ "limit": 100
34
+ },
35
+ "personalization": {
36
+ "project_id": "PROJ-1",
37
+ "importData": true,
38
+ "dirName": "personalization",
39
+ "importOrder": ["attributes", "audiences", "events", "experiences"],
40
+ "projects": { "dirName": "projects", "fileName": "projects.json" },
41
+ "attributes": { "dirName": "attributes", "fileName": "attributes.json" },
42
+ "audiences": { "dirName": "audiences", "fileName": "audiences.json" },
43
+ "events": { "dirName": "events", "fileName": "events.json" },
44
+ "experiences": {
45
+ "dirName": "experiences",
46
+ "fileName": "experiences.json",
47
+ "thresholdTimer": 0,
48
+ "checkIntervalDuration": 0
49
+ }
50
+ },
51
+ "variantEntry": {
52
+ "apiConcurrency": 1,
53
+ "dirName": "variants",
54
+ "fileName": "index.json",
55
+ "query": { "locale": "en-us" }
56
+ },
57
+ "taxonomies": {
58
+ "dirName": "taxonomies",
59
+ "fileName": "taxonomies.json"
60
+ }
61
+ },
62
+ "personalizationEnabled": true
63
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2016",
4
+ "module": "commonjs",
5
+ "outDir": "lib",
6
+ "rootDir": "src",
7
+ "declaration": true,
8
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
9
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
10
+ "strict": true, /* Enable all strict type-checking options. */
11
+ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
12
+ "resolveJsonModule": true,
13
+ "lib": [
14
+ "ES2019",
15
+ "es2020.promise"
16
+ ],
17
+ },
18
+ "include": ["src/*"]
19
+ }