@nocobase/plugin-file-manager 0.5.0-alpha.38 → 0.7.0-alpha.2

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 (85) hide show
  1. package/LICENSE +201 -21
  2. package/esm/actions/upload.d.ts +3 -0
  3. package/esm/actions/upload.js +143 -0
  4. package/esm/actions/upload.js.map +1 -0
  5. package/esm/collections/attachments.d.ts +3 -0
  6. package/esm/collections/attachments.js +59 -0
  7. package/esm/collections/attachments.js.map +1 -0
  8. package/esm/collections/storages.d.ts +3 -0
  9. package/esm/collections/storages.js +60 -0
  10. package/esm/collections/storages.js.map +1 -0
  11. package/esm/constants.d.ts +6 -0
  12. package/esm/constants.js +7 -0
  13. package/esm/constants.js.map +1 -0
  14. package/esm/index.d.ts +2 -0
  15. package/esm/index.js +3 -0
  16. package/esm/index.js.map +1 -0
  17. package/esm/rules/index.d.ts +1 -0
  18. package/esm/rules/index.js +3 -0
  19. package/esm/rules/index.js.map +1 -0
  20. package/esm/rules/mimetype.d.ts +1 -0
  21. package/esm/rules/mimetype.js +5 -0
  22. package/esm/rules/mimetype.js.map +1 -0
  23. package/esm/server.d.ts +7 -0
  24. package/esm/server.js +48 -0
  25. package/esm/server.js.map +1 -0
  26. package/esm/storages/ali-oss.d.ts +16 -0
  27. package/esm/storages/ali-oss.js +26 -0
  28. package/esm/storages/ali-oss.js.map +1 -0
  29. package/esm/storages/index.d.ts +8 -0
  30. package/esm/storages/index.js +12 -0
  31. package/esm/storages/index.js.map +1 -0
  32. package/esm/storages/local.d.ts +14 -0
  33. package/esm/storages/local.js +127 -0
  34. package/esm/storages/local.js.map +1 -0
  35. package/esm/storages/s3.d.ts +17 -0
  36. package/esm/storages/s3.js +53 -0
  37. package/esm/storages/s3.js.map +1 -0
  38. package/esm/utils.d.ts +2 -0
  39. package/esm/utils.js +16 -0
  40. package/esm/utils.js.map +1 -0
  41. package/lib/actions/upload.js +145 -228
  42. package/lib/actions/upload.js.map +1 -1
  43. package/lib/collections/attachments.d.ts +2 -2
  44. package/lib/collections/attachments.js +58 -56
  45. package/lib/collections/attachments.js.map +1 -1
  46. package/lib/collections/storages.d.ts +2 -2
  47. package/lib/collections/storages.js +59 -62
  48. package/lib/collections/storages.js.map +1 -1
  49. package/lib/constants.js +2 -17
  50. package/lib/constants.js.map +1 -1
  51. package/lib/index.js +14 -47
  52. package/lib/index.js.map +1 -1
  53. package/lib/rules/index.js +6 -30
  54. package/lib/rules/index.js.map +1 -1
  55. package/lib/rules/mimetype.js +5 -26
  56. package/lib/rules/mimetype.js.map +1 -1
  57. package/lib/server.d.ts +7 -3
  58. package/lib/server.js +46 -95
  59. package/lib/server.js.map +1 -1
  60. package/lib/storages/ali-oss.js +23 -44
  61. package/lib/storages/ali-oss.js.map +1 -1
  62. package/lib/storages/index.js +5 -31
  63. package/lib/storages/index.js.map +1 -1
  64. package/lib/storages/local.d.ts +2 -1
  65. package/lib/storages/local.js +110 -198
  66. package/lib/storages/local.js.map +1 -1
  67. package/lib/storages/s3.js +49 -84
  68. package/lib/storages/s3.js.map +1 -1
  69. package/lib/utils.js +14 -39
  70. package/lib/utils.js.map +1 -1
  71. package/package.json +17 -3
  72. package/tsconfig.build.json +9 -0
  73. package/lib/actions/upload.d.ts.map +0 -1
  74. package/lib/collections/attachments.d.ts.map +0 -1
  75. package/lib/collections/storages.d.ts.map +0 -1
  76. package/lib/constants.d.ts.map +0 -1
  77. package/lib/index.d.ts.map +0 -1
  78. package/lib/rules/index.d.ts.map +0 -1
  79. package/lib/rules/mimetype.d.ts.map +0 -1
  80. package/lib/server.d.ts.map +0 -1
  81. package/lib/storages/ali-oss.d.ts.map +0 -1
  82. package/lib/storages/index.d.ts.map +0 -1
  83. package/lib/storages/local.d.ts.map +0 -1
  84. package/lib/storages/s3.d.ts.map +0 -1
  85. package/lib/utils.d.ts.map +0 -1
