esa-cli 0.0.1-beta.1

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 (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +175 -0
  3. package/bin/enter.cjs +52 -0
  4. package/dist/README.md +175 -0
  5. package/dist/bin/enter.cjs +52 -0
  6. package/dist/cliconfig.toml +6 -0
  7. package/dist/commands/commit/index.js +147 -0
  8. package/dist/commands/commit/prodBuild.js +50 -0
  9. package/dist/commands/common/constant.js +54 -0
  10. package/dist/commands/config.js +51 -0
  11. package/dist/commands/deploy/helper.js +108 -0
  12. package/dist/commands/deploy/index.js +217 -0
  13. package/dist/commands/deployments/delete.js +92 -0
  14. package/dist/commands/deployments/index.js +27 -0
  15. package/dist/commands/deployments/list.js +89 -0
  16. package/dist/commands/dev/config/devBuild.js +26 -0
  17. package/dist/commands/dev/config/devEntry.js +71 -0
  18. package/dist/commands/dev/config/mock/cache.js +31 -0
  19. package/dist/commands/dev/config/mock/kv.js +87 -0
  20. package/dist/commands/dev/devPack.js +113 -0
  21. package/dist/commands/dev/doProcess.js +73 -0
  22. package/dist/commands/dev/index.js +240 -0
  23. package/dist/commands/dev/server.js +100 -0
  24. package/dist/commands/domain/add.js +72 -0
  25. package/dist/commands/domain/delete.js +74 -0
  26. package/dist/commands/domain/index.js +29 -0
  27. package/dist/commands/domain/list.js +51 -0
  28. package/dist/commands/init/index.js +149 -0
  29. package/dist/commands/lang.js +32 -0
  30. package/dist/commands/login/index.js +108 -0
  31. package/dist/commands/logout.js +44 -0
  32. package/dist/commands/route/add.js +115 -0
  33. package/dist/commands/route/delete.js +74 -0
  34. package/dist/commands/route/index.js +29 -0
  35. package/dist/commands/route/list.js +63 -0
  36. package/dist/commands/routine/delete.js +54 -0
  37. package/dist/commands/routine/index.js +27 -0
  38. package/dist/commands/routine/list.js +101 -0
  39. package/dist/commands/site/index.js +25 -0
  40. package/dist/commands/site/list.js +47 -0
  41. package/dist/commands/utils.js +139 -0
  42. package/dist/components/descriptionInput.js +38 -0
  43. package/dist/components/filterSelector.js +132 -0
  44. package/dist/components/mutiSelectTable.js +95 -0
  45. package/dist/components/selectInput.js +17 -0
  46. package/dist/components/selectItem.js +6 -0
  47. package/dist/components/yesNoPrompt.js +9 -0
  48. package/dist/docs/Commands_en.md +224 -0
  49. package/dist/docs/Commands_zh_CN.md +224 -0
  50. package/dist/docs/dev.png +0 -0
  51. package/dist/i18n/index.js +27 -0
  52. package/dist/i18n/locales.json +766 -0
  53. package/dist/index.js +80 -0
  54. package/dist/libs/apiService.js +914 -0
  55. package/dist/libs/git/index.js +52 -0
  56. package/dist/libs/interface.js +21 -0
  57. package/dist/libs/logger.js +149 -0
  58. package/dist/libs/request.js +98 -0
  59. package/dist/libs/templates/index.js +16 -0
  60. package/dist/package.json +93 -0
  61. package/dist/utils/checkDevPort.js +113 -0
  62. package/dist/utils/checkIsRoutineCreated.js +56 -0
  63. package/dist/utils/checkVersion.js +26 -0
  64. package/dist/utils/debounce.js +18 -0
  65. package/dist/utils/fileUtils/index.js +219 -0
  66. package/dist/utils/fileUtils/interface.js +1 -0
  67. package/dist/utils/install/install.ps1 +33 -0
  68. package/dist/utils/install/install.sh +53 -0
  69. package/dist/utils/installRuntime.js +80 -0
  70. package/dist/utils/openInBrowser.js +24 -0
  71. package/dist/utils/sleep.js +6 -0
  72. package/dist/zh_CN.md +177 -0
  73. package/package.json +93 -0
@@ -0,0 +1,914 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import * as $OpenApi from '@alicloud/openapi-client';
11
+ import FormData from 'form-data';
12
+ import fetch from 'node-fetch';
13
+ import { Environment } from './interface.js';
14
+ import { getApiConfig } from '../utils/fileUtils/index.js';
15
+ import chain from 'lodash';
16
+ import t from '../i18n/index.js';
17
+ export class ApiService {
18
+ constructor(cliConfig) {
19
+ var _a, _b;
20
+ let apiConfig = new $OpenApi.Config({
21
+ accessKeyId: (_a = cliConfig.auth) === null || _a === void 0 ? void 0 : _a.accessKeyId,
22
+ accessKeySecret: (_b = cliConfig.auth) === null || _b === void 0 ? void 0 : _b.accessKeySecret,
23
+ endpoint: cliConfig.endpoint
24
+ });
25
+ this.client = new $OpenApi.default.default(apiConfig);
26
+ }
27
+ static getInstance() {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ if (!ApiService.instance) {
30
+ const config = getApiConfig();
31
+ ApiService.instance = new ApiService(config);
32
+ }
33
+ return ApiService.instance;
34
+ });
35
+ }
36
+ updateConfig(newConfig) {
37
+ var _a, _b;
38
+ let apiConfig = new $OpenApi.Config({
39
+ accessKeyId: (_a = newConfig.auth) === null || _a === void 0 ? void 0 : _a.accessKeyId,
40
+ accessKeySecret: (_b = newConfig.auth) === null || _b === void 0 ? void 0 : _b.accessKeySecret,
41
+ endpoint: newConfig.endpoint
42
+ });
43
+ this.client = new $OpenApi.default.default(apiConfig);
44
+ }
45
+ /**
46
+ * Checks if the user is logged in.
47
+ * @returns A promise that resolves to an object with the following properties:
48
+ * - success: A boolean indicating if the login check was successful.
49
+ * - message: (Optional) A string providing additional information in case of failure.
50
+ */
51
+ checkLogin() {
52
+ return __awaiter(this, arguments, void 0, function* (isShowError = true) {
53
+ try {
54
+ let params = {
55
+ action: 'GetErService',
56
+ version: '2024-09-10',
57
+ protocol: 'https',
58
+ method: 'GET',
59
+ authType: 'AK',
60
+ bodyType: 'json',
61
+ reqBodyType: 'json',
62
+ style: 'RPC',
63
+ pathname: '/',
64
+ toMap: function () {
65
+ return this;
66
+ }
67
+ };
68
+ let request = new $OpenApi.OpenApiRequest({
69
+ query: {}
70
+ });
71
+ let runtime = {
72
+ toMap: function () {
73
+ return this;
74
+ }
75
+ };
76
+ const response = yield this.client.callApi(params, request, runtime);
77
+ if (response.statusCode === 200) {
78
+ return { success: true };
79
+ }
80
+ else if (response.statusCode === 403) {
81
+ return {
82
+ success: false,
83
+ message: t('login_permission_denied').d('Permission denied: Access key or secret is incorrect, or does not have the necessary permissions.')
84
+ };
85
+ }
86
+ else {
87
+ return {
88
+ success: false,
89
+ message: `${t('common_error_occurred').d('An error occurred')}: ${response.statusCode}`
90
+ };
91
+ }
92
+ }
93
+ catch (error) {
94
+ isShowError && console.log(error);
95
+ return {
96
+ success: false,
97
+ message: t('login_failed').d('An error occurred while trying to log in.')
98
+ };
99
+ }
100
+ });
101
+ }
102
+ quickDeployRoutine(edgeRoutine) {
103
+ return __awaiter(this, void 0, void 0, function* () {
104
+ try {
105
+ // 上传代码到unstable版本
106
+ const stagingRes = yield this.getRoutineStagingCodeUploadInfo(edgeRoutine);
107
+ if (stagingRes) {
108
+ // 生产版本
109
+ const commitRes = yield this.commitRoutineStagingCode({
110
+ Name: edgeRoutine.name,
111
+ CodeDescription: edgeRoutine.description
112
+ });
113
+ // 发布到生产环境
114
+ if (commitRes) {
115
+ const deployRes = yield this.publishRoutineCodeVersion({
116
+ Name: edgeRoutine.name,
117
+ CodeVersion: commitRes.data.CodeVersion,
118
+ Env: Environment.Production
119
+ });
120
+ return deployRes && Number(deployRes.code) === 200;
121
+ }
122
+ }
123
+ return false;
124
+ }
125
+ catch (error) {
126
+ console.log(error);
127
+ }
128
+ return false;
129
+ });
130
+ }
131
+ publishRoutineCodeVersion(requestParams) {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ var _a;
134
+ try {
135
+ let params = {
136
+ action: 'PublishRoutineCodeVersion',
137
+ version: '2024-09-10',
138
+ protocol: 'https',
139
+ method: 'GET',
140
+ authType: 'AK',
141
+ bodyType: 'json',
142
+ reqBodyType: 'json',
143
+ style: 'RPC',
144
+ pathname: '/',
145
+ toMap: function () {
146
+ return this;
147
+ }
148
+ };
149
+ const CanaryAreaList = (_a = requestParams.CanaryAreaList) !== null && _a !== void 0 ? _a : [];
150
+ const CanaryAreaListString = JSON.stringify(CanaryAreaList);
151
+ let request = new $OpenApi.OpenApiRequest({
152
+ query: {
153
+ Env: requestParams.Env,
154
+ Name: requestParams.Name,
155
+ CodeVersion: requestParams.CodeVersion,
156
+ CanaryCodeVersion: requestParams.CanaryCodeVersion,
157
+ CanaryAreaList: CanaryAreaListString
158
+ }
159
+ });
160
+ let runtime = {
161
+ toMap: function () {
162
+ return this;
163
+ }
164
+ };
165
+ const res = yield this.client.callApi(params, request, runtime);
166
+ if (res.statusCode === 200 && res.body) {
167
+ const ret = {
168
+ code: res.statusCode,
169
+ data: {
170
+ CodeVersion: res.body.CodeVersion,
171
+ RequestId: res.body.RequestId
172
+ }
173
+ };
174
+ return ret;
175
+ }
176
+ }
177
+ catch (error) {
178
+ console.log(error);
179
+ }
180
+ return null;
181
+ });
182
+ }
183
+ getMatchSite(requestParams) {
184
+ return __awaiter(this, void 0, void 0, function* () {
185
+ try {
186
+ let params = {
187
+ action: 'GetMatchSite',
188
+ version: '2024-09-10',
189
+ protocol: 'https',
190
+ method: 'GET',
191
+ authType: 'AK',
192
+ bodyType: 'json',
193
+ reqBodyType: 'json',
194
+ style: 'RPC',
195
+ pathname: '/',
196
+ toMap: function () {
197
+ return this;
198
+ }
199
+ };
200
+ let request = new $OpenApi.OpenApiRequest({
201
+ query: {
202
+ RecordName: requestParams.RecordName
203
+ }
204
+ });
205
+ let runtime = {
206
+ toMap: function () {
207
+ return this;
208
+ }
209
+ };
210
+ const res = yield this.client.callApi(params, request, runtime);
211
+ if (res.statusCode === 200 && res.body) {
212
+ const ret = {
213
+ code: res.statusCode,
214
+ data: {
215
+ SiteId: res.body.SiteId,
216
+ SiteName: res.body.SiteName
217
+ }
218
+ };
219
+ return ret;
220
+ }
221
+ }
222
+ catch (error) {
223
+ console.log(error);
224
+ }
225
+ return null;
226
+ });
227
+ }
228
+ listRoutineCanaryAreas() {
229
+ return __awaiter(this, void 0, void 0, function* () {
230
+ try {
231
+ let params = {
232
+ action: 'ListRoutineCanaryAreas',
233
+ version: '2024-09-10',
234
+ protocol: 'https',
235
+ method: 'GET',
236
+ authType: 'AK',
237
+ bodyType: 'json',
238
+ reqBodyType: 'json',
239
+ style: 'RPC',
240
+ pathname: '/',
241
+ toMap: function () {
242
+ return this;
243
+ }
244
+ };
245
+ let request = new $OpenApi.OpenApiRequest();
246
+ let runtime = {
247
+ toMap: function () {
248
+ return this;
249
+ }
250
+ };
251
+ const res = yield this.client.callApi(params, request, runtime);
252
+ if (res.statusCode === 200 && res.body) {
253
+ const ret = {
254
+ CanaryAreas: res.body.CanaryAreas
255
+ };
256
+ return ret;
257
+ }
258
+ }
259
+ catch (error) {
260
+ console.log(error);
261
+ }
262
+ return null;
263
+ });
264
+ }
265
+ getRoutineUserInfo() {
266
+ return __awaiter(this, void 0, void 0, function* () {
267
+ try {
268
+ let params = {
269
+ action: 'GetRoutineUserInfo',
270
+ version: '2024-09-10',
271
+ protocol: 'https',
272
+ method: 'GET',
273
+ authType: 'AK',
274
+ bodyType: 'json',
275
+ reqBodyType: 'json',
276
+ style: 'RPC',
277
+ pathname: '/',
278
+ toMap: function () {
279
+ return this;
280
+ }
281
+ };
282
+ let request = new $OpenApi.OpenApiRequest();
283
+ let runtime = {
284
+ toMap: function () {
285
+ return this;
286
+ }
287
+ };
288
+ const res = yield this.client.callApi(params, request, runtime);
289
+ if (res.statusCode === 200 && res.body) {
290
+ const ret = {
291
+ Subdomains: res.body.RoutineName,
292
+ Routines: res.body.Routines
293
+ };
294
+ return ret;
295
+ }
296
+ }
297
+ catch (error) {
298
+ console.log(error);
299
+ }
300
+ return null;
301
+ });
302
+ }
303
+ deleteRoutine(requestParams) {
304
+ return __awaiter(this, void 0, void 0, function* () {
305
+ try {
306
+ let params = {
307
+ action: 'DeleteRoutine',
308
+ version: '2024-09-10',
309
+ protocol: 'https',
310
+ method: 'GET',
311
+ authType: 'AK',
312
+ bodyType: 'json',
313
+ reqBodyType: 'json',
314
+ style: 'RPC',
315
+ pathname: '/',
316
+ toMap: function () {
317
+ return this;
318
+ }
319
+ };
320
+ let request = new $OpenApi.OpenApiRequest({
321
+ query: {
322
+ Name: requestParams.Name
323
+ }
324
+ });
325
+ let runtime = {
326
+ toMap: function () {
327
+ return this;
328
+ }
329
+ };
330
+ const res = yield this.client.callApi(params, request, runtime);
331
+ if (res.statusCode === 200 && res.body) {
332
+ const ret = {
333
+ Status: res.body.Status
334
+ };
335
+ return ret;
336
+ }
337
+ }
338
+ catch (error) {
339
+ console.log(error);
340
+ }
341
+ return null;
342
+ });
343
+ }
344
+ deleteRoutineCodeVersion(requestParams) {
345
+ return __awaiter(this, void 0, void 0, function* () {
346
+ try {
347
+ let params = {
348
+ action: 'DeleteRoutineCodeVersion',
349
+ version: '2024-09-10',
350
+ protocol: 'https',
351
+ method: 'GET',
352
+ authType: 'AK',
353
+ bodyType: 'json',
354
+ reqBodyType: 'json',
355
+ style: 'RPC',
356
+ pathname: '/',
357
+ toMap: function () {
358
+ return this;
359
+ }
360
+ };
361
+ let request = new $OpenApi.OpenApiRequest({
362
+ query: {
363
+ Name: requestParams.Name,
364
+ CodeVersion: requestParams.CodeVersion
365
+ }
366
+ });
367
+ let runtime = {
368
+ toMap: function () {
369
+ return this;
370
+ }
371
+ };
372
+ const res = yield this.client.callApi(params, request, runtime);
373
+ if (res.statusCode === 200 && res.body) {
374
+ const ret = {
375
+ Status: res.body.Status
376
+ };
377
+ return ret;
378
+ }
379
+ }
380
+ catch (error) {
381
+ console.log(error);
382
+ }
383
+ return null;
384
+ });
385
+ }
386
+ createRoutineRelatedRoute(requestParams) {
387
+ return __awaiter(this, void 0, void 0, function* () {
388
+ try {
389
+ let params = {
390
+ action: 'CreateRoutineRelatedRoute',
391
+ version: '2024-09-10',
392
+ protocol: 'https',
393
+ method: 'GET',
394
+ authType: 'AK',
395
+ bodyType: 'json',
396
+ reqBodyType: 'json',
397
+ style: 'RPC',
398
+ pathname: '/',
399
+ toMap: function () {
400
+ return this;
401
+ }
402
+ };
403
+ let request = new $OpenApi.OpenApiRequest({
404
+ query: {
405
+ Route: requestParams.Route,
406
+ SiteId: requestParams.SiteId,
407
+ SiteName: requestParams.SiteName,
408
+ Name: requestParams.Name
409
+ }
410
+ });
411
+ let runtime = {
412
+ toMap: function () {
413
+ return this;
414
+ }
415
+ };
416
+ const res = yield this.client.callApi(params, request, runtime);
417
+ if (res.statusCode === 200 && res.body) {
418
+ const ret = {
419
+ code: res.statusCode,
420
+ data: {
421
+ RequestId: res.body.RequestId,
422
+ Status: res.body.Status
423
+ }
424
+ };
425
+ return ret;
426
+ }
427
+ }
428
+ catch (error) {
429
+ console.log(error);
430
+ }
431
+ return null;
432
+ });
433
+ }
434
+ deleteRoutineRelatedRoute(requestParams) {
435
+ return __awaiter(this, void 0, void 0, function* () {
436
+ try {
437
+ let params = {
438
+ action: 'DeleteRoutineRelatedRoute',
439
+ version: '2024-09-10',
440
+ protocol: 'https',
441
+ method: 'GET',
442
+ authType: 'AK',
443
+ bodyType: 'json',
444
+ reqBodyType: 'json',
445
+ style: 'RPC',
446
+ pathname: '/',
447
+ toMap: function () {
448
+ return this;
449
+ }
450
+ };
451
+ let request = new $OpenApi.OpenApiRequest({
452
+ query: {
453
+ Route: requestParams.Route,
454
+ RouteId: requestParams.RouteId,
455
+ SiteId: requestParams.SiteId,
456
+ SiteName: requestParams.SiteName,
457
+ Name: requestParams.Name
458
+ }
459
+ });
460
+ let runtime = {
461
+ toMap: function () {
462
+ return this;
463
+ }
464
+ };
465
+ const res = yield this.client.callApi(params, request, runtime);
466
+ if (res.statusCode === 200 && res.body) {
467
+ const ret = {
468
+ code: res.statusCode,
469
+ data: {
470
+ RequestId: res.body.RequestId,
471
+ Status: res.body.Status
472
+ }
473
+ };
474
+ return ret;
475
+ }
476
+ }
477
+ catch (error) {
478
+ console.log(error);
479
+ }
480
+ return null;
481
+ });
482
+ }
483
+ listSites(requestParams) {
484
+ return __awaiter(this, void 0, void 0, function* () {
485
+ try {
486
+ let params = {
487
+ action: 'ListSites',
488
+ version: '2024-09-10',
489
+ protocol: 'https',
490
+ method: 'GET',
491
+ authType: 'AK',
492
+ bodyType: 'json',
493
+ reqBodyType: 'json',
494
+ style: 'RPC',
495
+ pathname: '/',
496
+ toMap: function () {
497
+ return this;
498
+ }
499
+ };
500
+ let request = new $OpenApi.OpenApiRequest({
501
+ query: requestParams
502
+ });
503
+ let runtime = {
504
+ toMap: function () {
505
+ return this;
506
+ }
507
+ };
508
+ const res = yield this.client.callApi(params, request, runtime);
509
+ if (res.statusCode === 200) {
510
+ const response = {
511
+ code: res.statusCode,
512
+ data: {
513
+ TotalCount: res.body.TotalCount,
514
+ RequestId: res.body.RequestId,
515
+ PageSize: res.body.PageSize,
516
+ PageNumber: res.body.PageNumber,
517
+ Sites: res.body.Sites
518
+ }
519
+ };
520
+ return response;
521
+ }
522
+ }
523
+ catch (error) {
524
+ console.log(error);
525
+ }
526
+ return null;
527
+ });
528
+ }
529
+ getRoutineStagingEnvIp() {
530
+ return __awaiter(this, void 0, void 0, function* () {
531
+ try {
532
+ let params = {
533
+ action: 'GetRoutineStagingEnvIp',
534
+ version: '2024-09-10',
535
+ protocol: 'https',
536
+ method: 'GET',
537
+ authType: 'AK',
538
+ bodyType: 'json',
539
+ reqBodyType: 'json',
540
+ style: 'RPC',
541
+ pathname: '/',
542
+ toMap: function () {
543
+ return this;
544
+ }
545
+ };
546
+ let request = new $OpenApi.OpenApiRequest({});
547
+ let runtime = {
548
+ toMap: function () {
549
+ return this;
550
+ }
551
+ };
552
+ const res = yield this.client.callApi(params, request, runtime);
553
+ if (res.statusCode === 200) {
554
+ const response = {
555
+ code: res.statusCode,
556
+ data: {
557
+ IPV4: res.body.IPV4,
558
+ RequestId: res.body.RequestId
559
+ }
560
+ };
561
+ return response;
562
+ }
563
+ }
564
+ catch (error) {
565
+ console.log(error);
566
+ }
567
+ return null;
568
+ });
569
+ }
570
+ getRoutine(requestParams_1) {
571
+ return __awaiter(this, arguments, void 0, function* (requestParams, isShowError = true) {
572
+ var _a, _b, _c, _d, _e, _f, _g, _h;
573
+ try {
574
+ let params = {
575
+ action: 'getRoutine',
576
+ version: '2024-09-10',
577
+ protocol: 'https',
578
+ method: 'GET',
579
+ authType: 'AK',
580
+ bodyType: 'json',
581
+ reqBodyType: 'json',
582
+ style: 'RPC',
583
+ pathname: '/',
584
+ toMap: function () {
585
+ return this;
586
+ }
587
+ };
588
+ let request = new $OpenApi.OpenApiRequest({
589
+ query: {
590
+ Name: requestParams.Name
591
+ }
592
+ });
593
+ let runtime = {
594
+ toMap: function () {
595
+ return this;
596
+ }
597
+ };
598
+ const res = yield this.client.callApi(params, request, runtime);
599
+ if (res.statusCode === 200 && res.body) {
600
+ const routineResponse = {
601
+ code: res.statusCode,
602
+ data: {
603
+ RequestId: (_a = res.body) === null || _a === void 0 ? void 0 : _a.RequestId,
604
+ CodeVersions: ((_b = res.body) === null || _b === void 0 ? void 0 : _b.CodeVersions) || [],
605
+ RelatedRecords: ((_c = res.body) === null || _c === void 0 ? void 0 : _c.RelatedRecords) || [],
606
+ Envs: ((_d = res.body) === null || _d === void 0 ? void 0 : _d.Envs) || [],
607
+ CreateTime: (_e = res.body) === null || _e === void 0 ? void 0 : _e.CreateTime,
608
+ Description: (_f = res.body) === null || _f === void 0 ? void 0 : _f.Description,
609
+ RelatedRoutes: ((_g = res.body) === null || _g === void 0 ? void 0 : _g.RelatedRoutes) || [],
610
+ DefaultRelatedRecord: (_h = res.body) === null || _h === void 0 ? void 0 : _h.DefaultRelatedRecord
611
+ }
612
+ };
613
+ return routineResponse;
614
+ }
615
+ }
616
+ catch (error) {
617
+ if (isShowError) {
618
+ console.log(error);
619
+ }
620
+ }
621
+ return null;
622
+ });
623
+ }
624
+ createRoutine(edgeRoutine) {
625
+ return __awaiter(this, void 0, void 0, function* () {
626
+ let params = {
627
+ action: 'CreateRoutine',
628
+ version: '2024-09-10',
629
+ protocol: 'https',
630
+ method: 'GET',
631
+ authType: 'AK',
632
+ bodyType: 'json',
633
+ reqBodyType: 'json',
634
+ style: 'RPC',
635
+ pathname: '/',
636
+ toMap: function () {
637
+ return this;
638
+ }
639
+ };
640
+ let request = new $OpenApi.OpenApiRequest({
641
+ query: {
642
+ Name: edgeRoutine.name,
643
+ Description: edgeRoutine.description,
644
+ SpecName: edgeRoutine.specName
645
+ }
646
+ });
647
+ let runtime = {
648
+ toMap: function () {
649
+ return this;
650
+ }
651
+ };
652
+ try {
653
+ const res = yield this.client.callApi(params, request, runtime);
654
+ if (res.statusCode === 200 && res.body) {
655
+ const ret = {
656
+ code: res.statusCode,
657
+ data: {
658
+ RequestId: res.body.RequestId,
659
+ Status: res.body.Status
660
+ }
661
+ };
662
+ return ret;
663
+ }
664
+ }
665
+ catch (error) {
666
+ console.log(error);
667
+ }
668
+ return null;
669
+ });
670
+ }
671
+ getRoutineStagingCodeUploadInfo(edgeRoutine) {
672
+ return __awaiter(this, void 0, void 0, function* () {
673
+ try {
674
+ let params = {
675
+ action: 'GetRoutineStagingCodeUploadInfo',
676
+ version: '2024-09-10',
677
+ protocol: 'https',
678
+ method: 'GET',
679
+ authType: 'AK',
680
+ bodyType: 'json',
681
+ reqBodyType: 'json',
682
+ style: 'RPC',
683
+ pathname: '/',
684
+ toMap: function () {
685
+ return this;
686
+ }
687
+ };
688
+ let request = new $OpenApi.OpenApiRequest({
689
+ query: {
690
+ Name: edgeRoutine.name
691
+ }
692
+ });
693
+ let runtime = {
694
+ toMap: function () {
695
+ return this;
696
+ }
697
+ };
698
+ const uploadResult = yield this.client.callApi(params, request, runtime);
699
+ const ossConfig = chain(uploadResult).get('body.OssPostConfig');
700
+ if (uploadResult.statusCode !== 200 || !ossConfig) {
701
+ return false;
702
+ }
703
+ const { OSSAccessKeyId, Signature, callback, Url, key, policy } = ossConfig;
704
+ const formData = new FormData();
705
+ formData.append('OSSAccessKeyId', OSSAccessKeyId);
706
+ formData.append('Signature', Signature);
707
+ formData.append('callback', callback);
708
+ formData.append('x:codeDescription', ossConfig['x:codeDescription']);
709
+ formData.append('policy', policy);
710
+ formData.append('key', key);
711
+ formData.append('file', edgeRoutine.code);
712
+ // TODO: 检查oss结果;
713
+ const ossRes = yield fetch(Url, {
714
+ method: 'POST',
715
+ body: formData,
716
+ headers: formData.getHeaders()
717
+ });
718
+ if (ossRes && ossRes.status === 200) {
719
+ return true;
720
+ }
721
+ return false;
722
+ }
723
+ catch (error) {
724
+ console.log(error);
725
+ return false;
726
+ }
727
+ });
728
+ }
729
+ commitRoutineStagingCode(requestParams) {
730
+ return __awaiter(this, void 0, void 0, function* () {
731
+ try {
732
+ let params = {
733
+ action: 'CommitRoutineStagingCode',
734
+ version: '2024-09-10',
735
+ protocol: 'https',
736
+ method: 'GET',
737
+ authType: 'AK',
738
+ bodyType: 'json',
739
+ reqBodyType: 'json',
740
+ style: 'RPC',
741
+ pathname: '/',
742
+ toMap: function () {
743
+ return this;
744
+ }
745
+ };
746
+ let request = new $OpenApi.OpenApiRequest({
747
+ query: {
748
+ Name: requestParams.Name,
749
+ CodeDescription: requestParams.CodeDescription
750
+ }
751
+ });
752
+ let runtime = {
753
+ toMap: function () {
754
+ return this;
755
+ }
756
+ };
757
+ const res = yield this.client.callApi(params, request, runtime);
758
+ if (res.statusCode === 200 && res.body) {
759
+ const ret = {
760
+ code: res.statusCode,
761
+ data: {
762
+ RequestId: res.body.RequestId,
763
+ CodeVersion: res.body.CodeVersion
764
+ }
765
+ };
766
+ return ret;
767
+ }
768
+ }
769
+ catch (error) {
770
+ console.log(error);
771
+ }
772
+ return null;
773
+ });
774
+ }
775
+ listRoutineSpecs() {
776
+ return __awaiter(this, void 0, void 0, function* () {
777
+ try {
778
+ let params = {
779
+ action: 'ListRoutineSpecs',
780
+ version: '2024-09-10',
781
+ protocol: 'https',
782
+ method: 'GET',
783
+ authType: 'AK',
784
+ bodyType: 'json',
785
+ reqBodyType: 'json',
786
+ style: 'RPC',
787
+ pathname: '/',
788
+ toMap: function () {
789
+ return this;
790
+ }
791
+ };
792
+ let request = new $OpenApi.OpenApiRequest();
793
+ let runtime = {
794
+ toMap: function () {
795
+ return this;
796
+ }
797
+ };
798
+ const res = yield this.client.callApi(params, request, runtime);
799
+ if (res.statusCode === 200 && res.body) {
800
+ const ret = {
801
+ code: res.statusCode,
802
+ data: {
803
+ RequestId: res.body.RequestId,
804
+ Specs: res.body.Specs
805
+ }
806
+ };
807
+ return ret;
808
+ }
809
+ }
810
+ catch (error) {
811
+ console.log(error);
812
+ }
813
+ return null;
814
+ });
815
+ }
816
+ createRoutineRelatedRecord(requestParams) {
817
+ return __awaiter(this, void 0, void 0, function* () {
818
+ try {
819
+ let params = {
820
+ action: 'CreateRoutineRelatedRecord',
821
+ version: '2024-09-10',
822
+ protocol: 'https',
823
+ method: 'GET',
824
+ authType: 'AK',
825
+ bodyType: 'json',
826
+ reqBodyType: 'json',
827
+ style: 'RPC',
828
+ pathname: '/',
829
+ toMap: function () {
830
+ return this;
831
+ }
832
+ };
833
+ let request = new $OpenApi.OpenApiRequest({
834
+ query: {
835
+ RecordName: requestParams.RecordName,
836
+ SiteId: requestParams.SiteId,
837
+ SiteName: requestParams.SiteName,
838
+ Name: requestParams.Name
839
+ }
840
+ });
841
+ let runtime = {
842
+ toMap: function () {
843
+ return this;
844
+ }
845
+ };
846
+ const res = yield this.client.callApi(params, request, runtime);
847
+ if (res.statusCode === 200 && res.body) {
848
+ const ret = {
849
+ code: res.statusCode,
850
+ data: {
851
+ Status: res.body.Status,
852
+ RequestId: res.body.RequestId
853
+ }
854
+ };
855
+ return ret;
856
+ }
857
+ }
858
+ catch (error) {
859
+ console.log(error);
860
+ }
861
+ return null;
862
+ });
863
+ }
864
+ deleteRoutineRelatedRecord(requestParams) {
865
+ return __awaiter(this, void 0, void 0, function* () {
866
+ try {
867
+ let params = {
868
+ action: 'DeleteRoutineRelatedRecord',
869
+ version: '2024-09-10',
870
+ protocol: 'https',
871
+ method: 'GET',
872
+ authType: 'AK',
873
+ bodyType: 'json',
874
+ reqBodyType: 'json',
875
+ style: 'RPC',
876
+ pathname: '/',
877
+ toMap: function () {
878
+ return this;
879
+ }
880
+ };
881
+ let request = new $OpenApi.OpenApiRequest({
882
+ query: {
883
+ RecordName: requestParams.RecordName,
884
+ SiteId: requestParams.SiteId,
885
+ SiteName: requestParams.SiteName,
886
+ Name: requestParams.Name,
887
+ RecordId: requestParams.RecordId
888
+ }
889
+ });
890
+ let runtime = {
891
+ toMap: function () {
892
+ return this;
893
+ }
894
+ };
895
+ const res = yield this.client.callApi(params, request, runtime);
896
+ if (res.statusCode === 200 && res.body) {
897
+ const ret = {
898
+ code: res.statusCode,
899
+ data: {
900
+ Status: res.body.Status,
901
+ RequestId: res.body.RequestId
902
+ }
903
+ };
904
+ return ret;
905
+ }
906
+ }
907
+ catch (error) {
908
+ console.log(error);
909
+ }
910
+ return null;
911
+ });
912
+ }
913
+ }
914
+ ApiService.instance = null;