@nocobase/plugin-file-manager 0.13.0-alpha.4 → 0.13.0-alpha.6

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 (40) hide show
  1. package/dist/client/index.js +1 -975
  2. package/dist/index.js +37 -16
  3. package/dist/locale/en-US.js +22 -4
  4. package/dist/locale/fr-FR.js +22 -4
  5. package/dist/locale/ja-JP.js +22 -4
  6. package/dist/locale/ru-RU.js +22 -4
  7. package/dist/locale/tr-TR.js +22 -4
  8. package/dist/locale/zh-CN.js +22 -4
  9. package/dist/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +3 -3
  10. package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
  11. package/dist/node_modules/mime-match/index.js +1 -1
  12. package/dist/node_modules/mime-match/package.json +1 -1
  13. package/dist/node_modules/mkdirp/index.js +1 -1
  14. package/dist/node_modules/mkdirp/package.json +1 -1
  15. package/dist/node_modules/multer-aliyun-oss/index.js +22 -22
  16. package/dist/node_modules/multer-aliyun-oss/package.json +1 -1
  17. package/dist/node_modules/multer-cos/index.js +15 -15
  18. package/dist/node_modules/multer-cos/package.json +1 -1
  19. package/dist/node_modules/multer-s3/index.js +5 -5
  20. package/dist/node_modules/multer-s3/package.json +1 -1
  21. package/dist/server/actions/attachments.js +54 -45
  22. package/dist/server/actions/index.js +37 -14
  23. package/dist/server/collections/attachments.js +22 -4
  24. package/dist/server/collections/storages.js +22 -4
  25. package/dist/server/constants.js +38 -10
  26. package/dist/server/index.js +37 -21
  27. package/dist/server/migrations/20230831160742-fix-attachment-field.d.ts +4 -0
  28. package/dist/server/migrations/20230831160742-fix-attachment-field.js +60 -0
  29. package/dist/server/rules/index.js +36 -13
  30. package/dist/server/rules/mimetype.js +34 -11
  31. package/dist/server/server.js +53 -24
  32. package/dist/server/storages/ali-oss.js +26 -9
  33. package/dist/server/storages/index.js +48 -26
  34. package/dist/server/storages/local.js +45 -25
  35. package/dist/server/storages/s3.js +26 -9
  36. package/dist/server/storages/tx-cos.js +28 -11
  37. package/dist/server/utils.js +42 -15
  38. package/dist/swagger/index.json +81 -0
  39. package/package.json +2 -2
  40. package/dist/swagger/index.js +0 -95
@@ -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":"2023-08-27T02:27:07.158Z"}
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":"2023-09-04T12:59:51.890Z"}
@@ -1,51 +1,58 @@
1
- 'use strict';
2
-
3
- var utils = require('@nocobase/utils');
4
- var path = require('path');
5
- var constants = require('../constants');
6
- var Rules = require('../rules');
7
- var storages = require('../storages');
8
-
9
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
-
11
- function _interopNamespace(e) {
12
- if (e && e.__esModule) return e;
13
- var n = Object.create(null);
14
- if (e) {
15
- Object.keys(e).forEach(function (k) {
16
- if (k !== 'default') {
17
- var d = Object.getOwnPropertyDescriptor(e, k);
18
- Object.defineProperty(n, k, d.get ? d : {
19
- enumerable: true,
20
- get: function () { return e[k]; }
21
- });
22
- }
23
- });
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
16
  }
25
- n.default = e;
26
- return Object.freeze(n);
27
- }
28
-
29
- var path__default = /*#__PURE__*/_interopDefault(path);
30
- var Rules__namespace = /*#__PURE__*/_interopNamespace(Rules);
31
-
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var attachments_exports = {};
29
+ __export(attachments_exports, {
30
+ createMiddleware: () => createMiddleware,
31
+ destroyMiddleware: () => destroyMiddleware
32
+ });
33
+ module.exports = __toCommonJS(attachments_exports);
34
+ var import_utils = require("@nocobase/utils");
35
+ var import_path = __toESM(require("path"));
36
+ var import_constants = require("../constants");
37
+ var Rules = __toESM(require("../rules"));
38
+ var import_storages = require("../storages");
32
39
  function getFileFilter(storage) {
33
40
  return (req, file, cb) => {
34
41
  const { size, ...rules } = storage.rules;
35
42
  const ruleKeys = Object.keys(rules);
36
- const result = !ruleKeys.length || !ruleKeys.some((key) => typeof Rules__namespace[key] !== "function" || !Rules__namespace[key](file, rules[key]));
43
+ const result = !ruleKeys.length || !ruleKeys.some((key) => typeof Rules[key] !== "function" || !Rules[key](file, rules[key]));
37
44
  cb(null, result);
38
45
  };
39
46
  }
