openxiangda 1.0.141 → 1.0.142

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.
Files changed (28) hide show
  1. package/README.md +52 -2
  2. package/lib/cli.js +89 -0
  3. package/lib/design-gates.js +29 -0
  4. package/openxiangda-skills/SKILL.md +3 -1
  5. package/package.json +1 -1
  6. package/packages/sdk/dist/{ProcessPreview-CsOTCTRT.d.mts → ProcessPreview-CUQFUDvw.d.mts} +5 -2
  7. package/packages/sdk/dist/{ProcessPreview-CsOTCTRT.d.ts → ProcessPreview-CUQFUDvw.d.ts} +5 -2
  8. package/packages/sdk/dist/components/index.cjs +59 -19
  9. package/packages/sdk/dist/components/index.cjs.map +1 -1
  10. package/packages/sdk/dist/components/index.d.mts +4 -4
  11. package/packages/sdk/dist/components/index.d.ts +4 -4
  12. package/packages/sdk/dist/components/index.mjs +59 -19
  13. package/packages/sdk/dist/components/index.mjs.map +1 -1
  14. package/packages/sdk/dist/{dataManagementApi-Cd1axl3v.d.ts → dataManagementApi-CwBEmnXg.d.ts} +1 -1
  15. package/packages/sdk/dist/{dataManagementApi-C1OKWpP7.d.mts → dataManagementApi-DQKInwWS.d.mts} +1 -1
  16. package/packages/sdk/dist/runtime/index.cjs +75 -20
  17. package/packages/sdk/dist/runtime/index.cjs.map +1 -1
  18. package/packages/sdk/dist/runtime/index.d.mts +3 -3
  19. package/packages/sdk/dist/runtime/index.d.ts +3 -3
  20. package/packages/sdk/dist/runtime/index.mjs +75 -20
  21. package/packages/sdk/dist/runtime/index.mjs.map +1 -1
  22. package/packages/sdk/dist/runtime/react.cjs +16 -1
  23. package/packages/sdk/dist/runtime/react.cjs.map +1 -1
  24. package/packages/sdk/dist/runtime/react.d.mts +17 -2
  25. package/packages/sdk/dist/runtime/react.d.ts +17 -2
  26. package/packages/sdk/dist/runtime/react.mjs +16 -1
  27. package/packages/sdk/dist/runtime/react.mjs.map +1 -1
  28. package/templates/openxiangda-react-spa/src/pages/defaults/FormRoutePage.tsx +9 -0
@@ -1,4 +1,4 @@
1
- import { F as FieldDefinition, a as FormRuntimeApi, R as RuntimeResponse, b as FormSchema } from './ProcessPreview-CsOTCTRT.js';
1
+ import { F as FieldDefinition, a as FormRuntimeApi, R as RuntimeResponse, b as FormSchema } from './ProcessPreview-CUQFUDvw.js';
2
2
 
3
3
  type DataManagementConfigScope = 'global' | 'personal';
4
4
  type DataManagementDensity = 'compact' | 'middle' | 'loose';
@@ -1,4 +1,4 @@
1
- import { F as FieldDefinition, a as FormRuntimeApi, R as RuntimeResponse, b as FormSchema } from './ProcessPreview-CsOTCTRT.mjs';
1
+ import { F as FieldDefinition, a as FormRuntimeApi, R as RuntimeResponse, b as FormSchema } from './ProcessPreview-CUQFUDvw.mjs';
2
2
 
3
3
  type DataManagementConfigScope = 'global' | 'personal';
4
4
  type DataManagementDensity = 'compact' | 'middle' | 'loose';
@@ -6161,6 +6161,12 @@ var OpenXiangdaProvider = ({
6161
6161
  () => createAuthorizedFetch(resolvedFetch, accessToken),
6162
6162
  [accessToken, resolvedFetch]
6163
6163
  );
6164
+ const getAuthHeaders = (0, import_react14.useCallback)(() => {
6165
+ const state2 = accessTokenRef.current;
6166
+ if (!state2) return {};
6167
+ const token = resolveAccessTokenForCurrentRoute(state2);
6168
+ return token ? { authorization: `Bearer ${token}` } : {};
6169
+ }, []);
6164
6170
  const [state, setState] = (0, import_react14.useState)({
6165
6171
  data: null,
6166
6172
  loading: true,
@@ -6230,10 +6236,19 @@ var OpenXiangdaProvider = ({
6230
6236
  servicePrefix,
6231
6237
  fetchImpl: authorizedFetch,
6232
6238
  baseFetchImpl: resolvedFetch,
6239
+ getAuthHeaders,
6233
6240
  reload,
6234
6241
  setAccessToken
6235
6242
  }),
6236
- [authorizedFetch, reload, resolvedAppType, resolvedFetch, servicePrefix, state]
6243
+ [
6244
+ authorizedFetch,
6245
+ getAuthHeaders,
6246
+ reload,
6247
+ resolvedAppType,
6248
+ resolvedFetch,
6249
+ servicePrefix,
6250
+ state
6251
+ ]
6237
6252
  );
6238
6253
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(OpenXiangdaRuntimeContext.Provider, { value, children });
6239
6254
  };
@@ -7189,7 +7204,31 @@ var parseResponse = async (response) => {
7189
7204
  message: response.statusText
7190
7205
  };
7191
7206
  };
