@contentful/experience-design-system-types 2.40.1-dev-build-1691fb91.0 → 2.40.1-dev-build-0aff4b7e.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/dist/package.json +1 -1
- package/dist/src/cdf/index.d.ts +1 -2
- package/dist/src/cdf/index.js +0 -1
- package/dist/src/cdf/types.d.ts +2 -25
- package/dist/src/cdf/vocabularies.d.ts +0 -1
- package/dist/src/cdf/vocabularies.js +0 -22
- package/dist/src/index.d.ts +1 -4
- package/dist/src/index.js +1 -5
- package/dist/src/property-contract/index.d.ts +0 -1
- package/dist/src/property-contract/index.js +0 -1
- package/package.json +1 -1
- package/dist/src/cdf/finite-values.d.ts +0 -8
- package/dist/src/cdf/finite-values.js +0 -21
- package/dist/src/cdf/property-validation.d.ts +0 -16
- package/dist/src/cdf/property-validation.js +0 -211
- package/dist/src/property-contract/content-digest.d.ts +0 -2
- package/dist/src/property-contract/content-digest.js +0 -69
- package/dist/src/shared-source.d.ts +0 -105
- package/dist/src/shared-source.js +0 -1
- package/dist/src/source-input-association.d.ts +0 -23
- package/dist/src/source-input-association.js +0 -52
package/dist/package.json
CHANGED
package/dist/src/cdf/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { validateCDF, parseCDFComponents } from './validate.js';
|
|
2
2
|
export { CDF_SCHEMA_URL, cdfJsonSchema } from './schema.js';
|
|
3
3
|
export { CDF_PROPERTY_TYPES, CDF_PROPERTY_CATEGORIES } from './vocabularies.js';
|
|
4
|
-
export { CDFComponentSchema, CDFPropertySchema, CDFSlotSchema, CDFTokenSchema, type CDFComponentEntry, type
|
|
4
|
+
export { CDFComponentSchema, CDFPropertySchema, CDFSlotSchema, CDFTokenSchema, type CDFComponentEntry, type CDFPropertyDefinition, type CDFSlotDefinition, type CDFTokenEntry, type CDFValidationError, type CDFValidationResult, } from './types.js';
|
|
5
5
|
export { buildCDF, buildFilteredCDF, stripUnsupportedSlotFields, validateSlotReferences, type CDFDocument, } from './build.js';
|
|
6
|
-
export { finiteValuesIssue, isFinitePrimitiveType, isFinitePrimitiveValue, type FinitePrimitiveType, type FinitePrimitiveValue, } from './finite-values.js';
|
package/dist/src/cdf/index.js
CHANGED
|
@@ -3,4 +3,3 @@ export { CDF_SCHEMA_URL, cdfJsonSchema } from './schema.js';
|
|
|
3
3
|
export { CDF_PROPERTY_TYPES, CDF_PROPERTY_CATEGORIES } from './vocabularies.js';
|
|
4
4
|
export { CDFComponentSchema, CDFPropertySchema, CDFSlotSchema, CDFTokenSchema, } from './types.js';
|
|
5
5
|
export { buildCDF, buildFilteredCDF, stripUnsupportedSlotFields, validateSlotReferences, } from './build.js';
|
|
6
|
-
export { finiteValuesIssue, isFinitePrimitiveType, isFinitePrimitiveValue, } from './finite-values.js';
|
package/dist/src/cdf/types.d.ts
CHANGED
|
@@ -1,36 +1,13 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import { CDF_FIELD_TYPES, CDF_PROPERTY_CATEGORIES } from './vocabularies.js';
|
|
3
|
-
/**
|
|
4
|
-
* Recursive field shape for the property-contract validators
|
|
5
|
-
* (`validateCDFProperty`). Dormant: the live `CDFPropertySchema` below is
|
|
6
|
-
* unchanged until generation switches over. See INTEG-4927.
|
|
7
|
-
*/
|
|
8
|
-
export interface CDFFieldDefinition {
|
|
9
|
-
$type: (typeof CDF_FIELD_TYPES)[number];
|
|
10
|
-
$category?: (typeof CDF_PROPERTY_CATEGORIES)[number];
|
|
11
|
-
$description?: string;
|
|
12
|
-
$required?: boolean;
|
|
13
|
-
$default?: import('../property-contract/json-value.js').JsonValue;
|
|
14
|
-
$values?: import('../property-contract/json-value.js').JsonValue[];
|
|
15
|
-
$items?: CDFFieldDefinition;
|
|
16
|
-
$fields?: Record<string, CDFFieldDefinition>;
|
|
17
|
-
value?: import('../property-contract/json-value.js').JsonValue;
|
|
18
|
-
valueType?: CDFFieldDefinition;
|
|
19
|
-
discriminator?: string;
|
|
20
|
-
members?: CDFFieldDefinition[];
|
|
21
|
-
allowedResources?: import('../property-contract/target-definition.js').TargetDefinition['allowedResources'];
|
|
22
|
-
'$token.kind'?: string;
|
|
23
|
-
'$token.allowed'?: string[];
|
|
24
|
-
}
|
|
25
2
|
export declare const CDFPropertySchema: z.ZodMiniObject<{
|
|
26
3
|
$type: z.ZodMiniEnum<{
|
|
27
4
|
string: "string";
|
|
28
5
|
number: "number";
|
|
29
6
|
boolean: "boolean";
|
|
30
|
-
enum: "enum";
|
|
31
7
|
richtext: "richtext";
|
|
32
8
|
media: "media";
|
|
33
9
|
link: "link";
|
|
10
|
+
enum: "enum";
|
|
34
11
|
token: "token";
|
|
35
12
|
}>;
|
|
36
13
|
$category: z.ZodMiniEnum<{
|
|
@@ -61,10 +38,10 @@ export declare const CDFComponentSchema: z.ZodMiniObject<{
|
|
|
61
38
|
string: "string";
|
|
62
39
|
number: "number";
|
|
63
40
|
boolean: "boolean";
|
|
64
|
-
enum: "enum";
|
|
65
41
|
richtext: "richtext";
|
|
66
42
|
media: "media";
|
|
67
43
|
link: "link";
|
|
44
|
+
enum: "enum";
|
|
68
45
|
token: "token";
|
|
69
46
|
}>;
|
|
70
47
|
$category: z.ZodMiniEnum<{
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export declare const CDF_PROPERTY_TYPES: readonly ["string", "richtext", "number", "media", "link", "enum", "token", "boolean"];
|
|
2
2
|
export declare const CDF_PROPERTY_CATEGORIES: readonly ["content", "design", "state", "unattached"];
|
|
3
|
-
export declare const CDF_FIELD_TYPES: readonly ["string", "richtext", "number", "media", "link", "token", "boolean", "array", "record", "Integer", "DateTime", "Literal", "RichText", "JSON", "ResourceLink", "DiscriminatedUnion"];
|
|
@@ -9,25 +9,3 @@ export const CDF_PROPERTY_TYPES = [
|
|
|
9
9
|
'boolean',
|
|
10
10
|
];
|
|
11
11
|
export const CDF_PROPERTY_CATEGORIES = ['content', 'design', 'state', 'unattached'];
|
|
12
|
-
// Richer field vocabulary for the property-contract validators. Dormant:
|
|
13
|
-
// `CDF_PROPERTY_TYPES` still drives the live CDF schema, review editor and
|
|
14
|
-
// server contract. The two converge (and `enum` is retired in favour of
|
|
15
|
-
// `$values`) when generation switches to the property contract. See INTEG-4927.
|
|
16
|
-
export const CDF_FIELD_TYPES = [
|
|
17
|
-
'string',
|
|
18
|
-
'richtext',
|
|
19
|
-
'number',
|
|
20
|
-
'media',
|
|
21
|
-
'link',
|
|
22
|
-
'token',
|
|
23
|
-
'boolean',
|
|
24
|
-
'array',
|
|
25
|
-
'record',
|
|
26
|
-
'Integer',
|
|
27
|
-
'DateTime',
|
|
28
|
-
'Literal',
|
|
29
|
-
'RichText',
|
|
30
|
-
'JSON',
|
|
31
|
-
'ResourceLink',
|
|
32
|
-
'DiscriminatedUnion',
|
|
33
|
-
];
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './source-input-association.js';
|
|
3
|
-
export { validateCDF, parseCDFComponents, CDF_SCHEMA_URL, cdfJsonSchema, CDF_PROPERTY_TYPES, CDF_PROPERTY_CATEGORIES, CDFComponentSchema, CDFPropertySchema, CDFSlotSchema, CDFTokenSchema, buildCDF, buildFilteredCDF, stripUnsupportedSlotFields, validateSlotReferences, finiteValuesIssue, isFinitePrimitiveType, isFinitePrimitiveValue, type FinitePrimitiveType, type FinitePrimitiveValue, type CDFComponentEntry, type CDFFieldDefinition, type CDFPropertyDefinition, type CDFSlotDefinition, type CDFTokenEntry, type CDFValidationError, type CDFValidationResult, type CDFDocument, } from './cdf/index.js';
|
|
1
|
+
export { validateCDF, parseCDFComponents, CDF_SCHEMA_URL, cdfJsonSchema, CDF_PROPERTY_TYPES, CDF_PROPERTY_CATEGORIES, CDFComponentSchema, CDFPropertySchema, CDFSlotSchema, CDFTokenSchema, buildCDF, buildFilteredCDF, stripUnsupportedSlotFields, validateSlotReferences, type CDFComponentEntry, type CDFPropertyDefinition, type CDFSlotDefinition, type CDFTokenEntry, type CDFValidationError, type CDFValidationResult, type CDFDocument, } from './cdf/index.js';
|
|
4
2
|
export { DESIGN_TOKEN_TYPES, flattenDTCG, validateDTCG, DTCGTokenSchema, type DesignTokenType, type DTCGTokenEntry, type DTCGTokenGroup, type DTCGTokenNode, type DTCGTokenGroupNode, type DTCGValidationError, type DTCGValidationResult, } from './dtcg/index.js';
|
|
5
3
|
export type { BreakingChange, ChangeClassification, DownstreamImpact, PropertySummary, ComponentTypeSummary, DesignTokenSummary, TaxonomySummary, ChangedEntity, EntityDiffGroup, ServerPreviewResponse, } from './sources-api/preview/index.js';
|
|
6
4
|
export type { ApplyOperationStatus, ApplyOperationItemError, ApplyOperationItem, ApplyOperationResponse, ApplyGateError, } from './sources-api/apply/index.js';
|
|
7
5
|
export * from './property-contract/index.js';
|
|
8
|
-
export { validateCDFProperty, cdfToTarget, targetToCDF, cdfDefinitionChildren, containsCDFDefinitionType, } from './cdf/property-validation.js';
|
package/dist/src/index.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
export * from './source-input-association.js';
|
|
2
1
|
// CDF (Component Definition Format) exports — one schema/file for both
|
|
3
2
|
// components and design tokens, no separate manifest envelope.
|
|
4
|
-
export { validateCDF, parseCDFComponents, CDF_SCHEMA_URL, cdfJsonSchema, CDF_PROPERTY_TYPES, CDF_PROPERTY_CATEGORIES, CDFComponentSchema, CDFPropertySchema, CDFSlotSchema, CDFTokenSchema, buildCDF, buildFilteredCDF, stripUnsupportedSlotFields, validateSlotReferences,
|
|
3
|
+
export { validateCDF, parseCDFComponents, CDF_SCHEMA_URL, cdfJsonSchema, CDF_PROPERTY_TYPES, CDF_PROPERTY_CATEGORIES, CDFComponentSchema, CDFPropertySchema, CDFSlotSchema, CDFTokenSchema, buildCDF, buildFilteredCDF, stripUnsupportedSlotFields, validateSlotReferences, } from './cdf/index.js';
|
|
5
4
|
// DTCG (W3C Design Token Community Group)
|
|
6
5
|
export { DESIGN_TOKEN_TYPES, flattenDTCG, validateDTCG, DTCGTokenSchema, } from './dtcg/index.js';
|
|
7
6
|
// Property contract — pillar #4 foundation (target types + validators).
|
|
8
7
|
// Dormant: no current consumer imports these. Available for forthcoming
|
|
9
8
|
// evidence-aware extractors and generation. See INTEG-5147 / INTEG-4927.
|
|
10
9
|
export * from './property-contract/index.js';
|
|
11
|
-
// CDF property validation over the property contract. Dormant: the live
|
|
12
|
-
// `validateCDF` path still uses `CDFPropertySchema`. See INTEG-4927.
|
|
13
|
-
export { validateCDFProperty, cdfToTarget, targetToCDF, cdfDefinitionChildren, containsCDFDefinitionType, } from './cdf/property-validation.js';
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type FinitePrimitiveValue = string | number | boolean;
|
|
2
|
-
export type FinitePrimitiveType = 'string' | 'number' | 'boolean';
|
|
3
|
-
export declare function isFinitePrimitiveType(type: unknown): type is FinitePrimitiveType;
|
|
4
|
-
export declare function isFinitePrimitiveValue(value: unknown): value is FinitePrimitiveValue;
|
|
5
|
-
export declare function finiteValuesIssue(type: unknown, values: readonly unknown[]): {
|
|
6
|
-
index?: number;
|
|
7
|
-
message: string;
|
|
8
|
-
} | undefined;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export function isFinitePrimitiveType(type) {
|
|
2
|
-
return type === 'string' || type === 'number' || type === 'boolean';
|
|
3
|
-
}
|
|
4
|
-
export function isFinitePrimitiveValue(value) {
|
|
5
|
-
return (typeof value === 'string' || typeof value === 'boolean' || (typeof value === 'number' && Number.isFinite(value)));
|
|
6
|
-
}
|
|
7
|
-
export function finiteValuesIssue(type, values) {
|
|
8
|
-
if (!isFinitePrimitiveType(type))
|
|
9
|
-
return { message: '$values is only valid for string, number, or boolean types' };
|
|
10
|
-
if (values.length === 0)
|
|
11
|
-
return { message: '$values must contain at least one value' };
|
|
12
|
-
const seen = new Set();
|
|
13
|
-
for (const [index, value] of values.entries()) {
|
|
14
|
-
if (!isFinitePrimitiveValue(value) || typeof value !== type)
|
|
15
|
-
return { index, message: `Each $values member must match the ${type} type` };
|
|
16
|
-
if (seen.has(value))
|
|
17
|
-
return { index, message: '$values must not contain duplicate values' };
|
|
18
|
-
seen.add(value);
|
|
19
|
-
}
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { CDFFieldDefinition } from './types.js';
|
|
2
|
-
import { type PropertyIssue } from '../property-contract/json-value.js';
|
|
3
|
-
import { type TargetDefinition } from '../property-contract/target-definition.js';
|
|
4
|
-
export declare function cdfToTarget(d: CDFFieldDefinition): TargetDefinition;
|
|
5
|
-
/** Decode complete target metadata without narrowing it to a type name. */
|
|
6
|
-
export declare function targetToCDF(d: TargetDefinition): CDFFieldDefinition;
|
|
7
|
-
/** All recursive grammar children retain their exact paths, including exclusive members. */
|
|
8
|
-
export declare function cdfDefinitionChildren(definition: CDFFieldDefinition): Array<{
|
|
9
|
-
definition: CDFFieldDefinition;
|
|
10
|
-
path: string;
|
|
11
|
-
}>;
|
|
12
|
-
export declare function containsCDFDefinitionType(definition: CDFFieldDefinition, type: string): boolean;
|
|
13
|
-
export declare function validateCDFProperty(input: unknown, requireCategory?: boolean): {
|
|
14
|
-
valid: boolean;
|
|
15
|
-
issues: PropertyIssue[];
|
|
16
|
-
};
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { CDF_FIELD_TYPES, CDF_PROPERTY_CATEGORIES } from './vocabularies.js';
|
|
2
|
-
import { childPath, cloneJson, jsonValueIssue, own } from '../property-contract/json-value.js';
|
|
3
|
-
import { validateTargetDefinition } from '../property-contract/target-definition.js';
|
|
4
|
-
import { SourceInputAssociationSchema } from '../source-input-association.js';
|
|
5
|
-
import { finiteValuesIssue } from './finite-values.js';
|
|
6
|
-
const targetTypes = {
|
|
7
|
-
string: 'String',
|
|
8
|
-
number: 'Number',
|
|
9
|
-
boolean: 'Boolean',
|
|
10
|
-
array: 'Array',
|
|
11
|
-
record: 'Record',
|
|
12
|
-
richtext: 'String',
|
|
13
|
-
media: 'String',
|
|
14
|
-
link: 'String',
|
|
15
|
-
token: 'String',
|
|
16
|
-
Integer: 'Integer',
|
|
17
|
-
DateTime: 'DateTime',
|
|
18
|
-
Literal: 'Literal',
|
|
19
|
-
RichText: 'RichText',
|
|
20
|
-
JSON: 'JSON',
|
|
21
|
-
ResourceLink: 'ResourceLink',
|
|
22
|
-
DiscriminatedUnion: 'DiscriminatedUnion',
|
|
23
|
-
};
|
|
24
|
-
export function cdfToTarget(d) {
|
|
25
|
-
const t = { type: targetTypes[d.$type] };
|
|
26
|
-
if (own(d, '$required'))
|
|
27
|
-
t.required = d.$required;
|
|
28
|
-
if (own(d, '$description'))
|
|
29
|
-
t.description = d.$description;
|
|
30
|
-
if (own(d, '$default'))
|
|
31
|
-
t.defaultValue = d.$default;
|
|
32
|
-
if (d.$values)
|
|
33
|
-
t.values = d.$values;
|
|
34
|
-
if (own(d, 'value'))
|
|
35
|
-
t.value = d.value;
|
|
36
|
-
if (d.valueType)
|
|
37
|
-
t.valueType = cdfToTarget(d.valueType);
|
|
38
|
-
if (d.discriminator !== undefined)
|
|
39
|
-
t.discriminator = d.discriminator;
|
|
40
|
-
if (d.members)
|
|
41
|
-
t.members = d.members.map(cdfToTarget);
|
|
42
|
-
if (d.allowedResources)
|
|
43
|
-
t.allowedResources = d.allowedResources;
|
|
44
|
-
if (d.$items)
|
|
45
|
-
t.items = cdfToTarget(d.$items);
|
|
46
|
-
if (d.$fields)
|
|
47
|
-
t.fields = Object.fromEntries(Object.entries(d.$fields).map(([key, field]) => [key, cdfToTarget(field)]));
|
|
48
|
-
return t;
|
|
49
|
-
}
|
|
50
|
-
/** Decode complete target metadata without narrowing it to a type name. */
|
|
51
|
-
export function targetToCDF(d) {
|
|
52
|
-
const types = {
|
|
53
|
-
String: 'string',
|
|
54
|
-
Number: 'number',
|
|
55
|
-
Boolean: 'boolean',
|
|
56
|
-
Array: 'array',
|
|
57
|
-
Record: 'record',
|
|
58
|
-
Integer: 'Integer',
|
|
59
|
-
DateTime: 'DateTime',
|
|
60
|
-
Literal: 'Literal',
|
|
61
|
-
RichText: 'RichText',
|
|
62
|
-
JSON: 'JSON',
|
|
63
|
-
ResourceLink: 'ResourceLink',
|
|
64
|
-
DiscriminatedUnion: 'DiscriminatedUnion',
|
|
65
|
-
};
|
|
66
|
-
const field = { $type: types[d.type] };
|
|
67
|
-
if (own(d, 'required'))
|
|
68
|
-
field.$required = d.required;
|
|
69
|
-
if (own(d, 'description'))
|
|
70
|
-
field.$description = d.description;
|
|
71
|
-
if (own(d, 'defaultValue'))
|
|
72
|
-
field.$default = cloneJson(d.defaultValue);
|
|
73
|
-
if (d.values)
|
|
74
|
-
field.$values = cloneJson(d.values);
|
|
75
|
-
if (d.items)
|
|
76
|
-
field.$items = targetToCDF(d.items);
|
|
77
|
-
if (d.fields)
|
|
78
|
-
field.$fields = Object.fromEntries(Object.entries(d.fields).map(([key, child]) => [key, targetToCDF(child)]));
|
|
79
|
-
if (own(d, 'value'))
|
|
80
|
-
field.value = cloneJson(d.value);
|
|
81
|
-
if (d.valueType)
|
|
82
|
-
field.valueType = targetToCDF(d.valueType);
|
|
83
|
-
if (d.discriminator !== undefined)
|
|
84
|
-
field.discriminator = d.discriminator;
|
|
85
|
-
if (d.members)
|
|
86
|
-
field.members = d.members.map(targetToCDF);
|
|
87
|
-
if (d.allowedResources)
|
|
88
|
-
field.allowedResources = cloneJson(d.allowedResources);
|
|
89
|
-
return field;
|
|
90
|
-
}
|
|
91
|
-
/** All recursive grammar children retain their exact paths, including exclusive members. */
|
|
92
|
-
export function cdfDefinitionChildren(definition) {
|
|
93
|
-
return [
|
|
94
|
-
...(definition.$items ? [{ definition: definition.$items, path: '/$items' }] : []),
|
|
95
|
-
...(definition.valueType ? [{ definition: definition.valueType, path: '/valueType' }] : []),
|
|
96
|
-
...Object.entries(definition.$fields ?? {}).map(([key, field]) => ({
|
|
97
|
-
definition: field,
|
|
98
|
-
path: childPath('/$fields', key),
|
|
99
|
-
})),
|
|
100
|
-
...(definition.members ?? []).map((member, index) => ({ definition: member, path: '/members/' + index })),
|
|
101
|
-
];
|
|
102
|
-
}
|
|
103
|
-
export function containsCDFDefinitionType(definition, type) {
|
|
104
|
-
return (definition.$type === type ||
|
|
105
|
-
cdfDefinitionChildren(definition).some((child) => containsCDFDefinitionType(child.definition, type)));
|
|
106
|
-
}
|
|
107
|
-
export function validateCDFProperty(input, requireCategory = true) {
|
|
108
|
-
const unsafe = jsonValueIssue(input);
|
|
109
|
-
if (unsafe)
|
|
110
|
-
return { valid: false, issues: [unsafe] };
|
|
111
|
-
const issues = [];
|
|
112
|
-
const walk = (value, path, root, depth) => {
|
|
113
|
-
if (depth > 64 || !value || typeof value !== 'object' || Array.isArray(value)) {
|
|
114
|
-
issues.push({ path, message: 'Expected bounded property definition' });
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
const d = value;
|
|
118
|
-
const add = (key, message) => issues.push({ path: childPath(path, key), message });
|
|
119
|
-
if (!CDF_FIELD_TYPES.includes(d.$type)) {
|
|
120
|
-
add('$type', 'Unknown CDF type');
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if ((root && requireCategory) || own(d, '$category'))
|
|
124
|
-
if (!CDF_PROPERTY_CATEGORIES.includes(d.$category))
|
|
125
|
-
add('$category', 'Unknown category');
|
|
126
|
-
const allowed = new Set(['$type', '$category', '$description', '$required', '$default', '$values']);
|
|
127
|
-
if (root)
|
|
128
|
-
allowed.add('$sourceInput');
|
|
129
|
-
if (own(d, '$sourceInput') &&
|
|
130
|
-
!SourceInputAssociationSchema.safeParse(d.$sourceInput).success)
|
|
131
|
-
add('$sourceInput', 'Invalid source input association');
|
|
132
|
-
if (d.$type === 'array')
|
|
133
|
-
allowed.add('$items');
|
|
134
|
-
if (d.$type === 'record')
|
|
135
|
-
allowed.add('$fields');
|
|
136
|
-
if (['Integer', 'DateTime', 'Literal', 'RichText', 'JSON', 'ResourceLink', 'DiscriminatedUnion'].includes(d.$type) &&
|
|
137
|
-
d.$category !== undefined &&
|
|
138
|
-
d.$category !== 'content')
|
|
139
|
-
add('$category', 'Richer representations require content category');
|
|
140
|
-
if (d.$type === 'Literal') {
|
|
141
|
-
allowed.add('value');
|
|
142
|
-
allowed.add('valueType');
|
|
143
|
-
walk(d.valueType, childPath(path, 'valueType'), false, depth + 1);
|
|
144
|
-
}
|
|
145
|
-
if (d.$type === 'ResourceLink')
|
|
146
|
-
allowed.add('allowedResources');
|
|
147
|
-
if (d.$type === 'DiscriminatedUnion') {
|
|
148
|
-
allowed.add('discriminator');
|
|
149
|
-
allowed.add('members');
|
|
150
|
-
if (!Array.isArray(d.members))
|
|
151
|
-
add('members', 'Expected complete union members');
|
|
152
|
-
else
|
|
153
|
-
d.members.forEach((member, index) => walk(member, childPath(childPath(path, 'members'), index), false, depth + 1));
|
|
154
|
-
}
|
|
155
|
-
if (d.$type === 'token') {
|
|
156
|
-
allowed.add('$token.kind');
|
|
157
|
-
allowed.add('$token.allowed');
|
|
158
|
-
}
|
|
159
|
-
for (const key of Object.keys(d))
|
|
160
|
-
if (!allowed.has(key))
|
|
161
|
-
add(key, 'Unexpected property metadata');
|
|
162
|
-
if (own(d, '$description') && typeof d.$description !== 'string')
|
|
163
|
-
add('$description', 'Expected string');
|
|
164
|
-
if (own(d, '$values')) {
|
|
165
|
-
if (!Array.isArray(d.$values))
|
|
166
|
-
add('$values', 'Expected array');
|
|
167
|
-
else {
|
|
168
|
-
const issue = finiteValuesIssue(d.$type, d.$values);
|
|
169
|
-
if (issue)
|
|
170
|
-
issues.push({
|
|
171
|
-
path: issue.index === undefined
|
|
172
|
-
? childPath(path, '$values')
|
|
173
|
-
: childPath(childPath(path, '$values'), issue.index),
|
|
174
|
-
message: issue.message,
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
if (own(d, '$required') && typeof d.$required !== 'boolean')
|
|
179
|
-
add('$required', 'Expected boolean');
|
|
180
|
-
if (own(d, '$token.kind') && typeof d['$token.kind'] !== 'string')
|
|
181
|
-
add('$token.kind', 'Expected string');
|
|
182
|
-
if (own(d, '$token.allowed') &&
|
|
183
|
-
(!Array.isArray(d['$token.allowed']) || !d['$token.allowed'].every((v) => typeof v === 'string')))
|
|
184
|
-
add('$token.allowed', 'Expected string paths');
|
|
185
|
-
if (d.$type === 'array')
|
|
186
|
-
walk(d.$items, childPath(path, '$items'), false, depth + 1);
|
|
187
|
-
if (d.$type === 'record') {
|
|
188
|
-
if (!d.$fields ||
|
|
189
|
-
typeof d.$fields !== 'object' ||
|
|
190
|
-
Array.isArray(d.$fields) ||
|
|
191
|
-
Object.keys(d.$fields).length === 0)
|
|
192
|
-
add('$fields', 'Expected nonempty field dictionary');
|
|
193
|
-
else
|
|
194
|
-
for (const [key, field] of Object.entries(d.$fields))
|
|
195
|
-
walk(field, childPath(childPath(path, '$fields'), key), false, depth + 1);
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
walk(input, '', true, 0);
|
|
199
|
-
if (!issues.length) {
|
|
200
|
-
for (const issue of validateTargetDefinition(cdfToTarget(input)).issues)
|
|
201
|
-
issues.push({
|
|
202
|
-
path: issue.path
|
|
203
|
-
.replace(/\/defaultValue(?=\/|$)/g, '/$default')
|
|
204
|
-
.replace(/\/items(?=\/|$)/g, '/$items')
|
|
205
|
-
.replace(/\/fields(?=\/|$)/g, '/$fields')
|
|
206
|
-
.replace(/\/values(?=\/|$)/g, '/$values'),
|
|
207
|
-
message: issue.message,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
return { valid: !issues.length, issues };
|
|
211
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { jsonValueIssue } from './json-value.js';
|
|
2
|
-
/** Stable SHA-256 identity for plain source/plan data in Node and browser runtimes. */
|
|
3
|
-
export function contentDigest(value) {
|
|
4
|
-
const issue = jsonValueIssue(value);
|
|
5
|
-
if (issue)
|
|
6
|
-
throw new Error(issue.message);
|
|
7
|
-
const canonical = (input) => {
|
|
8
|
-
if (Array.isArray(input))
|
|
9
|
-
return '[' + input.map(canonical).join(',') + ']';
|
|
10
|
-
if (input && typeof input === 'object')
|
|
11
|
-
return ('{' +
|
|
12
|
-
Object.keys(input)
|
|
13
|
-
.sort()
|
|
14
|
-
.map((key) => JSON.stringify(key) + ':' + canonical(input[key]))
|
|
15
|
-
.join(',') +
|
|
16
|
-
'}');
|
|
17
|
-
return JSON.stringify(input);
|
|
18
|
-
};
|
|
19
|
-
const bytes = new TextEncoder().encode(canonical(value));
|
|
20
|
-
const padded = new Uint8Array(Math.ceil((bytes.length + 9) / 64) * 64);
|
|
21
|
-
padded.set(bytes);
|
|
22
|
-
padded[bytes.length] = 128;
|
|
23
|
-
const view = new DataView(padded.buffer);
|
|
24
|
-
view.setUint32(padded.length - 8, Math.floor(bytes.length / 0x20000000));
|
|
25
|
-
view.setUint32(padded.length - 4, bytes.length * 8);
|
|
26
|
-
const primes = [];
|
|
27
|
-
for (let candidate = 2; primes.length < 64; candidate++)
|
|
28
|
-
if (!primes.some((prime) => prime * prime <= candidate && candidate % prime === 0))
|
|
29
|
-
primes.push(candidate);
|
|
30
|
-
const initial = primes.slice(0, 8).map((prime) => ((Math.sqrt(prime) % 1) * 0x100000000) >>> 0);
|
|
31
|
-
const constants = primes.map((prime) => ((Math.cbrt(prime) % 1) * 0x100000000) >>> 0);
|
|
32
|
-
const rotate = (word, bits) => (word >>> bits) | (word << (32 - bits));
|
|
33
|
-
for (let offset = 0; offset < padded.length; offset += 64) {
|
|
34
|
-
const words = new Uint32Array(64);
|
|
35
|
-
for (let i = 0; i < 16; i++)
|
|
36
|
-
words[i] = view.getUint32(offset + i * 4);
|
|
37
|
-
for (let i = 16; i < 64; i++) {
|
|
38
|
-
const x = words[i - 15], y = words[i - 2];
|
|
39
|
-
words[i] =
|
|
40
|
-
(words[i - 16] +
|
|
41
|
-
(rotate(x, 7) ^ rotate(x, 18) ^ (x >>> 3)) +
|
|
42
|
-
words[i - 7] +
|
|
43
|
-
(rotate(y, 17) ^ rotate(y, 19) ^ (y >>> 10))) >>>
|
|
44
|
-
0;
|
|
45
|
-
}
|
|
46
|
-
let [a, b, c, d, e, f, g, h] = initial;
|
|
47
|
-
for (let i = 0; i < 64; i++) {
|
|
48
|
-
const first = (h +
|
|
49
|
-
(rotate(e, 6) ^ rotate(e, 11) ^ rotate(e, 25)) +
|
|
50
|
-
((e & f) ^ (~e & g)) +
|
|
51
|
-
constants[i] +
|
|
52
|
-
words[i]) >>>
|
|
53
|
-
0;
|
|
54
|
-
const second = ((rotate(a, 2) ^ rotate(a, 13) ^ rotate(a, 22)) + ((a & b) ^ (a & c) ^ (b & c))) >>> 0;
|
|
55
|
-
h = g;
|
|
56
|
-
g = f;
|
|
57
|
-
f = e;
|
|
58
|
-
e = (d + first) >>> 0;
|
|
59
|
-
d = c;
|
|
60
|
-
c = b;
|
|
61
|
-
b = a;
|
|
62
|
-
a = (first + second) >>> 0;
|
|
63
|
-
}
|
|
64
|
-
[a, b, c, d, e, f, g, h].forEach((word, i) => {
|
|
65
|
-
initial[i] = (initial[i] + word) >>> 0;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
return initial.map((word) => word.toString(16).padStart(8, '0')).join('');
|
|
69
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
export type SharedSourceCoverage = 'complete-within-declared-bound' | 'partial' | 'unavailable';
|
|
2
|
-
export interface SharedSourceCallerCoverage {
|
|
3
|
-
scope: 'admitted-source';
|
|
4
|
-
analysis: 'lexical-jsx-in-known-component-bodies' | 'configured-lexical-references';
|
|
5
|
-
coverage: 'partial';
|
|
6
|
-
files: Array<{
|
|
7
|
-
path: string;
|
|
8
|
-
status: 'analyzed' | 'unsupported' | 'parse-error';
|
|
9
|
-
}>;
|
|
10
|
-
unresolvedReferences: number;
|
|
11
|
-
unownedReferences: number;
|
|
12
|
-
components: Array<{
|
|
13
|
-
name: string;
|
|
14
|
-
sourcePath: string;
|
|
15
|
-
referenceCount: number;
|
|
16
|
-
outcome: 'observed' | 'not-observed' | 'unknown';
|
|
17
|
-
reason: string;
|
|
18
|
-
}>;
|
|
19
|
-
}
|
|
20
|
-
export interface SharedSourceRange {
|
|
21
|
-
startLine: number;
|
|
22
|
-
endLine: number;
|
|
23
|
-
displayStartLine: number;
|
|
24
|
-
}
|
|
25
|
-
export interface SharedSourceFile {
|
|
26
|
-
path: string;
|
|
27
|
-
content: string;
|
|
28
|
-
partial: boolean;
|
|
29
|
-
fileId?: string;
|
|
30
|
-
compilerContextId?: string;
|
|
31
|
-
canonicalPath?: string;
|
|
32
|
-
textHash?: string | null;
|
|
33
|
-
coverage?: SharedSourceCoverage;
|
|
34
|
-
ranges?: SharedSourceRange[];
|
|
35
|
-
roles?: string[];
|
|
36
|
-
componentRefs?: Array<{
|
|
37
|
-
componentId: string;
|
|
38
|
-
name: string;
|
|
39
|
-
roles: string[];
|
|
40
|
-
observations?: Array<{
|
|
41
|
-
role: string;
|
|
42
|
-
startLine: number;
|
|
43
|
-
endLine: number;
|
|
44
|
-
}>;
|
|
45
|
-
}>;
|
|
46
|
-
}
|
|
47
|
-
export interface SharedSourceCompilerContext {
|
|
48
|
-
contextId: string;
|
|
49
|
-
configPath: string | null;
|
|
50
|
-
status: 'configured' | 'fallback' | 'ambiguous' | 'invalid';
|
|
51
|
-
referenceOutcome: 'selected' | 'fallback' | 'missing' | 'ambiguous' | 'invalid' | 'cycle' | 'budget-exhausted';
|
|
52
|
-
compilerOptions: Record<string, unknown>;
|
|
53
|
-
configFiles: Array<{
|
|
54
|
-
fileId: string;
|
|
55
|
-
textHash: string | null;
|
|
56
|
-
}>;
|
|
57
|
-
diagnostics: string[];
|
|
58
|
-
}
|
|
59
|
-
export interface SharedSourceReference {
|
|
60
|
-
path: string;
|
|
61
|
-
role: string;
|
|
62
|
-
partial: boolean;
|
|
63
|
-
fileId?: string;
|
|
64
|
-
}
|
|
65
|
-
/** Source files are stored once; lexical references do not prove runtime execution. */
|
|
66
|
-
export interface SharedSource {
|
|
67
|
-
inventory?: unknown;
|
|
68
|
-
omittedInventory?: number;
|
|
69
|
-
files: SharedSourceFile[];
|
|
70
|
-
/** Absent on older snapshots; missing configuration is unknown. */
|
|
71
|
-
compilerContexts?: SharedSourceCompilerContext[];
|
|
72
|
-
omittedCompilerContexts?: number;
|
|
73
|
-
components: Array<{
|
|
74
|
-
component: string;
|
|
75
|
-
source: string;
|
|
76
|
-
refs: SharedSourceReference[];
|
|
77
|
-
componentId?: string;
|
|
78
|
-
}>;
|
|
79
|
-
captureId?: string;
|
|
80
|
-
captureDigest?: string;
|
|
81
|
-
envelopeId?: string;
|
|
82
|
-
envelopeDigest?: string;
|
|
83
|
-
sessionId?: string;
|
|
84
|
-
extractionStepId?: number;
|
|
85
|
-
coverage?: SharedSourceCoverage;
|
|
86
|
-
promptCoverage?: SharedSourceCoverage;
|
|
87
|
-
/** Legacy snapshot metadata; ignored and removed from new prompt projections. */
|
|
88
|
-
projectionBounds?: {
|
|
89
|
-
maxBytes: number;
|
|
90
|
-
usedBytes: number;
|
|
91
|
-
};
|
|
92
|
-
extractionByteBinding?: 'verified-same' | 'changed' | 'unverified';
|
|
93
|
-
omittedFiles?: number;
|
|
94
|
-
omittedRanges?: number;
|
|
95
|
-
omittedComponents?: number;
|
|
96
|
-
omittedDiagnostics?: number;
|
|
97
|
-
omittedObservations?: number;
|
|
98
|
-
diagnostics?: unknown[];
|
|
99
|
-
observations?: {
|
|
100
|
-
accepted: unknown[];
|
|
101
|
-
rejected: unknown[];
|
|
102
|
-
callerCoverage?: SharedSourceCallerCoverage;
|
|
103
|
-
referenceIndexes?: unknown[];
|
|
104
|
-
};
|
|
105
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod/mini';
|
|
2
|
-
export declare const SourceInputAssociationSchema: z.ZodMiniObject<{
|
|
3
|
-
schemaVersion: z.ZodMiniLiteral<1>;
|
|
4
|
-
componentId: z.ZodMiniString<string>;
|
|
5
|
-
componentDeclarationId: z.ZodMiniString<string>;
|
|
6
|
-
rootSymbolId: z.ZodMiniString<string>;
|
|
7
|
-
inputName: z.ZodMiniString<string>;
|
|
8
|
-
inputPath: z.ZodMiniArray<z.ZodMiniString<string>>;
|
|
9
|
-
}, z.core.$strict>;
|
|
10
|
-
export type SourceInputAssociation = z.infer<typeof SourceInputAssociationSchema>;
|
|
11
|
-
export declare function sourceInputOwnerKey(input: SourceInputAssociation): string;
|
|
12
|
-
export declare function validateSourceInputOwners(owners: readonly {
|
|
13
|
-
name: string;
|
|
14
|
-
sourceInput?: SourceInputAssociation;
|
|
15
|
-
}[]): void;
|
|
16
|
-
export declare function validateCDFSourceOwnerContract(entry: {
|
|
17
|
-
$properties: Record<string, {
|
|
18
|
-
$sourceInput?: SourceInputAssociation;
|
|
19
|
-
}>;
|
|
20
|
-
$slots?: Record<string, {
|
|
21
|
-
$sourceInput?: SourceInputAssociation;
|
|
22
|
-
}>;
|
|
23
|
-
}): void;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod/mini';
|
|
2
|
-
const name = z.string().check(z.refine((value) => value.trim().length > 0));
|
|
3
|
-
export const SourceInputAssociationSchema = z
|
|
4
|
-
.strictObject({
|
|
5
|
-
schemaVersion: z.literal(1),
|
|
6
|
-
componentId: name,
|
|
7
|
-
componentDeclarationId: name,
|
|
8
|
-
rootSymbolId: name,
|
|
9
|
-
inputName: name,
|
|
10
|
-
inputPath: z.array(name).check(z.minLength(1)),
|
|
11
|
-
})
|
|
12
|
-
.check(z.refine((value) => value.inputPath[0] === value.inputName));
|
|
13
|
-
export function sourceInputOwnerKey(input) {
|
|
14
|
-
return JSON.stringify([input.componentId, input.componentDeclarationId, input.rootSymbolId, input.inputPath]);
|
|
15
|
-
}
|
|
16
|
-
export function validateSourceInputOwners(owners) {
|
|
17
|
-
const names = new Set();
|
|
18
|
-
const inputs = new Set();
|
|
19
|
-
for (const owner of owners) {
|
|
20
|
-
if (!owner.name.trim() || names.has(owner.name))
|
|
21
|
-
throw new Error('Blank or duplicate authoring name');
|
|
22
|
-
names.add(owner.name);
|
|
23
|
-
if (!owner.sourceInput)
|
|
24
|
-
continue;
|
|
25
|
-
if (!SourceInputAssociationSchema.safeParse(owner.sourceInput).success ||
|
|
26
|
-
owner.sourceInput.inputPath[0] !== owner.sourceInput.inputName)
|
|
27
|
-
throw new Error('Invalid source input association');
|
|
28
|
-
const key = sourceInputOwnerKey(owner.sourceInput);
|
|
29
|
-
if (inputs.has(key))
|
|
30
|
-
throw new Error('Source input has multiple owners');
|
|
31
|
-
inputs.add(key);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export function validateCDFSourceOwnerContract(entry) {
|
|
35
|
-
validateSourceInputOwners([
|
|
36
|
-
...Object.entries(entry.$properties).map(([name, property]) => ({
|
|
37
|
-
name: `property:${name}`,
|
|
38
|
-
sourceInput: property.$sourceInput,
|
|
39
|
-
})),
|
|
40
|
-
...Object.entries(entry.$slots ?? {}).map(([name, slot]) => ({
|
|
41
|
-
name: `slot:${name}`,
|
|
42
|
-
sourceInput: slot.$sourceInput,
|
|
43
|
-
})),
|
|
44
|
-
]);
|
|
45
|
-
for (const [name, slot] of Object.entries(entry.$slots ?? {})) {
|
|
46
|
-
if (!name.trim())
|
|
47
|
-
throw new Error('Blank slot name');
|
|
48
|
-
const input = slot.$sourceInput;
|
|
49
|
-
if (input && entry.$properties[input.inputName] && !entry.$properties[input.inputName].$sourceInput)
|
|
50
|
-
throw new Error('Property and slot conflict over source input ownership');
|
|
51
|
-
}
|
|
52
|
-
}
|