codify-schemas 1.0.60 → 1.0.61

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
@@ -270,9 +270,12 @@ declare const ImportRequestDataSchema: {
270
270
  title: string;
271
271
  type: string;
272
272
  properties: {
273
- config: {
273
+ core: {
274
274
  $ref: string;
275
275
  };
276
+ parameters: {
277
+ type: string;
278
+ };
276
279
  };
277
280
  required: string[];
278
281
  };
@@ -283,12 +286,28 @@ declare const ImportResponseDataSchema: {
283
286
  type: string;
284
287
  properties: {
285
288
  request: {
286
- $ref: string;
289
+ type: string;
290
+ properties: {
291
+ core: {
292
+ $ref: string;
293
+ };
294
+ parameters: {
295
+ type: string;
296
+ };
297
+ };
287
298
  };
288
299
  result: {
289
300
  type: string;
290
301
  items: {
291
- $ref: string;
302
+ type: string;
303
+ properties: {
304
+ core: {
305
+ $ref: string;
306
+ };
307
+ parameters: {
308
+ type: string;
309
+ };
310
+ };
292
311
  };
293
312
  };
294
313
  };
@@ -300,11 +319,16 @@ declare const PlanRequestDataSchema: {
300
319
  title: string;
301
320
  type: string;
302
321
  properties: {
303
- desired: {
322
+ core: {
304
323
  $ref: string;
305
324
  };
325
+ desired: {
326
+ type: string;
327
+ description: string;
328
+ };
306
329
  state: {
307
- $ref: string;
330
+ type: string;
331
+ description: string;
308
332
  };
309
333
  isStateful: {
310
334
  type: string;
@@ -382,7 +406,15 @@ declare const ValidateRequestDataSchema: {
382
406
  configs: {
383
407
  type: string;
384
408
  items: {
385
- $ref: string;
409
+ type: string;
410
+ properties: {
411
+ core: {
412
+ $ref: string;
413
+ };
414
+ parameters: {
415
+ type: string;
416
+ };
417
+ };
386
418
  };
387
419
  };
388
420
  };
@@ -4,9 +4,12 @@
4
4
  "title": "Import Request Schema Data",
5
5
  "type": "object",
6
6
  "properties": {
7
- "config": {
7
+ "core": {
8
8
  "$ref": "resource-schema.json"
9
+ },
10
+ "parameters": {
11
+ "type": "object"
9
12
  }
10
13
  },
11
- "required": ["config"]
14
+ "required": ["core", "parameters"]
12
15
  }
@@ -5,12 +5,28 @@
5
5
  "type": "object",
6
6
  "properties": {
7
7
  "request": {
8
- "$ref": "resource-schema.json"
8
+ "type": "object",
9
+ "properties": {
10
+ "core": {
11
+ "$ref": "resource-schema.json"
12
+ },
13
+ "parameters": {
14
+ "type": "object"
15
+ }
16
+ }
9
17
  },
10
18
  "result": {
11
19
  "type": "array",
12
20
  "items": {
13
- "$ref": "resource-schema.json"
21
+ "type": "object",
22
+ "properties": {
23
+ "core": {
24
+ "$ref": "resource-schema.json"
25
+ },
26
+ "parameters": {
27
+ "type": "object"
28
+ }
29
+ }
14
30
  }
15
31
  }
16
32
  },
@@ -4,11 +4,16 @@
4
4
  "title": "Plan Request Schema Data",
5
5
  "type": "object",
6
6
  "properties": {
7
- "desired": {
7
+ "core": {
8
8
  "$ref": "resource-schema.json"
9
9
  },
10
+ "desired": {
11
+ "type": "object",
12
+ "description": "The desired parameters specified by the user. A null desired means this config was not specified (for deletes). Pass an empty object {} for no parameters."
13
+ },
10
14
  "state": {
11
- "$ref": "resource-schema.json"
15
+ "type": "object",
16
+ "description": "The desired parameters specified by the user. A null state means this config was not specified (non-stateful). Pass an empty object {} for no parameters."
12
17
  },
13
18
  "isStateful": {
14
19
  "type": "boolean",
@@ -17,7 +22,7 @@
17
22
  },
18
23
  "additionalProperties": false,
19
24
  "anyOf": [
20
- { "required": ["desired", "isStateful"] },
21
- { "required": ["state", "isStateful"] }
25
+ { "required": ["core", "desired", "isStateful"] },
26
+ { "required": ["core", "state", "isStateful"] }
22
27
  ]
23
28
  }
@@ -7,7 +7,15 @@
7
7
  "configs": {
8
8
  "type": "array",
9
9
  "items": {
10
- "$ref": "resource-schema.json"
10
+ "type": "object",
11
+ "properties": {
12
+ "core": {
13
+ "$ref": "resource-schema.json"
14
+ },
15
+ "parameters": {
16
+ "type": "object"
17
+ }
18
+ }
11
19
  }
12
20
  }
13
21
  },
@@ -31,8 +31,16 @@ export interface IpcMessageV2 {
31
31
  status?: MessageStatus;
32
32
  data: unknown | null;
33
33
  }
34
+ /**
35
+ * Processed resource that is in a format suitable for sending. The core parameters (such as type and name) and other parameters
36
+ * are separate for easier processing.
37
+ */
38
+ export interface ResourceJson {
39
+ core: ResourceConfig;
40
+ parameters: Record<string, unknown>;
41
+ }
34
42
  export interface ValidateRequestData {
35
- configs: ResourceConfig[];
43
+ configs: Array<ResourceJson>;
36
44
  }
37
45
  export interface ValidateResponseData {
38
46
  resourceValidations: Array<{
@@ -44,8 +52,9 @@ export interface ValidateResponseData {
44
52
  }>;
45
53
  }
46
54
  export interface PlanRequestData {
47
- desired: ResourceConfig | undefined;
48
- state: ResourceConfig | undefined;
55
+ core: ResourceConfig;
56
+ desired?: Record<string, unknown>;
57
+ state?: Record<string, unknown>;
49
58
  isStateful: boolean;
50
59
  }
51
60
  export declare enum ResourceOperation {
@@ -87,11 +96,12 @@ export interface GetResourceInfoResponseData {
87
96
  };
88
97
  }
89
98
  export interface ImportRequestData {
90
- config: ResourceConfig;
99
+ core: ResourceConfig;
100
+ parameters: Record<string, unknown>;
91
101
  }
92
102
  export interface ImportResponseData {
93
- request: ResourceConfig;
94
- result: ResourceConfig[];
103
+ request: ResourceJson;
104
+ result: Array<ResourceJson>;
95
105
  }
96
106
  export interface ApplyRequestData {
97
107
  planId?: string;
@@ -115,10 +125,7 @@ export interface ResourceDefinition {
115
125
  export interface InitializeRequestData {
116
126
  }
117
127
  export interface InitializeResponseData {
118
- resourceDefinitions: Array<{
119
- type: string;
120
- dependencies: string[];
121
- }>;
128
+ resourceDefinitions: Array<ResourceDefinition>;
122
129
  }
123
130
  export interface SudoRequestData {
124
131
  command: string;
@@ -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,CA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,EAHW,WAAW,KAAX,WAAW,QAGtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-schemas",
3
- "version": "1.0.60",
3
+ "version": "1.0.61",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -4,9 +4,12 @@
4
4
  "title": "Import Request Schema Data",
5
5
  "type": "object",
6
6
  "properties": {
7
- "config": {
7
+ "core": {
8
8
  "$ref": "resource-schema.json"
9
+ },
10
+ "parameters": {
11
+ "type": "object"
9
12
  }
10
13
  },
11
- "required": ["config"]
14
+ "required": ["core", "parameters"]
12
15
  }
@@ -17,30 +17,34 @@ describe('Import request data schema', () => {
17
17
  it("Validates correct data", () => {
18
18
  const validate = ajv.compile(schema);
19
19
  expect(validate({
20
- config: {
20
+ core: {
21
21
  type: "type"
22
22
  },
23
+ parameters: {},
23
24
  })).to.be.true;
24
25
  expect(validate({
25
- config: {
26
+ core: {
26
27
  type: "type",
27
28
  name: "name",
29
+ },
30
+ parameters: {
28
31
  propA: "a",
29
32
  propB: { a: 'b' }
30
33
  },
31
34
  })).to.be.true;
32
35
  expect(validate({
33
- config: {
36
+ core: {
34
37
  type: "type",
35
38
  dependsOn: ["a", "b"]
36
39
  },
40
+ parameters: {},
37
41
  })).to.be.true;
38
42
  })
39
43
 
40
44
  it("Errors on incorrect data", () => {
41
45
  const validate = ajv.compile(schema);
42
46
  expect(validate({
43
- config: {},
47
+ core: {},
44
48
  })).to.be.false;
45
49
  expect(validate({})).to.be.false;
46
50
  })
@@ -5,12 +5,28 @@
5
5
  "type": "object",
6
6
  "properties": {
7
7
  "request": {
8
- "$ref": "resource-schema.json"
8
+ "type": "object",
9
+ "properties": {
10
+ "core": {
11
+ "$ref": "resource-schema.json"
12
+ },
13
+ "parameters": {
14
+ "type": "object"
15
+ }
16
+ }
9
17
  },
10
18
  "result": {
11
19
  "type": "array",
12
20
  "items": {
13
- "$ref": "resource-schema.json"
21
+ "type": "object",
22
+ "properties": {
23
+ "core": {
24
+ "$ref": "resource-schema.json"
25
+ },
26
+ "parameters": {
27
+ "type": "object"
28
+ }
29
+ }
14
30
  }
15
31
  }
16
32
  },
@@ -4,11 +4,16 @@
4
4
  "title": "Plan Request Schema Data",
5
5
  "type": "object",
6
6
  "properties": {
7
- "desired": {
7
+ "core": {
8
8
  "$ref": "resource-schema.json"
9
9
  },
10
+ "desired": {
11
+ "type": "object",
12
+ "description": "The desired parameters specified by the user. A null desired means this config was not specified (for deletes). Pass an empty object {} for no parameters."
13
+ },
10
14
  "state": {
11
- "$ref": "resource-schema.json"
15
+ "type": "object",
16
+ "description": "The desired parameters specified by the user. A null state means this config was not specified (non-stateful). Pass an empty object {} for no parameters."
12
17
  },
13
18
  "isStateful": {
14
19
  "type": "boolean",
@@ -17,7 +22,7 @@
17
22
  },
18
23
  "additionalProperties": false,
19
24
  "anyOf": [
20
- { "required": ["desired", "isStateful"] },
21
- { "required": ["state", "isStateful"] }
25
+ { "required": ["core", "desired", "isStateful"] },
26
+ { "required": ["core", "state", "isStateful"] }
22
27
  ]
23
28
  }
@@ -17,23 +17,22 @@ describe('Plan request data schema', () => {
17
17
  it("It accepts either state, desired or both", () => {
18
18
  const validate = ajv.compile(schema);
19
19
  expect(validate({
20
- desired: {
21
- type: "type"
22
- },
20
+ core: { type: "type" },
21
+ desired: {},
23
22
  isStateful: false
24
23
  })).to.be.true;
25
24
  expect(validate({
26
- state: {
27
- type: "type"
28
- },
25
+ core: { type: "type" },
26
+ state: {},
29
27
  isStateful: false
30
28
  })).to.be.true;
31
29
  expect(validate({
30
+ core: { type: "type" },
32
31
  desired: {
33
- type: "type"
32
+ parameter1: 'a'
34
33
  },
35
34
  state: {
36
- type: "type"
35
+ parameter2: 'b'
37
36
  },
38
37
  isStateful: false
39
38
  })).to.be.true;
@@ -43,22 +42,34 @@ describe('Plan request data schema', () => {
43
42
  it ("name and type are alpha-numeric and follow variable naming conventions", () => {
44
43
  const validate = ajv.compile(schema);
45
44
  expect(validate({
46
- desired: { type: "a234abcDEF_-" },
45
+ core: { type: "a234abcDEF_-" },
46
+ desired: { },
47
47
  isStateful: false
48
48
  })).to.be.true;
49
+
49
50
  expect(validate({
51
+ core: { type: "234" },
50
52
  desired: { type: "234" },
51
53
  isStateful: false
52
54
  })).to.be.false;
55
+
53
56
  expect(validate({
54
- desired: { type: "ABCDEF$" },
57
+ core: { type: "ABCDEF$" },
58
+ desired: { },
55
59
  isStateful: false
56
60
  })).to.be.false;
57
61
 
58
62
  expect(validate({
59
- desired: { type: "type", name: "a234abcDEF_-" },
63
+ core: { type: "type", name: "a234abcDEF_-" },
64
+ desired: { },
60
65
  isStateful: false
61
66
  })).to.be.true;
67
+ expect(validate({
68
+ core: { type: "type", name: "ABCDEF$" },
69
+ desired: {},
70
+ isStateful: false
71
+ })).to.be.false;
72
+
62
73
  expect(validate({
63
74
  desired: { type: "type", name: "ABCDEF$" },
64
75
  isStateful: false
@@ -7,7 +7,15 @@
7
7
  "configs": {
8
8
  "type": "array",
9
9
  "items": {
10
- "$ref": "resource-schema.json"
10
+ "type": "object",
11
+ "properties": {
12
+ "core": {
13
+ "$ref": "resource-schema.json"
14
+ },
15
+ "parameters": {
16
+ "type": "object"
17
+ }
18
+ }
11
19
  }
12
20
  }
13
21
  },
@@ -38,8 +38,17 @@ export interface IpcMessageV2 {
38
38
  data: unknown | null;
39
39
  }
40
40
 
41
+ /**
42
+ * Processed resource that is in a format suitable for sending. The core parameters (such as type and name) and other parameters
43
+ * are separate for easier processing.
44
+ */
45
+ export interface ResourceJson {
46
+ core: ResourceConfig;
47
+ parameters: Record<string, unknown>;
48
+ }
49
+
41
50
  export interface ValidateRequestData {
42
- configs: ResourceConfig[];
51
+ configs: Array<ResourceJson>;
43
52
  }
44
53
 
45
54
  export interface ValidateResponseData {
@@ -53,8 +62,9 @@ export interface ValidateResponseData {
53
62
  }
54
63
 
55
64
  export interface PlanRequestData {
56
- desired: ResourceConfig | undefined
57
- state: ResourceConfig | undefined
65
+ core: ResourceConfig;
66
+ desired?: Record<string, unknown>;
67
+ state?: Record<string, unknown>;
58
68
  isStateful: boolean
59
69
  }
60
70
 
@@ -102,12 +112,13 @@ export interface GetResourceInfoResponseData {
102
112
  }
103
113
 
104
114
  export interface ImportRequestData {
105
- config: ResourceConfig;
115
+ core: ResourceConfig;
116
+ parameters: Record<string, unknown>;
106
117
  }
107
118
 
108
119
  export interface ImportResponseData {
109
- request: ResourceConfig;
110
- result: ResourceConfig[];
120
+ request: ResourceJson
121
+ result: Array<ResourceJson>,
111
122
  }
112
123
 
113
124
  export interface ApplyRequestData {
@@ -134,10 +145,7 @@ export interface ResourceDefinition {
134
145
  export interface InitializeRequestData {}
135
146
 
136
147
  export interface InitializeResponseData {
137
- resourceDefinitions: Array<{
138
- type: string;
139
- dependencies: string[];
140
- }>;
148
+ resourceDefinitions: Array<ResourceDefinition>;
141
149
  }
142
150
 
143
151
  export interface SudoRequestData {