@contentful/experience-design-system-types 2.42.1-dev-build-f69db6bf.0 → 2.43.0-alpha.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 (94) hide show
  1. package/README.md +15 -0
  2. package/dist/package.json +1 -1
  3. package/dist/src/agent-process-lifecycle.d.ts +26 -0
  4. package/dist/src/agent-process-lifecycle.js +171 -0
  5. package/dist/src/agent-prompt-artifact.d.ts +8 -0
  6. package/dist/src/agent-prompt-artifact.js +37 -0
  7. package/dist/src/agent-prompt-transport.d.ts +1 -0
  8. package/dist/src/agent-prompt-transport.js +4 -0
  9. package/dist/src/cdf/build.d.ts +9 -2
  10. package/dist/src/cdf/build.js +134 -17
  11. package/dist/src/cdf/finite-values.d.ts +8 -0
  12. package/dist/src/cdf/finite-values.js +21 -0
  13. package/dist/src/cdf/index.d.ts +2 -1
  14. package/dist/src/cdf/index.js +1 -0
  15. package/dist/src/cdf/property-validation.d.ts +16 -0
  16. package/dist/src/cdf/property-validation.js +211 -0
  17. package/dist/src/cdf/representation-validation.d.ts +6 -0
  18. package/dist/src/cdf/representation-validation.js +182 -0
  19. package/dist/src/cdf/schema.d.ts +778 -20
  20. package/dist/src/cdf/schema.js +362 -5
  21. package/dist/src/cdf/types.d.ts +57 -59
  22. package/dist/src/cdf/types.js +72 -15
  23. package/dist/src/cdf/validate.js +31 -1
  24. package/dist/src/cdf/vocabularies.d.ts +1 -1
  25. package/dist/src/cdf/vocabularies.js +9 -1
  26. package/dist/src/config/index.js +6 -3
  27. package/dist/src/exploration/constants.d.ts +10 -0
  28. package/dist/src/exploration/constants.js +18 -0
  29. package/dist/src/exploration/index.d.ts +3 -0
  30. package/dist/src/exploration/index.js +3 -0
  31. package/dist/src/exploration/schemas.d.ts +201 -0
  32. package/dist/src/exploration/schemas.js +126 -0
  33. package/dist/src/exploration/types.d.ts +393 -0
  34. package/dist/src/exploration/types.js +1 -0
  35. package/dist/src/handoff/index.d.ts +1 -1
  36. package/dist/src/index.d.ts +15 -1
  37. package/dist/src/index.js +12 -4
  38. package/dist/src/property-contract/analysis-representation-candidates.d.ts +19 -0
  39. package/dist/src/property-contract/analysis-representation-candidates.js +45 -0
  40. package/dist/src/property-contract/classification.d.ts +38 -0
  41. package/dist/src/property-contract/classification.js +84 -0
  42. package/dist/src/property-contract/compact-model-components.d.ts +16 -0
  43. package/dist/src/property-contract/compact-model-components.js +113 -0
  44. package/dist/src/property-contract/content-digest.d.ts +2 -0
  45. package/dist/src/property-contract/content-digest.js +69 -0
  46. package/dist/src/property-contract/decision-protocol.d.ts +45 -0
  47. package/dist/src/property-contract/decision-protocol.js +251 -0
  48. package/dist/src/property-contract/definition-import-rules.d.ts +10 -0
  49. package/dist/src/property-contract/definition-import-rules.js +105 -0
  50. package/dist/src/property-contract/definition-import.d.ts +13 -0
  51. package/dist/src/property-contract/definition-import.js +52 -0
  52. package/dist/src/property-contract/discriminated-union-source.d.ts +17 -0
  53. package/dist/src/property-contract/discriminated-union-source.js +180 -0
  54. package/dist/src/property-contract/import-prerequisites.d.ts +70 -0
  55. package/dist/src/property-contract/import-prerequisites.js +208 -0
  56. package/dist/src/property-contract/index.d.ts +18 -1
  57. package/dist/src/property-contract/index.js +18 -6
  58. package/dist/src/property-contract/logical-source-graph.d.ts +36 -0
  59. package/dist/src/property-contract/logical-source-graph.js +240 -0
  60. package/dist/src/property-contract/mapper-readiness.d.ts +6 -0
  61. package/dist/src/property-contract/mapper-readiness.js +34 -0
  62. package/dist/src/property-contract/model-exploration.d.ts +42 -0
  63. package/dist/src/property-contract/model-exploration.js +94 -0
  64. package/dist/src/property-contract/native-source-region.d.ts +5 -0
  65. package/dist/src/property-contract/native-source-region.js +125 -0
  66. package/dist/src/property-contract/null-handling.d.ts +10 -0
  67. package/dist/src/property-contract/null-handling.js +45 -0
  68. package/dist/src/property-contract/physical-property-import.d.ts +6 -0
  69. package/dist/src/property-contract/physical-property-import.js +55 -0
  70. package/dist/src/property-contract/property-decision.d.ts +14 -0
  71. package/dist/src/property-contract/property-decision.js +155 -0
  72. package/dist/src/property-contract/property-model.d.ts +197 -0
  73. package/dist/src/property-contract/property-model.js +833 -0
  74. package/dist/src/property-contract/representation-plan.d.ts +133 -0
  75. package/dist/src/property-contract/representation-plan.js +756 -0
  76. package/dist/src/property-contract/representation-proposal.d.ts +65 -0
  77. package/dist/src/property-contract/representation-proposal.js +204 -0
  78. package/dist/src/property-contract/resource-link-schema.d.ts +55 -0
  79. package/dist/src/property-contract/resource-link-schema.js +28 -0
  80. package/dist/src/property-contract/source-representation.d.ts +9 -0
  81. package/dist/src/property-contract/source-representation.js +79 -0
  82. package/dist/src/property-contract/target-definition.d.ts +17 -16
  83. package/dist/src/property-contract/target-definition.js +4 -26
  84. package/dist/src/schema-export.d.ts +30 -0
  85. package/dist/src/schema-export.js +285 -0
  86. package/dist/src/shared-source.d.ts +105 -0
  87. package/dist/src/shared-source.js +1 -0
  88. package/dist/src/source-input-association.d.ts +23 -0
  89. package/dist/src/source-input-association.js +52 -0
  90. package/dist/src/sources-api/preview/index.d.ts +37 -3
  91. package/dist/src/sources-api/preview/index.js +39 -1
  92. package/dist/src/sources-api/preview/schema.d.ts +2 -0
  93. package/dist/src/sources-api/preview/schema.js +74 -0
  94. package/package.json +1 -1
