@nocobase/plugin-file-manager 2.1.0-alpha.1 → 2.1.0-alpha.11

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 (43) hide show
  1. package/LICENSE +201 -661
  2. package/README.md +79 -10
  3. package/dist/client/index.d.ts +3 -0
  4. package/dist/client/index.js +1 -1
  5. package/dist/client/models/UploadFieldModel.d.ts +22 -0
  6. package/dist/client/models/uploadFieldUtils.d.ts +56 -0
  7. package/dist/client/previewer/filePreviewTypes.d.ts +39 -0
  8. package/dist/client/schemas/storageTypes/ali-oss.d.ts +19 -0
  9. package/dist/client/schemas/storageTypes/common.d.ts +19 -0
  10. package/dist/client/schemas/storageTypes/index.d.ts +19 -0
  11. package/dist/client/templates/file.d.ts +2 -2
  12. package/dist/common/collections/storages.d.ts +11 -0
  13. package/dist/common/collections/storages.js +5 -0
  14. package/dist/externalVersion.js +9 -8
  15. package/dist/locale/en-US.json +2 -0
  16. package/dist/locale/zh-CN.json +3 -0
  17. package/dist/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +7858 -7858
  18. package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
  19. package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/index.js +7858 -7858
  20. package/dist/node_modules/@aws-sdk/lib-storage/node_modules/buffer/index.d.ts +186 -0
  21. package/dist/node_modules/@aws-sdk/lib-storage/node_modules/buffer/index.js +1794 -0
  22. package/dist/node_modules/@aws-sdk/lib-storage/node_modules/buffer/package.json +82 -0
  23. package/dist/node_modules/@aws-sdk/lib-storage/package.json +1 -1
  24. package/dist/node_modules/ali-oss/lib/client.js +3 -3
  25. package/dist/node_modules/ali-oss/package.json +1 -1
  26. package/dist/node_modules/mime-match/package.json +1 -1
  27. package/dist/node_modules/mime-types/package.json +1 -1
  28. package/dist/node_modules/mkdirp/package.json +1 -1
  29. package/dist/node_modules/multer-cos/package.json +1 -1
  30. package/dist/node_modules/url-join/package.json +1 -1
  31. package/dist/server/actions/attachments.js +21 -1
  32. package/dist/server/flow-schema-contributions/index.d.ts +10 -0
  33. package/dist/server/flow-schema-contributions/index.js +115 -0
  34. package/dist/server/server.d.ts +2 -0
  35. package/dist/server/server.js +4 -0
  36. package/dist/server/storages/index.d.ts +1 -0
  37. package/dist/server/storages/index.js +2 -0
  38. package/dist/server/storages/local.d.ts +2 -0
  39. package/dist/server/storages/local.js +27 -5
  40. package/dist/server/storages/s3.d.ts +0 -1
  41. package/dist/server/storages/s3.js +0 -27
  42. package/dist/server/utils.js +20 -6
  43. package/package.json +3 -3
@@ -0,0 +1,56 @@
1
+ interface UploadFieldFile {
2
+ uid?: string;
3
+ id?: number | string;
4
+ url?: string;
5
+ filename?: string;
6
+ name?: string;
7
+ thumbUrl?: string;
8
+ response?: UploadFieldFile;
9
+ }
10
+ /**
11
+ * 判断上传字段是否继续展示追加入口。
12
+ *
13
+ * 单值文件关系在已有文件后应隐藏“上传”和“选择”入口,多值字段允许继续追加。
14
+ *
15
+ * @param multiple 是否多值
16
+ * @param fileCount 当前文件数量
17
+ * @returns 是否显示追加入口
18
+ * @example
19
+ * ```typescript
20
+ * shouldShowUploadActionSlot(false, 1);
21
+ * ```
22
+ */
23
+ export declare const shouldShowUploadActionSlot: (multiple: boolean | undefined, fileCount: number) => boolean;
24
+ /**
25
+ * 规范化上传字段文件列表,并尽量复用上一轮 uid,避免列表项重挂载。
26
+ *
27
+ * @param data 当前外部值或上传组件返回的文件列表
28
+ * @param previousFileList 上一轮渲染中的文件列表
29
+ * @returns 规范化后的文件列表
30
+ * @example
31
+ * ```typescript
32
+ * normalizeUploadFieldFileList([{ id: 1, url: '/1.png' }], [{ uid: 'u1', response: { id: 1 } }]);
33
+ * ```
34
+ */
35
+ export declare const normalizeUploadFieldFileList: (data: UploadFieldFile[], previousFileList?: UploadFieldFile[]) => {
36
+ uid: string;
37
+ thumbUrl: string;
38
+ id?: number | string;
39
+ url?: string;
40
+ filename?: string;
41
+ name?: string;
42
+ response?: UploadFieldFile;
43
+ }[];
44
+ /**
45
+ * 根据当前文件列表解析预览索引,避免把非数字 uid 强转成 NaN。
46
+ *
47
+ * @param fileList 当前文件列表
48
+ * @param targetFile 当前预览文件
49
+ * @returns 预览索引
50
+ * @example
51
+ * ```typescript
52
+ * getUploadFieldPreviewIndex([{ uid: 'id:1' }], { uid: 'id:1' });
53
+ * ```
54
+ */
55
+ export declare const getUploadFieldPreviewIndex: (fileList: UploadFieldFile[], targetFile: UploadFieldFile) => number;
56
+ export {};
@@ -0,0 +1,39 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import React from 'react';
10
+ export interface FilePreviewerProps {
11
+ file: any;
12
+ index: number;
13
+ list: any[];
14
+ open?: boolean;
15
+ onOpenChange?: (open: boolean) => void;
16
+ onSwitchIndex?: (index: number) => void;
17
+ onClose?: () => void;
18
+ onDownload: (file: any) => void;
19
+ }
20
+ export interface FilePreviewType {
21
+ match(file: any): boolean;
22
+ getThumbnailURL?: (file: any) => string | null;
23
+ Previewer?: React.ComponentType<FilePreviewerProps>;
24
+ }
25
+ export declare class FilePreviewTypes {
26
+ types: FilePreviewType[];
27
+ add(type: FilePreviewType): void;
28
+ getTypeByFile(file: any): Omit<FilePreviewType, 'match'> | undefined;
29
+ }
30
+ export declare const filePreviewTypes: FilePreviewTypes;
31
+ export declare function normalizePreviewFile(file: any): any;
32
+ export declare function getPreviewFileUrl(file: any): any;
33
+ export declare function getFileUrl(file: any): any;
34
+ export declare const getFileExt: (file: any, url?: string) => string;
35
+ export declare const getFileName: (file: any, url?: string) => any;
36
+ export declare const getFallbackIcon: (file: any, url?: string) => string;
37
+ export declare const getPreviewThumbnailUrl: (file: any) => string;
38
+ export declare const wrapWithModalPreviewer: (Previewer: React.ComponentType<FilePreviewerProps>) => (props: FilePreviewerProps) => React.JSX.Element;
39
+ export declare const FilePreviewRenderer: (props: FilePreviewerProps) => React.JSX.Element;
@@ -136,6 +136,25 @@ declare const _default: {
136
136
  'x-content': string;
137
137
  description: string;
138
138
  };
