@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,136 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.resolveEvents = void 0;
37
+ const types_1 = require("../../types");
38
+ const ram = __importStar(require("@alicloud/ros-cdk-ram"));
39
+ const common_1 = require("../../common");
40
+ const agw = __importStar(require("@alicloud/ros-cdk-apigateway"));
41
+ const lodash_1 = require("lodash");
42
+ const resolveEvents = (scope, events, tags, context, service) => {
43
+ if ((0, lodash_1.isEmpty)(events)) {
44
+ return undefined;
45
+ }
46
+ const apiGateway = events.filter((event) => event.type === types_1.EventTypes.API_GATEWAY);
47
+ if (apiGateway?.length) {
48
+ const gatewayAccessRole = new ram.RosRole(scope, (0, common_1.replaceReference)(`${service}_role`, context), {
49
+ roleName: (0, common_1.replaceReference)(`${service}-gateway-access-role`, context),
50
+ description: (0, common_1.replaceReference)(`${service} role`, context),
51
+ assumeRolePolicyDocument: {
52
+ version: '1',
53
+ statement: [
54
+ {
55
+ action: 'sts:AssumeRole',
56
+ effect: 'Allow',
57
+ principal: {
58
+ service: ['apigateway.aliyuncs.com'],
59
+ },
60
+ },
61
+ ],
62
+ },
63
+ policies: [
64
+ {
65
+ policyName: (0, common_1.replaceReference)(`${service}-policy`, context),
66
+ policyDocument: {
67
+ version: '1',
68
+ statement: [
69
+ {
70
+ action: ['fc:InvokeFunction'],
71
+ effect: 'Allow',
72
+ // @TODO implement at least permission granting
73
+ resource: ['*'],
74
+ },
75
+ ],
76
+ },
77
+ },
78
+ ],
79
+ }, true);
80
+ const apiGatewayGroup = new agw.RosGroup(scope, (0, common_1.replaceReference)(`${service}_apigroup`, context), {
81
+ groupName: (0, common_1.replaceReference)(`${service}_apigroup`, context),
82
+ tags: (0, common_1.replaceReference)(tags, context),
83
+ passthroughHeaders: 'host',
84
+ }, true);
85
+ // new agw.RosCustomDomain(
86
+ // this,
87
+ // 'customDomain',
88
+ // {
89
+ // domainName: 'example.com',
90
+ // certificateName: 'example.com',
91
+ // certificateBody: 'example.com',
92
+ // certificatePrivateKey: 'example.com',
93
+ // groupId: apiGatewayGroup.attrGroupId,
94
+ // },
95
+ // true,
96
+ // );
97
+ apiGateway.forEach((event) => {
98
+ event.triggers.forEach((trigger) => {
99
+ const key = (0, common_1.encodeBase64)((0, common_1.replaceReference)(`${trigger.method}_${trigger.path}`, context)).replace(/=+$/, '');
100
+ const api = new agw.RosApi(scope, `${event.key}_api_${key}`, {
101
+ apiName: (0, common_1.replaceReference)(`${event.name}_api_${key}`, context),
102
+ groupId: apiGatewayGroup.attrGroupId,
103
+ visibility: 'PRIVATE',
104
+ authType: 'ANONYMOUS',
105
+ requestConfig: {
106
+ requestProtocol: 'HTTP',
107
+ requestHttpMethod: (0, common_1.replaceReference)(trigger.method, context),
108
+ requestPath: (0, common_1.replaceReference)(trigger.path, context),
109
+ requestMode: 'PASSTHROUGH',
110
+ },
111
+ serviceConfig: {
112
+ serviceProtocol: 'FunctionCompute',
113
+ functionComputeConfig: {
114
+ fcRegionId: context.region,
115
+ functionName: (0, common_1.replaceReference)(trigger.backend, context),
116
+ roleArn: gatewayAccessRole.attrArn,
117
+ fcVersion: '3.0',
118
+ method: (0, common_1.replaceReference)(trigger.method, context),
119
+ },
120
+ },
121
+ resultSample: 'ServerlessInsight resultSample',
122
+ resultType: 'PASSTHROUGH',
123
+ tags: (0, common_1.replaceReference)(tags, context),
124
+ }, true);
125
+ api.addDependsOn(apiGatewayGroup);
126
+ new agw.Deployment(scope, `${service}_deployment`, {
127
+ apiId: api.attrApiId,
128
+ groupId: apiGatewayGroup.attrGroupId,
129
+ stageName: 'RELEASE',
130
+ description: `${service} Api Gateway deployment`,
131
+ });
132
+ });
133
+ });
134
+ }
135
+ };
136
+ exports.resolveEvents = resolveEvents;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.resolveFunctions = void 0;
37
+ const common_1 = require("../../common");
38
+ const fc = __importStar(require("@alicloud/ros-cdk-fc3"));
39
+ const lodash_1 = require("lodash");
40
+ const ossDeployment = __importStar(require("@alicloud/ros-cdk-ossdeployment"));
41
+ const ros = __importStar(require("@alicloud/ros-cdk-core"));
42
+ const sls = __importStar(require("@alicloud/ros-cdk-sls"));
43
+ const resolveFunctions = (scope, functions, tags, context, service) => {
44
+ if ((0, lodash_1.isEmpty)(functions)) {
45
+ return undefined;
46
+ }
47
+ const slsService = new sls.Project(scope, `${service}_sls`, { name: `${service}-sls`, tags: (0, common_1.replaceReference)(tags, context) }, true);
48
+ const slsLogstore = new sls.Logstore(scope, `${service}_sls_logstore`, {
49
+ logstoreName: `${service}-sls-logstore`,
50
+ projectName: slsService.attrName,
51
+ ttl: 7,
52
+ }, true);
53
+ new sls.Index(scope, `${service}_sls_index`, {
54
+ projectName: slsService.attrName,
55
+ logstoreName: slsLogstore.attrLogstoreName,
56
+ fullTextIndex: { enable: true },
57
+ }, true);
58
+ const fileSources = functions
59
+ ?.filter(({ code }) => (0, common_1.readCodeSize)(code) > common_1.CODE_ZIP_SIZE_LIMIT)
60
+ .map(({ code, name }) => {
61
+ const fcName = (0, common_1.replaceReference)(name, context);
62
+ return { fcName, ...(0, common_1.getFileSource)(fcName, code) };
63
+ });
64
+ const destinationBucketName = ros.Fn.sub('si-bootstrap-artifacts-${ALIYUN::AccountId}-${ALIYUN::Region}');
65
+ const ossDeploymentId = `${service}_artifacts_code_deployment`;
66
+ if (!(0, lodash_1.isEmpty)(fileSources)) {
67
+ new ossDeployment.BucketDeployment(scope, ossDeploymentId, {
68
+ sources: fileSources.map(({ source }) => source),
69
+ destinationBucket: destinationBucketName,
70
+ timeout: 3000,
71
+ logMonitoring: false,
72
+ retainOnCreate: false,
73
+ }, true);
74
+ }
75
+ functions?.forEach((fnc) => {
76
+ const storeInBucket = (0, common_1.readCodeSize)(fnc.code) > common_1.CODE_ZIP_SIZE_LIMIT;
77
+ let code = {
78
+ zipFile: (0, common_1.resolveCode)(fnc.code),
79
+ };
80
+ if (storeInBucket) {
81
+ code = {
82
+ ossBucketName: destinationBucketName,
83
+ ossObjectName: fileSources?.find(({ fcName }) => fcName === (0, common_1.replaceReference)(fnc.name, context))?.objectKey,
84
+ };
85
+ }
86
+ const fcn = new fc.RosFunction(scope, fnc.key, {
87
+ functionName: (0, common_1.replaceReference)(fnc.name, context),
88
+ handler: (0, common_1.replaceReference)(fnc.handler, context),
89
+ runtime: (0, common_1.replaceReference)(fnc.runtime, context),
90
+ memorySize: (0, common_1.replaceReference)(fnc.memory, context),
91
+ timeout: (0, common_1.replaceReference)(fnc.timeout, context),
92
+ environmentVariables: (0, common_1.replaceReference)(fnc.environment, context),
93
+ code,
94
+ logConfig: {
95
+ project: slsLogstore.attrProjectName,
96
+ logstore: slsLogstore.attrLogstoreName,
97
+ enableRequestMetrics: true,
98
+ },
99
+ }, true);
100
+ fcn.addRosDependency(`${service}_sls`);
101
+ fcn.addRosDependency(`${service}_sls_logstore`);
102
+ fcn.addRosDependency(`${service}_sls_index`);
103
+ if (storeInBucket) {
104
+ fcn.addRosDependency(`${service}_artifacts_code_deployment`);
105
+ }
106
+ });
107
+ };
108
+ exports.resolveFunctions = resolveFunctions;
@@ -0,0 +1,7 @@
1
+ import * as ros from '@alicloud/ros-cdk-core';
2
+ import { ActionContext, ServerlessIac } from '../../types';
3
+ export * from './bootstrap';
4
+ export declare class RosStack extends ros.Stack {
5
+ private readonly service;
6
+ constructor(scope: ros.Construct, iac: ServerlessIac, context: ActionContext);
7
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.RosStack = void 0;
40
+ const ros = __importStar(require("@alicloud/ros-cdk-core"));
41
+ const common_1 = require("../../common");
42
+ const tag_1 = require("./tag");
43
+ const function_1 = require("./function");
44
+ const stage_1 = require("./stage");
45
+ const vars_1 = require("./vars");
46
+ const database_1 = require("./database");
47
+ const event_1 = require("./event");
48
+ __exportStar(require("./bootstrap"), exports);
49
+ class RosStack extends ros.Stack {
50
+ constructor(scope, iac, context) {
51
+ super(scope, (0, common_1.replaceReference)(iac.service, context), {
52
+ stackName: context.stackName,
53
+ tags: (0, tag_1.resolveTags)(iac.tags, context),
54
+ });
55
+ this.service = (0, common_1.replaceReference)(iac.service, context);
56
+ new ros.RosInfo(this, ros.RosInfo.description, `${this.service} stack`);
57
+ // Define Parameters
58
+ (0, vars_1.resloveVars)(this, iac.vars);
59
+ // Define Mappings
60
+ (0, stage_1.resolveStages)(this, iac.stages, context);
61
+ // Define functions
62
+ (0, function_1.resolveFunctions)(this, iac.functions, iac.tags, context, this.service);
63
+ // Define Events
64
+ (0, event_1.resolveEvents)(this, iac.events, iac.tags, context, this.service);
65
+ // Define Databases
66
+ (0, database_1.resolveDatabases)(this, iac.databases, context);
67
+ }
68
+ }
69
+ exports.RosStack = RosStack;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.resolveStages = void 0;
37
+ const ros = __importStar(require("@alicloud/ros-cdk-core"));
38
+ const common_1 = require("../../common");
39
+ const lodash_1 = require("lodash");
40
+ const resolveStages = (scope, stages, context) => {
41
+ if ((0, lodash_1.isEmpty)(stages)) {
42
+ return undefined;
43
+ }
44
+ new ros.RosMapping(scope, 'stages', { mapping: (0, common_1.replaceReference)(stages, context) });
45
+ };
46
+ exports.resolveStages = resolveStages;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveTags = void 0;
4
+ const common_1 = require("../../common");
5
+ const resolveTags = (tags, context) => {
6
+ return tags?.reduce((acc, tag) => {
7
+ acc[tag.key] = (0, common_1.replaceReference)(tag.value, context);
8
+ return acc;
9
+ }, {});
10
+ };
11
+ exports.resolveTags = resolveTags;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.resloveVars = void 0;
37
+ const ros = __importStar(require("@alicloud/ros-cdk-core"));
38
+ const ros_cdk_core_1 = require("@alicloud/ros-cdk-core");
39
+ const lodash_1 = require("lodash");
40
+ const resloveVars = (scope, vars) => {
41
+ if ((0, lodash_1.isEmpty)(vars)) {
42
+ return undefined;
43
+ }
44
+ Object.entries(vars).map(([id, value]) => new ros.RosParameter(scope, id, {
45
+ type: ros_cdk_core_1.RosParameterType.STRING,
46
+ defaultValue: value,
47
+ }));
48
+ };
49
+ exports.resloveVars = resloveVars;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TemplateFormat = void 0;
4
+ var TemplateFormat;
5
+ (function (TemplateFormat) {
6
+ TemplateFormat["YAML"] = "YAML";
7
+ TemplateFormat["JSON"] = "JSON";
8
+ })(TemplateFormat || (exports.TemplateFormat = TemplateFormat = {}));
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,44 @@
1
+ import { Stages, Vars } from './domains/vars';
2
+ import { Tags } from './domains/tag';
3
+ import { EventDomain, EventRaw } from './domains/event';
4
+ import { DatabaseDomain, DatabaseRaw } from './domains/database';
5
+ import { FunctionDomain, FunctionRaw } from './domains/function';
6
+ import { Provider } from './domains/provider';
7
+ export * from './domains/database';
8
+ export * from './domains/event';
9
+ export * from './domains/function';
10
+ export * from './domains/tag';
11
+ export * from './domains/vars';
12
+ export * from './domains/context';
13
+ export * from './assets';
14
+ export type ServerlessIacRaw = {
15
+ version: string;
16
+ provider: Provider;
17
+ vars: Vars;
18
+ stages: Stages;
19
+ service: string;
20
+ tags: Tags;
21
+ functions: {
22
+ [key: string]: FunctionRaw;
23
+ };
24
+ events: {
25
+ [key: string]: EventRaw;
26
+ };
27
+ databases: {
28
+ [key: string]: DatabaseRaw;
29
+ };
30
+ };
31
+ export type ServerlessIac = {
32
+ version: string;
33
+ provider: Provider;
34
+ service: string;
35
+ vars?: Vars;
36
+ stages?: Stages;
37
+ tags?: Array<{
38
+ key: string;
39
+ value: string;
40
+ }>;
41
+ functions?: Array<FunctionDomain>;
42
+ events?: Array<EventDomain>;
43
+ databases?: Array<DatabaseDomain>;
44
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./domains/database"), exports);
18
+ __exportStar(require("./domains/event"), exports);
19
+ __exportStar(require("./domains/function"), exports);
20
+ __exportStar(require("./domains/tag"), exports);
21
+ __exportStar(require("./domains/vars"), exports);
22
+ __exportStar(require("./domains/context"), exports);
23
+ __exportStar(require("./assets"), exports);
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.databaseSchema = void 0;
4
+ exports.databaseSchema = {
5
+ $id: 'https://serverlessinsight.geekfun.club/schemas/databaseschema.json',
6
+ type: 'object',
7
+ patternProperties: {
8
+ '.*': {
9
+ type: 'object',
10
+ properties: {
11
+ name: { type: 'string' },
12
+ type: {
13
+ type: 'string',
14
+ enum: [
15
+ 'ELASTICSEARCH_SERVERLESS',
16
+ 'RDS_MYSQL_SERVERLESS',
17
+ 'RDS_PGSQL_SERVERLESS',
18
+ 'RDS_MSSQL_SERVERLESS',
19
+ ],
20
+ },
21
+ version: {
22
+ type: 'string',
23
+ enum: [
24
+ 'MYSQL_5.7',
25
+ 'MYSQL_8.0',
26
+ 'MYSQL_HA_5.7',
27
+ 'MYSQL_HA_8.0',
28
+ 'PGSQL_14',
29
+ 'PGSQL_15',
30
+ 'PGSQL_16',
31
+ 'PGSQL_HA_14',
32
+ 'PGSQL_HA_15',
33
+ 'PGSQL_HA_16',
34
+ 'MSSQL_HA_2016',
35
+ 'MSSQL_HA_2017',
36
+ 'MSSQL_HA_2019',
37
+ 'ES_SEARCH_7.10',
38
+ 'ES_TIME_SERIES_7.10',
39
+ ],
40
+ },
41
+ cu: {
42
+ type: 'object',
43
+ properties: {
44
+ min: { type: 'integer', minimum: 0, maximum: 32 },
45
+ max: { type: 'integer', minimum: 1, maximum: 32 },
46
+ },
47
+ },
48
+ storage: {
49
+ type: 'object',
50
+ properties: { min: { type: 'integer', minimum: 20 } },
51
+ required: ['min'],
52
+ },
53
+ security: {
54
+ type: 'object',
55
+ properties: {
56
+ basic_auth: {
57
+ type: 'object',
58
+ properties: {
59
+ master_user: { type: 'string' },
60
+ password: { type: 'string' },
61
+ },
62
+ required: ['master_user', 'password'],
63
+ },
64
+ },
65
+ required: ['basic_auth'],
66
+ },
67
+ network: {
68
+ type: 'object',
69
+ properties: {
70
+ type: { type: 'string', enum: ['PUBLIC', 'PRIVATE'] },
71
+ ingress_rules: {
72
+ type: 'array',
73
+ items: { type: 'string' },
74
+ },
75
+ public: { type: 'boolean' },
76
+ },
77
+ },
78
+ },
79
+ required: ['name', 'type', 'version', 'security'],
80
+ additionalProperties: false,
81
+ },
82
+ },
83
+ };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.eventSchema = void 0;
4
+ exports.eventSchema = {
5
+ $id: 'https://serverlessinsight.geekfun.club/schemas/eventschema.json',
6
+ type: 'object',
7
+ patternProperties: {
8
+ '.*': {
9
+ type: 'object',
10
+ properties: {
11
+ name: { type: 'string' },
12
+ type: { type: 'string', enum: ['API_GATEWAY'] },
13
+ triggers: {
14
+ type: 'array',
15
+ items: {
16
+ method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE', 'ANY'] },
17
+ path: { type: 'string' },
18
+ backend: { type: 'string' },
19
+ required: ['method', 'path', 'backend'],
20
+ },
21
+ },
22
+ custom_domain: {
23
+ type: 'object',
24
+ properties: {
25
+ domain_name: { type: 'string' },
26
+ certificate_name: { type: 'string' },
27
+ certificate_body: { type: 'string' },
28
+ certificate_private_key: { type: 'string' },
29
+ },
30
+ required: [
31
+ 'domain_name',
32
+ 'certificate_name',
33
+ 'certificate_body',
34
+ 'certificate_private_key',
35
+ ],
36
+ },
37
+ },
38
+ required: ['name', 'type', 'triggers'],
39
+ },
40
+ },
41
+ };