@prenta/import 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/CHANGELOG.md +686 -0
  2. package/LICENSE +21 -0
  3. package/README.md +24 -0
  4. package/dist/adapter.d.ts +47 -0
  5. package/dist/adapter.d.ts.map +1 -0
  6. package/dist/adapter.js +60 -0
  7. package/dist/adapter.js.map +1 -0
  8. package/dist/adapters/contentful/asset.d.ts +47 -0
  9. package/dist/adapters/contentful/asset.d.ts.map +1 -0
  10. package/dist/adapters/contentful/asset.js +88 -0
  11. package/dist/adapters/contentful/asset.js.map +1 -0
  12. package/dist/adapters/contentful/index.d.ts +24 -0
  13. package/dist/adapters/contentful/index.d.ts.map +1 -0
  14. package/dist/adapters/contentful/index.js +242 -0
  15. package/dist/adapters/contentful/index.js.map +1 -0
  16. package/dist/adapters/contentful/locale.d.ts +66 -0
  17. package/dist/adapters/contentful/locale.d.ts.map +1 -0
  18. package/dist/adapters/contentful/locale.js +125 -0
  19. package/dist/adapters/contentful/locale.js.map +1 -0
  20. package/dist/adapters/contentful/map.d.ts +69 -0
  21. package/dist/adapters/contentful/map.d.ts.map +1 -0
  22. package/dist/adapters/contentful/map.js +174 -0
  23. package/dist/adapters/contentful/map.js.map +1 -0
  24. package/dist/adapters/contentful/rich-text.d.ts +52 -0
  25. package/dist/adapters/contentful/rich-text.d.ts.map +1 -0
  26. package/dist/adapters/contentful/rich-text.js +95 -0
  27. package/dist/adapters/contentful/rich-text.js.map +1 -0
  28. package/dist/adapters/contentful/types.d.ts +189 -0
  29. package/dist/adapters/contentful/types.d.ts.map +1 -0
  30. package/dist/adapters/contentful/types.js +26 -0
  31. package/dist/adapters/contentful/types.js.map +1 -0
  32. package/dist/adapters/identity.d.ts +27 -0
  33. package/dist/adapters/identity.d.ts.map +1 -0
  34. package/dist/adapters/identity.js +116 -0
  35. package/dist/adapters/identity.js.map +1 -0
  36. package/dist/adapters/sanity/asset.d.ts +45 -0
  37. package/dist/adapters/sanity/asset.d.ts.map +1 -0
  38. package/dist/adapters/sanity/asset.js +79 -0
  39. package/dist/adapters/sanity/asset.js.map +1 -0
  40. package/dist/adapters/sanity/index.d.ts +19 -0
  41. package/dist/adapters/sanity/index.d.ts.map +1 -0
  42. package/dist/adapters/sanity/index.js +165 -0
  43. package/dist/adapters/sanity/index.js.map +1 -0
  44. package/dist/adapters/sanity/map.d.ts +75 -0
  45. package/dist/adapters/sanity/map.d.ts.map +1 -0
  46. package/dist/adapters/sanity/map.js +245 -0
  47. package/dist/adapters/sanity/map.js.map +1 -0
  48. package/dist/adapters/sanity/parse.d.ts +64 -0
  49. package/dist/adapters/sanity/parse.d.ts.map +1 -0
  50. package/dist/adapters/sanity/parse.js +71 -0
  51. package/dist/adapters/sanity/parse.js.map +1 -0
  52. package/dist/adapters/sanity/portable-text.d.ts +64 -0
  53. package/dist/adapters/sanity/portable-text.d.ts.map +1 -0
  54. package/dist/adapters/sanity/portable-text.js +112 -0
  55. package/dist/adapters/sanity/portable-text.js.map +1 -0
  56. package/dist/adapters/sanity/types.d.ts +182 -0
  57. package/dist/adapters/sanity/types.d.ts.map +1 -0
  58. package/dist/adapters/sanity/types.js +17 -0
  59. package/dist/adapters/sanity/types.js.map +1 -0
  60. package/dist/adapters/strapi/asset.d.ts +56 -0
  61. package/dist/adapters/strapi/asset.d.ts.map +1 -0
  62. package/dist/adapters/strapi/asset.js +94 -0
  63. package/dist/adapters/strapi/asset.js.map +1 -0
  64. package/dist/adapters/strapi/index.d.ts +20 -0
  65. package/dist/adapters/strapi/index.d.ts.map +1 -0
  66. package/dist/adapters/strapi/index.js +205 -0
  67. package/dist/adapters/strapi/index.js.map +1 -0
  68. package/dist/adapters/strapi/links.d.ts +79 -0
  69. package/dist/adapters/strapi/links.d.ts.map +1 -0
  70. package/dist/adapters/strapi/links.js +98 -0
  71. package/dist/adapters/strapi/links.js.map +1 -0
  72. package/dist/adapters/strapi/loader.d.ts +68 -0
  73. package/dist/adapters/strapi/loader.d.ts.map +1 -0
  74. package/dist/adapters/strapi/loader.js +177 -0
  75. package/dist/adapters/strapi/loader.js.map +1 -0
  76. package/dist/adapters/strapi/map.d.ts +53 -0
  77. package/dist/adapters/strapi/map.d.ts.map +1 -0
  78. package/dist/adapters/strapi/map.js +193 -0
  79. package/dist/adapters/strapi/map.js.map +1 -0
  80. package/dist/adapters/strapi/types.d.ts +174 -0
  81. package/dist/adapters/strapi/types.d.ts.map +1 -0
  82. package/dist/adapters/strapi/types.js +31 -0
  83. package/dist/adapters/strapi/types.js.map +1 -0
  84. package/dist/adapters/strapi/uid.d.ts +44 -0
  85. package/dist/adapters/strapi/uid.d.ts.map +1 -0
  86. package/dist/adapters/strapi/uid.js +58 -0
  87. package/dist/adapters/strapi/uid.js.map +1 -0
  88. package/dist/adapters/wordpress/attachments.d.ts +37 -0
  89. package/dist/adapters/wordpress/attachments.d.ts.map +1 -0
  90. package/dist/adapters/wordpress/attachments.js +134 -0
  91. package/dist/adapters/wordpress/attachments.js.map +1 -0
  92. package/dist/adapters/wordpress/authors.d.ts +24 -0
  93. package/dist/adapters/wordpress/authors.d.ts.map +1 -0
  94. package/dist/adapters/wordpress/authors.js +40 -0
  95. package/dist/adapters/wordpress/authors.js.map +1 -0
  96. package/dist/adapters/wordpress/index.d.ts +19 -0
  97. package/dist/adapters/wordpress/index.d.ts.map +1 -0
  98. package/dist/adapters/wordpress/index.js +281 -0
  99. package/dist/adapters/wordpress/index.js.map +1 -0
  100. package/dist/adapters/wordpress/map.d.ts +61 -0
  101. package/dist/adapters/wordpress/map.d.ts.map +1 -0
  102. package/dist/adapters/wordpress/map.js +265 -0
  103. package/dist/adapters/wordpress/map.js.map +1 -0
  104. package/dist/adapters/wordpress/parse.d.ts +50 -0
  105. package/dist/adapters/wordpress/parse.d.ts.map +1 -0
  106. package/dist/adapters/wordpress/parse.js +141 -0
  107. package/dist/adapters/wordpress/parse.js.map +1 -0
  108. package/dist/adapters/wordpress/terms.d.ts +46 -0
  109. package/dist/adapters/wordpress/terms.d.ts.map +1 -0
  110. package/dist/adapters/wordpress/terms.js +87 -0
  111. package/dist/adapters/wordpress/terms.js.map +1 -0
  112. package/dist/adapters/wordpress/types.d.ts +201 -0
  113. package/dist/adapters/wordpress/types.d.ts.map +1 -0
  114. package/dist/adapters/wordpress/types.js +24 -0
  115. package/dist/adapters/wordpress/types.js.map +1 -0
  116. package/dist/cli.d.ts +16 -0
  117. package/dist/cli.d.ts.map +1 -0
  118. package/dist/cli.js +266 -0
  119. package/dist/cli.js.map +1 -0
  120. package/dist/formatter.d.ts +12 -0
  121. package/dist/formatter.d.ts.map +1 -0
  122. package/dist/formatter.js +48 -0
  123. package/dist/formatter.js.map +1 -0
  124. package/dist/index.d.ts +31 -0
  125. package/dist/index.d.ts.map +1 -0
  126. package/dist/index.js +25 -0
  127. package/dist/index.js.map +1 -0
  128. package/dist/migrate.d.ts +151 -0
  129. package/dist/migrate.d.ts.map +1 -0
  130. package/dist/migrate.js +255 -0
  131. package/dist/migrate.js.map +1 -0
  132. package/dist/registry.d.ts +39 -0
  133. package/dist/registry.d.ts.map +1 -0
  134. package/dist/registry.js +62 -0
  135. package/dist/registry.js.map +1 -0
  136. package/dist/runner.d.ts +33 -0
  137. package/dist/runner.d.ts.map +1 -0
  138. package/dist/runner.js +61 -0
  139. package/dist/runner.js.map +1 -0
  140. package/dist/types.d.ts +173 -0
  141. package/dist/types.d.ts.map +1 -0
  142. package/dist/types.js +17 -0
  143. package/dist/types.js.map +1 -0
  144. package/package.json +59 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,686 @@
