@nocobase/plugin-file-manager 1.6.0-alpha.9 → 1.6.0-beta.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.
- package/dist/externalVersion.js +7 -7
- 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 +0 -1
- package/dist/server/actions/attachments.js +0 -57
- package/dist/server/actions/index.js +0 -1
- package/dist/server/index.d.ts +4 -1
- package/dist/server/index.js +14 -0
- package/dist/server/server.d.ts +5 -2
- package/dist/server/server.js +37 -3
- package/dist/server/storages/index.d.ts +2 -2
- package/dist/server/storages/index.js +3 -0
- 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.6.0-
|
|
11
|
+
"@nocobase/client": "1.6.0-beta.2",
|
|
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.6.0-
|
|
22
|
-
"
|
|
23
|
-
"@nocobase/
|
|
24
|
-
"@nocobase/
|
|
25
|
-
"@nocobase/
|
|
26
|
-
"
|
|
21
|
+
"@nocobase/database": "1.6.0-beta.2",
|
|
22
|
+
"multer": "1.4.4",
|
|
23
|
+
"@nocobase/server": "1.6.0-beta.2",
|
|
24
|
+
"@nocobase/utils": "1.6.0-beta.2",
|
|
25
|
+
"@nocobase/test": "1.6.0-beta.2",
|
|
26
|
+
"@nocobase/actions": "1.6.0-beta.2"
|
|
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":"2025-
|
|
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":"2025-02-07T03:21:18.751Z"}
|
|
@@ -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":"2025-
|
|
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":"2025-02-07T03:21:08.667Z"}
|
|
@@ -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":"2025-
|
|
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":"2025-02-07T03:21:14.014Z"}
|
|
@@ -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":"2025-
|
|
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":"2025-02-07T03:21:13.909Z"}
|
|
@@ -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":"2025-
|
|
1
|
+
{"_from":"multer-cos","_id":"multer-cos@1.0.2","_inBundle":false,"_integrity":"sha512-4F8P1VTCSNhiem+BFJFLe3Ixco6cIuAQ6j7U+PBRvdbBJRZgq5Q+vaDMMBWJ1HmPGOOP3AyKS5yk2f0nbFoqqA==","_location":"/multer-cos","_phantomChildren":{},"_requested":{"type":"tag","registry":true,"raw":"multer-cos","name":"multer-cos","escapedName":"multer-cos","rawSpec":"","saveSpec":null,"fetchSpec":"latest"},"_requiredBy":["#USER","/"],"_resolved":"https://registry.npmjs.org/multer-cos/-/multer-cos-1.0.2.tgz","_shasum":"95c7c06cdee1b9311675a895481f9d946de6dcf3","_spec":"multer-cos","_where":"/Users/lanbo/workplace/websocket","author":{"name":"lanbosm"},"bugs":{"url":"https://github.com/lanbosm/multer-COS/issues"},"bundleDependencies":false,"deprecated":false,"description":"Streaming multer storage engine for QCloud COS","devDependencies":{"cos-nodejs-sdk-v5":"^2.2.6","dotenv":"^5.0.1","multer":"^1.3.0"},"engines":{"node":">= 6.10.0"},"homepage":"https://github.com/lanbosm/multer-COS#readme","keywords":["express","multer","COS"],"license":"MIT","main":"index.js","name":"multer-cos","repository":{"type":"git","url":"git+ssh://git@github.com/lanbosm/multer-COS.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"version":"1.0.3","_lastModified":"2025-02-07T03:21:27.483Z"}
|
|
@@ -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":"2025-
|
|
1
|
+
{"name":"multer-s3","version":"3.0.1","description":"Streaming multer storage engine for AWS S3","main":"index.js","scripts":{"test":"standard && mocha test/basic.js"},"engines":{"node":">= 12.0.0"},"repository":{"type":"git","url":"git+https://github.com/badunk/multer-s3.git"},"keywords":["multer","s3","amazon","aws"],"author":"badunk","license":"MIT","bugs":{"url":"https://github.com/badunk/multer-s3/issues"},"homepage":"https://github.com/badunk/multer-s3#readme","dependencies":{"@aws-sdk/lib-storage":"^3.46.0","file-type":"^3.3.0","html-comment-regex":"^1.1.2","run-parallel":"^1.1.6"},"peerDependencies":{"@aws-sdk/client-s3":"^3.0.0"},"devDependencies":{"express":"^4.13.1","form-data":"^1.0.0-rc3","mocha":"^2.2.5","multer":"^1.1.0","on-finished":"^2.3.0","standard":"^5.4.1","xtend":"^4.0.1"},"_lastModified":"2025-02-07T03:21:23.485Z"}
|
|
@@ -9,4 +9,3 @@
|
|
|
9
9
|
import { Context, Next } from '@nocobase/actions';
|
|
10
10
|
export declare function getFileData(ctx: Context): any;
|
|
11
11
|
export declare function createMiddleware(ctx: Context, next: Next): Promise<any>;
|
|
12
|
-
export declare function destroyMiddleware(ctx: Context, next: Next): Promise<any>;
|
|
@@ -37,7 +37,6 @@ 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,
|
|
41
40
|
getFileData: () => getFileData
|
|
42
41
|
});
|
|
43
42
|
module.exports = __toCommonJS(attachments_exports);
|
|
@@ -140,64 +139,8 @@ async function createMiddleware(ctx, next) {
|
|
|
140
139
|
await next();
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
|
-
async function destroyMiddleware(ctx, next) {
|
|
144
|
-
var _a;
|
|
145
|
-
const { resourceName, actionName, sourceId } = ctx.action;
|
|
146
|
-
const collection = ctx.db.getCollection(resourceName);
|
|
147
|
-
if (((_a = collection == null ? void 0 : collection.options) == null ? void 0 : _a.template) !== "file" || actionName !== "destroy") {
|
|
148
|
-
return next();
|
|
149
|
-
}
|
|
150
|
-
const repository = ctx.db.getRepository(resourceName, sourceId);
|
|
151
|
-
const { filterByTk, filter } = ctx.action.params;
|
|
152
|
-
const records = await repository.find({
|
|
153
|
-
filterByTk,
|
|
154
|
-
filter,
|
|
155
|
-
context: ctx
|
|
156
|
-
});
|
|
157
|
-
const storageIds = new Set(records.map((record) => record.storageId));
|
|
158
|
-
const storageGroupedRecords = records.reduce((result, record) => {
|
|
159
|
-
const storageId = record.storageId;
|
|
160
|
-
if (!result[storageId]) {
|
|
161
|
-
result[storageId] = [];
|
|
162
|
-
}
|
|
163
|
-
result[storageId].push(record);
|
|
164
|
-
return result;
|
|
165
|
-
}, {});
|
|
166
|
-
const storages = await ctx.db.getRepository("storages").find({
|
|
167
|
-
filter: {
|
|
168
|
-
id: [...storageIds],
|
|
169
|
-
paranoid: {
|
|
170
|
-
$ne: true
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
let count = 0;
|
|
175
|
-
const undeleted = [];
|
|
176
|
-
await storages.reduce(
|
|
177
|
-
(promise, storage) => promise.then(async () => {
|
|
178
|
-
const storageConfig = ctx.app.pm.get(import__.default).storageTypes.get(storage.type);
|
|
179
|
-
const result = await storageConfig.delete(storage, storageGroupedRecords[storage.id]);
|
|
180
|
-
count += result[0];
|
|
181
|
-
undeleted.push(...result[1]);
|
|
182
|
-
}),
|
|
183
|
-
Promise.resolve()
|
|
184
|
-
);
|
|
185
|
-
if (undeleted.length) {
|
|
186
|
-
const ids = undeleted.map((record) => record.id);
|
|
187
|
-
ctx.action.mergeParams({
|
|
188
|
-
filter: {
|
|
189
|
-
id: {
|
|
190
|
-
$notIn: ids
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
ctx.logger.error("[file-manager] some of attachment files are not successfully deleted: ", { ids });
|
|
195
|
-
}
|
|
196
|
-
await next();
|
|
197
|
-
}
|
|
198
142
|
// Annotate the CommonJS export names for ESM import in node:
|
|
199
143
|
0 && (module.exports = {
|
|
200
144
|
createMiddleware,
|
|
201
|
-
destroyMiddleware,
|
|
202
145
|
getFileData
|
|
203
146
|
});
|
|
@@ -49,5 +49,4 @@ function actions_default({ app }) {
|
|
|
49
49
|
});
|
|
50
50
|
app.resourcer.use(import_attachments.createMiddleware, { tag: "createMiddleware", after: "auth" });
|
|
51
51
|
app.resourcer.registerActionHandler("upload", import_actions.default.create);
|
|
52
|
-
app.resourcer.use(import_attachments.destroyMiddleware);
|
|
53
52
|
}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -6,5 +6,8 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
import { StorageEngine } from 'multer';
|
|
9
10
|
export * from '../constants';
|
|
10
|
-
export { default } from './server';
|
|
11
|
+
export { AttachmentModel, default, IStorage, PluginFileManagerServer, StorageModel } from './server';
|
|
12
|
+
export { StorageType } from './storages';
|
|
13
|
+
export { StorageEngine };
|
package/dist/server/index.js
CHANGED
|
@@ -37,12 +37,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
37
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
38
|
var server_exports = {};
|
|
39
39
|
__export(server_exports, {
|
|
40
|
+
AttachmentModel: () => import_server.AttachmentModel,
|
|
41
|
+
IStorage: () => import_server.IStorage,
|
|
42
|
+
PluginFileManagerServer: () => import_server.PluginFileManagerServer,
|
|
43
|
+
StorageEngine: () => import_multer.StorageEngine,
|
|
44
|
+
StorageModel: () => import_server.StorageModel,
|
|
45
|
+
StorageType: () => import_storages.StorageType,
|
|
40
46
|
default: () => import_server.default
|
|
41
47
|
});
|
|
42
48
|
module.exports = __toCommonJS(server_exports);
|
|
49
|
+
var import_multer = require("multer");
|
|
43
50
|
__reExport(server_exports, require("../constants"), module.exports);
|
|
44
51
|
var import_server = __toESM(require("./server"));
|
|
52
|
+
var import_storages = require("./storages");
|
|
45
53
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
54
|
0 && (module.exports = {
|
|
55
|
+
AttachmentModel,
|
|
56
|
+
IStorage,
|
|
57
|
+
PluginFileManagerServer,
|
|
58
|
+
StorageEngine,
|
|
59
|
+
StorageModel,
|
|
60
|
+
StorageType,
|
|
47
61
|
...require("../constants")
|
|
48
62
|
});
|
package/dist/server/server.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Plugin } from '@nocobase/server';
|
|
10
10
|
import { Registry } from '@nocobase/utils';
|
|
11
|
-
import { Transactionable } from '@nocobase/database';
|
|
11
|
+
import { Model, Transactionable } from '@nocobase/database';
|
|
12
12
|
import { IStorage, StorageModel } from './storages';
|
|
13
13
|
export type * from './storages';
|
|
14
14
|
export type FileRecordOptions = {
|
|
@@ -22,9 +22,11 @@ export type UploadFileOptions = {
|
|
|
22
22
|
storageName?: string;
|
|
23
23
|
documentRoot?: string;
|
|
24
24
|
};
|
|
25
|
-
export
|
|
25
|
+
export declare class PluginFileManagerServer extends Plugin {
|
|
26
26
|
storageTypes: Registry<IStorage>;
|
|
27
27
|
storagesCache: Map<number, StorageModel>;
|
|
28
|
+
afterDestroy: (record: Model, options: any) => Promise<void>;
|
|
29
|
+
registerStorageType(type: string, options: IStorage): void;
|
|
28
30
|
createFileRecord(options: FileRecordOptions): Promise<any>;
|
|
29
31
|
uploadFile(options: UploadFileOptions): Promise<any>;
|
|
30
32
|
loadStorages(options?: {
|
|
@@ -35,3 +37,4 @@ export default class PluginFileManagerServer extends Plugin {
|
|
|
35
37
|
beforeLoad(): Promise<void>;
|
|
36
38
|
load(): Promise<void>;
|
|
37
39
|
}
|
|
40
|
+
export default PluginFileManagerServer;
|
package/dist/server/server.js
CHANGED
|
@@ -36,7 +36,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
36
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
37
|
var server_exports = {};
|
|
38
38
|
__export(server_exports, {
|
|
39
|
-
|
|
39
|
+
PluginFileManagerServer: () => PluginFileManagerServer,
|
|
40
|
+
default: () => server_default
|
|
40
41
|
});
|
|
41
42
|
module.exports = __toCommonJS(server_exports);
|
|
42
43
|
var import_server = require("@nocobase/server");
|
|
@@ -53,9 +54,36 @@ var import_local = __toESM(require("./storages/local"));
|
|
|
53
54
|
var import_s3 = __toESM(require("./storages/s3"));
|
|
54
55
|
var import_tx_cos = __toESM(require("./storages/tx-cos"));
|
|
55
56
|
const DEFAULT_STORAGE_TYPE = import_constants.STORAGE_TYPE_LOCAL;
|
|
57
|
+
class FileDeleteError extends Error {
|
|
58
|
+
data;
|
|
59
|
+
constructor(message, data) {
|
|
60
|
+
super(message);
|
|
61
|
+
this.name = "FileDeleteError";
|
|
62
|
+
this.data = data;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
56
65
|
class PluginFileManagerServer extends import_server.Plugin {
|
|
57
66
|
storageTypes = new import_utils.Registry();
|
|
58
67
|
storagesCache = /* @__PURE__ */ new Map();
|
|
68
|
+
afterDestroy = async (record, options) => {
|
|
69
|
+
var _a;
|
|
70
|
+
const { collection } = record.constructor;
|
|
71
|
+
if (((_a = collection == null ? void 0 : collection.options) == null ? void 0 : _a.template) !== "file" && collection.name !== "attachments") {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const storage = this.storagesCache.get(record.get("storageId"));
|
|
75
|
+
if (storage == null ? void 0 : storage.paranoid) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const storageConfig = this.storageTypes.get(storage.type);
|
|
79
|
+
const result = await storageConfig.delete(storage, [record]);
|
|
80
|
+
if (!result[0]) {
|
|
81
|
+
throw new FileDeleteError("Failed to delete file", record);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
registerStorageType(type, options) {
|
|
85
|
+
this.storageTypes.register(type, options);
|
|
86
|
+
}
|
|
59
87
|
async createFileRecord(options) {
|
|
60
88
|
const { values, storageName, collectionName, filePath, transaction } = options;
|
|
61
89
|
const collection = this.db.getCollection(collectionName);
|
|
@@ -170,6 +198,7 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
170
198
|
});
|
|
171
199
|
}
|
|
172
200
|
async load() {
|
|
201
|
+
this.db.on("afterDestroy", this.afterDestroy);
|
|
173
202
|
this.storageTypes.register(import_constants.STORAGE_TYPE_LOCAL, new import_local.default());
|
|
174
203
|
this.storageTypes.register(import_constants.STORAGE_TYPE_ALI_OSS, new import_ali_oss.default());
|
|
175
204
|
this.storageTypes.register(import_constants.STORAGE_TYPE_S3, new import_s3.default());
|
|
@@ -210,9 +239,9 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
210
239
|
}
|
|
211
240
|
});
|
|
212
241
|
(0, import_actions.default)(this);
|
|
213
|
-
this.app.acl.allow("attachments", "upload", "loggedIn");
|
|
214
|
-
this.app.acl.allow("attachments", "create", "loggedIn");
|
|
242
|
+
this.app.acl.allow("attachments", ["upload", "create"], "loggedIn");
|
|
215
243
|
this.app.acl.allow("storages", "getBasicInfo", "loggedIn");
|
|
244
|
+
this.app.acl.appendStrategyResource("attachments");
|
|
216
245
|
const defaultStorageName = this.storageTypes.get(DEFAULT_STORAGE_TYPE).defaults().name;
|
|
217
246
|
this.app.acl.addFixedParams("storages", "destroy", () => {
|
|
218
247
|
return {
|
|
@@ -232,3 +261,8 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
232
261
|
this.app.db.interfaceManager.registerInterfaceType("attachment", import_attachment_interface.AttachmentInterface);
|
|
233
262
|
}
|
|
234
263
|
}
|
|
264
|
+
var server_default = PluginFileManagerServer;
|
|
265
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
266
|
+
0 && (module.exports = {
|
|
267
|
+
PluginFileManagerServer
|
|
268
|
+
});
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
import { StorageEngine } from 'multer';
|
|
10
9
|
import Application from '@nocobase/server';
|
|
10
|
+
import { StorageEngine } from 'multer';
|
|
11
11
|
export interface StorageModel {
|
|
12
12
|
id?: number;
|
|
13
13
|
title: string;
|
|
@@ -39,6 +39,6 @@ export interface IStorage {
|
|
|
39
39
|
}
|
|
40
40
|
export declare abstract class StorageType implements IStorage {
|
|
41
41
|
abstract make(storage: StorageModel): StorageEngine;
|
|
42
|
-
abstract defaults(): StorageModel;
|
|
43
42
|
abstract delete(storage: StorageModel, records: AttachmentModel[]): Promise<[number, AttachmentModel[]]>;
|
|
43
|
+
defaults(): StorageModel;
|
|
44
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-file-manager",
|
|
3
|
-
"version": "1.6.0-
|
|
3
|
+
"version": "1.6.0-beta.2",
|
|
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": "476ab2f424d86f585c8fba1459568c8aec49a5c6"
|
|
47
47
|
}
|