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
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Simple test function with no dependencies to verify ESM/CJS interop
3
+ */
4
+ export function testConnection() {
5
+ return {
6
+ success: true,
7
+ message: "sb-mig api-v2 connection successful!",
8
+ timestamp: new Date().toISOString(),
9
+ };
10
+ }
11
+ /**
12
+ * Async test function to verify async imports work
13
+ */
14
+ export async function testAsyncConnection() {
15
+ // Simulate a small delay
16
+ await new Promise((resolve) => setTimeout(resolve, 100));
17
+ return {
18
+ success: true,
19
+ message: "sb-mig api-v2 async connection successful!",
20
+ };
21
+ }
@@ -1,10 +1,11 @@
1
1
  import { managementApi } from "../../api/managementApi.js";
2
2
  import { backupStories } from "../../api/stories/backup.js";
3
3
  import storyblokConfig from "../../config/config.js";
4
- import { createAndSaveToFile } from "../../utils/files.js";
4
+ import { createAndSaveToFile, getPackageJson } from "../../utils/files.js";
5
5
  import Logger from "../../utils/logger.js";
6
- import { extractFields, getPackageJson, isItFactory, unpackOne, } from "../../utils/main.js";
6
+ import { extractFields } from "../../utils/object-utils.js";
7
7
  import { apiConfig } from "../api-config.js";
8
+ import { isItFactory, unpackOne } from "../utils/cli-utils.js";
8
9
  const BACKUP_COMMANDS = {
9
10
  components: "components",
10
11
  stories: "stories",
@@ -276,7 +277,10 @@ export const backup = async (props) => {
276
277
  filename: `${component.name}.presets.sb`,
277
278
  res: { allPresets: res, ...metadata },
278
279
  folder: storyblokConfig.presetsBackupDirectory,
279
- }, { ...apiConfig, sbmigWorkingDirectory: "." });
280
+ }, {
281
+ ...apiConfig,
282
+ sbmigWorkingDirectory: ".",
283
+ });
280
284
  }
281
285
  })