139
+ settings: {
140
+ type: string;
141
+ title: string;
142
+ 'x-component': string;
143
+ properties: {
144
+ requestOptions: {
145
+ type: string;
146
+ title: string;
147
+ description: string;
148
+ 'x-decorator': string;
149
+ 'x-component': string;
150
+ 'x-component-props': {
151
+ autoSize: {
152
+ minRows: number;
153
+ };
154
+ };
155
+ };
156
+ };
157
+ };
139
158
  };
140
159
  thumbnailRuleLink: string;
141
160
  };
@@ -77,5 +77,24 @@ declare const _default: {
77
77
  }[];
78
78
  default: string;
79
79
  };
80
+ settings: {
81
+ type: string;
82
+ title: string;
83
+ 'x-component': string;
84
+ properties: {
85
+ requestOptions: {
86
+ type: string;
87
+ title: string;
88
+ description: string;
89
+ 'x-decorator': string;
90
+ 'x-component': string;
91
+ 'x-component-props': {
92
+ autoSize: {
93
+ minRows: number;
94
+ };
95
+ };
96
+ };
97
+ };
98
+ };
80
99
  };
81
100
  export default _default;
@@ -230,6 +230,25 @@ export declare const storageTypes: {
230
230
  'x-content': string;
231
231
  description: string;
232
232
  };
233
+ settings: {
234
+ type: string;
235
+ title: string;
236
+ 'x-component': string;
237
+ properties: {
238
+ requestOptions: {
239
+ type: string;
240
+ title: string;
241
+ description: string;
242
+ 'x-decorator': string;
243
+ 'x-component': string;
244
+ 'x-component-props': {
245
+ autoSize: {
246
+ minRows: number;
247
+ };
248
+ };
249
+ };
250
+ };
251
+ };
233
252
  };
234
253
  thumbnailRuleLink: string;
235
254
  };
@@ -127,13 +127,13 @@ export declare class FileCollectionTemplate extends CollectionTemplate {
127
127
  name: any;
128
128
  createdAt: any;
129
129
  updatedAt: any;
130
+ updatedBy: any;
131
+ createdBy: any;
130
132
  title: any;
131
133
  description: any;
132
134
  inherits: any;
133
135
  category: any;
134
136
  autoGenId: any;
135
- createdBy: any;
136
- updatedBy: any;
137
137
  sortable: any;
138
138
  simplePaginate: any;
139
139
  presetFields: any;
@@ -110,6 +110,17 @@ declare const _default: {
110
110
  translation?: undefined;
111
111
  trim?: undefined;
112
112
  unique?: undefined;
113
+ } | {
114
+ type: string;
115
+ name: string;
116
+ defaultValue: {};
117
+ primaryKey?: undefined;
118
+ allowNull?: undefined;
119
+ title?: undefined;
120
+ comment?: undefined;
121
+ translation?: undefined;
122
+ trim?: undefined;
123
+ unique?: undefined;
113
124
  })[];
114
125
  };
115
126
  export default _default;
