@nocobase/plugin-file-manager 1.6.3 → 1.6.5
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/node_modules/url-join/.travis.yml +5 -0
- package/dist/node_modules/url-join/LICENSE +21 -0
- package/dist/node_modules/url-join/bin/changelog +28 -0
- package/dist/node_modules/url-join/lib/url-join.js +1 -0
- package/dist/node_modules/url-join/package.json +1 -0
- package/dist/node_modules/url-join/test/tests.js +151 -0
- package/dist/server/actions/attachments.d.ts +1 -11
- package/dist/server/actions/attachments.js +11 -10
- package/dist/server/actions/index.js +19 -0
- package/dist/server/server.d.ts +2 -12
- package/dist/server/server.js +30 -5
- package/dist/server/storages/index.d.ts +1 -1
- package/dist/server/storages/index.js +26 -2
- package/dist/server/storages/local.d.ts +1 -1
- package/dist/server/storages/local.js +12 -5
- package/dist/server/storages/s3.d.ts +4 -0
- package/dist/server/storages/s3.js +35 -11
- package/package.json +5 -4
- package/dist/server/FileModel.d.ts +0 -12
- package/dist/server/FileModel.js +0 -58
package/dist/externalVersion.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.6.
|
|
11
|
+
"@nocobase/client": "1.6.5",
|
|
12
12
|
"react": "18.2.0",
|
|
13
13
|
"antd": "5.12.8",
|
|
14
14
|
"@ant-design/icons": "5.6.1",
|
|
@@ -18,12 +18,12 @@ 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.3",
|
|
22
21
|
"multer": "1.4.4",
|
|
23
|
-
"@nocobase/server": "1.6.
|
|
24
|
-
"@nocobase/utils": "1.6.
|
|
25
|
-
"@nocobase/
|
|
26
|
-
"@nocobase/
|
|
22
|
+
"@nocobase/server": "1.6.5",
|
|
23
|
+
"@nocobase/utils": "1.6.5",
|
|
24
|
+
"@nocobase/database": "1.6.5",
|
|
25
|
+
"@nocobase/test": "1.6.5",
|
|
26
|
+
"@nocobase/actions": "1.6.5",
|
|
27
27
|
"sequelize": "6.35.2",
|
|
28
|
-
"@nocobase/plugin-data-source-main": "1.6.
|
|
28
|
+
"@nocobase/plugin-data-source-main": "1.6.5"
|
|
29
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@aws-sdk/client-s3","description":"AWS SDK for JavaScript S3 Client for Node.js, Browser and React Native","version":"3.750.0","scripts":{"build":"concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'","build:cjs":"node ../../scripts/compilation/inline client-s3","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 g:vitest run","test:browser":"node ./test/browser-build/esbuild && yarn g:vitest run -c vitest.config.browser.ts","test:browser:watch":"node ./test/browser-build/esbuild && yarn g:vitest watch -c vitest.config.browser.ts","test:e2e":"yarn g:vitest run -c vitest.config.e2e.ts && yarn test:browser","test:e2e:watch":"yarn g:vitest watch -c vitest.config.e2e.ts","test:watch":"yarn g:vitest watch"},"main":"./dist-cjs/index.js","types":"./dist-types/index.d.ts","module":"./dist-es/index.js","sideEffects":false,"dependencies":{"@aws-crypto/sha1-browser":"5.2.0","@aws-crypto/sha256-browser":"5.2.0","@aws-crypto/sha256-js":"5.2.0","@aws-sdk/core":"3.750.0","@aws-sdk/credential-provider-node":"3.750.0","@aws-sdk/middleware-bucket-endpoint":"3.734.0","@aws-sdk/middleware-expect-continue":"3.734.0","@aws-sdk/middleware-flexible-checksums":"3.750.0","@aws-sdk/middleware-host-header":"3.734.0","@aws-sdk/middleware-location-constraint":"3.734.0","@aws-sdk/middleware-logger":"3.734.0","@aws-sdk/middleware-recursion-detection":"3.734.0","@aws-sdk/middleware-sdk-s3":"3.750.0","@aws-sdk/middleware-ssec":"3.734.0","@aws-sdk/middleware-user-agent":"3.750.0","@aws-sdk/region-config-resolver":"3.734.0","@aws-sdk/signature-v4-multi-region":"3.750.0","@aws-sdk/types":"3.734.0","@aws-sdk/util-endpoints":"3.743.0","@aws-sdk/util-user-agent-browser":"3.734.0","@aws-sdk/util-user-agent-node":"3.750.0","@aws-sdk/xml-builder":"3.734.0","@smithy/config-resolver":"^4.0.1","@smithy/core":"^3.1.4","@smithy/eventstream-serde-browser":"^4.0.1","@smithy/eventstream-serde-config-resolver":"^4.0.1","@smithy/eventstream-serde-node":"^4.0.1","@smithy/fetch-http-handler":"^5.0.1","@smithy/hash-blob-browser":"^4.0.1","@smithy/hash-node":"^4.0.1","@smithy/hash-stream-node":"^4.0.1","@smithy/invalid-dependency":"^4.0.1","@smithy/md5-js":"^4.0.1","@smithy/middleware-content-length":"^4.0.1","@smithy/middleware-endpoint":"^4.0.5","@smithy/middleware-retry":"^4.0.6","@smithy/middleware-serde":"^4.0.2","@smithy/middleware-stack":"^4.0.1","@smithy/node-config-provider":"^4.0.1","@smithy/node-http-handler":"^4.0.2","@smithy/protocol-http":"^5.0.1","@smithy/smithy-client":"^4.1.5","@smithy/types":"^4.1.0","@smithy/url-parser":"^4.0.1","@smithy/util-base64":"^4.0.0","@smithy/util-body-length-browser":"^4.0.0","@smithy/util-body-length-node":"^4.0.0","@smithy/util-defaults-mode-browser":"^4.0.6","@smithy/util-defaults-mode-node":"^4.0.6","@smithy/util-endpoints":"^3.0.1","@smithy/util-middleware":"^4.0.1","@smithy/util-retry":"^4.0.1","@smithy/util-stream":"^4.1.1","@smithy/util-utf8":"^4.0.0","@smithy/util-waiter":"^4.0.2","tslib":"^2.6.2"},"devDependencies":{"@aws-sdk/signature-v4-crt":"3.750.0","@tsconfig/node18":"18.2.4","@types/node":"^18.19.69","concurrently":"7.0.0","downlevel-dts":"0.10.1","rimraf":"3.0.2","typescript":"~5.2.2"},"engines":{"node":">=18.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-03-
|
|
1
|
+
{"name":"@aws-sdk/client-s3","description":"AWS SDK for JavaScript S3 Client for Node.js, Browser and React Native","version":"3.750.0","scripts":{"build":"concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'","build:cjs":"node ../../scripts/compilation/inline client-s3","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 g:vitest run","test:browser":"node ./test/browser-build/esbuild && yarn g:vitest run -c vitest.config.browser.ts","test:browser:watch":"node ./test/browser-build/esbuild && yarn g:vitest watch -c vitest.config.browser.ts","test:e2e":"yarn g:vitest run -c vitest.config.e2e.ts && yarn test:browser","test:e2e:watch":"yarn g:vitest watch -c vitest.config.e2e.ts","test:watch":"yarn g:vitest watch"},"main":"./dist-cjs/index.js","types":"./dist-types/index.d.ts","module":"./dist-es/index.js","sideEffects":false,"dependencies":{"@aws-crypto/sha1-browser":"5.2.0","@aws-crypto/sha256-browser":"5.2.0","@aws-crypto/sha256-js":"5.2.0","@aws-sdk/core":"3.750.0","@aws-sdk/credential-provider-node":"3.750.0","@aws-sdk/middleware-bucket-endpoint":"3.734.0","@aws-sdk/middleware-expect-continue":"3.734.0","@aws-sdk/middleware-flexible-checksums":"3.750.0","@aws-sdk/middleware-host-header":"3.734.0","@aws-sdk/middleware-location-constraint":"3.734.0","@aws-sdk/middleware-logger":"3.734.0","@aws-sdk/middleware-recursion-detection":"3.734.0","@aws-sdk/middleware-sdk-s3":"3.750.0","@aws-sdk/middleware-ssec":"3.734.0","@aws-sdk/middleware-user-agent":"3.750.0","@aws-sdk/region-config-resolver":"3.734.0","@aws-sdk/signature-v4-multi-region":"3.750.0","@aws-sdk/types":"3.734.0","@aws-sdk/util-endpoints":"3.743.0","@aws-sdk/util-user-agent-browser":"3.734.0","@aws-sdk/util-user-agent-node":"3.750.0","@aws-sdk/xml-builder":"3.734.0","@smithy/config-resolver":"^4.0.1","@smithy/core":"^3.1.4","@smithy/eventstream-serde-browser":"^4.0.1","@smithy/eventstream-serde-config-resolver":"^4.0.1","@smithy/eventstream-serde-node":"^4.0.1","@smithy/fetch-http-handler":"^5.0.1","@smithy/hash-blob-browser":"^4.0.1","@smithy/hash-node":"^4.0.1","@smithy/hash-stream-node":"^4.0.1","@smithy/invalid-dependency":"^4.0.1","@smithy/md5-js":"^4.0.1","@smithy/middleware-content-length":"^4.0.1","@smithy/middleware-endpoint":"^4.0.5","@smithy/middleware-retry":"^4.0.6","@smithy/middleware-serde":"^4.0.2","@smithy/middleware-stack":"^4.0.1","@smithy/node-config-provider":"^4.0.1","@smithy/node-http-handler":"^4.0.2","@smithy/protocol-http":"^5.0.1","@smithy/smithy-client":"^4.1.5","@smithy/types":"^4.1.0","@smithy/url-parser":"^4.0.1","@smithy/util-base64":"^4.0.0","@smithy/util-body-length-browser":"^4.0.0","@smithy/util-body-length-node":"^4.0.0","@smithy/util-defaults-mode-browser":"^4.0.6","@smithy/util-defaults-mode-node":"^4.0.6","@smithy/util-endpoints":"^3.0.1","@smithy/util-middleware":"^4.0.1","@smithy/util-retry":"^4.0.1","@smithy/util-stream":"^4.1.1","@smithy/util-utf8":"^4.0.0","@smithy/util-waiter":"^4.0.2","tslib":"^2.6.2"},"devDependencies":{"@aws-sdk/signature-v4-crt":"3.750.0","@tsconfig/node18":"18.2.4","@types/node":"^18.19.69","concurrently":"7.0.0","downlevel-dts":"0.10.1","rimraf":"3.0.2","typescript":"~5.2.2"},"engines":{"node":">=18.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-03-17T10:38:59.013Z"}
|
|
@@ -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-03-
|
|
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-03-17T10:38:52.980Z"}
|
|
@@ -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-03-
|
|
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-03-17T10:38:57.620Z"}
|
|
@@ -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-03-
|
|
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-03-17T10:38:57.460Z"}
|
|
@@ -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-03-
|
|
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-03-17T10:39:04.505Z"}
|
|
@@ -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-03-
|
|
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-03-17T10:39:00.553Z"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 José F. Romaniello
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
var changelog = require('conventional-changelog');
|
|
4
|
+
var semver_regex = /\bv?(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?\b/ig;
|
|
5
|
+
|
|
6
|
+
const commitPartial = ` - {{header}}
|
|
7
|
+
|
|
8
|
+
{{~!-- commit hash --}} {{#if @root.linkReferences}}([{{hash}}]({{#if @root.host}}{{@root.host}}/{{/if}}{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}/{{@root.commit}}/{{hash}})){{else}}{{hash~}}{{/if}}
|
|
9
|
+
|
|
10
|
+
{{~!-- commit references --}}{{#if references}}, closes{{~#each references}} {{#if @root.linkReferences}}[{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}#{{this.issue}}]({{#if @root.host}}{{@root.host}}/{{/if}}{{#if this.repository}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}{{else}}{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}{{/if}}/{{@root.issue}}/{{this.issue}}){{else}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}#{{this.issue}}{{/if}}{{/each}}{{/if}}
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
const headerPartial = `## {{version}}{{#if title}} "{{title}}"{{/if}}{{#if date}} - {{date}}{{/if}}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
changelog({
|
|
17
|
+
releaseCount: 19,
|
|
18
|
+
// preset: 'jshint'
|
|
19
|
+
}, null, null, null, {
|
|
20
|
+
transform: function (commit) {
|
|
21
|
+
if (commit.header && semver_regex.exec(commit.header)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return commit;
|
|
25
|
+
},
|
|
26
|
+
commitPartial: commitPartial,
|
|
27
|
+
headerPartial: headerPartial
|
|
28
|
+
}).pipe(process.stdout);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){var e={821:function(e){(function(r,i,t){if(true&&e.exports)e.exports=t();else if(typeof define==="function"&&define.amd)define(t);else i[r]=t()})("urljoin",this,(function(){function normalize(e){var r=[];if(e.length===0){return""}if(typeof e[0]!=="string"){throw new TypeError("Url must be a string. Received "+e[0])}if(e[0].match(/^[^/:]+:\/*$/)&&e.length>1){var i=e.shift();e[0]=i+e[0]}if(e[0].match(/^file:\/\/\//)){e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///")}else{e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://")}for(var t=0;t<e.length;t++){var n=e[t];if(typeof n!=="string"){throw new TypeError("Url must be a string. Received "+n)}if(n===""){continue}if(t>0){n=n.replace(/^[\/]+/,"")}if(t<e.length-1){n=n.replace(/[\/]+$/,"")}else{n=n.replace(/[\/]+$/,"/")}r.push(n)}var f=r.join("/");f=f.replace(/\/(\?|&|#[^!])/g,"$1");var a=f.split("?");f=a.shift()+(a.length>0?"?":"")+a.join("&");return f}return function(){var e;if(typeof arguments[0]==="object"){e=arguments[0]}else{e=[].slice.call(arguments)}return normalize(e)}}))}};var r={};function __nccwpck_require__(i){var t=r[i];if(t!==undefined){return t.exports}var n=r[i]={exports:{}};var f=true;try{e[i].call(n.exports,n,n.exports,__nccwpck_require__);f=false}finally{if(f)delete r[i]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(821);module.exports=i})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"url-join","version":"4.0.1","description":"Join urls and normalize as in path.join.","main":"lib/url-join.js","scripts":{"test":"mocha --require should"},"repository":{"type":"git","url":"git://github.com/jfromaniello/url-join.git"},"keywords":["url","join"],"author":"José F. Romaniello <jfromaniello@gmail.com> (http://joseoncode.com)","license":"MIT","devDependencies":{"conventional-changelog":"^1.1.10","mocha":"^3.2.0","should":"~1.2.1"},"_lastModified":"2025-03-17T10:38:57.540Z"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
var urljoin = require('../lib/url-join');
|
|
2
|
+
var assert = require('assert');
|
|
3
|
+
|
|
4
|
+
describe('url join', function () {
|
|
5
|
+
it('should work for simple case', function () {
|
|
6
|
+
urljoin('http://www.google.com/', 'foo/bar', '?test=123')
|
|
7
|
+
.should.eql('http://www.google.com/foo/bar?test=123');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('should work for simple case with new syntax', function () {
|
|
11
|
+
urljoin(['http://www.google.com/', 'foo/bar', '?test=123'])
|
|
12
|
+
.should.eql('http://www.google.com/foo/bar?test=123');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should work for hashbang urls', function () {
|
|
16
|
+
urljoin(['http://www.google.com', '#!', 'foo/bar', '?test=123'])
|
|
17
|
+
.should.eql('http://www.google.com/#!/foo/bar?test=123');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should be able to join protocol', function () {
|
|
21
|
+
urljoin('http:', 'www.google.com/', 'foo/bar', '?test=123')
|
|
22
|
+
.should.eql('http://www.google.com/foo/bar?test=123');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should be able to join protocol with slashes', function () {
|
|
26
|
+
urljoin('http://', 'www.google.com/', 'foo/bar', '?test=123')
|
|
27
|
+
.should.eql('http://www.google.com/foo/bar?test=123');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should remove extra slashes', function () {
|
|
31
|
+
urljoin('http:', 'www.google.com///', 'foo/bar', '?test=123')
|
|
32
|
+
.should.eql('http://www.google.com/foo/bar?test=123');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should not remove extra slashes in an encoded URL', function () {
|
|
36
|
+
urljoin('http:', 'www.google.com///', 'foo/bar', '?url=http%3A//Ftest.com')
|
|
37
|
+
.should.eql('http://www.google.com/foo/bar?url=http%3A//Ftest.com');
|
|
38
|
+
|
|
39
|
+
urljoin('http://a.com/23d04b3/', '/b/c.html')
|
|
40
|
+
.should.eql('http://a.com/23d04b3/b/c.html')
|
|
41
|
+
.should.not.eql('http://a.com/23d04b3//b/c.html');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should support anchors in urls', function () {
|
|
45
|
+
urljoin('http:', 'www.google.com///', 'foo/bar', '?test=123', '#faaaaa')
|
|
46
|
+
.should.eql('http://www.google.com/foo/bar?test=123#faaaaa');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should support protocol-relative urls', function () {
|
|
50
|
+
urljoin('//www.google.com', 'foo/bar', '?test=123')
|
|
51
|
+
.should.eql('//www.google.com/foo/bar?test=123')
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should support file protocol urls', function () {
|
|
55
|
+
urljoin('file:/', 'android_asset', 'foo/bar')
|
|
56
|
+
.should.eql('file://android_asset/foo/bar')
|
|
57
|
+
|
|
58
|
+
urljoin('file:', '/android_asset', 'foo/bar')
|
|
59
|
+
.should.eql('file://android_asset/foo/bar')
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should support absolute file protocol urls', function () {
|
|
63
|
+
urljoin('file:', '///android_asset', 'foo/bar')
|
|
64
|
+
.should.eql('file:///android_asset/foo/bar')
|
|
65
|
+
|
|
66
|
+
urljoin('file:///', 'android_asset', 'foo/bar')
|
|
67
|
+
.should.eql('file:///android_asset/foo/bar')
|
|
68
|
+
|
|
69
|
+
urljoin('file:///', '//android_asset', 'foo/bar')
|
|
70
|
+
.should.eql('file:///android_asset/foo/bar')
|
|
71
|
+
|
|
72
|
+
urljoin('file:///android_asset', 'foo/bar')
|
|
73
|
+
.should.eql('file:///android_asset/foo/bar')
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should merge multiple query params properly', function () {
|
|
77
|
+
urljoin('http:', 'www.google.com///', 'foo/bar', '?test=123', '?key=456')
|
|
78
|
+
.should.eql('http://www.google.com/foo/bar?test=123&key=456');
|
|
79
|
+
|
|
80
|
+
urljoin('http:', 'www.google.com///', 'foo/bar', '?test=123', '?boom=value', '&key=456')
|
|
81
|
+
.should.eql('http://www.google.com/foo/bar?test=123&boom=value&key=456');
|
|
82
|
+
|
|
83
|
+
urljoin('http://example.org/x', '?a=1', '?b=2', '?c=3', '?d=4')
|
|
84
|
+
.should.eql('http://example.org/x?a=1&b=2&c=3&d=4');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should merge slashes in paths correctly', function () {
|
|
88
|
+
urljoin('http://example.org', 'a//', 'b//', 'A//', 'B//')
|
|
89
|
+
.should.eql('http://example.org/a/b/A/B/');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('should merge colons in paths correctly', function () {
|
|
93
|
+
urljoin('http://example.org/', ':foo:', 'bar')
|
|
94
|
+
.should.eql('http://example.org/:foo:/bar');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should merge just a simple path without URL correctly', function() {
|
|
98
|
+
urljoin('/', 'test')
|
|
99
|
+
.should.eql('/test');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should fail with segments that are not string', function() {
|
|
103
|
+
assert.throws(() => urljoin(true),
|
|
104
|
+
/Url must be a string. Received true/);
|
|
105
|
+
assert.throws(() => urljoin('http://blabla.com/', 1),
|
|
106
|
+
/Url must be a string. Received 1/);
|
|
107
|
+
assert.throws(() => urljoin('http://blabla.com/', undefined, 'test'),
|
|
108
|
+
/Url must be a string. Received undefined/);
|
|
109
|
+
assert.throws(() => urljoin('http://blabla.com/', null, 'test'),
|
|
110
|
+
/Url must be a string. Received null/);
|
|
111
|
+
assert.throws(() => urljoin('http://blabla.com/', { foo: 123 }, 'test'),
|
|
112
|
+
/Url must be a string. Received \[object Object\]/);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should merge a path with colon properly', function(){
|
|
116
|
+
urljoin('/users/:userId', '/cars/:carId')
|
|
117
|
+
.should.eql('/users/:userId/cars/:carId');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('should merge slashes in protocol correctly', function () {
|
|
121
|
+
urljoin('http://example.org', 'a')
|
|
122
|
+
.should.eql('http://example.org/a');
|
|
123
|
+
urljoin('http:', '//example.org', 'a')
|
|
124
|
+
.should.eql('http://example.org/a');
|
|
125
|
+
urljoin('http:///example.org', 'a')
|
|
126
|
+
.should.eql('http://example.org/a');
|
|
127
|
+
urljoin('file:///example.org', 'a')
|
|
128
|
+
.should.eql('file:///example.org/a');
|
|
129
|
+
|
|
130
|
+
urljoin('file:example.org', 'a')
|
|
131
|
+
.should.eql('file://example.org/a');
|
|
132
|
+
|
|
133
|
+
urljoin('file:/', 'example.org', 'a')
|
|
134
|
+
.should.eql('file://example.org/a');
|
|
135
|
+
urljoin('file:', '/example.org', 'a')
|
|
136
|
+
.should.eql('file://example.org/a');
|
|
137
|
+
urljoin('file:', '//example.org', 'a')
|
|
138
|
+
.should.eql('file://example.org/a');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should skip empty strings', function() {
|
|
142
|
+
urljoin('http://foobar.com', '', 'test')
|
|
143
|
+
.should.eql('http://foobar.com/test');
|
|
144
|
+
urljoin('', 'http://foobar.com', '', 'test')
|
|
145
|
+
.should.eql('http://foobar.com/test');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('should return an empty string if no arguments are supplied', function() {
|
|
149
|
+
urljoin().should.eql('');
|
|
150
|
+
});
|
|
151
|
+
});
|
|
@@ -7,15 +7,5 @@
|
|
|
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):
|
|
11
|
-
title: string;
|
|
12
|
-
filename: string;
|
|
13
|
-
extname: string;
|
|
14
|
-
path: any;
|
|
15
|
-
size: any;
|
|
16
|
-
url: string;
|
|
17
|
-
mimetype: any;
|
|
18
|
-
meta: unknown;
|
|
19
|
-
storageId: any;
|
|
20
|
-
};
|
|
10
|
+
export declare function getFileData(ctx: Context): Promise<any>;
|
|
21
11
|
export declare function createMiddleware(ctx: Context, next: Next): Promise<any>;
|
|
@@ -53,34 +53,35 @@ function getFileFilter(storage) {
|
|
|
53
53
|
cb(null, result);
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
function getFileData(ctx) {
|
|
56
|
+
async function getFileData(ctx) {
|
|
57
57
|
const { [import_constants.FILE_FIELD_NAME]: file, storage } = ctx;
|
|
58
58
|
if (!file) {
|
|
59
59
|
return ctx.throw(400, "file validation failed");
|
|
60
60
|
}
|
|
61
|
-
const
|
|
61
|
+
const plugin = ctx.app.pm.get(import__.default);
|
|
62
|
+
const StorageType = plugin.storageTypes.get(storage.type);
|
|
62
63
|
const { [StorageType.filenameKey || "filename"]: name } = file;
|
|
63
64
|
const filename = import_path.default.basename(name);
|
|
64
65
|
const extname = import_path.default.extname(filename);
|
|
65
66
|
const path = (storage.path || "").replace(/^\/|\/$/g, "");
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
let storageInstance = plugin.storagesCache.get(storage.id);
|
|
68
|
+
if (!storageInstance) {
|
|
69
|
+
await plugin.loadStorages();
|
|
70
|
+
storageInstance = plugin.storagesCache.get(storage.id);
|
|
71
|
+
}
|
|
72
|
+
const data = {
|
|
70
73
|
title: Buffer.from(file.originalname, "latin1").toString("utf8").replace(extname, ""),
|
|
71
74
|
filename,
|
|
72
75
|
extname,
|
|
73
76
|
// TODO(feature): 暂时两者相同,后面 storage.path 模版化以后,这里只是 file 实际的 path
|
|
74
77
|
path,
|
|
75
78
|
size: file.size,
|
|
76
|
-
// 直接缓存起来
|
|
77
|
-
url: `${baseUrl}/${pathname}`,
|
|
78
79
|
mimetype: file.mimetype,
|
|
79
|
-
// @ts-ignore
|
|
80
80
|
meta: ctx.request.body,
|
|
81
81
|
storageId: storage.id,
|
|
82
82
|
...storageInstance.getFileData ? storageInstance.getFileData(file) : {}
|
|
83
83
|
};
|
|
84
|
+
return data;
|
|
84
85
|
}
|
|
85
86
|
async function multipart(ctx, next) {
|
|
86
87
|
const { storage } = ctx;
|
|
@@ -114,7 +115,7 @@ async function multipart(ctx, next) {
|
|
|
114
115
|
ctx.logger.error(err);
|
|
115
116
|
return ctx.throw(500, err);
|
|
116
117
|
}
|
|
117
|
-
const values = getFileData(ctx);
|
|
118
|
+
const values = await getFileData(ctx);
|
|
118
119
|
ctx.action.mergeParams({
|
|
119
120
|
values
|
|
120
121
|
});
|
|
@@ -49,4 +49,23 @@ 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(
|
|
53
|
+
async (ctx, next) => {
|
|
54
|
+
var _a;
|
|
55
|
+
await next();
|
|
56
|
+
try {
|
|
57
|
+
const { resourceName, actionName } = ctx.action;
|
|
58
|
+
const collection = ctx.db.getCollection(resourceName);
|
|
59
|
+
if (((_a = collection == null ? void 0 : collection.options) == null ? void 0 : _a.template) !== "file") {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (actionName === "create" || actionName === "upload") {
|
|
63
|
+
ctx.body = await ctx.body.reload();
|
|
64
|
+
}
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.log(error);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{ before: "dataWrapping" }
|
|
70
|
+
);
|
|
52
71
|
}
|
package/dist/server/server.d.ts
CHANGED
|
@@ -29,17 +29,7 @@ export declare class PluginFileManagerServer extends Plugin {
|
|
|
29
29
|
registerStorageType(type: string, Type: StorageClassType): void;
|
|
30
30
|
createFileRecord(options: FileRecordOptions): Promise<any>;
|
|
31
31
|
parseStorage(instance: any): any;
|
|
32
|
-
uploadFile(options: UploadFileOptions): Promise<
|
|
33
|
-
title: string;
|
|
34
|
-
filename: string;
|
|
35
|
-
extname: string;
|
|
36
|
-
path: any;
|
|
37
|
-
size: any;
|
|
38
|
-
url: string;
|
|
39
|
-
mimetype: any;
|
|
40
|
-
meta: unknown;
|
|
41
|
-
storageId: any;
|
|
42
|
-
}>;
|
|
32
|
+
uploadFile(options: UploadFileOptions): Promise<any>;
|
|
43
33
|
loadStorages(options?: {
|
|
44
34
|
transaction: any;
|
|
45
35
|
}): Promise<void>;
|
|
@@ -47,6 +37,6 @@ export declare class PluginFileManagerServer extends Plugin {
|
|
|
47
37
|
handleSyncMessage(message: any): Promise<void>;
|
|
48
38
|
beforeLoad(): Promise<void>;
|
|
49
39
|
load(): Promise<void>;
|
|
50
|
-
getFileURL(file: AttachmentModel):
|
|
40
|
+
getFileURL(file: AttachmentModel, preview?: boolean): Promise<string>;
|
|
51
41
|
}
|
|
52
42
|
export default PluginFileManagerServer;
|
package/dist/server/server.js
CHANGED
|
@@ -43,9 +43,9 @@ module.exports = __toCommonJS(server_exports);
|
|
|
43
43
|
var import_server = require("@nocobase/server");
|
|
44
44
|
var import_utils = require("@nocobase/utils");
|
|
45
45
|
var import_path = require("path");
|
|
46
|
+
var import_database = require("@nocobase/database");
|
|
46
47
|
var import_fs = __toESM(require("fs"));
|
|
47
48
|
var import_constants = require("../constants");
|
|
48
|
-
var import_FileModel = require("./FileModel");
|
|
49
49
|
var import_actions = __toESM(require("./actions"));
|
|
50
50
|
var import_attachments = require("./actions/attachments");
|
|
51
51
|
var import_attachment_interface = require("./interfaces/attachment-interface");
|
|
@@ -149,7 +149,6 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
149
149
|
for (const storage of storages) {
|
|
150
150
|
this.storagesCache.set(storage.get("id"), this.parseStorage(storage));
|
|
151
151
|
}
|
|
152
|
-
this.db["_fileStorages"] = this.storagesCache;
|
|
153
152
|
}
|
|
154
153
|
async install() {
|
|
155
154
|
const defaultStorageType = this.storageTypes.get(DEFAULT_STORAGE_TYPE);
|
|
@@ -186,7 +185,7 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
186
185
|
}
|
|
187
186
|
}
|
|
188
187
|
async beforeLoad() {
|
|
189
|
-
this.db.registerModels({ FileModel:
|
|
188
|
+
this.db.registerModels({ FileModel: import_database.Model });
|
|
190
189
|
this.db.on("beforeDefineCollection", (options) => {
|
|
191
190
|
if (options.template === "file") {
|
|
192
191
|
options.model = "FileModel";
|
|
@@ -248,11 +247,37 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
248
247
|
this.app.acl.addFixedParams("attachments", "create", ownMerger);
|
|
249
248
|
this.app.acl.addFixedParams("attachments", "destroy", ownMerger);
|
|
250
249
|
this.app.db.interfaceManager.registerInterfaceType("attachment", import_attachment_interface.AttachmentInterface);
|
|
250
|
+
this.db.on("afterFind", async (instances) => {
|
|
251
|
+
var _a, _b, _c;
|
|
252
|
+
if (!instances) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const records = Array.isArray(instances) ? instances : [instances];
|
|
256
|
+
const name = (_b = (_a = records[0]) == null ? void 0 : _a.constructor) == null ? void 0 : _b.name;
|
|
257
|
+
if (name) {
|
|
258
|
+
const collection = this.db.getCollection(name);
|
|
259
|
+
if ((collection == null ? void 0 : collection.name) === "attachments" || ((_c = collection == null ? void 0 : collection.options) == null ? void 0 : _c.template) === "file") {
|
|
260
|
+
for (const record of records) {
|
|
261
|
+
const url = await this.getFileURL(record);
|
|
262
|
+
const previewUrl = await this.getFileURL(record, true);
|
|
263
|
+
record.set("url", url);
|
|
264
|
+
record.set("preview", previewUrl);
|
|
265
|
+
record.dataValues.preview = previewUrl;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
});
|
|
251
270
|
}
|
|
252
|
-
getFileURL(file) {
|
|
271
|
+
async getFileURL(file, preview = false) {
|
|
272
|
+
if (!file.storageId) {
|
|
273
|
+
return file.url;
|
|
274
|
+
}
|
|
253
275
|
const storage = this.storagesCache.get(file.storageId);
|
|
276
|
+
if (!storage) {
|
|
277
|
+
return file.url;
|
|
278
|
+
}
|
|
254
279
|
const storageType = this.storageTypes.get(storage.type);
|
|
255
|
-
return new storageType(storage).getFileURL(file);
|
|
280
|
+
return new storageType(storage).getFileURL(file, preview ? storage.options.thumbnailRule : "");
|
|
256
281
|
}
|
|
257
282
|
}
|
|
258
283
|
var server_default = PluginFileManagerServer;
|
|
@@ -38,7 +38,7 @@ export declare abstract class StorageType {
|
|
|
38
38
|
}): {
|
|
39
39
|
[key: string]: any;
|
|
40
40
|
};
|
|
41
|
-
getFileURL(file: AttachmentModel): string | Promise<string>;
|
|
41
|
+
getFileURL(file: AttachmentModel, preview?: boolean): string | Promise<string>;
|
|
42
42
|
}
|
|
43
43
|
export type StorageClassType = {
|
|
44
44
|
new (storage: StorageModel): StorageType;
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
var __create = Object.create;
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
11
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
13
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
15
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
16
|
var __export = (target, all) => {
|
|
15
17
|
for (var name in all)
|
|
@@ -23,12 +25,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
25
|
}
|
|
24
26
|
return to;
|
|
25
27
|
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
26
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
37
|
var storages_exports = {};
|
|
28
38
|
__export(storages_exports, {
|
|
29
39
|
StorageType: () => StorageType
|
|
30
40
|
});
|
|
31
41
|
module.exports = __toCommonJS(storages_exports);
|
|
42
|
+
var import_utils = require("@nocobase/utils");
|
|
43
|
+
var import_url_join = __toESM(require("url-join"));
|
|
32
44
|
class StorageType {
|
|
33
45
|
constructor(storage) {
|
|
34
46
|
this.storage = storage;
|
|
@@ -37,8 +49,20 @@ class StorageType {
|
|
|
37
49
|
return {};
|
|
38
50
|
}
|
|
39
51
|
static filenameKey;
|
|
40
|
-
getFileURL(file) {
|
|
41
|
-
|
|
52
|
+
getFileURL(file, preview) {
|
|
53
|
+
if (file.url && (0, import_utils.isURL)(file.url)) {
|
|
54
|
+
if (preview) {
|
|
55
|
+
return file.url + (this.storage.options.thumbnailRule || "");
|
|
56
|
+
}
|
|
57
|
+
return file.url;
|
|
58
|
+
}
|
|
59
|
+
const keys = [
|
|
60
|
+
this.storage.baseUrl,
|
|
61
|
+
file.path && encodeURI(file.path),
|
|
62
|
+
encodeURIComponent(file.filename),
|
|
63
|
+
preview && this.storage.options.thumbnailRule
|
|
64
|
+
].filter(Boolean);
|
|
65
|
+
return (0, import_url_join.default)(keys);
|
|
42
66
|
}
|
|
43
67
|
}
|
|
44
68
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -24,5 +24,5 @@ export default class extends StorageType {
|
|
|
24
24
|
};
|
|
25
25
|
make(): multer.StorageEngine;
|
|
26
26
|
delete(records: AttachmentModel[]): Promise<[number, AttachmentModel[]]>;
|
|
27
|
-
getFileURL(file: AttachmentModel):
|
|
27
|
+
getFileURL(file: AttachmentModel, preview?: boolean): Promise<any>;
|
|
28
28
|
}
|
|
@@ -39,13 +39,16 @@ __export(local_exports, {
|
|
|
39
39
|
default: () => local_default
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(local_exports);
|
|
42
|
+
var import_utils = require("@nocobase/utils");
|
|
42
43
|
var import_promises = __toESM(require("fs/promises"));
|
|
43
44
|
var import_mkdirp = __toESM(require("mkdirp"));
|
|
44
45
|
var import_multer = __toESM(require("multer"));
|
|
45
46
|
var import_path = __toESM(require("path"));
|
|
47
|
+
var import_url_join = __toESM(require("url-join"));
|
|
46
48
|
var import__ = require(".");
|
|
47
49
|
var import_constants = require("../../constants");
|
|
48
|
-
var
|
|
50
|
+
var import_utils2 = require("../utils");
|
|
51
|
+
const DEFAULT_BASE_URL = "/storage/uploads";
|
|
49
52
|
function getDocumentRoot(storage) {
|
|
50
53
|
const { documentRoot = process.env.LOCAL_STORAGE_DEST || "storage/uploads" } = storage.options || {};
|
|
51
54
|
return import_path.default.resolve(import_path.default.isAbsolute(documentRoot) ? documentRoot : import_path.default.join(process.cwd(), documentRoot));
|
|
@@ -56,7 +59,7 @@ class local_default extends import__.StorageType {
|
|
|
56
59
|
title: "Local storage",
|
|
57
60
|
type: import_constants.STORAGE_TYPE_LOCAL,
|
|
58
61
|
name: `local`,
|
|
59
|
-
baseUrl:
|
|
62
|
+
baseUrl: DEFAULT_BASE_URL,
|
|
60
63
|
options: {
|
|
61
64
|
documentRoot: "storage/uploads"
|
|
62
65
|
},
|
|
@@ -72,7 +75,7 @@ class local_default extends import__.StorageType {
|
|
|
72
75
|
const destPath = import_path.default.join(getDocumentRoot(this.storage), this.storage.path || "");
|
|
73
76
|
(0, import_mkdirp.default)(destPath, (err) => cb(err, destPath));
|
|
74
77
|
},
|
|
75
|
-
filename:
|
|
78
|
+
filename: import_utils2.getFilename
|
|
76
79
|
});
|
|
77
80
|
}
|
|
78
81
|
async delete(records) {
|
|
@@ -98,7 +101,11 @@ class local_default extends import__.StorageType {
|
|
|
98
101
|
);
|
|
99
102
|
return [count, undeleted];
|
|
100
103
|
}
|
|
101
|
-
getFileURL(file) {
|
|
102
|
-
|
|
104
|
+
async getFileURL(file, preview = false) {
|
|
105
|
+
const url = await super.getFileURL(file, preview);
|
|
106
|
+
if ((0, import_utils.isURL)(url)) {
|
|
107
|
+
return url;
|
|
108
|
+
}
|
|
109
|
+
return (0, import_url_join.default)(process.env.APP_PUBLIC_PATH, url);
|
|
103
110
|
}
|
|
104
111
|
}
|
|
@@ -22,5 +22,9 @@ export default class extends StorageType {
|
|
|
22
22
|
};
|
|
23
23
|
static filenameKey: string;
|
|
24
24
|
make(): any;
|
|
25
|
+
calculateContentMD5(body: any): string;
|
|
26
|
+
deleteS3Objects(bucketName: string, objects: string[]): Promise<{
|
|
27
|
+
Deleted: any[];
|
|
28
|
+
}>;
|
|
25
29
|
delete(records: AttachmentModel[]): Promise<[number, AttachmentModel[]]>;
|
|
26
30
|
}
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
var __create = Object.create;
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
11
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
13
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
15
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
16
|
var __export = (target, all) => {
|
|
15
17
|
for (var name in all)
|
|
@@ -23,12 +25,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
25
|
}
|
|
24
26
|
return to;
|
|
25
27
|
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
26
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
37
|
var s3_exports = {};
|
|
28
38
|
__export(s3_exports, {
|
|
29
39
|
default: () => s3_default
|
|
30
40
|
});
|
|
31
41
|
module.exports = __toCommonJS(s3_exports);
|
|
42
|
+
var import_client_s3 = require("@aws-sdk/client-s3");
|
|
43
|
+
var import_crypto = __toESM(require("crypto"));
|
|
32
44
|
var import__ = require(".");
|
|
33
45
|
var import_constants = require("../../constants");
|
|
34
46
|
var import_utils = require("../utils");
|
|
@@ -49,7 +61,6 @@ class s3_default extends import__.StorageType {
|
|
|
49
61
|
}
|
|
50
62
|
static filenameKey = "key";
|
|
51
63
|
make() {
|
|
52
|
-
const { S3Client } = require("@aws-sdk/client-s3");
|
|
53
64
|
const multerS3 = require("multer-s3");
|
|
54
65
|
const { accessKeyId, secretAccessKey, bucket, acl = "public-read", ...options } = this.storage.options;
|
|
55
66
|
if (options.endpoint) {
|
|
@@ -57,7 +68,7 @@ class s3_default extends import__.StorageType {
|
|
|
57
68
|
} else {
|
|
58
69
|
options.endpoint = void 0;
|
|
59
70
|
}
|
|
60
|
-
const s3 = new S3Client({
|
|
71
|
+
const s3 = new import_client_s3.S3Client({
|
|
61
72
|
...options,
|
|
62
73
|
credentials: {
|
|
63
74
|
accessKeyId,
|
|
@@ -78,16 +89,29 @@ class s3_default extends import__.StorageType {
|
|
|
78
89
|
key: (0, import_utils.cloudFilenameGetter)(this.storage)
|
|
79
90
|
});
|
|
80
91
|
}
|
|
81
|
-
|
|
82
|
-
const
|
|
92
|
+
calculateContentMD5(body) {
|
|
93
|
+
const hash = import_crypto.default.createHash("md5").update(body).digest("base64");
|
|
94
|
+
return hash;
|
|
95
|
+
}
|
|
96
|
+
async deleteS3Objects(bucketName, objects) {
|
|
83
97
|
const { s3 } = this.make();
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
const Deleted = [];
|
|
99
|
+
for (const Key of objects) {
|
|
100
|
+
const deleteCommand = new import_client_s3.DeleteObjectCommand({
|
|
101
|
+
Bucket: bucketName,
|
|
102
|
+
Key
|
|
103
|
+
});
|
|
104
|
+
await s3.send(deleteCommand);
|
|
105
|
+
Deleted.push({ Key });
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
Deleted
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async delete(records) {
|
|
112
|
+
const { Deleted } = await this.deleteS3Objects(
|
|
113
|
+
this.storage.options.bucket,
|
|
114
|
+
records.map((record) => (0, import_utils.getFileKey)(record))
|
|
91
115
|
);
|
|
92
116
|
return [Deleted.length, records.filter((record) => !Deleted.find((item) => item.Key === (0, import_utils.getFileKey)(record)))];
|
|
93
117
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-file-manager",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"displayName": "File manager",
|
|
5
5
|
"displayName.zh-CN": "文件管理器",
|
|
6
6
|
"description": "Provides files storage services with files collection template and attachment field.",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/file-manager",
|
|
11
11
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/file-manager",
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@aws-sdk/client-s3": "
|
|
13
|
+
"@aws-sdk/client-s3": "3.750.0",
|
|
14
14
|
"@formily/antd-v5": "1.x",
|
|
15
15
|
"@formily/core": "2.x",
|
|
16
16
|
"@formily/react": "2.x",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"multer-s3": "^3.0.1",
|
|
30
30
|
"react": "^18.2.0",
|
|
31
31
|
"react-i18next": "^11.15.1",
|
|
32
|
-
"supertest": "^6.1.6"
|
|
32
|
+
"supertest": "^6.1.6",
|
|
33
|
+
"url-join": "4.0.1"
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|
|
35
36
|
"@nocobase/actions": "1.x",
|
|
@@ -43,5 +44,5 @@
|
|
|
43
44
|
"Collections",
|
|
44
45
|
"Collection fields"
|
|
45
46
|
],
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "5b6c5b28eadaa9bc8e5d05952e433a9ccd056ae9"
|
|
47
48
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Model } from '@nocobase/database';
|
|
10
|
-
export declare class FileModel extends Model {
|
|
11
|
-
toJSON(): any;
|
|
12
|
-
}
|
package/dist/server/FileModel.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var FileModel_exports = {};
|
|
28
|
-
__export(FileModel_exports, {
|
|
29
|
-
FileModel: () => FileModel
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(FileModel_exports);
|
|
32
|
-
var import_database = require("@nocobase/database");
|
|
33
|
-
var import_constants = require("../constants");
|
|
34
|
-
const currentStorage = [import_constants.STORAGE_TYPE_LOCAL, import_constants.STORAGE_TYPE_ALI_OSS, import_constants.STORAGE_TYPE_S3, import_constants.STORAGE_TYPE_TX_COS];
|
|
35
|
-
class FileModel extends import_database.Model {
|
|
36
|
-
toJSON() {
|
|
37
|
-
var _a, _b, _c, _d, _e;
|
|
38
|
-
const json = super.toJSON();
|
|
39
|
-
const fileStorages = (_a = this.constructor["database"]) == null ? void 0 : _a["_fileStorages"];
|
|
40
|
-
if (json.storageId && fileStorages && fileStorages.has(json.storageId)) {
|
|
41
|
-
const storage = fileStorages.get(json.storageId);
|
|
42
|
-
if (currentStorage.includes(storage == null ? void 0 : storage.type) && ((_b = storage == null ? void 0 : storage.options) == null ? void 0 : _b.thumbnailRule)) {
|
|
43
|
-
json["preview"] = `${json["url"]}${((_c = storage == null ? void 0 : storage.options) == null ? void 0 : _c.thumbnailRule) || ""}`;
|
|
44
|
-
}
|
|
45
|
-
if ((_d = storage == null ? void 0 : storage.options) == null ? void 0 : _d.thumbnailRule) {
|
|
46
|
-
json["thumbnailRule"] = (_e = storage == null ? void 0 : storage.options) == null ? void 0 : _e.thumbnailRule;
|
|
47
|
-
}
|
|
48
|
-
if ((storage == null ? void 0 : storage.type) === "local" && process.env.APP_PUBLIC_PATH) {
|
|
49
|
-
json["url"] = process.env.APP_PUBLIC_PATH.replace(/\/$/g, "") + json.url;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return json;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
-
0 && (module.exports = {
|
|
57
|
-
FileModel
|
|
58
|
-
});
|