@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.
- package/README.md +15 -0
- package/dist/package.json +1 -1
- package/dist/src/agent-process-lifecycle.d.ts +26 -0
- package/dist/src/agent-process-lifecycle.js +171 -0
- package/dist/src/agent-prompt-artifact.d.ts +8 -0
- package/dist/src/agent-prompt-artifact.js +37 -0
- package/dist/src/agent-prompt-transport.d.ts +1 -0
- package/dist/src/agent-prompt-transport.js +4 -0
- package/dist/src/cdf/build.d.ts +9 -2
- package/dist/src/cdf/build.js +134 -17
- package/dist/src/cdf/finite-values.d.ts +8 -0
- package/dist/src/cdf/finite-values.js +21 -0
- package/dist/src/cdf/index.d.ts +2 -1
- package/dist/src/cdf/index.js +1 -0
- package/dist/src/cdf/property-validation.d.ts +16 -0
- package/dist/src/cdf/property-validation.js +211 -0
- package/dist/src/cdf/representation-validation.d.ts +6 -0
- package/dist/src/cdf/representation-validation.js +182 -0
- package/dist/src/cdf/schema.d.ts +778 -20
- package/dist/src/cdf/schema.js +362 -5
- package/dist/src/cdf/types.d.ts +57 -59
- package/dist/src/cdf/types.js +72 -15
- package/dist/src/cdf/validate.js +31 -1
- package/dist/src/cdf/vocabularies.d.ts +1 -1
- package/dist/src/cdf/vocabularies.js +9 -1
- package/dist/src/config/index.js +6 -3
- package/dist/src/exploration/constants.d.ts +10 -0
- package/dist/src/exploration/constants.js +18 -0
- package/dist/src/exploration/index.d.ts +3 -0
- package/dist/src/exploration/index.js +3 -0
- package/dist/src/exploration/schemas.d.ts +201 -0
- package/dist/src/exploration/schemas.js +126 -0
- package/dist/src/exploration/types.d.ts +393 -0
- package/dist/src/exploration/types.js +1 -0
- package/dist/src/handoff/index.d.ts +1 -1
- package/dist/src/index.d.ts +15 -1
- package/dist/src/index.js +12 -4
- package/dist/src/property-contract/analysis-representation-candidates.d.ts +19 -0
- package/dist/src/property-contract/analysis-representation-candidates.js +45 -0
- package/dist/src/property-contract/classification.d.ts +38 -0
- package/dist/src/property-contract/classification.js +84 -0
- package/dist/src/property-contract/compact-model-components.d.ts +16 -0
- package/dist/src/property-contract/compact-model-components.js +113 -0
- package/dist/src/property-contract/content-digest.d.ts +2 -0
- package/dist/src/property-contract/content-digest.js +69 -0
- package/dist/src/property-contract/decision-protocol.d.ts +45 -0
- package/dist/src/property-contract/decision-protocol.js +251 -0
- package/dist/src/property-contract/definition-import-rules.d.ts +10 -0
- package/dist/src/property-contract/definition-import-rules.js +105 -0
- package/dist/src/property-contract/definition-import.d.ts +13 -0
- package/dist/src/property-contract/definition-import.js +52 -0
- package/dist/src/property-contract/discriminated-union-source.d.ts +17 -0
- package/dist/src/property-contract/discriminated-union-source.js +180 -0
- package/dist/src/property-contract/import-prerequisites.d.ts +70 -0
- package/dist/src/property-contract/import-prerequisites.js +208 -0
- package/dist/src/property-contract/index.d.ts +18 -1
- package/dist/src/property-contract/index.js +18 -6
- package/dist/src/property-contract/logical-source-graph.d.ts +36 -0
- package/dist/src/property-contract/logical-source-graph.js +240 -0
- package/dist/src/property-contract/mapper-readiness.d.ts +6 -0
- package/dist/src/property-contract/mapper-readiness.js +34 -0
- package/dist/src/property-contract/model-exploration.d.ts +42 -0
- package/dist/src/property-contract/model-exploration.js +94 -0
- package/dist/src/property-contract/native-source-region.d.ts +5 -0
- package/dist/src/property-contract/native-source-region.js +125 -0
- package/dist/src/property-contract/null-handling.d.ts +10 -0
- package/dist/src/property-contract/null-handling.js +45 -0
- package/dist/src/property-contract/physical-property-import.d.ts +6 -0
- package/dist/src/property-contract/physical-property-import.js +55 -0
- package/dist/src/property-contract/property-decision.d.ts +14 -0
- package/dist/src/property-contract/property-decision.js +155 -0
- package/dist/src/property-contract/property-model.d.ts +197 -0
- package/dist/src/property-contract/property-model.js +833 -0
- package/dist/src/property-contract/representation-plan.d.ts +133 -0
- package/dist/src/property-contract/representation-plan.js +756 -0
- package/dist/src/property-contract/representation-proposal.d.ts +65 -0
- package/dist/src/property-contract/representation-proposal.js +204 -0
- package/dist/src/property-contract/resource-link-schema.d.ts +55 -0
- package/dist/src/property-contract/resource-link-schema.js +28 -0
- package/dist/src/property-contract/source-representation.d.ts +9 -0
- package/dist/src/property-contract/source-representation.js +79 -0
- package/dist/src/property-contract/target-definition.d.ts +17 -16
- package/dist/src/property-contract/target-definition.js +4 -26
- package/dist/src/schema-export.d.ts +30 -0
- package/dist/src/schema-export.js +285 -0
- package/dist/src/shared-source.d.ts +105 -0
- package/dist/src/shared-source.js +1 -0
- package/dist/src/source-input-association.d.ts +23 -0
- package/dist/src/source-input-association.js +52 -0
- package/dist/src/sources-api/preview/index.d.ts +37 -3
- package/dist/src/sources-api/preview/index.js +39 -1
- package/dist/src/sources-api/preview/schema.d.ts +2 -0
- package/dist/src/sources-api/preview/schema.js +74 -0
- package/package.json +1 -1
package/dist/src/cdf/schema.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { allowedResourcesJsonSchema, targetDefinitionMetadataJsonProperties, } from '../property-contract/resource-link-schema.js';
|
|
2
|
+
import { TARGET_PROPERTY_TYPES } from '../property-contract/target-definition.js';
|
|
1
3
|
import { CDF_PROPERTY_TYPES, CDF_PROPERTY_CATEGORIES } from './vocabularies.js';
|
|
2
4
|
import { DESIGN_TOKEN_TYPES } from '../dtcg/token-types.js';
|
|
5
|
+
import { modelComponentExplorationJsonSchema } from '../property-contract/model-exploration.js';
|
|
3
6
|
export const CDF_SCHEMA_URL = 'https://contentful.com/schemas/cdf';
|
|
4
7
|
/**
|
|
5
8
|
* Components and design tokens live in one recursive tree. A leaf's `$type`
|
|
@@ -8,6 +11,33 @@ export const CDF_SCHEMA_URL = 'https://contentful.com/schemas/cdf';
|
|
|
8
11
|
* separate manifest envelope — this document is the single file/wire
|
|
9
12
|
* payload sent to preview/apply.
|
|
10
13
|
*/
|
|
14
|
+
const finiteValuesSchema = {
|
|
15
|
+
if: { required: ['$values'] },
|
|
16
|
+
then: {
|
|
17
|
+
anyOf: ['string', 'number', 'boolean'].map((type) => ({
|
|
18
|
+
properties: {
|
|
19
|
+
$type: { const: type },
|
|
20
|
+
$values: { type: 'array', minItems: 1, uniqueItems: true, items: { type } },
|
|
21
|
+
},
|
|
22
|
+
})),
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
const fieldMetadataJsonProperties = {
|
|
26
|
+
$description: { type: 'string' },
|
|
27
|
+
$required: { type: 'boolean' },
|
|
28
|
+
$default: {},
|
|
29
|
+
$values: { type: 'array', minItems: 1 },
|
|
30
|
+
$items: { $ref: '#/definitions/field' },
|
|
31
|
+
$fields: { type: 'object', minProperties: 1, additionalProperties: { $ref: '#/definitions/field' } },
|
|
32
|
+
};
|
|
33
|
+
const fieldStructureJsonProperties = {
|
|
34
|
+
'$token.allowed': { type: 'array', items: { type: 'string' } },
|
|
35
|
+
value: {},
|
|
36
|
+
valueType: { $ref: '#/definitions/field' },
|
|
37
|
+
discriminator: { type: 'string', minLength: 1 },
|
|
38
|
+
members: { type: 'array', minItems: 2, items: { $ref: '#/definitions/field' } },
|
|
39
|
+
allowedResources: { $ref: '#/definitions/allowedResources' },
|
|
40
|
+
};
|
|
11
41
|
export const cdfJsonSchema = {
|
|
12
42
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
13
43
|
$id: CDF_SCHEMA_URL,
|
|
@@ -32,6 +62,8 @@ export const cdfJsonSchema = {
|
|
|
32
62
|
type: 'object',
|
|
33
63
|
additionalProperties: { $ref: '#/definitions/property' },
|
|
34
64
|
},
|
|
65
|
+
$model: { $ref: '#/definitions/modelBinding' },
|
|
66
|
+
$representationPlans: { type: 'object', additionalProperties: { $ref: '#/definitions/representationPlan' } },
|
|
35
67
|
$slots: {
|
|
36
68
|
type: 'object',
|
|
37
69
|
additionalProperties: { $ref: '#/definitions/slot' },
|
|
@@ -41,25 +73,350 @@ export const cdfJsonSchema = {
|
|
|
41
73
|
},
|
|
42
74
|
property: {
|
|
43
75
|
type: 'object',
|
|
76
|
+
allOf: [finiteValuesSchema],
|
|
44
77
|
required: ['$type', '$category'],
|
|
45
78
|
properties: {
|
|
46
79
|
$type: { type: 'string', enum: [...CDF_PROPERTY_TYPES] },
|
|
47
80
|
$category: { type: 'string', enum: [...CDF_PROPERTY_CATEGORIES] },
|
|
48
|
-
|
|
49
|
-
$
|
|
50
|
-
$default: {},
|
|
51
|
-
$values: { type: 'array', items: { type: 'string' } },
|
|
81
|
+
...fieldMetadataJsonProperties,
|
|
82
|
+
$sourceInput: { $ref: '#/definitions/sourceInput' },
|
|
52
83
|
'$token.kind': { type: 'string', minLength: 1 },
|
|
53
|
-
|
|
84
|
+
...fieldStructureJsonProperties,
|
|
54
85
|
},
|
|
55
86
|
// The API rejects a token property that does not say which kind of token it takes.
|
|
56
87
|
if: { type: 'object', properties: { $type: { const: 'token' } }, required: ['$type'] },
|
|
57
88
|
then: { type: 'object', required: ['$token.kind'] },
|
|
58
89
|
additionalProperties: false,
|
|
59
90
|
},
|
|
91
|
+
field: {
|
|
92
|
+
type: 'object',
|
|
93
|
+
allOf: [finiteValuesSchema],
|
|
94
|
+
required: ['$type'],
|
|
95
|
+
properties: {
|
|
96
|
+
$type: { enum: [...CDF_PROPERTY_TYPES] },
|
|
97
|
+
$category: { enum: [...CDF_PROPERTY_CATEGORIES] },
|
|
98
|
+
...fieldMetadataJsonProperties,
|
|
99
|
+
'$token.kind': { type: 'string' },
|
|
100
|
+
...fieldStructureJsonProperties,
|
|
101
|
+
},
|
|
102
|
+
additionalProperties: false,
|
|
103
|
+
},
|
|
104
|
+
allowedResources: allowedResourcesJsonSchema,
|
|
105
|
+
sourceInput: {
|
|
106
|
+
type: 'object',
|
|
107
|
+
required: ['schemaVersion', 'componentId', 'componentDeclarationId', 'rootSymbolId', 'inputName', 'inputPath'],
|
|
108
|
+
properties: {
|
|
109
|
+
schemaVersion: { const: 1 },
|
|
110
|
+
componentId: { type: 'string', minLength: 1 },
|
|
111
|
+
componentDeclarationId: { type: 'string', minLength: 1 },
|
|
112
|
+
rootSymbolId: { type: 'string', minLength: 1 },
|
|
113
|
+
inputName: { type: 'string', minLength: 1 },
|
|
114
|
+
inputPath: { type: 'array', minItems: 1, items: { type: 'string', minLength: 1 } },
|
|
115
|
+
},
|
|
116
|
+
additionalProperties: false,
|
|
117
|
+
},
|
|
118
|
+
modelBinding: {
|
|
119
|
+
type: 'object',
|
|
120
|
+
required: ['planId', 'componentId', 'propertyId', 'nodeId'],
|
|
121
|
+
properties: {
|
|
122
|
+
planId: { type: 'string' },
|
|
123
|
+
componentId: { type: 'string' },
|
|
124
|
+
propertyId: { type: 'string' },
|
|
125
|
+
nodeId: { type: 'string' },
|
|
126
|
+
sourceNodeId: { type: 'string' },
|
|
127
|
+
},
|
|
128
|
+
additionalProperties: false,
|
|
129
|
+
},
|
|
130
|
+
modelCardinality: {
|
|
131
|
+
type: 'object',
|
|
132
|
+
required: ['min', 'max', 'ordered'],
|
|
133
|
+
properties: {
|
|
134
|
+
min: { type: 'integer', minimum: 0 },
|
|
135
|
+
max: { type: ['integer', 'null'], minimum: 0 },
|
|
136
|
+
ordered: { type: 'boolean' },
|
|
137
|
+
tuplePosition: { type: 'integer', minimum: 0 },
|
|
138
|
+
rest: { type: 'boolean' },
|
|
139
|
+
},
|
|
140
|
+
additionalProperties: false,
|
|
141
|
+
},
|
|
142
|
+
targetDefinition: {
|
|
143
|
+
type: 'object',
|
|
144
|
+
required: ['type'],
|
|
145
|
+
properties: {
|
|
146
|
+
type: { enum: [...TARGET_PROPERTY_TYPES] },
|
|
147
|
+
...targetDefinitionMetadataJsonProperties,
|
|
148
|
+
values: { type: 'array', items: {} },
|
|
149
|
+
defaultValue: {},
|
|
150
|
+
items: { $ref: '#/definitions/targetDefinition' },
|
|
151
|
+
fields: { type: 'object', additionalProperties: { $ref: '#/definitions/targetDefinition' } },
|
|
152
|
+
allowedResources: { $ref: '#/definitions/allowedResources' },
|
|
153
|
+
value: {},
|
|
154
|
+
valueType: { $ref: '#/definitions/targetDefinition' },
|
|
155
|
+
discriminator: { type: 'string', minLength: 1 },
|
|
156
|
+
members: { type: 'array', minItems: 2, items: { $ref: '#/definitions/targetDefinition' } },
|
|
157
|
+
},
|
|
158
|
+
additionalProperties: false,
|
|
159
|
+
},
|
|
160
|
+
representationProposal: {
|
|
161
|
+
type: 'object',
|
|
162
|
+
required: [
|
|
163
|
+
'componentId',
|
|
164
|
+
'propertyId',
|
|
165
|
+
'key',
|
|
166
|
+
'name',
|
|
167
|
+
'sourceRevision',
|
|
168
|
+
'sourceNodeIds',
|
|
169
|
+
'declaredConstraints',
|
|
170
|
+
'provenConstraints',
|
|
171
|
+
'observations',
|
|
172
|
+
'judgment',
|
|
173
|
+
'desiredType',
|
|
174
|
+
'desiredDefinition',
|
|
175
|
+
],
|
|
176
|
+
properties: {
|
|
177
|
+
componentId: { type: 'string' },
|
|
178
|
+
propertyId: { type: 'string' },
|
|
179
|
+
key: { type: 'string' },
|
|
180
|
+
name: { type: 'string' },
|
|
181
|
+
sourceRevision: { type: 'string' },
|
|
182
|
+
sourceNodeIds: { type: 'array', items: { type: 'string' } },
|
|
183
|
+
declaredConstraints: {
|
|
184
|
+
type: 'array',
|
|
185
|
+
items: {
|
|
186
|
+
type: 'object',
|
|
187
|
+
required: ['nodeId', 'statement'],
|
|
188
|
+
properties: { nodeId: { type: 'string' }, statement: { type: 'string' } },
|
|
189
|
+
additionalProperties: false,
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
provenConstraints: {
|
|
193
|
+
type: 'array',
|
|
194
|
+
items: {
|
|
195
|
+
type: 'object',
|
|
196
|
+
required: ['nodeId', 'statement'],
|
|
197
|
+
properties: { nodeId: { type: 'string' }, statement: { type: 'string' } },
|
|
198
|
+
additionalProperties: false,
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
observations: {
|
|
202
|
+
type: 'array',
|
|
203
|
+
items: {
|
|
204
|
+
type: 'object',
|
|
205
|
+
required: ['nodeId', 'value'],
|
|
206
|
+
properties: { nodeId: { type: 'string' }, value: {} },
|
|
207
|
+
additionalProperties: false,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
judgment: { type: 'string' },
|
|
211
|
+
desiredType: { enum: [...TARGET_PROPERTY_TYPES] },
|
|
212
|
+
desiredDefinition: { $ref: '#/definitions/targetDefinition' },
|
|
213
|
+
compatibility: {
|
|
214
|
+
type: 'object',
|
|
215
|
+
required: ['status', 'sourceUseRefs', 'unresolvedRequirements'],
|
|
216
|
+
properties: {
|
|
217
|
+
status: { enum: ['judged-compatible', 'unresolved', 'contradicted'] },
|
|
218
|
+
sourceUseRefs: { type: 'array', uniqueItems: true, items: { type: 'string', minLength: 1 } },
|
|
219
|
+
unresolvedRequirements: { type: 'array', items: { type: 'string', minLength: 1 } },
|
|
220
|
+
},
|
|
221
|
+
additionalProperties: false,
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
additionalProperties: false,
|
|
225
|
+
},
|
|
226
|
+
representationPlan: {
|
|
227
|
+
type: 'object',
|
|
228
|
+
required: [
|
|
229
|
+
'schemaVersion',
|
|
230
|
+
'id',
|
|
231
|
+
'kind',
|
|
232
|
+
'identity',
|
|
233
|
+
'sourceModel',
|
|
234
|
+
'sourceDigest',
|
|
235
|
+
'contextDigest',
|
|
236
|
+
'logicalGraph',
|
|
237
|
+
'category',
|
|
238
|
+
'defaultIntent',
|
|
239
|
+
'models',
|
|
240
|
+
'mappings',
|
|
241
|
+
'issues',
|
|
242
|
+
'sdkValid',
|
|
243
|
+
'requirements',
|
|
244
|
+
],
|
|
245
|
+
properties: {
|
|
246
|
+
proposal: { $ref: '#/definitions/representationProposal' },
|
|
247
|
+
schemaVersion: { const: 1 },
|
|
248
|
+
id: { type: 'string' },
|
|
249
|
+
kind: { enum: ['native', 'component-model'] },
|
|
250
|
+
identity: {
|
|
251
|
+
type: 'object',
|
|
252
|
+
required: ['componentId', 'propertyId', 'key', 'sourceRevision', 'nodeId'],
|
|
253
|
+
properties: {
|
|
254
|
+
componentId: { type: 'string' },
|
|
255
|
+
propertyId: { type: 'string' },
|
|
256
|
+
key: { type: 'string' },
|
|
257
|
+
sourceRevision: { type: 'string' },
|
|
258
|
+
nodeId: { type: 'string' },
|
|
259
|
+
},
|
|
260
|
+
additionalProperties: false,
|
|
261
|
+
},
|
|
262
|
+
logicalGraph: { type: 'object' },
|
|
263
|
+
sourceModel: { type: 'object' },
|
|
264
|
+
contextSnapshot: {},
|
|
265
|
+
sourceDigest: { type: 'string' },
|
|
266
|
+
contextDigest: { type: 'string' },
|
|
267
|
+
category: { enum: [...CDF_PROPERTY_CATEGORIES] },
|
|
268
|
+
defaultIntent: {
|
|
269
|
+
oneOf: [
|
|
270
|
+
{
|
|
271
|
+
type: 'object',
|
|
272
|
+
required: ['action'],
|
|
273
|
+
properties: { action: { enum: ['absent', 'clear'] } },
|
|
274
|
+
additionalProperties: false,
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
type: 'object',
|
|
278
|
+
required: ['action', 'value'],
|
|
279
|
+
properties: { action: { const: 'set' }, value: {} },
|
|
280
|
+
additionalProperties: false,
|
|
281
|
+
},
|
|
282
|
+
],
|
|
283
|
+
},
|
|
284
|
+
sourceDefault: { type: 'object' },
|
|
285
|
+
nativeDefinition: { $ref: '#/definitions/property' },
|
|
286
|
+
models: {
|
|
287
|
+
type: 'array',
|
|
288
|
+
items: {
|
|
289
|
+
type: 'object',
|
|
290
|
+
required: ['key', 'originalKey', 'nodeId', 'entry'],
|
|
291
|
+
properties: {
|
|
292
|
+
key: { type: 'string' },
|
|
293
|
+
originalKey: { type: 'string' },
|
|
294
|
+
nodeId: { type: 'string' },
|
|
295
|
+
entry: { $ref: '#/definitions/component' },
|
|
296
|
+
},
|
|
297
|
+
additionalProperties: false,
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
modelExplorations: { type: 'array', items: modelComponentExplorationJsonSchema },
|
|
301
|
+
attachment: {
|
|
302
|
+
type: 'object',
|
|
303
|
+
required: ['slot', 'definition'],
|
|
304
|
+
properties: { slot: { type: 'string' }, definition: { $ref: '#/definitions/slot' } },
|
|
305
|
+
additionalProperties: false,
|
|
306
|
+
},
|
|
307
|
+
mappings: {
|
|
308
|
+
type: 'array',
|
|
309
|
+
items: {
|
|
310
|
+
type: 'object',
|
|
311
|
+
required: ['nodeId', 'path', 'required', 'nullable', 'undefinable', 'disposition'],
|
|
312
|
+
properties: {
|
|
313
|
+
nodeId: { type: 'string' },
|
|
314
|
+
sourceNodeId: { type: 'string' },
|
|
315
|
+
readonly: { type: 'boolean' },
|
|
316
|
+
occurrenceReadonly: { type: 'boolean' },
|
|
317
|
+
intrinsicReadonly: { type: 'boolean' },
|
|
318
|
+
defaultIntent: { type: 'object' },
|
|
319
|
+
path: { type: 'array', items: { type: 'object' } },
|
|
320
|
+
required: { type: 'boolean' },
|
|
321
|
+
nullable: { type: ['boolean', 'null'] },
|
|
322
|
+
undefinable: { type: ['boolean', 'null'] },
|
|
323
|
+
disposition: { enum: ['native-field', 'model', 'slot', 'reference', 'reconstruction', 'held'] },
|
|
324
|
+
reconstruction: {
|
|
325
|
+
oneOf: [
|
|
326
|
+
{
|
|
327
|
+
type: 'object',
|
|
328
|
+
required: ['kind', 'value'],
|
|
329
|
+
properties: { kind: { const: 'fixed-value' }, value: {} },
|
|
330
|
+
additionalProperties: false,
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
type: 'object',
|
|
334
|
+
required: ['kind', 'valueNodeId'],
|
|
335
|
+
properties: { kind: { const: 'optional-value' }, valueNodeId: { type: 'string' } },
|
|
336
|
+
additionalProperties: false,
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
type: 'object',
|
|
340
|
+
required: ['kind', 'field', 'valueNodeId'],
|
|
341
|
+
properties: {
|
|
342
|
+
kind: { const: 'object-envelope' },
|
|
343
|
+
field: { type: 'string' },
|
|
344
|
+
valueNodeId: { type: 'string' },
|
|
345
|
+
},
|
|
346
|
+
additionalProperties: false,
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
type: 'object',
|
|
350
|
+
required: ['kind', 'itemNodeId'],
|
|
351
|
+
properties: { kind: { const: 'ordered-array' }, itemNodeId: { type: 'string' } },
|
|
352
|
+
additionalProperties: false,
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
type: 'object',
|
|
356
|
+
required: ['kind', 'state'],
|
|
357
|
+
properties: {
|
|
358
|
+
kind: { const: 'empty-value' },
|
|
359
|
+
state: { enum: ['null', 'undefined', 'never'] },
|
|
360
|
+
},
|
|
361
|
+
additionalProperties: false,
|
|
362
|
+
},
|
|
363
|
+
],
|
|
364
|
+
},
|
|
365
|
+
componentKey: { type: 'string' },
|
|
366
|
+
field: { type: 'string' },
|
|
367
|
+
slot: { type: 'string' },
|
|
368
|
+
targetNodeId: { type: 'string' },
|
|
369
|
+
reason: { type: 'string' },
|
|
370
|
+
withinValue: {
|
|
371
|
+
type: 'object',
|
|
372
|
+
required: ['ownerNodeId', 'path'],
|
|
373
|
+
properties: { ownerNodeId: { type: 'string' }, path: { type: 'array', items: { type: 'object' } } },
|
|
374
|
+
additionalProperties: false,
|
|
375
|
+
},
|
|
376
|
+
branchConditions: { type: 'array', items: { type: 'object' } },
|
|
377
|
+
variant: {
|
|
378
|
+
type: 'object',
|
|
379
|
+
required: ['wrapperKey', 'slot', 'componentKey'],
|
|
380
|
+
properties: {
|
|
381
|
+
wrapperKey: { type: 'string' },
|
|
382
|
+
slot: { type: 'string' },
|
|
383
|
+
componentKey: { type: 'string' },
|
|
384
|
+
},
|
|
385
|
+
additionalProperties: false,
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
additionalProperties: false,
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
issues: {
|
|
392
|
+
type: 'array',
|
|
393
|
+
items: {
|
|
394
|
+
type: 'object',
|
|
395
|
+
required: ['path', 'message'],
|
|
396
|
+
properties: { path: { type: 'string' }, message: { type: 'string' } },
|
|
397
|
+
additionalProperties: false,
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
sdkValid: { type: 'boolean' },
|
|
401
|
+
branchSelections: { type: 'array', items: { type: 'object' } },
|
|
402
|
+
requirements: {
|
|
403
|
+
type: 'array',
|
|
404
|
+
items: {
|
|
405
|
+
type: 'object',
|
|
406
|
+
required: ['path', 'capability'],
|
|
407
|
+
properties: { path: { type: 'string' }, capability: { type: 'string' } },
|
|
408
|
+
additionalProperties: false,
|
|
409
|
+
},
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
additionalProperties: false,
|
|
413
|
+
},
|
|
60
414
|
slot: {
|
|
61
415
|
type: 'object',
|
|
62
416
|
properties: {
|
|
417
|
+
$sourceInput: { $ref: '#/definitions/sourceInput' },
|
|
418
|
+
$modelBinding: { $ref: '#/definitions/modelBinding' },
|
|
419
|
+
$cardinality: { $ref: '#/definitions/modelCardinality' },
|
|
63
420
|
$description: { type: 'string' },
|
|
64
421
|
$required: { type: 'boolean' },
|
|
65
422
|
$allowedComponents: { type: 'array', items: { type: 'string' } },
|
package/dist/src/cdf/types.d.ts
CHANGED
|
@@ -1,69 +1,67 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
$
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
$
|
|
20
|
-
$
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
export
|
|
2
|
+
import type { RepresentationPlan, ModelBinding } from '../property-contract/representation-plan.js';
|
|
3
|
+
import { CDF_PROPERTY_TYPES, CDF_PROPERTY_CATEGORIES } from './vocabularies.js';
|
|
4
|
+
import { type SourceInputAssociation } from '../source-input-association.js';
|
|
5
|
+
export interface CDFFieldDefinition {
|
|
6
|
+
$type: (typeof CDF_PROPERTY_TYPES)[number];
|
|
7
|
+
$category?: (typeof CDF_PROPERTY_CATEGORIES)[number];
|
|
8
|
+
$description?: string;
|
|
9
|
+
$required?: boolean;
|
|
10
|
+
$default?: import('../property-contract/json-value.js').JsonValue;
|
|
11
|
+
$values?: import('../property-contract/json-value.js').JsonValue[];
|
|
12
|
+
$items?: CDFFieldDefinition;
|
|
13
|
+
$fields?: Record<string, CDFFieldDefinition>;
|
|
14
|
+
value?: import('../property-contract/json-value.js').JsonValue;
|
|
15
|
+
valueType?: CDFFieldDefinition;
|
|
16
|
+
discriminator?: string;
|
|
17
|
+
members?: CDFFieldDefinition[];
|
|
18
|
+
allowedResources?: import('../property-contract/target-definition.js').TargetDefinition['allowedResources'];
|
|
19
|
+
'$token.kind'?: string;
|
|
20
|
+
'$token.allowed'?: string[];
|
|
21
|
+
}
|
|
22
|
+
export interface CDFPropertyDefinition extends CDFFieldDefinition {
|
|
23
|
+
$category: (typeof CDF_PROPERTY_CATEGORIES)[number];
|
|
24
|
+
$sourceInput?: SourceInputAssociation;
|
|
25
|
+
}
|
|
26
|
+
export declare const CDFPropertySchema: z.ZodMiniCustom<CDFPropertyDefinition, CDFPropertyDefinition>;
|
|
27
27
|
export declare const CDFSlotSchema: z.ZodMiniObject<{
|
|
28
|
+
$modelBinding: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
29
|
+
planId: z.ZodMiniString<string>;
|
|
30
|
+
componentId: z.ZodMiniString<string>;
|
|
31
|
+
propertyId: z.ZodMiniString<string>;
|
|
32
|
+
nodeId: z.ZodMiniString<string>;
|
|
33
|
+
sourceNodeId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
34
|
+
}, z.core.$strict>>;
|
|
35
|
+
$cardinality: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
36
|
+
min: z.ZodMiniNumber<number>;
|
|
37
|
+
max: z.ZodMiniNullable<z.ZodMiniNumber<number>>;
|
|
38
|
+
ordered: z.ZodMiniBoolean<boolean>;
|
|
39
|
+
tuplePosition: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
40
|
+
rest: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
41
|
+
}, z.core.$strict>>;
|
|
42
|
+
$sourceInput: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
43
|
+
schemaVersion: z.ZodMiniLiteral<1>;
|
|
44
|
+
componentId: z.ZodMiniString<string>;
|
|
45
|
+
componentDeclarationId: z.ZodMiniString<string>;
|
|
46
|
+
rootSymbolId: z.ZodMiniString<string>;
|
|
47
|
+
inputName: z.ZodMiniString<string>;
|
|
48
|
+
inputPath: z.ZodMiniArray<z.ZodMiniString<string>>;
|
|
49
|
+
}, z.core.$strict>>;
|
|
28
50
|
$description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
29
51
|
$allowedComponents: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
30
52
|
$required: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
31
53
|
}, z.core.$strict>;
|
|
32
54
|
export type CDFSlotDefinition = z.infer<typeof CDFSlotSchema>;
|
|
33
|
-
export
|
|
34
|
-
$type:
|
|
35
|
-
$description
|
|
36
|
-
$properties:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
link: "link";
|
|
44
|
-
enum: "enum";
|
|
45
|
-
token: "token";
|
|
46
|
-
}>;
|
|
47
|
-
$category: z.ZodMiniEnum<{
|
|
48
|
-
content: "content";
|
|
49
|
-
design: "design";
|
|
50
|
-
state: "state";
|
|
51
|
-
unattached: "unattached";
|
|
52
|
-
}>;
|
|
53
|
-
$description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
54
|
-
$required: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
55
|
-
$default: z.ZodMiniOptional<z.ZodMiniAny>;
|
|
56
|
-
$values: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
57
|
-
'$token.kind': z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
58
|
-
'$token.allowed': z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
59
|
-
}, z.core.$strict>>;
|
|
60
|
-
$slots: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
61
|
-
$description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
62
|
-
$allowedComponents: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
63
|
-
$required: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
64
|
-
}, z.core.$strict>>>;
|
|
65
|
-
}, z.core.$strict>;
|
|
66
|
-
export type CDFComponentEntry = z.infer<typeof CDFComponentSchema>;
|
|
55
|
+
export interface CDFComponentEntry {
|
|
56
|
+
$type: 'component';
|
|
57
|
+
$description?: string;
|
|
58
|
+
$properties: Record<string, CDFPropertyDefinition>;
|
|
59
|
+
$slots?: Record<string, CDFSlotDefinition>;
|
|
60
|
+
$model?: ModelBinding;
|
|
61
|
+
$representationPlans?: Record<string, RepresentationPlan>;
|
|
62
|
+
}
|
|
63
|
+
/** Custom admission keeps own dictionary keys intact instead of rebuilding a record. */
|
|
64
|
+
export declare const CDFComponentSchema: z.ZodMiniCustom<CDFComponentEntry, CDFComponentEntry>;
|
|
67
65
|
export interface CDFFile {
|
|
68
66
|
$schema: string;
|
|
69
67
|
[key: string]: unknown;
|
package/dist/src/cdf/types.js
CHANGED
|
@@ -1,26 +1,83 @@
|
|
|
1
|
+
import { Ajv } from 'ajv';
|
|
2
|
+
import { cdfJsonSchema } from './schema.js';
|
|
1
3
|
import * as z from 'zod/mini';
|
|
2
|
-
import {
|
|
4
|
+
import { jsonValueIssue } from '../property-contract/json-value.js';
|
|
5
|
+
import { validateCDFProperty } from './property-validation.js';
|
|
3
6
|
import { DESIGN_TOKEN_TYPES } from '../dtcg/token-types.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'$token.allowed': z.optional(z.array(z.string())),
|
|
7
|
+
import { SourceInputAssociationSchema, validateCDFSourceOwnerContract, } from '../source-input-association.js';
|
|
8
|
+
export const CDFPropertySchema = z.custom((value) => validateCDFProperty(value).valid);
|
|
9
|
+
const ModelBindingSchema = z.strictObject({
|
|
10
|
+
planId: z.string(),
|
|
11
|
+
componentId: z.string(),
|
|
12
|
+
propertyId: z.string(),
|
|
13
|
+
nodeId: z.string(),
|
|
14
|
+
sourceNodeId: z.optional(z.string()),
|
|
13
15
|
});
|
|
16
|
+
const ModelCardinalitySchema = z
|
|
17
|
+
.strictObject({
|
|
18
|
+
min: z.number().check(z.int(), z.minimum(0)),
|
|
19
|
+
max: z.nullable(z.number().check(z.int(), z.minimum(0))),
|
|
20
|
+
ordered: z.boolean(),
|
|
21
|
+
tuplePosition: z.optional(z.number().check(z.int(), z.minimum(0))),
|
|
22
|
+
rest: z.optional(z.boolean()),
|
|
23
|
+
})
|
|
24
|
+
.check(z.refine((value) => value.max === null || value.max >= value.min));
|
|
14
25
|
export const CDFSlotSchema = z.strictObject({
|
|
26
|
+
$modelBinding: z.optional(ModelBindingSchema),
|
|
27
|
+
$cardinality: z.optional(ModelCardinalitySchema),
|
|
28
|
+
$sourceInput: z.optional(SourceInputAssociationSchema),
|
|
15
29
|
$description: z.optional(z.string()),
|
|
16
30
|
$allowedComponents: z.optional(z.array(z.string())),
|
|
17
31
|
$required: z.optional(z.boolean()),
|
|
18
32
|
});
|
|
19
|
-
|
|
20
|
-
$
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
const admitComponent = new Ajv({ allErrors: true }).compile({
|
|
34
|
+
$ref: '#/definitions/component',
|
|
35
|
+
definitions: cdfJsonSchema.definitions,
|
|
36
|
+
});
|
|
37
|
+
/** Custom admission keeps own dictionary keys intact instead of rebuilding a record. */
|
|
38
|
+
export const CDFComponentSchema = z.custom((value) => {
|
|
39
|
+
if (jsonValueIssue(value) || !value || typeof value !== 'object' || Array.isArray(value))
|
|
40
|
+
return false;
|
|
41
|
+
if (!admitComponent(value))
|
|
42
|
+
return false;
|
|
43
|
+
const entry = value;
|
|
44
|
+
if (entry.$type !== 'component' ||
|
|
45
|
+
!entry.$properties ||
|
|
46
|
+
typeof entry.$properties !== 'object' ||
|
|
47
|
+
Array.isArray(entry.$properties))
|
|
48
|
+
return false;
|
|
49
|
+
if (Object.keys(entry).some((key) => !['$type', '$description', '$properties', '$slots', '$model', '$representationPlans'].includes(key)))
|
|
50
|
+
return false;
|
|
51
|
+
if (entry.$description !== undefined && typeof entry.$description !== 'string')
|
|
52
|
+
return false;
|
|
53
|
+
if (Object.values(entry.$properties).some((property) => !validateCDFProperty(property).valid))
|
|
54
|
+
return false;
|
|
55
|
+
if (entry.$slots !== undefined &&
|
|
56
|
+
(!entry.$slots ||
|
|
57
|
+
typeof entry.$slots !== 'object' ||
|
|
58
|
+
Array.isArray(entry.$slots) ||
|
|
59
|
+
Object.entries(entry.$slots).some(([key, slot]) => !key.trim() || !CDFSlotSchema.safeParse(slot).success)))
|
|
60
|
+
return false;
|
|
61
|
+
if (entry.$model !== undefined && !ModelBindingSchema.safeParse(entry.$model).success)
|
|
62
|
+
return false;
|
|
63
|
+
if (entry.$representationPlans !== undefined &&
|
|
64
|
+
(!entry.$representationPlans ||
|
|
65
|
+
typeof entry.$representationPlans !== 'object' ||
|
|
66
|
+
Array.isArray(entry.$representationPlans) ||
|
|
67
|
+
Object.entries(entry.$representationPlans).some(([key, plan]) => !plan ||
|
|
68
|
+
plan.identity?.key !== key ||
|
|
69
|
+
plan.schemaVersion !== 1 ||
|
|
70
|
+
typeof plan.id !== 'string' ||
|
|
71
|
+
!Array.isArray(plan.models) ||
|
|
72
|
+
!Array.isArray(plan.mappings))))
|
|
73
|
+
return false;
|
|
74
|
+
try {
|
|
75
|
+
validateCDFSourceOwnerContract(entry);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
24
81
|
});
|
|
25
82
|
/** A token leaf — same shape as a DTCG token entry, but discovered inside
|
|
26
83
|
* the CDF tree rather than a standalone DTCG document. */
|