282
286
  .catch((err) => {
@@ -1,8 +1,8 @@
1
1
  import { managementApi } from "../../api/managementApi.js";
2
2
  import { createTree, traverseAndCreate } from "../../api/stories/tree.js";
3
3
  import Logger from "../../utils/logger.js";
4
- import { getSourceSpace, getTargetSpace, getWhat, getWhere, } from "../../utils/others.js";
5
4
  import { apiConfig } from "../api-config.js";
5
+ import { getSourceSpace, getTargetSpace, getWhat, getWhere, } from "../utils/cli-utils.js";
6
6
  const COPY_COMMANDS = {
7
7
  stories: "stories",
8
8
  };
@@ -19,7 +19,7 @@ const decideStrategy = async (args) => {
19
19
  const { what, sourceSpace } = args;
20
20
  // Check if path ends with /* for recursive folder strategy
21
21
  if (what.endsWith("/*")) {
22
- const folderPath = what.slice(0, -2); // Remove /* from the end
22
+ const folderPath = what.slice(0, -2); // Remove /* from the endcurso
23
23
  const entryStory = await managementApi.stories.getStoryBySlug(folderPath, {
24
24
  ...apiConfig,
25
25
  spaceId: sourceSpace,
@@ -3,10 +3,9 @@ import { managementApi } from "../../api/managementApi.js";
3
3
  import { backupStories } from "../../api/stories/backup.js";
4
4
  import { createAndSaveToFile } from "../../utils/files.js";
5
5
  import Logger from "../../utils/logger.js";
6
- import { isItFactory, unpackElements } from "../../utils/main.js";
7
- import { getFrom, getTo } from "../../utils/others.js";
8
6
  import { apiConfig } from "../api-config.js";
9
7
  import { askForConfirmation } from "../helpers.js";
8
+ import { isItFactory, unpackElements, getFrom, getTo, } from "../utils/cli-utils.js";
10
9
  const MIGRATE_COMMANDS = {
11
10
  content: "content",
12
11
  presets: "presets",
@@ -1,8 +1,8 @@
1
1
  import path from "path";
2
- import { readFile } from "../../utils/files.js";
2
+ import { readFile, getFileContentWithRequire, getFilesContentWithRequire, } from "../../utils/files.js";
3
3
  import Logger from "../../utils/logger.js";
4
- import { getFileContentWithRequire, getFilesContentWithRequire, isItFactory, } from "../../utils/main.js";
5
4
  import { preselectMigrations } from "../../utils/migrations.js";
5
+ import { isItFactory } from "../utils/cli-utils.js";
6
6
  import { discoverVersionMapping, LOOKUP_TYPE, SCOPE, } from "../utils/discover.js";
7
7
  const MIGRATIONS_COMMANDS = {
8
8
  recognize: "recognize",
@@ -1,8 +1,8 @@
1
1
  import { managementApi } from "../../api/managementApi.js";
2
2
  import { removeAllComponents, removeSpecifiedComponents, } from "../../api/migrate.js";
3
3
  import Logger from "../../utils/logger.js";
4
- import { unpackElements } from "../../utils/main.js";
5
4
  import { apiConfig } from "../api-config.js";
5
+ import { unpackElements } from "../utils/cli-utils.js";
6
6
  const REMOVE_COMMANDS = {
7
7
  story: "story",
8
8
  components: "components",
@@ -1,9 +1,9 @@
1
1
  import { managementApi } from "../../api/managementApi.js";
2
+ import { getFilesContentWithRequire } from "../../utils/files.js";
2
3
  import Logger from "../../utils/logger.js";
3
- import { getFilesContentWithRequire, isItFactory } from "../../utils/main.js";
4
- import { getFrom, getTo } from "../../utils/others.js";
5
4
  import { apiConfig } from "../api-config.js";
6
5
  import { askForConfirmation } from "../helpers.js";
6
+ import { isItFactory, getFrom, getTo } from "../utils/cli-utils.js";
7
7
  import { discoverStories, LOOKUP_TYPE, SCOPE } from "../utils/discover.js";
8
8
  const REVERT_COMMANDS = {
9
9
  content: "content",
@@ -2,12 +2,11 @@ import { managementApi } from "../../api/managementApi.js";
2
2
  import { removeAllComponents, syncAllComponents, syncContent, syncProvidedComponents, setComponentDefaultPreset, } from "../../api/migrate.js";
3
3
  import storyblokConfig from "../../config/config.js";
4
4
  import Logger from "../../utils/logger.js";
5
- import { isItFactory, unpackElements } from "../../utils/main.js";
6
- import { getFrom, getTo } from "../../utils/others.js";
7
5
  import { apiConfig } from "../api-config.js";
8
6
  import { syncAllDatasources, syncProvidedDatasources, } from "../datasources/sync.js";
9
7
  import { askForConfirmation } from "../helpers.js";
10
8
  import { syncAllRoles, syncProvidedRoles } from "../roles/sync.js";
9
+ import { getFrom, getTo, isItFactory, unpackElements, } from "../utils/cli-utils.js";
11
10
  const SYNC_COMMANDS = {
12
11
  content: "content",
13
12
  components: "components",
package/dist/cli/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  #! /usr/bin/env node
2
2
  import meow from "meow";
3
- import { pipe, prop } from "../utils/main.js";
4
3
  import { backupDescription, debugDescription, mainDescription, syncDescription, removeDescription, initDescription, discoverDescription, migrateDescription, revertDescription, migrationsDescription, copyDescription, } from "./cli-descriptions.js";
5
4
  import { backup } from "./commands/backup.js";
6
5
  import { copyCommand } from "./commands/copy.js";
@@ -13,6 +12,7 @@ import { remove } from "./commands/remove.js";
13
12
  import { revert } from "./commands/revert.js";
14
13
  import { sync } from "./commands/sync.js";
15
14
  import { testCommand } from "./commands/test.js";
15
+ import { pipe, prop } from "./utils/cli-utils.js";
16
16
  const app = () => ({
17
17
  cli: meow(mainDescription, {
18
18
  importMeta: import.meta,
@@ -0,0 +1,69 @@
1
+ /**
2
+ * CLI-specific utility functions for building and parsing CLI commands
3
+ */
4
+ import type { RequestBaseConfig } from "../../api/utils/request.js";
5
+ /**
6
+ * Property accessor - curried function to get a property from an object
7
+ * @example prop('name')({ name: 'hero' }) // => 'hero'
8
+ */
9
+ export declare const prop: (k: any) => (o: any) => any;
10
+ /**
11
+ * Pipe functions left to right (function composition)
12
+ * @example pipe(addOne, double)(5) // => 12
13
+ */
14
+ export declare const pipe: (...fns: any[]) => (x: any) => any;
15
+ /**
16
+ * Extract elements after the first two from CLI input array
17
+ * Used for parsing component names from commands like: sync components hero card
18
+ * @example unpackElements(['sync', 'components', 'hero', 'card']) // => ['hero', 'card']
19
+ */
20
+ export declare const unpackElements: (input: string[]) => string[];
21
+ /**
22
+ * Extract the third element from CLI input array
23
+ * Used for parsing single component name from commands
24
+ * @example unpackOne(['sync', 'components', 'hero']) // => 'hero'
25
+ */
26
+ export declare const unpackOne: (input: string[]) => string | undefined;
27
+ /**
28
+ * Factory for creating flag matchers
29
+ * Used to determine which CLI action to take based on provided flags
30
+ *
31
+ * @param flags - The flags object from CLI parser
32
+ * @param rules - Object mapping action names to required flag combinations
33
+ * @param whitelist - Flags to ignore when matching (e.g., 'from', 'to')
34
+ * @returns A function that checks if a given action type matches the flags
35
+ *
36
+ * @example
37
+ * const rules = { all: ['all'], allWithPresets: ['all', 'presets'] };
38
+ * const isIt = isItFactory({ all: true, presets: true }, rules, []);
39
+ * isIt('allWithPresets') // => true
40
+ */
41
+ export declare const isItFactory: <T>(flags: any, rules: any, whitelist: string[]) => (type: T) => boolean;
42
+ /**
43
+ * Extract 'from' space ID from flags, falling back to config spaceId
44
+ */
45
+ export declare const getFrom: (flags: any, config: RequestBaseConfig) => string;
46
+ /**
47
+ * Extract 'to' space ID from flags, falling back to config spaceId
48
+ */
49
+ export declare const getTo: (flags: any, config: RequestBaseConfig) => string;
50
+ /**
51
+ * Extract 'sourceSpace' from flags, falling back to config spaceId
52
+ */
53
+ export declare const getSourceSpace: (flags: any, config: RequestBaseConfig) => string;
54
+ /**
55
+ * Extract 'targetSpace' from flags, falling back to config spaceId
56
+ */
57
+ export declare const getTargetSpace: (flags: any, config: RequestBaseConfig) => string;
58
+ /**
59
+ * Extract 'what' flag, defaulting to 'all'
60
+ */
61
+ export declare const getWhat: (flags: any) => string;
62
+ /**
63
+ * Extract 'where' flag, defaulting to 'all'
64
+ */
65
+ export declare const getWhere: (flags: any) => string;
66
+ /**
67
+ * Extract 'recursive' flag, defaulting to false
68
+ */
69
+ export declare const getRecursive: (flags: any) => boolean;
@@ -0,0 +1,100 @@
1
+ /**
2
+ * CLI-specific utility functions for building and parsing CLI commands
3
+ */
4
+ /**
5
+ * Property accessor - curried function to get a property from an object
6
+ * @example prop('name')({ name: 'hero' }) // => 'hero'
7
+ */
8
+ export const prop = (k) => (o) => o[k];
9
+ /**
10
+ * Pipe functions left to right (function composition)
11
+ * @example pipe(addOne, double)(5) // => 12
12
+ */
13
+ export const pipe = (...fns) => (x) => [...fns].reduce((acc, f) => f(acc), x);
14
+ /**
15
+ * Extract elements after the first two from CLI input array
16
+ * Used for parsing component names from commands like: sync components hero card
17
+ * @example unpackElements(['sync', 'components', 'hero', 'card']) // => ['hero', 'card']
18
+ */
19
+ export const unpackElements = (input) => {
20
+ const [_1, _2, ...elementsForUse] = input;
21
+ return elementsForUse;
22
+ };
23
+ /**
24
+ * Extract the third element from CLI input array
25
+ * Used for parsing single component name from commands
26
+ * @example unpackOne(['sync', 'components', 'hero']) // => 'hero'
27
+ */
28
+ export const unpackOne = (input) => {
29
+ const [_1, _2, elementForUse] = input;
30
+ return elementForUse;
31
+ };
32
+ /**
33
+ * Factory for creating flag matchers
34
+ * Used to determine which CLI action to take based on provided flags
35
+ *
36
+ * @param flags - The flags object from CLI parser
37
+ * @param rules - Object mapping action names to required flag combinations
38
+ * @param whitelist - Flags to ignore when matching (e.g., 'from', 'to')
39
+ * @returns A function that checks if a given action type matches the flags
40
+ *
41
+ * @example
42
+ * const rules = { all: ['all'], allWithPresets: ['all', 'presets'] };
43
+ * const isIt = isItFactory({ all: true, presets: true }, rules, []);
44
+ * isIt('allWithPresets') // => true
45
+ */
46
+ export const isItFactory = (flags, rules, whitelist) => {
47
+ return (type) => {
48
+ const rulesCopy = [...rules[type]];
49
+ const flagsKeys = Object.keys(flags);
50
+ const temp = flagsKeys.map((flag) => {
51
+ if (whitelist.includes(flag)) {
52
+ return true;
53
+ }
54
+ if (rulesCopy.includes(flag)) {
55
+ rulesCopy.splice(rulesCopy.indexOf(flag), 1);
56
+ return true;
57
+ }
58
+ else {
59
+ return false;
60
+ }
61
+ });
62
+ if (rulesCopy.length > 0) {
63
+ return false;
64
+ }
65
+ else {
66
+ return temp.every((el) => el === true);
67
+ }
68
+ };
69
+ };
70
+ // ============================================================================
71
+ // CLI Flag Extractors
72
+ // ============================================================================
73
+ /**
74
+ * Extract 'from' space ID from flags, falling back to config spaceId
75
+ */
76
+ export const getFrom = (flags, config) => (flags["from"] ? flags["from"] : config.spaceId).toString();
77
+ /**
78
+ * Extract 'to' space ID from flags, falling back to config spaceId
79
+ */
80
+ export const getTo = (flags, config) => (flags["to"] ? flags["to"] : config.spaceId).toString();
81
+ /**
82
+ * Extract 'sourceSpace' from flags, falling back to config spaceId
83
+ */
84
+ export const getSourceSpace = (flags, config) => (flags["sourceSpace"] ? flags["sourceSpace"] : config.spaceId).toString();
85
+ /**
86
+ * Extract 'targetSpace' from flags, falling back to config spaceId
87
+ */
88
+ export const getTargetSpace = (flags, config) => (flags["targetSpace"] ? flags["targetSpace"] : config.spaceId).toString();
89
+ /**
90
+ * Extract 'what' flag, defaulting to 'all'
91
+ */
92
+ export const getWhat = (flags) => (flags["what"] ? flags["what"] : "all").toString();
93
+ /**
94
+ * Extract 'where' flag, defaulting to 'all'
95
+ */
96
+ export const getWhere = (flags) => (flags["where"] ? flags["where"] : "all").toString();
97
+ /**
98
+ * Extract 'recursive' flag, defaulting to false
99
+ */
100
+ export const getRecursive = (flags) => flags["recursive"] ? flags["recursive"] : false;
@@ -1,3 +1,4 @@
1
+ import { type CompareResult, type OneFileElement } from "../../utils/path-utils.js";
1
2
  export declare enum SCOPE {
2
3
  local = "local",
3
4
  external = "external",
@@ -25,23 +26,9 @@ interface DiscoverManyByPackageNameRequest {
25
26
  packageNames: string[];
26
27
  scope: SCOPE;
27
28
  }
28
- interface CompareRequest {
29
- local: string[];
30
- external: string[];
31
- }
32
- export interface OneFileElement {
33
- name: string;
34
- p: string;
35
- }
36
- export interface CompareResult {
37
- local: OneFileElement[];
38
- external: OneFileElement[];
39
- }
40
29
  type DiscoverResult = string[];
41
- export declare const normalizeDiscover: ({ segments }: {
42
- segments: string[];
43
- }) => string | undefined;
44
- export declare const compare: (request: CompareRequest) => CompareResult;
30
+ export type { CompareResult, OneFileElement };
31
+ export { normalizeDiscover, compare, filesPattern, } from "../../utils/path-utils.js";
45
32
  export declare const discoverManyByPackageName: (request: DiscoverManyByPackageNameRequest) => DiscoverResult;
46
33
  export declare const discoverOneByPackageName: (request: DiscoverOneByPackageNameRequest) => DiscoverResult;
47
34
  export declare const discoverMany: (request: DiscoverManyRequest) => Promise<DiscoverResult>;
@@ -50,11 +37,6 @@ export declare const discoverStories: (request: DiscoverManyRequest) => Discover
50
37
  export declare const discoverMigrationConfig: (request: DiscoverManyRequest) => DiscoverResult;
51
38
  export declare const discoverVersionMapping: (request: DiscoverManyRequest) => DiscoverResult;
52
39
  export declare const discoverDatasources: (request: DiscoverRequest) => Promise<DiscoverResult>;
53
- export declare const filesPattern: ({ mainDirectory, componentDirectories, ext, }: {
54
- mainDirectory: string;
55
- componentDirectories: string[];
56
- ext: string;
57
- }) => string;
58
40
  export declare const discover: (request: DiscoverRequest) => Promise<DiscoverResult>;
59
41
  export declare const discoverResolvers: (request: DiscoverRequest) => Promise<DiscoverResult>;
60
42
  export declare const discoverRoles: (request: DiscoverRequest) => Promise<DiscoverResult>;
@@ -63,4 +45,3 @@ export declare const discoverAllComponents: () => Promise<{
63
45
  local: OneFileElement[];
64
46
  external: OneFileElement[];
65
47
  }>;
66
- export {};