@geek-fun/serverlessinsight 0.3.0 → 0.3.2

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 (47) hide show
  1. package/dist/package.json +40 -37
  2. package/dist/src/commands/deploy.js +2 -2
  3. package/dist/src/commands/destroy.js +2 -1
  4. package/dist/src/commands/index.js +32 -16
  5. package/dist/src/commands/local.js +35 -0
  6. package/dist/src/commands/template.js +3 -3
  7. package/dist/src/commands/validate.js +3 -2
  8. package/dist/src/common/constants.js +5 -2
  9. package/dist/src/common/{actionContext.js → context.js} +30 -9
  10. package/dist/src/common/iacHelper.js +54 -27
  11. package/dist/src/common/index.d.ts +1 -1
  12. package/dist/src/common/index.js +1 -1
  13. package/dist/src/common/rosAssets.js +34 -8
  14. package/dist/src/common/rosClient.js +6 -4
  15. package/dist/src/parser/index.js +2 -0
  16. package/dist/src/parser/tableParser.js +41 -0
  17. package/dist/src/stack/deploy.js +30 -13
  18. package/dist/src/stack/localStack/event.js +38 -0
  19. package/dist/src/stack/localStack/index.d.ts +2 -0
  20. package/dist/src/stack/localStack/index.js +23 -0
  21. package/dist/src/stack/rfsStack/index.d.ts +2 -2
  22. package/dist/src/stack/rfsStack/index.js +2 -1
  23. package/dist/src/stack/rosStack/bootstrap.js +157 -8
  24. package/dist/src/stack/rosStack/bucket.js +13 -12
  25. package/dist/src/stack/rosStack/database.js +11 -12
  26. package/dist/src/stack/rosStack/event.js +21 -21
  27. package/dist/src/stack/rosStack/function.js +66 -46
  28. package/dist/src/stack/rosStack/index.d.ts +2 -2
  29. package/dist/src/stack/rosStack/index.js +6 -3
  30. package/dist/src/stack/rosStack/stage.js +1 -1
  31. package/dist/src/stack/rosStack/table.js +95 -0
  32. package/dist/src/stack/rosStack/tag.js +1 -1
  33. package/dist/src/stack/rosStack/vars.js +3 -3
  34. package/dist/src/types/domains/table.js +16 -0
  35. package/dist/src/types/index.d.ts +5 -0
  36. package/dist/src/validator/functionSchema.js +1 -1
  37. package/dist/src/validator/iacSchema.js +2 -0
  38. package/dist/src/validator/rootSchema.js +3 -0
  39. package/dist/src/validator/tableschema.js +72 -0
  40. package/dist/tsconfig.tsbuildinfo +1 -1
  41. package/layers/si-bootstrap-sdk/Dockerfile-aliyuncli +12 -0
  42. package/layers/si-bootstrap-sdk/README.md +1 -0
  43. package/layers/si-bootstrap-sdk/package-lock.json +875 -0
  44. package/layers/si-bootstrap-sdk/package.json +33 -0
  45. package/package.json +40 -37
  46. package/samples/aliyun-poc-fc-gpu.yml +23 -22
  47. package/samples/aliyun-poc-table.yml +48 -0
@@ -39,10 +39,10 @@ const common_1 = require("../../common");
39
39
  const fc = __importStar(require("@alicloud/ros-cdk-fc3"));
40
40
  const lodash_1 = require("lodash");
41
41
  const ossDeployment = __importStar(require("@alicloud/ros-cdk-ossdeployment"));
42
- const ros = __importStar(require("@alicloud/ros-cdk-core"));
43
42
  const sls = __importStar(require("@alicloud/ros-cdk-sls"));
44
43
  const nas = __importStar(require("@alicloud/ros-cdk-nas"));
45
44
  const ecs = __importStar(require("@alicloud/ros-cdk-ecs"));
