@lark-apaas/fullstack-cli 1.1.66-alpha.20260908191831 → 1.1.66-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +172 -85
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3058,6 +3058,105 @@ var syncCommand = {
|
|
|
3058
3058
|
}
|
|
3059
3059
|
};
|
|
3060
3060
|
|
|
3061
|
+
// src/utils/api-error.ts
|
|
3062
|
+
var LOGID_HEADER = "x-tt-logid";
|
|
3063
|
+
var ERROR_RESPONSE_PREVIEW_LIMIT = 2e3;
|
|
3064
|
+
var InnerApiError = class _InnerApiError extends Error {
|
|
3065
|
+
constructor(message, detail = {}) {
|
|
3066
|
+
super(message);
|
|
3067
|
+
this.name = "InnerApiError";
|
|
3068
|
+
this.logId = detail.logId ?? "";
|
|
3069
|
+
this.status = detail.status;
|
|
3070
|
+
this.body = detail.body;
|
|
3071
|
+
if (detail.cause !== void 0) {
|
|
3072
|
+
this.cause = detail.cause;
|
|
3073
|
+
}
|
|
3074
|
+
Object.setPrototypeOf(this, _InnerApiError.prototype);
|
|
3075
|
+
}
|
|
3076
|
+
};
|
|
3077
|
+
function getLogId(response) {
|
|
3078
|
+
const headers = response?.headers;
|
|
3079
|
+
if (!headers || typeof headers !== "object") {
|
|
3080
|
+
return "";
|
|
3081
|
+
}
|
|
3082
|
+
try {
|
|
3083
|
+
const getter = headers.get;
|
|
3084
|
+
if (typeof getter === "function") {
|
|
3085
|
+
return getter.call(headers, LOGID_HEADER) ?? "";
|
|
3086
|
+
}
|
|
3087
|
+
const value = headers[LOGID_HEADER];
|
|
3088
|
+
return typeof value === "string" ? value : "";
|
|
3089
|
+
} catch {
|
|
3090
|
+
return "";
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
function formatLogId(response) {
|
|
3094
|
+
const logId = getLogId(response);
|
|
3095
|
+
return logId ? `, logid: ${logId}` : "";
|
|
3096
|
+
}
|
|
3097
|
+
async function readErrorBody(response) {
|
|
3098
|
+
try {
|
|
3099
|
+
if (typeof response.text === "function") {
|
|
3100
|
+
const text = await response.text();
|
|
3101
|
+
return text ? text.slice(0, ERROR_RESPONSE_PREVIEW_LIMIT) : "";
|
|
3102
|
+
}
|
|
3103
|
+
if (typeof response.json === "function") {
|
|
3104
|
+
const serialized = JSON.stringify(await response.json());
|
|
3105
|
+
return serialized ? serialized.slice(0, ERROR_RESPONSE_PREVIEW_LIMIT) : "";
|
|
3106
|
+
}
|
|
3107
|
+
} catch {
|
|
3108
|
+
return "";
|
|
3109
|
+
}
|
|
3110
|
+
return "";
|
|
3111
|
+
}
|
|
3112
|
+
function asHttpErrorResponse(error) {
|
|
3113
|
+
if (!error || typeof error !== "object") {
|
|
3114
|
+
return void 0;
|
|
3115
|
+
}
|
|
3116
|
+
const response = error.response;
|
|
3117
|
+
return response && typeof response === "object" ? response : void 0;
|
|
3118
|
+
}
|
|
3119
|
+
async function buildError(message, response, cause) {
|
|
3120
|
+
if (!response) {
|
|
3121
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
3122
|
+
return new InnerApiError(`${message}: ${reason}`, { cause });
|
|
3123
|
+
}
|
|
3124
|
+
const logId = getLogId(response);
|
|
3125
|
+
const body = await readErrorBody(response);
|
|
3126
|
+
const parts = [`${message}: ${response.status ?? "unknown"}`];
|
|
3127
|
+
if (response.statusText) {
|
|
3128
|
+
parts.push(` ${response.statusText}`);
|
|
3129
|
+
}
|
|
3130
|
+
if (logId) {
|
|
3131
|
+
parts.push(`, logid: ${logId}`);
|
|
3132
|
+
}
|
|
3133
|
+
if (body) {
|
|
3134
|
+
parts.push(`, response: ${body}`);
|
|
3135
|
+
}
|
|
3136
|
+
return new InnerApiError(parts.join(""), {
|
|
3137
|
+
logId,
|
|
3138
|
+
status: response.status,
|
|
3139
|
+
body,
|
|
3140
|
+
cause
|
|
3141
|
+
});
|
|
3142
|
+
}
|
|
3143
|
+
async function requestWithLogId(send, message, options = {}) {
|
|
3144
|
+
let response;
|
|
3145
|
+
try {
|
|
3146
|
+
response = await send();
|
|
3147
|
+
} catch (error) {
|
|
3148
|
+
throw await buildError(message, asHttpErrorResponse(error), error);
|
|
3149
|
+
}
|
|
3150
|
+
if (!response) {
|
|
3151
|
+
throw new InnerApiError(`${message}: \u672A\u62FF\u5230\u54CD\u5E94\u5BF9\u8C61`);
|
|
3152
|
+
}
|
|
3153
|
+
const isOk = options.expectStatus200 ? response.ok !== false && response.status === 200 : response.ok === true;
|
|
3154
|
+
if (!isOk) {
|
|
3155
|
+
throw await buildError(message, response, void 0);
|
|
3156
|
+
}
|
|
3157
|
+
return response;
|
|
3158
|
+
}
|
|
3159
|
+
|
|
3061
3160
|
// src/utils/telemetry.ts
|
|
3062
3161
|
async function reportEvents(events) {
|
|
3063
3162
|
if (events.length === 0) {
|
|
@@ -3065,14 +3164,13 @@ async function reportEvents(events) {
|
|
|
3065
3164
|
}
|
|
3066
3165
|
try {
|
|
3067
3166
|
const client = getHttpClient();
|
|
3068
|
-
const response = await
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
}
|
|
3167
|
+
const response = await requestWithLogId(
|
|
3168
|
+
() => client.post("/api/v1/studio/innerapi/resource_events", { events }),
|
|
3169
|
+
"resource_events \u8BF7\u6C42\u5931\u8D25"
|
|
3170
|
+
);
|
|
3073
3171
|
const result = await response.json();
|
|
3074
3172
|
if (result.status_code !== "0") {
|
|
3075
|
-
console.warn(`[telemetry] API error: ${result.message}`);
|
|
3173
|
+
console.warn(`[telemetry] API error: ${result.message}${formatLogId(response)}`);
|
|
3076
3174
|
return false;
|
|
3077
3175
|
}
|
|
3078
3176
|
return true;
|
|
@@ -4008,14 +4106,15 @@ import path12 from "path";
|
|
|
4008
4106
|
var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
|
|
4009
4107
|
async function getPluginVersions(keys, latestOnly = true) {
|
|
4010
4108
|
const client = getHttpClient();
|
|
4011
|
-
const response = await
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4109
|
+
const response = await requestWithLogId(
|
|
4110
|
+
() => client.post(`/api/v1/studio/innerapi/plugins/-/versions/batch_get?keys=${keys.join(",")}&latest_only=${latestOnly}`),
|
|
4111
|
+
"Failed to get plugin versions",
|
|
4112
|
+
{ expectStatus200: true }
|
|
4113
|
+
);
|
|
4015
4114
|
const result = await response.json();
|
|
4016
4115
|
console.log("getPluginVersions response:", result);
|
|
4017
4116
|
if (result.status_code !== "0") {
|
|
4018
|
-
throw new Error(`API error: ${result.message}`);
|
|
4117
|
+
throw new Error(`API error: ${result.message}${formatLogId(response)}`);
|
|
4019
4118
|
}
|
|
4020
4119
|
return result.data.pluginVersions;
|
|
4021
4120
|
}
|
|
@@ -4049,10 +4148,10 @@ async function downloadFromInner(pluginKey, version) {
|
|
|
4049
4148
|
const { scope, name } = parsePluginKey(pluginKey);
|
|
4050
4149
|
const url = `/api/v1/studio/innerapi/plugins/${scope}/${name}/versions/${version}/package`;
|
|
4051
4150
|
console.log(`[action-plugin] Downloading plugin from inner API: ${url}`);
|
|
4052
|
-
const response = await
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4151
|
+
const response = await requestWithLogId(
|
|
4152
|
+
() => client.get(url),
|
|
4153
|
+
"Failed to download plugin"
|
|
4154
|
+
);
|
|
4056
4155
|
const arrayBuffer = await response.arrayBuffer();
|
|
4057
4156
|
return Buffer.from(arrayBuffer);
|
|
4058
4157
|
}
|
|
@@ -4060,10 +4159,10 @@ async function downloadFromPublic(downloadURL) {
|
|
|
4060
4159
|
const client = new HttpClient2({
|
|
4061
4160
|
timeout: 6e4
|
|
4062
4161
|
});
|
|
4063
|
-
const response = await
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4162
|
+
const response = await requestWithLogId(
|
|
4163
|
+
() => client.get(downloadURL),
|
|
4164
|
+
"Failed to download plugin from public URL"
|
|
4165
|
+
);
|
|
4067
4166
|
const arrayBuffer = await response.arrayBuffer();
|
|
4068
4167
|
return Buffer.from(arrayBuffer);
|
|
4069
4168
|
}
|
|
@@ -4884,45 +4983,49 @@ var debug = createDebug("component");
|
|
|
4884
4983
|
async function getComponents(keys) {
|
|
4885
4984
|
const client = getHttpClient();
|
|
4886
4985
|
debug("\u8C03\u7528 /components/batch_get %o", keys);
|
|
4887
|
-
const response = await
|
|
4888
|
-
|
|
4986
|
+
const response = await requestWithLogId(
|
|
4987
|
+
() => client.post(
|
|
4988
|
+
`/api/v1/studio/innerapi/components/batch_get?keys=${keys.join(",")}`
|
|
4989
|
+
),
|
|
4990
|
+
"\u83B7\u53D6\u7EC4\u4EF6\u4FE1\u606F\u5931\u8D25",
|
|
4991
|
+
{ expectStatus200: true }
|
|
4889
4992
|
);
|
|
4890
|
-
if (response.status !== 200) {
|
|
4891
|
-
throw new Error(
|
|
4892
|
-
`\u83B7\u53D6\u7EC4\u4EF6\u4FE1\u606F\u5931\u8D25\uFF1A${response.status} ${response.statusText}`
|
|
4893
|
-
);
|
|
4894
|
-
}
|
|
4895
4993
|
const result = await response.json();
|
|
4896
4994
|
if (result.status_code !== "0") {
|
|
4897
4995
|
debug("\u63A5\u53E3\u8FD4\u56DE\u9519\u8BEF\uFF1A%o", result);
|
|
4898
|
-
throw new Error(`\u83B7\u53D6\u7EC4\u4EF6\u4FE1\u606F\u5931\u8D25\uFF1A${result.error_msg}`);
|
|
4996
|
+
throw new Error(`\u83B7\u53D6\u7EC4\u4EF6\u4FE1\u606F\u5931\u8D25\uFF1A${result.error_msg}${formatLogId(response)}`);
|
|
4899
4997
|
}
|
|
4900
4998
|
return mapValues(result.data.components, ([component]) => component);
|
|
4901
4999
|
}
|
|
4902
5000
|
async function getRegistryItem(url) {
|
|
4903
5001
|
const client = getHttpClient();
|
|
4904
5002
|
debug("\u4E0B\u8F7D registry-item.json\uFF1A%s", url);
|
|
4905
|
-
const response = await
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
);
|
|
4910
|
-
}
|
|
5003
|
+
const response = await requestWithLogId(
|
|
5004
|
+
() => client.get(url),
|
|
5005
|
+
"\u4E0B\u8F7D registry-item.json \u5931\u8D25"
|
|
5006
|
+
);
|
|
4911
5007
|
const item = await response.json();
|
|
4912
5008
|
return item;
|
|
4913
5009
|
}
|
|
4914
5010
|
async function sendInstallEvent(key) {
|
|
4915
5011
|
const client = getHttpClient();
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
{
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
5012
|
+
try {
|
|
5013
|
+
await requestWithLogId(
|
|
5014
|
+
() => client.post("/api/v1/studio/innerapi/resource_events", {
|
|
5015
|
+
events: [
|
|
5016
|
+
{
|
|
5017
|
+
resourceType: "component",
|
|
5018
|
+
resourceKey: key,
|
|
5019
|
+
eventType: "install",
|
|
5020
|
+
details: {}
|
|
5021
|
+
}
|
|
5022
|
+
]
|
|
5023
|
+
}),
|
|
5024
|
+
"\u4E0A\u62A5\u7EC4\u4EF6\u5B89\u88C5\u4E8B\u4EF6\u5931\u8D25"
|
|
5025
|
+
);
|
|
5026
|
+
} catch (error) {
|
|
5027
|
+
console.warn(`[component] ${error instanceof Error ? error.message : error}`);
|
|
5028
|
+
}
|
|
4926
5029
|
}
|
|
4927
5030
|
|
|
4928
5031
|
// src/commands/component/registry-preparer.ts
|
|
@@ -6009,7 +6112,7 @@ function addInjection(sourceFile) {
|
|
|
6009
6112
|
type: PARAM_TYPE,
|
|
6010
6113
|
scope: Scope.Private,
|
|
6011
6114
|
isReadonly: true,
|
|
6012
|
-
decorators: [{ name: "Inject", arguments: [
|
|
6115
|
+
decorators: [{ name: "Inject", arguments: [] }]
|
|
6013
6116
|
});
|
|
6014
6117
|
} else {
|
|
6015
6118
|
classDecl.addConstructor({
|
|
@@ -6018,7 +6121,7 @@ function addInjection(sourceFile) {
|
|
|
6018
6121
|
type: PARAM_TYPE,
|
|
6019
6122
|
scope: Scope.Private,
|
|
6020
6123
|
isReadonly: true,
|
|
6021
|
-
decorators: [{ name: "Inject", arguments: [
|
|
6124
|
+
decorators: [{ name: "Inject", arguments: [] }]
|
|
6022
6125
|
}]
|
|
6023
6126
|
});
|
|
6024
6127
|
}
|
|
@@ -7972,70 +8075,54 @@ var UPLOAD_STATIC_DEFAULTS = {
|
|
|
7972
8075
|
};
|
|
7973
8076
|
|
|
7974
8077
|
// src/commands/build/api-client.ts
|
|
7975
|
-
var ERROR_RESPONSE_PREVIEW_LIMIT = 2e3;
|
|
7976
|
-
async function getErrorResponseDetails(response) {
|
|
7977
|
-
try {
|
|
7978
|
-
if (typeof response.text === "function") {
|
|
7979
|
-
const text = await response.text();
|
|
7980
|
-
if (!text) {
|
|
7981
|
-
return "";
|
|
7982
|
-
}
|
|
7983
|
-
return `, response: ${text.slice(0, ERROR_RESPONSE_PREVIEW_LIMIT)}`;
|
|
7984
|
-
}
|
|
7985
|
-
if (typeof response.json === "function") {
|
|
7986
|
-
const data = await response.json();
|
|
7987
|
-
const serialized = JSON.stringify(data);
|
|
7988
|
-
if (!serialized) {
|
|
7989
|
-
return "";
|
|
7990
|
-
}
|
|
7991
|
-
return `, response: ${serialized.slice(0, ERROR_RESPONSE_PREVIEW_LIMIT)}`;
|
|
7992
|
-
}
|
|
7993
|
-
} catch {
|
|
7994
|
-
return "";
|
|
7995
|
-
}
|
|
7996
|
-
return "";
|
|
7997
|
-
}
|
|
7998
|
-
async function throwIfResponseNotOk(response, message) {
|
|
7999
|
-
if (response.ok && response.status === 200) {
|
|
8000
|
-
return;
|
|
8001
|
-
}
|
|
8002
|
-
const details = await getErrorResponseDetails(response);
|
|
8003
|
-
throw new Error(`${message}: ${response.status} ${response.statusText}${details}`);
|
|
8004
|
-
}
|
|
8005
8078
|
async function genArtifactUploadCredential(appId, body) {
|
|
8006
8079
|
const client = getHttpClient();
|
|
8007
8080
|
const url = `/v1/app/${appId}/pipeline/gen_artifact_upload_credential`;
|
|
8008
|
-
const response = await
|
|
8009
|
-
|
|
8081
|
+
const response = await requestWithLogId(
|
|
8082
|
+
() => client.post(url, body),
|
|
8083
|
+
"gen_artifact_upload_credential \u8BF7\u6C42\u5931\u8D25",
|
|
8084
|
+
{ expectStatus200: true }
|
|
8085
|
+
);
|
|
8010
8086
|
return response.json();
|
|
8011
8087
|
}
|
|
8012
8088
|
async function getDefaultBucketId(appId) {
|
|
8013
8089
|
const client = getHttpClient();
|
|
8014
8090
|
const url = `/v1/app/${appId}/storage/inner/staticBucket`;
|
|
8015
|
-
const response = await
|
|
8016
|
-
|
|
8091
|
+
const response = await requestWithLogId(
|
|
8092
|
+
() => client.post(url, {}),
|
|
8093
|
+
"getOrCreateStaticBucket \u8BF7\u6C42\u5931\u8D25",
|
|
8094
|
+
{ expectStatus200: true }
|
|
8095
|
+
);
|
|
8017
8096
|
const data = await response.json();
|
|
8018
8097
|
if (data.status_code !== "0") {
|
|
8019
|
-
throw new Error(
|
|
8098
|
+
throw new Error(
|
|
8099
|
+
`getOrCreateStaticBucket \u8FD4\u56DE\u5F02\u5E38, status_code: ${data.status_code}${formatLogId(response)}`
|
|
8100
|
+
);
|
|
8020
8101
|
}
|
|
8021
8102
|
const bucketId = data?.data?.bucketID;
|
|
8022
8103
|
if (!bucketId) {
|
|
8023
|
-
throw new Error(`\u672A\u627E\u5230\u5E94\u7528 ${appId} \u7684\u9759\u6001\u8D44\u6E90\u5B58\u50A8\u6876`);
|
|
8104
|
+
throw new Error(`\u672A\u627E\u5230\u5E94\u7528 ${appId} \u7684\u9759\u6001\u8D44\u6E90\u5B58\u50A8\u6876${formatLogId(response)}`);
|
|
8024
8105
|
}
|
|
8025
8106
|
return bucketId;
|
|
8026
8107
|
}
|
|
8027
8108
|
async function preUploadStaticAttachment(appId, bucketId) {
|
|
8028
8109
|
const client = getHttpClient();
|
|
8029
8110
|
const url = `/v1/app/${appId}/storage/bucket/${bucketId}/preUploadStatic`;
|
|
8030
|
-
const response = await
|
|
8031
|
-
|
|
8111
|
+
const response = await requestWithLogId(
|
|
8112
|
+
() => client.post(url, {}),
|
|
8113
|
+
"preUploadStatic \u8BF7\u6C42\u5931\u8D25",
|
|
8114
|
+
{ expectStatus200: true }
|
|
8115
|
+
);
|
|
8032
8116
|
return response.json();
|
|
8033
8117
|
}
|
|
8034
8118
|
async function uploadStaticAttachmentCallback(appId, bucketId, body) {
|
|
8035
8119
|
const client = getHttpClient();
|
|
8036
8120
|
const url = `/v1/app/${appId}/storage/bucket/${bucketId}/object/callbackStatic`;
|
|
8037
|
-
const response = await
|
|
8038
|
-
|
|
8121
|
+
const response = await requestWithLogId(
|
|
8122
|
+
() => client.post(url, body),
|
|
8123
|
+
"callbackStatic \u8BF7\u6C42\u5931\u8D25",
|
|
8124
|
+
{ expectStatus200: true }
|
|
8125
|
+
);
|
|
8039
8126
|
return response.json();
|
|
8040
8127
|
}
|
|
8041
8128
|
|