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
|
@@ -10116,7 +10116,31 @@ var parseResponse = async (response) => {
|
|
|
10116
10116
|
message: response.statusText
|
|
10117
10117
|
};
|
|
10118
10118
|
};
|
|
10119
|
-
var
|
|
10119
|
+
var applyAuthHeaders = (headers, getAuthHeaders) => {
|
|
10120
|
+
const authHeaders = getAuthHeaders?.();
|
|
10121
|
+
if (authHeaders) {
|
|
10122
|
+
new Headers(authHeaders).forEach((value, key) => {
|
|
10123
|
+
if (!headers.has(key)) headers.set(key, value);
|
|
10124
|
+
});
|
|
10125
|
+
}
|
|
10126
|
+
const token = typeof window !== "undefined" ? window.localStorage?.getItem("token") : void 0;
|
|
10127
|
+
if (token && !headers.has("authorization")) {
|
|
10128
|
+
headers.set("authorization", token);
|
|
10129
|
+
}
|
|
10130
|
+
};
|
|
10131
|
+
var applyXhrAuthHeaders = (xhr, getAuthHeaders) => {
|
|
10132
|
+
let hasAuthorization = false;
|
|
10133
|
+
const authHeaders = getAuthHeaders?.();
|
|
10134
|
+
if (authHeaders) {
|
|
10135
|
+
new Headers(authHeaders).forEach((value, key) => {
|
|
10136
|
+
if (key.toLowerCase() === "authorization") hasAuthorization = true;
|
|
10137
|
+
xhr.setRequestHeader(key, value);
|
|
10138
|
+
});
|
|
10139
|
+
}
|
|
10140
|
+
const token = typeof window !== "undefined" ? window.localStorage?.getItem("token") : void 0;
|
|
10141
|
+
if (token && !hasAuthorization) xhr.setRequestHeader("authorization", token);
|
|
10142
|
+
};
|
|
10143
|
+
var createDefaultRequest = (baseUrl, fetchImpl = fetch, getAuthHeaders) => async (config) => {
|
|
10120
10144
|
const method = config.method ?? "get";
|
|
10121
10145
|
const url = appendQuery(joinUrl(baseUrl, config.url), config.params);
|
|
10122
10146
|
const headers = new Headers(config.headers);
|
|
@@ -10129,11 +10153,8 @@ var createDefaultRequest = (baseUrl) => async (config) => {
|
|
|
10129
10153
|
body = JSON.stringify(config.data);
|
|
10130
10154
|
}
|
|
10131
10155
|
}
|
|
10132
|
-
|
|
10133
|
-
|
|
10134
|
-
headers.set("authorization", token);
|
|
10135
|
-
}
|
|
10136
|
-
const response = await fetch(url, {
|
|
10156
|
+
applyAuthHeaders(headers, getAuthHeaders);
|
|
10157
|
+
const response = await fetchImpl(url, {
|
|
10137
10158
|
method,
|
|
10138
10159
|
headers,
|
|
10139
10160
|
body,
|
|
@@ -10201,7 +10222,7 @@ var normalizeUploadData = (data, file, bucketName, baseUrl = "") => {
|
|
|
10201
10222
|
variants
|
|
10202
10223
|
};
|
|
10203
10224
|
};
|
|
10204
|
-
var uploadWithXhr = (baseUrl, file, bucketName, onProgress, options = {}) => new Promise((resolve, reject) => {
|
|
10225
|
+
var uploadWithXhr = (baseUrl, file, bucketName, onProgress, options = {}, getAuthHeaders) => new Promise((resolve, reject) => {
|
|
10205
10226
|
if (globalThis.process?.env?.VITEST) {
|
|
10206
10227
|
onProgress?.(100);
|
|
10207
10228
|
resolve({
|
|
@@ -10231,8 +10252,7 @@ var uploadWithXhr = (baseUrl, file, bucketName, onProgress, options = {}) => new
|
|
|
10231
10252
|
)
|
|
10232
10253
|
);
|
|
10233
10254
|
xhr.withCredentials = true;
|
|
10234
|
-
|
|
10235
|
-
if (token) xhr.setRequestHeader("authorization", token);
|
|
10255
|
+
applyXhrAuthHeaders(xhr, getAuthHeaders);
|
|
10236
10256
|
xhr.upload.onprogress = (event) => {
|
|
10237
10257
|
if (event.lengthComputable) {
|
|
10238
10258
|
onProgress?.(Math.round(event.loaded / event.total * 100));
|
|
@@ -10336,7 +10356,8 @@ async function uploadChunkedFile(request, file, bucketName, baseUrl, onProgress,
|
|
|
10336
10356
|
fileSize: file.size,
|
|
10337
10357
|
chunkSize: DEFAULT_CHUNK_SIZE,
|
|
10338
10358
|
bucketName,
|
|
10339
|
-
visibility: options.visibility
|
|
10359
|
+
visibility: options.visibility,
|
|
10360
|
+
contentType: file.type || void 0
|
|
10340
10361
|
}
|
|
10341
10362
|
});
|
|
10342
10363
|
const uploadInfo = initiate.data || initiate.result;
|
|
@@ -10395,7 +10416,7 @@ var createSegmentProgress = (onProgress, start, end) => (percent) => {
|
|
|
10395
10416
|
onProgress?.(Math.round(next));
|
|
10396
10417
|
};
|
|
10397
10418
|
var getAttachmentUrl = (item) => item.publicUrl || item.previewUrl || item.downloadUrl || item.url || "";
|
|
10398
|
-
async function uploadSingleRuntimeFile(request, baseUrl, file, bucketName, onProgress, options) {
|
|
10419
|
+
async function uploadSingleRuntimeFile(request, baseUrl, file, bucketName, onProgress, options, getAuthHeaders) {
|
|
10399
10420
|
const singleOptions = stripImageCompressionOptions(options);
|
|
10400
10421
|
if (singleOptions.uploadProvider === "builtin-oss") {
|
|
10401
10422
|
return uploadBuiltinOssFile(request, file, bucketName, onProgress, singleOptions);
|
|
@@ -10406,7 +10427,7 @@ async function uploadSingleRuntimeFile(request, baseUrl, file, bucketName, onPro
|
|
|
10406
10427
|
if (file.size > CHUNK_UPLOAD_THRESHOLD) {
|
|
10407
10428
|
return uploadChunkedFile(request, file, bucketName, baseUrl, onProgress);
|
|
10408
10429
|
}
|
|
10409
|
-
return uploadWithXhr(baseUrl, file, bucketName, onProgress);
|
|
10430
|
+
return uploadWithXhr(baseUrl, file, bucketName, onProgress, {}, getAuthHeaders);
|
|
10410
10431
|
}
|
|
10411
10432
|
function toImageVariantMetadata(uploaded, variant) {
|
|
10412
10433
|
return {
|
|
@@ -10420,7 +10441,7 @@ function toImageVariantMetadata(uploaded, variant) {
|
|
|
10420
10441
|
quality: variant.quality
|
|
10421
10442
|
};
|
|
10422
10443
|
}
|
|
10423
|
-
async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, onProgress, options) {
|
|
10444
|
+
async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, onProgress, options, getAuthHeaders) {
|
|
10424
10445
|
let variants = [];
|
|
10425
10446
|
try {
|
|
10426
10447
|
variants = await createCompressedImageVariants(file, options.imageCompression);
|
|
@@ -10428,7 +10449,15 @@ async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, o
|
|
|
10428
10449
|
variants = [];
|
|
10429
10450
|
}
|
|
10430
10451
|
if (variants.length === 0) {
|
|
10431
|
-
return uploadSingleRuntimeFile(
|
|
10452
|
+
return uploadSingleRuntimeFile(
|
|
10453
|
+
request,
|
|
10454
|
+
baseUrl,
|
|
10455
|
+
file,
|
|
10456
|
+
bucketName,
|
|
10457
|
+
onProgress,
|
|
10458
|
+
options,
|
|
10459
|
+
getAuthHeaders
|
|
10460
|
+
);
|
|
10432
10461
|
}
|
|
10433
10462
|
const originalProgressEnd = 70;
|
|
10434
10463
|
const uploaded = await uploadSingleRuntimeFile(
|
|
@@ -10437,7 +10466,8 @@ async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, o
|
|
|
10437
10466
|
file,
|
|
10438
10467
|
bucketName,
|
|
10439
10468
|
createSegmentProgress(onProgress, 0, originalProgressEnd),
|
|
10440
|
-
options
|
|
10469
|
+
options,
|
|
10470
|
+
getAuthHeaders
|
|
10441
10471
|
);
|
|
10442
10472
|
const imageVariants = { ...uploaded.variants || {} };
|
|
10443
10473
|
const variantProgressStep = (100 - originalProgressEnd) / variants.length;
|
|
@@ -10452,7 +10482,8 @@ async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, o
|
|
|
10452
10482
|
variant.file,
|
|
10453
10483
|
bucketName,
|
|
10454
10484
|
createSegmentProgress(onProgress, start, end),
|
|
10455
|
-
options
|
|
10485
|
+
options,
|
|
10486
|
+
getAuthHeaders
|
|
10456
10487
|
);
|
|
10457
10488
|
imageVariants[variant.kind] = toImageVariantMetadata(variantUpload, variant);
|
|
10458
10489
|
} catch {
|
|
@@ -10469,11 +10500,20 @@ async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, o
|
|
|
10469
10500
|
}
|
|
10470
10501
|
function createFormRuntimeApi(config) {
|
|
10471
10502
|
const { baseUrl = getDefaultBaseUrl(), ...overrides } = config ?? {};
|
|
10472
|
-
const
|
|
10503
|
+
const { fetchImpl, getAuthHeaders } = overrides;
|
|
10504
|
+
const request = overrides.request ?? createDefaultRequest(baseUrl, fetchImpl, getAuthHeaders);
|
|
10473
10505
|
const defaults = {
|
|
10474
10506
|
request,
|
|
10475
10507
|
uploadFile: async (file, bucketName = "files", onProgress, options = {}) => {
|
|
10476
|
-
return uploadFileWithImageVariants(
|
|
10508
|
+
return uploadFileWithImageVariants(
|
|
10509
|
+
request,
|
|
10510
|
+
baseUrl,
|
|
10511
|
+
file,
|
|
10512
|
+
bucketName,
|
|
10513
|
+
onProgress,
|
|
10514
|
+
options,
|
|
10515
|
+
getAuthHeaders
|
|
10516
|
+
);
|
|
10477
10517
|
},
|
|
10478
10518
|
uploadPublicFile: async (file, bucketName = DEFAULT_PUBLIC_FILE_BUCKET, onProgress) => {
|
|
10479
10519
|
if (file.size > CHUNK_UPLOAD_THRESHOLD) {
|
|
@@ -10483,7 +10523,7 @@ function createFormRuntimeApi(config) {
|
|
|
10483
10523
|
}
|
|
10484
10524
|
return uploadWithXhr(baseUrl, file, bucketName, onProgress, {
|
|
10485
10525
|
visibility: "public"
|
|
10486
|
-
});
|
|
10526
|
+
}, getAuthHeaders);
|
|
10487
10527
|
},
|
|
10488
10528
|
deleteFile: async (objectName, bucketName = "files", options = {}) => {
|
|
10489
10529
|
if (options.uploadProvider === "builtin-oss" || options.storageScope === "platform") {
|
|
@@ -12432,6 +12472,60 @@ var unwrap = (response) => {
|
|
|
12432
12472
|
return response;
|
|
12433
12473
|
};
|
|
12434
12474
|
var pickData = (value) => value?.data ?? value?.result ?? value;
|
|
12475
|
+
var normalizePlatformComponentName = (componentName) => {
|
|
12476
|
+
const value = String(componentName || "").trim();
|
|
12477
|
+
return value || "TextField";
|
|
12478
|
+
};
|
|
12479
|
+
var extractSlotNodes = (value) => {
|
|
12480
|
+
if (!value) return [];
|
|
12481
|
+
if (Array.isArray(value)) {
|
|
12482
|
+
return value.flatMap((item) => extractSlotNodes(item));
|
|
12483
|
+
}
|
|
12484
|
+
if (typeof value !== "object") return [];
|
|
12485
|
+
if (value.type === "JSSlot" && value.value) {
|
|
12486
|
+
return extractSlotNodes(value.value);
|
|
12487
|
+
}
|
|
12488
|
+
if (value.componentName || Array.isArray(value.children)) {
|
|
12489
|
+
return [value];
|
|
12490
|
+
}
|
|
12491
|
+
return Object.values(value).flatMap((item) => extractSlotNodes(item));
|
|
12492
|
+
};
|
|
12493
|
+
var extractFieldsFromComponentsTree = (componentsTree) => {
|
|
12494
|
+
const roots = Array.isArray(componentsTree) ? componentsTree : [componentsTree];
|
|
12495
|
+
const fields = [];
|
|
12496
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12497
|
+
const walk = (components) => {
|
|
12498
|
+
if (!Array.isArray(components)) return;
|
|
12499
|
+
components.forEach((component) => {
|
|
12500
|
+
if (!component || typeof component !== "object") return;
|
|
12501
|
+
const props = component.props || {};
|
|
12502
|
+
const fieldId = String(props.fieldId || component.fieldId || component.id || "").trim();
|
|
12503
|
+
if (props.isFormComponent === true && fieldId && !seen.has(fieldId)) {
|
|
12504
|
+
seen.add(fieldId);
|
|
12505
|
+
fields.push({
|
|
12506
|
+
...props,
|
|
12507
|
+
id: props.id || component.id || fieldId,
|
|
12508
|
+
fieldId,
|
|
12509
|
+
componentName: normalizePlatformComponentName(
|
|
12510
|
+
props.componentName || component.componentName
|
|
12511
|
+
),
|
|
12512
|
+
label: props.label || component.title || props.title || fieldId,
|
|
12513
|
+
title: props.title || component.title || props.label || fieldId,
|
|
12514
|
+
required: props.required ?? component.required
|
|
12515
|
+
});
|
|
12516
|
+
}
|
|
12517
|
+
if (component.componentName === "SubFormField") return;
|
|
12518
|
+
if (Array.isArray(component.children)) {
|
|
12519
|
+
walk(component.children);
|
|
12520
|
+
}
|
|
12521
|
+
Object.values(props).forEach((propValue) => {
|
|
12522
|
+
walk(extractSlotNodes(propValue));
|
|
12523
|
+
});
|
|
12524
|
+
});
|
|
12525
|
+
};
|
|
12526
|
+
walk(roots);
|
|
12527
|
+
return fields;
|
|
12528
|
+
};
|
|
12435
12529
|
var normalizeActionSummary = (value) => {
|
|
12436
12530
|
const raw = pickData(value) || {};
|
|
12437
12531
|
const actions = Array.from(
|
|
@@ -12460,6 +12554,11 @@ var normalizeField = (key, field, system = false) => ({
|
|
|
12460
12554
|
width: field?.width,
|
|
12461
12555
|
system
|
|
12462
12556
|
});
|
|
12557
|
+
var createDefaultLayout = (fields) => fields.map((field) => ({
|
|
12558
|
+
id: `layout_${field.fieldId}`,
|
|
12559
|
+
type: "field",
|
|
12560
|
+
fieldId: field.fieldId
|
|
12561
|
+
}));
|
|
12463
12562
|
var SYSTEM_VALUE_ALIASES = {
|
|
12464
12563
|
formInstanceId: ["formInstanceId", "formInstId", "form_instance_id", "processInstanceId"],
|
|
12465
12564
|
instanceTitle: ["instanceTitle", "instance_title", "processInstanceTitle", "title"],
|
|
@@ -12573,20 +12672,25 @@ var BASE_SYSTEM_FIELDS = [
|
|
|
12573
12672
|
)
|
|
12574
12673
|
];
|
|
12575
12674
|
var getSystemFieldsForFormType = (formType) => formType === "process" ? [...BASE_SYSTEM_FIELDS, ...PROCESS_SYSTEM_FIELDS] : BASE_SYSTEM_FIELDS;
|
|
12576
|
-
var normalizeDataManagementFields = (payload) => {
|
|
12675
|
+
var normalizeDataManagementFields = (payload, options = {}) => {
|
|
12577
12676
|
const data = pickData(payload);
|
|
12578
12677
|
const rawSchema = data?.schema || data?.formSchema || data?.publishedSchema || data;
|
|
12579
|
-
const schemaAppType = rawSchema?.formMeta?.appType || data?.appType;
|
|
12580
|
-
const schemaFormUuid = rawSchema?.formMeta?.formUuid || data?.formUuid;
|
|
12581
|
-
const schemaTitle = rawSchema?.formMeta?.title || data?.title || data?.name || data?.formName || schemaFormUuid;
|
|
12582
|
-
const formType = data?.formType || data?.schema?.formType || data?.schema?.template?.formType || rawSchema?.template?.formType || data?.type;
|
|
12583
|
-
const rawFields = data?.formFields || data?.schema?.formFields || data?.fields || data?.schema?.fields || data?.formSchema?.fields || [];
|
|
12584
|
-
const
|
|
12678
|
+
const schemaAppType = rawSchema?.formMeta?.appType || rawSchema?.appType || data?.appType || options.appType;
|
|
12679
|
+
const schemaFormUuid = rawSchema?.formMeta?.formUuid || rawSchema?.formUuid || data?.formUuid || options.formUuid;
|
|
12680
|
+
const schemaTitle = rawSchema?.formMeta?.title || rawSchema?.title || data?.title || data?.name || data?.formName || schemaFormUuid;
|
|
12681
|
+
const formType = data?.formType || data?.schema?.formType || data?.schema?.template?.formType || rawSchema?.formType || rawSchema?.template?.formType || data?.type;
|
|
12682
|
+
const rawFields = data?.formFields || data?.schema?.formFields || rawSchema?.formFields || data?.fields || data?.schema?.fields || data?.formSchema?.fields || rawSchema?.fields || [];
|
|
12683
|
+
const extractedFields = Array.isArray(rawFields) && rawFields.length === 0 && rawSchema?.componentsTree ? extractFieldsFromComponentsTree(rawSchema.componentsTree) : rawFields;
|
|
12684
|
+
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");
|
|
12685
|
+
const schemaFields = Array.isArray(rawSchema?.fields) ? rawSchema.fields : fields;
|
|
12686
|
+
const hasSchemaFields = Array.isArray(rawSchema?.fields) || fields.length > 0;
|
|
12585
12687
|
return {
|
|
12586
|
-
fields
|
|
12688
|
+
fields,
|
|
12587
12689
|
formType,
|
|
12588
|
-
schema: rawSchema &&
|
|
12690
|
+
schema: rawSchema && hasSchemaFields && schemaAppType && schemaFormUuid ? {
|
|
12589
12691
|
...rawSchema,
|
|
12692
|
+
fields: schemaFields,
|
|
12693
|
+
layout: rawSchema.layout || createDefaultLayout(fields),
|
|
12590
12694
|
formMeta: {
|
|
12591
12695
|
formUuid: schemaFormUuid,
|
|
12592
12696
|
appType: schemaAppType,
|
|
@@ -12677,7 +12781,7 @@ async function getDataManagementSchema(request, params) {
|
|
|
12677
12781
|
method: "get",
|
|
12678
12782
|
params
|
|
12679
12783
|
});
|
|
12680
|
-
const result = normalizeDataManagementFields(response);
|
|
12784
|
+
const result = normalizeDataManagementFields(response, params);
|
|
12681
12785
|
if (result.schema) {
|
|
12682
12786
|
result.schema = {
|
|
12683
12787
|
...result.schema,
|
|
@@ -18515,6 +18619,7 @@ var DataManagementList = ({
|
|
|
18515
18619
|
title,
|
|
18516
18620
|
formTitle,
|
|
18517
18621
|
formType: propFormType,
|
|
18622
|
+
schema: providedSchema,
|
|
18518
18623
|
forcedConfig,
|
|
18519
18624
|
showForcedConfig = true,
|
|
18520
18625
|
detailRenderer,
|
|
@@ -18732,7 +18837,10 @@ var DataManagementList = ({
|
|
|
18732
18837
|
setTotal(0);
|
|
18733
18838
|
setSelectedRowKeys([]);
|
|
18734
18839
|
try {
|
|
18735
|
-
const schemaResult =
|
|
18840
|
+
const schemaResult = providedSchema ? normalizeDataManagementFields(
|
|
18841
|
+
{ appType, formUuid, schema: providedSchema },
|
|
18842
|
+
{ appType, formUuid }
|
|
18843
|
+
) : await getDataManagementSchema(request, { appType, formUuid });
|
|
18736
18844
|
if (!mounted) return;
|
|
18737
18845
|
const allFields = uniqueFields([
|
|
18738
18846
|
...schemaResult.fields,
|
|
@@ -18808,6 +18916,7 @@ var DataManagementList = ({
|
|
|
18808
18916
|
loadData,
|
|
18809
18917
|
menuFormUuid,
|
|
18810
18918
|
propFormType,
|
|
18919
|
+
providedSchema,
|
|
18811
18920
|
request,
|
|
18812
18921
|
title
|
|
18813
18922
|
]);
|