openxiangda 1.0.149 → 1.0.150
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 +1 -1
- package/openxiangda-skills/SKILL.md +1 -1
- package/openxiangda-skills/references/automation-v3.md +1 -1
- package/openxiangda-skills/references/connector-resources.md +1 -1
- package/openxiangda-skills/references/resource-manifest-cheatsheet.md +2 -2
- package/openxiangda-skills/references/workflow-v3.md +1 -1
- package/openxiangda-skills/skills/openxiangda-workflow-automation/SKILL.md +1 -1
- package/package.json +1 -1
- package/packages/sdk/dist/runtime/index.cjs +299 -34
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.d.mts +1 -1
- package/packages/sdk/dist/runtime/index.d.ts +1 -1
- package/packages/sdk/dist/runtime/index.mjs +299 -34
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/react.cjs +287 -22
- package/packages/sdk/dist/runtime/react.cjs.map +1 -1
- package/packages/sdk/dist/runtime/react.d.mts +18 -1
- package/packages/sdk/dist/runtime/react.d.ts +18 -1
- package/packages/sdk/dist/runtime/react.mjs +287 -22
- package/packages/sdk/dist/runtime/react.mjs.map +1 -1
- package/templates/openxiangda-react-spa/src/app/router.tsx +6 -1
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/js-code-nodes/sync_roles_to_platform/index.ts +1 -1
|
@@ -43,6 +43,7 @@ __export(runtime_exports, {
|
|
|
43
43
|
ProcessTimeline: () => ProcessTimeline,
|
|
44
44
|
PublicAccessClientError: () => PublicAccessClientError,
|
|
45
45
|
PublicAccessGate: () => PublicAccessGate,
|
|
46
|
+
RuntimeAuthGuard: () => RuntimeAuthGuard,
|
|
46
47
|
createAuthClient: () => createAuthClient,
|
|
47
48
|
createBrowserPageBridge: () => createBrowserPageBridge,
|
|
48
49
|
createBrowserPageContext: () => createBrowserPageContext,
|
|
@@ -5581,14 +5582,14 @@ var useAuth = (options = {}) => {
|
|
|
5581
5582
|
() => createAuthClient({
|
|
5582
5583
|
appType: options.appType || runtime.appType,
|
|
5583
5584
|
servicePrefix: options.servicePrefix || runtime.servicePrefix,
|
|
5584
|
-
fetchImpl: options.fetchImpl || runtime.
|
|
5585
|
+
fetchImpl: options.fetchImpl || runtime.baseFetchImpl
|
|
5585
5586
|
}),
|
|
5586
5587
|
[
|
|
5587
5588
|
options.appType,
|
|
5588
5589
|
options.fetchImpl,
|
|
5589
5590
|
options.servicePrefix,
|
|
5590
5591
|
runtime.appType,
|
|
5591
|
-
runtime.
|
|
5592
|
+
runtime.baseFetchImpl,
|
|
5592
5593
|
runtime.servicePrefix
|
|
5593
5594
|
]
|
|
5594
5595
|
);
|
|
@@ -5867,7 +5868,19 @@ var LoginPage = ({
|
|
|
5867
5868
|
};
|
|
5868
5869
|
async function handleSuccess(data) {
|
|
5869
5870
|
await onSuccess?.(data);
|
|
5870
|
-
|
|
5871
|
+
const accessToken = data.accessToken || data.token;
|
|
5872
|
+
const accessTokenOptions = {
|
|
5873
|
+
expiresAt: data.accessTokenExpiresAt
|
|
5874
|
+
};
|
|
5875
|
+
if (accessToken) {
|
|
5876
|
+
runtime.setAccessToken(accessToken, accessTokenOptions);
|
|
5877
|
+
}
|
|
5878
|
+
await runtime.reload(
|
|
5879
|
+
accessToken ? {
|
|
5880
|
+
accessToken,
|
|
5881
|
+
accessTokenOptions
|
|
5882
|
+
} : void 0
|
|
5883
|
+
);
|
|
5871
5884
|
if (redirectOnSuccess && typeof window !== "undefined") {
|
|
5872
5885
|
window.location.replace(
|
|
5873
5886
|
redirectUrl || getCallbackUrl() || `/view/${auth.client.appType}`
|
|
@@ -6151,27 +6164,125 @@ var OpenXiangdaProvider = ({
|
|
|
6151
6164
|
() => appType || resolveAppTypeFromLocation(),
|
|
6152
6165
|
[appType]
|
|
6153
6166
|
);
|
|
6154
|
-
const [
|
|
6167
|
+
const [, setAccessTokenState] = (0, import_react14.useState)(null);
|
|
6168
|
+
const [authState, setAuthState] = (0, import_react14.useState)({
|
|
6169
|
+
status: "unknown",
|
|
6170
|
+
error: null
|
|
6171
|
+
});
|
|
6155
6172
|
const accessTokenRef = (0, import_react14.useRef)(null);
|
|
6156
|
-
const
|
|
6173
|
+
const refreshRequestRef = (0, import_react14.useRef)(null);
|
|
6174
|
+
const applyAccessToken = (0, import_react14.useCallback)(
|
|
6157
6175
|
(nextAccessToken, options = {}) => {
|
|
6158
6176
|
if (!nextAccessToken && options.clearIfToken && accessTokenRef.current?.token !== options.clearIfToken) {
|
|
6159
|
-
return;
|
|
6177
|
+
return accessTokenRef.current;
|
|
6160
6178
|
}
|
|
6161
6179
|
const normalizedAccessToken = nextAccessToken || null;
|
|
6162
6180
|
const nextState = normalizedAccessToken ? {
|
|
6163
6181
|
token: normalizedAccessToken,
|
|
6164
6182
|
scope: options.scope || "default",
|
|
6165
|
-
path: options.path || null
|
|
6183
|
+
path: options.path || null,
|
|
6184
|
+
expiresAt: options.expiresAt
|
|
6166
6185
|
} : null;
|
|
6167
6186
|
accessTokenRef.current = nextState;
|
|
6168
6187
|
setAccessTokenState(nextState);
|
|
6188
|
+
return nextState;
|
|
6169
6189
|
},
|
|
6170
6190
|
[]
|
|
6171
6191
|
);
|
|
6192
|
+
const setAccessToken = (0, import_react14.useCallback)(
|
|
6193
|
+
(nextAccessToken, options = {}) => {
|
|
6194
|
+
const previousState = accessTokenRef.current;
|
|
6195
|
+
const nextState = applyAccessToken(nextAccessToken, options);
|
|
6196
|
+
if (nextState) {
|
|
6197
|
+
if (nextState.scope === "public") return;
|
|
6198
|
+
setAuthState({
|
|
6199
|
+
status: "authenticated",
|
|
6200
|
+
error: null
|
|
6201
|
+
});
|
|
6202
|
+
} else if (previousState?.scope !== "public") {
|
|
6203
|
+
setAuthState({ status: "unauthenticated", error: null });
|
|
6204
|
+
}
|
|
6205
|
+
},
|
|
6206
|
+
[applyAccessToken]
|
|
6207
|
+
);
|
|
6208
|
+
const markUnauthenticated = (0, import_react14.useCallback)(
|
|
6209
|
+
(error) => {
|
|
6210
|
+
const runtimeError = normalizeRuntimeError(error);
|
|
6211
|
+
applyAccessToken(null);
|
|
6212
|
+
setAuthState({ status: "unauthenticated", error: runtimeError });
|
|
6213
|
+
},
|
|
6214
|
+
[applyAccessToken]
|
|
6215
|
+
);
|
|
6216
|
+
const refreshAccessToken = (0, import_react14.useCallback)(async () => {
|
|
6217
|
+
if (!resolvedAppType) return null;
|
|
6218
|
+
if (!refreshRequestRef.current) {
|
|
6219
|
+
setAuthState((prev) => ({ ...prev, status: "refreshing", error: null }));
|
|
6220
|
+
refreshRequestRef.current = (async () => {
|
|
6221
|
+
const response = await resolvedFetch(
|
|
6222
|
+
buildServiceUrl3(
|
|
6223
|
+
servicePrefix,
|
|
6224
|
+
`/openxiangda-api/v1/apps/${encodeURIComponent(
|
|
6225
|
+
resolvedAppType
|
|
6226
|
+
)}/auth/refresh`
|
|
6227
|
+
),
|
|
6228
|
+
{
|
|
6229
|
+
method: "POST",
|
|
6230
|
+
credentials: "include",
|
|
6231
|
+
headers: {
|
|
6232
|
+
accept: "application/json",
|
|
6233
|
+
"content-type": "application/json"
|
|
6234
|
+
},
|
|
6235
|
+
body: "{}"
|
|
6236
|
+
}
|
|
6237
|
+
);
|
|
6238
|
+
const payload = await readJsonPayload(response);
|
|
6239
|
+
if (isRuntimeEnvelopeFailure(response, payload)) {
|
|
6240
|
+
throw createRuntimeHttpError(
|
|
6241
|
+
response,
|
|
6242
|
+
payload,
|
|
6243
|
+
payload?.message || `Token refresh failed: ${response.status}`
|
|
6244
|
+
);
|
|
6245
|
+
}
|
|
6246
|
+
const data = unwrapRuntimePayload(payload);
|
|
6247
|
+
const nextAccessToken = getRecordString(data, "accessToken") || getRecordString(data, "token");
|
|
6248
|
+
if (!nextAccessToken) {
|
|
6249
|
+
throw createRuntimeError({
|
|
6250
|
+
type: "unauthenticated",
|
|
6251
|
+
status: response.status,
|
|
6252
|
+
code: getRecordValue3(payload, "code"),
|
|
6253
|
+
message: "Token refresh response missing accessToken",
|
|
6254
|
+
payload
|
|
6255
|
+
});
|
|
6256
|
+
}
|
|
6257
|
+
const nextState = applyAccessToken(nextAccessToken, {
|
|
6258
|
+
expiresAt: getRecordNumber(data, "accessTokenExpiresAt")
|
|
6259
|
+
});
|
|
6260
|
+
setAuthState({
|
|
6261
|
+
status: "authenticated",
|
|
6262
|
+
error: null,
|
|
6263
|
+
refreshedAt: Date.now()
|
|
6264
|
+
});
|
|
6265
|
+
return nextState;
|
|
6266
|
+
})().catch((error) => {
|
|
6267
|
+
const runtimeError = normalizeRuntimeError(error);
|
|
6268
|
+
applyAccessToken(null);
|
|
6269
|
+
setAuthState({ status: "unauthenticated", error: runtimeError });
|
|
6270
|
+
throw runtimeError;
|
|
6271
|
+
}).finally(() => {
|
|
6272
|
+
refreshRequestRef.current = null;
|
|
6273
|
+
});
|
|
6274
|
+
}
|
|
6275
|
+
return refreshRequestRef.current;
|
|
6276
|
+
}, [applyAccessToken, resolvedAppType, resolvedFetch, servicePrefix]);
|
|
6172
6277
|
const authorizedFetch = (0, import_react14.useMemo)(
|
|
6173
|
-
() => createAuthorizedFetch(
|
|
6174
|
-
|
|
6278
|
+
() => createAuthorizedFetch({
|
|
6279
|
+
appType: resolvedAppType,
|
|
6280
|
+
baseFetch: resolvedFetch,
|
|
6281
|
+
accessTokenRef,
|
|
6282
|
+
markUnauthenticated,
|
|
6283
|
+
refreshAccessToken
|
|
6284
|
+
}),
|
|
6285
|
+
[markUnauthenticated, refreshAccessToken, resolvedAppType, resolvedFetch]
|
|
6175
6286
|
);
|
|
6176
6287
|
const getAuthHeaders = (0, import_react14.useCallback)(() => {
|
|
6177
6288
|
const state2 = accessTokenRef.current;
|
|
@@ -6197,13 +6308,13 @@ var OpenXiangdaProvider = ({
|
|
|
6197
6308
|
return;
|
|
6198
6309
|
}
|
|
6199
6310
|
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
6200
|
-
const requestFetch = options.accessToken !== void 0 ?
|
|
6311
|
+
const requestFetch = options.accessToken !== void 0 ? createAccessTokenFetch(
|
|
6201
6312
|
resolvedFetch,
|
|
6202
6313
|
createAccessTokenState(
|
|
6203
6314
|
options.accessToken || null,
|
|
6204
6315
|
options.accessTokenOptions
|
|
6205
6316
|
)
|
|
6206
|
-
) :
|
|
6317
|
+
) : authorizedFetch;
|
|
6207
6318
|
try {
|
|
6208
6319
|
const response = await requestFetch(
|
|
6209
6320
|
buildServiceUrl3(
|
|
@@ -6225,19 +6336,29 @@ var OpenXiangdaProvider = ({
|
|
|
6225
6336
|
payload?.message || `Runtime bootstrap failed: ${response.status}`
|
|
6226
6337
|
);
|
|
6227
6338
|
}
|
|
6339
|
+
const nextData = payload?.data || null;
|
|
6228
6340
|
setState({
|
|
6229
|
-
data:
|
|
6341
|
+
data: nextData,
|
|
6230
6342
|
loading: false,
|
|
6231
6343
|
error: null
|
|
6232
6344
|
});
|
|
6345
|
+
if (isAuthenticatedBootstrap(nextData)) {
|
|
6346
|
+
setAuthState(
|
|
6347
|
+
(prev) => prev.status === "authenticated" ? prev : { status: "authenticated", error: null }
|
|
6348
|
+
);
|
|
6349
|
+
}
|
|
6233
6350
|
} catch (error) {
|
|
6351
|
+
const runtimeError = normalizeRuntimeError(error);
|
|
6234
6352
|
setState({
|
|
6235
6353
|
data: null,
|
|
6236
6354
|
loading: false,
|
|
6237
|
-
error:
|
|
6355
|
+
error: runtimeError
|
|
6238
6356
|
});
|
|
6357
|
+
if (runtimeError.type === "unauthenticated") {
|
|
6358
|
+
setAuthState({ status: "unauthenticated", error: runtimeError });
|
|
6359
|
+
}
|
|
6239
6360
|
}
|
|
6240
|
-
}, [resolvedAppType, resolvedFetch, servicePrefix]);
|
|
6361
|
+
}, [authorizedFetch, resolvedAppType, resolvedFetch, servicePrefix]);
|
|
6241
6362
|
(0, import_react14.useEffect)(() => {
|
|
6242
6363
|
void reload();
|
|
6243
6364
|
}, [reload]);
|
|
@@ -6248,6 +6369,7 @@ var OpenXiangdaProvider = ({
|
|
|
6248
6369
|
servicePrefix,
|
|
6249
6370
|
fetchImpl: authorizedFetch,
|
|
6250
6371
|
baseFetchImpl: resolvedFetch,
|
|
6372
|
+
authState,
|
|
6251
6373
|
getAuthHeaders,
|
|
6252
6374
|
reload,
|
|
6253
6375
|
setAccessToken
|
|
@@ -6259,7 +6381,8 @@ var OpenXiangdaProvider = ({
|
|
|
6259
6381
|
resolvedAppType,
|
|
6260
6382
|
resolvedFetch,
|
|
6261
6383
|
servicePrefix,
|
|
6262
|
-
state
|
|
6384
|
+
state,
|
|
6385
|
+
authState
|
|
6263
6386
|
]
|
|
6264
6387
|
);
|
|
6265
6388
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(OpenXiangdaRuntimeContext.Provider, { value, children });
|
|
@@ -6526,7 +6649,7 @@ var useRuntimeAuth = () => {
|
|
|
6526
6649
|
buildServiceUrl3(runtime.servicePrefix, "/api/sso/status"),
|
|
6527
6650
|
{ domain }
|
|
6528
6651
|
);
|
|
6529
|
-
const statusResponse = await runtime.
|
|
6652
|
+
const statusResponse = await runtime.baseFetchImpl(statusUrl, {
|
|
6530
6653
|
credentials: "include",
|
|
6531
6654
|
headers: { accept: "application/json" }
|
|
6532
6655
|
});
|
|
@@ -6537,7 +6660,7 @@ var useRuntimeAuth = () => {
|
|
|
6537
6660
|
enabled && (sso.forceLogin ?? sso.autoRedirect ?? true)
|
|
6538
6661
|
);
|
|
6539
6662
|
if (shouldUseSso) {
|
|
6540
|
-
const loginUrlResponse = await runtime.
|
|
6663
|
+
const loginUrlResponse = await runtime.baseFetchImpl(
|
|
6541
6664
|
withQuery(buildServiceUrl3(runtime.servicePrefix, "/api/sso/login-url"), {
|
|
6542
6665
|
domain,
|
|
6543
6666
|
redirectUri,
|
|
@@ -6561,7 +6684,7 @@ var useRuntimeAuth = () => {
|
|
|
6561
6684
|
}
|
|
6562
6685
|
return attachCallback("/platform/login", redirectUri);
|
|
6563
6686
|
},
|
|
6564
|
-
[runtime.
|
|
6687
|
+
[runtime.baseFetchImpl, runtime.data?.app, runtime.servicePrefix]
|
|
6565
6688
|
);
|
|
6566
6689
|
const redirectToLogin = (0, import_react14.useCallback)(
|
|
6567
6690
|
async (options = {}) => {
|
|
@@ -6578,7 +6701,7 @@ var useRuntimeAuth = () => {
|
|
|
6578
6701
|
[resolveLoginUrl2]
|
|
6579
6702
|
);
|
|
6580
6703
|
const logout = (0, import_react14.useCallback)(async () => {
|
|
6581
|
-
const response = await runtime.
|
|
6704
|
+
const response = await runtime.baseFetchImpl(
|
|
6582
6705
|
buildServiceUrl3(runtime.servicePrefix, "/api/auth/logout"),
|
|
6583
6706
|
{
|
|
6584
6707
|
method: "POST",
|
|
@@ -6594,8 +6717,9 @@ var useRuntimeAuth = () => {
|
|
|
6594
6717
|
payload?.message || `Logout failed: ${response.status}`
|
|
6595
6718
|
);
|
|
6596
6719
|
}
|
|
6720
|
+
runtime.setAccessToken(null);
|
|
6597
6721
|
return payload;
|
|
6598
|
-
}, [runtime.
|
|
6722
|
+
}, [runtime.baseFetchImpl, runtime.servicePrefix, runtime.setAccessToken]);
|
|
6599
6723
|
const logoutAndRedirect = (0, import_react14.useCallback)(
|
|
6600
6724
|
async (options = {}) => {
|
|
6601
6725
|
try {
|
|
@@ -6614,12 +6738,83 @@ var useRuntimeAuth = () => {
|
|
|
6614
6738
|
resolveLoginUrl: resolveLoginUrl2
|
|
6615
6739
|
};
|
|
6616
6740
|
};
|
|
6741
|
+
var RuntimeAuthGuard = ({
|
|
6742
|
+
children,
|
|
6743
|
+
fallback = null,
|
|
6744
|
+
disabled = false,
|
|
6745
|
+
excludedPaths = [],
|
|
6746
|
+
...redirectOptions
|
|
6747
|
+
}) => {
|
|
6748
|
+
const runtime = useOpenXiangda();
|
|
6749
|
+
const auth = useRuntimeAuth();
|
|
6750
|
+
const redirectedRef = (0, import_react14.useRef)(false);
|
|
6751
|
+
const currentPath = getCurrentPathname2();
|
|
6752
|
+
const excluded = isRuntimeAuthGuardExcluded(
|
|
6753
|
+
currentPath,
|
|
6754
|
+
runtime.appType,
|
|
6755
|
+
excludedPaths
|
|
6756
|
+
);
|
|
6757
|
+
const shouldRedirect = !disabled && !excluded && !runtime.loading && (runtime.authState.status === "unauthenticated" || runtime.error?.type === "unauthenticated");
|
|
6758
|
+
(0, import_react14.useEffect)(() => {
|
|
6759
|
+
if (!shouldRedirect || redirectedRef.current) return;
|
|
6760
|
+
redirectedRef.current = true;
|
|
6761
|
+
void auth.redirectToLogin({
|
|
6762
|
+
...redirectOptions,
|
|
6763
|
+
redirectUri: redirectOptions.redirectUri || getCurrentHref4()
|
|
6764
|
+
}).catch(() => {
|
|
6765
|
+
redirectedRef.current = false;
|
|
6766
|
+
});
|
|
6767
|
+
}, [
|
|
6768
|
+
auth,
|
|
6769
|
+
redirectOptions.domain,
|
|
6770
|
+
redirectOptions.loginUrl,
|
|
6771
|
+
redirectOptions.redirectUri,
|
|
6772
|
+
redirectOptions.replace,
|
|
6773
|
+
shouldRedirect
|
|
6774
|
+
]);
|
|
6775
|
+
if (excluded) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children });
|
|
6776
|
+
if (shouldRedirect) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: fallback });
|
|
6777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children });
|
|
6778
|
+
};
|
|
6617
6779
|
var buildServiceUrl3 = (servicePrefix, path) => {
|
|
6618
6780
|
const prefix = servicePrefix.endsWith("/") ? servicePrefix.slice(0, -1) : servicePrefix;
|
|
6619
6781
|
const suffix = path.startsWith("/") ? path : `/${path}`;
|
|
6620
6782
|
return `${prefix}${suffix}`;
|
|
6621
6783
|
};
|
|
6622
|
-
var createAuthorizedFetch = (
|
|
6784
|
+
var createAuthorizedFetch = ({
|
|
6785
|
+
appType,
|
|
6786
|
+
baseFetch,
|
|
6787
|
+
accessTokenRef,
|
|
6788
|
+
refreshAccessToken,
|
|
6789
|
+
markUnauthenticated
|
|
6790
|
+
}) => (async (input, init = {}) => {
|
|
6791
|
+
const currentTokenState = accessTokenRef.current;
|
|
6792
|
+
const response = await createAccessTokenFetch(
|
|
6793
|
+
baseFetch,
|
|
6794
|
+
currentTokenState
|
|
6795
|
+
)(input, init);
|
|
6796
|
+
if (!shouldAttemptAuthRefresh({
|
|
6797
|
+
appType,
|
|
6798
|
+
input,
|
|
6799
|
+
init,
|
|
6800
|
+
tokenState: currentTokenState
|
|
6801
|
+
})) {
|
|
6802
|
+
return response;
|
|
6803
|
+
}
|
|
6804
|
+
if (!await isUnauthenticatedResponse(response)) return response;
|
|
6805
|
+
try {
|
|
6806
|
+
const refreshedTokenState = await refreshAccessToken();
|
|
6807
|
+
if (!refreshedTokenState) return response;
|
|
6808
|
+
return await createAccessTokenFetch(
|
|
6809
|
+
baseFetch,
|
|
6810
|
+
refreshedTokenState
|
|
6811
|
+
)(input, init);
|
|
6812
|
+
} catch (error) {
|
|
6813
|
+
markUnauthenticated(error);
|
|
6814
|
+
return response;
|
|
6815
|
+
}
|
|
6816
|
+
});
|
|
6817
|
+
var createAccessTokenFetch = (baseFetch, accessToken) => {
|
|
6623
6818
|
if (!accessToken) return baseFetch;
|
|
6624
6819
|
return ((input, init = {}) => {
|
|
6625
6820
|
const token = resolveAccessTokenForCurrentRoute(accessToken);
|
|
@@ -6637,8 +6832,53 @@ var createAuthorizedFetch = (baseFetch, accessToken) => {
|
|
|
6637
6832
|
var createAccessTokenState = (accessToken, options = {}) => accessToken ? {
|
|
6638
6833
|
token: accessToken,
|
|
6639
6834
|
scope: options.scope || "default",
|
|
6640
|
-
path: options.path || null
|
|
6835
|
+
path: options.path || null,
|
|
6836
|
+
expiresAt: options.expiresAt
|
|
6641
6837
|
} : null;
|
|
6838
|
+
var shouldAttemptAuthRefresh = ({
|
|
6839
|
+
appType,
|
|
6840
|
+
input,
|
|
6841
|
+
init,
|
|
6842
|
+
tokenState
|
|
6843
|
+
}) => {
|
|
6844
|
+
if (!appType) return false;
|
|
6845
|
+
if (tokenState?.scope === "public") return false;
|
|
6846
|
+
if (isPublicRoutePath(normalizeRoutePath(getCurrentPathname2()))) return false;
|
|
6847
|
+
if (hasAuthorizationHeader(init?.headers)) return false;
|
|
6848
|
+
const pathname = getFetchInputPathname(input);
|
|
6849
|
+
if (!pathname) return false;
|
|
6850
|
+
if (/\/openxiangda-api\/v1\/apps\/[^/]+\/auth(?:\/|$)/.test(pathname)) {
|
|
6851
|
+
return false;
|
|
6852
|
+
}
|
|
6853
|
+
if (/\/openxiangda-api\/v1\/apps\/[^/]+\/public\/session(?:\/|$)/.test(pathname)) {
|
|
6854
|
+
return false;
|
|
6855
|
+
}
|
|
6856
|
+
if (/\/openxiangda-api\/v1\/auth(?:\/|$)/.test(pathname)) return false;
|
|
6857
|
+
if (/\/api\/auth\/logout(?:\/|$)/.test(pathname)) return false;
|
|
6858
|
+
if (/\/api\/sso(?:\/|$)/.test(pathname)) return false;
|
|
6859
|
+
return true;
|
|
6860
|
+
};
|
|
6861
|
+
var isUnauthenticatedResponse = async (response) => {
|
|
6862
|
+
if (response.status === 401) return true;
|
|
6863
|
+
const payload = await readJsonPayload(response.clone());
|
|
6864
|
+
const code = getRecordValue3(payload, "code");
|
|
6865
|
+
return classifyRuntimeError(response.status, code) === "unauthenticated";
|
|
6866
|
+
};
|
|
6867
|
+
var hasAuthorizationHeader = (headers) => {
|
|
6868
|
+
if (!headers) return false;
|
|
6869
|
+
const normalized = new Headers(headers);
|
|
6870
|
+
return normalized.has("authorization");
|
|
6871
|
+
};
|
|
6872
|
+
var getFetchInputPathname = (input) => {
|
|
6873
|
+
const text = typeof input === "string" ? input : input instanceof URL ? input.toString() : typeof Request !== "undefined" && input instanceof Request ? input.url : String(input || "");
|
|
6874
|
+
if (!text) return "";
|
|
6875
|
+
try {
|
|
6876
|
+
const base = typeof window !== "undefined" ? window.location.origin : "http://localhost";
|
|
6877
|
+
return new URL(text, base).pathname;
|
|
6878
|
+
} catch {
|
|
6879
|
+
return text.split(/[?#]/, 1)[0] || "";
|
|
6880
|
+
}
|
|
6881
|
+
};
|
|
6642
6882
|
var resolveAccessTokenForCurrentRoute = (accessToken) => {
|
|
6643
6883
|
if (accessToken.scope !== "public") return accessToken.token;
|
|
6644
6884
|
const scopedPath = normalizeRoutePath(accessToken.path);
|
|
@@ -6823,6 +7063,31 @@ var getRecordString = (value, key) => {
|
|
|
6823
7063
|
const result = getRecordValue3(value, key);
|
|
6824
7064
|
return typeof result === "string" ? result : void 0;
|
|
6825
7065
|
};
|
|
7066
|
+
var getRecordNumber = (value, key) => {
|
|
7067
|
+
const result = getRecordValue3(value, key);
|
|
7068
|
+
const numberValue = Number(result);
|
|
7069
|
+
return Number.isFinite(numberValue) ? numberValue : void 0;
|
|
7070
|
+
};
|
|
7071
|
+
var unwrapRuntimePayload = (payload) => {
|
|
7072
|
+
if (!payload || typeof payload !== "object") return payload;
|
|
7073
|
+
const record = payload;
|
|
7074
|
+
return "data" in record ? record.data : payload;
|
|
7075
|
+
};
|
|
7076
|
+
var isAuthenticatedBootstrap = (value) => {
|
|
7077
|
+
if (!value || typeof value !== "object") return false;
|
|
7078
|
+
const user = toRuntimeRecord(getRecordValue3(value, "user"));
|
|
7079
|
+
if (!getRecordValue3(user, "id") && !getRecordValue3(user, "username")) {
|
|
7080
|
+
return false;
|
|
7081
|
+
}
|
|
7082
|
+
return !getRecordValue3(user, "publicAccess");
|
|
7083
|
+
};
|
|
7084
|
+
var isRuntimeAuthGuardExcluded = (path, appType, excludedPaths) => {
|
|
7085
|
+
const normalizedPath = normalizeRoutePath(path);
|
|
7086
|
+
if (isPublicRoutePath(normalizedPath)) return true;
|
|
7087
|
+
const loginPath = normalizeRoutePath(`/view/${encodeURIComponent(appType)}/login`);
|
|
7088
|
+
if (appType && normalizedPath === loginPath) return true;
|
|
7089
|
+
return excludedPaths.map((item) => normalizeRoutePath(item)).some((item) => item && normalizedPath === item);
|
|
7090
|
+
};
|
|
6826
7091
|
var resolveAppTypeFromLocation = () => {
|
|
6827
7092
|
if (typeof window === "undefined") return "";
|
|
6828
7093
|
const segments = window.location.pathname.split("/").filter(Boolean);
|
|
@@ -17187,7 +17452,7 @@ async function fetchRuntimeFormData(api, appType, params) {
|
|
|
17187
17452
|
order: order ? JSON.stringify(order) : void 0
|
|
17188
17453
|
}
|
|
17189
17454
|
});
|
|
17190
|
-
const payload =
|
|
17455
|
+
const payload = unwrapRuntimePayload2(response);
|
|
17191
17456
|
const data = Array.isArray(payload?.data) ? payload.data : Array.isArray(payload) ? payload : [];
|
|
17192
17457
|
return {
|
|
17193
17458
|
data,
|
|
@@ -17244,7 +17509,7 @@ function FormProvider({
|
|
|
17244
17509
|
let cancelled = false;
|
|
17245
17510
|
api.getUserById("current").then((payload) => {
|
|
17246
17511
|
if (cancelled || !payload) return;
|
|
17247
|
-
const currentUser = normalizeUser(
|
|
17512
|
+
const currentUser = normalizeUser(unwrapRuntimePayload2(payload));
|
|
17248
17513
|
const departments = normalizeDepartmentArray(currentUser.departments);
|
|
17249
17514
|
const currentDepartment = departments[0];
|
|
17250
17515
|
const currentUserManagers = normalizeUserArray(
|
|
@@ -17641,7 +17906,7 @@ function needsCurrentUserRuntime(shortcutType) {
|
|
|
17641
17906
|
].includes(shortcutType)
|
|
17642
17907
|
);
|
|
17643
17908
|
}
|
|
17644
|
-
function
|
|
17909
|
+
function unwrapRuntimePayload2(payload) {
|
|
17645
17910
|
return payload?.data || payload?.result || payload?.user || payload;
|
|
17646
17911
|
}
|
|
17647
17912
|
function isBlankFormValue(value) {
|
|
@@ -19585,7 +19850,7 @@ var DraftManager = ({
|
|
|
19585
19850
|
// packages/sdk/src/components/templates/FormSubmitTemplate.tsx
|
|
19586
19851
|
var import_jsx_runtime96 = require("react/jsx-runtime");
|
|
19587
19852
|
var SUPERVISOR_APPROVER_TYPE = "ext_target_approval_department_supervisor";
|
|
19588
|
-
var
|
|
19853
|
+
var unwrapRuntimePayload3 = (value) => value?.data ?? value?.result ?? value;
|
|
19589
19854
|
var normalizeSubmitFormType = (value) => {
|
|
19590
19855
|
const raw = String(value || "").toLowerCase();
|
|
19591
19856
|
return raw === "process" || raw === "flow" ? "process" : "form";
|
|
@@ -19782,7 +20047,7 @@ var InnerFormContent = ({
|
|
|
19782
20047
|
return departmentId;
|
|
19783
20048
|
}
|
|
19784
20049
|
const runtimeUser = schema.runtime?.currentUser;
|
|
19785
|
-
const loadedUser = runtimeUser ||
|
|
20050
|
+
const loadedUser = runtimeUser || unwrapRuntimePayload3(await api.getUserById("current"));
|
|
19786
20051
|
const departments = normalizeDepartmentOptions(loadedUser?.departments);
|
|
19787
20052
|
if (departments.length === 0) {
|
|
19788
20053
|
import_antd36.message.error("\u5F53\u524D\u8D26\u53F7\u672A\u5206\u914D\u90E8\u95E8\uFF0C\u65E0\u6CD5\u53D1\u8D77\u4E3B\u7BA1\u5BA1\u6279\u6D41\u7A0B");
|
|
@@ -22755,7 +23020,7 @@ var downloadBlobResponse = async (response, fallbackName) => {
|
|
|
22755
23020
|
anchor.remove();
|
|
22756
23021
|
window.URL.revokeObjectURL(url);
|
|
22757
23022
|
};
|
|
22758
|
-
var
|
|
23023
|
+
var unwrapRuntimePayload4 = (payload) => {
|
|
22759
23024
|
const data = payload?.data?.result ?? payload?.result ?? payload?.data ?? payload;
|
|
22760
23025
|
return data?.items || data?.list || data?.data || data?.records || data || [];
|
|
22761
23026
|
};
|
|
@@ -22854,14 +23119,14 @@ function AsyncEntityFilterSelect({
|
|
|
22854
23119
|
method: "get",
|
|
22855
23120
|
params: keyword ? { keyword, pageSize: 20 } : { pageSize: 20 }
|
|
22856
23121
|
});
|
|
22857
|
-
rows =
|
|
23122
|
+
rows = unwrapRuntimePayload4(response);
|
|
22858
23123
|
}
|
|
22859
23124
|
} else {
|
|
22860
23125
|
const response = await api.request({
|
|
22861
23126
|
url: keyword ? "/department/list" : "/department/root",
|
|
22862
23127
|
method: "get"
|
|
22863
23128
|
});
|
|
22864
|
-
rows =
|
|
23129
|
+
rows = unwrapRuntimePayload4(response);
|
|
22865
23130
|
if (keyword) {
|
|
22866
23131
|
const normalizedKeyword = keyword.toLowerCase();
|
|
22867
23132
|
rows = rows.filter(
|
|
@@ -24647,7 +24912,7 @@ var getDetailBasePath = (appType, formUuid, formType) => {
|
|
|
24647
24912
|
const detailType = isProcessKind("data-manage-list", formType) ? "processDetail" : "formDetail";
|
|
24648
24913
|
return `/view/${appType}/${detailType}/${formUuid}`;
|
|
24649
24914
|
};
|
|
24650
|
-
var
|
|
24915
|
+
var unwrapRuntimePayload5 = (payload) => payload?.data ?? payload?.result ?? payload;
|
|
24651
24916
|
var formatFileSize2 = (size) => {
|
|
24652
24917
|
const value = Number(size || 0);
|
|
24653
24918
|
if (!value) return "0 B";
|
|
@@ -24728,7 +24993,7 @@ var OnlyOfficePreview = ({
|
|
|
24728
24993
|
url: configUrl || `/file/onlyoffice/config/${encodeURIComponent(ticket)}`,
|
|
24729
24994
|
method: "get"
|
|
24730
24995
|
});
|
|
24731
|
-
const payload =
|
|
24996
|
+
const payload = unwrapRuntimePayload5(response);
|
|
24732
24997
|
const scriptUrl = `${String(payload.documentServerUrl || "").replace(
|
|
24733
24998
|
/\/+$/,
|
|
24734
24999
|
""
|
|
@@ -24786,7 +25051,7 @@ var BuiltinFilePreview = ({
|
|
|
24786
25051
|
method: "get"
|
|
24787
25052
|
});
|
|
24788
25053
|
if (!disposed) {
|
|
24789
|
-
setMetadata(
|
|
25054
|
+
setMetadata(unwrapRuntimePayload5(response));
|
|
24790
25055
|
}
|
|
24791
25056
|
} catch (currentError) {
|
|
24792
25057
|
if (!disposed) {
|
|
@@ -24826,7 +25091,7 @@ var BuiltinFilePreview = ({
|
|
|
24826
25091
|
try {
|
|
24827
25092
|
const response = await request({ url, method: "get" });
|
|
24828
25093
|
if (!disposed) {
|
|
24829
|
-
setPayload(
|
|
25094
|
+
setPayload(unwrapRuntimePayload5(response));
|
|
24830
25095
|
}
|
|
24831
25096
|
} catch (currentError) {
|
|
24832
25097
|
if (!disposed) {
|