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
|
@@ -846,18 +846,39 @@ var normalizeDynamicOrder = (value) => {
|
|
|
846
846
|
}
|
|
847
847
|
return `${value.id}:${value.isAsc === "n" ? "-" : "+"}`;
|
|
848
848
|
};
|
|
849
|
+
var hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
850
|
+
var normalizeEnvelopeCode = (value) => {
|
|
851
|
+
if (value === void 0 || value === null || value === "") {
|
|
852
|
+
return 200;
|
|
853
|
+
}
|
|
854
|
+
const normalized = Number(value);
|
|
855
|
+
return Number.isFinite(normalized) ? normalized : String(value);
|
|
856
|
+
};
|
|
857
|
+
var isSuccessCode = (value) => {
|
|
858
|
+
if (value === void 0 || value === null || value === "") {
|
|
859
|
+
return true;
|
|
860
|
+
}
|
|
861
|
+
const normalized = Number(value);
|
|
862
|
+
return Number.isFinite(normalized) ? normalized === 0 || normalized >= 200 && normalized < 300 : false;
|
|
863
|
+
};
|
|
864
|
+
var getEnvelopeCode = (rawResponse) => {
|
|
865
|
+
if (isRecord(rawResponse) && hasOwn(rawResponse, "code")) {
|
|
866
|
+
return rawResponse.code;
|
|
867
|
+
}
|
|
868
|
+
const nestedData = rawResponse?.data;
|
|
869
|
+
if (isRecord(nestedData) && hasOwn(nestedData, "code")) {
|
|
870
|
+
return nestedData.code;
|
|
871
|
+
}
|
|
872
|
+
return void 0;
|
|
873
|
+
};
|
|
849
874
|
var normalizeJsonResponse = (rawResponse) => {
|
|
850
|
-
const
|
|
851
|
-
const nestedCode = Number(
|
|
852
|
-
rawResponse?.data?.code
|
|
853
|
-
);
|
|
854
|
-
const code = Number.isFinite(topLevelCode) ? topLevelCode : Number.isFinite(nestedCode) ? nestedCode : 200;
|
|
875
|
+
const code = normalizeEnvelopeCode(getEnvelopeCode(rawResponse));
|
|
855
876
|
const topLevelResult = isRecord(rawResponse) && "result" in rawResponse ? rawResponse.result : void 0;
|
|
856
877
|
const nestedResult = isRecord(rawResponse?.data) && "result" in (rawResponse.data || {}) ? rawResponse.data?.result : void 0;
|
|
857
878
|
const topLevelData = isRecord(rawResponse) && "data" in rawResponse ? rawResponse.data : void 0;
|
|
858
879
|
const result = topLevelResult !== void 0 ? topLevelResult : nestedResult !== void 0 ? nestedResult : topLevelData !== void 0 ? topLevelData : isRecord(rawResponse) ? rawResponse : null;
|
|
859
880
|
const nestedSuccess = typeof rawResponse?.data?.success === "boolean" ? rawResponse.data?.success : void 0;
|
|
860
|
-
const success =
|
|
881
|
+
const success = rawResponse?.success === false || nestedSuccess === false ? false : isSuccessCode(code);
|
|
861
882
|
return {
|
|
862
883
|
code,
|
|
863
884
|
success,
|
|
@@ -902,6 +923,9 @@ var normalizeBinaryResponse = (rawResponse) => {
|
|
|
902
923
|
};
|
|
903
924
|
};
|
|
904
925
|
var toSdkError = (input, payload) => {
|
|
926
|
+
if (input instanceof Error && input.response) {
|
|
927
|
+
return input;
|
|
928
|
+
}
|
|
905
929
|
const normalizedResponse = isRecord(input) ? normalizeJsonResponse(input) : void 0;
|
|
906
930
|
const nextError = input instanceof Error ? input : new Error(
|
|
907
931
|
normalizedResponse?.message || `\u8BF7\u6C42\u5931\u8D25: ${String(payload.method).toUpperCase()} ${payload.path}`
|
|
@@ -2560,7 +2584,8 @@ var createAuthClient = ({
|
|
|
2560
2584
|
});
|
|
2561
2585
|
const payload = await readPayload(response);
|
|
2562
2586
|
const code = getRecordValue(payload, "code");
|
|
2563
|
-
|
|
2587
|
+
const success = getRecordValue(payload, "success");
|
|
2588
|
+
if (!response.ok || success === false || !isSuccessCode2(code)) {
|
|
2564
2589
|
throw new AuthClientError(
|
|
2565
2590
|
String(getRecordValue(payload, "message") || `Auth request failed: ${response.status}`),
|
|
2566
2591
|
{ status: response.status, code, payload }
|
|
@@ -2613,6 +2638,11 @@ var getRecordValue = (value, key) => {
|
|
|
2613
2638
|
if (!value || typeof value !== "object") return void 0;
|
|
2614
2639
|
return value[key];
|
|
2615
2640
|
};
|
|
2641
|
+
var isSuccessCode2 = (code) => {
|
|
2642
|
+
if (code === void 0 || code === null || code === "") return true;
|
|
2643
|
+
const normalized = Number(code);
|
|
2644
|
+
return Number.isFinite(normalized) ? normalized === 0 || normalized >= 200 && normalized < 300 : false;
|
|
2645
|
+
};
|
|
2616
2646
|
var resolveLoginUrl = (appType, {
|
|
2617
2647
|
callbackUrl = getCurrentHref2(),
|
|
2618
2648
|
callbackParamName = "callback",
|
|
@@ -3193,7 +3223,7 @@ var OpenXiangdaProvider = ({
|
|
|
3193
3223
|
}
|
|
3194
3224
|
);
|
|
3195
3225
|
const payload = await readJsonPayload(response);
|
|
3196
|
-
if (
|
|
3226
|
+
if (isRuntimeEnvelopeFailure(response, payload)) {
|
|
3197
3227
|
throw createRuntimeHttpError(
|
|
3198
3228
|
response,
|
|
3199
3229
|
payload,
|
|
@@ -3328,7 +3358,7 @@ var useCanAccessRoute = (input) => {
|
|
|
3328
3358
|
payload
|
|
3329
3359
|
};
|
|
3330
3360
|
if (!disposed) {
|
|
3331
|
-
const shouldTreatAsError = !response.ok ||
|
|
3361
|
+
const shouldTreatAsError = !response.ok || isServerErrorCode(code);
|
|
3332
3362
|
setState({
|
|
3333
3363
|
data,
|
|
3334
3364
|
loading: false,
|
|
@@ -3460,7 +3490,7 @@ var useRuntimeAuth = () => {
|
|
|
3460
3490
|
}
|
|
3461
3491
|
);
|
|
3462
3492
|
const payload = await readJsonPayload(response);
|
|
3463
|
-
if (
|
|
3493
|
+
if (isRuntimeEnvelopeFailure(response, payload)) {
|
|
3464
3494
|
throw createRuntimeHttpError(
|
|
3465
3495
|
response,
|
|
3466
3496
|
payload,
|
|
@@ -3550,6 +3580,15 @@ var classifyRuntimeError = (status, code) => {
|
|
|
3550
3580
|
const normalizedCode = typeof code === "string" ? Number(code) : code;
|
|
3551
3581
|
if (status === 401 || normalizedCode === 401) return "unauthenticated";
|
|
3552
3582
|
if (status === 403 || normalizedCode === 403) return "forbidden";
|
|
3583
|
+
if (typeof code === "string") {
|
|
3584
|
+
const normalizedText = code.toUpperCase();
|
|
3585
|
+
if (normalizedText.includes("DENIED") || normalizedText.includes("FORBIDDEN")) {
|
|
3586
|
+
return "forbidden";
|
|
3587
|
+
}
|
|
3588
|
+
if (normalizedText.includes("UNAUTH") || normalizedText.includes("LOGIN")) {
|
|
3589
|
+
return "unauthenticated";
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3553
3592
|
if (!status && !normalizedCode) return "network";
|
|
3554
3593
|
return "unknown";
|
|
3555
3594
|
};
|
|
@@ -3605,6 +3644,20 @@ var getRecordValue2 = (value, key) => {
|
|
|
3605
3644
|
if (!value || typeof value !== "object") return void 0;
|
|
3606
3645
|
return value[key];
|
|
3607
3646
|
};
|
|
3647
|
+
var isSuccessCode3 = (code) => {
|
|
3648
|
+
if (code === void 0 || code === null || code === "") return true;
|
|
3649
|
+
const normalized = Number(code);
|
|
3650
|
+
return Number.isFinite(normalized) ? normalized === 0 || normalized >= 200 && normalized < 300 : false;
|
|
3651
|
+
};
|
|
3652
|
+
var isRuntimeEnvelopeFailure = (response, payload) => {
|
|
3653
|
+
const code = getRecordValue2(payload, "code");
|
|
3654
|
+
const success = getRecordValue2(payload, "success");
|
|
3655
|
+
return !response.ok || success === false || !isSuccessCode3(code);
|
|
3656
|
+
};
|
|
3657
|
+
var isServerErrorCode = (code) => {
|
|
3658
|
+
const normalized = Number(code);
|
|
3659
|
+
return Number.isFinite(normalized) && normalized >= 500;
|
|
3660
|
+
};
|
|
3608
3661
|
var getRecordString = (value, key) => {
|
|
3609
3662
|
const result = getRecordValue2(value, key);
|
|
3610
3663
|
return typeof result === "string" ? result : void 0;
|
|
@@ -3668,7 +3721,8 @@ var createPublicAccessClient = ({
|
|
|
3668
3721
|
);
|
|
3669
3722
|
const payload = await readPayload2(response);
|
|
3670
3723
|
const code = getRecordValue3(payload, "code");
|
|
3671
|
-
|
|
3724
|
+
const success = getRecordValue3(payload, "success");
|
|
3725
|
+
if (!response.ok || success === false || !isSuccessCode4(code)) {
|
|
3672
3726
|
throw new PublicAccessClientError(
|
|
3673
3727
|
String(
|
|
3674
3728
|
getRecordValue3(payload, "message") || `Public access session failed: ${response.status}`
|
|
@@ -3706,6 +3760,11 @@ var getRecordValue3 = (value, key) => {
|
|
|
3706
3760
|
if (!value || typeof value !== "object") return void 0;
|
|
3707
3761
|
return value[key];
|
|
3708
3762
|
};
|
|
3763
|
+
var isSuccessCode4 = (code) => {
|
|
3764
|
+
if (code === void 0 || code === null || code === "") return true;
|
|
3765
|
+
const normalized = Number(code);
|
|
3766
|
+
return Number.isFinite(normalized) ? normalized === 0 || normalized >= 200 && normalized < 300 : false;
|
|
3767
|
+
};
|
|
3709
3768
|
var getCurrentPathname = () => typeof window === "undefined" ? void 0 : window.location.pathname;
|
|
3710
3769
|
var getCurrentDomain = () => typeof window === "undefined" ? void 0 : window.location.host;
|
|
3711
3770
|
var getCurrentUserAgent = () => typeof navigator === "undefined" ? void 0 : navigator.userAgent;
|