@@ -1,65 +1,62 @@
1
1
  "use strict";
2
-
3
- function _react() {
4
- const data = _interopRequireDefault(require("react"));
5
-
6
- _react = function _react() {
7
- return data;
8
- };
9
-
10
- return data;
11
- }
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- Object.defineProperty(exports, "__esModule", {
16
- value: true
17
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.default = {
19
- name: 'storages',
20
- title: '存储引擎',
21
- fields: [{
22
- title: '存储引擎名称',
23
- comment: '存储引擎名称',
24
- type: 'string',
25
- name: 'title'
26
- }, {
27
- title: '英文标识',
28
- type: 'string',
29
- name: 'name',
30
- unique: true
31
- }, {
32
- comment: '类型标识,如 local/ali-oss 等',
33
- type: 'string',
34
- name: 'type'
35
- }, {
36
- comment: '配置项',
37
- type: 'jsonb',
38
- name: 'options',
39
- defaultValue: {}
40
- }, {
41
- comment: '文件规则',
42
- type: 'jsonb',
43
- name: 'rules',
44
- defaultValue: {}
45
- }, {
46
- comment: '存储相对路径模板',
47
- type: 'string',
48
- name: 'path',
49
- defaultValue: ''
50
- }, {
51
- comment: '访问地址前缀',
52
- type: 'string',
53
- name: 'baseUrl',
54
- defaultValue: ''
55
- }, {
56
- comment: '默认引擎',
57
- type: 'boolean',
58
- name: 'default',
59
- defaultValue: false
60
- }, {
61
- type: 'hasMany',
62
- name: 'attachments'
63
- }]
4
+ name: 'storages',
5
+ title: '存储引擎',
6
+ fields: [
7
+ {
8
+ title: '存储引擎名称',
9
+ comment: '存储引擎名称',
10
+ type: 'string',
11
+ name: 'title',
12
+ },
13
+ {
14
+ title: '英文标识',
15
+ // comment: '英文标识,用于代码层面配置',
16
+ type: 'string',
17
+ name: 'name',
18
+ unique: true,
19
+ },
20
+ {
21
+ comment: '类型标识,如 local/ali-oss 等',
22
+ type: 'string',
23
+ name: 'type',
24
+ },
25
+ {
26
+ comment: '配置项',
27
+ type: 'jsonb',
28
+ name: 'options',
29
+ defaultValue: {},
30
+ },
31
+ {
32
+ comment: '文件规则',
33
+ type: 'jsonb',
34
+ name: 'rules',
35
+ defaultValue: {},
36
+ },
37
+ {
38
+ comment: '存储相对路径模板',
39
+ type: 'string',
40
+ name: 'path',
41
+ defaultValue: '',
42
+ },
43
+ {
44
+ comment: '访问地址前缀',
45
+ type: 'string',
46
+ name: 'baseUrl',
47
+ defaultValue: '',
48
+ },
49
+ // TODO(feature): 需要使用一个实现了可设置默认值的字段
50
+ {
51
+ comment: '默认引擎',
52
+ type: 'radio',
53
+ name: 'default',
54
+ defaultValue: false,
55
+ },
56
+ {
57
+ type: 'hasMany',
58
+ name: 'attachments',
59
+ },
60
+ ],
64
61
  };
65
- //# sourceMappingURL=storages.js.map
62
+ //# sourceMappingURL=storages.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["collections/storages.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACb,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,MAAM;IACb,MAAM,EAAE;QACN;YACE,KAAK,EAAE,QAAQ;YACf,OAAO,EAAE,QAAQ;YACjB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;SACd;QACD;YACE,KAAK,EAAE,MAAM;YAEb,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,IAAI;SACb;QACD;YACE,OAAO,EAAE,wBAAwB;YACjC,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;SACb;QACD;YACE,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,SAAS;YACf,YAAY,EAAE,EAAE;SACjB;QACD;YACE,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,OAAO;YACb,YAAY,EAAE,EAAE;SACjB;QACD;YACE,OAAO,EAAE,UAAU;YACnB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;YACZ,YAAY,EAAE,EAAE;SACjB;QACD;YACE,OAAO,EAAE,QAAQ;YACjB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,SAAS;YACf,YAAY,EAAE,EAAE;SACjB;QAED;YACE,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;YACf,YAAY,EAAE,KAAK;SACpB;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,aAAa;SACpB;KACF;CACc,CAAC","file":"storages.js","sourcesContent":["import { TableOptions } from '@nocobase/database';\n\nexport default {\n name: 'storages',\n title: '存储引擎',\n fields: [\n {\n title: '存储引擎名称',\n comment: '存储引擎名称',\n type: 'string',\n name: 'title',\n },\n {\n title: '英文标识',\n // comment: '英文标识,用于代码层面配置',\n type: 'string',\n name: 'name',\n unique: true,\n },\n {\n comment: '类型标识,如 local/ali-oss 等',\n type: 'string',\n name: 'type',\n },\n {\n comment: '配置项',\n type: 'jsonb',\n name: 'options',\n defaultValue: {}\n },\n {\n comment: '文件规则',\n type: 'jsonb',\n name: 'rules',\n defaultValue: {}\n },\n {\n comment: '存储相对路径模板',\n type: 'string',\n name: 'path',\n defaultValue: ''\n },\n {\n comment: '访问地址前缀',\n type: 'string',\n name: 'baseUrl',\n defaultValue: ''\n },\n // TODO(feature): 需要使用一个实现了可设置默认值的字段\n {\n comment: '默认引擎',\n type: 'boolean',\n name: 'default',\n defaultValue: false\n },\n {\n type: 'hasMany',\n name: 'attachments'\n }\n ]\n} as TableOptions;\n"]}
1
+ {"version":3,"file":"storages.js","sourceRoot":"","sources":["../../src/collections/storages.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACb,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,MAAM;IACb,MAAM,EAAE;QACN;YACE,KAAK,EAAE,QAAQ;YACf,OAAO,EAAE,QAAQ;YACjB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;SACd;QACD;YACE,KAAK,EAAE,MAAM;YACb,4BAA4B;YAC5B,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,IAAI;SACb;QACD;YACE,OAAO,EAAE,wBAAwB;YACjC,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;SACb;QACD;YACE,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,SAAS;YACf,YAAY,EAAE,EAAE;SACjB;QACD;YACE,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,OAAO;YACb,YAAY,EAAE,EAAE;SACjB;QACD;YACE,OAAO,EAAE,UAAU;YACnB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;YACZ,YAAY,EAAE,EAAE;SACjB;QACD;YACE,OAAO,EAAE,QAAQ;YACjB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,SAAS;YACf,YAAY,EAAE,EAAE;SACjB;QACD,oCAAoC;QACpC;YACE,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,SAAS;YACf,YAAY,EAAE,KAAK;SACpB;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,aAAa;SACpB;KACF;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'storages',\n title: '存储引擎',\n fields: [\n {\n title: '存储引擎名称',\n comment: '存储引擎名称',\n type: 'string',\n name: 'title',\n },\n {\n title: '英文标识',\n // comment: '英文标识,用于代码层面配置',\n type: 'string',\n name: 'name',\n unique: true,\n },\n {\n comment: '类型标识,如 local/ali-oss 等',\n type: 'string',\n name: 'type',\n },\n {\n comment: '配置项',\n type: 'jsonb',\n name: 'options',\n defaultValue: {},\n },\n {\n comment: '文件规则',\n type: 'jsonb',\n name: 'rules',\n defaultValue: {},\n },\n {\n comment: '存储相对路径模板',\n type: 'string',\n name: 'path',\n defaultValue: '',\n },\n {\n comment: '访问地址前缀',\n type: 'string',\n name: 'baseUrl',\n defaultValue: '',\n },\n // TODO(feature): 需要使用一个实现了可设置默认值的字段\n {\n comment: '默认引擎',\n type: 'radio',\n name: 'default',\n defaultValue: false,\n },\n {\n type: 'hasMany',\n name: 'attachments',\n },\n ],\n} as CollectionOptions;\n"]}
package/lib/constants.js CHANGED
@@ -1,20 +1,5 @@
1
1
  "use strict";
2
-
3
- function _react() {
4
- const data = _interopRequireDefault(require("react"));
5
-
6
- _react = function _react() {
7
- return data;
8
- };
9
-
10
- return data;
11
- }
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- Object.defineProperty(exports, "__esModule", {
16
- value: true
17
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.STORAGE_TYPE_S3 = exports.STORAGE_TYPE_ALI_OSS = exports.STORAGE_TYPE_LOCAL = exports.LIMIT_MAX_FILE_SIZE = exports.LIMIT_FILES = exports.FILE_FIELD_NAME = void 0;
19
4
  exports.FILE_FIELD_NAME = 'file';
20
5
  exports.LIMIT_FILES = 1;
@@ -22,4 +7,4 @@ exports.LIMIT_MAX_FILE_SIZE = 1024 * 1024 * 1024;
22
7
  exports.STORAGE_TYPE_LOCAL = 'local';
23
8
  exports.STORAGE_TYPE_ALI_OSS = 'ali-oss';
24
9
  exports.STORAGE_TYPE_S3 = 's3';
25
- //# sourceMappingURL=constants.js.map
10
+ //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,MAAM,CAAC;AACzB,QAAA,WAAW,GAAG,CAAC,CAAC;AAChB,QAAA,mBAAmB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzC,QAAA,kBAAkB,GAAG,OAAO,CAAC;AAC7B,QAAA,oBAAoB,GAAG,SAAS,CAAC;AACjC,QAAA,eAAe,GAAG,IAAI,CAAC","file":"constants.js","sourcesContent":["export const FILE_FIELD_NAME = 'file';\nexport const LIMIT_FILES = 1;\nexport const LIMIT_MAX_FILE_SIZE = 1024 * 1024 * 1024;\n\nexport const STORAGE_TYPE_LOCAL = 'local';\nexport const STORAGE_TYPE_ALI_OSS = 'ali-oss';\nexport const STORAGE_TYPE_S3 = 's3';\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,MAAM,CAAC;AACzB,QAAA,WAAW,GAAG,CAAC,CAAC;AAChB,QAAA,mBAAmB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzC,QAAA,kBAAkB,GAAG,OAAO,CAAC;AAC7B,QAAA,oBAAoB,GAAG,SAAS,CAAC;AACjC,QAAA,eAAe,GAAG,IAAI,CAAC","sourcesContent":["export const FILE_FIELD_NAME = 'file';\nexport const LIMIT_FILES = 1;\nexport const LIMIT_MAX_FILE_SIZE = 1024 * 1024 * 1024;\n\nexport const STORAGE_TYPE_LOCAL = 'local';\nexport const STORAGE_TYPE_ALI_OSS = 'ali-oss';\nexport const STORAGE_TYPE_S3 = 's3';\n"]}
package/lib/index.js CHANGED
@@ -1,53 +1,20 @@
1
1
  "use strict";
2
-
3
- function _react() {
4
- const data = _interopRequireDefault(require("react"));
5
-
6
- _react = function _react() {
7
- return data;
8
- };
9
-
10
- return data;
11
- }
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- Object.defineProperty(o, k2, {
18
- enumerable: true,
19
- get: function get() {
20
- return m[k];
21
- }
22
- });
23
- } : function (o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- o[k2] = m[k];
26
- });
27
-
28
- var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
29
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
30
11
  };
31
-
32
- var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
33
- return mod && mod.__esModule ? mod : {
34
- "default": mod
35
- };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
14
  };
