@nocobase/plugin-file-manager 0.7.6-alpha.2 → 0.8.0-alpha.4

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.
@@ -0,0 +1 @@
1
+ export declare const FileStoragePane: () => JSX.Element;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FileStoragePane = void 0;
7
+
8
+ function _shared() {
9
+ const data = require("@formily/shared");
10
+
11
+ _shared = function _shared() {
12
+ return data;
13
+ };
14
+
15
+ return data;
16
+ }
17
+
18
+ function _client() {
19
+ const data = require("@nocobase/client");
20
+
21
+ _client = function _client() {
22
+ return data;
23
+ };
24
+
25
+ return data;
26
+ }
27
+
28
+ function _antd() {
29
+ const data = require("antd");
30
+
31
+ _antd = function _antd() {
32
+ return data;
33
+ };
34
+
35
+ return data;
36
+ }
37
+
38
+ function _react() {
39
+ const data = _interopRequireWildcard(require("react"));
40
+
41
+ _react = function _react() {
42
+ return data;
43
+ };
44
+
45
+ return data;
46
+ }
47
+
48
+ function _reactI18next() {
49
+ const data = require("react-i18next");
50
+
51
+ _reactI18next = function _reactI18next() {
52
+ return data;
53
+ };
54
+
55
+ return data;
56
+ }
57
+
58
+ var _storage = require("./schemas/storage");
59
+
60
+ var _StorageOptions = require("./StorageOptions");
61
+
62
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
63
+
64
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
65
+
66
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
67
+
68
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
69
+
70
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
71
+
72
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
73
+
74
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
75
+
76
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
77
+
78
+ const schema = {
79
+ type: 'object',
80
+ properties: {
81
+ [(0, _shared().uid)()]: _storage.storageSchema
82
+ }
83
+ };
84
+
85
+ const FileStoragePane = () => {
86
+ const _useState = (0, _react().useState)(false),
87
+ _useState2 = _slicedToArray(_useState, 2),
88
+ visible = _useState2[0],
89
+ setVisible = _useState2[1];
90
+
91
+ const _useTranslation = (0, _reactI18next().useTranslation)(),
92
+ t = _useTranslation.t;
93
+
94
+ return _react().default.createElement(_antd().Card, {
95
+ bordered: false
96
+ }, _react().default.createElement(_client().SchemaComponent, {
97
+ components: {
98
+ StorageOptions: _StorageOptions.StorageOptions
99
+ },
100
+ schema: schema
101
+ }));
102
+ };
103
+
104
+ exports.FileStoragePane = FileStoragePane;
@@ -25,30 +25,30 @@ function _shared() {
25
25
  return data;
26
26
  }
27
27
 
