@contractspec/lib.contracts 1.48.1 → 1.49.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/contract-registry/schemas.d.ts +2 -2
- package/dist/data-views/data-views.d.ts +2 -1
- package/dist/data-views/index.d.ts +2 -1
- package/dist/data-views/spec.d.ts +2 -8
- package/dist/examples/schema.d.ts +8 -8
- package/dist/features/index.d.ts +2 -2
- package/dist/index.d.ts +7 -4
- 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/serialization/index.d.ts +3 -0
- package/dist/serialization/index.js +3 -0
- package/dist/serialization/serializers.d.ts +40 -0
- package/dist/serialization/serializers.js +148 -0
- package/dist/serialization/types.d.ts +103 -0
- package/dist/serialization/types.js +0 -0
- package/dist/workflow/index.d.ts +2 -1
- package/dist/workflow/spec.d.ts +2 -9
- package/package.json +8 -5
|
@@ -2,47 +2,47 @@ import { AnyOperationSpec, OperationSpec } from "../operations/operation.js";
|
|
|
2
2
|
import { OperationSpecRegistry } from "../operations/registry.js";
|
|
3
3
|
import "../operations/index.js";
|
|
4
4
|
import "../index.js";
|
|
5
|
-
import * as
|
|
5
|
+
import * as _contractspec_lib_schema154 from "@contractspec/lib.schema";
|
|
6
6
|
import { SchemaModel } from "@contractspec/lib.schema";
|
|
7
7
|
|
|
8
8
|
//#region src/knowledge/operations.d.ts
|
|
9
9
|
declare const CreateKnowledgeSource: OperationSpec<SchemaModel<{
|
|
10
10
|
tenantId: {
|
|
11
|
-
type:
|
|
11
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
12
12
|
isOptional: false;
|
|
13
13
|
};
|
|
14
14
|
spaceKey: {
|
|
15
|
-
type:
|
|
15
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
16
16
|
isOptional: false;
|
|
17
17
|
};
|
|
18
18
|
spaceVersion: {
|
|
19
|
-
type:
|
|
19
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
20
20
|
isOptional: false;
|
|
21
21
|
};
|
|
22
22
|
label: {
|
|
23
|
-
type:
|
|
23
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
24
24
|
isOptional: false;
|
|
25
25
|
};
|
|
26
26
|
sourceType: {
|
|
27
|
-
type:
|
|
27
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
28
28
|
isOptional: false;
|
|
29
29
|
};
|
|
30
30
|
config: {
|
|
31
|
-
type:
|
|
31
|
+
type: _contractspec_lib_schema154.FieldType<Record<string, unknown>, Record<string, unknown>>;
|
|
32
32
|
isOptional: false;
|
|
33
33
|
};
|
|
34
34
|
syncSchedule: {
|
|
35
35
|
type: SchemaModel<{
|
|
36
36
|
enabled: {
|
|
37
|
-
type:
|
|
37
|
+
type: _contractspec_lib_schema154.FieldType<boolean, boolean>;
|
|
38
38
|
isOptional: false;
|
|
39
39
|
};
|
|
40
40
|
cron: {
|
|
41
|
-
type:
|
|
41
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
42
42
|
isOptional: true;
|
|
43
43
|
};
|
|
44
44
|
intervalMs: {
|
|
45
|
-
type:
|
|
45
|
+
type: _contractspec_lib_schema154.FieldType<number, number>;
|
|
46
46
|
isOptional: true;
|
|
47
47
|
};
|
|
48
48
|
}>;
|
|
@@ -50,92 +50,92 @@ declare const CreateKnowledgeSource: OperationSpec<SchemaModel<{
|
|
|
50
50
|
};
|
|
51
51
|
}>, SchemaModel<{
|
|
52
52
|
id: {
|
|
53
|
-
type:
|
|
53
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
54
54
|
isOptional: false;
|
|
55
55
|
};
|
|
56
56
|
tenantId: {
|
|
57
|
-
type:
|
|
57
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
58
58
|
isOptional: false;
|
|
59
59
|
};
|
|
60
60
|
spaceKey: {
|
|
61
|
-
type:
|
|
61
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
62
62
|
isOptional: false;
|
|
63
63
|
};
|
|
64
64
|
spaceVersion: {
|
|
65
|
-
type:
|
|
65
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
66
66
|
isOptional: false;
|
|
67
67
|
};
|
|
68
68
|
label: {
|
|
69
|
-
type:
|
|
69
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
70
70
|
isOptional: false;
|
|
71
71
|
};
|
|
72
72
|
sourceType: {
|
|
73
|
-
type:
|
|
73
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
74
74
|
isOptional: false;
|
|
75
75
|
};
|
|
76
76
|
syncSchedule: {
|
|
77
77
|
type: SchemaModel<{
|
|
78
78
|
enabled: {
|
|
79
|
-
type:
|
|
79
|
+
type: _contractspec_lib_schema154.FieldType<boolean, boolean>;
|
|
80
80
|
isOptional: false;
|
|
81
81
|
};
|
|
82
82
|
cron: {
|
|
83
|
-
type:
|
|
83
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
84
84
|
isOptional: true;
|
|
85
85
|
};
|
|
86
86
|
intervalMs: {
|
|
87
|
-
type:
|
|
87
|
+
type: _contractspec_lib_schema154.FieldType<number, number>;
|
|
88
88
|
isOptional: true;
|
|
89
89
|
};
|
|
90
90
|
}>;
|
|
91
91
|
isOptional: true;
|
|
92
92
|
};
|
|
93
93
|
lastSyncStatus: {
|
|
94
|
-
type:
|
|
94
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
95
95
|
isOptional: true;
|
|
96
96
|
};
|
|
97
97
|
lastSyncAt: {
|
|
98
|
-
type:
|
|
98
|
+
type: _contractspec_lib_schema154.FieldType<Date, string>;
|
|
99
99
|
isOptional: true;
|
|
100
100
|
};
|
|
101
101
|
itemsProcessed: {
|
|
102
|
-
type:
|
|
102
|
+
type: _contractspec_lib_schema154.FieldType<number, number>;
|
|
103
103
|
isOptional: true;
|
|
104
104
|
};
|
|
105
105
|
createdAt: {
|
|
106
|
-
type:
|
|
106
|
+
type: _contractspec_lib_schema154.FieldType<Date, string>;
|
|
107
107
|
isOptional: true;
|
|
108
108
|
};
|
|
109
109
|
updatedAt: {
|
|
110
|
-
type:
|
|
110
|
+
type: _contractspec_lib_schema154.FieldType<Date, string>;
|
|
111
111
|
isOptional: true;
|
|
112
112
|
};
|
|
113
113
|
}>, undefined>;
|
|
114
114
|
declare const UpdateKnowledgeSource: OperationSpec<SchemaModel<{
|
|
115
115
|
sourceId: {
|
|
116
|
-
type:
|
|
116
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
117
117
|
isOptional: false;
|
|
118
118
|
};
|
|
119
119
|
label: {
|
|
120
|
-
type:
|
|
120
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
121
121
|
isOptional: true;
|
|
122
122
|
};
|
|
123
123
|
config: {
|
|
124
|
-
type:
|
|
124
|
+
type: _contractspec_lib_schema154.FieldType<Record<string, unknown>, Record<string, unknown>>;
|
|
125
125
|
isOptional: true;
|
|
126
126
|
};
|
|
127
127
|
syncSchedule: {
|
|
128
128
|
type: SchemaModel<{
|
|
129
129
|
enabled: {
|
|
130
|
-
type:
|
|
130
|
+
type: _contractspec_lib_schema154.FieldType<boolean, boolean>;
|
|
131
131
|
isOptional: false;
|
|
132
132
|
};
|
|
133
133
|
cron: {
|
|
134
|
-
type:
|
|
134
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
135
135
|
isOptional: true;
|
|
136
136
|
};
|
|
137
137
|
intervalMs: {
|
|
138
|
-
type:
|
|
138
|
+
type: _contractspec_lib_schema154.FieldType<number, number>;
|
|
139
139
|
isOptional: true;
|
|
140
140
|
};
|
|
141
141
|
}>;
|
|
@@ -143,149 +143,149 @@ declare const UpdateKnowledgeSource: OperationSpec<SchemaModel<{
|
|
|
143
143
|
};
|
|
144
144
|
}>, SchemaModel<{
|
|
145
145
|
id: {
|
|
146
|
-
type:
|
|
146
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
147
147
|
isOptional: false;
|
|
148
148
|
};
|
|
149
149
|
tenantId: {
|
|
150
|
-
type:
|
|
150
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
151
151
|
isOptional: false;
|
|
152
152
|
};
|
|
153
153
|
spaceKey: {
|
|
154
|
-
type:
|
|
154
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
155
155
|
isOptional: false;
|
|
156
156
|
};
|
|
157
157
|
spaceVersion: {
|
|
158
|
-
type:
|
|
158
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
159
159
|
isOptional: false;
|
|
160
160
|
};
|
|
161
161
|
label: {
|
|
162
|
-
type:
|
|
162
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
163
163
|
isOptional: false;
|
|
164
164
|
};
|
|
165
165
|
sourceType: {
|
|
166
|
-
type:
|
|
166
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
167
167
|
isOptional: false;
|
|
168
168
|
};
|
|
169
169
|
syncSchedule: {
|
|
170
170
|
type: SchemaModel<{
|
|
171
171
|
enabled: {
|
|
172
|
-
type:
|
|
172
|
+
type: _contractspec_lib_schema154.FieldType<boolean, boolean>;
|
|
173
173
|
isOptional: false;
|
|
174
174
|
};
|
|
175
175
|
cron: {
|
|
176
|
-
type:
|
|
176
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
177
177
|
isOptional: true;
|
|
178
178
|
};
|
|
179
179
|
intervalMs: {
|
|
180
|
-
type:
|
|
180
|
+
type: _contractspec_lib_schema154.FieldType<number, number>;
|
|
181
181
|
isOptional: true;
|
|
182
182
|
};
|
|
183
183
|
}>;
|
|
184
184
|
isOptional: true;
|
|
185
185
|
};
|
|
186
186
|
lastSyncStatus: {
|
|
187
|
-
type:
|
|
187
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
188
188
|
isOptional: true;
|
|
189
189
|
};
|
|
190
190
|
lastSyncAt: {
|
|
191
|
-
type:
|
|
191
|
+
type: _contractspec_lib_schema154.FieldType<Date, string>;
|
|
192
192
|
isOptional: true;
|
|
193
193
|
};
|
|
194
194
|
itemsProcessed: {
|
|
195
|
-
type:
|
|
195
|
+
type: _contractspec_lib_schema154.FieldType<number, number>;
|
|
196
196
|
isOptional: true;
|
|
197
197
|
};
|
|
198
198
|
createdAt: {
|
|
199
|
-
type:
|
|
199
|
+
type: _contractspec_lib_schema154.FieldType<Date, string>;
|
|
200
200
|
isOptional: true;
|
|
201
201
|
};
|
|
202
202
|
updatedAt: {
|
|
203
|
-
type:
|
|
203
|
+
type: _contractspec_lib_schema154.FieldType<Date, string>;
|
|
204
204
|
isOptional: true;
|
|
205
205
|
};
|
|
206
206
|
}>, undefined>;
|
|
207
207
|
declare const DeleteKnowledgeSource: OperationSpec<SchemaModel<{
|
|
208
208
|
sourceId: {
|
|
209
|
-
type:
|
|
209
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
210
210
|
isOptional: false;
|
|
211
211
|
};
|
|
212
212
|
}>, SchemaModel<{
|
|
213
213
|
success: {
|
|
214
|
-
type:
|
|
214
|
+
type: _contractspec_lib_schema154.FieldType<boolean, boolean>;
|
|
215
215
|
isOptional: false;
|
|
216
216
|
};
|
|
217
217
|
}>, undefined>;
|
|
218
218
|
declare const ListKnowledgeSources: OperationSpec<SchemaModel<{
|
|
219
219
|
tenantId: {
|
|
220
|
-
type:
|
|
220
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
221
221
|
isOptional: false;
|
|
222
222
|
};
|
|
223
223
|
spaceKey: {
|
|
224
|
-
type:
|
|
224
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
225
225
|
isOptional: true;
|
|
226
226
|
};
|
|
227
227
|
}>, SchemaModel<{
|
|
228
228
|
sources: {
|
|
229
229
|
type: SchemaModel<{
|
|
230
230
|
id: {
|
|
231
|
-
type:
|
|
231
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
232
232
|
isOptional: false;
|
|
233
233
|
};
|
|
234
234
|
tenantId: {
|
|
235
|
-
type:
|
|
235
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
236
236
|
isOptional: false;
|
|
237
237
|
};
|
|
238
238
|
spaceKey: {
|
|
239
|
-
type:
|
|
239
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
240
240
|
isOptional: false;
|
|
241
241
|
};
|
|
242
242
|
spaceVersion: {
|
|
243
|
-
type:
|
|
243
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
244
244
|
isOptional: false;
|
|
245
245
|
};
|
|
246
246
|
label: {
|
|
247
|
-
type:
|
|
247
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
248
248
|
isOptional: false;
|
|
249
249
|
};
|
|
250
250
|
sourceType: {
|
|
251
|
-
type:
|
|
251
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
252
252
|
isOptional: false;
|
|
253
253
|
};
|
|
254
254
|
syncSchedule: {
|
|
255
255
|
type: SchemaModel<{
|
|
256
256
|
enabled: {
|
|
257
|
-
type:
|
|
257
|
+
type: _contractspec_lib_schema154.FieldType<boolean, boolean>;
|
|
258
258
|
isOptional: false;
|
|
259
259
|
};
|
|
260
260
|
cron: {
|
|
261
|
-
type:
|
|
261
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
262
262
|
isOptional: true;
|
|
263
263
|
};
|
|
264
264
|
intervalMs: {
|
|
265
|
-
type:
|
|
265
|
+
type: _contractspec_lib_schema154.FieldType<number, number>;
|
|
266
266
|
isOptional: true;
|
|
267
267
|
};
|
|
268
268
|
}>;
|
|
269
269
|
isOptional: true;
|
|
270
270
|
};
|
|
271
271
|
lastSyncStatus: {
|
|
272
|
-
type:
|
|
272
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
273
273
|
isOptional: true;
|
|
274
274
|
};
|
|
275
275
|
lastSyncAt: {
|
|
276
|
-
type:
|
|
276
|
+
type: _contractspec_lib_schema154.FieldType<Date, string>;
|
|
277
277
|
isOptional: true;
|
|
278
278
|
};
|
|
279
279
|
itemsProcessed: {
|
|
280
|
-
type:
|
|
280
|
+
type: _contractspec_lib_schema154.FieldType<number, number>;
|
|
281
281
|
isOptional: true;
|
|
282
282
|
};
|
|
283
283
|
createdAt: {
|
|
284
|
-
type:
|
|
284
|
+
type: _contractspec_lib_schema154.FieldType<Date, string>;
|
|
285
285
|
isOptional: true;
|
|
286
286
|
};
|
|
287
287
|
updatedAt: {
|
|
288
|
-
type:
|
|
288
|
+
type: _contractspec_lib_schema154.FieldType<Date, string>;
|
|
289
289
|
isOptional: true;
|
|
290
290
|
};
|
|
291
291
|
}>;
|
|
@@ -295,20 +295,20 @@ declare const ListKnowledgeSources: OperationSpec<SchemaModel<{
|
|
|
295
295
|
}>, undefined>;
|
|
296
296
|
declare const TriggerKnowledgeSourceSync: OperationSpec<SchemaModel<{
|
|
297
297
|
sourceId: {
|
|
298
|
-
type:
|
|
298
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
299
299
|
isOptional: false;
|
|
300
300
|
};
|
|
301
301
|
}>, SchemaModel<{
|
|
302
302
|
success: {
|
|
303
|
-
type:
|
|
303
|
+
type: _contractspec_lib_schema154.FieldType<boolean, boolean>;
|
|
304
304
|
isOptional: false;
|
|
305
305
|
};
|
|
306
306
|
itemsProcessed: {
|
|
307
|
-
type:
|
|
307
|
+
type: _contractspec_lib_schema154.FieldType<number, number>;
|
|
308
308
|
isOptional: true;
|
|
309
309
|
};
|
|
310
310
|
error: {
|
|
311
|
-
type:
|
|
311
|
+
type: _contractspec_lib_schema154.FieldType<string, string>;
|
|
312
312
|
isOptional: true;
|
|
313
313
|
};
|
|
314
314
|
}>, undefined>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SerializedDataViewSpec, SerializedEventSpec, SerializedFieldConfig, SerializedFormSpec, SerializedOperationSpec, SerializedPresentationSpec, SerializedSchemaModel } from "./types.js";
|
|
2
|
+
import { serializeDataViewSpec, serializeEventSpec, serializeFormSpec, serializeOperationSpec, serializePresentationSpec, serializeSchemaModel } from "./serializers.js";
|
|
3
|
+
export { SerializedDataViewSpec, SerializedEventSpec, SerializedFieldConfig, SerializedFormSpec, SerializedOperationSpec, SerializedPresentationSpec, SerializedSchemaModel, serializeDataViewSpec, serializeEventSpec, serializeFormSpec, serializeOperationSpec, serializePresentationSpec, serializeSchemaModel };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { serializeDataViewSpec, serializeEventSpec, serializeFormSpec, serializeOperationSpec, serializePresentationSpec, serializeSchemaModel } from "./serializers.js";
|
|
2
|
+
|
|
3
|
+
export { serializeDataViewSpec, serializeEventSpec, serializeFormSpec, serializeOperationSpec, serializePresentationSpec, serializeSchemaModel };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PresentationSpec } from "../presentations/presentations.js";
|
|
2
|
+
import { ResourceRefDescriptor } from "../resources.js";
|
|
3
|
+
import { AnyOperationSpec } from "../operations/operation.js";
|
|
4
|
+
import "../operations/index.js";
|
|
5
|
+
import "../presentations/index.js";
|
|
6
|
+
import { DataViewSpec } from "../data-views/spec.js";
|
|
7
|
+
import "../data-views/index.js";
|
|
8
|
+
import { AnyEventSpec } from "../events.js";
|
|
9
|
+
import { FormSpec } from "../forms/forms.js";
|
|
10
|
+
import "../forms/index.js";
|
|
11
|
+
import { SerializedDataViewSpec, SerializedEventSpec, SerializedFormSpec, SerializedOperationSpec, SerializedPresentationSpec, SerializedSchemaModel } from "./types.js";
|
|
12
|
+
import { AnySchemaModel } from "@contractspec/lib.schema";
|
|
13
|
+
|
|
14
|
+
//#region src/serialization/serializers.d.ts
|
|
15
|
+
/**
|
|
16
|
+
* Serialize a SchemaModel to a plain JSON object.
|
|
17
|
+
*/
|
|
18
|
+
declare function serializeSchemaModel(model: AnySchemaModel | ResourceRefDescriptor<boolean> | null | undefined): SerializedSchemaModel | null;
|
|
19
|
+
/**
|
|
20
|
+
* Serialize an OperationSpec to a plain JSON object.
|
|
21
|
+
*/
|
|
22
|
+
declare function serializeOperationSpec(spec: AnyOperationSpec | null | undefined): SerializedOperationSpec | null;
|
|
23
|
+
/**
|
|
24
|
+
* Serialize an EventSpec to a plain JSON object.
|
|
25
|
+
*/
|
|
26
|
+
declare function serializeEventSpec(spec: AnyEventSpec | null | undefined): SerializedEventSpec | null;
|
|
27
|
+
/**
|
|
28
|
+
* Serialize a PresentationSpec to a plain JSON object.
|
|
29
|
+
*/
|
|
30
|
+
declare function serializePresentationSpec(spec: PresentationSpec | null | undefined): SerializedPresentationSpec | null;
|
|
31
|
+
/**
|
|
32
|
+
* Serialize a DataViewSpec to a plain JSON object.
|
|
33
|
+
*/
|
|
34
|
+
declare function serializeDataViewSpec(spec: DataViewSpec | null | undefined): SerializedDataViewSpec | null;
|
|
35
|
+
/**
|
|
36
|
+
* Serialize a FormSpec to a plain JSON object.
|
|
37
|
+
*/
|
|
38
|
+
declare function serializeFormSpec(spec: FormSpec | null | undefined): SerializedFormSpec | null;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { serializeDataViewSpec, serializeEventSpec, serializeFormSpec, serializeOperationSpec, serializePresentationSpec, serializeSchemaModel };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
//#region src/serialization/serializers.ts
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a value is a ResourceRefDescriptor.
|
|
4
|
+
*/
|
|
5
|
+
function isResourceRefDescriptor(value) {
|
|
6
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === "resource_ref";
|
|
7
|
+
}
|
|
8
|
+
function getTypeName(type) {
|
|
9
|
+
if (!type) return "unknown";
|
|
10
|
+
if (typeof type === "string") return type;
|
|
11
|
+
if (typeof type === "object") {
|
|
12
|
+
if ("config" in type && type.config?.name) return type.config.name;
|
|
13
|
+
if ("name" in type && typeof type.name === "string") return type.name;
|
|
14
|
+
}
|
|
15
|
+
return "unknown";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Serialize a SchemaModel to a plain JSON object.
|
|
19
|
+
*/
|
|
20
|
+
function serializeSchemaModel(model) {
|
|
21
|
+
if (!model) return null;
|
|
22
|
+
if (isResourceRefDescriptor(model)) return {
|
|
23
|
+
name: `ResourceRef<${model.graphQLType}>`,
|
|
24
|
+
description: `Reference to ${model.graphQLType} resource (${model.uriTemplate})`,
|
|
25
|
+
fields: {}
|
|
26
|
+
};
|
|
27
|
+
if ("config" in model && model.config) {
|
|
28
|
+
const config = model.config;
|
|
29
|
+
return {
|
|
30
|
+
name: config.name,
|
|
31
|
+
description: config.description,
|
|
32
|
+
fields: Object.fromEntries(Object.entries(config.fields).map(([key, field]) => [key, {
|
|
33
|
+
typeName: getTypeName(field.type),
|
|
34
|
+
isOptional: field.isOptional,
|
|
35
|
+
isArray: field.isArray
|
|
36
|
+
}]))
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
name: "unknown",
|
|
41
|
+
fields: {}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Serialize an OperationSpec to a plain JSON object.
|
|
46
|
+
*/
|
|
47
|
+
function serializeOperationSpec(spec) {
|
|
48
|
+
if (!spec) return null;
|
|
49
|
+
return {
|
|
50
|
+
meta: {
|
|
51
|
+
key: spec.meta.key,
|
|
52
|
+
version: spec.meta.version,
|
|
53
|
+
stability: spec.meta.stability,
|
|
54
|
+
owners: spec.meta.owners,
|
|
55
|
+
tags: spec.meta.tags,
|
|
56
|
+
description: spec.meta.description,
|
|
57
|
+
goal: spec.meta.goal,
|
|
58
|
+
context: spec.meta.context
|
|
59
|
+
},
|
|
60
|
+
io: {
|
|
61
|
+
input: serializeSchemaModel(spec.io.input),
|
|
62
|
+
output: serializeSchemaModel(spec.io.output)
|
|
63
|
+
},
|
|
64
|
+
policy: spec.policy ? { auth: spec.policy.auth } : void 0
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Serialize an EventSpec to a plain JSON object.
|
|
69
|
+
*/
|
|
70
|
+
function serializeEventSpec(spec) {
|
|
71
|
+
if (!spec) return null;
|
|
72
|
+
return {
|
|
73
|
+
meta: {
|
|
74
|
+
key: spec.meta.key,
|
|
75
|
+
version: spec.meta.version,
|
|
76
|
+
stability: spec.meta.stability,
|
|
77
|
+
owners: spec.meta.owners,
|
|
78
|
+
tags: spec.meta.tags,
|
|
79
|
+
description: spec.meta.description
|
|
80
|
+
},
|
|
81
|
+
payload: serializeSchemaModel(spec.payload)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Serialize a PresentationSpec to a plain JSON object.
|
|
86
|
+
*/
|
|
87
|
+
function serializePresentationSpec(spec) {
|
|
88
|
+
if (!spec) return null;
|
|
89
|
+
return {
|
|
90
|
+
meta: {
|
|
91
|
+
key: spec.meta.key,
|
|
92
|
+
version: spec.meta.version,
|
|
93
|
+
stability: spec.meta.stability,
|
|
94
|
+
owners: spec.meta.owners,
|
|
95
|
+
tags: spec.meta.tags,
|
|
96
|
+
description: spec.meta.description,
|
|
97
|
+
goal: spec.meta.goal,
|
|
98
|
+
context: spec.meta.context
|
|
99
|
+
},
|
|
100
|
+
source: {
|
|
101
|
+
type: spec.source.type,
|
|
102
|
+
framework: spec.source.type === "component" ? spec.source.framework : void 0,
|
|
103
|
+
componentKey: spec.source.type === "component" ? spec.source.componentKey : void 0
|
|
104
|
+
},
|
|
105
|
+
targets: spec.targets
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Serialize a DataViewSpec to a plain JSON object.
|
|
110
|
+
*/
|
|
111
|
+
function serializeDataViewSpec(spec) {
|
|
112
|
+
if (!spec) return null;
|
|
113
|
+
return {
|
|
114
|
+
meta: {
|
|
115
|
+
key: spec.meta.key,
|
|
116
|
+
version: spec.meta.version,
|
|
117
|
+
stability: spec.meta.stability,
|
|
118
|
+
owners: spec.meta.owners,
|
|
119
|
+
tags: spec.meta.tags,
|
|
120
|
+
description: spec.meta.description,
|
|
121
|
+
title: spec.meta.title
|
|
122
|
+
},
|
|
123
|
+
source: spec.source,
|
|
124
|
+
view: spec.view
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Serialize a FormSpec to a plain JSON object.
|
|
129
|
+
*/
|
|
130
|
+
function serializeFormSpec(spec) {
|
|
131
|
+
if (!spec) return null;
|
|
132
|
+
return {
|
|
133
|
+
meta: {
|
|
134
|
+
key: spec.meta.key,
|
|
135
|
+
version: spec.meta.version,
|
|
136
|
+
stability: spec.meta.stability,
|
|
137
|
+
owners: spec.meta.owners,
|
|
138
|
+
tags: spec.meta.tags,
|
|
139
|
+
description: spec.meta.description,
|
|
140
|
+
title: spec.meta.title
|
|
141
|
+
},
|
|
142
|
+
fields: spec.fields,
|
|
143
|
+
actions: spec.actions
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
export { serializeDataViewSpec, serializeEventSpec, serializeFormSpec, serializeOperationSpec, serializePresentationSpec, serializeSchemaModel };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//#region src/serialization/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Serialized types for Server -> Client Component transfer.
|
|
4
|
+
*
|
|
5
|
+
* These are plain JSON-serializable versions of spec types that can be
|
|
6
|
+
* safely passed from Server Components to Client Components in Next.js.
|
|
7
|
+
*/
|
|
8
|
+
/** Serialized schema model that can be passed to client components */
|
|
9
|
+
interface SerializedSchemaModel {
|
|
10
|
+
name: string;
|
|
11
|
+
description?: string | null;
|
|
12
|
+
fields: Record<string, SerializedFieldConfig>;
|
|
13
|
+
}
|
|
14
|
+
interface SerializedFieldConfig {
|
|
15
|
+
typeName: string;
|
|
16
|
+
isOptional: boolean;
|
|
17
|
+
isArray?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Serialized operation spec for client components */
|
|
20
|
+
interface SerializedOperationSpec {
|
|
21
|
+
meta: {
|
|
22
|
+
key: string;
|
|
23
|
+
version: string;
|
|
24
|
+
stability?: string;
|
|
25
|
+
owners?: string[];
|
|
26
|
+
tags?: string[];
|
|
27
|
+
description?: string;
|
|
28
|
+
goal?: string;
|
|
29
|
+
context?: string;
|
|
30
|
+
};
|
|
31
|
+
io: {
|
|
32
|
+
input: SerializedSchemaModel | null;
|
|
33
|
+
output: SerializedSchemaModel | null;
|
|
34
|
+
};
|
|
35
|
+
policy?: {
|
|
36
|
+
auth?: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Serialized event spec for client components */
|
|
40
|
+
interface SerializedEventSpec {
|
|
41
|
+
meta: {
|
|
42
|
+
key: string;
|
|
43
|
+
version: string;
|
|
44
|
+
stability?: string;
|
|
45
|
+
owners?: string[];
|
|
46
|
+
tags?: string[];
|
|
47
|
+
description?: string;
|
|
48
|
+
};
|
|
49
|
+
payload: SerializedSchemaModel | null;
|
|
50
|
+
}
|
|
51
|
+
/** Serialized presentation spec for client components */
|
|
52
|
+
interface SerializedPresentationSpec {
|
|
53
|
+
meta: {
|
|
54
|
+
key: string;
|
|
55
|
+
version: string;
|
|
56
|
+
stability?: string;
|
|
57
|
+
owners?: string[];
|
|
58
|
+
tags?: string[];
|
|
59
|
+
description?: string;
|
|
60
|
+
goal?: string;
|
|
61
|
+
context?: string;
|
|
62
|
+
};
|
|
63
|
+
source: {
|
|
64
|
+
type: string;
|
|
65
|
+
framework?: string;
|
|
66
|
+
componentKey?: string;
|
|
67
|
+
};
|
|
68
|
+
targets?: string[];
|
|
69
|
+
}
|
|
70
|
+
/** Serialized data view spec for client components */
|
|
71
|
+
interface SerializedDataViewSpec {
|
|
72
|
+
meta: {
|
|
73
|
+
key: string;
|
|
74
|
+
version: string;
|
|
75
|
+
stability?: string;
|
|
76
|
+
owners?: string[];
|
|
77
|
+
tags?: string[];
|
|
78
|
+
description?: string;
|
|
79
|
+
title?: string;
|
|
80
|
+
};
|
|
81
|
+
/** Serialized source configuration */
|
|
82
|
+
source?: unknown;
|
|
83
|
+
/** Serialized view configuration */
|
|
84
|
+
view?: unknown;
|
|
85
|
+
}
|
|
86
|
+
/** Serialized form spec for client components */
|
|
87
|
+
interface SerializedFormSpec {
|
|
88
|
+
meta: {
|
|
89
|
+
key: string;
|
|
90
|
+
version?: string;
|
|
91
|
+
stability?: string;
|
|
92
|
+
owners?: string[];
|
|
93
|
+
tags?: string[];
|
|
94
|
+
description?: string;
|
|
95
|
+
title?: string;
|
|
96
|
+
};
|
|
97
|
+
/** Serialized form fields (passed through for display) */
|
|
98
|
+
fields?: unknown;
|
|
99
|
+
/** Serialized form actions (passed through for display) */
|
|
100
|
+
actions?: unknown;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { SerializedDataViewSpec, SerializedEventSpec, SerializedFieldConfig, SerializedFormSpec, SerializedOperationSpec, SerializedPresentationSpec, SerializedSchemaModel };
|
|
File without changes
|