@artinstack/migrator 0.1.4 → 0.1.5

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.
@@ -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/origin-url-rewrite.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,CAA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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 runMigration,\n writeFilesystemExport,\n} from \"../sinks/index.js\";\nimport { collectEntities } from \"../normalizer/bundle.js\";\nimport { createWpContentGatewayRewrite } from \"../lib/origin-url-rewrite.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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F,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"]}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,12 @@
1
- import { M as MigrationAdapter, a as MigrationPlatform, V as ValidationResult } from './bundle-DfM_jKbq.js';
2
- export { A as AdapterContext, B as BundleCounts, E as EntityBundle, b as EntityKey, c as EntityType, d as MigrationCursor, N as NormalizedAsset, e as NormalizedAssetExif, f as NormalizedCategory, g as NormalizedEntity, h as NormalizedPage, i as NormalizedPortfolio, j as NormalizedPost, k as NormalizedTag, P as PortfolioMediaLink, l as PublishStatus, S as SourceMetadata, m as ValidationIssue, n as bundleCounts, o as collectEntities, p as emptyBundle, q as entityKey } from './bundle-DfM_jKbq.js';
1
+ import { M as MigrationAdapter, g as MigrationPlatform } from './types-DWOP8Dcy.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, m as entityKey } from './types-DWOP8Dcy.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 { C as ConflictReport, D as DryRunOptions, a as DryRunResult, F as FALLBACK_ASSET_BYTES, b as FilesystemMigrationSink, M as MIGRATION_WRITE_STAGES, c as MigrationRedirect, d as MigrationReport, e as MigrationRunMode, f as MigrationRunOptions, g as MigrationRunResult, h as MigrationSink, i as MigrationWriteStage, R as RewriteInlineImageRef, j as RewriteInlineImagesOptions, k as RewriteInlineImagesResult, S as StorageEstimate, U as UploadAssetInput, l as UploadAssetResult, m as UploadedAssetRef, W as WriteFilesystemOptions, n as analyzeConflicts, o as buildMigrationReport, p as buildRedirectMap, q as bundleToCombinedJson, r as createFilesystemMigrationSink, s as detectRedirectLoops, t as emptyConflictReport, u as estimateStorage, v as hasBlockingConflicts, w as hasWarnings, x as portfolioMediaMatchesBundle, y as rewriteInlineImages, z as runDryRun, A as runMigration, B as runMigrationFromBundle, E as staleUrlsFromEstimate, G as writeFilesystemExport } from './index-D88mjcF5.js';
5
- import { z } from 'zod';
4
+ export { B as BundleCounts, E as EntityBundle, b as bundleCounts, c as collectEntities, e as emptyBundle } from './bundle-uAAHehbv.js';
5
+ export { 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, writeFilesystemExport } from './sinks/index.js';
6
+ export { R as RewriteInlineImageRef, a as RewriteInlineImagesOptions, b as RewriteInlineImagesResult, U as UploadedAssetRef, r as rewriteInlineImages } from './rewrite-inline-images-BckVKPbh.js';
7
+ export { GrapesComponent, GrapesProjectSnapshot, GrapesStyleRule, HtmlToGrapesOptions, HtmlToTiptapOptions, LayoutKind, LayoutTypeMap, TiptapDoc, TiptapMark, TiptapNode, ValidateGrapesProjectSnapshotOptions, ValidateTiptapDocOptions, cssToStyles, grapesComponentSchema, grapesProjectSnapshotSchema, grapesStyleRuleSchema, htmlToGrapes, htmlToTiptap, tiptapDocSchema, tiptapMarkSchema, tiptapNodeSchema, validateGrapesProjectSnapshot, validateTiptapDoc } from './transformers/index.js';
6
8
  export { discoverContentAssetUrls, discoverRawImgSrcs, extractInlineImageSrcs, isLikelyImageUrl, normalizeAssetUrl } from './lib/index.js';
9
+ import { z } from 'zod';
7
10
  import 'node:stream';
8
11
 
