@ai-matrx/content-ir 0.3.0 → 0.6.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.
- package/CHANGELOG.md +72 -0
- package/dist/index.cjs +186 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -13
- package/dist/index.d.ts +60 -13
- package/dist/index.js +186 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -12,8 +12,20 @@ import { ComponentType } from 'react';
|
|
|
12
12
|
*/
|
|
13
13
|
/** Path of a value inside a parsed region (object keys + array indices). */
|
|
14
14
|
type IrPath = Array<string | number>;
|
|
15
|
-
/**
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* How a node's kind was (or wasn't) established.
|
|
17
|
+
*
|
|
18
|
+
* 🚨 `unverified` IS NOT `raw`, AND THE DIFFERENCE IS LOAD-BEARING (Arman's
|
|
19
|
+
* ruling, 2026-08-29). "We checked it and it is wrong" and "we had nothing to
|
|
20
|
+
* check it with" are opposite facts about a payload, and collapsing them cost
|
|
21
|
+
* ~221 live kinds their component overnight: a kind whose schema never loaded
|
|
22
|
+
* degraded to `raw`, the render route read `raw` as "broken instance", and
|
|
23
|
+
* perfectly valid payloads were dumped as key/value lists instead of reaching
|
|
24
|
+
* the component the user built. A consumer that treats `unverified` as a
|
|
25
|
+
* failure is reintroducing that outage — the data is intact and MAY be
|
|
26
|
+
* entirely valid; all that is missing is the schema that would prove it.
|
|
27
|
+
*/
|
|
28
|
+
type IrKindState = "resolved" | "speculative" | "pending_kind" | "pending_schema" | "unverified" | "raw";
|
|
17
29
|
/**
|
|
18
30
|
* System-level zero-data-loss channel. Unknown keys are NEVER merged into a
|
|
19
31
|
* node's `value` (they'd be indistinguishable from schema fields); they are
|
|
@@ -290,6 +302,16 @@ interface SchemaResolver {
|
|
|
290
302
|
kindForJsonRootKey?(key: string): string | null;
|
|
291
303
|
}
|
|
292
304
|
declare function setJsonRootKeyLookup(lookup: ((key: string) => string | null) | null): void;
|
|
305
|
+
/**
|
|
306
|
+
* Why a node degraded off the `resolved` path.
|
|
307
|
+
*
|
|
308
|
+
* `"unverified"` is reserved for ONE situation: no schema was registered for
|
|
309
|
+
* an identified kind, so no check ever ran. Every other degrade — a schema
|
|
310
|
+
* violation, an array-item kind mismatch, a duplicate key, a bad field
|
|
311
|
+
* placement, a contradicted speculation — is `"invalid"`: something checked
|
|
312
|
+
* the node and it failed.
|
|
313
|
+
*/
|
|
314
|
+
type RawObjectCause = "unverified" | "invalid";
|
|
293
315
|
type KindStreamEvent = {
|
|
294
316
|
type: "kind_identified";
|
|
295
317
|
kind: string;
|
|
@@ -336,15 +358,23 @@ type KindStreamEvent = {
|
|
|
336
358
|
value: unknown;
|
|
337
359
|
reason: string;
|
|
338
360
|
/**
|
|
339
|
-
* The kind that WAS identified for this node before it degraded
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
* render seam can route to the generic viewer (or upgrade when the
|
|
345
|
-
* schema arrives late) instead of dumping raw JSON.
|
|
361
|
+
* The kind that WAS identified for this node before it degraded — set
|
|
362
|
+
* for schema-availability degrades AND (since 2026-08-29) structural
|
|
363
|
+
* ones, so a payload that said what it is stays acknowledged as an
|
|
364
|
+
* instance of that kind. Absent only when nothing ever identified it
|
|
365
|
+
* (an object with no `__kind` at all).
|
|
346
366
|
*/
|
|
347
367
|
kind?: string;
|
|
368
|
+
/**
|
|
369
|
+
* WHY this node is not `resolved` — the discriminator the render route
|
|
370
|
+
* reads. See `IrKindState` for why collapsing these two is an outage.
|
|
371
|
+
*
|
|
372
|
+
* - `"unverified"`: no schema was available, so nothing was checked.
|
|
373
|
+
* The value is intact and may be perfectly valid.
|
|
374
|
+
* - `"invalid"` (default): a check RAN and the node failed it, or the
|
|
375
|
+
* node is structurally broken (duplicate key, bad placement).
|
|
376
|
+
*/
|
|
377
|
+
cause?: RawObjectCause;
|
|
348
378
|
at: number;
|
|
349
379
|
} | {
|
|
350
380
|
type: "optional_field_missing";
|
|
@@ -508,6 +538,14 @@ declare class KindStreamParser {
|
|
|
508
538
|
private completeRoot;
|
|
509
539
|
/** Mark a node raw (node-scoped failure) without killing the stream. */
|
|
510
540
|
private markNodeRaw;
|
|
541
|
+
/**
|
|
542
|
+
* Degrade ONE node off the resolved path.
|
|
543
|
+
*
|
|
544
|
+
* `cause` defaults to `"invalid"` deliberately: every call site that omits
|
|
545
|
+
* it is a real failure (validation, duplicate key, placement, contradicted
|
|
546
|
+
* speculation). ONLY the "no schema registered" sites pass `"unverified"`,
|
|
547
|
+
* and they are the reason the parameter exists — see `IrKindState`.
|
|
548
|
+
*/
|
|
511
549
|
private emitRawObject;
|
|
512
550
|
private clearKindWait;
|
|
513
551
|
private emitFieldIfReady;
|
|
@@ -596,11 +634,20 @@ declare class IrTree {
|
|
|
596
634
|
*/
|
|
597
635
|
private readonly earlyFields;
|
|
598
636
|
/**
|
|
599
|
-
* pathKey → identified kind preserved through a
|
|
600
|
-
*
|
|
601
|
-
*
|
|
637
|
+
* pathKey → identified kind preserved through a raw fallback (parser stamped
|
|
638
|
+
* `kind` on the raw_object event) — schema-availability degrades and, since
|
|
639
|
+
* 2026-08-29, structural ones too. Only a node nothing ever identified (no
|
|
640
|
+
* `__kind` at all) is absent here.
|
|
602
641
|
*/
|
|
603
642
|
private readonly rawKinds;
|
|
643
|
+
/**
|
|
644
|
+
* pathKey → WHY the node degraded. `"unverified"` means no schema was
|
|
645
|
+
* available and nothing was ever checked; `"invalid"` means a check ran and
|
|
646
|
+
* failed. THE RENDER ROUTE BRANCHES ON THIS — see `IrKindState`. Absent =
|
|
647
|
+
* `"invalid"`, so a parser that predates the `cause` field (or any consumer
|
|
648
|
+
* hand-building events) keeps the strict, safe reading.
|
|
649
|
+
*/
|
|
650
|
+
private readonly rawCauses;
|
|
604
651
|
private regionStatus;
|
|
605
652
|
private errorReason;
|
|
606
653
|
private rootRawValue;
|
|
@@ -1932,4 +1979,4 @@ declare function emitPayloadJson(kind: string, value: unknown): string;
|
|
|
1932
1979
|
*/
|
|
1933
1980
|
declare function emitPayloadFence(kind: string, value: unknown): string;
|
|
1934
1981
|
|
|
1935
|
-
export { type AnyPartialKindEvent, type ArrayItemKindBinding, type ArrayItemScalarType, type BlockSchemaDraft, type CanonicalBlockIR, type CanonicalContent, type CanonicalSegment, type CompleteValueEnvelopeOptions, type CompliantKindSnapshot, type ContentRegionInit, type ConversionProblem, type DroppedMetadata, type DualGateDefinition, type DualGateInput, type DualGateResolvedComponent, type DualGateResult, type FieldComparison, type FieldSchema, type Fingerprinter, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, type InboundEnvelopeHooks, type InboundEnvelopeVerdict, type IrDiscriminator, type IrEnvelopeCache, type IrKindState, type IrPath, type IrResidue, type IrStructuredNode, IrTree, type IrTreeNode, type ItemKindRefCheck, JSON_DISCRIMINATOR, type JsonPath, type JsonSchemaNode, JsonStreamTokenizer, type JsonToken, KIND_KEY, type KindBlockProps, type KindDefinition, type KindEdgeSpec, type KindJsonSchemaExport, type KindJsonSchemaOptions, type KindResolution, type KindSchema, KindStorageError, type KindStorageShape, type KindStreamEvent, KindStreamParser, type KindStreamParserOptions, type KindTier, type KindVerdict, type LegResult, NODE_OUTCOME_KIND, type NodeOutcomeWrapper, type NormalizeJsonRegionOptions, ParseSession, type ParseSessionOptions, type PartialKindEvent, type PartialKindNode, type PartialKindState, type Punct, ROOT_STORAGE_NAME, RUN_RESULT_KIND, type RecordValueType, type RegionEndReason, type RegionFormat, type RegionSourceKind, type RetractedKindEvent, type RunResultWrapper, type SavePlanEntry, type SavePlanValidation, type ScalarFieldType, type SchemaConversionResult, type SchemaLayoutMode, type SchemaResolver, type StoredFieldElement, type SupersededKindEvent, advancePartialKind, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isProvisionalKind, isScalarArrayType, isTerminalKindEvent, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, makePartialKindStalenessGate, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
|
|
1982
|
+
export { type AnyPartialKindEvent, type ArrayItemKindBinding, type ArrayItemScalarType, type BlockSchemaDraft, type CanonicalBlockIR, type CanonicalContent, type CanonicalSegment, type CompleteValueEnvelopeOptions, type CompliantKindSnapshot, type ContentRegionInit, type ConversionProblem, type DroppedMetadata, type DualGateDefinition, type DualGateInput, type DualGateResolvedComponent, type DualGateResult, type FieldComparison, type FieldSchema, type Fingerprinter, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, type InboundEnvelopeHooks, type InboundEnvelopeVerdict, type IrDiscriminator, type IrEnvelopeCache, type IrKindState, type IrPath, type IrResidue, type IrStructuredNode, IrTree, type IrTreeNode, type ItemKindRefCheck, JSON_DISCRIMINATOR, type JsonPath, type JsonSchemaNode, JsonStreamTokenizer, type JsonToken, KIND_KEY, type KindBlockProps, type KindDefinition, type KindEdgeSpec, type KindJsonSchemaExport, type KindJsonSchemaOptions, type KindResolution, type KindSchema, KindStorageError, type KindStorageShape, type KindStreamEvent, KindStreamParser, type KindStreamParserOptions, type KindTier, type KindVerdict, type LegResult, NODE_OUTCOME_KIND, type NodeOutcomeWrapper, type NormalizeJsonRegionOptions, ParseSession, type ParseSessionOptions, type PartialKindEvent, type PartialKindNode, type PartialKindState, type Punct, ROOT_STORAGE_NAME, RUN_RESULT_KIND, type RawObjectCause, type RecordValueType, type RegionEndReason, type RegionFormat, type RegionSourceKind, type RetractedKindEvent, type RunResultWrapper, type SavePlanEntry, type SavePlanValidation, type ScalarFieldType, type SchemaConversionResult, type SchemaLayoutMode, type SchemaResolver, type StoredFieldElement, type SupersededKindEvent, advancePartialKind, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isProvisionalKind, isScalarArrayType, isTerminalKindEvent, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, makePartialKindStalenessGate, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,8 +12,20 @@ import { ComponentType } from 'react';
|
|
|
12
12
|
*/
|
|
13
13
|
/** Path of a value inside a parsed region (object keys + array indices). */
|
|
14
14
|
type IrPath = Array<string | number>;
|
|
15
|
-
/**
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* How a node's kind was (or wasn't) established.
|
|
17
|
+
*
|
|
18
|
+
* 🚨 `unverified` IS NOT `raw`, AND THE DIFFERENCE IS LOAD-BEARING (Arman's
|
|
19
|
+
* ruling, 2026-08-29). "We checked it and it is wrong" and "we had nothing to
|
|
20
|
+
* check it with" are opposite facts about a payload, and collapsing them cost
|
|
21
|
+
* ~221 live kinds their component overnight: a kind whose schema never loaded
|
|
22
|
+
* degraded to `raw`, the render route read `raw` as "broken instance", and
|
|
23
|
+
* perfectly valid payloads were dumped as key/value lists instead of reaching
|
|
24
|
+
* the component the user built. A consumer that treats `unverified` as a
|
|
25
|
+
* failure is reintroducing that outage — the data is intact and MAY be
|
|
26
|
+
* entirely valid; all that is missing is the schema that would prove it.
|
|
27
|
+
*/
|
|
28
|
+
type IrKindState = "resolved" | "speculative" | "pending_kind" | "pending_schema" | "unverified" | "raw";
|
|
17
29
|
/**
|
|
18
30
|
* System-level zero-data-loss channel. Unknown keys are NEVER merged into a
|
|
19
31
|
* node's `value` (they'd be indistinguishable from schema fields); they are
|
|
@@ -290,6 +302,16 @@ interface SchemaResolver {
|
|
|
290
302
|
kindForJsonRootKey?(key: string): string | null;
|
|
291
303
|
}
|
|
292
304
|
declare function setJsonRootKeyLookup(lookup: ((key: string) => string | null) | null): void;
|
|
305
|
+
/**
|
|
306
|
+
* Why a node degraded off the `resolved` path.
|
|
307
|
+
*
|
|
308
|
+
* `"unverified"` is reserved for ONE situation: no schema was registered for
|
|
309
|
+
* an identified kind, so no check ever ran. Every other degrade — a schema
|
|
310
|
+
* violation, an array-item kind mismatch, a duplicate key, a bad field
|
|
311
|
+
* placement, a contradicted speculation — is `"invalid"`: something checked
|
|
312
|
+
* the node and it failed.
|
|
313
|
+
*/
|
|
314
|
+
type RawObjectCause = "unverified" | "invalid";
|
|
293
315
|
type KindStreamEvent = {
|
|
294
316
|
type: "kind_identified";
|
|
295
317
|
kind: string;
|
|
@@ -336,15 +358,23 @@ type KindStreamEvent = {
|
|
|
336
358
|
value: unknown;
|
|
337
359
|
reason: string;
|
|
338
360
|
/**
|
|
339
|
-
* The kind that WAS identified for this node before it degraded
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
* render seam can route to the generic viewer (or upgrade when the
|
|
345
|
-
* schema arrives late) instead of dumping raw JSON.
|
|
361
|
+
* The kind that WAS identified for this node before it degraded — set
|
|
362
|
+
* for schema-availability degrades AND (since 2026-08-29) structural
|
|
363
|
+
* ones, so a payload that said what it is stays acknowledged as an
|
|
364
|
+
* instance of that kind. Absent only when nothing ever identified it
|
|
365
|
+
* (an object with no `__kind` at all).
|
|
346
366
|
*/
|
|
347
367
|
kind?: string;
|
|
368
|
+
/**
|
|
369
|
+
* WHY this node is not `resolved` — the discriminator the render route
|
|
370
|
+
* reads. See `IrKindState` for why collapsing these two is an outage.
|
|
371
|
+
*
|
|
372
|
+
* - `"unverified"`: no schema was available, so nothing was checked.
|
|
373
|
+
* The value is intact and may be perfectly valid.
|
|
374
|
+
* - `"invalid"` (default): a check RAN and the node failed it, or the
|
|
375
|
+
* node is structurally broken (duplicate key, bad placement).
|
|
376
|
+
*/
|
|
377
|
+
cause?: RawObjectCause;
|
|
348
378
|
at: number;
|
|
349
379
|
} | {
|
|
350
380
|
type: "optional_field_missing";
|
|
@@ -508,6 +538,14 @@ declare class KindStreamParser {
|
|
|
508
538
|
private completeRoot;
|
|
509
539
|
/** Mark a node raw (node-scoped failure) without killing the stream. */
|
|
510
540
|
private markNodeRaw;
|
|
541
|
+
/**
|
|
542
|
+
* Degrade ONE node off the resolved path.
|
|
543
|
+
*
|
|
544
|
+
* `cause` defaults to `"invalid"` deliberately: every call site that omits
|
|
545
|
+
* it is a real failure (validation, duplicate key, placement, contradicted
|
|
546
|
+
* speculation). ONLY the "no schema registered" sites pass `"unverified"`,
|
|
547
|
+
* and they are the reason the parameter exists — see `IrKindState`.
|
|
548
|
+
*/
|
|
511
549
|
private emitRawObject;
|
|
512
550
|
private clearKindWait;
|
|
513
551
|
private emitFieldIfReady;
|
|
@@ -596,11 +634,20 @@ declare class IrTree {
|
|
|
596
634
|
*/
|
|
597
635
|
private readonly earlyFields;
|
|
598
636
|
/**
|
|
599
|
-
* pathKey → identified kind preserved through a
|
|
600
|
-
*
|
|
601
|
-
*
|
|
637
|
+
* pathKey → identified kind preserved through a raw fallback (parser stamped
|
|
638
|
+
* `kind` on the raw_object event) — schema-availability degrades and, since
|
|
639
|
+
* 2026-08-29, structural ones too. Only a node nothing ever identified (no
|
|
640
|
+
* `__kind` at all) is absent here.
|
|
602
641
|
*/
|
|
603
642
|
private readonly rawKinds;
|
|
643
|
+
/**
|
|
644
|
+
* pathKey → WHY the node degraded. `"unverified"` means no schema was
|
|
645
|
+
* available and nothing was ever checked; `"invalid"` means a check ran and
|
|
646
|
+
* failed. THE RENDER ROUTE BRANCHES ON THIS — see `IrKindState`. Absent =
|
|
647
|
+
* `"invalid"`, so a parser that predates the `cause` field (or any consumer
|
|
648
|
+
* hand-building events) keeps the strict, safe reading.
|
|
649
|
+
*/
|
|
650
|
+
private readonly rawCauses;
|
|
604
651
|
private regionStatus;
|
|
605
652
|
private errorReason;
|
|
606
653
|
private rootRawValue;
|
|
@@ -1932,4 +1979,4 @@ declare function emitPayloadJson(kind: string, value: unknown): string;
|
|
|
1932
1979
|
*/
|
|
1933
1980
|
declare function emitPayloadFence(kind: string, value: unknown): string;
|
|
1934
1981
|
|
|
1935
|
-
export { type AnyPartialKindEvent, type ArrayItemKindBinding, type ArrayItemScalarType, type BlockSchemaDraft, type CanonicalBlockIR, type CanonicalContent, type CanonicalSegment, type CompleteValueEnvelopeOptions, type CompliantKindSnapshot, type ContentRegionInit, type ConversionProblem, type DroppedMetadata, type DualGateDefinition, type DualGateInput, type DualGateResolvedComponent, type DualGateResult, type FieldComparison, type FieldSchema, type Fingerprinter, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, type InboundEnvelopeHooks, type InboundEnvelopeVerdict, type IrDiscriminator, type IrEnvelopeCache, type IrKindState, type IrPath, type IrResidue, type IrStructuredNode, IrTree, type IrTreeNode, type ItemKindRefCheck, JSON_DISCRIMINATOR, type JsonPath, type JsonSchemaNode, JsonStreamTokenizer, type JsonToken, KIND_KEY, type KindBlockProps, type KindDefinition, type KindEdgeSpec, type KindJsonSchemaExport, type KindJsonSchemaOptions, type KindResolution, type KindSchema, KindStorageError, type KindStorageShape, type KindStreamEvent, KindStreamParser, type KindStreamParserOptions, type KindTier, type KindVerdict, type LegResult, NODE_OUTCOME_KIND, type NodeOutcomeWrapper, type NormalizeJsonRegionOptions, ParseSession, type ParseSessionOptions, type PartialKindEvent, type PartialKindNode, type PartialKindState, type Punct, ROOT_STORAGE_NAME, RUN_RESULT_KIND, type RecordValueType, type RegionEndReason, type RegionFormat, type RegionSourceKind, type RetractedKindEvent, type RunResultWrapper, type SavePlanEntry, type SavePlanValidation, type ScalarFieldType, type SchemaConversionResult, type SchemaLayoutMode, type SchemaResolver, type StoredFieldElement, type SupersededKindEvent, advancePartialKind, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isProvisionalKind, isScalarArrayType, isTerminalKindEvent, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, makePartialKindStalenessGate, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
|
|
1982
|
+
export { type AnyPartialKindEvent, type ArrayItemKindBinding, type ArrayItemScalarType, type BlockSchemaDraft, type CanonicalBlockIR, type CanonicalContent, type CanonicalSegment, type CompleteValueEnvelopeOptions, type CompliantKindSnapshot, type ContentRegionInit, type ConversionProblem, type DroppedMetadata, type DualGateDefinition, type DualGateInput, type DualGateResolvedComponent, type DualGateResult, type FieldComparison, type FieldSchema, type Fingerprinter, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, type InboundEnvelopeHooks, type InboundEnvelopeVerdict, type IrDiscriminator, type IrEnvelopeCache, type IrKindState, type IrPath, type IrResidue, type IrStructuredNode, IrTree, type IrTreeNode, type ItemKindRefCheck, JSON_DISCRIMINATOR, type JsonPath, type JsonSchemaNode, JsonStreamTokenizer, type JsonToken, KIND_KEY, type KindBlockProps, type KindDefinition, type KindEdgeSpec, type KindJsonSchemaExport, type KindJsonSchemaOptions, type KindResolution, type KindSchema, KindStorageError, type KindStorageShape, type KindStreamEvent, KindStreamParser, type KindStreamParserOptions, type KindTier, type KindVerdict, type LegResult, NODE_OUTCOME_KIND, type NodeOutcomeWrapper, type NormalizeJsonRegionOptions, ParseSession, type ParseSessionOptions, type PartialKindEvent, type PartialKindNode, type PartialKindState, type Punct, ROOT_STORAGE_NAME, RUN_RESULT_KIND, type RawObjectCause, type RecordValueType, type RegionEndReason, type RegionFormat, type RegionSourceKind, type RetractedKindEvent, type RunResultWrapper, type SavePlanEntry, type SavePlanValidation, type ScalarFieldType, type SchemaConversionResult, type SchemaLayoutMode, type SchemaResolver, type StoredFieldElement, type SupersededKindEvent, advancePartialKind, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isProvisionalKind, isScalarArrayType, isTerminalKindEvent, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, makePartialKindStalenessGate, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
|
package/dist/index.js
CHANGED
|
@@ -105,11 +105,20 @@ var IrTree = class {
|
|
|
105
105
|
*/
|
|
106
106
|
earlyFields = /* @__PURE__ */ new Map();
|
|
107
107
|
/**
|
|
108
|
-
* pathKey → identified kind preserved through a
|
|
109
|
-
*
|
|
110
|
-
*
|
|
108
|
+
* pathKey → identified kind preserved through a raw fallback (parser stamped
|
|
109
|
+
* `kind` on the raw_object event) — schema-availability degrades and, since
|
|
110
|
+
* 2026-08-29, structural ones too. Only a node nothing ever identified (no
|
|
111
|
+
* `__kind` at all) is absent here.
|
|
111
112
|
*/
|
|
112
113
|
rawKinds = /* @__PURE__ */ new Map();
|
|
114
|
+
/**
|
|
115
|
+
* pathKey → WHY the node degraded. `"unverified"` means no schema was
|
|
116
|
+
* available and nothing was ever checked; `"invalid"` means a check ran and
|
|
117
|
+
* failed. THE RENDER ROUTE BRANCHES ON THIS — see `IrKindState`. Absent =
|
|
118
|
+
* `"invalid"`, so a parser that predates the `cause` field (or any consumer
|
|
119
|
+
* hand-building events) keeps the strict, safe reading.
|
|
120
|
+
*/
|
|
121
|
+
rawCauses = /* @__PURE__ */ new Map();
|
|
113
122
|
regionStatus = "streaming";
|
|
114
123
|
errorReason = null;
|
|
115
124
|
rootRawValue = null;
|
|
@@ -162,6 +171,7 @@ var IrTree = class {
|
|
|
162
171
|
this.pendingSchemaPaths.delete(pathKey);
|
|
163
172
|
this.earlyFields.delete(pathKey);
|
|
164
173
|
if (event.kind) this.rawKinds.set(pathKey, event.kind);
|
|
174
|
+
this.rawCauses.set(pathKey, event.cause ?? "invalid");
|
|
165
175
|
this.markRaw(event.path, event.reason, event.value);
|
|
166
176
|
return;
|
|
167
177
|
}
|
|
@@ -360,10 +370,11 @@ var IrTree = class {
|
|
|
360
370
|
const isRaw = rootRawReason !== null;
|
|
361
371
|
const identifiedKind = this.identifiedKinds.get("") ?? "";
|
|
362
372
|
const rootKind = isRaw ? this.rawKinds.get("") ?? "" : rootNode?.kind ?? (this.completedKind || identifiedKind);
|
|
373
|
+
const rootRawState = this.rawCauses.get("") === "unverified" ? "unverified" : "raw";
|
|
363
374
|
const root = {
|
|
364
375
|
role: "structured",
|
|
365
376
|
kind: rootKind,
|
|
366
|
-
kindState: isRaw ?
|
|
377
|
+
kindState: isRaw ? rootRawState : rootNode ? rootNode.kindState : this.pendingSchemaPaths.has("") ? "pending_schema" : this.regionStatus === "streaming" ? identifiedKind ? "pending_schema" : "pending_kind" : "raw",
|
|
367
378
|
discriminator: JSON_DISCRIMINATOR,
|
|
368
379
|
path: [],
|
|
369
380
|
status: this.regionStatus,
|
|
@@ -386,7 +397,7 @@ var IrTree = class {
|
|
|
386
397
|
if (pathKey === "") continue;
|
|
387
398
|
nodeIndex[pathKey] = {
|
|
388
399
|
kind: this.rawKinds.get(pathKey) ?? "",
|
|
389
|
-
kindState: "raw",
|
|
400
|
+
kindState: this.rawCauses.get(pathKey) === "unverified" ? "unverified" : "raw",
|
|
390
401
|
status: "complete"
|
|
391
402
|
};
|
|
392
403
|
}
|
|
@@ -726,7 +737,8 @@ var KindStreamParser = class {
|
|
|
726
737
|
safeCopy(value),
|
|
727
738
|
`No block schema registered for "${kind}".`,
|
|
728
739
|
at,
|
|
729
|
-
kind
|
|
740
|
+
kind,
|
|
741
|
+
"unverified"
|
|
730
742
|
);
|
|
731
743
|
}
|
|
732
744
|
}
|
|
@@ -760,7 +772,8 @@ var KindStreamParser = class {
|
|
|
760
772
|
safeCopy(value ?? {}),
|
|
761
773
|
`No block schema registered for "${kind}".`,
|
|
762
774
|
at,
|
|
763
|
-
kind
|
|
775
|
+
kind,
|
|
776
|
+
"unverified"
|
|
764
777
|
);
|
|
765
778
|
this.closedPendingPaths.delete(pathKey);
|
|
766
779
|
continue;
|
|
@@ -1306,7 +1319,8 @@ var KindStreamParser = class {
|
|
|
1306
1319
|
objectValue,
|
|
1307
1320
|
`No block schema registered for "${kind}".`,
|
|
1308
1321
|
at,
|
|
1309
|
-
kind
|
|
1322
|
+
kind,
|
|
1323
|
+
"unverified"
|
|
1310
1324
|
);
|
|
1311
1325
|
return;
|
|
1312
1326
|
}
|
|
@@ -1340,7 +1354,8 @@ var KindStreamParser = class {
|
|
|
1340
1354
|
objectValue,
|
|
1341
1355
|
`No block schema registered for "${kind}".`,
|
|
1342
1356
|
at,
|
|
1343
|
-
kind
|
|
1357
|
+
kind,
|
|
1358
|
+
"unverified"
|
|
1344
1359
|
);
|
|
1345
1360
|
return;
|
|
1346
1361
|
}
|
|
@@ -1413,7 +1428,15 @@ var KindStreamParser = class {
|
|
|
1413
1428
|
this.speculativeKinds.delete(pathKey);
|
|
1414
1429
|
this.emitRawObject(path, safeCopy(liveValue), reason, at, identifiedKind);
|
|
1415
1430
|
}
|
|
1416
|
-
|
|
1431
|
+
/**
|
|
1432
|
+
* Degrade ONE node off the resolved path.
|
|
1433
|
+
*
|
|
1434
|
+
* `cause` defaults to `"invalid"` deliberately: every call site that omits
|
|
1435
|
+
* it is a real failure (validation, duplicate key, placement, contradicted
|
|
1436
|
+
* speculation). ONLY the "no schema registered" sites pass `"unverified"`,
|
|
1437
|
+
* and they are the reason the parameter exists — see `IrKindState`.
|
|
1438
|
+
*/
|
|
1439
|
+
emitRawObject(path, value, reason, at, identifiedKind, cause = "invalid") {
|
|
1417
1440
|
const pathKey = this.pathKey(path);
|
|
1418
1441
|
if (this.rawObjectPaths.has(pathKey)) return;
|
|
1419
1442
|
this.rawObjectPaths.add(pathKey);
|
|
@@ -1424,6 +1447,7 @@ var KindStreamParser = class {
|
|
|
1424
1447
|
value,
|
|
1425
1448
|
reason,
|
|
1426
1449
|
...identifiedKind !== void 0 && { kind: identifiedKind },
|
|
1450
|
+
cause,
|
|
1427
1451
|
at
|
|
1428
1452
|
});
|
|
1429
1453
|
}
|
|
@@ -2993,21 +3017,26 @@ function fieldSchemaSummary(field) {
|
|
|
2993
3017
|
function resolvePrimaryType(node) {
|
|
2994
3018
|
const raw = node.type;
|
|
2995
3019
|
if (typeof raw === "string") {
|
|
2996
|
-
|
|
3020
|
+
const t = raw === "integer" ? "number" : raw;
|
|
3021
|
+
return { type: t, nullable: false, members: [t] };
|
|
2997
3022
|
}
|
|
2998
3023
|
if (Array.isArray(raw)) {
|
|
2999
3024
|
const types = raw.filter((t) => typeof t === "string");
|
|
3000
3025
|
const nullable = types.includes("null");
|
|
3001
|
-
const
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
if (node.
|
|
3010
|
-
|
|
3026
|
+
const members = [
|
|
3027
|
+
...new Set(
|
|
3028
|
+
types.filter((t) => t !== "null").map((t) => t === "integer" ? "number" : t)
|
|
3029
|
+
)
|
|
3030
|
+
];
|
|
3031
|
+
const primary = members[0] ?? (nullable && types.length === 1 ? "null" : null);
|
|
3032
|
+
return { type: primary ?? null, nullable, members };
|
|
3033
|
+
}
|
|
3034
|
+
if (node.enum) return { type: "string", nullable: false, members: ["string"] };
|
|
3035
|
+
if (node.properties)
|
|
3036
|
+
return { type: "object", nullable: false, members: ["object"] };
|
|
3037
|
+
if (node.items)
|
|
3038
|
+
return { type: "array", nullable: false, members: ["array"] };
|
|
3039
|
+
return { type: null, nullable: false, members: [] };
|
|
3011
3040
|
}
|
|
3012
3041
|
function carriedMetadataKeys(field) {
|
|
3013
3042
|
if (field === null) return /* @__PURE__ */ new Set();
|
|
@@ -3142,6 +3171,29 @@ function buildAgentSchemaWithRenderBlockSupport(input, rootKindSlug, arrayBindin
|
|
|
3142
3171
|
}
|
|
3143
3172
|
return updatedRoot;
|
|
3144
3173
|
}
|
|
3174
|
+
function resolveRef(ref, ctx) {
|
|
3175
|
+
if (ref === "#" || ref === "#/") {
|
|
3176
|
+
return { slug: ctx.schemaName, node: ctx.rootSchema };
|
|
3177
|
+
}
|
|
3178
|
+
const match = /^#\/(?:\$defs|definitions)\/(.+)$/.exec(ref);
|
|
3179
|
+
if (!match) return null;
|
|
3180
|
+
const name = decodeURIComponent(
|
|
3181
|
+
(match[1] ?? "").replace(/~1/g, "/").replace(/~0/g, "~")
|
|
3182
|
+
);
|
|
3183
|
+
const node = ctx.defs[name];
|
|
3184
|
+
if (!isRecord4(node)) return null;
|
|
3185
|
+
const declared = isRecord4(node.properties) ? readBlockKindFromProperties(node.properties) : null;
|
|
3186
|
+
return { slug: declared ?? name, node };
|
|
3187
|
+
}
|
|
3188
|
+
function refToObjectField(resolved, path, ctx) {
|
|
3189
|
+
if (ctx.refsInProgress.has(resolved.slug)) return;
|
|
3190
|
+
ctx.refsInProgress.add(resolved.slug);
|
|
3191
|
+
try {
|
|
3192
|
+
registerDeclaredKindDraft(resolved.slug, resolved.node, path, ctx);
|
|
3193
|
+
} finally {
|
|
3194
|
+
ctx.refsInProgress.delete(resolved.slug);
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3145
3197
|
function isAnyValueSchema(node) {
|
|
3146
3198
|
return node.type === void 0 && node.enum === void 0 && node.const === void 0 && node.properties === void 0 && node.items === void 0 && node.additionalProperties === void 0 && node.anyOf === void 0 && node.oneOf === void 0 && node.allOf === void 0 && node.$ref === void 0;
|
|
3147
3199
|
}
|
|
@@ -3178,12 +3230,21 @@ function convertProperty(fieldName, node, required, path, ctx) {
|
|
|
3178
3230
|
}
|
|
3179
3231
|
function convertPropertyCore(fieldName, node, required, path, ctx) {
|
|
3180
3232
|
if (typeof node.$ref === "string") {
|
|
3181
|
-
ctx
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3233
|
+
const resolved = resolveRef(node.$ref, ctx);
|
|
3234
|
+
if (!resolved) {
|
|
3235
|
+
ctx.problems.push({
|
|
3236
|
+
severity: "error",
|
|
3237
|
+
path,
|
|
3238
|
+
message: `Unresolvable $ref ("${node.$ref}") \u2014 only "#", "#/$defs/<name>" and "#/definitions/<name>" are supported.`
|
|
3239
|
+
});
|
|
3240
|
+
return null;
|
|
3241
|
+
}
|
|
3242
|
+
refToObjectField(resolved, path, ctx);
|
|
3243
|
+
return {
|
|
3244
|
+
...requiredNullableFlags(required),
|
|
3245
|
+
type: "object",
|
|
3246
|
+
kind: resolved.slug
|
|
3247
|
+
};
|
|
3187
3248
|
}
|
|
3188
3249
|
if (Array.isArray(node.anyOf) || Array.isArray(node.oneOf)) {
|
|
3189
3250
|
const variants = node.anyOf ?? node.oneOf;
|
|
@@ -3199,12 +3260,18 @@ function convertPropertyCore(fieldName, node, required, path, ctx) {
|
|
|
3199
3260
|
continue;
|
|
3200
3261
|
}
|
|
3201
3262
|
if (typeof variant.$ref === "string") {
|
|
3202
|
-
ctx
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3263
|
+
const resolvedVariant = resolveRef(variant.$ref, ctx);
|
|
3264
|
+
if (!resolvedVariant) {
|
|
3265
|
+
ctx.problems.push({
|
|
3266
|
+
severity: "error",
|
|
3267
|
+
path,
|
|
3268
|
+
message: `Unresolvable $ref inside anyOf/oneOf ("${variant.$ref}").`
|
|
3269
|
+
});
|
|
3270
|
+
unsupported = true;
|
|
3271
|
+
continue;
|
|
3272
|
+
}
|
|
3273
|
+
refToObjectField(resolvedVariant, path, ctx);
|
|
3274
|
+
memberKinds.push(resolvedVariant.slug);
|
|
3208
3275
|
continue;
|
|
3209
3276
|
}
|
|
3210
3277
|
const { type: type2, nullable: nullable2 } = resolvePrimaryType(variant);
|
|
@@ -3325,7 +3392,34 @@ function convertPropertyCore(fieldName, node, required, path, ctx) {
|
|
|
3325
3392
|
});
|
|
3326
3393
|
return { ...requiredNullableFlags(required), type: "json" };
|
|
3327
3394
|
}
|
|
3328
|
-
const { type, nullable } = resolvePrimaryType(node);
|
|
3395
|
+
const { type, nullable, members } = resolvePrimaryType(node);
|
|
3396
|
+
if (members.length > 1) {
|
|
3397
|
+
const objectish = members.some((m) => m === "object" || m === "array");
|
|
3398
|
+
if (objectish) {
|
|
3399
|
+
ctx.problems.push({
|
|
3400
|
+
severity: "info",
|
|
3401
|
+
path,
|
|
3402
|
+
message: `Union of [${members.join(", ")}] at "${path || "(root)"}" spans objects/arrays \u2014 carried as any JSON value (json).`
|
|
3403
|
+
});
|
|
3404
|
+
return { ...requiredNullableFlags(required), type: "json" };
|
|
3405
|
+
}
|
|
3406
|
+
const scalars = members.filter(
|
|
3407
|
+
(m) => m === "string" || m === "number" || m === "boolean"
|
|
3408
|
+
);
|
|
3409
|
+
if (scalars.length === members.length && scalars.length > 1) {
|
|
3410
|
+
return {
|
|
3411
|
+
...requiredNullableFlags(required, nullable),
|
|
3412
|
+
type: "union",
|
|
3413
|
+
scalars
|
|
3414
|
+
};
|
|
3415
|
+
}
|
|
3416
|
+
ctx.problems.push({
|
|
3417
|
+
severity: "warning",
|
|
3418
|
+
path,
|
|
3419
|
+
message: `Union of [${members.join(", ")}] at "${path || "(root)"}" has no exact field type \u2014 carried as any JSON value (json) rather than narrowed to "${type}".`
|
|
3420
|
+
});
|
|
3421
|
+
return { ...requiredNullableFlags(required), type: "json" };
|
|
3422
|
+
}
|
|
3329
3423
|
if (type === "string") {
|
|
3330
3424
|
if (Array.isArray(node.enum)) {
|
|
3331
3425
|
const values = node.enum.filter(
|
|
@@ -3380,6 +3474,27 @@ function convertPropertyCore(fieldName, node, required, path, ctx) {
|
|
|
3380
3474
|
});
|
|
3381
3475
|
return null;
|
|
3382
3476
|
}
|
|
3477
|
+
if (typeof itemNode.$ref === "string") {
|
|
3478
|
+
const resolvedItem = resolveRef(itemNode.$ref, ctx);
|
|
3479
|
+
if (!resolvedItem) {
|
|
3480
|
+
ctx.problems.push({
|
|
3481
|
+
severity: "error",
|
|
3482
|
+
path: `${path}[]`,
|
|
3483
|
+
message: `Unresolvable $ref in array items ("${itemNode.$ref}").`
|
|
3484
|
+
});
|
|
3485
|
+
return null;
|
|
3486
|
+
}
|
|
3487
|
+
refToObjectField(resolvedItem, `${path}[]`, ctx);
|
|
3488
|
+
ctx.arrayBindings.push({
|
|
3489
|
+
arrayField: fieldName,
|
|
3490
|
+
itemKindSlug: resolvedItem.slug
|
|
3491
|
+
});
|
|
3492
|
+
return {
|
|
3493
|
+
...requiredNullableFlags(required, nullable),
|
|
3494
|
+
type: "array",
|
|
3495
|
+
itemKinds: [resolvedItem.slug]
|
|
3496
|
+
};
|
|
3497
|
+
}
|
|
3383
3498
|
if (isAnyValueSchema(itemNode)) {
|
|
3384
3499
|
return {
|
|
3385
3500
|
...requiredNullableFlags(required, nullable),
|
|
@@ -3414,11 +3529,29 @@ function convertPropertyCore(fieldName, node, required, path, ctx) {
|
|
|
3414
3529
|
}
|
|
3415
3530
|
const itemKinds = [];
|
|
3416
3531
|
for (const variant of itemVariants) {
|
|
3532
|
+
if (isRecord4(variant) && typeof variant.$ref === "string") {
|
|
3533
|
+
const resolvedVariant = resolveRef(variant.$ref, ctx);
|
|
3534
|
+
if (!resolvedVariant) {
|
|
3535
|
+
ctx.problems.push({
|
|
3536
|
+
severity: "error",
|
|
3537
|
+
path: `${path}[]`,
|
|
3538
|
+
message: `Unresolvable $ref in array items anyOf ("${variant.$ref}").`
|
|
3539
|
+
});
|
|
3540
|
+
return null;
|
|
3541
|
+
}
|
|
3542
|
+
itemKinds.push(resolvedVariant.slug);
|
|
3543
|
+
refToObjectField(resolvedVariant, `${path}[]<${resolvedVariant.slug}>`, ctx);
|
|
3544
|
+
ctx.arrayBindings.push({
|
|
3545
|
+
arrayField: fieldName,
|
|
3546
|
+
itemKindSlug: resolvedVariant.slug
|
|
3547
|
+
});
|
|
3548
|
+
continue;
|
|
3549
|
+
}
|
|
3417
3550
|
if (!isRecord4(variant) || !isRecord4(variant.properties)) {
|
|
3418
3551
|
ctx.problems.push({
|
|
3419
3552
|
severity: "error",
|
|
3420
3553
|
path: `${path}[]`,
|
|
3421
|
-
message: "Array items anyOf/oneOf variants must be inline objects declaring __kind."
|
|
3554
|
+
message: "Array items anyOf/oneOf variants must be inline objects declaring __kind, or $refs to defs."
|
|
3422
3555
|
});
|
|
3423
3556
|
return null;
|
|
3424
3557
|
}
|
|
@@ -3552,6 +3685,14 @@ function convertPropertyCore(fieldName, node, required, path, ctx) {
|
|
|
3552
3685
|
kind: referencedKind
|
|
3553
3686
|
};
|
|
3554
3687
|
}
|
|
3688
|
+
if (Object.keys(nestedFields).length === 0 && !apIsOpen && isRecord4(ap) && KIND_KEY in node.properties) {
|
|
3689
|
+
const apType = resolvePrimaryType(ap).type;
|
|
3690
|
+
return {
|
|
3691
|
+
...requiredNullableFlags(required, nullable),
|
|
3692
|
+
type: "record",
|
|
3693
|
+
values: apType === "string" || apType === "number" || apType === "boolean" ? apType : "json"
|
|
3694
|
+
};
|
|
3695
|
+
}
|
|
3555
3696
|
let open = apIsOpen;
|
|
3556
3697
|
if (!apIsOpen && isRecord4(ap)) {
|
|
3557
3698
|
ctx.problems.push({
|
|
@@ -3668,12 +3809,21 @@ function normalizeAiSchemaInput(input) {
|
|
|
3668
3809
|
return { name: null, strict: null, rootSchema: null, parseErrors };
|
|
3669
3810
|
}
|
|
3670
3811
|
function convertAiSchemaToBlockFields(schemaName, rootSchema, strict) {
|
|
3812
|
+
const rawDefs = isRecord4(rootSchema.$defs) ? rootSchema.$defs : isRecord4(rootSchema.definitions) ? rootSchema.definitions : {};
|
|
3813
|
+
const defs = {};
|
|
3814
|
+
for (const [name, node] of Object.entries(rawDefs)) {
|
|
3815
|
+
if (isRecord4(node)) defs[name] = node;
|
|
3816
|
+
}
|
|
3671
3817
|
const ctx = {
|
|
3672
3818
|
schemaName,
|
|
3819
|
+
strict,
|
|
3673
3820
|
problems: [],
|
|
3674
3821
|
droppedMetadata: [],
|
|
3675
3822
|
blockSchemas: [],
|
|
3676
|
-
arrayBindings: []
|
|
3823
|
+
arrayBindings: [],
|
|
3824
|
+
defs,
|
|
3825
|
+
rootSchema,
|
|
3826
|
+
refsInProgress: /* @__PURE__ */ new Set()
|
|
3677
3827
|
};
|
|
3678
3828
|
ctx.droppedMetadata.push(...collectDropped(rootSchema, ""));
|
|
3679
3829
|
const rootAp = rootSchema.additionalProperties;
|