@nocobase/plugin-file-manager 1.4.29 → 1.4.31
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 +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 +0 -1
- package/dist/server/actions/attachments.js +0 -57
- package/dist/server/actions/index.js +0 -1
- package/dist/server/server.d.ts +2 -1
- package/dist/server/server.js +27 -2
- 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.4.
|
|
11
|
+
"@nocobase/client": "1.4.31",
|
|
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.4.
|
|
21
|
+
"@nocobase/database": "1.4.31",
|
|
22
22
|
"multer": "1.4.4",
|
|
23
|
-
"@nocobase/server": "1.4.
|
|
24
|
-
"@nocobase/utils": "1.4.
|
|
25
|
-
"@nocobase/test": "1.4.
|
|
26
|
-
"@nocobase/actions": "1.4.
|
|
23
|
+
"@nocobase/server": "1.4.31",
|
|
24
|
+
"@nocobase/utils": "1.4.31",
|
|
25
|
+
"@nocobase/test": "1.4.31",
|
|
26
|
+
"@nocobase/actions": "1.4.31"
|
|
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-01-
|
|
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-01-26T05:43:53.332Z"}
|
|
@@ -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-01-
|
|
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-01-26T05:43:43.968Z"}
|
|
@@ -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-01-
|
|
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-01-26T05:43:48.888Z"}
|
|
@@ -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-01-
|
|
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-01-26T05:43:48.812Z"}
|
|
@@ -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-01-
|
|
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-01-26T05:44:01.352Z"}
|
|
@@ -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-01-
|
|
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-01-26T05:43:57.676Z"}
|
|
@@ -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);
|
|
@@ -136,64 +135,8 @@ async function createMiddleware(ctx, next) {
|
|
|
136
135
|
ctx.storage = storage;
|
|
137
136
|
await multipart(ctx, next);
|
|
138
137
|
}
|
|
139
|
-
async function destroyMiddleware(ctx, next) {
|
|
140
|
-
var _a;
|
|
141
|
-
const { resourceName, actionName, sourceId } = ctx.action;
|
|
142
|
-
const collection = ctx.db.getCollection(resourceName);
|
|
143
|
-
if (((_a = collection == null ? void 0 : collection.options) == null ? void 0 : _a.template) !== "file" || actionName !== "destroy") {
|
|
144
|
-
return next();
|
|
145
|
-
}
|
|
146
|
-
const repository = ctx.db.getRepository(resourceName, sourceId);
|
|
147
|
-
const { filterByTk, filter } = ctx.action.params;
|
|
148
|
-
const records = await repository.find({
|
|
149
|
-
filterByTk,
|
|
150
|
-
filter,
|
|
151
|
-
context: ctx
|
|
152
|
-
});
|
|
153
|
-
const storageIds = new Set(records.map((record) => record.storageId));
|
|
154
|
-
const storageGroupedRecords = records.reduce((result, record) => {
|
|
155
|
-
const storageId = record.storageId;
|
|
156
|
-
if (!result[storageId]) {
|
|
157
|
-
result[storageId] = [];
|
|
158
|
-
}
|
|
159
|
-
result[storageId].push(record);
|
|
160
|
-
return result;
|
|
161
|
-
}, {});
|
|
162
|
-
const storages = await ctx.db.getRepository("storages").find({
|
|
163
|
-
filter: {
|
|
164
|
-
id: [...storageIds],
|
|
165
|
-
paranoid: {
|
|
166
|
-
$ne: true
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
let count = 0;
|
|
171
|
-
const undeleted = [];
|
|
172
|
-
await storages.reduce(
|
|
173
|
-
(promise, storage) => promise.then(async () => {
|
|
174
|
-
const storageConfig = ctx.app.pm.get(import__.default).storageTypes.get(storage.type);
|
|
175
|
-
const result = await storageConfig.delete(storage, storageGroupedRecords[storage.id]);
|
|
176
|
-
count += result[0];
|
|
177
|
-
undeleted.push(...result[1]);
|
|
178
|
-
}),
|
|
179
|
-
Promise.resolve()
|
|
180
|
-
);
|
|
181
|
-
if (undeleted.length) {
|
|
182
|
-
const ids = undeleted.map((record) => record.id);
|
|
183
|
-
ctx.action.mergeParams({
|
|
184
|
-
filter: {
|
|
185
|
-
id: {
|
|
186
|
-
$notIn: ids
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
ctx.logger.error("[file-manager] some of attachment files are not successfully deleted: ", { ids });
|
|
191
|
-
}
|
|
192
|
-
await next();
|
|
193
|
-
}
|
|
194
138
|
// Annotate the CommonJS export names for ESM import in node:
|
|
195
139
|
0 && (module.exports = {
|
|
196
140
|
createMiddleware,
|
|
197
|
-
destroyMiddleware,
|
|
198
141
|
getFileData
|
|
199
142
|
});
|
|
@@ -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/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 = {
|
|
@@ -25,6 +25,7 @@ export type UploadFileOptions = {
|
|
|
25
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>;
|
|
28
29
|
registerStorageType(type: string, options: IStorage): void;
|
|
29
30
|
createFileRecord(options: FileRecordOptions): Promise<any>;
|
|
30
31
|
uploadFile(options: UploadFileOptions): Promise<any>;
|
package/dist/server/server.js
CHANGED
|
@@ -54,9 +54,33 @@ var import_local = __toESM(require("./storages/local"));
|
|
|
54
54
|
var import_s3 = __toESM(require("./storages/s3"));
|
|
55
55
|
var import_tx_cos = __toESM(require("./storages/tx-cos"));
|
|
56
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
|
+
}
|
|
57
65
|
class PluginFileManagerServer extends import_server.Plugin {
|
|
58
66
|
storageTypes = new import_utils.Registry();
|
|
59
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
|
+
};
|
|
60
84
|
registerStorageType(type, options) {
|
|
61
85
|
this.storageTypes.register(type, options);
|
|
62
86
|
}
|
|
@@ -174,6 +198,7 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
174
198
|
});
|
|
175
199
|
}
|
|
176
200
|
async load() {
|
|
201
|
+
this.db.on("afterDestroy", this.afterDestroy);
|
|
177
202
|
this.storageTypes.register(import_constants.STORAGE_TYPE_LOCAL, new import_local.default());
|
|
178
203
|
this.storageTypes.register(import_constants.STORAGE_TYPE_ALI_OSS, new import_ali_oss.default());
|
|
179
204
|
this.storageTypes.register(import_constants.STORAGE_TYPE_S3, new import_s3.default());
|
|
@@ -208,9 +233,9 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
208
233
|
}
|
|
209
234
|
});
|
|
210
235
|
(0, import_actions.default)(this);
|
|
211
|
-
this.app.acl.allow("attachments", "upload", "loggedIn");
|
|
212
|
-
this.app.acl.allow("attachments", "create", "loggedIn");
|
|
236
|
+
this.app.acl.allow("attachments", ["upload", "create"], "loggedIn");
|
|
213
237
|
this.app.acl.allow("storages", "getRules", "loggedIn");
|
|
238
|
+
this.app.acl.appendStrategyResource("attachments");
|
|
214
239
|
const defaultStorageName = this.storageTypes.get(DEFAULT_STORAGE_TYPE).defaults().name;
|
|
215
240
|
this.app.acl.addFixedParams("storages", "destroy", () => {
|
|
216
241
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-file-manager",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.31",
|
|
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": "931861310dfd8ab019906f8a3a73576922145e63"
|
|
47
47
|
}
|