@geek-fun/serverlessinsight 0.6.14 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/AGENTS.md +405 -10
  2. package/README.md +1 -0
  3. package/dist/package.json +8 -2
  4. package/dist/src/commands/deploy.js +4 -0
  5. package/dist/src/commands/destroy.js +4 -0
  6. package/dist/src/common/credentials.js +12 -0
  7. package/dist/src/common/providerEnum.js +1 -0
  8. package/dist/src/common/runtimeMapper.js +24 -3
  9. package/dist/src/common/volcengineClient/apigwOperations.js +271 -0
  10. package/dist/src/common/volcengineClient/iamOperations.js +349 -0
  11. package/dist/src/common/volcengineClient/index.js +99 -0
  12. package/dist/src/common/volcengineClient/tlsOperations.js +256 -0
  13. package/dist/src/common/volcengineClient/tosOperations.js +440 -0
  14. package/dist/src/common/volcengineClient/types.js +26 -0
  15. package/dist/src/common/volcengineClient/vefaasOperations.js +386 -0
  16. package/dist/src/lang/en.js +120 -0
  17. package/dist/src/lang/zh-CN.js +119 -0
  18. package/dist/src/stack/aliyunStack/fc3Resource.js +18 -3
  19. package/dist/src/stack/deploy.js +4 -0
  20. package/dist/src/stack/volcengineStack/apigwExecutor.js +87 -0
  21. package/dist/src/stack/volcengineStack/apigwPlanner.js +110 -0
  22. package/dist/src/stack/volcengineStack/apigwResource.js +302 -0
  23. package/dist/src/stack/volcengineStack/apigwTypes.js +106 -0
  24. package/dist/src/stack/volcengineStack/deployer.js +59 -0
  25. package/dist/src/stack/volcengineStack/destroyer.js +72 -0
  26. package/dist/src/stack/volcengineStack/index.js +44 -0
  27. package/dist/src/stack/volcengineStack/planner.js +27 -0
  28. package/dist/src/stack/volcengineStack/tosExecutor.js +106 -0
  29. package/dist/src/stack/volcengineStack/tosPlanner.js +96 -0
  30. package/dist/src/stack/volcengineStack/tosResource.js +103 -0
  31. package/dist/src/stack/volcengineStack/tosTypes.js +65 -0
  32. package/dist/src/stack/volcengineStack/vefaasExecutor.js +102 -0
  33. package/dist/src/stack/volcengineStack/vefaasPlanner.js +84 -0
  34. package/dist/src/stack/volcengineStack/vefaasResource.js +513 -0
  35. package/dist/src/stack/volcengineStack/vefaasTypes.js +75 -0
  36. package/dist/src/types/domains/state.js +3 -0
  37. package/dist/src/validator/functionSchema.js +13 -0
  38. package/dist/src/validator/rootSchema.js +1 -1
  39. package/dist/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +8 -2
  41. package/samples/volcengine-poc-advanced.yml +59 -0
  42. package/samples/volcengine-poc-api.yml +31 -0
  43. package/samples/volcengine-poc-bucket.yml +17 -0
  44. package/samples/volcengine-poc-function.yml +19 -0
  45. package/samples/volcengine-poc-vpc.yml +34 -0
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createVolcengineClient = void 0;
18
+ const openapi_1 = require("@volcengine/openapi");
19
+ const vefaasOperations_1 = require("./vefaasOperations");
20
+ const tosOperations_1 = require("./tosOperations");
21
+ const iamOperations_1 = require("./iamOperations");
22
+ const apigwOperations_1 = require("./apigwOperations");
23
+ const tlsOperations_1 = require("./tlsOperations");
24
+ __exportStar(require("./types"), exports);
25
+ __exportStar(require("./vefaasOperations"), exports);
26
+ __exportStar(require("./tosOperations"), exports);
27
+ __exportStar(require("./iamOperations"), exports);
28
+ __exportStar(require("./apigwOperations"), exports);
29
+ __exportStar(require("./tlsOperations"), exports);
30
+ const initializeSdkClients = (context) => {
31
+ const vefaasService = new openapi_1.Service({
32
+ serviceName: 'vefaas',
33
+ defaultVersion: '2024-06-06',
34
+ protocol: 'https',
35
+ host: 'vefaas.volcengineapi.com',
36
+ accessKeyId: context.accessKeyId,
37
+ secretKey: context.accessKeySecret,
38
+ region: context.region,
39
+ ...(context.securityToken && { sessionToken: context.securityToken }),
40
+ });
41
+ const tosService = new openapi_1.Service({
42
+ serviceName: 'tos',
43
+ defaultVersion: '2018-08-01',
44
+ protocol: 'https',
45
+ host: `tos-${context.region}.volces.com`,
46
+ accessKeyId: context.accessKeyId,
47
+ secretKey: context.accessKeySecret,
48
+ region: context.region,
49
+ ...(context.securityToken && { sessionToken: context.securityToken }),
50
+ });
51
+ const iamService = new openapi_1.Service({
52
+ serviceName: 'iam',
53
+ defaultVersion: '2024-01-01',
54
+ protocol: 'https',
55
+ host: 'iam.volcengineapi.com',
56
+ accessKeyId: context.accessKeyId,
57
+ secretKey: context.accessKeySecret,
58
+ region: context.region,
59
+ ...(context.securityToken && { sessionToken: context.securityToken }),
60
+ });
61
+ const tlsService = new openapi_1.Service({
62
+ serviceName: 'tls',
63
+ defaultVersion: '2024-01-01',
64
+ protocol: 'https',
65
+ host: `tls.${context.region}.volces.com`,
66
+ accessKeyId: context.accessKeyId,
67
+ secretKey: context.accessKeySecret,
68
+ region: context.region,
69
+ ...(context.securityToken && { sessionToken: context.securityToken }),
70
+ });
71
+ const apigwService = new openapi_1.Service({
72
+ serviceName: 'apig',
73
+ defaultVersion: '2021-03-03',
74
+ protocol: 'https',
75
+ host: 'apig.volcengineapi.com',
76
+ accessKeyId: context.accessKeyId,
77
+ secretKey: context.accessKeySecret,
78
+ region: context.region,
79
+ ...(context.securityToken && { sessionToken: context.securityToken }),
80
+ });
81
+ return {
82
+ vefaas: vefaasService,
83
+ tos: tosService,
84
+ iam: iamService,
85
+ tls: tlsService,
86
+ apigw: apigwService,
87
+ };
88
+ };
89
+ const createVolcengineClient = (context) => {
90
+ const sdkClients = initializeSdkClients(context);
91
+ return {
92
+ vefaas: (0, vefaasOperations_1.createVefaasOperations)(sdkClients.vefaas),
93
+ tos: (0, tosOperations_1.createTosOperations)(sdkClients.tos, context.region),
94
+ iam: (0, iamOperations_1.createIamOperations)(sdkClients.iam),
95
+ tls: (0, tlsOperations_1.createTlsOperations)(sdkClients.tls),
96
+ apigw: (0, apigwOperations_1.createApigwOperations)(sdkClients.apigw),
97
+ };
98
+ };
99
+ exports.createVolcengineClient = createVolcengineClient;
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTlsOperations = void 0;
4
+ const logger_1 = require("../logger");
5
+ const lang_1 = require("../../lang");
6
+ const WAIT_INTERVAL_MS = 5000;
7
+ const MAX_WAIT_ATTEMPTS = 30;
8
+ const delay = (ms) => new Promise((resolve) => {
9
+ setTimeout(resolve, ms);
10
+ });
11
+ const createTlsOperations = (tlsClient) => {
12
+ return {
13
+ createProject: async (config) => {
14
+ const response = await tlsClient.fetchOpenAPI({
15
+ Action: 'CreateProject',
16
+ Version: '2024-01-01',
17
+ method: 'POST',
18
+ headers: { 'content-type': 'application/json' },
19
+ data: {
20
+ ProjectName: config.projectName,
21
+ Description: config.description,
22
+ Region: config.region,
23
+ },
24
+ });
25
+ const data = (response.Result || {});
26
+ logger_1.logger.info(lang_1.lang.__('TLS_PROJECT_CREATED', { projectName: config.projectName }));
27
+ return {
28
+ projectId: data.ProjectId,
29
+ projectName: config.projectName,
30
+ description: config.description,
31
+ region: config.region,
32
+ createTime: data.CreateTime,
33
+ status: data.Status,
34
+ };
35
+ },
36
+ getProject: async (projectName) => {
37
+ try {
38
+ const response = await tlsClient.fetchOpenAPI({
39
+ Action: 'GetProject',
40
+ Version: '2024-01-01',
41
+ method: 'POST',
42
+ headers: { 'content-type': 'application/json' },
43
+ data: { ProjectName: projectName },
44
+ });
45
+ const data = (response.Result || {});
46
+ return {
47
+ projectId: data.ProjectId,
48
+ projectName: data.ProjectName,
49
+ description: data.Description,
50
+ region: data.Region,
51
+ createTime: data.CreateTime,
52
+ status: data.Status,
53
+ };
54
+ }
55
+ catch (error) {
56
+ if (error && typeof error === 'object' && 'code' in error) {
57
+ if (error.code === 'ProjectNotFound' || error.code === 'ResourceNotFound') {
58
+ return null;
59
+ }
60
+ }
61
+ throw error;
62
+ }
63
+ },
64
+ deleteProject: async (projectName) => {
65
+ try {
66
+ await tlsClient.fetchOpenAPI({
67
+ Action: 'DeleteProject',
68
+ Version: '2024-01-01',
69
+ method: 'POST',
70
+ headers: { 'content-type': 'application/json' },
71
+ data: { ProjectName: projectName },
72
+ });
73
+ logger_1.logger.info(lang_1.lang.__('TLS_PROJECT_DELETED', { projectName }));
74
+ }
75
+ catch (error) {
76
+ if (error && typeof error === 'object' && 'code' in error) {
77
+ if (error.code === 'ProjectNotFound' || error.code === 'ResourceNotFound') {
78
+ logger_1.logger.warn(lang_1.lang.__('TLS_PROJECT_NOT_FOUND', { projectName }));
79
+ return;
80
+ }
81
+ }
82
+ throw error;
83
+ }
84
+ },
85
+ createTopic: async (config) => {
86
+ const response = await tlsClient.fetchOpenAPI({
87
+ Action: 'CreateTopic',
88
+ Version: '2024-01-01',
89
+ method: 'POST',
90
+ headers: { 'content-type': 'application/json' },
91
+ data: {
92
+ ProjectName: config.projectName,
93
+ TopicName: config.topicName,
94
+ Description: config.description,
95
+ TTL: config.ttl ?? 30,
96
+ },
97
+ });
98
+ const data = (response.Result || {});
99
+ logger_1.logger.info(lang_1.lang.__('TLS_TOPIC_CREATED', { topicName: config.topicName }));
100
+ return {
101
+ topicId: data.TopicId,
102
+ topicName: config.topicName,
103
+ projectName: config.projectName,
104
+ description: config.description,
105
+ ttl: config.ttl,
106
+ createTime: data.CreateTime,
107
+ status: data.Status,
108
+ };
109
+ },
110
+ getTopic: async (projectName, topicName) => {
111
+ try {
112
+ const response = await tlsClient.fetchOpenAPI({
113
+ Action: 'GetTopic',
114
+ Version: '2024-01-01',
115
+ method: 'POST',
116
+ headers: { 'content-type': 'application/json' },
117
+ data: {
118
+ ProjectName: projectName,
119
+ TopicName: topicName,
120
+ },
121
+ });
122
+ const data = (response.Result || {});
123
+ return {
124
+ topicId: data.TopicId,
125
+ topicName: data.TopicName,
126
+ projectName: data.ProjectName,
127
+ description: data.Description,
128
+ ttl: data.TTL,
129
+ createTime: data.CreateTime,
130
+ status: data.Status,
131
+ };
132
+ }
133
+ catch (error) {
134
+ if (error && typeof error === 'object' && 'code' in error) {
135
+ if (error.code === 'TopicNotFound' || error.code === 'ResourceNotFound') {
136
+ return null;
137
+ }
138
+ }
139
+ throw error;
140
+ }
141
+ },
142
+ deleteTopic: async (projectName, topicName) => {
143
+ try {
144
+ await tlsClient.fetchOpenAPI({
145
+ Action: 'DeleteTopic',
146
+ Version: '2024-01-01',
147
+ method: 'POST',
148
+ headers: { 'content-type': 'application/json' },
149
+ data: {
150
+ ProjectName: projectName,
151
+ TopicName: topicName,
152
+ },
153
+ });
154
+ logger_1.logger.info(lang_1.lang.__('TLS_TOPIC_DELETED', { topicName }));
155
+ }
156
+ catch (error) {
157
+ if (error && typeof error === 'object' && 'code' in error) {
158
+ if (error.code === 'TopicNotFound' || error.code === 'ResourceNotFound') {
159
+ logger_1.logger.warn(lang_1.lang.__('TLS_TOPIC_NOT_FOUND', { topicName }));
160
+ return;
161
+ }
162
+ }
163
+ throw error;
164
+ }
165
+ },
166
+ createIndex: async (config) => {
167
+ await tlsClient.fetchOpenAPI({
168
+ Action: 'CreateIndex',
169
+ Version: '2024-01-01',
170
+ method: 'POST',
171
+ headers: { 'content-type': 'application/json' },
172
+ data: {
173
+ ProjectName: config.projectName,
174
+ TopicName: config.topicName,
175
+ FullTextIndex: config.fullTextIndex
176
+ ? {
177
+ Delimiter: config.fullTextIndex.delimiter ?? ' ,.?;!\n\t',
178
+ CaseSensitive: config.fullTextIndex.caseSensitive ?? false,
179
+ }
180
+ : undefined,
181
+ KeyValueIndex: config.keyValueIndex,
182
+ },
183
+ });
184
+ logger_1.logger.info(lang_1.lang.__('TLS_INDEX_CREATED', { topicName: config.topicName }));
185
+ },
186
+ deleteIndex: async (projectName, topicName) => {
187
+ try {
188
+ await tlsClient.fetchOpenAPI({
189
+ Action: 'DeleteIndex',
190
+ Version: '2024-01-01',
191
+ method: 'POST',
192
+ headers: { 'content-type': 'application/json' },
193
+ data: {
194
+ ProjectName: projectName,
195
+ TopicName: topicName,
196
+ },
197
+ });
198
+ logger_1.logger.info(lang_1.lang.__('TLS_INDEX_DELETED', { topicName }));
199
+ }
200
+ catch (error) {
201
+ if (error && typeof error === 'object' && 'code' in error) {
202
+ if (error.code === 'IndexNotFound' || error.code === 'ResourceNotFound') {
203
+ return;
204
+ }
205
+ }
206
+ throw error;
207
+ }
208
+ },
209
+ waitForProject: async (projectName) => {
210
+ for (let attempt = 0; attempt < MAX_WAIT_ATTEMPTS; attempt++) {
211
+ const project = await tlsClient.fetchOpenAPI({
212
+ Action: 'GetProject',
213
+ Version: '2024-01-01',
214
+ method: 'POST',
215
+ headers: { 'content-type': 'application/json' },
216
+ data: { ProjectName: projectName },
217
+ });
218
+ const data = (project.Result || {});
219
+ const status = data.Status;
220
+ if (status === 'Active') {
221
+ return;
222
+ }
223
+ if (status === 'Failed' || status === 'Error') {
224
+ throw new Error(lang_1.lang.__('TLS_PROJECT_FAILED', { projectName }));
225
+ }
226
+ await delay(WAIT_INTERVAL_MS);
227
+ }
228
+ throw new Error(lang_1.lang.__('TLS_PROJECT_TIMEOUT', { projectName }));
229
+ },
230
+ waitForTopic: async (projectName, topicName) => {
231
+ for (let attempt = 0; attempt < MAX_WAIT_ATTEMPTS; attempt++) {
232
+ const topic = await tlsClient.fetchOpenAPI({
233
+ Action: 'GetTopic',
234
+ Version: '2024-01-01',
235
+ method: 'POST',
236
+ headers: { 'content-type': 'application/json' },
237
+ data: {
238
+ ProjectName: projectName,
239
+ TopicName: topicName,
240
+ },
241
+ });
242
+ const data = (topic.Result || {});
243
+ const status = data.Status;
244
+ if (status === 'Active') {
245
+ return;
246
+ }
247
+ if (status === 'Failed' || status === 'Error') {
248
+ throw new Error(lang_1.lang.__('TLS_TOPIC_FAILED', { topicName }));
249
+ }
250
+ await delay(WAIT_INTERVAL_MS);
251
+ }
252
+ throw new Error(lang_1.lang.__('TLS_TOPIC_TIMEOUT', { topicName }));
253
+ },
254
+ };
255
+ };
256
+ exports.createTlsOperations = createTlsOperations;