@@ -0,0 +1,65 @@
1
+ import { type JsonValue, type PropertyIssue } from './json-value.js';
2
+ import { type TargetPropertyType, type TargetDefinition } from './target-definition.js';
3
+ import { type MapperAvailability, type PropertyModel } from './property-model.js';
4
+ export interface RepresentationProposalDraft {
5
+ componentId: string;
6
+ propertyId: string;
7
+ key: string;
8
+ name: string;
9
+ sourceRevision: string;
10
+ sourceNodeIds: string[];
11
+ declaredConstraints: Array<{
12
+ nodeId: string;
13
+ statement: string;
14
+ }>;
15
+ provenConstraints: Array<{
16
+ nodeId: string;
17
+ statement: string;
18
+ }>;
19
+ observations: Array<{
20
+ nodeId: string;
21
+ value: JsonValue;
22
+ }>;
23
+ judgment: string;
24
+ desiredType: TargetPropertyType;
25
+ desiredDefinition: TargetDefinition;
26
+ compatibility?: {
27
+ status: 'judged-compatible' | 'unresolved' | 'contradicted';
28
+ sourceUseRefs: string[];
29
+ unresolvedRequirements: string[];
30
+ };
31
+ }
32
+ export declare const REPRESENTATION_PROPOSAL_EVIDENCE_FIELDS: {
33
+ readonly declaredConstraints: "statement";
34
+ readonly provenConstraints: "statement";
35
+ readonly observations: "value";
36
+ };
37
+ export interface MapperReadiness {
38
+ requirements: Array<{
39
+ path: string;
40
+ capability: string;
41
+ availability: MapperAvailability;
42
+ }>;
43
+ status: MapperAvailability;
44
+ }
45
+ export interface ValidatedRepresentationProposal {
46
+ draft: Readonly<RepresentationProposalDraft>;
47
+ readiness: Readonly<MapperReadiness>;
48
+ }
49
+ export declare function validateProposalDraft(input: unknown): PropertyIssue[];
50
+ /** Check source binding independently of caller-owned mapper readiness. */
51
+ export declare function validateRepresentationProposalSource(input: unknown, model: PropertyModel): {
52
+ valid: boolean;
53
+ issues: PropertyIssue[];
54
+ draft?: Readonly<RepresentationProposalDraft>;
55
+ };
56
+ export declare function validateRepresentationProposal(input: unknown, model: PropertyModel, mapperReadinessFor: (draft: Readonly<RepresentationProposalDraft>) => MapperReadiness): {
57
+ valid: boolean;
58
+ issues: PropertyIssue[];
59
+ proposal?: ValidatedRepresentationProposal;
60
+ };
61
+ /** Staged transport has no apply, database or readiness side effects. */
62
+ export declare function parseRepresentationProposalDrafts(stdout: string): {
63
+ drafts: RepresentationProposalDraft[];
64
+ warnings: string[];
65
+ };
@@ -0,0 +1,204 @@
1
+ import { cloneJson, freezeJson, jsonValueIssue } from './json-value.js';
2
+ import { validateTargetDefinition, TARGET_PROPERTY_TYPES, } from './target-definition.js';
3
+ import { validateSourceGraph } from './property-model.js';
4
+ import { isSourceBoundRepresentation, sourceDomainHasKind, sourceJsonCompatibility } from './source-representation.js';
5
+ import { containsTargetDefinitionType } from './target-definition.js';
6
+ import { validateDiscriminatedUnionSourceDefinition } from './discriminated-union-source.js';
7
+ export const REPRESENTATION_PROPOSAL_EVIDENCE_FIELDS = {
8
+ declaredConstraints: 'statement',
9
+ provenConstraints: 'statement',
10
+ observations: 'value',
11
+ };
12
+ export function validateProposalDraft(input) {
13
+ const unsafe = jsonValueIssue(input);
14
+ if (unsafe)
15
+ return [unsafe];
16
+ if (!input || typeof input !== 'object' || Array.isArray(input))
17
+ return [{ path: '', message: 'Expected proposal draft' }];
18
+ const draft = input;
19
+ const issues = [];
20
+ const keys = [
21
+ 'componentId',
22
+ 'propertyId',
23
+ 'key',
24
+ 'name',
25
+ 'sourceRevision',
26
+ 'sourceNodeIds',
27
+ 'declaredConstraints',
28
+ 'provenConstraints',
29
+ 'observations',
30
+ 'judgment',
31
+ 'desiredType',
32
+ 'desiredDefinition',
33
+ 'compatibility',
34
+ ];
35
+ for (const key of Object.keys(draft))
36
+ if (!keys.includes(key))
37
+ issues.push({ path: `/${key}`, message: 'Unexpected draft member; readiness is caller-owned' });
38
+ for (const key of ['componentId', 'propertyId', 'key', 'name', 'sourceRevision', 'judgment'])
39
+ if (typeof draft[key] !== 'string' || !draft[key])
40
+ issues.push({ path: `/${key}`, message: 'Expected nonempty string' });
41
+ if (!Array.isArray(draft.sourceNodeIds) ||
42
+ !draft.sourceNodeIds.length ||
43
+ !draft.sourceNodeIds.every((id) => typeof id === 'string') ||
44
+ new Set(draft.sourceNodeIds).size !== draft.sourceNodeIds.length)
45
+ issues.push({ path: '/sourceNodeIds', message: 'Expected unique source node identities' });
46
+ for (const [channel, member] of Object.entries(REPRESENTATION_PROPOSAL_EVIDENCE_FIELDS)) {
47
+ const values = draft[channel];
48
+ if (!Array.isArray(values)) {
49
+ issues.push({ path: `/${channel}`, message: `Expected evidence list of { nodeId, ${member} } objects` });
50
+ continue;
51
+ }
52
+ values.forEach((value, i) => {
53
+ const allowed = ['nodeId', member];
54
+ if (!value ||
55
+ typeof value !== 'object' ||
56
+ typeof value.nodeId !== 'string' ||
57
+ Object.keys(value).some((key) => !allowed.includes(key)) ||
58
+ (channel === 'observations'
59
+ ? !Object.hasOwn(value, 'value')
60
+ : typeof value.statement !== 'string'))
61
+ issues.push({
62
+ path: `/${channel}/${i}`,
63
+ message: `Invalid evidence reference; expected { nodeId, ${member} }`,
64
+ });
65
+ });
66
+ }
67
+ if (!TARGET_PROPERTY_TYPES.includes(draft.desiredType) || draft.desiredDefinition?.type !== draft.desiredType)
68
+ issues.push({ path: '/desiredType', message: 'Desired type disagrees with definition' });
69
+ for (const issue of validateTargetDefinition(draft.desiredDefinition).issues)
70
+ issues.push({ path: `/desiredDefinition${issue.path}`, message: issue.message });
71
+ if (draft.compatibility !== undefined) {
72
+ const compatibility = draft.compatibility;
73
+ if (!compatibility ||
74
+ !['judged-compatible', 'unresolved', 'contradicted'].includes(compatibility.status) ||
75
+ !Array.isArray(compatibility.sourceUseRefs) ||
76
+ !compatibility.sourceUseRefs.every((ref) => typeof ref === 'string' && ref.length > 0) ||
77
+ new Set(compatibility.sourceUseRefs).size !== compatibility.sourceUseRefs.length ||
78
+ !Array.isArray(compatibility.unresolvedRequirements) ||
79
+ !compatibility.unresolvedRequirements.every((ref) => typeof ref === 'string' && ref.length > 0) ||
80
+ Object.keys(compatibility).some((key) => !['status', 'sourceUseRefs', 'unresolvedRequirements'].includes(key)))
81
+ issues.push({ path: '/compatibility', message: 'Invalid source compatibility judgment' });
82
+ }
83
+ return issues;
84
+ }
85
+ /** Check source binding independently of caller-owned mapper readiness. */
86
+ export function validateRepresentationProposalSource(input, model) {
87
+ const issues = validateProposalDraft(input);
88
+ if (issues.length)
89
+ return { valid: false, issues };
90
+ const draft = input;
91
+ for (const key of ['componentId', 'propertyId', 'key', 'sourceRevision'])
92
+ if (draft[key] !== model.identity[key])
93
+ issues.push({ path: `/${key}`, message: 'Stale or mismatched source identity' });
94
+ issues.push(...validateSourceGraph(model.source.graph));
95
+ if (!issues.length && containsTargetDefinitionType(draft.desiredDefinition, 'DiscriminatedUnion'))
96
+ issues.push(...validateDiscriminatedUnionSourceDefinition(draft.desiredDefinition, model.source.graph).map((issue) => ({
97
+ ...issue,
98
+ path: '/desiredDefinition' + issue.path,
99
+ })));
100
+ const ids = new Set(model.source.graph.nodes.map((node) => node.id));
101
+ for (const id of [
102
+ ...draft.sourceNodeIds,
103
+ ...draft.declaredConstraints.map((c) => c.nodeId),
104
+ ...draft.provenConstraints.map((c) => c.nodeId),
105
+ ...draft.observations.map((o) => o.nodeId),
106
+ ])
107
+ if (!ids.has(id))
108
+ issues.push({ path: '/sourceNodeIds', message: 'Unknown source node reference' });
109
+ if (!draft.sourceNodeIds.includes(model.identity.nodeId))
110
+ issues.push({ path: '/sourceNodeIds', message: 'Property source root missing' });
111
+ if (isSourceBoundRepresentation(draft.desiredType)) {
112
+ const compatibility = draft.compatibility;
113
+ const add = (message) => {
114
+ issues.push({ path: '/compatibility', message });
115
+ };
116
+ if (!compatibility)
117
+ add('Source-bound representation requires an explicit compatibility judgment');
118
+ else {
119
+ const uses = new Map((model.source.useEvidence ?? []).map((use) => [use.reference, use.status]));
120
+ if (compatibility.sourceUseRefs.some((ref) => !uses.has(ref)))
121
+ add('Unknown current source use reference');
122
+ if (compatibility.status === 'judged-compatible') {
123
+ if (!compatibility.sourceUseRefs.length ||
124
+ compatibility.sourceUseRefs.some((ref) => uses.get(ref) !== 'output-flow-found'))
125
+ add('Compatible judgment requires current positive output-flow evidence');
126
+ if (draft.desiredType === 'RichText' &&
127
+ sourceDomainHasKind(model.source.graph, [
128
+ 'string',
129
+ 'number',
130
+ 'boolean',
131
+ 'bigint',
132
+ 'symbol',
133
+ 'function',
134
+ 'never',
135
+ ]))
136
+ add('Primitive source domain contradicts document compatibility');
137
+ if (draft.desiredType === 'JSON' && sourceJsonCompatibility(model.source.graph) !== 'compatible')
138
+ add('Complete JSON-compatible source semantics are required');
139
+ if (draft.desiredType === 'ResourceLink') {
140
+ const root = model.source.graph.nodes.find((node) => node.id === model.source.graph.rootId);
141
+ if (model.source.graph.coverage !== 'complete-within-declared-bound' ||
142
+ root?.nullability?.null.state !== 'absent' ||
143
+ root.nullability.undefined.state !== 'absent' ||
144
+ sourceDomainHasKind(model.source.graph, ['boolean']))
145
+ add('Complete nonnullable resource-compatible source semantics are required');
146
+ if (!compatibility.unresolvedRequirements.length)
147
+ add('Resource and delivery prerequisites must remain explicit');
148
+ }
149
+ }
150
+ }
151
+ if (draft.desiredType === 'ResourceLink' && Object.hasOwn(draft.desiredDefinition, 'defaultValue'))
152
+ add('Resource defaults require a verified resource-value delivery contract');
153
+ }
154
+ if (issues.length)
155
+ return { valid: false, issues };
156
+ return { valid: true, issues: [], draft: freezeJson(cloneJson(draft)) };
157
+ }
158
+ export function validateRepresentationProposal(input, model, mapperReadinessFor) {
159
+ const source = validateRepresentationProposalSource(input, model);
160
+ if (!source.valid || !source.draft)
161
+ return { valid: false, issues: source.issues };
162
+ const frozen = source.draft;
163
+ const readiness = mapperReadinessFor(frozen);
164
+ const unsafe = jsonValueIssue(readiness);
165
+ if (unsafe ||
166
+ !readiness ||
167
+ !Array.isArray(readiness.requirements) ||
168
+ readiness.requirements.some((r) => !r ||
169
+ typeof r.path !== 'string' ||
170
+ typeof r.capability !== 'string' ||
171
+ !['enabled', 'unavailable', 'unknown'].includes(r.availability) ||
172
+ Object.keys(r).some((key) => !['path', 'capability', 'availability'].includes(key))) ||
173
+ Object.keys(readiness).some((key) => !['requirements', 'status'].includes(key)))
174
+ return { valid: false, issues: [{ path: '/readiness', message: 'Invalid caller readiness' }] };
175
+ const status = readiness.requirements.some((r) => r.availability === 'unavailable')
176
+ ? 'unavailable'
177
+ : readiness.requirements.some((r) => r.availability === 'unknown')
178
+ ? 'unknown'
179
+ : 'enabled';
180
+ if (readiness.status !== status)
181
+ return { valid: false, issues: [{ path: '/readiness/status', message: 'Contradictory readiness summary' }] };
182
+ return { valid: true, issues: [], proposal: { draft: frozen, readiness: freezeJson(cloneJson(readiness)) } };
183
+ }
184
+ /** Staged transport has no apply, database or readiness side effects. */
185
+ export function parseRepresentationProposalDrafts(stdout) {
186
+ const drafts = [];
187
+ const warnings = [];
188
+ for (const line of stdout.split(/\r?\n/)) {
189
+ if (!line.trim())
190
+ continue;
191
+ try {
192
+ const value = JSON.parse(line);
193
+ const issues = validateProposalDraft(value);
194
+ if (issues.length)
195
+ warnings.push(...issues.map((i) => `${i.path}: ${i.message}`));
196
+ else
197
+ drafts.push(cloneJson(value));
198
+ }
199
+ catch {
200
+ warnings.push('Invalid proposal JSON');
201
+ }
202
+ }
203
+ return { drafts, warnings };
204
+ }
@@ -0,0 +1,55 @@
1
+ export declare const SAME_SPACE_RESOURCE_SOURCE = "crn:contentful:::content:spaces/$self/environments/$self";
2
+ export declare const allowedResourcesJsonSchema: {
3
+ readonly type: "array";
4
+ readonly minItems: 1;
5
+ readonly items: {
6
+ readonly type: "object";
7
+ readonly required: readonly ["type", "source"];
8
+ readonly properties: {
9
+ readonly type: {
10
+ readonly enum: readonly ["Contentful:Entry", "Contentful:Asset"];
11
+ };
12
+ readonly source: {
13
+ readonly const: "crn:contentful:::content:spaces/$self/environments/$self";
14
+ };
15
+ readonly allowedTypes: {
16
+ readonly type: "array";
17
+ readonly items: {
18
+ readonly type: "string";
19
+ };
20
+ };
21
+ };
22
+ readonly allOf: readonly [{
23
+ readonly if: {
24
+ readonly properties: {
25
+ readonly type: {
26
+ readonly const: "Contentful:Entry";
27
+ };
28
+ };
29
+ };
30
+ readonly then: {
31
+ readonly required: readonly ["allowedTypes"];
32
+ };
33
+ readonly else: {
34
+ readonly not: {
35
+ readonly required: readonly ["allowedTypes"];
36
+ };
37
+ };
38
+ }];
39
+ readonly additionalProperties: false;
40
+ };
41
+ };
42
+ export declare const targetDefinitionMetadataJsonProperties: {
43
+ readonly id: {
44
+ readonly type: "string";
45
+ };
46
+ readonly name: {
47
+ readonly type: "string";
48
+ };
49
+ readonly description: {
50
+ readonly type: "string";
51
+ };
52
+ readonly required: {
53
+ readonly type: "boolean";
54
+ };
55
+ };
@@ -0,0 +1,28 @@
1
+ export const SAME_SPACE_RESOURCE_SOURCE = 'crn:contentful:::content:spaces/$self/environments/$self';
2
+ export const allowedResourcesJsonSchema = {
3
+ type: 'array',
4
+ minItems: 1,
5
+ items: {
6
+ type: 'object',
7
+ required: ['type', 'source'],
8
+ properties: {
9
+ type: { enum: ['Contentful:Entry', 'Contentful:Asset'] },
10
+ source: { const: SAME_SPACE_RESOURCE_SOURCE },
11
+ allowedTypes: { type: 'array', items: { type: 'string' } },
12
+ },
13
+ allOf: [
14
+ {
15
+ if: { properties: { type: { const: 'Contentful:Entry' } } },
16
+ then: { required: ['allowedTypes'] },
17
+ else: { not: { required: ['allowedTypes'] } },
18
+ },
19
+ ],
20
+ additionalProperties: false,
21
+ },
22
+ };
23
+ export const targetDefinitionMetadataJsonProperties = {
24
+ id: { type: 'string' },
25
+ name: { type: 'string' },
26
+ description: { type: 'string' },
27
+ required: { type: 'boolean' },
28
+ };
@@ -0,0 +1,9 @@
1
+ import { type PropertySourceGraph } from './property-model.js';
2
+ import { type JsonValue } from './json-value.js';
3
+ export declare const SOURCE_BOUND_REPRESENTATIONS: readonly ["RichText", "JSON", "ResourceLink"];
4
+ export declare function isSourceBoundRepresentation(type: string): boolean;
5
+ /** Defaults and observed callers do not establish a closed input domain. */
6
+ export declare function finiteSourceValueDomain(graph: PropertySourceGraph, nodeId?: string): JsonValue[] | undefined;
7
+ export declare function sourceJsonCompatibility(graph: PropertySourceGraph): 'compatible' | 'unresolved' | 'contradicted';
8
+ /** Inspect only input-domain branches, not primitive fields within a structured document. */
9
+ export declare function sourceDomainHasKind(graph: PropertySourceGraph, kinds: readonly string[]): boolean;
@@ -0,0 +1,79 @@
1
+ import { validateSourceGraph } from './property-model.js';
2
+ import { jsonEqual } from './json-value.js';
3
+ export const SOURCE_BOUND_REPRESENTATIONS = ['RichText', 'JSON', 'ResourceLink'];
4
+ export function isSourceBoundRepresentation(type) {
5
+ return SOURCE_BOUND_REPRESENTATIONS.includes(type);
6
+ }
7
+ /** Defaults and observed callers do not establish a closed input domain. */
8
+ export function finiteSourceValueDomain(graph, nodeId = graph.rootId) {
9
+ if (validateSourceGraph(graph).length || graph.coverage !== 'complete-within-declared-bound' || graph.omittedCount)
10
+ return;
11
+ const nodes = new Map(graph.nodes.map((node) => [node.id, node]));
12
+ const visit = (id, active) => {
13
+ const node = nodes.get(id);
14
+ if (!node || active.has(id) || node.coverage !== 'complete-within-declared-bound')
15
+ return;
16
+ const next = new Set(active).add(id);
17
+ let values;
18
+ if (node.kind === 'union' || node.kind === 'reference') {
19
+ const members = (node.alternatives ?? []).map((ref) => visit(ref, next));
20
+ if (members.length && members.every((member) => member !== undefined)) {
21
+ values = [];
22
+ for (const value of members.flat())
23
+ if (!values.some((existing) => jsonEqual(existing, value)))
24
+ values.push(value);
25
+ }
26
+ }
27
+ else if (['string', 'number', 'boolean', 'null'].includes(node.kind) &&
28
+ node.domain.provenance === 'compiler' &&
29
+ node.domain.openness === 'closed' &&
30
+ !node.domain.unrepresentedValues?.length)
31
+ values = node.domain.declaredValues;
32
+ const nullability = node.nullability;
33
+ if (!values?.length ||
34
+ !nullability ||
35
+ nullability.compilerMode !== 'enabled' ||
36
+ nullability.null.source !== 'compiler' ||
37
+ nullability.undefined.source !== 'compiler' ||
38
+ nullability.null.state !== (values.includes(null) ? 'present' : 'absent') ||
39
+ nullability.undefined.state !== 'absent')
40
+ return;
41
+ return values;
42
+ };
43
+ return visit(nodeId, new Set());
44
+ }
45
+ export function sourceJsonCompatibility(graph) {
46
+ if (graph.coverage !== 'complete-within-declared-bound' || graph.omittedCount)
47
+ return 'unresolved';
48
+ let unresolved = false;
49
+ for (const node of graph.nodes) {
50
+ if (['undefined', 'never', 'bigint', 'symbol', 'function'].includes(node.kind) ||
51
+ node.nullability?.undefined.state === 'present' ||
52
+ node.domain.unrepresentedValues?.length ||
53
+ node.callSignatures?.length ||
54
+ node.indexSignatures?.some((index) => index.keyType === 'symbol'))
55
+ return 'contradicted';
56
+ if (!node.nullability ||
57
+ node.nullability.undefined.state === 'unknown' ||
58
+ node.kind === 'unknown' ||
59
+ node.coverage !== 'complete-within-declared-bound' ||
60
+ (node.kind === 'record' && !node.fields?.length && !node.indexSignatures?.length) ||
61
+ node.indexSignatures?.some((index) => !['string', 'number'].includes(index.keyType)))
62
+ unresolved = true;
63
+ }
64
+ return unresolved ? 'unresolved' : 'compatible';
65
+ }
66
+ /** Inspect only input-domain branches, not primitive fields within a structured document. */
67
+ export function sourceDomainHasKind(graph, kinds) {
68
+ const nodes = new Map(graph.nodes.map((node) => [node.id, node]));
69
+ const seen = new Set();
70
+ const visit = (node) => {
71
+ if (!node || seen.has(node.id))
72
+ return false;
73
+ seen.add(node.id);
74
+ return (kinds.includes(node.kind) ||
75
+ (['union', 'intersection', 'reference'].includes(node.kind) &&
76
+ (node.alternatives ?? []).some((id) => visit(nodes.get(id)))));
77
+ };
78
+ return visit(nodes.get(graph.rootId));
79
+ }
@@ -1,7 +1,8 @@
1
+ import { SAME_SPACE_RESOURCE_SOURCE } from './resource-link-schema.js';
1
2
  import { type JsonValue, type PropertyIssue } from './json-value.js';
