@takeshape/schema 8.97.0 → 8.100.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/es/schema-util.js +92 -64
- package/lib/schema-util.d.ts +4 -2
- package/lib/schema-util.d.ts.map +1 -1
- package/lib/schema-util.js +97 -67
- package/package.json +4 -4
package/es/schema-util.js
CHANGED
|
@@ -42,60 +42,6 @@ export const arraySchemaKeys = [...commonSchemaKeys, 'items', 'additionalItems',
|
|
|
42
42
|
export const multipleRelationshipSchemaKeys = [...schemaMetadataKeys, 'maxItems', 'minItems']; // All properties except properties, items, additionalItems
|
|
43
43
|
|
|
44
44
|
export const nonStructuralSchemaKeys = [...scalarSchemaKeys, '@relationship', '@backreference', 'required', 'maxItems', 'minItems', 'uniqueItems'];
|
|
45
|
-
const commonProperties = {
|
|
46
|
-
_id: {
|
|
47
|
-
title: 'Id',
|
|
48
|
-
type: 'string'
|
|
49
|
-
},
|
|
50
|
-
_version: {
|
|
51
|
-
title: 'Version',
|
|
52
|
-
type: 'integer'
|
|
53
|
-
},
|
|
54
|
-
_shapeId: {
|
|
55
|
-
title: 'Shape Id',
|
|
56
|
-
type: 'string'
|
|
57
|
-
},
|
|
58
|
-
_shapeName: {
|
|
59
|
-
title: 'Shape Name',
|
|
60
|
-
type: 'string'
|
|
61
|
-
},
|
|
62
|
-
_createdAt: {
|
|
63
|
-
title: 'Created',
|
|
64
|
-
type: 'string',
|
|
65
|
-
format: 'date-time'
|
|
66
|
-
},
|
|
67
|
-
_createdBy: {
|
|
68
|
-
title: 'Created By',
|
|
69
|
-
'@ref': 'local:TSUser',
|
|
70
|
-
'@input': {
|
|
71
|
-
type: 'string'
|
|
72
|
-
},
|
|
73
|
-
'@resolver': {
|
|
74
|
-
name: 'takeshape:getUser',
|
|
75
|
-
service: 'takeshape:local'
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
_updatedAt: {
|
|
79
|
-
title: 'Updated',
|
|
80
|
-
type: 'string',
|
|
81
|
-
format: 'date-time'
|
|
82
|
-
},
|
|
83
|
-
_updatedBy: {
|
|
84
|
-
title: 'Updated By',
|
|
85
|
-
'@ref': 'local:TSUser',
|
|
86
|
-
'@input': {
|
|
87
|
-
type: 'string'
|
|
88
|
-
},
|
|
89
|
-
'@resolver': {
|
|
90
|
-
name: 'takeshape:getUser',
|
|
91
|
-
service: 'takeshape:local'
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
_schemaVersion: {
|
|
95
|
-
title: 'Schema Version',
|
|
96
|
-
type: 'number'
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
45
|
export function getServiceIdFieldName(serviceFieldName) {
|
|
100
46
|
return `${serviceFieldName}Id`;
|
|
101
47
|
}
|
|
@@ -107,9 +53,10 @@ export function getGeneratorVersion(generator) {
|
|
|
107
53
|
} // Returns info for all services found in shape, keyed by provider
|
|
108
54
|
|
|
109
55
|
export function getServiceInfo(projectSchema, shape) {
|
|
110
|
-
const result = {};
|
|
111
|
-
|
|
112
|
-
const
|
|
56
|
+
const result = {}; // Get inline dependencies by not following refs with @resolver
|
|
57
|
+
|
|
58
|
+
const inlineDepShapes = getShapeDependencies(projectSchema, shape, prop => !prop['@resolver']).map(name => projectSchema.shapes[name]);
|
|
59
|
+
const shapesToCheck = [shape, ...inlineDepShapes];
|
|
113
60
|
shapesToCheck.forEach(thisShape => {
|
|
114
61
|
createSchemaPropertyList(projectSchema, thisShape).forEach(([key, value]) => {
|
|
115
62
|
const resolver = value['@resolver'];
|
|
@@ -289,9 +236,84 @@ export function getShapeQueriesAndMutations(shapeList) {
|
|
|
289
236
|
mutations
|
|
290
237
|
};
|
|
291
238
|
}
|
|
292
|
-
export function
|
|
239
|
+
export function getBuiltinPropertiesSet(context, shape) {
|
|
240
|
+
if (isModelShape(shape)) {
|
|
241
|
+
return 'model';
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (isIndexedRemoteShape(context, shape)) {
|
|
245
|
+
return 'indexed';
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return 'none';
|
|
249
|
+
}
|
|
250
|
+
export function getBuiltinProperties(shapeId, builtinPropertiesSet, apiVersion = CURRENT_API_VERSION) {
|
|
251
|
+
if (builtinPropertiesSet === 'none') {
|
|
252
|
+
return {};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const commonFields = {
|
|
256
|
+
_shapeId: {
|
|
257
|
+
type: 'string',
|
|
258
|
+
title: 'Shape Id',
|
|
259
|
+
enum: [shapeId]
|
|
260
|
+
},
|
|
261
|
+
_id: {
|
|
262
|
+
title: 'Id',
|
|
263
|
+
type: 'string'
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
if (builtinPropertiesSet === 'indexed') {
|
|
268
|
+
return commonFields;
|
|
269
|
+
}
|
|
270
|
+
|
|
293
271
|
const showV1Deprecation = apiVersion !== '1';
|
|
294
|
-
return { ...
|
|
272
|
+
return { ...commonFields,
|
|
273
|
+
_version: {
|
|
274
|
+
title: 'Version',
|
|
275
|
+
type: 'integer'
|
|
276
|
+
},
|
|
277
|
+
_shapeName: {
|
|
278
|
+
title: 'Shape Name',
|
|
279
|
+
type: 'string'
|
|
280
|
+
},
|
|
281
|
+
_createdAt: {
|
|
282
|
+
title: 'Created',
|
|
283
|
+
type: 'string',
|
|
284
|
+
format: 'date-time'
|
|
285
|
+
},
|
|
286
|
+
_createdBy: {
|
|
287
|
+
title: 'Created By',
|
|
288
|
+
'@ref': 'local:TSUser',
|
|
289
|
+
'@input': {
|
|
290
|
+
type: 'string'
|
|
291
|
+
},
|
|
292
|
+
'@resolver': {
|
|
293
|
+
name: 'takeshape:getUser',
|
|
294
|
+
service: 'takeshape:local'
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
_updatedAt: {
|
|
298
|
+
title: 'Updated',
|
|
299
|
+
type: 'string',
|
|
300
|
+
format: 'date-time'
|
|
301
|
+
},
|
|
302
|
+
_updatedBy: {
|
|
303
|
+
title: 'Updated By',
|
|
304
|
+
'@ref': 'local:TSUser',
|
|
305
|
+
'@input': {
|
|
306
|
+
type: 'string'
|
|
307
|
+
},
|
|
308
|
+
'@resolver': {
|
|
309
|
+
name: 'takeshape:getUser',
|
|
310
|
+
service: 'takeshape:local'
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
_schemaVersion: {
|
|
314
|
+
title: 'Schema Version',
|
|
315
|
+
type: 'number'
|
|
316
|
+
},
|
|
295
317
|
_enabled: {
|
|
296
318
|
title: 'Enabled',
|
|
297
319
|
type: 'boolean',
|
|
@@ -309,13 +331,19 @@ export function getBuiltInProperties(apiVersion = CURRENT_API_VERSION) {
|
|
|
309
331
|
* Return all the built in property names,
|
|
310
332
|
*/
|
|
311
333
|
|
|
312
|
-
export const
|
|
334
|
+
export const getBuiltinPropertyNames = (builtinPropertiesSet, apiVersion = CURRENT_API_VERSION) => new Set([...Object.keys(getBuiltinProperties('shape-id', builtinPropertiesSet, apiVersion)), workflowsEnabled(apiVersion) ? '_status' : undefined].filter(isDefined));
|
|
313
335
|
export function applyBuiltinPropertiesToShape(projectSchema, shape) {
|
|
336
|
+
const builtinSet = getBuiltinPropertiesSet(projectSchema, shape);
|
|
337
|
+
|
|
338
|
+
if (builtinSet === 'none') {
|
|
339
|
+
return shape;
|
|
340
|
+
}
|
|
341
|
+
|
|
314
342
|
return { ...shape,
|
|
315
343
|
schema: { ...shape.schema,
|
|
316
|
-
properties: { ...omitBy(dereferenceObjectSchema(projectSchema, shape.schema).properties, (_, name) => name.startsWith('_')),
|
|
317
|
-
...
|
|
318
|
-
...(workflowsEnabled(projectSchema.apiVersion) && {
|
|
344
|
+
properties: { ...omitBy(dereferenceObjectSchema(projectSchema, shape.schema, ['shapes', shape.name]).properties, (_, name) => name.startsWith('_')),
|
|
345
|
+
...getBuiltinProperties(shape.id, builtinSet, projectSchema.apiVersion),
|
|
346
|
+
...(builtinSet === 'model' && workflowsEnabled(projectSchema.apiVersion) && {
|
|
319
347
|
_status: getStatusField(projectSchema.workflows, shape)
|
|
320
348
|
})
|
|
321
349
|
}
|
|
@@ -368,7 +396,7 @@ export function applyDefaultsToSchema(projectSchema) {
|
|
|
368
396
|
};
|
|
369
397
|
}
|
|
370
398
|
|
|
371
|
-
return
|
|
399
|
+
return applyBuiltinPropertiesToShape(projectSchema, shape);
|
|
372
400
|
}),
|
|
373
401
|
forms: mapValues({ ...builtInForms,
|
|
374
402
|
...projectSchema.forms
|
package/lib/schema-util.d.ts
CHANGED
|
@@ -23,11 +23,13 @@ export declare function getShapeQueriesAndMutations(shapeList: Array<Shape | Sha
|
|
|
23
23
|
queries: QueryMap;
|
|
24
24
|
mutations: QueryMap;
|
|
25
25
|
};
|
|
26
|
-
export declare
|
|
26
|
+
export declare type BuiltinPropertiesSet = 'model' | 'indexed' | 'none';
|
|
27
|
+
export declare function getBuiltinPropertiesSet(context: Pick<ProjectSchema, 'indexedShapes'>, shape: Shape): BuiltinPropertiesSet;
|
|
28
|
+
export declare function getBuiltinProperties(shapeId: string, builtinPropertiesSet: BuiltinPropertiesSet, apiVersion?: string): Record<string, PropertySchema>;
|
|
27
29
|
/**
|
|
28
30
|
* Return all the built in property names,
|
|
29
31
|
*/
|
|
30
|
-
export declare const
|
|
32
|
+
export declare const getBuiltinPropertyNames: (builtinPropertiesSet: BuiltinPropertiesSet, apiVersion?: string) => Set<string>;
|
|
31
33
|
export declare function applyBuiltinPropertiesToShape(projectSchema: ProjectSchema, shape: Shape): Shape;
|
|
32
34
|
/**
|
|
33
35
|
* Get all built-in shapes that are depended on by the given project schema.
|
package/lib/schema-util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-util.d.ts","sourceRoot":"","sources":["../../src/schema-util.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,UAAU,EAEV,KAAK,EACL,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,aAAa,EACb,WAAW,EAGX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B,GAClB,kBAAkB,GAClB,qBAAqB,CAAC;AAE1B;;GAEG;AACH,eAAO,MAAM,sBAAsB,cAAe,MAAM,YAAY,2BAA2B,KAAG,MAGjG,CAAC;AAEF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAQ3F"}
|
package/lib/schema-util.js
CHANGED
|
@@ -25,8 +25,9 @@ exports.getAllRefsInShapes = getAllRefsInShapes;
|
|
|
25
25
|
exports.getArgsReference = getArgsReference;
|
|
26
26
|
exports.getArgsReferenceWithPath = getArgsReferenceWithPath;
|
|
27
27
|
exports.getArgsShapeSchema = getArgsShapeSchema;
|
|
28
|
-
exports.
|
|
29
|
-
exports.
|
|
28
|
+
exports.getBuiltinProperties = getBuiltinProperties;
|
|
29
|
+
exports.getBuiltinPropertiesSet = getBuiltinPropertiesSet;
|
|
30
|
+
exports.getBuiltinPropertyNames = void 0;
|
|
30
31
|
exports.getBuiltinsUsed = getBuiltinsUsed;
|
|
31
32
|
exports.getDefaultMutationName = void 0;
|
|
32
33
|
exports.getFirstMapping = getFirstMapping;
|
|
@@ -143,60 +144,6 @@ const multipleRelationshipSchemaKeys = [...schemaMetadataKeys, 'maxItems', 'minI
|
|
|
143
144
|
exports.multipleRelationshipSchemaKeys = multipleRelationshipSchemaKeys;
|
|
144
145
|
const nonStructuralSchemaKeys = [...scalarSchemaKeys, '@relationship', '@backreference', 'required', 'maxItems', 'minItems', 'uniqueItems'];
|
|
145
146
|
exports.nonStructuralSchemaKeys = nonStructuralSchemaKeys;
|
|
146
|
-
const commonProperties = {
|
|
147
|
-
_id: {
|
|
148
|
-
title: 'Id',
|
|
149
|
-
type: 'string'
|
|
150
|
-
},
|
|
151
|
-
_version: {
|
|
152
|
-
title: 'Version',
|
|
153
|
-
type: 'integer'
|
|
154
|
-
},
|
|
155
|
-
_shapeId: {
|
|
156
|
-
title: 'Shape Id',
|
|
157
|
-
type: 'string'
|
|
158
|
-
},
|
|
159
|
-
_shapeName: {
|
|
160
|
-
title: 'Shape Name',
|
|
161
|
-
type: 'string'
|
|
162
|
-
},
|
|
163
|
-
_createdAt: {
|
|
164
|
-
title: 'Created',
|
|
165
|
-
type: 'string',
|
|
166
|
-
format: 'date-time'
|
|
167
|
-
},
|
|
168
|
-
_createdBy: {
|
|
169
|
-
title: 'Created By',
|
|
170
|
-
'@ref': 'local:TSUser',
|
|
171
|
-
'@input': {
|
|
172
|
-
type: 'string'
|
|
173
|
-
},
|
|
174
|
-
'@resolver': {
|
|
175
|
-
name: 'takeshape:getUser',
|
|
176
|
-
service: 'takeshape:local'
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
_updatedAt: {
|
|
180
|
-
title: 'Updated',
|
|
181
|
-
type: 'string',
|
|
182
|
-
format: 'date-time'
|
|
183
|
-
},
|
|
184
|
-
_updatedBy: {
|
|
185
|
-
title: 'Updated By',
|
|
186
|
-
'@ref': 'local:TSUser',
|
|
187
|
-
'@input': {
|
|
188
|
-
type: 'string'
|
|
189
|
-
},
|
|
190
|
-
'@resolver': {
|
|
191
|
-
name: 'takeshape:getUser',
|
|
192
|
-
service: 'takeshape:local'
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
_schemaVersion: {
|
|
196
|
-
title: 'Schema Version',
|
|
197
|
-
type: 'number'
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
147
|
|
|
201
148
|
function getServiceIdFieldName(serviceFieldName) {
|
|
202
149
|
return `${serviceFieldName}Id`;
|
|
@@ -212,9 +159,10 @@ function getGeneratorVersion(generator) {
|
|
|
212
159
|
|
|
213
160
|
|
|
214
161
|
function getServiceInfo(projectSchema, shape) {
|
|
215
|
-
const result = {};
|
|
216
|
-
|
|
217
|
-
const
|
|
162
|
+
const result = {}; // Get inline dependencies by not following refs with @resolver
|
|
163
|
+
|
|
164
|
+
const inlineDepShapes = getShapeDependencies(projectSchema, shape, prop => !prop['@resolver']).map(name => projectSchema.shapes[name]);
|
|
165
|
+
const shapesToCheck = [shape, ...inlineDepShapes];
|
|
218
166
|
shapesToCheck.forEach(thisShape => {
|
|
219
167
|
createSchemaPropertyList(projectSchema, thisShape).forEach(([key, value]) => {
|
|
220
168
|
const resolver = value['@resolver'];
|
|
@@ -397,9 +345,85 @@ function getShapeQueriesAndMutations(shapeList) {
|
|
|
397
345
|
};
|
|
398
346
|
}
|
|
399
347
|
|
|
400
|
-
function
|
|
348
|
+
function getBuiltinPropertiesSet(context, shape) {
|
|
349
|
+
if (isModelShape(shape)) {
|
|
350
|
+
return 'model';
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (isIndexedRemoteShape(context, shape)) {
|
|
354
|
+
return 'indexed';
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return 'none';
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function getBuiltinProperties(shapeId, builtinPropertiesSet, apiVersion = _versions.CURRENT_API_VERSION) {
|
|
361
|
+
if (builtinPropertiesSet === 'none') {
|
|
362
|
+
return {};
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const commonFields = {
|
|
366
|
+
_shapeId: {
|
|
367
|
+
type: 'string',
|
|
368
|
+
title: 'Shape Id',
|
|
369
|
+
enum: [shapeId]
|
|
370
|
+
},
|
|
371
|
+
_id: {
|
|
372
|
+
title: 'Id',
|
|
373
|
+
type: 'string'
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
if (builtinPropertiesSet === 'indexed') {
|
|
378
|
+
return commonFields;
|
|
379
|
+
}
|
|
380
|
+
|
|
401
381
|
const showV1Deprecation = apiVersion !== '1';
|
|
402
|
-
return { ...
|
|
382
|
+
return { ...commonFields,
|
|
383
|
+
_version: {
|
|
384
|
+
title: 'Version',
|
|
385
|
+
type: 'integer'
|
|
386
|
+
},
|
|
387
|
+
_shapeName: {
|
|
388
|
+
title: 'Shape Name',
|
|
389
|
+
type: 'string'
|
|
390
|
+
},
|
|
391
|
+
_createdAt: {
|
|
392
|
+
title: 'Created',
|
|
393
|
+
type: 'string',
|
|
394
|
+
format: 'date-time'
|
|
395
|
+
},
|
|
396
|
+
_createdBy: {
|
|
397
|
+
title: 'Created By',
|
|
398
|
+
'@ref': 'local:TSUser',
|
|
399
|
+
'@input': {
|
|
400
|
+
type: 'string'
|
|
401
|
+
},
|
|
402
|
+
'@resolver': {
|
|
403
|
+
name: 'takeshape:getUser',
|
|
404
|
+
service: 'takeshape:local'
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
_updatedAt: {
|
|
408
|
+
title: 'Updated',
|
|
409
|
+
type: 'string',
|
|
410
|
+
format: 'date-time'
|
|
411
|
+
},
|
|
412
|
+
_updatedBy: {
|
|
413
|
+
title: 'Updated By',
|
|
414
|
+
'@ref': 'local:TSUser',
|
|
415
|
+
'@input': {
|
|
416
|
+
type: 'string'
|
|
417
|
+
},
|
|
418
|
+
'@resolver': {
|
|
419
|
+
name: 'takeshape:getUser',
|
|
420
|
+
service: 'takeshape:local'
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
_schemaVersion: {
|
|
424
|
+
title: 'Schema Version',
|
|
425
|
+
type: 'number'
|
|
426
|
+
},
|
|
403
427
|
_enabled: {
|
|
404
428
|
title: 'Enabled',
|
|
405
429
|
type: 'boolean',
|
|
@@ -418,16 +442,22 @@ function getBuiltInProperties(apiVersion = _versions.CURRENT_API_VERSION) {
|
|
|
418
442
|
*/
|
|
419
443
|
|
|
420
444
|
|
|
421
|
-
const
|
|
445
|
+
const getBuiltinPropertyNames = (builtinPropertiesSet, apiVersion = _versions.CURRENT_API_VERSION) => new Set([...Object.keys(getBuiltinProperties('shape-id', builtinPropertiesSet, apiVersion)), (0, _apiVersion.workflowsEnabled)(apiVersion) ? '_status' : undefined].filter(_util.isDefined));
|
|
422
446
|
|
|
423
|
-
exports.
|
|
447
|
+
exports.getBuiltinPropertyNames = getBuiltinPropertyNames;
|
|
424
448
|
|
|
425
449
|
function applyBuiltinPropertiesToShape(projectSchema, shape) {
|
|
450
|
+
const builtinSet = getBuiltinPropertiesSet(projectSchema, shape);
|
|
451
|
+
|
|
452
|
+
if (builtinSet === 'none') {
|
|
453
|
+
return shape;
|
|
454
|
+
}
|
|
455
|
+
|
|
426
456
|
return { ...shape,
|
|
427
457
|
schema: { ...shape.schema,
|
|
428
|
-
properties: { ...(0, _omitBy.default)((0, _refs.dereferenceObjectSchema)(projectSchema, shape.schema).properties, (_, name) => name.startsWith('_')),
|
|
429
|
-
...
|
|
430
|
-
...((0, _apiVersion.workflowsEnabled)(projectSchema.apiVersion) && {
|
|
458
|
+
properties: { ...(0, _omitBy.default)((0, _refs.dereferenceObjectSchema)(projectSchema, shape.schema, ['shapes', shape.name]).properties, (_, name) => name.startsWith('_')),
|
|
459
|
+
...getBuiltinProperties(shape.id, builtinSet, projectSchema.apiVersion),
|
|
460
|
+
...(builtinSet === 'model' && (0, _apiVersion.workflowsEnabled)(projectSchema.apiVersion) && {
|
|
431
461
|
_status: (0, _workflows.getStatusField)(projectSchema.workflows, shape)
|
|
432
462
|
})
|
|
433
463
|
}
|
|
@@ -482,7 +512,7 @@ function applyDefaultsToSchema(projectSchema) {
|
|
|
482
512
|
};
|
|
483
513
|
}
|
|
484
514
|
|
|
485
|
-
return
|
|
515
|
+
return applyBuiltinPropertiesToShape(projectSchema, shape);
|
|
486
516
|
}),
|
|
487
517
|
forms: (0, _mapValues.default)({ ..._builtinSchema.builtInForms,
|
|
488
518
|
...projectSchema.forms
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/schema",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.100.0",
|
|
4
4
|
"description": "TakeShape Schema",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"examples"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@takeshape/errors": "8.
|
|
25
|
-
"@takeshape/json-schema": "8.
|
|
26
|
-
"@takeshape/util": "8.
|
|
24
|
+
"@takeshape/errors": "8.100.0",
|
|
25
|
+
"@takeshape/json-schema": "8.100.0",
|
|
26
|
+
"@takeshape/util": "8.100.0",
|
|
27
27
|
"ajv": "^8.10.0",
|
|
28
28
|
"ajv-formats": "^2.1.1",
|
|
29
29
|
"blueimp-md5": "^2.10.0",
|