@takeshape/schema 9.84.0 → 9.86.2
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/validate.d.ts +2 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +19 -4
- package/es/validate.js +20 -5
- package/package.json +5 -5
package/dist/validate.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { RoleImport, RoleInput } from './auth-schemas';
|
|
|
3
3
|
import type { ProjectSchemaImport, LayerState } from './types/types';
|
|
4
4
|
import type { AnyProjectSchemaJSON, ProjectSchemaJSON } from './project-schema';
|
|
5
5
|
import { SchemaValidationErrorItem } from '@takeshape/errors';
|
|
6
|
+
import { Entitlements } from '@takeshape/util';
|
|
6
7
|
import { SetRequired } from 'type-fest';
|
|
7
8
|
export type SchemaValidationResult = {
|
|
8
9
|
valid: true;
|
|
@@ -28,6 +29,7 @@ export type ResolveLayer = (layerId: string) => Promise<LayerState>;
|
|
|
28
29
|
export interface ValidateContext extends ValidateSyntaxOptions {
|
|
29
30
|
resolveLayer?: ResolveLayer;
|
|
30
31
|
allowDisconnectedLayers?: boolean;
|
|
32
|
+
entitlements: Entitlements;
|
|
31
33
|
}
|
|
32
34
|
export type ValidateReferencesContext = SetRequired<ValidateContext, 'resolveLayer'>;
|
|
33
35
|
export declare function validateSchemaSyntax(obj: unknown, options?: ValidateSyntaxOptions): SchemaValidationResult;
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,WAAW,EAAC,MAAM,KAAK,CAAC;AACvD,OAAO,KAAK,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAC,mBAAmB,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AAChF,OAAO,KAAK,EACV,oBAAo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AQxF"}
|
package/dist/validate.js
CHANGED
|
@@ -362,7 +362,8 @@ async function validateShapeJoins(context, projectSchema) {
|
|
|
362
362
|
}
|
|
363
363
|
return (0, _lodash.flatten)(await Promise.all(promises));
|
|
364
364
|
}
|
|
365
|
-
function validateShapeLoaders(projectSchema, shape) {
|
|
365
|
+
function validateShapeLoaders(context, projectSchema, shape) {
|
|
366
|
+
var _shape$cache2;
|
|
366
367
|
const errors = [];
|
|
367
368
|
if (shape.loaders) {
|
|
368
369
|
const getNamespace = (0, _refs.createGetNamespace)(projectSchema);
|
|
@@ -393,6 +394,20 @@ function validateShapeLoaders(projectSchema, shape) {
|
|
|
393
394
|
}
|
|
394
395
|
}
|
|
395
396
|
}
|
|
397
|
+
if ((_shape$cache2 = shape.cache) !== null && _shape$cache2 !== void 0 && _shape$cache2.triggers) {
|
|
398
|
+
var _context$entitlements;
|
|
399
|
+
const min = ((_context$entitlements = context.entitlements) === null || _context$entitlements === void 0 ? void 0 : _context$entitlements.minScheduleTriggerInterval) ?? _util.DEFAULT_MIN_SCHEDULE_TRIGGER_INTERVAL;
|
|
400
|
+
for (let i = 0; i < shape.cache.triggers.length; i++) {
|
|
401
|
+
const trigger = shape.cache.triggers[i];
|
|
402
|
+
if (trigger.type === 'schedule' && trigger.interval < min) {
|
|
403
|
+
errors.push({
|
|
404
|
+
path: ['shapes', shape.name, 'cache', 'triggers', i, 'interval'],
|
|
405
|
+
type: 'entitlement',
|
|
406
|
+
message: `Trigger interval ${trigger.interval} is below minimum ${min}`
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
396
411
|
return errors;
|
|
397
412
|
}
|
|
398
413
|
function visitProperties(projectSchema, callback) {
|
|
@@ -402,13 +417,13 @@ function visitProperties(projectSchema, callback) {
|
|
|
402
417
|
callback(property, propertyPath.slice(3, -2).split(`']['`));
|
|
403
418
|
}, undefined);
|
|
404
419
|
}
|
|
405
|
-
function validateIndexedShapes(projectSchema) {
|
|
420
|
+
function validateIndexedShapes(context, projectSchema) {
|
|
406
421
|
const errors = [];
|
|
407
422
|
const {
|
|
408
423
|
shapes
|
|
409
424
|
} = projectSchema;
|
|
410
425
|
for (const shape of Object.values(shapes)) {
|
|
411
|
-
const newErrors = validateShapeLoaders(projectSchema, shape);
|
|
426
|
+
const newErrors = validateShapeLoaders(context, projectSchema, shape);
|
|
412
427
|
if (newErrors.length) {
|
|
413
428
|
errors.push(...newErrors);
|
|
414
429
|
}
|
|
@@ -787,7 +802,7 @@ function formatValidationResult(context, errors, schema) {
|
|
|
787
802
|
}
|
|
788
803
|
function validateSyntax(context, schema) {
|
|
789
804
|
let errors = [];
|
|
790
|
-
errors = errors.concat(checkShapeNames(schema.shapes)).concat(checkShapeIds(schema.shapes)).concat(validateWorkflows(schema)).concat(validateLocalQueryConfigs(schema)).concat(validateLocalRefs(schema)).concat(validateLocalShapeJoins(schema)).concat(validateDirectives(schema)).concat(validateLocales(schema)).concat(checkWorkflowStepNames(schema.workflows)).concat(checkWorkflowStepKeys(schema.workflows)).concat(validateOneOfs(schema)).concat(validateIndexedShapes(schema)).concat(validateInterfaces(schema)).concat(validateInterfaceImplementations(schema));
|
|
805
|
+
errors = errors.concat(checkShapeNames(schema.shapes)).concat(checkShapeIds(schema.shapes)).concat(validateWorkflows(schema)).concat(validateLocalQueryConfigs(schema)).concat(validateLocalRefs(schema)).concat(validateLocalShapeJoins(schema)).concat(validateDirectives(schema)).concat(validateLocales(schema)).concat(checkWorkflowStepNames(schema.workflows)).concat(checkWorkflowStepKeys(schema.workflows)).concat(validateOneOfs(schema)).concat(validateIndexedShapes(context, schema)).concat(validateInterfaces(schema)).concat(validateInterfaceImplementations(schema));
|
|
791
806
|
return formatValidationResult(context, errors, schema);
|
|
792
807
|
}
|
|
793
808
|
async function validateReferences(context, schema) {
|
package/es/validate.js
CHANGED
|
@@ -18,7 +18,7 @@ import { refItemToShapeName, getRefShapeName, parsePropertyRef, propertyRefItemT
|
|
|
18
18
|
import { scalars } from './scalars';
|
|
19
19
|
import { isUnionSchema } from './unions';
|
|
20
20
|
import { isEnumLikeSchema } from './enum';
|
|
21
|
-
import { ensureArray, isIntegerLike, isRecord, value } from '@takeshape/util';
|
|
21
|
+
import { DEFAULT_MIN_SCHEDULE_TRIGGER_INTERVAL, ensureArray, isIntegerLike, isRecord, value } from '@takeshape/util';
|
|
22
22
|
import uniqBy from 'lodash/uniqBy';
|
|
23
23
|
import initial from 'lodash/initial';
|
|
24
24
|
import last from 'lodash/last';
|
|
@@ -348,7 +348,8 @@ async function validateShapeJoins(context, projectSchema) {
|
|
|
348
348
|
}
|
|
349
349
|
return flatten(await Promise.all(promises));
|
|
350
350
|
}
|
|
351
|
-
function validateShapeLoaders(projectSchema, shape) {
|
|
351
|
+
function validateShapeLoaders(context, projectSchema, shape) {
|
|
352
|
+
var _shape$cache2;
|
|
352
353
|
const errors = [];
|
|
353
354
|
if (shape.loaders) {
|
|
354
355
|
const getNamespace = createGetNamespace(projectSchema);
|
|
@@ -379,6 +380,20 @@ function validateShapeLoaders(projectSchema, shape) {
|
|
|
379
380
|
}
|
|
380
381
|
}
|
|
381
382
|
}
|
|
383
|
+
if ((_shape$cache2 = shape.cache) !== null && _shape$cache2 !== void 0 && _shape$cache2.triggers) {
|
|
384
|
+
var _context$entitlements;
|
|
385
|
+
const min = ((_context$entitlements = context.entitlements) === null || _context$entitlements === void 0 ? void 0 : _context$entitlements.minScheduleTriggerInterval) ?? DEFAULT_MIN_SCHEDULE_TRIGGER_INTERVAL;
|
|
386
|
+
for (let i = 0; i < shape.cache.triggers.length; i++) {
|
|
387
|
+
const trigger = shape.cache.triggers[i];
|
|
388
|
+
if (trigger.type === 'schedule' && trigger.interval < min) {
|
|
389
|
+
errors.push({
|
|
390
|
+
path: ['shapes', shape.name, 'cache', 'triggers', i, 'interval'],
|
|
391
|
+
type: 'entitlement',
|
|
392
|
+
message: `Trigger interval ${trigger.interval} is below minimum ${min}`
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
382
397
|
return errors;
|
|
383
398
|
}
|
|
384
399
|
function visitProperties(projectSchema, callback) {
|
|
@@ -388,13 +403,13 @@ function visitProperties(projectSchema, callback) {
|
|
|
388
403
|
callback(property, propertyPath.slice(3, -2).split(`']['`));
|
|
389
404
|
}, undefined);
|
|
390
405
|
}
|
|
391
|
-
function validateIndexedShapes(projectSchema) {
|
|
406
|
+
function validateIndexedShapes(context, projectSchema) {
|
|
392
407
|
const errors = [];
|
|
393
408
|
const {
|
|
394
409
|
shapes
|
|
395
410
|
} = projectSchema;
|
|
396
411
|
for (const shape of Object.values(shapes)) {
|
|
397
|
-
const newErrors = validateShapeLoaders(projectSchema, shape);
|
|
412
|
+
const newErrors = validateShapeLoaders(context, projectSchema, shape);
|
|
398
413
|
if (newErrors.length) {
|
|
399
414
|
errors.push(...newErrors);
|
|
400
415
|
}
|
|
@@ -773,7 +788,7 @@ function formatValidationResult(context, errors, schema) {
|
|
|
773
788
|
}
|
|
774
789
|
function validateSyntax(context, schema) {
|
|
775
790
|
let errors = [];
|
|
776
|
-
errors = errors.concat(checkShapeNames(schema.shapes)).concat(checkShapeIds(schema.shapes)).concat(validateWorkflows(schema)).concat(validateLocalQueryConfigs(schema)).concat(validateLocalRefs(schema)).concat(validateLocalShapeJoins(schema)).concat(validateDirectives(schema)).concat(validateLocales(schema)).concat(checkWorkflowStepNames(schema.workflows)).concat(checkWorkflowStepKeys(schema.workflows)).concat(validateOneOfs(schema)).concat(validateIndexedShapes(schema)).concat(validateInterfaces(schema)).concat(validateInterfaceImplementations(schema));
|
|
791
|
+
errors = errors.concat(checkShapeNames(schema.shapes)).concat(checkShapeIds(schema.shapes)).concat(validateWorkflows(schema)).concat(validateLocalQueryConfigs(schema)).concat(validateLocalRefs(schema)).concat(validateLocalShapeJoins(schema)).concat(validateDirectives(schema)).concat(validateLocales(schema)).concat(checkWorkflowStepNames(schema.workflows)).concat(checkWorkflowStepKeys(schema.workflows)).concat(validateOneOfs(schema)).concat(validateIndexedShapes(context, schema)).concat(validateInterfaces(schema)).concat(validateInterfaceImplementations(schema));
|
|
777
792
|
return formatValidationResult(context, errors, schema);
|
|
778
793
|
}
|
|
779
794
|
async function validateReferences(context, schema) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/schema",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.86.2",
|
|
4
4
|
"description": "TakeShape Schema",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"p-reduce": "^2.1.0",
|
|
29
29
|
"semver": "^7.3.2",
|
|
30
30
|
"tiny-invariant": "^1.2.0",
|
|
31
|
-
"@takeshape/
|
|
32
|
-
"@takeshape/
|
|
33
|
-
"@takeshape/util": "9.
|
|
31
|
+
"@takeshape/json-schema": "9.86.2",
|
|
32
|
+
"@takeshape/errors": "9.86.2",
|
|
33
|
+
"@takeshape/util": "9.86.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@takeshape/json-schema-to-typescript": "^11.0.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"meow": "^9.0.0",
|
|
47
47
|
"p-map": "^5.0.0",
|
|
48
48
|
"shortid": "^2.2.15",
|
|
49
|
-
"@takeshape/typescript-jest-junit-reporter": "9.
|
|
49
|
+
"@takeshape/typescript-jest-junit-reporter": "9.86.2"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">=16"
|