@geek-fun/serverlessinsight 0.0.6 → 0.2.0

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.
Files changed (63) hide show
  1. package/dist/package.json +24 -14
  2. package/dist/src/commands/deploy.js +2 -1
  3. package/dist/src/commands/destroy.js +10 -0
  4. package/dist/src/commands/index.js +28 -13
  5. package/dist/src/commands/template.js +26 -0
  6. package/dist/src/commands/validate.js +4 -5
  7. package/dist/src/common/actionContext.js +13 -7
  8. package/dist/src/common/base64.js +5 -0
  9. package/dist/src/common/constants.js +4 -0
  10. package/dist/src/common/iacHelper.js +48 -12
  11. package/dist/src/common/imsClient.js +52 -0
  12. package/dist/src/common/index.d.ts +4 -1
  13. package/dist/src/common/index.js +4 -1
  14. package/dist/src/common/providerEnum.js +11 -0
  15. package/dist/src/common/rosClient.js +92 -9
  16. package/dist/src/parser/databaseParser.js +33 -0
  17. package/dist/src/parser/eventParser.js +15 -0
  18. package/dist/src/parser/functionParser.js +20 -0
  19. package/dist/src/parser/index.d.ts +2 -0
  20. package/dist/src/parser/index.js +36 -0
  21. package/dist/src/parser/tagParser.js +10 -0
  22. package/dist/src/stack/deploy.js +57 -13
  23. package/dist/src/stack/index.d.ts +0 -2
  24. package/dist/src/stack/index.js +0 -16
  25. package/dist/src/stack/rfsStack/function.js +32 -0
  26. package/dist/src/stack/rfsStack/index.d.ts +9 -0
  27. package/dist/src/stack/rfsStack/index.js +39 -0
  28. package/dist/src/stack/rosStack/bootstrap.js +40 -0
  29. package/dist/src/stack/rosStack/database.js +314 -0
  30. package/dist/src/stack/rosStack/event.js +136 -0
  31. package/dist/src/stack/rosStack/function.js +108 -0
  32. package/dist/src/stack/rosStack/index.d.ts +7 -0
  33. package/dist/src/stack/rosStack/index.js +69 -0
  34. package/dist/src/stack/rosStack/stage.js +46 -0
  35. package/dist/src/stack/rosStack/tag.js +11 -0
  36. package/dist/src/stack/rosStack/vars.js +49 -0
  37. package/dist/src/types/assets.js +2 -0
  38. package/dist/src/types/domains/context.js +8 -0
  39. package/dist/src/types/domains/database.js +2 -0
  40. package/dist/src/types/domains/function.js +2 -0
  41. package/dist/src/types/domains/provider.js +2 -0
  42. package/dist/src/types/domains/tag.js +2 -0
  43. package/dist/src/types/domains/vars.js +2 -0
  44. package/dist/src/types/index.d.ts +44 -0
  45. package/dist/src/types/index.js +23 -0
  46. package/dist/src/validator/databaseSchema.js +83 -0
  47. package/dist/src/validator/eventSchema.js +41 -0
  48. package/dist/src/validator/functionSchema.js +45 -0
  49. package/dist/src/validator/iacSchema.js +42 -0
  50. package/dist/src/validator/index.d.ts +1 -0
  51. package/dist/src/validator/index.js +5 -0
  52. package/dist/src/validator/rootSchema.js +52 -0
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +24 -14
  55. package/samples/aliyun-poc-es.yml +30 -0
  56. package/samples/aliyun-poc-fc.yml +60 -0
  57. package/samples/aliyun-poc-rds.yml +24 -0
  58. package/samples/huawei-poc-fc.yml +60 -0
  59. package/dist/src/common/provider.js +0 -11
  60. package/dist/src/stack/iacSchema.js +0 -145
  61. package/dist/src/stack/iacStack.js +0 -146
  62. package/dist/src/stack/parse.js +0 -46
  63. /package/dist/src/{types.js → types/domains/event.js} +0 -0
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.functionSchema = void 0;
4
+ exports.functionSchema = {
5
+ $id: 'https://serverlessinsight.geekfun.club/schemas/functionschema.json',
6
+ type: 'object',
7
+ patternProperties: {
8
+ '.*': {
9
+ type: 'object',
10
+ properties: {
11
+ name: { type: 'string' },
12
+ runtime: {
13
+ type: 'string',
14
+ enum: [
15
+ 'nodejs20',
16
+ 'nodejs18',
17
+ 'nodejs16',
18
+ 'nodejs14',
19
+ 'nodejs12',
20
+ 'nodejs10',
21
+ 'nodejs8',
22
+ 'python3.10',
23
+ 'python3.9',
24
+ 'python3',
25
+ 'PHP 7.2',
26
+ 'Java 11',
27
+ '.NET Core 3.1',
28
+ 'Go 1.x',
29
+ ],
30
+ },
31
+ handler: { type: 'string' },
32
+ code: { type: 'string' },
33
+ memory: { type: 'number' },
34
+ timeout: { type: 'number' },
35
+ environment: {
36
+ type: 'object',
37
+ additionalProperties: {
38
+ type: ['string', 'number', 'boolean'],
39
+ },
40
+ },
41
+ },
42
+ additionalProperties: false,
43
+ },
44
+ },
45
+ };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.validateYaml = void 0;
7
+ const ajv_1 = __importDefault(require("ajv"));
8
+ const common_1 = require("../common");
9
+ const rootSchema_1 = require("./rootSchema");
10
+ const databaseSchema_1 = require("./databaseSchema");
11
+ const eventSchema_1 = require("./eventSchema");
12
+ const functionSchema_1 = require("./functionSchema");
13
+ class IacSchemaErrors extends Error {
14
+ constructor(errors) {
15
+ super(`Invalid yaml`);
16
+ this.schemaErrors = errors.map((error) => ({
17
+ instancePath: error.instancePath,
18
+ schemaPath: error.schemaPath,
19
+ message: error.message,
20
+ allowedValues: error.params?.allowedValues,
21
+ type: error.keyword,
22
+ }));
23
+ }
24
+ get errors() {
25
+ return this.schemaErrors;
26
+ }
27
+ }
28
+ const ajv = new ajv_1.default({ allowUnionTypes: true, strict: false, allErrors: true });
29
+ const validate = ajv
30
+ .addSchema(functionSchema_1.functionSchema)
31
+ .addSchema(eventSchema_1.eventSchema)
32
+ .addSchema(databaseSchema_1.databaseSchema)
33
+ .compile(rootSchema_1.rootSchema);
34
+ const validateYaml = (iacJson) => {
35
+ const valid = validate(iacJson);
36
+ if (!valid) {
37
+ common_1.logger.debug(`Invalid yaml: ${JSON.stringify(validate.errors)}`);
38
+ throw new IacSchemaErrors(validate.errors);
39
+ }
40
+ return true;
41
+ };
42
+ exports.validateYaml = validateYaml;
@@ -0,0 +1 @@
1
+ export { validateYaml } from './iacSchema';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateYaml = void 0;
4
+ var iacSchema_1 = require("./iacSchema");
5
+ Object.defineProperty(exports, "validateYaml", { enumerable: true, get: function () { return iacSchema_1.validateYaml; } });
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rootSchema = void 0;
4
+ exports.rootSchema = {
5
+ $id: 'https://serverlessinsight.geekfun.club/schemas/schema.json',
6
+ type: 'object',
7
+ properties: {
8
+ version: { type: 'string', enum: ['0.0.0', '0.0.1'] },
9
+ provider: {
10
+ type: 'object',
11
+ properties: {
12
+ name: { type: 'string', enum: ['huawei', 'aliyun'] },
13
+ region: { type: 'string' },
14
+ },
15
+ },
16
+ service: { type: 'string' },
17
+ vars: {
18
+ type: 'object',
19
+ additionalProperties: {
20
+ type: ['string', 'number', 'boolean'],
21
+ },
22
+ },
23
+ stages: {
24
+ type: 'object',
25
+ patternProperties: {
26
+ '.*': {
27
+ type: 'object',
28
+ additionalProperties: {
29
+ type: ['string', 'number', 'boolean'],
30
+ },
31
+ },
32
+ },
33
+ },
34
+ tags: {
35
+ type: 'object',
36
+ additionalProperties: {
37
+ type: ['string', 'number', 'boolean'],
38
+ },
39
+ },
40
+ functions: {
41
+ $ref: 'https://serverlessinsight.geekfun.club/schemas/functionschema.json',
42
+ },
43
+ events: {
44
+ $ref: 'https://serverlessinsight.geekfun.club/schemas/eventschema.json',
45
+ },
46
+ databases: {
47
+ $ref: 'https://serverlessinsight.geekfun.club/schemas/databaseschema.json',
48
+ },
49
+ },
50
+ required: ['version', 'provider', 'service'],
51
+ additionalProperties: false,
52
+ };
@@ -1 +1 @@
1
- {"root":["../src/index.ts","../src/types.ts","../src/commands/deploy.ts","../src/commands/index.ts","../src/commands/validate.ts","../src/common/actionContext.ts","../src/common/getVersion.ts","../src/common/iacHelper.ts","../src/common/index.ts","../src/common/logger.ts","../src/common/provider.ts","../src/common/rosClient.ts","../src/lang/index.ts","../src/stack/deploy.ts","../src/stack/iacSchema.ts","../src/stack/iacStack.ts","../src/stack/index.ts","../src/stack/parse.ts"],"version":"5.6.2"}
1
+ {"root":["../src/index.ts","../src/commands/deploy.ts","../src/commands/destroy.ts","../src/commands/index.ts","../src/commands/template.ts","../src/commands/validate.ts","../src/common/actionContext.ts","../src/common/base64.ts","../src/common/constants.ts","../src/common/getVersion.ts","../src/common/iacHelper.ts","../src/common/imsClient.ts","../src/common/index.ts","../src/common/logger.ts","../src/common/providerEnum.ts","../src/common/rosClient.ts","../src/lang/index.ts","../src/parser/databaseParser.ts","../src/parser/eventParser.ts","../src/parser/functionParser.ts","../src/parser/index.ts","../src/parser/tagParser.ts","../src/stack/deploy.ts","../src/stack/index.ts","../src/stack/rfsStack/function.ts","../src/stack/rfsStack/index.ts","../src/stack/rosStack/bootstrap.ts","../src/stack/rosStack/database.ts","../src/stack/rosStack/event.ts","../src/stack/rosStack/function.ts","../src/stack/rosStack/index.ts","../src/stack/rosStack/stage.ts","../src/stack/rosStack/tag.ts","../src/stack/rosStack/vars.ts","../src/types/assets.ts","../src/types/index.ts","../src/types/domains/context.ts","../src/types/domains/database.ts","../src/types/domains/event.ts","../src/types/domains/function.ts","../src/types/domains/provider.ts","../src/types/domains/tag.ts","../src/types/domains/vars.ts","../src/validator/databaseSchema.ts","../src/validator/eventSchema.ts","../src/validator/functionSchema.ts","../src/validator/iacSchema.ts","../src/validator/index.ts","../src/validator/rootSchema.ts"],"version":"5.7.2"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geek-fun/serverlessinsight",
3
- "version": "0.0.6",
3
+ "version": "0.2.0",
4
4
  "description": "Full life cycle cross providers serverless application management for your fast-growing business.",
5
5
  "homepage": "https://serverlessinsight.geekfun.club",
6
6
  "main": "dist/src/index.js",
@@ -49,35 +49,45 @@
49
49
  "function"
50
50
  ],