37
-
38
- Object.defineProperty(exports, "__esModule", {
39
- value: true
40
- });
15
+ Object.defineProperty(exports, "__esModule", { value: true });
41
16
  exports.default = void 0;
42
-
43
17
  __exportStar(require("./constants"), exports);
44
-
45
18
  var server_1 = require("./server");
46
-
47
- Object.defineProperty(exports, "default", {
48
- enumerable: true,
49
- get: function get() {
50
- return __importDefault(server_1).default;
51
- }
52
- });
53
- //# sourceMappingURL=index.js.map
19
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(server_1).default; } });
20
+ //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,mCAAmC;AAA1B,kHAAA,OAAO,OAAA","file":"index.js","sourcesContent":["export * from './constants';\nexport { default } from './server';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,mCAAmC;AAA1B,kHAAA,OAAO,OAAA","sourcesContent":["export * from './constants';\nexport { default } from './server';\n\n"]}
@@ -1,34 +1,10 @@
1
1
  "use strict";
2
-
3
- function _react() {
4
- const data = _interopRequireDefault(require("react"));
5
-
6
- _react = function _react() {
7
- return data;
8
- };
9
-
10
- return data;
11
- }
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
16
- return mod && mod.__esModule ? mod : {
17
- "default": mod
18
- };
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
4
  };
