openxiangda 1.0.88 → 1.0.89
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/README.md +2 -0
- package/openxiangda-skills/SKILL.md +2 -0
- package/openxiangda-skills/references/architecture-design.md +1 -0
- package/openxiangda-skills/references/openxiangda-api.md +2 -0
- package/openxiangda-skills/references/pages/page-sdk.md +2 -0
- package/openxiangda-skills/references/resource-manifest-cheatsheet.md +2 -0
- package/package.json +1 -1
- package/packages/sdk/dist/components/index.cjs +13 -2
- package/packages/sdk/dist/components/index.cjs.map +1 -1
- package/packages/sdk/dist/components/index.mjs +13 -2
- package/packages/sdk/dist/components/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/index.cjs +102 -21
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.mjs +102 -21
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/react.cjs +70 -11
- package/packages/sdk/dist/runtime/react.cjs.map +1 -1
- package/packages/sdk/dist/runtime/react.d.mts +1 -1
- package/packages/sdk/dist/runtime/react.d.ts +1 -1
- package/packages/sdk/dist/runtime/react.mjs +70 -11
- package/packages/sdk/dist/runtime/react.mjs.map +1 -1
|
@@ -47,7 +47,7 @@ var require_classnames = __commonJS({
|
|
|
47
47
|
init_cjs_shims();
|
|
48
48
|
(function() {
|
|
49
49
|
"use strict";
|
|
50
|
-
var
|
|
50
|
+
var hasOwn3 = {}.hasOwnProperty;
|
|
51
51
|
function classNames80() {
|
|
52
52
|
var classes = "";
|
|
53
53
|
for (var i2 = 0; i2 < arguments.length; i2++) {
|
|
@@ -73,7 +73,7 @@ var require_classnames = __commonJS({
|
|
|
73
73
|
}
|
|
74
74
|
var classes = "";
|
|
75
75
|
for (var key in arg) {
|
|
76
|
-
if (
|
|
76
|
+
if (hasOwn3.call(arg, key) && arg[key]) {
|
|
77
77
|
classes = appendClass(classes, key);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -1093,18 +1093,39 @@ var normalizeDynamicOrder = (value) => {
|
|
|
1093
1093
|
}
|
|
1094
1094
|
return `${value.id}:${value.isAsc === "n" ? "-" : "+"}`;
|
|
1095
1095
|
};
|
|
1096
|
+
var hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
1097
|
+
var normalizeEnvelopeCode = (value) => {
|
|
1098
|
+
if (value === void 0 || value === null || value === "") {
|
|
1099
|
+
return 200;
|
|
1100
|
+
}
|
|
1101
|
+
const normalized = Number(value);
|
|
1102
|
+
return Number.isFinite(normalized) ? normalized : String(value);
|
|
1103
|
+
};
|
|
1104
|
+
var isSuccessCode = (value) => {
|
|
1105
|
+
if (value === void 0 || value === null || value === "") {
|
|
1106
|
+
return true;
|
|
1107
|
+
}
|
|
1108
|
+
const normalized = Number(value);
|
|
1109
|
+
return Number.isFinite(normalized) ? normalized === 0 || normalized >= 200 && normalized < 300 : false;
|
|
1110
|
+
};
|
|
1111
|
+
var getEnvelopeCode = (rawResponse) => {
|
|
1112
|
+
if (isRecord(rawResponse) && hasOwn(rawResponse, "code")) {
|
|
1113
|
+
return rawResponse.code;
|
|
1114
|
+
}
|
|
1115
|
+
const nestedData = rawResponse?.data;
|
|
1116
|
+
if (isRecord(nestedData) && hasOwn(nestedData, "code")) {
|
|
1117
|
+
return nestedData.code;
|
|
1118
|
+
}
|
|
1119
|
+
return void 0;
|
|
1120
|
+
};
|
|
1096
1121
|
var normalizeJsonResponse = (rawResponse) => {
|
|
1097
|
-
const
|
|
1098
|
-
const nestedCode = Number(
|
|
1099
|
-
rawResponse?.data?.code
|
|
1100
|
-
);
|
|
1101
|
-
const code = Number.isFinite(topLevelCode) ? topLevelCode : Number.isFinite(nestedCode) ? nestedCode : 200;
|
|
1122
|
+
const code = normalizeEnvelopeCode(getEnvelopeCode(rawResponse));
|
|
1102
1123
|
const topLevelResult = isRecord(rawResponse) && "result" in rawResponse ? rawResponse.result : void 0;
|
|
1103
1124
|
const nestedResult = isRecord(rawResponse?.data) && "result" in (rawResponse.data || {}) ? rawResponse.data?.result : void 0;
|
|
1104
1125
|
const topLevelData = isRecord(rawResponse) && "data" in rawResponse ? rawResponse.data : void 0;
|
|
1105
1126
|
const result = topLevelResult !== void 0 ? topLevelResult : nestedResult !== void 0 ? nestedResult : topLevelData !== void 0 ? topLevelData : isRecord(rawResponse) ? rawResponse : null;
|
|
1106
1127
|
const nestedSuccess = typeof rawResponse?.data?.success === "boolean" ? rawResponse.data?.success : void 0;
|
|
1107
|
-
const success =
|
|
1128
|
+
const success = rawResponse?.success === false || nestedSuccess === false ? false : isSuccessCode(code);
|
|
1108
1129
|
return {
|
|
1109
1130
|
code,
|
|
1110
1131
|
success,
|
|
@@ -1149,6 +1170,9 @@ var normalizeBinaryResponse = (rawResponse) => {
|
|
|
1149
1170
|
};
|
|
1150
1171
|
};
|
|
1151
1172
|
var toSdkError = (input, payload) => {
|
|
1173
|
+
if (input instanceof Error && input.response) {
|
|
1174
|
+
return input;
|
|
1175
|
+
}
|
|
1152
1176
|
const normalizedResponse = isRecord(input) ? normalizeJsonResponse(input) : void 0;
|
|
1153
1177
|
const nextError = input instanceof Error ? input : new Error(
|
|
1154
1178
|
normalizedResponse?.message || `\u8BF7\u6C42\u5931\u8D25: ${String(payload.method).toUpperCase()} ${payload.path}`
|
|
@@ -2295,7 +2319,8 @@ var createAuthClient = ({
|
|
|
2295
2319
|
});
|
|
2296
2320
|
const payload = await readPayload(response);
|
|
2297
2321
|
const code = getRecordValue(payload, "code");
|
|
2298
|
-
|
|
2322
|
+
const success = getRecordValue(payload, "success");
|
|
2323
|
+
if (!response.ok || success === false || !isSuccessCode2(code)) {
|
|
2299
2324
|
throw new AuthClientError(
|
|
2300
2325
|
String(getRecordValue(payload, "message") || `Auth request failed: ${response.status}`),
|
|
2301
2326
|
{ status: response.status, code, payload }
|
|
@@ -2348,6 +2373,11 @@ var getRecordValue = (value, key) => {
|
|
|
2348
2373
|
if (!value || typeof value !== "object") return void 0;
|
|
2349
2374
|
return value[key];
|
|
2350
2375
|
};
|
|
2376
|
+
var isSuccessCode2 = (code) => {
|
|
2377
|
+
if (code === void 0 || code === null || code === "") return true;
|
|
2378
|
+
const normalized = Number(code);
|
|
2379
|
+
return Number.isFinite(normalized) ? normalized === 0 || normalized >= 200 && normalized < 300 : false;
|
|
2380
|
+
};
|
|
2351
2381
|
var resolveLoginUrl = (appType, {
|
|
2352
2382
|
callbackUrl = getCurrentHref2(),
|
|
2353
2383
|
callbackParamName = "callback",
|
|
@@ -2420,7 +2450,8 @@ var createPublicAccessClient = ({
|
|
|
2420
2450
|
);
|
|
2421
2451
|
const payload = await readPayload2(response);
|
|
2422
2452
|
const code = getRecordValue2(payload, "code");
|
|
2423
|
-
|
|
2453
|
+
const success = getRecordValue2(payload, "success");
|
|
2454
|
+
if (!response.ok || success === false || !isSuccessCode3(code)) {
|
|
2424
2455
|
throw new PublicAccessClientError(
|
|
2425
2456
|
String(
|
|
2426
2457
|
getRecordValue2(payload, "message") || `Public access session failed: ${response.status}`
|
|
@@ -2458,6 +2489,11 @@ var getRecordValue2 = (value, key) => {
|
|
|
2458
2489
|
if (!value || typeof value !== "object") return void 0;
|
|
2459
2490
|
return value[key];
|
|
2460
2491
|
};
|
|
2492
|
+
var isSuccessCode3 = (code) => {
|
|
2493
|
+
if (code === void 0 || code === null || code === "") return true;
|
|
2494
|
+
const normalized = Number(code);
|
|
2495
|
+
return Number.isFinite(normalized) ? normalized === 0 || normalized >= 200 && normalized < 300 : false;
|
|
2496
|
+
};
|
|
2461
2497
|
var getCurrentPathname = () => typeof window === "undefined" ? void 0 : window.location.pathname;
|
|
2462
2498
|
var getCurrentDomain = () => typeof window === "undefined" ? void 0 : window.location.host;
|
|
2463
2499
|
var getCurrentUserAgent = () => typeof navigator === "undefined" ? void 0 : navigator.userAgent;
|
|
@@ -4146,7 +4182,7 @@ var OpenXiangdaProvider = ({
|
|
|
4146
4182
|
}
|
|
4147
4183
|
);
|
|
4148
4184
|
const payload = await readJsonPayload(response);
|
|
4149
|
-
if (
|
|
4185
|
+
if (isRuntimeEnvelopeFailure(response, payload)) {
|
|
4150
4186
|
throw createRuntimeHttpError(
|
|
4151
4187
|
response,
|
|
4152
4188
|
payload,
|
|
@@ -4281,7 +4317,7 @@ var useCanAccessRoute = (input) => {
|
|
|
4281
4317
|
payload
|
|
4282
4318
|
};
|
|
4283
4319
|
if (!disposed) {
|
|
4284
|
-
const shouldTreatAsError = !response.ok ||
|
|
4320
|
+
const shouldTreatAsError = !response.ok || isServerErrorCode(code);
|
|
4285
4321
|
setState({
|
|
4286
4322
|
data,
|
|
4287
4323
|
loading: false,
|
|
@@ -4413,7 +4449,7 @@ var useRuntimeAuth = () => {
|
|
|
4413
4449
|
}
|
|
4414
4450
|
);
|
|
4415
4451
|
const payload = await readJsonPayload(response);
|
|
4416
|
-
if (
|
|
4452
|
+
if (isRuntimeEnvelopeFailure(response, payload)) {
|
|
4417
4453
|
throw createRuntimeHttpError(
|
|
4418
4454
|
response,
|
|
4419
4455
|
payload,
|
|
@@ -4503,6 +4539,15 @@ var classifyRuntimeError = (status, code) => {
|
|
|
4503
4539
|
const normalizedCode = typeof code === "string" ? Number(code) : code;
|
|
4504
4540
|
if (status === 401 || normalizedCode === 401) return "unauthenticated";
|
|
4505
4541
|
if (status === 403 || normalizedCode === 403) return "forbidden";
|
|
4542
|
+
if (typeof code === "string") {
|
|
4543
|
+
const normalizedText = code.toUpperCase();
|
|
4544
|
+
if (normalizedText.includes("DENIED") || normalizedText.includes("FORBIDDEN")) {
|
|
4545
|
+
return "forbidden";
|
|
4546
|
+
}
|
|
4547
|
+
if (normalizedText.includes("UNAUTH") || normalizedText.includes("LOGIN")) {
|
|
4548
|
+
return "unauthenticated";
|
|
4549
|
+
}
|
|
4550
|
+
}
|
|
4506
4551
|
if (!status && !normalizedCode) return "network";
|
|
4507
4552
|
return "unknown";
|
|
4508
4553
|
};
|
|
@@ -4558,6 +4603,20 @@ var getRecordValue3 = (value, key) => {
|
|
|
4558
4603
|
if (!value || typeof value !== "object") return void 0;
|
|
4559
4604
|
return value[key];
|
|
4560
4605
|
};
|
|
4606
|
+
var isSuccessCode4 = (code) => {
|
|
4607
|
+
if (code === void 0 || code === null || code === "") return true;
|
|
4608
|
+
const normalized = Number(code);
|
|
4609
|
+
return Number.isFinite(normalized) ? normalized === 0 || normalized >= 200 && normalized < 300 : false;
|
|
4610
|
+
};
|
|
4611
|
+
var isRuntimeEnvelopeFailure = (response, payload) => {
|
|
4612
|
+
const code = getRecordValue3(payload, "code");
|
|
4613
|
+
const success = getRecordValue3(payload, "success");
|
|
4614
|
+
return !response.ok || success === false || !isSuccessCode4(code);
|
|
4615
|
+
};
|
|
4616
|
+
var isServerErrorCode = (code) => {
|
|
4617
|
+
const normalized = Number(code);
|
|
4618
|
+
return Number.isFinite(normalized) && normalized >= 500;
|
|
4619
|
+
};
|
|
4561
4620
|
var getRecordString = (value, key) => {
|
|
4562
4621
|
const result = getRecordValue3(value, key);
|
|
4563
4622
|
return typeof result === "string" ? result : void 0;
|
|
@@ -4695,6 +4754,16 @@ var normalizeCssIsolation2 = (value) => {
|
|
|
4695
4754
|
}
|
|
4696
4755
|
return "none";
|
|
4697
4756
|
};
|
|
4757
|
+
var normalizeEnvelopeCode2 = (value, fallback) => {
|
|
4758
|
+
if (value === void 0 || value === null || value === "") return fallback;
|
|
4759
|
+
const normalized = Number(value);
|
|
4760
|
+
return Number.isFinite(normalized) ? normalized : String(value);
|
|
4761
|
+
};
|
|
4762
|
+
var isSuccessCode5 = (value) => {
|
|
4763
|
+
if (value === void 0 || value === null || value === "") return true;
|
|
4764
|
+
const normalized = Number(value);
|
|
4765
|
+
return Number.isFinite(normalized) ? normalized === 0 || normalized >= 200 && normalized < 300 : false;
|
|
4766
|
+
};
|
|
4698
4767
|
var parseJsonResponse = async (response) => {
|
|
4699
4768
|
const payload = await response.json().catch(() => null);
|
|
4700
4769
|
if (!response.ok) {
|
|
@@ -4702,9 +4771,10 @@ var parseJsonResponse = async (response) => {
|
|
|
4702
4771
|
throw new Error(message7 || "\u8BF7\u6C42\u5931\u8D25");
|
|
4703
4772
|
}
|
|
4704
4773
|
if (payload && typeof payload === "object" && "code" in payload) {
|
|
4774
|
+
const code = normalizeEnvelopeCode2(payload.code, response.status);
|
|
4705
4775
|
return {
|
|
4706
|
-
code
|
|
4707
|
-
success: payload.success
|
|
4776
|
+
code,
|
|
4777
|
+
success: payload.success !== false && isSuccessCode5(code),
|
|
4708
4778
|
message: payload.message,
|
|
4709
4779
|
result: payload.result ?? payload.data ?? null,
|
|
4710
4780
|
data: payload.data,
|
|
@@ -5072,6 +5142,11 @@ var joinUrl = (baseUrl, url2) => {
|
|
|
5072
5142
|
if (/^https?:\/\//i.test(url2)) return url2;
|
|
5073
5143
|
return `${trimTrailingSlash2(baseUrl)}${url2.startsWith("/") ? url2 : `/${url2}`}`;
|
|
5074
5144
|
};
|
|
5145
|
+
var isSuccessCode6 = (value) => {
|
|
5146
|
+
if (value === void 0 || value === null || value === "") return true;
|
|
5147
|
+
const code = Number(value);
|
|
5148
|
+
return Number.isFinite(code) ? code === 0 || code >= 200 && code < 300 : false;
|
|
5149
|
+
};
|
|
5075
5150
|
var normalizeRuntimeFileUrl = (baseUrl, value) => {
|
|
5076
5151
|
if (typeof value !== "string" || !value) return value;
|
|
5077
5152
|
if (/^(https?:)?\/\//i.test(value) || /^(blob|data):/i.test(value)) return value;
|
|
@@ -5098,6 +5173,12 @@ var parseResponse = async (response) => {
|
|
|
5098
5173
|
const message7 = typeof payload === "object" && payload ? payload.message || payload.error || response.statusText : response.statusText;
|
|
5099
5174
|
throw new Error(message7 || "\u8BF7\u6C42\u5931\u8D25");
|
|
5100
5175
|
}
|
|
5176
|
+
if (typeof payload === "object" && payload) {
|
|
5177
|
+
const hasCode = Object.prototype.hasOwnProperty.call(payload, "code");
|
|
5178
|
+
if (payload.success === false || hasCode && !isSuccessCode6(payload.code)) {
|
|
5179
|
+
throw new Error(payload.message || payload.error || "\u8BF7\u6C42\u5931\u8D25");
|
|
5180
|
+
}
|
|
5181
|
+
}
|
|
5101
5182
|
if (typeof payload === "object" && payload) {
|
|
5102
5183
|
return payload;
|
|
5103
5184
|
}
|
|
@@ -44324,20 +44405,20 @@ var import_react267 = require("react");
|
|
|
44324
44405
|
|
|
44325
44406
|
// packages/sdk/src/components/core/processApi.ts
|
|
44326
44407
|
init_cjs_shims();
|
|
44327
|
-
var
|
|
44328
|
-
var isRuntimeEnvelope = (value) => !!value && typeof value === "object" && !Array.isArray(value) && (
|
|
44329
|
-
var
|
|
44408
|
+
var hasOwn2 = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
44409
|
+
var isRuntimeEnvelope = (value) => !!value && typeof value === "object" && !Array.isArray(value) && (hasOwn2(value, "code") || hasOwn2(value, "success") || hasOwn2(value, "data") || hasOwn2(value, "result") || hasOwn2(value, "message") || hasOwn2(value, "error"));
|
|
44410
|
+
var isSuccessCode7 = (code) => {
|
|
44330
44411
|
if (code === void 0 || code === null || code === "") return true;
|
|
44331
44412
|
const normalized = Number(code);
|
|
44332
44413
|
return Number.isFinite(normalized) ? normalized === 0 || normalized === 200 : false;
|
|
44333
44414
|
};
|
|
44334
44415
|
var unwrapRuntimeResponse = (response) => {
|
|
44335
44416
|
if (!isRuntimeEnvelope(response)) return response;
|
|
44336
|
-
if (response.success === false || !
|
|
44417
|
+
if (response.success === false || !isSuccessCode7(response.code)) {
|
|
44337
44418
|
throw new Error(response.message || response.error || "\u8BF7\u6C42\u5931\u8D25");
|
|
44338
44419
|
}
|
|
44339
|
-
if (
|
|
44340
|
-
if (
|
|
44420
|
+
if (hasOwn2(response, "data")) return response.data;
|
|
44421
|
+
if (hasOwn2(response, "result")) return response.result;
|
|
44341
44422
|
return response;
|
|
44342
44423
|
};
|
|
44343
44424
|
var withInitiatorSelectedApprovers = (payload, initiatorSelectedApprovers) => {
|