@geek-fun/serverlessinsight 0.9.7 → 0.9.8
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/AGENTS.md +1 -0
- package/CHANGELOG.md +68 -6
- package/README.md +51 -10
- package/README.zh-CN.md +44 -10
- package/dist/package.json +2 -1
- package/dist/src/commands/deploy.js +3 -1
- package/dist/src/commands/destroy.js +3 -1
- package/dist/src/commands/forceUnlock.js +2 -2
- package/dist/src/commands/index.js +28 -8
- package/dist/src/commands/local.js +3 -2
- package/dist/src/commands/login.js +120 -37
- package/dist/src/commands/logout.js +3 -5
- package/dist/src/commands/migrate.js +17 -10
- package/dist/src/commands/plan.js +5 -1
- package/dist/src/commands/show.js +3 -1
- package/dist/src/commands/whoami.js +24 -6
- package/dist/src/common/aliyunClient/cdnOperations.js +64 -29
- package/dist/src/common/aliyunClient/dnsOperations.js +10 -0
- package/dist/src/common/aliyunClient/fc3Operations.js +36 -7
- package/dist/src/common/apiClient.js +1 -0
- package/dist/src/common/bindingReconcile.js +182 -0
- package/dist/src/common/cdnCapabilities.js +80 -0
- package/dist/src/common/certUtils.js +44 -5
- package/dist/src/common/consoleLines.js +126 -0
- package/dist/src/common/constants.js +4 -2
- package/dist/src/common/credentialStore.js +136 -39
- package/dist/src/common/domainUtils.js +23 -4
- package/dist/src/common/functionDefinition.js +4 -1
- package/dist/src/common/functionDomainCapabilities.js +28 -0
- package/dist/src/common/functionDomainReconcile.js +197 -0
- package/dist/src/common/lineContext.js +164 -0
- package/dist/src/common/planCapabilities.js +14 -27
- package/dist/src/common/planCompare.js +8 -7
- package/dist/src/common/planFormatter.js +71 -37
- package/dist/src/common/stateBackend/index.js +24 -16
- package/dist/src/common/stateBackend/saasStateBackend.js +46 -53
- package/dist/src/common/stateBackend/tosStateBackend.js +100 -0
- package/dist/src/common/tencentClient/cdnOperations.js +165 -0
- package/dist/src/common/tencentClient/cosOperations.js +18 -2
- package/dist/src/common/tencentClient/dnspodOperations.js +12 -0
- package/dist/src/common/tencentClient/index.js +16 -0
- package/dist/src/common/tencentClient/scfOperations.js +23 -1
- package/dist/src/common/tencentClient/sslOperations.js +147 -77
- package/dist/src/common/volcengineClient/cdnOperations.js +221 -0
- package/dist/src/common/volcengineClient/dnsOperations.js +132 -0
- package/dist/src/common/volcengineClient/index.js +28 -0
- package/dist/src/common/volcengineClient/tosOperations.js +131 -1
- package/dist/src/lang/en.js +89 -10
- package/dist/src/lang/zh-CN.js +90 -9
- package/dist/src/parser/bucketParser.js +22 -79
- package/dist/src/parser/functionParser.js +13 -9
- package/dist/src/stack/aliyunStack/apigwResource.js +2 -1
- package/dist/src/stack/aliyunStack/fc3Planner.js +32 -12
- package/dist/src/stack/aliyunStack/fc3Resource.js +169 -121
- package/dist/src/stack/aliyunStack/ossPlanner.js +12 -4
- package/dist/src/stack/aliyunStack/ossResource.js +484 -501
- package/dist/src/stack/aliyunStack/ossTypes.js +21 -67
- package/dist/src/stack/localStack/aliyunFc.js +59 -9
- package/dist/src/stack/localStack/bucket.js +75 -28
- package/dist/src/stack/localStack/event.js +33 -24
- package/dist/src/stack/localStack/httpAdapter.js +1 -13
- package/dist/src/stack/localStack/index.js +2 -2
- package/dist/src/stack/localStack/localServer.js +85 -7
- package/dist/src/stack/scfStack/cosPlanner.js +11 -3
- package/dist/src/stack/scfStack/cosResource.js +339 -161
- package/dist/src/stack/scfStack/cosTypes.js +25 -34
- package/dist/src/stack/scfStack/scfPlanner.js +26 -8
- package/dist/src/stack/scfStack/scfResource.js +191 -124
- package/dist/src/stack/volcengineStack/tosPlanner.js +13 -1
- package/dist/src/stack/volcengineStack/tosResource.js +398 -7
- package/dist/src/stack/volcengineStack/tosTypes.js +27 -0
- package/dist/src/stack/volcengineStack/vefaasTypes.js +1 -1
- package/dist/src/types/domains/state.js +6 -0
- package/dist/src/validator/bucketSchema.js +35 -113
- package/dist/src/validator/cdnSchema.js +30 -0
- package/dist/src/validator/eventSchema.js +2 -20
- package/dist/src/validator/functionSchema.js +55 -8
- package/dist/src/validator/rootSchema.js +3 -3
- package/dist/src/validator/semanticValidation.js +504 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/release-notes.md +82 -6
- package/samples/aliyun-poc-api-cdn.yml +1 -1
- package/samples/aliyun-poc-bucket-cdn.yml +28 -26
- package/samples/aliyun-poc-domain.yml +2 -1
- package/samples/volcengine-poc-tos-state.yml +36 -0
|
@@ -43,6 +43,7 @@ const open_1 = __importDefault(require("open"));
|
|
|
43
43
|
const common_1 = require("../common");
|
|
44
44
|
const apiClient_1 = require("../common/apiClient");
|
|
45
45
|
const credentialStore_1 = require("../common/credentialStore");
|
|
46
|
+
const consoleLines_1 = require("../common/consoleLines");
|
|
46
47
|
const lang_1 = require("../lang");
|
|
47
48
|
const ask = (query) => {
|
|
48
49
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
@@ -53,24 +54,76 @@ const ask = (query) => {
|
|
|
53
54
|
});
|
|
54
55
|
});
|
|
55
56
|
};
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
/** ADR-008: pick the line by NAME; the origin shown is informational only. */
|
|
58
|
+
const promptLinePicker = async () => {
|
|
59
|
+
console.log(`\n ${lang_1.lang.__('LOGIN_PICK_LINE')}\n`);
|
|
60
|
+
consoleLines_1.LINE_NAMES.forEach((name, index) => {
|
|
61
|
+
console.log(lang_1.lang.__('LOGIN_LINE_OPTION', {
|
|
62
|
+
index: String(index + 1),
|
|
63
|
+
name,
|
|
64
|
+
origin: consoleLines_1.CONSOLE_LINES[name].origin,
|
|
65
|
+
}));
|
|
66
|
+
});
|
|
67
|
+
console.log('');
|
|
68
|
+
for (;;) {
|
|
69
|
+
const answer = await ask(lang_1.lang.__('LOGIN_LINE_PROMPT'));
|
|
70
|
+
const index = Number.parseInt(answer.trim(), 10);
|
|
71
|
+
if (Number.isNaN(index)) {
|
|
72
|
+
// Empty input accepts the first option as the default.
|
|
73
|
+
if (answer.trim() === '')
|
|
74
|
+
return consoleLines_1.LINE_NAMES[0];
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (index >= 1 && index <= consoleLines_1.LINE_NAMES.length) {
|
|
78
|
+
return consoleLines_1.LINE_NAMES[index - 1];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const finalizeLogin = (apiKey, line, identity, orgFlag, region) => {
|
|
83
|
+
const keyLine = (0, consoleLines_1.parseApiKeyLine)(apiKey);
|
|
84
|
+
if (keyLine && keyLine !== line) {
|
|
85
|
+
common_1.logger.error(lang_1.lang.__('LOGIN_LINE_MISMATCH', { keyLine, line }));
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
// ADR-008 defensive cross-check: the issuing platform's own line segment
|
|
89
|
+
// must agree with the line we authenticated against.
|
|
90
|
+
const expectedSegment = consoleLines_1.CONSOLE_LINES[line].keySegment;
|
|
91
|
+
if (region && region !== expectedSegment) {
|
|
92
|
+
common_1.logger.error(lang_1.lang.__('LOGIN_LINE_MISMATCH', { keyLine: region, line }));
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
if (orgFlag && identity.orgSlug && identity.orgSlug !== orgFlag) {
|
|
96
|
+
common_1.logger.error(lang_1.lang.__('LOGIN_ORG_MISMATCH', { actual: identity.orgSlug, expected: orgFlag }));
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
const slug = identity.orgSlug || identity.orgId || 'unknown';
|
|
100
|
+
(0, credentialStore_1.saveProfile)(line, {
|
|
101
|
+
apiKey,
|
|
102
|
+
orgId: identity.orgId,
|
|
103
|
+
orgName: identity.orgName,
|
|
104
|
+
orgSlug: slug,
|
|
105
|
+
userEmail: identity.userEmail,
|
|
106
|
+
}, { activate: true });
|
|
107
|
+
common_1.logger.info(lang_1.lang.__('LOGIN_PROFILE_SAVED', {
|
|
108
|
+
profileKey: (0, consoleLines_1.toProfileKey)(line, slug),
|
|
109
|
+
userEmail: identity.userEmail || '(unknown)',
|
|
110
|
+
}));
|
|
111
|
+
return true;
|
|
112
|
+
};
|
|
113
|
+
const loginWithKey = async (apiKey, line, orgFlag) => {
|
|
114
|
+
if (!(0, consoleLines_1.validateApiKeyFormat)(apiKey)) {
|
|
58
115
|
common_1.logger.error(lang_1.lang.__('LOGIN_KEY_FORMAT_INVALID'));
|
|
59
116
|
return false;
|
|
60
117
|
}
|
|
61
118
|
common_1.logger.info(lang_1.lang.__('LOGIN_VALIDATING_KEY'));
|
|
62
119
|
try {
|
|
63
|
-
const result = await (0, apiClient_1.validateApiKey)(apiKey,
|
|
64
|
-
(
|
|
65
|
-
apiKey,
|
|
66
|
-
consoleUrl,
|
|
120
|
+
const result = await (0, apiClient_1.validateApiKey)(apiKey, (0, consoleLines_1.consoleOriginFor)(line));
|
|
121
|
+
return finalizeLogin(apiKey, line, {
|
|
67
122
|
orgId: result.orgId,
|
|
68
123
|
orgName: result.orgName,
|
|
69
124
|
orgSlug: result.orgSlug,
|
|
70
125
|
userEmail: result.userEmail,
|
|
71
|
-
});
|
|
72
|
-
common_1.logger.info(lang_1.lang.__('LOGIN_SUCCESS_KEY', { orgName: result.orgName }));
|
|
73
|
-
return true;
|
|
126
|
+
}, orgFlag, result.region);
|
|
74
127
|
}
|
|
75
128
|
catch (error) {
|
|
76
129
|
common_1.logger.error(lang_1.lang.__('LOGIN_KEY_INVALID'));
|
|
@@ -78,12 +131,12 @@ const loginWithKey = async (apiKey, consoleUrl) => {
|
|
|
78
131
|
return false;
|
|
79
132
|
}
|
|
80
133
|
};
|
|
81
|
-
const loginWithBrowser = async (
|
|
134
|
+
const loginWithBrowser = async (line, orgFlag) => {
|
|
82
135
|
const randomPort = Math.floor(Math.random() * 79) + 54321; // 54321-54399
|
|
83
136
|
let apiKey = null;
|
|
84
137
|
common_1.logger.info(lang_1.lang.__('LOGIN_STARTING_SERVER'));
|
|
85
138
|
return new Promise((resolve) => {
|
|
86
|
-
const uiUrl = (0,
|
|
139
|
+
const uiUrl = (0, consoleLines_1.consoleUiOriginFor)(line);
|
|
87
140
|
const server = (0, node_http_1.createServer)(async (req, res) => {
|
|
88
141
|
if (!req.url)
|
|
89
142
|
return;
|
|
@@ -120,22 +173,31 @@ const loginWithBrowser = async (consoleUrl) => {
|
|
|
120
173
|
clearTimeout(timeoutTimer);
|
|
121
174
|
server.closeAllConnections();
|
|
122
175
|
server.close();
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
176
|
+
const identity = {
|
|
177
|
+
orgId: url.searchParams.get('org_id') || '',
|
|
178
|
+
orgName: url.searchParams.get('org_name') || '',
|
|
179
|
+
userEmail: url.searchParams.get('user_email') || '',
|
|
180
|
+
orgSlug: undefined,
|
|
181
|
+
};
|
|
126
182
|
// The authorize callback doesn't carry the org slug; fetch the full
|
|
127
183
|
// identity once so the yml `org:` cross-check works out of the box.
|
|
128
184
|
// Degrade to the callback params if the validate roundtrip fails.
|
|
129
|
-
let
|
|
185
|
+
let region;
|
|
130
186
|
try {
|
|
131
|
-
|
|
187
|
+
const validated = await (0, apiClient_1.validateApiKey)(key, (0, consoleLines_1.consoleOriginFor)(line));
|
|
188
|
+
identity.orgSlug = validated.orgSlug;
|
|
189
|
+
region = validated.region;
|
|
190
|
+
if (!identity.orgId)
|
|
191
|
+
identity.orgId = validated.orgId;
|
|
192
|
+
if (!identity.orgName)
|
|
193
|
+
identity.orgName = validated.orgName;
|
|
194
|
+
if (!identity.userEmail)
|
|
195
|
+
identity.userEmail = validated.userEmail;
|
|
132
196
|
}
|
|
133
197
|
catch {
|
|
134
|
-
orgSlug = undefined;
|
|
198
|
+
identity.orgSlug = undefined;
|
|
135
199
|
}
|
|
136
|
-
(
|
|
137
|
-
common_1.logger.info(lang_1.lang.__('LOGIN_SUCCESS', { userEmail, orgName }));
|
|
138
|
-
resolve(true);
|
|
200
|
+
resolve(finalizeLogin(key, line, identity, orgFlag, region));
|
|
139
201
|
}
|
|
140
202
|
else {
|
|
141
203
|
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
@@ -166,41 +228,62 @@ const loginWithBrowser = async (consoleUrl) => {
|
|
|
166
228
|
});
|
|
167
229
|
};
|
|
168
230
|
const login = async (options) => {
|
|
169
|
-
const consoleUrl = (0, credentialStore_1.resolveConsoleUrl)((0, credentialStore_1.loadCredentials)() ?? undefined);
|
|
170
231
|
// Check if already logged in
|
|
171
|
-
const
|
|
172
|
-
|
|
232
|
+
const file = (0, credentialStore_1.loadCredentialsFile)();
|
|
233
|
+
const activeProfile = file?.active ? file.profiles[file.active] : undefined;
|
|
234
|
+
if (activeProfile && process.stdin.isTTY === true) {
|
|
173
235
|
const answer = await ask(lang_1.lang.__('LOGIN_ALREADY_LOGGED_IN', {
|
|
174
|
-
userEmail:
|
|
175
|
-
orgName:
|
|
236
|
+
userEmail: activeProfile.userEmail || '',
|
|
237
|
+
orgName: activeProfile.orgName || activeProfile.orgId,
|
|
176
238
|
}));
|
|
177
239
|
if (answer.toLowerCase() !== 'y' && answer.toLowerCase() !== 'yes') {
|
|
178
240
|
common_1.logger.info(lang_1.lang.__('LOGIN_CANCELLED'));
|
|
179
241
|
return;
|
|
180
242
|
}
|
|
181
|
-
(0, credentialStore_1.deleteCredentials)();
|
|
182
|
-
}
|
|
183
|
-
// If --si-api-key provided, use it directly
|
|
184
|
-
if (options.siApiKey) {
|
|
185
|
-
await loginWithKey(options.siApiKey, consoleUrl);
|
|
186
|
-
return;
|
|
187
243
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
244
|
+
const flagLine = (0, consoleLines_1.normalizeLineName)(options.line);
|
|
245
|
+
// If --si-api-key provided (or SI_API_KEY env), use it directly
|
|
246
|
+
const key = options.siApiKey ?? process.env.SI_API_KEY;
|
|
247
|
+
if (key) {
|
|
248
|
+
const keyLine = (0, consoleLines_1.parseApiKeyLine)(key);
|
|
249
|
+
if (keyLine && flagLine && keyLine !== flagLine) {
|
|
250
|
+
common_1.logger.error(lang_1.lang.__('LOGIN_LINE_MISMATCH', { keyLine, line: flagLine }));
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const line = keyLine ?? flagLine ?? (0, consoleLines_1.normalizeLineName)(process.env.SI_CONSOLE_LINE);
|
|
254
|
+
if (!line) {
|
|
255
|
+
if (process.stdin.isTTY === true) {
|
|
256
|
+
const picked = await promptLinePicker();
|
|
257
|
+
await loginWithKey(key, picked, options.org);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
common_1.logger.error(lang_1.lang.__('LOGIN_NEED_LINE'));
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (!keyLine && !flagLine && process.env.SI_CONSOLE_LINE) {
|
|
264
|
+
common_1.logger.warn(lang_1.lang.__('SAAS_LINE_ENV_DEPRECATED'));
|
|
265
|
+
}
|
|
266
|
+
await loginWithKey(key, line, options.org);
|
|
191
267
|
return;
|
|
192
268
|
}
|
|
269
|
+
// Interactive flow: pick the region first (ADR-008), then the method.
|
|
270
|
+
const line = flagLine ??
|
|
271
|
+
(process.stdin.isTTY === true
|
|
272
|
+
? await promptLinePicker()
|
|
273
|
+
: (() => {
|
|
274
|
+
throw new Error(lang_1.lang.__('SAAS_LINE_UNRESOLVED', { operation: 'login' }));
|
|
275
|
+
})());
|
|
193
276
|
// Interactive prompt
|
|
194
277
|
console.log(`\n ${lang_1.lang.__('LOGIN_CHOOSE_METHOD')}\n`);
|
|
195
278
|
console.log(` 1. ${lang_1.lang.__('LOGIN_OPTION_BROWSER')}`);
|
|
196
279
|
console.log(` 2. ${lang_1.lang.__('LOGIN_OPTION_API_KEY')}\n`);
|
|
197
280
|
const choice = await ask(lang_1.lang.__('LOGIN_SELECT_CHOICE'));
|
|
198
281
|
if (choice.trim() === '2') {
|
|
199
|
-
const
|
|
200
|
-
await loginWithKey(
|
|
282
|
+
const keyInput = await ask(lang_1.lang.__('LOGIN_ENTER_API_KEY'));
|
|
283
|
+
await loginWithKey(keyInput.trim(), line, options.org);
|
|
201
284
|
}
|
|
202
285
|
else {
|
|
203
|
-
await loginWithBrowser(
|
|
286
|
+
await loginWithBrowser(line, options.org);
|
|
204
287
|
}
|
|
205
288
|
};
|
|
206
289
|
exports.login = login;
|
|
@@ -5,13 +5,11 @@ const common_1 = require("../common");
|
|
|
5
5
|
const credentialStore_1 = require("../common/credentialStore");
|
|
6
6
|
const lang_1 = require("../lang");
|
|
7
7
|
const logout = async () => {
|
|
8
|
-
const
|
|
9
|
-
if (!
|
|
8
|
+
const removed = (0, credentialStore_1.removeActiveProfile)();
|
|
9
|
+
if (!removed) {
|
|
10
10
|
common_1.logger.info(lang_1.lang.__('LOGOUT_NOT_LOGGED_IN'));
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
common_1.logger.info(lang_1.lang.__('
|
|
14
|
-
(0, credentialStore_1.deleteCredentials)();
|
|
15
|
-
common_1.logger.info(lang_1.lang.__('LOGOUT_SUCCESS'));
|
|
13
|
+
common_1.logger.info(lang_1.lang.__('LOGOUT_SUCCESS', { profileKey: removed.profileKey }));
|
|
16
14
|
};
|
|
17
15
|
exports.logout = logout;
|
|
@@ -37,7 +37,8 @@ exports.migrate = void 0;
|
|
|
37
37
|
const readline = __importStar(require("node:readline"));
|
|
38
38
|
const common_1 = require("../common");
|
|
39
39
|
const stateBackend_1 = require("../common/stateBackend");
|
|
40
|
-
const
|
|
40
|
+
const lineContext_1 = require("../common/lineContext");
|
|
41
|
+
const consoleLines_1 = require("../common/consoleLines");
|
|
41
42
|
const apiClient_1 = require("../common/apiClient");
|
|
42
43
|
const migrationMarker_1 = require("../common/migrationMarker");
|
|
43
44
|
const types_1 = require("../types");
|
|
@@ -93,7 +94,10 @@ const migrate = async (options) => {
|
|
|
93
94
|
}
|
|
94
95
|
// Marker checks stay OFF on the source backend: si migrate must be able to
|
|
95
96
|
// read a marked state (idempotent re-runs, --rollback).
|
|
96
|
-
const sourceBackend = (0, stateBackend_1.createStateBackend)(iac.backend, {
|
|
97
|
+
const sourceBackend = await (0, stateBackend_1.createStateBackend)(iac.backend, {
|
|
98
|
+
...context,
|
|
99
|
+
siApiKey: options.siApiKey,
|
|
100
|
+
});
|
|
97
101
|
// --rollback: the explicit undo — clear the marker, legacy path reopens.
|
|
98
102
|
// Purely local to the source backend, so it needs NO Console credentials.
|
|
99
103
|
if (options.rollback) {
|
|
@@ -112,16 +116,19 @@ const migrate = async (options) => {
|
|
|
112
116
|
});
|
|
113
117
|
return;
|
|
114
118
|
}
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
// ADR-008: one resolution entry for line + key + org identity.
|
|
120
|
+
const lineCtx = await (0, lineContext_1.resolveLineContext)({
|
|
121
|
+
siApiKey: options.siApiKey,
|
|
122
|
+
declaredOrg: iac.org,
|
|
123
|
+
orgFlag: options.org,
|
|
124
|
+
lineFlag: options.line,
|
|
125
|
+
operation: 'migrate',
|
|
126
|
+
});
|
|
127
|
+
const { apiKey, consoleUrl: baseUrl } = lineCtx;
|
|
120
128
|
const identity = await (0, apiClient_1.validateApiKey)(apiKey, baseUrl);
|
|
129
|
+
(0, consoleLines_1.assertValidatedRegion)(lineCtx.line, identity.region);
|
|
130
|
+
(0, consoleLines_1.assertValidatedOrg)(iac.org ?? options.org, identity.orgSlug);
|
|
121
131
|
const orgId = identity.orgId;
|
|
122
|
-
if (iac.org && identity.orgSlug && iac.org !== identity.orgSlug) {
|
|
123
|
-
throw new Error(lang_1.lang.__('SAAS_ORG_MISMATCH', { declared: iac.org, actual: identity.orgSlug }));
|
|
124
|
-
}
|
|
125
132
|
const client = (0, apiClient_1.createApiClient)({ apiKey, baseUrl, orgId });
|
|
126
133
|
if (!(0, common_1.supportsRegionalSaas)(await client.get('/api/v1/capabilities'))) {
|
|
127
134
|
throw new Error(lang_1.lang.__('SAAS_REGIONAL_SCOPE_UNSUPPORTED', { consoleUrl: baseUrl }));
|
|
@@ -34,9 +34,11 @@ const plan = async (options) => {
|
|
|
34
34
|
};
|
|
35
35
|
const providerDisplayName = providerDisplayNames[iac.provider.name] ?? iac.provider.name;
|
|
36
36
|
common_1.logger.info(lang_1.lang.__('GENERATING_PLAN_FOR_PROVIDER', { provider: providerDisplayName }));
|
|
37
|
-
const backend = (0, stateBackend_1.createStateBackend)(iac.backend, {
|
|
37
|
+
const backend = await (0, stateBackend_1.createStateBackend)(iac.backend, {
|
|
38
38
|
...context,
|
|
39
39
|
declaredOrg: iac.org,
|
|
40
|
+
org: options.org,
|
|
41
|
+
line: options.line,
|
|
40
42
|
migrationMarker: 'warn',
|
|
41
43
|
mode: 'read-only',
|
|
42
44
|
});
|
|
@@ -92,6 +94,8 @@ const runDiffCommand = async (options) => {
|
|
|
92
94
|
refresh: options.refresh,
|
|
93
95
|
json: !!options.json,
|
|
94
96
|
noColor: options.color === false,
|
|
97
|
+
org: options.org,
|
|
98
|
+
line: options.line,
|
|
95
99
|
});
|
|
96
100
|
// Issue #250 exit-code convention (terraform-compatible):
|
|
97
101
|
// 0 = no changes, 2 = changes present, 1 = execution error (handler).
|
|
@@ -215,10 +215,12 @@ const show = async (options) => {
|
|
|
215
215
|
!backendType;
|
|
216
216
|
if (shouldUseRemoteBackend) {
|
|
217
217
|
try {
|
|
218
|
-
const backend = (0, stateBackend_1.createStateBackend)(options.iac.backend, {
|
|
218
|
+
const backend = await (0, stateBackend_1.createStateBackend)(options.iac.backend, {
|
|
219
219
|
...context,
|
|
220
220
|
stage,
|
|
221
221
|
declaredOrg: options.iac.org,
|
|
222
|
+
org: options.org,
|
|
223
|
+
line: options.line,
|
|
222
224
|
migrationMarker: 'warn',
|
|
223
225
|
mode: 'read-only',
|
|
224
226
|
});
|
|
@@ -3,18 +3,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.whoami = void 0;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const credentialStore_1 = require("../common/credentialStore");
|
|
6
|
+
const consoleLines_1 = require("../common/consoleLines");
|
|
6
7
|
const lang_1 = require("../lang");
|
|
7
8
|
const whoami = async () => {
|
|
8
|
-
const
|
|
9
|
-
|
|
9
|
+
const file = (0, credentialStore_1.loadCredentialsFile)();
|
|
10
|
+
const profileKeys = Object.keys(file?.profiles ?? {});
|
|
11
|
+
if (!file || profileKeys.length === 0) {
|
|
10
12
|
common_1.logger.info(lang_1.lang.__('WHOAMI_NOT_LOGGED_IN'));
|
|
11
13
|
return;
|
|
12
14
|
}
|
|
13
15
|
common_1.logger.info('');
|
|
14
|
-
common_1.logger.info(` ${lang_1.lang.__('
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
common_1.logger.info(` ${lang_1.lang.__('WHOAMI_PROFILES_HEADER', { count: String(profileKeys.length) })}`);
|
|
17
|
+
let activeLine;
|
|
18
|
+
for (const key of profileKeys) {
|
|
19
|
+
const profile = file.profiles[key];
|
|
20
|
+
const isActive = key === file.active;
|
|
21
|
+
const split = (0, consoleLines_1.splitProfileKey)(key);
|
|
22
|
+
if (isActive && split)
|
|
23
|
+
activeLine = split.line;
|
|
24
|
+
common_1.logger.info(' ' +
|
|
25
|
+
lang_1.lang.__('WHOAMI_PROFILE', {
|
|
26
|
+
marker: isActive ? lang_1.lang.__('WHOAMI_ACTIVE_MARK') : ' ',
|
|
27
|
+
profileKey: key,
|
|
28
|
+
orgName: profile.orgName || profile.orgId,
|
|
29
|
+
keyPrefix: profile.apiKey.slice(0, 12),
|
|
30
|
+
}) +
|
|
31
|
+
(isActive ? lang_1.lang.__('WHOAMI_ACTIVE_SUFFIX') : ''));
|
|
32
|
+
}
|
|
33
|
+
if (activeLine) {
|
|
34
|
+
common_1.logger.info(` ${lang_1.lang.__('WHOAMI_CONSOLE', { url: (0, consoleLines_1.consoleOriginFor)(activeLine) })}`);
|
|
35
|
+
}
|
|
18
36
|
common_1.logger.info('');
|
|
19
37
|
};
|
|
20
38
|
exports.whoami = whoami;
|
|
@@ -104,7 +104,32 @@ const setDomainServerCertificate = (cdnClient) => async (domainName, certConfig)
|
|
|
104
104
|
});
|
|
105
105
|
await cdnClient.setCdnDomainSSLCertificate(request);
|
|
106
106
|
};
|
|
107
|
+
// Aliyun expresses "off" for module-style functions (cache_expire,
|
|
108
|
+
// force_redirect) by the absence of the config item — there is no off value,
|
|
109
|
+
// so a reset is a describe + delete of that function's config.
|
|
110
|
+
const removeDomainConfig = (cdnClient) => async (domainName, functionName) => {
|
|
111
|
+
const describeRequest = new cdn.DescribeCdnDomainConfigsRequest({
|
|
112
|
+
domainName,
|
|
113
|
+
functionNames: functionName,
|
|
114
|
+
});
|
|
115
|
+
const response = await cdnClient.describeCdnDomainConfigs(describeRequest);
|
|
116
|
+
const configured = response.body?.domainConfigs?.domainConfig ?? [];
|
|
117
|
+
if (!configured.some((config) => config.functionName === functionName))
|
|
118
|
+
return;
|
|
119
|
+
const deleteRequest = new cdn.BatchDeleteCdnDomainConfigRequest({
|
|
120
|
+
domainNames: domainName,
|
|
121
|
+
functionNames: functionName,
|
|
122
|
+
});
|
|
123
|
+
await cdnClient.batchDeleteCdnDomainConfig(deleteRequest);
|
|
124
|
+
};
|
|
107
125
|
const applyCacheConfig = (cdnClient) => async (domainName, cacheTtl, ignoreQueryString) => {
|
|
126
|
+
// Both options reset → the provider default is the absence of the
|
|
127
|
+
// cache_expire config; a ttl of '0' would mean "do not cache", not
|
|
128
|
+
// "follow origin", so deletion is the only honest reset.
|
|
129
|
+
if (cacheTtl == null && ignoreQueryString == null) {
|
|
130
|
+
await removeDomainConfig(cdnClient)(domainName, 'cache_expire');
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
108
133
|
const functions = [];
|
|
109
134
|
if (cacheTtl != null || ignoreQueryString != null) {
|
|
110
135
|
functions.push({
|
|
@@ -125,21 +150,25 @@ const applyCacheConfig = (cdnClient) => async (domainName, cacheTtl, ignoreQuery
|
|
|
125
150
|
}
|
|
126
151
|
};
|
|
127
152
|
const applyProtocolConfig = (cdnClient) => async (domainName, originProtocol) => {
|
|
128
|
-
if (originProtocol) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
enable: originProtocol,
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
];
|
|
137
|
-
const request = new cdn.BatchSetCdnDomainConfigRequest({
|
|
138
|
-
domainNames: domainName,
|
|
139
|
-
functions: JSON.stringify(functions),
|
|
140
|
-
});
|
|
141
|
-
await cdnClient.batchSetCdnDomainConfig(request);
|
|
153
|
+
if (!originProtocol) {
|
|
154
|
+
// Dropped option → provider default = the absence of the forward_scheme
|
|
155
|
+
// config, so the reset deletes it instead of leaving the old scheme.
|
|
156
|
+
await removeDomainConfig(cdnClient)(domainName, 'forward_scheme');
|
|
157
|
+
return;
|
|
142
158
|
}
|
|
159
|
+
const functions = [
|
|
160
|
+
{
|
|
161
|
+
featureName: 'forward_scheme',
|
|
162
|
+
featureParameters: {
|
|
163
|
+
enable: originProtocol,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
const request = new cdn.BatchSetCdnDomainConfigRequest({
|
|
168
|
+
domainNames: domainName,
|
|
169
|
+
functions: JSON.stringify(functions),
|
|
170
|
+
});
|
|
171
|
+
await cdnClient.batchSetCdnDomainConfig(request);
|
|
143
172
|
};
|
|
144
173
|
const applyCompression = (cdnClient) => async (domainName, enabled) => {
|
|
145
174
|
if (enabled != null) {
|
|
@@ -159,22 +188,28 @@ const applyCompression = (cdnClient) => async (domainName, enabled) => {
|
|
|
159
188
|
}
|
|
160
189
|
};
|
|
161
190
|
const applyHttpsRedirect = (cdnClient) => async (domainName, enabled) => {
|
|
162
|
-
if (enabled
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
];
|
|
172
|
-
const request = new cdn.BatchSetCdnDomainConfigRequest({
|
|
173
|
-
domainNames: domainName,
|
|
174
|
-
functions: JSON.stringify(functions),
|
|
175
|
-
});
|
|
176
|
-
await cdnClient.batchSetCdnDomainConfig(request);
|
|
191
|
+
if (enabled == null)
|
|
192
|
+
return;
|
|
193
|
+
if (!enabled) {
|
|
194
|
+
// redirect_type 'http' would be an active HTTPS→HTTP downgrade —
|
|
195
|
+
// disabling removes the force_redirect config instead.
|
|
196
|
+
await removeDomainConfig(cdnClient)(domainName, 'force_redirect');
|
|
197
|
+
return;
|
|
177
198
|
}
|
|
199
|
+
const functions = [
|
|
200
|
+
{
|
|
201
|
+
featureName: 'force_redirect',
|
|
202
|
+
featureParameters: {
|
|
203
|
+
redirect_code: '301',
|
|
204
|
+
redirect_type: 'https',
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
];
|
|
208
|
+
const request = new cdn.BatchSetCdnDomainConfigRequest({
|
|
209
|
+
domainNames: domainName,
|
|
210
|
+
functions: JSON.stringify(functions),
|
|
211
|
+
});
|
|
212
|
+
await cdnClient.batchSetCdnDomainConfig(request);
|
|
178
213
|
};
|
|
179
214
|
/* istanbul ignore next */
|
|
180
215
|
const createCdnOperations = (cdnClient) => ({
|
|
@@ -52,6 +52,15 @@ const deleteDomainRecord = (dnsClient) => async (recordId) => {
|
|
|
52
52
|
});
|
|
53
53
|
await dnsClient.deleteDomainRecord(request);
|
|
54
54
|
};
|
|
55
|
+
const updateDomainRecord = (dnsClient) => async (recordId, config) => {
|
|
56
|
+
await dnsClient.updateDomainRecord(new dns.UpdateDomainRecordRequest({
|
|
57
|
+
recordId,
|
|
58
|
+
RR: config.rr,
|
|
59
|
+
type: config.type,
|
|
60
|
+
value: config.value,
|
|
61
|
+
TTL: config.ttl ?? 600,
|
|
62
|
+
}));
|
|
63
|
+
};
|
|
55
64
|
const describeDomainRecords = (dnsClient) => async (domainName, rrKeyWord) => {
|
|
56
65
|
const request = new dns.DescribeDomainRecordsRequest({
|
|
57
66
|
domainName,
|
|
@@ -82,6 +91,7 @@ const createDnsOperations = (dnsClient) => {
|
|
|
82
91
|
const describe = describeDomainRecords(dnsClient);
|
|
83
92
|
return {
|
|
84
93
|
addDomainRecord: addDomainRecord(dnsClient),
|
|
94
|
+
updateDomainRecord: updateDomainRecord(dnsClient),
|
|
85
95
|
deleteDomainRecord: deleteDomainRecord(dnsClient),
|
|
86
96
|
describeDomainRecords: describe,
|
|
87
97
|
checkDomainRecordExists: checkDomainRecordExists(describe),
|
|
@@ -540,18 +540,17 @@ const buildCodeLocation = (codePath, ossCode) => {
|
|
|
540
540
|
deleteTrigger: async (functionName, triggerName) => {
|
|
541
541
|
await fc3Client.deleteTrigger(functionName, triggerName);
|
|
542
542
|
},
|
|
543
|
-
createCustomDomain: async (domainName, protocol,
|
|
543
|
+
createCustomDomain: async (domainName, protocol, routes, certConfig) => {
|
|
544
544
|
const createCustomDomainInput = new fc.CreateCustomDomainInput({
|
|
545
545
|
domainName,
|
|
546
546
|
protocol,
|
|
547
547
|
...(certConfig ? { certConfig: new fc.CertConfig(certConfig) } : {}),
|
|
548
548
|
routeConfig: new fc.RouteConfig({
|
|
549
|
-
routes:
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
],
|
|
549
|
+
routes: routes.map((route) => new fc.PathConfig({
|
|
550
|
+
path: route.path,
|
|
551
|
+
functionName: route.functionName,
|
|
552
|
+
...(route.qualifier ? { qualifier: route.qualifier } : {}),
|
|
553
|
+
})),
|
|
555
554
|
}),
|
|
556
555
|
});
|
|
557
556
|
const request = new fc.CreateCustomDomainRequest({
|
|
@@ -559,6 +558,27 @@ const buildCodeLocation = (codePath, ossCode) => {
|
|
|
559
558
|
});
|
|
560
559
|
await fc3Client.createCustomDomain(request);
|
|
561
560
|
},
|
|
561
|
+
updateCustomDomain: async (domainName, patch) => {
|
|
562
|
+
const updateCustomDomainInput = new fc.UpdateCustomDomainInput({
|
|
563
|
+
...(patch.protocol !== undefined ? { protocol: patch.protocol } : {}),
|
|
564
|
+
...(patch.routes
|
|
565
|
+
? {
|
|
566
|
+
routeConfig: new fc.RouteConfig({
|
|
567
|
+
routes: patch.routes.map((route) => new fc.PathConfig({
|
|
568
|
+
path: route.path,
|
|
569
|
+
functionName: route.functionName,
|
|
570
|
+
...(route.qualifier ? { qualifier: route.qualifier } : {}),
|
|
571
|
+
})),
|
|
572
|
+
}),
|
|
573
|
+
}
|
|
574
|
+
: {}),
|
|
575
|
+
...(patch.certConfig ? { certConfig: new fc.CertConfig(patch.certConfig) } : {}),
|
|
576
|
+
});
|
|
577
|
+
const request = new fc.UpdateCustomDomainRequest({
|
|
578
|
+
body: updateCustomDomainInput,
|
|
579
|
+
});
|
|
580
|
+
await fc3Client.updateCustomDomain(domainName, request);
|
|
581
|
+
},
|
|
562
582
|
getCustomDomain: async (domainName) => {
|
|
563
583
|
try {
|
|
564
584
|
const response = await fc3Client.getCustomDomain(domainName);
|
|
@@ -573,6 +593,15 @@ const buildCodeLocation = (codePath, ossCode) => {
|
|
|
573
593
|
certificateId: response.body.certConfig.certificateId,
|
|
574
594
|
}
|
|
575
595
|
: undefined,
|
|
596
|
+
routeConfig: response.body.routeConfig
|
|
597
|
+
? {
|
|
598
|
+
routes: (response.body.routeConfig.routes ?? []).map((route) => ({
|
|
599
|
+
path: route.path,
|
|
600
|
+
functionName: route.functionName,
|
|
601
|
+
qualifier: route.qualifier,
|
|
602
|
+
})),
|
|
603
|
+
}
|
|
604
|
+
: undefined,
|
|
576
605
|
};
|
|
577
606
|
}
|
|
578
607
|
catch (error) {
|
|
@@ -137,6 +137,7 @@ const validateApiKey = async (apiKey, baseUrl) => {
|
|
|
137
137
|
orgSlug: result.orgSlug,
|
|
138
138
|
userEmail: result.userEmail ?? result.user?.email ?? '',
|
|
139
139
|
scopes: result.scopes ?? [],
|
|
140
|
+
region: result.region,
|
|
140
141
|
};
|
|
141
142
|
};
|
|
142
143
|
exports.validateApiKey = validateApiKey;
|