openxiangda 1.0.149 → 1.0.151

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.
@@ -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.fetchImpl
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.fetchImpl,
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
- await runtime.reload();
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 [accessToken, setAccessTokenState] = (0, import_react14.useState)(null);
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 setAccessToken = (0, import_react14.useCallback)(
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(resolvedFetch, accessToken),
6174
- [accessToken, resolvedFetch]
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 ? createAuthorizedFetch(
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
- ) : createAuthorizedFetch(resolvedFetch, accessTokenRef.current);
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: payload?.data || null,
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: normalizeRuntimeError(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.fetchImpl(statusUrl, {
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.fetchImpl(
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.data?.app, runtime.fetchImpl, runtime.servicePrefix]
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.fetchImpl(
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.fetchImpl, runtime.servicePrefix]);
6722
+ }, [runtime.baseFetchImpl, runtime.servicePrefix, runtime.setAccessToken]);
6599
6723
  const logoutAndRedirect = (0, import_react14.useCallback)(
6600
6724
  async (options = {}) => {
6601
6725
  try {
@@ -6607,19 +6731,93 @@ var useRuntimeAuth = () => {
6607
6731
  },
6608
6732
  [logout, redirectToLogin]
6609
6733
  );
6610
- return {
6611
- logout,
6612
- logoutAndRedirect,
6613
- redirectToLogin,
6614
- resolveLoginUrl: resolveLoginUrl2
6615
- };
6734
+ return (0, import_react14.useMemo)(
6735
+ () => ({
6736
+ logout,
6737
+ logoutAndRedirect,
6738
+ redirectToLogin,
6739
+ resolveLoginUrl: resolveLoginUrl2
6740
+ }),
6741
+ [logout, logoutAndRedirect, redirectToLogin, resolveLoginUrl2]
6742
+ );
6743
+ };
6744
+ var RuntimeAuthGuard = ({
6745
+ children,
6746
+ fallback = null,
6747
+ disabled = false,
6748
+ excludedPaths = [],
6749
+ ...redirectOptions
6750
+ }) => {
6751
+ const runtime = useOpenXiangda();
6752
+ const auth = useRuntimeAuth();
6753
+ const redirectedRef = (0, import_react14.useRef)(false);
6754
+ const currentPath = getCurrentPathname2();
6755
+ const excluded = isRuntimeAuthGuardExcluded(
6756
+ currentPath,
6757
+ runtime.appType,
6758
+ excludedPaths
6759
+ );
6760
+ const shouldRedirect = !disabled && !excluded && !runtime.loading && (runtime.authState.status === "unauthenticated" || runtime.error?.type === "unauthenticated");
6761
+ (0, import_react14.useEffect)(() => {
6762
+ if (!shouldRedirect || redirectedRef.current) return;
6763
+ redirectedRef.current = true;
6764
+ void auth.redirectToLogin({
6765
+ ...redirectOptions,
6766
+ redirectUri: redirectOptions.redirectUri || getCurrentHref4()
6767
+ }).catch(() => {
6768
+ redirectedRef.current = false;
6769
+ });
6770
+ }, [
6771
+ auth,
6772
+ redirectOptions.domain,
6773
+ redirectOptions.loginUrl,
6774
+ redirectOptions.redirectUri,
6775
+ redirectOptions.replace,
6776
+ shouldRedirect
6777
+ ]);
6778
+ if (excluded) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children });
6779
+ if (shouldRedirect) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: fallback });
6780
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children });
6616
6781
  };
6617
6782
  var buildServiceUrl3 = (servicePrefix, path) => {
6618
6783
  const prefix = servicePrefix.endsWith("/") ? servicePrefix.slice(0, -1) : servicePrefix;
6619
6784
  const suffix = path.startsWith("/") ? path : `/${path}`;
6620
6785
  return `${prefix}${suffix}`;
6621
6786
  };