40
47
  function getFileData(ctx) {
41
- const { [constants.FILE_FIELD_NAME]: file, storage } = ctx;
48
+ const { [import_constants.FILE_FIELD_NAME]: file, storage } = ctx;
42
49
  if (!file) {
43
50
  return ctx.throw(400, "file validation failed");
44
51
  }
45
- const storageConfig = storages.getStorageConfig(storage.type);
52
+ const storageConfig = (0, import_storages.getStorageConfig)(storage.type);
46
53
  const { [storageConfig.filenameKey || "filename"]: name } = file;
47
- const filename = path__default.default.basename(name);
48
- const extname = path__default.default.extname(filename);
54
+ const filename = import_path.default.basename(name);
55
+ const extname = import_path.default.extname(filename);
49
56
  const urlPath = storage.path ? storage.path.replace(/^([^/])/, "/$1") : "";
50
57
  return {
51
58
  title: Buffer.from(file.originalname, "latin1").toString("utf8").replace(extname, ""),
@@ -69,7 +76,7 @@ async function multipart(ctx, next) {
69
76
  ctx.logger.error("[file-manager] no linked or default storage provided");
70
77
  return ctx.throw(500);
71
78
  }
72
- const storageConfig = storages.getStorageConfig(storage.type);
79
+ const storageConfig = (0, import_storages.getStorageConfig)(storage.type);
73
80
  if (!storageConfig) {
74
81
  ctx.logger.error(`[file-manager] storage type "${storage.type}" is not defined`);
75
82
  return ctx.throw(500);
@@ -77,13 +84,13 @@ async function multipart(ctx, next) {
77
84
  const multerOptions = {
78
85
  fileFilter: getFileFilter(storage),
79
86
  limits: {
80
- fileSize: storage.rules.size ?? constants.DEFAULT_MAX_FILE_SIZE,
87
+ fileSize: storage.rules.size ?? import_constants.DEFAULT_MAX_FILE_SIZE,
81
88
  // 每次只允许提交一个文件
82
- files: constants.LIMIT_FILES
89
+ files: import_constants.LIMIT_FILES
83
90
  },
84
91
  storage: storageConfig.make(storage)
85
92
  };
86
- const upload = utils.koaMulter(multerOptions).single(constants.FILE_FIELD_NAME);
93
+ const upload = (0, import_utils.koaMulter)(multerOptions).single(import_constants.FILE_FIELD_NAME);
87
94
  try {
88
95
  await upload(ctx, () => {
89
96
  });
@@ -136,7 +143,7 @@ async function destroyMiddleware(ctx, next) {
136
143
  result[storageId].push(record);
137
144
  return result;
138
145
  }, {});
139
- const storages$1 = await ctx.db.getRepository("storages").find({
146
+ const storages = await ctx.db.getRepository("storages").find({
140
147
  filter: {
141
148
  id: [...storageIds],
142
149
  paranoid: {
@@ -146,9 +153,9 @@ async function destroyMiddleware(ctx, next) {
146
153
  });
147
154
  let count = 0;
148
155
  const undeleted = [];
149
- await storages$1.reduce(
156
+ await storages.reduce(
150
157
  (promise, storage) => promise.then(async () => {
151
- const storageConfig = storages.getStorageConfig(storage.type);
158
+ const storageConfig = (0, import_storages.getStorageConfig)(storage.type);
152
159
  const result = await storageConfig.delete(storage, storageGroupedRecords[storage.id]);
153
160
  count += result[0];
154
161
  undeleted.push(...result[1]);
@@ -168,6 +175,8 @@ async function destroyMiddleware(ctx, next) {
168
175
  }
169
176
  await next();
170
177
  }
171
-
172
- exports.createMiddleware = createMiddleware;
173
- exports.destroyMiddleware = destroyMiddleware;
178
+ // Annotate the CommonJS export names for ESM import in node:
179
+ 0 && (module.exports = {
180
+ createMiddleware,
181
+ destroyMiddleware
182
+ });
@@ -1,16 +1,39 @@
1
- 'use strict';
2
-
3
- var actions = require('@nocobase/actions');
4
- var attachments = require('./attachments');
5
-
6
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
-
8
- var actions__default = /*#__PURE__*/_interopDefault(actions);
9
-
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var actions_exports = {};
29
+ __export(actions_exports, {
30
+ default: () => actions_default
31
+ });
32
+ module.exports = __toCommonJS(actions_exports);
33
+ var import_actions = __toESM(require("@nocobase/actions"));
34
+ var import_attachments = require("./attachments");
10
35
  function actions_default({ app }) {
11
- app.resourcer.use(attachments.createMiddleware);
12
- app.resourcer.registerActionHandler("upload", actions__default.default.create);
13
- app.resourcer.use(attachments.destroyMiddleware);
36
+ app.resourcer.use(import_attachments.createMiddleware);
37
+ app.resourcer.registerActionHandler("upload", import_actions.default.create);
38
+ app.resourcer.use(import_attachments.destroyMiddleware);
14
39
  }
15
-
16
- module.exports = actions_default;
@@ -1,5 +1,25 @@
1
- 'use strict';
2
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var attachments_exports = {};
19
+ __export(attachments_exports, {
20
+ default: () => attachments_default
21
+ });
22
+ module.exports = __toCommonJS(attachments_exports);
3
23
  var attachments_default = {
4
24
  namespace: "file-manager.attachmentRecords",
5
25
  duplicator: "optional",
@@ -63,5 +83,3 @@ var attachments_default = {
63
83
  }
64
84
  ]
65
85
  };
66
-
67
- module.exports = attachments_default;
@@ -1,5 +1,25 @@
1
- 'use strict';
2
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var storages_exports = {};
19
+ __export(storages_exports, {
20
+ default: () => storages_default
21
+ });
22
+ module.exports = __toCommonJS(storages_exports);
3
23
  var storages_default = {
4
24
  namespace: "file-manager.storageSetting",
5
25
  duplicator: "optional",
@@ -63,5 +83,3 @@ var storages_default = {
63
83
  }
64
84
  ]
65
85
  };
66
-
67
- module.exports = storages_default;
@@ -1,5 +1,31 @@
1
- 'use strict';
2
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var constants_exports = {};
19
+ __export(constants_exports, {
20
+ DEFAULT_MAX_FILE_SIZE: () => DEFAULT_MAX_FILE_SIZE,
21
+ FILE_FIELD_NAME: () => FILE_FIELD_NAME,
22
+ LIMIT_FILES: () => LIMIT_FILES,
23
+ STORAGE_TYPE_ALI_OSS: () => STORAGE_TYPE_ALI_OSS,
24
+ STORAGE_TYPE_LOCAL: () => STORAGE_TYPE_LOCAL,
25
+ STORAGE_TYPE_S3: () => STORAGE_TYPE_S3,
26
+ STORAGE_TYPE_TX_COS: () => STORAGE_TYPE_TX_COS
27
+ });
28
+ module.exports = __toCommonJS(constants_exports);
3
29
  const FILE_FIELD_NAME = "file";
4
30
  const LIMIT_FILES = 1;
5
31
  const DEFAULT_MAX_FILE_SIZE = 1024 * 1024 * 1024;
@@ -7,11 +33,13 @@ const STORAGE_TYPE_LOCAL = "local";
7
33
  const STORAGE_TYPE_ALI_OSS = "ali-oss";
8
34
  const STORAGE_TYPE_S3 = "s3";
9
35
  const STORAGE_TYPE_TX_COS = "tx-cos";
10
-
11
- exports.DEFAULT_MAX_FILE_SIZE = DEFAULT_MAX_FILE_SIZE;
12
- exports.FILE_FIELD_NAME = FILE_FIELD_NAME;
13
- exports.LIMIT_FILES = LIMIT_FILES;
14
- exports.STORAGE_TYPE_ALI_OSS = STORAGE_TYPE_ALI_OSS;
15
- exports.STORAGE_TYPE_LOCAL = STORAGE_TYPE_LOCAL;
16
- exports.STORAGE_TYPE_S3 = STORAGE_TYPE_S3;
17
- exports.STORAGE_TYPE_TX_COS = STORAGE_TYPE_TX_COS;
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ DEFAULT_MAX_FILE_SIZE,
39
+ FILE_FIELD_NAME,
40
+ LIMIT_FILES,
41
+ STORAGE_TYPE_ALI_OSS,
42
+ STORAGE_TYPE_LOCAL,
43
+ STORAGE_TYPE_S3,
44
+ STORAGE_TYPE_TX_COS
45
+ });
@@ -1,23 +1,39 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var constants = require('./constants');
6
- var server = require('./server');
7
-
8
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
-
10
- var server__default = /*#__PURE__*/_interopDefault(server);
11
-
12
-
13
-
14
- Object.defineProperty(exports, 'default', {
15
- enumerable: true,
16
- get: function () { return server__default.default; }
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var server_exports = {};
30
+ __export(server_exports, {
31
+ default: () => import_server.default
17
32
  });
18
- Object.keys(constants).forEach(function (k) {
19
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
20
- enumerable: true,
21
- get: function () { return constants[k]; }
22
- });
33
+ module.exports = __toCommonJS(server_exports);
34
+ __reExport(server_exports, require("./constants"), module.exports);
35
+ var import_server = __toESM(require("./server"));
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ ...require("./constants")
23
39
  });
@@ -0,0 +1,4 @@
1
+ import { Migration } from '@nocobase/server';
2
+ export default class extends Migration {
3
+ up(): Promise<void>;
4
+ }
@@ -0,0 +1,60 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var fix_attachment_field_exports = {};
19
+ __export(fix_attachment_field_exports, {
20
+ default: () => fix_attachment_field_default
21
+ });
22
+ module.exports = __toCommonJS(fix_attachment_field_exports);
23
+ var import_server = require("@nocobase/server");
24
+ var import_database = require("@nocobase/database");
25
+ class fix_attachment_field_default extends import_server.Migration {
26
+ async up() {
27
+ const result = await this.app.version.satisfies("<0.13.0-alpha.5");
28
+ if (!result) {
29
+ return;
30
+ }
31
+ const r = this.db.getRepository("uiSchemas");
32
+ const items = await r.find({
33
+ filter: {
34
+ "schema.x-component": "CollectionField",
35
+ "schema.x-component-props.action": {
36
+ [import_database.Op.like]: "%:create?attachementField%"
37
+ }
38
+ }
39
+ });
40
+ console.log(items == null ? void 0 : items.length);
41
+ await this.db.sequelize.transaction(async (transaction) => {
42
+ for (const item of items) {
43
+ const schema = item.schema;
44
+ if (!schema["x-collection-field"]) {
45
+ continue;
46
+ }
47
+ const field = this.db.getFieldByPath(schema["x-collection-field"]);
48
+ if (!field) {
49
+ continue;
50
+ }
51
+ schema["x-component-props"].action = schema["x-component-props"].action.replace(
52
+ "attachementField",
53
+ "attachmentField"
54
+ );
55
+ item.set("schema", schema);
56
+ await item.save({ transaction });
57
+ }
58
+ });
59
+ }
60
+ }
@@ -1,14 +1,37 @@
1
- 'use strict';
2
-
3
- var mimetype = require('./mimetype');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var mimetype__default = /*#__PURE__*/_interopDefault(mimetype);
8
-
9
-
10
-
11
- Object.defineProperty(exports, 'mimetype', {
12
- enumerable: true,
13
- get: function () { return mimetype__default.default; }
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var rules_exports = {};
29
+ __export(rules_exports, {
30
+ mimetype: () => import_mimetype.default
31
+ });
32
+ module.exports = __toCommonJS(rules_exports);
33
+ var import_mimetype = __toESM(require("./mimetype"));
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ mimetype
14
37
  });
@@ -1,13 +1,36 @@
1
- 'use strict';
2
-
3
- var match = require('mime-match');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var match__default = /*#__PURE__*/_interopDefault(match);
8
-
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var mimetype_exports = {};
29
+ __export(mimetype_exports, {
30
+ default: () => mimetype_default
31
+ });
32
+ module.exports = __toCommonJS(mimetype_exports);
33
+ var import_mime_match = __toESM(require("mime-match"));
9
34
  function mimetype_default(file, options = "*") {
10
- return options.toString().split(",").some(match__default.default(file.mimetype));
35
+ return options.toString().split(",").some((0, import_mime_match.default)(file.mimetype));
11
36
  }
12
-
13
- module.exports = mimetype_default;