@seedprotocol/mapping 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +22 -3
  3. package/dist/applyMapping.d.ts +4 -2
  4. package/dist/applyMapping.d.ts.map +1 -1
  5. package/dist/autoMap-Dh9SiWhT.js +631 -0
  6. package/dist/autoMap-Dh9SiWhT.js.map +1 -0
  7. package/dist/edgeMapping.d.ts +21 -0
  8. package/dist/edgeMapping.d.ts.map +1 -0
  9. package/dist/index.d.ts +2 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +34 -34
  12. package/dist/react/FieldMapper.d.ts +12 -2
  13. package/dist/react/FieldMapper.d.ts.map +1 -1
  14. package/dist/react/FieldMapperWires.d.ts.map +1 -1
  15. package/dist/react/PropertyRows.d.ts +4 -2
  16. package/dist/react/PropertyRows.d.ts.map +1 -1
  17. package/dist/react/SourceRows.d.ts +4 -2
  18. package/dist/react/SourceRows.d.ts.map +1 -1
  19. package/dist/react/fieldMapperCore.d.ts +3 -1
  20. package/dist/react/fieldMapperCore.d.ts.map +1 -1
  21. package/dist/react/fieldMapperSlots.d.ts +1 -1
  22. package/dist/react/fieldMapperSlots.d.ts.map +1 -1
  23. package/dist/react/fieldMapperTheme.d.ts +1 -1
  24. package/dist/react/fieldMapperTheme.d.ts.map +1 -1
  25. package/dist/react/fieldMapperTransforms.d.ts +7 -0
  26. package/dist/react/fieldMapperTransforms.d.ts.map +1 -0
  27. package/dist/react/fieldMapperTypes.d.ts +11 -1
  28. package/dist/react/fieldMapperTypes.d.ts.map +1 -1
  29. package/dist/react/useFieldMapper.d.ts.map +1 -1
  30. package/dist/react.d.ts +2 -1
  31. package/dist/react.d.ts.map +1 -1
  32. package/dist/react.js +741 -658
  33. package/dist/react.js.map +1 -1
  34. package/dist/resolvedSources.d.ts.map +1 -1
  35. package/dist/types.d.ts +20 -3
  36. package/dist/types.d.ts.map +1 -1
  37. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.0
4
+
5
+ - `ResolveJob` adds `'derive' | 'assemble'`. `FieldMapping.sourceId` is optional so a derive-only edge is legal.
6
+ - Persist `derive?: { from: string; fallback?: boolean }` and `assemble?: { blocks: string[] }` on the edge. Mutators pass them through, including copy + `derive` fallback. Empty `sourceId` is omitted.
7
+ - Coverage and `data-state` treat source-less `resolve: 'derive'` as mapped. `resolve: 'assemble'` does not flag `needs extract`.
8
+ - `useFieldMapper.setAssembleBlocks` / `setDerive`. Clearing a source on a derive edge keeps a derive-only mapping.
9
+ - `FieldMapper` `transformOptions` and `renderRowExpansion`. Default transform list still copy / extract / file / lookup; **assemble** is offered on `Html` targets; the current resolve is always listed.
10
+ - Sync and async `applyMapping` skip derive/assemble (host apply stays host-owned). Package does not slugify or assemble HTML.
11
+ - `resolvedSourceId` only suffixes `extract` / `file`.
12
+ - Package `autoMap` is unchanged: it does not inject derive-only slug or default html to assemble.
13
+
3
14
  ## 0.7.0
4
15
 
5
16
  - Relation lookup is an edge-local stored intent: `FieldMapping.lookup.entries` as `{ value, ref }[]`. `ref` is opaque (`seedLocalId` or `seedUid`). Empty entries are a valid unassigned map.
