codify-schemas 1.0.70 → 1.0.72

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 CHANGED
@@ -10,6 +10,8 @@ import GetResourceInfoRequestDataSchema from './messages/get-resource-info-reque
10
10
  import GetResourceInfoResponseDataSchema from './messages/get-resource-info-response-data-schema.json';
11
11
  import ImportRequestDataSchema from './messages/import-request-data-schema.json';
12
12
  import ImportResponseDataSchema from './messages/import-response-data-schema.json';
13
+ import MatchRequestDataSchema from './messages/match-request-data-schema.json';
14
+ import MatchResponseDataSchema from './messages/match-response-data-schema.json';
13
15
  import PlanRequestDataSchema from './messages/plan-request-data-schema.json';
14
16
  import PlanResponseDataSchema from './messages/plan-response-data-schema.json';
15
17
  import ValidateRequestDataSchema from './messages/validate-request-data-schema.json';
@@ -18,6 +20,6 @@ import InitializeRequestDataSchema from './messages/initialize-request-data-sche
18
20
  import InitializeResponseDataSchema from './messages/initialize-response-data-schema.json';
19
21
  import SudoRequestDataSchema from './messages/sudo-request-data-schema.json';
20
22
  import SudoRequestResponseDataSchema from './messages/sudo-response-data-schema.json';
21
- export { ConfigFileSchema, ProjectSchema, ResourceSchema, IpcMessageSchema, IpcMessageV2Schema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, ImportRequestDataSchema, ImportResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
23
+ export { ConfigFileSchema, ProjectSchema, ResourceSchema, IpcMessageSchema, IpcMessageV2Schema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, ImportRequestDataSchema, ImportResponseDataSchema, MatchRequestDataSchema, MatchResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
22
24
  export * from './types/index.js';
23
25
  export * from './messages/commands.js';
package/dist/index.js CHANGED
@@ -10,6 +10,8 @@ import GetResourceInfoRequestDataSchema from './messages/get-resource-info-reque
10
10
  import GetResourceInfoResponseDataSchema from './messages/get-resource-info-response-data-schema.json' with { type: 'json' };
11
11
  import ImportRequestDataSchema from './messages/import-request-data-schema.json' with { type: 'json' };
12
12
  import ImportResponseDataSchema from './messages/import-response-data-schema.json' with { type: 'json' };
13
+ import MatchRequestDataSchema from './messages/match-request-data-schema.json' with { type: 'json' };
14
+ import MatchResponseDataSchema from './messages/match-response-data-schema.json' with { type: 'json' };
13
15
  import PlanRequestDataSchema from './messages/plan-request-data-schema.json' with { type: 'json' };
14
16
  import PlanResponseDataSchema from './messages/plan-response-data-schema.json' with { type: 'json' };
15
17
  import ValidateRequestDataSchema from './messages/validate-request-data-schema.json' with { type: 'json' };
@@ -18,7 +20,7 @@ import InitializeRequestDataSchema from './messages/initialize-request-data-sche
18
20
  import InitializeResponseDataSchema from './messages/initialize-response-data-schema.json' with { type: 'json' };
19
21
  import SudoRequestDataSchema from './messages/sudo-request-data-schema.json' with { type: 'json' };
20
22
  import SudoRequestResponseDataSchema from './messages/sudo-response-data-schema.json' with { type: 'json' };
21
- export { ConfigFileSchema, ProjectSchema, ResourceSchema, IpcMessageSchema, IpcMessageV2Schema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, ImportRequestDataSchema, ImportResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
23
+ export { ConfigFileSchema, ProjectSchema, ResourceSchema, IpcMessageSchema, IpcMessageV2Schema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, ImportRequestDataSchema, ImportResponseDataSchema, MatchRequestDataSchema, MatchResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
22
24
  export * from './types/index.js';
23
25
  export * from './messages/commands.js';
24
26
  //# 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":"AAAA,OAAO,gBAAgB,MAAM,2BAA2B,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AAC5E,OAAO,aAAa,MAAM,uBAAuB,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AACrE,OAAO,cAAc,MAAM,wBAAwB,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AACvE,OAAO,gBAAgB,MAAM,2BAA2B,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AAC5E,OAAO,kBAAkB,MAAM,8BAA8B,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AACjF,OAAO,sBAAsB,MAAM,2CAA2C,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AAClG,OAAO,uBAAuB,MAAM,4CAA4C,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AACpG,OAAO,uBAAuB,MAAM,4CAA4C,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AACpG,OAAO,gCAAgC,MAAM,uDAAuD,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AACxH,OAAO,iCAAiC,MAAM,wDAAwD,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAA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A8C,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AACxG,OAAO,0BAA0B,MAAM,+CAA+C,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AAC1G,OAAO,2BAA2B,MAAM,gDAAgD,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AAC5G,OAAO,4BAA4B,MAAM,iDAAiD,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AAC9G,OAAO,qBAAqB,MAAM,0CAA0C,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAC;AACjG,OAAO,6BAA6B,MAAM,2CAA2C,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAC;AAE1G,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,gCAAgC,EAChC,iCAAiC,EACjC,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,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"}
@@ -50,16 +50,7 @@
50
50
  }
51
51
  },
52
52
  "allowMultiple": {
53
- "type": "object",
54
- "properties": {
55
- "identifyingParameters": {
56
- "type": "array",
57
- "items": {
58
- "type": "string"
59
- }
60
- }
61
- },
62
- "required": ["identifyingParameters"]
53
+ "type": "boolean"
63
54
  }
64
55
  },
65
56
  "required": ["type", "plugin"]
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "https://www.codifycli.com/match-request-data-schema.json",
4
+ "title": "Match resources request data",
5
+ "type": "object",
6
+ "properties": {
7
+ "resource": {
8
+ "type": "object",
9
+ "properties": {
10
+ "core": {
11
+ "$ref": "resource-schema.json"
12
+ },
13
+ "parameters": {
14
+ "type": "object"
15
+ }
16
+ },
17
+ "required": ["core", "parameters"]
18
+ },
19
+ "array": {
20
+ "type": "array",
21
+ "items": {
22
+ "type": "object",
23
+ "properties": {
24
+ "core": {
25
+ "$ref": "resource-schema.json"
26
+ },
27
+ "parameters": {
28
+ "type": "object"
29
+ }
30
+ },
31
+ "required": ["core", "parameters"]
32
+ }
33
+ }
34
+ },
35
+ "required": ["resource", "array"]
36
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "https://www.codifycli.com/match-response-data-schema.json",
4
+ "title": "Match resources response data",
5
+ "type": "object",
6
+ "properties": {
7
+ "match": {
8
+ "type": "object",
9
+ "properties": {
10
+ "core": {
11
+ "$ref": "resource-schema.json"
12
+ },
13
+ "parameters": {
14
+ "type": "object"
15
+ }
16
+ },
17
+ "required": ["core", "parameters"]
18
+ }
19
+ },
20
+ "required": ["match"]
21
+ }
@@ -100,8 +100,22 @@ export interface GetResourceInfoResponseData {
100
100
  requiredParameters: string[] | null;
101
101
  preventImport?: boolean;
102
102
  };
