sb-mig 5.6.0-beta.1 → 5.6.0-beta.3

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 (173) hide show
  1. package/README.md +20 -19
  2. package/dist/api/assets/assets.js +2 -15
  3. package/dist/api/auth/auth.types.d.ts +1 -1
  4. package/dist/api/components/components.js +2 -1
  5. package/dist/api/components/components.sync.d.ts +8 -0
  6. package/dist/api/components/components.sync.js +193 -0
  7. package/dist/api/data-migration/component-data-migration.js +2 -2
  8. package/dist/api/datasources/datasource-entries.js +4 -5
  9. package/dist/api/datasources/datasources.d.ts +5 -2
  10. package/dist/api/datasources/datasources.js +42 -35
  11. package/dist/api/datasources/datasources.sync.d.ts +2 -0
  12. package/dist/api/datasources/datasources.sync.js +11 -0
  13. package/dist/api/datasources/datasources.types.d.ts +1 -1
  14. package/dist/api/datasources/index.d.ts +2 -1
  15. package/dist/api/datasources/index.js +2 -1
  16. package/dist/api/managementApi.d.ts +2 -2
  17. package/dist/api/migrate.d.ts +1 -1
  18. package/dist/api/migrate.js +3 -48
  19. package/dist/api/plugins/index.d.ts +2 -1
  20. package/dist/api/plugins/index.js +2 -1
  21. package/dist/api/plugins/plugins.d.ts +7 -2
  22. package/dist/api/plugins/plugins.js +28 -15
  23. package/dist/api/plugins/plugins.sync.d.ts +2 -0
  24. package/dist/api/plugins/plugins.sync.js +11 -0
  25. package/dist/api/roles/index.d.ts +2 -1
  26. package/dist/api/roles/index.js +2 -1
  27. package/dist/api/roles/roles.d.ts +5 -2
  28. package/dist/api/roles/roles.js +34 -11
  29. package/dist/api/roles/roles.sync.d.ts +2 -0
  30. package/dist/api/roles/roles.sync.js +6 -0
  31. package/dist/api/roles/roles.types.d.ts +1 -1
  32. package/dist/api/stories/stories.js +3 -11
  33. package/dist/api/sync/sync.types.d.ts +30 -0
  34. package/dist/api/sync/sync.types.js +1 -0
  35. package/dist/api/testApi.d.ts +2 -2
  36. package/dist/api/utils/helper-functions.d.ts +5 -1
  37. package/dist/api/utils/helper-functions.js +6 -1
  38. package/dist/api/utils/request.d.ts +1 -1
  39. package/dist/api/utils/request.js +11 -2
  40. package/dist/api/utils/resolverTransformations.js +2 -57
  41. package/dist/api-v2/assets/index.d.ts +13 -0
  42. package/dist/api-v2/assets/index.js +25 -0
  43. package/dist/api-v2/auth/index.d.ts +3 -0
  44. package/dist/api-v2/auth/index.js +8 -0
  45. package/dist/api-v2/client.d.ts +13 -0
  46. package/dist/api-v2/client.js +17 -0
  47. package/dist/api-v2/components/index.d.ts +10 -0
  48. package/dist/api-v2/components/index.js +29 -0
  49. package/dist/api-v2/datasources/index.d.ts +8 -0
  50. package/dist/api-v2/datasources/index.js +58 -0
  51. package/dist/api-v2/discover/discover.d.ts +47 -0
  52. package/dist/api-v2/discover/discover.js +328 -0
  53. package/dist/api-v2/discover/index.d.ts +2 -0
  54. package/dist/api-v2/discover/index.js +1 -0
  55. package/dist/api-v2/index.d.ts +19 -0
  56. package/dist/api-v2/index.js +21 -0
  57. package/dist/api-v2/plugins/index.d.ts +9 -0
  58. package/dist/api-v2/plugins/index.js +42 -0
  59. package/dist/api-v2/precompile/index.d.ts +2 -0
  60. package/dist/api-v2/precompile/index.js +1 -0
  61. package/dist/api-v2/precompile/precompile.d.ts +65 -0
  62. package/dist/api-v2/precompile/precompile.js +127 -0
  63. package/dist/api-v2/presets/index.d.ts +13 -0
  64. package/dist/api-v2/presets/index.js +25 -0
  65. package/dist/api-v2/requestConfig.d.ts +5 -0
  66. package/dist/api-v2/requestConfig.js +34 -0
  67. package/dist/api-v2/roles/index.d.ts +5 -0
  68. package/dist/api-v2/roles/index.js +35 -0
  69. package/dist/api-v2/spaces/index.d.ts +7 -0
  70. package/dist/api-v2/spaces/index.js +11 -0
  71. package/dist/api-v2/stories/index.d.ts +34 -0
  72. package/dist/api-v2/stories/index.js +172 -0
  73. package/dist/api-v2/stories/types.d.ts +28 -0
  74. package/dist/api-v2/stories/types.js +1 -0
  75. package/dist/api-v2/sync/index.d.ts +24 -0
  76. package/dist/api-v2/sync/index.js +109 -0
  77. package/dist/api-v2/sync/types.d.ts +1 -0
  78. package/dist/api-v2/sync/types.js +1 -0
  79. package/dist/api-v2/test.d.ts +15 -0
  80. package/dist/api-v2/test.js +21 -0
  81. package/dist/cli/commands/backup.js +7 -3
  82. package/dist/cli/commands/copy.js +2 -2
  83. package/dist/cli/commands/migrate.js +1 -2
  84. package/dist/cli/commands/migrations.js +2 -2
  85. package/dist/cli/commands/remove.js +1 -1
  86. package/dist/cli/commands/revert.js +2 -2
  87. package/dist/cli/commands/sync.js +1 -2
  88. package/dist/cli/index.js +1 -1
  89. package/dist/cli/utils/cli-utils.d.ts +69 -0
  90. package/dist/cli/utils/cli-utils.js +100 -0
  91. package/dist/cli/utils/discover.d.ts +3 -22
  92. package/dist/cli/utils/discover.js +53 -100
  93. package/dist/config/config.d.ts +2 -39
  94. package/dist/config/config.types.d.ts +40 -0
  95. package/dist/config/config.types.js +1 -0
  96. package/dist/config/defaultConfig.d.ts +1 -1
  97. package/dist/config/defaultConfig.js +2 -2
  98. package/dist/utils/array-utils.d.ts +20 -0
  99. package/dist/utils/array-utils.js +20 -0
  100. package/dist/utils/async-utils.d.ts +13 -0
  101. package/dist/utils/async-utils.js +13 -0
  102. package/dist/utils/date-utils.d.ts +14 -0
  103. package/dist/utils/date-utils.js +21 -0
  104. package/dist/utils/files.d.ts +35 -0
  105. package/dist/utils/files.js +57 -2
  106. package/dist/utils/main.d.ts +8 -18
  107. package/dist/utils/main.js +12 -104
  108. package/dist/utils/migrations.d.ts +9 -3
  109. package/dist/utils/object-utils.d.ts +46 -0
  110. package/dist/utils/object-utils.js +71 -0
  111. package/dist/utils/others.d.ts +6 -9
  112. package/dist/utils/others.js +8 -15
  113. package/dist/utils/path-utils.d.ts +89 -0
  114. package/dist/utils/path-utils.js +106 -0
  115. package/dist/utils/pkg.d.ts +16 -2
  116. package/dist/utils/pkg.js +16 -3
  117. package/dist/utils/string-utils.d.ts +33 -0
  118. package/dist/utils/string-utils.js +45 -0
  119. package/dist/utils/transform-utils.d.ts +62 -0
  120. package/dist/utils/transform-utils.js +113 -0
  121. package/dist-cjs/api/auth/auth.js +28 -0
  122. package/dist-cjs/api/auth/auth.types.js +2 -0
  123. package/dist-cjs/api/components/components.js +202 -0
  124. package/dist-cjs/api/components/components.sync.js +199 -0
  125. package/dist-cjs/api/components/components.types.js +2 -0
  126. package/dist-cjs/api/datasources/datasource-entries.js +166 -0
  127. package/dist-cjs/api/datasources/datasources.js +166 -0
  128. package/dist-cjs/api/datasources/datasources.types.js +2 -0
  129. package/dist-cjs/api/plugins/plugins.js +132 -0
  130. package/dist-cjs/api/plugins/plugins.types.js +2 -0
  131. package/dist-cjs/api/presets/componentPresets.js +25 -0
  132. package/dist-cjs/api/presets/presets.js +92 -0
  133. package/dist-cjs/api/presets/presets.types.js +2 -0
  134. package/dist-cjs/api/presets/resolvePresets.js +49 -0
  135. package/dist-cjs/api/roles/roles.js +131 -0
  136. package/dist-cjs/api/roles/roles.types.js +2 -0
  137. package/dist-cjs/api/spaces/spaces.js +34 -0
  138. package/dist-cjs/api/spaces/spaces.types.js +2 -0
  139. package/dist-cjs/api/stories/stories.js +214 -0
  140. package/dist-cjs/api/stories/stories.types.js +2 -0
  141. package/dist-cjs/api/sync/sync.types.js +2 -0
  142. package/dist-cjs/api/utils/request.js +48 -0
  143. package/dist-cjs/api/utils/resolvers.types.js +2 -0
  144. package/dist-cjs/api-v2/assets/index.js +30 -0
  145. package/dist-cjs/api-v2/auth/index.js +12 -0
  146. package/dist-cjs/api-v2/client.js +23 -0
  147. package/dist-cjs/api-v2/components/index.js +40 -0
  148. package/dist-cjs/api-v2/datasources/index.js +64 -0
  149. package/dist-cjs/api-v2/discover/discover.js +368 -0
  150. package/dist-cjs/api-v2/discover/index.js +9 -0
  151. package/dist-cjs/api-v2/index.js +60 -0
  152. package/dist-cjs/api-v2/plugins/index.js +49 -0
  153. package/dist-cjs/api-v2/precompile/index.js +7 -0
  154. package/dist-cjs/api-v2/precompile/precompile.js +136 -0
  155. package/dist-cjs/api-v2/presets/index.js +33 -0
  156. package/dist-cjs/api-v2/requestConfig.js +37 -0
  157. package/dist-cjs/api-v2/roles/index.js +41 -0
  158. package/dist-cjs/api-v2/spaces/index.js +16 -0
  159. package/dist-cjs/api-v2/stories/index.js +180 -0
  160. package/dist-cjs/api-v2/stories/types.js +2 -0
  161. package/dist-cjs/api-v2/sync/index.js +115 -0
  162. package/dist-cjs/api-v2/sync/types.js +2 -0
  163. package/dist-cjs/api-v2/test.js +25 -0
  164. package/dist-cjs/config/config.types.js +2 -0
  165. package/dist-cjs/config/constants.js +29 -0
  166. package/dist-cjs/package.json +3 -0
  167. package/dist-cjs/utils/array-utils.js +24 -0
  168. package/dist-cjs/utils/logger.js +32 -0
  169. package/dist-cjs/utils/object-utils.js +77 -0
  170. package/dist-cjs/utils/path-utils.js +115 -0
  171. package/package.json +43 -27
  172. package/dist/utils/pkg-require.d.ts +0 -2
  173. package/dist/utils/pkg-require.js +0 -4
