sb-mig 6.2.0 → 6.3.0

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 (38) hide show
  1. package/README.md +15 -4
  2. package/dist/api/assets/asset-folders.d.ts +3 -0
  3. package/dist/api/assets/asset-folders.js +56 -0
  4. package/dist/api/assets/asset-folders.types.d.ts +29 -0
  5. package/dist/api/assets/asset-folders.types.js +1 -0
  6. package/dist/api/assets/assets.d.ts +4 -1
  7. package/dist/api/assets/assets.js +61 -16
  8. package/dist/api/assets/assets.types.d.ts +12 -1
  9. package/dist/api/assets/index.d.ts +4 -2
  10. package/dist/api/assets/index.js +2 -1
  11. package/dist/api/copy/assets.d.ts +12 -0
  12. package/dist/api/copy/assets.js +84 -0
  13. package/dist/api/copy/graph.d.ts +8 -0
  14. package/dist/api/copy/graph.js +27 -0
  15. package/dist/api/copy/index.d.ts +6 -0
  16. package/dist/api/copy/index.js +6 -0
  17. package/dist/api/copy/manifest.d.ts +23 -0
  18. package/dist/api/copy/manifest.js +115 -0
  19. package/dist/api/copy/reference-rewriter.d.ts +6 -0
  20. package/dist/api/copy/reference-rewriter.js +153 -0
  21. package/dist/api/copy/reference-scanner.d.ts +23 -0
  22. package/dist/api/copy/reference-scanner.js +322 -0
  23. package/dist/api/copy/types.d.ts +196 -0
  24. package/dist/api/copy/types.js +1 -0
  25. package/dist/api/managementApi.d.ts +6 -0
  26. package/dist/api/stories/stories.js +3 -3
  27. package/dist/api/stories/stories.types.d.ts +3 -1
  28. package/dist/api/testApi.d.ts +6 -0
  29. package/dist/api-v2/requestConfig.d.ts +17 -1
  30. package/dist/api-v2/requestConfig.js +28 -0
  31. package/dist/cli/cli-descriptions.d.ts +2 -2
  32. package/dist/cli/cli-descriptions.js +83 -18
  33. package/dist/cli/commands/copy.js +2091 -145
  34. package/dist/utils/files.d.ts +1 -0
  35. package/dist/utils/files.js +77 -3
  36. package/dist-cjs/api/stories/stories.js +3 -3
  37. package/dist-cjs/api-v2/requestConfig.js +29 -0
  38. package/package.json +2 -2
@@ -1,3 +1,4 @@
1
+ import * as assets from "./assets/index.js";
1
2
  import * as inspect from "./inspect/index.js";
2
3
  import * as stories from "./stories/index.js";
