@nocobase/plugin-file-manager 1.7.0-alpha.13 → 1.7.0-alpha.14

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.
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("lodash"),require("@nocobase/client"),require("@formily/shared"),require("@formily/react"),require("@ant-design/icons"),require("antd"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-file-manager",["react","lodash","@nocobase/client","@formily/shared","@formily/react","@ant-design/icons","antd","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-file-manager"]=t(require("react"),require("lodash"),require("@nocobase/client"),require("@formily/shared"),require("@formily/react"),require("@ant-design/icons"),require("antd"),require("react-i18next")):e["@nocobase/plugin-file-manager"]=t(e.react,e.lodash,e["@nocobase/client"],e["@formily/shared"],e["@formily/react"],e["@ant-design/icons"],e.antd,e["react-i18next"])}(self,function(e,t,n,o,r,a,i,c){return function(){"use strict";var l={482:function(e){e.exports=a},505:function(e){e.exports=r},875:function(e){e.exports=o},772:function(e){e.exports=n},721:function(e){e.exports=i},467:function(e){e.exports=t},156:function(t){t.exports=e},238:function(e){e.exports=c}},u={};function p(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return l[e](n,n.exports,p),n.exports}p.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return p.d(t,{a:t}),t},p.d=function(e,t){for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},p.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return!function(){p.r(s),p.d(s,{PluginFileManagerClient:function(){return eg},default:function(){return eh}});var e,t,n,o={};p.r(o),p.d(o,{useAttachmentFieldProps:function(){return x},useFileCollectionStorageRules:function(){return v},useStorageRules:function(){return h},useUploadFiles:function(){return b}});var r=p(772),a=Number.POSITIVE_INFINITY,i=p(156),c=p.n(i);function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}function u(){var e,t,n,o,a,c,l,u=(0,r.useCollectionField)(),p=(0,r.useCollectionManager)().getCollection(null==u?void 0:u.target),s=(0,r.useCollection)(),m=(0,r.usePlugin)(eh),f=(t=null!=(e=(null==u?void 0:u.storage)||(null==s?void 0:s.getOption("storage"))||(null==p?void 0:p.getOption("storage")))?e:"",n="storages:getBasicInfo/".concat(t),a=(o=(0,r.useRequest)({url:n},{manual:!0,refreshDeps:[t],cacheKey:n})).loading,c=o.data,l=o.run,(0,i.useEffect)(function(){l()},[l]),!a&&(null==c?void 0:c.data)||null),d=m.getStorageType(null==f?void 0:f.type);return{storage:f,storageType:d}}function m(e){var t=u(),n=t.storage,o=t.storageType,r=null==o?void 0:o.useUploadProps,a=(null==r?void 0:r(l({storage:n,rules:n.rules},e)))||{};return l({rules:null==n?void 0:n.rules},a)}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function d(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||y(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.")}()}function y(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}}var b=function(){var e=(0,r.useDataBlockRequestGetter)().getDataBlockRequest,t=((0,r.useDataBlockProps)()||{}).association,n=(0,r.useActionContext)().setVisible,o=(0,r.useCollection)(),a=(0,r.useSourceId)(),c=(0,i.useMemo)(function(){var e="".concat(o.name,":create");if(t){var n,r=(n=t.split("."),function(e){if(Array.isArray(e))return e}(n)||function(e,t){var n,o,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var a=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return a}}(n,2)||y(n,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=r[0],c=r[1];e="".concat(i,"/").concat(a,"/").concat(c,":create")}return e},[o.name,t,a]),l=((0,i.useContext)(r.RecordPickerContext)||{}).setSelectedRows,u={},p=0,s={action:c,onChange:function(t){t.forEach(function(n){if("uploading"!==n.status||u[n.uid]||(p++,u[n.uid]=!0),"uploading"!==n.status&&u[n.uid]&&(delete u[n.uid],0==--p)){var o,r;null==(r=e())||null==(o=r.refresh)||o.call(r),null==l||l(function(e){return d(e).concat(d(t.filter(function(e){return"done"===e.status}).map(function(e){return e.response.data})))})}}),t.every(function(e){return"done"===e.status})&&n(!1)}},f=m(s);return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}({},s,f)},g=p(505);function h(e){var t,n=null!=e?e:"";(0,r.useAPIClient)();var o=(0,g.useField)(),a=(0,r.useRequest)({url:"storages:getBasicInfo/".concat(n)},{manual:!0,refreshDeps:[n],cacheKey:n}),c=a.loading,l=a.data,u=a.run;return(0,i.useEffect)(function(){"editable"===o.pattern&&u()},[o.pattern,u]),!c&&(null==l||null==(t=l.data)?void 0:t.rules)||null}function x(){var e=(0,r.useCollectionField)(),t="".concat(e.target,":create").concat(e.storage?"?attachmentField=".concat(e.collectionName,".").concat(e.name):""),n=m({action:t});return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}({action:t},n)}function v(){var e=(0,r.useCollectionField)(),t=(0,r.useCollectionManager)().getCollection(null==e?void 0:e.target);return h(null==t?void 0:t.getOption("storage"))}var O=function(e){var t,n,o={type:"void","x-action":"create",title:"{{t('Upload')}}","x-designer":"Action.Designer","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",icon:"UploadOutlined"},properties:{drawer:{type:"void",title:'{{ t("Upload files") }}',"x-component":"Action.Container",properties:{upload:{type:"void",title:'{{ t("Upload files") }}',"x-component":"Upload.DraggerV2","x-use-component-props":"useUploadFiles","x-component-props":{height:"50vh",multiple:!0,listType:"picture"}}}}}};return c().createElement(r.ActionInitializerItem,(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}({},e),n=n={schema:o},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))},S=function(e){return c().createElement(r.SchemaComponentOptions,{scope:o,components:{UploadActionInitializer:O}},e.children)},j=p(721),w=[{value:1,label:"Byte"},{value:1024,label:"KB"},{value:1048576,label:"MB"},{value:0x40000000,label:"GB"}];function P(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1048576,n=e||t,o=w.length-1;o>=0;o--){var r=w[o];if(n%r.value==0)return r}return w[0]}function A(e,t,n){return Math.min(Math.max(t,e),n)}function C(e){var t,n=e.value,o=e.defaultUnit,r=void 0===o?1048576:o,l=e.min,u=void 0===l?1:l,p=e.max,s=void 0===p?a:p,m=e.step,f=e.onChange,d=null!=(t=e.defaultValue)?t:0x1400000,y=P(d,r),b=d/y.value,g=P(null!=n?n:d,r),h=null==n?n:n/g.value,x=(0,i.useCallback)(function(e){null==f||f(A(null==e?e:e*g.value,u,s))},[g.value]),v=(0,i.useCallback)(function(e){null==f||f(A(h*e,u,s))},[h]);return c().createElement(j.Space.Compact,null,c().createElement(j.InputNumber,{value:h,onChange:x,defaultValue:"".concat(b),step:void 0===m?1:m}),c().createElement(j.Select,{options:w,value:g.value,onChange:v,className:"auto-width"}))}var I=p(482),F=p(875),T=p(467),E=p.n(T),D=p(238),k="file-manager",R={name:"storages",fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{t("Title")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Storage name", { ns: "'.concat(k,'" })}}'),descriptions:'{{t("Will be used for API", { ns: "'.concat(k,'" })}}'),type:"string","x-component":"Input"}},{type:"string",name:"type",interface:"select",uiSchema:{title:'{{t("Storage type", { ns: "'.concat(k,'" })}}'),type:"string","x-component":"Select",required:!0,enum:"{{ storageTypeOptions }}"}},{type:"string",name:"baseUrl",interface:"input",uiSchema:{title:'{{t("Base URL", { ns: "'.concat(k,'" })}}'),type:"string","x-component":"TextAreaWithGlobalScope",required:!0}},{type:"string",name:"path",interface:"input",uiSchema:{title:'{{t("Path", { ns: "'.concat(k,'" })}}'),type:"string","x-component":"TextAreaWithGlobalScope"}},{type:"boolean",name:"default",interface:"boolean",uiSchema:{type:"boolean","x-component":"Checkbox"}},{type:"boolean",name:"paranoid",interface:"boolean",uiSchema:{type:"boolean","x-component":"Checkbox"}}]},q={type:"object",properties:(e={},t=(0,F.uid)(),n={type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:R,resourceName:"storages",request:{resource:"storages",action:"list",params:{pageSize:50,sort:["id"],appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:R},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"CreateStorage","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},default:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{t("Default storage", { ns: "'.concat(k,'" })}}'),properties:{default:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Edit")}}',"x-component":"EditStorage","x-component-props":{type:"primary"}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:'{{t("Delete")}}',content:'{{t("Are you sure you want to delete it?")}}'},useAction:"{{cm.useDestroyAction}}"}}}}}}}}}},t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e)},_={title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":"{{ !createOnly }}",required:!0,default:'{{ useNewId("s_") }}',description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'},baseUrl:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t(\'Base URL for file access, could be your CDN base URL. For example: "https://cdn.nocobase.com".\', { ns: "'.concat(k,'" })}}')},path:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t(\'Relative path the file will be saved to. Left blank as root path. The leading and trailing slashes "/" will be ignored. For example: "user/avatar".\', { ns: "'.concat(k,'" })}}')},rules:{type:"object","x-component":"fieldset",properties:{size:{type:"number",title:'{{t("File size limit", { ns: "'.concat(k,'" })}}'),description:'{{t("Minimum from 1 byte, maximum up to 1GB.", { ns: "'.concat(k,'" })}}'),"x-decorator":"FormItem","x-component":"FileSizeField",required:!0,default:0x1400000},mimetype:{type:"string",title:'{{t("File type (in MIME type format)", { ns: "'.concat(k,'" })}}'),description:'{{t(\'Multi-types seperated with comma, for example: "image/*", "image/png", "image/*, application/pdf" etc.\', { ns: "'.concat(k,'" })}}'),"x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"*"}}}},default:{"x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Default storage", { ns: "'.concat(k,'" })}}')},paranoid:{"x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Keep file in storage when destroy record", { ns: "'.concat(k,'" })}}')}},M={title:'{{t("Aliyun OSS", { ns: "'.concat(k,'" })}}'),name:"ali-oss",fieldset:{title:_.title,name:_.name,baseUrl:_.baseUrl,options:{type:"object","x-component":"fieldset",properties:{region:{title:'{{t("Region", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",description:'{{t(\'Aliyun OSS region part of the bucket. For example: "oss-cn-beijing".\', { ns: "'.concat(k,'" })}}'),required:!0},accessKeyId:{title:'{{t("AccessKey ID", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},accessKeySecret:{title:'{{t("AccessKey Secret", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},bucket:{title:'{{t("Bucket", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},thumbnailRule:{title:"Thumbnail rule",type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{placeholder:"?x-oss-process=image/auto-orient,1/resize,m_fill,w_94,h_94/quality,q_90"},description:'{{ renderThumbnailRuleDesc("ali-oss") }}'}}},path:_.path,rules:_.rules,default:_.default,paranoid:_.paranoid},thumbnailRuleLink:"https://help.aliyun.com/zh/oss/user-guide/resize-images-4"},U={local:{title:'{{t("Local storage", { ns: "'.concat(k,'" })}}'),name:"local",fieldset:{title:_.title,name:_.name,baseUrl:{"x-component":"CollectionField","x-decorator":"FormItem","x-display":"hidden",default:"/storage/uploads"},options:{type:"object","x-component":"div",properties:{documentRoot:{title:'{{t("Destination", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"Input","x-display":"hidden",default:"storage/uploads"}}},path:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{addonBefore:"storage/uploads/"}},rules:_.rules,default:_.default,paranoid:_.paranoid}},"ali-oss":M,s3:{title:'{{t("Amazon S3", { ns: "'.concat(k,'" })}}'),name:"s3",fieldset:{title:_.title,name:_.name,baseUrl:_.baseUrl,options:{type:"object","x-component":"fieldset",properties:{region:{title:'{{t("Region", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},accessKeyId:{title:'{{t("AccessKey ID", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},secretAccessKey:{title:'{{t("AccessKey Secret", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},bucket:{title:'{{t("Bucket", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},endpoint:{title:'{{t("Endpoint", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope"}}},path:_.path,rules:_.rules,default:_.default,paranoid:_.paranoid}},"tx-cos":{title:'{{t("Tencent COS", { ns: "'.concat(k,'" })}}'),name:"tx-cos",fieldset:{title:_.title,name:_.name,baseUrl:_.baseUrl,options:{type:"object","x-component":"fieldset",properties:{Region:{title:'{{t("Region", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},SecretId:{title:'{{t("SecretId", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},SecretKey:{title:'{{t("SecretKey", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},Bucket:{title:'{{t("Bucket", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},thumbnailRule:{title:"Thumbnail rule",type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{placeholder:"?imageMogr2/thumbnail/!50p"},description:'{{ renderThumbnailRuleDesc("tx-cos") }}'}}},path:_.path,rules:_.rules,default:_.default,paranoid:_.paranoid},thumbnailRuleLink:"https://cloud.tencent.com/document/product/436/42214"}};function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function K(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function G(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){K(e,t,n[t])})}return e}function W(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function z(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,o,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var a=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return a}}(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 N(e){return function(e){if(Array.isArray(e))return B(e)}(e)||function(e){if("undefined"!=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.")}()}function V(e,t){if(e){if("string"==typeof e)return B(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return B(e,t)}}var L=function(){var e=z((0,i.useState)({}),2),t=e[0],n=e[1],o=(0,r.usePlugin)(eh),a=(0,r.useCompile)(),l=z((0,i.useState)(!1),2),u=l[0],p=l[1],s=(0,D.useTranslation)().t;return c().createElement("div",null,c().createElement(r.ActionContext.Provider,{value:{visible:u,setVisible:p}},c().createElement(j.Dropdown,{menu:{onClick:function(e){var t=o.storageTypes.get(e.key);p(!0),n({type:"object",properties:K({},(0,F.uid)(),{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{type:t.name}},title:a("{{t('Add new')}}")+" - "+a(t.title),properties:W(G({},E().cloneDeep(t.fieldset)),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}})})})},items:N(o.storageTypes.values()).map(function(e){return{key:e.name,label:a(e.title)}})}},c().createElement(j.Button,{type:"primary",icon:c().createElement(I.PlusOutlined,null)},s("Add new")," ",c().createElement(I.DownOutlined,null))),c().createElement(r.SchemaComponent,{scope:{createOnly:!0},schema:t})))},$=function(){var e=(0,r.useRecord)(),t=z((0,i.useState)({}),2),n=t[0],o=t[1],a=(0,r.usePlugin)(eh),l=(0,r.useCompile)(),u=z((0,i.useState)(!1),2),p=u[0],s=u[1],m=(0,D.useTranslation)().t;return c().createElement("div",null,c().createElement(r.ActionContext.Provider,{value:{visible:p,setVisible:s}},c().createElement("a",{onClick:function(){s(!0);var t=a.storageTypes.get(e.type);t.fieldset.default&&(t.fieldset.default["x-reactions"]=function(e){e.initialValue?e.disabled=!0:e.disabled=!1}),o({type:"object",properties:K({},(0,F.uid)(),{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:G({},e)},title:l("{{t('Edit')}}")+" - "+l(t.title),properties:W(G({},E().cloneDeep(t.fieldset)),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}})})})}},m("Edit")),c().createElement(r.SchemaComponent,{scope:{createOnly:!1},schema:n})))};function Y(e){var t=U[e];return(null==t?void 0:t.thumbnailRule)?c().createElement("div",null,c().createElement("a",{target:"_blank",href:t.thumbnailRuleLink,rel:"noreferrer"},r.i18n.t("See more"))):null}var H=function(){var e=(0,r.useCompile)(),t=N((0,r.usePlugin)(eh).storageTypes.values()).map(function(t){return{value:t.name,label:e(t.title)}});return c().createElement(j.Card,{bordered:!1},c().createElement(r.SchemaComponent,{components:{CreateStorage:L,EditStorage:$},scope:{useNewId:function(e){return"".concat(e).concat((0,F.uid)())},storageTypeOptions:t,renderThumbnailRuleDesc:Y},schema:q}))};function J(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Q(e){return(Q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function X(e,t){return(X=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Z(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Z=function(){return!!e})()}var ee=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,o,a,i;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,o=arguments,t=Q(t),J(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,Z()?Reflect.construct(t,o||[],Q(this).constructor):t.apply(this,o)),"name","attachment"),J(e,"type","object"),J(e,"group","media"),J(e,"title",'{{t("Attachment", { ns: "'.concat(k,'" })}}')),J(e,"isAssociation",!0),J(e,"default",{type:"belongsToMany",target:"attachments",uiSchema:{type:"array","x-component":"Upload.Attachment","x-use-component-props":"useAttachmentFieldProps"}}),J(e,"availableTypes",["belongsToMany"]),J(e,"properties",(a=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){J(e,t,n[t])})}return e}({},r.interfacesProperties.defaultProps),i=i={"uiSchema.x-component-props.accept":{type:"string",title:'{{t("MIME type", { ns: "'.concat(k,'" })}}'),"x-component":"Input","x-component-props":{placeholder:"image/*"},"x-decorator":"FormItem",description:"Example: image/png"},"uiSchema.x-component-props.multiple":{type:"boolean","x-content":"{{t('Allow uploading multiple files', { ns: \"".concat(k,'" })}}'),"x-decorator":"FormItem","x-component":"Checkbox",default:!0},storage:{type:"string",title:'{{t("Storage", { ns: "'.concat(k,'" })}}'),description:"{{t('Default storage will be used when not selected', { ns: \"".concat(k,'" })}}'),"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{service:{resource:"storages",params:{}},manual:!1,fieldNames:{label:"title",value:"name"}}}},Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(i)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(i)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(i,e))}),a)),J(e,"filterable",{children:[{name:"id",title:'{{t("Exists")}}',operators:[{label:'{{t("exists")}}',value:"$exists",noValue:!0},{label:'{{t("not exists")}}',value:"$notExists",noValue:!0}],schema:{title:'{{t("Exists")}}',type:"string","x-component":"Input"}},{name:"filename",title:'{{t("Filename", { ns: "'.concat(k,'" })}}'),operators:r.interfacesProperties.operators.string,schema:{title:'{{t("Filename", { ns: "'.concat(k,'" })}}'),type:"string","x-component":"Input"}}]}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&X(n,e),t=[{key:"schemaInitialize",value:function(e,t){var n=t.block;t.field,e["x-component-props"]||(e["x-component-props"]={}),["Table","Kanban"].includes(n)&&(e["x-component-props"].size="small"),e["x-use-component-props"]="useAttachmentFieldProps"}},{key:"initialize",value:function(e){e.through||(e.through="t_".concat((0,F.uid)())),e.foreignKey||(e.foreignKey="f_".concat((0,F.uid)())),e.otherKey||(e.otherKey="f_".concat((0,F.uid)())),e.sourceKey||(e.sourceKey="id"),e.targetKey||(e.targetKey="id")}}],function(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,t),n}(r.CollectionFieldInterface);function et(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function en(e){return(en=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){et(e,t,n[t])})}return e}function er(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function ea(e,t){return(ea=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ei(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ei=function(){return!!e})()}var ec=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(){var e,n,o;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");return n=t,o=arguments,n=en(n),et(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,ei()?Reflect.construct(n,o||[],en(this).constructor):n.apply(this,o)),"name","file"),et(e,"title",'{{t("File collection", { ns: "'.concat(k,'" })}}')),et(e,"order",3),et(e,"color","blue"),et(e,"default",{createdBy:!0,updatedBy:!0,fields:[{interface:"input",type:"string",name:"title",deletable:!1,uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"input",type:"string",name:"filename",deletable:!1,uiSchema:{type:"string",title:'{{t("File name", { ns: "'.concat(k,'" })}}'),"x-component":"Input","x-read-pretty":!0}},{interface:"input",type:"string",name:"extname",deletable:!1,uiSchema:{type:"string",title:'{{t("Extension name", { ns: "'.concat(k,'" })}}'),"x-component":"Input","x-read-pretty":!0}},{interface:"integer",type:"integer",name:"size",deletable:!1,uiSchema:{type:"number",title:'{{t("Size", { ns: "'.concat(k,'" })}}'),"x-component":"InputNumber","x-read-pretty":!0,"x-component-props":{stringMode:!0,step:"0"}}},{interface:"input",type:"string",name:"mimetype",deletable:!1,uiSchema:{type:"string",title:'{{t("MIME type", { ns: "'.concat(k,'" })}}'),"x-component":"Input","x-read-pretty":!0}},{interface:"input",type:"text",name:"path",deletable:!1,uiSchema:{type:"string",title:'{{t("Path", { ns: "'.concat(k,'" })}}'),"x-component":"TextAreaWithGlobalScope","x-read-pretty":!0}},{interface:"url",type:"text",name:"url",deletable:!1,uiSchema:{type:"string",title:'{{t("URL")}}',"x-component":"Input.URL","x-read-pretty":!0}},{interface:"url",type:"text",name:"preview",field:"url",deletable:!1,uiSchema:{type:"string",title:'{{t("Preview", { ns: "'.concat(k,'" })}}'),"x-component":"Preview","x-read-pretty":!0}},{comment:"存储引擎",type:"belongsTo",name:"storage",target:"storages",foreignKey:"storageId",deletable:!1,uiSchema:{type:"string",title:'{{t("Storage", { ns: "'.concat(k,'" })}}'),"x-component":"Input","x-read-pretty":!0}},{type:"jsonb",name:"meta",deletable:!1,defaultValue:{}}]}),et(e,"presetFieldsDisabled",!0),et(e,"configurableProperties",eo(er(eo(er(eo({},(0,r.getConfigurableProperties)("title","name")),{inherits:er(eo({},(0,r.getConfigurableProperties)("inherits").inherits),{"x-reactions":["{{useAsyncDataSource(loadCollections)}}"]})}),(0,r.getConfigurableProperties)("category","description")),{storage:{type:"string",name:"storage",title:'{{t("File storage", { ns: "'.concat(k,'" })}}'),"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{service:{resource:"storages",params:{}},manual:!1,fieldNames:{label:"title",value:"name"}}}}),(0,r.getConfigurableProperties)("presetFields"))),e}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ea(t,e),t}(r.CollectionTemplate);function el(e,t,n,o,r,a,i){try{var c=e[a](i),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(o,r)}function eu(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var a=e.apply(t,n);function i(e){el(a,o,r,i,c,"next",e)}function c(e){el(a,o,r,i,c,"throw",e)}i(void 0)})}}function ep(e,t,n){return(ep=ey()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var r=new(Function.bind.apply(e,o));return n&&ef(r,n.prototype),r}).apply(null,arguments)}function es(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function em(e){return(em=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ef(e,t){return(ef=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ed(e){var t="function"==typeof Map?new Map:void 0;return(ed=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return ep(e,arguments,em(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),ef(n,e)})(e)}function ey(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ey=function(){return!!e})()}function eb(e,t){var n,o,r,a,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){var l=[a,c];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,o&&(r=2&l[0]?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,o=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){i.label=l[1];break}if(6===l[0]&&i.label<r[1]){i.label=r[1],r=l;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(l);break}r[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],o=0}finally{n=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var eg=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,o=arguments,t=em(t),es(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,ey()?Reflect.construct(t,o||[],em(this).constructor):t.apply(this,o)),"storageTypes",new Map),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&ef(n,e),t=[{key:"load",value:function(){var e=this;return eu(function(){var t;return eb(this,function(n){return e.app.dataSourceManager.addFieldInterfaces([ee]),e.app.dataSourceManager.addCollectionTemplates([ec]),e.app.use(S),e.app.pluginSettingsManager.add(k,{title:'{{t("File manager", { ns: "'.concat(k,'" })}}'),icon:"FileOutlined",Component:H,aclSnippet:"pm.file-manager.storages"}),Object.values(U).forEach(function(t){e.registerStorageType(t.name,t)}),null==(t=e.app.schemaInitializerManager.get("table:configureActions"))||t.add("enableActions.upload",{title:"{{t('Upload')}}",Component:"UploadActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible:function(){return"file"===(0,r.useCollection)().template}}),e.app.addScopes({useAttachmentFieldProps:x,useFileCollectionStorageRules:v,useStorageCfg:u}),e.app.addComponents({FileSizeField:C}),[2]})})()}},{key:"registerStorageType",value:function(e,t){this.storageTypes.set(e,t)}},{key:"getStorageType",value:function(e){return this.storageTypes.get(e)}},{key:"uploadFile",value:function(e){var t=this;return eu(function(){var n,o,r;return eb(this,function(a){switch(a.label){case 0:if(!(null==(n=t.getStorageType(null==e?void 0:e.storageType))?void 0:n.upload))return[3,2];return[4,n.upload({file:e.file,apiClient:t.app.apiClient,storageType:e.storageType,storageId:e.storageId,storageRules:e.storageRules,fileCollectionName:e.fileCollectionName})];case 1:return[2,a.sent()];case 2:return a.trys.push([2,4,,5]),(r=new FormData).append("file",e.file),[4,t.app.apiClient.request({url:"".concat(e.fileCollectionName||"attachments",":create"),method:"post",data:r})];case 3:return[2,{data:null==(o=a.sent().data)?void 0:o.data}];case 4:return[2,{errorMessage:a.sent().message}];case 5:return[2]}})})()}}],function(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,t),n}(ed(r.Plugin));es(eg,"buildInStorage",["local","ali-oss","s3","tx-cos"]);var eh=eg}(),s}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("react"),require("lodash"),require("@formily/shared"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-file-manager",["react-i18next","react","lodash","@formily/shared","@nocobase/client","@formily/react","@ant-design/icons","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-file-manager"]=t(require("react-i18next"),require("react"),require("lodash"),require("@formily/shared"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("antd")):e["@nocobase/plugin-file-manager"]=t(e["react-i18next"],e.react,e.lodash,e["@formily/shared"],e["@nocobase/client"],e["@formily/react"],e["@ant-design/icons"],e.antd)}(self,function(e,t,n,o,r,a,i,c){return function(){"use strict";var l={482:function(e){e.exports=i},505:function(e){e.exports=a},875:function(e){e.exports=o},772:function(e){e.exports=r},721:function(e){e.exports=c},467:function(e){e.exports=n},156:function(e){e.exports=t},238:function(t){t.exports=e}},u={};function p(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return l[e](n,n.exports,p),n.exports}p.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return p.d(t,{a:t}),t},p.d=function(e,t){for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},p.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return!function(){p.r(s),p.d(s,{PluginFileManagerClient:function(){return eg},default:function(){return eh}});var e,t,n,o={};p.r(o),p.d(o,{useAttachmentFieldProps:function(){return x},useFileCollectionStorageRules:function(){return v},useStorageRules:function(){return h},useUploadFiles:function(){return b}});var r=p(772),a=Number.POSITIVE_INFINITY,i=p(156),c=p.n(i);function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}function u(){var e,t,n,o,a,c,l,u=(0,r.useCollectionField)(),p=(0,r.useCollectionManager)().getCollection(null==u?void 0:u.target),s=(0,r.useCollection)(),m=(0,r.usePlugin)(eh),f=(t=null!=(e=(null==u?void 0:u.storage)||(null==s?void 0:s.getOption("storage"))||(null==p?void 0:p.getOption("storage")))?e:"",n="storages:getBasicInfo/".concat(t),a=(o=(0,r.useRequest)({url:n},{manual:!0,refreshDeps:[t],cacheKey:n})).loading,c=o.data,l=o.run,(0,i.useEffect)(function(){l()},[l]),!a&&(null==c?void 0:c.data)||null),d=m.getStorageType(null==f?void 0:f.type);return{storage:f,storageType:d}}function m(e){var t=u(),n=t.storage,o=t.storageType,r=null==o?void 0:o.useUploadProps,a=(null==r?void 0:r(l({storage:n,rules:n.rules},e)))||{};return l({rules:null==n?void 0:n.rules},a)}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function d(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||y(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.")}()}function y(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}}var b=function(){var e=(0,r.useDataBlockRequestGetter)().getDataBlockRequest,t=((0,r.useDataBlockProps)()||{}).association,n=(0,r.useActionContext)().setVisible,o=(0,r.useCollection)(),a=(0,r.useSourceId)(),c=(0,i.useMemo)(function(){var e="".concat(o.name,":create");if(t){var n,r=(n=t.split("."),function(e){if(Array.isArray(e))return e}(n)||function(e,t){var n,o,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var a=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return a}}(n,2)||y(n,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=r[0],c=r[1];e="".concat(i,"/").concat(a,"/").concat(c,":create")}return e},[o.name,t,a]),l=((0,i.useContext)(r.RecordPickerContext)||{}).setSelectedRows,u={},p=0,s={action:c,onChange:function(t){t.forEach(function(n){if("uploading"!==n.status||u[n.uid]||(p++,u[n.uid]=!0),"uploading"!==n.status&&u[n.uid]&&(delete u[n.uid],0==--p)){var o,r;null==(r=e())||null==(o=r.refresh)||o.call(r),null==l||l(function(e){return d(e).concat(d(t.filter(function(e){return"done"===e.status}).map(function(e){return e.response.data})))})}}),t.every(function(e){return"done"===e.status})&&n(!1)}},f=m(s);return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}({},s,f)},g=p(505);function h(e){var t,n=null!=e?e:"";(0,r.useAPIClient)();var o=(0,g.useField)(),a=(0,r.useRequest)({url:"storages:getBasicInfo/".concat(n)},{manual:!0,refreshDeps:[n],cacheKey:n}),c=a.loading,l=a.data,u=a.run;return(0,i.useEffect)(function(){"editable"===o.pattern&&u()},[o.pattern,u]),!c&&(null==l||null==(t=l.data)?void 0:t.rules)||null}function x(){var e=(0,r.useCollectionField)(),t="".concat(e.target,":create").concat(e.storage?"?attachmentField=".concat(e.collectionName,".").concat(e.name):""),n=m({action:t});return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}({action:t},n)}function v(){var e=(0,r.useCollectionField)(),t=(0,r.useCollectionManager)().getCollection(null==e?void 0:e.target);return h(null==t?void 0:t.getOption("storage"))}var O=function(e){var t,n,o={type:"void","x-action":"create",title:"{{t('Upload')}}","x-designer":"Action.Designer","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",icon:"UploadOutlined"},properties:{drawer:{type:"void",title:'{{ t("Upload files") }}',"x-component":"Action.Container",properties:{upload:{type:"void",title:'{{ t("Upload files") }}',"x-component":"Upload.DraggerV2","x-use-component-props":"useUploadFiles","x-component-props":{height:"50vh",multiple:!0,listType:"picture"}}}}}};return c().createElement(r.ActionInitializerItem,(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}({},e),n=n={schema:o},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))},S=function(e){return c().createElement(r.SchemaComponentOptions,{scope:o,components:{UploadActionInitializer:O}},e.children)},j=p(721),w=[{value:1,label:"Byte"},{value:1024,label:"KB"},{value:1048576,label:"MB"},{value:0x40000000,label:"GB"}];function P(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1048576,n=e||t,o=w.length-1;o>=0;o--){var r=w[o];if(n%r.value==0)return r}return w[0]}function A(e,t,n){return Math.min(Math.max(t,e),n)}function C(e){var t,n=e.value,o=e.defaultUnit,r=void 0===o?1048576:o,l=e.min,u=void 0===l?1:l,p=e.max,s=void 0===p?a:p,m=e.step,f=e.onChange,d=null!=(t=e.defaultValue)?t:0x1400000,y=P(d,r),b=d/y.value,g=P(null!=n?n:d,r),h=null==n?n:n/g.value,x=(0,i.useCallback)(function(e){null==f||f(A(null==e?e:e*g.value,u,s))},[g.value]),v=(0,i.useCallback)(function(e){null==f||f(A(h*e,u,s))},[h]);return c().createElement(j.Space.Compact,null,c().createElement(j.InputNumber,{value:h,onChange:x,defaultValue:"".concat(b),step:void 0===m?1:m}),c().createElement(j.Select,{options:w,value:g.value,onChange:v,className:"auto-width"}))}var I=p(482),F=p(875),T=p(467),E=p.n(T),D=p(238),k="file-manager",R={name:"storages",fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{t("Title")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Storage name", { ns: "'.concat(k,'" })}}'),descriptions:'{{t("Will be used for API", { ns: "'.concat(k,'" })}}'),type:"string","x-component":"Input"}},{type:"string",name:"type",interface:"select",uiSchema:{title:'{{t("Storage type", { ns: "'.concat(k,'" })}}'),type:"string","x-component":"Select",required:!0,enum:"{{ storageTypeOptions }}"}},{type:"string",name:"baseUrl",interface:"input",uiSchema:{title:'{{t("Base URL", { ns: "'.concat(k,'" })}}'),type:"string","x-component":"TextAreaWithGlobalScope",required:!0}},{type:"string",name:"path",interface:"input",uiSchema:{title:'{{t("Path", { ns: "'.concat(k,'" })}}'),type:"string","x-component":"TextAreaWithGlobalScope"}},{type:"boolean",name:"default",interface:"boolean",uiSchema:{type:"boolean","x-component":"Checkbox"}},{type:"boolean",name:"paranoid",interface:"boolean",uiSchema:{type:"boolean","x-component":"Checkbox"}}]},q={type:"object",properties:(e={},t=(0,F.uid)(),n={type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:R,resourceName:"storages",request:{resource:"storages",action:"list",params:{pageSize:50,sort:["id"],appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:R},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"CreateStorage","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},default:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{t("Default storage", { ns: "'.concat(k,'" })}}'),properties:{default:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Edit")}}',"x-component":"EditStorage","x-component-props":{type:"primary"}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:'{{t("Delete")}}',content:'{{t("Are you sure you want to delete it?")}}'},useAction:"{{cm.useDestroyAction}}"}}}}}}}}}},t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e)},_={title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":"{{ !createOnly }}",required:!0,default:'{{ useNewId("s_") }}',description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'},baseUrl:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t(\'Base URL for file access, could be your CDN base URL. For example: "https://cdn.nocobase.com".\', { ns: "'.concat(k,'" })}}')},path:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t(\'Relative path the file will be saved to. Left blank as root path. The leading and trailing slashes "/" will be ignored. For example: "user/avatar".\', { ns: "'.concat(k,'" })}}')},rules:{type:"object","x-component":"fieldset",properties:{size:{type:"number",title:'{{t("File size limit", { ns: "'.concat(k,'" })}}'),description:'{{t("Minimum from 1 byte, maximum up to 1GB.", { ns: "'.concat(k,'" })}}'),"x-decorator":"FormItem","x-component":"FileSizeField",required:!0,default:0x1400000},mimetype:{type:"string",title:'{{t("File type (in MIME type format)", { ns: "'.concat(k,'" })}}'),description:'{{t(\'Multi-types seperated with comma, for example: "image/*", "image/png", "image/*, application/pdf" etc.\', { ns: "'.concat(k,'" })}}'),"x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"*"}}}},default:{"x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Default storage", { ns: "'.concat(k,'" })}}')},paranoid:{"x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Keep file in storage when destroy record", { ns: "'.concat(k,'" })}}')}},M={title:'{{t("Aliyun OSS", { ns: "'.concat(k,'" })}}'),name:"ali-oss",fieldset:{title:_.title,name:_.name,baseUrl:_.baseUrl,options:{type:"object","x-component":"fieldset",properties:{region:{title:'{{t("Region", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",description:'{{t(\'Aliyun OSS region part of the bucket. For example: "oss-cn-beijing".\', { ns: "'.concat(k,'" })}}'),required:!0},accessKeyId:{title:'{{t("AccessKey ID", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},accessKeySecret:{title:'{{t("AccessKey Secret", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},bucket:{title:'{{t("Bucket", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},thumbnailRule:{title:"Thumbnail rule",type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{placeholder:"?x-oss-process=image/auto-orient,1/resize,m_fill,w_94,h_94/quality,q_90"},description:'{{ renderThumbnailRuleDesc("ali-oss") }}'}}},path:_.path,rules:_.rules,default:_.default,paranoid:_.paranoid},thumbnailRuleLink:"https://help.aliyun.com/zh/oss/user-guide/resize-images-4"},U={local:{title:'{{t("Local storage", { ns: "'.concat(k,'" })}}'),name:"local",fieldset:{title:_.title,name:_.name,baseUrl:{"x-component":"CollectionField","x-decorator":"FormItem","x-display":"hidden",default:"/storage/uploads"},options:{type:"object","x-component":"div",properties:{documentRoot:{title:'{{t("Destination", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"Input","x-display":"hidden",default:"storage/uploads"}}},path:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{addonBefore:"storage/uploads/"}},rules:_.rules,default:_.default,paranoid:_.paranoid}},"ali-oss":M,s3:{title:'{{t("Amazon S3", { ns: "'.concat(k,'" })}}'),name:"s3",fieldset:{title:_.title,name:_.name,baseUrl:_.baseUrl,options:{type:"object","x-component":"fieldset",properties:{region:{title:'{{t("Region", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},accessKeyId:{title:'{{t("AccessKey ID", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},secretAccessKey:{title:'{{t("AccessKey Secret", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},bucket:{title:'{{t("Bucket", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},endpoint:{title:'{{t("Endpoint", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope"}}},path:_.path,rules:_.rules,default:_.default,paranoid:_.paranoid}},"tx-cos":{title:'{{t("Tencent COS", { ns: "'.concat(k,'" })}}'),name:"tx-cos",fieldset:{title:_.title,name:_.name,baseUrl:_.baseUrl,options:{type:"object","x-component":"fieldset",properties:{Region:{title:'{{t("Region", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},SecretId:{title:'{{t("SecretId", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},SecretKey:{title:'{{t("SecretKey", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},Bucket:{title:'{{t("Bucket", { ns: "'.concat(k,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},thumbnailRule:{title:"Thumbnail rule",type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{placeholder:"?imageMogr2/thumbnail/!50p"},description:'{{ renderThumbnailRuleDesc("tx-cos") }}'}}},path:_.path,rules:_.rules,default:_.default,paranoid:_.paranoid},thumbnailRuleLink:"https://cloud.tencent.com/document/product/436/42214"}};function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function K(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function G(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){K(e,t,n[t])})}return e}function W(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function z(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,o,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var a=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return a}}(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 N(e){return function(e){if(Array.isArray(e))return B(e)}(e)||function(e){if("undefined"!=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.")}()}function V(e,t){if(e){if("string"==typeof e)return B(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return B(e,t)}}var L=function(){var e=z((0,i.useState)({}),2),t=e[0],n=e[1],o=(0,r.usePlugin)(eh),a=(0,r.useCompile)(),l=z((0,i.useState)(!1),2),u=l[0],p=l[1],s=(0,D.useTranslation)().t;return c().createElement("div",null,c().createElement(r.ActionContext.Provider,{value:{visible:u,setVisible:p}},c().createElement(j.Dropdown,{menu:{onClick:function(e){var t=o.storageTypes.get(e.key);p(!0),n({type:"object",properties:K({},(0,F.uid)(),{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{type:t.name}},title:a("{{t('Add new')}}")+" - "+a(t.title),properties:W(G({},E().cloneDeep(t.fieldset)),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}})})})},items:N(o.storageTypes.values()).map(function(e){return{key:e.name,label:a(e.title)}})}},c().createElement(j.Button,{type:"primary",icon:c().createElement(I.PlusOutlined,null)},s("Add new")," ",c().createElement(I.DownOutlined,null))),c().createElement(r.SchemaComponent,{scope:{createOnly:!0},schema:t})))},$=function(){var e=(0,r.useRecord)(),t=z((0,i.useState)({}),2),n=t[0],o=t[1],a=(0,r.usePlugin)(eh),l=(0,r.useCompile)(),u=z((0,i.useState)(!1),2),p=u[0],s=u[1],m=(0,D.useTranslation)().t;return c().createElement("div",null,c().createElement(r.ActionContext.Provider,{value:{visible:p,setVisible:s}},c().createElement("a",{onClick:function(){s(!0);var t=a.storageTypes.get(e.type);t.fieldset.default&&(t.fieldset.default["x-reactions"]=function(e){e.initialValue?e.disabled=!0:e.disabled=!1}),o({type:"object",properties:K({},(0,F.uid)(),{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:G({},e)},title:l("{{t('Edit')}}")+" - "+l(t.title),properties:W(G({},E().cloneDeep(t.fieldset)),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}})})})}},m("Edit")),c().createElement(r.SchemaComponent,{scope:{createOnly:!1},schema:n})))};function Y(e){var t=U[e];return(null==t?void 0:t.thumbnailRule)?c().createElement("div",null,c().createElement("a",{target:"_blank",href:t.thumbnailRuleLink,rel:"noreferrer"},r.i18n.t("See more"))):null}var H=function(){var e=(0,r.useCompile)(),t=N((0,r.usePlugin)(eh).storageTypes.values()).map(function(t){return{value:t.name,label:e(t.title)}});return c().createElement(j.Card,{bordered:!1},c().createElement(r.SchemaComponent,{components:{CreateStorage:L,EditStorage:$},scope:{useNewId:function(e){return"".concat(e).concat((0,F.uid)())},storageTypeOptions:t,renderThumbnailRuleDesc:Y},schema:q}))};function J(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Q(e){return(Q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function X(e,t){return(X=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Z(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Z=function(){return!!e})()}var ee=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,o,a,i;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,o=arguments,t=Q(t),J(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,Z()?Reflect.construct(t,o||[],Q(this).constructor):t.apply(this,o)),"name","attachment"),J(e,"type","object"),J(e,"group","media"),J(e,"title",'{{t("Attachment", { ns: "'.concat(k,'" })}}')),J(e,"isAssociation",!0),J(e,"default",{type:"belongsToMany",target:"attachments",uiSchema:{type:"array","x-component":"Upload.Attachment","x-use-component-props":"useAttachmentFieldProps"}}),J(e,"availableTypes",["belongsToMany"]),J(e,"properties",(a=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){J(e,t,n[t])})}return e}({},r.interfacesProperties.defaultProps),i=i={"uiSchema.x-component-props.accept":{type:"string",title:'{{t("MIME type", { ns: "'.concat(k,'" })}}'),"x-component":"Input","x-component-props":{placeholder:"image/*"},"x-decorator":"FormItem",description:"Example: image/png"},"uiSchema.x-component-props.multiple":{type:"boolean","x-content":"{{t('Allow uploading multiple files', { ns: \"".concat(k,'" })}}'),"x-decorator":"FormItem","x-component":"Checkbox",default:!0},storage:{type:"string",title:'{{t("Storage", { ns: "'.concat(k,'" })}}'),description:"{{t('Default storage will be used when not selected', { ns: \"".concat(k,'" })}}'),"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{service:{resource:"storages",params:{}},manual:!1,fieldNames:{label:"title",value:"name"}}}},Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(i)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(i)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(i,e))}),a)),J(e,"filterable",{children:[{name:"id",title:'{{t("Exists")}}',operators:[{label:'{{t("exists")}}',value:"$exists",noValue:!0},{label:'{{t("not exists")}}',value:"$notExists",noValue:!0}],schema:{title:'{{t("Exists")}}',type:"string","x-component":"Input"}},{name:"filename",title:'{{t("Filename", { ns: "'.concat(k,'" })}}'),operators:r.interfacesProperties.operators.string,schema:{title:'{{t("Filename", { ns: "'.concat(k,'" })}}'),type:"string","x-component":"Input"}}]}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&X(n,e),t=[{key:"schemaInitialize",value:function(e,t){var n=t.block;t.field,e["x-component-props"]||(e["x-component-props"]={}),["Table","Kanban"].includes(n)&&(e["x-component-props"].size="small"),e["x-use-component-props"]="useAttachmentFieldProps"}},{key:"initialize",value:function(e){e.through||(e.through="t_".concat((0,F.uid)())),e.foreignKey||(e.foreignKey="f_".concat((0,F.uid)())),e.otherKey||(e.otherKey="f_".concat((0,F.uid)())),e.sourceKey||(e.sourceKey="id"),e.targetKey||(e.targetKey="id")}}],function(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,t),n}(r.CollectionFieldInterface);function et(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function en(e){return(en=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){et(e,t,n[t])})}return e}function er(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function ea(e,t){return(ea=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ei(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ei=function(){return!!e})()}var ec=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(){var e,n,o;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");return n=t,o=arguments,n=en(n),et(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,ei()?Reflect.construct(n,o||[],en(this).constructor):n.apply(this,o)),"name","file"),et(e,"title",'{{t("File collection", { ns: "'.concat(k,'" })}}')),et(e,"order",3),et(e,"color","blue"),et(e,"default",{createdBy:!0,updatedBy:!0,fields:[{interface:"input",type:"string",name:"title",deletable:!1,uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"input",type:"string",name:"filename",deletable:!1,uiSchema:{type:"string",title:'{{t("File name", { ns: "'.concat(k,'" })}}'),"x-component":"Input","x-read-pretty":!0}},{interface:"input",type:"string",name:"extname",deletable:!1,uiSchema:{type:"string",title:'{{t("Extension name", { ns: "'.concat(k,'" })}}'),"x-component":"Input","x-read-pretty":!0}},{interface:"integer",type:"integer",name:"size",deletable:!1,uiSchema:{type:"number",title:'{{t("Size", { ns: "'.concat(k,'" })}}'),"x-component":"InputNumber","x-read-pretty":!0,"x-component-props":{stringMode:!0,step:"0"}}},{interface:"input",type:"string",name:"mimetype",deletable:!1,uiSchema:{type:"string",title:'{{t("MIME type", { ns: "'.concat(k,'" })}}'),"x-component":"Input","x-read-pretty":!0}},{interface:"input",type:"text",name:"path",deletable:!1,uiSchema:{type:"string",title:'{{t("Path", { ns: "'.concat(k,'" })}}'),"x-component":"TextAreaWithGlobalScope","x-read-pretty":!0}},{interface:"url",type:"text",name:"url",deletable:!1,uiSchema:{type:"string",title:'{{t("URL")}}',"x-component":"Input.URL","x-read-pretty":!0}},{interface:"url",type:"text",name:"preview",field:"url",deletable:!1,uiSchema:{type:"string",title:'{{t("Preview", { ns: "'.concat(k,'" })}}'),"x-component":"Preview","x-read-pretty":!0}},{comment:"存储引擎",type:"belongsTo",name:"storage",target:"storages",foreignKey:"storageId",deletable:!1,uiSchema:{type:"string",title:'{{t("Storage", { ns: "'.concat(k,'" })}}'),"x-component":"Input","x-read-pretty":!0}},{type:"jsonb",name:"meta",deletable:!1,defaultValue:{}}]}),et(e,"presetFieldsDisabled",!0),et(e,"configurableProperties",eo(er(eo(er(eo({},(0,r.getConfigurableProperties)("title","name")),{inherits:er(eo({},(0,r.getConfigurableProperties)("inherits").inherits),{"x-reactions":["{{useAsyncDataSource(loadCollections)}}"]})}),(0,r.getConfigurableProperties)("category","description")),{storage:{type:"string",name:"storage",title:'{{t("File storage", { ns: "'.concat(k,'" })}}'),"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{service:{resource:"storages",params:{}},manual:!1,fieldNames:{label:"title",value:"name"}}}}),(0,r.getConfigurableProperties)("presetFields"))),e}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ea(t,e),t}(r.CollectionTemplate);function el(e,t,n,o,r,a,i){try{var c=e[a](i),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(o,r)}function eu(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var a=e.apply(t,n);function i(e){el(a,o,r,i,c,"next",e)}function c(e){el(a,o,r,i,c,"throw",e)}i(void 0)})}}function ep(e,t,n){return(ep=ey()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var r=new(Function.bind.apply(e,o));return n&&ef(r,n.prototype),r}).apply(null,arguments)}function es(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function em(e){return(em=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ef(e,t){return(ef=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ed(e){var t="function"==typeof Map?new Map:void 0;return(ed=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return ep(e,arguments,em(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),ef(n,e)})(e)}function ey(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ey=function(){return!!e})()}function eb(e,t){var n,o,r,a,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){var l=[a,c];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,o&&(r=2&l[0]?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,o=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){i.label=l[1];break}if(6===l[0]&&i.label<r[1]){i.label=r[1],r=l;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(l);break}r[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],o=0}finally{n=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var eg=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,o=arguments,t=em(t),es(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,ey()?Reflect.construct(t,o||[],em(this).constructor):t.apply(this,o)),"storageTypes",new Map),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&ef(n,e),t=[{key:"load",value:function(){var e=this;return eu(function(){var t;return eb(this,function(n){return e.app.dataSourceManager.addFieldInterfaces([ee]),e.app.dataSourceManager.addCollectionTemplates([ec]),e.app.use(S),e.app.pluginSettingsManager.add(k,{title:'{{t("File manager", { ns: "'.concat(k,'" })}}'),icon:"FileOutlined",Component:H,aclSnippet:"pm.file-manager.storages"}),Object.values(U).forEach(function(t){e.registerStorageType(t.name,t)}),null==(t=e.app.schemaInitializerManager.get("table:configureActions"))||t.add("enableActions.upload",{title:"{{t('Upload')}}",Component:"UploadActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible:function(){return"file"===(0,r.useCollection)().template}}),e.app.addScopes({useAttachmentFieldProps:x,useFileCollectionStorageRules:v,useStorageCfg:u}),e.app.addComponents({FileSizeField:C}),[2]})})()}},{key:"registerStorageType",value:function(e,t){this.storageTypes.set(e,t)}},{key:"getStorageType",value:function(e){return this.storageTypes.get(e)}},{key:"uploadFile",value:function(e){var t=this;return eu(function(){var n,o,r;return eb(this,function(a){switch(a.label){case 0:if(!(null==(n=t.getStorageType(null==e?void 0:e.storageType))?void 0:n.upload))return[3,2];return[4,n.upload({file:e.file,apiClient:t.app.apiClient,storageType:e.storageType,storageId:e.storageId,storageRules:e.storageRules,fileCollectionName:e.fileCollectionName})];case 1:return[2,a.sent()];case 2:return a.trys.push([2,4,,5]),(r=new FormData).append("file",e.file),[4,t.app.apiClient.request({url:"".concat(e.fileCollectionName||"attachments",":create"),method:"post",data:r})];case 3:return[2,{data:null==(o=a.sent().data)?void 0:o.data}];case 4:return[2,{errorMessage:a.sent().message}];case 5:return[2]}})})()}}],function(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,t),n}(ed(r.Plugin));es(eg,"buildInStorage",["local","ali-oss","s3","tx-cos"]);var eh=eg}(),s}()});
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.7.0-alpha.13",
11
+ "@nocobase/client": "1.7.0-alpha.14",
12
12
  "react": "18.2.0",
13
13
  "antd": "5.24.2",
14
14
  "@ant-design/icons": "5.6.1",
@@ -19,12 +19,12 @@ module.exports = {
19
19
  "@formily/core": "2.3.0",
20
20
  "@formily/react": "2.3.0",
21
21
  "multer": "1.4.5-lts.2",
22
- "@nocobase/database": "1.7.0-alpha.13",
23
- "@nocobase/server": "1.7.0-alpha.13",
24
- "@nocobase/utils": "1.7.0-alpha.13",
25
- "@nocobase/test": "1.7.0-alpha.13",
26
- "@nocobase/actions": "1.7.0-alpha.13",
22
+ "@nocobase/database": "1.7.0-alpha.14",
23
+ "@nocobase/server": "1.7.0-alpha.14",
24
+ "@nocobase/utils": "1.7.0-alpha.14",
25
+ "@nocobase/test": "1.7.0-alpha.14",
26
+ "@nocobase/actions": "1.7.0-alpha.14",
27
27
  "sequelize": "6.35.2",
28
- "@nocobase/plugin-data-source-main": "1.7.0-alpha.13",
28
+ "@nocobase/plugin-data-source-main": "1.7.0-alpha.14",
29
29
  "axios": "1.7.7"
30
30
  };
@@ -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-05-08T06:29:08.991Z"}
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-05-20T16:09:01.547Z"}
@@ -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-05-08T06:29:02.896Z"}
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-05-20T16:08:54.797Z"}
@@ -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-05-08T06:29:07.567Z"}
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-05-20T16:08:59.766Z"}
@@ -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-05-08T06:29:07.484Z"}
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-05-20T16:08:59.684Z"}
@@ -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-05-08T06:29:14.650Z"}
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-05-20T16:09:06.958Z"}
@@ -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-05-08T06:29:10.637Z"}
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-05-20T16:09:03.217Z"}
@@ -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":"2025-05-08T06:29:02.811Z"}
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-05-20T16:08:54.879Z"}
@@ -101,13 +101,24 @@ async function createMiddleware(ctx, next) {
101
101
  if (((_a = collection == null ? void 0 : collection.options) == null ? void 0 : _a.template) !== "file" || !["upload", "create"].includes(actionName)) {
102
102
  return next();
103
103
  }
104
+ const storageName = resourceName === "attachments" ? (_c = (_b = ctx.db.getFieldByPath(attachmentField)) == null ? void 0 : _b.options) == null ? void 0 : _c.storage : collection.options.storage;
104
105
  const plugin = ctx.app.pm.get(import__.default);
105
- const storageName = ((_c = (_b = ctx.db.getFieldByPath(attachmentField)) == null ? void 0 : _b.options) == null ? void 0 : _c.storage) || collection.options.storage;
106
- const storages = Array.from(plugin.storagesCache.values());
107
- ctx.storage = storages.find((item) => item.name === storageName) || storages.find((item) => item.default);
106
+ const storage = Array.from(plugin.storagesCache.values()).find(
107
+ (storage2) => storageName ? storage2.name === storageName : storage2.default
108
+ );
109
+ if (!storage) {
110
+ ctx.logger.error(`[file-manager] no storage found`);
111
+ return ctx.throw(500);
112
+ }
113
+ ctx.storage = storage;
108
114
  if (ctx == null ? void 0 : ctx.request.is("multipart/*")) {
109
115
  await multipart(ctx, next);
110
116
  } else {
117
+ ctx.action.mergeParams({
118
+ values: {
119
+ storage: { id: storage.id }
120
+ }
121
+ });
111
122
  await next();
112
123
  }
113
124
  }
@@ -48,7 +48,7 @@ export declare class PluginFileManagerServer extends Plugin {
48
48
  handleSyncMessage(message: any): Promise<void>;
49
49
  beforeLoad(): Promise<void>;
50
50
  load(): Promise<void>;
51
- getFileURL(file: AttachmentModel, preview?: boolean): Promise<string>;
51
+ getFileURL(file: AttachmentModel, preview?: boolean): Promise<any>;
52
52
  isPublicAccessStorage(storageName: any): Promise<boolean>;
53
53
  getFileStream(file: AttachmentModel): Promise<{
54
54
  stream: Readable;
@@ -42,6 +42,7 @@ __export(server_exports, {
42
42
  module.exports = __toCommonJS(server_exports);
43
43
  var import_fs = __toESM(require("fs"));
44
44
  var import_path = require("path");
45
+ var import_mime_match = __toESM(require("mime-match"));
45
46
  var import_database = require("@nocobase/database");
46
47
  var import_server = require("@nocobase/server");
47
48
  var import_utils = require("@nocobase/utils");
@@ -284,7 +285,10 @@ class PluginFileManagerServer extends import_server.Plugin {
284
285
  return (0, import_utils2.encodeURL)(file.url);
285
286
  }
286
287
  const storageType = this.storageTypes.get(storage.type);
287
- return new storageType(storage).getFileURL(file, preview ? storage.options.thumbnailRule : "");
288
+ return new storageType(storage).getFileURL(
289
+ file,
290
+ Boolean((0, import_mime_match.default)(file.mimetype, "image/*") && preview && storage.options.thumbnailRule)
291
+ );
288
292
  }
289
293
  async isPublicAccessStorage(storageName) {
290
294
  var _a;
@@ -24,10 +24,10 @@ export interface StorageModel {
24
24
  export interface AttachmentModel {
25
25
  title: string;
26
26
  filename: string;
27
+ mimetype?: string;
27
28
  path: string;
28
- url: string;
29
+ url?: string;
29
30
  storageId: number;
30
- mimetype: string;
31
31
  }
32
32
  export declare abstract class StorageType {
33
33
  storage: StorageModel;
@@ -39,10 +39,10 @@ __export(storages_exports, {
39
39
  StorageType: () => StorageType
40
40
  });
41
41
  module.exports = __toCommonJS(storages_exports);
42
- var import_utils = require("@nocobase/utils");
43
42
  var import_axios = __toESM(require("axios"));
44
43
  var import_path = __toESM(require("path"));
45
44
  var import_url_join = __toESM(require("url-join"));
45
+ var import_utils = require("@nocobase/utils");
46
46
  var import_utils2 = require("../utils");
47
47
  class StorageType {
48
48
  constructor(storage) {
@@ -75,8 +75,8 @@ class StorageType {
75
75
  }
76
76
  getFileURL(file, preview) {
77
77
  if (file.url && (0, import_utils.isURL)(file.url)) {
78
- if (preview) {
79
- return (0, import_utils2.encodeURL)(file.url) + (this.storage.options.thumbnailRule || "");
78
+ if (preview && this.storage.options.thumbnailRule) {
79
+ return (0, import_utils2.encodeURL)(file.url) + this.storage.options.thumbnailRule;
80
80
  }
81
81
  return (0, import_utils2.encodeURL)(file.url);
82
82
  }
@@ -10,4 +10,4 @@ export declare function getFilename(req: any, file: any, cb: any): void;
10
10
  export declare const cloudFilenameGetter: (storage: any) => (req: any, file: any, cb: any) => void;
11
11
  export declare function getFileKey(record: any): any;
12
12
  export declare function ensureUrlEncoded(value: any): any;
13
- export declare function encodeURL(url: any): string;
13
+ export declare function encodeURL(url: any): any;
@@ -76,9 +76,13 @@ function encodePathKeepSlash(path2) {
76
76
  return path2.split("/").map((segment) => ensureUrlEncoded(segment)).join("/");
77
77
  }
78
78
  function encodeURL(url) {
79
- const parsedUrl = new URL(url);
80
- parsedUrl.pathname = encodePathKeepSlash(parsedUrl.pathname);
81
- return parsedUrl.toString();
79
+ try {
80
+ const parsedUrl = new URL(url);
81
+ parsedUrl.pathname = encodePathKeepSlash(parsedUrl.pathname);
82
+ return parsedUrl.toString();
83
+ } catch (error) {
84
+ return url;
85
+ }
82
86
  }
83
87
  // Annotate the CommonJS export names for ESM import in node:
84
88
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-file-manager",
3
- "version": "1.7.0-alpha.13",
3
+ "version": "1.7.0-alpha.14",
4
4
  "displayName": "File manager",
5
5
  "displayName.zh-CN": "文件管理器",
6
6
  "description": "Provides files storage services with files collection template and attachment field.",
@@ -45,5 +45,5 @@
45
45
  "Collections",
46
46
  "Collection fields"
47
47
  ],
48
- "gitHead": "92281d435ef3c4c0a9b56d6d88405f8abc0a6cbf"
48
+ "gitHead": "726870b3afcd0ae02a353730a1dffe7da9be6f1c"
49
49
  }