51
51
  "dependencies": {
52
+ "@alicloud/ims20190815": "^2.1.4",
52
53
  "@alicloud/openapi-client": "^0.4.12",
53
54
  "@alicloud/ros-cdk-apigateway": "^1.4.0",
54
55
  "@alicloud/ros-cdk-core": "^1.4.0",
56
+ "@alicloud/ros-cdk-elasticsearchserverless": "^1.4.0",
55
57
  "@alicloud/ros-cdk-fc3": "^1.4.0",
58
+ "@alicloud/ros-cdk-oss": "^1.4.0",
59
+ "@alicloud/ros-cdk-ossdeployment": "^1.4.0",
56
60
  "@alicloud/ros-cdk-ram": "^1.4.0",
57
- "@alicloud/ros20190910": "^3.5.0",
61
+ "@alicloud/ros-cdk-rds": "^1.5.0",
62
+ "@alicloud/ros-cdk-sls": "^1.5.0",
63
+ "@alicloud/ros20190910": "^3.5.2",
58
64
  "ajv": "^8.17.1",
65
+ "ali-oss": "^6.22.0",
59
66
  "chalk": "^5.3.0",
60
67
  "commander": "^12.1.0",
61
68
  "i18n": "^0.15.1",
62
- "pino": "^9.4.0",
63
- "pino-pretty": "^11.2.2",
64
- "yaml": "^2.5.1"
69
+ "lodash": "^4.17.21",
70
+ "pino": "^9.5.0",
71
+ "pino-pretty": "^13.0.0",
72
+ "yaml": "^2.6.1"
65
73
  },