@@ -2,10 +2,11 @@
2
2
  // https://github.com/maoberlehner/storyblok-migrate
3
3
  // edit: changed a lot in here, but inspiration still is valid :)
4
4
  import path from "path";
5
- import glob from "glob";
5
+ import { globSync } from "glob";
6
6
  import storyblokConfig, { SCHEMA } from "../../config/config.js";
7
7
  import { buildOnTheFly } from "../../rollup/build-on-the-fly.js";
8
- import { getFileContentWithRequire } from "../../utils/main.js";
8
+ import { getFileContentWithRequire } from "../../utils/files.js";
9
+ import { normalizeDiscover, filesPattern, compare, } from "../../utils/path-utils.js";
9
10
  export var SCOPE;
10
11
  (function (SCOPE) {
11
12
  SCOPE["local"] = "local";
@@ -18,51 +19,8 @@ export var LOOKUP_TYPE;
18
19
  LOOKUP_TYPE["packagName"] = "packageName";
19
20
  LOOKUP_TYPE["fileName"] = "fileName";
20
21
  })(LOOKUP_TYPE || (LOOKUP_TYPE = {}));
21
- // problem with glob sync is, that when there is only one folder to search for
22
- // we have to omit { } and when a lot, we have to use {folder1, folder2}
23
- // so this function will normalize it based on amount of folders provided
24
- export const normalizeDiscover = ({ segments }) => {
25
- if (segments.length === 0) {
26
- return "";
27
- }
28
- if (segments.length === 1) {
29
- return segments[0];
30
- }
31
- return `{${segments.join(",")}}`;
32
- };
33
- export const compare = (request) => {
34
- const { local, external } = request;
35
- const splittedLocal = local.map((p) => {
36
- return {
37
- name: p.split(path.sep)[p.split(path.sep).length - 1],
38
- p,
39
- };
40
- });
41
- const splittedExternal = external
42
- .map((p) => {
43
- return {
44
- name: p.split(path.sep)[p.split(path.sep).length - 1],
45
- p,
46
- };
47
- })
48
- .filter((file) => {
49
- // 1. check if the file has node_modules > 1
50
- const nodeModulesCount = (file.p.match(/node_modules/g) || [])
51
- .length;
52
- return nodeModulesCount <= 1;
53
- });
54
- // we only want to modify external array, because we want sometimes remove stuff which are already on local (overwrite node_modules ones)
55
- const result = {
56
- local: splittedLocal,
57
- external: splittedExternal.filter((externalComponent) => {
58
- if (splittedLocal.find((localComponent) => externalComponent.name === localComponent.name)) {
59
- return false;
60
- }
61
- return true;
62
- }),
63
- };
64
- return result;
65
- };
22
+ // Re-export functions for backwards compatibility
23
+ export { normalizeDiscover, compare, filesPattern, } from "../../utils/path-utils.js";
66
24
  export const discoverManyByPackageName = (request) => {
67
25
  const rootDirectory = "./";
68
26
  const directory = path.resolve(process.cwd(), rootDirectory);
@@ -76,7 +34,7 @@ export const discoverManyByPackageName = (request) => {
76
34
  pattern = path.join(`${directory}`, `${normalizeDiscover({
77
35
  segments: onlyLocalComponentsDirectories,
78
36
  })}`, "**", "package.json");
79
- listOfPackagesJsonFiles = glob.sync(pattern.replace(/\\/g, "/"), {
37
+ listOfPackagesJsonFiles = globSync(pattern.replace(/\\/g, "/"), {
80
38
  follow: true,
81
39
  });
82
40
  listOfFiles = listOfPackagesJsonFiles
@@ -88,7 +46,7 @@ export const discoverManyByPackageName = (request) => {
88
46
  .slice(0, -1)
89
47
  .join(path.sep);
90
48
  const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, "**", `[^_]*.${storyblokConfig.schemaFileExt}`);
91
- return glob.sync(allStoryblokSchemaFilesWithinFolderPattern.replace(/\\/g, "/"), { follow: true });
49
+ return globSync(allStoryblokSchemaFilesWithinFolderPattern.replace(/\\/g, "/"), { follow: true });
92
50
  })
93
51
  .flat();
94
52
  break;
@@ -98,7 +56,7 @@ export const discoverManyByPackageName = (request) => {
98
56
  pattern = path.join(`${directory}`, `${normalizeDiscover({
99
57
  segments: onlyNodeModulesPackagesComponentsDirectories,
100
58
  })}`, "**", "package.json");
101
- listOfPackagesJsonFiles = glob.sync(pattern.replace(/\\/g, "/"), {
59
+ listOfPackagesJsonFiles = globSync(pattern.replace(/\\/g, "/"), {
102
60
  follow: true,
103
61
  });
104
62
  listOfFiles = listOfPackagesJsonFiles
@@ -110,7 +68,7 @@ export const discoverManyByPackageName = (request) => {
110
68
  .slice(0, -1)
111
69
  .join(path.sep);
112
70
  const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, "**", `[^_]*.${storyblokConfig.schemaFileExt}`);
113
- return glob.sync(allStoryblokSchemaFilesWithinFolderPattern.replace(/\\/g, "/"), { follow: true });
71
+ return globSync(allStoryblokSchemaFilesWithinFolderPattern.replace(/\\/g, "/"), { follow: true });
114
72
  })
115
73
  .flat();
116
74
  break;
@@ -119,7 +77,7 @@ export const discoverManyByPackageName = (request) => {
119
77
  pattern = path.join(`${directory}`, `${normalizeDiscover({
120
78
  segments: storyblokConfig.componentsDirectories,
121
79
  })}`, "**", "package.json");
122
- listOfPackagesJsonFiles = glob.sync(pattern.replace(/\\/g, "/"), {
80
+ listOfPackagesJsonFiles = globSync(pattern.replace(/\\/g, "/"), {
123
81
  follow: true,
124
82
  });
125
83
  listOfFiles = listOfPackagesJsonFiles
@@ -131,7 +89,7 @@ export const discoverManyByPackageName = (request) => {
131
89
  .slice(0, -1)
132
90
  .join(path.sep);
133
91
  const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, "**", `[^_]*.${storyblokConfig.schemaFileExt}`);
134
- return glob.sync(allStoryblokSchemaFilesWithinFolderPattern.replace(/\\/g, "/"), { follow: true });
92
+ return globSync(allStoryblokSchemaFilesWithinFolderPattern.replace(/\\/g, "/"), { follow: true });
135
93
  })
136
94
  .flat();
137
95
  break;
@@ -153,7 +111,7 @@ export const discoverOneByPackageName = (request) => {
153
111
  pattern = path.join(`${directory}`, `${normalizeDiscover({
154
112
  segments: onlyLocalComponentsDirectories,
155
113
  })}`, "**", "package.json");
156
- listOfPackagesJsonFiles = glob.sync(pattern.replace(/\\/g, "/"), {
114
+ listOfPackagesJsonFiles = globSync(pattern.replace(/\\/g, "/"), {
157
115
  follow: true,
158
116
  });
159
117
  listOfFiles = listOfPackagesJsonFiles
@@ -166,7 +124,7 @@ export const discoverOneByPackageName = (request) => {
166
124
  .slice(0, -1)
167
125
  .join(path.sep);
168
126
  const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, "**", `[^_]*.${storyblokConfig.schemaFileExt}`);
169
- return glob.sync(allStoryblokSchemaFilesWithinFolderPattern.replace(/\\/g, "/"), { follow: true });
127
+ return globSync(allStoryblokSchemaFilesWithinFolderPattern.replace(/\\/g, "/"), { follow: true });
170
128
  })
171
129
  .flat();
172
130
  break;
@@ -176,7 +134,7 @@ export const discoverOneByPackageName = (request) => {
176
134
  pattern = path.join(`${directory}`, `${normalizeDiscover({
177
135
  segments: onlyNodeModulesPackagesComponentsDirectories,
178
136
  })}`, "**", "package.json");
179
- listOfPackagesJsonFiles = glob.sync(pattern.replace(/\\/g, "/"), {
137
+ listOfPackagesJsonFiles = globSync(pattern.replace(/\\/g, "/"), {
180
138
  follow: true,
181
139
  });
182
140
  listOfFiles = listOfPackagesJsonFiles
@@ -189,7 +147,7 @@ export const discoverOneByPackageName = (request) => {
189
147
  .slice(0, -1)
190
148
  .join(path.sep);
191
149
  const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, "**", `[^_]*.${storyblokConfig.schemaFileExt}`);
192
- return glob.sync(allStoryblokSchemaFilesWithinFolderPattern.replace(/\\/g, "/"), { follow: true });
150
+ return globSync(allStoryblokSchemaFilesWithinFolderPattern.replace(/\\/g, "/"), { follow: true });
193
151
  })
194
152
  .flat();
195
153
  break;
@@ -198,7 +156,7 @@ export const discoverOneByPackageName = (request) => {
198
156
  pattern = path.join(`${directory}`, `${normalizeDiscover({
199
157
  segments: storyblokConfig.componentsDirectories,
200
158
  })}`, "**", "package.json");
201
- listOfPackagesJsonFiles = glob.sync(pattern.replace(/\\/g, "/"), {
159
+ listOfPackagesJsonFiles = globSync(pattern.replace(/\\/g, "/"), {
202
160
  follow: true,
203
161
  });
204
162
  listOfFiles = listOfPackagesJsonFiles
@@ -211,7 +169,7 @@ export const discoverOneByPackageName = (request) => {
211
169
  .slice(0, -1)
212
170
  .join(path.sep);
213
171
  const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, "**", `[^_]*.${storyblokConfig.schemaFileExt}`);
214
- return glob.sync(allStoryblokSchemaFilesWithinFolderPattern.replace(/\\/g, "/"), { follow: true });
172
+ return globSync(allStoryblokSchemaFilesWithinFolderPattern.replace(/\\/g, "/"), { follow: true });
215
173
  })
216
174
  .flat();
217
175
  break;
@@ -234,19 +192,19 @@ export const discoverMany = async (request) => {
234
192
  pattern = path.join(`${directory}`, `${normalizeDiscover({
235
193
  segments: onlyLocalComponentsDirectories,
236
194
  })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.sb.${storyblokConfig.schemaType}`);
237
- const listOfFilesToCompile = glob.sync(pattern.replace(/\\/g, "/"), {
195
+ const listOfFilesToCompile = globSync(pattern.replace(/\\/g, "/"), {
238
196
  follow: true,
239
197
  });
240
198
  await buildOnTheFly({ files: listOfFilesToCompile });
241
199
  pattern = path.join(directory, ".next", "cache", "sb-mig", "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.schemaFileExt}`);
242
- listOFSchemaTSFilesCompiled = glob.sync(pattern.replace(/\\/g, "/"), {
200
+ listOFSchemaTSFilesCompiled = globSync(pattern.replace(/\\/g, "/"), {
243
201
  follow: true,
244
202
  });
245
203
  }
246
204
  pattern = path.join(`${directory}`, `${normalizeDiscover({
247
205
  segments: onlyLocalComponentsDirectories,
248
206
  })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.schemaFileExt}`);
249
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
207
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
250
208
  follow: true,
251
209
  });
252
210
  listOfFiles = [...listOfFiles, ...listOFSchemaTSFilesCompiled];
@@ -257,7 +215,7 @@ export const discoverMany = async (request) => {
257
215
  pattern = path.join(`${directory}`, `${normalizeDiscover({
258
216
  segments: onlyNodeModulesPackagesComponentsDirectories,
259
217
  })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.schemaFileExt}`);
260
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
218
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
261
219
  follow: true,
262
220
  });
263
221
  break;
@@ -268,7 +226,7 @@ export const discoverMany = async (request) => {
268
226
  pattern = path.join(`${directory}`, `${normalizeDiscover({
269
227
  segments: storyblokConfig.componentsDirectories,
270
228
  })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.schemaFileExt}`);
271
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
229
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
272
230
  follow: true,
273
231
  });
274
232
  break;
@@ -293,14 +251,14 @@ export const discoverManyDatasources = async (request) => {
293
251
  })}`, "**", `${normalizeDiscover({
294
252
  segments: request.fileNames,
295
253
  })}.sb.datasource.${storyblokConfig.schemaType}`);
296
- const listOfFilesToCompile = glob.sync(pattern.replace(/\\/g, "/"), {
254
+ const listOfFilesToCompile = globSync(pattern.replace(/\\/g, "/"), {
297
255
  follow: true,
298
256
  });
299
257
  await buildOnTheFly({ files: listOfFilesToCompile });
300
258
  pattern = path.join(directory, ".next", "cache", "sb-mig", "**", `${normalizeDiscover({
301
259
  segments: request.fileNames,
302
260
  })}.${storyblokConfig.datasourceExt}`);
303
- listOFSchemaTSFilesCompiled = glob.sync(pattern.replace(/\\/g, "/"), {
261
+ listOFSchemaTSFilesCompiled = globSync(pattern.replace(/\\/g, "/"), {
304
262
  follow: true,
305
263
  });
306
264
  }
@@ -309,7 +267,7 @@ export const discoverManyDatasources = async (request) => {
309
267
  })}`, "**", `${normalizeDiscover({
310
268
  segments: request.fileNames,
311
269
  })}.${storyblokConfig.datasourceExt}`);
312
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
270
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
313
271
  follow: true,
314
272
  });
315
273
  listOfFiles = [...listOfFiles, ...listOFSchemaTSFilesCompiled];
@@ -320,7 +278,7 @@ export const discoverManyDatasources = async (request) => {
320
278
  pattern = path.join(`${directory}`, `${normalizeDiscover({
321
279
  segments: onlyNodeModulesPackagesComponentsDirectories,
322
280
  })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.datasourceExt}`);
323
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
281
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
324
282
  follow: true,
325
283
  });
326
284
  break;
@@ -329,7 +287,7 @@ export const discoverManyDatasources = async (request) => {
329
287
  pattern = path.join(`${directory}`, `${normalizeDiscover({
330
288
  segments: storyblokConfig.componentsDirectories,
331
289
  })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.datasourceExt}`);
332
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
290
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
333
291
  follow: true,
334
292
  });
335
293
  break;
@@ -350,7 +308,7 @@ export const discoverStories = (request) => {
350
308
  const pattern = path.join(`${directory}`, `${normalizeDiscover({
351
309
  segments: onlyLocalComponentsDirectories,
352
310
  })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.storiesExt}`);
353
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
311
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
354
312
  follow: true,
355
313
  });
