codify-schemas 1.0.44 → 1.0.46
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/README.md +3 -0
- package/dist/config-file-schema.json +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/ipc-message-schema.json +1 -1
- package/dist/messages/apply-request-data-schema.json +1 -1
- package/dist/messages/apply-response-data-schema.json +1 -1
- package/dist/messages/error-response-data-schema.json +1 -1
- package/dist/messages/get-resource-info-request-data-schema.json +13 -0
- package/dist/messages/get-resource-info-response-data-schema.json +27 -0
- package/dist/messages/initialize-request-data-schema.json +1 -1
- package/dist/messages/initialize-response-data-schema.json +1 -1
- package/dist/messages/plan-request-data-schema.json +1 -1
- package/dist/messages/plan-response-data-schema.json +1 -1
- package/dist/messages/sudo-request-data-schema.json +1 -1
- package/dist/messages/sudo-response-data-schema.json +1 -1
- package/dist/messages/validate-request-data-schema.json +1 -1
- package/dist/messages/validate-response-data-schema.json +1 -1
- package/dist/project-schema.json +1 -1
- package/dist/resource-schema.json +1 -1
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
- package/src/config-file-schema.json +1 -1
- package/src/config-file-schema.test.ts +2 -2
- package/src/index.ts +5 -1
- package/src/ipc-message-schema.json +1 -1
- package/src/ipc-message-schema.test.ts +2 -2
- package/src/messages/apply-request-data-schema.json +1 -1
- package/src/messages/apply-request-data-schema.test.ts +4 -3
- package/src/messages/apply-response-data-schema.json +1 -1
- package/src/messages/apply-response-data-schema.test.ts +21 -0
- package/src/messages/error-response-data-schema.json +1 -1
- package/src/messages/error-response-data-schema.test.ts +23 -0
- package/src/messages/get-resource-info-request-data-schema.json +13 -0
- package/src/messages/get-resource-info-request-data-schema.test.ts +26 -0
- package/src/messages/get-resource-info-response-data-schema.json +27 -0
- package/src/messages/get-resource-info-response-data-schema.test.ts +126 -0
- package/src/messages/initialize-request-data-schema.json +1 -1
- package/src/messages/initialize-request-data-schema.test.ts +2 -2
- package/src/messages/initialize-response-data-schema.json +1 -1
- package/src/messages/initialize-response-data-schema.test.ts +2 -2
- package/src/messages/plan-request-data-schema.json +1 -1
- package/src/messages/plan-request-data-schema.test.ts +2 -2
- package/src/messages/plan-response-data-schema.json +1 -1
- package/src/messages/plan-response-data-schema.test.ts +2 -2
- package/src/messages/sudo-request-data-schema.json +1 -1
- package/src/messages/sudo-request-data-schema.test.ts +2 -2
- package/src/messages/sudo-response-data-schema.json +1 -1
- package/src/messages/sudo-response-data-schema.test.ts +2 -2
- package/src/messages/validate-request-data-schema.json +1 -1
- package/src/messages/validate-response-data-schema.json +1 -1
- package/src/messages/validate-response-data-schema.test.ts +2 -2
- package/src/project-schema.json +1 -1
- package/src/project-schema.test.ts +2 -2
- package/src/resource-schema.json +1 -1
- package/src/resource-schema.test.ts +2 -2
- package/src/schemastore/codify-schema.json +83 -0
- package/src/schemastore/config-schema.test.ts +87 -0
- package/src/types/index.ts +12 -1
- package/src/messages/get-resources-response-data-schema.json +0 -28
- package/src/messages/get-resources-response-data-schema.test.ts +0 -43
package/README.md
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import ConfigFileSchema from './config-
|
|
1
|
+
import ConfigFileSchema from './config-schema.json';
|
|
2
2
|
import ProjectSchema from './project-schema.json';
|
|
3
3
|
import ResourceSchema from './resource-schema.json';
|
|
4
4
|
import IpcMessageSchema from './ipc-message-schema.json';
|
|
5
5
|
import ApplyRequestDataSchema from './messages/apply-request-data-schema.json';
|
|
6
6
|
import ApplyResponseDataSchema from './messages/apply-response-data-schema.json';
|
|
7
7
|
import ErrorResponseDataSchema from './messages/error-response-data-schema.json';
|
|
8
|
+
import GetResourceInfoRequestDataSchema from './messages/get-resource-info-request-data-schema.json';
|
|
9
|
+
import GetResourceInfoResponseDataSchema from './messages/get-resource-info-response-data-schema.json';
|
|
8
10
|
import PlanRequestDataSchema from './messages/plan-request-data-schema.json';
|
|
9
11
|
import PlanResponseDataSchema from './messages/plan-response-data-schema.json';
|
|
10
12
|
import ValidateRequestDataSchema from './messages/validate-request-data-schema.json';
|
|
@@ -13,6 +15,6 @@ import InitializeRequestDataSchema from './messages/initialize-request-data-sche
|
|
|
13
15
|
import InitializeResponseDataSchema from './messages/initialize-response-data-schema.json';
|
|
14
16
|
import SudoRequestDataSchema from './messages/sudo-request-data-schema.json';
|
|
15
17
|
import SudoRequestResponseDataSchema from './messages/sudo-response-data-schema.json';
|
|
16
|
-
export { ConfigFileSchema, ProjectSchema, ResourceSchema, IpcMessageSchema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
|
|
18
|
+
export { ConfigFileSchema, ProjectSchema, ResourceSchema, IpcMessageSchema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
|
|
17
19
|
export * from './types/index.js';
|
|
18
20
|
export * from './messages/commands.js';
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import ConfigFileSchema from './config-
|
|
1
|
+
import ConfigFileSchema from './config-schema.json' assert { type: 'json' };
|
|
2
2
|
import ProjectSchema from './project-schema.json' assert { type: 'json' };
|
|
3
3
|
import ResourceSchema from './resource-schema.json' assert { type: 'json' };
|
|
4
4
|
import IpcMessageSchema from './ipc-message-schema.json' assert { type: 'json' };
|
|
5
5
|
import ApplyRequestDataSchema from './messages/apply-request-data-schema.json' assert { type: 'json' };
|
|
6
6
|
import ApplyResponseDataSchema from './messages/apply-response-data-schema.json' assert { type: 'json' };
|
|
7
7
|
import ErrorResponseDataSchema from './messages/error-response-data-schema.json' assert { type: 'json' };
|
|
8
|
+
import GetResourceInfoRequestDataSchema from './messages/get-resource-info-request-data-schema.json' assert { type: 'json' };
|
|
9
|
+
import GetResourceInfoResponseDataSchema from './messages/get-resource-info-response-data-schema.json' assert { type: 'json' };
|
|
8
10
|
import PlanRequestDataSchema from './messages/plan-request-data-schema.json' assert { type: 'json' };
|
|
9
11
|
import PlanResponseDataSchema from './messages/plan-response-data-schema.json' assert { type: 'json' };
|
|
10
12
|
import ValidateRequestDataSchema from './messages/validate-request-data-schema.json' assert { type: 'json' };
|
|
@@ -13,7 +15,7 @@ import InitializeRequestDataSchema from './messages/initialize-request-data-sche
|
|
|
13
15
|
import InitializeResponseDataSchema from './messages/initialize-response-data-schema.json' assert { type: 'json' };
|
|
14
16
|
import SudoRequestDataSchema from './messages/sudo-request-data-schema.json' assert { type: 'json' };
|
|
15
17
|
import SudoRequestResponseDataSchema from './messages/sudo-response-data-schema.json' assert { type: 'json' };
|
|
16
|
-
export { ConfigFileSchema, ProjectSchema, ResourceSchema, IpcMessageSchema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
|
|
18
|
+
export { ConfigFileSchema, ProjectSchema, ResourceSchema, IpcMessageSchema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
|
|
17
19
|
export * from './types/index.js';
|
|
18
20
|
export * from './messages/commands.js';
|
|
19
21
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,gBAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,gBAAgB,MAAM,sBAAsB,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AACzE,OAAO,aAAa,MAAM,uBAAuB,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AACvE,OAAO,cAAc,MAAM,wBAAwB,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AACzE,OAAO,gBAAgB,MAAM,2BAA2B,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AAC9E,OAAO,sBAAsB,MAAM,2CAA2C,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AACpG,OAAO,uBAAuB,MAAM,4CAA4C,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AACtG,OAAO,uBAAuB,MAAM,4CAA4C,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AACtG,OAAO,gCAAgC,MAAM,uDAAuD,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AAC1H,OAAO,iCAAiC,MAAM,wDAAwD,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AAC5H,OAAO,qBAAqB,MAAM,0CAA0C,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AAClG,OAAO,sBAAsB,MAAM,2CAA2C,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AACpG,OAAO,yBAAyB,MAAM,8CAA8C,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AAC1G,OAAO,0BAA0B,MAAM,+CAA+C,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AAC5G,OAAO,2BAA2B,MAAM,gDAAgD,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AAC9G,OAAO,4BAA4B,MAAM,iDAAiD,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AAChH,OAAO,qBAAqB,MAAM,0CAA0C,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAC;AACnG,OAAO,6BAA6B,MAAM,2CAA2C,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAC;AAE5G,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,gCAAgC,EAChC,iCAAiC,EACjC,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,qBAAqB,EACrB,6BAA6B,GAC9B,CAAA;AAED,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
3
|
"$id": "https://www.codifycli.com/apply-request-data-schema.json",
|
|
4
4
|
"title": "Apply Request Schema Data",
|
|
5
5
|
"description": "Apply the previously generated plan. The plan must already be generated in order for apply to work.",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "https://www.codifycli.com/get-resource-schema-data-schema.json",
|
|
4
|
+
"title": "Get Resource Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"type": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The id/type of the resource"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"required": ["type"]
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "https://www.codifycli.com/get-resource-schema-data-schema.json",
|
|
4
|
+
"title": "Get Resource Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"plugin": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The plugin the resource is from"
|
|
10
|
+
},
|
|
11
|
+
"type": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "The id/type of the resource"
|
|
14
|
+
},
|
|
15
|
+
"schema": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"description": "The JSON Schema validation schema for the resource."
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"type": "array",
|
|
21
|
+
"items": {
|
|
22
|
+
"type": "string"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"required": ["type", "plugin"]
|
|
27
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
3
|
"$id": "https://www.codifycli.com/initialize-request-data-schema.json",
|
|
4
4
|
"title": "Initialize Request Schema Data",
|
|
5
5
|
"description": "Initialize the plugin",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
3
|
"$id": "https://www.codifycli.com/initialize-response-data-schema.json",
|
|
4
4
|
"title": "Initialize Request Schema Data",
|
|
5
5
|
"description": "Initialize the plugin",
|
package/dist/project-schema.json
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -67,6 +67,15 @@ export interface PlanResponseData {
|
|
|
67
67
|
newValue: unknown | null;
|
|
68
68
|
}>;
|
|
69
69
|
}
|
|
70
|
+
export interface GetResourceInfoRequestData {
|
|
71
|
+
type: string;
|
|
72
|
+
}
|
|
73
|
+
export interface GetResourceInfoResponseData {
|
|
74
|
+
plugin: string;
|
|
75
|
+
type: string;
|
|
76
|
+
schema?: Record<string, unknown>;
|
|
77
|
+
dependencies?: string[];
|
|
78
|
+
}
|
|
70
79
|
export interface ApplyRequestData {
|
|
71
80
|
planId?: string;
|
|
72
81
|
plan?: {
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,gCAAe,CAAA;AACjB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AA4BD,MAAM,CAAN,IAAY,iBAMX;AAND,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,wCAAmB,CAAA;IACnB,sCAAiB,CAAA;IACjB,0CAAqB,CAAA;IACrB,kCAAa,CAAA;AACf,CAAC,EANW,iBAAiB,KAAjB,iBAAiB,QAM5B;AAED,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iCAAW,CAAA;IACX,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,mCAAa,CAAA;AACf,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,gCAAe,CAAA;AACjB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AA4BD,MAAM,CAAN,IAAY,iBAMX;AAND,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,wCAAmB,CAAA;IACnB,sCAAiB,CAAA;IACjB,0CAAqB,CAAA;IACrB,kCAAa,CAAA;AACf,CAAC,EANW,iBAAiB,KAAjB,iBAAiB,QAM5B;AAED,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iCAAW,CAAA;IACX,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,mCAAa,CAAA;AACf,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AA8DD,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,8BAAe,CAAA;AACjB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import configFileSchema from './config-file-schema.json';
|
|
2
2
|
import { describe, it, expect } from 'vitest'
|
|
3
|
-
import
|
|
3
|
+
import Ajv from 'ajv'
|
|
4
4
|
|
|
5
|
-
const ajv = new
|
|
5
|
+
const ajv = new Ajv.default({
|
|
6
6
|
strict: true,
|
|
7
7
|
})
|
|
8
8
|
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// @ts-ignore
|
|
2
|
-
import ConfigFileSchema from './config-
|
|
2
|
+
import ConfigFileSchema from './config-schema.json' assert {type: 'json'}
|
|
3
3
|
import ProjectSchema from './project-schema.json' assert {type: 'json'}
|
|
4
4
|
import ResourceSchema from './resource-schema.json' assert {type: 'json'}
|
|
5
5
|
import IpcMessageSchema from './ipc-message-schema.json' assert {type: 'json'}
|
|
6
6
|
import ApplyRequestDataSchema from './messages/apply-request-data-schema.json' assert {type: 'json'}
|
|
7
7
|
import ApplyResponseDataSchema from './messages/apply-response-data-schema.json' assert {type: 'json'}
|
|
8
8
|
import ErrorResponseDataSchema from './messages/error-response-data-schema.json' assert {type: 'json'}
|
|
9
|
+
import GetResourceInfoRequestDataSchema from './messages/get-resource-info-request-data-schema.json' assert {type: 'json'}
|
|
10
|
+
import GetResourceInfoResponseDataSchema from './messages/get-resource-info-response-data-schema.json' assert {type: 'json'}
|
|
9
11
|
import PlanRequestDataSchema from './messages/plan-request-data-schema.json' assert {type: 'json'}
|
|
10
12
|
import PlanResponseDataSchema from './messages/plan-response-data-schema.json' assert {type: 'json'}
|
|
11
13
|
import ValidateRequestDataSchema from './messages/validate-request-data-schema.json' assert {type: 'json'}
|
|
@@ -23,6 +25,8 @@ export {
|
|
|
23
25
|
ApplyRequestDataSchema,
|
|
24
26
|
ApplyResponseDataSchema,
|
|
25
27
|
ErrorResponseDataSchema,
|
|
28
|
+
GetResourceInfoRequestDataSchema,
|
|
29
|
+
GetResourceInfoResponseDataSchema,
|
|
26
30
|
PlanRequestDataSchema,
|
|
27
31
|
PlanResponseDataSchema,
|
|
28
32
|
ValidateRequestDataSchema,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
3
|
"$id": "https://www.codifycli.com/apply-request-data-schema.json",
|
|
4
4
|
"title": "Apply Request Schema Data",
|
|
5
5
|
"description": "Apply the previously generated plan. The plan must already be generated in order for apply to work.",
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import schema from './apply-request-data-schema.json';
|
|
2
2
|
import resourceSchema from '../resource-schema.json'
|
|
3
3
|
import {describe, expect, it} from 'vitest'
|
|
4
|
-
import Ajv2020 from 'ajv/dist/2020.js'
|
|
5
4
|
import addFormats from 'ajv-formats';
|
|
6
|
-
import {ApplyRequestData, ParameterOperation, ResourceOperation} from "../types/index.js";
|
|
5
|
+
import { ApplyRequestData, ParameterOperation, ResourceOperation } from "../types/index.js";
|
|
6
|
+
import Ajv from 'ajv';
|
|
7
7
|
|
|
8
|
-
const ajv = new
|
|
8
|
+
const ajv = new Ajv.default({
|
|
9
9
|
strict: true,
|
|
10
10
|
})
|
|
11
|
+
|
|
11
12
|
addFormats.default(ajv);
|
|
12
13
|
ajv.addSchema(resourceSchema);
|
|
13
14
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import schema from './apply-response-data-schema.json';
|
|
2
|
+
import {describe, expect, it} from 'vitest'
|
|
3
|
+
import addFormats from 'ajv-formats';
|
|
4
|
+
import Ajv from 'ajv';
|
|
5
|
+
|
|
6
|
+
const ajv = new Ajv.default({
|
|
7
|
+
strict: true,
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
addFormats.default(ajv);
|
|
11
|
+
|
|
12
|
+
describe('Apply request data schema', () => {
|
|
13
|
+
it('compiles', () => {
|
|
14
|
+
ajv.compile(schema);
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it("validates an empty config", () => {
|
|
18
|
+
const validate = ajv.compile(schema);
|
|
19
|
+
expect(validate(null)).to.be.true;
|
|
20
|
+
})
|
|
21
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import schema from './error-response-data-schema.json';
|
|
2
|
+
import {describe, expect, it} from 'vitest'
|
|
3
|
+
import addFormats from 'ajv-formats';
|
|
4
|
+
import Ajv from 'ajv';
|
|
5
|
+
|
|
6
|
+
const ajv = new Ajv.default({
|
|
7
|
+
strict: true,
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
addFormats.default(ajv);
|
|
11
|
+
|
|
12
|
+
describe('Apply request data schema', () => {
|
|
13
|
+
it('compiles', () => {
|
|
14
|
+
ajv.compile(schema);
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it("validates an error message", () => {
|
|
18
|
+
const validate = ajv.compile(schema);
|
|
19
|
+
expect(validate({
|
|
20
|
+
reason: "This was an error"
|
|
21
|
+
})).to.be.true;
|
|
22
|
+
})
|
|
23
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "https://www.codifycli.com/get-resource-schema-data-schema.json",
|
|
4
|
+
"title": "Get Resource Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"type": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The id/type of the resource"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"required": ["type"]
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import schema from './get-resource-info-request-data-schema.json';
|
|
2
|
+
import { describe, it, expect } from 'vitest'
|
|
3
|
+
import Ajv from 'ajv'
|
|
4
|
+
|
|
5
|
+
const ajv = new Ajv.default({
|
|
6
|
+
strict: true,
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
describe('Get resources response data schema', () => {
|
|
10
|
+
it('compiles', () => {
|
|
11
|
+
ajv.compile(schema);
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it("Validates a correct response", () => {
|
|
15
|
+
const validate = ajv.compile(schema);
|
|
16
|
+
expect(validate({
|
|
17
|
+
type: 'type',
|
|
18
|
+
})).to.be.true;
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it("Rejects an invalid response", () => {
|
|
22
|
+
const validate = ajv.compile(schema);
|
|
23
|
+
expect(validate({})).to.be.false;
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "https://www.codifycli.com/get-resource-schema-data-schema.json",
|
|
4
|
+
"title": "Get Resource Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"plugin": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The plugin the resource is from"
|
|
10
|
+
},
|
|
11
|
+
"type": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "The id/type of the resource"
|
|
14
|
+
},
|
|
15
|
+
"schema": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"description": "The JSON Schema validation schema for the resource."
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"type": "array",
|
|
21
|
+
"items": {
|
|
22
|
+
"type": "string"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"required": ["type", "plugin"]
|
|
27
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import schema from './get-resource-info-response-data-schema.json';
|
|
2
|
+
import { describe, it, expect } from 'vitest'
|
|
3
|
+
import Ajv from 'ajv'
|
|
4
|
+
import {GetResourceInfoResponseData} from "../types";
|
|
5
|
+
|
|
6
|
+
const ajv = new Ajv.default({
|
|
7
|
+
strict: true,
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
describe('Get resources response data schema', () => {
|
|
11
|
+
it('compiles', () => {
|
|
12
|
+
ajv.compile(schema);
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it("Validates a correct response", () => {
|
|
16
|
+
const validate = ajv.compile(schema);
|
|
17
|
+
expect(validate({
|
|
18
|
+
type: 'type',
|
|
19
|
+
plugin: 'core-plugin',
|
|
20
|
+
schema: {
|
|
21
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
22
|
+
"$id": "https://www.codifycli.com/get-resource-schema-data-schema.json",
|
|
23
|
+
"title": "Get Resource Schema",
|
|
24
|
+
"type": "object",
|
|
25
|
+
"properties": {
|
|
26
|
+
"plugin": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "The plugin the resource is from"
|
|
29
|
+
},
|
|
30
|
+
"type": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "The id/type of the resource"
|
|
33
|
+
},
|
|
34
|
+
"schema": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"description": "The JSON Schema validation schema for the resource."
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"type": "array",
|
|
40
|
+
"items": {
|
|
41
|
+
"type": "string"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
dependencies: [
|
|
46
|
+
"typeA",
|
|
47
|
+
"typeB"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
})).to.be.true;
|
|
51
|
+
|
|
52
|
+
expect(validate({
|
|
53
|
+
type: 'type',
|
|
54
|
+
plugin: 'core-plugin',
|
|
55
|
+
})).to.be.true;
|
|
56
|
+
|
|
57
|
+
const a: GetResourceInfoResponseData = {
|
|
58
|
+
type: 'type',
|
|
59
|
+
plugin: 'core-plugin',
|
|
60
|
+
schema: {
|
|
61
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
62
|
+
"$id": "https://www.codifycli.com/get-resource-schema-data-schema.json",
|
|
63
|
+
"title": "Get Resource Schema",
|
|
64
|
+
"type": "object",
|
|
65
|
+
"properties": {
|
|
66
|
+
"plugin": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"description": "The plugin the resource is from"
|
|
69
|
+
},
|
|
70
|
+
"type": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"description": "The id/type of the resource"
|
|
73
|
+
},
|
|
74
|
+
"schema": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"description": "The JSON Schema validation schema for the resource."
|
|
77
|
+
},
|
|
78
|
+
"dependencies": {
|
|
79
|
+
"type": "array",
|
|
80
|
+
"items": {
|
|
81
|
+
"type": "string"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
dependencies: [
|
|
86
|
+
"typeA",
|
|
87
|
+
"typeB"
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it("Rejects an invalid response", () => {
|
|
94
|
+
const validate = ajv.compile(schema);
|
|
95
|
+
expect(validate({
|
|
96
|
+
schema: {
|
|
97
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
98
|
+
"$id": "https://www.codifycli.com/get-resource-schema-data-schema.json",
|
|
99
|
+
"title": "Get Resource Schema",
|
|
100
|
+
"type": "object",
|
|
101
|
+
"properties": {
|
|
102
|
+
"plugin": {
|
|
103
|
+
"type": "string",
|
|
104
|
+
"description": "The plugin the resource is from"
|
|
105
|
+
},
|
|
106
|
+
"type": {
|
|
107
|
+
"type": "string",
|
|
108
|
+
"description": "The id/type of the resource"
|
|
109
|
+
},
|
|
110
|
+
"schema": {
|
|
111
|
+
"type": "object",
|
|
112
|
+
"description": "The JSON Schema validation schema for the resource."
|
|
113
|
+
},
|
|
114
|
+
"dependencies": {
|
|
115
|
+
"type": "array",
|
|
116
|
+
"items": {
|
|
117
|
+
"type": "string"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
})).to.be.false;
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
3
|
"$id": "https://www.codifycli.com/initialize-request-data-schema.json",
|
|
4
4
|
"title": "Initialize Request Schema Data",
|
|
5
5
|
"description": "Initialize the plugin",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import schema from './initialize-request-data-schema.json';
|
|
2
2
|
import {describe, expect, it} from 'vitest'
|
|
3
|
-
import
|
|
3
|
+
import Ajv from 'ajv'
|
|
4
4
|
|
|
5
|
-
const ajv = new
|
|
5
|
+
const ajv = new Ajv.default({
|
|
6
6
|
strict: true,
|
|
7
7
|
})
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
3
|
"$id": "https://www.codifycli.com/initialize-response-data-schema.json",
|
|
4
4
|
"title": "Initialize Request Schema Data",
|
|
5
5
|
"description": "Initialize the plugin",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import schema from './initialize-response-data-schema.json';
|
|
2
2
|
import {describe, expect, it} from 'vitest'
|
|
3
|
-
import
|
|
3
|
+
import Ajv from 'ajv'
|
|
4
4
|
|
|
5
|
-
const ajv = new
|
|
5
|
+
const ajv = new Ajv.default({
|
|
6
6
|
strict: true,
|
|
7
7
|
})
|
|
8
8
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import schema from './plan-request-data-schema.json';
|
|
2
2
|
import resourceSchema from '../resource-schema.json'
|
|
3
3
|
import { describe, it, expect } from 'vitest'
|
|
4
|
-
import
|
|
4
|
+
import Ajv from 'ajv'
|
|
5
5
|
|
|
6
|
-
const ajv = new
|
|
6
|
+
const ajv = new Ajv.default({
|
|
7
7
|
strict: true,
|
|
8
8
|
strictRequired: false,
|
|
9
9
|
})
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import schema from './plan-response-data-schema.json';
|
|
2
2
|
import resourceSchema from '../resource-schema.json'
|
|
3
3
|
import {describe, expect, it} from 'vitest'
|
|
4
|
-
import
|
|
4
|
+
import Ajv from 'ajv'
|
|
5
5
|
import addFormats from 'ajv-formats';
|
|
6
6
|
import {ParameterOperation, PlanResponseData, ResourceOperation} from "../types/index.js";
|
|
7
7
|
|
|
8
|
-
const ajv = new
|
|
8
|
+
const ajv = new Ajv.default({
|
|
9
9
|
strict: true,
|
|
10
10
|
})
|
|
11
11
|
addFormats.default(ajv);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import schema from './validate-response-data-schema.json';
|
|
2
2
|
import {describe, expect, it} from 'vitest'
|
|
3
|
-
import
|
|
3
|
+
import Ajv from 'ajv'
|
|
4
4
|
import addFormats from 'ajv-formats';
|
|
5
5
|
import {ValidateResponseData} from "../types/index.js";
|
|
6
6
|
|
|
7
|
-
const ajv = new
|
|
7
|
+
const ajv = new Ajv.default({
|
|
8
8
|
strict: true,
|
|
9
9
|
})
|
|
10
10
|
addFormats.default(ajv);
|
package/src/project-schema.json
CHANGED
package/src/resource-schema.json
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "https://www.codifycli.com/codify-schema.json",
|
|
4
|
+
"title": "JSON schema for Codify configuration files",
|
|
5
|
+
"type": "array",
|
|
6
|
+
"items": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"type": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Specifies the type of the config block. Ex: project, homebrew",
|
|
12
|
+
"pattern": "^[a-zA-Z][\\w-]+$"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"required": ["type"],
|
|
16
|
+
"allOf": [
|
|
17
|
+
{
|
|
18
|
+
"if": {
|
|
19
|
+
"properties": {
|
|
20
|
+
"type": { "enum": ["project"] }
|
|
21
|
+
},
|
|
22
|
+
"required": ["type"]
|
|
23
|
+
},
|
|
24
|
+
"then": {
|
|
25
|
+
"description": "Represents a project configuration block\nhttps://docs.codifycli.com/user-guide/codify-json/#project-configs",
|
|
26
|
+
"properties": {
|
|
27
|
+
"type": {},
|
|
28
|
+
"version": {
|
|
29
|
+
"description": "Specifies a CLI version constraint. An error will be throw if the CLI version is outside of the semver range",
|
|
30
|
+
"type": "string",
|
|
31
|
+
"pattern": "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+)?$"
|
|
32
|
+
},
|
|
33
|
+
"plugins": {
|
|
34
|
+
"description": "A list of third party plugins to include.",
|
|
35
|
+
"type": "object",
|
|
36
|
+
"patternProperties": {
|
|
37
|
+
".*": {
|
|
38
|
+
"type": "string"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"description": {
|
|
43
|
+
"description": "An optional description of the project. This value is not applied.",
|
|
44
|
+
"type": "string"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"additionalProperties": false
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"if": {
|
|
52
|
+
"not": {
|
|
53
|
+
"properties": {
|
|
54
|
+
"type": {
|
|
55
|
+
"enum": ["project"]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"required": ["type"]
|
|
60
|
+
},
|
|
61
|
+
"then": {
|
|
62
|
+
"description": "Represents a resource configuration block\nhttps://docs.codifycli.com/user-guide/codify-json/#resource-configs",
|
|
63
|
+
"properties": {
|
|
64
|
+
"name": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"pattern": "^[\\w-]+$",
|
|
67
|
+
"description": "Optionally specify a name. Useful for specifying multiple resources of the same type"
|
|
68
|
+
},
|
|
69
|
+
"dependsOn": {
|
|
70
|
+
"type": "array",
|
|
71
|
+
"items": {
|
|
72
|
+
"type": "string"
|
|
73
|
+
},
|
|
74
|
+
"uniqueItems": true,
|
|
75
|
+
"description": "Specify resource dependencies. Must be the type or id of another resource"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"additionalProperties": true
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import schema from './codify-schema.json';
|
|
2
|
+
import { describe, it, expect } from 'vitest'
|
|
3
|
+
import Ajv from 'ajv'
|
|
4
|
+
|
|
5
|
+
const ajv = new Ajv.default({
|
|
6
|
+
strict: true,
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
describe("Config file schema tests", () => {
|
|
10
|
+
it('Compiles', () => {
|
|
11
|
+
ajv.compile(schema);
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('And successfully validate blocks with type', () => {
|
|
15
|
+
const validator = ajv.compile(schema);
|
|
16
|
+
|
|
17
|
+
expect(validator([])).to.be.true;
|
|
18
|
+
|
|
19
|
+
expect(validator([
|
|
20
|
+
{
|
|
21
|
+
"type": "resource1",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"type": "resource2",
|
|
25
|
+
"name": "abc",
|
|
26
|
+
"prop1": {
|
|
27
|
+
"a": "b",
|
|
28
|
+
},
|
|
29
|
+
"prop2": "c"
|
|
30
|
+
}
|
|
31
|
+
])).to.be.true;
|
|
32
|
+
|
|
33
|
+
expect(validator([
|
|
34
|
+
{
|
|
35
|
+
"type": "resource1",
|
|
36
|
+
"dependsOn": [
|
|
37
|
+
"resource2"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
])).to.be.true;
|
|
41
|
+
|
|
42
|
+
expect(validator([
|
|
43
|
+
{
|
|
44
|
+
"type": "project",
|
|
45
|
+
"version": "0.0.1",
|
|
46
|
+
"description": "description",
|
|
47
|
+
}
|
|
48
|
+
])).to.be.true;
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('And errors on improper json', () => {
|
|
52
|
+
const validator = ajv.compile(schema);
|
|
53
|
+
|
|
54
|
+
expect(validator({
|
|
55
|
+
"a": {},
|
|
56
|
+
"b": {},
|
|
57
|
+
})).to.be.false;
|
|
58
|
+
|
|
59
|
+
expect(validator([
|
|
60
|
+
{
|
|
61
|
+
"type": "resource1"
|
|
62
|
+
},
|
|
63
|
+
"homebrew"
|
|
64
|
+
])).to.be.false;
|
|
65
|
+
|
|
66
|
+
expect(validator([
|
|
67
|
+
{
|
|
68
|
+
"type": "resource1"
|
|
69
|
+
},
|
|
70
|
+
{}
|
|
71
|
+
])).to.be.false;
|
|
72
|
+
|
|
73
|
+
expect(validator([
|
|
74
|
+
{
|
|
75
|
+
"type": "resource1",
|
|
76
|
+
"dependsOn": {}
|
|
77
|
+
}
|
|
78
|
+
])).to.be.false;
|
|
79
|
+
|
|
80
|
+
expect(validator([
|
|
81
|
+
{
|
|
82
|
+
"type": "project",
|
|
83
|
+
"additionalProperty": true
|
|
84
|
+
}
|
|
85
|
+
])).to.be.false;
|
|
86
|
+
})
|
|
87
|
+
})
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SpawnOptions } from "node:child_process";
|
|
2
|
-
import {
|
|
2
|
+
import {ErrorObject, JSONSchemaType} from "ajv";
|
|
3
3
|
|
|
4
4
|
export interface StringIndexedObject {
|
|
5
5
|
[x: string]: unknown;
|
|
@@ -79,6 +79,17 @@ export interface PlanResponseData {
|
|
|
79
79
|
}>
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
export interface GetResourceInfoRequestData {
|
|
83
|
+
type: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface GetResourceInfoResponseData {
|
|
87
|
+
plugin: string;
|
|
88
|
+
type: string;
|
|
89
|
+
schema?: Record<string, unknown>,
|
|
90
|
+
dependencies?: string[],
|
|
91
|
+
}
|
|
92
|
+
|
|
82
93
|
export interface ApplyRequestData {
|
|
83
94
|
planId?: string;
|
|
84
95
|
plan?: {
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://www.codifycli.com/get-resources-response-data-schema.json",
|
|
4
|
-
"title": "Get Resources Response Schema Data",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"resources": {
|
|
8
|
-
"type": "array",
|
|
9
|
-
"items": {
|
|
10
|
-
"type": "object",
|
|
11
|
-
"properties": {
|
|
12
|
-
"type": {
|
|
13
|
-
"$ref": "resource-schema.json#/properties/type"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"type": "array",
|
|
17
|
-
"items": {
|
|
18
|
-
"type": "string"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"required": ["type"]
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"required": ["resources"],
|
|
27
|
-
"additionalProperties": false
|
|
28
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import schema from './get-resources-response-data-schema.json';
|
|
2
|
-
import resourceSchema from '../resource-schema.json'
|
|
3
|
-
import { describe, it, expect } from 'vitest'
|
|
4
|
-
import Ajv2020 from 'ajv/dist/2020.js'
|
|
5
|
-
|
|
6
|
-
const ajv = new Ajv2020.default({
|
|
7
|
-
strict: true,
|
|
8
|
-
})
|
|
9
|
-
ajv.addSchema(resourceSchema);
|
|
10
|
-
|
|
11
|
-
describe('Get resources response data schema', () => {
|
|
12
|
-
it('compiles', () => {
|
|
13
|
-
ajv.compile(schema);
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it("requires a type field to be specified", () => {
|
|
17
|
-
const validate = ajv.compile(schema);
|
|
18
|
-
expect(validate({ resources: [
|
|
19
|
-
{
|
|
20
|
-
type: "typeA",
|
|
21
|
-
dependencies: [
|
|
22
|
-
"typeB"
|
|
23
|
-
]
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
type: "typeB"
|
|
27
|
-
}
|
|
28
|
-
]})).to.be.true;
|
|
29
|
-
|
|
30
|
-
expect(validate({
|
|
31
|
-
resources: [
|
|
32
|
-
{
|
|
33
|
-
type: "typeA",
|
|
34
|
-
dependencies: [
|
|
35
|
-
"typeB"
|
|
36
|
-
]
|
|
37
|
-
},
|
|
38
|
-
{}
|
|
39
|
-
]
|
|
40
|
-
})).to.be.false;
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
})
|