openxiangda 1.0.118 → 1.0.119
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/lib/cli.js +299 -1
- package/lib/workspace-init.js +1 -0
- package/openxiangda-skills/references/component-guide.md +8 -7
- package/openxiangda-skills/references/forms/component-registry.md +1 -0
- package/openxiangda-skills/references/platform-data-model.md +2 -2
- package/openxiangda-skills/references/resource-manifest-cheatsheet.md +39 -0
- package/package.json +1 -1
- package/packages/sdk/dist/{ProcessPreview-Cw7X8odD.d.mts → ProcessPreview-CFmuu427.d.mts} +13 -3
- package/packages/sdk/dist/{ProcessPreview-Cw7X8odD.d.ts → ProcessPreview-CFmuu427.d.ts} +13 -3
- package/packages/sdk/dist/components/index.cjs +134 -11
- package/packages/sdk/dist/components/index.cjs.map +1 -1
- package/packages/sdk/dist/components/index.d.mts +2 -2
- package/packages/sdk/dist/components/index.d.ts +2 -2
- package/packages/sdk/dist/components/index.mjs +134 -11
- package/packages/sdk/dist/components/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/index.cjs +134 -11
- 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 +134 -11
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/react.d.mts +1 -1
- package/packages/sdk/dist/runtime/react.d.ts +1 -1
- package/packages/sdk/src/build-source/scripts/utils/form-api.mjs +1 -0
|
@@ -252,11 +252,16 @@ interface RuntimeRequestConfig {
|
|
|
252
252
|
headers?: Record<string, string>;
|
|
253
253
|
responseType?: 'json' | 'blob';
|
|
254
254
|
}
|
|
255
|
+
interface RuntimeUploadOptions {
|
|
256
|
+
uploadProvider?: 'platform' | 'oss';
|
|
257
|
+
storageCode?: string;
|
|
258
|
+
appType?: string;
|
|
259
|
+
}
|
|
255
260
|
interface FormRuntimeApi {
|
|
256
261
|
request: <T = any>(config: RuntimeRequestConfig) => Promise<RuntimeResponse<T> | Blob>;
|
|
257
|
-
uploadFile: (file: File, bucketName?: string, onProgress?: (percent: number) => void) => Promise<AttachmentItem>;
|
|
262
|
+
uploadFile: (file: File, bucketName?: string, onProgress?: (percent: number) => void, options?: RuntimeUploadOptions) => Promise<AttachmentItem>;
|
|
258
263
|
uploadPublicFile: (file: File, bucketName?: string, onProgress?: (percent: number) => void) => Promise<AttachmentItem>;
|
|
259
|
-
deleteFile: (objectName: string, bucketName?: string) => Promise<{
|
|
264
|
+
deleteFile: (objectName: string, bucketName?: string, options?: RuntimeUploadOptions) => Promise<{
|
|
260
265
|
success: boolean;
|
|
261
266
|
}>;
|
|
262
267
|
createDownloadTicket: (bucketName: string, objectName: string, fileName?: string) => Promise<any>;
|
|
@@ -571,6 +576,9 @@ interface AttachmentItem {
|
|
|
571
576
|
id: string;
|
|
572
577
|
uid?: string;
|
|
573
578
|
status?: 'uploading' | 'done' | 'error';
|
|
579
|
+
provider?: 'platform' | 'oss';
|
|
580
|
+
storageCode?: string;
|
|
581
|
+
appType?: string;
|
|
574
582
|
objectName?: string;
|
|
575
583
|
bucketName?: string;
|
|
576
584
|
originalName?: string;
|
|
@@ -593,6 +601,8 @@ interface AttachmentFieldProps extends BaseFieldProps {
|
|
|
593
601
|
maxSize?: number;
|
|
594
602
|
uploadAction?: string;
|
|
595
603
|
bucketName?: string;
|
|
604
|
+
uploadProvider?: 'platform' | 'oss';
|
|
605
|
+
storageCode?: string;
|
|
596
606
|
multiple?: boolean;
|
|
597
607
|
allowedTypes?: string[];
|
|
598
608
|
showPreview?: boolean;
|
|
@@ -1095,4 +1105,4 @@ interface ProcessPreviewProps {
|
|
|
1095
1105
|
}
|
|
1096
1106
|
declare const ProcessPreview: React__default.FC<ProcessPreviewProps>;
|
|
1097
1107
|
|
|
1098
|
-
export { type FormRuntimeConfig as $, type AddressFieldProps as A, type BaseFieldProps as B, type CascadeDateFieldProps as C, type DataFilter as D, type DepartmentTreeNode as E, type DigitalSignatureFieldProps as F, type DigitalSignatureValue as G, type EditorChoiceOption as H, type EditorFieldProps as I, type EditorToolbarAction as J, type FieldBehavior as K, type FieldDefinition as L, type FieldLayoutNode as M, type FieldValueSyncConfig as N, type FormAppearanceConfig as O, type FormDataDeleteParams as P, type FormDataQueryParams as Q, type FormEffect as R, type FormEffectAction as S, type FormEffectCondition as T, type FormEffectConditionOperator as U, type FormEngineConfig as V, type FormEngineMode as W, type FormInstanceData as X, type FormLayoutNode as Y, type FormRuntimeApi as Z, type FormRuntimeApiConfig as _, type AddressValue as a, type
|
|
1108
|
+
export { type FormRuntimeConfig as $, type AddressFieldProps as A, type BaseFieldProps as B, type CascadeDateFieldProps as C, type DataFilter as D, type DepartmentTreeNode as E, type DigitalSignatureFieldProps as F, type DigitalSignatureValue as G, type EditorChoiceOption as H, type EditorFieldProps as I, type EditorToolbarAction as J, type FieldBehavior as K, type FieldDefinition as L, type FieldLayoutNode as M, type FieldValueSyncConfig as N, type FormAppearanceConfig as O, type FormDataDeleteParams as P, type FormDataQueryParams as Q, type FormEffect as R, type FormEffectAction as S, type FormEffectCondition as T, type FormEffectConditionOperator as U, type FormEngineConfig as V, type FormEngineMode as W, type FormInstanceData as X, type FormLayoutNode as Y, type FormRuntimeApi as Z, type FormRuntimeApiConfig as _, type AddressValue as a, type TextAreaFieldProps as a$, type FormSchema as a0, FormSection as a1, type FormSectionProps as a2, type FormSubmitBehavior as a3, type FormTemplateConfig as a4, type GridLayoutCell as a5, type GridLayoutNode as a6, type ImageFieldProps as a7, type InitiatorSelectCandidate as a8, type InitiatorSelectRequirement as a9, type ProcessStatus as aA, type ProcessTask as aB, type RadioFieldProps as aC, type ResubmitParams as aD, type ReturnParams as aE, type ReturnPolicy as aF, type ReturnableNode as aG, type ReturnableNodeResult as aH, type RuntimeDataQueryParams as aI, type RuntimeDataQueryResult as aJ, type RuntimeRequestConfig as aK, type RuntimeResponse as aL, type RuntimeUploadOptions as aM, type SaveTaskParams as aN, type SectionLayoutNode as aO, type SelectFieldProps as aP, type SerialNumberFieldProps as aQ, type SignaturePoint as aR, type StandardFormPageMode as aS, type StatusMeta as aT, type StepLayoutItem as aU, type StepsLayoutNode as aV, type SubFormColumn as aW, type SubFormFieldProps as aX, type TabLayoutItem as aY, type TabsLayoutNode as aZ, type TaskStatus as a_, type InitiatorSelectScope as aa, type InitiatorSelectedApprovers as ab, type JSONFieldProps as ac, type LayoutVisibleWhen as ad, type LinkedFormOptionConfig as ae, type LocationFieldProps as af, type LocationValue as ag, type LowcodePageMeta as ah, type LowcodePageNode as ai, type LowcodePageNodeType as aj, type LowcodePageSchema as ak, type MultiSelectFieldProps as al, type NumberFieldProps as am, type OptionItem as an, type OptionSourceConfig as ao, type OptionSourceType as ap, type PeopleShortcutConfig as aq, type PeopleShortcutType as ar, type PreviewParams as as, type ProcessAction as at, type ProcessBasicInfo as au, type ProcessDefinition as av, type ProcessNodeType as aw, ProcessPreview as ax, type ProcessPreviewProps as ay, type ProcessRoute as az, type ApprovalActionType as b, type TextFieldProps as b0, type TextShortcutConfig as b1, type TextShortcutType as b2, type TransferParams as b3, type UserDisplayFormat as b4, type UserItem as b5, type UserSelectFieldProps as b6, type ValidationPreset as b7, type ValidationRule as b8, type ViewPermissionQueryParams as b9, type ViewPermissionSummary as ba, type WithdrawParams as bb, type ApprovalPermission as c, ApprovalTimeline as d, type ApprovalTimelineProps as e, type ApproveParams as f, type AssociationFormConfig as g, type AssociationFormFieldProps as h, type AssociationValue as i, type AttachmentFieldProps as j, type AttachmentItem as k, type BaseLayoutNode as l, type CascadeSelectFieldProps as m, type ChangeRecord as n, type ChangeRecordListResponse as o, type ChangeRecordQueryParams as p, type CheckboxFieldProps as q, type DataLinkageCondition as r, type DataLinkageConfig as s, type DateFieldProps as t, type DateRangeRestriction as u, type DateRestrictionConfig as v, type DateShortcutConfig as w, type DateShortcutType as x, type DefaultValueLinkageConfig as y, type DepartmentSelectFieldProps as z };
|
|
@@ -32925,6 +32925,8 @@ function AttachmentFieldPC({
|
|
|
32925
32925
|
accept,
|
|
32926
32926
|
maxSize,
|
|
32927
32927
|
bucketName = "attachments",
|
|
32928
|
+
uploadProvider,
|
|
32929
|
+
storageCode,
|
|
32928
32930
|
multiple = true,
|
|
32929
32931
|
allowedTypes,
|
|
32930
32932
|
showPreview = true,
|
|
@@ -32934,7 +32936,7 @@ function AttachmentFieldPC({
|
|
|
32934
32936
|
previewPagePath = "/file-preview",
|
|
32935
32937
|
onChange
|
|
32936
32938
|
}) {
|
|
32937
|
-
const { formData, setFieldValue, api } = useFormContext();
|
|
32939
|
+
const { formData, setFieldValue, api, config: config3 } = useFormContext();
|
|
32938
32940
|
const value = import_react223.default.useMemo(
|
|
32939
32941
|
() => dedupeAttachmentItems(
|
|
32940
32942
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
@@ -32943,6 +32945,14 @@ function AttachmentFieldPC({
|
|
|
32943
32945
|
);
|
|
32944
32946
|
const valueRef = import_react223.default.useRef(value);
|
|
32945
32947
|
const disabled = behavior === "DISABLED";
|
|
32948
|
+
const fieldUploadProvider = uploadProvider || (storageCode ? "oss" : "platform");
|
|
32949
|
+
const fieldUploadOptions = fieldUploadProvider === "oss" ? { uploadProvider: "oss", storageCode, appType: config3.appType } : void 0;
|
|
32950
|
+
const getItemUploadOptions = (item) => item.provider === "oss" || item.storageCode ? {
|
|
32951
|
+
uploadProvider: "oss",
|
|
32952
|
+
storageCode: item.storageCode || storageCode,
|
|
32953
|
+
appType: item.appType || config3.appType
|
|
32954
|
+
} : void 0;
|
|
32955
|
+
const isDirectStorageItem2 = (item) => item.provider === "oss" || Boolean(item.storageCode);
|
|
32946
32956
|
import_react223.default.useEffect(() => {
|
|
32947
32957
|
valueRef.current = value;
|
|
32948
32958
|
}, [value]);
|
|
@@ -32978,10 +32988,15 @@ function AttachmentFieldPC({
|
|
|
32978
32988
|
);
|
|
32979
32989
|
setValue(newValue);
|
|
32980
32990
|
if (removed?.objectName) {
|
|
32981
|
-
|
|
32991
|
+
const options = getItemUploadOptions(removed);
|
|
32992
|
+
const deletePromise = options ? api.deleteFile(removed.objectName, removed.bucketName || bucketName, options) : api.deleteFile(removed.objectName, removed.bucketName || bucketName);
|
|
32993
|
+
deletePromise.catch(() => void 0);
|
|
32982
32994
|
}
|
|
32983
32995
|
};
|
|
32984
32996
|
const resolvePreviewUrl = async (item) => {
|
|
32997
|
+
if (isDirectStorageItem2(item)) {
|
|
32998
|
+
return item.previewUrl || item.publicUrl || item.url || "";
|
|
32999
|
+
}
|
|
32985
33000
|
if (item.objectName) {
|
|
32986
33001
|
const ticket = await api.createFileAccessTicket(
|
|
32987
33002
|
item.bucketName || bucketName,
|
|
@@ -33003,6 +33018,9 @@ function AttachmentFieldPC({
|
|
|
33003
33018
|
return item.previewUrl || item.url || "";
|
|
33004
33019
|
};
|
|
33005
33020
|
const resolveDownloadUrl = async (item) => {
|
|
33021
|
+
if (isDirectStorageItem2(item)) {
|
|
33022
|
+
return item.downloadUrl || item.publicUrl || item.url || "";
|
|
33023
|
+
}
|
|
33006
33024
|
if (item.objectName) {
|
|
33007
33025
|
const ticket = await api.createDownloadTicket(
|
|
33008
33026
|
item.bucketName || bucketName,
|
|
@@ -33045,10 +33063,11 @@ function AttachmentFieldPC({
|
|
|
33045
33063
|
const nextValue = multiple ? [...currentValue, localItem] : [localItem];
|
|
33046
33064
|
setValue(nextValue);
|
|
33047
33065
|
try {
|
|
33048
|
-
const
|
|
33066
|
+
const handleProgress = (percent) => {
|
|
33049
33067
|
callbacks?.onProgress?.({ percent });
|
|
33050
33068
|
replaceItem(localItem, { ...localItem, percent, status: "uploading" });
|
|
33051
|
-
}
|
|
33069
|
+
};
|
|
33070
|
+
const uploaded = fieldUploadOptions ? await api.uploadFile(currentFile, bucketName, handleProgress, fieldUploadOptions) : await api.uploadFile(currentFile, bucketName, handleProgress);
|
|
33052
33071
|
const completed = normalizeAttachmentItem(
|
|
33053
33072
|
{
|
|
33054
33073
|
...uploaded,
|
|
@@ -33242,6 +33261,8 @@ function AttachmentFieldMobile({
|
|
|
33242
33261
|
accept,
|
|
33243
33262
|
maxSize,
|
|
33244
33263
|
bucketName = "attachments",
|
|
33264
|
+
uploadProvider,
|
|
33265
|
+
storageCode,
|
|
33245
33266
|
multiple = true,
|
|
33246
33267
|
allowedTypes,
|
|
33247
33268
|
showPreview = true,
|
|
@@ -33251,7 +33272,7 @@ function AttachmentFieldMobile({
|
|
|
33251
33272
|
previewPagePath = "/file-preview",
|
|
33252
33273
|
onChange
|
|
33253
33274
|
}) {
|
|
33254
|
-
const { formData, setFieldValue, api } = useFormContext();
|
|
33275
|
+
const { formData, setFieldValue, api, config: config3 } = useFormContext();
|
|
33255
33276
|
const value = import_react224.default.useMemo(
|
|
33256
33277
|
() => dedupeAttachmentItems(
|
|
33257
33278
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
@@ -33261,6 +33282,14 @@ function AttachmentFieldMobile({
|
|
|
33261
33282
|
const valueRef = import_react224.default.useRef(value);
|
|
33262
33283
|
const inputRef = import_react224.default.useRef(null);
|
|
33263
33284
|
const disabled = behavior === "DISABLED";
|
|
33285
|
+
const fieldUploadProvider = uploadProvider || (storageCode ? "oss" : "platform");
|
|
33286
|
+
const fieldUploadOptions = fieldUploadProvider === "oss" ? { uploadProvider: "oss", storageCode, appType: config3.appType } : void 0;
|
|
33287
|
+
const getItemUploadOptions = (item) => item.provider === "oss" || item.storageCode ? {
|
|
33288
|
+
uploadProvider: "oss",
|
|
33289
|
+
storageCode: item.storageCode || storageCode,
|
|
33290
|
+
appType: item.appType || config3.appType
|
|
33291
|
+
} : void 0;
|
|
33292
|
+
const isDirectStorageItem2 = (item) => item.provider === "oss" || Boolean(item.storageCode);
|
|
33264
33293
|
import_react224.default.useEffect(() => {
|
|
33265
33294
|
valueRef.current = value;
|
|
33266
33295
|
}, [value]);
|
|
@@ -33301,9 +33330,11 @@ function AttachmentFieldMobile({
|
|
|
33301
33330
|
setValue(multiple ? [...valueRef.current, ...localItems] : localItems.slice(0, 1));
|
|
33302
33331
|
files.forEach((file, index2) => {
|
|
33303
33332
|
const localItem = localItems[index2];
|
|
33304
|
-
|
|
33333
|
+
const handleProgress = (percent) => {
|
|
33305
33334
|
replaceItem(localItem, { ...localItem, percent, status: "uploading" });
|
|
33306
|
-
}
|
|
33335
|
+
};
|
|
33336
|
+
const uploadPromise = fieldUploadOptions ? api.uploadFile(file, bucketName, handleProgress, fieldUploadOptions) : api.uploadFile(file, bucketName, handleProgress);
|
|
33337
|
+
uploadPromise.then((uploaded) => {
|
|
33307
33338
|
replaceItem(
|
|
33308
33339
|
localItem,
|
|
33309
33340
|
normalizeAttachmentItem(
|
|
@@ -33332,10 +33363,15 @@ function AttachmentFieldMobile({
|
|
|
33332
33363
|
);
|
|
33333
33364
|
setValue(next);
|
|
33334
33365
|
if (item.objectName) {
|
|
33335
|
-
|
|
33366
|
+
const options = getItemUploadOptions(item);
|
|
33367
|
+
const deletePromise = options ? api.deleteFile(item.objectName, item.bucketName || bucketName, options) : api.deleteFile(item.objectName, item.bucketName || bucketName);
|
|
33368
|
+
deletePromise.catch(() => void 0);
|
|
33336
33369
|
}
|
|
33337
33370
|
};
|
|
33338
33371
|
const resolvePreviewUrl = async (item) => {
|
|
33372
|
+
if (isDirectStorageItem2(item)) {
|
|
33373
|
+
return item.previewUrl || item.publicUrl || item.url || "";
|
|
33374
|
+
}
|
|
33339
33375
|
if (item.objectName) {
|
|
33340
33376
|
const ticket = await api.createFileAccessTicket(
|
|
33341
33377
|
item.bucketName || bucketName,
|
|
@@ -33357,6 +33393,9 @@ function AttachmentFieldMobile({
|
|
|
33357
33393
|
return item.previewUrl || item.url || "";
|
|
33358
33394
|
};
|
|
33359
33395
|
const resolveDownloadUrl = async (item) => {
|
|
33396
|
+
if (isDirectStorageItem2(item)) {
|
|
33397
|
+
return item.downloadUrl || item.publicUrl || item.url || "";
|
|
33398
|
+
}
|
|
33360
33399
|
if (item.objectName) {
|
|
33361
33400
|
const ticket = await api.createDownloadTicket(
|
|
33362
33401
|
item.bucketName || bucketName,
|
|
@@ -33459,6 +33498,7 @@ function AttachmentFieldMobile({
|
|
|
33459
33498
|
init_cjs_shims();
|
|
33460
33499
|
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
33461
33500
|
var getTicketUrl = (ticket, fallback) => typeof ticket === "string" ? ticket : ticket?.previewUrl || ticket?.downloadUrl || ticket?.relayUrl || ticket?.url || fallback;
|
|
33501
|
+
var isDirectStorageItem = (item) => item.provider === "oss" || Boolean(item.storageCode);
|
|
33462
33502
|
var PREVIEW_PAGE_EXTENSIONS3 = [
|
|
33463
33503
|
"pdf",
|
|
33464
33504
|
"xls",
|
|
@@ -33503,6 +33543,11 @@ function AttachmentFieldReadonly({
|
|
|
33503
33543
|
}
|
|
33504
33544
|
const previewFile = async (item) => {
|
|
33505
33545
|
let url2 = item.previewUrl || item.url;
|
|
33546
|
+
if (isDirectStorageItem(item)) {
|
|
33547
|
+
url2 = item.previewUrl || item.publicUrl || item.url;
|
|
33548
|
+
if (url2) window.open(url2, "_blank", "noopener,noreferrer");
|
|
33549
|
+
return;
|
|
33550
|
+
}
|
|
33506
33551
|
if (item.objectName) {
|
|
33507
33552
|
const ticket = await api.createFileAccessTicket(
|
|
33508
33553
|
item.bucketName || bucketName,
|
|
@@ -33525,6 +33570,11 @@ function AttachmentFieldReadonly({
|
|
|
33525
33570
|
};
|
|
33526
33571
|
const downloadFile = async (item) => {
|
|
33527
33572
|
let url2 = item.downloadUrl || item.url;
|
|
33573
|
+
if (isDirectStorageItem(item)) {
|
|
33574
|
+
url2 = item.downloadUrl || item.publicUrl || item.url;
|
|
33575
|
+
if (url2) window.open(url2, "_blank", "noopener,noreferrer");
|
|
33576
|
+
return;
|
|
33577
|
+
}
|
|
33528
33578
|
if (item.objectName) {
|
|
33529
33579
|
const ticket = await api.createDownloadTicket(
|
|
33530
33580
|
item.bucketName || bucketName,
|
|
@@ -33561,7 +33611,7 @@ function AttachmentFieldReadonly({
|
|
|
33561
33611
|
rel: "noopener noreferrer",
|
|
33562
33612
|
title: item.name,
|
|
33563
33613
|
onClick: (event) => {
|
|
33564
|
-
if (!item.objectName) return;
|
|
33614
|
+
if (!item.objectName || isDirectStorageItem(item)) return;
|
|
33565
33615
|
event.preventDefault();
|
|
33566
33616
|
void downloadFile(item);
|
|
33567
33617
|
},
|
|
@@ -39267,6 +39317,9 @@ var normalizeUploadData = (data, file, bucketName, baseUrl = "") => {
|
|
|
39267
39317
|
previewUrl: normalizeRuntimeFileUrl(baseUrl, item?.previewUrl),
|
|
39268
39318
|
publicUrl: normalizeRuntimeFileUrl(baseUrl, item?.publicUrl),
|
|
39269
39319
|
visibility: item?.visibility,
|
|
39320
|
+
provider: item?.provider,
|
|
39321
|
+
storageCode: item?.storageCode,
|
|
39322
|
+
appType: item?.appType,
|
|
39270
39323
|
status: "done",
|
|
39271
39324
|
size: item?.size ?? file.size,
|
|
39272
39325
|
objectName,
|
|
@@ -39327,6 +39380,61 @@ var uploadWithXhr = (baseUrl, file, bucketName, onProgress, options = {}) => new
|
|
|
39327
39380
|
xhr.onerror = () => reject(new Error("\u4E0A\u4F20\u5931\u8D25"));
|
|
39328
39381
|
xhr.send(formData);
|
|
39329
39382
|
});
|
|
39383
|
+
var uploadWithSignedUrl = (file, uploadInfo, bucketName, onProgress) => new Promise((resolve, reject) => {
|
|
39384
|
+
if (!uploadInfo?.uploadUrl) {
|
|
39385
|
+
reject(new Error("OSS \u4E0A\u4F20\u7B7E\u540D\u7F3A\u5C11 uploadUrl"));
|
|
39386
|
+
return;
|
|
39387
|
+
}
|
|
39388
|
+
const xhr = new XMLHttpRequest();
|
|
39389
|
+
xhr.open(String(uploadInfo.uploadMethod || "PUT").toUpperCase(), uploadInfo.uploadUrl);
|
|
39390
|
+
Object.entries(uploadInfo.headers || {}).forEach(([key, value]) => {
|
|
39391
|
+
if (value !== void 0 && value !== null) {
|
|
39392
|
+
xhr.setRequestHeader(key, String(value));
|
|
39393
|
+
}
|
|
39394
|
+
});
|
|
39395
|
+
xhr.upload.onprogress = (event) => {
|
|
39396
|
+
if (event.lengthComputable) {
|
|
39397
|
+
onProgress?.(Math.round(event.loaded / event.total * 100));
|
|
39398
|
+
}
|
|
39399
|
+
};
|
|
39400
|
+
xhr.onload = () => {
|
|
39401
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
39402
|
+
onProgress?.(100);
|
|
39403
|
+
resolve(
|
|
39404
|
+
normalizeUploadData(
|
|
39405
|
+
{
|
|
39406
|
+
...uploadInfo,
|
|
39407
|
+
provider: uploadInfo.provider || "oss",
|
|
39408
|
+
storageCode: uploadInfo.storageCode
|
|
39409
|
+
},
|
|
39410
|
+
file,
|
|
39411
|
+
uploadInfo.bucketName || bucketName
|
|
39412
|
+
)
|
|
39413
|
+
);
|
|
39414
|
+
return;
|
|
39415
|
+
}
|
|
39416
|
+
reject(new Error(xhr.statusText || "OSS \u4E0A\u4F20\u5931\u8D25"));
|
|
39417
|
+
};
|
|
39418
|
+
xhr.onerror = () => reject(new Error("OSS \u4E0A\u4F20\u5931\u8D25"));
|
|
39419
|
+
xhr.send(file);
|
|
39420
|
+
});
|
|
39421
|
+
async function uploadOssFile(request, file, bucketName, onProgress, options) {
|
|
39422
|
+
if (!options.appType) throw new Error("OSS \u4E0A\u4F20\u7F3A\u5C11 appType");
|
|
39423
|
+
if (!options.storageCode) throw new Error("OSS \u4E0A\u4F20\u7F3A\u5C11 storageCode");
|
|
39424
|
+
const response = await request({
|
|
39425
|
+
url: `/openxiangda-api/v1/apps/${encodeURIComponent(
|
|
39426
|
+
options.appType
|
|
39427
|
+
)}/storage-configs/${encodeURIComponent(options.storageCode)}/uploads/initiate`,
|
|
39428
|
+
method: "post",
|
|
39429
|
+
data: {
|
|
39430
|
+
fileName: file.name,
|
|
39431
|
+
fileSize: file.size,
|
|
39432
|
+
contentType: file.type || void 0,
|
|
39433
|
+
bucketName
|
|
39434
|
+
}
|
|
39435
|
+
});
|
|
39436
|
+
return uploadWithSignedUrl(file, response.data || response.result, bucketName, onProgress);
|
|
39437
|
+
}
|
|
39330
39438
|
async function uploadChunkedFile(request, file, bucketName, baseUrl, onProgress, options = {}) {
|
|
39331
39439
|
const initiate = await request({
|
|
39332
39440
|
url: "/file/multipart/initiate",
|
|
@@ -39391,7 +39499,10 @@ function createFormRuntimeApi(config3) {
|
|
|
39391
39499
|
const request = overrides.request ?? createDefaultRequest(baseUrl);
|
|
39392
39500
|
const defaults2 = {
|
|
39393
39501
|
request,
|
|
39394
|
-
uploadFile: async (file, bucketName = "files", onProgress) => {
|
|
39502
|
+
uploadFile: async (file, bucketName = "files", onProgress, options = {}) => {
|
|
39503
|
+
if (options.uploadProvider === "oss" || options.storageCode) {
|
|
39504
|
+
return uploadOssFile(request, file, bucketName, onProgress, options);
|
|
39505
|
+
}
|
|
39395
39506
|
if (file.size > CHUNK_UPLOAD_THRESHOLD) {
|
|
39396
39507
|
return uploadChunkedFile(request, file, bucketName, baseUrl, onProgress);
|
|
39397
39508
|
}
|
|
@@ -39407,7 +39518,19 @@ function createFormRuntimeApi(config3) {
|
|
|
39407
39518
|
visibility: "public"
|
|
39408
39519
|
});
|
|
39409
39520
|
},
|
|
39410
|
-
deleteFile: async (objectName, bucketName = "files") => {
|
|
39521
|
+
deleteFile: async (objectName, bucketName = "files", options = {}) => {
|
|
39522
|
+
if (options.uploadProvider === "oss" || options.storageCode) {
|
|
39523
|
+
if (!options.appType) throw new Error("OSS \u5220\u9664\u7F3A\u5C11 appType");
|
|
39524
|
+
if (!options.storageCode) throw new Error("OSS \u5220\u9664\u7F3A\u5C11 storageCode");
|
|
39525
|
+
await request({
|
|
39526
|
+
url: `/openxiangda-api/v1/apps/${encodeURIComponent(
|
|
39527
|
+
options.appType
|
|
39528
|
+
)}/storage-configs/${encodeURIComponent(options.storageCode)}/objects/delete`,
|
|
39529
|
+
method: "post",
|
|
39530
|
+
data: { bucketName, objectName }
|
|
39531
|
+
});
|
|
39532
|
+
return { success: true };
|
|
39533
|
+
}
|
|
39411
39534
|
await request({ url: "/file/delete", method: "post", data: { bucketName, objectName } });
|
|
39412
39535
|
return { success: true };
|
|
39413
39536
|
},
|