@contentful/experience-design-system-types 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @contentful/experience-design-system-types
2
+
3
+ Shared TypeScript types for the Contentful Experience Design System import pipeline. Covers the two file formats consumers provide (CDF for components, DTCG for tokens) and the contract types for the Design System Sources API.
4
+
5
+ ## Modules
6
+
7
+ ### CDF — Component Definition Format
8
+
9
+ Types and validation for `.cdf.json` component definition files that describe a design system's component library. Exports `validateCDF`, `CDF_V1_SCHEMA_URL`, `CDF_PROPERTY_TYPES`, `CDFComponentEntry`, `CDFPropertyDefinition`, `CDFValidationError`.
10
+
11
+ ### DTCG — Design Token Community Group
12
+
13
+ Types for `.tokens.json` files in the [W3C DTCG format](https://tr.designtokens.org/format/) that describe a design system's token library. Exports `DESIGN_TOKEN_TYPES`, `DesignTokenType`, `DTCGTokenEntry`, `DTCGTokenGroup`, `DTCGTokenNode`, `DTCGTokenGroupNode`.
14
+
15
+ ### Sources API — Manifest
16
+
17
+ Request body sent to both the preview and apply endpoints. Exports `ManifestPayload`.
18
+
19
+ ### Sources API — Preview
20
+
21
+ Response types for the Sources API preview endpoint, which returns a diff of what will change before committing. Exports `ServerPreviewResponse`, `EntityDiffGroup`, `ChangedEntity`, `BreakingChange`, `ChangeClassification`, `DownstreamImpact`, and entity summary types (`ComponentTypeSummary`, `DesignTokenSummary`, `TaxonomySummary`, `PropertySummary`).
22
+
23
+ ### Sources API — Apply
24
+
25
+ Response types for the Sources API apply endpoint, which runs the async import operation. Exports `ApplyOperationResponse`, `ApplyOperationItem`, `ApplyOperationItemError`, `ApplyOperationStatus`, `ApplyGateError`.
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@contentful/experience-design-system-types",
3
+ "version": "2.2.1",
4
+ "type": "module",
5
+ "module": "./dist/src/index.js",
6
+ "main": "./dist/src/index.js",
7
+ "types": "./dist/src/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/src/index.d.ts",
11
+ "import": "./dist/src/index.js",
12
+ "node": "./dist/src/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist/"
17
+ ],
18
+ "scripts": {
19
+ "build": "nx build experience-design-system-types",
20
+ "typecheck": "nx typecheck experience-design-system-types",
21
+ "clean": "nx clean experience-design-system-types",
22
+ "test": "nx test experience-design-system-types",
23
+ "test:watch": "nx test:watch experience-design-system-types",
24
+ "lint": "nx lint experience-design-system-types",
25
+ "lint:fix": "nx lint:fix experience-design-system-types"
26
+ },
27
+ "dependencies": {
28
+ "ajv": "^8.17.1",
29
+ "zod": "^4.3.6"
30
+ },
31
+ "devDependencies": {
32
+ "@tsconfig/node24": "^24.0.3",
33
+ "@types/node": "^24.0.3",
34
+ "eslint": "^9.39.2",
35
+ "eslint-config-prettier": "^10.1.8",
36
+ "eslint-plugin-prettier": "^5.5.4",
37
+ "typescript": "^5.9.3",
38
+ "typescript-eslint": "^8.52.0",
39
+ "vitest": "^4.0.16"
40
+ }
41
+ }
@@ -0,0 +1,4 @@
1
+ export { validateCDF, parseCDFComponents } from './validate.js';
2
+ export { CDF_V1_SCHEMA_URL } from './schema.js';
3
+ export { CDF_PROPERTY_TYPES, CDF_PROPERTY_CATEGORIES } from './vocabularies.js';
4
+ export type { CDFComponentEntry, CDFPropertyDefinition, CDFSlotDefinition, CDFValidationError } from './types.js';
@@ -0,0 +1,3 @@
1
+ export { validateCDF, parseCDFComponents } from './validate.js';
2
+ export { CDF_V1_SCHEMA_URL } from './schema.js';
3
+ export { CDF_PROPERTY_TYPES, CDF_PROPERTY_CATEGORIES } from './vocabularies.js';
@@ -0,0 +1,112 @@
1
+ export declare const CDF_V1_SCHEMA_URL = "https://contentful.com/schemas/cdf/v1";
2
+ export declare const cdfV1JsonSchema: {
3
+ readonly $schema: "http://json-schema.org/draft-07/schema#";
4
+ readonly $id: "https://contentful.com/schemas/cdf/v1";
5
+ readonly title: "CDF Component Definition Format v1";
6
+ readonly type: "object";
7
+ readonly required: readonly ["$schema"];
8
+ readonly properties: {
9
+ readonly $schema: {
10
+ readonly type: "string";
11
+ readonly const: "https://contentful.com/schemas/cdf/v1";
12
+ };
13
+ };
14
+ readonly additionalProperties: {
15
+ readonly $ref: "#/definitions/groupOrComponent";
16
+ };
17
+ readonly definitions: {
18
+ readonly groupOrComponent: {
19
+ readonly oneOf: readonly [{
20
+ readonly $ref: "#/definitions/component";
21
+ }, {
22
+ readonly $ref: "#/definitions/group";
23
+ }];
24
+ };
25
+ readonly component: {
26
+ readonly type: "object";
27
+ readonly required: readonly ["$type", "$properties"];
28
+ readonly properties: {
29
+ readonly $type: {
30
+ readonly type: "string";
31
+ readonly const: "component";
32
+ };
33
+ readonly $description: {
34
+ readonly type: "string";
35
+ };
36
+ readonly $properties: {
37
+ readonly type: "object";
38
+ readonly additionalProperties: {
39
+ readonly $ref: "#/definitions/property";
40
+ };
41
+ };
42
+ readonly $slots: {
43
+ readonly type: "object";
44
+ readonly additionalProperties: {
45
+ readonly $ref: "#/definitions/slot";
46
+ };
47
+ };
48
+ };
49
+ readonly additionalProperties: false;
50
+ };
51
+ readonly property: {
52
+ readonly type: "object";
53
+ readonly required: readonly ["$type", "$category"];
54
+ readonly properties: {
55
+ readonly $type: {
56
+ readonly type: "string";
57
+ readonly enum: readonly ["string", "richtext", "media", "link", "enum", "token", "boolean"];
58
+ };
59
+ readonly $category: {
60
+ readonly type: "string";
61
+ readonly enum: readonly ["content", "design", "state"];
62
+ };
63
+ readonly $description: {
64
+ readonly type: "string";
65
+ };
66
+ readonly $required: {
67
+ readonly type: "boolean";
68
+ };
69
+ readonly $default: {};
70
+ readonly $values: {
71
+ readonly type: "array";
72
+ readonly items: {
73
+ readonly type: "string";
74
+ };
75
+ };
76
+ readonly '$token.kind': {
77
+ readonly type: "string";
78
+ };
79
+ };
80
+ readonly additionalProperties: false;
81
+ };
82
+ readonly slot: {
83
+ readonly type: "object";
84
+ readonly properties: {
85
+ readonly $description: {
86
+ readonly type: "string";
87
+ };
88
+ readonly $required: {
89
+ readonly type: "boolean";
90
+ };
91
+ readonly $allowedComponents: {
92
+ readonly type: "array";
93
+ readonly items: {
94
+ readonly type: "string";
95
+ };
96
+ };
97
+ };
98
+ readonly additionalProperties: false;
99
+ };
100
+ readonly group: {
101
+ readonly type: "object";
102
+ readonly properties: {
103
+ readonly $description: {
104
+ readonly type: "string";
105
+ };
106
+ };
107
+ readonly additionalProperties: {
108
+ readonly $ref: "#/definitions/groupOrComponent";
109
+ };
110
+ };
111
+ };
112
+ };
@@ -0,0 +1,63 @@
1
+ import { CDF_PROPERTY_TYPES, CDF_PROPERTY_CATEGORIES } from './vocabularies.js';
2
+ export const CDF_V1_SCHEMA_URL = 'https://contentful.com/schemas/cdf/v1';
3
+ export const cdfV1JsonSchema = {
4
+ $schema: 'http://json-schema.org/draft-07/schema#',
5
+ $id: CDF_V1_SCHEMA_URL,
6
+ title: 'CDF Component Definition Format v1',
7
+ type: 'object',
8
+ required: ['$schema'],
9
+ properties: {
10
+ $schema: { type: 'string', const: CDF_V1_SCHEMA_URL },
11
+ },
12
+ additionalProperties: { $ref: '#/definitions/groupOrComponent' },
13
+ definitions: {
14
+ groupOrComponent: {
15
+ oneOf: [{ $ref: '#/definitions/component' }, { $ref: '#/definitions/group' }],
16
+ },
17
+ component: {
18
+ type: 'object',
19
+ required: ['$type', '$properties'],
20
+ properties: {
21
+ $type: { type: 'string', const: 'component' },
22
+ $description: { type: 'string' },
23
+ $properties: {
24
+ type: 'object',
25
+ additionalProperties: { $ref: '#/definitions/property' },
26
+ },
27
+ $slots: {
28
+ type: 'object',
29
+ additionalProperties: { $ref: '#/definitions/slot' },
30
+ },
31
+ },
32
+ additionalProperties: false,
33
+ },
34
+ property: {
35
+ type: 'object',
36
+ required: ['$type', '$category'],
37
+ properties: {
38
+ $type: { type: 'string', enum: [...CDF_PROPERTY_TYPES] },
39
+ $category: { type: 'string', enum: [...CDF_PROPERTY_CATEGORIES] },
40
+ $description: { type: 'string' },
41
+ $required: { type: 'boolean' },
42
+ $default: {},
43
+ $values: { type: 'array', items: { type: 'string' } },
44
+ '$token.kind': { type: 'string' },
45
+ },
46
+ additionalProperties: false,
47
+ },
48
+ slot: {
49
+ type: 'object',
50
+ properties: {
51
+ $description: { type: 'string' },
52
+ $required: { type: 'boolean' },
53
+ $allowedComponents: { type: 'array', items: { type: 'string' } },
54
+ },
55
+ additionalProperties: false,
56
+ },
57
+ group: {
58
+ type: 'object',
59
+ properties: { $description: { type: 'string' } },
60
+ additionalProperties: { $ref: '#/definitions/groupOrComponent' },
61
+ },
62
+ },
63
+ };
@@ -0,0 +1,44 @@
1
+ import type { CDFPropertyType, CDFPropertyCategory } from './vocabularies.js';
2
+ export interface CDFPropertyDefinition {
3
+ $type: CDFPropertyType;
4
+ $category: CDFPropertyCategory;
5
+ $description?: string;
6
+ $required?: boolean;
7
+ $default?: unknown;
8
+ $values?: string[];
9
+ '$token.kind'?: string;
10
+ }
11
+ export interface CDFSlotDefinition {
12
+ $description?: string;
13
+ $allowedComponents?: string[];
14
+ $required?: boolean;
15
+ }
16
+ export interface CDFComponentEntry {
17
+ $type: 'component';
18
+ $description?: string;
19
+ $properties: Record<string, CDFPropertyDefinition>;
20
+ $slots?: Record<string, CDFSlotDefinition>;
21
+ }
22
+ export type CDFGroupOrComponent = CDFComponentEntry | CDFGroup;
23
+ export interface CDFGroup {
24
+ $description?: string;
25
+ [key: string]: CDFGroupOrComponent | string | undefined;
26
+ }
27
+ export interface CDFFile {
28
+ $schema: string;
29
+ [key: string]: CDFGroupOrComponent | string | undefined;
30
+ }
31
+ export interface CDFValidationError {
32
+ path: string;
33
+ message: string;
34
+ expected?: string;
35
+ actual?: string;
36
+ }
37
+ export interface CDFValidationResult {
38
+ valid: boolean;
39
+ errors: CDFValidationError[];
40
+ components: Array<{
41
+ key: string;
42
+ entry: CDFComponentEntry;
43
+ }>;
44
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { CDFComponentEntry, CDFValidationResult } from './types.js';
2
+ export declare function parseCDFComponents(obj: Record<string, unknown>, prefix?: string): Array<{
3
+ key: string;
4
+ entry: CDFComponentEntry;
5
+ }>;
6
+ export declare function validateCDF(input: unknown): CDFValidationResult;
@@ -0,0 +1,52 @@
1
+ import { Ajv } from 'ajv';
2
+ import { cdfV1JsonSchema, CDF_V1_SCHEMA_URL } from './schema.js';
3
+ const ajv = new Ajv({ allErrors: true });
4
+ const validate = ajv.compile(cdfV1JsonSchema);
5
+ function isComponentEntry(value) {
6
+ return (typeof value === 'object' &&
7
+ value !== null &&
8
+ '$type' in value &&
9
+ value['$type'] === 'component');
10
+ }
11
+ export function parseCDFComponents(obj, prefix = '') {
12
+ const results = [];
13
+ for (const [key, value] of Object.entries(obj)) {
14
+ if (key.startsWith('$'))
15
+ continue;
16
+ if (isComponentEntry(value)) {
17
+ results.push({ key: prefix ? `${prefix}.${key}` : key, entry: value });
18
+ }
19
+ else if (typeof value === 'object' && value !== null) {
20
+ results.push(...parseCDFComponents(value, prefix ? `${prefix}.${key}` : key));
21
+ }
22
+ }
23
+ return results;
24
+ }
25
+ export function validateCDF(input) {
26
+ const valid = validate(input);
27
+ if (!valid) {
28
+ const errors = (validate.errors ?? []).map((err) => ({
29
+ path: err.instancePath || '/',
30
+ message: err.message ?? 'Unknown validation error',
31
+ expected: err.params ? JSON.stringify(err.params) : undefined,
32
+ }));
33
+ return { valid: false, errors, components: [] };
34
+ }
35
+ const file = input;
36
+ if (file.$schema !== CDF_V1_SCHEMA_URL) {
37
+ return {
38
+ valid: false,
39
+ errors: [
40
+ {
41
+ path: '/$schema',
42
+ message: `Expected schema "${CDF_V1_SCHEMA_URL}"`,
43
+ expected: CDF_V1_SCHEMA_URL,
44
+ actual: file.$schema,
45
+ },
46
+ ],
47
+ components: [],
48
+ };
49
+ }
50
+ const components = parseCDFComponents(file);
51
+ return { valid: true, errors: [], components };
52
+ }
@@ -0,0 +1,4 @@
1
+ export declare const CDF_PROPERTY_TYPES: readonly ["string", "richtext", "media", "link", "enum", "token", "boolean"];
2
+ export type CDFPropertyType = (typeof CDF_PROPERTY_TYPES)[number];
3
+ export declare const CDF_PROPERTY_CATEGORIES: readonly ["content", "design", "state"];
4
+ export type CDFPropertyCategory = (typeof CDF_PROPERTY_CATEGORIES)[number];
@@ -0,0 +1,2 @@
1
+ export const CDF_PROPERTY_TYPES = ['string', 'richtext', 'media', 'link', 'enum', 'token', 'boolean'];
2
+ export const CDF_PROPERTY_CATEGORIES = ['content', 'design', 'state'];
@@ -0,0 +1,4 @@
1
+ export { DESIGN_TOKEN_TYPES, type DesignTokenType } from './token-types.js';
2
+ export type { DTCGTokenEntry, DTCGTokenGroup, DTCGTokenNode, DTCGTokenGroupNode } from './types.js';
3
+ export { flattenDTCG } from './utils.js';
4
+ export { validateDTCG, type DTCGValidationError, type DTCGValidationResult } from './validate.js';
@@ -0,0 +1,3 @@
1
+ export { DESIGN_TOKEN_TYPES } from './token-types.js';
2
+ export { flattenDTCG } from './utils.js';
3
+ export { validateDTCG } from './validate.js';
@@ -0,0 +1,2 @@
1
+ export declare const DESIGN_TOKEN_TYPES: readonly ["color", "dimension", "fontFamily", "fontWeight", "duration", "cubicBezier", "number", "strokeStyle", "border", "transition", "shadow", "gradient", "typography"];
2
+ export type DesignTokenType = (typeof DESIGN_TOKEN_TYPES)[number];
@@ -0,0 +1,15 @@
1
+ export const DESIGN_TOKEN_TYPES = [
2
+ 'color',
3
+ 'dimension',
4
+ 'fontFamily',
5
+ 'fontWeight',
6
+ 'duration',
7
+ 'cubicBezier',
8
+ 'number',
9
+ 'strokeStyle',
10
+ 'border',
11
+ 'transition',
12
+ 'shadow',
13
+ 'gradient',
14
+ 'typography',
15
+ ];
@@ -0,0 +1,22 @@
1
+ import type { DesignTokenType } from './token-types.js';
2
+ export interface DTCGTokenEntry {
3
+ path: string;
4
+ $type: DesignTokenType;
5
+ $value: unknown;
6
+ $description?: string;
7
+ }
8
+ export interface DTCGTokenGroup {
9
+ path: string;
10
+ $description?: string;
11
+ tokenIds: string[];
12
+ }
13
+ export type DTCGTokenNode = DTCGTokenLeaf | DTCGTokenGroupNode;
14
+ export interface DTCGTokenLeaf {
15
+ $type: string;
16
+ $value: unknown;
17
+ $description?: string;
18
+ }
19
+ export interface DTCGTokenGroupNode {
20
+ $description?: string;
21
+ [key: string]: DTCGTokenNode | string | undefined;
22
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { DTCGTokenEntry } from './types.js';
2
+ export declare function flattenDTCG(obj: Record<string, unknown>, prefix: string): DTCGTokenEntry[];
@@ -0,0 +1,23 @@
1
+ export function flattenDTCG(obj, prefix) {
2
+ const results = [];
3
+ for (const [key, value] of Object.entries(obj)) {
4
+ if (key.startsWith('$'))
5
+ continue;
6
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
7
+ continue;
8
+ const node = value;
9
+ const path = prefix ? `${prefix}.${key}` : key;
10
+ if ('$value' in node) {
11
+ results.push({
12
+ path,
13
+ $type: node.$type,
14
+ $value: node.$value,
15
+ $description: node.$description,
16
+ });
17
+ }
18
+ else {
19
+ results.push(...flattenDTCG(node, path));
20
+ }
21
+ }
22
+ return results;
23
+ }
@@ -0,0 +1,10 @@
1
+ export interface DTCGValidationError {
2
+ path: string;
3
+ message: string;
4
+ actual?: unknown;
5
+ }
6
+ export interface DTCGValidationResult {
7
+ valid: boolean;
8
+ errors: DTCGValidationError[];
9
+ }
10
+ export declare function validateDTCG(obj: Record<string, unknown>): DTCGValidationResult;
@@ -0,0 +1,20 @@
1
+ import { DESIGN_TOKEN_TYPES } from './token-types.js';
2
+ import { flattenDTCG } from './utils.js';
3
+ const TOKEN_TYPE_SET = new Set(DESIGN_TOKEN_TYPES);
4
+ function isDesignTokenType(value) {
5
+ return typeof value === 'string' && TOKEN_TYPE_SET.has(value);
6
+ }
7
+ export function validateDTCG(obj) {
8
+ const errors = [];
9
+ const tokens = flattenDTCG(obj, '');
10
+ for (const token of tokens) {
11
+ if (!isDesignTokenType(token.$type)) {
12
+ errors.push({
13
+ path: token.path,
14
+ message: `Unknown $type "${token.$type}". Must be one of: ${DESIGN_TOKEN_TYPES.join(', ')}.`,
15
+ actual: token.$type,
16
+ });
17
+ }
18
+ }
19
+ return { valid: errors.length === 0, errors };
20
+ }
@@ -0,0 +1,6 @@
1
+ export { validateCDF, parseCDFComponents, CDF_V1_SCHEMA_URL, CDF_PROPERTY_TYPES, CDF_PROPERTY_CATEGORIES, type CDFComponentEntry, type CDFPropertyDefinition, type CDFSlotDefinition, type CDFValidationError, } from './cdf/index.js';
2
+ export { DESIGN_TOKEN_TYPES, flattenDTCG, validateDTCG, type DesignTokenType, type DTCGTokenEntry, type DTCGTokenGroup, type DTCGTokenNode, type DTCGTokenGroupNode, type DTCGValidationError, type DTCGValidationResult, } from './dtcg/index.js';
3
+ export type { BreakingChange, ChangeClassification, DownstreamImpact, PropertySummary, ComponentTypeSummary, DesignTokenSummary, TaxonomySummary, ChangedEntity, EntityDiffGroup, ServerPreviewResponse, } from './sources-api/preview/index.js';
4
+ export type { ApplyOperationStatus, ApplyOperationItemError, ApplyOperationItem, ApplyOperationResponse, ApplyGateError, } from './sources-api/apply/index.js';
5
+ export type { ManifestPayload } from './sources-api/manifest/index.js';
6
+ export { buildManifest, buildFilteredManifest, stripUnsupportedSlotFields } from './sources-api/manifest/index.js';
@@ -0,0 +1,5 @@
1
+ // CDF (Component Definition Format)
2
+ export { validateCDF, parseCDFComponents, CDF_V1_SCHEMA_URL, CDF_PROPERTY_TYPES, CDF_PROPERTY_CATEGORIES, } from './cdf/index.js';
3
+ // DTCG (W3C Design Token Community Group)
4
+ export { DESIGN_TOKEN_TYPES, flattenDTCG, validateDTCG, } from './dtcg/index.js';
5
+ export { buildManifest, buildFilteredManifest, stripUnsupportedSlotFields } from './sources-api/manifest/index.js';
@@ -0,0 +1,49 @@
1
+ export type ApplyOperationStatus = 'queued' | 'running' | 'succeeded' | 'partial' | 'failed';
2
+ export interface ApplyOperationItemError {
3
+ code: string;
4
+ message: string;
5
+ }
6
+ export interface ApplyOperationItem {
7
+ entityType: 'ComponentType' | 'DesignToken';
8
+ id: string;
9
+ action: 'create' | 'update' | 'delete';
10
+ status: 'queued' | 'succeeded' | 'failed';
11
+ error?: string | ApplyOperationItemError;
12
+ }
13
+ export interface ApplyOperationResponse {
14
+ sys: {
15
+ type: 'ApplyOperation';
16
+ id: string;
17
+ status: ApplyOperationStatus;
18
+ createdAt: string;
19
+ createdBy: {
20
+ sys: {
21
+ type: 'Link';
22
+ linkType: string;
23
+ id: string;
24
+ };
25
+ };
26
+ };
27
+ summary: {
28
+ total: number;
29
+ pending: number;
30
+ succeeded: number;
31
+ failed: number;
32
+ };
33
+ items?: ApplyOperationItem[];
34
+ }
35
+ export interface ApplyGateError {
36
+ sys: {
37
+ type: 'Error';
38
+ id: string;
39
+ };
40
+ message: string;
41
+ details?: {
42
+ breakingComponentIds?: string[];
43
+ affectedEntities?: number;
44
+ errors?: Array<{
45
+ path: string;
46
+ message: string;
47
+ }>;
48
+ };
49
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export interface ManifestPayload {
2
+ componentsManifest?: Record<string, unknown>;
3
+ tokensManifest?: Record<string, unknown>;
4
+ }
5
+ export { buildManifest, buildFilteredManifest, stripUnsupportedSlotFields } from './utils.js';
@@ -0,0 +1 @@
1
+ export { buildManifest, buildFilteredManifest, stripUnsupportedSlotFields } from './utils.js';
@@ -0,0 +1,9 @@
1
+ import type { CDFComponentEntry } from '../../cdf/index.js';
2
+ import type { DTCGTokenEntry } from '../../dtcg/types.js';
3
+ import type { ManifestPayload } from './index.js';
4
+ export declare function stripUnsupportedSlotFields(entry: CDFComponentEntry): CDFComponentEntry;
5
+ export declare function buildManifest(components: Array<{
6
+ key: string;
7
+ entry: CDFComponentEntry;
8
+ }>, tokens: DTCGTokenEntry[]): ManifestPayload;
9
+ export declare function buildFilteredManifest(fullManifest: ManifestPayload, selectedComponentKeys: Set<string>, selectedTokenPaths: Set<string>): ManifestPayload;
@@ -0,0 +1,60 @@
1
+ import { CDF_V1_SCHEMA_URL } from '../../cdf/index.js';
2
+ export function stripUnsupportedSlotFields(entry) {
3
+ if (!entry.$slots)
4
+ return entry;
5
+ const cleaned = {};
6
+ for (const [name, slot] of Object.entries(entry.$slots)) {
7
+ const { $required: _required, ...rest } = slot;
8
+ cleaned[name] = rest;
9
+ }
10
+ return { ...entry, $slots: cleaned };
11
+ }
12
+ export function buildManifest(components, tokens) {
13
+ const manifest = {};
14
+ if (components.length > 0) {
15
+ const componentsObj = { $schema: CDF_V1_SCHEMA_URL };
16
+ for (const { key, entry } of components) {
17
+ componentsObj[key] = stripUnsupportedSlotFields(entry);
18
+ }
19
+ manifest.componentsManifest = componentsObj;
20
+ }
21
+ if (tokens.length > 0) {
22
+ const tokensObj = {};
23
+ for (const token of tokens) {
24
+ tokensObj[token.path] = {
25
+ $type: token.$type,
26
+ $value: token.$value,
27
+ ...(token.$description ? { $description: token.$description } : {}),
28
+ };
29
+ }
30
+ manifest.tokensManifest = tokensObj;
31
+ }
32
+ return manifest;
33
+ }
34
+ export function buildFilteredManifest(fullManifest, selectedComponentKeys, selectedTokenPaths) {
35
+ const filtered = {};
36
+ if (fullManifest.componentsManifest) {
37
+ const obj = {};
38
+ if (fullManifest.componentsManifest['$schema']) {
39
+ obj['$schema'] = fullManifest.componentsManifest['$schema'];
40
+ }
41
+ for (const [key, value] of Object.entries(fullManifest.componentsManifest)) {
42
+ if (key === '$schema')
43
+ continue;
44
+ if (selectedComponentKeys.has(key))
45
+ obj[key] = value;
46
+ }
47
+ if (Object.keys(obj).length > 1)
48
+ filtered.componentsManifest = obj;
49
+ }
50
+ if (fullManifest.tokensManifest) {
51
+ const obj = {};
52
+ for (const [path, value] of Object.entries(fullManifest.tokensManifest)) {
53
+ if (selectedTokenPaths.has(path))
54
+ obj[path] = value;
55
+ }
56
+ if (Object.keys(obj).length > 0)
57
+ filtered.tokensManifest = obj;
58
+ }
59
+ return filtered;
60
+ }
@@ -0,0 +1,54 @@
1
+ export interface BreakingChange {
2
+ propertyId: string;
3
+ reason: 'removed' | 'added_required_no_default' | 'type_changed' | 'validation_narrowed';
4
+ }
5
+ export interface ChangeClassification {
6
+ classification: 'breaking' | 'compatible';
7
+ breakingChanges: BreakingChange[];
8
+ }
9
+ export interface DownstreamImpact {
10
+ affectedFragments: number;
11
+ affectedExperiences: number;
12
+ }
13
+ export interface PropertySummary {
14
+ type: string;
15
+ category: string;
16
+ required: boolean;
17
+ default?: unknown;
18
+ }
19
+ export interface ComponentTypeSummary {
20
+ id: string;
21
+ name: string;
22
+ contentProperties: string[];
23
+ designProperties: string[];
24
+ slots: string[];
25
+ fullProperties?: Record<string, PropertySummary>;
26
+ }
27
+ export interface DesignTokenSummary {
28
+ id: string;
29
+ name: string;
30
+ kind: string;
31
+ }
32
+ export interface TaxonomySummary {
33
+ id: string;
34
+ name: string;
35
+ tokenIds: string[];
36
+ }
37
+ export interface ChangedEntity<TCurrent, TProposed> {
38
+ current: TCurrent;
39
+ proposed: TProposed;
40
+ hasPendingDraftChanges: boolean;
41
+ changeClassification?: ChangeClassification;
42
+ impact?: DownstreamImpact;
43
+ }
44
+ export interface EntityDiffGroup<TCurrent, TProposed> {
45
+ new: TProposed[];
46
+ changed: ChangedEntity<TCurrent, TProposed>[];
47
+ unchanged: string[];
48
+ removed: TCurrent[];
49
+ }
50
+ export interface ServerPreviewResponse {
51
+ components: EntityDiffGroup<ComponentTypeSummary, Record<string, unknown>>;
52
+ tokens: EntityDiffGroup<DesignTokenSummary, Record<string, unknown>>;
53
+ taxonomies: EntityDiffGroup<TaxonomySummary, Record<string, unknown>>;
54
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@contentful/experience-design-system-types",
3
+ "version": "2.2.1",
4
+ "type": "module",
5
+ "module": "./dist/src/index.js",
6
+ "main": "./dist/src/index.js",
7
+ "types": "./dist/src/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/src/index.d.ts",
11
+ "import": "./dist/src/index.js",
12
+ "node": "./dist/src/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist/"
17
+ ],
18
+ "dependencies": {
19
+ "ajv": "^8.17.1",
20
+ "zod": "^4.3.6"
21
+ },
22
+ "devDependencies": {
23
+ "@tsconfig/node24": "^24.0.3",
24
+ "@types/node": "^24.0.3",
25
+ "eslint": "^9.39.2",
26
+ "eslint-config-prettier": "^10.1.8",
27
+ "eslint-plugin-prettier": "^5.5.4",
28
+ "typescript": "^5.9.3",
29
+ "typescript-eslint": "^8.52.0",
30
+ "vitest": "^4.0.16"
31
+ },
32
+ "scripts": {
33
+ "build": "nx build experience-design-system-types",
34
+ "typecheck": "nx typecheck experience-design-system-types",
35
+ "clean": "nx clean experience-design-system-types",
36
+ "test": "nx test experience-design-system-types",
37
+ "test:watch": "nx test:watch experience-design-system-types",
38
+ "lint": "nx lint experience-design-system-types",
39
+ "lint:fix": "nx lint:fix experience-design-system-types"
40
+ }
41
+ }