@nocobase/plugin-file-manager 2.2.0-beta.16 → 2.2.0-beta.18

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.
@@ -1 +1 @@
1
- {"name":"cos-nodejs-sdk-v5","version":"2.12.6","description":"cos nodejs sdk v5","main":"index.js","types":"index.d.ts","scripts":{"prettier":"prettier --write sdk demo/demo.js test/test.js index.d.ts","demo":"node demo/demo.js","demo-sts":"node demo/demo-sts.js","demo-sts-scope":"node demo/demo-sts-scope.js","test":"mocha test/test.js","cov":"istanbul cover _mocha -- -u exports 'test/test.js'","nyc":"nyc --reporter=clover --reporter=cobertura mocha --reporter xunit --reporter-options output=mocha.xml test/test.js","csp":"mocha test/csp.js"},"repository":{"type":"git","url":"git+https://github.com/tencentyun/cos-nodejs-sdk-v5.git"},"keywords":["tencent","tencent cloud","qcloud","cos","cos-sdk"],"author":"carsonxu","license":"ISC","bugs":{"url":"https://github.com/tencentyun/cos-nodejs-sdk-v5/issues"},"homepage":"https://github.com/tencentyun/cos-nodejs-sdk-v5#readme","dependencies":{"conf":"^9.0.0","fast-xml-parser":"4.2.5","mime-types":"^2.1.24","request":"^2.88.2"},"devDependencies":{"@types/node":"^14.14.20","batch":"^0.6.1","crc64-ecma182.js":"^1.0.0","mocha":"^4.0.1","nyc":"^15.1.0","prettier":"^3.0.1","qcloud-cos-sts":"^3.0.0"},"engines":{"node":">= 6"},"_lastModified":"2026-07-31T07:45:56.163Z"}
1
+ {"name":"cos-nodejs-sdk-v5","version":"2.12.6","description":"cos nodejs sdk v5","main":"index.js","types":"index.d.ts","scripts":{"prettier":"prettier --write sdk demo/demo.js test/test.js index.d.ts","demo":"node demo/demo.js","demo-sts":"node demo/demo-sts.js","demo-sts-scope":"node demo/demo-sts-scope.js","test":"mocha test/test.js","cov":"istanbul cover _mocha -- -u exports 'test/test.js'","nyc":"nyc --reporter=clover --reporter=cobertura mocha --reporter xunit --reporter-options output=mocha.xml test/test.js","csp":"mocha test/csp.js"},"repository":{"type":"git","url":"git+https://github.com/tencentyun/cos-nodejs-sdk-v5.git"},"keywords":["tencent","tencent cloud","qcloud","cos","cos-sdk"],"author":"carsonxu","license":"ISC","bugs":{"url":"https://github.com/tencentyun/cos-nodejs-sdk-v5/issues"},"homepage":"https://github.com/tencentyun/cos-nodejs-sdk-v5#readme","dependencies":{"conf":"^9.0.0","fast-xml-parser":"4.2.5","mime-types":"^2.1.24","request":"^2.88.2"},"devDependencies":{"@types/node":"^14.14.20","batch":"^0.6.1","crc64-ecma182.js":"^1.0.0","mocha":"^4.0.1","nyc":"^15.1.0","prettier":"^3.0.1","qcloud-cos-sts":"^3.0.0"},"engines":{"node":">= 6"},"_lastModified":"2026-08-20T12:47:31.859Z"}
@@ -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":"2026-07-31T07:45:44.334Z"}
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":"2026-08-20T12:47:23.152Z"}
@@ -1 +1 @@
1
- {"name":"mime-types","description":"The ultimate javascript content-type utility.","version":"3.0.1","contributors":["Douglas Christopher Wilson <doug@somethingdoug.com>","Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)","Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"],"license":"MIT","keywords":["mime","types"],"repository":"jshttp/mime-types","dependencies":{"mime-db":"^1.54.0"},"devDependencies":{"eslint":"8.33.0","eslint-config-standard":"14.1.1","eslint-plugin-import":"2.27.5","eslint-plugin-markdown":"3.0.0","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"6.1.1","eslint-plugin-standard":"4.1.0","mocha":"10.2.0","nyc":"15.1.0"},"files":["HISTORY.md","LICENSE","index.js","mimeScore.js"],"engines":{"node":">= 0.6"},"scripts":{"lint":"eslint .","test":"mocha --reporter spec test/test.js","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_lastModified":"2026-07-31T07:45:44.666Z"}
1
+ {"name":"mime-types","description":"The ultimate javascript content-type utility.","version":"3.0.1","contributors":["Douglas Christopher Wilson <doug@somethingdoug.com>","Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)","Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"],"license":"MIT","keywords":["mime","types"],"repository":"jshttp/mime-types","dependencies":{"mime-db":"^1.54.0"},"devDependencies":{"eslint":"8.33.0","eslint-config-standard":"14.1.1","eslint-plugin-import":"2.27.5","eslint-plugin-markdown":"3.0.0","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"6.1.1","eslint-plugin-standard":"4.1.0","mocha":"10.2.0","nyc":"15.1.0"},"files":["HISTORY.md","LICENSE","index.js","mimeScore.js"],"engines":{"node":">= 0.6"},"scripts":{"lint":"eslint .","test":"mocha --reporter spec test/test.js","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_lastModified":"2026-08-20T12:47:23.478Z"}
@@ -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":"2026-07-31T07:45:49.600Z"}
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":"2026-08-20T12:47:27.221Z"}
@@ -1 +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":"2026-07-31T07:45:44.444Z"}
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":"2026-08-20T12:47:23.312Z"}
@@ -35,8 +35,16 @@ var import_temporary_access = require("../temporary-access");
35
35
  var import_utils = require("../utils");
36
36
  var import_resolve_file_access_filter = require("../resolve-file-access-filter");
37
37
  const GET_FILE_ACTION = "getFile";
38
+ function preserveSubAppInLocalURL(url, appName) {
39
+ if (!appName || appName === "main" || !url.startsWith("/") || url.startsWith("//")) {
40
+ return url;
41
+ }
42
+ const [urlWithoutHash, hash] = url.split("#", 2);
43
+ const separator = urlWithoutHash.includes("?") ? "&" : "?";
44
+ return `${urlWithoutHash}${separator}__appName=${encodeURIComponent(appName)}${hash ? `#${hash}` : ""}`;
45
+ }
38
46
  async function getFile(ctx, next) {
39
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
47
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
40
48
  const collection = ctx.dataSource.collectionManager.getCollection(ctx.action.resourceName);
41
49
  if (!collection || collection.name !== "attachments" && ((_a = collection.options) == null ? void 0 : _a.template) !== "file") {
42
50
  return ctx.throw(404);
@@ -99,7 +107,8 @@ async function getFile(ctx, next) {
99
107
  return ctx.throw(404);
100
108
  }
101
109
  const publicAccess = Boolean((_g = (_f = plugin.storagesCache.get(storageId)) == null ? void 0 : _f.options) == null ? void 0 : _g.public);
102
- if (!temporaryAccess && !publicAccess && !authorizedByExtension && ctx.app.options.acl !== false && ((_h = ctx.dataSource.options) == null ? void 0 : _h.useACL) !== false && ((_i = ctx.dataSource.options) == null ? void 0 : _i.acl) !== false) {
110
+ const loggedInAttachmentAccess = collection.name === "attachments" && Boolean(ctx.state.currentUser);
111
+ if (!temporaryAccess && !publicAccess && !loggedInAttachmentAccess && !authorizedByExtension && ctx.app.options.acl !== false && ((_h = ctx.dataSource.options) == null ? void 0 : _h.useACL) !== false && ((_i = ctx.dataSource.options) == null ? void 0 : _i.acl) !== false) {
103
112
  const filter = await (0, import_resolve_file_access_filter.resolveFileAccessFilter)(ctx, collection, { id });
104
113
  file = await ctx.getCurrentRepository().findOne({
105
114
  filter,
@@ -113,12 +122,13 @@ async function getFile(ctx, next) {
113
122
  const download = !temporaryAccess && ctx.method === "GET" && ctx.query.download === "1";
114
123
  const preview = download ? false : temporaryAccess ? false : Boolean((_j = ctx.state.fileAccess) == null ? void 0 : _j.preview);
115
124
  const dataSource = ctx.dataSource;
116
- const finalUrl = await ((_k = dataSource.resolveStorageFileURL) == null ? void 0 : _k.call(dataSource, {
125
+ const storageUrl = await ((_k = dataSource.resolveStorageFileURL) == null ? void 0 : _k.call(dataSource, {
117
126
  collectionName: collection.name,
118
127
  file: (0, import_utils.getFilePlainObject)(file),
119
128
  preview,
120
129
  download
121
130
  })) || await plugin.getFileURL(file, preview, { download });
131
+ const finalUrl = preserveSubAppInLocalURL(storageUrl, (_l = ctx.state.fileAccess) == null ? void 0 : _l.appName);
122
132
  ctx.status = 302;
123
133
  ctx.redirect(finalUrl);
124
134
  await next();
@@ -119,7 +119,8 @@ async function createTemporaryURLAction(ctx, next) {
119
119
  }
120
120
  const id = ctx.action.params.filterByTk;
121
121
  let filter = { id };
122
- if (ctx.app.options.acl !== false && ((_a = ctx.dataSource.options) == null ? void 0 : _a.useACL) !== false && ((_b = ctx.dataSource.options) == null ? void 0 : _b.acl) !== false) {
122
+ const loggedInAttachmentAccess = collection.name === "attachments" && Boolean(ctx.state.currentUser);
123
+ if (!loggedInAttachmentAccess && ctx.app.options.acl !== false && ((_a = ctx.dataSource.options) == null ? void 0 : _a.useACL) !== false && ((_b = ctx.dataSource.options) == null ? void 0 : _b.acl) !== false) {
123
124
  filter = await (0, import_resolve_file_access_filter.resolveFileAccessFilter)(ctx, collection, filter);
124
125
  }
125
126
  const file = await ctx.getCurrentRepository().findOne({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-file-manager",
3
- "version": "2.2.0-beta.16",
3
+ "version": "2.2.0-beta.18",
4
4
  "displayName": "File manager",
5
5
  "displayName.ru-RU": "Менеджер файлов",
6
6
  "displayName.zh-CN": "文件管理器",
@@ -62,5 +62,5 @@
62
62
  "Collections",
63
63
  "Collection fields"
64
64
  ],
65
- "gitHead": "49d9bd2e21122eab9435f128375828b8c5bb4c07"
65
+ "gitHead": "b74c962f7d35aa12012d908d16bd74fe6ac20a3d"
66
66
  }