45
+ const vpc = __importStar(require("@alicloud/ros-cdk-vpc"));
46
46
  const storageClassMap = {
47
47
  [types_1.NasStorageClassEnum.STANDARD_CAPACITY]: { fileSystemType: 'standard', storageType: 'Capacity' },
48
48
  [types_1.NasStorageClassEnum.STANDARD_PERFORMANCE]: {
@@ -95,14 +95,17 @@ const resolveFunctions = (scope, functions, tags, context, service) => {
95
95
  }
96
96
  let logConfig = undefined;
97
97
  const enableLog = functions?.some(({ log }) => log);
98
- const slsService = new sls.Project(scope, `${service}_sls`, { name: `${service}-sls`, tags: (0, common_1.replaceReference)(tags, context) }, true);
99
- const slsLogstore = new sls.Logstore(scope, `${service}_sls_logstore`, {
100
- logstoreName: `${service}-sls-logstore`,
101
- projectName: slsService.attrName,
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,
102
105
  ttl: 7,
103
106
  }, true);
104
- new sls.Index(scope, `${service}_sls_index`, {
105
- projectName: slsService.attrName,
107
+ new sls.Index(scope, slsIndexId, {
108
+ projectName: slsProject.attrName,
106
109
  logstoreName: slsLogstore.attrLogstoreName,
107
110
  fullTextIndex: { enable: true },
108
111
  }, true);
@@ -116,99 +119,118 @@ const resolveFunctions = (scope, functions, tags, context, service) => {
116
119
  const fileSources = functions
117
120
  ?.filter(({ code }) => code?.path && (0, common_1.readCodeSize)(code.path) > common_1.CODE_ZIP_SIZE_LIMIT)
118
121
  .map(({ code, name }) => {
119
- const fcName = (0, common_1.replaceReference)(name, context);
122
+ const fcName = (0, common_1.calcRefs)(name, context);
120
123
  return { fcName, ...(0, common_1.getFileSource)(fcName, code.path) };
121
124
  });
122
- const destinationBucketName = ros.Fn.sub('si-bootstrap-artifacts-${ALIYUN::AccountId}-${ALIYUN::Region}');
123
- const ossDeploymentId = `${service}_artifacts_code_deployment`;
125
+ const destinationBucketName = `${common_1.SI_BOOTSTRAP_BUCKET_PREFIX}-${context.accountId}-${context.region}`;
126
+ const ossDeploymentId = 'si_auto_artifacts_code_deployment';
124
127
  if (!(0, lodash_1.isEmpty)(fileSources)) {
125
128
  new ossDeployment.BucketDeployment(scope, ossDeploymentId, {
126
129
  sources: fileSources.map(({ source }) => source),
127
130
  destinationBucket: destinationBucketName,
128
- timeout: 3000,
131
+ timeout: common_1.OSS_DEPLOYMENT_TIMEOUT,
129
132
  logMonitoring: false,
130
133
  retainOnCreate: false,
131
134
  }, true);
132
135
  }
133
136
  functions?.forEach((fnc) => {
134
137
  let runtimeConfig;
135
- const storeInBucket = !!fnc.code?.path && (0, common_1.readCodeSize)(fnc.code.path) > common_1.CODE_ZIP_SIZE_LIMIT;
138
+ const storeInBucket = !!fnc.code?.path && (0, common_1.readCodeSize)((0, common_1.calcValue)(fnc.code.path, context)) > common_1.CODE_ZIP_SIZE_LIMIT;
136
139
  if (fnc.container) {
137
140
  runtimeConfig = {
138
141
  runtime: 'custom-container',
139
142
  handler: 'index.handler',
140
143
  customContainerConfig: {
141
- image: fnc.container.image,
142
- command: fnc.container.cmd?.split(' '),
143
- port: fnc.container.port,
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),
144
147
  },
145
148
  };
146
149
  }
147
150
  else {
148
151
  let code = {
149
- zipFile: (0, common_1.resolveCode)(fnc.code.path),
152
+ zipFile: (0, common_1.resolveCode)((0, common_1.calcValue)(fnc.code.path, context)),
150
153
  };
151
154
  if (storeInBucket) {
152
155
  code = {
153
156
  ossBucketName: destinationBucketName,
154
- ossObjectName: fileSources?.find(({ fcName }) => fcName === (0, common_1.replaceReference)(fnc.name, context))?.objectKey,
157
+ ossObjectName: fileSources?.find(({ fcName }) => fcName === (0, common_1.calcRefs)(fnc.name, context))
158
+ ?.objectKey,
155
159
  };
156
160
  }
157
161
  runtimeConfig = {
158
162
  code,
159
- handler: (0, common_1.replaceReference)(fnc.code.handler, context),
160
- runtime: (0, common_1.replaceReference)(fnc.code.runtime, context),
163
+ handler: (0, common_1.calcRefs)(fnc.code.handler, context),
164
+ runtime: (0, common_1.calcRefs)(fnc.code.runtime, context),
161
165
  };
162
166
  }
163
167
  let vpcConfig = undefined;
164
168
  if (fnc.network) {
165
- const securityGroup = new ecs.SecurityGroup(scope, `${fnc.key}_security_group`, {
169
+ const securityGroup = new ecs.SecurityGroup(scope, (0, common_1.formatRosId)(`${fnc.key}_security_group`), {
166
170
  securityGroupName: fnc.network.security_group.name,
167
- vpcId: (0, common_1.replaceReference)(fnc.network.vpc_id, context),
168
- tags: (0, common_1.replaceReference)(tags, context),
171
+ vpcId: (0, common_1.calcRefs)(fnc.network.vpc_id, context),
172
+ tags: (0, common_1.calcRefs)(tags, context),
169
173
  securityGroupIngress: transformSecurityRules(fnc.network.security_group.ingress, 'INGRESS'),
170
174
  securityGroupEgress: transformSecurityRules(fnc.network.security_group.egress, 'EGRESS'),
171
175
  }, true);
172
176
  vpcConfig = {
173
- vpcId: (0, common_1.replaceReference)(fnc.network.vpc_id, context),
174
- vSwitchIds: (0, common_1.replaceReference)(fnc.network.subnet_ids, context),
177
+ vpcId: (0, common_1.calcRefs)(fnc.network.vpc_id, context),
178
+ vSwitchIds: (0, common_1.calcRefs)(fnc.network.subnet_ids, context),
175
179
  securityGroupId: securityGroup.attrSecurityGroupId,
176
180
  };
177
181
  }
178
182
  let fcNas;
179
183
  if (fnc.storage?.nas) {
180
184
  fcNas = fnc.storage.nas.map((nasItem) => {
181
- const { fileSystemType, storageType } = storageClassMap[nasItem.storage_class];
182
- const accessGroup = new nas.AccessGroup(scope, `${fnc.key}_nas_access_${(0, common_1.encodeBase64ForRosId)(nasItem.mount_path)}`, {
183
- accessGroupName: `${fnc.name}-nas-access-${(0, common_1.encodeBase64ForRosId)(nasItem.mount_path)}`,
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),
184
191
  accessGroupType: 'Vpc',
185
192
  }, true);
186
- const nasResource = new nas.FileSystem(scope, `${fnc.key}_nas_${(0, common_1.encodeBase64ForRosId)(nasItem.mount_path)}`, {
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}`), {
187
204
  fileSystemType,
188
205
  storageType,
189
206
  protocolType: 'NFS',
190
207
  tags: [
191
- ...((0, common_1.replaceReference)(tags, context) ?? []),
192
- { key: 'function-name', value: fnc.name },
208
+ ...((0, common_1.calcRefs)(tags, context) ?? []),
209
+ { key: 'function-name', value: (0, common_1.calcRefs)(fnc.name, context) },
193
210
  ],
194
211
  }, true);
195
- const nasMountTarget = new nas.MountTarget(scope, `${fnc.key}_nas_mount_${(0, common_1.encodeBase64ForRosId)(nasItem.mount_path)}`, {
212
+ const nasMountTarget = new nas.MountTarget(scope, nasMountTargetId, {
196
213
  fileSystemId: nasResource.attrFileSystemId,
197
214
  networkType: 'Vpc',
198
215
  accessGroupName: accessGroup.attrAccessGroupName,
199
- vpcId: fnc.network.vpc_id,
200
- vSwitchId: fnc.network.subnet_ids[0],
216
+ vpcId: (0, common_1.calcRefs)(fnc.network.vpc_id, context),
217
+ vSwitchId: (0, common_1.calcRefs)(fnc.network.subnet_ids[0], context),
201
218
  }, true);
202
- return { nas: nasResource, nasMount: nasMountTarget, mountDir: nasItem.mount_path };
219
+ return {
220
+ nas: nasResource,
221
+ nasMount: nasMountTarget,
222
+ mountDir: (0, common_1.calcRefs)(nasItem.mount_path, context),
223
+ nasMountTargetId,
224
+ };
203
225
  });
204
226
  }
205
227
  const fcn = new fc.RosFunction(scope, fnc.key, {
206
- functionName: (0, common_1.replaceReference)(fnc.name, context),
207
- memorySize: (0, common_1.replaceReference)(fnc.memory, context),
208
- diskSize: fnc.storage?.disk,
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),
209
231
  gpuConfig: transformGpuConfig(fnc.gpu),
210
- timeout: (0, common_1.replaceReference)(fnc.timeout, context),
211
- environmentVariables: (0, common_1.replaceReference)(fnc.environment, context),
232
+ timeout: (0, common_1.calcRefs)(fnc.timeout, context),
233
+ environmentVariables: (0, common_1.calcRefs)(fnc.environment, context),
212
234
  logConfig,
213
235
  vpcConfig,
214
236
  ...runtimeConfig,
@@ -222,17 +244,15 @@ const resolveFunctions = (scope, functions, tags, context, service) => {
222
244
  : undefined,
223
245
  }, true);
224
246
  if (enableLog) {
225
- fcn.addRosDependency(`${service}_sls`);
226
- fcn.addRosDependency(`${service}_sls_logstore`);
227
- fcn.addRosDependency(`${service}_sls_index`);
247
+ fcn.addRosDependency(slsProjectId);
248
+ fcn.addRosDependency(slsLogstoreId);
249
+ fcn.addRosDependency(slsIndexId);
228
250
  }
229
251
  if (storeInBucket) {
230
- fcn.addRosDependency(`${service}_artifacts_code_deployment`);
252
+ fcn.addRosDependency(ossDeploymentId);
231
253
  }
232
254
  if (fcNas?.length) {
233
- fcNas.forEach((nasItem) => {
234
- fcn.addRosDependency(`${fnc.key}_nas_mount_${(0, common_1.encodeBase64ForRosId)(nasItem.mountDir)}`);
235
- });
255
+ fcNas.forEach(({ nasMountTargetId }) => fcn.addRosDependency(nasMountTargetId));
236
256
  }
237
257
  });
238
258
  };
@@ -1,7 +1,7 @@
1
1
  import * as ros from '@alicloud/ros-cdk-core';
2
- import { ActionContext, ServerlessIac } from '../../types';
2
+ import { Context, ServerlessIac } from '../../types';
3
3
  export * from './bootstrap';
4
4
  export declare class RosStack extends ros.Stack {
5
5
  private readonly service;
6
- constructor(scope: ros.Construct, iac: ServerlessIac, context: ActionContext);
6
+ constructor(scope: ros.Construct, iac: ServerlessIac, context: Context);
7
7
  }
@@ -46,17 +46,18 @@ const vars_1 = require("./vars");
46
46
  const database_1 = require("./database");
47
47
  const event_1 = require("./event");
48
48
  const bucket_1 = require("./bucket");
49
+ const table_1 = require("./table");
49
50
  __exportStar(require("./bootstrap"), exports);
50
51
  class RosStack extends ros.Stack {
51
52
  constructor(scope, iac, context) {
52
- super(scope, (0, common_1.replaceReference)(iac.service, context), {
53
+ super(scope, (0, common_1.calcRefs)(iac.service, context), {
53
54
  stackName: context.stackName,
54
55
  tags: (0, tag_1.resolveTags)(iac.tags, context),
55
56
  });
56
- this.service = (0, common_1.replaceReference)(iac.service, context);
57
+ this.service = (0, common_1.calcRefs)(iac.service, context);
57
58
  new ros.RosInfo(this, ros.RosInfo.description, `${this.service} stack`);
58
59
  // Define Parameters
59
- (0, vars_1.resloveVars)(this, iac.vars);
60
+ (0, vars_1.resolveVars)(this, iac.vars);
60
61
  // Define Mappings
61
62
  (0, stage_1.resolveStages)(this, iac.stages, context);
62
63
  // Define functions
@@ -65,6 +66,8 @@ class RosStack extends ros.Stack {
65
66
  (0, event_1.resolveEvents)(this, iac.events, iac.tags, context, this.service);
66
67
  // Define Databases
67
68
  (0, database_1.resolveDatabases)(this, iac.databases, context);
69
+ // Define Tables
70
+ (0, table_1.resolveTables)(this, iac.tables, iac.tags, context);
68
71
  // Define Buckets
69
72
  (0, bucket_1.resolveBuckets)(this, iac.buckets, context);
70
73
  }
@@ -41,6 +41,6 @@ const resolveStages = (scope, stages, context) => {
41
41
  if ((0, lodash_1.isEmpty)(stages)) {
42
42
  return undefined;
43
43
  }
44
- new ros.RosMapping(scope, 'stages', { mapping: (0, common_1.replaceReference)(stages, context) });
44
+ new ros.RosMapping(scope, 'stages', { mapping: (0, common_1.calcRefs)(stages, context) });
45
45
  };
46
46
  exports.resolveStages = resolveStages;
@@ -0,0 +1,95 @@
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;
@@ -4,7 +4,7 @@ exports.resolveTags = void 0;
4
4
  const common_1 = require("../../common");
5
5
  const resolveTags = (tags, context) => {
6
6
  return tags?.reduce((acc, tag) => {
7
- acc[tag.key] = (0, common_1.replaceReference)(tag.value, context);
7
+ acc[tag.key] = (0, common_1.calcRefs)(tag.value, context);
8
8
  return acc;
9
9
  }, {});
10
10
  };
@@ -33,11 +33,11 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.resloveVars = void 0;
36
+ exports.resolveVars = void 0;
37
37
  const ros = __importStar(require("@alicloud/ros-cdk-core"));
38
38
  const ros_cdk_core_1 = require("@alicloud/ros-cdk-core");
39
39
  const lodash_1 = require("lodash");
40
- const resloveVars = (scope, vars) => {
40
+ const resolveVars = (scope, vars) => {
41
41
  if ((0, lodash_1.isEmpty)(vars)) {
42
42
  return undefined;
43
43
  }
@@ -46,4 +46,4 @@ const resloveVars = (scope, vars) => {
46
46
  defaultValue: value,
47
47
  }));
48
48
  };
49
- exports.resloveVars = resloveVars;
49
+ exports.resolveVars = resolveVars;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KeyTypeEnum = exports.AttributeTypeEnum = void 0;
4
+ var AttributeTypeEnum;
5
+ (function (AttributeTypeEnum) {
6
+ AttributeTypeEnum["STRING"] = "STRING";
7
+ AttributeTypeEnum["INTEGER"] = "INTEGER";
8
+ AttributeTypeEnum["DOUBLE"] = "DOUBLE";
9
+ AttributeTypeEnum["BOOLEAN"] = "BOOLEAN";
10
+ AttributeTypeEnum["BINARY"] = "BINARY";
11
+ })(AttributeTypeEnum || (exports.AttributeTypeEnum = AttributeTypeEnum = {}));
12
+ var KeyTypeEnum;
13
+ (function (KeyTypeEnum) {
14
+ KeyTypeEnum["HASH"] = "HASH";
15
+ KeyTypeEnum["RANGE"] = "RANGE";
16
+ })(KeyTypeEnum || (exports.KeyTypeEnum = KeyTypeEnum = {}));
@@ -5,6 +5,7 @@ import { DatabaseDomain, DatabaseRaw } from './domains/database';
5
5
  import { FunctionDomain, FunctionRaw } from './domains/function';
6
6
  import { Provider } from './domains/provider';
7
7
  import { BucketDomain, BucketRaw } from './domains/bucket';
8
+ import { TableDomain, TableRaw } from './domains/table';
8
9
  export * from './domains/database';
9
10
  export * from './domains/event';
10
11
  export * from './domains/function';
@@ -29,6 +30,9 @@ export type ServerlessIacRaw = {
29
30
  databases: {
30
31
  [key: string]: DatabaseRaw;
31
32
  };
33
+ tables: {
34
+ [key: string]: TableRaw;
35
+ };
32
36
  buckets: {
33
37
  [key: string]: BucketRaw;
34
38
  };
@@ -46,5 +50,6 @@ export type ServerlessIac = {
46
50
  functions?: Array<FunctionDomain>;
47
51
  events?: Array<EventDomain>;
48
52
  databases?: Array<DatabaseDomain>;
53
+ tables?: Array<TableDomain>;
49
54
  buckets?: Array<BucketDomain>;
50
55
  };
@@ -101,8 +101,8 @@ exports.functionSchema = {
101
101
  storage_class: {
102
102
  type: 'string',
103
103
  enum: [
104
- 'STANDARD_PERFORMANCE',
105
104
  'STANDARD_CAPACITY',
105
+ 'STANDARD_PERFORMANCE',
106
106
  'EXTREME_STANDARD',
107
107
  'EXTREME_ADVANCE',
108
108
  ],
@@ -11,6 +11,7 @@ const databaseSchema_1 = require("./databaseSchema");
11
11
  const eventSchema_1 = require("./eventSchema");
12
12
  const functionSchema_1 = require("./functionSchema");
13
13
  const bucketSchema_1 = require("./bucketSchema");
14
+ const tableschema_1 = require("./tableschema");
14
15
  class IacSchemaErrors extends Error {
15
16
  constructor(errors) {
16
17
  super(`Invalid yaml`);
@@ -31,6 +32,7 @@ const validate = ajv
31
32
  .addSchema(functionSchema_1.functionSchema)
32
33
  .addSchema(eventSchema_1.eventSchema)
33
34
  .addSchema(databaseSchema_1.databaseSchema)
35
+ .addSchema(tableschema_1.tableSchema)
34
36
  .addSchema(bucketSchema_1.bucketSchema)
35
37
  .compile(rootSchema_1.rootSchema);
36
38
  const validateYaml = (iacJson) => {
@@ -49,6 +49,9 @@ exports.rootSchema = {
49
49
  buckets: {
50
50
  $ref: 'https://serverlessinsight.geekfun.club/schemas/bucketschema.json',
51
51
  },
52
+ tables: {
53
+ $ref: 'https://serverlessinsight.geekfun.club/schemas/tableschema.json',
54
+ },
52
55
  },
53
56
  required: ['version', 'provider', 'service'],
54
57
  additionalProperties: false,
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tableSchema = void 0;
4
+ exports.tableSchema = {
5
+ $id: 'https://serverlessinsight.geekfun.club/schemas/tableschema.json',
6
+ type: 'object',
7
+ patternProperties: {
8
+ '.*': {
9
+ type: 'object',
10
+ properties: {
11
+ collection: { type: 'string' },
12
+ name: { type: 'string' },
13
+ type: { type: 'string', enum: ['TABLE_STORE_C', 'TABLE_STORE_H'] },
14
+ desc: { type: 'string', maxLength: 256 },
15
+ network: {
16
+ type: 'object',
17
+ properties: {
18
+ type: { type: 'string', enum: ['PUBLIC', 'PRIVATE'] },
19
+ ingress_rules: {
20
+ type: 'array',
21
+ items: { type: 'string' },
22
+ },
23
+ },
24
+ required: ['type'],
25
+ },
26
+ throughput: {
27
+ type: 'object',
28
+ properties: {
29
+ reserved: {
30
+ type: 'object',
31
+ properties: {
32
+ read: { type: 'integer' },
33
+ write: { type: 'integer' },
34
+ },
35
+ },
36
+ on_demand: {
37
+ type: 'object',
38
+ properties: {
39
+ read: { type: 'integer' },
40
+ write: { type: 'integer' },
41
+ },
42
+ },
43
+ },
44
+ },
45
+ key_schema: {
46
+ type: 'array',
47
+ items: {
48
+ type: 'object',
49
+ properties: {
50
+ name: { type: 'string' },
51
+ type: { type: 'string', enum: ['HASH', 'RANGE'] },
52
+ },
53
+ required: ['name', 'type'],
54
+ },
55
+ },
56
+ attributes: {
57
+ type: 'array',
58
+ items: {
59
+ type: 'object',
60
+ properties: {
61
+ name: { type: 'string' },
62
+ type: { type: 'string', enum: ['STRING', 'INTEGER', 'DOUBLE', 'BOOLEAN', 'BINARY'] },
63
+ },
64
+ required: ['name', 'type'],
65
+ },
66
+ },
67
+ },
68
+ required: ['collection', 'name', 'type', 'key_schema', 'attributes'],
69
+ additionalProperties: false,
70
+ },
71
+ },
72
+ };
@@ -1 +1 @@
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/domainHelper.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/rosAssets.ts","../src/common/rosClient.ts","../src/lang/index.ts","../src/parser/bucketParser.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/bucket.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/bucket.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/bucketSchema.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"}
1
+ {"root":["../src/index.ts","../src/commands/deploy.ts","../src/commands/destroy.ts","../src/commands/index.ts","../src/commands/local.ts","../src/commands/template.ts","../src/commands/validate.ts","../src/common/base64.ts","../src/common/constants.ts","../src/common/context.ts","../src/common/domainHelper.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/rosAssets.ts","../src/common/rosClient.ts","../src/lang/index.ts","../src/parser/bucketParser.ts","../src/parser/databaseParser.ts","../src/parser/eventParser.ts","../src/parser/functionParser.ts","../src/parser/index.ts","../src/parser/tableParser.ts","../src/parser/tagParser.ts","../src/stack/deploy.ts","../src/stack/index.ts","../src/stack/localStack/event.ts","../src/stack/localStack/index.ts","../src/stack/rfsStack/function.ts","../src/stack/rfsStack/index.ts","../src/stack/rosStack/bootstrap.ts","../src/stack/rosStack/bucket.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/table.ts","../src/stack/rosStack/tag.ts","../src/stack/rosStack/vars.ts","../src/types/assets.ts","../src/types/index.ts","../src/types/domains/bucket.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/table.ts","../src/types/domains/tag.ts","../src/types/domains/vars.ts","../src/validator/bucketSchema.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","../src/validator/tableschema.ts"],"version":"5.9.2"}
@@ -0,0 +1,12 @@
1
+ FROM alpine:latest
2
+
3
+ RUN apk update && apk add --no-cache jq
4
+
5
+ # install aliyuncli
6
+ RUN wget https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz
7
+ RUN tar -xvzf aliyun-cli-linux-latest-amd64.tgz
8
+ RUN rm aliyun-cli-linux-latest-amd64.tgz
9
+ RUN mv aliyun /usr/local/bin/
10
+
11
+ # 注意:alpine需要额外创建 lib64 的动态链接库软连接
12
+ RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
@@ -0,0 +1 @@
1
+ # ServerlessInsight bootstrap SDK