103
- allowMultiple?: {
104
- identifyingParameters: string[];
103
+ allowMultiple: boolean;
104
+ }
105
+ export interface MatchRequestData {
106
+ resource: {
107
+ core: ResourceConfig;
108
+ parameters: Record<string, unknown>;
109
+ };
110
+ array: Array<{
111
+ core: ResourceConfig;
112
+ parameters: Record<string, unknown>;
113
+ }>;
114
+ }
115
+ export interface MatchResponseData {
116
+ match: {
117
+ core: ResourceConfig;
118
+ parameters: Record<string, unknown>;
105
119
  };
106
120
  }
107
121
  export interface ImportRequestData {
@@ -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,EA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,WAAW,QAGtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-schemas",
3
- "version": "1.0.70",
3
+ "version": "1.0.72",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -10,6 +10,8 @@ import GetResourceInfoRequestDataSchema from './messages/get-resource-info-reque
10
10
  import GetResourceInfoResponseDataSchema from './messages/get-resource-info-response-data-schema.json' with {type: 'json'}
11
11
  import ImportRequestDataSchema from './messages/import-request-data-schema.json' with {type: 'json'}
12
12
  import ImportResponseDataSchema from './messages/import-response-data-schema.json' with {type: 'json'}
13
+ import MatchRequestDataSchema from './messages/match-request-data-schema.json' with {type: 'json'}
14
+ import MatchResponseDataSchema from './messages/match-response-data-schema.json' with {type: 'json'}
13
15
  import PlanRequestDataSchema from './messages/plan-request-data-schema.json' with {type: 'json'}
14
16
  import PlanResponseDataSchema from './messages/plan-response-data-schema.json' with {type: 'json'}
15
17
  import ValidateRequestDataSchema from './messages/validate-request-data-schema.json' with {type: 'json'}
@@ -32,6 +34,8 @@ export {
32
34
  GetResourceInfoResponseDataSchema,
33
35
  ImportRequestDataSchema,
34
36
  ImportResponseDataSchema,
37
+ MatchRequestDataSchema,
38
+ MatchResponseDataSchema,
35
39
  PlanRequestDataSchema,
36
40
  PlanResponseDataSchema,
37
41
  ValidateRequestDataSchema,
@@ -50,16 +50,7 @@
50
50
  }
51
51
  },