@@ -105,6 +105,11 @@ var storages_default = {
105
105
  type: "boolean",
106
106
  name: "paranoid",
107
107
  defaultValue: false
108
+ },
109
+ {
110
+ type: "json",
111
+ name: "settings",
112
+ defaultValue: {}
108
113
  }
109
114
  ]
110
115
  };
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-alpha.1",
11
+ "@nocobase/client": "2.1.0-alpha.11",
12
12
  "react": "18.2.0",
13
13
  "antd": "5.24.2",
14
14
  "@ant-design/icons": "5.6.1",
@@ -19,13 +19,14 @@ module.exports = {
19
19
  "@formily/core": "2.3.7",
20
20
  "@formily/react": "2.3.7",
21
21
  "multer": "1.4.5-lts.2",
22
- "@nocobase/database": "2.1.0-alpha.1",
23
- "@nocobase/server": "2.1.0-alpha.1",
24
- "@nocobase/utils": "2.1.0-alpha.1",
25
- "@nocobase/test": "2.1.0-alpha.1",
26
- "@nocobase/flow-engine": "2.1.0-alpha.1",
27
- "@nocobase/actions": "2.1.0-alpha.1",
22
+ "@nocobase/database": "2.1.0-alpha.11",
23
+ "@nocobase/flow-engine": "2.1.0-alpha.11",
24
+ "@nocobase/server": "2.1.0-alpha.11",
25
+ "@nocobase/utils": "2.1.0-alpha.11",
26
+ "@nocobase/test": "2.1.0-alpha.11",
27
+ "@emotion/css": "11.13.0",
28
+ "@nocobase/actions": "2.1.0-alpha.11",
28
29
  "sequelize": "6.35.2",
29
- "@nocobase/plugin-data-source-main": "2.1.0-alpha.1",
30
+ "@nocobase/plugin-data-source-main": "2.1.0-alpha.11",
30
31
  "axios": "1.7.7"
31
32
  };
@@ -1,4 +1,5 @@
1
1
  {
2
+ "Additional options for HTTP requests when fetching files from remote storage on server side, such as headers.": "Additional options for HTTP requests when fetching files from remote storage on server side, such as headers.",
2
3
  "Access base URL": "Access base URL",
3
4
  "Aliyun OSS": "Aliyun OSS",
4
5
  "Aliyun OSS region part of the bucket. For example: \"oss-cn-beijing\".": "Aliyun OSS region part of the bucket. For example: \"oss-cn-beijing\".",
@@ -36,6 +37,7 @@
36
37
  "Region": "Region",
37
38
  "Relative path the file will be saved to. Left blank as root path. The leading and trailing slashes \"/\" will be ignored. For example: \"user/avatar\".": "Relative path the file will be saved to. Left blank as root path. The leading and trailing slashes \"/\" will be ignored. For example: \"user/avatar\".",
38
39
  "Renaming strategy to avoid filename conflicts when uploading files.": "Renaming strategy to avoid filename conflicts when uploading files.",
40
+ "Request options": "Request options",
39
41
  "See more": "See more",
40
42
  "Size": "Size",
41
43
  "Storage": "Storage",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "Additional options for HTTP requests when fetching files from remote storage on server side, such as headers.": "在服务器端从远程存储获取文件时,HTTP 请求的附加选项,例如请求头等。",
2
3
  "Access base URL": "访问 URL 基础",
3
4
  "Aliyun OSS": "阿里云 OSS",
4
5
  "Aliyun OSS region part of the bucket. For example: \"oss-cn-beijing\".": "阿里云 OSS 存储桶所在区域。例如:\"oss-cn-beijing\"。",
@@ -21,6 +22,7 @@
21
22
  "File size limit": "文件大小限制",
22
23
  "File storage": "文件存储器",
23
24
  "File type allowed (in MIME type format)": "允许的文件类型(MIME 格式)",
25
+ "File type is not supported for previewing, please <1>download it to preview</1>": "文件类型不支持预览,请<1>下载后查看</1>",
24
26
  "Filename": "文件名",
25
27
  "Files are only removed when their corresponding records in the file collection are deleted. If a record from another collection includes an associating field referencing the file collection, the file will not be deleted unless cascade deletion is enabled for that association.": "只有在删除文件表记录时,文件才会被删除。当删除其他表的记录包含指向文件表的关系字段时,除非关系中配置了级联删除,否则文件不会被删除。",
26
28
  "Keep file in storage when destroy record": "删除记录时保留文件",
@@ -36,6 +38,7 @@
36
38
  "Relative path the file will be saved to. Left blank as root path. The leading and trailing slashes \"/\" will be ignored. For example: \"user/avatar\".": "文件保存的相对路径。留空则为根路径。开始和结尾的斜杠“/”会被忽略。例如:\"user/avatar\"。",
37
39
  "Renaming": "重命名",
38
40
  "Renaming strategy to avoid filename conflicts when uploading files.": "上传文件时避免文件名冲突的重命名策略。",
41
+ "Request options": "请求选项",
39
42
  "See more": "更多请查阅",
40
43
  "Size": "文件大小",
41
44
  "Storage": "存储空间",