package/README.md CHANGED
@@ -14,6 +14,9 @@ Mappings are an edge list: one source may fan out to multiple properties (e.g. R
14
14
  source may map to it. `resolve: 'extract' | 'file'` is applied by the host callback.
15
15
  `resolve: 'lookup'` is a stored string → ref table on the edge — the package never
16
16
  fetches, runs Readability, or loads Seed Identity items.
17
+ `resolve: 'derive' | 'assemble'` are host-applied transforms persisted on the edge
18
+ (`derive.from` is a property name; `assemble.blocks` is a host-owned string list).
19
+ A derive-only edge may omit `sourceId`. Sync and async `applyMapping` skip these jobs.
17
20
 
18
21
  ## Install
19
22
 
@@ -199,6 +202,14 @@ import { FieldMapper, useFieldMapper } from '@seedprotocol/mapping/react'
199
202
  onChange={row.onLookupChange}
200
203
  />
201
204
  )}
205
+ renderRowExpansion={(row) =>
206
+ row.mapping?.resolve === 'assemble' ? <AssembleStack row={row} /> : null
207
+ }
208
+ transformOptions={(row, defaults) =>
209
+ row.target?.name === 'slug'
210
+ ? [...defaults, { value: 'derive', label: 'from title' }]
211
+ : defaults
212
+ }
202
213
  />
203
214
 
204
215
  // Rows — source-keyed
@@ -234,7 +245,13 @@ Pass `renderLookup` to paint the host picker (Identity, etc.) on that row. Witho
234
245
  `lookups` / `onLookupsChange` are deprecated — persist `lookup.entries` on the edge.
235
246
 
236
247
  Row and JSON previews match sync `applyMapping` output. Lookup hits appear in the
237
- bag; only extract/file stay under `_pendingResolve`. JSON sits behind a disclosure.
248
+ bag; extract/file/derive/assemble stay under `_pendingResolve`. JSON sits behind a disclosure.
249
+
250
+ `derive` and `assemble` are first-class resolve words. The package persists the
251
+ keys and treats a source-less derive edge as mapped. Hosts own apply (`slugify`,
252
+ named-block HTML) and product labels (e.g. **from title** via `transformOptions`).
253
+ Do not invent a leftover source named “from title”. Package `autoMap` does not
254
+ default html to assemble.
238
255
 
239
256
  **Theming**
240
257
 
@@ -249,6 +266,8 @@ bag; only extract/file stay under `_pendingResolve`. JSON sits behind a disclosu
249
266
  | `slots` | Toggle chrome: `autoMap`, `filter`, `inspector`, `preview` (`'row' \| 'json' \| 'both' \| false`), `lookups` (`'row' \| 'section' \| false`; rows layout defaults to `'row'`, wires to `'section'`) |
250
267
  | `renderRowAccessory` | Optional `(row: FieldMapperRow) => ReactNode` for host chrome (e.g. extract/file **Preview**) in `.fm-row-accessory`. Unrelated to `slots.preview`. Package does not fetch. |
251
268
  | `renderLookup` | Optional `(row: FieldMapperLookupRow) => ReactNode` for host lookup chrome on `resolve: 'lookup'` rows. Package does not fetch or list identities. |
269
+ | `renderRowExpansion` | Optional `(row: FieldMapperRow) => ReactNode` under the row (e.g. host assemble stack) in `.fm-row-expansion`. |
270
+ | `transformOptions` | Optional `(row, defaults) => options` to add or relabel transforms (e.g. **from title** on slug). Defaults: copy / extract / file / lookup, plus assemble on `Html` targets. |
252
271
  | `showPreview` | **Deprecated** — prefer `slots.preview` |
253
272
  | `connectionColors` | **Deprecated** optional stroke palette for wires; prefer `--sfm-map-*` / `--fm-map-*` / `--map-*` |
254
273
  | `layout="wires"` | **Deprecated** — prefer `layout="rows"` (now the default) |
@@ -260,7 +279,7 @@ bag; only extract/file stay under `_pendingResolve`. JSON sits behind a disclosu
260
279
  - Wires: mapped wells expose `data-mapping-index` / `data-pair={index % 8}` (kept for host CSS); pending `.active` only on the selected source.