66
74
  "devDependencies": {
75
+ "@types/ali-oss": "^6.16.11",
67
76
  "@types/i18n": "^0.13.12",
68
- "@types/jest": "^29.5.13",
69
- "@types/node": "^22.7.4",
70
- "@typescript-eslint/eslint-plugin": "^8.8.0",
71
- "@typescript-eslint/parser": "^8.8.0",
72
- "eslint": "^8.57.1",
77
+ "@types/jest": "^29.5.14",
78
+ "@types/lodash": "^4.17.13",
79
+ "@types/node": "^22.10.1",
80
+ "@typescript-eslint/eslint-plugin": "^8.17.0",
81
+ "@typescript-eslint/parser": "^8.17.0",
82
+ "eslint": "^9.16.0",
73
83
  "eslint-config-prettier": "^9.1.0",
74
84
  "eslint-plugin-prettier": "^5.2.1",
75
- "globals": "^15.9.0",
76
- "husky": "^9.1.6",
85
+ "globals": "^15.13.0",
86
+ "husky": "^9.1.7",
77
87
  "jest": "^29.7.0",
78
- "prettier": "^3.3.3",
88
+ "prettier": "^3.4.2",
79
89
  "ts-jest": "^29.2.5",
80
90
  "ts-node": "^10.9.2",
81
- "typescript": "^5.6.2"
91
+ "typescript": "^5.7.2"
82
92
  }
