@geek-fun/serverlessinsight 0.8.3 → 0.8.5

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 (61) hide show
  1. package/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +3 -2
  2. package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +21 -2
  3. package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +46 -35
  4. package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +3 -2
  5. package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +63 -23
  6. package/CHANGELOG.md +55 -0
  7. package/README.md +1 -1
  8. package/dist/package.json +26 -25
  9. package/dist/src/common/aliyunClient/apigwOperations.js +36 -0
  10. package/dist/src/common/aliyunClient/fc3Operations.js +7 -0
  11. package/dist/src/common/aliyunClient/slsOperations.js +35 -3
  12. package/dist/src/common/constants.js +5 -1
  13. package/dist/src/common/index.js +2 -0
  14. package/dist/src/common/nameBuilder.js +80 -0
  15. package/dist/src/common/providerNames.js +54 -0
  16. package/dist/src/common/runtimeMapper.js +25 -4
  17. package/dist/src/common/stateBackend/remoteStateBackend.js +4 -1
  18. package/dist/src/common/stateManager.js +52 -2
  19. package/dist/src/common/tencentClient/clsOperations.js +137 -0
  20. package/dist/src/common/tencentClient/index.js +21 -1
  21. package/dist/src/common/tencentClient/scfOperations.js +11 -0
  22. package/dist/src/common/volcengineClient/iamOperations.js +33 -0
  23. package/dist/src/common/volcengineClient/tlsOperations.js +84 -1
  24. package/dist/src/lang/en.js +29 -1
  25. package/dist/src/lang/zh-CN.js +29 -1
  26. package/dist/src/parser/index.js +2 -1
  27. package/dist/src/stack/aliyunStack/apigwPlanner.js +2 -0
  28. package/dist/src/stack/aliyunStack/apigwResource.js +118 -1
  29. package/dist/src/stack/aliyunStack/apigwTypes.js +32 -20
  30. package/dist/src/stack/aliyunStack/destroyer.js +25 -0
  31. package/dist/src/stack/aliyunStack/fc3Resource.js +91 -32
  32. package/dist/src/stack/aliyunStack/sharedLogProject.js +137 -0
  33. package/dist/src/stack/ownershipTag.js +19 -1
  34. package/dist/src/stack/scfStack/destroyer.js +13 -0
  35. package/dist/src/stack/scfStack/scfPlanner.js +9 -1
  36. package/dist/src/stack/scfStack/scfResource.js +205 -13
  37. package/dist/src/stack/scfStack/scfTypes.js +6 -0
  38. package/dist/src/stack/scfStack/sharedLogset.js +126 -0
  39. package/dist/src/stack/volcengineStack/apigwResource.js +64 -48
  40. package/dist/src/stack/volcengineStack/apigwTypes.js +10 -7
  41. package/dist/src/stack/volcengineStack/destroyer.js +12 -0
  42. package/dist/src/stack/volcengineStack/sharedLogProject.js +190 -0
  43. package/dist/src/stack/volcengineStack/vefaasPlanner.js +20 -13
  44. package/dist/src/stack/volcengineStack/vefaasResource.js +76 -76
  45. package/dist/src/types/domains/state.js +3 -0
  46. package/dist/src/validator/bucketSchema.js +3 -5
  47. package/dist/src/validator/eventSchema.js +7 -4
  48. package/dist/src/validator/functionSchema.js +3 -2
  49. package/dist/src/validator/iacSchema.js +11 -4
  50. package/dist/src/validator/rootSchema.js +27 -0
  51. package/dist/src/validator/semanticValidation.js +122 -0
  52. package/dist/src/validator/tableschema.js +2 -0
  53. package/dist/src/validator/templateRefSchema.js +23 -3
  54. package/dist/tsconfig.tsbuildinfo +1 -1
  55. package/package.json +26 -25
  56. package/samples/aliyun-poc-fc-gpu.yml +2 -2
  57. package/samples/aliyun-poc-table.yml +1 -1
  58. package/samples/volcengine-poc-advanced.yml +4 -8
  59. package/samples/volcengine-poc-api.yml +1 -1
  60. package/samples/volcengine-poc-function.yml +1 -1
  61. package/samples/volcengine-poc-vpc.yml +3 -7
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SCF_STATUS_POLL_MAX_ATTEMPTS = exports.SCF_STATUS_POLL_INTERVAL_MS = exports.RAM_ROLE_PROPAGATION_DELAY_MS = exports.APIGW_DNS_PUBLIC_RESOLUTION_DELAY_MS = exports.APIGW_DNS_PUBLIC_RESOLUTION_MAX_ATTEMPTS = exports.APIGW_DOMAIN_BIND_RETRY_DELAY_MS = exports.APIGW_DOMAIN_BIND_MAX_RETRIES = exports.DNS_PROPAGATION_DELAY_MS = exports.DNS_PROPAGATION_MAX_ATTEMPTS = exports.DOMAIN_BIND_RETRY_DELAY_MS = exports.DOMAIN_BIND_MAX_RETRIES = exports.STALE_LOCK_THRESHOLD = exports.DEFAULT_LOCK_RETRY_DELAY = exports.DEFAULT_LOCK_TIMEOUT = exports.LOCK_FILE_SUFFIX = exports.OSS_STATE_REQUEST_TIMEOUT_MS = exports.OSS_STATE_CONNECT_TIMEOUT_MS = exports.FC3_CODE_INLINE_SIZE_LIMIT = exports.ALIYUN_FC3_READ_TIMEOUT_MS = exports.ALIYUN_FC3_CONNECT_TIMEOUT_MS = exports.SI_LOCALSTACK_SERVER_PORT = exports.SI_BOOTSTRAP_BUCKET_PREFIX = exports.SI_BOOTSTRAP_FC_PREFIX = exports.OSS_DEPLOYMENT_TIMEOUT = exports.CODE_ZIP_SIZE_LIMIT = void 0;
3
+ exports.CLS_TOPIC_POLL_MAX_ATTEMPTS = exports.CLS_TOPIC_POLL_INTERVAL_MS = exports.SCF_STATUS_POLL_MAX_ATTEMPTS = exports.SCF_STATUS_POLL_INTERVAL_MS = exports.RAM_ROLE_PROPAGATION_DELAY_MS = exports.APIGW_DNS_PUBLIC_RESOLUTION_DELAY_MS = exports.APIGW_DNS_PUBLIC_RESOLUTION_MAX_ATTEMPTS = exports.APIGW_DOMAIN_BIND_RETRY_DELAY_MS = exports.APIGW_DOMAIN_BIND_MAX_RETRIES = exports.DNS_PROPAGATION_DELAY_MS = exports.DNS_PROPAGATION_MAX_ATTEMPTS = exports.DOMAIN_BIND_RETRY_DELAY_MS = exports.DOMAIN_BIND_MAX_RETRIES = exports.STALE_LOCK_THRESHOLD = exports.DEFAULT_LOCK_RETRY_DELAY = exports.DEFAULT_LOCK_TIMEOUT = exports.LOCK_FILE_SUFFIX = exports.OSS_STATE_REQUEST_TIMEOUT_MS = exports.OSS_STATE_CONNECT_TIMEOUT_MS = exports.FC3_CODE_INLINE_SIZE_LIMIT = exports.ALIYUN_FC3_READ_TIMEOUT_MS = exports.ALIYUN_FC3_CONNECT_TIMEOUT_MS = exports.SI_LOCALSTACK_SERVER_PORT = exports.SI_BOOTSTRAP_BUCKET_PREFIX = exports.SI_BOOTSTRAP_FC_PREFIX = exports.OSS_DEPLOYMENT_TIMEOUT = exports.CODE_ZIP_SIZE_LIMIT = void 0;
4
4
  exports.CODE_ZIP_SIZE_LIMIT = 300 * 1000; // 300 KB - code package size limit for inline deployment