261
280
  - Rows: `data-state="empty|mapped|needsResolve|needsLookup|conflict"`, `data-property-name`, `data-resolve`, `data-required`, `data-source-kind`.
262
281
 
263
- Sync `applyMapping` preview lists pending **extract/file** edges under `_pendingResolve`. Lookup refs from stored entries appear in the bag.
282
+ Sync `applyMapping` preview lists pending **extract/file/derive/assemble** edges under `_pendingResolve`. Lookup refs from stored entries appear in the bag.
264
283
 
265
284
  See [FIELD_MAPPER_REDESIGN.md](../../docs/FIELD_MAPPER_REDESIGN.md) for the row-layout design study (Phases 1–5 shipped). PermaPress: [FIELD_MAPPER_PERMAPRESS_HANDOFF.md](../../docs/FIELD_MAPPER_PERMAPRESS_HANDOFF.md).
266
285
 
@@ -268,7 +287,7 @@ See [FIELD_MAPPER_REDESIGN.md](../../docs/FIELD_MAPPER_REDESIGN.md) for the row-
268
287
 
269
288
  | Type | Package | Meaning |
270
289
  |------|---------|---------|
271
- | `FieldMapping` / `MappingDocument` | `@seedprotocol/mapping` | Source id → **model property name** (1→N edges; optional `resolve`; optional `lookup.entries`) |
290
+ | `FieldMapping` / `MappingDocument` | `@seedprotocol/mapping` | Source id (optional) → **model property name** (1→N edges; optional `resolve`; optional `lookup.entries` / `derive` / `assemble`) |
272
291
  | `FeedFieldManifest` | `@seedprotocol/sdk` | Property/key → **role** (`image` / `audio` / `video` / `file` / `html` / `text`) for display |
273
292
 
274
293
  Compose them: map + resolve into a plain item, then optionally normalize roles for media/HTML display. Storage stays `Image` / `File` schema types — no separate Audio/Video dataTypes.
@@ -6,7 +6,8 @@ export declare function coerceValue(rawValue: string, dataType: string): unknown
6
6
  /**
7
7
  * Apply field mappings to produce a property bag for createItem / publish.
8
8
  * Missing sources or unknown target properties are skipped (no throw).
9
- * `resolve: 'extract' | 'file'` edges are skipped — use `applyMappingAsync`.
9
+ * `resolve: 'extract' | 'file' | 'derive' | 'assemble'` edges are skipped.
10
+ * Use `applyMappingAsync` for extract/file. Derive/assemble stay host-applied.
10
11
  * `resolve: 'lookup'` is applied from stored entries (or deprecated document lookups).
11
12
  */
12
13
  export declare function applyMapping(sources: SourceNode[], mappings: FieldMapping[], targets: TargetProperty[], options?: {
@@ -23,7 +24,8 @@ export type ApplyMappingAsyncOptions = {
23
24
  };
24
25
  /**
25
26
  * Async apply: copy+coerce plain edges; apply lookup entries; for extract/file
26
- * call the host callback then coerce. Partial success — failed resolve edges
27
+ * call the host callback then coerce. `derive` / `assemble` are skipped —
28
+ * host apply stays host-owned. Partial success — failed resolve edges
27
29
  * are listed in `errors` and omitted from `properties`.
28
30
  */
29
31
  export declare function applyMappingAsync(sources: SourceNode[], mappings: FieldMapping[], targets: TargetProperty[], options?: ApplyMappingAsyncOptions): Promise<ApplyMappingAsyncResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"applyMapping.d.ts","sourceRoot":"","sources":["../src/applyMapping.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,uBAAuB,EACvB,YAAY,EACZ,cAAc,EACd,WAAW,EACX,eAAe,EAEf,UAAU,EACV,cAAc,EAEf,MAAM,SAAS,CAAA;AAEhB;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAuBvE;AA8DD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,UAAU,EAAE,EACrB,QAAQ,EAAE,YAAY,EAAE,EACxB,OAAO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