@geek-fun/serverlessinsight 0.4.0 → 0.5.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.
- package/.gitattributes +1 -0
- package/README.md +108 -8
- package/README.zh-CN.md +52 -8
- package/dist/package.json +37 -35
- package/dist/src/commands/deploy.js +17 -7
- package/dist/src/commands/destroy.js +27 -4
- package/dist/src/commands/forceUnlock.js +61 -0
- package/dist/src/commands/index.js +86 -14
- package/dist/src/commands/local.js +10 -1
- package/dist/src/commands/plan.js +33 -0
- package/dist/src/commands/template.js +3 -1
- package/dist/src/commands/validate.js +2 -1
- package/dist/src/common/aliyunClient/apigwOperations.js +652 -0
- package/dist/src/common/aliyunClient/dnsOperations.js +90 -0
- package/dist/src/common/aliyunClient/ecsOperations.js +141 -0
- package/dist/src/common/aliyunClient/esOperations.js +219 -0
- package/dist/src/common/aliyunClient/fc3Operations.js +270 -0
- package/dist/src/common/aliyunClient/index.js +141 -0
- package/dist/src/common/aliyunClient/nasOperations.js +233 -0
- package/dist/src/common/aliyunClient/ossOperations.js +237 -0
- package/dist/src/common/aliyunClient/ramOperations.js +205 -0
- package/dist/src/common/aliyunClient/rdsOperations.js +206 -0
- package/dist/src/common/aliyunClient/slsOperations.js +218 -0
- package/dist/src/common/aliyunClient/tablestoreOperations.js +199 -0
- package/dist/src/common/aliyunClient/types.js +2 -0
- package/dist/src/common/constants.js +7 -1
- package/dist/src/common/context.js +32 -14
- package/dist/src/common/credentials.js +39 -0
- package/dist/src/common/dependencyGraph/graph.js +280 -0
- package/dist/src/common/dependencyGraph/index.js +18 -0
- package/dist/src/common/dependencyGraph/types.js +2 -0
- package/dist/src/common/fileUtils.js +16 -0
- package/dist/src/common/hashUtils.js +121 -0
- package/dist/src/common/iacHelper.js +25 -97
- package/dist/src/common/imsClient.js +4 -0
- package/dist/src/common/index.js +7 -2
- package/dist/src/common/lockManager.js +212 -0
- package/dist/src/common/logger.js +89 -6
- package/dist/src/common/providerEnum.js +2 -3
- package/dist/src/common/runtimeMapper.js +160 -0
- package/dist/src/common/scfClient.js +84 -0
- package/dist/src/common/stateManager.js +107 -0
- package/dist/src/common/tencentClient/cosOperations.js +287 -0
- package/dist/src/common/tencentClient/esOperations.js +156 -0
- package/dist/src/common/tencentClient/index.js +116 -0
- package/dist/src/common/tencentClient/scfOperations.js +141 -0
- package/dist/src/common/tencentClient/tdsqlcOperations.js +211 -0
- package/dist/src/common/tencentClient/types.js +17 -0
- package/dist/src/lang/en.js +254 -0
- package/dist/src/lang/index.js +28 -8
- package/dist/src/lang/zh-CN.js +229 -0
- package/dist/src/parser/bucketParser.js +25 -12
- package/dist/src/parser/databaseParser.js +14 -10
- package/dist/src/parser/functionParser.js +19 -6
- package/dist/src/parser/parseUtils.js +74 -0
- package/dist/src/parser/tableParser.js +19 -17
- package/dist/src/stack/aliyunStack/apigwExecutor.js +84 -0
- package/dist/src/stack/aliyunStack/apigwPlanner.js +118 -0
- package/dist/src/stack/aliyunStack/apigwResource.js +339 -0
- package/dist/src/stack/aliyunStack/apigwTypes.js +125 -0
- package/dist/src/stack/aliyunStack/databaseExecutor.js +112 -0
- package/dist/src/stack/aliyunStack/databasePlanner.js +128 -0
- package/dist/src/stack/aliyunStack/databaseResource.js +228 -0
- package/dist/src/stack/aliyunStack/deployer.js +133 -0
- package/dist/src/stack/aliyunStack/destroyer.js +114 -0
- package/dist/src/stack/aliyunStack/esServerlessTypes.js +141 -0
- package/dist/src/stack/aliyunStack/fc3Executor.js +91 -0
- package/dist/src/stack/aliyunStack/fc3Planner.js +77 -0
- package/dist/src/stack/aliyunStack/fc3Resource.js +511 -0
- package/dist/src/stack/aliyunStack/fc3Types.js +76 -0
- package/dist/src/stack/aliyunStack/index.js +40 -0
- package/dist/src/stack/aliyunStack/ossExecutor.js +91 -0
- package/dist/src/stack/aliyunStack/ossPlanner.js +76 -0
- package/dist/src/stack/aliyunStack/ossResource.js +196 -0
- package/dist/src/stack/aliyunStack/ossTypes.js +50 -0
- package/dist/src/stack/aliyunStack/planner.js +37 -0
- package/dist/src/stack/aliyunStack/rdsTypes.js +217 -0
- package/dist/src/stack/aliyunStack/tablestoreExecutor.js +92 -0
- package/dist/src/stack/aliyunStack/tablestorePlanner.js +94 -0
- package/dist/src/stack/aliyunStack/tablestoreResource.js +120 -0
- package/dist/src/stack/aliyunStack/tablestoreTypes.js +77 -0
- package/dist/src/stack/bucketTypes.js +17 -0
- package/dist/src/stack/deploy.js +24 -77
- package/dist/src/stack/localStack/bucket.js +11 -6
- package/dist/src/stack/localStack/event.js +10 -5
- package/dist/src/stack/localStack/function.js +13 -7
- package/dist/src/stack/localStack/functionRunner.js +1 -1
- package/dist/src/stack/localStack/localServer.js +7 -6
- package/dist/src/stack/scfStack/cosExecutor.js +91 -0
- package/dist/src/stack/scfStack/cosPlanner.js +76 -0
- package/dist/src/stack/scfStack/cosResource.js +126 -0
- package/dist/src/stack/scfStack/cosTypes.js +46 -0
- package/dist/src/stack/scfStack/deployer.js +91 -0
- package/dist/src/stack/scfStack/destroyer.js +88 -0
- package/dist/src/stack/scfStack/esServerlessExecutor.js +105 -0
- package/dist/src/stack/scfStack/esServerlessPlanner.js +86 -0
- package/dist/src/stack/scfStack/esServerlessResource.js +94 -0
- package/dist/src/stack/scfStack/esServerlessTypes.js +48 -0
- package/dist/src/stack/scfStack/index.js +35 -0
- package/dist/src/stack/scfStack/planner.js +91 -0
- package/dist/src/stack/scfStack/scfExecutor.js +91 -0
- package/dist/src/stack/scfStack/scfPlanner.js +78 -0
- package/dist/src/stack/scfStack/scfResource.js +216 -0
- package/dist/src/stack/scfStack/scfTypes.js +41 -0
- package/dist/src/stack/scfStack/tdsqlcExecutor.js +105 -0
- package/dist/src/stack/scfStack/tdsqlcPlanner.js +90 -0
- package/dist/src/stack/scfStack/tdsqlcResource.js +146 -0
- package/dist/src/stack/scfStack/tdsqlcTypes.js +59 -0
- package/dist/src/types/domains/lock.js +2 -0
- package/dist/src/types/domains/resolvable.js +2 -0
- package/dist/src/types/domains/state.js +19 -0
- package/dist/src/types/index.js +4 -0
- package/dist/src/validator/bucketSchema.js +4 -10
- package/dist/src/validator/databaseSchema.js +36 -36
- package/dist/src/validator/eventSchema.js +3 -2
- package/dist/src/validator/functionSchema.js +51 -46
- package/dist/src/validator/iacSchema.js +52 -3
- package/dist/src/validator/rootSchema.js +47 -1
- package/dist/src/validator/tableschema.js +9 -8
- package/dist/src/validator/templateRefSchema.js +23 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -35
- package/samples/README_TENCENT_COS.md +486 -0
- package/samples/README_TENCENT_SCF.md +272 -0
- package/samples/aliyun-poc-api.yml +1 -1
- package/samples/aliyun-poc-bucket.yml +0 -1
- package/samples/aliyun-poc-domain.yml +0 -1
- package/samples/aliyun-poc-es.yml +14 -13
- package/samples/aliyun-poc-rds.yml +0 -2
- package/samples/aliyun-poc-table.yml +1 -3
- package/samples/tencent-poc-cos.yml +20 -0
- package/samples/tencent-poc-scf.yml +36 -0
- package/dist/src/commands/index.d.ts +0 -2
- package/dist/src/common/index.d.ts +0 -11
- package/dist/src/common/rosAssets.js +0 -178
- package/dist/src/common/rosClient.js +0 -198
- package/dist/src/index.d.ts +0 -1
- package/dist/src/lang/index.d.ts +0 -3
- package/dist/src/parser/index.d.ts +0 -3
- package/dist/src/stack/index.d.ts +0 -1
- package/dist/src/stack/localStack/index.d.ts +0 -5
- package/dist/src/stack/rfsStack/index.d.ts +0 -9
- package/dist/src/stack/rosStack/bootstrap.js +0 -187
- package/dist/src/stack/rosStack/bucket.js +0 -127
- package/dist/src/stack/rosStack/database.js +0 -313
- package/dist/src/stack/rosStack/event.js +0 -143
- package/dist/src/stack/rosStack/function.js +0 -259
- package/dist/src/stack/rosStack/index.d.ts +0 -7
- package/dist/src/stack/rosStack/index.js +0 -75
- package/dist/src/stack/rosStack/stage.js +0 -46
- package/dist/src/stack/rosStack/table.js +0 -95
- package/dist/src/stack/rosStack/tag.js +0 -11
- package/dist/src/stack/rosStack/vars.js +0 -49
- package/dist/src/types/index.d.ts +0 -55
- package/dist/src/types/localStack/index.d.ts +0 -81
- package/dist/src/validator/index.d.ts +0 -1
- package/layers/si-bootstrap-sdk/Dockerfile-aliyuncli +0 -12
- package/layers/si-bootstrap-sdk/README.md +0 -1
- package/layers/si-bootstrap-sdk/package-lock.json +0 -875
- package/layers/si-bootstrap-sdk/package.json +0 -33
|
@@ -1,259 +0,0 @@
|
|
|
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 types_1 = require("../../types");
|
|
38
|
-
const common_1 = require("../../common");
|
|
39
|
-
const fc = __importStar(require("@alicloud/ros-cdk-fc3"));
|
|
40
|
-
const lodash_1 = require("lodash");
|
|
41
|
-
const ossDeployment = __importStar(require("@alicloud/ros-cdk-ossdeployment"));
|
|
42
|
-
const sls = __importStar(require("@alicloud/ros-cdk-sls"));
|
|
43
|
-
const nas = __importStar(require("@alicloud/ros-cdk-nas"));
|
|
44
|
-
const ecs = __importStar(require("@alicloud/ros-cdk-ecs"));
|
|
45
|
-
const vpc = __importStar(require("@alicloud/ros-cdk-vpc"));
|
|
46
|
-
const storageClassMap = {
|
|
47
|
-
[types_1.NasStorageClassEnum.STANDARD_CAPACITY]: { fileSystemType: 'standard', storageType: 'Capacity' },
|
|
48
|
-
[types_1.NasStorageClassEnum.STANDARD_PERFORMANCE]: {
|
|
49
|
-
fileSystemType: 'standard',
|
|
50
|
-
storageType: 'Performance',
|
|
51
|
-
},
|
|
52
|
-
[types_1.NasStorageClassEnum.EXTREME_STANDARD]: { fileSystemType: 'extreme', storageType: 'standard' },
|
|
53
|
-
[types_1.NasStorageClassEnum.EXTREME_ADVANCE]: { fileSystemType: 'extreme', storageType: 'advance' },
|
|
54
|
-
};
|
|
55
|
-
const securityGroupRangeMap = {
|
|
56
|
-
TCP: '1/65535',
|
|
57
|
-
UDP: '1/65535',
|
|
58
|
-
ICMP: '-1/-1',
|
|
59
|
-
GRE: '-1/-1',
|
|
60
|
-
ALL: '-1/-1',
|
|
61
|
-
};
|
|
62
|
-
const gpuConfigMap = {
|
|
63
|
-
[types_1.FunctionGpuEnum.TESLA_8]: { gpuMemorySize: 8192, gpuType: 'fc.gpu.tesla.1' },
|
|
64
|
-
[types_1.FunctionGpuEnum.TESLA_12]: { gpuMemorySize: 12288, gpuType: 'fc.gpu.tesla.1' },
|
|
65
|
-
[types_1.FunctionGpuEnum.TESLA_16]: { gpuMemorySize: 16384, gpuType: 'fc.gpu.tesla.1' },
|
|
66
|
-
[types_1.FunctionGpuEnum.AMPERE_8]: { gpuMemorySize: 8192, gpuType: 'fc.gpu.ampere.1' },
|
|
67
|
-
[types_1.FunctionGpuEnum.AMPERE_12]: { gpuMemorySize: 12288, gpuType: 'fc.gpu.ampere.1' },
|
|
68
|
-
[types_1.FunctionGpuEnum.AMPERE_16]: { gpuMemorySize: 16384, gpuType: 'fc.gpu.ampere.1' },
|
|
69
|
-
[types_1.FunctionGpuEnum.AMPERE_24]: { gpuMemorySize: 24576, gpuType: 'fc.gpu.ampere.1' },
|
|
70
|
-
[types_1.FunctionGpuEnum.ADA_48]: { gpuMemorySize: 49152, gpuType: 'fc.gpu.ada.1' },
|
|
71
|
-
};
|
|
72
|
-
const transformSecurityRules = (rules, ruleType) => {
|
|
73
|
-
return rules.map((rule) => {
|
|
74
|
-
const [protocol, cidrIp, portRange] = rule.split(':');
|
|
75
|
-
return {
|
|
76
|
-
ipProtocol: protocol.toLowerCase(),
|
|
77
|
-
portRange: portRange.toUpperCase() === 'ALL'
|
|
78
|
-
? securityGroupRangeMap[protocol.toUpperCase()]
|
|
79
|
-
: portRange.includes('/')
|
|
80
|
-
? portRange
|
|
81
|
-
: `${portRange}/${portRange}`,
|
|
82
|
-
[ruleType === 'INGRESS' ? 'sourceCidrIp' : 'destCidrIp']: cidrIp,
|
|
83
|
-
};
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
const transformGpuConfig = (gpu) => {
|
|
87
|
-
if (!gpu) {
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
return gpuConfigMap[gpu];
|
|
91
|
-
};
|
|
92
|
-
const resolveFunctions = (scope, functions, tags, context, service) => {
|
|
93
|
-
if ((0, lodash_1.isEmpty)(functions)) {
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
let logConfig = undefined;
|
|
97
|
-
const enableLog = functions?.some(({ log }) => log);
|
|
98
|
-
const slsProjectId = 'sls_project';
|
|
99
|
-
const slsLogstoreId = 'sls_logstore';
|
|
100
|
-
const slsIndexId = 'sls_index';
|
|
101
|
-
const slsProject = new sls.Project(scope, slsProjectId, { name: (0, common_1.calcRefs)(`${service}-sls`, context), tags: (0, common_1.calcRefs)(tags, context) }, true);
|
|
102
|
-
const slsLogstore = new sls.Logstore(scope, slsLogstoreId, {
|
|
103
|
-
logstoreName: (0, common_1.calcRefs)(`${service}-sls-logstore`, context),
|
|
104
|
-
projectName: slsProject.attrName,
|
|
105
|
-
ttl: 7,
|
|
106
|
-
}, true);
|
|
107
|
-
new sls.Index(scope, slsIndexId, {
|
|
108
|
-
projectName: slsProject.attrName,
|
|
109
|
-
logstoreName: slsLogstore.attrLogstoreName,
|
|
110
|
-
fullTextIndex: { enable: true },
|
|
111
|
-
}, true);
|
|
112
|
-
if (enableLog) {
|
|
113
|
-
logConfig = {
|
|
114
|
-
project: slsLogstore.attrProjectName,
|
|
115
|
-
logstore: slsLogstore.attrLogstoreName,
|
|
116
|
-
enableRequestMetrics: true,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
const fileSources = functions
|
|
120
|
-
?.filter(({ code }) => code?.path && (0, common_1.readCodeSize)(code.path) > common_1.CODE_ZIP_SIZE_LIMIT)
|
|
121
|
-
.map(({ code, name }) => {
|
|
122
|
-
const fcName = (0, common_1.calcRefs)(name, context);
|
|
123
|
-
return { fcName, ...(0, common_1.getFileSource)(fcName, code.path) };
|
|
124
|
-
});
|
|
125
|
-
const destinationBucketName = `${common_1.SI_BOOTSTRAP_BUCKET_PREFIX}-${context.accountId}-${context.region}`;
|
|
126
|
-
const ossDeploymentId = 'si_auto_artifacts_code_deployment';
|
|
127
|
-
if (!(0, lodash_1.isEmpty)(fileSources)) {
|
|
128
|
-
new ossDeployment.BucketDeployment(scope, ossDeploymentId, {
|
|
129
|
-
sources: fileSources.map(({ source }) => source),
|
|
130
|
-
destinationBucket: destinationBucketName,
|
|
131
|
-
timeout: common_1.OSS_DEPLOYMENT_TIMEOUT,
|
|
132
|
-
logMonitoring: false,
|
|
133
|
-
retainOnCreate: false,
|
|
134
|
-
}, true);
|
|
135
|
-
}
|
|
136
|
-
functions?.forEach((fnc) => {
|
|
137
|
-
let runtimeConfig;
|
|
138
|
-
const storeInBucket = !!fnc.code?.path && (0, common_1.readCodeSize)((0, common_1.calcValue)(fnc.code.path, context)) > common_1.CODE_ZIP_SIZE_LIMIT;
|
|
139
|
-
if (fnc.container) {
|
|
140
|
-
runtimeConfig = {
|
|
141
|
-
runtime: 'custom-container',
|
|
142
|
-
handler: 'index.handler',
|
|
143
|
-
customContainerConfig: {
|
|
144
|
-
image: (0, common_1.calcRefs)(fnc.container.image, context),
|
|
145
|
-
command: (0, common_1.calcRefs)(fnc.container.cmd, context)?.split(' '),
|
|
146
|
-
port: (0, common_1.calcRefs)(fnc.container.port, context),
|
|
147
|
-
},
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
let code = {
|
|
152
|
-
zipFile: (0, common_1.resolveCode)((0, common_1.calcValue)(fnc.code.path, context)),
|
|
153
|
-
};
|
|
154
|
-
if (storeInBucket) {
|
|
155
|
-
code = {
|
|
156
|
-
ossBucketName: destinationBucketName,
|
|
157
|
-
ossObjectName: fileSources?.find(({ fcName }) => fcName === (0, common_1.calcRefs)(fnc.name, context))
|
|
158
|
-
?.objectKey,
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
runtimeConfig = {
|
|
162
|
-
code,
|
|
163
|
-
handler: (0, common_1.calcRefs)(fnc.code.handler, context),
|
|
164
|
-
runtime: (0, common_1.calcRefs)(fnc.code.runtime, context),
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
let vpcConfig = undefined;
|
|
168
|
-
if (fnc.network) {
|
|
169
|
-
const securityGroup = new ecs.SecurityGroup(scope, (0, common_1.formatRosId)(`${fnc.key}_security_group`), {
|
|
170
|
-
securityGroupName: fnc.network.security_group.name,
|
|
171
|
-
vpcId: (0, common_1.calcRefs)(fnc.network.vpc_id, context),
|
|
172
|
-
tags: (0, common_1.calcRefs)(tags, context),
|
|
173
|
-
securityGroupIngress: transformSecurityRules(fnc.network.security_group.ingress, 'INGRESS'),
|
|
174
|
-
securityGroupEgress: transformSecurityRules(fnc.network.security_group.egress, 'EGRESS'),
|
|
175
|
-
}, true);
|
|
176
|
-
vpcConfig = {
|
|
177
|
-
vpcId: (0, common_1.calcRefs)(fnc.network.vpc_id, context),
|
|
178
|
-
vSwitchIds: (0, common_1.calcRefs)(fnc.network.subnet_ids, context),
|
|
179
|
-
securityGroupId: securityGroup.attrSecurityGroupId,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
let fcNas;
|
|
183
|
-
if (fnc.storage?.nas) {
|
|
184
|
-
fcNas = fnc.storage.nas.map((nasItem) => {
|
|
185
|
-
const storageClass = (0, common_1.calcValue)(nasItem.storage_class, context);
|
|
186
|
-
const { fileSystemType, storageType } = storageClassMap[storageClass];
|
|
187
|
-
const mountPathValue = (0, common_1.formatRosId)((0, common_1.calcValue)(nasItem.mount_path, context));
|
|
188
|
-
const nasMountTargetId = (0, common_1.formatRosId)(`${fnc.key}_nas_mount_${mountPathValue}`);
|
|
189
|
-
const accessGroup = new nas.AccessGroup(scope, (0, common_1.formatRosId)(`${fnc.key}_nas_access_${mountPathValue}`), {
|
|
190
|
-
accessGroupName: (0, common_1.calcRefs)(`${fnc.name}-nas-access-${mountPathValue.replace(/_/g, '-')}`, context),
|
|
191
|
-
accessGroupType: 'Vpc',
|
|
192
|
-
}, true);
|
|
193
|
-
const fcVpcSubnets = fnc.network?.subnet_ids.map((subnet) => new vpc.datasource.VSwitch(scope, (0, common_1.formatRosId)((0, common_1.calcValue)(`${fnc.key}_datasource_subnet_${subnet}`, context)), {
|
|
194
|
-
vSwitchId: subnet,
|
|
195
|
-
refreshOptions: 'Always',
|
|
196
|
-
}));
|
|
197
|
-
fcVpcSubnets?.forEach((subnetDatasource, index) => {
|
|
198
|
-
new nas.AccessRule(scope, (0, common_1.formatRosId)((0, common_1.calcValue)(`${fnc.key}_nas_rule_${fnc.network.subnet_ids[index]}`, context)), {
|
|
199
|
-
accessGroupName: accessGroup.attrAccessGroupName,
|
|
200
|
-
sourceCidrIp: subnetDatasource.attrCidrBlock,
|
|
201
|
-
}, true);
|
|
202
|
-
});
|
|
203
|
-
const nasResource = new nas.FileSystem(scope, (0, common_1.formatRosId)(`${fnc.key}_nas_${mountPathValue}`), {
|
|
204
|
-
fileSystemType,
|
|
205
|
-
storageType,
|
|
206
|
-
protocolType: 'NFS',
|
|
207
|
-
tags: [
|
|
208
|
-
...((0, common_1.calcRefs)(tags, context) ?? []),
|
|
209
|
-
{ key: 'function-name', value: (0, common_1.calcRefs)(fnc.name, context) },
|
|
210
|
-
],
|
|
211
|
-
}, true);
|
|
212
|
-
const nasMountTarget = new nas.MountTarget(scope, nasMountTargetId, {
|
|
213
|
-
fileSystemId: nasResource.attrFileSystemId,
|
|
214
|
-
networkType: 'Vpc',
|
|
215
|
-
accessGroupName: accessGroup.attrAccessGroupName,
|
|
216
|
-
vpcId: (0, common_1.calcRefs)(fnc.network.vpc_id, context),
|
|
217
|
-
vSwitchId: (0, common_1.calcRefs)(fnc.network.subnet_ids[0], context),
|
|
218
|
-
}, true);
|
|
219
|
-
return {
|
|
220
|
-
nas: nasResource,
|
|
221
|
-
nasMount: nasMountTarget,
|
|
222
|
-
mountDir: (0, common_1.calcRefs)(nasItem.mount_path, context),
|
|
223
|
-
nasMountTargetId,
|
|
224
|
-
};
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
const fcn = new fc.RosFunction(scope, fnc.key, {
|
|
228
|
-
functionName: (0, common_1.calcRefs)(fnc.name, context),
|
|
229
|
-
memorySize: (0, common_1.calcRefs)(fnc.memory, context),
|
|
230
|
-
diskSize: (0, common_1.calcRefs)(fnc.storage?.disk, context),
|
|
231
|
-
gpuConfig: transformGpuConfig(fnc.gpu),
|
|
232
|
-
timeout: (0, common_1.calcRefs)(fnc.timeout, context),
|
|
233
|
-
environmentVariables: (0, common_1.calcRefs)(fnc.environment, context),
|
|
234
|
-
logConfig,
|
|
235
|
-
vpcConfig,
|
|
236
|
-
...runtimeConfig,
|
|
237
|
-
nasConfig: fcNas?.length
|
|
238
|
-
? {
|
|
239
|
-
mountPoints: fcNas?.map(({ nasMount, mountDir }) => ({
|
|
240
|
-
mountDir,
|
|
241
|
-
serverAddr: `${nasMount.attrMountTargetDomain}:/`,
|
|
242
|
-
})),
|
|
243
|
-
}
|
|
244
|
-
: undefined,
|
|
245
|
-
}, true);
|
|
246
|
-
if (enableLog) {
|
|
247
|
-
fcn.addRosDependency(slsProjectId);
|
|
248
|
-
fcn.addRosDependency(slsLogstoreId);
|
|
249
|
-
fcn.addRosDependency(slsIndexId);
|
|
250
|
-
}
|
|
251
|
-
if (storeInBucket) {
|
|
252
|
-
fcn.addRosDependency(ossDeploymentId);
|
|
253
|
-
}
|
|
254
|
-
if (fcNas?.length) {
|
|
255
|
-
fcNas.forEach(({ nasMountTargetId }) => fcn.addRosDependency(nasMountTargetId));
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
};
|
|
259
|
-
exports.resolveFunctions = resolveFunctions;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as ros from '@alicloud/ros-cdk-core';
|
|
2
|
-
import { Context, 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: Context);
|
|
7
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
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
|
-
const bucket_1 = require("./bucket");
|
|
49
|
-
const table_1 = require("./table");
|
|
50
|
-
__exportStar(require("./bootstrap"), exports);
|
|
51
|
-
class RosStack extends ros.Stack {
|
|
52
|
-
constructor(scope, iac, context) {
|
|
53
|
-
super(scope, (0, common_1.calcRefs)(iac.service, context), {
|
|
54
|
-
stackName: context.stackName,
|
|
55
|
-
tags: (0, tag_1.resolveTags)(iac.tags, context),
|
|
56
|
-
});
|
|
57
|
-
this.service = (0, common_1.calcRefs)(iac.service, context);
|
|
58
|
-
new ros.RosInfo(this, ros.RosInfo.description, `${this.service} stack`);
|
|
59
|
-
// Define Parameters
|
|
60
|
-
(0, vars_1.resolveVars)(this, iac.vars);
|
|
61
|
-
// Define Mappings
|
|
62
|
-
(0, stage_1.resolveStages)(this, iac.stages, context);
|
|
63
|
-
// Define functions
|
|
64
|
-
(0, function_1.resolveFunctions)(this, iac.functions, iac.tags, context, this.service);
|
|
65
|
-
// Define Events
|
|
66
|
-
(0, event_1.resolveEvents)(this, iac.events, iac.tags, context, this.service);
|
|
67
|
-
// Define Databases
|
|
68
|
-
(0, database_1.resolveDatabases)(this, iac.databases, context);
|
|
69
|
-
// Define Tables
|
|
70
|
-
(0, table_1.resolveTables)(this, iac.tables, iac.tags, context);
|
|
71
|
-
// Define Buckets
|
|
72
|
-
(0, bucket_1.resolveBuckets)(this, iac.buckets, context);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.RosStack = RosStack;
|
|
@@ -1,46 +0,0 @@
|
|
|
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.calcRefs)(stages, context) });
|
|
45
|
-
};
|
|
46
|
-
exports.resolveStages = resolveStages;
|
|
@@ -1,95 +0,0 @@
|
|
|
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.resolveTables = void 0;
|
|
37
|
-
const rosRos = __importStar(require("@alicloud/ros-cdk-ros"));
|
|
38
|
-
const lodash_1 = require("lodash");
|
|
39
|
-
const common_1 = require("../../common");
|
|
40
|
-
const tableEngineMap = new Map([
|
|
41
|
-
[
|
|
42
|
-
"TABLE_STORE_C" /* TableEnum.TABLE_STORE_C */,
|
|
43
|
-
{
|
|
44
|
-
clusterType: 'HYBRID',
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
[
|
|
48
|
-
"TABLE_STORE_H" /* TableEnum.TABLE_STORE_H */,
|
|
49
|
-
{
|
|
50
|
-
clusterType: 'SSD',
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
]);
|
|
54
|
-
const resolveTables = (scope, tables, tags, context) => {
|
|
55
|
-
if ((0, lodash_1.isEmpty)(tables)) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
tables.forEach((tableDomain) => {
|
|
59
|
-
const { collection, throughput, attributes, keySchema, network } = tableDomain;
|
|
60
|
-
const primaryKey = keySchema.map((key) => {
|
|
61
|
-
const name = (0, common_1.calcRefs)(key.name, context);
|
|
62
|
-
const type = attributes.find((attribute) => (0, common_1.calcRefs)(attribute.name, context) === name)?.type ||
|
|
63
|
-
'STRING';
|
|
64
|
-
return { name, type: (0, common_1.calcRefs)(type, context) };
|
|
65
|
-
});
|
|
66
|
-
const columns = attributes
|
|
67
|
-
?.filter(({ name }) => !primaryKey.find((pk) => pk.name === (0, common_1.calcRefs)(name, context)))
|
|
68
|
-
.map((attribute) => ({
|
|
69
|
-
name: (0, common_1.calcRefs)(attribute.name, context),
|
|
70
|
-
type: (0, common_1.calcRefs)(attribute.type, context),
|
|
71
|
-
})) || [];
|
|
72
|
-
const clusterType = tableEngineMap.get((0, common_1.calcRefs)(tableDomain.type, context))?.clusterType;
|
|
73
|
-
new rosRos.RosCustomResource(scope, tableDomain.key, {
|
|
74
|
-
serviceToken: `acs:fc:${context.region}:${context.accountId}:functions/${common_1.SI_BOOTSTRAP_FC_PREFIX}-${context.accountId}-${context.region}`,
|
|
75
|
-
timeout: 600,
|
|
76
|
-
parameters: {
|
|
77
|
-
resource: (0, common_1.calcRefs)(tableDomain.type, context),
|
|
78
|
-
instanceName: (0, common_1.calcRefs)(collection, context),
|
|
79
|
-
tableName: (0, common_1.calcRefs)(tableDomain.name, context),
|
|
80
|
-
primaryKey,
|
|
81
|
-
columns,
|
|
82
|
-
clusterType,
|
|
83
|
-
network,
|
|
84
|
-
reservedThroughput: (0, common_1.calcRefs)(throughput?.reserved, context),
|
|
85
|
-
tags,
|
|
86
|
-
credentials: {
|
|
87
|
-
accessKeyId: context.accessKeyId,
|
|
88
|
-
accessKeySecret: context.accessKeySecret,
|
|
89
|
-
securityToken: context.securityToken,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
}, true);
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
exports.resolveTables = resolveTables;
|
|
@@ -1,11 +0,0 @@
|
|
|
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.calcRefs)(tag.value, context);
|
|
8
|
-
return acc;
|
|
9
|
-
}, {});
|
|
10
|
-
};
|
|
11
|
-
exports.resolveTags = resolveTags;
|
|
@@ -1,49 +0,0 @@
|
|
|
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.resolveVars = 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 resolveVars = (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.resolveVars = resolveVars;
|
|
@@ -1,55 +0,0 @@
|
|
|
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
|
-
import { BucketDomain, BucketRaw } from './domains/bucket';
|
|
8
|
-
import { TableDomain, TableRaw } from './domains/table';
|
|
9
|
-
export * from './domains/database';
|
|
10
|
-
export * from './domains/event';
|
|
11
|
-
export * from './domains/function';
|
|
12
|
-
export * from './domains/tag';
|
|
13
|
-
export * from './domains/vars';
|
|
14
|
-
export * from './domains/context';
|
|
15
|
-
export * from './domains/bucket';
|
|
16
|
-
export * from './assets';
|
|
17
|
-
export type ServerlessIacRaw = {
|
|
18
|
-
version: string;
|
|
19
|
-
provider: Provider;
|
|
20
|
-
vars: Vars;
|
|
21
|
-
stages: Stages;
|
|
22
|
-
service: string;
|
|
23
|
-
tags: Tags;
|
|
24
|
-
functions: {
|
|
25
|
-
[key: string]: FunctionRaw;
|
|
26
|
-
};
|
|
27
|
-
events: {
|
|
28
|
-
[key: string]: EventRaw;
|
|
29
|
-
};
|
|
30
|
-
databases: {
|
|
31
|
-
[key: string]: DatabaseRaw;
|
|
32
|
-
};
|
|
33
|
-
tables: {
|
|
34
|
-
[key: string]: TableRaw;
|
|
35
|
-
};
|
|
36
|
-
buckets: {
|
|
37
|
-
[key: string]: BucketRaw;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export type ServerlessIac = {
|
|
41
|
-
version: string;
|
|
42
|
-
provider: Provider;
|
|
43
|
-
service: string;
|
|
44
|
-
vars?: Vars;
|
|
45
|
-
stages?: Stages;
|
|
46
|
-
tags?: Array<{
|
|
47
|
-
key: string;
|
|
48
|
-
value: string;
|
|
49
|
-
}>;
|
|
50
|
-
functions?: Array<FunctionDomain>;
|
|
51
|
-
events?: Array<EventDomain>;
|
|
52
|
-
databases?: Array<DatabaseDomain>;
|
|
53
|
-
tables?: Array<TableDomain>;
|
|
54
|
-
buckets?: Array<BucketDomain>;
|
|
55
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { IncomingMessage } from 'node:http';
|
|
2
|
-
import { ServerlessIac } from '../index';
|
|
3
|
-
export declare enum RouteKind {
|
|
4
|
-
SI_FUNCTIONS = "SI_FUNCTIONS",
|
|
5
|
-
SI_BUCKETS = "SI_BUCKETS",
|
|
6
|
-
SI_WEBSITE_BUCKETS = "SI_WEBSITE_BUCKETS",
|
|
7
|
-
SI_EVENTS = "SI_EVENTS"
|
|
8
|
-
}
|
|
9
|
-
export type ParsedRequest = {
|
|
10
|
-
kind: RouteKind;
|
|
11
|
-
identifier: string;
|
|
12
|
-
url: string;
|
|
13
|
-
method: string;
|
|
14
|
-
query: Record<string, string>;
|
|
15
|
-
rawUrl: string;
|
|
16
|
-
};
|
|
17
|
-
export type RouteResponse = {
|
|
18
|
-
statusCode: number;
|
|
19
|
-
headers?: Record<string, string>;
|
|
20
|
-
body?: unknown;
|
|
21
|
-
};
|
|
22
|
-
export type RouteHandler = (req: IncomingMessage, parsed: ParsedRequest, iac: ServerlessIac) => Promise<RouteResponse | void> | RouteResponse | void;
|
|
23
|
-
export type FunctionOptions = {
|
|
24
|
-
codeDir: string;
|
|
25
|
-
functionKey: string;
|
|
26
|
-
handler: string;
|
|
27
|
-
servicePath: string;
|
|
28
|
-
timeout: number;
|
|
29
|
-
};
|
|
30
|
-
export type AliyunApiGatewayContext = {
|
|
31
|
-
requestId: string;
|
|
32
|
-
region: string;
|
|
33
|
-
accountId: string;
|
|
34
|
-
credentials: {
|
|
35
|
-
accessKeyId: string;
|
|
36
|
-
accessKeySecret: string;
|
|
37
|
-
securityToken: string;
|
|
38
|
-
};
|
|
39
|
-
function: {
|
|
40
|
-
name: string;
|
|
41
|
-
handler: string;
|
|
42
|
-
memory: number;
|
|
43
|
-
timeout: number;
|
|
44
|
-
initializer: string;
|
|
45
|
-
};
|
|
46
|
-
service: {
|
|
47
|
-
name: string;
|
|
48
|
-
logProject: string;
|
|
49
|
-
logStore: string;
|
|
50
|
-
qualifier: string;
|
|
51
|
-
versionId: string;
|
|
52
|
-
};
|
|
53
|
-
tracing: {
|
|
54
|
-
spanContext: string;
|
|
55
|
-
jaegerEndpoint: string;
|
|
56
|
-
spanBaggages: Record<string, string>;
|
|
57
|
-
parseOpenTracingBaggages: () => Record<string, string>;
|
|
58
|
-
};
|
|
59
|
-
logger: {
|
|
60
|
-
debug: (message: string) => void;
|
|
61
|
-
info: (message: string) => void;
|
|
62
|
-
warn: (message: string) => void;
|
|
63
|
-
error: (message: string) => void;
|
|
64
|
-
log: (message: string) => void;
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
export type AliyunServerlessEvent = {
|
|
68
|
-
path: string;
|
|
69
|
-
httpMethod: string;
|
|
70
|
-
headers: Record<string, string>;
|
|
71
|
-
queryParameters: Record<string, string>;
|
|
72
|
-
pathParameters: Record<string, string>;
|
|
73
|
-
body: string | undefined;
|
|
74
|
-
isBase64Encoded: boolean;
|
|
75
|
-
};
|
|
76
|
-
export type AliyunFCResponse = {
|
|
77
|
-
isBase64Encoded: boolean;
|
|
78
|
-
statusCode: string | number;
|
|
79
|
-
headers?: Record<string, string>;
|
|
80
|
-
body: string | unknown;
|
|
81
|
-
};
|