20
-
21
- Object.defineProperty(exports, "__esModule", {
22
- value: true
23
- });
5
+ Object.defineProperty(exports, "__esModule", { value: true });
24
6
  exports.mimetype = void 0;
25
-
26
7
  var mimetype_1 = require("./mimetype");
27
-
28
- Object.defineProperty(exports, "mimetype", {
29
- enumerable: true,
30
- get: function get() {
31
- return __importDefault(mimetype_1).default;
32
- }
33
- });
34
- //# sourceMappingURL=index.js.map
8
+ Object.defineProperty(exports, "mimetype", { enumerable: true, get: function () { return __importDefault(mimetype_1).default; } });
9
+ // TODO(feature): 提供注册新规则的方法,规则可动态添加
10
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["rules/index.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAiD;AAAxC,qHAAA,OAAO,OAAY","file":"index.js","sourcesContent":["export { default as mimetype } from './mimetype';\n\n// TODO(feature): 提供注册新规则的方法,规则可动态添加\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAiD;AAAxC,qHAAA,OAAO,OAAY;AAE5B,oCAAoC","sourcesContent":["export { default as mimetype } from './mimetype';\n\n// TODO(feature): 提供注册新规则的方法,规则可动态添加\n"]}
@@ -1,32 +1,11 @@
1
1
  "use strict";
2
-
3
- function _react() {
4
- const data = _interopRequireDefault(require("react"));
5
-
6
- _react = function _react() {
7
- return data;
8
- };
9
-
10
- return data;
11
- }
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
16
- return mod && mod.__esModule ? mod : {
17
- "default": mod
18
- };
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
4
  };