1
+ # @actuate-media/import
2
+
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5eea995: Product rename: ActuateCMS is now **Prenta**. Every package moves from the
8
+ `@actuate-media/*` scope to `@prenta/*` with simplified names (`@prenta/core`,
9
+ `@prenta/admin`, `create-prenta`), and version numbers continue from where the
10
+ old scope left off.
11
+
12
+ This is a clean break — no backwards-compat aliases:
13
+ - **npm packages**: `@actuate-media/cms-core` → `@prenta/core`,
14
+ `@actuate-media/cms-admin` → `@prenta/admin`, all other packages keep their
15
+ suffix under `@prenta/*`. `create-actuate-cms` → `create-prenta`
16
+ (`npm create prenta`), `create-actuate-astro` → `create-prenta-astro`.
17
+ CLI bins: `actuate`/`actuate-cms` → `prenta`/`prenta-cms`; `actuate-mcp` →
18
+ `prenta-mcp`.
19
+ - **Database**: migration `0012_rename_to_prenta` renames all 36 `actuate_*`
20
+ tables to `prenta_*` in place (plus prefixed constraints, indexes, and
21
+ sequences). Run `prisma migrate deploy` when upgrading.
22
+ - **Runtime identifiers**: `getActuateConfig` → `getPrentaConfig`,
23
+ `handleActuateAPI` → `handlePrentaAPI`, `ActuateClient` → `PrentaClient`,
24
+ `ActuateDB` → `PrentaDB`, config file `actuate.config.ts` →
25
+ `prenta.config.ts`, CSS scopes `.actuate-admin`/`.actuate-canvas` →
26
+ `.prenta-admin`/`.prenta-canvas`, preview protocol `actuate-preview:*` →
27
+ `prenta-preview:*`, webhook headers `X-Actuate-*` → `X-Prenta-*`, session
28
+ cookie `actuate_session` → `prenta_session`, env vars `ACTUATE_*` →
29
+ `PRENTA_*`, purge route `/api/actuate/purge` → `/api/prenta/purge`.
30
+ - **Sessions and webhooks**: all sessions reset on upgrade (cookie + JWT issuer
31
+ changed); webhook consumers must re-verify signatures against the new
32
+ `X-Prenta-*` headers.
33
+
34
+ The old `@actuate-media/*` packages are deprecated on npm and will receive no
35
+ further releases.
36
+
37
+ ## 0.4.2
38
+
39
+ ### Patch Changes
40
+
41
+ - 041a228: Add the MIT `license` field to every published package (previously missing) and correct `repository.url` to `github.com/actuate-media/actuatecms` (13 packages carried the wrong org).
42
+
43
+ ## 0.4.1
44
+
45
+ ### Patch Changes
46
+
47
+ - 854152d: Developer experience improvements from external-consumer feedback:
48
+ - Every published package now ships its `CHANGELOG.md` in the npm tarball, and packages that were missing a `README.md` (cli, cms-admin, cms-core, import, platform-vercel, all plugins, sections-react) now have one — so release notes and usage docs are visible on npmjs.com and in `node_modules`.
49
+ - New client-safe form validation entry point: `@actuate-media/cms-core/forms/client` exports `validateFormFieldClient()`, `validateFormValuesClient()`, visibility/conditional helpers, and the exact `FORM_EMAIL_RE` / `FORM_PHONE_RE` regexes the server enforces — zero Node dependencies, so public-site forms can mirror server rules without reimplementing them. The server validator now imports the same primitives, so client and server can never drift.
50
+
51
+ ## 0.4.0
52
+
53
+ ### Minor Changes
54
+
55
+ - 7d29142: Add a generic post-import migration pipeline to `actuate-import` (Phase 6 polish; closes the doc-promised "import + migrate in one CI run" workflow).
56
+
57
+ #### CLI surface
58
+
59
+ ```bash
60
+ actuate-import wordpress ./export.xml \
61
+ --migrate ./migrations/01-rename-hero-cta.mjs \
62
+ --migrate ./migrations/02-rewrite-asset-urls.mjs \
63
+ --write --out ./content.json
64
+ ```
65
+
66
+ - **`--migrate <file>`** (repeatable) — apply a migration script after the adapter runs. Multiple flags chain in order, each migration seeing the output of the previous. Loaded via dynamic `import()`; supports any `import()`-able shape (`.mjs`, `.js`, compiled `.ts`).
67
+ - **`--validate`** — dry-run: run the full pipeline (adapter + migrations) but never write. Mutually exclusive with `--write`. Still exits `2` on any unresolved field, so CI gates can use it instead of `--write` to skip artifact production.
68
+
69
+ #### Migration script contract
70
+
71
+ A migration is a pure function from documents to documents. The orchestrator accepts three export shapes so operators can pick the style that fits the script:
72
+ 1. **Default-exported function** — `export default function migrate(docs) { return docs.map(...) }`.
73
+ 2. **Named `migrate` export** — `export function migrate(docs) { ... }` (optionally with `export const name = '...'`).
74
+ 3. **Default-exported object** — `export default { name, migrate }`.
75
+
76
+ Return shapes: a bare `ImportedDocument[]` for quick rewrites, or `{ documents, warnings?, unresolved? }` for migrations that want to flag issues or block on operator action. Sync and async both supported.
77
+
78
+ #### Programmatic API
79
+
80
+ Three new public exports for projects that prefer to drive the pipeline from a script rather than the CLI:
81
+ - `loadMigration(path): Promise<NamedMigration>` — load + validate a migration script.
82
+ - `applyMigrations(result, migrations): Promise<ImportResult>` — run a chain of `NamedMigration`s against an `ImportResult`, merging warnings + updating `summary.converted`.
83
+ - `MigrationLoadError` / `MigrationRunError` — typed error classes the CLI / library consumers can `instanceof`-check.
84
+
85
+ Type exports: `Migration`, `MigrationOutput`, `NamedMigration`.
86
+
87
+ #### Mechanics
88
+ - **Sequential composition.** Migrations run in declaration order; each sees the prior one's documents.
89
+ - **Warnings and unresolved fields merge.** Adapter-emitted warnings are preserved; migration-emitted warnings append. Downstream consumers (formatter, `--write` envelope, exit-code gate) see the unified picture.
90
+ - **`summary.converted` updates** to reflect the post-migration document count. A migration that drops documents lowers `converted`; `totalRead` stays at the adapter's view.
91
+ - **Failures short-circuit.** A migration that throws raises `MigrationRunError` (exit code `1`). Partial output is never written, because downstream migrations may assume a shape the failed one was supposed to produce.
92
+
93
+ #### Implementation
94
+ - `packages/import/src/migrate.ts` — orchestrator (loader + applier + typed errors).
95
+ - `packages/import/src/cli.ts` — `--migrate` and `--validate` flags, error mapping.
96
+ - `packages/import/src/__tests__/migrate.test.ts` — 19 unit tests (loader shape detection, error paths, async, composition, programmatic NamedMigration, warning/unresolved merge, summary update).
97
+ - `packages/import/src/__tests__/migrate-cli.test.ts` — 10 CLI integration tests (single, chained, --validate, conflicting flags, missing file, no-migrate-export, runtime throw).
98
+ - `packages/import/src/__tests__/fixtures/migrations/*` — anonymized example scripts (rename, drop-with-warnings, async, throw, no-export).
99
+
100
+ #### Tests
101
+
102
+ **29 new — `@actuate-media/import` now at 408 tests total.**
103
+
104
+ - a580465: Phase 6 PR #5 — `wordpress` adapter (closes Phase 6).
105
+
106
+ Imports a WordPress **WXR** (eXtended RSS) XML export — the file you get from `Tools → Export` in WP Admin. WordPress runs the long tail of "we have content we'd like to migrate off this CMS" requests, and WXR is the de-facto interchange format every WP-aware tool reads. Ships in five pieces:
107
+ - **`actuate-import wordpress <path-to-.xml>`** — single-pass import over the parsed XML tree. Powered by `fast-xml-parser` (added as a runtime dependency on the `@actuate-media/import` package).
108
+ - **First-class WP entities.** `<wp:author>`, `<wp:category>`, `<wp:tag>`, `<wp:term>`, and attachment `<item>`s build resolution maps; post `<item>`s consume them. By default the adapter also emits authors, categories, tags, and custom-taxonomy terms as their own Actuate documents — toggleable with `importAuthors` / `importTerms`.
109
+ - **`featuredImage` from `_thumbnail_id`.** The `<wp:postmeta>` key `_thumbnail_id` is recognized specifically and resolved against the attachment URL map, producing `data.featuredImage = { url, sourceId, mime, width, height, title }`. Width / height / mime come from JSON-shaped `_wp_attachment_metadata` when present.
110
+ - **HTML pass-through.** `<content:encoded>` and `<excerpt:encoded>` land verbatim on `data.content` / `data.excerpt`. Block conversion is intentionally out of scope — operators run their own HTML → MDX / portable-text pass downstream.
111
+ - **`postMetaStrategy` config.** Three meta-folding strategies (`'object'` default, `'fields'`, `'none'`) plus an `includeInternalMeta` toggle for `_`-prefixed keys. Default behaviour folds non-internal meta onto `data.meta`.
112
+
113
+ #### Warning + unresolved codes
114
+
115
+ | Code | Severity | Trigger |
116
+ | --------------------------- | -------------- | ---------------------------------------------------------------------------------------------------- |
117
+ | `unmapped-type` | warning | `wp:post_type` not in `typeMap`; adapter used the type as the collection slug. |
118
+ | `invalid-items-skipped` | warning | `<item>` elements missing `wp:post_id` / `wp:post_type` were skipped. |
119
+ | `unresolved-author-ref` | warning | `<dc:creator>` doesn't match any `<wp:author>`. Adapter falls back to `{ sourceId, login }`. |
120
+ | `unresolved-term-ref` | warning | A per-item `<category>` references a slug not declared at the channel level. Slug ref still emitted. |
121
+ | `unresolved-attachment-ref` | warning | `_thumbnail_id` points at an attachment not in this export. |
122
+ | `asset-without-url` | warning | `importAttachments: true` saw an attachment with no `wp:attachment_url`. |
123
+ | `input-missing` | **unresolved** | The path passed to the adapter doesn't exist. |
124
+ | `parse-error` | **unresolved** | The XML wouldn't parse. |
125
+ | `unsupported-format` | **unresolved** | XML parsed but isn't a WXR document (root not `<rss>` / `<channel>`). |
126
+
127
+ #### Config
128
+
129
+ ```json
130
+ {
131
+ "typeMap": { "post": "posts", "page": "pages" },
132
+ "publishedOnly": true,
133
+ "importAuthors": true,
134
+ "authorsCollection": "authors",
135
+ "importTerms": true,
136
+ "categoriesCollection": "categories",
137
+ "tagsCollection": "tags",
138
+ "importAttachments": false,
139
+ "attachmentsCollection": "media",
140
+ "postMetaStrategy": "object",
141
+ "includeInternalMeta": false,
142
+ "includeSystemFields": false,
143
+ "ignoreTypes": ["wp_block"]
144
+ }
145
+ ```
146
+
147
+ Default `ignoreTypes` already covers WP's housekeeping (`attachment` — kept only for URL-map building, `nav_menu_item`, `revision`, `customize_changeset`, `oembed_cache`, `user_request`, `wp_block`, `wp_navigation`, `wp_template`, `wp_template_part`, `wp_global_styles`). Operators add to the list; they don't have to re-state it.
148
+
149
+ #### Implementation
150
+
151
+ Modular layout matches the other Phase 6 adapters:
152
+ - `packages/import/src/adapters/wordpress/types.ts` — WXR shapes + adapter config.
153
+ - `packages/import/src/adapters/wordpress/parse.ts` — `fast-xml-parser` wrapper with WXR-tuned options and structured-error returns (never throws).
154
+ - `packages/import/src/adapters/wordpress/authors.ts` — `<wp:author>` → `login → AuthorEntry` index.
155
+ - `packages/import/src/adapters/wordpress/terms.ts` — categories / tags / custom-taxonomies → keyed-by-slug indexes.
156
+ - `packages/import/src/adapters/wordpress/attachments.ts` — attachment URL map with mime / width / height resolution from JSON-shaped `_wp_attachment_metadata`.
157
+ - `packages/import/src/adapters/wordpress/map.ts` — per-item field mapper (collection resolution, byline, terms, featured image, postmeta strategies).
158
+ - `packages/import/src/adapters/wordpress/index.ts` — the adapter itself + author / term / attachment document emission.
159
+
160
+ Registered automatically in the built-in adapter registry; re-exported from the package root as `wordpressAdapter` + `WordPressAdapterConfig`.
161
+
162
+ #### Tests (76 new, 379 total in `@actuate-media/import`)
163
+ - `wordpress-parse.test.ts` — 14 tests covering XML parsing, structured-error returns, CDATA pass-through, and the array-forcing config.
164
+ - `wordpress-authors.test.ts` — 4 tests covering the author index.
165
+ - `wordpress-terms.test.ts` — 7 tests covering categories, tags, and custom taxonomies.
166
+ - `wordpress-attachments.test.ts` — 9 tests covering attachment URL map, JSON-shaped metadata, mime fallback by extension, parent-id handling.
167
+ - `wordpress-map.test.ts` — 18 tests covering byline resolution, category/tag grouping, featured-image resolution, three `postMetaStrategy` paths, `includeInternalMeta`, `includeSystemFields`.
168
+ - `wordpress.test.ts` — 18 adapter-level tests against the WXR fixture (publishedOnly toggle, importAttachments, importAuthors/importTerms toggles, `shouldInclude` predicate, all three "bad input" paths).
169
+ - `wordpress-cli.test.ts` — 6 CLI integration tests (listing, fixture import, `--config`, `--out`, `--json`, parse-error exit code).
170
+
171
+ Phase 6 ships complete: framework + Sanity + Contentful + Strapi + WordPress adapters.
172
+
173
+ ## 0.3.0
174
+
175
+ ### Minor Changes
176
+
177
+ - d725310: Phase 6, PR #3 — Contentful adapter for the content importer
178
+ framework.
179
+
180
+ Adds the second source-specific adapter and the first one with
181
+ real i18n complexity. Contentful is locale-first: every field is
182
+ `{ [locale]: value }`. The adapter ships three locale strategies
183
+ out of the box (primary-only, primary-with-fallback, all) so the
184
+ operator can pick the right shape for their downstream rendering
185
+ without writing their own pre-processor.
186
+
187
+ **New built-in adapter:** `contentful` — reads the JSON file
188
+ produced by `contentful-export` and emits Actuate-shaped
189
+ `ImportedDocument`s. Two-pass: first pass builds the entry-id →
190
+ collection map (for forward/backward entry-link resolution) and
191
+ the asset-id → asset URL map (locale-aware); second pass walks each
192
+ entry with the resolved context.
193
+
194
+ **Field mapping:**
195
+
196
+ | Source | Emitted |
197
+ | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ |
198
+ | `sys.id` | `sourceId` |
199
+ | `sys.contentType.sys.id` | `sourceType` + `collection` (via `typeMap` or fallback) |
200
+ | `sys.publishedVersion === undefined` | Entry skipped by default |
201
+ | `sys.createdAt`/`updatedAt`/`publishedAt`/`publishedVersion` | Stripped (configurable via `includeSystemFields`) |
202
+ | `{ <locale>: value }` field values | Unwrapped per locale strategy |
203
+ | `{ sys: { type: 'Link', linkType: 'Entry', id } }` | `{ collection, sourceId }` when resolvable; broken → unresolved field |
204
+ | `{ sys: { type: 'Link', linkType: 'Asset', id } }` | `{ url, sourceId, fileName, contentType, width, height, title, description, size }`; broken or no-url → unresolved field |
205
+ | Rich Text `{ nodeType: 'document', content: [...] }` | Passed through unchanged; walked for broken embedded-entry / embedded-asset / entry-hyperlink / asset-hyperlink refs |
206
+ | `slug` field with a string value | Lifted to top-level `slug` |
207
+ | `assets[]` array | Consumed for URL-map building by default; with `importAssets: true`, also emitted as documents in `assetCollection` |
208
+
209
+ **Locale strategies** (`localeStrategy` config):
210
+ - **`primary-only` (default)** — unwrap each field to the primary locale; fields missing in that locale return `undefined`.
211
+ - **`primary-with-fallback`** — unwrap to the primary locale, walking the locale's declared `fallbackCode` chain when a value is missing.
212
+ - **`all`** — preserve the full `{ [locale]: value }` map verbatim; downstream tooling handles multi-language records.
213
+
214
+ Primary locale resolves: explicit config → `default: true` locale → first locale → `'en-US'`.
215
+
216
+ **Per-import config:**
217
+
218
+ ```json
219
+ {
220
+ "typeMap": { "page": "pages", "post": "posts", "author": "authors" },
221
+ "primaryLocale": "en-US",
222
+ "localeStrategy": "primary-only",
223
+ "publishedOnly": true,
224
+ "includeSystemFields": false,
225
+ "importAssets": false,
226
+ "assetCollection": "assets",
227
+ "ignoreTypes": []
228
+ }
229
+ ```
230
+
231
+ **New stable warning + unresolved codes:**
232
+ - `unmapped-type` (warning) — contentType id not in `typeMap`.
233
+ - `unresolved-rich-text-entry-ref` (warning) — embedded entry / entry-hyperlink pointed outside the export.
234
+ - `unresolved-rich-text-asset-ref` (warning) — embedded asset / asset-hyperlink pointed outside the export.
235
+ - `asset-without-url` (warning) — `importAssets: true` saw an asset with no file URL; skipped.
236
+ - `invalid-json` (unresolved) — input wasn't valid JSON.
237
+ - `invalid-shape` (unresolved) — top-level JSON wasn't an object, or an entry was missing `sys.id` / `sys.contentType.sys.id`.
238
+ - `unresolved-entry-link` (unresolved) — hard entry link pointed outside the export.
239
+ - `unresolved-asset-link` (unresolved) — asset link pointed outside the export, or the asset existed but had no file URL.
240
+
241
+ **Modular implementation** under `src/adapters/contentful/`:
242
+ - `types.ts` — narrow types for the structural bits the adapter inspects.
243
+ - `locale.ts` — primary-locale resolution + fallback chains + per-value unwrap. Cycle-safe.
244
+ - `asset.ts` — asset URL map builder. Normalizes protocol-relative URLs to `https://`.
245
+ - `rich-text.ts` — Rich Text detector + reference walker. Recognizes 6 reference-carrying node types.
246
+ - `map.ts` — pure per-entry field mapper.
247
+ - `index.ts` — adapter wiring + orchestration.
248
+
249
+ **Tests** (87 new tests, 216 total in the package):
250
+ - `contentful-locale.test.ts` (18) — primary-locale resolution; fallback chain construction including cycle clipping; locale-wrapped detection; pickLocaleValue across all three strategies.
251
+ - `contentful-asset.test.ts` (7) — URL map construction; protocol-relative normalization; fully-qualified passthrough; placeholder for assets without a file; locale-aware reads of title / description / file.
252
+ - `contentful-rich-text.test.ts` (15) — document detection; link reader; reference collection across all six node types; nested-paragraph recursion; tolerance for malformed targets.
253
+ - `contentful-map.test.ts` (23) — locale unwrap; slug lifting; entry-link resolution; broken entry/asset links; Rich Text passthrough + ref warnings; typeMap warnings; system-fields toggle; array-of-links element-wise mapping.
254
+ - `contentful.test.ts` (18) — adapter-level against fixture: clean summary, full entry mapping, draft drop, orphan detection, locale strategies, importAssets behaviour, shouldInclude filter, invalid-JSON / invalid-shape handling.
255
+ - `contentful-cli.test.ts` (6) — CLI integration: listing exposure, fixture import, `--write` envelope, `--config` typeMap, `--json`, missing-input.
256
+
257
+ **Anonymized JSON fixture** at `src/__tests__/fixtures/contentful-export.json` — single 7-entry export with 3 locales, asset with full file metadata, Rich Text body with embedded entry hyperlink + embedded asset block, draft entry, orphan with broken hard entry + asset links, malformed entry missing contentType.
258
+
259
+ **Public exports** added to the main barrel:
260
+ - `contentfulAdapter` — pre-registered automatically.
261
+ - `ContentfulAdapterConfig` — per-import config type.
262
+
263
+ **Limitations** (deliberate scope):
264
+ - Asset binaries aren't downloaded — adapter uses the URLs Contentful embedded in the export.
265
+ - Content-type definitions aren't imported (use `actuate-component-blocks` for schema migration).
266
+ - No webhook / role / scheduled-action import.
267
+ - Single locale per output document; locale-as-collection patterns (one document per locale) need a follow-up adapter setting.
268
+
269
+ **Test plan summary:**
270
+ - 216 tests pass in `@actuate-media/import` (up from 129).
271
+ - TypeScript build, type-check, format all clean.
272
+ - Full workspace `pnpm build` + `pnpm test` green.
273
+ - CLI end-to-end smoke-tested against the fixture.
274
+
275
+ Stacked on PR #2 (`feat/phase-6-import-sanity`). PR #4 (Strapi)
276
+ follows next.
277
+
278
+ - 678f981: Phase 6, PR #2 — Sanity adapter for the content importer framework.
279
+
280
+ Closes the credibility gap the Phase 4 marketing docs opened up: when
281
+ those docs name-drop Sanity in the comparison matrix, evaluators
282
+ should be able to migrate their real Sanity dataset in one command.
283
+ This PR ships that command.
284
+
285
+ **New built-in adapter:** `sanity` — reads the NDJSON inside a
286
+ `sanity dataset export <name> <archive>` archive and produces
287
+ Actuate-shaped `ImportedDocument`s. Two-pass: first builds a
288
+ doc-id → collection map (for in-export reference resolution
289
+ regardless of file order) and an asset URL map (for inline image
290
+ refs); then walks again mapping each record with the resolved
291
+ context in hand.
292
+
293
+ **Field mapping:**
294
+
295
+ | Source | Emitted |
296
+ | ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
297
+ | `_id` | `sourceId` |
298
+ | `_type` | `sourceType` + collection (via `typeMap` or falls back to `_type` as-is) |
299
+ | `_rev`, `_createdAt`, `_updatedAt` | Stripped from `data` (configurable via `includeSystemFields`) |
300
+ | `{ _type: 'slug', current: 'x' }` | `'x'`. First slug field also becomes the top-level `slug`. |
301
+ | `{ _type: 'reference', _ref: 'doc-id' }` | `{ collection: '<target>', sourceId: '<doc-id>' }` when resolvable. Broken hard refs → unresolved field; weak → warning. |
302
+ | `{ _type: 'image' \| 'file', asset: { _ref } }` | Decorated with `assetId`, `width`/`height`/`extension`, and `url` (declared, derived from config, or warning). |
303
+ | Portable Text arrays | Passed through unchanged. Adapter walks them once to surface broken markDef refs / inline refs / embedded asset refs as warnings. |
304
+ | `sanity.imageAsset` / `sanity.fileAsset` | Skipped as documents; consumed for URL-map building. |
305
+ | `drafts.<id>` documents | Skipped by default (`dropDrafts: true`). |
306
+
307
+ **Per-import config** loaded via `actuate-import sanity ./data.ndjson --config ./sanity.json`:
308
+
309
+ ```json
310
+ {
311
+ "typeMap": { "page": "pages", "post": "posts", "author": "authors" },
312
+ "projectId": "your-sanity-project-id",
313
+ "dataset": "production",
314
+ "dropDrafts": true,
315
+ "includeSystemFields": false,
316
+ "ignoreTypes": ["sanity.imageMetadata"]
317
+ }
318
+ ```
319
+
320
+ `projectId` + `dataset` build the canonical Sanity CDN URL
321
+ (`https://cdn.sanity.io/{folder}/{projectId}/{dataset}/<filename>`)
322
+ for image refs that don't carry a declared URL. `assetBaseUrl`
323
+ wins over the CDN pattern for projects that serve assets through a
324
+ custom domain.
325
+
326
+ **New stable warning + unresolved codes** (see `docs/import.md` for the full table):
327
+ - `unmapped-type` (warning) — `_type` not in `typeMap`, fell back to using `_type` as the collection slug.
328
+ - `weak-reference-unresolved` (warning) — weak ref pointed outside the export.
329
+ - `asset-missing` (warning) — `image`/`file` block had no asset ref.
330
+ - `asset-ref-unrecognized` (warning) — ref didn't match Sanity's `image-<id>-<w>x<h>-<ext>` format.
331
+ - `asset-url-unresolved` (warning) — couldn't derive an asset URL from config or asset doc.
332
+ - `unresolved-portable-text-ref` (warning) — markDef / inline / embedded asset ref pointed outside the export.
333
+ - `invalid-ndjson-line` (unresolved) — NDJSON parse error on a specific line.
334
+ - `invalid-shape` (unresolved) — record missing `_id` or `_type`.
335
+ - `unresolved-reference` (unresolved) — hard ref pointed outside the export.
336
+
337
+ **Modular implementation** under `src/adapters/sanity/`:
338
+ - `types.ts` — narrow types for the structural bits the adapter inspects.
339
+ - `parse.ts` — tolerant NDJSON parser (per-line errors, no thrown exceptions; handles blank lines and CRLF).
340
+ - `asset.ts` — asset ref parser + CDN URL builder.
341
+ - `portable-text.ts` — Portable Text detector + reference walker.
342
+ - `map.ts` — pure per-document field mapper. Pure function, no I/O.
343
+ - `index.ts` — adapter wiring + orchestration.
344
+
345
+ **Tests** (78 new tests, 129 total in the package):
346
+ - `sanity-parse.test.ts` (7) — NDJSON parser tolerance, line numbers, previews.
347
+ - `sanity-asset.test.ts` (10) — ref parser + URL builder including custom `assetBaseUrl` and dataset defaults.
348
+ - `sanity-portable-text.test.ts` (15) — detector + reference walker (markDef, inline, embedded asset).
349
+ - `sanity-map.test.ts` (24) — per-document mapping across system fields, slug, references, images, Portable Text, type maps, nested recursion.
350
+ - `sanity.test.ts` (16) — adapter-level tests against the anonymized fixture.
351
+ - `sanity-cli.test.ts` (6) — CLI integration (`list` exposure, fixture import, `--write`, `--json`, `--config`, missing-input).
352
+
353
+ **Anonymized NDJSON fixture** at `src/__tests__/fixtures/sanity-export.ndjson` — covers the long tail in a single 9-line file: pages, posts, authors, slugs, Portable Text with markDef references, an image asset doc, a draft document, a malformed asset ref, an orphan with both hard + weak broken refs, an untyped `_type`, and a shapeless line.
354
+
355
+ **Public exports** added to the main barrel:
356
+ - `sanityAdapter` — the adapter instance, pre-registered automatically.
357
+ - `SanityAdapterConfig` — the per-import config type.
358
+
359
+ **Limitations** (deliberate scope):
360
+ - Asset binaries aren't read from the tar archive — operators provide URLs via config or upload assets separately.
361
+ - No locale-aware field merging yet (Sanity has three i18n patterns; landing alongside the first migration that needs it).
362
+ - No GROQ-style projection / partial imports — use `shouldInclude` programmatically or pre-filter the NDJSON.
363
+
364
+ **Test plan summary:**
365
+ - 129 tests pass in `@actuate-media/import` (up from 51).
366
+ - TypeScript build green, type-check clean, format clean.
367
+ - Full workspace `pnpm build` + `pnpm test` green.
368
+ - CLI end-to-end smoke-tested against the fixture.
369
+
370
+ Stacked on PR #1 (`feat/phase-6-import-foundation`). PR #3
371
+ (Contentful) follows next.
372
+
373
+ - 65b90db: Phase 6, PR #4 — Strapi adapter for the content importer
374
+ framework.
375
+
376
+ Third source-specific adapter, and the first that has to do
377
+ **relational join reconstruction**. Strapi's `data-transfer`
378
+ engine emits one `.jsonl` file per content type under
379
+ `entities/`, then carries every relational join in a sidecar
380
+ `links/links.jsonl` file. The adapter walks the entities once to
381
+ seed the `(type, ref) → collection` map, then a second time to
382
+ weave the sidecar relations back onto their declared fields with
383
+ correct cardinality.
384
+
385
+ **New built-in adapter:** `strapi` — reads the directory you get
386
+ from extracting `strapi export`'s `.tar.gz` (or a single
387
+ `entities/<uid>.jsonl` file as a one-content-type fallback) and
388
+ emits Actuate-shaped `ImportedDocument`s.
389
+
390
+ **Dataset shape consumed:**
391
+
392
+ ```
393
+ <dataset-root>/
394
+ entities/<uid>.jsonl # { id, type, data } per line
395
+ assets/metadata.jsonl # asset records (URLs, mime, dims)
396
+ links/links.jsonl # cross-entity relations + i18n joins
397
+ ```
398
+
399
+ **Field semantics:**
400
+
401
+ | Source | Emitted |
402
+ | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
403
+ | `id` | `sourceId` (stringified) |
404
+ | `type` (`api::article.article`) | `sourceType` + `collection` (via `typeMap` or last-segment fallback) |
405
+ | `data.publishedAt === null` | Skipped by default |
406
+ | `data.locale !== primaryLocale` (when configured) | Skipped; non-i18n types always kept |
407
+ | `data.id` / `createdAt` / `updatedAt` / `publishedAt` / `locale` / `localizations` etc. | Stripped (configurable via `includeSystemFields`) |
408
+ | Inline single media (`{ id, url, mime, ... }`) | `{ url, sourceId, fileName, contentType, width, height, size, alternativeText, caption }` — inline data wins, manifest fills sparse fields |
409
+ | Inline multi media (array of media objects) | Element-wise array of the above |
410
+ | `links/links.jsonl` entry (`left = (this, field)`) | Woven onto `data[field]`. `oneToMany` / `manyToMany` → always an array. `oneToOne` / `manyToOne` → single object. Inline values for the same field win. |
411
+ | String field named `slug` | Lifted to top-level `slug` |
412
+ | `assets/metadata.jsonl` | Consumed for the asset map by default; emitted as documents in `assetCollection` when `importAssets: true` |
413
+
414
+ **Locale filtering:**
415
+
416
+ Strapi i18n creates a separate entity per locale, joined via the
417
+ `localizations` link. `primaryLocale` config filters to a single
418
+ locale (non-i18n types always kept). Multi-locale fan-out is
419
+ intentionally deferred — it will land once Actuate's locale
420
+ storage model is finalised.
421
+
422
+ **Per-import config:**
423
+
424
+ ```json
425
+ {
426
+ "typeMap": {
427
+ "api::article.article": "posts",
428
+ "api::author.author": "authors"
429
+ },
430
+ "primaryLocale": "en",
431
+ "publishedOnly": true,
432
+ "includeSystemFields": false,
433
+ "importAssets": false,
434
+ "assetCollection": "assets",
435
+ "ignoreTypes": []
436
+ }
437
+ ```
438
+
439
+ Defaults for `ignoreTypes`: `admin::user`, `admin::role`,
440
+ `admin::permission`, `plugin::users-permissions.user`,
441
+ `plugin::users-permissions.role`,
442
+ `plugin::users-permissions.permission`, `plugin::i18n.locale`,
443
+ `plugin::upload.file`, `plugin::upload.folder`.
444
+
445
+ **New stable warning + unresolved codes:**
446
+ - `unmapped-type` (warning) — UID not in `typeMap`; collection
447
+ derived from UID.
448
+ - `parse-error` (warning) — single line in one of the `.jsonl`
449
+ files failed to parse; the rest of the file kept going.
450
+ - `read-error` (warning) — `.jsonl` file unreadable; adapter
451
+ continued with whatever it could load.
452
+ - `asset-without-url` (warning) — `importAssets: true` saw an
453
+ asset with no file URL.
454
+ - `input-missing` (unresolved) — input path doesn't exist.
455
+ - `empty-dataset` (unresolved) — path exists but no entity
456
+ records loaded.
457
+ - `media-without-url` (unresolved) — media reference has no URL
458
+ inline AND no matching record in `assets/metadata.jsonl`.
459
+ - `unresolved-link-target` (unresolved) — sidecar link pointed
460
+ at an entity that isn't in the dataset.
461
+
462
+ **Modular implementation** under `src/adapters/strapi/`:
463
+ - `types.ts` — narrow shapes for entities, assets, links, config.
464
+ - `uid.ts` — Strapi UID parser + collection resolution.
465
+ - `loader.ts` — NDJSON parser + dataset loader. Tolerates blank
466
+ lines, CRLF, BOM, malformed lines. Accepts directory mode
467
+ (canonical layout) and single-file mode (one-content-type
468
+ fallback, including legacy `{ id, __type, ...fields }` shape).
469
+ - `asset.ts` — asset URL map + inline media detection + URL
470
+ normalization (protocol-relative → `https://`,
471
+ `mediaBaseUrl`-prefixing for relative paths).
472
+ - `links.ts` — sidecar-relation index. Partitions into the main
473
+ index, a `localizations` sub-index (filtered by default), and
474
+ an `unfielded` bucket for field-less links. Carries relation
475
+ kind for cardinality decisions.
476
+ - `map.ts` — pure per-entity mapper: system-field stripping,
477
+ inline media resolution, slug lifting, sidecar-link weaving
478
+ with cardinality.
479
+ - `index.ts` — adapter wiring + two-pass orchestration + config
480
+ validator.
481
+
482
+ **Tests** (87 new tests, 303 total in the package, up from 216):
483
+ - `strapi-uid.test.ts` (9) — last-segment derivation across api /
484
+ plugin / admin UIDs, single-segment passthrough, empty input,
485
+ typeMap precedence and warning behaviour, custom
486
+ `collectionFromUid` override.
487
+ - `strapi-loader.test.ts` (16) — NDJSON tolerance (parse errors,
488
+ CRLF, BOM, read errors, blank lines); directory mode discovery
489
+ of entities / assets / links; single-file mode (wrapped and
490
+ legacy `__type` shapes); missing-input handling.
491
+ - `strapi-asset.test.ts` (18) — media detection that rejects
492
+ bare relation stubs; URL normalization across protocol-relative,
493
+ absolute, relative + base, and bare relative; stringification
494
+ of numeric ids; placeholders for URL-less assets;
495
+ per-record metadata capture; `liftInlineMedia` base-URL
496
+ plumbing.
497
+ - `strapi-links.test.ts` (5) — key encoding; per-(source, field)
498
+ grouping; partitioning of `localizations` and field-less
499
+ links; malformed-record drop; numeric/string ref normalization.
500
+ - `strapi-map.test.ts` (15) — collection + system fields; slug
501
+ lifting; inline media (single, multi, missing-URL,
502
+ relation-stub guard); sidecar relation weaving (single,
503
+ many-to-many array, broken link unresolved, inline-wins).
504
+ - `strapi.test.ts` (19) — adapter against the dataset fixture:
505
+ totals, full home-page mapping, post → author + author →
506
+ posts weaving (with `oneToMany` array semantics), draft drop,
507
+ admin user drop, typeMap warning, orphan broken-link
508
+ surfacing, orphan media-without-url, primaryLocale filter,
509
+ `publishedOnly: false`, custom `ignoreTypes`, importAssets
510
+ emission + asset-without-url warning, missing/empty input
511
+ handling, `shouldInclude` filter, single-file mode.
512
+ - `strapi-cli.test.ts` (6) — listing exposure; fixture import
513
+ via CLI; `--write`; `--config` typeMap; `--json`; missing-input
514
+ exit code.
515
+
516
+ **Anonymized dataset fixture** at
517
+ `src/__tests__/fixtures/strapi-dataset/` — directory with
518
+ `entities/` (3 pages across 2 locales including 1 draft, 2 posts
519
+ including 1 orphan with broken link + media, 1 author, 1 snippet
520
+ for typeMap-warning coverage, 1 admin user for default-ignore
521
+ coverage), `assets/metadata.jsonl` (4 assets including one
522
+ URL-less), `links/links.jsonl` (`manyToOne` author, `oneToMany`
523
+ back-reference with array cardinality, `manyToMany` featured,
524
+ `localizations`, broken target, field-less link).
525
+
526
+ **Public exports** added to the main barrel:
527
+ - `strapiAdapter` — pre-registered automatically.
528
+ - `StrapiAdapterConfig` — per-import config type.
529
+
530
+ **Test plan summary:**
531
+ - 303 tests pass in `@actuate-media/import` (up from 216; 87 new).
532
+ - TypeScript build, type-check, format all clean.
533
+ - Full workspace `pnpm build` + `pnpm test` green.
534
+ - CLI end-to-end smoke-tested against the fixture.
535
+
536
+ Stacked on PR #3 (`feat/phase-6-import-contentful`). PR #5
537
+ (WordPress WXR XML adapter) closes Phase 6.
538
+
539
+ ## 0.2.0
540
+
541
+ ### Minor Changes
542
+
543
+ - b376dd1: Phase 6, PR #1 — content import framework + `identity` adapter.
544
+ Opens Phase 6 of the competitive gaps roadmap.
545
+
546
+ The headline pitch: every other CMS migration story is either "we
547
+ have a JSON endpoint" (i.e. write your own script) or a black-box
548
+ importer that silently drops what it can't map. Actuate ships a
549
+ small framework, an adapter-author SDK, and a CI-grade report —
550
+ three pieces every real migration needs and nobody else gives you
551
+ together.
552
+
553
+ This PR ships the foundation that subsequent adapter PRs (Sanity,
554
+ Contentful, Strapi, WordPress) build on. No source-specific adapter
555
+ lands in this PR; the `identity` adapter validates Actuate-shaped
556
+ JSON and exists primarily as the reference implementation, the
557
+ validation gate, and the CLI integration-test harness.
558
+
559
+ **New `@actuate-media/import` package** with three subpath exports:
560
+ - `.` — full public API (`runImport`, `writeImportResult`,
561
+ `formatImportSummary`, `listAdapters`, `registerAdapter`,
562
+ `identityAdapter`, all public types).
563
+ - `./adapter` — narrow adapter-author surface (`buildResult`,
564
+ `buildSummary`, `isImportedDocument` + types). Third-party adapter
565
+ packages should import from here to stay CLI-free.
566
+ - `./cli` — CLI entry, exposed for embedding in custom binaries.
567
+
568
+ **Adapter contract** (`ImportAdapter`):
569
+
570
+ ```ts
571
+ interface ImportAdapter {
572
+ readonly name: string
573
+ readonly description: string
574
+ readonly docsUrl?: string
575
+ run(options: AdapterOptions): Promise<ImportResult> | ImportResult
576
+ }
577
+ ```
578
+
579
+ Pure-function-friendly. The framework owns disk writes, not the
580
+ adapter — `--dry-run` vs `--write` semantics compose cleanly because
581
+ adapters never touch the filesystem on the write path.
582
+
583
+ **`actuate-import` CLI:**
584
+
585
+ ```text
586
+ actuate-import <command> [options]
587
+
588
+ Commands:
589
+ list Print every registered adapter.
590
+ <adapter> <input> Run the named adapter against <input>.
591
+
592
+ Options:
593
+ --out <file> Destination for --write
594
+ --write Write the result envelope to disk
595
+ --json Emit the full ImportResult JSON to stdout
596
+ --config <file> Load adapter-specific config JSON
597
+ --help Show usage
598
+
599
+ Exit codes:
600
+ 0 import clean (no unresolved fields)
601
+ 1 invalid invocation (unknown adapter, missing file, malformed config)
602
+ 2 at least one unresolved field — CI gate signal
603
+ ```
604
+
605
+ The `--write` envelope is stable and self-describing
606
+ (`{ summary, documents, warnings, unresolved }`) — downstream tooling
607
+ can rely on the `documents` envelope even for a single-document
608
+ import.
609
+
610
+ **Built-in `identity` adapter:**
611
+ - Reads Actuate-shaped JSON (single doc, array, or `{ documents }`
612
+ envelope) and emits it unchanged after structural validation.
613
+ - Three roles: pipeline reference for adapter authors, validation
614
+ gate for hand-curated migration JSON, test harness for the
615
+ framework's own CLI integration tests.
616
+ - Malformed inputs surface as `invalid-json` / `invalid-shape`
617
+ unresolved fields rather than crashing — operators can fix the
618
+ file and re-run.
619
+
620
+ **Public types** exported from the main entry:
621
+ `ImportedDocument`, `ImportResult`, `ImportSummary`, `ImportWarning`,
622
+ `UnresolvedField`, `AdapterOptions`, `ImportInvocation`,
623
+ `ImportAdapter`, `UnknownAdapterError`.
624
+
625
+ **Runtime adapter registration:**
626
+
627
+ ```ts
628
+ import { registerAdapter } from '@actuate-media/import'
629
+ import { prismicAdapter } from '@my-org/actuate-import-prismic'
630
+
631
+ registerAdapter(prismicAdapter)
632
+ ```
633
+
634
+ One line. The adapter shows up in `actuate-import list` and routes
635
+ correctly. Ship a custom importer for any source — Builder.io,
636
+ Hygraph, Webflow CMS, your homegrown spreadsheet-CMS — without
637
+ forking Actuate.
638
+
639
+ **New tests** (58 total in this package):
640
+ - `adapter.test.ts` — `buildSummary` / `buildResult` /
641
+ `isImportedDocument` helpers + a compile-time witness that the
642
+ `./adapter` subpath re-exports the full author-facing type surface
643
+ (12 tests).
644
+ - `formatter.test.ts` — clean/warning/unresolved rendering (5 tests).
645
+ - `identity.test.ts` — accepts single / array / envelope shapes;
646
+ invalid JSON; per-index malformed documents; `shouldInclude`;
647
+ summary fields (7 tests).
648
+ - `registry.test.ts` — built-ins, registration, re-registration,
649
+ unregistration (7 tests).
650
+ - `runner.test.ts` — adapter routing, unknown-adapter error,
651
+ config/filter forwarding, async adapter support, envelope shape
652
+ on `writeImportResult` (6 tests).
653
+ - `cli.test.ts` — list, help, dry-run clean, dry-run with
654
+ unresolved, missing file, unknown adapter, `--json`, `--write`,
655
+ default `--out`, partial-import write, `--config` error paths,
656
+ positional-arg validation, `--out` / `--config` missing-value
657
+ validation, unknown-flag rejection, non-object `--config` JSON
658
+ rejection (21 tests).
659
+
660
+ **Reference docs:**
661
+ - Public-facing intro: [`docs/import-intro.md`](../docs/import-intro.md) —
662
+ 60-second tour with comparison matrix vs Sanity / Contentful /
663
+ Strapi-export / custom-script approaches.
664
+ - Technical reference: [`docs/import.md`](../docs/import.md) — full
665
+ type catalogue, CLI semantics, author guidelines, composition
666
+ patterns with `actuate-component-blocks migrate`.
667
+
668
+ **Known limits** (deliberate scope for the foundation PR):
669
+ - No source-specific adapters yet — `sanity` ships in PR #2.
670
+ - `--config` accepts JSON only (no JSONC / JS modules / env interp).
671
+ - Adapters return the full result in memory (no streaming).
672
+ - File-input adapters only — HTTP-source adapters land alongside
673
+ the first one that needs them.
674
+ - No re-import dedupe — operators today import into an empty
675
+ Actuate instance.
676
+
677
+ **Test plan summary:**
678
+ - 51 unit + integration tests in `@actuate-media/import`.
679
+ - Workspace `pnpm test` continues to pass (no other packages
680
+ touched).
681
+ - TypeScript build green across the workspace.
682
+
683
+ PR #1 of N in Phase 6. Stacked PRs follow: Sanity adapter, then
684
+ Contentful / Strapi / WordPress in independent PRs (no inter-PR
685
+ dependencies — every adapter PR rebases cleanly off `main` once #1
686
+ lands).