3
4
  export declare const managementApi: {
@@ -8,7 +9,12 @@ export declare const managementApi: {
8
9
  getAsset: (assetName: string | undefined) => Promise<void>;
9
10
  getAssetById: import("./assets/assets.types.js").GetAssetById;
10
11
  getAssetByName: import("./assets/assets.types.js").GetAssetByName;
12
+ createAssetAndFinalize: assets.CreateAssetAndFinalize;
13
+ downloadAsset: import("./assets/assets.types.js").DownloadAsset;
14
+ finishAssetUpload: assets.FinishAssetUpload;
11
15
  updateAsset: import("./assets/assets.types.js").UpdateAsset;
16
+ createAssetFolder: assets.CreateAssetFolder;
17
+ getAllAssetFolders: import("./assets/asset-folders.types.js").GetAllAssetFolders;
12
18
  };
13
19
  auth: {
14
20
  getCurrentUser: import("./auth/auth.types.js").GetCurrentUser;
@@ -338,13 +338,13 @@ export const getStoryVersions = async ({ storyId, showContent = true, page = 1,
338
338
  .catch((err) => Logger.error(err));
339
339
  };
340
340
  // CREATE
341
- export const createStory = (content, config) => {
341
+ export const createStory = (content, config, options) => {
342
342
  const { spaceId, sbApi } = config;
343
343
  Logger.log(`Creating story with name: ${content.name} in space: ${spaceId}`);
344
344
  return sbApi
345
345
  .post(`spaces/${spaceId}/stories/`, {
346
346
  story: content,
347
- publish: true,
347
+ publish: options?.publish ?? true,
348
348
  })
349
349
  .then((res) => res.data)
350
350
  .catch((err) => console.error(err));
@@ -354,7 +354,7 @@ export const updateStory = (content, storyId, options, config) => {
354
354
  const { spaceId, sbApi } = config;
355
355
  const storyLabel = resolveStoryLabel(content, storyId);
356
356
  Logger.warning("Trying to update Story...");
357
- Logger.log(`Updating story with name: ${content.name} in space: ${spaceId}`);
357
+ Logger.log(`Updating story '${storyLabel}' in space: ${spaceId}`);
358
358
  // console.log("THis is content to update: ");
359
359
  // console.log(JSON.stringify(content, null, 2));
360
360
  return sbApi
@@ -41,7 +41,9 @@ export type GetStoryVersions = (args: {
41
41
  export type GetAllStories = (args: {
42
42
  options?: ExtendedISbStoriesParams;
43
43
  }, config: RequestBaseConfig) => Promise<any>;
44
- export type CreateStory = (content: any, config: RequestBaseConfig) => Promise<any>;
44
+ export type CreateStory = (content: any, config: RequestBaseConfig, options?: {
45
+ publish?: boolean;
46
+ }) => Promise<any>;
45
47
  export type UpdateStory = (content: any, storyId: string, options: ModifyStoryOptions, config: RequestBaseConfig) => Promise<any>;
46
48
  export type UpdateStories = (args: {
47
49
  stories: any;
@@ -1,3 +1,4 @@
1
+ import * as assets from "./assets/index.js";
1
2
  import * as stories from "./stories/index.js";
2
3
  export declare const testApi: {
3
4
  assets: {
@@ -7,7 +8,12 @@ export declare const testApi: {
7
8
  getAsset: (assetName: string | undefined) => Promise<void>;
8
9
  getAssetById: import("./assets/assets.types.js").GetAssetById;
9
10
  getAssetByName: import("./assets/assets.types.js").GetAssetByName;
11
+ createAssetAndFinalize: assets.CreateAssetAndFinalize;
12
+ downloadAsset: import("./assets/assets.types.js").DownloadAsset;
13
+ finishAssetUpload: assets.FinishAssetUpload;
10
14
  updateAsset: import("./assets/assets.types.js").UpdateAsset;
15
+ createAssetFolder: assets.CreateAssetFolder;
16
+ getAllAssetFolders: import("./assets/asset-folders.types.js").GetAllAssetFolders;
11
17
  };
12
18
  auth: {
13
19
  getCurrentUser: import("./auth/auth.types.js").GetCurrentUser;
@@ -1,5 +1,21 @@
1
- import type { ApiClient } from "./client.js";
1
+ import type { ApiClient, ClientConfig } from "./client.js";
2
2
  import type { RequestBaseConfig } from "../api/utils/request.js";
3
3
  export declare function toRequestConfig(client: ApiClient, overrides?: Partial<Omit<RequestBaseConfig, "sbApi">> & {
4
4
  spaceId?: string;
5
5
  }): RequestBaseConfig;
6
+ /**
7
+ * Inverse of `toRequestConfig`: adapt a legacy `RequestBaseConfig` into an
8
+ * `ApiClient`.
9
+ *
10
+ * This is the primitive used by the Strategy-B shims (see SDK-REFACTOR.md §3): a
11
+ * legacy `api/<x>` function receives a `RequestBaseConfig` and delegates to the
12
+ * moved `api-v2/<x>` function, which takes an `ApiClient`. The live `sbApi`
13
+ * instance is reused (not recreated) so rate-limit and cache state are preserved.
14
+ *
15
+ * Note: `ApiClient` intentionally carries only the data-API essentials (`sbApi`,
16
+ * `spaceId`, tokens). The remaining `IStoryblokConfig` fields on
17
+ * `RequestBaseConfig` (directories, extensions, resolvers, …) are node-tier /
18
+ * file-discovery concerns handled separately — they are not represented on
19
+ * `ApiClient`. See SDK-REFACTOR.md §4 and ticket F5.
20
+ */
21
+ export declare function configToClient(config: RequestBaseConfig, overrides?: Partial<ClientConfig>): ApiClient;
@@ -32,3 +32,31 @@ export function toRequestConfig(client, overrides) {
32
32
  storyblokComponentsLocalDirectory: overrides?.storyblokComponentsLocalDirectory,
33
33
  };
34
34
  }
35
+ /**
36
+ * Inverse of `toRequestConfig`: adapt a legacy `RequestBaseConfig` into an
37
+ * `ApiClient`.
38
+ *
39
+ * This is the primitive used by the Strategy-B shims (see SDK-REFACTOR.md §3): a
40
+ * legacy `api/<x>` function receives a `RequestBaseConfig` and delegates to the
41
+ * moved `api-v2/<x>` function, which takes an `ApiClient`. The live `sbApi`
42
+ * instance is reused (not recreated) so rate-limit and cache state are preserved.
43
+ *
44
+ * Note: `ApiClient` intentionally carries only the data-API essentials (`sbApi`,
45
+ * `spaceId`, tokens). The remaining `IStoryblokConfig` fields on
46
+ * `RequestBaseConfig` (directories, extensions, resolvers, …) are node-tier /
47
+ * file-discovery concerns handled separately — they are not represented on
48
+ * `ApiClient`. See SDK-REFACTOR.md §4 and ticket F5.
49
+ */
50
+ export function configToClient(config, overrides) {
51
+ const clientConfig = {
52
+ oauthToken: overrides?.oauthToken ?? config.oauthToken ?? "",
53
+ spaceId: overrides?.spaceId ?? config.spaceId,
54
+ accessToken: overrides?.accessToken ?? config.accessToken,
55
+ rateLimit: overrides?.rateLimit ?? config.rateLimit,
56
+ };
57
+ return {
58
+ config: clientConfig,
59
+ sbApi: config.sbApi,
60
+ spaceId: clientConfig.spaceId,
61
+ };
62
+ }
@@ -1,10 +1,10 @@
1
- export declare const mainDescription = "\n USAGE\n $ sb-mig [command]\n\n COMMANDS\n sync Synchronize components, roles, datasources, plugins, stories, and assets.\n copy Copy Storyblok stories or folders between spaces.\n inspect Inspect Storyblok content without writing changes.\n discover Discover local components and migration config files.\n backup Back up Storyblok resources to local JSON files.\n migrate Run story or preset data migrations.\n language-publish-state Build a read-only story language publish-state map.\n story-versions Inspect raw Management API story version history for one story.\n published-layer-export Export draft/current and published story layers as JSON.\n remove Remove components or stories from a Storyblok space.\n revert Restore stories from a local story backup file.\n migrations Recognize migration commands to run for a package upgrade.\n init Initialize project Storyblok environment settings.\n debug Output extra debugging information.\n help Show this screen.\n\n EXAMPLES\n $ sb-mig sync components --all\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --dry-run\n $ sb-mig inspect component-usage --from 12345 --all --query flex-group-width-child\n $ sb-mig copy stories --sourceSpace 12345 --targetSpace 67890 --what folder/* --where target-folder\n";
1
+ export declare const mainDescription = "\n USAGE\n $ sb-mig [command]\n\n COMMANDS\n sync Synchronize components, roles, datasources, plugins, stories, and assets.\n copy Copy Storyblok stories or folders between spaces.\n inspect Inspect Storyblok content without writing changes.\n discover Discover local components and migration config files.\n backup Back up Storyblok resources to local JSON files.\n migrate Run story or preset data migrations.\n language-publish-state Build a read-only story language publish-state map.\n story-versions Inspect raw Management API story version history for one story.\n published-layer-export Export draft/current and published story layers as JSON.\n remove Remove components or stories from a Storyblok space.\n revert Restore stories from a local story backup file.\n migrations Recognize migration commands to run for a package upgrade.\n init Initialize project Storyblok environment settings.\n debug Output extra debugging information.\n help Show this screen.\n\n EXAMPLES\n $ sb-mig sync components --all\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --dry-run\n $ sb-mig inspect component-usage --from 12345 --all --query flex-group-width-child\n $ sb-mig copy stories --from 12345 --to 67890 --source folder/* --destination target-folder\n $ sb-mig copy assets --from 12345 --to 67890 --all --dry-run --outputPath sbmig/copy-plans/assets.json\n";
2
2
  export declare const inspectDescription = "\n USAGE\n $ sb-mig inspect component-usage --from [spaceId] --all --query [query-name]\n $ sb-mig inspect component-usage --from [spaceId] --withSlug [full_slug] --query [query-name]\n $ sb-mig inspect component-usage --from [spaceId] --startsWith [prefix] --query [query-name]\n\n DESCRIPTION\n Inspect Storyblok story content with a local component usage query file.\n This command is read-only against Storyblok and writes a local JSON file only when --outputPath is passed.\n\n COMMANDS\n component-usage Find component usage patterns in selected stories.\n\n FLAGS\n --from Source space ID to inspect. Falls back to configured spaceId.\n --all Inspect all non-folder stories.\n --withSlug Exact story full_slug to inspect. Can be repeated.\n --startsWith Filter stories by starts_with prefix.\n --query Query file name or path. Looks for *.sb.query.js, *.sb.query.cjs, or *.sb.query.mjs.\n --outputPath Optional file path for JSON report output.\n\n SIDE EFFECTS\n Read-only against Storyblok. Writes a local JSON report only when --outputPath is passed.\n\n GOTCHAS\n Pass exactly one selection mode: --all, --withSlug, or --startsWith.\n A query file must default-export an object with name and match(node, context).\n TypeScript query files are planned, but the first implementation supports JS/CJS/MJS query files.\n\n EXAMPLES\n $ sb-mig inspect component-usage --from 12345 --all --query flex-group-width-child\n $ sb-mig inspect component-usage --from 12345 --startsWith landing-pages --query ./queries/flex-group-width-child.sb.query.js --outputPath sbmig/usage/flex-group-width-child.json\n";
3
3
  export declare const storyVersionsDescription = "\n USAGE\n $ sb-mig story-versions --from [spaceId] --storyId [storyId]\n $ sb-mig story-versions --from [spaceId] --withSlug [full_slug]\n\n DESCRIPTION\n Read Storyblok Management API story_versions for a single story.\n This command is read-only and is meant for inspecting version status values and content shape.\n\n FLAGS\n --from Source space ID to inspect. Required.\n --storyId Story ID to inspect. Required unless --withSlug is passed.\n --withSlug Story full_slug to resolve to a story ID. Required unless --storyId is passed.\n --showContent Include version content from Storyblok. Default: true.\n --page Versions page. Default: 1.\n --perPage Versions per page. Default: 25.\n --raw Print the raw Storyblok API response instead of the compact summary.\n --outputPath Optional file path for JSON output.\n\n SIDE EFFECTS\n Read-only against Storyblok. Writes a local JSON file only when --outputPath is passed.\n\n EXAMPLES\n $ sb-mig story-versions --from 12345 --storyId 98765\n $ sb-mig story-versions --from 12345 --withSlug tours/europe --raw --outputPath sbmig/story-versions/tours-europe.raw.json\n";
4
4
  export declare const publishedLayerExportDescription = "\n USAGE\n $ sb-mig published-layer-export --from [spaceId] --all\n $ sb-mig published-layer-export --from [spaceId] --storyId [storyId]\n $ sb-mig published-layer-export --from [spaceId] --withSlug [full_slug]\n $ sb-mig published-layer-export --from [spaceId] --startsWith [prefix]\n\n DESCRIPTION\n Read selected Management API stories and their latest published Story Versions API content.\n This command is read-only against Storyblok. It writes JSON files for inspecting draft/current and published layers before changing migrate behavior.\n\n FLAGS\n --from Source space ID to inspect. Required.\n --all Export all non-folder stories.\n --storyId Story ID to export. Can be repeated.\n --withSlug Exact story full_slug to export. Can be repeated.\n --startsWith Filter stories by starts_with prefix.\n --fileName Stable output base name.\n --outputPath Output directory. Default: sbmig/published-layer-export.\n --versionsPerPage Story versions per page. Default: 25.\n --maxVersionPages Maximum Story Versions API pages to inspect per story. Default: 4.\n\n OUTPUT\n <name>---draft-current-full.json\n <name>---published-layer-full.json\n <name>---dual-layer-summary.json\n\n SIDE EFFECTS\n Read-only against Storyblok. Always writes local JSON export files.\n\n EXAMPLES\n $ sb-mig published-layer-export --from 12345 --withSlug translation-migration-testing/test-1/contact-us\n $ sb-mig published-layer-export --from 12345 --storyId 178888427520390\n $ sb-mig published-layer-export --from 12345 --startsWith translation-migration-testing --fileName translation-test\n";
5
5
  export declare const languagePublishStateDescription = "\n USAGE\n $ sb-mig language-publish-state --from [spaceId]\n\n DESCRIPTION\n Read stories from a source Storyblok space and write a JSON map of default and translated language publication states.\n This command is read-only against Storyblok. It uses Management API for story listing and default-language state, and Delivery API for translated language published/draft comparisons.\n\n FLAGS\n --from Source space ID to inspect. Required.\n --accessToken Optional source space Delivery API access token override. Falls back to configured accessToken.\n --languages Languages to inspect: all, default,fr,de. Default: all.\n --withSlug Exact story full_slug to inspect. Can be repeated.\n --startsWith Filter stories by starts_with prefix.\n --fileName Stable output base name under sbmig/language-publish-state.\n --outputPath Explicit output path for the generated JSON file.\n\n SIDE EFFECTS\n Read-only against Storyblok. Writes a local JSON publish-state map.\n\n EXAMPLES\n $ sb-mig language-publish-state --from 12345 --startsWith about-ef --languages all --fileName about-ef-prod\n $ sb-mig language-publish-state --from 12345 --accessToken xxx --withSlug about-ef/testimonials --languages default,fr\n";
6
6
  export declare const syncDescription = "\n USAGE\n $ sb-mig sync components [component-name ...] | --all [--presets] [--ssot] [--dry-run]\n $ sb-mig sync roles [role-name ...] | --all [--dry-run]\n $ sb-mig sync datasources [datasource-name ...] | --all [--dry-run]\n $ sb-mig sync plugins [plugin-name ...] [--dry-run]\n $ sb-mig sync content (--all | --stories | --assets) --from [spaceId] --to [spaceId-or-file] --syncDirection [direction]\n\n DESCRIPTION\n Synchronize components, roles, datasources, plugins, stories, and assets with Storyblok.\n\n COMMANDS\n components Sync local component schema files to Storyblok.\n roles Sync local role schema files to Storyblok.\n datasources Sync local datasource schema files to Storyblok.\n plugins Sync a provided plugin. Run from a plugin folder with ./dist/export.js.\n content Sync stories and/or assets between spaces, local files, or AWS content hub data.\n\n FLAGS\n --all Sync all supported resources for the selected command.\n --stories Sync only stories. [content only]\n --assets Sync only assets. [content only]\n --presets Also sync component presets and set default presets. [components only]\n --ssot Single Source of Truth mode. Removes GUI-only components and replaces them with code versions. [components only]\n --packageName External package name used when resolving provided components. [components only]\n --dry-run Preview planned changes without making writes. [components, roles, datasources, plugins, content]\n --yes Skip confirmation prompts. [components --ssot, destructive content sync]\n --from Source space ID or local story file name, depending on --syncDirection. [content only]\n --to Target space ID or local output file name, depending on --syncDirection. [content only]\n --syncDirection Sync direction. Values: fromSpaceToFile, fromFileToSpace, fromSpaceToSpace, fromAWSToSpace. [content only]\n\n SIDE EFFECTS\n components, roles, datasources, and plugins write to Storyblok unless --dry-run is passed.\n content with fromSpaceToSpace or fromFileToSpace can delete all target stories before recreating them.\n content with fromSpaceToFile writes local story and asset backup files.\n\n GOTCHAS\n --syncDirection is required for content sync.\n fromFileToSpace is implemented for stories, but assets log that it is not implemented.\n fromAWSToSpace is implemented for stories. Assets log that unsupported directions are not implemented.\n --ssot is destructive for components and prompts unless --yes is passed.\n\n EXAMPLES\n $ sb-mig sync components --all\n $ sb-mig sync components --all --dry-run\n $ sb-mig sync components --all --presets\n $ sb-mig sync components --all --ssot --yes\n $ sb-mig sync components accordion accordion-item --presets\n\n $ sb-mig sync roles --all\n $ sb-mig sync roles admin editor --dry-run\n\n $ sb-mig sync datasources --all\n $ sb-mig sync datasources countries cities --dry-run\n\n $ sb-mig sync plugins my-awesome-plugin\n\n $ sb-mig sync content --all --from 12345 --to 67890 --syncDirection fromSpaceToSpace --yes\n $ sb-mig sync content --stories --from 12345 --to all-stories-backup --syncDirection fromSpaceToFile\n $ sb-mig sync content --stories --from all-stories-backup --to 67890 --syncDirection fromFileToSpace --dry-run\n $ sb-mig sync content --stories --from 12345 --to 67890 --syncDirection fromAWSToSpace\n";
7
- export declare const copyDescription = "\n USAGE\n $ sb-mig copy stories --sourceSpace [spaceId] --targetSpace [spaceId] --what [full_slug] --where [target_folder_full_slug]\n $ sb-mig copy stories --sourceSpace [spaceId] --targetSpace [spaceId] --what [folder_full_slug]\n $ sb-mig copy stories --sourceSpace [spaceId] --targetSpace [spaceId] --what [folder_full_slug]/* --where [target_folder_full_slug]\n\n DESCRIPTION\n Copy Storyblok stories or folders from one space to a folder in another space.\n\n COMMANDS\n stories Copy one story, one folder with its root, or a folder's children recursively.\n\n FLAGS\n --sourceSpace Source Storyblok space ID. Falls back to configured spaceId.\n --targetSpace Target Storyblok space ID. Falls back to configured spaceId.\n --what Source story or folder full_slug. Use folder/* to copy a folder's children without the folder root.\n --where Target folder full_slug where copied stories are attached.\n\n SIDE EFFECTS\n Writes copied stories into the target Storyblok space.\n\n GOTCHAS\n --what must resolve to an existing source story or folder.\n --where must resolve to an existing target folder.\n folder/* requires the source path before /* to be a folder.\n Copy currently logs internal strategy details while it runs.\n\n EXAMPLES\n $ sb-mig copy stories --sourceSpace 12345 --targetSpace 67890 --what blog/post-1 --where imported\n $ sb-mig copy stories --sourceSpace 12345 --targetSpace 67890 --what blog --where imported\n $ sb-mig copy stories --sourceSpace 12345 --targetSpace 67890 --what blog/* --where imported\n";
7
+ export declare const copyDescription = "\n USAGE\n $ sb-mig copy stories --from [spaceId] --to [spaceId] --source [full_slug] --destination [target_folder_full_slug]\n $ sb-mig copy stories --from [spaceId] --to [spaceId] --source [folder_full_slug]\n $ sb-mig copy stories --from [spaceId] --to [spaceId] --source [folder_full_slug]/* --destination [target_folder_full_slug]\n $ sb-mig copy stories --from [spaceId] --to [spaceId] --source [folder_full_slug] --mode self --destination /\n $ sb-mig copy assets --from [spaceId] --to [spaceId] --all\n $ sb-mig copy assets --from [spaceId] --to [spaceId] --asset [asset_id_or_filename]\n $ sb-mig copy assets --from [spaceId] --to [spaceId] --assetFolder [folder_id_or_path]\n $ sb-mig copy assets --from [spaceId] --to [spaceId] --referenced-by-stories --source [story_or_folder_full_slug]\n $ sb-mig copy assets --from [spaceId] --to [spaceId] --all --dry-run\n\n DESCRIPTION\n Copy Storyblok stories, folders, assets, or asset folders from one space to another.\n\n COMMANDS\n stories Copy one story, one folder subtree, a folder's children, or one folder shell.\n assets Copy or plan all assets and asset folders with durable manifests.\n\n FLAGS\n --from Source Storyblok space ID. Falls back to configured spaceId.\n --to Target Storyblok space ID. Falls back to configured spaceId.\n --source Source story or folder full_slug. Use folder/* to copy a folder's children without the folder root.\n --destination Target folder full_slug where copied stories are attached. Omit, '/', or 'root' to copy into target root.\n --mode Copy mode: subtree, children, or self. Default: subtree. folder/* defaults to children.\n --with-assets For copy stories, copy referenced assets first and rewrite copied stories to target asset IDs/filenames.\n --publicationMode\n How copy stories should preserve Storyblok publication state. Values: preserve-layers, collapse-draft, save-only. Default: preserve-layers. [stories only]\n --publicationLanguages\n Language scope to publish when publicationMode publishes stories. Values: default, all, or comma-separated Storyblok language codes. Default: all. [stories only]\n --all Select all assets and asset folders. [assets only]\n --asset Select one source asset by numeric ID, exact Storyblok asset URL, or unique file name. Repeatable. [assets only]\n --assetFolder Select one source asset folder by numeric ID or folder path. Includes descendants and assets in that subtree. Repeatable. [assets only]\n --referenced-by-stories\n Select assets referenced by a story/folder scope. Requires --source. [assets only]\n --dry-run Preview story paths, manifest-mapped references, and likely target conflicts without writing to Storyblok.\n --outputPath Optional JSON file path for a dry-run copy plan artifact. Only writes locally when passed.\n\n LEGACY FLAGS\n --sourceSpace Alias for --from.\n --targetSpace Alias for --to.\n --what Alias for --source.\n --where Alias for --destination.\n\n SIDE EFFECTS\n copy stories writes copied stories into the target Storyblok space unless --dry-run is passed.\n copy stories writes story ID/UUID manifests under .sb-mig/copy/<source>/<target>/ during apply.\n copy stories --with-assets writes referenced asset folders/assets before story writes unless --dry-run is passed.\n copy assets writes asset folders and assets into the target Storyblok space unless --dry-run is passed.\n copy assets writes JSONL manifests under .sb-mig/copy/<source>/<target>/ during apply.\n --outputPath writes a local JSON report for dry-run or apply.\n\n GOTCHAS\n --source must resolve to an existing source story or folder.\n --destination must resolve to an existing target folder unless it is omitted, '/', or 'root'.\n mode 'subtree' copies a folder and all descendants. This is the default for folders.\n mode 'children' copies a folder's descendants without the folder root.\n mode 'self' copies only the source story or folder shell.\n copy stories creates or matches target story shells, then fills them with rewritten source content.\n copy stories matches existing targets by manifest first, then target full_slug when safe, so reruns can reuse mapped target stories.\n copy stories rewrites mapped asset and story references after story manifests exist.\n copy stories creates shells as save-only drafts, then applies publicationMode after full rewritten content is saved.\n publicationMode preserve-layers publishes clean published source stories; for dirty published source stories it copies the source published version, publishes it in target, then restores the source draft/current layer as save-only.\n publicationMode collapse-draft publishes published source stories from their current draft/current JSON.\n publicationMode save-only never publishes copied stories.\n --publicationLanguages cannot be used with --publicationMode save-only.\n copy stories --with-assets scans selected stories with source component schemas and only copies referenced assets it can resolve from the source asset list.\n --dry-run checks likely target path conflicts and reports mapped/planned/unresolved story and asset references, with occurrence and unique-asset counts in JSON output.\n Without --with-assets, run copy assets first when copied stories should point to target-space assets.\n copy assets supports --all, --asset, or --assetFolder. Use only one selector family per run.\n copy assets --asset includes the selected asset's folder ancestors so target folder mappings can be preserved.\n copy assets --assetFolder includes the selected folder, descendants, folder ancestors, and assets inside that selected subtree.\n copy assets --referenced-by-stories scans selected stories with source component schemas and copies only source-space assets referenced by that story scope.\n copy assets matches by manifest first, then safe target folder path or unique asset file name before creating.\n copy assets uploads assets, finalizes the upload, and writes source-to-target asset/folder manifests.\n\n EXAMPLES\n $ sb-mig copy stories --from 12345 --to 67890 --source blog/post-1 --destination imported\n $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported\n $ sb-mig copy stories --from 12345 --to 67890 --source blog/* --destination imported\n $ sb-mig copy stories --from 12345 --to 67890 --source blog --mode self --destination /\n $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported --with-assets\n $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported --with-assets --publicationMode preserve-layers\n $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported --publicationMode collapse-draft --publicationLanguages default,fr,de\n $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported --publicationMode save-only\n $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported --dry-run\n $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported --with-assets --dry-run --outputPath sbmig/copy-plans/blog-copy.json\n $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported --dry-run --outputPath sbmig/copy-plans/blog-copy.json\n $ sb-mig copy assets --from 12345 --to 67890 --all\n $ sb-mig copy assets --from 12345 --to 67890 --asset 987654\n $ sb-mig copy assets --from 12345 --to 67890 --asset hero.jpg --dry-run\n $ sb-mig copy assets --from 12345 --to 67890 --assetFolder Marketing/Heroes --dry-run\n $ sb-mig copy assets --from 12345 --to 67890 --referenced-by-stories --source blog --dry-run --outputPath sbmig/copy-plans/blog-assets.json\n $ sb-mig copy assets --from 12345 --to 67890 --all --dry-run\n $ sb-mig copy assets --from 12345 --to 67890 --all --dry-run --outputPath sbmig/copy-plans/assets-copy.json\n";
8
8
  export declare const migrateDescription = "\n USAGE\n $ sb-mig migrate content [component-name ...] --from [spaceId] --to [spaceId] --migration [migration-config]\n $ sb-mig migrate content --all --from [spaceId] --to [spaceId] --migration [migration-config]\n $ sb-mig migrate presets --all --from [spaceId-or-file] --to [spaceId] --migration [migration-config]\n\n DESCRIPTION\n Migrate story content or presets using local migration config files.\n This is a potentially destructive command. It prompts for confirmation unless --yes or --dry-run is passed.\n\n COMMANDS\n content Migrate story content for all components or provided component names.\n presets Migrate presets. Supports --all and exactly one --migration value.\n\n FLAGS\n --from Source space ID, or local file name when --migrate-from file is used.\n --fromFilePath Direct path to stories or presets JSON when using --migrate-from file.\n --to Target Storyblok space ID.\n --migrate-from Migrate from space or file. Default: space.\n --migration Migration file name without extension. Can be repeated for ordered content pipelines. Presets support exactly one.\n --migrationComponentAlias\n Add extra component aliases for a migration. Repeatable. Format: <migration>:<source>=<alias1>,<alias2>.\n --migrationComponents\n Override the exact component scope for a migration. Repeatable. Format: <migration>:<component1>,<component2>.\n --withSlug Filter stories by full_slug. Can be repeated. [content only]\n --startsWith Filter stories by starts_with prefix. [content only]\n --yes Skip confirmation prompts.\n --dry-run Preview what would be migrated without making API changes.\n --publicationMode How migrate content should preserve Storyblok publication state. Values: preserve-layers, collapse-draft, save-only. Default: preserve-layers. [content only]\n --publicationLanguages\n Language scope to inspect and preserve when publicationMode publishes stories. Values: default, all, or comma-separated Storyblok language codes. Default: all. [content only]\n --languagePublishStatePath\n Optional JSON file generated by language-publish-state. When omitted, migrate builds the map automatically for selected stories. [content only]\n --fileName Stable base name for migration output files.\n\n SIDE EFFECTS\n content writes migrated stories to Storyblok unless --dry-run is passed.\n content creates a story backup before provided-component migrations unless --dry-run is passed.\n presets backs up all remote presets before writing migrated presets unless --dry-run is passed.\n\n GOTCHAS\n At least one --migration value is required.\n preserve-layers currently requires --migrate-from space and requires --from and --to to be the same Storyblok space.\n --publicationLanguages cannot be used with --publicationMode save-only.\n --languagePublishStatePath cannot be used with --publicationMode save-only.\n --publicationMode, --publicationLanguages, and --languagePublishStatePath are only supported for migrate content, not migrate presets.\n Legacy flags --publish, --publishLanguages, and --preservePublishedLayer are rejected. Use --publicationMode and --publicationLanguages instead.\n\n EXAMPLES\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --dry-run\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration migration-a --migration migration-b --migration migration-c --yes\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration colorPickerModeValues --migrationComponentAlias colorPickerModeValues:sb-button=sb-open-drift-button\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration colorPickerModeValues --migrationComponents colorPickerModeValues:sb-section,sb-tour-page-section\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --withSlug blog/home --withSlug docs/getting-started\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --startsWith blog/\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --publicationMode preserve-layers --yes\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --publicationMode collapse-draft --publicationLanguages default,fr,de --yes\n $ sb-mig migrate content --all --migrate-from file --from file-with-stories --to 12345 --migration file-with-migration\n $ sb-mig migrate content --all --migrate-from file --fromFilePath sbmig/migrations/dry-run--123---story-to-migrate.json --to 12345 --migration migration-a --migration migration-b\n $ sb-mig migrate content my-component-1 my-component-2 --from 12345 --to 12345 --migration file-with-migration\n $ sb-mig migrate presets --all --from 12345 --to 12345 --migration preset-migration --dry-run\n $ sb-mig migrate presets --all --migrate-from file --fromFilePath sbmig/presets/presets-backup.json --to 12345 --migration preset-migration\n";
9
9
  export declare const revertDescription = "\n USAGE\n $ sb-mig revert content --from [stories-file-name] --to [spaceId] [--yes]\n\n DESCRIPTION\n Restore stories from a local story backup file into a Storyblok space.\n\n COMMANDS\n content Revert content by updating target stories from a local story backup.\n\n FLAGS\n --from Local story backup file name to discover and load.\n --to Target Storyblok space ID to update.\n --yes Skip confirmation prompt.\n\n SIDE EFFECTS\n Writes stories to the target Storyblok space.\n Creates a target-space story backup before restoring.\n Restored stories are updated with publish: false.\n\n GOTCHAS\n This command restores local story files directly and does not run migration configs.\n The --from value is resolved as a local story file name, not a source space ID.\n\n EXAMPLES\n $ sb-mig revert content --from 12345--backup-before-migration --to 12345\n $ sb-mig revert content --from prod-stories-backup --to 12345 --yes\n";
10
10
  export declare const discoverDescription = "\n USAGE\n $ sb-mig discover components --all [--write] [--file file-name]\n $ sb-mig discover migrations --all\n\n DESCRIPTION\n Discover local and external component schema files or migration config files.\n\n COMMANDS\n components Discover component schema files.\n migrations Discover migration config files.\n\n FLAGS\n --all Discover all components or migration config files.\n --write Write discovered component names to a local file. [components only]\n --file Output file name when --write is passed. [components only]\n\n SIDE EFFECTS\n Read-only unless --write is passed.\n --write creates or overwrites a local component list file.\n\n EXAMPLES\n $ sb-mig discover components --all\n $ sb-mig discover components --all --write\n $ sb-mig discover components --all --write --file all-components\n $ sb-mig discover migrations --all\n";
@@ -23,7 +23,8 @@ export const mainDescription = `
23
23
  $ sb-mig sync components --all
24
24
  $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --dry-run
25
25
  $ sb-mig inspect component-usage --from 12345 --all --query flex-group-width-child
26
- $ sb-mig copy stories --sourceSpace 12345 --targetSpace 67890 --what folder/* --where target-folder
26
+ $ sb-mig copy stories --from 12345 --to 67890 --source folder/* --destination target-folder
27
+ $ sb-mig copy assets --from 12345 --to 67890 --all --dry-run --outputPath sbmig/copy-plans/assets.json
27
28
  `;
28
29
  export const inspectDescription = `
29
30
  USAGE
@@ -207,35 +208,99 @@ export const syncDescription = `
207
208
  `;
208
209
  export const copyDescription = `
209
210
  USAGE
210
- $ sb-mig copy stories --sourceSpace [spaceId] --targetSpace [spaceId] --what [full_slug] --where [target_folder_full_slug]
211
- $ sb-mig copy stories --sourceSpace [spaceId] --targetSpace [spaceId] --what [folder_full_slug]
212
- $ sb-mig copy stories --sourceSpace [spaceId] --targetSpace [spaceId] --what [folder_full_slug]/* --where [target_folder_full_slug]
211
+ $ sb-mig copy stories --from [spaceId] --to [spaceId] --source [full_slug] --destination [target_folder_full_slug]
212
+ $ sb-mig copy stories --from [spaceId] --to [spaceId] --source [folder_full_slug]
213
+ $ sb-mig copy stories --from [spaceId] --to [spaceId] --source [folder_full_slug]/* --destination [target_folder_full_slug]
214
+ $ sb-mig copy stories --from [spaceId] --to [spaceId] --source [folder_full_slug] --mode self --destination /
215
+ $ sb-mig copy assets --from [spaceId] --to [spaceId] --all
216
+ $ sb-mig copy assets --from [spaceId] --to [spaceId] --asset [asset_id_or_filename]
217
+ $ sb-mig copy assets --from [spaceId] --to [spaceId] --assetFolder [folder_id_or_path]
218
+ $ sb-mig copy assets --from [spaceId] --to [spaceId] --referenced-by-stories --source [story_or_folder_full_slug]
219
+ $ sb-mig copy assets --from [spaceId] --to [spaceId] --all --dry-run
213
220
 
214
221
  DESCRIPTION
215
- Copy Storyblok stories or folders from one space to a folder in another space.
222
+ Copy Storyblok stories, folders, assets, or asset folders from one space to another.
216
223
 
217
224
  COMMANDS
218
- stories Copy one story, one folder with its root, or a folder's children recursively.
225
+ stories Copy one story, one folder subtree, a folder's children, or one folder shell.
226
+ assets Copy or plan all assets and asset folders with durable manifests.
219
227
 
220
228
  FLAGS
221
- --sourceSpace Source Storyblok space ID. Falls back to configured spaceId.
222
- --targetSpace Target Storyblok space ID. Falls back to configured spaceId.
223
- --what Source story or folder full_slug. Use folder/* to copy a folder's children without the folder root.
224
- --where Target folder full_slug where copied stories are attached.
229
+ --from Source Storyblok space ID. Falls back to configured spaceId.
230
+ --to Target Storyblok space ID. Falls back to configured spaceId.
231
+ --source Source story or folder full_slug. Use folder/* to copy a folder's children without the folder root.
232
+ --destination Target folder full_slug where copied stories are attached. Omit, '/', or 'root' to copy into target root.
233
+ --mode Copy mode: subtree, children, or self. Default: subtree. folder/* defaults to children.
234
+ --with-assets For copy stories, copy referenced assets first and rewrite copied stories to target asset IDs/filenames.
235
+ --publicationMode
236
+ How copy stories should preserve Storyblok publication state. Values: preserve-layers, collapse-draft, save-only. Default: preserve-layers. [stories only]
237
+ --publicationLanguages
238
+ Language scope to publish when publicationMode publishes stories. Values: default, all, or comma-separated Storyblok language codes. Default: all. [stories only]
239
+ --all Select all assets and asset folders. [assets only]
240
+ --asset Select one source asset by numeric ID, exact Storyblok asset URL, or unique file name. Repeatable. [assets only]
241
+ --assetFolder Select one source asset folder by numeric ID or folder path. Includes descendants and assets in that subtree. Repeatable. [assets only]
242
+ --referenced-by-stories
243
+ Select assets referenced by a story/folder scope. Requires --source. [assets only]
244
+ --dry-run Preview story paths, manifest-mapped references, and likely target conflicts without writing to Storyblok.
245
+ --outputPath Optional JSON file path for a dry-run copy plan artifact. Only writes locally when passed.
246
+
247
+ LEGACY FLAGS
248
+ --sourceSpace Alias for --from.
249
+ --targetSpace Alias for --to.
250
+ --what Alias for --source.
251
+ --where Alias for --destination.
225
252
 
226
253
  SIDE EFFECTS
227
- Writes copied stories into the target Storyblok space.
254
+ copy stories writes copied stories into the target Storyblok space unless --dry-run is passed.
255
+ copy stories writes story ID/UUID manifests under .sb-mig/copy/<source>/<target>/ during apply.
256
+ copy stories --with-assets writes referenced asset folders/assets before story writes unless --dry-run is passed.
257
+ copy assets writes asset folders and assets into the target Storyblok space unless --dry-run is passed.
258
+ copy assets writes JSONL manifests under .sb-mig/copy/<source>/<target>/ during apply.
259
+ --outputPath writes a local JSON report for dry-run or apply.
228
260
 
229
261
  GOTCHAS
230
- --what must resolve to an existing source story or folder.
231
- --where must resolve to an existing target folder.
232
- folder/* requires the source path before /* to be a folder.
233
- Copy currently logs internal strategy details while it runs.
262
+ --source must resolve to an existing source story or folder.
263
+ --destination must resolve to an existing target folder unless it is omitted, '/', or 'root'.
264
+ mode 'subtree' copies a folder and all descendants. This is the default for folders.
265
+ mode 'children' copies a folder's descendants without the folder root.
266
+ mode 'self' copies only the source story or folder shell.
267
+ copy stories creates or matches target story shells, then fills them with rewritten source content.
268
+ copy stories matches existing targets by manifest first, then target full_slug when safe, so reruns can reuse mapped target stories.
269
+ copy stories rewrites mapped asset and story references after story manifests exist.
270
+ copy stories creates shells as save-only drafts, then applies publicationMode after full rewritten content is saved.
271
+ publicationMode preserve-layers publishes clean published source stories; for dirty published source stories it copies the source published version, publishes it in target, then restores the source draft/current layer as save-only.
272
+ publicationMode collapse-draft publishes published source stories from their current draft/current JSON.
273
+ publicationMode save-only never publishes copied stories.
274
+ --publicationLanguages cannot be used with --publicationMode save-only.
275
+ copy stories --with-assets scans selected stories with source component schemas and only copies referenced assets it can resolve from the source asset list.
276
+ --dry-run checks likely target path conflicts and reports mapped/planned/unresolved story and asset references, with occurrence and unique-asset counts in JSON output.
277
+ Without --with-assets, run copy assets first when copied stories should point to target-space assets.
278
+ copy assets supports --all, --asset, or --assetFolder. Use only one selector family per run.
279
+ copy assets --asset includes the selected asset's folder ancestors so target folder mappings can be preserved.
280
+ copy assets --assetFolder includes the selected folder, descendants, folder ancestors, and assets inside that selected subtree.
281
+ copy assets --referenced-by-stories scans selected stories with source component schemas and copies only source-space assets referenced by that story scope.
282
+ copy assets matches by manifest first, then safe target folder path or unique asset file name before creating.
283
+ copy assets uploads assets, finalizes the upload, and writes source-to-target asset/folder manifests.
234
284
 
235
285
  EXAMPLES
236
- $ sb-mig copy stories --sourceSpace 12345 --targetSpace 67890 --what blog/post-1 --where imported
237
- $ sb-mig copy stories --sourceSpace 12345 --targetSpace 67890 --what blog --where imported
238
- $ sb-mig copy stories --sourceSpace 12345 --targetSpace 67890 --what blog/* --where imported
286
+ $ sb-mig copy stories --from 12345 --to 67890 --source blog/post-1 --destination imported
287
+ $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported
288
+ $ sb-mig copy stories --from 12345 --to 67890 --source blog/* --destination imported
289
+ $ sb-mig copy stories --from 12345 --to 67890 --source blog --mode self --destination /
290
+ $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported --with-assets
291
+ $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported --with-assets --publicationMode preserve-layers
292
+ $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported --publicationMode collapse-draft --publicationLanguages default,fr,de
293
+ $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported --publicationMode save-only
294
+ $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported --dry-run
295
+ $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported --with-assets --dry-run --outputPath sbmig/copy-plans/blog-copy.json
296
+ $ sb-mig copy stories --from 12345 --to 67890 --source blog --destination imported --dry-run --outputPath sbmig/copy-plans/blog-copy.json
297
+ $ sb-mig copy assets --from 12345 --to 67890 --all
298
+ $ sb-mig copy assets --from 12345 --to 67890 --asset 987654
299
+ $ sb-mig copy assets --from 12345 --to 67890 --asset hero.jpg --dry-run
300
+ $ sb-mig copy assets --from 12345 --to 67890 --assetFolder Marketing/Heroes --dry-run
301
+ $ sb-mig copy assets --from 12345 --to 67890 --referenced-by-stories --source blog --dry-run --outputPath sbmig/copy-plans/blog-assets.json
302
+ $ sb-mig copy assets --from 12345 --to 67890 --all --dry-run
303
+ $ sb-mig copy assets --from 12345 --to 67890 --all --dry-run --outputPath sbmig/copy-plans/assets-copy.json
239
304
  `;
240
305
  export const migrateDescription = `
241
306
  USAGE