openxiangda 1.0.140 → 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.
- package/README.md +52 -2
- package/lib/cli.js +89 -0
- package/lib/design-gates.js +29 -0
- package/openxiangda-skills/SKILL.md +3 -1
- package/package.json +1 -1
- package/packages/sdk/dist/{ProcessPreview-CZJP8n3e.d.mts → ProcessPreview-CUQFUDvw.d.mts} +5 -2
- package/packages/sdk/dist/{ProcessPreview-CZJP8n3e.d.ts → ProcessPreview-CUQFUDvw.d.ts} +5 -2
- package/packages/sdk/dist/components/index.cjs +139 -30
- package/packages/sdk/dist/components/index.cjs.map +1 -1
- package/packages/sdk/dist/components/index.d.mts +6 -136
- package/packages/sdk/dist/components/index.d.ts +6 -136
- package/packages/sdk/dist/components/index.mjs +139 -30
- package/packages/sdk/dist/components/index.mjs.map +1 -1
- package/packages/sdk/dist/dataManagementApi-CwBEmnXg.d.ts +141 -0
- package/packages/sdk/dist/dataManagementApi-DQKInwWS.d.mts +141 -0
- package/packages/sdk/dist/runtime/index.cjs +157 -87
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.d.mts +4 -4
- package/packages/sdk/dist/runtime/index.d.ts +4 -4
- package/packages/sdk/dist/runtime/index.mjs +157 -87
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/react.cjs +16 -1
- package/packages/sdk/dist/runtime/react.cjs.map +1 -1
- package/packages/sdk/dist/runtime/react.d.mts +17 -2
- package/packages/sdk/dist/runtime/react.d.ts +17 -2
- package/packages/sdk/dist/runtime/react.mjs +16 -1
- package/packages/sdk/dist/runtime/react.mjs.map +1 -1
- package/templates/openxiangda-react-spa/src/pages/defaults/FormRoutePage.tsx +9 -0
|
@@ -10002,7 +10002,31 @@ var parseResponse = async (response) => {
|
|
|
10002
10002
|
message: response.statusText
|
|
10003
10003
|
};
|
|
10004
10004
|
};
|
|
10005
|
-
var
|
|
10005
|
+
var applyAuthHeaders = (headers, getAuthHeaders) => {
|
|
10006
|
+
const authHeaders = getAuthHeaders?.();
|
|
10007
|
+
if (authHeaders) {
|
|
10008
|
+
new Headers(authHeaders).forEach((value, key) => {
|
|
10009
|
+
if (!headers.has(key)) headers.set(key, value);
|
|
10010
|
+
});
|
|
10011
|
+
}
|
|
10012
|
+
const token = typeof window !== "undefined" ? window.localStorage?.getItem("token") : void 0;
|
|
10013
|
+
if (token && !headers.has("authorization")) {
|
|
10014
|
+
headers.set("authorization", token);
|
|
10015
|
+
}
|
|
10016
|
+
};
|
|
10017
|
+
var applyXhrAuthHeaders = (xhr, getAuthHeaders) => {
|
|
10018
|
+
let hasAuthorization = false;
|
|
10019
|
+
const authHeaders = getAuthHeaders?.();
|
|
10020
|
+
if (authHeaders) {
|
|
10021
|
+
new Headers(authHeaders).forEach((value, key) => {
|
|
10022
|
+
if (key.toLowerCase() === "authorization") hasAuthorization = true;
|
|
10023
|
+
xhr.setRequestHeader(key, value);
|
|
10024
|
+
});
|
|
10025
|
+
}
|
|
10026
|
+
const token = typeof window !== "undefined" ? window.localStorage?.getItem("token") : void 0;
|
|
10027
|
+
if (token && !hasAuthorization) xhr.setRequestHeader("authorization", token);
|
|
10028
|
+
};
|
|
10029
|
+
var createDefaultRequest = (baseUrl, fetchImpl = fetch, getAuthHeaders) => async (config) => {
|
|
10006
10030
|
const method = config.method ?? "get";
|
|
10007
10031
|
const url = appendQuery(joinUrl(baseUrl, config.url), config.params);
|
|
10008
10032
|
const headers = new Headers(config.headers);
|
|
@@ -10015,11 +10039,8 @@ var createDefaultRequest = (baseUrl) => async (config) => {
|
|
|
10015
10039
|
body = JSON.stringify(config.data);
|
|
10016
10040
|
}
|
|
10017
10041
|
}
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
headers.set("authorization", token);
|
|
10021
|
-
}
|
|
10022
|
-
const response = await fetch(url, {
|
|
10042
|
+
applyAuthHeaders(headers, getAuthHeaders);
|
|
10043
|
+
const response = await fetchImpl(url, {
|
|
10023
10044
|
method,
|
|
10024
10045
|
headers,
|
|
10025
10046
|
body,
|
|
@@ -10087,7 +10108,7 @@ var normalizeUploadData = (data, file, bucketName, baseUrl = "") => {
|
|
|
10087
10108
|
variants
|
|
10088
10109
|
};
|
|
10089
10110
|
};
|
|
10090
|
-
var uploadWithXhr = (baseUrl, file, bucketName, onProgress, options = {}) => new Promise((resolve, reject) => {
|
|
10111
|
+
var uploadWithXhr = (baseUrl, file, bucketName, onProgress, options = {}, getAuthHeaders) => new Promise((resolve, reject) => {
|
|
10091
10112
|
if (globalThis.process?.env?.VITEST) {
|
|
10092
10113
|
onProgress?.(100);
|
|
10093
10114
|
resolve({
|
|
@@ -10117,8 +10138,7 @@ var uploadWithXhr = (baseUrl, file, bucketName, onProgress, options = {}) => new
|
|
|
10117
10138
|
)
|
|
10118
10139
|
);
|
|
10119
10140
|
xhr.withCredentials = true;
|
|
10120
|
-
|
|
10121
|
-
if (token) xhr.setRequestHeader("authorization", token);
|
|
10141
|
+
applyXhrAuthHeaders(xhr, getAuthHeaders);
|
|
10122
10142
|
xhr.upload.onprogress = (event) => {
|
|
10123
10143
|
if (event.lengthComputable) {
|
|
10124
10144
|
onProgress?.(Math.round(event.loaded / event.total * 100));
|
|
@@ -10222,7 +10242,8 @@ async function uploadChunkedFile(request, file, bucketName, baseUrl, onProgress,
|
|
|
10222
10242
|
fileSize: file.size,
|
|
10223
10243
|
chunkSize: DEFAULT_CHUNK_SIZE,
|
|
10224
10244
|
bucketName,
|
|
10225
|
-
visibility: options.visibility
|
|
10245
|
+
visibility: options.visibility,
|
|
10246
|
+
contentType: file.type || void 0
|
|
10226
10247
|
}
|
|
10227
10248
|
});
|
|
10228
10249
|
const uploadInfo = initiate.data || initiate.result;
|
|
@@ -10281,7 +10302,7 @@ var createSegmentProgress = (onProgress, start, end) => (percent) => {
|
|
|
10281
10302
|
onProgress?.(Math.round(next));
|
|
10282
10303
|
};
|
|
10283
10304
|
var getAttachmentUrl = (item) => item.publicUrl || item.previewUrl || item.downloadUrl || item.url || "";
|
|
10284
|
-
async function uploadSingleRuntimeFile(request, baseUrl, file, bucketName, onProgress, options) {
|
|
10305
|
+
async function uploadSingleRuntimeFile(request, baseUrl, file, bucketName, onProgress, options, getAuthHeaders) {
|
|
10285
10306
|
const singleOptions = stripImageCompressionOptions(options);
|
|
10286
10307
|
if (singleOptions.uploadProvider === "builtin-oss") {
|
|
10287
10308
|
return uploadBuiltinOssFile(request, file, bucketName, onProgress, singleOptions);
|
|
@@ -10292,7 +10313,7 @@ async function uploadSingleRuntimeFile(request, baseUrl, file, bucketName, onPro
|
|
|
10292
10313
|
if (file.size > CHUNK_UPLOAD_THRESHOLD) {
|
|
10293
10314
|
return uploadChunkedFile(request, file, bucketName, baseUrl, onProgress);
|
|
10294
10315
|
}
|
|
10295
|
-
return uploadWithXhr(baseUrl, file, bucketName, onProgress);
|
|
10316
|
+
return uploadWithXhr(baseUrl, file, bucketName, onProgress, {}, getAuthHeaders);
|
|
10296
10317
|
}
|
|
10297
10318
|
function toImageVariantMetadata(uploaded, variant) {
|
|
10298
10319
|
return {
|
|
@@ -10306,7 +10327,7 @@ function toImageVariantMetadata(uploaded, variant) {
|
|
|
10306
10327
|
quality: variant.quality
|
|
10307
10328
|
};
|
|
10308
10329
|
}
|
|
10309
|
-
async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, onProgress, options) {
|
|
10330
|
+
async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, onProgress, options, getAuthHeaders) {
|
|
10310
10331
|
let variants = [];
|
|
10311
10332
|
try {
|
|
10312
10333
|
variants = await createCompressedImageVariants(file, options.imageCompression);
|
|
@@ -10314,7 +10335,15 @@ async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, o
|
|
|
10314
10335
|
variants = [];
|
|
10315
10336
|
}
|
|
10316
10337
|
if (variants.length === 0) {
|
|
10317
|
-
return uploadSingleRuntimeFile(
|
|
10338
|
+
return uploadSingleRuntimeFile(
|
|
10339
|
+
request,
|
|
10340
|
+
baseUrl,
|
|
10341
|
+
file,
|
|
10342
|
+
bucketName,
|
|
10343
|
+
onProgress,
|
|
10344
|
+
options,
|
|
10345
|
+
getAuthHeaders
|
|
10346
|
+
);
|
|
10318
10347
|
}
|
|
10319
10348
|
const originalProgressEnd = 70;
|
|
10320
10349
|
const uploaded = await uploadSingleRuntimeFile(
|
|
@@ -10323,7 +10352,8 @@ async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, o
|
|
|
10323
10352
|
file,
|
|
10324
10353
|
bucketName,
|
|
10325
10354
|
createSegmentProgress(onProgress, 0, originalProgressEnd),
|
|
10326
|
-
options
|
|
10355
|
+
options,
|
|
10356
|
+
getAuthHeaders
|
|
10327
10357
|
);
|
|
10328
10358
|
const imageVariants = { ...uploaded.variants || {} };
|
|
10329
10359
|
const variantProgressStep = (100 - originalProgressEnd) / variants.length;
|
|
@@ -10338,7 +10368,8 @@ async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, o
|
|
|
10338
10368
|
variant.file,
|
|
10339
10369
|
bucketName,
|
|
10340
10370
|
createSegmentProgress(onProgress, start, end),
|
|
10341
|
-
options
|
|
10371
|
+
options,
|
|
10372
|
+
getAuthHeaders
|
|
10342
10373
|
);
|
|
10343
10374
|
imageVariants[variant.kind] = toImageVariantMetadata(variantUpload, variant);
|
|
10344
10375
|
} catch {
|
|
@@ -10355,11 +10386,20 @@ async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, o
|
|
|
10355
10386
|
}
|
|
10356
10387
|
function createFormRuntimeApi(config) {
|
|
10357
10388
|
const { baseUrl = getDefaultBaseUrl(), ...overrides } = config ?? {};
|
|
10358
|
-
const
|
|
10389
|
+
const { fetchImpl, getAuthHeaders } = overrides;
|
|
10390
|
+
const request = overrides.request ?? createDefaultRequest(baseUrl, fetchImpl, getAuthHeaders);
|
|
10359
10391
|
const defaults = {
|
|
10360
10392
|
request,
|
|
10361
10393
|
uploadFile: async (file, bucketName = "files", onProgress, options = {}) => {
|
|
10362
|
-
return uploadFileWithImageVariants(
|
|
10394
|
+
return uploadFileWithImageVariants(
|
|
10395
|
+
request,
|
|
10396
|
+
baseUrl,
|
|
10397
|
+
file,
|
|
10398
|
+
bucketName,
|
|
10399
|
+
onProgress,
|
|
10400
|
+
options,
|
|
10401
|
+
getAuthHeaders
|
|
10402
|
+
);
|
|
10363
10403
|
},
|
|
10364
10404
|
uploadPublicFile: async (file, bucketName = DEFAULT_PUBLIC_FILE_BUCKET, onProgress) => {
|
|
10365
10405
|
if (file.size > CHUNK_UPLOAD_THRESHOLD) {
|
|
@@ -10369,7 +10409,7 @@ function createFormRuntimeApi(config) {
|
|
|
10369
10409
|
}
|
|
10370
10410
|
return uploadWithXhr(baseUrl, file, bucketName, onProgress, {
|
|
10371
10411
|
visibility: "public"
|
|
10372
|
-
});
|
|
10412
|
+
}, getAuthHeaders);
|
|
10373
10413
|
},
|
|
10374
10414
|
deleteFile: async (objectName, bucketName = "files", options = {}) => {
|
|
10375
10415
|
if (options.uploadProvider === "builtin-oss" || options.storageScope === "platform") {
|
|
@@ -12323,6 +12363,60 @@ var unwrap = (response) => {
|
|
|
12323
12363
|
return response;
|
|
12324
12364
|
};
|
|
12325
12365
|
var pickData = (value) => value?.data ?? value?.result ?? value;
|
|
12366
|
+
var normalizePlatformComponentName = (componentName) => {
|
|
12367
|
+
const value = String(componentName || "").trim();
|
|
12368
|
+
return value || "TextField";
|
|
12369
|
+
};
|
|
12370
|
+
var extractSlotNodes = (value) => {
|
|
12371
|
+
if (!value) return [];
|
|
12372
|
+
if (Array.isArray(value)) {
|
|
12373
|
+
return value.flatMap((item) => extractSlotNodes(item));
|
|
12374
|
+
}
|
|
12375
|
+
if (typeof value !== "object") return [];
|
|
12376
|
+
if (value.type === "JSSlot" && value.value) {
|
|
12377
|
+
return extractSlotNodes(value.value);
|
|
12378
|
+
}
|
|
12379
|
+
if (value.componentName || Array.isArray(value.children)) {
|
|
12380
|
+
return [value];
|
|
12381
|
+
}
|
|
12382
|
+
return Object.values(value).flatMap((item) => extractSlotNodes(item));
|
|
12383
|
+
};
|
|
12384
|
+
var extractFieldsFromComponentsTree = (componentsTree) => {
|
|
12385
|
+
const roots = Array.isArray(componentsTree) ? componentsTree : [componentsTree];
|
|
12386
|
+
const fields = [];
|
|
12387
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12388
|
+
const walk = (components) => {
|
|
12389
|
+
if (!Array.isArray(components)) return;
|
|
12390
|
+
components.forEach((component) => {
|
|
12391
|
+
if (!component || typeof component !== "object") return;
|
|
12392
|
+
const props = component.props || {};
|
|
12393
|
+
const fieldId = String(props.fieldId || component.fieldId || component.id || "").trim();
|
|
12394
|
+
if (props.isFormComponent === true && fieldId && !seen.has(fieldId)) {
|
|
12395
|
+
seen.add(fieldId);
|
|
12396
|
+
fields.push({
|
|
12397
|
+
...props,
|
|
12398
|
+
id: props.id || component.id || fieldId,
|
|
12399
|
+
fieldId,
|
|
12400
|
+
componentName: normalizePlatformComponentName(
|
|
12401
|
+
props.componentName || component.componentName
|
|
12402
|
+
),
|
|
12403
|
+
label: props.label || component.title || props.title || fieldId,
|
|
12404
|
+
title: props.title || component.title || props.label || fieldId,
|
|
12405
|
+
required: props.required ?? component.required
|
|
12406
|
+
});
|
|
12407
|
+
}
|
|
12408
|
+
if (component.componentName === "SubFormField") return;
|
|
12409
|
+
if (Array.isArray(component.children)) {
|
|
12410
|
+
walk(component.children);
|
|
12411
|
+
}
|
|
12412
|
+
Object.values(props).forEach((propValue) => {
|
|
12413
|
+
walk(extractSlotNodes(propValue));
|
|
12414
|
+
});
|
|
12415
|
+
});
|
|
12416
|
+
};
|
|
12417
|
+
walk(roots);
|
|
12418
|
+
return fields;
|
|
12419
|
+
};
|
|
12326
12420
|
var normalizeActionSummary = (value) => {
|
|
12327
12421
|
const raw = pickData(value) || {};
|
|
12328
12422
|
const actions = Array.from(
|
|
@@ -12351,6 +12445,11 @@ var normalizeField = (key, field, system = false) => ({
|
|
|
12351
12445
|
width: field?.width,
|
|
12352
12446
|
system
|
|
12353
12447
|
});
|
|
12448
|
+
var createDefaultLayout = (fields) => fields.map((field) => ({
|
|
12449
|
+
id: `layout_${field.fieldId}`,
|
|
12450
|
+
type: "field",
|
|
12451
|
+
fieldId: field.fieldId
|
|
12452
|
+
}));
|
|
12354
12453
|
var SYSTEM_VALUE_ALIASES = {
|
|
12355
12454
|
formInstanceId: ["formInstanceId", "formInstId", "form_instance_id", "processInstanceId"],
|
|
12356
12455
|
instanceTitle: ["instanceTitle", "instance_title", "processInstanceTitle", "title"],
|
|
@@ -12464,20 +12563,25 @@ var BASE_SYSTEM_FIELDS = [
|
|
|
12464
12563
|
)
|
|
12465
12564
|
];
|
|
12466
12565
|
var getSystemFieldsForFormType = (formType) => formType === "process" ? [...BASE_SYSTEM_FIELDS, ...PROCESS_SYSTEM_FIELDS] : BASE_SYSTEM_FIELDS;
|
|
12467
|
-
var normalizeDataManagementFields = (payload) => {
|
|
12566
|
+
var normalizeDataManagementFields = (payload, options = {}) => {
|
|
12468
12567
|
const data = pickData(payload);
|
|
12469
12568
|
const rawSchema = data?.schema || data?.formSchema || data?.publishedSchema || data;
|
|
12470
|
-
const schemaAppType = rawSchema?.formMeta?.appType || data?.appType;
|
|
12471
|
-
const schemaFormUuid = rawSchema?.formMeta?.formUuid || data?.formUuid;
|
|
12472
|
-
const schemaTitle = rawSchema?.formMeta?.title || data?.title || data?.name || data?.formName || schemaFormUuid;
|
|
12473
|
-
const formType = data?.formType || data?.schema?.formType || data?.schema?.template?.formType || rawSchema?.template?.formType || data?.type;
|
|
12474
|
-
const rawFields = data?.formFields || data?.schema?.formFields || data?.fields || data?.schema?.fields || data?.formSchema?.fields || [];
|
|
12475
|
-
const
|
|
12569
|
+
const schemaAppType = rawSchema?.formMeta?.appType || rawSchema?.appType || data?.appType || options.appType;
|
|
12570
|
+
const schemaFormUuid = rawSchema?.formMeta?.formUuid || rawSchema?.formUuid || data?.formUuid || options.formUuid;
|
|
12571
|
+
const schemaTitle = rawSchema?.formMeta?.title || rawSchema?.title || data?.title || data?.name || data?.formName || schemaFormUuid;
|
|
12572
|
+
const formType = data?.formType || data?.schema?.formType || data?.schema?.template?.formType || rawSchema?.formType || rawSchema?.template?.formType || data?.type;
|
|
12573
|
+
const rawFields = data?.formFields || data?.schema?.formFields || rawSchema?.formFields || data?.fields || data?.schema?.fields || data?.formSchema?.fields || rawSchema?.fields || [];
|
|
12574
|
+
const extractedFields = Array.isArray(rawFields) && rawFields.length === 0 && rawSchema?.componentsTree ? extractFieldsFromComponentsTree(rawSchema.componentsTree) : rawFields;
|
|
12575
|
+
const fields = (Array.isArray(extractedFields) ? extractedFields.map((field) => normalizeField(field?.fieldId || field?.id, field)) : Object.entries(extractedFields).map(([key, field]) => normalizeField(key, field))).filter((field) => field.componentName !== "PageSection");
|
|
12576
|
+
const schemaFields = Array.isArray(rawSchema?.fields) ? rawSchema.fields : fields;
|
|
12577
|
+
const hasSchemaFields = Array.isArray(rawSchema?.fields) || fields.length > 0;
|
|
12476
12578
|
return {
|
|
12477
|
-
fields
|
|
12579
|
+
fields,
|
|
12478
12580
|
formType,
|
|
12479
|
-
schema: rawSchema &&
|
|
12581
|
+
schema: rawSchema && hasSchemaFields && schemaAppType && schemaFormUuid ? {
|
|
12480
12582
|
...rawSchema,
|
|
12583
|
+
fields: schemaFields,
|
|
12584
|
+
layout: rawSchema.layout || createDefaultLayout(fields),
|
|
12481
12585
|
formMeta: {
|
|
12482
12586
|
formUuid: schemaFormUuid,
|
|
12483
12587
|
appType: schemaAppType,
|
|
@@ -12568,7 +12672,7 @@ async function getDataManagementSchema(request, params) {
|
|
|
12568
12672
|
method: "get",
|
|
12569
12673
|
params
|
|
12570
12674
|
});
|
|
12571
|
-
const result = normalizeDataManagementFields(response);
|
|
12675
|
+
const result = normalizeDataManagementFields(response, params);
|
|
12572
12676
|
if (result.schema) {
|
|
12573
12677
|
result.schema = {
|
|
12574
12678
|
...result.schema,
|
|
@@ -18465,6 +18569,7 @@ var DataManagementList = ({
|
|
|
18465
18569
|
title,
|
|
18466
18570
|
formTitle,
|
|
18467
18571
|
formType: propFormType,
|
|
18572
|
+
schema: providedSchema,
|
|
18468
18573
|
forcedConfig,
|
|
18469
18574
|
showForcedConfig = true,
|
|
18470
18575
|
detailRenderer,
|
|
@@ -18682,7 +18787,10 @@ var DataManagementList = ({
|
|
|
18682
18787
|
setTotal(0);
|
|
18683
18788
|
setSelectedRowKeys([]);
|
|
18684
18789
|
try {
|
|
18685
|
-
const schemaResult =
|
|
18790
|
+
const schemaResult = providedSchema ? normalizeDataManagementFields(
|
|
18791
|
+
{ appType, formUuid, schema: providedSchema },
|
|
18792
|
+
{ appType, formUuid }
|
|
18793
|
+
) : await getDataManagementSchema(request, { appType, formUuid });
|
|
18686
18794
|
if (!mounted) return;
|
|
18687
18795
|
const allFields = uniqueFields([
|
|
18688
18796
|
...schemaResult.fields,
|
|
@@ -18758,6 +18866,7 @@ var DataManagementList = ({
|
|
|
18758
18866
|
loadData,
|
|
18759
18867
|
menuFormUuid,
|
|
18760
18868
|
propFormType,
|
|
18869
|
+
providedSchema,
|
|
18761
18870
|
request,
|
|
18762
18871
|
title
|
|
18763
18872
|
]);
|