356
314
  break;
@@ -374,7 +332,7 @@ export const discoverMigrationConfig = (request) => {
374
332
  pattern = path.join(`${directory}`, `${normalizeDiscover({
375
333
  segments: storyblokConfig.componentsDirectories,
376
334
  })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.migrationConfigExt}`);
377
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
335
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
378
336
  follow: true,
379
337
  });
380
338
  break;
@@ -395,7 +353,7 @@ export const discoverVersionMapping = (request) => {
395
353
  })}`, "**", `${normalizeDiscover({
396
354
  segments: request.fileNames,
397
355
  })}.${"sb.migrations.cjs"}`);
398
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
356
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
399
357
  follow: true,
400
358
  });
401
359
  break;
@@ -418,7 +376,7 @@ export const discoverDatasources = async (request) => {
418
376
  pattern = path.join(`${directory}`, `${normalizeDiscover({
419
377
  segments: onlyLocalComponentsDirectories,
420
378
  })}`, "**", `[^_]*.sb.datasource.${storyblokConfig.schemaType}`);
421
- const listOfFilesToCompile = glob.sync(pattern.replace(/\\/g, "/"), {
379
+ const listOfFilesToCompile = globSync(pattern.replace(/\\/g, "/"), {
422
380
  follow: true,
423
381
  });
424
382
  if (storyblokConfig.debug) {
@@ -428,14 +386,14 @@ export const discoverDatasources = async (request) => {
428
386
  }
429
387
  await buildOnTheFly({ files: listOfFilesToCompile });
430
388
  pattern = path.join(directory, ".next", "cache", "sb-mig", "**", `[^_]*.${storyblokConfig.datasourceExt}`);
431
- listOFSchemaTSFilesCompiled = glob.sync(pattern.replace(/\\/g, "/"), {
389
+ listOFSchemaTSFilesCompiled = globSync(pattern.replace(/\\/g, "/"), {
432
390
  follow: true,
433
391
  });
434
392
  }
435
393
  pattern = path.join(`${directory}`, `${normalizeDiscover({
436
394
  segments: onlyLocalComponentsDirectories,
437
395
  })}`, "**", `[^_]*.${storyblokConfig.datasourceExt}`);
438
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
396
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
439
397
  follow: true,
440
398
  });
441
399
  listOfFiles = [...listOfFiles, ...listOFSchemaTSFilesCompiled];
@@ -446,7 +404,7 @@ export const discoverDatasources = async (request) => {
446
404
  pattern = path.join(`${directory}`, `${normalizeDiscover({
447
405
  segments: onlyNodeModulesPackagesComponentsDirectories,
448
406
  })}`, "**", `[^_]*.${storyblokConfig.datasourceExt}`);
449
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
407
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
450
408
  follow: true,
451
409
  });
452
410
  break;
@@ -455,7 +413,7 @@ export const discoverDatasources = async (request) => {
455
413
  pattern = path.join(`${directory}`, `${normalizeDiscover({
456
414
  segments: storyblokConfig.componentsDirectories,
457
415
  })}`, "**", `[^_]*.${storyblokConfig.datasourceExt}`);
458
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
416
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
459
417
  follow: true,
460
418
  });
461
419
  break;
@@ -464,11 +422,6 @@ export const discoverDatasources = async (request) => {
464
422
  }
465
423
  return listOfFiles;
466
424
  };
467
- export const filesPattern = ({ mainDirectory, componentDirectories, ext, }) => {
468
- return componentDirectories.length === 1
469
- ? path.join(`${mainDirectory}`, `${componentDirectories[0]}`, "**", `[^_]*.${ext}`)
470
- : path.join(`${mainDirectory}`, `{${componentDirectories.join(",")}}`, "**", `[^_]*.${ext}`);
471
- };
472
425
  export const discover = async (request) => {
473
426
  const rootDirectory = ".";
474
427
  const directory = path.resolve(process.cwd(), rootDirectory);
@@ -485,12 +438,12 @@ export const discover = async (request) => {
485
438
  componentDirectories: onlyLocalComponentsDirectories,
486
439
  ext: "sb.ts",
487
440
  });
488
- const listOfFilesToCompile = glob.sync(pattern.replace(/\\/g, "/"), {
441
+ const listOfFilesToCompile = globSync(pattern.replace(/\\/g, "/"), {
489
442
  follow: true,
490
443
  });
491
444
  await buildOnTheFly({ files: listOfFilesToCompile });
492
445
  pattern = path.join(directory, ".next", "cache", "sb-mig", "**", `[^_]*.${storyblokConfig.schemaFileExt}`);
493
- listOFSchemaTSFilesCompiled = glob.sync(pattern.replace(/\\/g, "/"), {
446
+ listOFSchemaTSFilesCompiled = globSync(pattern.replace(/\\/g, "/"), {
494
447
  follow: true,
495
448
  });
496
449
  }
@@ -499,7 +452,7 @@ export const discover = async (request) => {
499
452
  componentDirectories: onlyLocalComponentsDirectories,
500
453
  ext: storyblokConfig.schemaFileExt,
501
454
  });
502
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
455
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
503
456
  follow: true,
504
457
  });
505
458
  listOfFiles = [...listOfFiles, ...listOFSchemaTSFilesCompiled];
@@ -512,7 +465,7 @@ export const discover = async (request) => {
512
465
  componentDirectories: onlyNodeModulesPackagesComponentsDirectories,
513
466
  ext: storyblokConfig.schemaFileExt,
514
467
  });
515
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
468
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
516
469
  follow: true,
517
470
  });
518
471
  break;
@@ -523,7 +476,7 @@ export const discover = async (request) => {
523
476
  componentDirectories: storyblokConfig.componentsDirectories,
524
477
  ext: storyblokConfig.schemaFileExt,
525
478
  });
526
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
479
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
527
480
  follow: true,
528
481
  });
529
482
  break;
@@ -548,12 +501,12 @@ export const discoverResolvers = async (request) => {
548
501
  componentDirectories: onlyLocalComponentsDirectories,
549
502
  ext: "sb.resolvers.ts",
550
503
  });
551
- const listOfFilesToCompile = glob.sync(pattern.replace(/\\/g, "/"), {
504
+ const listOfFilesToCompile = globSync(pattern.replace(/\\/g, "/"), {
552
505
  follow: true,
553
506
  });
554
507
  await buildOnTheFly({ files: listOfFilesToCompile });
555
508
  pattern = path.join(directory, ".next", "cache", "sb-mig", "**", `[^_]*.sb.resolvers.cjs`);
556
- listOFSchemaTSFilesCompiled = glob.sync(pattern.replace(/\\/g, "/"), {
509
+ listOFSchemaTSFilesCompiled = globSync(pattern.replace(/\\/g, "/"), {
557
510
  follow: true,
558
511
  });
559
512
  }
@@ -562,7 +515,7 @@ export const discoverResolvers = async (request) => {
562
515
  componentDirectories: onlyLocalComponentsDirectories,
563
516
  ext: "sb.resolvers.cjs",
564
517
  });
565
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
518
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
566
519
  follow: true,
567
520
  });
568
521
  listOfFiles = [...listOfFiles, ...listOFSchemaTSFilesCompiled];
@@ -586,19 +539,19 @@ export const discoverRoles = async (request) => {
586
539
  pattern = path.join(`${directory}`, `${normalizeDiscover({
587
540
  segments: onlyLocalComponentsDirectories,
588
541
  })}`, "**", `[^_]*.sb.roles.${storyblokConfig.schemaType}`);
589
- const listOfFilesToCompile = glob.sync(pattern.replace(/\\/g, "/"), {
542
+ const listOfFilesToCompile = globSync(pattern.replace(/\\/g, "/"), {
590
543
  follow: true,
591
544
  });
592
545
  await buildOnTheFly({ files: listOfFilesToCompile });
593
546
  pattern = path.join(directory, ".next", "cache", "sb-mig", "**", `[^_]*.${storyblokConfig.rolesExt}`);
594
- listOFSchemaTSFilesCompiled = glob.sync(pattern.replace(/\\/g, "/"), {
547
+ listOFSchemaTSFilesCompiled = globSync(pattern.replace(/\\/g, "/"), {
595
548
  follow: true,
596
549
  });
597
550
  }
598
551
  pattern = path.join(`${directory}`, `${normalizeDiscover({
599
552
  segments: onlyLocalComponentsDirectories,
600
553
  })}`, "**", `[^_]*.${storyblokConfig.rolesExt}`);
601
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
554
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
602
555
  follow: true,
603
556
  });
604
557
  listOfFiles = [...listOfFiles, ...listOFSchemaTSFilesCompiled];
@@ -609,7 +562,7 @@ export const discoverRoles = async (request) => {
609
562
  pattern = path.join(`${directory}`, `${normalizeDiscover({
610
563
  segments: onlyNodeModulesPackagesComponentsDirectories,
611
564
  })}`, "**", `[^_]*.${storyblokConfig.rolesExt}`);
612
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
565
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
613
566
  follow: true,
614
567
  });
615
568
  break;
@@ -618,7 +571,7 @@ export const discoverRoles = async (request) => {
618
571
  pattern = path.join(`${directory}`, `${normalizeDiscover({
619
572
  segments: storyblokConfig.componentsDirectories,
620
573
  })}`, "**", `[^_]*.${storyblokConfig.rolesExt}`);
621
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
574
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
622
575
  follow: true,
623
576
  });
624
577
  break;
@@ -643,21 +596,21 @@ export const discoverManyRoles = async (request) => {
643
596
  })}`, "**", `${normalizeDiscover({
644
597
  segments: request.fileNames,
645
598
  })}.sb.roles.${storyblokConfig.schemaType}`);