7192
- var createDefaultRequest = (baseUrl) => async (config) => {
7207
+ var applyAuthHeaders = (headers, getAuthHeaders) => {
7208
+ const authHeaders = getAuthHeaders?.();
7209
+ if (authHeaders) {
7210
+ new Headers(authHeaders).forEach((value, key) => {
7211
+ if (!headers.has(key)) headers.set(key, value);
7212
+ });
7213
+ }
7214
+ const token = typeof window !== "undefined" ? window.localStorage?.getItem("token") : void 0;
7215
+ if (token && !headers.has("authorization")) {
7216
+ headers.set("authorization", token);
7217
+ }
7218
+ };
7219
+ var applyXhrAuthHeaders = (xhr, getAuthHeaders) => {
7220
+ let hasAuthorization = false;
7221
+ const authHeaders = getAuthHeaders?.();
7222
+ if (authHeaders) {
7223
+ new Headers(authHeaders).forEach((value, key) => {
7224
+ if (key.toLowerCase() === "authorization") hasAuthorization = true;
7225
+ xhr.setRequestHeader(key, value);
7226
+ });
7227
+ }
7228
+ const token = typeof window !== "undefined" ? window.localStorage?.getItem("token") : void 0;
7229
+ if (token && !hasAuthorization) xhr.setRequestHeader("authorization", token);
7230
+ };
7231
+ var createDefaultRequest = (baseUrl, fetchImpl = fetch, getAuthHeaders) => async (config) => {
7193
7232
  const method = config.method ?? "get";
7194
7233
  const url = appendQuery2(joinUrl(baseUrl, config.url), config.params);
7195
7234
  const headers = new Headers(config.headers);
@@ -7202,11 +7241,8 @@ var createDefaultRequest = (baseUrl) => async (config) => {
7202
7241
  body = JSON.stringify(config.data);
7203
7242
  }
7204
7243
  }
7205
- const token = typeof window !== "undefined" ? window.localStorage?.getItem("token") : void 0;
7206
- if (token && !headers.has("authorization")) {
7207
- headers.set("authorization", token);
7208
- }
7209
- const response = await fetch(url, {
7244
+ applyAuthHeaders(headers, getAuthHeaders);
7245
+ const response = await fetchImpl(url, {
7210
7246
  method,
7211
7247
  headers,
7212
7248
  body,
@@ -7274,7 +7310,7 @@ var normalizeUploadData = (data, file, bucketName, baseUrl = "") => {
7274
7310
  variants
7275
7311
  };
7276
7312
  };
7277
- var uploadWithXhr = (baseUrl, file, bucketName, onProgress, options = {}) => new Promise((resolve, reject) => {
7313
+ var uploadWithXhr = (baseUrl, file, bucketName, onProgress, options = {}, getAuthHeaders) => new Promise((resolve, reject) => {
7278
7314
  if (globalThis.process?.env?.VITEST) {
7279
7315
  onProgress?.(100);
7280
7316
  resolve({
@@ -7304,8 +7340,7 @@ var uploadWithXhr = (baseUrl, file, bucketName, onProgress, options = {}) => new
7304
7340
  )
7305
7341
  );
7306
7342
  xhr.withCredentials = true;
7307
- const token = typeof window !== "undefined" ? window.localStorage?.getItem("token") : void 0;
7308
- if (token) xhr.setRequestHeader("authorization", token);
7343
+ applyXhrAuthHeaders(xhr, getAuthHeaders);
7309
7344
  xhr.upload.onprogress = (event) => {
7310
7345
  if (event.lengthComputable) {
7311
7346
  onProgress?.(Math.round(event.loaded / event.total * 100));
@@ -7409,7 +7444,8 @@ async function uploadChunkedFile(request, file, bucketName, baseUrl, onProgress,
7409
7444
  fileSize: file.size,
7410
7445
  chunkSize: DEFAULT_CHUNK_SIZE,
7411
7446
  bucketName,
7412
- visibility: options.visibility
7447
+ visibility: options.visibility,
7448
+ contentType: file.type || void 0
7413
7449
  }
7414
7450
  });
7415
7451
  const uploadInfo = initiate.data || initiate.result;
@@ -7468,7 +7504,7 @@ var createSegmentProgress = (onProgress, start, end) => (percent) => {
7468
7504
  onProgress?.(Math.round(next));
7469
7505
  };
7470
7506
  var getAttachmentUrl = (item) => item.publicUrl || item.previewUrl || item.downloadUrl || item.url || "";
7471
- async function uploadSingleRuntimeFile(request, baseUrl, file, bucketName, onProgress, options) {
7507
+ async function uploadSingleRuntimeFile(request, baseUrl, file, bucketName, onProgress, options, getAuthHeaders) {
7472
7508
  const singleOptions = stripImageCompressionOptions(options);
7473
7509
  if (singleOptions.uploadProvider === "builtin-oss") {
7474
7510
  return uploadBuiltinOssFile(request, file, bucketName, onProgress, singleOptions);
@@ -7479,7 +7515,7 @@ async function uploadSingleRuntimeFile(request, baseUrl, file, bucketName, onPro
7479
7515
  if (file.size > CHUNK_UPLOAD_THRESHOLD) {
7480
7516
  return uploadChunkedFile(request, file, bucketName, baseUrl, onProgress);
7481
7517
  }
7482
- return uploadWithXhr(baseUrl, file, bucketName, onProgress);
7518
+ return uploadWithXhr(baseUrl, file, bucketName, onProgress, {}, getAuthHeaders);
7483
7519
  }
7484
7520
  function toImageVariantMetadata(uploaded, variant) {
7485
7521
  return {
@@ -7493,7 +7529,7 @@ function toImageVariantMetadata(uploaded, variant) {
7493
7529
  quality: variant.quality
7494
7530
  };
7495
7531
  }
7496
- async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, onProgress, options) {
7532
+ async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, onProgress, options, getAuthHeaders) {
7497
7533
  let variants = [];
7498
7534
  try {
7499
7535
  variants = await createCompressedImageVariants(file, options.imageCompression);
@@ -7501,7 +7537,15 @@ async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, o
7501
7537
  variants = [];
7502
7538
  }
7503
7539
  if (variants.length === 0) {
7504
- return uploadSingleRuntimeFile(request, baseUrl, file, bucketName, onProgress, options);
7540
+ return uploadSingleRuntimeFile(
7541
+ request,
7542
+ baseUrl,
7543
+ file,
7544
+ bucketName,
7545
+ onProgress,
7546
+ options,
7547
+ getAuthHeaders
7548
+ );
7505
7549
  }
7506
7550
  const originalProgressEnd = 70;
7507
7551
  const uploaded = await uploadSingleRuntimeFile(
@@ -7510,7 +7554,8 @@ async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, o
7510
7554
  file,
7511
7555
  bucketName,
7512
7556
  createSegmentProgress(onProgress, 0, originalProgressEnd),
7513
- options
7557
+ options,
7558
+ getAuthHeaders
7514
7559
  );
7515
7560
  const imageVariants = { ...uploaded.variants || {} };
7516
7561
  const variantProgressStep = (100 - originalProgressEnd) / variants.length;
@@ -7525,7 +7570,8 @@ async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, o
7525
7570
  variant.file,
7526
7571
  bucketName,
7527
7572
  createSegmentProgress(onProgress, start, end),
7528
- options
7573
+ options,
7574
+ getAuthHeaders
7529
7575
  );
7530
7576
  imageVariants[variant.kind] = toImageVariantMetadata(variantUpload, variant);
7531
7577
  } catch {
@@ -7542,11 +7588,20 @@ async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, o
7542
7588
  }
7543
7589
  function createFormRuntimeApi(config) {
7544
7590
  const { baseUrl = getDefaultBaseUrl(), ...overrides } = config ?? {};
7545
- const request = overrides.request ?? createDefaultRequest(baseUrl);
7591
+ const { fetchImpl, getAuthHeaders } = overrides;
7592
+ const request = overrides.request ?? createDefaultRequest(baseUrl, fetchImpl, getAuthHeaders);
7546
7593
  const defaults = {
7547
7594
  request,
7548
7595
  uploadFile: async (file, bucketName = "files", onProgress, options = {}) => {
7549
- return uploadFileWithImageVariants(request, baseUrl, file, bucketName, onProgress, options);
7596
+ return uploadFileWithImageVariants(
7597
+ request,
7598
+ baseUrl,
7599
+ file,
7600
+ bucketName,
7601
+ onProgress,
7602
+ options,
7603
+ getAuthHeaders
7604
+ );
7550
7605
  },
7551
7606
  uploadPublicFile: async (file, bucketName = DEFAULT_PUBLIC_FILE_BUCKET, onProgress) => {
7552
7607
  if (file.size > CHUNK_UPLOAD_THRESHOLD) {
@@ -7556,7 +7611,7 @@ function createFormRuntimeApi(config) {
7556
7611
  }
7557
7612
  return uploadWithXhr(baseUrl, file, bucketName, onProgress, {
7558
7613
  visibility: "public"
7559
- });
7614
+ }, getAuthHeaders);
7560
7615
  },
7561
7616
  deleteFile: async (objectName, bucketName = "files", options = {}) => {
7562
7617
  if (options.uploadProvider === "builtin-oss" || options.storageScope === "platform") {