@kumwe/studio-core 0.1.0-alpha.8 → 0.1.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -3
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/dist/binding-projection.d.ts +47 -0
- package/dist/binding-projection.d.ts.map +1 -0
- package/dist/binding-projection.js +253 -0
- package/dist/binding-projection.js.map +1 -0
- package/dist/contributions.d.ts +30 -2
- package/dist/contributions.d.ts.map +1 -1
- package/dist/contributions.js +150 -17
- package/dist/contributions.js.map +1 -1
- package/dist/extension-sdk.d.ts +9 -4
- package/dist/extension-sdk.d.ts.map +1 -1
- package/dist/extension-sdk.js +87 -15
- package/dist/extension-sdk.js.map +1 -1
- package/dist/history.d.ts +10 -1
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +18 -0
- package/dist/history.js.map +1 -1
- package/dist/host-session.d.ts +74 -0
- package/dist/host-session.d.ts.map +1 -0
- package/dist/host-session.js +713 -0
- package/dist/host-session.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/layout.d.ts +66 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +240 -0
- package/dist/layout.js.map +1 -0
- package/dist/production-values.d.ts +12 -0
- package/dist/production-values.d.ts.map +1 -0
- package/dist/production-values.js +224 -0
- package/dist/production-values.js.map +1 -0
- package/dist/production.d.ts +86 -0
- package/dist/production.d.ts.map +1 -0
- package/dist/production.js +811 -0
- package/dist/production.js.map +1 -0
- package/dist/session.d.ts +8 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +15 -2
- package/dist/session.js.map +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +52 -6
- package/dist/validation.js.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -15,16 +15,72 @@ The implemented surface covers:
|
|
|
15
15
|
- `applyEntryCommand` — the locale-guarded `set-field-value` reducer for entries;
|
|
16
16
|
- `StudioSession` — bounded history behind fail-closed session guards (read-only state, session
|
|
17
17
|
generation, expected revision), dirty tracking, and a validated selection model;
|
|
18
|
-
- `
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
- `openStudioSession` — capability-negotiated Blueprint loading and a headless host-session handle for
|
|
19
|
+
serialized optimistic saves, raw optional recovery-port access, read-only model `list`/`get`, bounded
|
|
20
|
+
resource search, stale-generation invalidation, and local idempotent disposal;
|
|
21
|
+
- `projectBlueprintFieldBindings` — an immutable exact-model projection of compatible block-port field
|
|
22
|
+
candidates, declared authoring controls and stable invalid-binding diagnostics;
|
|
23
|
+
- `ContributionRuntime` — owner-aware, transactional, schema-validated activation of block,
|
|
24
|
+
pattern, design-vocabulary, migration, inspector, and field-adapter payloads into kind-scoped
|
|
25
|
+
immutable generations, with disable, reactivate, trust-revocation, stale-generation refusal, and
|
|
26
|
+
inspectable unresolved contributions;
|
|
21
27
|
- `validateBlueprint` and `BlockRegistry` — schema, limit, lock, and registry validation with
|
|
22
28
|
stable diagnostics;
|
|
23
29
|
- `canonicalStringify` / `canonicalUtf8Bytes` — the canonical cross-language serialization form
|
|
24
30
|
used for checksums.
|
|
31
|
+
- `createCoreLayoutBlockDefinitions` / `resolveCoreLayoutIntent` — first-party section, stack, grid,
|
|
32
|
+
and columns definitions plus theme-validated responsive intent resolution, with no DOM or stored
|
|
33
|
+
CSS;
|
|
34
|
+
- `createCoreProductionBlockDefinitions` / `createCoreProductionPatterns` — the standalone 45-block
|
|
35
|
+
production catalog and ten portable starter compositions, including media, rich content,
|
|
36
|
+
progressive composites including dialogs, popovers, and notices, data display, and
|
|
37
|
+
host-authoritative resource/query projections;
|
|
38
|
+
- `coreProductionInitialProperties` — schema-valid defaults used by the Studio insertion path for
|
|
39
|
+
every first-party type;
|
|
40
|
+
- `parseStudioPresentationIntent` — the closed, CSS-free visual capability contract shared by all
|
|
41
|
+
first-party inspector surfaces and renderers;
|
|
25
42
|
- `compileStudioPropertySchema` / `assertStudioPropertySchema` — eval-free admission and validation
|
|
26
43
|
for the closed, local-only `studio.profile/schema-property` surface, with stable
|
|
27
44
|
`StudioSchemaProfileError` codes and schema pointers.
|
|
28
45
|
|
|
29
46
|
The package has no DOM dependency. Web Components, Flutter clients, command-line tools, and server
|
|
30
47
|
adapters can therefore share the same command and validation semantics through the protocol.
|
|
48
|
+
|
|
49
|
+
## Blueprint host-session composition
|
|
50
|
+
|
|
51
|
+
`openStudioSession(hostAdapter, options)` consumes a complete, host-resolved `StudioConfiguration` from
|
|
52
|
+
`OpenStudioSessionOptions`. Its injected `StudioHostSessionIdentifierFactories` provide deterministic
|
|
53
|
+
`requestId(operationId)` and `idempotencyKey(operationId)` values. Opening requires
|
|
54
|
+
`mode: blueprint`, `composite: single`, either session state, and the configured Blueprint reference;
|
|
55
|
+
it passes the resolved Blueprint/read-only mode, session generation, resource context, locale,
|
|
56
|
+
protocol, and history limit through the headless lifecycle. It does not perform the host handshake,
|
|
57
|
+
automatically load model/theme dependencies, fabricate an artifact for model/content/hybrid
|
|
58
|
+
configuration, or provide a transport.
|
|
59
|
+
|
|
60
|
+
The returned handle serializes saves against the latest accepted host revision and coalesces matching
|
|
61
|
+
concurrent intents. An exact retry after failure retains its idempotency key. If the document changes
|
|
62
|
+
while a snapshot is saving, the success advances the accepted revision but the newer state remains
|
|
63
|
+
dirty. Every current, undo, and redo snapshot carries that accepted revision without a local state-version
|
|
64
|
+
change, so later history and exact preview staging use one coherent base. Conflicts and other refusals
|
|
65
|
+
preserve the document, history, selection, and saved baseline.
|
|
66
|
+
|
|
67
|
+
`StudioHostSessionHandle.recovery` is a `StudioHostSessionRecovery` with direct `store`, `load`, and
|
|
68
|
+
`discard` calls when the optional port is present, and is `undefined` otherwise. The core does not
|
|
69
|
+
synthesize or reconcile recovery envelopes. A
|
|
70
|
+
`studio.host/stale-session-generation` diagnostic invalidates the complete handle. `dispose()` is
|
|
71
|
+
local and idempotent and does not imply host teardown or preview cleanup. See
|
|
72
|
+
[ADR 0020](../../docs/decisions/0020-blueprint-host-session-composition.md) for the deliberate scope.
|
|
73
|
+
|
|
74
|
+
`StudioHostSessionHandle.models` is present only when the negotiated model port and adapter both implement
|
|
75
|
+
`list` and `get`. Results are canonical-schema validated, exact-coordinate checked and detached before they
|
|
76
|
+
leave the boundary; stale generation invalidates the whole handle. The surface is deliberately read-only.
|
|
77
|
+
Pass an authorized active model to `projectBlueprintFieldBindings(blueprint, model, definitions)` to derive
|
|
78
|
+
portable candidates and diagnostics without changing any input. See
|
|
79
|
+
[ADR 0024](../../docs/decisions/0024-read-only-model-binding-projection.md).
|
|
80
|
+
|
|
81
|
+
`StudioHostSessionHandle.resources` is present only when the negotiated resource port advertises
|
|
82
|
+
`studio.operation/resource.search` and the adapter implements it. `search` validates and clones bounded
|
|
83
|
+
queries before allocating a request, then accepts only detached pages whose stable, unique hit IDs and
|
|
84
|
+
qualified message references match the requested resource type. Malformed adapter output becomes a safe
|
|
85
|
+
`studio.host/unexpected-resource-result` failure. This is a read-only discovery surface: hosts still own
|
|
86
|
+
authorization and resolution, and first-party dynamic resource/query bindings remain read-only in Studio.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
<!-- Generated by scripts/generate-third-party-notices.mjs. Do not edit by hand. -->
|
|
4
|
+
|
|
5
|
+
Package: `@kumwe/studio-core`
|
|
6
|
+
|
|
7
|
+
Production closure SHA-256: `4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945`
|
|
8
|
+
|
|
9
|
+
This package has no third-party runtime dependencies.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { BlockDefinition, BlueprintDocument, ContentFieldKind, ContentModelDocument, FieldBinding, FieldDefinition, LocalName, LockedArtifactReference, MessageReference, QualifiedName, StudioDiagnostic } from '@kumwe/studio-protocol';
|
|
2
|
+
/** The stable outcomes a binding port can expose to any authoring shell. */
|
|
3
|
+
export type FieldBindingProjectionStatus = 'invalid' | 'non-field-source' | 'resolved' | 'unbound';
|
|
4
|
+
/** One model field that can be bound to one exact block port. */
|
|
5
|
+
export interface FieldBindingCandidate {
|
|
6
|
+
readonly cardinality: FieldDefinition['cardinality'];
|
|
7
|
+
readonly control?: QualifiedName;
|
|
8
|
+
readonly fieldPath: readonly LocalName[];
|
|
9
|
+
readonly itemKind?: Exclude<ContentFieldKind, 'collection'>;
|
|
10
|
+
readonly kind: ContentFieldKind;
|
|
11
|
+
readonly label: MessageReference;
|
|
12
|
+
}
|
|
13
|
+
/** Deterministic projection of one declared or preserved node binding port. */
|
|
14
|
+
export interface FieldBindingPortProjection {
|
|
15
|
+
readonly binding?: FieldBinding;
|
|
16
|
+
readonly boundFieldPath?: readonly LocalName[];
|
|
17
|
+
readonly candidates: readonly FieldBindingCandidate[];
|
|
18
|
+
readonly multiple?: boolean;
|
|
19
|
+
readonly port: LocalName;
|
|
20
|
+
readonly required?: boolean;
|
|
21
|
+
readonly status: FieldBindingProjectionStatus;
|
|
22
|
+
readonly valueType?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Deterministic projection of all binding affordances on one Blueprint node. */
|
|
25
|
+
export interface NodeFieldBindingProjection {
|
|
26
|
+
readonly nodeId: string;
|
|
27
|
+
readonly ports: readonly FieldBindingPortProjection[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Read-only, language-neutral view of a Blueprint's bindings against one exact
|
|
31
|
+
* host-projected model revision.
|
|
32
|
+
*/
|
|
33
|
+
export interface BlueprintFieldBindingProjection {
|
|
34
|
+
readonly diagnostics: readonly StudioDiagnostic[];
|
|
35
|
+
readonly model: LockedArtifactReference;
|
|
36
|
+
readonly nodes: readonly NodeFieldBindingProjection[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Projects the active model into field-binding affordances and diagnostics.
|
|
40
|
+
*
|
|
41
|
+
* The function never changes a model, Blueprint, block definition, workflow,
|
|
42
|
+
* translation, or permission value. It accepts only already-authorized model
|
|
43
|
+
* projections and returns detached JSON-compatible snapshots. Field IDs, not
|
|
44
|
+
* labels or storage names, are the only binding coordinates.
|
|
45
|
+
*/
|
|
46
|
+
export declare function projectBlueprintFieldBindings(blueprint: BlueprintDocument, model: ContentModelDocument, definitions: readonly BlockDefinition[]): BlueprintFieldBindingProjection;
|
|
47
|
+
//# sourceMappingURL=binding-projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding-projection.d.ts","sourceRoot":"","sources":["../src/binding-projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAEf,iBAAiB,EAEjB,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EAEf,SAAS,EACT,uBAAuB,EACvB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAGhC,4EAA4E;AAC5E,MAAM,MAAM,4BAA4B,GAAG,SAAS,GAAG,kBAAkB,GAAG,UAAU,GAAG,SAAS,CAAC;AAEnG,iEAAiE;AACjE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;IACrD,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,SAAS,SAAS,EAAE,CAAC;IACzC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;IAC5D,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;CAClC;AAED,+EAA+E;AAC/E,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC/C,QAAQ,CAAC,UAAU,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,4BAA4B,CAAC;IAC9C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,iFAAiF;AACjF,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,0BAA0B,EAAE,CAAC;CACvD;AAED;;;GAGG;AACH,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAClD,QAAQ,CAAC,KAAK,EAAE,uBAAuB,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,SAAS,0BAA0B,EAAE,CAAC;CACvD;AAgBD;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,iBAAiB,EAC5B,KAAK,EAAE,oBAAoB,EAC3B,WAAW,EAAE,SAAS,eAAe,EAAE,GACtC,+BAA+B,CA6BjC"}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { cloneContractValue } from './clone.js';
|
|
2
|
+
/**
|
|
3
|
+
* Projects the active model into field-binding affordances and diagnostics.
|
|
4
|
+
*
|
|
5
|
+
* The function never changes a model, Blueprint, block definition, workflow,
|
|
6
|
+
* translation, or permission value. It accepts only already-authorized model
|
|
7
|
+
* projections and returns detached JSON-compatible snapshots. Field IDs, not
|
|
8
|
+
* labels or storage names, are the only binding coordinates.
|
|
9
|
+
*/
|
|
10
|
+
export function projectBlueprintFieldBindings(blueprint, model, definitions) {
|
|
11
|
+
const documentSnapshot = cloneContractValue(blueprint);
|
|
12
|
+
const modelSnapshot = cloneContractValue(model);
|
|
13
|
+
const definitionSnapshots = cloneContractValue(definitions);
|
|
14
|
+
const diagnostics = [];
|
|
15
|
+
const modelReference = cloneContractValue(documentSnapshot.model);
|
|
16
|
+
const modelCompatible = appendModelCoordinateDiagnostics(documentSnapshot, modelSnapshot, diagnostics);
|
|
17
|
+
const indexedDefinitions = new Map();
|
|
18
|
+
for (const definition of definitionSnapshots) {
|
|
19
|
+
indexedDefinitions.set(blockKey(definition.type, definition.version), definition);
|
|
20
|
+
}
|
|
21
|
+
const context = {
|
|
22
|
+
blueprintId: documentSnapshot.id,
|
|
23
|
+
definitions: indexedDefinitions,
|
|
24
|
+
diagnostics,
|
|
25
|
+
fields: modelCompatible ? flattenModelFields(modelSnapshot.fields) : [],
|
|
26
|
+
modelCompatible,
|
|
27
|
+
modelReference,
|
|
28
|
+
};
|
|
29
|
+
const nodes = [];
|
|
30
|
+
visitNodes(documentSnapshot.roots, (node) => {
|
|
31
|
+
nodes.push(projectNode(node, context));
|
|
32
|
+
});
|
|
33
|
+
return cloneContractValue({ diagnostics, model: modelReference, nodes });
|
|
34
|
+
}
|
|
35
|
+
function appendModelCoordinateDiagnostics(blueprint, model, diagnostics) {
|
|
36
|
+
let compatible = true;
|
|
37
|
+
for (const mismatch of [
|
|
38
|
+
{
|
|
39
|
+
actual: model.id,
|
|
40
|
+
code: 'studio.binding/model-id-mismatch',
|
|
41
|
+
expected: blueprint.model.id,
|
|
42
|
+
member: 'id',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
actual: model.version,
|
|
46
|
+
code: 'studio.binding/model-version-mismatch',
|
|
47
|
+
expected: blueprint.model.version,
|
|
48
|
+
member: 'version',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
actual: model.revision,
|
|
52
|
+
code: 'studio.binding/model-revision-mismatch',
|
|
53
|
+
expected: blueprint.model.revision,
|
|
54
|
+
member: 'revision',
|
|
55
|
+
},
|
|
56
|
+
]) {
|
|
57
|
+
if (mismatch.actual === mismatch.expected) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
compatible = false;
|
|
61
|
+
diagnostics.push(diagnostic(mismatch.code, `The projected model ${mismatch.member} {actual} does not match the Blueprint lock {expected}.`, 'error', {
|
|
62
|
+
actual: mismatch.actual,
|
|
63
|
+
expected: mismatch.expected,
|
|
64
|
+
member: mismatch.member,
|
|
65
|
+
}, { artifactId: blueprint.id }));
|
|
66
|
+
}
|
|
67
|
+
return compatible;
|
|
68
|
+
}
|
|
69
|
+
function projectNode(node, context) {
|
|
70
|
+
const definition = context.definitions.get(blockKey(node.type, node.version));
|
|
71
|
+
const declaredPorts = definition?.ports ?? [];
|
|
72
|
+
const declaredIds = new Set(declaredPorts.map((port) => port.id));
|
|
73
|
+
const preservedPortIds = Object.keys(node.bindings)
|
|
74
|
+
.filter((port) => !declaredIds.has(port))
|
|
75
|
+
.sort(compareCodeUnits);
|
|
76
|
+
const ports = [
|
|
77
|
+
...declaredPorts.map((port) => projectPort(node, port, context)),
|
|
78
|
+
...preservedPortIds.map((port) => projectMissingPort(node, port, context)),
|
|
79
|
+
];
|
|
80
|
+
return { nodeId: node.id, ports };
|
|
81
|
+
}
|
|
82
|
+
function projectPort(node, port, context) {
|
|
83
|
+
const candidates = context.modelCompatible
|
|
84
|
+
? context.fields
|
|
85
|
+
.filter((candidate) => candidate.field.authoring?.hidden !== true && fieldMatchesPort(candidate.field, port))
|
|
86
|
+
.map(({ field, fieldPath }) => candidateProjection(field, fieldPath))
|
|
87
|
+
: [];
|
|
88
|
+
const binding = node.bindings[port.id];
|
|
89
|
+
if (binding === undefined) {
|
|
90
|
+
if (port.required) {
|
|
91
|
+
context.diagnostics.push(diagnostic('studio.binding/required-port-unbound', 'Required block port {port} is not bound to a source.', 'warning', { port: port.id }, { artifactId: context.blueprintId, nodeId: node.id }));
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
candidates,
|
|
95
|
+
multiple: port.multiple,
|
|
96
|
+
port: port.id,
|
|
97
|
+
required: port.required,
|
|
98
|
+
status: 'unbound',
|
|
99
|
+
valueType: port.valueType,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (binding.source.kind !== 'entry-field') {
|
|
103
|
+
return {
|
|
104
|
+
binding: cloneContractValue(binding),
|
|
105
|
+
candidates,
|
|
106
|
+
multiple: port.multiple,
|
|
107
|
+
port: port.id,
|
|
108
|
+
required: port.required,
|
|
109
|
+
status: 'non-field-source',
|
|
110
|
+
valueType: port.valueType,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const fieldPath = [...binding.source.fieldPath];
|
|
114
|
+
if (!context.modelCompatible) {
|
|
115
|
+
return invalidProjection(port, binding, fieldPath, candidates);
|
|
116
|
+
}
|
|
117
|
+
const resolution = resolveFieldPath(context.fields, fieldPath);
|
|
118
|
+
if (resolution === undefined) {
|
|
119
|
+
context.diagnostics.push(diagnostic('studio.binding/field-missing', 'Binding port {port} addresses field path {fieldPath}, which the locked model no longer declares.', 'error', { fieldPath: fieldPath.join('.'), port: port.id }, { artifactId: context.blueprintId, fieldPath, nodeId: node.id }));
|
|
120
|
+
return invalidProjection(port, binding, fieldPath, candidates);
|
|
121
|
+
}
|
|
122
|
+
if (fieldIsMultiple(resolution.field) !== port.multiple) {
|
|
123
|
+
context.diagnostics.push(diagnostic('studio.binding/field-cardinality-incompatible', 'Binding port {port} and field {fieldPath} no longer have compatible cardinality.', 'error', { fieldPath: fieldPath.join('.'), port: port.id }, { artifactId: context.blueprintId, fieldPath, nodeId: node.id }));
|
|
124
|
+
return invalidProjection(port, binding, fieldPath, candidates);
|
|
125
|
+
}
|
|
126
|
+
if (!fieldKindMatchesValueType(resolution.field, port.valueType)) {
|
|
127
|
+
context.diagnostics.push(diagnostic('studio.binding/field-kind-incompatible', 'Binding port {port} expects {valueType}, but field {fieldPath} now projects as {fieldKind}.', 'error', {
|
|
128
|
+
fieldKind: effectiveFieldKind(resolution.field),
|
|
129
|
+
fieldPath: fieldPath.join('.'),
|
|
130
|
+
port: port.id,
|
|
131
|
+
valueType: port.valueType,
|
|
132
|
+
}, { artifactId: context.blueprintId, fieldPath, nodeId: node.id }));
|
|
133
|
+
return invalidProjection(port, binding, fieldPath, candidates);
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
binding: cloneContractValue(binding),
|
|
137
|
+
boundFieldPath: fieldPath,
|
|
138
|
+
candidates,
|
|
139
|
+
multiple: port.multiple,
|
|
140
|
+
port: port.id,
|
|
141
|
+
required: port.required,
|
|
142
|
+
status: 'resolved',
|
|
143
|
+
valueType: port.valueType,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function projectMissingPort(node, port, context) {
|
|
147
|
+
const binding = node.bindings[port];
|
|
148
|
+
if (binding === undefined) {
|
|
149
|
+
return { candidates: [], port, status: 'invalid' };
|
|
150
|
+
}
|
|
151
|
+
context.diagnostics.push(diagnostic('studio.binding/port-missing', 'Binding port {port} is not declared by the locked block definition.', 'error', { port }, { artifactId: context.blueprintId, nodeId: node.id }));
|
|
152
|
+
return {
|
|
153
|
+
binding: cloneContractValue(binding),
|
|
154
|
+
...(binding.source.kind === 'entry-field'
|
|
155
|
+
? { boundFieldPath: [...binding.source.fieldPath] }
|
|
156
|
+
: {}),
|
|
157
|
+
candidates: [],
|
|
158
|
+
port,
|
|
159
|
+
status: 'invalid',
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function invalidProjection(port, binding, fieldPath, candidates) {
|
|
163
|
+
return {
|
|
164
|
+
binding: cloneContractValue(binding),
|
|
165
|
+
boundFieldPath: [...fieldPath],
|
|
166
|
+
candidates,
|
|
167
|
+
multiple: port.multiple,
|
|
168
|
+
port: port.id,
|
|
169
|
+
required: port.required,
|
|
170
|
+
status: 'invalid',
|
|
171
|
+
valueType: port.valueType,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function candidateProjection(field, fieldPath) {
|
|
175
|
+
return {
|
|
176
|
+
cardinality: field.cardinality,
|
|
177
|
+
...(field.authoring?.control === undefined ? {} : { control: field.authoring.control }),
|
|
178
|
+
fieldPath: [...fieldPath],
|
|
179
|
+
...(field.itemKind === undefined ? {} : { itemKind: field.itemKind }),
|
|
180
|
+
kind: field.kind,
|
|
181
|
+
label: cloneContractValue(field.label),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function flattenModelFields(fields) {
|
|
185
|
+
const flattened = [];
|
|
186
|
+
const visit = (siblings, prefix) => {
|
|
187
|
+
const ordered = siblings
|
|
188
|
+
.map((field, index) => ({ field, index }))
|
|
189
|
+
.sort((left, right) => (left.field.authoring?.order ?? Number.MAX_SAFE_INTEGER) -
|
|
190
|
+
(right.field.authoring?.order ?? Number.MAX_SAFE_INTEGER) || left.index - right.index);
|
|
191
|
+
for (const { field } of ordered) {
|
|
192
|
+
const fieldPath = [...prefix, field.id];
|
|
193
|
+
flattened.push({ field, fieldPath });
|
|
194
|
+
if (field.kind === 'object' && field.cardinality === 'one' && field.fields !== undefined) {
|
|
195
|
+
visit(field.fields, fieldPath);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
visit(fields, []);
|
|
200
|
+
return flattened;
|
|
201
|
+
}
|
|
202
|
+
function resolveFieldPath(fields, fieldPath) {
|
|
203
|
+
return fields.find((candidate) => samePath(candidate.fieldPath, fieldPath));
|
|
204
|
+
}
|
|
205
|
+
function fieldMatchesPort(field, port) {
|
|
206
|
+
return (fieldIsMultiple(field) === port.multiple && fieldKindMatchesValueType(field, port.valueType));
|
|
207
|
+
}
|
|
208
|
+
function fieldIsMultiple(field) {
|
|
209
|
+
return field.cardinality === 'many';
|
|
210
|
+
}
|
|
211
|
+
function fieldKindMatchesValueType(field, valueType) {
|
|
212
|
+
const kind = effectiveFieldKind(field);
|
|
213
|
+
if (kind === valueType) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
if (valueType === 'text') {
|
|
217
|
+
return kind === 'string' || kind === 'enum';
|
|
218
|
+
}
|
|
219
|
+
if (valueType === 'number') {
|
|
220
|
+
return kind === 'decimal' || kind === 'integer';
|
|
221
|
+
}
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
function effectiveFieldKind(field) {
|
|
225
|
+
return field.kind === 'collection' ? (field.itemKind ?? 'object') : field.kind;
|
|
226
|
+
}
|
|
227
|
+
function visitNodes(nodes, visit) {
|
|
228
|
+
for (const node of nodes) {
|
|
229
|
+
visit(node);
|
|
230
|
+
for (const slot of Object.keys(node.slots).sort(compareCodeUnits)) {
|
|
231
|
+
visitNodes(node.slots[slot] ?? [], visit);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function diagnostic(code, defaultMessage, severity, parameters, location) {
|
|
236
|
+
return {
|
|
237
|
+
code,
|
|
238
|
+
...(location === undefined ? {} : { location }),
|
|
239
|
+
message: { defaultMessage, key: code },
|
|
240
|
+
...(parameters === undefined ? {} : { parameters }),
|
|
241
|
+
severity,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function blockKey(type, version) {
|
|
245
|
+
return `${type}@${version}`;
|
|
246
|
+
}
|
|
247
|
+
function samePath(left, right) {
|
|
248
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
249
|
+
}
|
|
250
|
+
function compareCodeUnits(left, right) {
|
|
251
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=binding-projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding-projection.js","sourceRoot":"","sources":["../src/binding-projection.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAyDhD;;;;;;;GAOG;AACH,MAAM,UAAU,6BAA6B,CAC3C,SAA4B,EAC5B,KAA2B,EAC3B,WAAuC;IAEvC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACvD,MAAM,aAAa,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AC;QAC/C,OAAO,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,IAAI,EAAE;QACtC,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;QACnD,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,OAAe;IAC7C,OAAO,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC;AAC9B,CAAC;AAED,SAAS,QAAQ,CAAC,IAAuB,EAAE,KAAwB;IACjE,OAAO,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9F,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,KAAa;IACnD,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
package/dist/contributions.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import type { BlockDefinition, BlockType, BlueprintDocument, ExtensionLifecycleState, NodeId, OwnerReference, Revision, StudioDiagnostic, UnresolvedContribution, UnresolvedContributionReason } from '@kumwe/studio-protocol';
|
|
1
|
+
import type { BlockDefinition, BlockType, BlueprintDocument, DesignVocabulary, ExtensionLifecycleState, FieldAdapterContribution, InspectorContribution, MigrationDeclaration, NodeId, OwnerReference, PatternDocument, Revision, StudioDiagnostic, UnresolvedContribution, UnresolvedContributionReference, UnresolvedContributionReason } from '@kumwe/studio-protocol';
|
|
2
2
|
import { BlockRegistry } from './registry.js';
|
|
3
3
|
export interface ExtensionContributions {
|
|
4
4
|
blocks: BlockDefinition[];
|
|
5
|
+
designVocabularies?: DesignVocabulary[];
|
|
6
|
+
fieldAdapters?: FieldAdapterContribution[];
|
|
7
|
+
inspectors?: InspectorContribution[];
|
|
8
|
+
migrations?: MigrationDeclaration[];
|
|
9
|
+
patterns?: PatternDocument[];
|
|
5
10
|
}
|
|
11
|
+
export type StudioCompositionContributionKind = 'block' | 'design-vocabulary' | 'field-adapter' | 'inspector' | 'migration' | 'pattern';
|
|
12
|
+
export type StudioCompositionContribution = BlockDefinition | DesignVocabulary | FieldAdapterContribution | InspectorContribution | MigrationDeclaration | PatternDocument;
|
|
6
13
|
export interface ExtensionInventory {
|
|
7
14
|
diagnostics: StudioDiagnostic[];
|
|
8
15
|
owner: OwnerReference;
|
|
@@ -22,18 +29,29 @@ export declare class StudioContributionError extends Error {
|
|
|
22
29
|
readonly diagnostics: StudioDiagnostic[];
|
|
23
30
|
constructor(message: string, diagnostics: StudioDiagnostic[]);
|
|
24
31
|
}
|
|
32
|
+
interface ContributionEntry {
|
|
33
|
+
id: string;
|
|
34
|
+
kind: StudioCompositionContributionKind;
|
|
35
|
+
owner: OwnerReference;
|
|
36
|
+
payload: StudioCompositionContribution;
|
|
37
|
+
version: string;
|
|
38
|
+
}
|
|
25
39
|
/**
|
|
26
40
|
* One immutable, resolvable registry generation. A generation never changes
|
|
27
41
|
* after publication; lifecycle transitions publish a successor instead.
|
|
28
42
|
*/
|
|
29
43
|
export declare class RegistryGeneration {
|
|
30
44
|
#private;
|
|
31
|
-
constructor(generation: Revision, owners: readonly OwnerReference[], registry: BlockRegistry);
|
|
45
|
+
constructor(generation: Revision, owners: readonly OwnerReference[], registry: BlockRegistry, contributions?: readonly ContributionEntry[]);
|
|
32
46
|
get generation(): Revision;
|
|
33
47
|
get registry(): BlockRegistry;
|
|
34
48
|
blocks(): BlockDefinition[];
|
|
35
49
|
owners(): OwnerReference[];
|
|
36
50
|
resolveBlock(type: BlockType, version: string): BlockDefinition | undefined;
|
|
51
|
+
/** Resolve one of the six canonical composition payload kinds by exact identity. */
|
|
52
|
+
resolveContribution(kind: StudioCompositionContributionKind, id: string, version: string): StudioCompositionContribution | undefined;
|
|
53
|
+
/** Enumerate one canonical kind in deterministic identity/version order. */
|
|
54
|
+
contributions(kind: StudioCompositionContributionKind): StudioCompositionContribution[];
|
|
37
55
|
}
|
|
38
56
|
/**
|
|
39
57
|
* The owner-aware contribution runtime. Activation is transactional: a
|
|
@@ -61,5 +79,15 @@ export declare class ContributionRuntime {
|
|
|
61
79
|
* owner.
|
|
62
80
|
*/
|
|
63
81
|
unresolvedContributions(document: BlueprintDocument): UnresolvedContribution[];
|
|
82
|
+
/**
|
|
83
|
+
* Resolve the lifecycle reason for any canonical contribution reference.
|
|
84
|
+
* Identity is kind-scoped, so a pattern can never satisfy a field-adapter
|
|
85
|
+
* reference merely because their IDs and versions match.
|
|
86
|
+
*/
|
|
87
|
+
unresolvedReference(reference: UnresolvedContributionReference): {
|
|
88
|
+
owner?: OwnerReference;
|
|
89
|
+
reason: UnresolvedContributionReason;
|
|
90
|
+
} | undefined;
|
|
64
91
|
}
|
|
92
|
+
export {};
|
|
65
93
|
//# sourceMappingURL=contributions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contributions.d.ts","sourceRoot":"","sources":["../src/contributions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contributions.d.ts","sourceRoot":"","sources":["../src/contributions.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,eAAe,EACf,SAAS,EACT,iBAAiB,EAEjB,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,MAAM,EACN,cAAc,EACd,eAAe,EACf,QAAQ,EACR,gBAAgB,EAChB,sBAAsB,EACtB,+BAA+B,EAC/B,4BAA4B,EAC7B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI9C,MAAM,WAAW,sBAAsB;IACrC,MAA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