5
5
  exports.OSS_DEPLOYMENT_TIMEOUT = 3000; // in seconds
6
6
  exports.SI_BOOTSTRAP_FC_PREFIX = 'si-bootstrap-api';
@@ -35,3 +35,7 @@ exports.RAM_ROLE_PROPAGATION_DELAY_MS = 5000; // 5 seconds
35
35
  // fail with "Status is Creating, unsupport operate" if issued too early)
36
36
  exports.SCF_STATUS_POLL_INTERVAL_MS = 3000; // 3 seconds
37
37
  exports.SCF_STATUS_POLL_MAX_ATTEMPTS = 20; // up to 60 seconds
38
+ // CLS topic visibility polling (CreateTopic is async — the topic is not
39
+ // queryable via DescribeTopics until the platform finishes provisioning)
40
+ exports.CLS_TOPIC_POLL_INTERVAL_MS = 3000; // 3 seconds
41
+ exports.CLS_TOPIC_POLL_MAX_ATTEMPTS = 20; // up to 60 seconds
@@ -36,3 +36,5 @@ __exportStar(require("./planFormatter"), exports);
36
36
  __exportStar(require("./credentialStore"), exports);
37
37
  __exportStar(require("./apiClient"), exports);
38
38
  __exportStar(require("./triggerMapper"), exports);