52
52
  "allowMultiple": {
53
- "type": "object",
54
- "properties": {
55
- "identifyingParameters": {
56
- "type": "array",
57
- "items": {
58
- "type": "string"
59
- }
60
- }
61
- },
62
- "required": ["identifyingParameters"]
53
+ "type": "boolean"
63
54
  }
64
55
  },
65
56
  "required": ["type", "plugin"]
@@ -55,9 +55,7 @@ describe('Get resources response data schema', () => {
55
55
  preventImport: true,
56
56
  requiredParameters: ['plugin']
57
57
  },
58
- allowMultiple: {
59
- identifyingParameters: ['plugin']
60
- }
58
+ allowMultiple: true,
61
59
  })).to.be.true;
62
60
 
63
61
  expect(validate({
@@ -106,9 +104,7 @@ describe('Get resources response data schema', () => {
106
104
  preventImport: true,
107
105
  requiredParameters: ['plugin'],
108
106
  },
109
- allowMultiple: {
110
- requiredParameters: ['plugin']
111
- }
107
+ allowMultiple: false,
112
108
  }
113
109
  })
114
110
 
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "https://www.codifycli.com/match-request-data-schema.json",
4
+ "title": "Match resources request data",
5
+ "type": "object",
6
+ "properties": {
7
+ "resource": {
8
+ "type": "object",
9
+ "properties": {
10
+ "core": {
11
+ "$ref": "resource-schema.json"
12
+ },
13
+ "parameters": {
14
+ "type": "object"
15
+ }
16
+ },
17
+ "required": ["core", "parameters"]
18
+ },
19
+ "array": {
20
+ "type": "array",
21
+ "items": {
22
+ "type": "object",
23
+ "properties": {
24
+ "core": {
25
+ "$ref": "resource-schema.json"
26
+ },
27
+ "parameters": {
28
+ "type": "object"
29
+ }
30
+ },
31
+ "required": ["core", "parameters"]
32
+ }
33
+ }
34
+ },
35
+ "required": ["resource", "array"]
36
+ }
@@ -0,0 +1,86 @@
1
+ import schema from './match-request-data-schema.json';
2
+ import resourceSchema from '../resource-schema.json'
3
+ import { describe, it, expect } from 'vitest'
4
+ import Ajv from 'ajv'
5
+
6
+ const ajv = new Ajv({
7
+ strict: true,
8
+ strictRequired: false,
9
+ })
10
+ ajv.addSchema(resourceSchema);
11
+
12
+ describe('Matches request data schema', () => {
13
+ it('compiles', () => {
14
+ ajv.compile(schema);
15
+ })
16
+
17
+ it("Validates a correct request", () => {
18
+ const validate = ajv.compile(schema);
19
+ expect(validate({
20
+ resource: {
21
+ core: {
22
+ type: "type"
23
+ },
24
+ parameters: {
25
+ param1: 'a',
26
+ param2: 2
27
+ }
28
+ },
29
+ array: [
30
+ {
31
+ core: {
32
+ type: "type"
33
+ },
34
+ parameters: {
35
+ param1: 'a',
36
+ param2: 2
37
+ }
38
+ },
39
+ {
40
+ core: {
41
+ type: "type2"
42
+ },
43
+ parameters: {
44
+ param1: 'a',
45
+ param2: 2
46
+ }
47
+ }
48
+ ]
49
+ })).to.be.true;
50
+ })
51
+
52
+ it("Rejects an invalid request", () => {
53
+ const validate = ajv.compile(schema);
54
+ expect(validate({
55
+ resource: {
56
+ core: {
57
+ type: "type"
58
+ },
59
+ parameters: {
60
+ param1: 'a',
61
+ param2: 2
62
+ }
63
+ },
64
+ array: [
65
+ {
66
+ core: {
67
+ type: "type"
68
+ },
69
+ parameters: {
70
+ param1: 'a',
71
+ param2: 2
72
+ }
73
+ },
74
+ {
75
+ core: {
76
+ },
77
+ parameters: {
78
+ param1: 'a',
79
+ param2: 2
80
+ }
81
+ }
82
+ ]
83
+ })).to.be.false;
84
+ })
85
+
86
+ })
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "https://www.codifycli.com/match-response-data-schema.json",
4
+ "title": "Match resources response data",
5
+ "type": "object",
6
+ "properties": {
7
+ "match": {
8
+ "type": "object",
9
+ "properties": {
10
+ "core": {
11
+ "$ref": "resource-schema.json"
12
+ },
13
+ "parameters": {
14
+ "type": "object"
15
+ }
16
+ },
17
+ "required": ["core", "parameters"]
18
+ }
19
+ },
20
+ "required": ["match"]
21
+ }
@@ -0,0 +1,46 @@
1
+ import schema from './match-response-data-schema.json';
2
+ import resourceSchema from '../resource-schema.json'
3
+ import { describe, it, expect } from 'vitest'
4
+ import Ajv from 'ajv'
5
+
6
+ const ajv = new Ajv({
7
+ strict: true,
8
+ strictRequired: false,
9
+ })
10
+ ajv.addSchema(resourceSchema);
11
+
12
+ describe('Match response data schema', () => {
13
+ it('compiles', () => {
14
+ ajv.compile(schema);
15
+ })
16
+
17
+ it("Validates a correct response", () => {
18
+ const validate = ajv.compile(schema);
19
+ expect(validate({
20
+ match: {
21
+ core: {
22
+ type: "type"
23
+ },
24
+ parameters: {
25
+ param1: 'a',
26
+ param2: 2
27
+ }
28
+ }
29
+ })).to.be.true;
30
+ })
31
+
32
+ it("Rejects an invalid response", () => {
33
+ const validate = ajv.compile(schema);
34
+ expect(validate({
35
+ match: {
36
+ core: {
37
+ },
38
+ parameters: {
39
+ param1: 'a',
40
+ param2: 2
41
+ }
42
+ }
43
+ })).to.be.false;
44
+ })
45
+
46
+ })
@@ -104,20 +104,36 @@ export interface GetResourceInfoRequestData {
104
104
  export interface GetResourceInfoResponseData {
105
105
  plugin: string;
106
106
  type: string;
107
- schema?: Record<string, unknown>,
108
- dependencies?: string[],
107
+ schema?: Record<string, unknown>;
108
+ dependencies?: string[];
109
109
  /**
110
110
  * @deprecated: Use import and destroy instead.
111
111
  */
112
112
  import?: {
113
- requiredParameters: string[] | null,
113
+ requiredParameters: string[] | null;
114
114
  },
115
115
  importAndDestroy?: {
116
- requiredParameters: string[] | null,
117
- preventImport?: boolean,
116
+ requiredParameters: string[] | null;
117
+ preventImport?: boolean;
118
118
  },
119
- allowMultiple?: {
120
- identifyingParameters: string[]
119
+ allowMultiple: boolean;
120
+ }
121
+
122
+ export interface MatchRequestData {
123
+ resource: {
124
+ core: ResourceConfig;
125
+ parameters: Record<string, unknown>;
126
+ };
127
+ array: Array<{
128
+ core: ResourceConfig;
129
+ parameters: Record<string, unknown>;
130
+ }>
131
+ }
132
+
133
+ export interface MatchResponseData {
134
+ match: {
135
+ core: ResourceConfig;
136
+ parameters: Record<string, unknown>;
121
137
  }
122
138
  }
123
139
 
@@ -127,8 +143,8 @@ export interface ImportRequestData {
127
143
  }
128
144
 
129
145
  export interface ImportResponseData {
130
- request: ResourceJson
131
- result: Array<ResourceJson>,
146
+ request: ResourceJson;
147
+ result: Array<ResourceJson>;
132
148
  }
133
149
 
134
150
  export interface ApplyRequestData {