6622
- var createAuthorizedFetch = (baseFetch, accessToken) => {
6787
+ var createAuthorizedFetch = ({
6788
+ appType,
6789
+ baseFetch,
6790
+ accessTokenRef,
6791
+ refreshAccessToken,
6792
+ markUnauthenticated
6793
+ }) => (async (input, init = {}) => {
6794
+ const currentTokenState = accessTokenRef.current;
6795
+ const response = await createAccessTokenFetch(
6796
+ baseFetch,
6797
+ currentTokenState
6798
+ )(input, init);
6799
+ if (!shouldAttemptAuthRefresh({
6800
+ appType,
6801
+ input,
6802
+ init,
6803
+ tokenState: currentTokenState
6804
+ })) {
6805
+ return response;
6806
+ }
6807
+ if (!await isUnauthenticatedResponse(response)) return response;
6808
+ try {
6809
+ const refreshedTokenState = await refreshAccessToken();
6810
+ if (!refreshedTokenState) return response;
6811
+ return await createAccessTokenFetch(
6812
+ baseFetch,
6813
+ refreshedTokenState
6814
+ )(input, init);
6815
+ } catch (error) {
6816
+ markUnauthenticated(error);
6817
+ return response;
6818
+ }
6819
+ });
6820
+ var createAccessTokenFetch = (baseFetch, accessToken) => {
6623
6821
  if (!accessToken) return baseFetch;
6624
6822
  return ((input, init = {}) => {
6625
6823
  const token = resolveAccessTokenForCurrentRoute(accessToken);
@@ -6637,8 +6835,53 @@ var createAuthorizedFetch = (baseFetch, accessToken) => {
6637
6835
  var createAccessTokenState = (accessToken, options = {}) => accessToken ? {
6638
6836
  token: accessToken,
6639
6837
  scope: options.scope || "default",
6640
- path: options.path || null
6838
+ path: options.path || null,
6839
+ expiresAt: options.expiresAt
6641
6840
  } : null;
6841
+ var shouldAttemptAuthRefresh = ({
6842
+ appType,
6843
+ input,
6844
+ init,
6845
+ tokenState
6846
+ }) => {
6847
+ if (!appType) return false;
6848
+ if (tokenState?.scope === "public") return false;
6849
+ if (isPublicRoutePath(normalizeRoutePath(getCurrentPathname2()))) return false;
6850
+ if (hasAuthorizationHeader(init?.headers)) return false;
6851
+ const pathname = getFetchInputPathname(input);
6852
+ if (!pathname) return false;
6853
+ if (/\/openxiangda-api\/v1\/apps\/[^/]+\/auth(?:\/|$)/.test(pathname)) {
6854
+ return false;
6855
+ }
6856
+ if (/\/openxiangda-api\/v1\/apps\/[^/]+\/public\/session(?:\/|$)/.test(pathname)) {
6857
+ return false;
6858
+ }
6859
+ if (/\/openxiangda-api\/v1\/auth(?:\/|$)/.test(pathname)) return false;
6860
+ if (/\/api\/auth\/logout(?:\/|$)/.test(pathname)) return false;
6861
+ if (/\/api\/sso(?:\/|$)/.test(pathname)) return false;
6862
+ return true;
6863
+ };
6864
+ var isUnauthenticatedResponse = async (response) => {
6865
+ if (response.status === 401) return true;
6866
+ const payload = await readJsonPayload(response.clone());
6867
+ const code = getRecordValue3(payload, "code");
6868
+ return classifyRuntimeError(response.status, code) === "unauthenticated";
6869
+ };
6870
+ var hasAuthorizationHeader = (headers) => {
6871
+ if (!headers) return false;
6872
+ const normalized = new Headers(headers);
6873
+ return normalized.has("authorization");
6874
+ };
6875
+ var getFetchInputPathname = (input) => {
6876
+ const text = typeof input === "string" ? input : input instanceof URL ? input.toString() : typeof Request !== "undefined" && input instanceof Request ? input.url : String(input || "");
6877
+ if (!text) return "";
6878
+ try {
6879
+ const base = typeof window !== "undefined" ? window.location.origin : "http://localhost";
6880
+ return new URL(text, base).pathname;
6881
+ } catch {
6882
+ return text.split(/[?#]/, 1)[0] || "";
6883
+ }
6884
+ };
6642
6885
  var resolveAccessTokenForCurrentRoute = (accessToken) => {
6643
6886
  if (accessToken.scope !== "public") return accessToken.token;
6644
6887
  const scopedPath = normalizeRoutePath(accessToken.path);
@@ -6823,6 +7066,31 @@ var getRecordString = (value, key) => {
6823
7066
  const result = getRecordValue3(value, key);
6824
7067
  return typeof result === "string" ? result : void 0;
6825
7068
  };
7069
+ var getRecordNumber = (value, key) => {
7070
+ const result = getRecordValue3(value, key);
7071
+ const numberValue = Number(result);
7072
+ return Number.isFinite(numberValue) ? numberValue : void 0;
7073
+ };
7074
+ var unwrapRuntimePayload = (payload) => {
7075
+ if (!payload || typeof payload !== "object") return payload;
7076
+ const record = payload;
7077
+ return "data" in record ? record.data : payload;
7078
+ };
7079
+ var isAuthenticatedBootstrap = (value) => {
7080
+ if (!value || typeof value !== "object") return false;
7081
+ const user = toRuntimeRecord(getRecordValue3(value, "user"));
7082
+ if (!getRecordValue3(user, "id") && !getRecordValue3(user, "username")) {
7083
+ return false;
7084
+ }
7085
+ return !getRecordValue3(user, "publicAccess");
7086
+ };
7087
+ var isRuntimeAuthGuardExcluded = (path, appType, excludedPaths) => {
7088
+ const normalizedPath = normalizeRoutePath(path);
7089
+ if (isPublicRoutePath(normalizedPath)) return true;
7090
+ const loginPath = normalizeRoutePath(`/view/${encodeURIComponent(appType)}/login`);
7091
+ if (appType && normalizedPath === loginPath) return true;
7092
+ return excludedPaths.map((item) => normalizeRoutePath(item)).some((item) => item && normalizedPath === item);
7093
+ };
6826
7094
  var resolveAppTypeFromLocation = () => {
6827
7095
  if (typeof window === "undefined") return "";
6828
7096
  const segments = window.location.pathname.split("/").filter(Boolean);
@@ -17187,7 +17455,7 @@ async function fetchRuntimeFormData(api, appType, params) {
17187
17455
  order: order ? JSON.stringify(order) : void 0
17188
17456
  }
17189
17457
  });
17190
- const payload = unwrapRuntimePayload(response);
17458
+ const payload = unwrapRuntimePayload2(response);
17191
17459
  const data = Array.isArray(payload?.data) ? payload.data : Array.isArray(payload) ? payload : [];
17192
17460
  return {
17193
17461
  data,
@@ -17244,7 +17512,7 @@ function FormProvider({
17244
17512
  let cancelled = false;
17245
17513
  api.getUserById("current").then((payload) => {
17246
17514
  if (cancelled || !payload) return;
17247
- const currentUser = normalizeUser(unwrapRuntimePayload(payload));
17515
+ const currentUser = normalizeUser(unwrapRuntimePayload2(payload));
17248
17516
  const departments = normalizeDepartmentArray(currentUser.departments);
17249
17517
  const currentDepartment = departments[0];
17250
17518
  const currentUserManagers = normalizeUserArray(
@@ -17641,7 +17909,7 @@ function needsCurrentUserRuntime(shortcutType) {
17641
17909
  ].includes(shortcutType)
17642
17910
  );
17643
17911
  }
17644
- function unwrapRuntimePayload(payload) {
17912
+ function unwrapRuntimePayload2(payload) {
17645
17913
  return payload?.data || payload?.result || payload?.user || payload;
17646
17914
  }
17647
17915
  function isBlankFormValue(value) {
@@ -19585,7 +19853,7 @@ var DraftManager = ({
19585
19853
  // packages/sdk/src/components/templates/FormSubmitTemplate.tsx
19586
19854
  var import_jsx_runtime96 = require("react/jsx-runtime");
19587
19855
  var SUPERVISOR_APPROVER_TYPE = "ext_target_approval_department_supervisor";
19588
- var unwrapRuntimePayload2 = (value) => value?.data ?? value?.result ?? value;
19856
+ var unwrapRuntimePayload3 = (value) => value?.data ?? value?.result ?? value;
19589
19857
  var normalizeSubmitFormType = (value) => {
19590
19858
  const raw = String(value || "").toLowerCase();
19591
19859
  return raw === "process" || raw === "flow" ? "process" : "form";
@@ -19782,7 +20050,7 @@ var InnerFormContent = ({
19782
20050
  return departmentId;
19783
20051
  }
19784
20052
  const runtimeUser = schema.runtime?.currentUser;
19785
- const loadedUser = runtimeUser || unwrapRuntimePayload2(await api.getUserById("current"));
20053
+ const loadedUser = runtimeUser || unwrapRuntimePayload3(await api.getUserById("current"));
19786
20054
  const departments = normalizeDepartmentOptions(loadedUser?.departments);
19787
20055
  if (departments.length === 0) {
19788
20056
  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 +23023,7 @@ var downloadBlobResponse = async (response, fallbackName) => {
22755
23023
  anchor.remove();
22756
23024
  window.URL.revokeObjectURL(url);
22757
23025
  };
22758
- var unwrapRuntimePayload3 = (payload) => {
23026
+ var unwrapRuntimePayload4 = (payload) => {
22759
23027
  const data = payload?.data?.result ?? payload?.result ?? payload?.data ?? payload;
22760
23028
  return data?.items || data?.list || data?.data || data?.records || data || [];
22761
23029
  };
@@ -22854,14 +23122,14 @@ function AsyncEntityFilterSelect({
22854
23122
  method: "get",
22855
23123
  params: keyword ? { keyword, pageSize: 20 } : { pageSize: 20 }
22856
23124
  });
22857
- rows = unwrapRuntimePayload3(response);
23125
+ rows = unwrapRuntimePayload4(response);
22858
23126
  }
22859
23127
  } else {
22860
23128
  const response = await api.request({
22861
23129
  url: keyword ? "/department/list" : "/department/root",
22862
23130
  method: "get"
22863
23131
  });
22864
- rows = unwrapRuntimePayload3(response);
23132
+ rows = unwrapRuntimePayload4(response);
22865
23133
  if (keyword) {
22866
23134
  const normalizedKeyword = keyword.toLowerCase();
22867
23135
  rows = rows.filter(
@@ -24647,7 +24915,7 @@ var getDetailBasePath = (appType, formUuid, formType) => {
24647
24915
  const detailType = isProcessKind("data-manage-list", formType) ? "processDetail" : "formDetail";
24648
24916
  return `/view/${appType}/${detailType}/${formUuid}`;
24649
24917
  };
24650
- var unwrapRuntimePayload4 = (payload) => payload?.data ?? payload?.result ?? payload;
24918
+ var unwrapRuntimePayload5 = (payload) => payload?.data ?? payload?.result ?? payload;
24651
24919
  var formatFileSize2 = (size) => {
24652
24920
  const value = Number(size || 0);
24653
24921
  if (!value) return "0 B";
@@ -24728,7 +24996,7 @@ var OnlyOfficePreview = ({
24728
24996
  url: configUrl || `/file/onlyoffice/config/${encodeURIComponent(ticket)}`,
24729
24997
  method: "get"
24730
24998
  });
24731
- const payload = unwrapRuntimePayload4(response);
24999
+ const payload = unwrapRuntimePayload5(response);
24732
25000
  const scriptUrl = `${String(payload.documentServerUrl || "").replace(
24733
25001
  /\/+$/,
24734
25002
  ""
@@ -24786,7 +25054,7 @@ var BuiltinFilePreview = ({
24786
25054
  method: "get"
24787
25055
  });
24788
25056
  if (!disposed) {
24789
- setMetadata(unwrapRuntimePayload4(response));
25057
+ setMetadata(unwrapRuntimePayload5(response));
24790
25058
  }
24791
25059
  } catch (currentError) {
24792
25060
  if (!disposed) {
@@ -24826,7 +25094,7 @@ var BuiltinFilePreview = ({
24826
25094
  try {
24827
25095
  const response = await request({ url, method: "get" });
24828
25096
  if (!disposed) {
24829
- setPayload(unwrapRuntimePayload4(response));
25097
+ setPayload(unwrapRuntimePayload5(response));
24830
25098
  }
24831
25099
  } catch (currentError) {
24832
25100
  if (!disposed) {