2
3
  export declare const TARGET_PROPERTY_TYPES: readonly ["String", "Number", "Boolean", "Array", "Record", "Integer", "DateTime", "RichText", "JSON", "ResourceLink", "Literal", "DiscriminatedUnion"];
3
4
  export type TargetPropertyType = (typeof TARGET_PROPERTY_TYPES)[number];
4
- export declare const SAME_SPACE_RESOURCE_SOURCE = "crn:contentful:::content:spaces/$self/environments/$self";
5
+ export { SAME_SPACE_RESOURCE_SOURCE } from './resource-link-schema.js';
5
6
  export type AllowedResourceDefinition = {
6
7
  type: 'Contentful:Entry';
7
8
  source: typeof SAME_SPACE_RESOURCE_SOURCE;
@@ -42,21 +43,6 @@ export declare const targetDefinitionJsonSchema: {
42
43
  readonly type: "object";
43
44
  readonly required: readonly ["type"];
44
45
  readonly properties: {
45
- readonly type: {
46
- readonly enum: readonly ["String", "Number", "Boolean", "Array", "Record", "Integer", "DateTime", "RichText", "JSON", "ResourceLink", "Literal", "DiscriminatedUnion"];
47
- };
48
- readonly id: {
49
- readonly type: "string";
50
- };
51
- readonly name: {
52
- readonly type: "string";
53
- };
54
- readonly description: {
55
- readonly type: "string";
56
- };
57
- readonly required: {
58
- readonly type: "boolean";
59
- };
60
46
  readonly values: {
61
47
  readonly type: "array";
62
48
  readonly minItems: 1;
@@ -138,6 +124,21 @@ export declare const targetDefinitionJsonSchema: {
138
124
  }];
139
125
  };
140
126
  };
127
+ readonly id: {
128
+ readonly type: "string";
129
+ };
130
+ readonly name: {
131
+ readonly type: "string";
132
+ };
133
+ readonly description: {
134
+ readonly type: "string";
135
+ };
136
+ readonly required: {
137
+ readonly type: "boolean";
138
+ };
139
+ readonly type: {
140
+ readonly enum: readonly ["String", "Number", "Boolean", "Array", "Record", "Integer", "DateTime", "RichText", "JSON", "ResourceLink", "Literal", "DiscriminatedUnion"];
141
+ };
141
142
  };