28
- function _react() {
29
- const data = _interopRequireWildcard(require("react"));
28
+ function _client() {
29
+ const data = require("@nocobase/client");
30
30
 
31
- _react = function _react() {
31
+ _client = function _client() {
32
32
  return data;
33
33
  };
34
34
 
35
35
  return data;
36
36
  }
37
37
 
38
- function _reactI18next() {
39
- const data = require("react-i18next");
38
+ function _react() {
39
+ const data = _interopRequireWildcard(require("react"));
40
40
 
41
- _reactI18next = function _reactI18next() {
41
+ _react = function _react() {
42
42
  return data;
43
43
  };
44
44
 
45
45
  return data;
46
46
  }
47
47
 
48
- function _client() {
49
- const data = require("@nocobase/client");
48
+ function _reactI18next() {
49
+ const data = require("react-i18next");
50
50
 
51
- _client = function _client() {
51
+ _reactI18next = function _reactI18next() {
52
52
  return data;
53
53
  };
54
54
 
@@ -114,6 +114,38 @@ const schema = {
114
114
  }
115
115
  }
116
116
  },
117
+ 'tx-cos': {
118
+ properties: {
119
+ Region: {
120
+ title: '{{t("Region")}}',
121
+ type: 'string',
122
+ 'x-decorator': 'FormItem',
123
+ 'x-component': 'Input',
124
+ required: true
125
+ },
126
+ SecretId: {
127
+ title: '{{t("SecretId")}}',
128
+ type: 'string',
129
+ 'x-decorator': 'FormItem',
130
+ 'x-component': 'Input',
131
+ required: true
132
+ },
133
+ SecretKey: {
134
+ title: '{{t("SecretKey")}}',
135
+ type: 'string',
136
+ 'x-decorator': 'FormItem',
137
+ 'x-component': 'Password',
138
+ required: true
139
+ },
140
+ Bucket: {
141
+ title: '{{t("Bucket")}}',
142
+ type: 'string',
143
+ 'x-decorator': 'FormItem',
144
+ 'x-component': 'Input',
145
+ required: true
146
+ }
147
+ }
148
+ },
117
149
  s3: {
118
150
  properties: {
119
151
  region: {
@@ -5,26 +5,28 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = _default;
7
7
 
8
- function _react() {
9
- const data = _interopRequireWildcard(require("react"));
8
+ function _client() {
9
+ const data = require("@nocobase/client");
10
10
 
11
- _react = function _react() {
11
+ _client = function _client() {
12
12
  return data;
13
13
  };
14
14
 
15
15
  return data;
16
16
  }
17
17
 
18
- function _client() {
19
- const data = require("@nocobase/client");
18
+ function _react() {
19
+ const data = _interopRequireWildcard(require("react"));
20
20
 
21
- _client = function _client() {
21
+ _react = function _react() {
22
22
  return data;
23
23
  };
24
24
 
25
25
  return data;
26
26
  }
27
27
 
28
+ var _FileStorage = require("./FileStorage");
29
+
28
30
  var _FileStorageShortcut = require("./FileStorageShortcut");
29
31
 
30
32
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -39,13 +41,24 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
39
41
 
40
42
  function _default(props) {
41
43
  const ctx = (0, _react().useContext)(_client().PluginManagerContext);
42
- return _react().default.createElement(_client().PluginManagerContext.Provider, {
44
+ return _react().default.createElement(_client().SettingsCenterProvider, {
45
+ settings: {
46
+ 'file-manager': {
47
+ title: '{{t("File manager")}}',
48
+ icon: 'FileOutlined',
49
+ tabs: {
50
+ storages: {
51
+ title: '{{t("File storages")}}',
52
+ component: _FileStorage.FileStoragePane
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }, _react().default.createElement(_client().PluginManagerContext.Provider, {
43
58
  value: {
44
59
  components: _objectSpread(_objectSpread({}, ctx === null || ctx === void 0 ? void 0 : ctx.components), {}, {
45
60
  FileStorageShortcut: _FileStorageShortcut.FileStorageShortcut
46
61
  })
47
62
  }
48
- }, props.children);
49
- }
50
-
51
- ;
63
+ }, props.children));
64
+ }
@@ -70,6 +70,9 @@ const collection = {
70
70
  }, {
71
71
  label: '{{t("Amazon S3")}}',
72
72
  value: 's3'
73
+ }, {
74
+ label: '{{t("Tencent COS")}}',
75
+ value: 'tx-cos'
73
76
  }]
74
77
  }
75
78
  }, {
@@ -4,3 +4,4 @@ export declare const LIMIT_MAX_FILE_SIZE: number;
4
4
  export declare const STORAGE_TYPE_LOCAL = "local";
5
5
  export declare const STORAGE_TYPE_ALI_OSS = "ali-oss";
6
6
  export declare const STORAGE_TYPE_S3 = "s3";
7
+ export declare const STORAGE_TYPE_TX_COS = "tx-cos";
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.STORAGE_TYPE_S3 = exports.STORAGE_TYPE_LOCAL = exports.STORAGE_TYPE_ALI_OSS = exports.LIMIT_MAX_FILE_SIZE = exports.LIMIT_FILES = exports.FILE_FIELD_NAME = void 0;
6
+ exports.STORAGE_TYPE_TX_COS = exports.STORAGE_TYPE_S3 = exports.STORAGE_TYPE_LOCAL = exports.STORAGE_TYPE_ALI_OSS = exports.LIMIT_MAX_FILE_SIZE = exports.LIMIT_FILES = exports.FILE_FIELD_NAME = void 0;
7
7
  const FILE_FIELD_NAME = 'file';
8
8
  exports.FILE_FIELD_NAME = FILE_FIELD_NAME;
9
9
  const LIMIT_FILES = 1;
@@ -15,4 +15,6 @@ exports.STORAGE_TYPE_LOCAL = STORAGE_TYPE_LOCAL;
15
15
  const STORAGE_TYPE_ALI_OSS = 'ali-oss';
16
16
  exports.STORAGE_TYPE_ALI_OSS = STORAGE_TYPE_ALI_OSS;
17
17
  const STORAGE_TYPE_S3 = 's3';
18
- exports.STORAGE_TYPE_S3 = STORAGE_TYPE_S3;
18
+ exports.STORAGE_TYPE_S3 = STORAGE_TYPE_S3;
19
+ const STORAGE_TYPE_TX_COS = 'tx-cos';
20
+ exports.STORAGE_TYPE_TX_COS = STORAGE_TYPE_TX_COS;
@@ -3,5 +3,4 @@ export default class PluginFileManager extends Plugin {
3
3
  storageType(): string;
4
4
  install(): Promise<void>;
5
5
  load(): Promise<void>;
6
- getName(): string;
7
6
  }
@@ -85,10 +85,6 @@ class PluginFileManager extends _server().Plugin {
85
85
  })();
86
86
  }
87
87
 
88
- getName() {
89
- return this.getPackageName(__dirname);
90
- }
91
-
92
88
  }
93
89
 
94
90
  exports.default = PluginFileManager;
@@ -11,6 +11,8 @@ var _aliOss = _interopRequireDefault(require("./ali-oss"));
11
11
 
12
12
  var _s = _interopRequireDefault(require("./s3"));
13
13
 
14
+ var _txCos = _interopRequireDefault(require("./tx-cos"));
15
+
14
16
  var _constants = require("../constants");
15
17
 
16
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -19,6 +21,7 @@ const map = new Map();
19
21
  map.set(_constants.STORAGE_TYPE_LOCAL, _local.default);
20
22
  map.set(_constants.STORAGE_TYPE_ALI_OSS, _aliOss.default);
21
23
  map.set(_constants.STORAGE_TYPE_S3, _s.default);
24
+ map.set(_constants.STORAGE_TYPE_TX_COS, _txCos.default);
22
25
 
23
26
  function getStorageConfig(key) {
24
27
  return map.get(key);
@@ -0,0 +1,17 @@
1
+ declare const _default: {
2
+ filenameKey: string;
3
+ make(storage: any): any;
4
+ defaults(): {
5
+ title: string;
6
+ type: string;
7
+ name: string;
8
+ baseUrl: string;
9
+ options: {
10
+ Region: string;
11
+ SecretId: string;
12
+ SecretKey: string;
13
+ Bucket: string;
14
+ };
15
+ };
16
+ };
17
+ export default _default;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _constants = require("../constants");
9
+
10
+ var _utils = require("../utils");
11
+
12
+ var _default = {
13
+ filenameKey: 'url',
14
+
15
+ make(storage) {
16
+ const createTxCosStorage = require('multer-cos');
17
+
18
+ return new createTxCosStorage({
19
+ cos: storage.options,
20
+ filename: (0, _utils.cloudFilenameGetter)(storage)
21
+ });
22
+ },
23
+
24
+ defaults() {
25
+ return {
26
+ title: '腾讯云对象存储',
27
+ type: _constants.STORAGE_TYPE_TX_COS,
28
+ name: 'tx-cos-1',
29
+ baseUrl: process.env.TX_COS_STORAGE_BASE_URL,
30
+ options: {
31
+ Region: process.env.TX_COS_REGION,
32
+ SecretId: process.env.TX_COS_SECRET_ID,
33
+ SecretKey: process.env.TX_COS_SECRET_KEY,
34
+ Bucket: process.env.TX_COS_BUCKET
35
+ }
36
+ };
37
+ }
38
+
39
+ };
40
+ exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-file-manager",
3
- "version": "0.7.6-alpha.2",
3
+ "version": "0.8.0-alpha.4",
4
4
  "main": "lib/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "licenses": [
@@ -11,22 +11,22 @@
11
11
  ],
12
12
  "dependencies": {
13
13
  "@koa/multer": "^3.0.0",
14
- "@nocobase/actions": "0.7.6-alpha.2",
15
- "@nocobase/client": "0.7.6-alpha.2",
16
- "@nocobase/database": "0.7.6-alpha.2",
17
- "@nocobase/server": "0.7.6-alpha.2",
14
+ "@nocobase/client": "0.8.0-alpha.4",
15
+ "@nocobase/server": "0.8.0-alpha.4",
18
16
  "aws-sdk": "^2.2.32",
17
+ "cos-nodejs-sdk-v5": "^2.11.14",
19
18
  "koa-static": "^5.0.0",
20
19
  "mime-match": "^1.0.2",
21
20
  "mkdirp": "~0.5.4",
22
21
  "multer": "^1.4.2",
23
22
  "multer-aliyun-oss": "2.1.1",
23
+ "multer-cos": "^1.0.3",
24
24
  "multer-s3": "^2.10.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@nocobase/test": "0.7.6-alpha.2",
27
+ "@nocobase/test": "0.8.0-alpha.4",
28
28
  "@types/koa-multer": "^1.0.1",
29
29
  "@types/multer": "^1.4.5"
30
30
  },
31
- "gitHead": "2cfccff9d3ff14c521bf317fa7ee4efa18444c92"
31
+ "gitHead": "433f068ce4479a53f51d3ceac3f22b710e7bb13e"
32
32
  }