@nocobase/plugin-file-manager 1.5.0-beta.3 → 1.5.0-beta.31

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.
@@ -1 +1 @@
1
- {"_from":"multer-cos","_id":"multer-cos@1.0.2","_inBundle":false,"_integrity":"sha512-4F8P1VTCSNhiem+BFJFLe3Ixco6cIuAQ6j7U+PBRvdbBJRZgq5Q+vaDMMBWJ1HmPGOOP3AyKS5yk2f0nbFoqqA==","_location":"/multer-cos","_phantomChildren":{},"_requested":{"type":"tag","registry":true,"raw":"multer-cos","name":"multer-cos","escapedName":"multer-cos","rawSpec":"","saveSpec":null,"fetchSpec":"latest"},"_requiredBy":["#USER","/"],"_resolved":"https://registry.npmjs.org/multer-cos/-/multer-cos-1.0.2.tgz","_shasum":"95c7c06cdee1b9311675a895481f9d946de6dcf3","_spec":"multer-cos","_where":"/Users/lanbo/workplace/websocket","author":{"name":"lanbosm"},"bugs":{"url":"https://github.com/lanbosm/multer-COS/issues"},"bundleDependencies":false,"deprecated":false,"description":"Streaming multer storage engine for QCloud COS","devDependencies":{"cos-nodejs-sdk-v5":"^2.2.6","dotenv":"^5.0.1","multer":"^1.3.0"},"engines":{"node":">= 6.10.0"},"homepage":"https://github.com/lanbosm/multer-COS#readme","keywords":["express","multer","COS"],"license":"MIT","main":"index.js","name":"multer-cos","repository":{"type":"git","url":"git+ssh://git@github.com/lanbosm/multer-COS.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"version":"1.0.3","_lastModified":"2024-12-10T07:16:20.684Z"}
1
+ {"_from":"multer-cos","_id":"multer-cos@1.0.2","_inBundle":false,"_integrity":"sha512-4F8P1VTCSNhiem+BFJFLe3Ixco6cIuAQ6j7U+PBRvdbBJRZgq5Q+vaDMMBWJ1HmPGOOP3AyKS5yk2f0nbFoqqA==","_location":"/multer-cos","_phantomChildren":{},"_requested":{"type":"tag","registry":true,"raw":"multer-cos","name":"multer-cos","escapedName":"multer-cos","rawSpec":"","saveSpec":null,"fetchSpec":"latest"},"_requiredBy":["#USER","/"],"_resolved":"https://registry.npmjs.org/multer-cos/-/multer-cos-1.0.2.tgz","_shasum":"95c7c06cdee1b9311675a895481f9d946de6dcf3","_spec":"multer-cos","_where":"/Users/lanbo/workplace/websocket","author":{"name":"lanbosm"},"bugs":{"url":"https://github.com/lanbosm/multer-COS/issues"},"bundleDependencies":false,"deprecated":false,"description":"Streaming multer storage engine for QCloud COS","devDependencies":{"cos-nodejs-sdk-v5":"^2.2.6","dotenv":"^5.0.1","multer":"^1.3.0"},"engines":{"node":">= 6.10.0"},"homepage":"https://github.com/lanbosm/multer-COS#readme","keywords":["express","multer","COS"],"license":"MIT","main":"index.js","name":"multer-cos","repository":{"type":"git","url":"git+ssh://git@github.com/lanbosm/multer-COS.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"version":"1.0.3","_lastModified":"2025-01-16T17:05:02.622Z"}
@@ -1 +1 @@
1
- {"name":"multer-s3","version":"3.0.1","description":"Streaming multer storage engine for AWS S3","main":"index.js","scripts":{"test":"standard && mocha test/basic.js"},"engines":{"node":">= 12.0.0"},"repository":{"type":"git","url":"git+https://github.com/badunk/multer-s3.git"},"keywords":["multer","s3","amazon","aws"],"author":"badunk","license":"MIT","bugs":{"url":"https://github.com/badunk/multer-s3/issues"},"homepage":"https://github.com/badunk/multer-s3#readme","dependencies":{"@aws-sdk/lib-storage":"^3.46.0","file-type":"^3.3.0","html-comment-regex":"^1.1.2","run-parallel":"^1.1.6"},"peerDependencies":{"@aws-sdk/client-s3":"^3.0.0"},"devDependencies":{"express":"^4.13.1","form-data":"^1.0.0-rc3","mocha":"^2.2.5","multer":"^1.1.0","on-finished":"^2.3.0","standard":"^5.4.1","xtend":"^4.0.1"},"_lastModified":"2024-12-10T07:16:16.862Z"}
1
+ {"name":"multer-s3","version":"3.0.1","description":"Streaming multer storage engine for AWS S3","main":"index.js","scripts":{"test":"standard && mocha test/basic.js"},"engines":{"node":">= 12.0.0"},"repository":{"type":"git","url":"git+https://github.com/badunk/multer-s3.git"},"keywords":["multer","s3","amazon","aws"],"author":"badunk","license":"MIT","bugs":{"url":"https://github.com/badunk/multer-s3/issues"},"homepage":"https://github.com/badunk/multer-s3#readme","dependencies":{"@aws-sdk/lib-storage":"^3.46.0","file-type":"^3.3.0","html-comment-regex":"^1.1.2","run-parallel":"^1.1.6"},"peerDependencies":{"@aws-sdk/client-s3":"^3.0.0"},"devDependencies":{"express":"^4.13.1","form-data":"^1.0.0-rc3","mocha":"^2.2.5","multer":"^1.1.0","on-finished":"^2.3.0","standard":"^5.4.1","xtend":"^4.0.1"},"_lastModified":"2025-01-16T17:04:58.767Z"}
@@ -6,5 +6,8 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import { StorageEngine } from 'multer';
9
10
  export * from '../constants';
10
- export { default } from './server';
11
+ export { AttachmentModel, default, IStorage, PluginFileManagerServer, StorageModel } from './server';
12
+ export { StorageType } from './storages';
13
+ export { StorageEngine };
@@ -37,12 +37,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
37
37
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
38
  var server_exports = {};
39
39
  __export(server_exports, {
40
+ AttachmentModel: () => import_server.AttachmentModel,
41
+ IStorage: () => import_server.IStorage,
42
+ PluginFileManagerServer: () => import_server.PluginFileManagerServer,
43
+ StorageEngine: () => import_multer.StorageEngine,
44
+ StorageModel: () => import_server.StorageModel,
45
+ StorageType: () => import_storages.StorageType,
40
46
  default: () => import_server.default
41
47
  });
42
48
  module.exports = __toCommonJS(server_exports);
49
+ var import_multer = require("multer");
43
50
  __reExport(server_exports, require("../constants"), module.exports);
44
51
  var import_server = __toESM(require("./server"));
52
+ var import_storages = require("./storages");
45
53
  // Annotate the CommonJS export names for ESM import in node:
46
54
  0 && (module.exports = {
55
+ AttachmentModel,
56
+ IStorage,
57
+ PluginFileManagerServer,
58
+ StorageEngine,
59
+ StorageModel,
60
+ StorageType,
47
61
  ...require("../constants")
48
62
  });
@@ -22,16 +22,18 @@ export type UploadFileOptions = {
22
22
  storageName?: string;
23
23
  documentRoot?: string;
24
24
  };
25
- export default class PluginFileManagerServer extends Plugin {
25
+ export declare class PluginFileManagerServer extends Plugin {
26
26
  storageTypes: Registry<IStorage>;
27
27
  storagesCache: Map<number, StorageModel>;
28
+ registerStorageType(type: string, options: IStorage): void;
28
29
  createFileRecord(options: FileRecordOptions): Promise<any>;
29
30
  uploadFile(options: UploadFileOptions): Promise<any>;
30
31
  loadStorages(options?: {
31
32
  transaction: any;
32
33
  }): Promise<void>;
33
34
  install(): Promise<void>;
34
- onSync(message: any): Promise<void>;
35
+ handleSyncMessage(message: any): Promise<void>;
35
36
  beforeLoad(): Promise<void>;
36
37
  load(): Promise<void>;
37
38
  }
39
+ export default PluginFileManagerServer;
@@ -36,7 +36,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
37
  var server_exports = {};
38
38
  __export(server_exports, {
39
- default: () => PluginFileManagerServer
39
+ PluginFileManagerServer: () => PluginFileManagerServer,
40
+ default: () => server_default
40
41
  });
41
42
  module.exports = __toCommonJS(server_exports);
42
43
  var import_server = require("@nocobase/server");
@@ -56,6 +57,9 @@ const DEFAULT_STORAGE_TYPE = import_constants.STORAGE_TYPE_LOCAL;
56
57
  class PluginFileManagerServer extends import_server.Plugin {
57
58
  storageTypes = new import_utils.Registry();
58
59
  storagesCache = /* @__PURE__ */ new Map();
60
+ registerStorageType(type, options) {
61
+ this.storageTypes.register(type, options);
62
+ }
59
63
  async createFileRecord(options) {
60
64
  const { values, storageName, collectionName, filePath, transaction } = options;
61
65
  const collection = this.db.getCollection(collectionName);
@@ -144,7 +148,7 @@ class PluginFileManagerServer extends import_server.Plugin {
144
148
  });
145
149
  }
146
150
  }
147
- async onSync(message) {
151
+ async handleSyncMessage(message) {
148
152
  if (message.type === "storageChange") {
149
153
  const storage = await this.db.getRepository("storages").findOne({
150
154
  filterByTk: message.storageId
@@ -154,7 +158,7 @@ class PluginFileManagerServer extends import_server.Plugin {
154
158
  }
155
159
  }
156
160
  if (message.type === "storageRemove") {
157
- const id = Number.parseInt(message.storageId, 10);
161
+ const id = message.storageId;
158
162
  this.storagesCache.delete(id);
159
163
  }
160
164
  }
@@ -178,19 +182,25 @@ class PluginFileManagerServer extends import_server.Plugin {
178
182
  directory: (0, import_path.resolve)(__dirname, "./collections")
179
183
  });
180
184
  const Storage = this.db.getModel("storages");
181
- Storage.afterSave((m) => {
185
+ Storage.afterSave((m, { transaction }) => {
182
186
  this.storagesCache.set(m.id, m.toJSON());
183
- this.sync({
184
- type: "storageChange",
185
- storageId: `${m.id}`
186
- });
187
+ this.sendSyncMessage(
188
+ {
189
+ type: "storageChange",
190
+ storageId: m.id
191
+ },
192
+ { transaction }
193
+ );
187
194
  });
188
- Storage.afterDestroy((m) => {
195
+ Storage.afterDestroy((m, { transaction }) => {
189
196
  this.storagesCache.delete(m.id);
190
- this.sync({
191
- type: "storageRemove",
192
- storageId: `${m.id}`
193
- });
197
+ this.sendSyncMessage(
198
+ {
199
+ type: "storageRemove",
200
+ storageId: m.id
201
+ },
202
+ { transaction }
203
+ );
194
204
  });
195
205
  this.app.acl.registerSnippet({
196
206
  name: `pm.${this.name}.storages`,
@@ -226,3 +236,8 @@ class PluginFileManagerServer extends import_server.Plugin {
226
236
  this.app.db.interfaceManager.registerInterfaceType("attachment", import_attachment_interface.AttachmentInterface);
227
237
  }
228
238
  }
239
+ var server_default = PluginFileManagerServer;
240
+ // Annotate the CommonJS export names for ESM import in node:
241
+ 0 && (module.exports = {
242
+ PluginFileManagerServer
243
+ });
@@ -6,8 +6,8 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- import { StorageEngine } from 'multer';
10
9
  import Application from '@nocobase/server';
10
+ import { StorageEngine } from 'multer';
11
11
  export interface StorageModel {
12
12
  id?: number;
13
13
  title: string;
@@ -39,6 +39,6 @@ export interface IStorage {
39
39
  }
40
40
  export declare abstract class StorageType implements IStorage {
41
41
  abstract make(storage: StorageModel): StorageEngine;
42
- abstract defaults(): StorageModel;
43
42
  abstract delete(storage: StorageModel, records: AttachmentModel[]): Promise<[number, AttachmentModel[]]>;
43
+ defaults(): StorageModel;
44
44
  }
@@ -30,6 +30,9 @@ __export(storages_exports, {
30
30
  });
31
31
  module.exports = __toCommonJS(storages_exports);
32
32
  class StorageType {
33
+ defaults() {
34
+ return {};
35
+ }
33
36
  }
34
37
  // Annotate the CommonJS export names for ESM import in node:
35
38
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-file-manager",
3
- "version": "1.5.0-beta.3",
3
+ "version": "1.5.0-beta.31",
4
4
  "displayName": "File manager",
5
5
  "displayName.zh-CN": "文件管理器",
6
6
  "description": "Provides files storage services with files collection template and attachment field.",
@@ -43,5 +43,5 @@
43
43
  "Collections",
44
44
  "Collection fields"
45
45
  ],
46
- "gitHead": "81afcf4affdb652faf4636e6d9351828ce8906be"
46
+ "gitHead": "75fe2500e19dfbb2ae1a29a27f136f3b794e633a"
47
47
  }