@lark-apaas/db-schema-sync 0.1.19 → 0.1.20-alpha.20260930084920
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/bin.js +1 -1
- package/dist/{chunk-EPPFM6BV.js → chunk-BJGCO5TN.js} +84 -5
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -1092,6 +1092,75 @@ function resolveEnvOptions(env = process.env) {
|
|
|
1092
1092
|
timeoutMs: env.SCHEMA_API_TIMEOUT_MS ? Number(env.SCHEMA_API_TIMEOUT_MS) : 3e4
|
|
1093
1093
|
};
|
|
1094
1094
|
}
|
|
1095
|
+
function isJsonObject(value) {
|
|
1096
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1097
|
+
}
|
|
1098
|
+
function getHeader(headers, name) {
|
|
1099
|
+
if (!headers) return "";
|
|
1100
|
+
const getter = headers.get;
|
|
1101
|
+
if (typeof getter === "function") return getter.call(headers, name) ?? "";
|
|
1102
|
+
const record = headers;
|
|
1103
|
+
return record[name] ?? record[name.toLowerCase()] ?? "";
|
|
1104
|
+
}
|
|
1105
|
+
async function readBody(response) {
|
|
1106
|
+
if (typeof response.text === "function") {
|
|
1107
|
+
const raw = await response.text();
|
|
1108
|
+
if (!raw) return { raw, json: {} };
|
|
1109
|
+
const parsed = JSON.parse(raw);
|
|
1110
|
+
if (!isJsonObject(parsed)) {
|
|
1111
|
+
throw new Error("listTableView API returned non-object JSON");
|
|
1112
|
+
}
|
|
1113
|
+
return { raw, json: parsed };
|
|
1114
|
+
}
|
|
1115
|
+
if (typeof response.json === "function") {
|
|
1116
|
+
const parsed = await response.json();
|
|
1117
|
+
if (!isJsonObject(parsed)) {
|
|
1118
|
+
throw new Error("listTableView API returned non-object JSON");
|
|
1119
|
+
}
|
|
1120
|
+
return { raw: JSON.stringify(parsed), json: parsed };
|
|
1121
|
+
}
|
|
1122
|
+
return { raw: "", json: {} };
|
|
1123
|
+
}
|
|
1124
|
+
function pickMessage(json, fallback) {
|
|
1125
|
+
const data = isJsonObject(json.data) ? json.data : void 0;
|
|
1126
|
+
const message = json.error_msg ?? json.err_msg ?? json.message ?? json.status_message ?? data?.error_msg ?? data?.err_msg ?? data?.message ?? data?.status_message;
|
|
1127
|
+
return typeof message === "string" && message ? message : fallback;
|
|
1128
|
+
}
|
|
1129
|
+
function getNestedStatus(json, key) {
|
|
1130
|
+
const data = isJsonObject(json.data) ? json.data : void 0;
|
|
1131
|
+
return json[key] ?? data?.[key];
|
|
1132
|
+
}
|
|
1133
|
+
function assertPlatformBodySuccess(json, logId, body) {
|
|
1134
|
+
const statusCode = getNestedStatus(json, "status_code");
|
|
1135
|
+
if (statusCode != null && String(statusCode) !== "0") {
|
|
1136
|
+
throw new Error(
|
|
1137
|
+
`listTableView API failed: business status_code=${String(statusCode)}
|
|
1138
|
+
LogID: ${logId}
|
|
1139
|
+
Message: ${pickMessage(json, "platform business error")}
|
|
1140
|
+
Body: ${body.slice(0, 500)}`
|
|
1141
|
+
);
|
|
1142
|
+
}
|
|
1143
|
+
const rawHttpStatus = getNestedStatus(json, "raw_http_status") ?? getNestedStatus(json, "rawHttpStatus");
|
|
1144
|
+
if (rawHttpStatus != null && Number(rawHttpStatus) >= 400) {
|
|
1145
|
+
throw new Error(
|
|
1146
|
+
`listTableView API failed: raw_http_status=${String(rawHttpStatus)}
|
|
1147
|
+
LogID: ${logId}
|
|
1148
|
+
Message: ${pickMessage(json, "platform raw HTTP failure")}
|
|
1149
|
+
Body: ${body.slice(0, 500)}`
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
const data = isJsonObject(json.data) ? json.data : void 0;
|
|
1153
|
+
const baseResp = (isJsonObject(json.BaseResp) ? json.BaseResp : void 0) ?? (data && isJsonObject(data.BaseResp) ? data.BaseResp : void 0);
|
|
1154
|
+
const kStatusCode = baseResp?.KStatusCode;
|
|
1155
|
+
if (kStatusCode) {
|
|
1156
|
+
throw new Error(
|
|
1157
|
+
`listTableView API failed: BaseResp.KStatusCode=${String(kStatusCode)}
|
|
1158
|
+
LogID: ${logId}
|
|
1159
|
+
Message: ${String(baseResp?.KStatusMessage ?? baseResp?.StatusMessage ?? "platform RPC error")}
|
|
1160
|
+
Body: ${body.slice(0, 500)}`
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1095
1164
|
async function fetchListTableView(options) {
|
|
1096
1165
|
const { appId, dbBranch = "main", timeoutMs = 3e4 } = options;
|
|
1097
1166
|
const client = getHttpClient();
|
|
@@ -1125,16 +1194,26 @@ async function fetchListTableView(options) {
|
|
|
1125
1194
|
URL: ${response.url}
|
|
1126
1195
|
Body: ${body.slice(0, 500)}`);
|
|
1127
1196
|
}
|
|
1128
|
-
const
|
|
1129
|
-
const
|
|
1197
|
+
const logId = getHeader(response.headers, "x-tt-logid");
|
|
1198
|
+
const { raw, json } = await readBody(response);
|
|
1199
|
+
assertPlatformBodySuccess(json, logId, raw);
|
|
1200
|
+
const data = isJsonObject(json.data) ? json.data : void 0;
|
|
1130
1201
|
if (!data) {
|
|
1131
|
-
|
|
1202
|
+
throw new Error(`listTableView API failed: response missing data
|
|
1203
|
+
LogID: ${logId}
|
|
1204
|
+
Body: ${raw.slice(0, 500)}`);
|
|
1205
|
+
}
|
|
1206
|
+
const tableView = data.data ?? data.schema;
|
|
1207
|
+
if (tableView === void 0) {
|
|
1208
|
+
throw new Error(`listTableView API failed: response missing data.schema/data.data
|
|
1209
|
+
LogID: ${logId}
|
|
1210
|
+
Body: ${raw.slice(0, 500)}`);
|
|
1132
1211
|
}
|
|
1133
|
-
return
|
|
1212
|
+
return tableView;
|
|
1134
1213
|
} catch (err) {
|
|
1135
1214
|
if (err?.response) {
|
|
1136
1215
|
const headers = err.response.headers;
|
|
1137
|
-
const logId = headers
|
|
1216
|
+
const logId = getHeader(headers, "x-tt-logid");
|
|
1138
1217
|
let body = "";
|
|
1139
1218
|
try {
|
|
1140
1219
|
body = typeof err.response.text === "function" ? await err.response.text() : JSON.stringify(err.response.data ?? err.response.body ?? "");
|
package/dist/index.js
CHANGED