@artinstack/migrator 0.1.9 → 0.1.10
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.
- package/dist/{bundle-B3XS20r_.d.ts → bundle-Do-9ikQv.d.ts} +1 -1
- package/dist/{chunk-PPT5RIZ4.js → chunk-3A2PA4P3.js} +38 -6
- package/dist/chunk-3A2PA4P3.js.map +1 -0
- package/dist/{chunk-KTQGOM45.js → chunk-LC7CGWDN.js} +1 -1
- package/dist/chunk-LC7CGWDN.js.map +1 -0
- package/dist/{chunk-FB3MMCHY.js → chunk-YLVPZ4M3.js} +71 -9
- package/dist/chunk-YLVPZ4M3.js.map +1 -0
- package/dist/cli/index.js +10 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -3
- package/dist/normalizer/index.d.ts +4 -4
- package/dist/normalizer/index.js +1 -1
- package/dist/sinks/index.d.ts +13 -3
- package/dist/sinks/index.js +4 -2
- package/dist/transformers/index.d.ts +1 -1
- package/dist/{types-Ce4r6zqt.d.ts → types-TCHy3Oko.d.ts} +13 -1
- package/package.json +1 -1
- package/dist/chunk-FB3MMCHY.js.map +0 -1
- package/dist/chunk-KTQGOM45.js.map +0 -1
- package/dist/chunk-PPT5RIZ4.js.map +0 -1
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { writeFile } from \"node:fs/promises\";\nimport { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport { getAdapter } from \"../parsers/index.js\";\nimport type { MigrationPlatform } from \"../normalizer/types.js\";\nimport {\n analyzeConflicts,\n buildMigrationReport,\n buildRedirectMap,\n bundleToCombinedJson,\n createFilesystemMigrationSink,\n detectRedirectLoops,\n hasBlockingConflicts,\n hasWarnings,\n runDryRun,\n runMigration,\n writeFilesystemExport,\n} from \"../sinks/index.js\";\nimport { collectEntities } from \"../normalizer/bundle.js\";\nimport { createWpContentGatewayRewrite } from \"../lib/media-urls.js\";\nimport { estimateStorage, staleUrlsFromEstimate } from \"../sinks/storage-estimate.js\";\n\nconst PLATFORMS: MigrationPlatform[] = [\"wordpress\", \"smugmug\", \"squarespace\", \"wix\"];\nconst SINKS = [\"filesystem\"] as const;\n\nfunction printUsage(): void {\n console.log(`artinstack-migrate — platform content migration CLI\n\nUsage:\n artinstack-migrate <platform> <export-file> [options]\n artinstack-migrate validate <platform> <export-file>\n\nPlatforms: ${PLATFORMS.join(\", \")}\n\nOptions:\n --out <dir> Write grouped JSON files to directory\n --sink <name> Run through MigrationSink (supported: ${SINKS.join(\", \")})\n --format json Write combined JSON to stdout\n --dry-run Parse and analyze without writing content files\n --report <dir> With --dry-run, write conflicts.json + migration-report.json\n --offline Skip network HEAD requests (4 MB fallback per asset)\n --urls <file> Wix W2: newline URL list or sitemap.xml for static page snapshots\n --rewrite-gateway <url> WordPress: API gateway base (requires --rewrite-public)\n --rewrite-public <url> WordPress: public origin for /wp-content/ asset paths\n\nExamples:\n artinstack-migrate wordpress export.xml --dry-run --report ./preview/\n artinstack-migrate wordpress export.xml --rewrite-gateway https://gateway.example/prod --rewrite-public https://www.example.com --dry-run --report ./preview/\n artinstack-migrate wix feed.xml --urls ./sitemap-urls.txt --dry-run\n artinstack-migrate wordpress export.xml --out ./output\n artinstack-migrate wordpress export.xml --sink filesystem --out ./output\n pnpm cli wordpress fixtures/wordpress/long-form-journal.xml --dry-run\n`);\n}\n\nfunction printDryRunStatus(exitCode: 0 | 1 | 2, reportDir?: string): void {\n const dest = reportDir ? ` Reports written to ${reportDir}.` : \"\";\n if (exitCode === 0) {\n console.error(`Dry run complete.${dest}`);\n } else if (exitCode === 2) {\n console.error(`Dry run complete with warnings (exit 2).${dest}`);\n } else {\n console.error(`Dry run found blocking conflicts (exit 1).${dest}`);\n }\n}\n\nfunction parseArgs(argv: string[]): {\n command: string | undefined;\n platform: MigrationPlatform | undefined;\n inputPath: string | undefined;\n urlsPath: string | undefined;\n outDir: string | undefined;\n reportDir: string | undefined;\n sinkName: string | undefined;\n dryRun: boolean;\n formatJson: boolean;\n offline: boolean;\n rewriteGateway: string | undefined;\n rewritePublic: string | undefined;\n} {\n const args = [...argv];\n let command: string | undefined;\n let platform: MigrationPlatform | undefined;\n let inputPath: string | undefined;\n let urlsPath: string | undefined;\n let outDir: string | undefined;\n let reportDir: string | undefined;\n let sinkName: string | undefined;\n let dryRun = false;\n let formatJson = false;\n let offline = false;\n let rewriteGateway: string | undefined;\n let rewritePublic: string | undefined;\n\n const first = args[0];\n if (first === \"validate\") {\n command = \"validate\";\n platform = args[1] as MigrationPlatform;\n inputPath = args[2];\n for (let i = 3; i < args.length; i++) {\n if (args[i] === \"--urls\" && args[i + 1]) urlsPath = args[++i];\n }\n } else if (first && PLATFORMS.includes(first as MigrationPlatform)) {\n command = \"migrate\";\n platform = first as MigrationPlatform;\n inputPath = args[1];\n for (let i = 2; i < args.length; i++) {\n const flag = args[i];\n if (flag === \"--dry-run\") dryRun = true;\n else if (flag === \"--format\" && args[i + 1] === \"json\") formatJson = true;\n else if (flag === \"--offline\") offline = true;\n else if (flag === \"--out\" && args[i + 1]) {\n outDir = args[++i];\n } else if (flag === \"--report\" && args[i + 1]) {\n reportDir = args[++i];\n } else if (flag === \"--sink\" && args[i + 1]) {\n sinkName = args[++i];\n } else if (flag === \"--urls\" && args[i + 1]) {\n urlsPath = args[++i];\n } else if (flag === \"--rewrite-gateway\" && args[i + 1]) {\n rewriteGateway = args[++i];\n } else if (flag === \"--rewrite-public\" && args[i + 1]) {\n rewritePublic = args[++i];\n }\n }\n } else {\n command = first;\n }\n\n return { command, platform, inputPath, urlsPath, outDir, reportDir, sinkName, dryRun, formatJson, offline, rewriteGateway, rewritePublic };\n}\n\nfunction buildAdapterInput(\n platform: MigrationPlatform,\n inputPath: string,\n urlsPath: string | undefined,\n rewriteGateway: string | undefined,\n rewritePublic: string | undefined,\n): unknown {\n if (rewriteGateway || rewritePublic) {\n if (platform !== \"wordpress\") {\n throw new Error(\"--rewrite-gateway and --rewrite-public are WordPress-only options\");\n }\n if (!rewriteGateway || !rewritePublic) {\n throw new Error(\"Both --rewrite-gateway and --rewrite-public are required together\");\n }\n }\n\n if (platform === \"wordpress\") {\n return {\n path: inputPath,\n ...(rewriteGateway && rewritePublic\n ? { originUrlRewrite: createWpContentGatewayRewrite(rewriteGateway, rewritePublic) }\n : {}),\n };\n }\n\n return {\n path: inputPath,\n ...(urlsPath ? { urlsFile: urlsPath } : {}),\n };\n}\n\nfunction migrationExitCode(hasBlockers: boolean, hasWarn: boolean): 0 | 1 | 2 {\n if (hasBlockers) return 1;\n if (hasWarn) return 2;\n return 0;\n}\n\nasync function main(): Promise<void> {\n const { command, platform, inputPath, urlsPath, outDir, reportDir, sinkName, dryRun, formatJson, offline, rewriteGateway, rewritePublic } =\n parseArgs(process.argv.slice(2));\n\n if (!command || command === \"--help\" || command === \"-h\") {\n printUsage();\n process.exit(0);\n }\n\n if (command === \"validate\") {\n if (!platform || !PLATFORMS.includes(platform) || !inputPath) {\n console.error(\"Usage: artinstack-migrate validate <platform> <export-file>\");\n process.exit(1);\n }\n const adapter = getAdapter(platform);\n const result = await adapter.validateInput({\n path: inputPath,\n ...(urlsPath ? { urlsFile: urlsPath } : {}),\n });\n console.log(JSON.stringify(result, null, 2));\n process.exit(result.ok ? 0 : 1);\n }\n\n if (command === \"migrate\") {\n if (!platform || !inputPath) {\n printUsage();\n process.exit(1);\n }\n\n if (sinkName && !SINKS.includes(sinkName as (typeof SINKS)[number])) {\n console.error(`Unknown sink: ${sinkName}. Supported: ${SINKS.join(\", \")}`);\n process.exit(1);\n }\n\n const adapter = getAdapter(platform);\n let input: unknown;\n try {\n input = buildAdapterInput(platform, inputPath, urlsPath, rewriteGateway, rewritePublic);\n } catch (error) {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n }\n\n if (dryRun) {\n const result = await runDryRun({\n adapter,\n input,\n platform,\n offlineStorageEstimate: offline,\n });\n\n if (reportDir) {\n await mkdir(reportDir, { recursive: true });\n await writeFile(\n join(reportDir, \"conflicts.json\"),\n `${JSON.stringify(result.conflicts, null, 2)}\\n`,\n );\n await writeFile(\n join(reportDir, \"migration-report.json\"),\n `${JSON.stringify(result.report, null, 2)}\\n`,\n );\n } else {\n console.log(JSON.stringify(result.report, null, 2));\n }\n\n printDryRunStatus(result.exitCode, reportDir);\n process.exit(result.exitCode);\n }\n\n const startedAt = new Date();\n\n if (sinkName === \"filesystem\") {\n if (!outDir) {\n console.error(\"Filesystem sink requires --out <dir>\");\n process.exit(1);\n }\n\n const sink = createFilesystemMigrationSink();\n const runResult = await runMigration({\n sink,\n platform,\n entities: adapter.enumerateEntities({ input }),\n });\n\n const bundle = sink.bundle;\n const estimate = await estimateStorage({\n assets: bundle.media,\n offline,\n });\n const redirectMap = buildRedirectMap(bundle);\n const conflicts = analyzeConflicts(bundle, {\n staleAssetUrls: staleUrlsFromEstimate(estimate),\n redirectLoops: detectRedirectLoops(redirectMap),\n });\n const report = buildMigrationReport({\n platform,\n mode: \"sink\",\n bundle,\n conflicts,\n redirectMap,\n startedAt,\n storageBytesEstimated: estimate.totalBytes,\n warnings:\n runResult.failed > 0\n ? [`${runResult.failed} entity write(s) failed during sink migration`]\n : [],\n });\n\n await sink.flush({ outDir, bundle, conflicts, report });\n console.error(`Wrote sink export to ${outDir}`);\n\n const exitCode = migrationExitCode(\n hasBlockingConflicts(conflicts) || runResult.failed > 0,\n hasWarnings(conflicts),\n );\n process.exit(exitCode);\n }\n\n const bundle = await collectEntities(adapter.enumerateEntities({ input }));\n\n const estimate = await estimateStorage({\n assets: bundle.media,\n offline,\n });\n const redirectMap = buildRedirectMap(bundle);\n const conflicts = analyzeConflicts(bundle, {\n staleAssetUrls: staleUrlsFromEstimate(estimate),\n });\n\n const report = buildMigrationReport({\n platform,\n mode: \"export\",\n bundle,\n conflicts,\n redirectMap,\n startedAt,\n storageBytesEstimated: estimate.totalBytes,\n });\n\n if (formatJson) {\n console.log(JSON.stringify({ ...bundleToCombinedJson(bundle), conflicts, report }, null, 2));\n process.exit(0);\n }\n\n if (!outDir) {\n console.error(\"Specify --out <dir>, --format json, --dry-run, or --sink filesystem --out <dir>\");\n process.exit(1);\n }\n\n await writeFilesystemExport({\n outDir,\n bundle,\n conflicts,\n report,\n });\n\n console.error(`Wrote export to ${outDir}`);\n process.exit(0);\n }\n\n console.error(`Unknown command: ${command}`);\n printUsage();\n process.exit(1);\n}\n\nmain().catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,YAAY;AAqBrB,IAAM,YAAiC,CAAC,aAAa,WAAW,eAAe,KAAK;AACpF,IAAM,QAAQ,CAAC,YAAY;AAE3B,SAAS,aAAmB;AAC1B,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAMD,UAAU,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA,4DAI2B,MAAM,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAgB3E;AACD;AAEA,SAAS,kBAAkB,UAAqB,WAA0B;AACxE,QAAM,OAAO,YAAY,uBAAuB,SAAS,MAAM;AAC/D,MAAI,aAAa,GAAG;AAClB,YAAQ,MAAM,oBAAoB,IAAI,EAAE;AAAA,EAC1C,WAAW,aAAa,GAAG;AACzB,YAAQ,MAAM,2CAA2C,IAAI,EAAE;AAAA,EACjE,OAAO;AACL,YAAQ,MAAM,6CAA6C,IAAI,EAAE;AAAA,EACnE;AACF;AAEA,SAAS,UAAU,MAajB;AACA,QAAM,OAAO,CAAC,GAAG,IAAI;AACrB,MAAI;AACJ,MAAI;AACJ,MAAI;A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AAA,MACrC,QAAQ,OAAO;AAAA,MACf;AAAA,IACF,CAAC;AACD,UAAM,cAAc,iBAAiB,MAAM;AAC3C,UAAM,YAAY,iBAAiB,QAAQ;AAAA,MACzC,gBAAgB,sBAAsB,QAAQ;AAAA,IAChD,CAAC;AAED,UAAM,SAAS,qBAAqB;AAAA,MAClC;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,uBAAuB,SAAS;AAAA,IAClC,CAAC;AAED,QAAI,YAAY;AACd,cAAQ,IAAI,KAAK,UAAU,EAAE,GAAG,qBAAqB,MAAM,GAAG,WAAW,OAAO,GAAG,MAAM,CAAC,CAAC;AAC3F,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,QAAI,CAAC,QAAQ;AACX,cAAQ,MAAM,iFAAiF;AAC/F,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,UAAM,sBAAsB;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,YAAQ,MAAM,mBAAmB,MAAM,EAAE;AACzC,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,UAAQ,MAAM,oBAAoB,OAAO,EAAE;AAC3C,aAAW;AACX,UAAQ,KAAK,CAAC;AAChB;AAEA,KAAK,EAAE,MAAM,CAAC,UAAmB;AAC/B,UAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,KAAK;AAC5D,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["bundle","estimate","redirectMap","conflicts","report"]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { writeFile } from \"node:fs/promises\";\nimport { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport { getAdapter } from \"../parsers/index.js\";\nimport type { MigrationPlatform } from \"../normalizer/types.js\";\nimport {\n analyzeConflicts,\n buildMigrationReport,\n buildRedirectMap,\n bundleToCombinedJson,\n createFilesystemMigrationSink,\n detectRedirectLoops,\n hasBlockingConflicts,\n hasWarnings,\n runDryRun,\n resolveAdapterImportSummary,\n runMigration,\n writeFilesystemExport,\n} from \"../sinks/index.js\";\nimport { collectEntities } from \"../normalizer/bundle.js\";\nimport { createWpContentGatewayRewrite } from \"../lib/media-urls.js\";\nimport { estimateStorage, staleUrlsFromEstimate } from \"../sinks/storage-estimate.js\";\n\nconst PLATFORMS: MigrationPlatform[] = [\"wordpress\", \"smugmug\", \"squarespace\", \"wix\"];\nconst SINKS = [\"filesystem\"] as const;\n\nfunction printUsage(): void {\n console.log(`artinstack-migrate — platform content migration CLI\n\nUsage:\n artinstack-migrate <platform> <export-file> [options]\n artinstack-migrate validate <platform> <export-file>\n\nPlatforms: ${PLATFORMS.join(\", \")}\n\nOptions:\n --out <dir> Write grouped JSON files to directory\n --sink <name> Run through MigrationSink (supported: ${SINKS.join(\", \")})\n --format json Write combined JSON to stdout\n --dry-run Parse and analyze without writing content files\n --report <dir> With --dry-run, write conflicts.json + migration-report.json\n --offline Skip network HEAD requests (4 MB fallback per asset)\n --urls <file> Wix W2: newline URL list or sitemap.xml for static page snapshots\n --rewrite-gateway <url> WordPress: API gateway base (requires --rewrite-public)\n --rewrite-public <url> WordPress: public origin for /wp-content/ asset paths\n\nExamples:\n artinstack-migrate wordpress export.xml --dry-run --report ./preview/\n artinstack-migrate wordpress export.xml --rewrite-gateway https://gateway.example/prod --rewrite-public https://www.example.com --dry-run --report ./preview/\n artinstack-migrate wix feed.xml --urls ./sitemap-urls.txt --dry-run\n artinstack-migrate wordpress export.xml --out ./output\n artinstack-migrate wordpress export.xml --sink filesystem --out ./output\n pnpm cli wordpress fixtures/wordpress/long-form-journal.xml --dry-run\n`);\n}\n\nfunction printDryRunStatus(exitCode: 0 | 1 | 2, reportDir?: string): void {\n const dest = reportDir ? ` Reports written to ${reportDir}.` : \"\";\n if (exitCode === 0) {\n console.error(`Dry run complete.${dest}`);\n } else if (exitCode === 2) {\n console.error(`Dry run complete with warnings (exit 2).${dest}`);\n } else {\n console.error(`Dry run found blocking conflicts (exit 1).${dest}`);\n }\n}\n\nfunction parseArgs(argv: string[]): {\n command: string | undefined;\n platform: MigrationPlatform | undefined;\n inputPath: string | undefined;\n urlsPath: string | undefined;\n outDir: string | undefined;\n reportDir: string | undefined;\n sinkName: string | undefined;\n dryRun: boolean;\n formatJson: boolean;\n offline: boolean;\n rewriteGateway: string | undefined;\n rewritePublic: string | undefined;\n} {\n const args = [...argv];\n let command: string | undefined;\n let platform: MigrationPlatform | undefined;\n let inputPath: string | undefined;\n let urlsPath: string | undefined;\n let outDir: string | undefined;\n let reportDir: string | undefined;\n let sinkName: string | undefined;\n let dryRun = false;\n let formatJson = false;\n let offline = false;\n let rewriteGateway: string | undefined;\n let rewritePublic: string | undefined;\n\n const first = args[0];\n if (first === \"validate\") {\n command = \"validate\";\n platform = args[1] as MigrationPlatform;\n inputPath = args[2];\n for (let i = 3; i < args.length; i++) {\n if (args[i] === \"--urls\" && args[i + 1]) urlsPath = args[++i];\n }\n } else if (first && PLATFORMS.includes(first as MigrationPlatform)) {\n command = \"migrate\";\n platform = first as MigrationPlatform;\n inputPath = args[1];\n for (let i = 2; i < args.length; i++) {\n const flag = args[i];\n if (flag === \"--dry-run\") dryRun = true;\n else if (flag === \"--format\" && args[i + 1] === \"json\") formatJson = true;\n else if (flag === \"--offline\") offline = true;\n else if (flag === \"--out\" && args[i + 1]) {\n outDir = args[++i];\n } else if (flag === \"--report\" && args[i + 1]) {\n reportDir = args[++i];\n } else if (flag === \"--sink\" && args[i + 1]) {\n sinkName = args[++i];\n } else if (flag === \"--urls\" && args[i + 1]) {\n urlsPath = args[++i];\n } else if (flag === \"--rewrite-gateway\" && args[i + 1]) {\n rewriteGateway = args[++i];\n } else if (flag === \"--rewrite-public\" && args[i + 1]) {\n rewritePublic = args[++i];\n }\n }\n } else {\n command = first;\n }\n\n return { command, platform, inputPath, urlsPath, outDir, reportDir, sinkName, dryRun, formatJson, offline, rewriteGateway, rewritePublic };\n}\n\nfunction buildAdapterInput(\n platform: MigrationPlatform,\n inputPath: string,\n urlsPath: string | undefined,\n rewriteGateway: string | undefined,\n rewritePublic: string | undefined,\n): unknown {\n if (rewriteGateway || rewritePublic) {\n if (platform !== \"wordpress\") {\n throw new Error(\"--rewrite-gateway and --rewrite-public are WordPress-only options\");\n }\n if (!rewriteGateway || !rewritePublic) {\n throw new Error(\"Both --rewrite-gateway and --rewrite-public are required together\");\n }\n }\n\n if (platform === \"wordpress\") {\n return {\n path: inputPath,\n ...(rewriteGateway && rewritePublic\n ? { originUrlRewrite: createWpContentGatewayRewrite(rewriteGateway, rewritePublic) }\n : {}),\n };\n }\n\n return {\n path: inputPath,\n ...(urlsPath ? { urlsFile: urlsPath } : {}),\n };\n}\n\nfunction migrationExitCode(hasBlockers: boolean, hasWarn: boolean): 0 | 1 | 2 {\n if (hasBlockers) return 1;\n if (hasWarn) return 2;\n return 0;\n}\n\nasync function main(): Promise<void> {\n const { command, platform, inputPath, urlsPath, outDir, reportDir, sinkName, dryRun, formatJson, offline, rewriteGateway, rewritePublic } =\n parseArgs(process.argv.slice(2));\n\n if (!command || command === \"--help\" || command === \"-h\") {\n printUsage();\n process.exit(0);\n }\n\n if (command === \"validate\") {\n if (!platform || !PLATFORMS.includes(platform) || !inputPath) {\n console.error(\"Usage: artinstack-migrate validate <platform> <export-file>\");\n process.exit(1);\n }\n const adapter = getAdapter(platform);\n const result = await adapter.validateInput({\n path: inputPath,\n ...(urlsPath ? { urlsFile: urlsPath } : {}),\n });\n console.log(JSON.stringify(result, null, 2));\n process.exit(result.ok ? 0 : 1);\n }\n\n if (command === \"migrate\") {\n if (!platform || !inputPath) {\n printUsage();\n process.exit(1);\n }\n\n if (sinkName && !SINKS.includes(sinkName as (typeof SINKS)[number])) {\n console.error(`Unknown sink: ${sinkName}. Supported: ${SINKS.join(\", \")}`);\n process.exit(1);\n }\n\n const adapter = getAdapter(platform);\n let input: unknown;\n try {\n input = buildAdapterInput(platform, inputPath, urlsPath, rewriteGateway, rewritePublic);\n } catch (error) {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n }\n\n if (dryRun) {\n const result = await runDryRun({\n adapter,\n input,\n platform,\n offlineStorageEstimate: offline,\n });\n\n if (reportDir) {\n await mkdir(reportDir, { recursive: true });\n await writeFile(\n join(reportDir, \"conflicts.json\"),\n `${JSON.stringify(result.conflicts, null, 2)}\\n`,\n );\n await writeFile(\n join(reportDir, \"migration-report.json\"),\n `${JSON.stringify(result.report, null, 2)}\\n`,\n );\n } else {\n console.log(JSON.stringify(result.report, null, 2));\n }\n\n printDryRunStatus(result.exitCode, reportDir);\n process.exit(result.exitCode);\n }\n\n const startedAt = new Date();\n\n if (sinkName === \"filesystem\") {\n if (!outDir) {\n console.error(\"Filesystem sink requires --out <dir>\");\n process.exit(1);\n }\n\n const sink = createFilesystemMigrationSink();\n const runResult = await runMigration({\n sink,\n platform,\n entities: adapter.enumerateEntities({ input }),\n });\n\n const bundle = sink.bundle;\n const wxrImportSummary = await resolveAdapterImportSummary(adapter, input);\n const estimate = await estimateStorage({\n assets: bundle.media,\n offline,\n });\n const redirectMap = buildRedirectMap(bundle);\n const conflicts = analyzeConflicts(bundle, {\n staleAssetUrls: staleUrlsFromEstimate(estimate),\n redirectLoops: detectRedirectLoops(redirectMap),\n wxrImportSummary,\n });\n const report = buildMigrationReport({\n platform,\n mode: \"sink\",\n bundle,\n conflicts,\n redirectMap,\n startedAt,\n storageBytesEstimated: estimate.totalBytes,\n warnings:\n runResult.failed > 0\n ? [`${runResult.failed} entity write(s) failed during sink migration`]\n : [],\n });\n\n await sink.flush({ outDir, bundle, conflicts, report });\n console.error(`Wrote sink export to ${outDir}`);\n\n const exitCode = migrationExitCode(\n hasBlockingConflicts(conflicts) || runResult.failed > 0,\n hasWarnings(conflicts),\n );\n process.exit(exitCode);\n }\n\n const bundle = await collectEntities(adapter.enumerateEntities({ input }));\n const wxrImportSummary = await resolveAdapterImportSummary(adapter, input);\n\n const estimate = await estimateStorage({\n assets: bundle.media,\n offline,\n });\n const redirectMap = buildRedirectMap(bundle);\n const conflicts = analyzeConflicts(bundle, {\n staleAssetUrls: staleUrlsFromEstimate(estimate),\n wxrImportSummary,\n });\n\n const report = buildMigrationReport({\n platform,\n mode: \"export\",\n bundle,\n conflicts,\n redirectMap,\n startedAt,\n storageBytesEstimated: estimate.totalBytes,\n });\n\n if (formatJson) {\n console.log(JSON.stringify({ ...bundleToCombinedJson(bundle), conflicts, report }, null, 2));\n process.exit(0);\n }\n\n if (!outDir) {\n console.error(\"Specify --out <dir>, --format json, --dry-run, or --sink filesystem --out <dir>\");\n process.exit(1);\n }\n\n await writeFilesystemExport({\n outDir,\n bundle,\n conflicts,\n report,\n });\n\n console.error(`Wrote export to ${outDir}`);\n process.exit(0);\n }\n\n console.error(`Unknown command: ${command}`);\n printUsage();\n process.exit(1);\n}\n\nmain().catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,YAAY;AAsBrB,IAAM,YAAiC,CAAC,aAAa,WAAW,eAAe,KAAK;AACpF,IAAM,QAAQ,CAAC,YAAY;AAE3B,SAAS,aAAmB;AAC1B,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAMD,UAAU,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA,4DAI2B,MAAM,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAgB3E;AACD;AAEA,SAAS,kBAAkB,UAAqB,WAA0B;AACxE,QAAM,OAAO,YAAY,uBAAuB,SAAS,MAAM;AAC/D,MAAI,aAAa,GAAG;AAClB,YAAQ,MAAM,oBAAoB,IAAI,EAAE;AAAA,EAC1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MAAM,UAAU,KAAK;AAC5D,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["bundle","wxrImportSummary","estimate","redirectMap","conflicts","report"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { M as MigrationAdapter, g as MigrationPlatform } from './types-
|
|
2
|
-
export { A as AdapterContext, E as EntityKey, h as EntityType, i as MigrationCursor, b as NormalizedAsset, j as NormalizedAssetExif, d as NormalizedCategory, f as NormalizedEntity, a as NormalizedPage, c as NormalizedPortfolio, N as NormalizedPost, e as NormalizedTag, P as PortfolioMediaLink, k as PublishStatus, S as SourceMetadata, V as ValidationIssue, l as ValidationResult, m as entityKey } from './types-
|
|
1
|
+
import { M as MigrationAdapter, g as MigrationPlatform } from './types-TCHy3Oko.js';
|
|
2
|
+
export { A as AdapterContext, E as EntityKey, h as EntityType, i as MigrationCursor, b as NormalizedAsset, j as NormalizedAssetExif, d as NormalizedCategory, f as NormalizedEntity, a as NormalizedPage, c as NormalizedPortfolio, N as NormalizedPost, e as NormalizedTag, P as PortfolioMediaLink, k as PublishStatus, S as SourceMetadata, V as ValidationIssue, l as ValidationResult, W as WxrImportSummary, m as entityKey } from './types-TCHy3Oko.js';
|
|
3
3
|
export { EntityState, MigrationCheckpoint, TrackedEntity, buildPortfolioMediaLinks, isTerminalState, normalizedAssetExifSchema, normalizedAssetSchema, normalizedCategorySchema, normalizedEntitySchema, normalizedPageSchema, normalizedPortfolioSchema, normalizedPostSchema, normalizedTagSchema, shouldProcessEntity, sourceMetadataSchema, validateNormalizedAsset, validateNormalizedCategory, validateNormalizedEntity, validateNormalizedPage, validateNormalizedPortfolio, validateNormalizedPost, validateNormalizedTag } from './normalizer/index.js';
|
|
4
|
-
export { B as BundleCounts, E as EntityBundle, b as bundleCounts, c as collectEntities, e as emptyBundle } from './bundle-
|
|
5
|
-
export { AssetDiscoverySummary, ConflictReport, DryRunOptions, DryRunResult, FALLBACK_ASSET_BYTES, FilesystemMigrationSink, MIGRATION_WRITE_STAGES, MigrationRedirect, MigrationReport, MigrationRunMode, MigrationRunOptions, MigrationRunResult, MigrationSink, MigrationWriteStage, StorageEstimate, UploadAssetInput, UploadAssetResult, WriteFilesystemOptions, analyzeConflicts, buildMigrationReport, buildRedirectMap, bundleToCombinedJson, createFilesystemMigrationSink, detectRedirectLoops, emptyConflictReport, estimateStorage, hasBlockingConflicts, hasWarnings, portfolioMediaMatchesBundle, runDryRun, runMigration, runMigrationFromBundle, staleUrlsFromEstimate, summarizeAssetDiscovery, writeFilesystemExport } from './sinks/index.js';
|
|
4
|
+
export { B as BundleCounts, E as EntityBundle, b as bundleCounts, c as collectEntities, e as emptyBundle } from './bundle-Do-9ikQv.js';
|
|
5
|
+
export { AssetDiscoverySummary, ConflictReport, DryRunOptions, DryRunResult, FALLBACK_ASSET_BYTES, FilesystemMigrationSink, MIGRATION_WRITE_STAGES, MigrationRedirect, MigrationReport, MigrationRunMode, MigrationRunOptions, MigrationRunResult, MigrationSink, MigrationWriteStage, StorageEstimate, UploadAssetInput, UploadAssetResult, WriteFilesystemOptions, analyzeConflicts, buildMigrationReport, buildRedirectMap, bundleToCombinedJson, createFilesystemMigrationSink, detectRedirectLoops, emptyConflictReport, estimateStorage, hasBlockingConflicts, hasWarnings, portfolioMediaMatchesBundle, resolveAdapterImportSummary, runDryRun, runMigration, runMigrationFromBundle, staleUrlsFromEstimate, summarizeAssetDiscovery, writeFilesystemExport } from './sinks/index.js';
|
|
6
6
|
export { R as RewriteInlineImageRef, a as RewriteInlineImagesOptions, b as RewriteInlineImagesResult, S as StampMigrationMediaRefsOptions, U as UploadedAssetRef, r as rewriteInlineImages, s as stampMigrationMediaRefs } from './rewrite-inline-images-BsgSquzV.js';
|
|
7
7
|
export { ExpandMigrationMediaRefsResult, GrapesComponent, GrapesProjectSnapshot, GrapesStyleRule, HtmlToGrapesOptions, HtmlToTiptapOptions, LayoutKind, LayoutTypeMap, TiptapDoc, TiptapMark, TiptapNode, ValidateGrapesProjectSnapshotOptions, ValidateTiptapDocOptions, cssToStyles, expandMigrationMediaRefs, grapesComponentSchema, grapesProjectSnapshotSchema, grapesStyleRuleSchema, htmlToGrapes, htmlToTiptap, tiptapDocSchema, tiptapMarkSchema, tiptapNodeSchema, validateGrapesProjectSnapshot, validateTiptapDoc } from './transformers/index.js';
|
|
8
8
|
export { C as CanonicalInlineAssetUrl, a as ContentAssetDiscovery, M as MIGRATION_MEDIA_REF_SCHEME, O as OriginUrlRewriteConfig, b as OriginUrlRewriteRule, c as buildContentMediaUrlIndex, d as buildMigrationMediaUrlIndex, e as canonicalizeInlineAssetUrl, f as createMigrationMediaRefReplaceWith, g as createWpContentGatewayRewrite, h as discoverContentAssetUrls, i as discoverContentAssets, j as discoverFeaturedAssetCandidateUrls, k as discoverRawImgSrcs, l as extractInlineImageSrcs, m as formatMigrationMediaRef, n as isLikelyImageUrl, o as isMigrationMediaRef, p as normalizeAssetUrl, q as parseMigrationMediaRef, r as resolveFeaturedContentAssetUrl, s as resolveMigrationMediaSourceId, t as rewriteOriginUrlsInText } from './media-urls-u49RCyPn.js';
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
squarespaceAdapter,
|
|
14
14
|
wixAdapter,
|
|
15
15
|
wordpressAdapter
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-YLVPZ4M3.js";
|
|
17
17
|
import {
|
|
18
18
|
normalizedAssetExifSchema,
|
|
19
19
|
normalizedAssetSchema,
|
|
@@ -51,13 +51,14 @@ import {
|
|
|
51
51
|
hasWarnings,
|
|
52
52
|
mapJsonPrettyWire,
|
|
53
53
|
portfolioMediaMatchesBundle,
|
|
54
|
+
resolveAdapterImportSummary,
|
|
54
55
|
runDryRun,
|
|
55
56
|
runMigration,
|
|
56
57
|
runMigrationFromBundle,
|
|
57
58
|
staleUrlsFromEstimate,
|
|
58
59
|
summarizeAssetDiscovery,
|
|
59
60
|
writeFilesystemExport
|
|
60
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-3A2PA4P3.js";
|
|
61
62
|
import {
|
|
62
63
|
buildPortfolioMediaLinks,
|
|
63
64
|
bundleCounts,
|
|
@@ -66,7 +67,7 @@ import {
|
|
|
66
67
|
entityKey,
|
|
67
68
|
isTerminalState,
|
|
68
69
|
shouldProcessEntity
|
|
69
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-LC7CGWDN.js";
|
|
70
71
|
import {
|
|
71
72
|
cssToStyles,
|
|
72
73
|
expandMigrationMediaRefs,
|
|
@@ -176,6 +177,7 @@ export {
|
|
|
176
177
|
parseMigrationMediaRef,
|
|
177
178
|
portfolioMediaMatchesBundle,
|
|
178
179
|
readSmugMugCredentialsFromEnv,
|
|
180
|
+
resolveAdapterImportSummary,
|
|
179
181
|
resolveFeaturedContentAssetUrl,
|
|
180
182
|
resolveMigrationMediaSourceId,
|
|
181
183
|
rewriteInlineImages,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as MigrationCursor, E as EntityKey, P as PortfolioMediaLink, l as ValidationResult } from '../types-
|
|
2
|
-
export { A as AdapterContext, h as EntityType, M as MigrationAdapter, g as MigrationPlatform, b as NormalizedAsset, j as NormalizedAssetExif, d as NormalizedCategory, f as NormalizedEntity, a as NormalizedPage, c as NormalizedPortfolio, N as NormalizedPost, e as NormalizedTag, k as PublishStatus, S as SourceMetadata, V as ValidationIssue, m as entityKey } from '../types-
|
|
3
|
-
import { E as EntityBundle } from '../bundle-
|
|
4
|
-
export { B as BundleCounts, b as bundleCounts, c as collectEntities, e as emptyBundle } from '../bundle-
|
|
1
|
+
import { i as MigrationCursor, E as EntityKey, P as PortfolioMediaLink, l as ValidationResult } from '../types-TCHy3Oko.js';
|
|
2
|
+
export { A as AdapterContext, h as EntityType, M as MigrationAdapter, g as MigrationPlatform, b as NormalizedAsset, j as NormalizedAssetExif, d as NormalizedCategory, f as NormalizedEntity, a as NormalizedPage, c as NormalizedPortfolio, N as NormalizedPost, e as NormalizedTag, k as PublishStatus, S as SourceMetadata, V as ValidationIssue, W as WxrImportSummary, m as entityKey } from '../types-TCHy3Oko.js';
|
|
3
|
+
import { E as EntityBundle } from '../bundle-Do-9ikQv.js';
|
|
4
|
+
export { B as BundleCounts, b as bundleCounts, c as collectEntities, e as emptyBundle } from '../bundle-Do-9ikQv.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
7
7
|
/** Portable entity state for resume / idempotency (not Directus field names). */
|
package/dist/normalizer/index.js
CHANGED
package/dist/sinks/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { d as NormalizedCategory, e as NormalizedTag, b as NormalizedAsset, c as NormalizedPortfolio, N as NormalizedPost, a as NormalizedPage, P as PortfolioMediaLink, E as EntityKey, f as NormalizedEntity, g as MigrationPlatform, M as MigrationAdapter } from '../types-
|
|
1
|
+
import { d as NormalizedCategory, e as NormalizedTag, b as NormalizedAsset, c as NormalizedPortfolio, N as NormalizedPost, a as NormalizedPage, P as PortfolioMediaLink, E as EntityKey, f as NormalizedEntity, g as MigrationPlatform, W as WxrImportSummary, M as MigrationAdapter } from '../types-TCHy3Oko.js';
|
|
2
2
|
import { Readable } from 'node:stream';
|
|
3
3
|
import { a as RewriteInlineImagesOptions } from '../rewrite-inline-images-BsgSquzV.js';
|
|
4
4
|
export { b as RewriteInlineImagesResult, r as rewriteInlineImages } from '../rewrite-inline-images-BsgSquzV.js';
|
|
5
|
-
import { E as EntityBundle } from '../bundle-
|
|
5
|
+
import { E as EntityBundle } from '../bundle-Do-9ikQv.js';
|
|
6
6
|
import '../media-urls-u49RCyPn.js';
|
|
7
7
|
|
|
8
8
|
interface CreatePostResult {
|
|
@@ -138,12 +138,18 @@ interface ConflictReport {
|
|
|
138
138
|
unsupportedBlocks: UnsupportedBlockConflict[];
|
|
139
139
|
redirectLoops: RedirectLoopConflict[];
|
|
140
140
|
assetDiscovery: AssetDiscoverySummary;
|
|
141
|
+
/** OSS-19 — unsupported WXR `post_type` counts (commerce, builder globals, …). */
|
|
142
|
+
skippedPostTypes: Record<string, number>;
|
|
143
|
+
importableItemCount: number;
|
|
144
|
+
unsupportedOnly: boolean;
|
|
145
|
+
skippedWooCommerceStubPages?: number;
|
|
141
146
|
}
|
|
142
147
|
declare function summarizeAssetDiscovery(bundle: EntityBundle): AssetDiscoverySummary;
|
|
143
148
|
declare function emptyConflictReport(): ConflictReport;
|
|
144
149
|
declare function analyzeConflicts(bundle: EntityBundle, options?: {
|
|
145
150
|
staleAssetUrls?: StaleAssetUrlConflict[];
|
|
146
151
|
redirectLoops?: RedirectLoopConflict[];
|
|
152
|
+
wxrImportSummary?: WxrImportSummary;
|
|
147
153
|
}): ConflictReport;
|
|
148
154
|
declare function hasBlockingConflicts(report: ConflictReport): boolean;
|
|
149
155
|
declare function hasWarnings(report: ConflictReport): boolean;
|
|
@@ -173,6 +179,9 @@ interface MigrationReport {
|
|
|
173
179
|
tags: number;
|
|
174
180
|
storageBytesEstimated?: number;
|
|
175
181
|
assetDiscovery?: AssetDiscoverySummary;
|
|
182
|
+
importableItemCount?: number;
|
|
183
|
+
unsupportedOnly?: boolean;
|
|
184
|
+
skippedPostTypes?: Record<string, number>;
|
|
176
185
|
};
|
|
177
186
|
warnings: string[];
|
|
178
187
|
errors: string[];
|
|
@@ -248,6 +257,7 @@ interface DryRunResult {
|
|
|
248
257
|
report: MigrationReport;
|
|
249
258
|
exitCode: 0 | 1 | 2;
|
|
250
259
|
}
|
|
260
|
+
declare function resolveAdapterImportSummary(adapter: MigrationAdapter, input: unknown): Promise<WxrImportSummary | undefined>;
|
|
251
261
|
declare function runDryRun(options: DryRunOptions): Promise<DryRunResult>;
|
|
252
262
|
|
|
253
263
|
declare const FALLBACK_ASSET_BYTES: number;
|
|
@@ -275,4 +285,4 @@ declare function staleUrlsFromEstimate(estimate: StorageEstimate): {
|
|
|
275
285
|
reason: string;
|
|
276
286
|
}[];
|
|
277
287
|
|
|
278
|
-
export { type AssetDiscoverySummary, type ConflictReport, type DryRunOptions, type DryRunResult, FALLBACK_ASSET_BYTES, FilesystemMigrationSink, MIGRATION_WRITE_STAGES, type MigrationRedirect, type MigrationReport, type MigrationRunMode, type MigrationRunOptions, type MigrationRunResult, type MigrationSink, type MigrationWriteStage, RewriteInlineImagesOptions, type StorageEstimate, type UploadAssetInput, type UploadAssetResult, type WriteFilesystemOptions, analyzeConflicts, buildMigrationReport, buildRedirectMap, bundleToCombinedJson, createFilesystemMigrationSink, detectRedirectLoops, emptyConflictReport, estimateStorage, hasBlockingConflicts, hasWarnings, portfolioMediaMatchesBundle, runDryRun, runMigration, runMigrationFromBundle, staleUrlsFromEstimate, summarizeAssetDiscovery, writeFilesystemExport };
|
|
288
|
+
export { type AssetDiscoverySummary, type ConflictReport, type DryRunOptions, type DryRunResult, FALLBACK_ASSET_BYTES, FilesystemMigrationSink, MIGRATION_WRITE_STAGES, type MigrationRedirect, type MigrationReport, type MigrationRunMode, type MigrationRunOptions, type MigrationRunResult, type MigrationSink, type MigrationWriteStage, RewriteInlineImagesOptions, type StorageEstimate, type UploadAssetInput, type UploadAssetResult, type WriteFilesystemOptions, analyzeConflicts, buildMigrationReport, buildRedirectMap, bundleToCombinedJson, createFilesystemMigrationSink, detectRedirectLoops, emptyConflictReport, estimateStorage, hasBlockingConflicts, hasWarnings, portfolioMediaMatchesBundle, resolveAdapterImportSummary, runDryRun, runMigration, runMigrationFromBundle, staleUrlsFromEstimate, summarizeAssetDiscovery, writeFilesystemExport };
|
package/dist/sinks/index.js
CHANGED
|
@@ -13,14 +13,15 @@ import {
|
|
|
13
13
|
hasBlockingConflicts,
|
|
14
14
|
hasWarnings,
|
|
15
15
|
portfolioMediaMatchesBundle,
|
|
16
|
+
resolveAdapterImportSummary,
|
|
16
17
|
runDryRun,
|
|
17
18
|
runMigration,
|
|
18
19
|
runMigrationFromBundle,
|
|
19
20
|
staleUrlsFromEstimate,
|
|
20
21
|
summarizeAssetDiscovery,
|
|
21
22
|
writeFilesystemExport
|
|
22
|
-
} from "../chunk-
|
|
23
|
-
import "../chunk-
|
|
23
|
+
} from "../chunk-3A2PA4P3.js";
|
|
24
|
+
import "../chunk-LC7CGWDN.js";
|
|
24
25
|
import {
|
|
25
26
|
rewriteInlineImages
|
|
26
27
|
} from "../chunk-BONZ3U3I.js";
|
|
@@ -41,6 +42,7 @@ export {
|
|
|
41
42
|
hasBlockingConflicts,
|
|
42
43
|
hasWarnings,
|
|
43
44
|
portfolioMediaMatchesBundle,
|
|
45
|
+
resolveAdapterImportSummary,
|
|
44
46
|
rewriteInlineImages,
|
|
45
47
|
runDryRun,
|
|
46
48
|
runMigration,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { l as ValidationResult } from '../types-
|
|
2
|
+
import { l as ValidationResult } from '../types-TCHy3Oko.js';
|
|
3
3
|
export { R as RewriteInlineImageRef, a as RewriteInlineImagesOptions, b as RewriteInlineImagesResult, S as StampMigrationMediaRefsOptions, U as UploadedAssetRef, r as rewriteInlineImages, s as stampMigrationMediaRefs } from '../rewrite-inline-images-BsgSquzV.js';
|
|
4
4
|
export { d as buildMigrationMediaUrlIndex } from '../media-urls-u49RCyPn.js';
|
|
5
5
|
|
|
@@ -112,8 +112,18 @@ interface ValidationResult {
|
|
|
112
112
|
portfolioCpt?: number;
|
|
113
113
|
categories?: number;
|
|
114
114
|
tags?: number;
|
|
115
|
+
/** WXR rows the parser would emit (OSS-19). */
|
|
116
|
+
importableItemCount?: number;
|
|
117
|
+
unsupportedOnly?: boolean;
|
|
118
|
+
skippedPostTypes?: Record<string, number>;
|
|
115
119
|
};
|
|
116
120
|
}
|
|
121
|
+
interface WxrImportSummary {
|
|
122
|
+
importableItemCount: number;
|
|
123
|
+
unsupportedOnly: boolean;
|
|
124
|
+
skippedPostTypes: Record<string, number>;
|
|
125
|
+
skippedWooCommerceStubPages?: number;
|
|
126
|
+
}
|
|
117
127
|
interface AdapterContext {
|
|
118
128
|
input: unknown;
|
|
119
129
|
cursor?: MigrationCursor;
|
|
@@ -122,6 +132,8 @@ interface MigrationAdapter {
|
|
|
122
132
|
platform: MigrationPlatform;
|
|
123
133
|
validateInput(input: unknown): ValidationResult | Promise<ValidationResult>;
|
|
124
134
|
enumerateEntities(ctx: AdapterContext): AsyncIterable<NormalizedEntity>;
|
|
135
|
+
/** Platform-specific import accounting (e.g. WordPress skipped `post_type`s). */
|
|
136
|
+
getImportSummary?(input: unknown): Promise<WxrImportSummary | undefined>;
|
|
125
137
|
}
|
|
126
138
|
interface MigrationCursor {
|
|
127
139
|
lastEntityKey?: EntityKey;
|
|
@@ -134,4 +146,4 @@ interface EntityKey {
|
|
|
134
146
|
}
|
|
135
147
|
declare function entityKey(entity: NormalizedEntity, platform: MigrationPlatform): EntityKey;
|
|
136
148
|
|
|
137
|
-
export { type AdapterContext as A, type EntityKey as E, type MigrationAdapter as M, type NormalizedPost as N, type PortfolioMediaLink as P, type SourceMetadata as S, type ValidationIssue as V, type NormalizedPage as a, type NormalizedAsset as b, type NormalizedPortfolio as c, type NormalizedCategory as d, type NormalizedTag as e, type NormalizedEntity as f, type MigrationPlatform as g, type EntityType as h, type MigrationCursor as i, type NormalizedAssetExif as j, type PublishStatus as k, type ValidationResult as l, entityKey as m };
|
|
149
|
+
export { type AdapterContext as A, type EntityKey as E, type MigrationAdapter as M, type NormalizedPost as N, type PortfolioMediaLink as P, type SourceMetadata as S, type ValidationIssue as V, type WxrImportSummary as W, type NormalizedPage as a, type NormalizedAsset as b, type NormalizedPortfolio as c, type NormalizedCategory as d, type NormalizedTag as e, type NormalizedEntity as f, type MigrationPlatform as g, type EntityType as h, type MigrationCursor as i, type NormalizedAssetExif as j, type PublishStatus as k, type ValidationResult as l, entityKey as m };
|
package/package.json
CHANGED