@geek-fun/serverlessinsight 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +40 -38
- package/dist/src/commands/deploy.js +1 -1
- package/dist/src/commands/destroy.js +1 -1
- package/dist/src/commands/index.js +22 -7
- package/dist/src/commands/local.js +35 -0
- package/dist/src/commands/template.js +2 -2
- package/dist/src/commands/validate.js +2 -2
- package/dist/src/common/constants.js +4 -2
- package/dist/src/common/context.js +33 -12
- package/dist/src/common/iacHelper.js +1 -1
- package/dist/src/common/rosAssets.js +1 -0
- package/dist/src/common/rosClient.js +1 -1
- package/dist/src/parser/index.js +2 -0
- package/dist/src/parser/tableParser.js +41 -0
- package/dist/src/stack/localStack/event.js +38 -0
- package/dist/src/stack/localStack/index.d.ts +2 -0
- package/dist/src/stack/localStack/index.js +23 -0
- package/dist/src/stack/rosStack/bootstrap.js +153 -5
- package/dist/src/stack/rosStack/bucket.js +1 -0
- package/dist/src/stack/rosStack/database.js +1 -2
- package/dist/src/stack/rosStack/function.js +1 -2
- package/dist/src/stack/rosStack/index.js +3 -0
- package/dist/src/stack/rosStack/table.js +95 -0
- package/dist/src/types/domains/table.js +16 -0
- package/dist/src/types/index.d.ts +5 -0
- package/dist/src/validator/iacSchema.js +2 -0
- package/dist/src/validator/rootSchema.js +3 -0
- package/dist/src/validator/tableschema.js +72 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/layers/si-bootstrap-sdk/Dockerfile-aliyuncli +12 -0
- package/layers/si-bootstrap-sdk/README.md +1 -0
- package/layers/si-bootstrap-sdk/package-lock.json +875 -0
- package/layers/si-bootstrap-sdk/package.json +33 -0
- package/package.json +40 -38
- package/samples/aliyun-poc-table.yml +48 -0
|
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.prepareBootstrapStack = void 0;
|
|
4
4
|
const common_1 = require("../../common");
|
|
5
5
|
const getBootstrapTemplate = async (context) => {
|
|
6
|
-
const
|
|
7
|
-
const stackName = `si-bootstrap-${iamInfo?.accountId}-${context.region}`;
|
|
6
|
+
const stackName = `si-bootstrap-${context.accountId}-${context.region}`;
|
|
8
7
|
const template = {
|
|
9
8
|
Description: 'ServerlessInsight Bootstrap Stack',
|
|
10
9
|
Metadata: {
|
|
@@ -17,9 +16,7 @@ const getBootstrapTemplate = async (context) => {
|
|
|
17
16
|
si_auto_artifacts_bucket: {
|
|
18
17
|
Type: 'ALIYUN::OSS::Bucket',
|
|
19
18
|
Properties: {
|
|
20
|
-
BucketName: {
|
|
21
|
-
'Fn::Sub': 'si-bootstrap-artifacts-${ALIYUN::AccountId}-${ALIYUN::Region}',
|
|
22
|
-
},
|
|
19
|
+
BucketName: `${common_1.SI_BOOTSTRAP_BUCKET_PREFIX}-${context.accountId}-${context.region}`,
|
|
23
20
|
AccessControl: 'private',
|
|
24
21
|
DeletionForce: false,
|
|
25
22
|
EnableOssHdfsService: false,
|
|
@@ -29,6 +26,157 @@ const getBootstrapTemplate = async (context) => {
|
|
|
29
26
|
},
|
|
30
27
|
},
|
|
31
28
|
},
|
|
29
|
+
si_auto_bootstrap_api_lambda: {
|
|
30
|
+
Type: 'ALIYUN::FC3::Function',
|
|
31
|
+
Properties: {
|
|
32
|
+
FunctionName: `${common_1.SI_BOOTSTRAP_FC_PREFIX}-${context.accountId}-${context.region}`,
|
|
33
|
+
Description: 'ServerlessInsight Bootstrap API',
|
|
34
|
+
Handler: 'index.handler',
|
|
35
|
+
Runtime: 'nodejs20',
|
|
36
|
+
Layers: [
|
|
37
|
+
`acs:fc:${context.region}:${context.accountId}:layers/si-bootstrap-sdk/versions/18`,
|
|
38
|
+
],
|
|
39
|
+
Code: {
|
|
40
|
+
SourceCode: `
|
|
41
|
+
const { bootstrapHandler } = require('@geek-fun/si-bootstrap-sdk');
|
|
42
|
+
|
|
43
|
+
module.exports.handler = async (rawEvent, context) => {
|
|
44
|
+
// 处理 Buffer 类型的事件
|
|
45
|
+
const event = parseEvent(rawEvent);
|
|
46
|
+
|
|
47
|
+
const commonResponse = {
|
|
48
|
+
RequestId: event.requestId,
|
|
49
|
+
LogicalResourceId: event.logicalResourceId,
|
|
50
|
+
StackId: event.stackId
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
// 处理业务逻辑
|
|
55
|
+
const result = await bootstrapHandler(event);
|
|
56
|
+
|
|
57
|
+
// 构建符合 ROS 要求的响应结构
|
|
58
|
+
const rosResponse = {
|
|
59
|
+
...commonResponse,
|
|
60
|
+
Status: result.status,
|
|
61
|
+
Reason: result.reason,
|
|
62
|
+
PhysicalResourceId: result.physicalResourceId,
|
|
63
|
+
Data: result.data || {} // 业务数据
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// 如果是删除操作,不需要返回数据
|
|
67
|
+
if (event.requestType === 'Delete') {
|
|
68
|
+
delete rosResponse.Data;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 发送响应到 ROS 服务(如果提供了 ResponseURL)
|
|
72
|
+
if (event.responseURL) {
|
|
73
|
+
await sendResponse(event.responseURL, rosResponse);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 返回成功响应
|
|
77
|
+
return {
|
|
78
|
+
statusCode: 200,
|
|
79
|
+
body: JSON.stringify({
|
|
80
|
+
message: 'Request processed successfully',
|
|
81
|
+
rosResponse
|
|
82
|
+
})
|
|
83
|
+
};
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error('Error:', error);
|
|
86
|
+
|
|
87
|
+
// 构建错误响应
|
|
88
|
+
const errorResponse = {
|
|
89
|
+
...commonResponse,
|
|
90
|
+
Status: 'FAILED',
|
|
91
|
+
Reason: error.message || 'Internal Server Error',
|
|
92
|
+
PhysicalResourceId: 'error-' + Date.now()
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// 发送错误响应到 ROS 服务
|
|
96
|
+
if (event.responseURL) {
|
|
97
|
+
try {
|
|
98
|
+
await sendResponse(event.responseURL, errorResponse);
|
|
99
|
+
} catch (err) {
|
|
100
|
+
console.error('Failed to send error response:', err);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// 返回错误响应
|
|
105
|
+
return {
|
|
106
|
+
statusCode: 500,
|
|
107
|
+
body: JSON.stringify({
|
|
108
|
+
error: 'Internal Server Error',
|
|
109
|
+
details: error.message,
|
|
110
|
+
rosErrorResponse: errorResponse
|
|
111
|
+
})
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// 使用原生 fetch API 发送响应
|
|
117
|
+
async function sendResponse(responseUrl, responseBody) {
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
const body = JSON.stringify(responseBody);
|
|
121
|
+
|
|
122
|
+
const response = await fetch(responseUrl, {
|
|
123
|
+
method: 'POST',
|
|
124
|
+
headers: {
|
|
125
|
+
'Content-Type': 'application/json',
|
|
126
|
+
'Content-Length': Buffer.byteLength(body).toString(),
|
|
127
|
+
'Date': new Date().toUTCString()
|
|
128
|
+
},
|
|
129
|
+
body: body
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
if (!response.ok) {
|
|
133
|
+
const errorText = await response.text();
|
|
134
|
+
throw new Error(\`Failed to send response. Status: \${response.status}, Body: \${errorText}\`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
console.log('Response sent successfully');
|
|
138
|
+
} catch (error) {
|
|
139
|
+
console.error('Error sending response:', error);
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
const parseEvent = (rawEvent) => {
|
|
146
|
+
// 处理 Buffer 类型的事件
|
|
147
|
+
let event;
|
|
148
|
+
if (Buffer.isBuffer(rawEvent)) {
|
|
149
|
+
event = JSON.parse(rawEvent.toString('utf8'));
|
|
150
|
+
} else if (typeof rawEvent === 'string') {
|
|
151
|
+
event = JSON.parse(rawEvent);
|
|
152
|
+
} else {
|
|
153
|
+
event = rawEvent;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const { credentials, ...resourceProperties } = event.ResourceProperties
|
|
157
|
+
return {
|
|
158
|
+
stackId: event.StackId,
|
|
159
|
+
responseURL: event.ResponseURL,
|
|
160
|
+
resourceOwnerId: event.ResourceOwnerId,
|
|
161
|
+
callerId: event.CallerId,
|
|
162
|
+
resourceProperties,
|
|
163
|
+
eventType: event.ResourceType,
|
|
164
|
+
requestType: event.RequestType?.toUpperCase(),
|
|
165
|
+
resourceType: resourceProperties.resource,
|
|
166
|
+
regionId: event.RegionId,
|
|
167
|
+
stackName: event.StackName,
|
|
168
|
+
requestId: event.RequestId,
|
|
169
|
+
intranetResponseURL: event.IntranetResponseURL,
|
|
170
|
+
logicalResourceId: event.LogicalResourceId,
|
|
171
|
+
physicalResourceId: event.PhysicalResourceId,
|
|
172
|
+
credentials
|
|
173
|
+
};
|
|
174
|
+
};`,
|
|
175
|
+
},
|
|
176
|
+
MemorySize: 512,
|
|
177
|
+
Timeout: 900, // 15 minutes
|
|
178
|
+
},
|
|
179
|
+
},
|
|
32
180
|
},
|
|
33
181
|
};
|
|
34
182
|
return { stackName, template };
|
|
@@ -81,6 +81,7 @@ const resolveBuckets = (scope, buckets, context) => {
|
|
|
81
81
|
const ossBucket = new oss.Bucket(scope, bucket.key, {
|
|
82
82
|
bucketName: (0, common_1.calcRefs)(bucket.name, context),
|
|
83
83
|
accessControl: aclMap.get((0, common_1.calcRefs)(bucket.security?.acl, context) ?? ''),
|
|
84
|
+
blockPublicAccess: (0, common_1.calcRefs)(bucket.security?.acl, context) === types_1.BucketAccessEnum.PRIVATE,
|
|
84
85
|
websiteConfigurationV2: bucket.website
|
|
85
86
|
? {
|
|
86
87
|
indexDocument: {
|
|
@@ -39,7 +39,6 @@ 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"));
|
|
@@ -123,7 +122,7 @@ const resolveFunctions = (scope, functions, tags, context, service) => {
|
|
|
123
122
|
const fcName = (0, common_1.calcRefs)(name, context);
|
|
124
123
|
return { fcName, ...(0, common_1.getFileSource)(fcName, code.path) };
|
|
125
124
|
});
|
|
126
|
-
const destinationBucketName =
|
|
125
|
+
const destinationBucketName = `${common_1.SI_BOOTSTRAP_BUCKET_PREFIX}-${context.accountId}-${context.region}`;
|
|
127
126
|
const ossDeploymentId = 'si_auto_artifacts_code_deployment';
|
|
128
127
|
if (!(0, lodash_1.isEmpty)(fileSources)) {
|
|
129
128
|
new ossDeployment.BucketDeployment(scope, ossDeploymentId, {
|
|
@@ -46,6 +46,7 @@ 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) {
|
|
@@ -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
|
}
|
|
@@ -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;
|
|
@@ -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
|
};
|
|
@@ -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/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/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.
|
|
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
|