codify-schemas 1.0.8 → 1.0.10
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/index.d.ts +1 -1
- package/dist/index.js +13 -45
- package/dist/index.js.map +1 -1
- package/dist/types/index.js +6 -9
- package/dist/types/index.js.map +1 -1
- package/package.json +4 -7
- package/src/config-file-schema.test.ts +8 -10
- package/src/index.ts +1 -1
- package/src/ipc-message-schema.test.ts +11 -12
- package/src/messages/get-resources-response-data-schema.test.ts +7 -6
- package/src/messages/plan-request-data-schema.test.ts +9 -10
- package/src/project-schema.test.ts +11 -11
- package/src/resource-meta-schema.test.ts +19 -20
- package/src/resource-schema.test.ts +13 -14
- package/tsconfig.json +2 -1
- package/.mocharc.json +0 -7
package/dist/index.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export { default as PlanRequestDataSchema } from './messages/plan-request-data-s
|
|
|
10
10
|
export { default as PlanResponseDataSchema } from './messages/plan-response-data-schema.json';
|
|
11
11
|
export { default as ValidateRequestDataSchema } from './messages/validate-request-data-schema.json';
|
|
12
12
|
export { default as ValidateResponseDataSchema } from './messages/validate-response-data-schema.json';
|
|
13
|
-
export * from './types';
|
|
13
|
+
export * from './types/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,46 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.ValidateResponseDataSchema = exports.ValidateRequestDataSchema = exports.PlanResponseDataSchema = exports.PlanRequestDataSchema = exports.ErrorResponseDataSchema = exports.ApplyResponseDataSchema = exports.ApplyRequestDataSchema = exports.IpcMessageSchema = exports.ResourceSchema = exports.ResourceMetaSchema = exports.ProjectSchema = exports.ConfigFileSchema = void 0;
|
|
21
|
-
var config_file_schema_json_1 = require("./config-file-schema.json");
|
|
22
|
-
Object.defineProperty(exports, "ConfigFileSchema", { enumerable: true, get: function () { return __importDefault(config_file_schema_json_1).default; } });
|
|
23
|
-
var project_schema_json_1 = require("./project-schema.json");
|
|
24
|
-
Object.defineProperty(exports, "ProjectSchema", { enumerable: true, get: function () { return __importDefault(project_schema_json_1).default; } });
|
|
25
|
-
var resource_meta_schema_json_1 = require("./resource-meta-schema.json");
|
|
26
|
-
Object.defineProperty(exports, "ResourceMetaSchema", { enumerable: true, get: function () { return __importDefault(resource_meta_schema_json_1).default; } });
|
|
27
|
-
var resource_schema_json_1 = require("./resource-schema.json");
|
|
28
|
-
Object.defineProperty(exports, "ResourceSchema", { enumerable: true, get: function () { return __importDefault(resource_schema_json_1).default; } });
|
|
29
|
-
var ipc_message_schema_json_1 = require("./ipc-message-schema.json");
|
|
30
|
-
Object.defineProperty(exports, "IpcMessageSchema", { enumerable: true, get: function () { return __importDefault(ipc_message_schema_json_1).default; } });
|
|
31
|
-
var apply_request_data_schema_json_1 = require("./messages/apply-request-data-schema.json");
|
|
32
|
-
Object.defineProperty(exports, "ApplyRequestDataSchema", { enumerable: true, get: function () { return __importDefault(apply_request_data_schema_json_1).default; } });
|
|
33
|
-
var apply_response_data_schema_json_1 = require("./messages/apply-response-data-schema.json");
|
|
34
|
-
Object.defineProperty(exports, "ApplyResponseDataSchema", { enumerable: true, get: function () { return __importDefault(apply_response_data_schema_json_1).default; } });
|
|
35
|
-
var error_response_data_schema_json_1 = require("./messages/error-response-data-schema.json");
|
|
36
|
-
Object.defineProperty(exports, "ErrorResponseDataSchema", { enumerable: true, get: function () { return __importDefault(error_response_data_schema_json_1).default; } });
|
|
37
|
-
var plan_request_data_schema_json_1 = require("./messages/plan-request-data-schema.json");
|
|
38
|
-
Object.defineProperty(exports, "PlanRequestDataSchema", { enumerable: true, get: function () { return __importDefault(plan_request_data_schema_json_1).default; } });
|
|
39
|
-
var plan_response_data_schema_json_1 = require("./messages/plan-response-data-schema.json");
|
|
40
|
-
Object.defineProperty(exports, "PlanResponseDataSchema", { enumerable: true, get: function () { return __importDefault(plan_response_data_schema_json_1).default; } });
|
|
41
|
-
var validate_request_data_schema_json_1 = require("./messages/validate-request-data-schema.json");
|
|
42
|
-
Object.defineProperty(exports, "ValidateRequestDataSchema", { enumerable: true, get: function () { return __importDefault(validate_request_data_schema_json_1).default; } });
|
|
43
|
-
var validate_response_data_schema_json_1 = require("./messages/validate-response-data-schema.json");
|
|
44
|
-
Object.defineProperty(exports, "ValidateResponseDataSchema", { enumerable: true, get: function () { return __importDefault(validate_response_data_schema_json_1).default; } });
|
|
45
|
-
__exportStar(require("./types"), exports);
|
|
1
|
+
export { default as ConfigFileSchema } from './config-file-schema.json';
|
|
2
|
+
export { default as ProjectSchema } from './project-schema.json';
|
|
3
|
+
export { default as ResourceMetaSchema } from './resource-meta-schema.json';
|
|
4
|
+
export { default as ResourceSchema } from './resource-schema.json';
|
|
5
|
+
export { default as IpcMessageSchema } from './ipc-message-schema.json';
|
|
6
|
+
export { default as ApplyRequestDataSchema } from './messages/apply-request-data-schema.json';
|
|
7
|
+
export { default as ApplyResponseDataSchema } from './messages/apply-response-data-schema.json';
|
|
8
|
+
export { default as ErrorResponseDataSchema } from './messages/error-response-data-schema.json';
|
|
9
|
+
export { default as PlanRequestDataSchema } from './messages/plan-request-data-schema.json';
|
|
10
|
+
export { default as PlanResponseDataSchema } from './messages/plan-response-data-schema.json';
|
|
11
|
+
export { default as ValidateRequestDataSchema } from './messages/validate-request-data-schema.json';
|
|
12
|
+
export { default as ValidateResponseDataSchema } from './messages/validate-response-data-schema.json';
|
|
13
|
+
export * from './types/index.js';
|
|
46
14
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAC9F,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,4CAA4C,CAAA;AAC/F,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAChG,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAC5F,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAC9F,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AACpG,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AACtG,cAAc,kBAAkB,CAAC"}
|
package/dist/types/index.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParameterOperation = exports.ResourceOperation = exports.MessageStatus = void 0;
|
|
4
|
-
var MessageStatus;
|
|
1
|
+
export var MessageStatus;
|
|
5
2
|
(function (MessageStatus) {
|
|
6
3
|
MessageStatus["SUCCESS"] = "success";
|
|
7
4
|
MessageStatus["ERROR"] = "error";
|
|
8
|
-
})(MessageStatus || (
|
|
9
|
-
var ResourceOperation;
|
|
5
|
+
})(MessageStatus || (MessageStatus = {}));
|
|
6
|
+
export var ResourceOperation;
|
|
10
7
|
(function (ResourceOperation) {
|
|
11
8
|
ResourceOperation["CREATE"] = "create";
|
|
12
9
|
ResourceOperation["DESTROY"] = "destroy";
|
|
13
10
|
ResourceOperation["MODIFY"] = "modify";
|
|
14
11
|
ResourceOperation["RECREATE"] = "recreate";
|
|
15
12
|
ResourceOperation["NOOP"] = "noop";
|
|
16
|
-
})(ResourceOperation || (
|
|
17
|
-
var ParameterOperation;
|
|
13
|
+
})(ResourceOperation || (ResourceOperation = {}));
|
|
14
|
+
export var ParameterOperation;
|
|
18
15
|
(function (ParameterOperation) {
|
|
19
16
|
ParameterOperation["ADD"] = "add";
|
|
20
17
|
ParameterOperation["REMOVE"] = "remove";
|
|
21
18
|
ParameterOperation["MODIFY"] = "modify";
|
|
22
19
|
ParameterOperation["NOOP"] = "noop";
|
|
23
|
-
})(ParameterOperation || (
|
|
20
|
+
})(ParameterOperation || (ParameterOperation = {}));
|
|
24
21
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAaA,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,gCAAe,CAAA;AACjB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAgBD,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"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codify-schemas",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"typings": "dist/index.d.ts",
|
|
7
8
|
"scripts": {
|
|
8
|
-
"test": "
|
|
9
|
+
"test": "vitest",
|
|
9
10
|
"prepublish": "tsc"
|
|
10
11
|
},
|
|
11
12
|
"keywords": [],
|
|
@@ -15,11 +16,7 @@
|
|
|
15
16
|
"ajv": "^8.12.0"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
|
-
"
|
|
19
|
-
"@types/mocha": "^10.0.6",
|
|
20
|
-
"chai": "^5.0.3",
|
|
21
|
-
"mocha": "^10.2.0",
|
|
22
|
-
"ts-node": "^10.9.2",
|
|
19
|
+
"vitest": "^1.4.0",
|
|
23
20
|
"typescript": "^5.3.3"
|
|
24
21
|
}
|
|
25
22
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Ajv2020 from "ajv/dist/2020";
|
|
2
2
|
import configSchema from './config-file-schema.json';
|
|
3
3
|
import resourceSchema from './resource-schema.json';
|
|
4
|
-
import
|
|
4
|
+
import { describe, it, expect } from 'vitest'
|
|
5
5
|
|
|
6
6
|
const ajv = new Ajv2020({
|
|
7
7
|
strict: true,
|
|
@@ -16,7 +16,7 @@ describe("config file schema tests", () => {
|
|
|
16
16
|
it('accepts resource blocks', () => {
|
|
17
17
|
const validator = ajv.compile(configSchema);
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
expect(validator([
|
|
20
20
|
{
|
|
21
21
|
"type": "resource1",
|
|
22
22
|
},
|
|
@@ -28,25 +28,23 @@ describe("config file schema tests", () => {
|
|
|
28
28
|
},
|
|
29
29
|
"prop2": "c"
|
|
30
30
|
}
|
|
31
|
-
])
|
|
31
|
+
])).to.be.true;
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
expect(validator([
|
|
34
34
|
{
|
|
35
35
|
"type": "resource1",
|
|
36
36
|
},
|
|
37
37
|
{}
|
|
38
|
-
])
|
|
38
|
+
])).to.be.false;
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
expect(validator([
|
|
41
41
|
{
|
|
42
42
|
"type": "project",
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
"type": "resource2"
|
|
46
46
|
}
|
|
47
|
-
])
|
|
48
|
-
|
|
47
|
+
])).to.be.true;
|
|
49
48
|
})
|
|
50
49
|
|
|
51
|
-
|
|
52
|
-
})
|
|
50
|
+
})
|
package/src/index.ts
CHANGED
|
@@ -10,4 +10,4 @@ export { default as PlanRequestDataSchema } from './messages/plan-request-data-s
|
|
|
10
10
|
export { default as PlanResponseDataSchema } from './messages/plan-response-data-schema.json';
|
|
11
11
|
export { default as ValidateRequestDataSchema } from './messages/validate-request-data-schema.json';
|
|
12
12
|
export { default as ValidateResponseDataSchema } from './messages/validate-response-data-schema.json';
|
|
13
|
-
export * from './types';
|
|
13
|
+
export * from './types/index.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Ajv2020 from "ajv/dist/2020";
|
|
2
|
-
import { describe, it } from 'mocha';
|
|
3
2
|
import schema from './ipc-message-schema.json';
|
|
4
|
-
import
|
|
3
|
+
import { describe, it, expect } from 'vitest'
|
|
5
4
|
|
|
6
5
|
const ajv = new Ajv2020({
|
|
7
6
|
strict: true,
|
|
@@ -14,24 +13,24 @@ describe("Ipc message schema tests", () => {
|
|
|
14
13
|
|
|
15
14
|
it("requires a cmd field to be specified", () => {
|
|
16
15
|
const validate = ajv.compile(schema);
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
expect(validate({ cmd: "doSomething", data: "data" })).to.be.true;
|
|
17
|
+
expect(validate({ data: "data" })).to.be.false;
|
|
19
18
|
})
|
|
20
19
|
|
|
21
20
|
it("has an optional status field for responses", () => {
|
|
22
21
|
const validate = ajv.compile(schema);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
expect(validate({ cmd: "doSomething", status: "success", data: "data" })).to.be.true;
|
|
23
|
+
expect(validate({ cmd: "doSomething", status: "error", data: "data" })).to.be.true;
|
|
24
|
+
expect(validate({ cmd: "doSomething", status: "other", data: "data" })).to.be.false;
|
|
25
|
+
expect(validate({ cmd: "doSomething", data: "data" })).to.be.true;
|
|
27
26
|
})
|
|
28
27
|
|
|
29
28
|
it ("accepts data or null", () => {
|
|
30
29
|
const validate = ajv.compile(schema);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
expect(validate({ cmd: "doSomething", data: "data" })).to.be.true;
|
|
31
|
+
expect(validate({ cmd: "doSomething", data: null })).to.be.true;
|
|
32
|
+
expect(validate({ cmd: "doSomething" })).to.be.false;
|
|
33
|
+
expect(validate({ cmd: "doSomething", data: {} })).to.be.true;
|
|
35
34
|
});
|
|
36
35
|
|
|
37
36
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Ajv2020 from "ajv/dist/2020";
|
|
2
2
|
import schema from './get-resources-response-data-schema.json';
|
|
3
3
|
import resourceSchema from '../resource-schema.json'
|
|
4
|
-
import {it} from
|
|
5
|
-
|
|
4
|
+
import { describe, it, expect } from 'vitest'
|
|
5
|
+
|
|
6
6
|
|
|
7
7
|
const ajv = new Ajv2020({
|
|
8
8
|
strict: true,
|
|
@@ -16,7 +16,7 @@ describe('Get resources response data schema', () => {
|
|
|
16
16
|
|
|
17
17
|
it("requires a type field to be specified", () => {
|
|
18
18
|
const validate = ajv.compile(schema);
|
|
19
|
-
|
|
19
|
+
expect(validate({ resources: [
|
|
20
20
|
{
|
|
21
21
|
type: "typeA",
|
|
22
22
|
dependencies: [
|
|
@@ -26,8 +26,9 @@ describe('Get resources response data schema', () => {
|
|
|
26
26
|
{
|
|
27
27
|
type: "typeB"
|
|
28
28
|
}
|
|
29
|
-
]})
|
|
30
|
-
|
|
29
|
+
]})).to.be.true;
|
|
30
|
+
|
|
31
|
+
expect(validate({
|
|
31
32
|
resources: [
|
|
32
33
|
{
|
|
33
34
|
type: "typeA",
|
|
@@ -37,7 +38,7 @@ describe('Get resources response data schema', () => {
|
|
|
37
38
|
},
|
|
38
39
|
{}
|
|
39
40
|
]
|
|
40
|
-
})
|
|
41
|
+
})).to.be.false;
|
|
41
42
|
})
|
|
42
43
|
|
|
43
44
|
})
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Ajv2020 from "ajv/dist/2020";
|
|
2
2
|
import schema from './plan-request-data-schema.json';
|
|
3
3
|
import resourceSchema from '../resource-schema.json'
|
|
4
|
-
import {it} from
|
|
5
|
-
import assert from "node:assert";
|
|
4
|
+
import { describe, it, expect } from 'vitest'
|
|
6
5
|
|
|
7
6
|
const ajv = new Ajv2020({
|
|
8
7
|
strict: true,
|
|
@@ -16,19 +15,19 @@ describe('Plan request data schema', () => {
|
|
|
16
15
|
|
|
17
16
|
it("requires a type field to be specified", () => {
|
|
18
17
|
const validate = ajv.compile(schema);
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
expect(validate({ type: "type" })).to.be.true;
|
|
19
|
+
expect(validate({})).to.be.false;
|
|
21
20
|
})
|
|
22
21
|
|
|
23
22
|
it ("name and type are alpha-numeric and follow variable naming conventions", () => {
|
|
24
23
|
const validate = ajv.compile(schema);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
expect(validate({ type: "a234abcDEF_-"})).to.be.true;
|
|
25
|
+
expect(validate({ type: "234"})).to.be.false;
|
|
26
|
+
expect(validate({ type: "ABCDEF$"})).to.be.false;
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
expect(validate({ type: "type", name: "a234abcDEF_-"})).to.be.true;
|
|
29
|
+
expect(validate({ type: "type", name: "234"})).to.be.false;
|
|
30
|
+
expect(validate({ type: "type", name: "ABCDEF$"})).to.be.false;
|
|
32
31
|
});
|
|
33
32
|
|
|
34
33
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Ajv2020 from "ajv/dist/2020";
|
|
2
2
|
import schema from './project-schema.json';
|
|
3
|
-
import
|
|
3
|
+
import { describe, it, expect } from 'vitest'
|
|
4
4
|
|
|
5
5
|
const ajv = new Ajv2020({
|
|
6
6
|
strict: true,
|
|
@@ -13,35 +13,35 @@ describe("project file schema tests", () => {
|
|
|
13
13
|
|
|
14
14
|
it("must have type project", () => {
|
|
15
15
|
const validator = ajv.compile(schema);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
expect(validator({ type: 'project' })).to.be.true;
|
|
17
|
+
expect(validator({})).to.be.false;
|
|
18
|
+
expect(validator({ type: 'resource' })).to.be.false;
|
|
19
19
|
})
|
|
20
20
|
|
|
21
21
|
it("plugins must be <string, string>", () => {
|
|
22
22
|
const validator = ajv.compile(schema);
|
|
23
|
-
|
|
23
|
+
expect(validator({
|
|
24
24
|
type: 'project',
|
|
25
25
|
plugins: {
|
|
26
26
|
"plugin1": "3.2.3"
|
|
27
27
|
}
|
|
28
|
-
})
|
|
28
|
+
})).to.be.true;
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
expect(validator({
|
|
31
31
|
type: 'project',
|
|
32
32
|
plugins: {
|
|
33
33
|
"plugin1": 1,
|
|
34
34
|
}
|
|
35
|
-
})
|
|
35
|
+
})).to.be.false;
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
expect(validator({
|
|
38
38
|
type: 'project',
|
|
39
39
|
plugins: {
|
|
40
40
|
"plugins2": "https://link.to.plugin.com"
|
|
41
41
|
}
|
|
42
|
-
})
|
|
42
|
+
})).to.be.true;
|
|
43
43
|
})
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
})
|
|
47
|
+
})
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Ajv2020 from "ajv/dist/2020";
|
|
2
|
-
import { describe, it } from 'mocha';
|
|
3
2
|
import schema from './resource-meta-schema.json';
|
|
4
3
|
import resourceSchema from './resource-schema.json';
|
|
5
|
-
import
|
|
4
|
+
import { describe, it, expect } from 'vitest'
|
|
6
5
|
|
|
7
6
|
const ajv = new Ajv2020({
|
|
8
7
|
strict: true,
|
|
@@ -16,7 +15,7 @@ describe("Resource meta schema tests", () => {
|
|
|
16
15
|
it("must have additional properties and $ref to resource-schema specified", () => {
|
|
17
16
|
const validate = ajv.compile(schema);
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
expect(validate({
|
|
20
19
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
21
20
|
"type": "object",
|
|
22
21
|
"properties": {
|
|
@@ -24,9 +23,9 @@ describe("Resource meta schema tests", () => {
|
|
|
24
23
|
"type": "string"
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
|
-
})
|
|
26
|
+
})).to.be.false;
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
expect(validate({
|
|
30
29
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
31
30
|
"type": "object",
|
|
32
31
|
"properties": {
|
|
@@ -34,15 +33,15 @@ describe("Resource meta schema tests", () => {
|
|
|
34
33
|
"type": "string"
|
|
35
34
|
}
|
|
36
35
|
},
|
|
37
|
-
"
|
|
36
|
+
"unevaluatedProperties": false,
|
|
38
37
|
"$ref": "https://www.codify.com/resource-schema.json"
|
|
39
|
-
})
|
|
38
|
+
})).to.be.true;
|
|
40
39
|
})
|
|
41
40
|
|
|
42
41
|
it("does not allow resource keywords to be specified", () => {
|
|
43
42
|
const validate = ajv.compile(schema);
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
expect(validate({
|
|
46
45
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
47
46
|
"type": "object",
|
|
48
47
|
"properties": {
|
|
@@ -50,11 +49,11 @@ describe("Resource meta schema tests", () => {
|
|
|
50
49
|
"type": "string"
|
|
51
50
|
}
|
|
52
51
|
},
|
|
53
|
-
"
|
|
52
|
+
"unevaluatedProperties": false,
|
|
54
53
|
"$ref": "https://www.codify.com/resource-schema.json"
|
|
55
|
-
})
|
|
54
|
+
})).to.be.false;
|
|
56
55
|
|
|
57
|
-
|
|
56
|
+
expect(validate({
|
|
58
57
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
59
58
|
"type": "object",
|
|
60
59
|
"properties": {
|
|
@@ -62,11 +61,11 @@ describe("Resource meta schema tests", () => {
|
|
|
62
61
|
"type": "string"
|
|
63
62
|
}
|
|
64
63
|
},
|
|
65
|
-
"
|
|
64
|
+
"unevaluatedProperties": false,
|
|
66
65
|
"$ref": "https://www.codify.com/resource-schema.json"
|
|
67
|
-
})
|
|
66
|
+
})).to.be.false;
|
|
68
67
|
|
|
69
|
-
|
|
68
|
+
expect(validate({
|
|
70
69
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
71
70
|
"type": "object",
|
|
72
71
|
"properties": {
|
|
@@ -74,9 +73,9 @@ describe("Resource meta schema tests", () => {
|
|
|
74
73
|
"type": "array"
|
|
75
74
|
}
|
|
76
75
|
},
|
|
77
|
-
"
|
|
76
|
+
"unevaluatedProperties": false,
|
|
78
77
|
"$ref": "https://www.codify.com/resource-schema.json"
|
|
79
|
-
})
|
|
78
|
+
})).to.be.false;
|
|
80
79
|
})
|
|
81
80
|
|
|
82
81
|
it("allows for schema composition with base resource schema", () => {
|
|
@@ -112,10 +111,10 @@ describe("Resource meta schema tests", () => {
|
|
|
112
111
|
});
|
|
113
112
|
|
|
114
113
|
const metaSchemaValidator = ajv.compile(resourceMetaSchema);
|
|
115
|
-
|
|
114
|
+
expect(metaSchemaValidator(propertySchema)).to.be.true;
|
|
116
115
|
|
|
117
116
|
const resourceValidator = ajv.compile(propertySchema);
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
expect(resourceValidator(resourceConfigValid)).to.be.true;
|
|
118
|
+
expect(resourceValidator(resourceConfigInvalid)).to.be.false;
|
|
120
119
|
})
|
|
121
|
-
});
|
|
120
|
+
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Ajv2020 from "ajv/dist/2020";
|
|
2
|
-
import { describe, it } from 'mocha';
|
|
3
2
|
import schema from './resource-schema.json';
|
|
4
|
-
import
|
|
3
|
+
import { describe, it, expect } from 'vitest'
|
|
5
4
|
|
|
6
5
|
const ajv = new Ajv2020({
|
|
7
6
|
strict: true,
|
|
@@ -14,26 +13,26 @@ describe("Resource schema tests", () => {
|
|
|
14
13
|
|
|
15
14
|
it("requires a type field to be specified", () => {
|
|
16
15
|
const validate = ajv.compile(schema);
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
expect(validate({ type: "type" })).to.be.true;
|
|
17
|
+
expect(validate({})).to.be.false;
|
|
19
18
|
})
|
|
20
19
|
|
|
21
20
|
it ("name and type are alpha-numeric and follow variable naming conventions", () => {
|
|
22
21
|
const validate = ajv.compile(schema);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
expect(validate({ type: "a234abcDEF_-"})).to.be.true;
|
|
23
|
+
expect(validate({ type: "234"})).to.be.false;
|
|
24
|
+
expect(validate({ type: "ABCDEF$"})).to.be.false;
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
expect(validate({ type: "type", name: "a234abcDEF_-"})).to.be.true;
|
|
27
|
+
expect(validate({ type: "type", name: "234"})).to.be.false;
|
|
28
|
+
expect(validate({ type: "type", name: "ABCDEF$"})).to.be.false;
|
|
30
29
|
});
|
|
31
30
|
|
|
32
31
|
it("dependsOn is an array of unique strings", () => {
|
|
33
32
|
const validate = ajv.compile(schema);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
expect(validate({ type: "type", dependsOn: ["item1", "item2"] })).to.be.true;
|
|
34
|
+
expect(validate({ type: "type", dependsOn: ["item1", "item1"] })).to.be.false;
|
|
35
|
+
expect(validate({ type: "type", dependsOn: "item1" })).to.be.false;
|
|
36
|
+
expect(validate({ type: "type", dependsOn: [6] })).to.be.false;
|
|
38
37
|
})
|
|
39
38
|
});
|
package/tsconfig.json
CHANGED