20
-
21
- Object.defineProperty(exports, "__esModule", {
22
- value: true
23
- });
24
-
5
+ Object.defineProperty(exports, "__esModule", { value: true });
25
6
  const mime_match_1 = __importDefault(require("mime-match"));
26
-
27
7
  function default_1(file, options = '*', ctx) {
28
- return options.toString().split(',').some((0, mime_match_1.default)(file.mimetype));
8
+ return options.toString().split(',').some((0, mime_match_1.default)(file.mimetype));
29
9
  }
30
-
31
10
  exports.default = default_1;
32
- //# sourceMappingURL=mimetype.js.map
11
+ //# sourceMappingURL=mimetype.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["rules/mimetype.ts"],"names":[],"mappings":";;;;;AAAA,4DAA+B;AAE/B,mBAAyB,IAAI,EAAE,UAA6B,GAAG,EAAE,GAAG;IAClE,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,4BAEC","file":"mimetype.js","sourcesContent":["import match from 'mime-match';\n\nexport default function (file, options: string | string[] = '*', ctx): boolean {\n return options.toString().split(',').some(match(file.mimetype));\n}\n"]}
1
+ {"version":3,"file":"mimetype.js","sourceRoot":"","sources":["../../src/rules/mimetype.ts"],"names":[],"mappings":";;;;;AAAA,4DAA+B;AAE/B,mBAAyB,IAAI,EAAE,UAA6B,GAAG,EAAE,GAAG;IAClE,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,4BAEC","sourcesContent":["import match from 'mime-match';\n\nexport default function (file, options: string | string[] = '*', ctx): boolean {\n return options.toString().split(',').some(match(file.mimetype));\n}\n"]}
package/lib/server.d.ts CHANGED
@@ -1,3 +1,7 @@
1
- import { PluginOptions } from '@nocobase/server';
2
- declare const _default: PluginOptions;
3
- export default _default;
1
+ import { Plugin } from '@nocobase/server';
2
+ export default class PluginFileManager extends Plugin {
3
+ storageType(): string;
4
+ install(): Promise<void>;
5
+ load(): Promise<void>;
6
+ getName(): string;
7
+ }
package/lib/server.js CHANGED
@@ -1,100 +1,51 @@
1
1
  "use strict";
2
-
3
- function _react() {
4
- const data = _interopRequireDefault(require("react"));
5
-
6
- _react = function _react() {
7
- return data;
8
- };
9
-
10
- return data;
11
- }
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
16
- function adopt(value) {
17
- return value instanceof P ? value : new P(function (resolve) {
18
- resolve(value);
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
9
  });
20
- }
21
-
22
- return new (P || (P = Promise))(function (resolve, reject) {
23
- function fulfilled(value) {
24
- try {
25
- step(generator.next(value));
26
- } catch (e) {
27
- reject(e);
28
- }
29
- }
30
-
31
- function rejected(value) {
32
- try {
33
- step(generator["throw"](value));
34
- } catch (e) {
35
- reject(e);
36
- }
37
- }
38
-
39
- function step(result) {
40
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
41
- }
42
-
43
- step((generator = generator.apply(thisArg, _arguments || [])).next());
44
- });
45
10
  };
46
-
47
- var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
48
- return mod && mod.__esModule ? mod : {
49
- "default": mod
50
- };
51
- };
52
-
53
- Object.defineProperty(exports, "__esModule", {
54
- value: true
55
- });
56
-
57
- const path_1 = __importDefault(require("path"));
58
-
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const server_1 = require("@nocobase/server");
13
+ const path_1 = require("path");
59
14
  const upload_1 = require("./actions/upload");
60
-
61
- const storages_1 = require("./storages");
62
-
63
15
  const constants_1 = require("./constants");
