Named import mappings: wire defineMapping into the import path (#2611)#2629
Merged
Conversation
… into the import path Closes the consumer gap behind #2611: a registered `mapping` artifact (defineMapping / stack mappings:) is now resolvable by name at import. - rest: `mappingName` on POST /data/:object/import (sync + async job path via the shared prepareImportRequest). Resolution via getMetaItem ('mapping'); 404 MAPPING_NOT_FOUND, 400 MAPPING_TARGET_MISMATCH / MAPPING_FORMAT_MISMATCH / CONFLICTING_MAPPING (mutually exclusive with the inline rename — one mapping source of truth per request). The artifact's mode/upsertKey apply as writeMode/matchFields DEFAULTS (explicit request values win). - transforms (import-mapping.ts, unit-tested): none/constant/map/split/ join implemented; lookup passes the raw value through to the import path's existing reference resolution (no second dialect); javascript is REJECTED with 400 UNSUPPORTED_TRANSFORM — no server-side sandbox, and a silently skipped transform would corrupt data (Prime Directive #10). Artifact output is a strict projection (only mapped targets reach the write path); the inline mapping keeps its passthrough rename semantics — inline = one-off wizard rename, artifact = reusable governed ETL. - spec: defineStack cross-reference validation now rejects a mapping whose targetObject is undefined and any javascript transform at BUILD time (Prime Directive #12: fail at the producer). Tests: 7 transform unit tests + 6 end-to-end route tests (real engine/ protocol/registry; happy path proves artifact map→label→code coercion composition, lookup name→id, strict projection, artifact upsert defaults, and every error code) + 3 build-lint tests. rest 211 · spec 6695 — green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G6pPpRszk9cD3SxcKNFMWs
- src/data/mappings/index.ts — showcase_inquiry_feed: the marketing-CSV → inquiry mapping (rename + map transform for channel codes), with artifact-declared idempotent upsert on email. Wired via stack mappings:. - STACK_COLLECTION_COVERAGE.mappings: waived → demonstrated (the consumer landed in the previous commit). - gap-fill tests assert the wiring AND target liveness: every mapped target and upsertKey must be a real field of the target object — a typo'd target would silently import into nowhere. - Data tour documents the named-mapping workflow; changeset added. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G6pPpRszk9cD3SxcKNFMWs
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 3 package(s): 94 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
…passed) With the import consumer landed, mapping now passes all three admission criteria (independent lifecycle · governable · real consumer), so it graduates from a bare stack collection to a registry kind (26 → 27): - MetadataTypeSchema + DEFAULT_METADATA_TYPE_REGISTRY entry (domain data, allowRuntimeCreate: true so the import wizard can SAVE a hand-built mapping as a named artifact; packaged mappings stay locked like every artifact-backed item; *.mapping.ts file pattern). - metadata-type-schemas: MappingSchema wired → Studio's zero-code metadata admin auto-renders list/edit forms for mappings, and /api/v1/meta/types/mapping serves the JSON Schema (no Studio code). - metadata-create-seeds: 'New Import Mapping' template so runtime-create starts from a valid artifact. - metadata-core lockstep enum; showcase KIND_COVERAGE gains the mapping kind entry (and drops the now-redundant stack-collection row); reference docs regenerated. spec 6696 · metadata-core 80 · objectql 773 · rest 211 · showcase verify — green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G6pPpRszk9cD3SxcKNFMWs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes #2611.
defineMapping/ stackmappings:artifacts were registered but never consumed — the classic enterprise capability (recurring feeds, packaged migration kits, programmatic imports) existed only as inert metadata. Two commits:feat(rest,spec)— the consumer.POST /data/:object/import(sync + async job path, sharedprepareImportRequest) acceptsmappingName, resolving the registered artifact viagetMetaItem('mapping')and applying itsfieldMappingpipeline as a strict projection before the existing coercion/reference resolution.none/constant/map/split/joinimplemented;lookuppasses through to the import path's built-in name→id resolution (no second dialect);javascript→ 400UNSUPPORTED_TRANSFORM(no server-side sandbox — a silently skipped transform would corrupt data).mode/upsertKeyapply aswriteMode/matchFieldsdefaults; explicit request values win.mappingNameis mutually exclusive with the inline rename (400 CONFLICTING_MAPPING) — one mapping source of truth per request; the inline{column: field}rename keeps its one-off wizard semantics (unmapped passthrough), the artifact is the governed ETL form (strict projection).MAPPING_NOT_FOUND(404),MAPPING_TARGET_MISMATCH,MAPPING_FORMAT_MISMATCH/MAPPING_FORMAT_UNSUPPORTED,CONFLICTING_MAPPING,UNSUPPORTED_TRANSFORM.defineStackcross-reference validation rejects mappings targeting undefined objects and anyjavascripttransform at build time.feat(showcase)— the demo + waiver flip.showcase_inquiry_feedmaps a marketing tool's CSV (Full Name/Channel/…) ontoshowcase_inquirywith amaptransform for channel codes and artifact-declared idempotent upsert on email.STACK_COLLECTION_COVERAGE.mappingsflips waived → demonstrated; gap-fill tests assert wiring and target liveness (every mapped target/upsertKey must be a real field). Data tour documents the workflow.Why
Enterprise deployments live on recurring, headless imports (nightly ERP feeds, bank statements, partner files) and packaged migration kits — both need the mapping to be a governed, versioned, package-shippable artifact, not wizard state. This lands the missing consumer, and the capability now passes the ADR-0088 admission test it previously failed.
Verification
import-mapping.test.ts). Integration: 6 end-to-end route tests against the real engine/protocol/registry — the happy path proves artifactmap→ select-label coercion composition, lookup name→id, strict projection, artifact upsert defaults, plus every error code. Build lint: 3 newdefineStacktests. Suites: rest 211, spec 6695, showcase verify 55 — green.objectstack dev): imported a marketing CSV withmappingName=showcase_inquiry_feed→created: 2; re-imported the same file →updated: 2(idempotent upsert from artifact defaults); unknown mapping → 404; stored rows showChannel: "Webform"→source: "website"and"Partner Referral"→"referral".🤖 Generated with Claude Code
https://claude.ai/code/session_01G6pPpRszk9cD3SxcKNFMWs
Generated by Claude Code