142
143
  readonly allOf: readonly [{
143
144
  readonly if: {
@@ -1,3 +1,4 @@
1
+ import { allowedResourcesJsonSchema, SAME_SPACE_RESOURCE_SOURCE, targetDefinitionMetadataJsonProperties, } from './resource-link-schema.js';
1
2
  import { childPath, jsonEqual, jsonValueIssue, own } from './json-value.js';
2
3
  import { isDateTimeValue } from './date-time-value.js';
3
4
  import { discriminatedUnionIssues, matchingDiscriminatedUnionMember } from './discriminated-union.js';
@@ -15,7 +16,7 @@ export const TARGET_PROPERTY_TYPES = [
15
16
  'Literal',
16
17
  'DiscriminatedUnion',
17
18
  ];
18
- export const SAME_SPACE_RESOURCE_SOURCE = 'crn:contentful:::content:spaces/$self/environments/$self';
19
+ export { SAME_SPACE_RESOURCE_SOURCE } from './resource-link-schema.js';
19
20
  export function containsTargetDefinitionType(definition, type) {
20
21
  return (definition.type === type ||
21
22
  (definition.items !== undefined && containsTargetDefinitionType(definition.items, type)) ||
@@ -189,35 +190,12 @@ export const targetDefinitionJsonSchema = {
189
190
  required: ['type'],
190
191
  properties: {
191
192
  type: { enum: [...TARGET_PROPERTY_TYPES] },
192
- id: { type: 'string' },
193
- name: { type: 'string' },
194
- description: { type: 'string' },
195
- required: { type: 'boolean' },
193
+ ...targetDefinitionMetadataJsonProperties,
196
194
  values: { type: 'array', minItems: 1 },
197
195
  defaultValue: {},
198
196
  items: { $ref: '#/definitions/target' },
199
197
  fields: { type: 'object', minProperties: 1, additionalProperties: { $ref: '#/definitions/target' } },
200
- allowedResources: {
201
- type: 'array',
202
- minItems: 1,
203
- items: {
204
- type: 'object',
205
- required: ['type', 'source'],
206
- properties: {
207
- type: { enum: ['Contentful:Entry', 'Contentful:Asset'] },
208
- source: { const: SAME_SPACE_RESOURCE_SOURCE },
209
- allowedTypes: { type: 'array', items: { type: 'string' } },
210
- },
211
- allOf: [
212
- {
213
- if: { properties: { type: { const: 'Contentful:Entry' } } },
214
- then: { required: ['allowedTypes'] },
215
- else: { not: { required: ['allowedTypes'] } },
216
- },
217
- ],
218
- additionalProperties: false,
219
- },
220
- },
198
+ allowedResources: allowedResourcesJsonSchema,
221
199
  value: {},
222
200
  valueType: { $ref: '#/definitions/target' },
223
201
  discriminator: { type: 'string', minLength: 1 },
@@ -0,0 +1,30 @@
1
+ import { type core } from 'zod/mini';
2
+ export type SchemaDescriptor = Record<string, unknown>;
3
+ export type SchemaDirection = 'input' | 'output';
4
+ /** Only schema reference positions are rewritten; defaults and examples remain data. */
5
+ export declare function rewriteSchemaReferences(input: SchemaDescriptor, aliases: Readonly<Record<string, string>>, from?: string, to?: string): SchemaDescriptor;
6
+ /** Translate schema keywords for OpenAPI while keeping example/default data unchanged. */
7
+ export declare function toOpenAPISchema(input: SchemaDescriptor): SchemaDescriptor;
8
+ /** Registrations and generated descriptor copies belong to one invocation. */
9
+ export declare class SchemaExportScope {
10
+ private readonly nodes;
11
+ private readonly definitions;
12
+ private readonly aliases;
13
+ register(schema: core.$ZodType, name: string, descriptor: SchemaDescriptor | {
14
+ input: SchemaDescriptor;
15
+ output: SchemaDescriptor;
16
+ }): string;
17
+ addDefinition(name: string, descriptor: SchemaDescriptor): void;
18
+ convert(schema: core.$ZodType, options?: {
19
+ direction?: SchemaDirection;
20
+ target?: 'draft-7' | 'openapi-3.0';
21
+ }): SchemaDescriptor;
22
+ openAPI(schemas: Readonly<Record<string, core.$ZodType>>, options?: {
23
+ direction?: SchemaDirection;
24
+ existingNames?: readonly string[];
25
+ }): {
26
+ schemas: Record<string, SchemaDescriptor>;
27
+ aliases: Record<string, string>;
28
+ };
29
+ }
30
+ export declare function createCDFSchemaExportScope(): SchemaExportScope;