646
- const listOfFilesToCompile = glob.sync(pattern.replace(/\\/g, "/"), {
599
+ const listOfFilesToCompile = globSync(pattern.replace(/\\/g, "/"), {
647
600
  follow: true,
648
601
  });
649
602
  await buildOnTheFly({ files: listOfFilesToCompile });
650
603
  pattern = path.join(directory, ".next", "cache", "sb-mig", "**", `${normalizeDiscover({
651
604
  segments: request.fileNames,
652
605
  })}.${storyblokConfig.rolesExt}`);
653
- listOFSchemaTSFilesCompiled = glob.sync(pattern.replace(/\\/g, "/"), {
606
+ listOFSchemaTSFilesCompiled = globSync(pattern.replace(/\\/g, "/"), {
654
607
  follow: true,
655
608
  });
656
609
  }
657
610
  pattern = path.join(`${directory}`, `${normalizeDiscover({
658
611
  segments: onlyLocalComponentsDirectories,
659
612
  })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.rolesExt}`);
660
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
613
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
661
614
  follow: true,
662
615
  });
663
616
  listOfFiles = [...listOfFiles, ...listOFSchemaTSFilesCompiled];
@@ -668,7 +621,7 @@ export const discoverManyRoles = async (request) => {
668
621
  pattern = path.join(`${directory}`, `${normalizeDiscover({
669
622
  segments: onlyNodeModulesPackagesComponentsDirectories,
670
623
  })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.rolesExt}`);
671
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
624
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
672
625
  follow: true,
673
626
  });
