@continuum-dev/contract 0.1.1-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/CONTRACT_REFERENCE.md +349 -0
- package/LICENSE +21 -0
- package/README.md +170 -0
- package/index.d.ts +6 -0
- package/index.d.ts.map +1 -0
- package/index.js +5 -0
- package/lib/constants.d.ts +93 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +71 -0
- package/lib/continuity-snapshot.d.ts +16 -0
- package/lib/continuity-snapshot.d.ts.map +1 -0
- package/lib/continuity-snapshot.js +1 -0
- package/lib/data-snapshot.d.ts +263 -0
- package/lib/data-snapshot.d.ts.map +1 -0
- package/lib/data-snapshot.js +1 -0
- package/lib/interaction.d.ts +29 -0
- package/lib/interaction.d.ts.map +1 -0
- package/lib/interactions.d.ts +98 -0
- package/lib/interactions.d.ts.map +1 -0
- package/lib/interactions.js +1 -0
- package/lib/schema.d.ts +62 -0
- package/lib/schema.d.ts.map +1 -0
- package/lib/snapshot.d.ts +7 -0
- package/lib/snapshot.d.ts.map +1 -0
- package/lib/state.d.ts +39 -0
- package/lib/state.d.ts.map +1 -0
- package/lib/view-definition.d.ts +257 -0
- package/lib/view-definition.d.ts.map +1 -0
- package/lib/view-definition.js +12 -0
- package/package.json +42 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The root AST representing the AI-generated UI layout and structure.
|
|
3
|
+
* The AI owns this structure, while the user owns the corresponding DataSnapshot.
|
|
4
|
+
*/
|
|
5
|
+
export interface ViewDefinition {
|
|
6
|
+
/**
|
|
7
|
+
* Stable logical identity of the view family.
|
|
8
|
+
*/
|
|
9
|
+
viewId: string;
|
|
10
|
+
/**
|
|
11
|
+
* View revision identifier for ordering and compatibility checks.
|
|
12
|
+
*/
|
|
13
|
+
version: string;
|
|
14
|
+
/**
|
|
15
|
+
* Top-level nodes in render order.
|
|
16
|
+
*/
|
|
17
|
+
nodes: ViewNode[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Discriminated union of all supported view node types.
|
|
21
|
+
*/
|
|
22
|
+
export type ViewNode = FieldNode | GroupNode | CollectionNode | ActionNode | PresentationNode | RowNode | GridNode;
|
|
23
|
+
/**
|
|
24
|
+
* Base properties shared by all nodes in the ViewDefinition tree.
|
|
25
|
+
*/
|
|
26
|
+
export interface BaseNode {
|
|
27
|
+
/**
|
|
28
|
+
* Required per-version structural identifier.
|
|
29
|
+
*/
|
|
30
|
+
id: string;
|
|
31
|
+
/**
|
|
32
|
+
* Node discriminant.
|
|
33
|
+
*/
|
|
34
|
+
type: string;
|
|
35
|
+
/**
|
|
36
|
+
* Optional semantic identity for cross-version data matching.
|
|
37
|
+
*/
|
|
38
|
+
key?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Optional visibility hint.
|
|
41
|
+
*/
|
|
42
|
+
hidden?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Structural fingerprint used to detect node-configuration changes.
|
|
45
|
+
*/
|
|
46
|
+
hash?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Rules for safely migrating data when node hashes change.
|
|
49
|
+
*/
|
|
50
|
+
migrations?: MigrationRule[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Select option for constrained field values.
|
|
54
|
+
*/
|
|
55
|
+
export interface FieldOption {
|
|
56
|
+
/**
|
|
57
|
+
* Canonical option value.
|
|
58
|
+
*/
|
|
59
|
+
value: string;
|
|
60
|
+
/**
|
|
61
|
+
* User-facing option label.
|
|
62
|
+
*/
|
|
63
|
+
label: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Data-bearing input node.
|
|
67
|
+
*/
|
|
68
|
+
export interface FieldNode extends BaseNode {
|
|
69
|
+
type: 'field';
|
|
70
|
+
/**
|
|
71
|
+
* Primitive value domain expected for this field.
|
|
72
|
+
*/
|
|
73
|
+
dataType: 'string' | 'number' | 'boolean';
|
|
74
|
+
/**
|
|
75
|
+
* User-facing field label.
|
|
76
|
+
*/
|
|
77
|
+
label?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Placeholder hint for empty state.
|
|
80
|
+
*/
|
|
81
|
+
placeholder?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Optional helper text.
|
|
84
|
+
*/
|
|
85
|
+
description?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Disables user edits when true.
|
|
88
|
+
*/
|
|
89
|
+
readOnly?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Initial value before user interaction.
|
|
92
|
+
*/
|
|
93
|
+
defaultValue?: unknown;
|
|
94
|
+
/**
|
|
95
|
+
* Optional validation constraints.
|
|
96
|
+
*/
|
|
97
|
+
constraints?: FieldConstraints;
|
|
98
|
+
/**
|
|
99
|
+
* Optional list of allowed values.
|
|
100
|
+
*/
|
|
101
|
+
options?: FieldOption[];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Structural container that groups child nodes.
|
|
105
|
+
*/
|
|
106
|
+
export interface GroupNode extends BaseNode {
|
|
107
|
+
type: 'group';
|
|
108
|
+
/**
|
|
109
|
+
* Optional group label.
|
|
110
|
+
*/
|
|
111
|
+
label?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Suggested layout strategy for rendering children.
|
|
114
|
+
*/
|
|
115
|
+
layout?: 'vertical' | 'horizontal' | 'grid';
|
|
116
|
+
/**
|
|
117
|
+
* Optional column count when layout is grid-like.
|
|
118
|
+
*/
|
|
119
|
+
columns?: number;
|
|
120
|
+
/**
|
|
121
|
+
* Child nodes in order.
|
|
122
|
+
*/
|
|
123
|
+
children: ViewNode[];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Repeatable node pattern with a single item template.
|
|
127
|
+
*/
|
|
128
|
+
export interface CollectionNode extends BaseNode {
|
|
129
|
+
type: 'collection';
|
|
130
|
+
/**
|
|
131
|
+
* Optional collection label.
|
|
132
|
+
*/
|
|
133
|
+
label?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Template applied to each item.
|
|
136
|
+
*/
|
|
137
|
+
template: ViewNode;
|
|
138
|
+
/**
|
|
139
|
+
* Minimum item count.
|
|
140
|
+
*/
|
|
141
|
+
minItems?: number;
|
|
142
|
+
/**
|
|
143
|
+
* Maximum item count.
|
|
144
|
+
*/
|
|
145
|
+
maxItems?: number;
|
|
146
|
+
/**
|
|
147
|
+
* Optional default payloads for initial items.
|
|
148
|
+
*/
|
|
149
|
+
defaultValues?: Array<Record<string, unknown>>;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Trigger node that emits intents.
|
|
153
|
+
*/
|
|
154
|
+
export interface ActionNode extends BaseNode {
|
|
155
|
+
type: 'action';
|
|
156
|
+
/**
|
|
157
|
+
* Intent identifier emitted by this action.
|
|
158
|
+
*/
|
|
159
|
+
intentId: string;
|
|
160
|
+
/**
|
|
161
|
+
* User-facing action text.
|
|
162
|
+
*/
|
|
163
|
+
label: string;
|
|
164
|
+
/**
|
|
165
|
+
* Optional disabled state.
|
|
166
|
+
*/
|
|
167
|
+
disabled?: boolean;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Read-only content node.
|
|
171
|
+
*/
|
|
172
|
+
export interface PresentationNode extends BaseNode {
|
|
173
|
+
type: 'presentation';
|
|
174
|
+
/**
|
|
175
|
+
* Rendering mode for content.
|
|
176
|
+
*/
|
|
177
|
+
contentType: 'text' | 'markdown';
|
|
178
|
+
/**
|
|
179
|
+
* Raw content payload.
|
|
180
|
+
*/
|
|
181
|
+
content: string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Horizontal structural container.
|
|
185
|
+
*/
|
|
186
|
+
export interface RowNode extends BaseNode {
|
|
187
|
+
type: 'row';
|
|
188
|
+
/**
|
|
189
|
+
* Child nodes in order.
|
|
190
|
+
*/
|
|
191
|
+
children: ViewNode[];
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Grid structural container.
|
|
195
|
+
*/
|
|
196
|
+
export interface GridNode extends BaseNode {
|
|
197
|
+
type: 'grid';
|
|
198
|
+
/**
|
|
199
|
+
* Explicit column count for grid layout.
|
|
200
|
+
*/
|
|
201
|
+
columns?: number;
|
|
202
|
+
/**
|
|
203
|
+
* Child nodes in order.
|
|
204
|
+
*/
|
|
205
|
+
children: ViewNode[];
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Portable field validation metadata.
|
|
209
|
+
*/
|
|
210
|
+
export interface FieldConstraints {
|
|
211
|
+
/**
|
|
212
|
+
* Whether a value is required.
|
|
213
|
+
*/
|
|
214
|
+
required?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Inclusive minimum for numeric values.
|
|
217
|
+
*/
|
|
218
|
+
min?: number;
|
|
219
|
+
/**
|
|
220
|
+
* Inclusive maximum for numeric values.
|
|
221
|
+
*/
|
|
222
|
+
max?: number;
|
|
223
|
+
/**
|
|
224
|
+
* Minimum string length.
|
|
225
|
+
*/
|
|
226
|
+
minLength?: number;
|
|
227
|
+
/**
|
|
228
|
+
* Maximum string length.
|
|
229
|
+
*/
|
|
230
|
+
maxLength?: number;
|
|
231
|
+
/**
|
|
232
|
+
* Regex pattern string for value validation.
|
|
233
|
+
*/
|
|
234
|
+
pattern?: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Declares an allowed data-shape transition when a node changes structure.
|
|
238
|
+
*/
|
|
239
|
+
export interface MigrationRule {
|
|
240
|
+
/**
|
|
241
|
+
* Source node hash.
|
|
242
|
+
*/
|
|
243
|
+
fromHash: string;
|
|
244
|
+
/**
|
|
245
|
+
* Destination node hash.
|
|
246
|
+
*/
|
|
247
|
+
toHash: string;
|
|
248
|
+
/**
|
|
249
|
+
* Identifier matching a registered migration strategy.
|
|
250
|
+
*/
|
|
251
|
+
strategyId?: string;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Returns child nodes for recursive traversal.
|
|
255
|
+
*/
|
|
256
|
+
export declare function getChildNodes(node: ViewNode): ViewNode[];
|
|
257
|
+
//# sourceMappingURL=view-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-definition.d.ts","sourceRoot":"","sources":["../../../../packages/contract/src/lib/view-definition.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,GAChB,SAAS,GACT,SAAS,GACT,cAAc,GACd,UAAU,GACV,gBAAgB,GAChB,OAAO,GACP,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC1C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB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AAC;IACjC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,OAAQ,SAAQ,QAAQ;IACvC,IAAI,EAAE,KAAK,CAAC;IACZ;;OAEG;IACH,QAAQ,EAAE,QAAQ,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,QAAS,SAAQ,QAAQ;IACxC,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,EAAE,QAAQ,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAQxD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns child nodes for recursive traversal.
|
|
3
|
+
*/
|
|
4
|
+
export function getChildNodes(node) {
|
|
5
|
+
if (node.type === 'group' || node.type === 'row' || node.type === 'grid') {
|
|
6
|
+
return node.children;
|
|
7
|
+
}
|
|
8
|
+
if (node.type === 'collection') {
|
|
9
|
+
return [node.template];
|
|
10
|
+
}
|
|
11
|
+
return [];
|
|
12
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@continuum-dev/contract",
|
|
3
|
+
"version": "0.1.1-alpha.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Type definitions and constants for the Continuum continuity runtime",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/brytoncooper/cooper-continuum.git",
|
|
12
|
+
"directory": "packages/contract"
|
|
13
|
+
},
|
|
14
|
+
"author": "CooperContinuum",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"continuum",
|
|
17
|
+
"ai",
|
|
18
|
+
"ui",
|
|
19
|
+
"continuity",
|
|
20
|
+
"reconciliation",
|
|
21
|
+
"types"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"main": "./index.js",
|
|
26
|
+
"types": "./index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./index.d.ts",
|
|
30
|
+
"import": "./index.js",
|
|
31
|
+
"default": "./index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"**/*.js",
|
|
36
|
+
"**/*.d.ts",
|
|
37
|
+
"**/*.d.ts.map",
|
|
38
|
+
"README.md",
|
|
39
|
+
"CONTRACT_REFERENCE.md",
|
|
40
|
+
"LICENSE*"
|
|
41
|
+
]
|
|
42
|
+
}
|