codify-schemas 1.0.49 → 1.0.50
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 +3 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/messages/import-request-data-schema.json +12 -0
- package/dist/messages/import-response-data-schema.json +18 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
- package/src/config-file-schema.test.ts +1 -1
- package/src/index.ts +4 -0
- package/src/ipc-message-schema.test.ts +1 -1
- package/src/messages/apply-request-data-schema.test.ts +1 -1
- package/src/messages/apply-response-data-schema.test.ts +1 -1
- package/src/messages/error-response-data-schema.test.ts +1 -1
- package/src/messages/get-resource-info-request-data-schema.test.ts +1 -1
- package/src/messages/get-resource-info-response-data-schema.test.ts +2 -1
- package/src/messages/import-request-data-schema.json +12 -0
- package/src/messages/import-request-data-schema.test.ts +48 -0
- package/src/messages/import-response-data-schema.json +18 -0
- package/src/messages/import-response-data-schema.test.ts +61 -0
- package/src/messages/initialize-request-data-schema.test.ts +1 -1
- package/src/messages/initialize-response-data-schema.test.ts +1 -1
- package/src/messages/plan-request-data-schema.test.ts +1 -1
- package/src/messages/plan-response-data-schema.test.ts +1 -1
- package/src/messages/sudo-request-data-schema.test.ts +1 -1
- package/src/messages/sudo-response-data-schema.test.ts +1 -1
- package/src/messages/validate-response-data-schema.test.ts +1 -1
- package/src/project-schema.test.ts +1 -1
- package/src/resource-schema.test.ts +1 -1
- package/src/schemastore/config-schema.test.ts +1 -1
- package/src/types/index.ts +10 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ import ApplyResponseDataSchema from './messages/apply-response-data-schema.json'
|
|
|
7
7
|
import ErrorResponseDataSchema from './messages/error-response-data-schema.json';
|
|
8
8
|
import GetResourceInfoRequestDataSchema from './messages/get-resource-info-request-data-schema.json';
|
|
9
9
|
import GetResourceInfoResponseDataSchema from './messages/get-resource-info-response-data-schema.json';
|
|
10
|
+
import ImportRequestDataSchema from './messages/import-request-data-schema.json';
|
|
11
|
+
import ImportResponseDataSchema from './messages/import-response-data-schema.json';
|
|
10
12
|
import PlanRequestDataSchema from './messages/plan-request-data-schema.json';
|
|
11
13
|
import PlanResponseDataSchema from './messages/plan-response-data-schema.json';
|
|
12
14
|
import ValidateRequestDataSchema from './messages/validate-request-data-schema.json';
|
|
@@ -15,6 +17,6 @@ import InitializeRequestDataSchema from './messages/initialize-request-data-sche
|
|
|
15
17
|
import InitializeResponseDataSchema from './messages/initialize-response-data-schema.json';
|
|
16
18
|
import SudoRequestDataSchema from './messages/sudo-request-data-schema.json';
|
|
17
19
|
import SudoRequestResponseDataSchema from './messages/sudo-response-data-schema.json';
|
|
18
|
-
export { ConfigFileSchema, ProjectSchema, ResourceSchema, IpcMessageSchema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
|
|
20
|
+
export { ConfigFileSchema, ProjectSchema, ResourceSchema, IpcMessageSchema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, ImportRequestDataSchema, ImportResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
|
|
19
21
|
export * from './types/index.js';
|
|
20
22
|
export * from './messages/commands.js';
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,8 @@ import ApplyResponseDataSchema from './messages/apply-response-data-schema.json'
|
|
|
7
7
|
import ErrorResponseDataSchema from './messages/error-response-data-schema.json' assert { type: 'json' };
|
|
8
8
|
import GetResourceInfoRequestDataSchema from './messages/get-resource-info-request-data-schema.json' assert { type: 'json' };
|
|
9
9
|
import GetResourceInfoResponseDataSchema from './messages/get-resource-info-response-data-schema.json' assert { type: 'json' };
|
|
10
|
+
import ImportRequestDataSchema from './messages/import-request-data-schema.json' assert { type: 'json' };
|
|
11
|
+
import ImportResponseDataSchema from './messages/import-response-data-schema.json' assert { type: 'json' };
|
|
10
12
|
import PlanRequestDataSchema from './messages/plan-request-data-schema.json' assert { type: 'json' };
|
|
11
13
|
import PlanResponseDataSchema from './messages/plan-response-data-schema.json' assert { type: 'json' };
|
|
12
14
|
import ValidateRequestDataSchema from './messages/validate-request-data-schema.json' assert { type: 'json' };
|
|
@@ -15,7 +17,7 @@ import InitializeRequestDataSchema from './messages/initialize-request-data-sche
|
|
|
15
17
|
import InitializeResponseDataSchema from './messages/initialize-response-data-schema.json' assert { type: 'json' };
|
|
16
18
|
import SudoRequestDataSchema from './messages/sudo-request-data-schema.json' assert { type: 'json' };
|
|
17
19
|
import SudoRequestResponseDataSchema from './messages/sudo-response-data-schema.json' assert { type: 'json' };
|
|
18
|
-
export { ConfigFileSchema, ProjectSchema, ResourceSchema, IpcMessageSchema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
|
|
20
|
+
export { ConfigFileSchema, ProjectSchema, ResourceSchema, IpcMessageSchema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, ImportRequestDataSchema, ImportResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
|
|
19
21
|
export * from './types/index.js';
|
|
20
22
|
export * from './messages/commands.js';
|
|
21
23
|
//# 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,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AAC9E,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,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BAA4B,EAC5B,qBAAqB,EACrB,6BAA6B,GAC9B,CAAA;AAED,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "https://www.codifycli.com/import-request-data-schema.json",
|
|
4
|
+
"title": "Import Request Schema Data",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"config": {
|
|
8
|
+
"$ref": "resource-schema.json"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"required": ["config"]
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "https://www.codifycli.com/import-response-data-schema.json",
|
|
4
|
+
"title": "Import Response Schema Data",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"request": {
|
|
8
|
+
"$ref": "resource-schema.json"
|
|
9
|
+
},
|
|
10
|
+
"result": {
|
|
11
|
+
"type": "array",
|
|
12
|
+
"items": {
|
|
13
|
+
"$ref": "resource-schema.json"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"required": ["request", "result"]
|
|
18
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -76,6 +76,13 @@ export interface GetResourceInfoResponseData {
|
|
|
76
76
|
schema?: Record<string, unknown>;
|
|
77
77
|
dependencies?: string[];
|
|
78
78
|
}
|
|
79
|
+
export interface ImportRequestData {
|
|
80
|
+
config: ResourceConfig;
|
|
81
|
+
}
|
|
82
|
+
export interface ImportResponseData {
|
|
83
|
+
request: ResourceConfig;
|
|
84
|
+
result: ResourceConfig;
|
|
85
|
+
}
|
|
79
86
|
export interface ApplyRequestData {
|
|
80
87
|
planId?: string;
|
|
81
88
|
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;AAuED,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,8BAAe,CAAA;AACjB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -7,6 +7,8 @@ import ApplyResponseDataSchema from './messages/apply-response-data-schema.json'
|
|
|
7
7
|
import ErrorResponseDataSchema from './messages/error-response-data-schema.json' assert {type: 'json'}
|
|
8
8
|
import GetResourceInfoRequestDataSchema from './messages/get-resource-info-request-data-schema.json' assert {type: 'json'}
|
|
9
9
|
import GetResourceInfoResponseDataSchema from './messages/get-resource-info-response-data-schema.json' assert {type: 'json'}
|
|
10
|
+
import ImportRequestDataSchema from './messages/import-request-data-schema.json' assert {type: 'json'}
|
|
11
|
+
import ImportResponseDataSchema from './messages/import-response-data-schema.json' assert {type: 'json'}
|
|
10
12
|
import PlanRequestDataSchema from './messages/plan-request-data-schema.json' assert {type: 'json'}
|
|
11
13
|
import PlanResponseDataSchema from './messages/plan-response-data-schema.json' assert {type: 'json'}
|
|
12
14
|
import ValidateRequestDataSchema from './messages/validate-request-data-schema.json' assert {type: 'json'}
|
|
@@ -26,6 +28,8 @@ export {
|
|
|
26
28
|
ErrorResponseDataSchema,
|
|
27
29
|
GetResourceInfoRequestDataSchema,
|
|
28
30
|
GetResourceInfoResponseDataSchema,
|
|
31
|
+
ImportRequestDataSchema,
|
|
32
|
+
ImportResponseDataSchema,
|
|
29
33
|
PlanRequestDataSchema,
|
|
30
34
|
PlanResponseDataSchema,
|
|
31
35
|
ValidateRequestDataSchema,
|
|
@@ -3,7 +3,7 @@ import { describe, it, expect } from 'vitest'
|
|
|
3
3
|
import Ajv from 'ajv'
|
|
4
4
|
import {GetResourceInfoResponseData} from "../types";
|
|
5
5
|
|
|
6
|
-
const ajv = new Ajv
|
|
6
|
+
const ajv = new Ajv({
|
|
7
7
|
strict: true,
|
|
8
8
|
})
|
|
9
9
|
|
|
@@ -54,6 +54,7 @@ describe('Get resources response data schema', () => {
|
|
|
54
54
|
plugin: 'core-plugin',
|
|
55
55
|
})).to.be.true;
|
|
56
56
|
|
|
57
|
+
// For testing the typescript type
|
|
57
58
|
const a: GetResourceInfoResponseData = {
|
|
58
59
|
type: 'type',
|
|
59
60
|
plugin: 'core-plugin',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "https://www.codifycli.com/import-request-data-schema.json",
|
|
4
|
+
"title": "Import Request Schema Data",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"config": {
|
|
8
|
+
"$ref": "resource-schema.json"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"required": ["config"]
|
|
12
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import schema from './import-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('Import request data schema', () => {
|
|
13
|
+
it('compiles', () => {
|
|
14
|
+
ajv.compile(schema);
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it("Validates correct data", () => {
|
|
18
|
+
const validate = ajv.compile(schema);
|
|
19
|
+
expect(validate({
|
|
20
|
+
config: {
|
|
21
|
+
type: "type"
|
|
22
|
+
},
|
|
23
|
+
})).to.be.true;
|
|
24
|
+
expect(validate({
|
|
25
|
+
config: {
|
|
26
|
+
type: "type",
|
|
27
|
+
name: "name",
|
|
28
|
+
propA: "a",
|
|
29
|
+
propB: { a: 'b' }
|
|
30
|
+
},
|
|
31
|
+
})).to.be.true;
|
|
32
|
+
expect(validate({
|
|
33
|
+
config: {
|
|
34
|
+
type: "type",
|
|
35
|
+
dependsOn: ["a", "b"]
|
|
36
|
+
},
|
|
37
|
+
})).to.be.true;
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it("Errors on incorrect data", () => {
|
|
41
|
+
const validate = ajv.compile(schema);
|
|
42
|
+
expect(validate({
|
|
43
|
+
config: {},
|
|
44
|
+
})).to.be.false;
|
|
45
|
+
expect(validate({})).to.be.false;
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "https://www.codifycli.com/import-response-data-schema.json",
|
|
4
|
+
"title": "Import Response Schema Data",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"request": {
|
|
8
|
+
"$ref": "resource-schema.json"
|
|
9
|
+
},
|
|
10
|
+
"result": {
|
|
11
|
+
"type": "array",
|
|
12
|
+
"items": {
|
|
13
|
+
"$ref": "resource-schema.json"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"required": ["request", "result"]
|
|
18
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import schema from './import-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('Import response data schema', () => {
|
|
13
|
+
it('compiles', () => {
|
|
14
|
+
ajv.compile(schema);
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it("Validates correct data", () => {
|
|
18
|
+
const validate = ajv.compile(schema);
|
|
19
|
+
expect(validate({
|
|
20
|
+
request: {
|
|
21
|
+
type: "type"
|
|
22
|
+
},
|
|
23
|
+
result: [{
|
|
24
|
+
type: "type"
|
|
25
|
+
}]
|
|
26
|
+
})).to.be.true;
|
|
27
|
+
expect(validate({
|
|
28
|
+
request: {
|
|
29
|
+
type: "type",
|
|
30
|
+
name: "name",
|
|
31
|
+
propA: "a",
|
|
32
|
+
propB: { a: 'b' }
|
|
33
|
+
},
|
|
34
|
+
result: [{
|
|
35
|
+
type: "type",
|
|
36
|
+
name: "name",
|
|
37
|
+
propA: "b",
|
|
38
|
+
propB: null,
|
|
39
|
+
}]
|
|
40
|
+
})).to.be.true;
|
|
41
|
+
expect(validate({
|
|
42
|
+
request: {
|
|
43
|
+
type: "type",
|
|
44
|
+
dependsOn: ["a", "b"]
|
|
45
|
+
},
|
|
46
|
+
result: [{
|
|
47
|
+
type: "type",
|
|
48
|
+
dependsOn: ["a", "b"]
|
|
49
|
+
}]
|
|
50
|
+
})).to.be.true;
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it("Errors on incorrect data", () => {
|
|
54
|
+
const validate = ajv.compile(schema);
|
|
55
|
+
expect(validate({
|
|
56
|
+
config: {},
|
|
57
|
+
})).to.be.false;
|
|
58
|
+
expect(validate({})).to.be.false;
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
})
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SpawnOptions } from "node:child_process";
|
|
2
|
-
import {ErrorObject
|
|
2
|
+
import { ErrorObject } from "ajv";
|
|
3
3
|
|
|
4
4
|
export interface StringIndexedObject {
|
|
5
5
|
[x: string]: unknown;
|
|
@@ -90,6 +90,15 @@ export interface GetResourceInfoResponseData {
|
|
|
90
90
|
dependencies?: string[],
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
export interface ImportRequestData {
|
|
94
|
+
config: ResourceConfig;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface ImportResponseData {
|
|
98
|
+
request: ResourceConfig;
|
|
99
|
+
result: ResourceConfig;
|
|
100
|
+
}
|
|
101
|
+
|
|
93
102
|
export interface ApplyRequestData {
|
|
94
103
|
planId?: string;
|
|
95
104
|
plan?: {
|