@nocobase/plugin-file-manager 1.3.0-alpha.20240819011229 → 1.3.0-beta
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.
- package/dist/client/templates/file.d.ts +1 -0
- package/dist/externalVersion.js +6 -6
- package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
- package/dist/node_modules/mime-match/package.json +1 -1
- package/dist/node_modules/mkdirp/package.json +1 -1
- package/dist/node_modules/multer-aliyun-oss/package.json +1 -1
- package/dist/node_modules/multer-cos/package.json +1 -1
- package/dist/node_modules/multer-s3/package.json +1 -1
- package/dist/server/actions/attachments.d.ts +1 -0
- package/dist/server/actions/attachments.js +5 -3
- package/dist/server/server.d.ts +14 -0
- package/dist/server/server.js +63 -4
- package/package.json +2 -2
package/dist/externalVersion.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.3.0-
|
|
11
|
+
"@nocobase/client": "1.3.0-beta",
|
|
12
12
|
"react": "18.2.0",
|
|
13
13
|
"antd": "5.12.8",
|
|
14
14
|
"@ant-design/icons": "5.2.6",
|
|
@@ -18,10 +18,10 @@ module.exports = {
|
|
|
18
18
|
"@formily/antd-v5": "1.1.9",
|
|
19
19
|
"@formily/core": "2.3.0",
|
|
20
20
|
"@formily/react": "2.3.0",
|
|
21
|
-
"@nocobase/database": "1.3.0-
|
|
22
|
-
"@nocobase/server": "1.3.0-
|
|
23
|
-
"@nocobase/utils": "1.3.0-
|
|
24
|
-
"@nocobase/test": "1.3.0-
|
|
25
|
-
"@nocobase/actions": "1.3.0-
|
|
21
|
+
"@nocobase/database": "1.3.0-beta",
|
|
22
|
+
"@nocobase/server": "1.3.0-beta",
|
|
23
|
+
"@nocobase/utils": "1.3.0-beta",
|
|
24
|
+
"@nocobase/test": "1.3.0-beta",
|
|
25
|
+
"@nocobase/actions": "1.3.0-beta",
|
|
26
26
|
"multer": "1.4.4"
|
|
27
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@aws-sdk/client-s3","description":"AWS SDK for JavaScript S3 Client for Node.js, Browser and React Native","version":"3.474.0","scripts":{"build":"concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'","build:cjs":"tsc -p tsconfig.cjs.json","build:es":"tsc -p tsconfig.es.json","build:include:deps":"lerna run --scope $npm_package_name --include-dependencies build","build:types":"tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4","clean":"rimraf ./dist-* && rimraf *.tsbuildinfo","extract:docs":"api-extractor run --local","generate:client":"node ../../scripts/generate-clients/single-service --solo s3","test":"yarn test:unit","test:e2e":"yarn test:e2e:node && yarn test:e2e:browser","test:e2e:browser":"ts-mocha test/**/*.browser.ispec.ts && karma start karma.conf.js","test:e2e:node":"jest --c jest.config.e2e.js","test:unit":"ts-mocha test/unit/**/*.spec.ts"},"main":"./dist-cjs/index.js","types":"./dist-types/index.d.ts","module":"./dist-es/index.js","sideEffects":false,"dependencies":{"@aws-crypto/sha1-browser":"3.0.0","@aws-crypto/sha256-browser":"3.0.0","@aws-crypto/sha256-js":"3.0.0","@aws-sdk/client-sts":"3.474.0","@aws-sdk/core":"3.474.0","@aws-sdk/credential-provider-node":"3.474.0","@aws-sdk/middleware-bucket-endpoint":"3.470.0","@aws-sdk/middleware-expect-continue":"3.468.0","@aws-sdk/middleware-flexible-checksums":"3.468.0","@aws-sdk/middleware-host-header":"3.468.0","@aws-sdk/middleware-location-constraint":"3.468.0","@aws-sdk/middleware-logger":"3.468.0","@aws-sdk/middleware-recursion-detection":"3.468.0","@aws-sdk/middleware-sdk-s3":"3.474.0","@aws-sdk/middleware-signing":"3.468.0","@aws-sdk/middleware-ssec":"3.468.0","@aws-sdk/middleware-user-agent":"3.470.0","@aws-sdk/region-config-resolver":"3.470.0","@aws-sdk/signature-v4-multi-region":"3.474.0","@aws-sdk/types":"3.468.0","@aws-sdk/util-endpoints":"3.470.0","@aws-sdk/util-user-agent-browser":"3.468.0","@aws-sdk/util-user-agent-node":"3.470.0","@aws-sdk/xml-builder":"3.472.0","@smithy/config-resolver":"^2.0.21","@smithy/eventstream-serde-browser":"^2.0.15","@smithy/eventstream-serde-config-resolver":"^2.0.15","@smithy/eventstream-serde-node":"^2.0.15","@smithy/fetch-http-handler":"^2.3.1","@smithy/hash-blob-browser":"^2.0.16","@smithy/hash-node":"^2.0.17","@smithy/hash-stream-node":"^2.0.17","@smithy/invalid-dependency":"^2.0.15","@smithy/md5-js":"^2.0.17","@smithy/middleware-content-length":"^2.0.17","@smithy/middleware-endpoint":"^2.2.3","@smithy/middleware-retry":"^2.0.24","@smithy/middleware-serde":"^2.0.15","@smithy/middleware-stack":"^2.0.9","@smithy/node-config-provider":"^2.1.8","@smithy/node-http-handler":"^2.2.1","@smithy/protocol-http":"^3.0.11","@smithy/smithy-client":"^2.1.18","@smithy/types":"^2.7.0","@smithy/url-parser":"^2.0.15","@smithy/util-base64":"^2.0.1","@smithy/util-body-length-browser":"^2.0.1","@smithy/util-body-length-node":"^2.1.0","@smithy/util-defaults-mode-browser":"^2.0.22","@smithy/util-defaults-mode-node":"^2.0.29","@smithy/util-endpoints":"^1.0.7","@smithy/util-retry":"^2.0.8","@smithy/util-stream":"^2.0.23","@smithy/util-utf8":"^2.0.2","@smithy/util-waiter":"^2.0.15","fast-xml-parser":"4.2.5","tslib":"^2.5.0"},"devDependencies":{"@smithy/service-client-documentation-generator":"^2.0.0","@tsconfig/node14":"1.0.3","@types/chai":"^4.2.11","@types/mocha":"^8.0.4","@types/node":"^14.14.31","concurrently":"7.0.0","downlevel-dts":"0.10.1","rimraf":"3.0.2","typescript":"~4.9.5"},"engines":{"node":">=14.0.0"},"typesVersions":{"<4.0":{"dist-types/*":["dist-types/ts3.4/*"]}},"files":["dist-*/**"],"author":{"name":"AWS SDK for JavaScript Team","url":"https://aws.amazon.com/javascript/"},"license":"Apache-2.0","browser":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.browser"},"react-native":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.native"},"homepage":"https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-s3","repository":{"type":"git","url":"https://github.com/aws/aws-sdk-js-v3.git","directory":"clients/client-s3"},"_lastModified":"2024-08-
|
|
1
|
+
{"name":"@aws-sdk/client-s3","description":"AWS SDK for JavaScript S3 Client for Node.js, Browser and React Native","version":"3.474.0","scripts":{"build":"concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'","build:cjs":"tsc -p tsconfig.cjs.json","build:es":"tsc -p tsconfig.es.json","build:include:deps":"lerna run --scope $npm_package_name --include-dependencies build","build:types":"tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4","clean":"rimraf ./dist-* && rimraf *.tsbuildinfo","extract:docs":"api-extractor run --local","generate:client":"node ../../scripts/generate-clients/single-service --solo s3","test":"yarn test:unit","test:e2e":"yarn test:e2e:node && yarn test:e2e:browser","test:e2e:browser":"ts-mocha test/**/*.browser.ispec.ts && karma start karma.conf.js","test:e2e:node":"jest --c jest.config.e2e.js","test:unit":"ts-mocha test/unit/**/*.spec.ts"},"main":"./dist-cjs/index.js","types":"./dist-types/index.d.ts","module":"./dist-es/index.js","sideEffects":false,"dependencies":{"@aws-crypto/sha1-browser":"3.0.0","@aws-crypto/sha256-browser":"3.0.0","@aws-crypto/sha256-js":"3.0.0","@aws-sdk/client-sts":"3.474.0","@aws-sdk/core":"3.474.0","@aws-sdk/credential-provider-node":"3.474.0","@aws-sdk/middleware-bucket-endpoint":"3.470.0","@aws-sdk/middleware-expect-continue":"3.468.0","@aws-sdk/middleware-flexible-checksums":"3.468.0","@aws-sdk/middleware-host-header":"3.468.0","@aws-sdk/middleware-location-constraint":"3.468.0","@aws-sdk/middleware-logger":"3.468.0","@aws-sdk/middleware-recursion-detection":"3.468.0","@aws-sdk/middleware-sdk-s3":"3.474.0","@aws-sdk/middleware-signing":"3.468.0","@aws-sdk/middleware-ssec":"3.468.0","@aws-sdk/middleware-user-agent":"3.470.0","@aws-sdk/region-config-resolver":"3.470.0","@aws-sdk/signature-v4-multi-region":"3.474.0","@aws-sdk/types":"3.468.0","@aws-sdk/util-endpoints":"3.470.0","@aws-sdk/util-user-agent-browser":"3.468.0","@aws-sdk/util-user-agent-node":"3.470.0","@aws-sdk/xml-builder":"3.472.0","@smithy/config-resolver":"^2.0.21","@smithy/eventstream-serde-browser":"^2.0.15","@smithy/eventstream-serde-config-resolver":"^2.0.15","@smithy/eventstream-serde-node":"^2.0.15","@smithy/fetch-http-handler":"^2.3.1","@smithy/hash-blob-browser":"^2.0.16","@smithy/hash-node":"^2.0.17","@smithy/hash-stream-node":"^2.0.17","@smithy/invalid-dependency":"^2.0.15","@smithy/md5-js":"^2.0.17","@smithy/middleware-content-length":"^2.0.17","@smithy/middleware-endpoint":"^2.2.3","@smithy/middleware-retry":"^2.0.24","@smithy/middleware-serde":"^2.0.15","@smithy/middleware-stack":"^2.0.9","@smithy/node-config-provider":"^2.1.8","@smithy/node-http-handler":"^2.2.1","@smithy/protocol-http":"^3.0.11","@smithy/smithy-client":"^2.1.18","@smithy/types":"^2.7.0","@smithy/url-parser":"^2.0.15","@smithy/util-base64":"^2.0.1","@smithy/util-body-length-browser":"^2.0.1","@smithy/util-body-length-node":"^2.1.0","@smithy/util-defaults-mode-browser":"^2.0.22","@smithy/util-defaults-mode-node":"^2.0.29","@smithy/util-endpoints":"^1.0.7","@smithy/util-retry":"^2.0.8","@smithy/util-stream":"^2.0.23","@smithy/util-utf8":"^2.0.2","@smithy/util-waiter":"^2.0.15","fast-xml-parser":"4.2.5","tslib":"^2.5.0"},"devDependencies":{"@smithy/service-client-documentation-generator":"^2.0.0","@tsconfig/node14":"1.0.3","@types/chai":"^4.2.11","@types/mocha":"^8.0.4","@types/node":"^14.14.31","concurrently":"7.0.0","downlevel-dts":"0.10.1","rimraf":"3.0.2","typescript":"~4.9.5"},"engines":{"node":">=14.0.0"},"typesVersions":{"<4.0":{"dist-types/*":["dist-types/ts3.4/*"]}},"files":["dist-*/**"],"author":{"name":"AWS SDK for JavaScript Team","url":"https://aws.amazon.com/javascript/"},"license":"Apache-2.0","browser":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.browser"},"react-native":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.native"},"homepage":"https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-s3","repository":{"type":"git","url":"https://github.com/aws/aws-sdk-js-v3.git","directory":"clients/client-s3"},"_lastModified":"2024-08-25T16:22:42.113Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"mime-match","version":"1.0.2","description":"A simple function to check whether a mimetype matches the specified mimetype (with wildcard support)","main":"index.js","scripts":{"test":"node test.js","gendocs":"gendocs > README.md"},"repository":{"type":"git","url":"https://github.com/DamonOehlman/mime-match.git"},"keywords":["mime","wildcard"],"author":"Damon Oehlman <damon.oehlman@gmail.com>","license":"ISC","bugs":{"url":"https://github.com/DamonOehlman/mime-match/issues"},"homepage":"https://github.com/DamonOehlman/mime-match","dependencies":{"wildcard":"^1.1.0"},"devDependencies":{"tape":"^4.5.1"},"_lastModified":"2024-08-
|
|
1
|
+
{"name":"mime-match","version":"1.0.2","description":"A simple function to check whether a mimetype matches the specified mimetype (with wildcard support)","main":"index.js","scripts":{"test":"node test.js","gendocs":"gendocs > README.md"},"repository":{"type":"git","url":"https://github.com/DamonOehlman/mime-match.git"},"keywords":["mime","wildcard"],"author":"Damon Oehlman <damon.oehlman@gmail.com>","license":"ISC","bugs":{"url":"https://github.com/DamonOehlman/mime-match/issues"},"homepage":"https://github.com/DamonOehlman/mime-match","dependencies":{"wildcard":"^1.1.0"},"devDependencies":{"tape":"^4.5.1"},"_lastModified":"2024-08-25T16:22:32.711Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"mkdirp","description":"Recursively mkdir, like `mkdir -p`","version":"0.5.6","publishConfig":{"tag":"legacy"},"author":"James Halliday <mail@substack.net> (http://substack.net)","main":"index.js","keywords":["mkdir","directory"],"repository":{"type":"git","url":"https://github.com/substack/node-mkdirp.git"},"scripts":{"test":"tap test/*.js"},"dependencies":{"minimist":"^1.2.6"},"devDependencies":{"tap":"^16.0.1"},"bin":"bin/cmd.js","license":"MIT","files":["bin","index.js"],"_lastModified":"2024-08-
|
|
1
|
+
{"name":"mkdirp","description":"Recursively mkdir, like `mkdir -p`","version":"0.5.6","publishConfig":{"tag":"legacy"},"author":"James Halliday <mail@substack.net> (http://substack.net)","main":"index.js","keywords":["mkdir","directory"],"repository":{"type":"git","url":"https://github.com/substack/node-mkdirp.git"},"scripts":{"test":"tap test/*.js"},"dependencies":{"minimist":"^1.2.6"},"devDependencies":{"tap":"^16.0.1"},"bin":"bin/cmd.js","license":"MIT","files":["bin","index.js"],"_lastModified":"2024-08-25T16:22:37.991Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"multer-aliyun-oss","version":"2.1.3","description":"Multer Storage for AliYun OSS","main":"index.js","scripts":{},"author":"AngusYoung","license":"ISC","repository":{"type":"git","url":"git+https://github.com/ay86/multer-aliyun-oss.git"},"keywords":["multer","storage","aliyun","oss"],"dependencies":{"ali-oss":"^6.1.0"},"_lastModified":"2024-08-
|
|
1
|
+
{"name":"multer-aliyun-oss","version":"2.1.3","description":"Multer Storage for AliYun OSS","main":"index.js","scripts":{},"author":"AngusYoung","license":"ISC","repository":{"type":"git","url":"git+https://github.com/ay86/multer-aliyun-oss.git"},"keywords":["multer","storage","aliyun","oss"],"dependencies":{"ali-oss":"^6.1.0"},"_lastModified":"2024-08-25T16:22:37.911Z"}
|
|
@@ -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-08-
|
|
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-08-25T16:22:49.482Z"}
|
|
@@ -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-08-
|
|
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-08-25T16:22:46.040Z"}
|
|
@@ -7,5 +7,6 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { Context, Next } from '@nocobase/actions';
|
|
10
|
+
export declare function getFileData(ctx: Context): any;
|
|
10
11
|
export declare function createMiddleware(ctx: Context, next: Next): Promise<any>;
|
|
11
12
|
export declare function destroyMiddleware(ctx: Context, next: Next): Promise<any>;
|
|
@@ -37,14 +37,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
37
37
|
var attachments_exports = {};
|
|
38
38
|
__export(attachments_exports, {
|
|
39
39
|
createMiddleware: () => createMiddleware,
|
|
40
|
-
destroyMiddleware: () => destroyMiddleware
|
|
40
|
+
destroyMiddleware: () => destroyMiddleware,
|
|
41
|
+
getFileData: () => getFileData
|
|
41
42
|
});
|
|
42
43
|
module.exports = __toCommonJS(attachments_exports);
|
|
43
44
|
var import_utils = require("@nocobase/utils");
|
|
44
45
|
var import_path = __toESM(require("path"));
|
|
46
|
+
var import__ = __toESM(require(".."));
|
|
45
47
|
var import_constants = require("../../constants");
|
|
46
48
|
var Rules = __toESM(require("../rules"));
|
|
47
|
-
var import__ = __toESM(require(".."));
|
|
48
49
|
function getFileFilter(storage) {
|
|
49
50
|
return (req, file, cb) => {
|
|
50
51
|
const { size, ...rules } = storage.rules;
|
|
@@ -193,5 +194,6 @@ async function destroyMiddleware(ctx, next) {
|
|
|
193
194
|
// Annotate the CommonJS export names for ESM import in node:
|
|
194
195
|
0 && (module.exports = {
|
|
195
196
|
createMiddleware,
|
|
196
|
-
destroyMiddleware
|
|
197
|
+
destroyMiddleware,
|
|
198
|
+
getFileData
|
|
197
199
|
});
|
package/dist/server/server.d.ts
CHANGED
|
@@ -8,11 +8,25 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Plugin } from '@nocobase/server';
|
|
10
10
|
import { Registry } from '@nocobase/utils';
|
|
11
|
+
import { Transactionable } from '@nocobase/database';
|
|
11
12
|
import { IStorage, StorageModel } from './storages';
|
|
12
13
|
export type * from './storages';
|
|
14
|
+
export type FileRecordOptions = {
|
|
15
|
+
collectionName: string;
|
|
16
|
+
filePath: string;
|
|
17
|
+
storageName?: string;
|
|
18
|
+
values?: any;
|
|
19
|
+
} & Transactionable;
|
|
20
|
+
export type UploadFileOptions = {
|
|
21
|
+
filePath: string;
|
|
22
|
+
storageName?: string;
|
|
23
|
+
documentRoot?: string;
|
|
24
|
+
};
|
|
13
25
|
export default class PluginFileManagerServer extends Plugin {
|
|
14
26
|
storageTypes: Registry<IStorage>;
|
|
15
27
|
storagesCache: Map<number, StorageModel>;
|
|
28
|
+
createFileRecord(options: FileRecordOptions): Promise<any>;
|
|
29
|
+
uploadFile(options: UploadFileOptions): Promise<any>;
|
|
16
30
|
loadStorages(options?: {
|
|
17
31
|
transaction: any;
|
|
18
32
|
}): Promise<void>;
|
package/dist/server/server.js
CHANGED
|
@@ -39,21 +39,80 @@ __export(server_exports, {
|
|
|
39
39
|
default: () => PluginFileManagerServer
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(server_exports);
|
|
42
|
-
var import_path = require("path");
|
|
43
42
|
var import_server = require("@nocobase/server");
|
|
44
43
|
var import_utils = require("@nocobase/utils");
|
|
44
|
+
var import_path = require("path");
|
|
45
|
+
var import_fs = __toESM(require("fs"));
|
|
46
|
+
var import_constants = require("../constants");
|
|
45
47
|
var import_FileModel = require("./FileModel");
|
|
46
48
|
var import_actions = __toESM(require("./actions"));
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
+
var import_attachments = require("./actions/attachments");
|
|
50
|
+
var import_attachment_interface = require("./interfaces/attachment-interface");
|
|
49
51
|
var import_ali_oss = __toESM(require("./storages/ali-oss"));
|
|
52
|
+
var import_local = __toESM(require("./storages/local"));
|
|
50
53
|
var import_s3 = __toESM(require("./storages/s3"));
|
|
51
54
|
var import_tx_cos = __toESM(require("./storages/tx-cos"));
|
|
52
|
-
var import_attachment_interface = require("./interfaces/attachment-interface");
|
|
53
55
|
const DEFAULT_STORAGE_TYPE = import_constants.STORAGE_TYPE_LOCAL;
|
|
54
56
|
class PluginFileManagerServer extends import_server.Plugin {
|
|
55
57
|
storageTypes = new import_utils.Registry();
|
|
56
58
|
storagesCache = /* @__PURE__ */ new Map();
|
|
59
|
+
async createFileRecord(options) {
|
|
60
|
+
const { values, storageName, collectionName, filePath, transaction } = options;
|
|
61
|
+
const collection = this.db.getCollection(collectionName);
|
|
62
|
+
if (!collection) {
|
|
63
|
+
throw new Error(`collection does not exist`);
|
|
64
|
+
}
|
|
65
|
+
const collectionRepository = this.db.getRepository(collectionName);
|
|
66
|
+
const name = storageName || collection.options.storage;
|
|
67
|
+
const data = await this.uploadFile({ storageName: name, filePath });
|
|
68
|
+
return await collectionRepository.create({ values: { ...data, ...values }, transaction });
|
|
69
|
+
}
|
|
70
|
+
async uploadFile(options) {
|
|
71
|
+
const { storageName, filePath, documentRoot } = options;
|
|
72
|
+
const storageRepository = this.db.getRepository("storages");
|
|
73
|
+
let storageInstance;
|
|
74
|
+
if (storageName) {
|
|
75
|
+
storageInstance = await storageRepository.findOne({
|
|
76
|
+
filter: {
|
|
77
|
+
name: storageName
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (!storageInstance) {
|
|
82
|
+
storageInstance = await storageRepository.findOne({
|
|
83
|
+
filter: {
|
|
84
|
+
default: true
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const fileStream = import_fs.default.createReadStream(filePath);
|
|
89
|
+
if (!storageInstance) {
|
|
90
|
+
throw new Error("[file-manager] no linked or default storage provided");
|
|
91
|
+
}
|
|
92
|
+
if (documentRoot) {
|
|
93
|
+
storageInstance.options["documentRoot"] = documentRoot;
|
|
94
|
+
}
|
|
95
|
+
const storageConfig = this.storageTypes.get(storageInstance.type);
|
|
96
|
+
if (!storageConfig) {
|
|
97
|
+
throw new Error(`[file-manager] storage type "${storageInstance.type}" is not defined`);
|
|
98
|
+
}
|
|
99
|
+
const engine = storageConfig.make(storageInstance);
|
|
100
|
+
const file = {
|
|
101
|
+
originalname: (0, import_path.basename)(filePath),
|
|
102
|
+
path: filePath,
|
|
103
|
+
stream: fileStream
|
|
104
|
+
};
|
|
105
|
+
await new Promise((resolve2, reject) => {
|
|
106
|
+
engine._handleFile({}, file, (error, info) => {
|
|
107
|
+
if (error) {
|
|
108
|
+
reject(error);
|
|
109
|
+
}
|
|
110
|
+
Object.assign(file, info);
|
|
111
|
+
resolve2(info);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
return (0, import_attachments.getFileData)({ app: this.app, file, storage: storageInstance, request: { body: {} } });
|
|
115
|
+
}
|
|
57
116
|
async loadStorages(options) {
|
|
58
117
|
const repository = this.db.getRepository("storages");
|
|
59
118
|
const storages = await repository.find({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-file-manager",
|
|
3
|
-
"version": "1.3.0-
|
|
3
|
+
"version": "1.3.0-beta",
|
|
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": "
|
|
46
|
+
"gitHead": "175a86dcc41577bff4f94ae614ebe778fd532f3f"
|
|
47
47
|
}
|