39
+ __exportStar(require("./nameBuilder"), exports);
40
+ __exportStar(require("./providerNames"), exports);
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ /**
3
+ * Deterministic constrained-name builder.
4
+ *
5
+ * Contract (see GitHub issue #222):
6
+ * - Identifiers are derived from user config and must respect a provider
7
+ * maximum length. Silent truncation used to discard the distinguishing
8
+ * discriminator (issue #221: RepeatedApiName collisions).
9
+ * - When the composed name fits the maximum length, it is returned verbatim
10
+ * (minus charset sanitisation) so existing well-fitting configurations keep
11
+ * their deployed names and do not churn.
12
+ * - When it does not fit, the human-readable prefix is truncated FIRST while
13
+ * the discriminator (later parts) is preserved whenever possible, and a
14
+ * deterministic hash of the raw parts is always appended so distinct inputs
15
+ * never collapse to the same name. Theoretical digest collisions within a
16
+ * deploy set are additionally rejected up-front by semantic validation.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.CONSTRAINT_NAME_LIMITS = exports.buildConstrainedName = exports.stableHash = exports.DEFAULT_HASH_LENGTH = void 0;
20
+ const FNV_OFFSET_BASIS = 0x811c9dc5;
21
+ const FNV_PRIME = 0x01000193;
22
+ const SANITISERS = {
23
+ // Aliyun identifiers (CreateApi apiName: [A-Za-z0-9_], hyphens forbidden)
24
+ underscore: { invalidChars: /[^A-Za-z0-9_]/g, separator: '_' },
25
+ // Volcengine identifiers (letters/digits/hyphens, underscores folded to hyphens)
26
+ hyphen: { invalidChars: /[^A-Za-z0-9-]/g, separator: '-' },
27
+ };
28
+ exports.DEFAULT_HASH_LENGTH = 7;
29
+ const toUtf8Bytes = (input) => Array.from(Buffer.from(input, 'utf8'));
30
+ /** Deterministic 32-bit FNV-1a rendered as fixed-width base36. */
31
+ const stableHash = (raw, length = exports.DEFAULT_HASH_LENGTH) => toUtf8Bytes(raw)
32
+ .reduce((hash, byte) => ((hash ^ byte) * FNV_PRIME) >>> 0, FNV_OFFSET_BASIS)
33
+ .toString(36)
34
+ .padStart(length, '0')
35
+ .slice(0, length);
36
+ exports.stableHash = stableHash;
37
+ const sanitizePart = (part, mode) => part.replace(SANITISERS[mode].invalidChars, SANITISERS[mode].separator);
38
+ /**
39
+ * Build a provider-constrained identifier from ordered user-derived segments,
40
+ * joined by the charset separator. Over-long compositions truncate the leading
41
+ * (human-readable) segments first and append a hash of the raw segments so
42
+ * distinct inputs never collapse into one name.
43
+ */
44
+ const buildConstrainedName = ({ parts, maxLength, charset, }) => {
45
+ const { separator } = SANITISERS[charset];
46
+ const joinSegments = (segments) => segments
47
+ .map((part) => sanitizePart(part, charset))
48
+ .filter((part) => part.length > 0)
49
+ .join(separator);
50
+ const readable = joinSegments(parts);
51
+ if (readable.length <= maxLength) {
52
+ return readable;
53
+ }
54
+ const hashLength = Math.max(1, Math.min(exports.DEFAULT_HASH_LENGTH, maxLength - 1));
55
+ // Hash over the RAW segments so inputs sanitising identically stay distinct.
56
+ const hash = (0, exports.stableHash)(parts.join('\u0000'), hashLength);
57
+ const clampPrefix = (cap) => {
58
+ const prefix = joinSegments(parts.slice(0, -1)).slice(0, Math.max(cap, 0));
59
+ return prefix.replace(new RegExp(`\\${separator}+$`), '');
60
+ };
61
+ const separatorAllowance = separator.length * 2;
62
+ const discriminatorRoom = maxLength - hashLength - separatorAllowance;
63
+ const discriminatorSanitized = sanitizePart(parts[parts.length - 1], charset);
64
+ if (parts.length > 1 && discriminatorSanitized.length <= discriminatorRoom) {
65
+ const headSegments = [
66
+ clampPrefix(discriminatorRoom - discriminatorSanitized.length),
67
+ discriminatorSanitized,
68
+ ].filter((segment) => segment.length > 0);
69
+ return `${headSegments.join(separator)}${separator}${hash}`;
70
+ }
71
+ const headOnly = clampPrefix(maxLength - hashLength - separator.length);
72
+ return [headOnly, hash].filter((segment) => segment.length > 0).join(separator);
73
+ };
74
+ exports.buildConstrainedName = buildConstrainedName;
75
+ /** Per-provider maximum lengths for names generated through this module. */
76
+ exports.CONSTRAINT_NAME_LIMITS = {
77
+ ALIYUN_CREATE_API_NAME: 50,
78
+ ALIYUN_API_GROUP_NAME: 50,
79
+ VOLCENGINE_ROUTE_NAME: 63,
80
+ };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildVolcengineRouteName = exports.buildAliyunApigwApiName = exports.generateApiKey = void 0;
4
+ /**
5
+ * Leaf module for generated provider resource names.
6
+ *
7
+ * Lives in src/common (not in the stack modules) so that both the deployment
8
+ * stacks and the pre-deploy semantic validator share ONE source of truth for
9
+ * generated names without introducing import cycles. See issue #222.
10
+ */
11
+ const nameBuilder_1 = require("./nameBuilder");
12
+ /**
13
+ * Generate a unique API key from an HTTP method and path.
14
+ * Uses URL encoding to preserve path structure and avoid collisions.
15
+ */
16
+ const generateApiKey = (method, path) => {
17
+ // Replace slashes with double underscores to preserve path structure
18
+ // Replace other non-alphanumeric chars with single underscore
19
+ const sanitizedPath = path
20
+ .replace(/\//g, '__')
21
+ .replace(/[^a-zA-Z0-9_]/g, '_')
22
+ .replace(/^__/, '') // Remove leading double underscore
23
+ .replace(/__$/, ''); // Remove trailing double underscore
24
+ return `${method}_${sanitizedPath}`;
25
+ };
26
+ exports.generateApiKey = generateApiKey;
27
+ /**
28
+ * Aliyun API Gateway apiName. Aliyun CreateApi requires 4-50 chars of
29
+ * [A-Za-z0-9_] — no hyphens.
30
+ *
31
+ * Resolves issue #221: long event names no longer truncate the trailing
32
+ * method/path discriminator out of existence.
33
+ */
34
+ const buildAliyunApigwApiName = (eventName, stage, apiKey) => (0, nameBuilder_1.buildConstrainedName)({
35
+ parts: [eventName, stage, 'agw_api', apiKey],
36
+ maxLength: nameBuilder_1.CONSTRAINT_NAME_LIMITS.ALIYUN_CREATE_API_NAME,
37
+ charset: 'underscore',
38
+ });
39
+ exports.buildAliyunApigwApiName = buildAliyunApigwApiName;
40
+ /**
41
+ * Volcengine API Gateway route name (max 63 chars, letters/digits/hyphens).
42
+ */
43
+ const buildVolcengineRouteName = (eventName, method, path) => {
44
+ const sanitizedPath = path
45
+ .replace(/\//g, '_')
46
+ .replace(/[^a-zA-Z0-9_]/g, '_')
47
+ .replace(/^_+|_+$/g, '');
48
+ return (0, nameBuilder_1.buildConstrainedName)({
49
+ parts: [eventName, `${method}_${sanitizedPath}`],
50
+ maxLength: nameBuilder_1.CONSTRAINT_NAME_LIMITS.VOLCENGINE_ROUTE_NAME,
51
+ charset: 'hyphen',
52
+ });
53
+ };
54
+ exports.buildVolcengineRouteName = buildVolcengineRouteName;
@@ -42,26 +42,32 @@ const runtimeMappings = {
42
42
  [StandardRuntime.NODEJS20]: {
43
43
  [providerEnum_1.ProviderEnum.ALIYUN]: 'nodejs20',
44
44
  [providerEnum_1.ProviderEnum.AWS]: 'nodejs20.x',
45
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'nodejs20.15',
45
46
  },
46
47
  [StandardRuntime.NODEJS18]: {
47
48
  [providerEnum_1.ProviderEnum.ALIYUN]: 'nodejs18',
48
49
  [providerEnum_1.ProviderEnum.TENCENT]: 'Nodejs18.15',
50
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'nodejs18.15',
49
51
  },
50
52
  [StandardRuntime.NODEJS16]: {
51
53
  [providerEnum_1.ProviderEnum.ALIYUN]: 'nodejs16',
52
54
  [providerEnum_1.ProviderEnum.TENCENT]: 'Nodejs16.13',
55
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'nodejs16.17',
53
56
  },
54
57
  [StandardRuntime.NODEJS14]: {
55
58
  [providerEnum_1.ProviderEnum.ALIYUN]: 'nodejs14',
56
59
  [providerEnum_1.ProviderEnum.TENCENT]: 'Nodejs14.18',
60
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'nodejs14.18',
57
61
  },
58
62
  [StandardRuntime.NODEJS12]: {
59
63
  [providerEnum_1.ProviderEnum.ALIYUN]: 'nodejs12',
60
64
  [providerEnum_1.ProviderEnum.TENCENT]: 'Nodejs12.16',
65
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'nodejs12.13',
61
66
  },
62
67
  [StandardRuntime.NODEJS10]: {
63
68
  [providerEnum_1.ProviderEnum.ALIYUN]: 'nodejs10',
64
69
  [providerEnum_1.ProviderEnum.TENCENT]: 'Nodejs10.15',
70
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'nodejs10.16',
65
71
  },
66
72
  [StandardRuntime.PYTHON3_14]: {
67
73
  [providerEnum_1.ProviderEnum.AWS]: 'python3.14',
@@ -72,6 +78,7 @@ const runtimeMappings = {
72
78
  [StandardRuntime.PYTHON3_12]: {
73
79
  [providerEnum_1.ProviderEnum.ALIYUN]: 'python3.12',
74
80
  [providerEnum_1.ProviderEnum.AWS]: 'python3.12',
81
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'python3.12',
75
82
  },
76
83
  [StandardRuntime.PYTHON3_11]: {
77
84
  [providerEnum_1.ProviderEnum.AWS]: 'python3.11',
@@ -80,10 +87,12 @@ const runtimeMappings = {
80
87
  [providerEnum_1.ProviderEnum.ALIYUN]: 'python3.10',
81
88
  [providerEnum_1.ProviderEnum.TENCENT]: 'Python3.10',
82
89
  [providerEnum_1.ProviderEnum.AWS]: 'python3.10',
90
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'python3.10',
83
91
  },
84
92
  [StandardRuntime.PYTHON3_9]: {
85
93
  [providerEnum_1.ProviderEnum.ALIYUN]: 'python3.9',
86
94
  [providerEnum_1.ProviderEnum.TENCENT]: 'Python3.9',
95
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'python3.9',
87
96
  },
88
97
  [StandardRuntime.PYTHON3_7]: {
89
98
  [providerEnum_1.ProviderEnum.TENCENT]: 'Python3.7',
@@ -91,24 +100,30 @@ const runtimeMappings = {
91
100
  [StandardRuntime.PYTHON3_6]: {
92
101
  [providerEnum_1.ProviderEnum.ALIYUN]: 'python3.6',
93
102
  [providerEnum_1.ProviderEnum.TENCENT]: 'Python3.6',
103
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'python3.6',
94
104
  },
95
105
  [StandardRuntime.JAVA25]: {
96
106
  [providerEnum_1.ProviderEnum.AWS]: 'java25',
97
107
  },
98
108
  [StandardRuntime.JAVA21]: {
99
109
  [providerEnum_1.ProviderEnum.AWS]: 'java21',
110
+ // Huawei java21 is regional (ME-Riyadh, TR-Istanbul) per FunctionGraph docs.
111
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'java21',
100
112
  },
101
113
  [StandardRuntime.JAVA17]: {
102
114
  [providerEnum_1.ProviderEnum.AWS]: 'java17',
115
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'java17',
103
116
  },
104
117
  [StandardRuntime.JAVA11]: {
105
118
  [providerEnum_1.ProviderEnum.ALIYUN]: 'java11',
106
119
  [providerEnum_1.ProviderEnum.AWS]: 'java11',
120
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'java11',
107
121
  },
108
122
  [StandardRuntime.JAVA8]: {
109
123
  [providerEnum_1.ProviderEnum.ALIYUN]: 'java8',
110
124
  [providerEnum_1.ProviderEnum.TENCENT]: 'Java8',
111
125
  [providerEnum_1.ProviderEnum.AWS]: 'java8.al2',
126
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'java8',
112
127
  },
113
128
  [StandardRuntime.PHP8_0]: {
114
129
  [providerEnum_1.ProviderEnum.TENCENT]: 'Php8.0',
@@ -126,9 +141,11 @@ const runtimeMappings = {
126
141
  [StandardRuntime.GO1]: {
127
142
  [providerEnum_1.ProviderEnum.ALIYUN]: 'go 1.x',
128
143
  [providerEnum_1.ProviderEnum.TENCENT]: 'Go1',
144
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'go1.x',
129
145
  },
130
146
  [StandardRuntime.DOTNET_CORE3_1]: {
131
147
  [providerEnum_1.ProviderEnum.ALIYUN]: '.NET Core 3.1',
148
+ [providerEnum_1.ProviderEnum.HUAWEI]: 'dotnetcore3.1',
132
149
  },
133
150
  };
134
151
  const mapRuntime = (standardRuntime, provider) => {
@@ -144,9 +161,12 @@ const mapRuntime = (standardRuntime, provider) => {
144
161
  return providerRuntime;
145
162
  };
146
163
  exports.mapRuntime = mapRuntime;
147
- // Valid veFaaS runtimes per the official CreateFunction API reference:
148
- // golang/v1, native/v1, nativejava8/v1, node14/v1, node20/v1, nodeprime14/v1,
149
- // python3.12/v1, python3.8/v1, python3.9/v1
164
+ // Valid veFaaS runtimes per the official CreateFunction API reference, adjusted
165
+ // for product notices: python3.8/v1 retired (volcengine notice 2121844) and the
166
+ // native-family ids added from Volcengine-maintained tooling (mcp-server / veadk).
167
+ // Verified 2026-08: golang/v1, native/v1, nativejava8/v1, node14/v1, node20/v1,
168
+ // nodeprime14/v1, python3.12/v1, python3.9/v1, native-python3.12/v1,
169
+ // native-node20/v1
150
170
  const VOLCENGINE_NATIVE_RUNTIMES = [
151
171
  'golang/v1',
152
172
  'native/v1',
@@ -155,8 +175,9 @@ const VOLCENGINE_NATIVE_RUNTIMES = [
155
175
  'node20/v1',
156
176
  'nodeprime14/v1',
157
177
  'python3.12/v1',
158
- 'python3.8/v1',
159
178
  'python3.9/v1',
179
+ 'native-python3.12/v1',
180
+ 'native-node20/v1',
160
181
  ];
161
182
  const isRuntimeSupported = (runtime, provider) => {
162
183
  if (provider === providerEnum_1.ProviderEnum.VOLCENGINE) {
@@ -102,7 +102,10 @@ const createRemoteStateBackend = (adapter, config) => {
102
102
  provider: state.provider,
103
103
  stages: {
104
104
  ...existing.stages,
105
- [stage]: { resources: state.resources },
105
+ [stage]: {
106
+ resources: state.resources,
107
+ shared: state.stages?.[stage]?.shared ?? existing.stages?.[stage]?.shared ?? {},
108
+ },
106
109
  },
107
110
  resources: state.resources,
108
111
  };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getRoleArnFromState = exports.getAllResources = exports.removeResource = exports.setResource = exports.getResource = exports.saveStateWithLock = exports.saveState = exports.loadState = exports.migrateState = exports.clearStateMigrations = exports.registerStateMigration = exports.ensureStateDir = exports.getStatePath = void 0;
6
+ exports.getRoleArnFromState = exports.removeSharedResource = exports.setSharedResource = exports.getSharedResource = exports.getAllSharedResources = exports.getAllResources = exports.removeResource = exports.setResource = exports.getResource = exports.saveStateWithLock = exports.saveState = exports.loadState = exports.migrateState = exports.clearStateMigrations = exports.registerStateMigration = exports.ensureStateDir = exports.getStatePath = void 0;
7
7
  const node_fs_1 = __importDefault(require("node:fs"));
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const node_crypto_1 = __importDefault(require("node:crypto"));
@@ -172,7 +172,10 @@ const saveState = (state, app, service, stage, baseDir = process.cwd()) => {
172
172
  provider: state.provider,
173
173
  stages: {
174
174
  ...existing.stages,
175
- [stage]: { resources: state.resources },
175
+ [stage]: {
176
+ resources: state.resources,
177
+ shared: state.stages?.[stage]?.shared ?? existing.stages?.[stage]?.shared ?? {},
178
+ },
176
179
  },
177
180
  resources: state.resources,
178
181
  };
@@ -246,6 +249,53 @@ const getAllResources = (state) => {
246
249
  return state.resources;
247
250
  };
248
251
  exports.getAllResources = getAllResources;
252
+ /* istanbul ignore next */
253
+ const getAllSharedResources = (state, stage) => {
254
+ return state.stages?.[stage]?.shared ?? {};
255
+ };
256
+ exports.getAllSharedResources = getAllSharedResources;
257
+ /* istanbul ignore next */
258
+ const getSharedResource = (state, stage, key) => {
259
+ return state.stages?.[stage]?.shared?.[key];
260
+ };
261
+ exports.getSharedResource = getSharedResource;
262
+ /* istanbul ignore next */
263
+ const setSharedResource = (state, stage, key, resourceState) => {
264
+ return {
265
+ ...state,
266
+ stages: {
267
+ ...state.stages,
268
+ [stage]: {
269
+ ...state.stages?.[stage],
270
+ resources: state.stages?.[stage]?.resources ?? {},
271
+ shared: {
272
+ ...state.stages?.[stage]?.shared,
273
+ [key]: resourceState,
274
+ },
275
+ },
276
+ },
277
+ };
278
+ };
279
+ exports.setSharedResource = setSharedResource;
280
+ /* istanbul ignore next */
281
+ const removeSharedResource = (state, stage, key) => {
282
+ const existingShared = state.stages?.[stage]?.shared;
283
+ if (!existingShared) {
284
+ return state;
285
+ }
286
+ const { [key]: _removed, ...remainingShared } = existingShared;
287
+ return {
288
+ ...state,
289
+ stages: {
290
+ ...state.stages,
291
+ [stage]: {
292
+ ...state.stages[stage],
293
+ shared: remainingShared,
294
+ },
295
+ },
296
+ };
297
+ };
298
+ exports.removeSharedResource = removeSharedResource;
249
299
  /**
250
300
  * Extract role ARN from function state for event resources.
251
301
  * Looks through all function resources to find a RAM role instance and returns its ARN.
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createClsOperations = void 0;
4
+ const polling_1 = require("../polling");
5
+ const constants_1 = require("../constants");
6
+ // CLS reports missing resources with `ResourceNotFound.<Kind>NotExist` codes —
7
+ // match by suffix so get/delete operations stay idempotent.
8
+ const isResourceNotFound = (error) => {
9
+ if (!error || typeof error !== 'object' || !('code' in error)) {
10
+ return false;
11
+ }
12
+ const code = error.code;
13
+ return typeof code === 'string' && code.includes('NotExist');
14
+ };
15
+ const isAlreadyExists = (error) => {
16
+ if (!error || typeof error !== 'object') {
17
+ return false;
18
+ }
19
+ const rec = error;
20
+ const code = typeof rec.code === 'string' ? rec.code : '';
21
+ const message = typeof rec.message === 'string' ? rec.message.toLowerCase() : '';
22
+ return (code.includes('AlreadyExists') ||
23
+ code.includes('ResourceExists') ||
24
+ message.includes('already exist'));
25
+ };
26
+ const createClsOperations = (clsClient) => {
27
+ const operations = {
28
+ createLogset: async (logsetName, tags) => {
29
+ const response = await clsClient.CreateLogset({
30
+ LogsetName: logsetName,
31
+ Tags: tags.map((t) => ({ Key: t.key, Value: t.value })),
32
+ });
33
+ return { logsetId: response?.LogsetId ?? '' };
34
+ },
35
+ getLogsetByName: async (logsetName) => {
36
+ const response = await clsClient.DescribeLogsets({
37
+ Filters: [{ Key: 'logsetName', Values: [logsetName] }],
38
+ });
39
+ // Preserve Tags so adopters can verify app-scope ownership of the logset.
40
+ const found = response?.Logsets?.find((l) => l.LogsetName === logsetName) ?? null;
41
+ if (!found) {
42
+ return null;
43
+ }
44
+ return {
45
+ LogsetId: found.LogsetId,
46
+ LogsetName: found.LogsetName,
47
+ Tags: found.Tags,
48
+ };
49
+ },
50
+ listTopicsByLogset: async (logsetId) => {
51
+ const response = await clsClient.DescribeTopics({
52
+ Filters: [{ Key: 'logsetId', Values: [logsetId] }],
53
+ Limit: 500,
54
+ });
55
+ return response?.Topics ?? [];
56
+ },
57
+ getTopicByName: async (logsetId, topicName) => {
58
+ const response = await clsClient.DescribeTopics({
59
+ Filters: [
60
+ { Key: 'topicName', Values: [topicName] },
61
+ { Key: 'logsetId', Values: [logsetId] },
62
+ ],
63
+ PreciseSearch: 3,
64
+ });
65
+ return response?.Topics?.find((t) => t.TopicName === topicName) ?? null;
66
+ },
67
+ waitForTopic: async (logsetId, topicName) => (0, polling_1.pollUntil)({
68
+ description: `CLS topic ${topicName} to become visible`,
69
+ fetch: () => operations.getTopicByName(logsetId, topicName),
70
+ isDone: (topic) => topic !== null,
71
+ intervalMs: constants_1.CLS_TOPIC_POLL_INTERVAL_MS,
72
+ maxAttempts: constants_1.CLS_TOPIC_POLL_MAX_ATTEMPTS,
73
+ }),
74
+ // Topic creation is async on Tencent CLS — CreateTopic returns before the
75
+ // topic is queryable, so poll until DescribeTopics sees it.
76
+ createTopic: async (logsetId, topicName, opts) => {
77
+ await clsClient.CreateTopic({
78
+ LogsetId: logsetId,
79
+ TopicName: topicName,
80
+ StorageType: opts.storageType ?? 'hot',
81
+ Period: opts.period ?? 30,
82
+ Tags: opts.tags.map((t) => ({ Key: t.key, Value: t.value })),
83
+ });
84
+ const topic = await operations.waitForTopic(logsetId, topicName);
85
+ return { topicId: topic?.TopicId ?? '' };
86
+ },
87
+ deleteTopic: async (topicId) => {
88
+ try {
89
+ await clsClient.DeleteTopic({ TopicId: topicId });
90
+ }
91
+ catch (error) {
92
+ if (isResourceNotFound(error)) {
93
+ return;
94
+ }
95
+ throw error;
96
+ }
97
+ },
98
+ deleteLogset: async (logsetId) => {
99
+ try {
100
+ await clsClient.DeleteLogset({ LogsetId: logsetId });
101
+ }
102
+ catch (error) {
103
+ if (isResourceNotFound(error)) {
104
+ return;
105
+ }
106
+ throw error;
107
+ }
108
+ },
109
+ createFulltextIndex: async (topicId) => {
110
+ try {
111
+ await clsClient.CreateIndex({
112
+ TopicId: topicId,
113
+ Rule: { FullText: { CaseSensitive: false, Tokenizer: ' ,.?;!\n\t' } },
114
+ });
115
+ }
116
+ catch (error) {
117
+ if (isResourceNotFound(error) || isAlreadyExists(error)) {
118
+ return;
119
+ }
120
+ throw error;
121
+ }
122
+ },
123
+ deleteIndex: async (topicId) => {
124
+ try {
125
+ await clsClient.DeleteIndex({ TopicId: topicId });
126
+ }
127
+ catch (error) {
128
+ if (isResourceNotFound(error)) {
129
+ return;
130
+ }
131
+ throw error;
132
+ }
133
+ },
134
+ };
135
+ return operations;
136
+ };
137
+ exports.createClsOperations = createClsOperations;
@@ -39,13 +39,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.createTencentClient = void 0;
42
+ exports.createTencentClient = exports.createClsOperations = void 0;
43
43
  const tencentcloud = __importStar(require("tencentcloud-sdk-nodejs-scf"));
44
44
  const cynosdb = __importStar(require("tencentcloud-sdk-nodejs-cynosdb"));
45
45
  const tencentCam = __importStar(require("tencentcloud-sdk-nodejs-cam"));
46
46
  const tencentEs = __importStar(require("tencentcloud-sdk-nodejs-es"));
47
47
  const tencentSsl = __importStar(require("tencentcloud-sdk-nodejs-ssl"));
48
48
  const tencentTag = __importStar(require("tencentcloud-sdk-nodejs-tag"));
49
+ const tencentCls = __importStar(require("tencentcloud-sdk-nodejs-cls"));
49
50
  const cos_nodejs_sdk_v5_1 = __importDefault(require("cos-nodejs-sdk-v5"));
50
51
  const scfOperations_1 = require("./scfOperations");
51
52
  const cosOperations_1 = require("./cosOperations");
@@ -54,13 +55,17 @@ const tdsqlcOperations_1 = require("./tdsqlcOperations");
54
55
  const esOperations_1 = require("./esOperations");
55
56
  const dnspodOperations_1 = require("./dnspodOperations");
56
57
  const sslOperations_1 = require("./sslOperations");
58
+ const clsOperations_1 = require("./clsOperations");
57
59
  __exportStar(require("./types"), exports);
60
+ var clsOperations_2 = require("./clsOperations");
61
+ Object.defineProperty(exports, "createClsOperations", { enumerable: true, get: function () { return clsOperations_2.createClsOperations; } });
58
62
  const ScfClient = tencentcloud.scf.v20180416.Client;
59
63
  const CynosdbClient = cynosdb.cynosdb.v20190107.Client;
60
64
  const CamClient = tencentCam.cam.v20190116.Client;
61
65
  const EsClient = tencentEs.es.v20180416.Client;
62
66
  const SslClient = tencentSsl.ssl.v20191205.Client;
63
67
  const TagClient = tencentTag.tag.v20180813.Client;
68
+ const ClsClient = tencentCls.cls.v20201016.Client;
64
69
  // Initialize SDK clients (internal)
65
70
  const initializeSdkClients = (context) => {
66
71
  const scfClientConfig = {
@@ -145,6 +150,19 @@ const initializeSdkClients = (context) => {
145
150
  },
146
151
  };
147
152
  const tagClient = new TagClient(tagClientConfig);
153
+ const clsClientConfig = {
154
+ credential: {
155
+ secretId: context.accessKeyId,
156
+ secretKey: context.accessKeySecret,
157
+ },
158
+ region: context.region,
159
+ profile: {
160
+ httpProfile: {
161
+ endpoint: 'cls.tencentcloudapi.com',
162
+ },
163
+ },
164
+ };
165
+ const clsClient = new ClsClient(clsClientConfig);
148
166
  return {
149
167
  scf: scfClient,
150
168
  cos: cosClient,
@@ -154,6 +172,7 @@ const initializeSdkClients = (context) => {
154
172
  dns: (0, dnspodOperations_1.createDnsClient)(context),
155
173
  cam: camClient,
156
174
  tag: tagClient,
175
+ cls: clsClient,
157
176
  };
158
177
  };
159
178
  const createTencentClient = (context) => {
@@ -171,6 +190,7 @@ const createTencentClient = (context) => {
171
190
  tdsqlc: (0, tdsqlcOperations_1.createTdsqlcOperations)(sdkClients.cynosdb, context),
172
191
  es: (0, esOperations_1.createTencentEsOperations)(sdkClients.es, context),
173
192
  ssl: (0, sslOperations_1.createSslOperations)(sdkClients.ssl),
193
+ cls: (0, clsOperations_1.createClsOperations)(sdkClients.cls),
174
194
  dns: dnsOps,
175
195
  };
176
196
  };
@@ -55,6 +55,8 @@ const createScfOperations = (scfClient, deps) => {
55
55
  MemorySize: config.MemorySize,
56
56
  Timeout: config.Timeout,
57
57
  ...(config.Role && { Role: config.Role }),
58
+ ...(config.ClsLogsetId && { ClsLogsetId: config.ClsLogsetId }),
59
+ ...(config.ClsTopicId && { ClsTopicId: config.ClsTopicId }),
58
60
  ...(config.Environment && { Environment: config.Environment }),
59
61
  };
60
62
  await scfClient.CreateFunction(params);
@@ -174,11 +176,20 @@ const createScfOperations = (scfClient, deps) => {
174
176
  // Handler and Runtime are set at creation time and CANNOT be changed via
175
177
  // UpdateFunctionConfiguration (Tencent rejects them with
176
178
  // InvalidParameterValue.Handler / .Runtime) — omit them here.
179
+ //
180
+ // Tencent requires Role whenever the Cls* destination changes, else
181
+ // UpdateFunctionConfiguration fails with InvalidParameterValue.ClsRole —
182
+ // so Role is forwarded here whenever an si-managed role is present.
183
+ //
184
+ // Cls ids are forwarded whenever present — including '' — because
185
+ // passing ClsLogsetId/ClsTopicId as '' is Tencent's unbind contract.
177
186
  const params = {
178
187
  FunctionName: config.FunctionName,
179
188
  MemorySize: config.MemorySize,
180
189
  Timeout: config.Timeout,
181
190
  ...(config.Role && { Role: config.Role }),
191
+ ...(config.ClsLogsetId !== undefined ? { ClsLogsetId: config.ClsLogsetId } : {}),
192
+ ...(config.ClsTopicId !== undefined ? { ClsTopicId: config.ClsTopicId } : {}),
182
193
  ...(config.Environment && { Environment: config.Environment }),
183
194
  };
184
195
  await operations.waitForFunctionActive(config.FunctionName);
@@ -58,6 +58,16 @@ const buildExecutionPolicy = (customStatements) => {
58
58
  const merged = (0, iamStatements_1.mergePolicyStatements)(VEFAAS_EXECUTION_STATEMENTS, customStatements, mapToVolcengineStatement);
59
59
  return (0, iamStatements_1.buildPolicyDocument)(merged);
60
60
  };
61
+ // TagResources expects flat numbered query params (ResourceIds.1, Tags.1.Key, ...).
62
+ // ResourceIds.1 carries the ROLE NAME (consistent with DeleteRole using RoleName).
63
+ const buildTagResourceQuery = (roleName, tags) => {
64
+ return tags.reduce((query, tag, index) => {
65
+ const n = index + 1;
66
+ query[`Tags.${n}.Key`] = tag.key;
67
+ query[`Tags.${n}.Value`] = tag.value;
68
+ return query;
69
+ }, { ResourceType: 'role', 'ResourceIds.1': roleName });
70
+ };
61
71
  const createIamOperations = (iamClient) => {
62
72
  const createAndAttachPolicy = async (roleName, customStatements) => {
63
73
  const policyName = `${roleName}-policy`;
@@ -440,6 +450,29 @@ const createIamOperations = (iamClient) => {
440
450
  logger_1.logger.info(lang_1.lang.__('MANAGED_POLICY_ATTACHED', { policyArn: policyName, roleName }));
441
451
  }
442
452
  },
453
+ tagRole: async (roleName, tags) => {
454
+ try {
455
+ await iamClient.fetchOpenAPI({
456
+ Action: 'TagResources',
457
+ Version: '2018-01-01',
458
+ method: 'GET',
459
+ headers: { 'content-type': 'application/json' },
460
+ query: buildTagResourceQuery(roleName, tags),
461
+ });
462
+ }
463
+ catch (error) {
464
+ if (error && typeof error === 'object' && 'code' in error) {
465
+ const code = String(error.code);
466
+ if (code.startsWith('ResourceNotFound.Role') ||
467
+ code === 'RoleNotFound' ||
468
+ code === 'NoSuchEntity') {
469
+ logger_1.logger.warn(lang_1.lang.__('VOLCENGINE_ROLE_NOT_FOUND_FOR_TAG', { roleName }));
470
+ return;
471
+ }
472
+ }
473
+ throw error;
474
+ }
475
+ },
443
476
  };
444
477
  };
445
478
  exports.createIamOperations = createIamOperations;