83
93
  }
@@ -0,0 +1,30 @@
1
+ version: 0.0.1
2
+
3
+ provider:
4
+ name: aliyun
5
+ region: cn-chengdu
6
+
7
+
8
+ service: insight-db-poc
9
+
10
+ tags:
11
+ owner: geek-fun
12
+
13
+ databases:
14
+ # insight_es_db:
15
+ # name: insight-poc-es
16
+ # type: ELASTICSEARCH_SERVERLESS
17
+ # version: '7.10'
18
+ # engine_mode: SEARCH
19
+ # cu: 1
20
+ # storage_size: 20
21
+ # security:
22
+ # basic_auth:
23
+ # password: 'U34I6InQ8elseTgqTWT2t2oFXpoqFg'
24
+ insight_poc_db:
25
+ name: insight-poc-rds
26
+ type: RDS_PGSQL_SERVERLESS
27
+ version: PGSQL_16
28
+ security:
29
+ basic_auth:
30
+ password: 'U34I6InQ8elseTgqTWT2t2oFXpoqFg'
@@ -0,0 +1,60 @@
1
+ version: 0.0.1
2
+ provider:
3
+ name: aliyun
4
+ region: cn-chengdu
5
+
6
+ vars:
7
+ region: cn-hangzhou
8
+ testv: testVarValue
9
+ handler: index.handler
10
+
11
+ stages:
12
+ default:
13
+ region: ${vars.region}
14
+ node_env: default
15
+ dev:
16
+ region: ${vars.region}
17
+ node_env: development
18
+ prod:
19
+ region: cn-shanghai
20
+
21
+ service: insight-poc
22
+
23
+ tags:
24
+ owner: geek-fun
25
+
26
+ functions:
27
+ insight_poc_fn:
28
+ name: insight-poc-fn
29
+ runtime: nodejs18
30
+ handler: ${vars.handler}
31
+ code: tests/fixtures/artifacts/artifact.zip
32
+ memory: 512
33
+ timeout: 10
34
+ environment:
35
+ NODE_ENV: ${stages.node_env}
36
+ TEST_VAR: ${vars.testv}
37
+ TEST_VAR_EXTRA: abcds-${vars.testv}-andyou
38
+
39
+ databases:
40
+ insight_poc_db:
41
+ name: insight-poc-db
42
+ type: RDS_POSTGRESQL_SERVERLESS
43
+ version: '17.0'
44
+ security:
45
+ basic_auth:
46
+ password: 'U34I6InQ8elseTgqTWT2t2oFXpoqFg'
47
+
48
+ events:
49
+ gateway_event:
50
+ type: API_GATEWAY
51
+ name: insight-poc-gateway
52
+ triggers:
53
+ - method: GET
54
+ path: /api/hello
55
+ backend: ${functions.insight_poc_fn}
56
+ # custom_domain:
57
+ # domain_name: test.com
58
+ # certificate_name: test
59
+ # certificate_private_key: test
60
+ # certificate_body: test
@@ -0,0 +1,24 @@
1
+ version: 0.0.1
2
+
3
+ provider:
4
+ name: aliyun
5
+ region: cn-chengdu
6
+
7
+
8
+ service: insight-rds-poc
9
+
10
+ tags:
11
+ owner: geek-fun
12
+
13
+ databases:
14
+ insight_poc_db:
15
+ name: insight-poc-rds
16
+ type: RDS_PGSQL_SERVERLESS
17
+ version: PGSQL_16
18
+ security:
19
+ basic_auth:
20
+ master_user: 'db_root'
21
+ password: 'U34I6InQ8elseTgqTWT2t2oFXpoqFg'
22
+ network:
23
+ type: 'PRIVATE'
24
+
@@ -0,0 +1,60 @@
1
+ version: 0.0.1
2
+ provider:
3
+ name: huawei
4
+ region: cn-north-4
5
+
6
+ vars:
7
+ testv: testVarValue
8
+ handler: index.handler
9
+
10
+ stages:
11
+ default:
12
+ node_env: default
13
+ dev:
14
+ region: ${vars.region}
15
+ node_env: development
16
+ prod:
17
+ node_env: prod
18
+ service: insight-poc
19
+
20
+ tags:
21
+ owner: geek-fun
22
+
23
+ functions:
24
+ insight_poc_fn:
25
+ name: insight-poc-fn
26
+ runtime: nodejs18
27
+ handler: ${vars.handler}
28
+ code: tests/fixtures/artifacts/artifact.zip
29
+ memory: 512
30
+ timeout: 10
31
+ environment:
32
+ NODE_ENV: ${stages.node_env}
33
+ TEST_VAR: ${vars.testv}
34
+ TEST_VAR_EXTRA: abcds-${vars.testv}-andyou
35
+
36
+ #databases:
37
+ # insight_es_db:
38
+ # name: insight-poc-es
39
+ # type: ELASTICSEARCH_SERVERLESS
40
+ # version: 7.10
41
+ # engine_mode: SEARCH
42
+ # security:
43
+ # basic_auth:
44
+ # password: 123456
45
+ # cu: 1
46
+ # storage_size: 20
47
+
48
+ events:
49
+ gateway_event:
50
+ type: API_GATEWAY
51
+ name: insight-poc-gateway
52
+ triggers:
53
+ - method: GET
54
+ path: /api/hello
55
+ backend: ${functions.insight_poc_fn}
56
+ # custom_domain:
57
+ # domain_name: test.com
58
+ # certificate_name: test
59
+ # certificate_private_key: test
60
+ # certificate_body: test
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROVIDER = void 0;
4
- var PROVIDER;
5
- (function (PROVIDER) {
6
- PROVIDER["HUAWEI"] = "HUAWEI";
7
- PROVIDER["ALIBABA"] = "ALIBABA";
8
- // TENCENT = 'TENCENT',
9
- // AWS = 'AZURE',
10
- // AZURE = 'AZURE',
11
- })(PROVIDER || (exports.PROVIDER = PROVIDER = {}));
@@ -1,145 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateYaml = void 0;
7
- const ajv_1 = __importDefault(require("ajv"));
8
- const common_1 = require("../common");
9
- const ajv = new ajv_1.default({ allowUnionTypes: true, strict: false, allErrors: true });
10
- const schema = {
11
- type: 'object',
12
- properties: {
13
- version: { type: 'string', enum: ['0.0.0', '0.0.1'] },
14
- provider: { type: 'string', enum: ['aliyun', 'huawei'] },
15
- service: { type: 'string' },
16
- vars: {
17
- type: 'object',
18
- additionalProperties: {
19
- type: ['string', 'number', 'boolean'],
20
- },
21
- },
22
- stages: {
23
- type: 'object',
24
- patternProperties: {
25
- '.*': {
26
- type: 'object',
27
- additionalProperties: {
28
- type: ['string', 'number', 'boolean'],
29
- },
30
- },
31
- },
32
- },
33
- tags: {
34
- type: 'object',
35
- additionalProperties: {
36
- type: ['string', 'number', 'boolean'],
37
- },
38
- },
39
- functions: {
40
- type: 'object',
41
- patternProperties: {
42
- '.*': {
43
- type: 'object',
44
- properties: {
45
- name: { type: 'string' },
46
- runtime: {
47
- type: 'string',
48
- enum: [
49
- 'nodejs20',
50
- 'nodejs18',
51
- 'nodejs16',
52
- 'nodejs14',
53
- 'nodejs12',
54
- 'nodejs10',
55
- 'nodejs8',
56
- 'python3.10',
57
- 'python3.9',
58
- 'python3',
59
- 'PHP 7.2',
60
- 'Java 11',
61
- '.NET Core 3.1',
62
- 'Go 1.x',
63
- ],
64
- },
65
- handler: { type: 'string' },
66
- code: { type: 'string' },
67
- memory: { type: 'number' },
68
- timeout: { type: 'number' },
69
- environment: {
70
- type: 'object',
71
- additionalProperties: {
72
- type: ['string', 'number', 'boolean'],
73
- },
74
- },
75
- },
76
- additionalProperties: false,
77
- },
78
- },
79
- },
80
- events: {
81
- type: 'object',
82
- patternProperties: {
83
- '.*': {
84
- type: 'object',
85
- properties: {
86
- name: { type: 'string' },
87
- type: { type: 'string', enum: ['API_GATEWAY'] },
88
- triggers: {
89
- type: 'array',
90
- items: {
91
- method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE', 'ANY'] },
92
- path: { type: 'string' },
93
- backend: { type: 'string' },
94
- required: ['method', 'path', 'backend'],
95
- },
96
- },
97
- custom_domain: {
98
- type: 'object',
99
- properties: {
100
- domain_name: { type: 'string' },
101
- certificate_name: { type: 'string' },
102
- certificate_body: { type: 'string' },
103
- certificate_private_key: { type: 'string' },
104
- },
105
- required: [
106
- 'domain_name',
107
- 'certificate_name',
108
- 'certificate_body',
109
- 'certificate_private_key',
110
- ],
111
- },
112
- },
113
- required: ['name', 'type', 'triggers'],
114
- },
115
- },
116
- },
117
- },
118
- required: ['version', 'provider', 'service'],
119
- additionalProperties: false,
120
- };
121
- class IacSchemaErrors extends Error {
122
- constructor(errors) {
123
- super(`Invalid yaml`);
124
- this.schemaErrors = errors.map((error) => ({
125
- instancePath: error.instancePath,
126
- schemaPath: error.schemaPath,
127
- message: error.message,
128
- allowedValues: error.params?.allowedValues,
129
- type: error.keyword,
130
- }));
131
- }
132
- get errors() {
133
- return this.schemaErrors;
134
- }
135
- }
136
- const validateYaml = (iacJson) => {
137
- const validate = ajv.compile(schema);
138
- const valid = validate(iacJson);
139
- if (!valid) {
140
- common_1.logger.debug(`Invalid yaml: ${JSON.stringify(validate.errors)}`);
141
- throw new IacSchemaErrors(validate.errors);
142
- }
143
- return true;
144
- };
145
- exports.validateYaml = validateYaml;