@nocobase/plugin-file-manager 2.3.0-alpha.1 → 2.3.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/UseOriginalUrlRadio.d.ts +12 -0
- package/dist/client/index.js +1 -1
- package/dist/client/schemas/storageTypes/ali-oss.d.ts +12 -0
- package/dist/client/schemas/storageTypes/common.d.ts +12 -0
- package/dist/client/schemas/storageTypes/index.d.ts +48 -0
- package/dist/client/schemas/storageTypes/local.d.ts +12 -0
- package/dist/client/schemas/storageTypes/s3.d.ts +12 -0
- package/dist/client/schemas/storageTypes/tx-cos.d.ts +12 -0
- package/dist/client-v2/{229.bd72c2d7aa088310.js → 229.297c431f63a29cb2.js} +1 -1
- package/dist/client-v2/{336.1dd1b32466d0c778.js → 336.04d06f2cdcc3d0b5.js} +1 -1
- package/dist/client-v2/{43.eb45d53ba3e9828b.js → 43.1ec3e5bf1118d239.js} +1 -1
- package/dist/client-v2/{929.d7e783304cc1f236.js → 929.3744119eff70b3a3.js} +1 -1
- package/dist/client-v2/942.c3dcb7d4c8ebbc72.js +10 -0
- package/dist/client-v2/FileCollectionConfigure.d.ts +17 -0
- package/dist/client-v2/components/PublicAccessField.d.ts +19 -0
- package/dist/client-v2/components/UseOriginalUrlField.d.ts +25 -0
- package/dist/client-v2/components/index.d.ts +2 -0
- package/dist/client-v2/index.d.ts +2 -1
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +14 -13
- package/dist/locale/de-DE.json +7 -0
- package/dist/locale/en-US.json +7 -0
- package/dist/locale/es-ES.json +7 -0
- package/dist/locale/fr-FR.json +7 -0
- package/dist/locale/hu-HU.json +7 -0
- package/dist/locale/id-ID.json +7 -0
- package/dist/locale/it-IT.json +7 -0
- package/dist/locale/ja-JP.json +7 -0
- package/dist/locale/ko-KR.json +7 -0
- package/dist/locale/nl-NL.json +7 -0
- package/dist/locale/pt-BR.json +7 -0
- package/dist/locale/ru-RU.json +7 -0
- package/dist/locale/tr-TR.json +7 -0
- package/dist/locale/uk-UA.json +7 -0
- package/dist/locale/vi-VN.json +7 -0
- package/dist/locale/zh-CN.json +7 -0
- package/dist/locale/zh-TW.json +7 -0
- package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
- package/dist/node_modules/@aws-sdk/lib-storage/package.json +1 -1
- package/dist/node_modules/@aws-sdk/s3-request-presigner/package.json +1 -1
- package/dist/node_modules/ali-oss/package.json +1 -1
- package/dist/node_modules/cos-nodejs-sdk-v5/package.json +1 -1
- package/dist/node_modules/mime-match/package.json +1 -1
- package/dist/node_modules/mime-types/package.json +1 -1
- package/dist/node_modules/mkdirp/package.json +1 -1
- package/dist/node_modules/url-join/package.json +1 -1
- package/dist/server/actions/attachments.js +9 -1
- package/dist/server/actions/get-file.js +31 -11
- package/dist/server/file-reference.d.ts +16 -0
- package/dist/server/file-reference.js +108 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +4 -1
- package/dist/server/server.js +8 -7
- package/dist/server/temporary-access.js +2 -1
- package/package.json +2 -2
- package/dist/client-v2/942.f36d807d763a1b53.js +0 -10
package/dist/server/server.js
CHANGED
|
@@ -358,9 +358,13 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
358
358
|
});
|
|
359
359
|
}
|
|
360
360
|
async setFileResponseURLs(record, collectionName) {
|
|
361
|
-
|
|
362
|
-
const previewUrl = this.getPermanentFileURL(record, true, { collectionName });
|
|
361
|
+
var _a;
|
|
363
362
|
const storage = this.storagesCache.get(record.get("storageId"));
|
|
363
|
+
const useOriginalUrl = Boolean((_a = storage == null ? void 0 : storage.options) == null ? void 0 : _a.useOriginalUrl);
|
|
364
|
+
const [url, previewUrl] = useOriginalUrl ? await Promise.all([this.getFileURL(record), this.getFileURL(record, true)]) : [
|
|
365
|
+
this.getPermanentFileURL(record, false, { collectionName }),
|
|
366
|
+
this.getPermanentFileURL(record, true, { collectionName })
|
|
367
|
+
];
|
|
364
368
|
record.set("url", url);
|
|
365
369
|
record.set("preview", previewUrl);
|
|
366
370
|
record.dataValues.preview = previewUrl;
|
|
@@ -407,7 +411,7 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
407
411
|
);
|
|
408
412
|
}
|
|
409
413
|
async isPublicAccessStorage(storageName) {
|
|
410
|
-
var _a;
|
|
414
|
+
var _a, _b;
|
|
411
415
|
const storageRepository = this.db.getRepository("storages");
|
|
412
416
|
const storages = await storageRepository.findOne({
|
|
413
417
|
filter: { default: true }
|
|
@@ -423,10 +427,7 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
423
427
|
});
|
|
424
428
|
}
|
|
425
429
|
storage = this.parseStorage(storage);
|
|
426
|
-
|
|
427
|
-
return true;
|
|
428
|
-
}
|
|
429
|
-
return !!((_a = storage.options) == null ? void 0 : _a.public);
|
|
430
|
+
return Boolean(((_a = storage.options) == null ? void 0 : _a.public) || ((_b = storage.options) == null ? void 0 : _b.useOriginalUrl));
|
|
430
431
|
}
|
|
431
432
|
async getFileStream(file, options) {
|
|
432
433
|
var _a;
|
|
@@ -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
|
-
|
|
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.3.0-
|
|
3
|
+
"version": "2.3.0-beta.10",
|
|
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": "
|
|
65
|
+
"gitHead": "7aa3dce6cf3201752882f7012c72997898015d89"
|
|
66
66
|
}
|
|
@@ -1,10 +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
|
-
"use strict";(self.webpackChunk_nocobase_plugin_file_manager_client_v2=self.webpackChunk_nocobase_plugin_file_manager_client_v2||[]).push([["942"],{837:function(e,t,r){r.r(t),r.d(t,{default:function(){return E}});var n=r(375),a=r(477),o=r(485),l=r(694),u=r(625),i=r(59),c=r(773),s=r(155),f=r.n(s),p=r(488),d=r(667);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function y(e,t,r,n,a,o,l){try{var u=e[o](l),i=u.value}catch(e){r(e);return}u.done?t(i):Promise.resolve(i).then(n,a)}function b(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function l(e){y(o,n,a,l,u,"next",e)}function u(e){y(o,n,a,l,u,"throw",e)}l(void 0)})}}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],l=!0,u=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){u=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(u)throw n}}return o}}(e,t)||v(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e,t){if(e){if("string"==typeof e)return m(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return m(e,t)}}function h(e,t){var r,n,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(l,"next",{value:i(0)}),u(l,"throw",{value:i(1)}),u(l,"return",{value:i(2)}),"function"==typeof Symbol&&u(l,Symbol.iterator,{value:function(){return this}}),l;function i(u){return function(i){var c=[u,i];if(r)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){o=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){o.label=c[1];break}if(6===c[0]&&o.label<a[1]){o.label=a[1],a=c;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(c);break}a[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function w(){var e,t,r=(e=["\n .ant-radio-group {\n display: flex;\n flex-wrap: wrap;\n gap: ","px;\n }\n\n .ant-radio-wrapper {\n margin-inline-end: 0;\n max-width: 100%;\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return w=function(){return r},r}function S(){return(0,l.useFlowContext)().api.resource("storages")}function O(e){var t,r=(0,p.k)(),n=S(),u=g(i.Form.useForm(),1)[0],d=g((0,s.useState)(!1),2),m=d[0],y=d[1],v=(t=i.theme.useToken().token,(0,s.useMemo)(function(){return(0,a.css)(w(),t.marginSM)},[t.marginSM])),O=(0,s.useMemo)(function(){var t,r,n={mode:e.mode,storageType:e.storageType,record:e.record};return"edit"===n.mode?(0,c.cloneDeep)(n.record||{}):(t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},(0,c.cloneDeep)(n.storageType.defaultValues||{})),r=r={type:n.storageType.name,name:(0,l.randomId)("s_")},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t)},[e.mode,e.record,e.storageType]);(0,s.useEffect)(function(){u.setFieldsValue(O)},[u,O]);var E=(0,s.useCallback)(function(){return b(function(){var t,r;return h(this,function(a){switch(a.label){case 0:return[4,u.validateFields()];case 1:t=a.sent(),y(!0),a.label=2;case 2:if(a.trys.push([2,,7,8]),"create"!==e.mode)return[3,4];return[4,n.create({values:t})];case 3:return a.sent(),[3,6];case 4:return[4,n.update({filterByTk:null==(r=e.record)?void 0:r.id,values:t})];case 5:a.sent(),a.label=6;case 6:return e.onSubmitted(),[3,8];case 7:return y(!1),[7];case 8:return[2]}})})()},[u,e,n]),k=(0,s.useMemo)(function(){return(0,s.lazy)(e.storageType.formLoader)},[e.storageType]),j="".concat(r("create"===e.mode?"Add new":"Edit")," - ").concat(r(e.storageType.title));return f().createElement(o.DrawerFormLayout,{title:j,onSubmit:E,submitting:m,submitText:r("Submit"),cancelText:r("Cancel")},f().createElement(i.Form,{form:u,layout:"vertical",initialValues:O,className:v},f().createElement(i.Form.Item,{name:"type",hidden:!0},f().createElement(i.Input,null)),f().createElement(s.Suspense,{fallback:f().createElement(i.Spin,null)},f().createElement(k,null))))}function E(){var e=(0,p.k)(),t=(0,l.useFlowContext)(),r=i.theme.useToken().token,a=i.App.useApp(),c=a.modal,y=a.message,w=S(),E=t.app.pm.get(d.S),k=(0,s.useMemo)(function(){var e;return function(e){if(Array.isArray(e))return m(e)}(e=E.storageTypes.values())||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||v(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},[E]),j=g((0,s.useState)(1),2),T=j[0],A=j[1],x=g((0,s.useState)(o.DEFAULT_PAGE_SIZE),2),C=x[0],P=x[1],D=g((0,s.useState)([]),2),_=D[0],I=D[1],F=(0,u.useRequest)(function(){return b(function(){return h(this,function(e){switch(e.label){case 0:return[4,w.list({page:T,pageSize:C,sort:["id"],appends:[]})];case 1:var t,r,n,a,o;return[2,{records:a=Array.isArray(n=null==(r=null==(t=e.sent())?void 0:t.data)?void 0:r.data)?n:Array.isArray(null==n?void 0:n.data)?n.data:[],total:(o=(null==r?void 0:r.meta)||(null==n?void 0:n.meta)||{}).count||o.total||a.length}]}})})()},{refreshDeps:[T,C]}),M=F.data,z=F.loading,B=F.refresh,L=(0,u.useMemoizedFn)(function(e,t){if(t!==C){P(t),A(1);return}A(e)}),V=(0,s.useCallback)(function(e,r,n){t.viewer.drawer({width:"50%",closable:!0,content:function(){return f().createElement(O,{mode:e,storageType:r,record:n,onSubmitted:function(){return B()}})}})},[t.viewer,B]),G=(0,s.useCallback)(function(t){c.confirm({title:e("Delete"),content:e("Are you sure you want to delete it?"),onOk:function(){return b(function(){return h(this,function(e){switch(e.label){case 0:return[4,w.destroy({filterByTk:t})];case 1:return e.sent(),I([]),B(),[2]}})})()}})},[c,B,w,e]),K=(0,s.useMemo)(function(){return[{title:e("Title"),dataIndex:"title"},{title:e("Storage name"),dataIndex:"name"},{title:e("Default storage"),dataIndex:"default",render:function(e){return e?f().createElement(n.CheckOutlined,{style:{color:r.colorSuccess}}):null}},{title:e("Actions"),render:function(t,r){return f().createElement(i.Space,null,f().createElement("a",{onClick:function(){var t=E.getStorageType(r.type);t?V("edit",t,r):y.error(e("Storage type {{type}} is not registered, please check if related plugin is enabled.").replace("{{type}}",r.type||""))}},e("Edit")),f().createElement("a",{onClick:function(){return G(r.id)}},e("Delete")))}}]},[E,G,y,V,e]);return f().createElement(i.Card,{variant:"borderless"},f().createElement("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginBottom:16}},f().createElement(i.Button,{icon:f().createElement(n.DeleteOutlined,null),disabled:!_.length,onClick:function(){return G(_)}},e("Delete")),f().createElement(i.Dropdown,{menu:{items:k.map(function(t){return{key:t.name,label:e(t.title)}}),onClick:function(e){var t=E.getStorageType(e.key);t&&V("create",t)}}},f().createElement(i.Button,{type:"primary",icon:f().createElement(n.PlusOutlined,null)},e("Add new")," ",f().createElement(n.DownOutlined,null)))),f().createElement(o.Table,{rowKey:"id",loading:z,columns:K,dataSource:(null==M?void 0:M.records)||[],rowSelection:{selectedRowKeys:_,onChange:I},pagination:{current:T,pageSize:C,total:(null==M?void 0:M.total)||0,onChange:L}}))}}}]);
|