674
627
  break;
@@ -677,7 +630,7 @@ export const discoverManyRoles = async (request) => {
677
630
  pattern = path.join(`${directory}`, `${normalizeDiscover({
678
631
  segments: storyblokConfig.componentsDirectories,
679
632
  })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.rolesExt}`);
680
- listOfFiles = glob.sync(pattern.replace(/\\/g, "/"), {
633
+ listOfFiles = globSync(pattern.replace(/\\/g, "/"), {
681
634
  follow: true,
682
635
  });
683
636
  break;
@@ -1,43 +1,6 @@
1
- import type { SchemaGlobalResolvers, SimpleResolver } from "../api/utils/resolvers.types.js";
2
- import type StoryblokClient from "storyblok-js-client";
1
+ import type { IStoryblokConfig } from "./config.types.js";
3
2
  import { SCHEMA } from "./helper.js";
4
- type SchemaType = (typeof SCHEMA)[keyof typeof SCHEMA];
5
3
  export { SCHEMA };
6
- export interface IStoryblokConfig {
7
- storyblokComponentsLocalDirectory: string;
8
- sbmigWorkingDirectory: string;
9
- presetsBackupDirectory: string;
10
- storiesBackupDirectory: string;
11
- componentsDirectories: string[];
12
- awsBucketData: {
13
- bucketName: string;
14
- s3Url: `s3://${string}`;
15
- httpUrl: `https://${string}`;
16
- };
17
- metadataSelection: Record<string, any>;
18
- contentHubOriginUrl: string;
19
- contentHubAuthorizationToken: string;
20
- schemaFileExt: "sb.cjs" | "sb.js";
21
- datasourceExt: string;
22
- rolesExt: string;
23
- storiesExt: string;
24
- migrationConfigExt: string;
25
- storyblokApiUrl: string;
26
- storyblokDeliveryApiUrl: string;
27
- storyblokGraphqlApiUrl: string;
28
- oauthToken: string;
29
- openaiToken: string;
30
- spaceId: string;
31
- accessToken: string;
32
- boilerplateSpaceId: string;
33
- schemaType: SchemaType;
34
- flushCache: boolean;
35
- cacheDir: string;
36
- debug: boolean;
37
- rateLimit: number;
38
- sbApi?: () => StoryblokClient;
39
- resolvers?: SimpleResolver[];
40
- advancedResolvers?: SchemaGlobalResolvers;
41
- }
4
+ export type { IStoryblokConfig };
42
5
  declare const _default: IStoryblokConfig;
43
6
  export default _default;
@@ -0,0 +1,40 @@
1
+ import type { SCHEMA } from "./constants.js";
2
+ import type { SchemaGlobalResolvers, SimpleResolver } from "../api/utils/resolvers.types.js";
3
+ import type StoryblokClient from "storyblok-js-client";
4
+ export type SchemaType = (typeof SCHEMA)[keyof typeof SCHEMA];
5
+ export interface IStoryblokConfig {
6
+ storyblokComponentsLocalDirectory: string;
7
+ sbmigWorkingDirectory: string;
8
+ presetsBackupDirectory: string;
9
+ storiesBackupDirectory: string;
10
+ componentsDirectories: string[];
11
+ awsBucketData: {
12
+ bucketName: string;
13
+ s3Url: `s3://${string}`;
14
+ httpUrl: `https://${string}`;
15
+ };
16
+ metadataSelection: Record<string, any>;
17
+ contentHubOriginUrl: string;
18
+ contentHubAuthorizationToken: string;
19
+ schemaFileExt: "sb.cjs" | "sb.js";
20
+ datasourceExt: string;
21
+ rolesExt: string;
22
+ storiesExt: string;
23
+ migrationConfigExt: string;
24
+ storyblokApiUrl: string;
25
+ storyblokDeliveryApiUrl: string;
26
+ storyblokGraphqlApiUrl: string;
27
+ oauthToken: string;
28
+ openaiToken: string;
29
+ spaceId: string;
30
+ accessToken: string;
31
+ boilerplateSpaceId: string;
32
+ schemaType: SchemaType;
33
+ flushCache: boolean;
34
+ cacheDir: string;
35
+ debug: boolean;
36
+ rateLimit: number;
37
+ sbApi?: () => StoryblokClient;
38
+ resolvers?: SimpleResolver[];
39
+ advancedResolvers?: SchemaGlobalResolvers;
40
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,2 @@
1
- import type { IStoryblokConfig } from "./config.js";
1
+ import type { IStoryblokConfig } from "./config.types.js";
2
2
  export declare const defaultConfig: (pkg: any, path: string, env: any) => IStoryblokConfig;
@@ -35,7 +35,7 @@ export const defaultConfig = (pkg, path, env) => {
35
35
  // : "sb.stories.cjs",
36
36
  storiesExt: "sb.stories.json",
37
37
  storyblokApiUrl: env["NEXT_PUBLIC_STORYBLOK_MANAGEMENT_API_URL"] ||
38
- "https://mapi.storyblok.com/v1",
38
+ "https://mapi.storyblok.com/v1", // should be mapi.storyblok.com ?
39
39
  storyblokDeliveryApiUrl: env["NEXT_PUBLIC_STORYBLOK_DELIVERY_API_URL"] ||
40
40
  "https://api.storyblok.com/v2",
41
41
  storyblokGraphqlApiUrl: env["NEXT_PUBLIC_STORYBLOK_GRAPHQL_API_URL"] ||
@@ -46,7 +46,7 @@ export const defaultConfig = (pkg, path, env) => {
46
46
  accessToken: env["GATSBY_STORYBLOK_ACCESS_TOKEN"] ||
47
47
  env["NEXT_PUBLIC_STORYBLOK_ACCESS_TOKEN"] ||
48
48
  "",
49
- boilerplateSpaceId: "172677",
49
+ boilerplateSpaceId: "172677", // this is id of Content seed for nextjs boilerplate space
50
50
  schemaType: SCHEMA.JS,
51
51
  flushCache: true,
52
52
  cacheDir: ".next/cache",
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Array utility functions
3
+ */
4
+ /**
5
+ * Get unique values from an array
6
+ * Uses Set for O(n) deduplication
7
+ *
8
+ * @param array - The array to deduplicate
9
+ * @returns A new array with only unique values
10
+ *
11
+ * @example
12
+ * uniqueValuesFrom([1, 2, 2, 3, 3, 3]) // => [1, 2, 3]
13
+ * uniqueValuesFrom(['a', 'b', 'a']) // => ['a', 'b']
14
+ */
15
+ export declare const uniqueValuesFrom: <T>(array: T[]) => T[];
16
+ /**
17
+ * @deprecated Use uniqueValuesFrom instead
18
+ * Alias for backwards compatibility
19
+ */
20
+ export declare const _uniqueValuesFrom: <T>(array: T[]) => T[];
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Array utility functions
3
+ */
4
+ /**
5
+ * Get unique values from an array
6
+ * Uses Set for O(n) deduplication
7
+ *
8
+ * @param array - The array to deduplicate
9
+ * @returns A new array with only unique values
10
+ *
11
+ * @example
12
+ * uniqueValuesFrom([1, 2, 2, 3, 3, 3]) // => [1, 2, 3]
13
+ * uniqueValuesFrom(['a', 'b', 'a']) // => ['a', 'b']
14
+ */
15
+ export const uniqueValuesFrom = (array) => [...new Set(array)];
16
+ /**
17
+ * @deprecated Use uniqueValuesFrom instead
18
+ * Alias for backwards compatibility
19
+ */
20
+ export const _uniqueValuesFrom = uniqueValuesFrom;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Async utility functions
3
+ */
4
+ /**
5
+ * Delay execution for a specified time
6
+ *
7
+ * @param time - Time to delay in milliseconds
8
+ * @returns Promise that resolves after the delay
9
+ *
10
+ * @example
11
+ * await delay(1000); // Wait 1 second
12
+ */
13
+ export declare const delay: (time: number) => Promise<void>;