@contractspec/lib.contracts 1.49.0 → 1.50.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/app-config/contracts.d.ts +50 -50
- package/dist/app-config/events.d.ts +27 -27
- package/dist/app-config/lifecycle-contracts.d.ts +54 -54
- package/dist/capabilities/capabilities.d.ts +27 -4
- package/dist/contract-registry/schemas.d.ts +2 -2
- package/dist/events.d.ts +73 -13
- package/dist/events.js +33 -3
- package/dist/examples/schema.d.ts +8 -8
- package/dist/experiments/spec.d.ts +7 -4
- package/dist/features/types.d.ts +25 -29
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -1
- package/dist/integrations/openbanking/contracts/accounts.d.ts +66 -66
- package/dist/integrations/openbanking/contracts/balances.d.ts +34 -34
- package/dist/integrations/openbanking/contracts/transactions.d.ts +48 -48
- package/dist/integrations/openbanking/models.d.ts +55 -55
- package/dist/integrations/operations.d.ts +102 -102
- package/dist/knowledge/operations.d.ts +66 -66
- package/dist/onboarding-base.d.ts +29 -29
- package/dist/ownership.d.ts +133 -8
- package/dist/ownership.js +25 -0
- package/dist/policy/spec.d.ts +7 -4
- package/dist/tests/spec.d.ts +17 -12
- package/dist/themes.d.ts +7 -4
- package/dist/types.d.ts +140 -14
- package/dist/versioning/index.d.ts +2 -1
- package/dist/versioning/index.js +2 -1
- package/dist/versioning/refs.d.ts +179 -0
- package/dist/versioning/refs.js +161 -0
- package/package.json +6 -5
|
@@ -3,50 +3,50 @@ import { OperationSpecRegistry } from "../operations/registry.js";
|
|
|
3
3
|
import "../operations/index.js";
|
|
4
4
|
import { EventSpecMeta } from "../events.js";
|
|
5
5
|
import "../index.js";
|
|
6
|
-
import * as
|
|
6
|
+
import * as _contractspec_lib_schema167 from "@contractspec/lib.schema";
|
|
7
7
|
import { SchemaModel } from "@contractspec/lib.schema";
|
|
8
8
|
|
|
9
9
|
//#region src/app-config/lifecycle-contracts.d.ts
|
|
10
10
|
declare const CreateTenantConfigDraftCommand: OperationSpec<SchemaModel<{
|
|
11
11
|
tenantId: {
|
|
12
|
-
type:
|
|
12
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
13
13
|
isOptional: false;
|
|
14
14
|
};
|
|
15
15
|
appId: {
|
|
16
|
-
type:
|
|
16
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
17
17
|
isOptional: false;
|
|
18
18
|
};
|
|
19
19
|
blueprintName: {
|
|
20
|
-
type:
|
|
20
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
21
21
|
isOptional: false;
|
|
22
22
|
};
|
|
23
23
|
blueprintVersion: {
|
|
24
|
-
type:
|
|
24
|
+
type: _contractspec_lib_schema167.FieldType<number, number>;
|
|
25
25
|
isOptional: false;
|
|
26
26
|
};
|
|
27
27
|
environment: {
|
|
28
|
-
type:
|
|
28
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
29
29
|
isOptional: true;
|
|
30
30
|
};
|
|
31
31
|
fromVersion: {
|
|
32
|
-
type:
|
|
32
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
33
33
|
isOptional: true;
|
|
34
34
|
};
|
|
35
35
|
createdBy: {
|
|
36
|
-
type:
|
|
36
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
37
37
|
isOptional: false;
|
|
38
38
|
};
|
|
39
39
|
}>, SchemaModel<{
|
|
40
40
|
version: {
|
|
41
|
-
type:
|
|
41
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
42
42
|
isOptional: false;
|
|
43
43
|
};
|
|
44
44
|
status: {
|
|
45
|
-
type:
|
|
45
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
46
46
|
isOptional: false;
|
|
47
47
|
};
|
|
48
48
|
createdAt: {
|
|
49
|
-
type:
|
|
49
|
+
type: _contractspec_lib_schema167.FieldType<Date, string>;
|
|
50
50
|
isOptional: false;
|
|
51
51
|
};
|
|
52
52
|
}>, {
|
|
@@ -55,32 +55,32 @@ declare const CreateTenantConfigDraftCommand: OperationSpec<SchemaModel<{
|
|
|
55
55
|
}[]>;
|
|
56
56
|
declare const PromoteTenantConfigToPreviewCommand: OperationSpec<SchemaModel<{
|
|
57
57
|
tenantId: {
|
|
58
|
-
type:
|
|
58
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
59
59
|
isOptional: false;
|
|
60
60
|
};
|
|
61
61
|
appId: {
|
|
62
|
-
type:
|
|
62
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
63
63
|
isOptional: false;
|
|
64
64
|
};
|
|
65
65
|
version: {
|
|
66
|
-
type:
|
|
66
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
67
67
|
isOptional: false;
|
|
68
68
|
};
|
|
69
69
|
promotedBy: {
|
|
70
|
-
type:
|
|
70
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
71
71
|
isOptional: false;
|
|
72
72
|
};
|
|
73
73
|
}>, SchemaModel<{
|
|
74
74
|
version: {
|
|
75
|
-
type:
|
|
75
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
76
76
|
isOptional: false;
|
|
77
77
|
};
|
|
78
78
|
status: {
|
|
79
|
-
type:
|
|
79
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
80
80
|
isOptional: false;
|
|
81
81
|
};
|
|
82
82
|
warnings: {
|
|
83
|
-
type:
|
|
83
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
84
84
|
isOptional: true;
|
|
85
85
|
isArray: true;
|
|
86
86
|
};
|
|
@@ -90,44 +90,44 @@ declare const PromoteTenantConfigToPreviewCommand: OperationSpec<SchemaModel<{
|
|
|
90
90
|
}[]>;
|
|
91
91
|
declare const PublishTenantConfigCommand: OperationSpec<SchemaModel<{
|
|
92
92
|
tenantId: {
|
|
93
|
-
type:
|
|
93
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
94
94
|
isOptional: false;
|
|
95
95
|
};
|
|
96
96
|
appId: {
|
|
97
|
-
type:
|
|
97
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
98
98
|
isOptional: false;
|
|
99
99
|
};
|
|
100
100
|
version: {
|
|
101
|
-
type:
|
|
101
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
102
102
|
isOptional: false;
|
|
103
103
|
};
|
|
104
104
|
environment: {
|
|
105
|
-
type:
|
|
105
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
106
106
|
isOptional: true;
|
|
107
107
|
};
|
|
108
108
|
publishedBy: {
|
|
109
|
-
type:
|
|
109
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
110
110
|
isOptional: false;
|
|
111
111
|
};
|
|
112
112
|
changeSummary: {
|
|
113
|
-
type:
|
|
113
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
114
114
|
isOptional: true;
|
|
115
115
|
};
|
|
116
116
|
}>, SchemaModel<{
|
|
117
117
|
version: {
|
|
118
|
-
type:
|
|
118
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
119
119
|
isOptional: false;
|
|
120
120
|
};
|
|
121
121
|
status: {
|
|
122
|
-
type:
|
|
122
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
123
123
|
isOptional: false;
|
|
124
124
|
};
|
|
125
125
|
previousVersion: {
|
|
126
|
-
type:
|
|
126
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
127
127
|
isOptional: true;
|
|
128
128
|
};
|
|
129
129
|
publishedAt: {
|
|
130
|
-
type:
|
|
130
|
+
type: _contractspec_lib_schema167.FieldType<Date, string>;
|
|
131
131
|
isOptional: false;
|
|
132
132
|
};
|
|
133
133
|
}>, {
|
|
@@ -136,40 +136,40 @@ declare const PublishTenantConfigCommand: OperationSpec<SchemaModel<{
|
|
|
136
136
|
}[]>;
|
|
137
137
|
declare const RollbackTenantConfigCommand: OperationSpec<SchemaModel<{
|
|
138
138
|
tenantId: {
|
|
139
|
-
type:
|
|
139
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
140
140
|
isOptional: false;
|
|
141
141
|
};
|
|
142
142
|
appId: {
|
|
143
|
-
type:
|
|
143
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
144
144
|
isOptional: false;
|
|
145
145
|
};
|
|
146
146
|
toVersion: {
|
|
147
|
-
type:
|
|
147
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
148
148
|
isOptional: false;
|
|
149
149
|
};
|
|
150
150
|
environment: {
|
|
151
|
-
type:
|
|
151
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
152
152
|
isOptional: true;
|
|
153
153
|
};
|
|
154
154
|
rolledBackBy: {
|
|
155
|
-
type:
|
|
155
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
156
156
|
isOptional: false;
|
|
157
157
|
};
|
|
158
158
|
reason: {
|
|
159
|
-
type:
|
|
159
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
160
160
|
isOptional: false;
|
|
161
161
|
};
|
|
162
162
|
}>, SchemaModel<{
|
|
163
163
|
newVersion: {
|
|
164
|
-
type:
|
|
164
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
165
165
|
isOptional: false;
|
|
166
166
|
};
|
|
167
167
|
status: {
|
|
168
|
-
type:
|
|
168
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
169
169
|
isOptional: false;
|
|
170
170
|
};
|
|
171
171
|
rolledBackFrom: {
|
|
172
|
-
type:
|
|
172
|
+
type: _contractspec_lib_schema167.FieldType<number, number>;
|
|
173
173
|
isOptional: false;
|
|
174
174
|
};
|
|
175
175
|
}>, {
|
|
@@ -178,22 +178,22 @@ declare const RollbackTenantConfigCommand: OperationSpec<SchemaModel<{
|
|
|
178
178
|
}[]>;
|
|
179
179
|
declare const ListTenantConfigVersionsQuery: OperationSpec<SchemaModel<{
|
|
180
180
|
tenantId: {
|
|
181
|
-
type:
|
|
181
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
182
182
|
isOptional: false;
|
|
183
183
|
};
|
|
184
184
|
appId: {
|
|
185
|
-
type:
|
|
185
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
186
186
|
isOptional: false;
|
|
187
187
|
};
|
|
188
188
|
}>, SchemaModel<{
|
|
189
189
|
versions: {
|
|
190
190
|
type: SchemaModel<{
|
|
191
191
|
meta: {
|
|
192
|
-
type:
|
|
192
|
+
type: _contractspec_lib_schema167.FieldType<Record<string, unknown>, Record<string, unknown>>;
|
|
193
193
|
isOptional: false;
|
|
194
194
|
};
|
|
195
195
|
config: {
|
|
196
|
-
type:
|
|
196
|
+
type: _contractspec_lib_schema167.FieldType<Record<string, unknown>, Record<string, unknown>>;
|
|
197
197
|
isOptional: false;
|
|
198
198
|
};
|
|
199
199
|
}>;
|
|
@@ -203,35 +203,35 @@ declare const ListTenantConfigVersionsQuery: OperationSpec<SchemaModel<{
|
|
|
203
203
|
transitions: {
|
|
204
204
|
type: SchemaModel<{
|
|
205
205
|
tenantId: {
|
|
206
|
-
type:
|
|
206
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
207
207
|
isOptional: false;
|
|
208
208
|
};
|
|
209
209
|
appId: {
|
|
210
|
-
type:
|
|
210
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
211
211
|
isOptional: false;
|
|
212
212
|
};
|
|
213
213
|
fromStatus: {
|
|
214
|
-
type:
|
|
214
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
215
215
|
isOptional: false;
|
|
216
216
|
};
|
|
217
217
|
toStatus: {
|
|
218
|
-
type:
|
|
218
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
219
219
|
isOptional: false;
|
|
220
220
|
};
|
|
221
221
|
version: {
|
|
222
|
-
type:
|
|
222
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
223
223
|
isOptional: false;
|
|
224
224
|
};
|
|
225
225
|
timestamp: {
|
|
226
|
-
type:
|
|
226
|
+
type: _contractspec_lib_schema167.FieldType<Date, string>;
|
|
227
227
|
isOptional: false;
|
|
228
228
|
};
|
|
229
229
|
actor: {
|
|
230
|
-
type:
|
|
230
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
231
231
|
isOptional: false;
|
|
232
232
|
};
|
|
233
233
|
reason: {
|
|
234
|
-
type:
|
|
234
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
235
235
|
isOptional: true;
|
|
236
236
|
};
|
|
237
237
|
}>;
|
|
@@ -241,26 +241,26 @@ declare const ListTenantConfigVersionsQuery: OperationSpec<SchemaModel<{
|
|
|
241
241
|
}>, undefined>;
|
|
242
242
|
declare const GetTenantConfigVersionQuery: OperationSpec<SchemaModel<{
|
|
243
243
|
tenantId: {
|
|
244
|
-
type:
|
|
244
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
245
245
|
isOptional: false;
|
|
246
246
|
};
|
|
247
247
|
appId: {
|
|
248
|
-
type:
|
|
248
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
249
249
|
isOptional: false;
|
|
250
250
|
};
|
|
251
251
|
version: {
|
|
252
|
-
type:
|
|
252
|
+
type: _contractspec_lib_schema167.FieldType<string, string>;
|
|
253
253
|
isOptional: false;
|
|
254
254
|
};
|
|
255
255
|
}>, SchemaModel<{
|
|
256
256
|
version: {
|
|
257
257
|
type: SchemaModel<{
|
|
258
258
|
meta: {
|
|
259
|
-
type:
|
|
259
|
+
type: _contractspec_lib_schema167.FieldType<Record<string, unknown>, Record<string, unknown>>;
|
|
260
260
|
isOptional: false;
|
|
261
261
|
};
|
|
262
262
|
config: {
|
|
263
|
-
type:
|
|
263
|
+
type: _contractspec_lib_schema167.FieldType<Record<string, unknown>, Record<string, unknown>>;
|
|
264
264
|
isOptional: false;
|
|
265
265
|
};
|
|
266
266
|
}>;
|
|
@@ -1,28 +1,51 @@
|
|
|
1
1
|
import { OwnerShipMeta } from "../ownership.js";
|
|
2
|
+
import { VersionedSpecRef } from "../versioning/refs.js";
|
|
2
3
|
|
|
3
4
|
//#region src/capabilities/capabilities.d.ts
|
|
5
|
+
/** Classification of capability types. */
|
|
4
6
|
type CapabilityKind = 'api' | 'event' | 'data' | 'ui' | 'integration';
|
|
7
|
+
/** Surfaces where capabilities can be exposed or consumed. */
|
|
5
8
|
type CapabilitySurface = 'operation' | 'event' | 'workflow' | 'presentation' | 'resource';
|
|
9
|
+
/**
|
|
10
|
+
* Reference to a capability on a specific surface.
|
|
11
|
+
* Extends VersionedSpecRef with surface and description context.
|
|
12
|
+
*/
|
|
6
13
|
interface CapabilitySurfaceRef {
|
|
14
|
+
/** The surface type where this capability is exposed. */
|
|
7
15
|
surface: CapabilitySurface;
|
|
16
|
+
/** Unique key identifying the capability. */
|
|
8
17
|
key: string;
|
|
18
|
+
/** Semantic version of the capability. */
|
|
9
19
|
version: string;
|
|
20
|
+
/** Optional description of what this capability provides. */
|
|
10
21
|
description?: string;
|
|
11
22
|
}
|
|
23
|
+
/** Metadata for a capability spec, extending ownership with kind. */
|
|
12
24
|
interface CapabilityMeta extends OwnerShipMeta {
|
|
25
|
+
/** The kind/category of this capability. */
|
|
13
26
|
kind: CapabilityKind;
|
|
14
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Requirement for a capability dependency.
|
|
30
|
+
* Used to declare what capabilities a spec needs.
|
|
31
|
+
*/
|
|
15
32
|
interface CapabilityRequirement {
|
|
33
|
+
/** Unique key of the required capability. */
|
|
16
34
|
key: string;
|
|
35
|
+
/** Optional specific version required. */
|
|
17
36
|
version?: string;
|
|
37
|
+
/** Optional kind filter for the requirement. */
|
|
18
38
|
kind?: CapabilityKind;
|
|
39
|
+
/** If true, the requirement is optional and won't block if missing. */
|
|
19
40
|
optional?: boolean;
|
|
41
|
+
/** Human-readable reason why this capability is required. */
|
|
20
42
|
reason?: string;
|
|
21
43
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Reference to a capability spec.
|
|
46
|
+
* Uses key and version to identify a specific capability.
|
|
47
|
+
*/
|
|
48
|
+
type CapabilityRef = VersionedSpecRef;
|
|
26
49
|
interface CapabilitySpec {
|
|
27
50
|
meta: CapabilityMeta;
|
|
28
51
|
provides?: CapabilitySurfaceRef[];
|
|
@@ -46,12 +46,12 @@ declare const ContractRegistryItemSchema: z.ZodObject<{
|
|
|
46
46
|
description: z.ZodString;
|
|
47
47
|
meta: z.ZodObject<{
|
|
48
48
|
stability: z.ZodEnum<{
|
|
49
|
+
deprecated: "deprecated";
|
|
49
50
|
idea: "idea";
|
|
50
51
|
in_creation: "in_creation";
|
|
51
52
|
experimental: "experimental";
|
|
52
53
|
beta: "beta";
|
|
53
54
|
stable: "stable";
|
|
54
|
-
deprecated: "deprecated";
|
|
55
55
|
}>;
|
|
56
56
|
owners: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
57
57
|
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
@@ -95,12 +95,12 @@ declare const ContractRegistryManifestSchema: z.ZodObject<{
|
|
|
95
95
|
description: z.ZodString;
|
|
96
96
|
meta: z.ZodObject<{
|
|
97
97
|
stability: z.ZodEnum<{
|
|
98
|
+
deprecated: "deprecated";
|
|
98
99
|
idea: "idea";
|
|
99
100
|
in_creation: "in_creation";
|
|
100
101
|
experimental: "experimental";
|
|
101
102
|
beta: "beta";
|
|
102
103
|
stable: "stable";
|
|
103
|
-
deprecated: "deprecated";
|
|
104
104
|
}>;
|
|
105
105
|
owners: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
106
106
|
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
package/dist/events.d.ts
CHANGED
|
@@ -4,42 +4,102 @@ import { SpecContractRegistry } from "./registry.js";
|
|
|
4
4
|
import { AnySchemaModel } from "@contractspec/lib.schema";
|
|
5
5
|
|
|
6
6
|
//#region src/events.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Metadata for an event specification.
|
|
10
|
+
* Extends OwnerShipMeta with event-specific documentation.
|
|
11
|
+
*/
|
|
7
12
|
interface EventSpecMeta extends Omit<OwnerShipMeta, 'docId'> {
|
|
8
|
-
/**
|
|
13
|
+
/** Associated DocBlock identifiers for this event. */
|
|
9
14
|
docId?: DocId[];
|
|
10
15
|
}
|
|
11
16
|
/**
|
|
12
|
-
* Typed event specification.
|
|
13
|
-
*
|
|
17
|
+
* Typed event specification.
|
|
18
|
+
*
|
|
19
|
+
* Declare once, validate payloads at publish time, and guard emissions
|
|
20
|
+
* via the contracts runtime. Events are the backbone of event-driven
|
|
21
|
+
* architectures in ContractSpec.
|
|
22
|
+
*
|
|
23
|
+
* @typeParam T - The SchemaModel type defining the event payload structure
|
|
14
24
|
*/
|
|
15
25
|
interface EventSpec<T extends AnySchemaModel> {
|
|
26
|
+
/** Event metadata including key, version, and ownership. */
|
|
16
27
|
meta: EventSpecMeta;
|
|
17
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* JSON paths to PII fields that should be redacted in logs/exports.
|
|
30
|
+
* @example ['email', 'user.phone', 'billing.address']
|
|
31
|
+
*/
|
|
18
32
|
pii?: string[];
|
|
19
33
|
/** Event payload schema from @contractspec/lib.schema. */
|
|
20
34
|
payload: T;
|
|
21
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Type alias for any EventSpec regardless of payload type.
|
|
38
|
+
* Useful for collections and registries.
|
|
39
|
+
*/
|
|
22
40
|
type AnyEventSpec<T extends AnySchemaModel = AnySchemaModel> = EventSpec<T>;
|
|
23
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Identity function to define an event spec with full type inference.
|
|
43
|
+
*
|
|
44
|
+
* @param e - The event specification
|
|
45
|
+
* @returns The same event specification with preserved types
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const MyEvent = defineEvent({
|
|
50
|
+
* meta: { key: 'my.event', version: '1.0.0', ... },
|
|
51
|
+
* payload: myPayloadSchema,
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
24
55
|
declare function defineEvent<T extends AnySchemaModel>(e: EventSpec<T>): EventSpec<T>;
|
|
56
|
+
/**
|
|
57
|
+
* Wrapper for a published event with metadata.
|
|
58
|
+
*
|
|
59
|
+
* Used when events are serialized for transport or storage.
|
|
60
|
+
* Contains the validated payload plus envelope metadata.
|
|
61
|
+
*
|
|
62
|
+
* @typeParam T - The payload type
|
|
63
|
+
*/
|
|
25
64
|
interface EventEnvelope<T> {
|
|
26
|
-
/** Unique identifier for
|
|
65
|
+
/** Unique identifier for this event instance (UUID recommended). */
|
|
27
66
|
id: string;
|
|
28
|
-
/** ISO timestamp when the event occurred. */
|
|
67
|
+
/** ISO 8601 timestamp when the event occurred. */
|
|
29
68
|
occurredAt: string;
|
|
30
|
-
/**
|
|
69
|
+
/** Trace identifier for correlating across services. */
|
|
31
70
|
traceId?: string;
|
|
32
|
-
/** Event
|
|
71
|
+
/** Event key (should match spec.meta.key). */
|
|
33
72
|
key: string;
|
|
34
|
-
/** Event version
|
|
73
|
+
/** Event version (should match spec.meta.version). */
|
|
35
74
|
version: string;
|
|
36
|
-
/** Validated payload. */
|
|
75
|
+
/** Validated event payload. */
|
|
37
76
|
payload: T;
|
|
38
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Template literal type for event keys.
|
|
80
|
+
* Format: "key.vversion" (e.g., "user.created.v1.0.0")
|
|
81
|
+
*/
|
|
39
82
|
type EventKey = `${string}.v${string}`;
|
|
40
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Builds a stable string key for an event name/version pair.
|
|
85
|
+
*
|
|
86
|
+
* @param key - The event key (e.g., "user.created")
|
|
87
|
+
* @param version - The event version (e.g., "1.0.0")
|
|
88
|
+
* @returns A string in format "key.vversion"
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const key = eventKey('user.created', '1.0.0');
|
|
93
|
+
* // "user.created.v1.0.0"
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
41
96
|
declare const eventKey: (key: string, version: string) => EventKey;
|
|
42
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* In-memory registry for EventSpec instances.
|
|
99
|
+
*
|
|
100
|
+
* Provides registration, lookup, and listing of event specifications.
|
|
101
|
+
* Used by the contracts runtime to validate event emissions.
|
|
102
|
+
*/
|
|
43
103
|
declare class EventRegistry extends SpecContractRegistry<'event', AnyEventSpec> {
|
|
44
104
|
constructor(items?: AnyEventSpec[]);
|
|
45
105
|
}
|
package/dist/events.js
CHANGED
|
@@ -2,13 +2,43 @@ import { SpecContractRegistry } from "./registry.js";
|
|
|
2
2
|
import "@contractspec/lib.schema";
|
|
3
3
|
|
|
4
4
|
//#region src/events.ts
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Identity function to define an event spec with full type inference.
|
|
7
|
+
*
|
|
8
|
+
* @param e - The event specification
|
|
9
|
+
* @returns The same event specification with preserved types
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const MyEvent = defineEvent({
|
|
14
|
+
* meta: { key: 'my.event', version: '1.0.0', ... },
|
|
15
|
+
* payload: myPayloadSchema,
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
6
19
|
function defineEvent(e) {
|
|
7
20
|
return e;
|
|
8
21
|
}
|
|
9
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Builds a stable string key for an event name/version pair.
|
|
24
|
+
*
|
|
25
|
+
* @param key - The event key (e.g., "user.created")
|
|
26
|
+
* @param version - The event version (e.g., "1.0.0")
|
|
27
|
+
* @returns A string in format "key.vversion"
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const key = eventKey('user.created', '1.0.0');
|
|
32
|
+
* // "user.created.v1.0.0"
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
10
35
|
const eventKey = (key, version) => `${key}.v${version}`;
|
|
11
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* In-memory registry for EventSpec instances.
|
|
38
|
+
*
|
|
39
|
+
* Provides registration, lookup, and listing of event specifications.
|
|
40
|
+
* Used by the contracts runtime to validate event emissions.
|
|
41
|
+
*/
|
|
12
42
|
var EventRegistry = class extends SpecContractRegistry {
|
|
13
43
|
constructor(items) {
|
|
14
44
|
super("event", items);
|
|
@@ -3,10 +3,10 @@ import { z as z$1 } from "zod";
|
|
|
3
3
|
|
|
4
4
|
//#region src/examples/schema.d.ts
|
|
5
5
|
declare const ExampleKindSchema: z$1.ZodEnum<{
|
|
6
|
+
knowledge: "knowledge";
|
|
6
7
|
library: "library";
|
|
7
8
|
workflow: "workflow";
|
|
8
9
|
integration: "integration";
|
|
9
|
-
knowledge: "knowledge";
|
|
10
10
|
template: "template";
|
|
11
11
|
blueprint: "blueprint";
|
|
12
12
|
ui: "ui";
|
|
@@ -25,12 +25,12 @@ declare const ExampleSandboxModeSchema: z$1.ZodEnum<{
|
|
|
25
25
|
evolution: "evolution";
|
|
26
26
|
}>;
|
|
27
27
|
declare const StabilitySchema: z$1.ZodEnum<{
|
|
28
|
+
deprecated: "deprecated";
|
|
28
29
|
idea: "idea";
|
|
29
30
|
in_creation: "in_creation";
|
|
30
31
|
experimental: "experimental";
|
|
31
32
|
beta: "beta";
|
|
32
33
|
stable: "stable";
|
|
33
|
-
deprecated: "deprecated";
|
|
34
34
|
}>;
|
|
35
35
|
declare const ExampleDocumentationSchema: z$1.ZodObject<{
|
|
36
36
|
rootDocId: z$1.ZodOptional<z$1.ZodString>;
|
|
@@ -93,21 +93,21 @@ declare const ExampleMetaSchema: z$1.ZodObject<{
|
|
|
93
93
|
description: z$1.ZodString;
|
|
94
94
|
domain: z$1.ZodOptional<z$1.ZodString>;
|
|
95
95
|
stability: z$1.ZodEnum<{
|
|
96
|
+
deprecated: "deprecated";
|
|
96
97
|
idea: "idea";
|
|
97
98
|
in_creation: "in_creation";
|
|
98
99
|
experimental: "experimental";
|
|
99
100
|
beta: "beta";
|
|
100
101
|
stable: "stable";
|
|
101
|
-
deprecated: "deprecated";
|
|
102
102
|
}>;
|
|
103
103
|
owners: z$1.ZodArray<z$1.ZodString>;
|
|
104
104
|
tags: z$1.ZodArray<z$1.ZodString>;
|
|
105
105
|
docId: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
106
106
|
kind: z$1.ZodEnum<{
|
|
107
|
+
knowledge: "knowledge";
|
|
107
108
|
library: "library";
|
|
108
109
|
workflow: "workflow";
|
|
109
110
|
integration: "integration";
|
|
110
|
-
knowledge: "knowledge";
|
|
111
111
|
template: "template";
|
|
112
112
|
blueprint: "blueprint";
|
|
113
113
|
ui: "ui";
|
|
@@ -141,21 +141,21 @@ declare const ExampleSpecSchema: z$1.ZodObject<{
|
|
|
141
141
|
description: z$1.ZodString;
|
|
142
142
|
domain: z$1.ZodOptional<z$1.ZodString>;
|
|
143
143
|
stability: z$1.ZodEnum<{
|
|
144
|
+
deprecated: "deprecated";
|
|
144
145
|
idea: "idea";
|
|
145
146
|
in_creation: "in_creation";
|
|
146
147
|
experimental: "experimental";
|
|
147
148
|
beta: "beta";
|
|
148
149
|
stable: "stable";
|
|
149
|
-
deprecated: "deprecated";
|
|
150
150
|
}>;
|
|
151
151
|
owners: z$1.ZodArray<z$1.ZodString>;
|
|
152
152
|
tags: z$1.ZodArray<z$1.ZodString>;
|
|
153
153
|
docId: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
154
154
|
kind: z$1.ZodEnum<{
|
|
155
|
+
knowledge: "knowledge";
|
|
155
156
|
library: "library";
|
|
156
157
|
workflow: "workflow";
|
|
157
158
|
integration: "integration";
|
|
158
|
-
knowledge: "knowledge";
|
|
159
159
|
template: "template";
|
|
160
160
|
blueprint: "blueprint";
|
|
161
161
|
ui: "ui";
|
|
@@ -221,10 +221,10 @@ declare function safeParseExampleSpec(data: unknown): z$1.ZodSafeParseResult<{
|
|
|
221
221
|
version: string;
|
|
222
222
|
key: string;
|
|
223
223
|
description: string;
|
|
224
|
-
stability: "idea" | "in_creation" | "experimental" | "beta" | "stable"
|
|
224
|
+
stability: "deprecated" | "idea" | "in_creation" | "experimental" | "beta" | "stable";
|
|
225
225
|
owners: string[];
|
|
226
226
|
tags: string[];
|
|
227
|
-
kind: "
|
|
227
|
+
kind: "knowledge" | "library" | "workflow" | "integration" | "template" | "blueprint" | "ui" | "script";
|
|
228
228
|
visibility: "experimental" | "public" | "internal";
|
|
229
229
|
title?: string | undefined;
|
|
230
230
|
domain?: string | undefined;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { OwnerShipMeta } from "../ownership.js";
|
|
2
|
+
import { OptionalVersionedSpecRef } from "../versioning/refs.js";
|
|
2
3
|
import { PolicyRef } from "../policy/spec.js";
|
|
3
4
|
import { TelemetryEventDef } from "../telemetry/spec.js";
|
|
4
5
|
import { SpecContractRegistry } from "../registry.js";
|
|
5
6
|
|
|
6
7
|
//#region src/experiments/spec.d.ts
|
|
8
|
+
/** Metadata for an experiment spec. */
|
|
7
9
|
type ExperimentMeta = OwnerShipMeta;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Reference to an experiment spec.
|
|
12
|
+
* Version is optional; when omitted, refers to the latest version.
|
|
13
|
+
*/
|
|
14
|
+
type ExperimentRef = OptionalVersionedSpecRef;
|
|
12
15
|
type ExperimentOverrideType = 'dataView' | 'workflow' | 'theme' | 'policy' | 'presentation';
|
|
13
16
|
interface ExperimentOverride {
|
|
14
17
|
type: ExperimentOverrideType;
|