64
-
65
- exports.default = {
66
- name: 'file-manager',
67
-
68
- load() {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- const database = this.app.db;
71
- const resourcer = this.app.resourcer;
72
- database.import({
73
- directory: path_1.default.resolve(__dirname, 'collections')
74
- });
75
- resourcer.use(upload_1.middleware);
76
- resourcer.registerActionHandler('upload', upload_1.action);
77
- const DEFAULT_STORAGE_TYPE = process.env.DEFAULT_STORAGE_TYPE;
78
-
79
- if (process.env.NOCOBASE_ENV !== 'production') {
80
- this.app.on('beforeStart', () => __awaiter(this, void 0, void 0, function* () {
81
- yield (0, storages_1.getStorageConfig)(constants_1.STORAGE_TYPE_LOCAL).middleware(this.app);
82
- }));
83
- }
84
-
85
- this.app.on('db.init', () => __awaiter(this, void 0, void 0, function* () {
86
- const defaultStorageConfig = (0, storages_1.getStorageConfig)(DEFAULT_STORAGE_TYPE);
87
-
88
- if (defaultStorageConfig) {
89
- const StorageModel = database.getModel('storages');
90
- yield StorageModel.create(Object.assign(Object.assign({}, defaultStorageConfig.defaults()), {
91
- type: DEFAULT_STORAGE_TYPE,
92
- default: true
93
- }));
94
- }
95
- }));
96
- });
97
- }
98
-
99
- };
100
- //# sourceMappingURL=server.js.map
16
+ const storages_1 = require("./storages");
17
+ class PluginFileManager extends server_1.Plugin {
18
+ storageType() {
19
+ return process.env.DEFAULT_STORAGE_TYPE;
20
+ }
21
+ install() {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const defaultStorageConfig = (0, storages_1.getStorageConfig)(this.storageType());
24
+ if (defaultStorageConfig) {
25
+ const Storage = this.db.getCollection('storages');
26
+ yield Storage.repository.create({
27
+ values: Object.assign(Object.assign({}, defaultStorageConfig.defaults()), { type: this.storageType(), default: true }),
28
+ });
29
+ }
30
+ });
31
+ }
32
+ load() {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ yield this.db.import({
35
+ directory: (0, path_1.resolve)(__dirname, 'collections'),
36
+ });
37
+ // 暂时中间件只能通过 use 加进来
38
+ this.app.resourcer.use(upload_1.middleware);
39
+ this.app.resourcer.registerActionHandler('upload', upload_1.action);
40
+ if (process.env.NOCOBASE_ENV !== 'production') {
41
+ yield (0, storages_1.getStorageConfig)(constants_1.STORAGE_TYPE_LOCAL).middleware(this.app);
42
+ }
43
+ this.app.acl.allow('attachments', 'upload', 'loggedIn');
44
+ });
45
+ }
46
+ getName() {
47
+ return this.getPackageName(__dirname);
48
+ }
49
+ }
50
+ exports.default = PluginFileManager;
51
+ //# sourceMappingURL=server.js.map
package/lib/server.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gDAAwB;AAKxB,6CAG0B;AAC1B,yCAA8C;AAC9C,2CAAiD;AAEjD,kBAAe;IACb,IAAI,EAAE,cAAc;IACd,IAAI;;YACR,MAAM,QAAQ,GAAa,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACvC,MAAM,SAAS,GAAc,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;YAEhD,QAAQ,CAAC,MAAM,CAAC;gBACd,SAAS,EAAE,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC;aAClD,CAAC,CAAC;YAGH,SAAS,CAAC,GAAG,CAAC,mBAAgB,CAAC,CAAC;YAChC,SAAS,CAAC,qBAAqB,CAAC,QAAQ,EAAE,eAAY,CAAC,CAAC;YAExD,MAAM,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;YAE7C,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,YAAY,EAAE;gBAC7C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,aAAa,EAAE,GAAS,EAAE;oBACpC,MAAM,IAAA,2BAAgB,EAAC,8BAAkB,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClE,CAAC,CAAA,CAAC,CAAC;aACJ;YAED,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,GAAS,EAAE;gBAChC,MAAM,oBAAoB,GAAG,IAAA,2BAAgB,EAAC,oBAAoB,CAAC,CAAC;gBACpE,IAAI,oBAAoB,EAAE;oBACxB,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;oBACnD,MAAM,YAAY,CAAC,MAAM,iCACpB,oBAAoB,CAAC,QAAQ,EAAE,KAClC,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAE,IAAI,IACb,CAAC;iBACJ;YACH,CAAC,CAAA,CAAC,CAAC;QACL,CAAC;KAAA;CACe,CAAC","file":"server.js","sourcesContent":["import path from 'path';\nimport Database from '@nocobase/database';\nimport Resourcer from '@nocobase/resourcer';\nimport { PluginOptions } from '@nocobase/server';\n\nimport {\n action as uploadAction,\n middleware as uploadMiddleware,\n} from './actions/upload';\nimport { getStorageConfig } from './storages';\nimport { STORAGE_TYPE_LOCAL } from './constants';\n\nexport default {\n name: 'file-manager',\n async load() {\n const database: Database = this.app.db;\n const resourcer: Resourcer = this.app.resourcer;\n \n database.import({\n directory: path.resolve(__dirname, 'collections'),\n });\n \n // 暂时中间件只能通过 use 加进来\n resourcer.use(uploadMiddleware);\n resourcer.registerActionHandler('upload', uploadAction);\n\n const { DEFAULT_STORAGE_TYPE } = process.env;\n\n if (process.env.NOCOBASE_ENV !== 'production') {\n this.app.on('beforeStart', async () => {\n await getStorageConfig(STORAGE_TYPE_LOCAL).middleware(this.app);\n });\n }\n\n this.app.on('db.init', async () => {\n const defaultStorageConfig = getStorageConfig(DEFAULT_STORAGE_TYPE);\n if (defaultStorageConfig) {\n const StorageModel = database.getModel('storages');\n await StorageModel.create({\n ...defaultStorageConfig.defaults(),\n type: DEFAULT_STORAGE_TYPE,\n default: true\n });\n }\n });\n },\n} as PluginOptions;\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6CAA0C;AAC1C,+BAA+B;AAC/B,6CAA0F;AAC1F,2CAAiD;AACjD,yCAA8C;AAE9C,MAAqB,iBAAkB,SAAQ,eAAM;IACnD,WAAW;QACT,OAAO,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;IAC1C,CAAC;IAEK,OAAO;;YACX,MAAM,oBAAoB,GAAG,IAAA,2BAAgB,EAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;YAClE,IAAI,oBAAoB,EAAE;gBACxB,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;gBAClD,MAAM,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;oBAC9B,MAAM,kCACD,oBAAoB,CAAC,QAAQ,EAAE,KAClC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,EACxB,OAAO,EAAE,IAAI,GACd;iBACF,CAAC,CAAC;aACJ;QACH,CAAC;KAAA;IAEK,IAAI;;YACR,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;gBACnB,SAAS,EAAE,IAAA,cAAO,EAAC,SAAS,EAAE,aAAa,CAAC;aAC7C,CAAC,CAAC;YAEH,oBAAoB;YACpB,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,mBAAgB,CAAC,CAAC;YACzC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,qBAAqB,CAAC,QAAQ,EAAE,eAAY,CAAC,CAAC;YAEjE,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,YAAY,EAAE;gBAC7C,MAAM,IAAA,2BAAgB,EAAC,8BAAkB,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACjE;YAED,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC1D,CAAC;KAAA;IAED,OAAO;QACL,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CACF;AAtCD,oCAsCC","sourcesContent":["import { Plugin } from '@nocobase/server';\nimport { resolve } from 'path';\nimport { action as uploadAction, middleware as uploadMiddleware } from './actions/upload';\nimport { STORAGE_TYPE_LOCAL } from './constants';\nimport { getStorageConfig } from './storages';\n\nexport default class PluginFileManager extends Plugin {\n storageType() {\n return process.env.DEFAULT_STORAGE_TYPE;\n }\n\n async install() {\n const defaultStorageConfig = getStorageConfig(this.storageType());\n if (defaultStorageConfig) {\n const Storage = this.db.getCollection('storages');\n await Storage.repository.create({\n values: {\n ...defaultStorageConfig.defaults(),\n type: this.storageType(),\n default: true,\n },\n });\n }\n }\n\n async load() {\n await this.db.import({\n directory: resolve(__dirname, 'collections'),\n });\n\n // 暂时中间件只能通过 use 加进来\n this.app.resourcer.use(uploadMiddleware);\n this.app.resourcer.registerActionHandler('upload', uploadAction);\n\n if (process.env.NOCOBASE_ENV !== 'production') {\n await getStorageConfig(STORAGE_TYPE_LOCAL).middleware(this.app);\n }\n\n this.app.acl.allow('attachments', 'upload', 'loggedIn');\n }\n\n getName(): string {\n return this.getPackageName(__dirname);\n }\n}\n"]}
@@ -1,49 +1,28 @@
1
1
  "use strict";
2
-
3
- function _react() {
4
- const data = _interopRequireDefault(require("react"));
5
-
6
- _react = function _react() {
7
- return data;
8
- };
9
-
10
- return data;
11
- }
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- Object.defineProperty(exports, "__esModule", {
16
- value: true
17
- });
18
-
2
+ Object.defineProperty(exports, "__esModule", { value: true });
19
3
  const constants_1 = require("../constants");
20
-
21
4
  const utils_1 = require("../utils");
22
-
23
5
  exports.default = {
24
- make(storage) {
25
- const createAliOssStorage = require('multer-aliyun-oss');
26
-
27
- return new createAliOssStorage({
28
- config: storage.options,
29
- filename: (0, utils_1.cloudFilenameGetter)(storage)
30
- });
31
- },
32
-
33
- defaults() {
34
- return {
35
- title: '阿里云对象存储',
36
- type: constants_1.STORAGE_TYPE_ALI_OSS,
37
- name: 'ali-oss-1',
38
- baseUrl: process.env.ALI_OSS_STORAGE_BASE_URL,
39
- options: {
40
- region: process.env.ALI_OSS_REGION,
41
- accessKeyId: process.env.ALI_OSS_ACCESS_KEY_ID,
42
- accessKeySecret: process.env.ALI_OSS_ACCESS_KEY_SECRET,
43
- bucket: process.env.ALI_OSS_BUCKET
44
- }
45
- };
46
- }
47
-
6
+ make(storage) {
7
+ const createAliOssStorage = require('multer-aliyun-oss');
8
+ return new createAliOssStorage({
9
+ config: storage.options,
10
+ filename: (0, utils_1.cloudFilenameGetter)(storage),
11
+ });
12
+ },
13
+ defaults() {
14
+ return {
15
+ title: '阿里云对象存储',
16
+ type: constants_1.STORAGE_TYPE_ALI_OSS,
17
+ name: 'ali-oss-1',
18
+ baseUrl: process.env.ALI_OSS_STORAGE_BASE_URL,
19
+ options: {
20
+ region: process.env.ALI_OSS_REGION,
21
+ accessKeyId: process.env.ALI_OSS_ACCESS_KEY_ID,
22
+ accessKeySecret: process.env.ALI_OSS_ACCESS_KEY_SECRET,
23
+ bucket: process.env.ALI_OSS_BUCKET,
24
+ },
25
+ };
26
+ },
48
27
  };
49
- //# sourceMappingURL=ali-oss.js.map
28
+ //# sourceMappingURL=ali-oss.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["storages/ali-oss.ts"],"names":[],"mappings":";;AAAA,4CAAoD;AACpD,oCAA+C;AAE/C,kBAAe;IACb,IAAI,CAAC,OAAO;QACV,MAAM,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACzD,OAAO,IAAI,mBAAmB,CAAC;YAC7B,MAAM,EAAE,OAAO,CAAC,OAAO;YACvB,QAAQ,EAAE,IAAA,2BAAmB,EAAC,OAAO,CAAC;SACvC,CAAC,CAAC;IACL,CAAC;IACD,QAAQ;QACN,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,gCAAoB;YAC1B,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB;YAC7C,OAAO,EAAE;gBACP,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;gBAClC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;gBAC9C,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB;gBACtD,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;aACnC;SACF,CAAA;IACH,CAAC;CACF,CAAA","file":"ali-oss.js","sourcesContent":["import { STORAGE_TYPE_ALI_OSS } from '../constants';\nimport { cloudFilenameGetter } from '../utils';\n\nexport default {\n make(storage) {\n const createAliOssStorage = require('multer-aliyun-oss');\n return new createAliOssStorage({\n config: storage.options,\n filename: cloudFilenameGetter(storage)\n });\n },\n defaults() {\n return {\n title: '阿里云对象存储',\n type: STORAGE_TYPE_ALI_OSS,\n name: 'ali-oss-1',\n baseUrl: process.env.ALI_OSS_STORAGE_BASE_URL,\n options: {\n region: process.env.ALI_OSS_REGION,\n accessKeyId: process.env.ALI_OSS_ACCESS_KEY_ID,\n accessKeySecret: process.env.ALI_OSS_ACCESS_KEY_SECRET,\n bucket: process.env.ALI_OSS_BUCKET,\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ali-oss.js","sourceRoot":"","sources":["../../src/storages/ali-oss.ts"],"names":[],"mappings":";;AAAA,4CAAoD;AACpD,oCAA+C;AAE/C,kBAAe;IACb,IAAI,CAAC,OAAO;QACV,MAAM,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACzD,OAAO,IAAI,mBAAmB,CAAC;YAC7B,MAAM,EAAE,OAAO,CAAC,OAAO;YACvB,QAAQ,EAAE,IAAA,2BAAmB,EAAC,OAAO,CAAC;SACvC,CAAC,CAAC;IACL,CAAC;IACD,QAAQ;QACN,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,gCAAoB;YAC1B,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB;YAC7C,OAAO,EAAE;gBACP,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;gBAClC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;gBAC9C,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB;gBACtD,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;aACnC;SACF,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { STORAGE_TYPE_ALI_OSS } from '../constants';\nimport { cloudFilenameGetter } from '../utils';\n\nexport default {\n make(storage) {\n const createAliOssStorage = require('multer-aliyun-oss');\n return new createAliOssStorage({\n config: storage.options,\n filename: cloudFilenameGetter(storage),\n });\n },\n defaults() {\n return {\n title: '阿里云对象存储',\n type: STORAGE_TYPE_ALI_OSS,\n name: 'ali-oss-1',\n baseUrl: process.env.ALI_OSS_STORAGE_BASE_URL,\n options: {\n region: process.env.ALI_OSS_REGION,\n accessKeyId: process.env.ALI_OSS_ACCESS_KEY_ID,\n accessKeySecret: process.env.ALI_OSS_ACCESS_KEY_SECRET,\n bucket: process.env.ALI_OSS_BUCKET,\n },\n };\n },\n};\n"]}