9
12
  interface OriginUrlRewriteRule {
@@ -518,86 +521,4 @@ declare const wixAdapter: MigrationAdapter;
518
521
 
519
522
  declare function getAdapter(platform: MigrationPlatform): MigrationAdapter;
520
523
 
521
- interface HtmlToGrapesOptions {
522
- /** Map source class names to Grapes component types. */
523
- componentMap?: Record<string, string>;
524
- }
525
- interface GrapesStyleRule {
526
- selectors: string[];
527
- style: Record<string, string>;
528
- }
529
- interface GrapesComponent {
530
- type: string;
531
- tagName?: string;
532
- attributes?: Record<string, string>;
533
- classes?: string[];
534
- components?: GrapesComponent[];
535
- content?: string;
536
- void?: boolean;
537
- }
538
- interface GrapesProjectSnapshot {
539
- content: GrapesComponent[];
540
- styles: GrapesStyleRule[];
541
- contentHtml?: string;
542
- contentCss?: string;
543
- }
544
-
545
- /** Cheerio HTML walk → Grapes `content` + root `styles`. */
546
- declare function htmlToGrapes(html: string, options?: HtmlToGrapesOptions): GrapesProjectSnapshot;
547
-
548
- /** Parse `<style>` blocks and class rules into Grapes root `styles[]`. */
549
- declare function cssToStyles(css: string): GrapesStyleRule[];
550
-
551
- declare const grapesStyleRuleSchema: z.ZodObject<{
552
- selectors: z.ZodArray<z.ZodString, "many">;
553
- style: z.ZodRecord<z.ZodString, z.ZodString>;
554
- }, "strip", z.ZodTypeAny, {
555
- style: Record<string, string>;
556
- selectors: string[];
557
- }, {
558
- style: Record<string, string>;
559
- selectors: string[];
560
- }>;
561
- declare const grapesComponentSchema: z.ZodType<GrapesComponent>;
562
- declare const grapesProjectSnapshotSchema: z.ZodObject<{
563
- content: z.ZodArray<z.ZodType<GrapesComponent, z.ZodTypeDef, GrapesComponent>, "many">;
564
- styles: z.ZodArray<z.ZodObject<{
565
- selectors: z.ZodArray<z.ZodString, "many">;
566
- style: z.ZodRecord<z.ZodString, z.ZodString>;
567
- }, "strip", z.ZodTypeAny, {
568
- style: Record<string, string>;
569
- selectors: string[];
570
- }, {
571
- style: Record<string, string>;
572
- selectors: string[];
573
- }>, "many">;
574
- contentHtml: z.ZodOptional<z.ZodString>;
575
- contentCss: z.ZodOptional<z.ZodString>;
576
- }, "strip", z.ZodTypeAny, {
577
- content: GrapesComponent[];
578
- styles: {
579
- style: Record<string, string>;
580
- selectors: string[];
581
- }[];
582
- contentHtml?: string | undefined;
583
- contentCss?: string | undefined;
584
- }, {
585
- content: GrapesComponent[];
586
- styles: {
587
- style: Record<string, string>;
588
- selectors: string[];
589
- }[];
590
- contentHtml?: string | undefined;
591
- contentCss?: string | undefined;
592
- }>;
593
- interface ValidateGrapesProjectSnapshotOptions {
594
- /** When set, every component `type` in the tree must be in this allowlist. */
595
- allowedComponentTypes?: string[];
596
- }
597
- /**
598
- * Opt-in structural check for a Grapes project snapshot (not a full Grapes editor project file).
599
- * Does not validate host-specific component registries unless `allowedComponentTypes` is passed.
600
- */
601
- declare function validateGrapesProjectSnapshot(snapshot: unknown, options?: ValidateGrapesProjectSnapshotOptions): ValidationResult;
602
-
603
- export { type GrapesComponent, type GrapesProjectSnapshot, type GrapesStyleRule, type HtmlToGrapesOptions, MigrationAdapter, MigrationPlatform, type OriginUrlRewriteConfig, type OriginUrlRewriteRule, SMUGMUG_API_BASE, SMUGMUG_OAUTH_ENDPOINTS, SQUARESPACE_JSON_FORMAT, SmugMugApiClient, type SmugMugClientOptions, type SmugMugCredentials, type SquarespaceClientOptions, type SquarespaceCollectTarget, SquarespaceCollectionClient, type ValidateGrapesProjectSnapshotOptions, ValidationResult, WixCollectionClient, WixPageSnapshotCollector, buildJsonPrettyUrl, buildSmugMugAuthorizationHeader, createWpContentGatewayRewrite, cssToStyles, getAdapter, grapesComponentSchema, grapesProjectSnapshotSchema, grapesStyleRuleSchema, htmlToGrapes, mapJsonPrettyWire, readSmugMugCredentialsFromEnv, rewriteOriginUrlsInText, signSmugMugOAuthRequest, smugMugCredentialsSchema, smugmugAdapter, squarespaceAdapter, validateGrapesProjectSnapshot, wixAdapter, wordpressAdapter };
524
+ export { MigrationAdapter, MigrationPlatform, type OriginUrlRewriteConfig, type OriginUrlRewriteRule, SMUGMUG_API_BASE, SMUGMUG_OAUTH_ENDPOINTS, SQUARESPACE_JSON_FORMAT, SmugMugApiClient, type SmugMugClientOptions, type SmugMugCredentials, type SquarespaceClientOptions, type SquarespaceCollectTarget, SquarespaceCollectionClient, WixCollectionClient, WixPageSnapshotCollector, buildJsonPrettyUrl, buildSmugMugAuthorizationHeader, createWpContentGatewayRewrite, getAdapter, mapJsonPrettyWire, readSmugMugCredentialsFromEnv, rewriteOriginUrlsInText, signSmugMugOAuthRequest, smugMugCredentialsSchema, smugmugAdapter, squarespaceAdapter, wixAdapter, wordpressAdapter };
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  squarespaceAdapter,
16
16
  wixAdapter,
17
17
  wordpressAdapter
18
- } from "./chunk-Q6M5JEL3.js";
18
+ } from "./chunk-XUBCG3IA.js";
19
19
  import {
20
20
  normalizedAssetExifSchema,
21
21
  normalizedAssetSchema,
@@ -53,13 +53,12 @@ import {
53
53
  hasWarnings,
54
54
  mapJsonPrettyWire,
55
55
  portfolioMediaMatchesBundle,
56
- rewriteInlineImages,
57
56
  runDryRun,
58
57
  runMigration,
59
58
  runMigrationFromBundle,
60
59
  staleUrlsFromEstimate,
61
60
  writeFilesystemExport
62
- } from "./chunk-XKWWXKP3.js";
61
+ } from "./chunk-YLFVYPB3.js";
63
62
  import {
64
63
  buildPortfolioMediaLinks,
65
64
  bundleCounts,
@@ -69,6 +68,22 @@ import {
69
68
  isTerminalState,
70
69
  shouldProcessEntity
71
70
  } from "./chunk-HI7JHWZU.js";
71
+ import {
72
+ cssToStyles,
73
+ grapesComponentSchema,
74
+ grapesProjectSnapshotSchema,
75
+ grapesStyleRuleSchema,
76
+ htmlToGrapes,
77
+ htmlToTiptap,
78
+ tiptapDocSchema,
79
+ tiptapMarkSchema,
80
+ tiptapNodeSchema,
81
+ validateGrapesProjectSnapshot,
82
+ validateTiptapDoc
83
+ } from "./chunk-CIOYDRY5.js";
84
+ import {
85
+ rewriteInlineImages
86
+ } from "./chunk-S7TRWILI.js";
72
87
  import {
73
88
  discoverContentAssetUrls,
74
89
  discoverRawImgSrcs,
@@ -76,354 +91,6 @@ import {
76
91
  isLikelyImageUrl,
77
92
  normalizeAssetUrl
78
93
  } from "./chunk-2PNSVE5Y.js";
79
-
80
- // src/transformers/html-to-grapes/index.ts
81
- import * as cheerio from "cheerio";
82
-
83
- // src/transformers/css-to-styles/index.ts
84
- function stripCssComments(css) {
85
- return css.replace(/\/\*[\s\S]*?\*\//g, "");
86
- }
87
- function parseDeclarations(block) {
88
- const style = {};
89
- for (const declaration of block.split(";")) {
90
- const trimmed = declaration.trim();
91
- if (!trimmed) continue;
92
- const separator = trimmed.indexOf(":");
93
- if (separator === -1) continue;
94
- const property = trimmed.slice(0, separator).trim();
95
- const value = trimmed.slice(separator + 1).trim();
96
- if (!property || !value) continue;
97
- style[property] = value;
98
- }
99
- return style;
100
- }
101
- function cssToStyles(css) {
102
- const cleaned = stripCssComments(css);
103
- const rules = [];
104
- const rulePattern = /([^{]+)\{([^}]*)\}/g;
105
- for (const match of cleaned.matchAll(rulePattern)) {
106
- const selectorText = match[1]?.trim() ?? "";
107
- const declarationBlock = match[2] ?? "";
108
- if (!selectorText || selectorText.startsWith("@")) continue;
109
- const style = parseDeclarations(declarationBlock);
110
- if (Object.keys(style).length === 0) continue;
111
- const selectors = selectorText.split(",").map((selector) => selector.trim()).filter(Boolean);
112
- if (selectors.length === 0) continue;
113
- rules.push({ selectors, style });
114
- }
115
- return rules;
116
- }
117
-
118
- // src/transformers/html-to-grapes/walk.ts
119
- var INLINE_TAGS = /* @__PURE__ */ new Set([
120
- "a",
121
- "abbr",
122
- "b",
123
- "br",
124
- "cite",
125
- "code",
126
- "del",
127
- "em",
128
- "i",
129
- "img",
130
- "ins",
131
- "mark",
132
- "q",
133
- "s",
134
- "small",
135
- "span",
136
- "strong",
137
- "sub",
138
- "sup",
139
- "u",
140
- "wbr"
141
- ]);
142
- var VOID_TAGS = /* @__PURE__ */ new Set([
143
- "area",
144
- "base",
145
- "br",
146
- "col",
147
- "embed",
148
- "hr",
149
- "img",
150
- "input",
151
- "link",
152
- "meta",
153
- "param",
154
- "source",
155
- "track",
156
- "wbr"
157
- ]);
158
- var TEXT_CONTAINER_TAGS = /* @__PURE__ */ new Set([
159
- "blockquote",
160
- "figcaption",
161
- "h1",
162
- "h2",
163
- "h3",
164
- "h4",
165
- "h5",
166
- "h6",
167
- "label",
168
- "li",
169
- "p",
170
- "pre",
171
- "td",
172
- "th"
173
- ]);
174
- var SKIP_TAGS = /* @__PURE__ */ new Set(["script", "style", "noscript", "template"]);
175
- var DEFAULT_TYPES = {
176
- a: "link",
177
- img: "image"
178
- };
179
- function tagNameOf($el) {
180
- const raw = $el.prop("tagName");
181
- return typeof raw === "string" ? raw.toLowerCase() : void 0;
182
- }
183
- function applyElementMeta(component, meta) {
184
- if (meta.attributes) component.attributes = meta.attributes;
185
- if (meta.classes) component.classes = meta.classes;
186
- return component;
187
- }
188
- function pickElementMeta($el) {
189
- const attributes = {};
190
- const classes = [];
191
- if (typeof $el.attr() === "object") {
192
- for (const [key, value] of Object.entries($el.attr() ?? {})) {
193
- if (key === "class") {
194
- classes.push(...value.split(/\s+/).filter(Boolean));
195
- continue;
196
- }
197
- attributes[key] = value;
198
- }
199
- }
200
- return {
201
- attributes: Object.keys(attributes).length > 0 ? attributes : void 0,
202
- classes: classes.length > 0 ? classes : void 0
203
- };
204
- }
205
- function resolveComponentType(tagName, classes, options) {
206
- if (options.componentMap && classes) {
207
- for (const className of classes) {
208
- const mapped = options.componentMap[className];
209
- if (mapped) return mapped;
210
- }
211
- }
212
- return DEFAULT_TYPES[tagName] ?? "default";
213
- }
214
- function hasOnlyInlineContent($, $el) {
215
- let inlineOnly = true;
216
- $el.contents().each((_, node) => {
217
- if (!inlineOnly) return;
218
- const $child = $(node);
219
- if ($child.get(0)?.type === "text") return;
220
- const childTag = tagNameOf($child);
221
- if (!childTag || !INLINE_TAGS.has(childTag)) {
222
- inlineOnly = false;
223
- return;
224
- }
225
- if (!hasOnlyInlineContent($, $child)) {
226
- inlineOnly = false;
227
- }
228
- });
229
- return inlineOnly;
230
- }
231
- function walkChildren($, $el, options) {
232
- const components = [];
233
- $el.contents().each((_, node) => {
234
- const walked = walkNode($, $(node), options);
235
- if (!walked) return;
236
- if (Array.isArray(walked)) {
237
- components.push(...walked);
238
- } else {
239
- components.push(walked);
240
- }
241
- });
242
- return components;
243
- }
244
- function walkNode($, $el, options) {
245
- const node = $el.get(0);
246
- if (!node) return null;
247
- if (node.type === "text") {
248
- const text = "data" in node ? String(node.data ?? "") : "";
249
- if (!text.trim()) return null;
250
- return { type: "textnode", content: text };
251
- }
252
- if (node.type !== "tag") return null;
253
- const tagName = tagNameOf($el);
254
- if (!tagName || SKIP_TAGS.has(tagName)) return null;
255
- const meta = pickElementMeta($el);
256
- if (VOID_TAGS.has(tagName)) {
257
- return applyElementMeta(
258
- {
259
- type: resolveComponentType(tagName, meta.classes, options),
260
- tagName,
261
- void: true
262
- },
263
- meta
264
- );
265
- }
266
- if (TEXT_CONTAINER_TAGS.has(tagName) && hasOnlyInlineContent($, $el)) {
267
- return applyElementMeta(
268
- {
269
- type: "text",
270
- tagName,
271
- content: $el.html() ?? ""
272
- },
273
- meta
274
- );
275
- }
276
- if (INLINE_TAGS.has(tagName)) {
277
- return applyElementMeta(
278
- {
279
- type: "text",
280
- content: $.html($el) ?? ""
281
- },
282
- meta
283
- );
284
- }
285
- const components = walkChildren($, $el, options);
286
- const component = applyElementMeta(
287
- {
288
- type: resolveComponentType(tagName, meta.classes, options),
289
- tagName
290
- },
291
- meta
292
- );
293
- if (components.length > 0) {
294
- component.components = components;
295
- }
296
- return component;
297
- }
298
- function appendWalked(content, walked) {
299
- if (!walked) return;
300
- if (Array.isArray(walked)) {
301
- content.push(...walked);
302
- return;
303
- }
304
- content.push(walked);
305
- }
306
- function walkNodes($, $nodes, content, options) {
307
- $nodes.each((_, node) => {
308
- appendWalked(content, walkNode($, $(node), options));
309
- });
310
- }
311
- function walkHtmlToComponents($, options = {}) {
312
- const content = [];
313
- const body = $("body");
314
- if (body.length) {
315
- walkNodes($, body.contents(), content, options);
316
- return content;
317
- }
318
- const children = $.root().children();
319
- if (children.length) {
320
- walkNodes($, children, content, options);
321
- } else {
322
- walkNodes($, $.root().contents(), content, options);
323
- }
324
- return content;
325
- }
326
-
327
- // src/transformers/html-to-grapes/index.ts
328
- function htmlToGrapes(html, options = {}) {
329
- const trimmed = html.trim();
330
- if (!trimmed) {
331
- return { content: [], styles: [] };
332
- }
333
- const $ = cheerio.load(trimmed, { xml: false });
334
- const styleBlocks = [];
335
- $("style").each((_, element) => {
336
- styleBlocks.push($(element).html() ?? "");
337
- $(element).remove();
338
- });
339
- const contentCss = styleBlocks.join("\n").trim();
340
- const styles = cssToStyles(contentCss);
341
- const content = walkHtmlToComponents($, options);
342
- const contentHtml = serializeContentHtml($);
343
- return {
344
- content,
345
- styles,
346
- ...contentHtml ? { contentHtml } : {},
347
- ...contentCss ? { contentCss } : {}
348
- };
349
- }
350
- function serializeContentHtml($) {
351
- const body = $("body");
352
- if (body.length) {
353
- const html = body.html()?.trim();
354
- return html || void 0;
355
- }
356
- const rootHtml = $.root().html()?.trim();
357
- return rootHtml || void 0;
358
- }
359
-
360
- // src/transformers/validate-snapshot.ts
361
- import { z } from "zod";
362
- var grapesStyleRuleSchema = z.object({
363
- selectors: z.array(z.string().min(1)).min(1),
364
- style: z.record(z.string(), z.string())
365
- });
366
- var grapesComponentSchema = z.lazy(
367
- () => z.object({
368
- type: z.string().min(1),
369
- tagName: z.string().optional(),
370
- attributes: z.record(z.string(), z.string()).optional(),
371
- classes: z.array(z.string()).optional(),
372
- components: z.array(grapesComponentSchema).optional(),
373
- content: z.string().optional(),
374
- void: z.boolean().optional()
375
- })
376
- );
377
- var grapesProjectSnapshotSchema = z.object({
378
- content: z.array(grapesComponentSchema),
379
- styles: z.array(grapesStyleRuleSchema),
380
- contentHtml: z.string().optional(),
381
- contentCss: z.string().optional()
382
- });
383
- function zodIssuesToValidationIssues(issues) {
384
- return issues.map((issue) => ({
385
- code: issue.code,
386
- message: issue.message,
387
- path: issue.path.length > 0 ? issue.path.join(".") : void 0
388
- }));
389
- }
390
- function collectComponentTypes(components) {
391
- const types = [];
392
- for (const component of components) {
393
- types.push(component.type);
394
- if (component.components?.length) {
395
- types.push(...collectComponentTypes(component.components));
396
- }
397
- }
398
- return types;
399
- }
400
- function validateAllowedComponentTypes(snapshot, allowedComponentTypes) {
401
- const allowlist = new Set(allowedComponentTypes);
402
- const issues = [];
403
- for (const componentType of collectComponentTypes(snapshot.content)) {
404
- if (!allowlist.has(componentType)) {
405
- issues.push({
406
- code: "invalid_component_type",
407
- message: `Component type "${componentType}" is not in allowedComponentTypes`,
408
- path: "content"
409
- });
410
- }
411
- }
412
- return issues;
413
- }
414
- function validateGrapesProjectSnapshot(snapshot, options = {}) {
415
- const result = grapesProjectSnapshotSchema.safeParse(snapshot);
416
- if (!result.success) {
417
- return { ok: false, issues: zodIssuesToValidationIssues(result.error.issues) };
418
- }
419
- if (options.allowedComponentTypes?.length) {
420
- const typeIssues = validateAllowedComponentTypes(result.data, options.allowedComponentTypes);
421
- if (typeIssues.length > 0) {
422
- return { ok: false, issues: typeIssues };
423
- }
424
- }
425
- return { ok: true, issues: [] };
426
- }
427
94
  export {
428
95
  FALLBACK_ASSET_BYTES,
429
96
  FilesystemMigrationSink,
@@ -462,6 +129,7 @@ export {
462
129
  hasBlockingConflicts,
463
130
  hasWarnings,
464
131
  htmlToGrapes,
132
+ htmlToTiptap,
465
133
  isLikelyImageUrl,
466
134
  isTerminalState,
467
135
  mapJsonPrettyWire,
@@ -488,6 +156,9 @@ export {
488
156
  sourceMetadataSchema,
489
157
  squarespaceAdapter,
490
158
  staleUrlsFromEstimate,
159
+ tiptapDocSchema,
160
+ tiptapMarkSchema,
161
+ tiptapNodeSchema,
491
162
  validateGrapesProjectSnapshot,
492
163
  validateNormalizedAsset,
493
164
  validateNormalizedCategory,
@@ -496,6 +167,7 @@ export {
496
167
  validateNormalizedPortfolio,
497
168
  validateNormalizedPost,
498
169
  validateNormalizedTag,
170
+ validateTiptapDoc,
499
171
  wixAdapter,
500
172
  wordpressAdapter,
501
173
  writeFilesystemExport
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/transformers/html-to-grapes/index.ts","../src/transformers/css-to-styles/index.ts","../src/transformers/html-to-grapes/walk.ts","../src/transformers/validate-snapshot.ts"],"sourcesContent":["import * as cheerio from \"cheerio\";\n\nimport { cssToStyles } from \"../css-to-styles/index.js\";\nimport type { GrapesProjectSnapshot, HtmlToGrapesOptions } from \"./types.js\";\nimport { walkHtmlToComponents } from \"./walk.js\";\n\nexport type {\n GrapesComponent,\n GrapesProjectSnapshot,\n GrapesStyleRule,\n HtmlToGrapesOptions,\n} from \"./types.js\";\n\n/** Cheerio HTML walk → Grapes `content` + root `styles`. */\nexport function htmlToGrapes(html: string, options: HtmlToGrapesOptions = {}): GrapesProjectSnapshot {\n const trimmed = html.trim();\n if (!trimmed) {\n return { content: [], styles: [] };\n }\n\n const $ = cheerio.load(trimmed, { xml: false });\n const styleBlocks: string[] = [];\n\n $(\"style\").each((_, element) => {\n styleBlocks.push($(element).html() ?? \"\");\n $(element).remove();\n });\n\n const contentCss = styleBlocks.join(\"\\n\").trim();\n const styles = cssToStyles(contentCss);\n const content = walkHtmlToComponents($, options);\n const contentHtml = serializeContentHtml($);\n\n return {\n content,\n styles,\n ...(contentHtml ? { contentHtml } : {}),\n ...(contentCss ? { contentCss } : {}),\n };\n}\n\nfunction serializeContentHtml($: cheerio.CheerioAPI): string | undefined {\n const body = $(\"body\");\n if (body.length) {\n const html = body.html()?.trim();\n return html || undefined;\n }\n\n const rootHtml = $.root().html()?.trim();\n return rootHtml || undefined;\n}\n","import type { GrapesStyleRule } from \"../html-to-grapes/types.js\";\n\nfunction stripCssComments(css: string): string {\n return css.replace(/\\/\\*[\\s\\S]*?\\*\\//g, \"\");\n}\n\nfunction parseDeclarations(block: string): Record<string, string> {\n const style: Record<string, string> = {};\n for (const declaration of block.split(\";\")) {\n const trimmed = declaration.trim();\n if (!trimmed) continue;\n const separator = trimmed.indexOf(\":\");\n if (separator === -1) continue;\n const property = trimmed.slice(0, separator).trim();\n const value = trimmed.slice(separator + 1).trim();\n if (!property || !value) continue;\n style[property] = value;\n }\n return style;\n}\n\n/** Parse `<style>` blocks and class rules into Grapes root `styles[]`. */\nexport function cssToStyles(css: string): GrapesStyleRule[] {\n const cleaned = stripCssComments(css);\n const rules: GrapesStyleRule[] = [];\n const rulePattern = /([^{]+)\\{([^}]*)\\}/g;\n\n for (const match of cleaned.matchAll(rulePattern)) {\n const selectorText = match[1]?.trim() ?? \"\";\n const declarationBlock = match[2] ?? \"\";\n if (!selectorText || selectorText.startsWith(\"@\")) continue;\n\n const style = parseDeclarations(declarationBlock);\n if (Object.keys(style).length === 0) continue;\n\n const selectors = selectorText\n .split(\",\")\n .map((selector) => selector.trim())\n .filter(Boolean);\n\n if (selectors.length === 0) continue;\n rules.push({ selectors, style });\n }\n\n return rules;\n}\n","import type { Cheerio, CheerioAPI } from \"cheerio\";\nimport type { AnyNode } from \"domhandler\";\n\nimport type { GrapesComponent, HtmlToGrapesOptions } from \"./types.js\";\n\ntype CheerioSelection = Cheerio<AnyNode>;\n\nconst INLINE_TAGS = new Set([\n \"a\",\n \"abbr\",\n \"b\",\n \"br\",\n \"cite\",\n \"code\",\n \"del\",\n \"em\",\n \"i\",\n \"img\",\n \"ins\",\n \"mark\",\n \"q\",\n \"s\",\n \"small\",\n \"span\",\n \"strong\",\n \"sub\",\n \"sup\",\n \"u\",\n \"wbr\",\n]);\n\nconst VOID_TAGS = new Set([\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n\nconst TEXT_CONTAINER_TAGS = new Set([\n \"blockquote\",\n \"figcaption\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"label\",\n \"li\",\n \"p\",\n \"pre\",\n \"td\",\n \"th\",\n]);\n\nconst SKIP_TAGS = new Set([\"script\", \"style\", \"noscript\", \"template\"]);\n\nconst DEFAULT_TYPES: Record<string, string> = {\n a: \"link\",\n img: \"image\",\n};\n\nfunction tagNameOf($el: CheerioSelection): string | undefined {\n const raw = $el.prop(\"tagName\");\n return typeof raw === \"string\" ? raw.toLowerCase() : undefined;\n}\n\nfunction applyElementMeta(\n component: GrapesComponent,\n meta: Pick<GrapesComponent, \"attributes\" | \"classes\">,\n): GrapesComponent {\n if (meta.attributes) component.attributes = meta.attributes;\n if (meta.classes) component.classes = meta.classes;\n return component;\n}\n\nfunction pickElementMeta($el: CheerioSelection): Pick<GrapesComponent, \"attributes\" | \"classes\"> {\n const attributes: Record<string, string> = {};\n const classes: string[] = [];\n\n if (typeof $el.attr() === \"object\") {\n for (const [key, value] of Object.entries($el.attr() ?? {})) {\n if (key === \"class\") {\n classes.push(...value.split(/\\s+/).filter(Boolean));\n continue;\n }\n attributes[key] = value;\n }\n }\n\n return {\n attributes: Object.keys(attributes).length > 0 ? attributes : undefined,\n classes: classes.length > 0 ? classes : undefined,\n };\n}\n\nfunction resolveComponentType(\n tagName: string,\n classes: string[] | undefined,\n options: HtmlToGrapesOptions,\n): string {\n if (options.componentMap && classes) {\n for (const className of classes) {\n const mapped = options.componentMap[className];\n if (mapped) return mapped;\n }\n }\n return DEFAULT_TYPES[tagName] ?? \"default\";\n}\n\nfunction hasOnlyInlineContent($: CheerioAPI, $el: CheerioSelection): boolean {\n let inlineOnly = true;\n\n $el.contents().each((_, node) => {\n if (!inlineOnly) return;\n const $child = $(node);\n if ($child.get(0)?.type === \"text\") return;\n const childTag = tagNameOf($child);\n if (!childTag || !INLINE_TAGS.has(childTag)) {\n inlineOnly = false;\n return;\n }\n if (!hasOnlyInlineContent($, $child)) {\n inlineOnly = false;\n }\n });\n\n return inlineOnly;\n}\n\nfunction walkChildren(\n $: CheerioAPI,\n $el: CheerioSelection,\n options: HtmlToGrapesOptions,\n): GrapesComponent[] {\n const components: GrapesComponent[] = [];\n\n $el.contents().each((_, node) => {\n const walked = walkNode($, $(node), options);\n if (!walked) return;\n if (Array.isArray(walked)) {\n components.push(...walked);\n } else {\n components.push(walked);\n }\n });\n\n return components;\n}\n\nfunction walkNode(\n $: CheerioAPI,\n $el: CheerioSelection,\n options: HtmlToGrapesOptions,\n): GrapesComponent | GrapesComponent[] | null {\n const node = $el.get(0);\n if (!node) return null;\n\n if (node.type === \"text\") {\n const text = \"data\" in node ? String(node.data ?? \"\") : \"\";\n if (!text.trim()) return null;\n return { type: \"textnode\", content: text };\n }\n\n if (node.type !== \"tag\") return null;\n\n const tagName = tagNameOf($el);\n if (!tagName || SKIP_TAGS.has(tagName)) return null;\n\n const meta = pickElementMeta($el);\n\n if (VOID_TAGS.has(tagName)) {\n return applyElementMeta(\n {\n type: resolveComponentType(tagName, meta.classes, options),\n tagName,\n void: true,\n },\n meta,\n );\n }\n\n if (TEXT_CONTAINER_TAGS.has(tagName) && hasOnlyInlineContent($, $el)) {\n return applyElementMeta(\n {\n type: \"text\",\n tagName,\n content: $el.html() ?? \"\",\n },\n meta,\n );\n }\n\n if (INLINE_TAGS.has(tagName)) {\n return applyElementMeta(\n {\n type: \"text\",\n content: $.html($el) ?? \"\",\n },\n meta,\n );\n }\n\n const components = walkChildren($, $el, options);\n const component = applyElementMeta(\n {\n type: resolveComponentType(tagName, meta.classes, options),\n tagName,\n },\n meta,\n );\n\n if (components.length > 0) {\n component.components = components;\n }\n\n return component;\n}\n\nfunction appendWalked(\n content: GrapesComponent[],\n walked: GrapesComponent | GrapesComponent[] | null,\n): void {\n if (!walked) return;\n if (Array.isArray(walked)) {\n content.push(...walked);\n return;\n }\n content.push(walked);\n}\n\nfunction walkNodes(\n $: CheerioAPI,\n $nodes: CheerioSelection,\n content: GrapesComponent[],\n options: HtmlToGrapesOptions,\n): void {\n $nodes.each((_, node) => {\n appendWalked(content, walkNode($, $(node), options));\n });\n}\n\nexport function walkHtmlToComponents(\n $: CheerioAPI,\n options: HtmlToGrapesOptions = {},\n): GrapesComponent[] {\n const content: GrapesComponent[] = [];\n const body = $(\"body\");\n\n if (body.length) {\n walkNodes($, body.contents(), content, options);\n return content;\n }\n\n const children = $.root().children();\n if (children.length) {\n walkNodes($, children, content, options);\n } else {\n walkNodes($, $.root().contents(), content, options);\n }\n\n return content;\n}\n","import { z } from \"zod\";\n\nimport type { ValidationIssue, ValidationResult } from \"../normalizer/types.js\";\nimport type { GrapesComponent, GrapesProjectSnapshot } from \"./html-to-grapes/types.js\";\n\nexport const grapesStyleRuleSchema = z.object({\n selectors: z.array(z.string().min(1)).min(1),\n style: z.record(z.string(), z.string()),\n});\n\nexport const grapesComponentSchema: z.ZodType<GrapesComponent> = z.lazy(() =>\n z.object({\n type: z.string().min(1),\n tagName: z.string().optional(),\n attributes: z.record(z.string(), z.string()).optional(),\n classes: z.array(z.string()).optional(),\n components: z.array(grapesComponentSchema).optional(),\n content: z.string().optional(),\n void: z.boolean().optional(),\n }),\n);\n\nexport const grapesProjectSnapshotSchema = z.object({\n content: z.array(grapesComponentSchema),\n styles: z.array(grapesStyleRuleSchema),\n contentHtml: z.string().optional(),\n contentCss: z.string().optional(),\n});\n\nexport interface ValidateGrapesProjectSnapshotOptions {\n /** When set, every component `type` in the tree must be in this allowlist. */\n allowedComponentTypes?: string[];\n}\n\nfunction zodIssuesToValidationIssues(issues: z.ZodIssue[]): ValidationIssue[] {\n return issues.map((issue) => ({\n code: issue.code,\n message: issue.message,\n path: issue.path.length > 0 ? issue.path.join(\".\") : undefined,\n }));\n}\n\nfunction collectComponentTypes(components: GrapesComponent[]): string[] {\n const types: string[] = [];\n for (const component of components) {\n types.push(component.type);\n if (component.components?.length) {\n types.push(...collectComponentTypes(component.components));\n }\n }\n return types;\n}\n\nfunction validateAllowedComponentTypes(\n snapshot: GrapesProjectSnapshot,\n allowedComponentTypes: string[],\n): ValidationIssue[] {\n const allowlist = new Set(allowedComponentTypes);\n const issues: ValidationIssue[] = [];\n\n for (const componentType of collectComponentTypes(snapshot.content)) {\n if (!allowlist.has(componentType)) {\n issues.push({\n code: \"invalid_component_type\",\n message: `Component type \"${componentType}\" is not in allowedComponentTypes`,\n path: \"content\",\n });\n }\n }\n\n return issues;\n}\n\n/**\n * Opt-in structural check for a Grapes project snapshot (not a full Grapes editor project file).\n * Does not validate host-specific component registries unless `allowedComponentTypes` is passed.\n */\nexport function validateGrapesProjectSnapshot(\n snapshot: unknown,\n options: ValidateGrapesProjectSnapshotOptions = {},\n): ValidationResult {\n const result = grapesProjectSnapshotSchema.safeParse(snapshot);\n if (!result.success) {\n return { ok: false, issues: zodIssuesToValidationIssues(result.error.issues) };\n }\n\n if (options.allowedComponentTypes?.length) {\n const typeIssues = validateAllowedComponentTypes(result.data, options.allowedComponentTypes);\n if (typeIssues.length > 0) {\n return { ok: false, issues: typeIssues };\n }\n }\n\n return { ok: true, issues: [] };\n}\n"],"mappings":";;;;;;;;;;;;;;;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