@nocobase/plugin-acl 2.1.0-alpha.13 → 2.1.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +1 -1
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +10 -10
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +2 -0
- package/dist/server/middlewares/check-query-permission.d.ts +10 -0
- package/dist/server/middlewares/check-query-permission.js +64 -0
- package/dist/server/query/apply-query-permission.d.ts +27 -0
- package/dist/server/query/apply-query-permission.js +232 -0
- package/dist/server/server.js +2 -0
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -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-i18next"),require("@formily/antd-v5"),require("@formily/react"),require("@ant-design/icons"),require("ahooks"),require("@formily/core"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("antd-style"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-acl",["react-i18next","@formily/antd-v5","@formily/react","@ant-design/icons","ahooks","@formily/core","@formily/shared","react","antd","@nocobase/client","antd-style","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-acl"]=t(require("react-i18next"),require("@formily/antd-v5"),require("@formily/react"),require("@ant-design/icons"),require("ahooks"),require("@formily/core"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("antd-style"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-acl"]=t(e["react-i18next"],e["@formily/antd-v5"],e["@formily/react"],e["@ant-design/icons"],e.ahooks,e["@formily/core"],e["@formily/shared"],e.react,e.antd,e["@nocobase/client"],e["antd-style"],e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,n,r,o,i,a,c,l,u,s,p,f){return function(){"use strict";var m,d,y,b={268:function(e,t,n){n.d(t,{s:function(){return r}});var r=(0,n(155).createContext)({role:null});r.displayName="RolesManagerContext"},570:function(e,t,n){n.d(t,{K:function(){return u},c:function(){return l}});var r=n(342),o=n(59),i=n(155),a=n.n(i),c=(0,i.createContext)([]);c.displayName="AvailableActionsContext";var l=function(e){var t=(0,r.useRequest)({resource:"availableActions",action:"list"}),n=t.data;return t.loading?a().createElement(o.Spin,null):a().createElement(c.Provider,{value:null==n?void 0:n.data},e.children)},u=function(){return(0,i.useContext)(c)}},365:function(e,t,n){n.r(t),n.d(t,{DesktopAllRoutesProvider:function(){return A},MenuPermissions:function(){return E}});var r=n(452),o=n(166),i=n(342),a=n(625),c=n(59),l=n(773),u=n(155),s=n.n(u),p=n(953),f=n(268);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function y(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){d(i,r,o,a,c,"next",e)}function c(e){d(i,r,o,a,c,"throw",e)}a(void 0)})}}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function h(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(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 g(e,t){if(e){if("string"==typeof e)return m(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 m(e,t)}}function x(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function w(){var e,t,n=(e=["\n .ant-table-cell {\n > .ant-space-horizontal {\n .ant-space-item-split:has(+ .ant-space-item:empty) {\n display: none;\n }\n }\n }\n"],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return w=function(){return n},n}var O=function(e,t){return Array.isArray(e)?e.map(function(e){var n,r=O(e.children,e),o=0===r.length;return{title:e.title,id:e.id,children:o?null:r,hideChildren:o,firstTabId:null==(n=r[0])?void 0:n.id,parent:t}}):[]},S=function(e){if(!Array.isArray(e))return[];var t=[],n=!0,r=!1,o=void 0;try{for(var i,a=e[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var c=i.value;t.push(c.id),t.push.apply(t,h(S(c.children)))}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return t},P=(0,i.css)(w()),C=function(e,t,n){return e.map(function(e){var r,o=((null==(r=e.title)?void 0:r.match(/^\s*\{\{\s*.+?\s*\}\}\s*$/))?n(e.title):t(e.title))||t("Unnamed");return e.children?v(b({},e),{title:o,children:C(e.children,t,n)}):v(b({},e),{title:o})})},j=(0,u.createContext)({routeList:[]}),k=function(e){var t=e.children,n=e.refreshRef,r=(0,i.useAPIClient)(),o=(0,u.useMemo)(function(){return r.resource("desktopRoutes")},[r]),a=(0,i.useRequest)(function(){return o.list({tree:!0,sort:"sort",paginate:!1,filter:{hidden:{$ne:!0}}}).then(function(e){return e.data})},{manual:!0}),c=a.data,l=a.runAsync;n&&(n.current=l);var p=(0,u.useMemo)(function(){return(null==c?void 0:c.data)||[]},[c]),f=(0,u.useMemo)(function(){return{routeList:p}},[p]);return s().createElement(j.Provider,{value:f},t)},A=function(e){var t=e.children,n=e.active,r=s().useRef(function(){});return(0,u.useEffect)(function(){if(n){var e;null==(e=r.current)||e.call(r)}},[n]),s().createElement(k,{refreshRef:r},t)},E=function(e){var t,n=e.active,m=O((0,u.useContext)(j).routeList),d=(0,u.useContext)(f.s),v=d.role,w=d.setRole,k=(0,i.useAPIClient)(),A=(0,p.useTranslation)().t,E=S(m),R=function(e){if(Array.isArray(e))return e}(t=(0,u.useState)([]))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||g(t,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],T=R[1],F=(0,i.useRequest)({resource:"roles.desktopRoutes",resourceOf:v.name,action:"list",params:{paginate:!1,filter:{hidden:{$ne:!0}}}},{ready:!!v&&n,refreshDeps:[null==v?void 0:v.name],onSuccess:function(e){var t;T((null==e||null==(t=e.data)?void 0:t.map(function(e){return e.id}))||[])}}),_=F.loading,q=F.refresh,M=k.resource("roles.desktopRoutes",v.name),N=E.length===I.length,D=(0,i.useAllAccessDesktopRoutes)().refresh,B=(0,a.useMemoizedFn)(function(e){return y(function(){return x(this,function(t){switch(t.label){case 0:return[4,k.resource("roles").update({filterByTk:v.name,values:e.values})];case 1:return t.sent(),w(b({},v,e.values)),c.message.success(A("Saved successfully")),[2]}})})()}),L=(0,u.useMemo)(function(){return(0,r.createForm)({values:v,effects:function(){(0,r.onFormValuesChange)(function(e){return y(function(){return x(this,function(t){switch(t.label){case 0:return[4,B(e)];case 1:return t.sent(),[2]}})})()})}})},[v,B]),z=(0,i.useCompile)();return s().createElement(s().Fragment,null,s().createElement(i.SchemaComponent,{schema:{type:"void",name:(0,o.uid)(),"x-component":"FormV2","x-component-props":{form:L},properties:{allowNewMenu:{title:A("Route permissions"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":A("New routes are allowed to be accessed by default")}}}}),s().createElement(c.Table,{className:P,loading:_,rowKey:"id",pagination:!1,expandable:{defaultExpandAllRows:!1},columns:[{dataIndex:"title",title:A("Route name")},{dataIndex:"accessible",title:s().createElement(s().Fragment,null,s().createElement(c.Checkbox,{checked:N,onChange:function(e){return y(function(){return x(this,function(e){switch(e.label){case 0:if(!N)return[3,2];return[4,M.set({values:[]})];case 1:return e.sent(),[3,4];case 2:return[4,M.set({values:E})];case 3:e.sent(),e.label=4;case 4:return q(),D(),c.message.success(A("Saved successfully")),[2]}})})()}})," ",A("Accessible")),render:function(e,t){var n=I.includes(t.id);return s().createElement(c.Checkbox,{checked:n,onChange:function(){return y(function(){var e,r,o,i,a,u,s,p;return x(this,function(f){switch(f.label){case 0:if(!n)return[3,2];return e=I.filter(function(e){return e!==t.id}),r=[t.id],t.parent&&0===t.parent.children.filter(function(t){return e.includes(t.id)}).length&&(e=e.filter(function(e){return e!==t.parent.id}),r.push(t.parent.id)),t.children&&(e=e.filter(function(e){return!S(t.children).includes(e)}),(o=r).push.apply(o,h(S(t.children)))),T(e),[4,M.remove({values:r})];case 1:return f.sent(),[3,4];case 2:return i=h(I).concat([t.id]),a=[t.id],t.parent&&!i.includes(t.parent.id)&&(i.push(t.parent.id),a.push(t.parent.id)),t.children&&(p=S(t.children),(u=i).push.apply(u,h(p)),(s=a).push.apply(s,h(p))),T((0,l.uniq)(i)),[4,M.add({values:a})];case 3:f.sent(),f.label=4;case 4:return D(),c.message.success(A("Saved successfully")),[2]}})})()}})}}],dataSource:C(m,A,z)}))}},747:function(e,t,n){n.r(t),n.d(t,{PluginACLClient:function(){return $},default:function(){return K},RoleResourceCollectionContext:function(){return F},RolesManagerContext:function(){return _.s}});var r=n(342),o=n(155),i=n.n(o),a=n(365),c=(0,r.lazy)(function(){return n.e("971").then(n.bind(n,486))},"GeneralPermissions").GeneralPermissions,l=(0,r.lazy)(function(){return Promise.resolve().then(n.bind(n,365))},"MenuPermissions").MenuPermissions,u=function(){var e;function t(){var e,n;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");e="permissionsTabs",n=[function(e){var t=e.t,n=e.TabLayout;return{key:"general",label:t("System"),sort:10,children:i().createElement(n,null,i().createElement(c,null))}},function(e){var t=e.activeKey,n=e.t,r=e.TabLayout;return{key:"menu",label:n("Desktop routes"),sort:20,children:i().createElement(r,null,i().createElement(a.DesktopAllRoutesProvider,{active:"menu"===t},i().createElement(l,{active:"menu"===t})))}}],e in this?Object.defineProperty(this,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):this[e]=n}return e=[{key:"addPermissionsTab",value:function(e){this.permissionsTabs.push(e)}},{key:"getPermissionsTabs",value:function(e){return this.permissionsTabs.map(function(t){return"function"==typeof t?t(e):t}).sort(function(e,t){var n,r;return(null!=(n=null==e?void 0:e.sort)?n:100)-(null!=(r=null==t?void 0:t.sort)?r:100)})}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,e),t}(),s=n(768),p=function(){var e;function t(){var e,n;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");e="rolesManager",n=new s.Registry,e in this?Object.defineProperty(this,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):this[e]=n}return e=[{key:"add",value:function(e,t){this.rolesManager.register(e,t)}},{key:"list",value:function(){return this.rolesManager.getEntities()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,e),t}(),f=n(953),m=n(59),d=n(773),y=n.n(d);function b(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}var v=function(){var e,t=(0,f.useTranslation)().t,n=(0,r.useAPIClient)(),o=y().cloneDeep((0,r.useCurrentRoles)()),a=(0,r.useCurrentRoleMode)(),c=null==(e=o.find(function(e){return e.name===n.auth.role}))?void 0:e.name;return("allow-use-union"===a&&o.unshift({name:"__union__",title:t("Full permissions",{ns:"acl"})}),o.length<=1||"only-use-union"===a)?null:i().createElement(r.SchemaSettingsItem,{eventKey:"SwitchRole",title:"SwitchRole"},i().createElement(r.SelectWithTitle,{title:t("Switch role"),fieldNames:{label:"title",value:"name"},options:o.reduce(function(e,t){return e.push(t),"__union__"===t.name&&e.push({name:"divider",title:i().createElement(m.Divider,{style:{margin:"2px 1px"}}),disabled:!0,style:{minHeight:0,height:"auto",padding:0}}),e},[]),defaultValue:c||o[0].name,onChange:function(e){var t;return(t=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:return n.auth.setRole(e),[4,n.resource("users").setDefaultRole({values:{roleName:e}})];case 1:return t.sent(),location.reload(),window.location.reload(),[2]}})},function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(e){b(i,r,o,a,c,"next",e)}function c(e){b(i,r,o,a,c,"throw",e)}a(void 0)})})()}}))},h=n(418),g=n(230),x=n(570),w=n(452),O={name:"rolesResourcesScopes",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Scope name")}}',type:"string","x-component":"Input",required:!0}}]},S={type:"object",properties:{scope:{"x-component":"RecordPicker","x-component-props":{size:"small",fieldNames:{label:"name",value:"id"},multiple:!1,association:{target:"rolesResourcesScopes"},onChange:"{{ onChange }}"},properties:{selector:{type:"void",title:'{{ t("Select record") }}',"x-component":"RecordPicker.Selector","x-component-props":{className:"nb-record-picker-selector"},properties:{tableBlock:{type:"void","x-decorator":"TableSelectorProvider","x-decorator-props":{collection:O,resource:"rolesResourcesScopes",action:"list",params:{pageSize:20},useParams:function(){return{filter:{$or:[{resourceName:(0,o.useContext)(F).name},{resourceName:null}]}}},rowKey:"id"},"x-component":"BlockItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{create:{type:"void",title:'{{ t("Add new") }}',"x-action":"create","x-component":"Action","x-component-props":{icon:"PlusOutlined",openMode:"drawer",type:"primary"},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"rolesResourcesScopes",collection:O},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":function(){var e=(0,o.useContext)(F).name,t=(0,r.useFormBlockContext)();return(0,o.useEffect)(function(){t.form.setInitialValues({resourceName:e})},[e]),{form:t.form}},properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":"Filter","x-use-component-props":function(){var e=(0,o.useContext)(F);return{options:(0,r.useFilterOptions)(e.name)}},"x-component-props":{dynamicComponent:r.VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{create:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}}}},value:{type:"array","x-component":"TableV2.Selector","x-use-component-props":"useTableSelectorProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-component":"TableV2.Column",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{edit:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"rolesResourcesScopes",collection:O,action:"get",useParams:"{{ useParamsFromRecord }}"},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":"Filter","x-use-component-props":function(){var e=(0,o.useContext)(F);return{options:(0,r.useFilterOptions)(e.name)}},"x-component-props":{dynamicComponent:r.VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{update:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}},destroy:{title:'{{ t("Delete") }}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}},footer:{"x-component":"Action.Container.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"usePickActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}};function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var C=(0,o.createContext)(null);C.displayName="RolesResourcesScopesSelectedRowKeysContext";var j=function(e){var t,n=function(e){if(Array.isArray(e))return e}(t=(0,o.useState)([]))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||function(e){if(e){if("string"==typeof e)return P(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return P(e,2)}}(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.")}(),r=n[0],a=n[1];return i().createElement(C.Provider,{value:[r,a]},e.children)},k=function(e){var t=(0,o.useMemo)(function(){return(0,w.createForm)({values:{scope:e.value}})},[]);return i().createElement(r.FormProvider,{form:t},i().createElement(r.SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider:j},scope:{onChange:function(t){var n;null==e||null==(n=e.onChange)||n.call(e,t)}},schema:S}))},A=n(143);function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function R(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function I(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var T=function(e){var t,n={};return null==e||null==(t=e.forEach)||t.call(e,function(e){e.name&&(n[e.name]=e,n[e.name].scope=(0,d.isEmpty)(e.scope)?null:e.scope)}),n},F=(0,o.createContext)({});F.displayName="RoleResourceCollectionContext",(0,g.connect)(function(e){var t,n=(0,A.I)().styles,o=function(t){var n=t.map(function(e){return I(R({},e),{scope:(0,d.isEmpty)(e.scope)?null:e.scope})});e.onChange(n)};(0,g.useForm)();var a=(0,r.useRecord)(),c=(0,x.K)(),l=(0,r.useCollectionManager_deprecated)(),u=l.getCollection,s=l.getCollectionFields,p=u(a.collectionName),y=s(a.collectionName),b=(0,r.useCompile)(),v=(0,f.useTranslation)().t,w=T((0,g.useField)().value||[]),O=function(e,t){var n,r=null==w?void 0:w[e];return!!r&&(null==r||null==(n=r.fields)?void 0:n.includes(t))},S=c.filter(function(e){return e.allowConfigureFields}),P=null==y||null==(D=y.filter(function(e){return e.interface}))?void 0:D.map(function(e){var t=R({},e),n=!0,r=!1,o=void 0;try{for(var i,a=S[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var c=i.value;t[c.name]=O(c.name,e.name)}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return t}),C=function(e){if(w[e])delete w[e];else{var t,n;w[e]={name:e,fields:null==y||null==(n=y.filter(function(e){return e.interface}))||null==(t=n.map)?void 0:t.call(n,function(e){return e.name})}}o(Object.values(w))},j=function(e,t){w[e]?(w[e].scope=t,o(Object.values(w))):(C(e),w[e].scope=t)},_={},q=!0,M=!1,N=void 0;try{for(var D,B,L=S[Symbol.iterator]();!(q=(B=L.next()).done);q=!0){var z,V,$,K=B.value;_[K.name]=(null==y||null==(z=y.filter(function(e){return e.interface}))?void 0:z.length)===(null==w||null==($=w[K.name])||null==(V=$.fields)?void 0:V.length)}}catch(e){M=!0,N=e}finally{try{q||null==L.return||L.return()}finally{if(M)throw N}}return i().createElement("div",null,i().createElement(F.Provider,{value:p},i().createElement(h.FormLayout,{layout:"vertical"},i().createElement(h.FormItem,{label:v("Action permission")},i().createElement(m.Table,{className:n,size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:v("Action display name"),render:function(e){return b(e)}},{dataIndex:"onNewRecord",title:v("Action type"),render:function(e){return e?i().createElement(m.Tag,{color:"green"},v("Action on new records")):i().createElement(m.Tag,{color:"geekblue"},v("Action on existing records"))}},{dataIndex:"enabled",title:v("Allow"),render:function(e,t){return i().createElement(m.Checkbox,{checked:e,onChange:function(){C(t.name)}})}},{dataIndex:"scope",title:v("Data scope"),render:function(e,t){return!t.onNewRecord&&i().createElement(k,{value:e,onChange:function(e){j(t.name,e)}})}}],dataSource:null==c?void 0:c.map(function(e){var t=!1,n=null;return w[e.name]&&(t=!0,e.onNewRecord||(n=w[e.name].scope)),I(R({},e),{enabled:t,scope:n})})})),i().createElement(h.FormItem,{label:v("Field permission")},i().createElement(m.Table,{className:n,pagination:!1,dataSource:P,columns:[{dataIndex:["uiSchema","title"],title:v("Field display name"),render:function(e){return b(e)}}].concat(function(e){if(Array.isArray(e))return E(e)}(t=S.map(function(e){var t=null==_?void 0:_[e.name];return{dataIndex:e.name,title:i().createElement(i().Fragment,null,i().createElement(m.Checkbox,{checked:t,onChange:function(){var n,r=w[e.name]||{name:e.name};t?r.fields=[]:r.fields=null==y||null==(n=y.map)?void 0:n.call(y,function(e){return e.name}),w[e.name]=r,o(Object.values(w))}})," ",b(e.displayName)),render:function(t,n){return i().createElement(m.Checkbox,{checked:t,"aria-label":"".concat(e.name,"_checkbox"),onChange:function(){var r=w[e.name]||{name:e.name},i=r.fields||[];if(t){var a=i.indexOf(n.name);i.splice(a,1)}else i.push(n.name);r.fields=i,w[e.name]=r,o(Object.values(w))}})}}}))||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e){if(e){if("string"==typeof e)return E(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return E(e,void 0)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())})))))});var _=n(268);function q(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function M(e,t,n){return(M=z()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&B(o,n.prototype),o}).apply(null,arguments)}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function D(e){return(D=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function B(e,t){return(B=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function L(e){var t="function"==typeof Map?new Map:void 0;return(L=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 M(e,arguments,D(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),B(n,e)})(e)}function z(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(z=function(){return!!e})()}var V=(0,r.lazy)(function(){return n.e("949").then(n.bind(n,916))},"RolesManagement").RolesManagement,$=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,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=D(t),N(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,r||[],D(this).constructor):t.apply(this,r)),"rolesManager",new p),N(e,"settingsUI",new u),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&B(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return this.pluginSettingsManager.add("users-permissions.roles",{title:this.t("Roles & Permissions"),icon:"LockOutlined",Component:V,aclSnippet:"pm.acl.roles",sort:3}),this.app.addUserCenterSettingsItem({name:"divider_switchRole",type:"divider",sort:200}),this.app.addUserCenterSettingsItem({name:"switchRole",Component:v,sort:300}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){q(i,r,o,a,c,"next",e)}function c(e){q(i,r,o,a,c,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(L(r.Plugin)),K=$},143:function(e,t,n){function r(){var e,t,n=(e=["\n .ant-table-cell {\n > .ant-space-horizontal {\n .ant-space-item-split:has(+ .ant-space-item:empty) {\n display: none;\n }\n }\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return r=function(){return n},n}n.d(t,{I:function(){return o}});var o=(0,n(235).createStyles)(function(e){return(0,e.css)(r())})},375:function(e){e.exports=r},418:function(e){e.exports=t},452:function(e){e.exports=i},230:function(e){e.exports=n},166:function(e){e.exports=a},342:function(e){e.exports=u},768:function(e){e.exports=p},625:function(e){e.exports=o},59:function(e){e.exports=l},235:function(e){e.exports=s},773:function(e){e.exports=f},155:function(e){e.exports=c},953:function(t){t.exports=e},531:function(e,t,n){var r=window.__nocobase_public_path__||"";if(!r&&window.location&&window.location.pathname){var o=window.location.pathname||"/",i=o.indexOf("/v2/");r=i>=0?o.slice(0,i+1):"/"}r&&(r=r.replace(/\/v2\/?$/,"/")),r||(r="/"),"/"!==r.charAt(r.length-1)&&(r+="/"),n.p=r+"static/plugins/@nocobase/plugin-acl/dist/client/"}},v={};function h(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return b[e](n,n.exports,h),n.exports}h.m=b,h.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return h.d(t,{a:t}),t},h.d=function(e,t){for(var n in t)h.o(t,n)&&!h.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},h.f={},h.e=function(e){return Promise.all(Object.keys(h.f).reduce(function(t,n){return h.f[n](e,t),t},[]))},h.u=function(e){return""+({949:"a8ee1085b1883873",971:"d4b1aca44e7fa5bc"})[e]+".js"},h.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),h.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},g={},h.l=function(e,t,n,r){if(g[e])return void g[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),c=0;c<a.length;c++){var l=a[c];if(l.getAttribute("src")==e||l.getAttribute("data-rspack")=="@nocobase/plugin-acl:"+n){o=l;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,h.nc&&o.setAttribute("nonce",h.nc),o.setAttribute("data-rspack","@nocobase/plugin-acl:"+n),o.src=e),g[e]=[t];var u=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=g[e];if(delete g[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(u.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=u.bind(null,o.onerror),o.onload=u.bind(null,o.onload),i&&document.head.appendChild(o)},h.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},h.g.importScripts&&(x=h.g.location+"");var g,x,w=h.g.document;if(!x&&w&&(w.currentScript&&"SCRIPT"===w.currentScript.tagName.toUpperCase()&&(x=w.currentScript.src),!x)){var O=w.getElementsByTagName("script");if(O.length)for(var S=O.length-1;S>-1&&(!x||!/^http(s?):/.test(x));)x=O[S--].src}if(!x)throw Error("Automatic publicPath is not supported in this browser");return h.p=x.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),m={889:0},h.f.j=function(e,t){var n=h.o(m,e)?m[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=m[e]=[t,r]});t.push(n[2]=r);var o=h.p+h.u(e),i=Error();h.l(o,function(t){if(h.o(m,e)&&(0!==(n=m[e])&&(m[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},d=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],c=0;if(o.some(function(e){return 0!==m[e]})){for(n in i)h.o(i,n)&&(h.m[n]=i[n]);a&&a(h)}for(e&&e(t);c<o.length;c++)r=o[c],h.o(m,r)&&m[r]&&m[r][0](),m[r]=0},(y=self.webpackChunk_nocobase_plugin_acl=self.webpackChunk_nocobase_plugin_acl||[]).forEach(d.bind(null,0)),y.push=d.bind(null,y.push.bind(y)),h(531),h(747)}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@formily/antd-v5"),require("@formily/react"),require("@ant-design/icons"),require("ahooks"),require("@formily/core"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("antd-style"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-acl",["react-i18next","@formily/antd-v5","@formily/react","@ant-design/icons","ahooks","@formily/core","@formily/shared","react","antd","@nocobase/client","antd-style","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-acl"]=t(require("react-i18next"),require("@formily/antd-v5"),require("@formily/react"),require("@ant-design/icons"),require("ahooks"),require("@formily/core"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("antd-style"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-acl"]=t(e["react-i18next"],e["@formily/antd-v5"],e["@formily/react"],e["@ant-design/icons"],e.ahooks,e["@formily/core"],e["@formily/shared"],e.react,e.antd,e["@nocobase/client"],e["antd-style"],e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,n,r,o,i,a,c,l,u,s,p,f){return function(){"use strict";var m,d,y,b={268:function(e,t,n){n.d(t,{s:function(){return r}});var r=(0,n(155).createContext)({role:null});r.displayName="RolesManagerContext"},570:function(e,t,n){n.d(t,{K:function(){return u},c:function(){return l}});var r=n(342),o=n(59),i=n(155),a=n.n(i),c=(0,i.createContext)([]);c.displayName="AvailableActionsContext";var l=function(e){var t=(0,r.useRequest)({resource:"availableActions",action:"list"}),n=t.data;return t.loading?a().createElement(o.Spin,null):a().createElement(c.Provider,{value:null==n?void 0:n.data},e.children)},u=function(){return(0,i.useContext)(c)}},365:function(e,t,n){n.r(t),n.d(t,{DesktopAllRoutesProvider:function(){return A},MenuPermissions:function(){return E}});var r=n(452),o=n(166),i=n(342),a=n(625),c=n(59),l=n(773),u=n(155),s=n.n(u),p=n(953),f=n(268);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function y(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){d(i,r,o,a,c,"next",e)}function c(e){d(i,r,o,a,c,"throw",e)}a(void 0)})}}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function h(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(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 g(e,t){if(e){if("string"==typeof e)return m(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 m(e,t)}}function x(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function w(){var e,t,n=(e=["\n .ant-table-cell {\n > .ant-space-horizontal {\n .ant-space-item-split:has(+ .ant-space-item:empty) {\n display: none;\n }\n }\n }\n"],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return w=function(){return n},n}var O=function(e,t){return Array.isArray(e)?e.map(function(e){var n,r=O(e.children,e),o=0===r.length;return{title:e.title,id:e.id,children:o?null:r,hideChildren:o,firstTabId:null==(n=r[0])?void 0:n.id,parent:t}}):[]},S=function(e){if(!Array.isArray(e))return[];var t=[],n=!0,r=!1,o=void 0;try{for(var i,a=e[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var c=i.value;t.push(c.id),t.push.apply(t,h(S(c.children)))}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return t},P=(0,i.css)(w()),C=function(e,t,n){return e.map(function(e){var r,o=((null==(r=e.title)?void 0:r.match(/^\s*\{\{\s*.+?\s*\}\}\s*$/))?n(e.title):t(e.title))||t("Unnamed");return e.children?v(b({},e),{title:o,children:C(e.children,t,n)}):v(b({},e),{title:o})})},j=(0,u.createContext)({routeList:[]}),k=function(e){var t=e.children,n=e.refreshRef,r=(0,i.useAPIClient)(),o=(0,u.useMemo)(function(){return r.resource("desktopRoutes")},[r]),a=(0,i.useRequest)(function(){return o.list({tree:!0,sort:"sort",paginate:!1,filter:{hidden:{$ne:!0}}}).then(function(e){return e.data})},{manual:!0}),c=a.data,l=a.runAsync;n&&(n.current=l);var p=(0,u.useMemo)(function(){return(null==c?void 0:c.data)||[]},[c]),f=(0,u.useMemo)(function(){return{routeList:p}},[p]);return s().createElement(j.Provider,{value:f},t)},A=function(e){var t=e.children,n=e.active,r=s().useRef(function(){});return(0,u.useEffect)(function(){if(n){var e;null==(e=r.current)||e.call(r)}},[n]),s().createElement(k,{refreshRef:r},t)},E=function(e){var t,n=e.active,m=O((0,u.useContext)(j).routeList),d=(0,u.useContext)(f.s),v=d.role,w=d.setRole,k=(0,i.useAPIClient)(),A=(0,p.useTranslation)().t,E=S(m),R=function(e){if(Array.isArray(e))return e}(t=(0,u.useState)([]))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||g(t,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],T=R[1],F=(0,i.useRequest)({resource:"roles.desktopRoutes",resourceOf:v.name,action:"list",params:{paginate:!1,filter:{hidden:{$ne:!0}}}},{ready:!!v&&n,refreshDeps:[null==v?void 0:v.name],onSuccess:function(e){var t;T((null==e||null==(t=e.data)?void 0:t.map(function(e){return e.id}))||[])}}),_=F.loading,q=F.refresh,M=k.resource("roles.desktopRoutes",v.name),N=E.length===I.length,D=(0,i.useAllAccessDesktopRoutes)().refresh,B=(0,a.useMemoizedFn)(function(e){return y(function(){return x(this,function(t){switch(t.label){case 0:return[4,k.resource("roles").update({filterByTk:v.name,values:e.values})];case 1:return t.sent(),w(b({},v,e.values)),c.message.success(A("Saved successfully")),[2]}})})()}),L=(0,u.useMemo)(function(){return(0,r.createForm)({values:v,effects:function(){(0,r.onFormValuesChange)(function(e){return y(function(){return x(this,function(t){switch(t.label){case 0:return[4,B(e)];case 1:return t.sent(),[2]}})})()})}})},[v,B]),$=(0,i.useCompile)();return s().createElement(s().Fragment,null,s().createElement(i.SchemaComponent,{schema:{type:"void",name:(0,o.uid)(),"x-component":"FormV2","x-component-props":{form:L},properties:{allowNewMenu:{title:A("Route permissions"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":A("New routes are allowed to be accessed by default")}}}}),s().createElement(c.Table,{className:P,loading:_,rowKey:"id",pagination:!1,expandable:{defaultExpandAllRows:!1},columns:[{dataIndex:"title",title:A("Route name")},{dataIndex:"accessible",title:s().createElement(s().Fragment,null,s().createElement(c.Checkbox,{checked:N,onChange:function(e){return y(function(){return x(this,function(e){switch(e.label){case 0:if(!N)return[3,2];return[4,M.set({values:[]})];case 1:return e.sent(),[3,4];case 2:return[4,M.set({values:E})];case 3:e.sent(),e.label=4;case 4:return q(),D(),c.message.success(A("Saved successfully")),[2]}})})()}})," ",A("Accessible")),render:function(e,t){var n=I.includes(t.id);return s().createElement(c.Checkbox,{checked:n,onChange:function(){return y(function(){var e,r,o,i,a,u,s,p;return x(this,function(f){switch(f.label){case 0:if(!n)return[3,2];return e=I.filter(function(e){return e!==t.id}),r=[t.id],t.parent&&0===t.parent.children.filter(function(t){return e.includes(t.id)}).length&&(e=e.filter(function(e){return e!==t.parent.id}),r.push(t.parent.id)),t.children&&(e=e.filter(function(e){return!S(t.children).includes(e)}),(o=r).push.apply(o,h(S(t.children)))),T(e),[4,M.remove({values:r})];case 1:return f.sent(),[3,4];case 2:return i=h(I).concat([t.id]),a=[t.id],t.parent&&!i.includes(t.parent.id)&&(i.push(t.parent.id),a.push(t.parent.id)),t.children&&(p=S(t.children),(u=i).push.apply(u,h(p)),(s=a).push.apply(s,h(p))),T((0,l.uniq)(i)),[4,M.add({values:a})];case 3:f.sent(),f.label=4;case 4:return D(),c.message.success(A("Saved successfully")),[2]}})})()}})}}],dataSource:C(m,A,$)}))}},747:function(e,t,n){n.r(t),n.d(t,{PluginACLClient:function(){return V},default:function(){return K},RoleResourceCollectionContext:function(){return F},RolesManagerContext:function(){return _.s}});var r=n(342),o=n(155),i=n.n(o),a=n(365),c=(0,r.lazy)(function(){return n.e("971").then(n.bind(n,486))},"GeneralPermissions").GeneralPermissions,l=(0,r.lazy)(function(){return Promise.resolve().then(n.bind(n,365))},"MenuPermissions").MenuPermissions,u=function(){var e;function t(){var e,n;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");e="permissionsTabs",n=[function(e){var t=e.t,n=e.TabLayout;return{key:"general",label:t("System"),sort:10,children:i().createElement(n,null,i().createElement(c,null))}},function(e){var t=e.activeKey,n=e.t,r=e.TabLayout;return{key:"menu",label:n("Desktop routes"),sort:20,children:i().createElement(r,null,i().createElement(a.DesktopAllRoutesProvider,{active:"menu"===t},i().createElement(l,{active:"menu"===t})))}}],e in this?Object.defineProperty(this,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):this[e]=n}return e=[{key:"addPermissionsTab",value:function(e){this.permissionsTabs.push(e)}},{key:"getPermissionsTabs",value:function(e){return this.permissionsTabs.map(function(t){return"function"==typeof t?t(e):t}).sort(function(e,t){var n,r;return(null!=(n=null==e?void 0:e.sort)?n:100)-(null!=(r=null==t?void 0:t.sort)?r:100)})}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,e),t}(),s=n(768),p=function(){var e;function t(){var e,n;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");e="rolesManager",n=new s.Registry,e in this?Object.defineProperty(this,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):this[e]=n}return e=[{key:"add",value:function(e,t){this.rolesManager.register(e,t)}},{key:"list",value:function(){return this.rolesManager.getEntities()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,e),t}(),f=n(953),m=n(59),d=n(773),y=n.n(d);function b(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}var v=function(){var e,t=(0,f.useTranslation)().t,n=(0,r.useAPIClient)(),o=y().cloneDeep((0,r.useCurrentRoles)()),a=(0,r.useCurrentRoleMode)(),c=null==(e=o.find(function(e){return e.name===n.auth.role}))?void 0:e.name;return("allow-use-union"===a&&o.unshift({name:"__union__",title:t("Full permissions",{ns:"acl"})}),o.length<=1||"only-use-union"===a)?null:i().createElement(r.SchemaSettingsItem,{eventKey:"SwitchRole",title:"SwitchRole"},i().createElement(r.SelectWithTitle,{title:t("Switch role"),fieldNames:{label:"title",value:"name"},options:o.reduce(function(e,t){return e.push(t),"__union__"===t.name&&e.push({name:"divider",title:i().createElement(m.Divider,{style:{margin:"2px 1px"}}),disabled:!0,style:{minHeight:0,height:"auto",padding:0}}),e},[]),defaultValue:c||o[0].name,onChange:function(e){var t;return(t=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:return n.auth.setRole(e),[4,n.resource("users").setDefaultRole({values:{roleName:e}})];case 1:return t.sent(),location.reload(),window.location.reload(),[2]}})},function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(e){b(i,r,o,a,c,"next",e)}function c(e){b(i,r,o,a,c,"throw",e)}a(void 0)})})()}}))},h=n(418),g=n(230),x=n(570),w=n(452),O={name:"rolesResourcesScopes",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Scope name")}}',type:"string","x-component":"Input",required:!0}}]},S={type:"object",properties:{scope:{"x-component":"RecordPicker","x-component-props":{size:"small",fieldNames:{label:"name",value:"id"},multiple:!1,association:{target:"rolesResourcesScopes"},onChange:"{{ onChange }}"},properties:{selector:{type:"void",title:'{{ t("Select record") }}',"x-component":"RecordPicker.Selector","x-component-props":{className:"nb-record-picker-selector"},properties:{tableBlock:{type:"void","x-decorator":"TableSelectorProvider","x-decorator-props":{collection:O,resource:"rolesResourcesScopes",action:"list",params:{pageSize:20},useParams:function(){return{filter:{$or:[{resourceName:(0,o.useContext)(F).name},{resourceName:null}]}}},rowKey:"id"},"x-component":"BlockItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{create:{type:"void",title:'{{ t("Add new") }}',"x-action":"create","x-component":"Action","x-component-props":{icon:"PlusOutlined",openMode:"drawer",type:"primary"},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"rolesResourcesScopes",collection:O},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":function(){var e=(0,o.useContext)(F).name,t=(0,r.useFormBlockContext)();return(0,o.useEffect)(function(){t.form.setInitialValues({resourceName:e})},[e]),{form:t.form}},properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":"Filter","x-use-component-props":function(){var e=(0,o.useContext)(F);return{options:(0,r.useFilterOptions)(e.name)}},"x-component-props":{dynamicComponent:r.VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{create:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}}}},value:{type:"array","x-component":"TableV2.Selector","x-use-component-props":"useTableSelectorProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-component":"TableV2.Column",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{edit:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"rolesResourcesScopes",collection:O,action:"get",useParams:"{{ useParamsFromRecord }}"},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":"Filter","x-use-component-props":function(){var e=(0,o.useContext)(F);return{options:(0,r.useFilterOptions)(e.name)}},"x-component-props":{dynamicComponent:r.VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{update:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}},destroy:{title:'{{ t("Delete") }}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}},footer:{"x-component":"Action.Container.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"usePickActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}};function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var C=(0,o.createContext)(null);C.displayName="RolesResourcesScopesSelectedRowKeysContext";var j=function(e){var t,n=function(e){if(Array.isArray(e))return e}(t=(0,o.useState)([]))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||function(e){if(e){if("string"==typeof e)return P(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return P(e,2)}}(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.")}(),r=n[0],a=n[1];return i().createElement(C.Provider,{value:[r,a]},e.children)},k=function(e){var t=(0,o.useMemo)(function(){return(0,w.createForm)({values:{scope:e.value}})},[]);return i().createElement(r.FormProvider,{form:t},i().createElement(r.SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider:j},scope:{onChange:function(t){var n;null==e||null==(n=e.onChange)||n.call(e,t)}},schema:S}))},A=n(143);function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function R(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function I(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var T=function(e){var t,n={};return null==e||null==(t=e.forEach)||t.call(e,function(e){e.name&&(n[e.name]=e,n[e.name].scope=(0,d.isEmpty)(e.scope)?null:e.scope)}),n},F=(0,o.createContext)({});F.displayName="RoleResourceCollectionContext",(0,g.connect)(function(e){var t,n=(0,A.I)().styles,o=function(t){var n=t.map(function(e){return I(R({},e),{scope:(0,d.isEmpty)(e.scope)?null:e.scope})});e.onChange(n)};(0,g.useForm)();var a=(0,r.useRecord)(),c=(0,x.K)(),l=(0,r.useCollectionManager_deprecated)(),u=l.getCollection,s=l.getCollectionFields,p=u(a.collectionName),y=s(a.collectionName),b=(0,r.useCompile)(),v=(0,f.useTranslation)().t,w=T((0,g.useField)().value||[]),O=function(e,t){var n,r=null==w?void 0:w[e];return!!r&&(null==r||null==(n=r.fields)?void 0:n.includes(t))},S=c.filter(function(e){return e.allowConfigureFields}),P=null==y||null==(D=y.filter(function(e){return e.interface}))?void 0:D.map(function(e){var t=R({},e),n=!0,r=!1,o=void 0;try{for(var i,a=S[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var c=i.value;t[c.name]=O(c.name,e.name)}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return t}),C=function(e){if(w[e])delete w[e];else{var t,n;w[e]={name:e,fields:null==y||null==(n=y.filter(function(e){return e.interface}))||null==(t=n.map)?void 0:t.call(n,function(e){return e.name})}}o(Object.values(w))},j=function(e,t){w[e]?(w[e].scope=t,o(Object.values(w))):(C(e),w[e].scope=t)},_={},q=!0,M=!1,N=void 0;try{for(var D,B,L=S[Symbol.iterator]();!(q=(B=L.next()).done);q=!0){var $,z,V,K=B.value;_[K.name]=(null==y||null==($=y.filter(function(e){return e.interface}))?void 0:$.length)===(null==w||null==(V=w[K.name])||null==(z=V.fields)?void 0:z.length)}}catch(e){M=!0,N=e}finally{try{q||null==L.return||L.return()}finally{if(M)throw N}}return i().createElement("div",null,i().createElement(F.Provider,{value:p},i().createElement(h.FormLayout,{layout:"vertical"},i().createElement(h.FormItem,{label:v("Action permission")},i().createElement(m.Table,{className:n,size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:v("Action display name"),render:function(e){return b(e)}},{dataIndex:"onNewRecord",title:v("Action type"),render:function(e){return e?i().createElement(m.Tag,{color:"green"},v("Action on new records")):i().createElement(m.Tag,{color:"geekblue"},v("Action on existing records"))}},{dataIndex:"enabled",title:v("Allow"),render:function(e,t){return i().createElement(m.Checkbox,{checked:e,onChange:function(){C(t.name)}})}},{dataIndex:"scope",title:v("Data scope"),render:function(e,t){return!t.onNewRecord&&i().createElement(k,{value:e,onChange:function(e){j(t.name,e)}})}}],dataSource:null==c?void 0:c.map(function(e){var t=!1,n=null;return w[e.name]&&(t=!0,e.onNewRecord||(n=w[e.name].scope)),I(R({},e),{enabled:t,scope:n})})})),i().createElement(h.FormItem,{label:v("Field permission")},i().createElement(m.Table,{className:n,pagination:!1,dataSource:P,columns:[{dataIndex:["uiSchema","title"],title:v("Field display name"),render:function(e){return b(e)}}].concat(function(e){if(Array.isArray(e))return E(e)}(t=S.map(function(e){var t=null==_?void 0:_[e.name];return{dataIndex:e.name,title:i().createElement(i().Fragment,null,i().createElement(m.Checkbox,{checked:t,onChange:function(){var n,r=w[e.name]||{name:e.name};t?r.fields=[]:r.fields=null==y||null==(n=y.map)?void 0:n.call(y,function(e){return e.name}),w[e.name]=r,o(Object.values(w))}})," ",b(e.displayName)),render:function(t,n){return i().createElement(m.Checkbox,{checked:t,"aria-label":"".concat(e.name,"_checkbox"),onChange:function(){var r=w[e.name]||{name:e.name},i=r.fields||[];if(t){var a=i.indexOf(n.name);i.splice(a,1)}else i.push(n.name);r.fields=i,w[e.name]=r,o(Object.values(w))}})}}}))||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e){if(e){if("string"==typeof e)return E(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return E(e,void 0)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())})))))});var _=n(268);function q(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function M(e,t,n){return(M=$()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&B(o,n.prototype),o}).apply(null,arguments)}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function D(e){return(D=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function B(e,t){return(B=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function L(e){var t="function"==typeof Map?new Map:void 0;return(L=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 M(e,arguments,D(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),B(n,e)})(e)}function $(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return($=function(){return!!e})()}var z=(0,r.lazy)(function(){return n.e("949").then(n.bind(n,916))},"RolesManagement").RolesManagement,V=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,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=D(t),N(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,$()?Reflect.construct(t,r||[],D(this).constructor):t.apply(this,r)),"rolesManager",new p),N(e,"settingsUI",new u),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&B(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return this.pluginSettingsManager.add("users-permissions.roles",{title:this.t("Roles & Permissions"),icon:"LockOutlined",Component:z,aclSnippet:"pm.acl.roles",sort:3}),this.app.addUserCenterSettingsItem({name:"divider_switchRole",type:"divider",sort:200}),this.app.addUserCenterSettingsItem({name:"switchRole",Component:v,sort:300}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){q(i,r,o,a,c,"next",e)}function c(e){q(i,r,o,a,c,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(L(r.Plugin)),K=V},143:function(e,t,n){function r(){var e,t,n=(e=["\n .ant-table-cell {\n > .ant-space-horizontal {\n .ant-space-item-split:has(+ .ant-space-item:empty) {\n display: none;\n }\n }\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return r=function(){return n},n}n.d(t,{I:function(){return o}});var o=(0,n(235).createStyles)(function(e){return(0,e.css)(r())})},375:function(e){e.exports=r},418:function(e){e.exports=t},452:function(e){e.exports=i},230:function(e){e.exports=n},166:function(e){e.exports=a},342:function(e){e.exports=u},768:function(e){e.exports=p},625:function(e){e.exports=o},59:function(e){e.exports=l},235:function(e){e.exports=s},773:function(e){e.exports=f},155:function(e){e.exports=c},953:function(t){t.exports=e},378:function(e,t,n){var r="",o="u">typeof document?document.currentScript:null;if(o&&o.src&&(r=o.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!r){var i=window.__webpack_public_path__||"";i&&("/"!==i.charAt(i.length-1)&&(i+="/"),r=i+"static/plugins/@nocobase/plugin-acl/dist/client/")}if(!r){if(!(r=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",c=a.indexOf("/v2/");r=c>=0?a.slice(0,c+1):"/"}r&&(r=r.replace(/\/v2\/?$/,"/")),r||(r="/"),"/"!==r.charAt(r.length-1)&&(r+="/"),r+="static/plugins/@nocobase/plugin-acl/dist/client/"}n.p=r}},v={};function h(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return b[e](n,n.exports,h),n.exports}h.m=b,h.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return h.d(t,{a:t}),t},h.d=function(e,t){for(var n in t)h.o(t,n)&&!h.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},h.f={},h.e=function(e){return Promise.all(Object.keys(h.f).reduce(function(t,n){return h.f[n](e,t),t},[]))},h.u=function(e){return""+({949:"a8ee1085b1883873",971:"d4b1aca44e7fa5bc"})[e]+".js"},h.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),h.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},g={},h.l=function(e,t,n,r){if(g[e])return void g[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),c=0;c<a.length;c++){var l=a[c];if(l.getAttribute("src")==e||l.getAttribute("data-rspack")=="@nocobase/plugin-acl:"+n){o=l;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,h.nc&&o.setAttribute("nonce",h.nc),o.setAttribute("data-rspack","@nocobase/plugin-acl:"+n),o.src=e),g[e]=[t];var u=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=g[e];if(delete g[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(u.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=u.bind(null,o.onerror),o.onload=u.bind(null,o.onload),i&&document.head.appendChild(o)},h.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},h.g.importScripts&&(x=h.g.location+"");var g,x,w=h.g.document;if(!x&&w&&(w.currentScript&&"SCRIPT"===w.currentScript.tagName.toUpperCase()&&(x=w.currentScript.src),!x)){var O=w.getElementsByTagName("script");if(O.length)for(var S=O.length-1;S>-1&&(!x||!/^http(s?):/.test(x));)x=O[S--].src}if(!x)throw Error("Automatic publicPath is not supported in this browser");return h.p=x.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),m={889:0},h.f.j=function(e,t){var n=h.o(m,e)?m[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=m[e]=[t,r]});t.push(n[2]=r);var o=h.p+h.u(e),i=Error();h.l(o,function(t){if(h.o(m,e)&&(0!==(n=m[e])&&(m[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},d=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],c=0;if(o.some(function(e){return 0!==m[e]})){for(n in i)h.o(i,n)&&(h.m[n]=i[n]);a&&a(h)}for(e&&e(t);c<o.length;c++)r=o[c],h.o(m,r)&&m[r]&&m[r][0](),m[r]=0},(y=self.webpackChunk_nocobase_plugin_acl=self.webpackChunk_nocobase_plugin_acl||[]).forEach(d.bind(null,0)),y.push=d.bind(null,y.push.bind(y)),h(378),h(747)}()});
|
package/dist/client-v2/index.js
CHANGED
|
@@ -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("@nocobase/client-v2"),require("@formily/core"),require("react"),require("antd"),require("@formily/react"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-acl",["@nocobase/client-v2","@formily/core","react","antd","@formily/react","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-acl"]=t(require("@nocobase/client-v2"),require("@formily/core"),require("react"),require("antd"),require("@formily/react"),require("@nocobase/flow-engine")):e["@nocobase/plugin-acl"]=t(e["@nocobase/client-v2"],e["@formily/core"],e.react,e.antd,e["@formily/react"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o,i){return function(){"use strict";var c,a,u,l={452:function(e){e.exports=t},230:function(e){e.exports=o},485:function(t){t.exports=e},694:function(e){e.exports=i},59:function(e){e.exports=r},155:function(e){e.exports=n}},f={};function p(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return l[e](n,n.exports,p),n.exports}p.m=l,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.f={},p.e=function(e){return Promise.all(Object.keys(p.f).reduce(function(t,n){return p.f[n](e,t),t},[]))},p.u=function(e){return""+({139:"90be8e43cfaeafd9",193:"9b3f3766358e320c",366:"2d20c90fbb39ce2a",627:"809ab4bace5cbbcf"})[e]+".js"},p.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),p.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s={},p.l=function(e,t,n,r){if(s[e])return void s[e].push(t);if(void 0!==n)for(var o,i,c=document.getElementsByTagName("script"),a=0;a<c.length;a++){var u=c[a];if(u.getAttribute("src")==e||u.getAttribute("data-rspack")=="@nocobase/plugin-acl:"+n){o=u;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,p.nc&&o.setAttribute("nonce",p.nc),o.setAttribute("data-rspack","@nocobase/plugin-acl:"+n),o.src=e),s[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=s[e];if(delete s[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},f=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},p.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},p.g.importScripts&&(d=p.g.location+"");var s,d,b=p.g.document;if(!d&&b&&(b.currentScript&&"SCRIPT"===b.currentScript.tagName.toUpperCase()&&(d=b.currentScript.src),!d)){var h=b.getElementsByTagName("script");if(h.length)for(var v=h.length-1;v>-1&&(!d||!/^http(s?):/.test(d));)d=h[v--].src}if(!d)throw Error("Automatic publicPath is not supported in this browser");p.p=d.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),c={889:0},p.f.j=function(e,t){var n=p.o(c,e)?c[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=c[e]=[t,r]});t.push(n[2]=r);var o=p.p+p.u(e),i=Error();p.l(o,function(t){if(p.o(c,e)&&(0!==(n=c[e])&&(c[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},a=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],u=0;if(o.some(function(e){return 0!==c[e]})){for(n in i)p.o(i,n)&&(p.m[n]=i[n]);a&&a(p)}for(e&&e(t);u<o.length;u++)r=o[u],p.o(c,r)&&c[r]&&c[r][0](),c[r]=0},(u=self.webpackChunk_nocobase_plugin_acl=self.webpackChunk_nocobase_plugin_acl||[]).forEach(a.bind(null,0)),u.push=a.bind(null,u.push.bind(u));var y={},
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("@formily/core"),require("react"),require("antd"),require("@formily/react"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-acl",["@nocobase/client-v2","@formily/core","react","antd","@formily/react","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-acl"]=t(require("@nocobase/client-v2"),require("@formily/core"),require("react"),require("antd"),require("@formily/react"),require("@nocobase/flow-engine")):e["@nocobase/plugin-acl"]=t(e["@nocobase/client-v2"],e["@formily/core"],e.react,e.antd,e["@formily/react"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o,i){return function(){"use strict";var c,a,u,l={452:function(e){e.exports=t},230:function(e){e.exports=o},485:function(t){t.exports=e},694:function(e){e.exports=i},59:function(e){e.exports=r},155:function(e){e.exports=n}},f={};function p(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return l[e](n,n.exports,p),n.exports}p.m=l,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.f={},p.e=function(e){return Promise.all(Object.keys(p.f).reduce(function(t,n){return p.f[n](e,t),t},[]))},p.u=function(e){return""+({139:"90be8e43cfaeafd9",193:"9b3f3766358e320c",366:"2d20c90fbb39ce2a",627:"809ab4bace5cbbcf"})[e]+".js"},p.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),p.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s={},p.l=function(e,t,n,r){if(s[e])return void s[e].push(t);if(void 0!==n)for(var o,i,c=document.getElementsByTagName("script"),a=0;a<c.length;a++){var u=c[a];if(u.getAttribute("src")==e||u.getAttribute("data-rspack")=="@nocobase/plugin-acl:"+n){o=u;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,p.nc&&o.setAttribute("nonce",p.nc),o.setAttribute("data-rspack","@nocobase/plugin-acl:"+n),o.src=e),s[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=s[e];if(delete s[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},f=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},p.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},p.g.importScripts&&(d=p.g.location+"");var s,d,b=p.g.document;if(!d&&b&&(b.currentScript&&"SCRIPT"===b.currentScript.tagName.toUpperCase()&&(d=b.currentScript.src),!d)){var h=b.getElementsByTagName("script");if(h.length)for(var v=h.length-1;v>-1&&(!d||!/^http(s?):/.test(d));)d=h[v--].src}if(!d)throw Error("Automatic publicPath is not supported in this browser");p.p=d.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),c={889:0},p.f.j=function(e,t){var n=p.o(c,e)?c[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=c[e]=[t,r]});t.push(n[2]=r);var o=p.p+p.u(e),i=Error();p.l(o,function(t){if(p.o(c,e)&&(0!==(n=c[e])&&(c[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},a=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],u=0;if(o.some(function(e){return 0!==c[e]})){for(n in i)p.o(i,n)&&(p.m[n]=i[n]);a&&a(p)}for(e&&e(t);u<o.length;u++)r=o[u],p.o(c,r)&&c[r]&&c[r][0](),c[r]=0},(u=self.webpackChunk_nocobase_plugin_acl=self.webpackChunk_nocobase_plugin_acl||[]).forEach(a.bind(null,0)),u.push=a.bind(null,u.push.bind(u));var y={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-acl/dist/client-v2/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var r=window.location.pathname||"/",o=r.indexOf("/v2/");e=o>=0?r.slice(0,o+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-acl/dist/client-v2/"}p.p=e}(),!function(){p.r(y),p.d(y,{default:function(){return a}});var e=p(485);function t(e,t,n,r,o,i,c){try{var a=e[i](c),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function n(e,t,r){return(n=c()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&o(i,n.prototype),i}).apply(null,arguments)}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e){var t="function"==typeof Map?new Map:void 0;return(i=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,i)}function i(){return n(e,arguments,r(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),o(i,e)})(e)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}var a=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return e=i,t=arguments,e=r(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,c()?Reflect.construct(e,t||[],r(this).constructor):e.apply(this,t))}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&o(i,e),n=[{key:"load",value:function(){var e;return(e=function(){var e;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(c,"next",{value:u(0)}),a(c,"throw",{value:u(1)}),a(c,"return",{value:u(2)}),"function"==typeof Symbol&&a(c,Symbol.iterator,{value:function(){return this}}),c;function u(a){return function(u){var l=[a,u];if(n)throw TypeError("Generator is already executing.");for(;c&&(c=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:this.flowEngine.flowSettings.registerComponentLoaders({DemoFlowSettingsLazyField:function(){return p.e("193").then(p.bind(p,296))}}),this.router.add("acl-v2.homepage",{path:"/v2-demo/",componentLoader:function(){return p.e("366").then(p.bind(p,173))}}),this.router.add("acl-v2.app-info",{path:"/v2-demo/app-info",componentLoader:function(){return p.e("627").then(p.bind(p,726))}}),this.router.add("acl-v2.flow-settings-component-loader",{path:"/v2-demo/flow-settings-component-loader",componentLoader:function(){return p.e("139").then(p.bind(p,870))}}),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.app.apiClient.request({url:"app:getInfo"})];case 2:return console.log("[client-v2 demo plugin] /api/app:getInfo",null==(e=t.sent())?void 0:e.data),[3,4];case 3:return console.error("[client-v2 demo plugin] failed to request /api/app:getInfo",t.sent()),[3,4];case 4:return[2]}})},function(){var n=this,r=arguments;return new Promise(function(o,i){var c=e.apply(n,r);function a(e){t(c,o,i,a,u,"next",e)}function u(e){t(c,o,i,a,u,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(i.prototype,n),i}(i(e.Plugin))}(),y}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.1.0-alpha.
|
|
11
|
+
"@nocobase/client": "2.1.0-alpha.15",
|
|
12
12
|
"antd": "5.24.2",
|
|
13
13
|
"react": "18.2.0",
|
|
14
14
|
"react-i18next": "11.18.6",
|
|
@@ -17,16 +17,16 @@ module.exports = {
|
|
|
17
17
|
"@formily/react": "2.3.7",
|
|
18
18
|
"@ant-design/icons": "5.6.1",
|
|
19
19
|
"lodash": "4.17.21",
|
|
20
|
-
"@nocobase/utils": "2.1.0-alpha.
|
|
21
|
-
"@nocobase/client-v2": "2.1.0-alpha.
|
|
22
|
-
"@nocobase/actions": "2.1.0-alpha.
|
|
23
|
-
"@nocobase/cache": "2.1.0-alpha.
|
|
24
|
-
"@nocobase/database": "2.1.0-alpha.
|
|
25
|
-
"@nocobase/server": "2.1.0-alpha.
|
|
26
|
-
"@nocobase/acl": "2.1.0-alpha.
|
|
27
|
-
"@nocobase/test": "2.1.0-alpha.
|
|
20
|
+
"@nocobase/utils": "2.1.0-alpha.15",
|
|
21
|
+
"@nocobase/client-v2": "2.1.0-alpha.15",
|
|
22
|
+
"@nocobase/actions": "2.1.0-alpha.15",
|
|
23
|
+
"@nocobase/cache": "2.1.0-alpha.15",
|
|
24
|
+
"@nocobase/database": "2.1.0-alpha.15",
|
|
25
|
+
"@nocobase/server": "2.1.0-alpha.15",
|
|
26
|
+
"@nocobase/acl": "2.1.0-alpha.15",
|
|
27
|
+
"@nocobase/test": "2.1.0-alpha.15",
|
|
28
28
|
"@formily/core": "2.3.7",
|
|
29
29
|
"@formily/antd-v5": "1.2.3",
|
|
30
30
|
"antd-style": "3.7.1",
|
|
31
|
-
"@nocobase/flow-engine": "2.1.0-alpha.
|
|
31
|
+
"@nocobase/flow-engine": "2.1.0-alpha.15"
|
|
32
32
|
};
|
package/dist/server/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export * from './middlewares/setCurrentRole';
|
|
10
10
|
export * from './middlewares/with-acl-meta';
|
|
11
|
+
export * from './query/apply-query-permission';
|
|
11
12
|
export { RoleResourceActionModel } from './model/RoleResourceActionModel';
|
|
12
13
|
export { RoleResourceModel } from './model/RoleResourceModel';
|
|
13
14
|
export * from './constants';
|
package/dist/server/index.js
CHANGED
|
@@ -44,6 +44,7 @@ __export(server_exports, {
|
|
|
44
44
|
module.exports = __toCommonJS(server_exports);
|
|
45
45
|
__reExport(server_exports, require("./middlewares/setCurrentRole"), module.exports);
|
|
46
46
|
__reExport(server_exports, require("./middlewares/with-acl-meta"), module.exports);
|
|
47
|
+
__reExport(server_exports, require("./query/apply-query-permission"), module.exports);
|
|
47
48
|
var import_RoleResourceActionModel = require("./model/RoleResourceActionModel");
|
|
48
49
|
var import_RoleResourceModel = require("./model/RoleResourceModel");
|
|
49
50
|
__reExport(server_exports, require("./constants"), module.exports);
|
|
@@ -55,6 +56,7 @@ var import_server = __toESM(require("./server"));
|
|
|
55
56
|
RoleResourceModel,
|
|
56
57
|
...require("./middlewares/setCurrentRole"),
|
|
57
58
|
...require("./middlewares/with-acl-meta"),
|
|
59
|
+
...require("./query/apply-query-permission"),
|
|
58
60
|
...require("./constants"),
|
|
59
61
|
...require("./enum")
|
|
60
62
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import type { Next } from '@nocobase/actions';
|
|
10
|
+
export declare function checkQueryPermission(ctx: any, next: Next): Promise<void>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var check_query_permission_exports = {};
|
|
28
|
+
__export(check_query_permission_exports, {
|
|
29
|
+
checkQueryPermission: () => checkQueryPermission
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(check_query_permission_exports);
|
|
32
|
+
var import_acl = require("@nocobase/acl");
|
|
33
|
+
var import_apply_query_permission = require("../query/apply-query-permission");
|
|
34
|
+
async function checkQueryPermission(ctx, next) {
|
|
35
|
+
var _a, _b, _c, _d;
|
|
36
|
+
const query = { ...ctx.action.params.values };
|
|
37
|
+
try {
|
|
38
|
+
const result = await (0, import_apply_query_permission.applyQueryPermission)({
|
|
39
|
+
acl: ctx.acl,
|
|
40
|
+
db: ctx.database,
|
|
41
|
+
resourceName: ctx.action.resourceName,
|
|
42
|
+
query,
|
|
43
|
+
currentUser: (_a = ctx.state) == null ? void 0 : _a.currentUser,
|
|
44
|
+
currentRole: (_b = ctx.state) == null ? void 0 : _b.currentRole,
|
|
45
|
+
currentRoles: (_c = ctx.state) == null ? void 0 : _c.currentRoles,
|
|
46
|
+
timezone: (_d = ctx.get) == null ? void 0 : _d.call(ctx, "x-timezone"),
|
|
47
|
+
state: ctx.state
|
|
48
|
+
});
|
|
49
|
+
ctx.action.params = {
|
|
50
|
+
...ctx.action.params,
|
|
51
|
+
values: result.query
|
|
52
|
+
};
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (error instanceof import_acl.NoPermissionError) {
|
|
55
|
+
ctx.throw(403, "No permissions");
|
|
56
|
+
}
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
await next();
|
|
60
|
+
}
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
checkQueryPermission
|
|
64
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { ACL } from '@nocobase/acl';
|
|
10
|
+
import type { QueryOptions } from '@nocobase/database';
|
|
11
|
+
import { Database } from '@nocobase/database';
|
|
12
|
+
export type QueryPermissionQuery = QueryOptions & Record<string, any>;
|
|
13
|
+
export type ApplyQueryPermissionOptions = {
|
|
14
|
+
acl: ACL;
|
|
15
|
+
db: Database;
|
|
16
|
+
resourceName: string;
|
|
17
|
+
query: QueryPermissionQuery;
|
|
18
|
+
currentUser?: any;
|
|
19
|
+
currentRole?: string;
|
|
20
|
+
currentRoles?: string[];
|
|
21
|
+
timezone?: string;
|
|
22
|
+
state?: any;
|
|
23
|
+
};
|
|
24
|
+
export declare function applyQueryPermission(options: ApplyQueryPermissionOptions): Promise<{
|
|
25
|
+
permission: import("@nocobase/acl").CanResult;
|
|
26
|
+
query: QueryPermissionQuery;
|
|
27
|
+
}>;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var apply_query_permission_exports = {};
|
|
28
|
+
__export(apply_query_permission_exports, {
|
|
29
|
+
applyQueryPermission: () => applyQueryPermission
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(apply_query_permission_exports);
|
|
32
|
+
var import_acl = require("@nocobase/acl");
|
|
33
|
+
var import_utils = require("@nocobase/utils");
|
|
34
|
+
function normalizeFieldPath(field) {
|
|
35
|
+
if (!field) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const parts = Array.isArray(field) ? field : field.split(".");
|
|
39
|
+
const normalized = parts.filter(Boolean);
|
|
40
|
+
return normalized.length ? normalized : null;
|
|
41
|
+
}
|
|
42
|
+
function stringifyFieldPath(field) {
|
|
43
|
+
const path = normalizeFieldPath(field);
|
|
44
|
+
if (!path) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return path.join(".");
|
|
48
|
+
}
|
|
49
|
+
function resolveQueryFieldKey(resourceName, field) {
|
|
50
|
+
const path = normalizeFieldPath(field);
|
|
51
|
+
if (!path) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
if (path.length === 1) {
|
|
55
|
+
return `${resourceName}.${path[0]}`;
|
|
56
|
+
}
|
|
57
|
+
return path.join(".");
|
|
58
|
+
}
|
|
59
|
+
function pruneEmptyArray(items) {
|
|
60
|
+
return items && items.length > 0 ? items : void 0;
|
|
61
|
+
}
|
|
62
|
+
function getRoleNames(options) {
|
|
63
|
+
var _a;
|
|
64
|
+
if ((_a = options.currentRoles) == null ? void 0 : _a.length) {
|
|
65
|
+
return options.currentRoles;
|
|
66
|
+
}
|
|
67
|
+
if (options.currentRole) {
|
|
68
|
+
return [options.currentRole];
|
|
69
|
+
}
|
|
70
|
+
return ["anonymous"];
|
|
71
|
+
}
|
|
72
|
+
function getSelectableFields(permission) {
|
|
73
|
+
var _a, _b;
|
|
74
|
+
const fields = (_a = permission == null ? void 0 : permission.params) == null ? void 0 : _a.fields;
|
|
75
|
+
const appends = (_b = permission == null ? void 0 : permission.params) == null ? void 0 : _b.appends;
|
|
76
|
+
if (fields === void 0 && appends === void 0) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return Array.from(/* @__PURE__ */ new Set([...fields || [], ...appends || []]));
|
|
80
|
+
}
|
|
81
|
+
function isAllowedFieldPath(acl, db, roles, rootCollectionName, field) {
|
|
82
|
+
var _a;
|
|
83
|
+
const fieldPath = normalizeFieldPath(field);
|
|
84
|
+
if (!fieldPath) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
let collectionName = rootCollectionName;
|
|
88
|
+
let permission = acl.can({
|
|
89
|
+
roles,
|
|
90
|
+
resource: collectionName,
|
|
91
|
+
action: "view"
|
|
92
|
+
});
|
|
93
|
+
if (!permission) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
for (let index = 0; index < fieldPath.length; index++) {
|
|
97
|
+
const fieldName = fieldPath[index];
|
|
98
|
+
const field2 = (_a = db.getCollection(collectionName)) == null ? void 0 : _a.getField(fieldName);
|
|
99
|
+
if (!field2) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
const selectableFields = getSelectableFields(permission);
|
|
103
|
+
if (selectableFields && !selectableFields.includes(fieldName)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
if (index === fieldPath.length - 1) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
if (!field2.target) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
collectionName = field2.target;
|
|
113
|
+
permission = acl.can({
|
|
114
|
+
roles,
|
|
115
|
+
resource: collectionName,
|
|
116
|
+
action: "view"
|
|
117
|
+
});
|
|
118
|
+
if (!permission) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
function pruneSelections(items, acl, db, roles, resourceName) {
|
|
125
|
+
return pruneEmptyArray((items || []).filter((item) => isAllowedFieldPath(acl, db, roles, resourceName, item.field)));
|
|
126
|
+
}
|
|
127
|
+
function getAvailableHavingKeys(resourceName, query) {
|
|
128
|
+
const keys = /* @__PURE__ */ new Set();
|
|
129
|
+
for (const item of [...query.measures || [], ...query.dimensions || []]) {
|
|
130
|
+
if (item.alias) {
|
|
131
|
+
keys.add(item.alias);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const fieldPathKey = stringifyFieldPath(item.field);
|
|
135
|
+
if (fieldPathKey) {
|
|
136
|
+
keys.add(fieldPathKey);
|
|
137
|
+
}
|
|
138
|
+
const qualifiedFieldKey = resolveQueryFieldKey(resourceName, item.field);
|
|
139
|
+
if (qualifiedFieldKey) {
|
|
140
|
+
keys.add(qualifiedFieldKey);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return keys;
|
|
144
|
+
}
|
|
145
|
+
function pruneHavingNode(node, availableKeys) {
|
|
146
|
+
if (!(0, import_utils.isPlainObject)(node)) {
|
|
147
|
+
return void 0;
|
|
148
|
+
}
|
|
149
|
+
const result = {};
|
|
150
|
+
for (const [key, value] of Object.entries(node)) {
|
|
151
|
+
if ((key === "$and" || key === "$or") && Array.isArray(value)) {
|
|
152
|
+
const items = value.map((item) => pruneHavingNode(item, availableKeys)).filter((item) => item !== void 0);
|
|
153
|
+
if (items.length > 0) {
|
|
154
|
+
result[key] = items;
|
|
155
|
+
}
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (!availableKeys.has(key)) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
result[key] = value;
|
|
162
|
+
}
|
|
163
|
+
return Object.keys(result).length ? result : void 0;
|
|
164
|
+
}
|
|
165
|
+
async function getParsedPermissionFilter(options, permission) {
|
|
166
|
+
var _a;
|
|
167
|
+
const filterParams = (_a = permission == null ? void 0 : permission.params) == null ? void 0 : _a.filter;
|
|
168
|
+
if (!filterParams) {
|
|
169
|
+
return void 0;
|
|
170
|
+
}
|
|
171
|
+
(0, import_acl.checkFilterParams)(options.db.getCollection(options.resourceName), filterParams);
|
|
172
|
+
return await (0, import_acl.parseJsonTemplate)(filterParams, {
|
|
173
|
+
state: options.state,
|
|
174
|
+
timezone: options.timezone,
|
|
175
|
+
userProvider: (0, import_acl.createUserProvider)({
|
|
176
|
+
db: options.db,
|
|
177
|
+
currentUser: options.currentUser
|
|
178
|
+
})
|
|
179
|
+
}) ?? filterParams;
|
|
180
|
+
}
|
|
181
|
+
async function applyQueryPermission(options) {
|
|
182
|
+
var _a, _b, _c, _d, _e, _f;
|
|
183
|
+
const { acl, db, resourceName, query: sourceQuery, currentUser, state, timezone } = options;
|
|
184
|
+
const roles = getRoleNames(options);
|
|
185
|
+
const rootPermission = acl.can({
|
|
186
|
+
roles,
|
|
187
|
+
resource: resourceName,
|
|
188
|
+
action: "view"
|
|
189
|
+
});
|
|
190
|
+
if (!rootPermission) {
|
|
191
|
+
throw new import_acl.NoPermissionError(`No permission for resource: ${resourceName}`);
|
|
192
|
+
}
|
|
193
|
+
const query = {
|
|
194
|
+
...sourceQuery,
|
|
195
|
+
measures: pruneSelections(sourceQuery.measures, acl, db, roles, resourceName),
|
|
196
|
+
dimensions: pruneSelections(sourceQuery.dimensions, acl, db, roles, resourceName),
|
|
197
|
+
orders: pruneSelections(sourceQuery.orders, acl, db, roles, resourceName)
|
|
198
|
+
};
|
|
199
|
+
const availableHavingKeys = getAvailableHavingKeys(resourceName, query);
|
|
200
|
+
query.having = pruneHavingNode(query.having, availableHavingKeys);
|
|
201
|
+
const aclFilter = await getParsedPermissionFilter(
|
|
202
|
+
{
|
|
203
|
+
...options,
|
|
204
|
+
acl,
|
|
205
|
+
db,
|
|
206
|
+
resourceName,
|
|
207
|
+
query,
|
|
208
|
+
currentUser,
|
|
209
|
+
state,
|
|
210
|
+
timezone
|
|
211
|
+
},
|
|
212
|
+
rootPermission
|
|
213
|
+
);
|
|
214
|
+
if (aclFilter) {
|
|
215
|
+
query.filter = (0, import_utils.assign)(query.filter || {}, aclFilter, {
|
|
216
|
+
filter: "andMerge"
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
const hasSelection = (((_a = options.query.measures) == null ? void 0 : _a.length) || 0) > 0 || (((_b = options.query.dimensions) == null ? void 0 : _b.length) || 0) > 0 || (((_c = options.query.orders) == null ? void 0 : _c.length) || 0) > 0;
|
|
220
|
+
const hasRemainingSelection = (((_d = query.measures) == null ? void 0 : _d.length) || 0) > 0 || (((_e = query.dimensions) == null ? void 0 : _e.length) || 0) > 0 || (((_f = query.orders) == null ? void 0 : _f.length) || 0) > 0;
|
|
221
|
+
if (hasSelection && !hasRemainingSelection) {
|
|
222
|
+
throw new import_acl.NoPermissionError(`No permission for query fields: ${options.resourceName}`);
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
permission: rootPermission,
|
|
226
|
+
query
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
230
|
+
0 && (module.exports = {
|
|
231
|
+
applyQueryPermission
|
|
232
|
+
});
|
package/dist/server/server.js
CHANGED
|
@@ -57,6 +57,7 @@ var import_RoleResourceModel = require("./model/RoleResourceModel");
|
|
|
57
57
|
var import_union_role = require("./actions/union-role");
|
|
58
58
|
var import_check_association_operate = require("./middlewares/check-association-operate");
|
|
59
59
|
var import_check_change_with_association = require("./middlewares/check-change-with-association");
|
|
60
|
+
var import_check_query_permission = require("./middlewares/check-query-permission");
|
|
60
61
|
class PluginACLServer extends import_server.Plugin {
|
|
61
62
|
get acl() {
|
|
62
63
|
return this.app.acl;
|
|
@@ -583,6 +584,7 @@ class PluginACLServer extends import_server.Plugin {
|
|
|
583
584
|
before: "core"
|
|
584
585
|
});
|
|
585
586
|
if (dataSource.options.acl !== false && dataSource.options.useACL !== false) {
|
|
587
|
+
dataSource.resourceManager.registerPreActionHandler("query", import_check_query_permission.checkQueryPermission);
|
|
586
588
|
dataSource.resourceManager.registerPreActionHandler("create", import_check_change_with_association.checkChangesWithAssociation);
|
|
587
589
|
dataSource.resourceManager.registerPreActionHandler("firstOrCreate", import_check_change_with_association.checkChangesWithAssociation);
|
|
588
590
|
dataSource.resourceManager.registerPreActionHandler("updateOrCreate", import_check_change_with_association.checkChangesWithAssociation);
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "Based on roles, resources, and actions, access control can precisely manage interface configuration permissions, data operation permissions, menu access permissions, and plugin permissions.",
|
|
7
7
|
"description.ru-RU": "На основе ролей, ресурсов и действий система контроля доступа может точно управлять разрешениями на изменение интерфейса, работу с данными, доступ к меню и разрешениями для подключаемых модулей.",
|
|
8
8
|
"description.zh-CN": "基于角色、资源和操作的权限控制,可以精确控制界面配置权限、数据操作权限、菜单访问权限、插件权限。",
|
|
9
|
-
"version": "2.1.0-alpha.
|
|
9
|
+
"version": "2.1.0-alpha.15",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"main": "./dist/server/index.js",
|
|
12
12
|
"homepage": "https://docs.nocobase.com/handbook/acl",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
47
47
|
"directory": "packages/plugins/acl"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "7c86e75b0af4b9f532c8ebf5ef96a7423b0ab60e"
|
|
50
50
|
}
|