@tachybase/module-acl 0.23.8

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.
Files changed (75) hide show
  1. package/.turbo/turbo-build.log +14 -0
  2. package/LICENSE +201 -0
  3. package/README.md +11 -0
  4. package/README.zh-CN.md +11 -0
  5. package/client.d.ts +2 -0
  6. package/client.js +1 -0
  7. package/dist/client/NewRole.d.ts +2 -0
  8. package/dist/client/RolesManagement.d.ts +2 -0
  9. package/dist/client/RolesManagerProvider.d.ts +4 -0
  10. package/dist/client/RolesMenu.d.ts +7 -0
  11. package/dist/client/hooks/load-more-observer.d.ts +7 -0
  12. package/dist/client/index.d.ts +8 -0
  13. package/dist/client/index.js +9 -0
  14. package/dist/client/locale.d.ts +1 -0
  15. package/dist/client/permissions/ActionPermissions.d.ts +4 -0
  16. package/dist/client/permissions/AvailableActions.d.ts +3 -0
  17. package/dist/client/permissions/GeneralPermissions.d.ts +4 -0
  18. package/dist/client/permissions/MenuItemsProvider.d.ts +4 -0
  19. package/dist/client/permissions/MenuPermissions.d.ts +4 -0
  20. package/dist/client/permissions/Permissions.d.ts +4 -0
  21. package/dist/client/permissions/PluginPermissions.d.ts +4 -0
  22. package/dist/client/permissions/RolesResourcesActions.d.ts +3 -0
  23. package/dist/client/permissions/ScopeSelect.d.ts +3 -0
  24. package/dist/client/permissions/StrategyActions.d.ts +2 -0
  25. package/dist/client/permissions/style.d.ts +1 -0
  26. package/dist/client/roles-manager.d.ts +10 -0
  27. package/dist/client/schemas/roles.d.ts +55 -0
  28. package/dist/client/schemas/scopes.d.ts +11 -0
  29. package/dist/externalVersion.js +19 -0
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.js +39 -0
  32. package/dist/locale/en-US.json +6 -0
  33. package/dist/locale/ko_KR.json +4 -0
  34. package/dist/locale/zh-CN.json +11 -0
  35. package/dist/server/actions/available-actions.d.ts +7 -0
  36. package/dist/server/actions/available-actions.js +42 -0
  37. package/dist/server/actions/role-check.d.ts +1 -0
  38. package/dist/server/actions/role-check.js +67 -0
  39. package/dist/server/actions/role-collections.d.ts +7 -0
  40. package/dist/server/actions/role-collections.js +75 -0
  41. package/dist/server/actions/user-setDefaultRole.d.ts +2 -0
  42. package/dist/server/actions/user-setDefaultRole.js +65 -0
  43. package/dist/server/collections/roles-users.d.ts +2 -0
  44. package/dist/server/collections/roles-users.js +30 -0
  45. package/dist/server/collections/roles.d.ts +2 -0
  46. package/dist/server/collections/roles.js +119 -0
  47. package/dist/server/collections/rolesResources.d.ts +2 -0
  48. package/dist/server/collections/rolesResources.js +55 -0
  49. package/dist/server/collections/rolesResourcesActions.d.ts +2 -0
  50. package/dist/server/collections/rolesResourcesActions.js +51 -0
  51. package/dist/server/collections/rolesResourcesScopes.d.ts +2 -0
  52. package/dist/server/collections/rolesResourcesScopes.js +45 -0
  53. package/dist/server/collections/users.d.ts +2 -0
  54. package/dist/server/collections/users.js +52 -0
  55. package/dist/server/index.d.ts +6 -0
  56. package/dist/server/index.js +50 -0
  57. package/dist/server/middlewares/setCurrentRole.d.ts +2 -0
  58. package/dist/server/middlewares/setCurrentRole.js +74 -0
  59. package/dist/server/middlewares/with-acl-meta.d.ts +2 -0
  60. package/dist/server/middlewares/with-acl-meta.js +242 -0
  61. package/dist/server/migrations/20221214072638-set-role-snippets.d.ts +6 -0
  62. package/dist/server/migrations/20221214072638-set-role-snippets.js +43 -0
  63. package/dist/server/model/RoleModel.d.ts +8 -0
  64. package/dist/server/model/RoleModel.js +46 -0
  65. package/dist/server/model/RoleResourceActionModel.d.ts +12 -0
  66. package/dist/server/model/RoleResourceActionModel.js +85 -0
  67. package/dist/server/model/RoleResourceModel.d.ts +18 -0
  68. package/dist/server/model/RoleResourceModel.js +79 -0
  69. package/dist/server/server.d.ts +34 -0
  70. package/dist/server/server.js +648 -0
  71. package/dist/swagger/index.d.ts +366 -0
  72. package/dist/swagger/index.js +395 -0
  73. package/package.json +40 -0
  74. package/server.d.ts +3 -0
  75. package/server.js +1 -0
@@ -0,0 +1,14 @@
1
+
2
+ 
3
+ > @tachybase/module-acl@0.23.2 build /Users/seal/Documents/projects/tachybase/packages/module-acl
4
+ > tachybase-build --no-dts @tachybase/module-acl
5
+
6
+ The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
7
+ @tachybase/module-acl: module-acl build start
8
+ @tachybase/module-acl: build plugin client
9
+ @tachybase/module-acl: build plugin server source
10
+ @tachybase/module-acl: delete server files
11
+ @tachybase/module-acl: build plugin server dependencies
12
+ @tachybase/module-acl: These packages @tachybase/actions, @tachybase/cache, @tachybase/database, @tachybase/server, async-mutex, lodash, @tachybase/acl will be exclude.
13
+ @tachybase/module-acl: write external version
14
+
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2023-2024] [Tachybase team]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # acl
2
+
3
+ English | [中文](./README.zh-CN.md)
4
+
5
+ 基于角色的权限控制插件。
6
+
7
+ ## 安装激活
8
+
9
+ 内置插件无需手动安装激活。
10
+
11
+ ## 使用方法
@@ -0,0 +1,11 @@
1
+ # acl
2
+
3
+ [English](./README.md) | 中文
4
+
5
+ 基于角色的权限控制插件。
6
+
7
+ ## 安装激活
8
+
9
+ 内置插件无需手动安装激活。
10
+
11
+ ## 使用方法
package/client.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/client';
2
+ export { default } from './dist/client';
package/client.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client/index.js');
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const NewRole: React.FC;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const RolesManagement: React.FC;
@@ -0,0 +1,4 @@
1
+ export declare const RolesManagerContext: import("react").Context<{
2
+ role: any;
3
+ setRole: (role: any) => void;
4
+ }>;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export declare const RolesMenu: React.FC & {
3
+ Item: React.FC<{
4
+ item: any;
5
+ onEdit: () => void;
6
+ }>;
7
+ };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export declare const useLoadMoreObserver: ({ loadMore, }: {
3
+ loadMore: () => void;
4
+ }) => {
5
+ lastItem: React.RefObject<any>;
6
+ setLastItem: React.Dispatch<React.SetStateAction<React.RefObject<any>>>;
7
+ };
@@ -0,0 +1,8 @@
1
+ import { Plugin } from '@tachybase/client';
2
+ import { RolesManager } from './roles-manager';
3
+ export declare class PluginACLClient extends Plugin {
4
+ rolesManager: RolesManager;
5
+ load(): Promise<void>;
6
+ }
7
+ export { RolesManagerContext } from './RolesManagerProvider';
8
+ export default PluginACLClient;
@@ -0,0 +1,9 @@
1
+ (function(v,c){typeof exports=="object"&&typeof module!="undefined"?c(exports,require("@tachybase/client"),require("@tachybase/utils/client"),require("react/jsx-runtime"),require("react"),require("@tachybase/schema"),require("antd"),require("react-i18next"),require("ahooks"),require("lodash"),require("@ant-design/icons")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/utils/client","react/jsx-runtime","react","@tachybase/schema","antd","react-i18next","ahooks","lodash","@ant-design/icons"],c):(v=typeof globalThis!="undefined"?globalThis:v||self,c(v["@tachybase/module-acl"]={},v["@tachybase/client"],v["@tachybase/utils"],v.jsxRuntime,v.react,v["@tachybase/schema"],v.antd,v["react-i18next"],v.ahooks,v.lodash,v["@ant-design/icons"]))})(this,function(v,c,C,s,h,S,p,M,T,N,fe){"use strict";var wi=Object.defineProperty,Ai=Object.defineProperties;var Pi=Object.getOwnPropertyDescriptors;var Qe=Object.getOwnPropertySymbols;var Ii=Object.prototype.hasOwnProperty,Ti=Object.prototype.propertyIsEnumerable;var de=(v,c,C)=>c in v?wi(v,c,{enumerable:!0,configurable:!0,writable:!0,value:C}):v[c]=C,I=(v,c)=>{for(var C in c||(c={}))Ii.call(c,C)&&de(v,C,c[C]);if(Qe)for(var C of Qe(c))Ti.call(c,C)&&de(v,C,c[C]);return v},k=(v,c)=>Ai(v,Pi(c));var he=(v,c,C)=>de(v,typeof c!="symbol"?c+"":c,C);var A=(v,c,C)=>new Promise((s,h)=>{var S=T=>{try{M(C.next(T))}catch(N){h(N)}},p=T=>{try{M(C.throw(T))}catch(N){h(N)}},M=T=>T.done?s(T.value):Promise.resolve(T.value).then(S,p);M((C=C.apply(v,c)).next())});class Re{constructor(){he(this,"rolesManager",new C.Registry)}add(t,r){this.rolesManager.register(t,r)}list(){return this.rolesManager.getEntities()}}function H(){return M.useTranslation(["@tachybase/module-acl","core"],{nsMode:"fallback"})}const et=()=>{const{t:e}=H();return s.jsx(c.SchemaComponent,{scope:{t:e},schema:{type:"void",properties:{newRole:{type:"void",title:e("New role"),"x-component":"Action","x-component-props":{type:"text",icon:"PlusOutlined",style:{width:"100%",textAlign:"left"}},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(t){const r=c.useActionContext();return c.useRequest(()=>Promise.resolve({data:{name:`r_${S.uid()}`,snippets:["!ui.*","!pm","!pm.*"]}}),k(I({},t),{refreshDeps:[r.visible]}))}},title:e("New role"),properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'},default:{"x-component":"CollectionField","x-decorator":"FormItem",title:"","x-content":'{{t("Default role")}}'},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}}})},D=h.createContext({role:null});D.displayName="RolesManagerContext";const R=h.createContext([]);R.displayName="AvailableActionsContext";const tt=e=>{const{data:t,loading:r}=c.useRequest({resource:"availableActions",action:"list"});return r?s.jsx(p.Spin,{}):s.jsx(R.Provider,{value:t==null?void 0:t.data,children:e.children})},rt=()=>h.useContext(R);var K=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ve(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var nt=typeof K=="object"&&K&&K.Object===Object&&K,at=nt,st=at,ot=typeof self=="object"&&self&&self.Object===Object&&self,it=st||ot||Function("return this")(),L=it,ct=L,lt=ct.Symbol,V=lt,ge=V,me=Object.prototype,ut=me.hasOwnProperty,pt=me.toString,z=ge?ge.toStringTag:void 0;function dt(e){var t=ut.call(e,z),r=e[z];try{e[z]=void 0;var n=!0}catch(i){}var a=pt.call(e);return n&&(t?e[z]=r:delete e[z]),a}var ht=dt,ft=Object.prototype,vt=ft.toString;function gt(e){return vt.call(e)}var mt=gt,ye=V,yt=ht,bt=mt,_t="[object Null]",Ct="[object Undefined]",be=ye?ye.toStringTag:void 0;function xt(e){return e==null?e===void 0?Ct:_t:be&&be in Object(e)?yt(e):bt(e)}var ee=xt;function St(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var te=St,$t=ee,wt=te,At="[object AsyncFunction]",Pt="[object Function]",It="[object GeneratorFunction]",Tt="[object Proxy]";function Ot(e){if(!wt(e))return!1;var t=$t(e);return t==Pt||t==It||t==At||t==Tt}var Mt=Ot,Ft=L,Et=Ft["__core-js_shared__"],Dt=Et,re=Dt,_e=function(){var e=/[^.]+$/.exec(re&&re.keys&&re.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Nt(e){return!!_e&&_e in e}var kt=Nt,Ht=Function.prototype,jt=Ht.toString;function qt(e){if(e!=null){try{return jt.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var Gt=qt,zt=Mt,Ut=kt,Kt=te,Lt=Gt,Vt=/[\\^$.*+?()[\]{}|]/g,Wt=/^\[object .+?Constructor\]$/,Bt=Function.prototype,Yt=Object.prototype,Xt=Bt.toString,Jt=Yt.hasOwnProperty,Zt=RegExp("^"+Xt.call(Jt).replace(Vt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Qt(e){if(!Kt(e)||Ut(e))return!1;var t=zt(e)?Zt:Wt;return t.test(Lt(e))}var Rt=Qt;function er(e,t){return e==null?void 0:e[t]}var tr=er,rr=Rt,nr=tr;function ar(e,t){var r=nr(e,t);return rr(r)?r:void 0}var W=ar,sr=W,or=sr(Object,"create"),B=or,Ce=B;function ir(){this.__data__=Ce?Ce(null):{},this.size=0}var cr=ir;function lr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var ur=lr,pr=B,dr="__lodash_hash_undefined__",hr=Object.prototype,fr=hr.hasOwnProperty;function vr(e){var t=this.__data__;if(pr){var r=t[e];return r===dr?void 0:r}return fr.call(t,e)?t[e]:void 0}var gr=vr,mr=B,yr=Object.prototype,br=yr.hasOwnProperty;function _r(e){var t=this.__data__;return mr?t[e]!==void 0:br.call(t,e)}var Cr=_r,xr=B,Sr="__lodash_hash_undefined__";function $r(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=xr&&t===void 0?Sr:t,this}var wr=$r,Ar=cr,Pr=ur,Ir=gr,Tr=Cr,Or=wr;function j(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}j.prototype.clear=Ar,j.prototype.delete=Pr,j.prototype.get=Ir,j.prototype.has=Tr,j.prototype.set=Or;var Mr=j;function Fr(){this.__data__=[],this.size=0}var Er=Fr;function Dr(e,t){return e===t||e!==e&&t!==t}var xe=Dr,Nr=xe;function kr(e,t){for(var r=e.length;r--;)if(Nr(e[r][0],t))return r;return-1}var Y=kr,Hr=Y,jr=Array.prototype,qr=jr.splice;function Gr(e){var t=this.__data__,r=Hr(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():qr.call(t,r,1),--this.size,!0}var zr=Gr,Ur=Y;function Kr(e){var t=this.__data__,r=Ur(t,e);return r<0?void 0:t[r][1]}var Lr=Kr,Vr=Y;function Wr(e){return Vr(this.__data__,e)>-1}var Br=Wr,Yr=Y;function Xr(e,t){var r=this.__data__,n=Yr(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var Jr=Xr,Zr=Er,Qr=zr,Rr=Lr,en=Br,tn=Jr;function q(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}q.prototype.clear=Zr,q.prototype.delete=Qr,q.prototype.get=Rr,q.prototype.has=en,q.prototype.set=tn;var rn=q,nn=W,an=L,sn=nn(an,"Map"),on=sn,Se=Mr,cn=rn,ln=on;function un(){this.size=0,this.__data__={hash:new Se,map:new(ln||cn),string:new Se}}var pn=un;function dn(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var hn=dn,fn=hn;function vn(e,t){var r=e.__data__;return fn(t)?r[typeof t=="string"?"string":"hash"]:r.map}var X=vn,gn=X;function mn(e){var t=gn(this,e).delete(e);return this.size-=t?1:0,t}var yn=mn,bn=X;function _n(e){return bn(this,e).get(e)}var Cn=_n,xn=X;function Sn(e){return xn(this,e).has(e)}var $n=Sn,wn=X;function An(e,t){var r=wn(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var Pn=An,In=pn,Tn=yn,On=Cn,Mn=$n,Fn=Pn;function G(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}G.prototype.clear=In,G.prototype.delete=Tn,G.prototype.get=On,G.prototype.has=Mn,G.prototype.set=Fn;var $e=G,En="__lodash_hash_undefined__";function Dn(e){return this.__data__.set(e,En),this}var Nn=Dn;function kn(e){return this.__data__.has(e)}var Hn=kn,jn=$e,qn=Nn,Gn=Hn;function J(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new jn;++t<r;)this.add(e[t])}J.prototype.add=J.prototype.push=qn,J.prototype.has=Gn;var zn=J;function Un(e,t,r,n){for(var a=e.length,i=r+(n?1:-1);n?i--:++i<a;)if(t(e[i],i,e))return i;return-1}var Kn=Un;function Ln(e){return e!==e}var Vn=Ln;function Wn(e,t,r){for(var n=r-1,a=e.length;++n<a;)if(e[n]===t)return n;return-1}var Bn=Wn,Yn=Kn,Xn=Vn,Jn=Bn;function Zn(e,t,r){return t===t?Jn(e,t,r):Yn(e,Xn,r)}var Qn=Zn,Rn=Qn;function ea(e,t){var r=e==null?0:e.length;return!!r&&Rn(e,t,0)>-1}var ta=ea;function ra(e,t,r){for(var n=-1,a=e==null?0:e.length;++n<a;)if(r(t,e[n]))return!0;return!1}var na=ra;function aa(e,t){return e.has(t)}var sa=aa,oa=W,ia=L,ca=oa(ia,"Set"),la=ca;function ua(){}var pa=ua;function da(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var we=da,ne=la,ha=pa,fa=we,va=1/0,ga=ne&&1/fa(new ne([,-0]))[1]==va?function(e){return new ne(e)}:ha,ma=ga,ya=zn,ba=ta,_a=na,Ca=sa,xa=ma,Sa=we,$a=200;function wa(e,t,r){var n=-1,a=ba,i=e.length,o=!0,l=[],u=l;if(r)o=!1,a=_a;else if(i>=$a){var d=t?null:xa(e);if(d)return Sa(d);o=!1,a=Ca,u=new ya}else u=t?[]:l;e:for(;++n<i;){var y=e[n],x=t?t(y):y;if(y=r||y!==0?y:0,o&&x===x){for(var _=u.length;_--;)if(u[_]===x)continue e;t&&u.push(x),l.push(y)}else a(u,x,r)||(u!==l&&u.push(x),l.push(y))}return l}var Aa=wa,Pa=Aa;function Ia(e){return e&&e.length?Pa(e):[]}var Ta=Ia;const Oa=ve(Ta),Ae=c.createStyles(({css:e})=>e`
2
+ .ant-table-cell {
3
+ > .ant-space-horizontal {
4
+ .ant-space-item-split:has(+ .ant-space-item:empty) {
5
+ display: none;
6
+ }
7
+ }
8
+ }
9
+ `),Pe=(e=[],t=[])=>{for(const r of e)t.push(r.aclSnippet),r.children&&r.children.length&&Pe(r.children,t);return t},Ma=({active:e})=>{const t=c.useApp(),{styles:r}=Ae(),{role:n}=h.useContext(D),a=c.useAPIClient(),i=c.useCompile(),o=t.systemSettingsManager.getList(!1),l=t.systemSettingsManager.getAclSnippets(),[u,d]=h.useState((n==null?void 0:n.snippets)||[]),y=h.useMemo(()=>N.flatMap(o,g=>g.children?[g,...g.children]:g),[o]),x=h.useMemo(()=>u.includes("pm.*")&&u.every(g=>!g.startsWith("!pm.")),[u]),{t:_}=M.useTranslation(),{loading:w,refresh:P}=c.useRequest({resource:"roles.snippets",resourceOf:n==null?void 0:n.name,action:"list",params:{paginate:!1}},{ready:!!n&&e,refreshDeps:[n==null?void 0:n.name],manual:!0,onSuccess(g){d((g==null?void 0:g.data.filter(m=>y.find(f=>m.includes(`!${f.aclSnippet}`)||!m.startsWith("!pm."))))||[])}});if(!n)return;const $=a.resource("roles.snippets",n==null?void 0:n.name),O=(g,m)=>A(this,null,function*(){const b=Pe(m==null?void 0:m.children,[]).concat(m.aclSnippet);g?(yield $.add({values:b.map(F=>"!"+F)}),P()):(yield $.remove({values:b.map(F=>"!"+F)}),P()),p.message.success(_("Saved successfully"))});return s.jsx(p.Table,{className:r,loading:w,rowKey:"key",pagination:!1,expandable:{defaultExpandAllRows:!0},columns:[{dataIndex:"title",title:_("Plugin name"),render:g=>i(g)},{dataIndex:"accessible",title:s.jsxs(s.Fragment,{children:[s.jsx(p.Checkbox,{checked:x,onChange:()=>A(this,null,function*(){const g=l.map(m=>"!"+m);x?yield $.add({values:g}):yield $.remove({values:g}),P(),p.message.success(_("Saved successfully"))})}),_("Accessible")]}),render:(g,m)=>{const f=!u.includes("!"+m.aclSnippet);return s.jsx(p.Checkbox,{checked:f,onChange:()=>O(f,m)})}}],dataSource:o.filter(g=>g.isTopLevel!==!1).map(g=>g.showTabs!==!1?g:N.omit(g,"children"))})},Fa=e=>{var r;if(!e)return{};const t={};return(r=e==null?void 0:e.forEach)==null||r.call(e,n=>{const[a,i]=n.split(":");t[a]=i||"all"}),t},Ie=e=>{const t=[];for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r];n==="all"?t.push(r):t.push(`${r}:${n}`)}return t},Ea=S.connect(e=>{const{onChange:t}=e,r=rt(),n=c.useCompile(),{t:a}=M.useTranslation(),i=S.useField(),o=Fa(i.value);return s.jsx("div",{children:s.jsx(p.Table,{rowKey:"name",size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:a("Action display name"),render:l=>n(l)},{dataIndex:"onNewRecord",title:a("Action type"),render:l=>l?s.jsx(p.Tag,{color:"green",children:a("Action on new records")}):s.jsx(p.Tag,{color:"geekblue",children:a("Action on existing records")})},{dataIndex:"enabled",title:a("Allow"),render:(l,u)=>s.jsx(p.Checkbox,{checked:l,"aria-label":`${u.name}_checkbox`,onChange:d=>{l?delete o[u.name]:o[u.name]="all",t(Ie(o))}})},{dataIndex:"scope",title:a("Data scope"),render:(l,u)=>!u.onNewRecord&&s.jsx(p.Select,{"data-testid":"select-data-scope",popupMatchSelectWidth:!1,size:"small",value:l,options:[{label:a("All records"),value:"all"},{label:a("Own records"),value:"own"}],onChange:d=>{o[u.name]=d,t(Ie(o))}})}],dataSource:r==null?void 0:r.map(l=>{let u="all",d=!1;return o[l.name]&&(d=!0,u=o[l.name]),k(I({},l),{enabled:d,scope:u})})})})}),Da=S.connect(e=>{const{t}=M.useTranslation();return s.jsxs(p.Checkbox.Group,{style:{width:"100%",display:"block"},value:e.value,onChange:r=>{const n=["ui.*","pm","pm.*","app"],a=n.map(o=>`!${o}`),i=Oa([...e.value||[],...r]).filter(o=>o&&!a.includes(o)).map(o=>!n.includes(o)||r!=null&&r.includes(o)?o:`!${o}`);for(const o of n)!i.includes(o)&&!i.includes(`!${o}`)&&i.push(`!${o}`);e.onChange(i)},children:[s.jsx("div",{style:{marginTop:16},children:s.jsx(p.Checkbox,{value:"ui.*",children:t("Allows to configure interface")})}),s.jsx("div",{style:{marginTop:8},children:s.jsx(p.Checkbox,{value:"pm",children:t("Allows to install, activate, disable plugins")})}),s.jsx("div",{style:{marginTop:8},children:s.jsx(p.Checkbox,{value:"pm.*",children:t("Allows to configure plugins")})}),s.jsx("div",{style:{marginTop:8},children:s.jsx(p.Checkbox,{value:"app",children:t("Allows to clear cache, reboot application")})})]})}),Na=({active:e})=>{var u;const{role:t,setRole:r}=h.useContext(D),{t:n}=H(),a=c.useAPIClient(),i=(u=t==null?void 0:t.snippets)==null?void 0:u.includes("pm.*"),o=T.useMemoizedFn(d=>A(this,null,function*(){yield a.resource("roles").update({filterByTk:t.name,values:d.values}),r(I(I({},t),d.values)),p.message.success(n("Saved successfully"))})),l=h.useMemo(()=>S.createForm({values:t,effects(){S.onFormValuesChange(d=>A(this,null,function*(){yield o(d)}))}}),[t,o]);return s.jsx(c.SchemaComponent,{components:{SnippetCheckboxGroup:Da,StrategyActions:Ea,PluginPermissions:Ma},scope:{pm:i},schema:{type:"void",name:S.uid(),"x-component":"div",properties:{general:{"x-component":"FormV2","x-component-props":{form:l},properties:{snippets:{title:n("Configure permissions"),type:"boolean","x-decorator":"FormItem","x-component":"SnippetCheckboxGroup"}}},plugins:{"x-component":"FormV2",properties:{pluginSettings:{title:n("Plugin settings"),"x-decorator":"FormItem","x-component":"PluginPermissions","x-visible":"{{pm}}"}}}}}})},ae=h.createContext(null);ae.displayName="MenuItemsContext";const Te=(e={})=>{const t=[];for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r],a={title:n.title,uid:n["x-uid"]};n.properties&&(a.children=Te(n.properties)),t.push(a)}return t},ka=()=>h.useContext(ae),Oe=e=>{var i,o;const r={url:`uiSchemas:getProperties/${c.useAdminSchemaUid()}`},n=c.useRequest(r);if(n.loading)return s.jsx(p.Spin,{});const a=Te((o=(i=n.data)==null?void 0:i.data)==null?void 0:o.properties);return s.jsx(ae.Provider,{value:{service:n,items:a},children:e.children})},Me=e=>{if(!Array.isArray(e))return[];const t=[];for(const r of e)t.push(r.uid),t.push(...Me(r.children));return t},Fe=(e,t,r=[])=>{if(!e)return[];for(const n of e){if(r.push(n.uid),t(n))return r;if(n.children){const a=Fe(n.children,t,r);if(a.length)return a}r.pop()}return[]},Ee=(e=[],t=[])=>{for(const r of e)t.push(r.uid),r.children&&r.children.length&&Ee(r.children,t);return t},Ha=({active:e})=>{const{styles:t}=Ae(),{role:r,setRole:n}=h.useContext(D),a=c.useAPIClient(),{items:i}=ka(),{t:o}=M.useTranslation(),l=Me(i),[u,d]=h.useState([]),{loading:y,refresh:x}=c.useRequest({resource:"roles.menuUiSchemas",resourceOf:r.name,action:"list",params:{paginate:!1}},{ready:!!r&&e,refreshDeps:[r==null?void 0:r.name],onSuccess(m){var f;d(((f=m==null?void 0:m.data)==null?void 0:f.map(b=>b["x-uid"]))||[])}}),_=a.resource("roles.menuUiSchemas",r.name),w=l.length===u.length,P=(m,f)=>A(this,null,function*(){const b=Fe(i,E=>E.uid===f.uid),F=Ee(f==null?void 0:f.children,[]);if(m){const E=F.concat(f.uid),pe=u.filter($i=>!E.includes($i));d([...pe]),yield _.remove({values:E})}else{const E=F.concat(b);d(pe=>N.uniq([...pe,...E])),yield _.add({values:E})}p.message.success(o("Saved successfully"))}),$=m=>m.map(f=>{const b=o(f.title);return f.children?k(I({},f),{title:b,children:$(f.children)}):k(I({},f),{title:b})}),O=T.useMemoizedFn(m=>A(this,null,function*(){yield a.resource("roles").update({filterByTk:r.name,values:m.values}),n(I(I({},r),m.values)),p.message.success(o("Saved successfully"))})),g=h.useMemo(()=>S.createForm({values:r,effects(){S.onFormValuesChange(m=>A(this,null,function*(){yield O(m)}))}}),[r,O]);return s.jsxs(s.Fragment,{children:[s.jsx(c.SchemaComponent,{schema:{type:"void",name:S.uid(),"x-component":"FormV2","x-component-props":{form:g},properties:{allowNewMenu:{title:o("Menu permissions"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":o("New menu items are allowed to be accessed by default.")}}}}),s.jsx(p.Table,{className:t,loading:y,rowKey:"uid",pagination:!1,expandable:{defaultExpandAllRows:!0},columns:[{dataIndex:"title",title:o("Menu item title")},{dataIndex:"accessible",title:s.jsxs(s.Fragment,{children:[s.jsx(p.Checkbox,{checked:w,onChange:m=>A(this,null,function*(){w?yield _.set({values:[]}):yield _.set({values:l}),x(),p.message.success(o("Saved successfully"))})})," ",o("Accessible")]}),render:(m,f)=>{const b=u.includes(f.uid);return s.jsx(p.Checkbox,{checked:b,onChange:()=>P(b,f)})}}],dataSource:$(i)})]})},se=e=>s.jsx("div",{style:{maxHeight:"60vh",overflowY:"auto"},children:e.children}),ja=({active:e})=>{var _;const{t}=H(),[r,n]=h.useState("general"),{role:a,setRole:i}=h.useContext(D),o=(_=a==null?void 0:a.snippets)==null?void 0:_.includes("pm.*"),u=c.useApp().getComponent("DataSourcePermissionManager"),d=h.useMemo(()=>[{key:"general",label:t("System"),children:s.jsx(se,{children:s.jsx(Na,{active:r==="general"&&e})})},{key:"menu",label:t("Menu"),children:s.jsx(se,{children:s.jsx(Oe,{children:s.jsx(Ha,{active:r==="menu"&&e})})})},...u?[{key:"dataSource",label:t("Data sources"),children:s.jsx(se,{children:s.jsx(Oe,{children:s.jsx(u,{role:a,active:r==="dataSource"&&e})})})}]:[]],[o,r,e,t]),y=c.useAPIClient(),{data:x}=c.useRequest(()=>y.resource("roles").get({filterByTk:a==null?void 0:a.name}).then(w=>{var $,O;const P=($=w==null?void 0:w.data)==null?void 0:$.data;return(O=P.snippets)==null||O.forEach(g=>{P[g]=!0}),P}),{ready:e&&!!a,refreshDeps:[a==null?void 0:a.name]});return h.useEffect(()=>{n("general")},[a==null?void 0:a.name]),h.useEffect(()=>{i(x)},[x]),s.jsx(tt,{children:s.jsx(p.Tabs,{type:"card",activeKey:r,onChange:w=>n(w),items:d})})},qa=({loadMore:e})=>{const[t,r]=h.useState(null),n=h.useRef(null),a=h.useCallback(i=>{i&&(n.current&&n.current.disconnect(),n.current=new IntersectionObserver(o=>{o.forEach(l=>{l.target===i.current&&l.isIntersecting&&(n.current&&n.current.unobserve(i.current),e())})}),i.current&&n.current&&n.current.observe(i.current))},[e]);return h.useEffect(()=>(a(t),()=>{n.current&&n.current.disconnect()}),[t,a]),{lastItem:t,setLastItem:r}};var Ga=Array.isArray,U=Ga;function za(e){return e!=null&&typeof e=="object"}var oe=za,Ua=ee,Ka=oe,La="[object Symbol]";function Va(e){return typeof e=="symbol"||Ka(e)&&Ua(e)==La}var ie=Va,Wa=U,Ba=ie,Ya=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Xa=/^\w*$/;function Ja(e,t){if(Wa(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||Ba(e)?!0:Xa.test(e)||!Ya.test(e)||t!=null&&e in Object(t)}var Za=Ja,De=$e,Qa="Expected a function";function ce(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Qa);var r=function(){var n=arguments,a=t?t.apply(this,n):n[0],i=r.cache;if(i.has(a))return i.get(a);var o=e.apply(this,n);return r.cache=i.set(a,o)||i,o};return r.cache=new(ce.Cache||De),r}ce.Cache=De;var Ra=ce,es=Ra,ts=500;function rs(e){var t=es(e,function(n){return r.size===ts&&r.clear(),n}),r=t.cache;return t}var ns=rs,as=ns,ss=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,os=/\\(\\)?/g,is=as(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(ss,function(r,n,a,i){t.push(a?i.replace(os,"$1"):n||r)}),t}),cs=is;function ls(e,t){for(var r=-1,n=e==null?0:e.length,a=Array(n);++r<n;)a[r]=t(e[r],r,e);return a}var us=ls,Ne=V,ps=us,ds=U,hs=ie,fs=1/0,ke=Ne?Ne.prototype:void 0,He=ke?ke.toString:void 0;function je(e){if(typeof e=="string")return e;if(ds(e))return ps(e,je)+"";if(hs(e))return He?He.call(e):"";var t=e+"";return t=="0"&&1/e==-fs?"-0":t}var vs=je,gs=vs;function ms(e){return e==null?"":gs(e)}var ys=ms,bs=U,_s=Za,Cs=cs,xs=ys;function Ss(e,t){return bs(e)?e:_s(e,t)?[e]:Cs(xs(e))}var Z=Ss,$s=ie,ws=1/0;function As(e){if(typeof e=="string"||$s(e))return e;var t=e+"";return t=="0"&&1/e==-ws?"-0":t}var le=As,Ps=Z,Is=le;function Ts(e,t){t=Ps(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[Is(t[r++])];return r&&r==n?e:void 0}var Os=Ts,Ms=W,Fs=function(){try{var e=Ms(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),qe=Fs,Ge=qe;function Es(e,t,r){t=="__proto__"&&Ge?Ge(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var Ds=Es,Ns=Ds,ks=xe,Hs=Object.prototype,js=Hs.hasOwnProperty;function qs(e,t,r){var n=e[t];(!(js.call(e,t)&&ks(n,r))||r===void 0&&!(t in e))&&Ns(e,t,r)}var Gs=qs,zs=9007199254740991,Us=/^(?:0|[1-9]\d*)$/;function Ks(e,t){var r=typeof e;return t=t==null?zs:t,!!t&&(r=="number"||r!="symbol"&&Us.test(e))&&e>-1&&e%1==0&&e<t}var ze=Ks,Ls=Gs,Vs=Z,Ws=ze,Ue=te,Bs=le;function Ys(e,t,r,n){if(!Ue(e))return e;t=Vs(t,e);for(var a=-1,i=t.length,o=i-1,l=e;l!=null&&++a<i;){var u=Bs(t[a]),d=r;if(u==="__proto__"||u==="constructor"||u==="prototype")return e;if(a!=o){var y=l[u];d=n?n(y,u,l):void 0,d===void 0&&(d=Ue(y)?y:Ws(t[a+1])?[]:{})}Ls(l,u,d),l=l[u]}return e}var Xs=Ys,Js=Os,Zs=Xs,Qs=Z;function Rs(e,t,r){for(var n=-1,a=t.length,i={};++n<a;){var o=t[n],l=Js(e,o);r(l,o)&&Zs(i,Qs(o,e),l)}return i}var eo=Rs;function to(e,t){return e!=null&&t in Object(e)}var ro=to,no=ee,ao=oe,so="[object Arguments]";function oo(e){return ao(e)&&no(e)==so}var io=oo,Ke=io,co=oe,Le=Object.prototype,lo=Le.hasOwnProperty,uo=Le.propertyIsEnumerable,po=Ke(function(){return arguments}())?Ke:function(e){return co(e)&&lo.call(e,"callee")&&!uo.call(e,"callee")},Ve=po,ho=9007199254740991;function fo(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=ho}var vo=fo,go=Z,mo=Ve,yo=U,bo=ze,_o=vo,Co=le;function xo(e,t,r){t=go(t,e);for(var n=-1,a=t.length,i=!1;++n<a;){var o=Co(t[n]);if(!(i=e!=null&&r(e,o)))break;e=e[o]}return i||++n!=a?i:(a=e==null?0:e.length,!!a&&_o(a)&&bo(o,a)&&(yo(e)||mo(e)))}var So=xo,$o=ro,wo=So;function Ao(e,t){return e!=null&&wo(e,t,$o)}var Po=Ao,Io=eo,To=Po;function Oo(e,t){return Io(e,t,function(r,n){return To(e,n)})}var Mo=Oo;function Fo(e,t){for(var r=-1,n=t.length,a=e.length;++r<n;)e[a+r]=t[r];return e}var Eo=Fo,We=V,Do=Ve,No=U,Be=We?We.isConcatSpreadable:void 0;function ko(e){return No(e)||Do(e)||!!(Be&&e&&e[Be])}var Ho=ko,jo=Eo,qo=Ho;function Ye(e,t,r,n,a){var i=-1,o=e.length;for(r||(r=qo),a||(a=[]);++i<o;){var l=e[i];t>0&&r(l)?t>1?Ye(l,t-1,r,n,a):jo(a,l):n||(a[a.length]=l)}return a}var Go=Ye,zo=Go;function Uo(e){var t=e==null?0:e.length;return t?zo(e,1):[]}var Ko=Uo;function Lo(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var Vo=Lo,Wo=Vo,Xe=Math.max;function Bo(e,t,r){return t=Xe(t===void 0?e.length-1:t,0),function(){for(var n=arguments,a=-1,i=Xe(n.length-t,0),o=Array(i);++a<i;)o[a]=n[t+a];a=-1;for(var l=Array(t+1);++a<t;)l[a]=n[a];return l[t]=r(o),Wo(e,this,l)}}var Yo=Bo;function Xo(e){return function(){return e}}var Jo=Xo;function Zo(e){return e}var Qo=Zo,Ro=Jo,Je=qe,ei=Qo,ti=Je?function(e,t){return Je(e,"toString",{configurable:!0,enumerable:!1,value:Ro(t),writable:!0})}:ei,ri=ti,ni=800,ai=16,si=Date.now;function oi(e){var t=0,r=0;return function(){var n=si(),a=ai-(n-r);if(r=n,a>0){if(++t>=ni)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var ii=oi,ci=ri,li=ii,ui=li(ci),pi=ui,di=Ko,hi=Yo,fi=pi;function vi(e){return fi(hi(e,void 0,di),e+"")}var gi=vi,mi=Mo,yi=gi,bi=yi(function(e,t){return e==null?{}:mi(e,t)}),_i=bi;const Ci=ve(_i),xi={type:"object",properties:{[S.uid()]:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:e=>{const t=c.useRecord(),r=c.useRequest(()=>Promise.resolve({data:Ci(t,["title","name","default"])}),k(I({},e),{manual:!0})),n=c.useActionContext();return h.useEffect(()=>{n.visible&&r.run()},[n.visible]),r}},title:'{{t("Edit role")}}',properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},default:{title:"","x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Default role")}}',"x-reactions":e=>{e.initialValue?e.disabled=!0:e.disabled=!1}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},Q=()=>{const{t:e}=H(),{data:t,mutate:r}=c.useResourceActionContext(),[n,a]=h.useState(!1),[i,o]=h.useState(null),{role:l,setRole:u}=h.useContext(D),[d,y]=h.useState([]),[x,_]=h.useState(!1),w=c.useAPIClient(),P=h.useCallback(()=>A(this,null,function*(){const f=t==null?void 0:t.meta;if(!f||f.page>=f.totalPage)return;_(!0);const b=yield w.resource("roles").list({page:f.page+1,pageSize:f.pageSize,filter:{"name.$ne":"root"},showAnonymous:!0,sort:["createdAt"],appends:[]});r((b==null?void 0:b.data)||{}),_(!1)}),[t]),{lastItem:$,setLastItem:O}=qa({loadMore:P}),g=({key:f})=>{u(d.find(b=>b.name===f))};h.useEffect(()=>{d[0]&&u(d[0])},[d,u]),h.useEffect(()=>{var b,F;if(!((b=t==null?void 0:t.data)!=null&&b.length))return;const f=h.createRef();O(f),((F=t.meta)==null?void 0:F.page)>1?y(E=>E.concat(t.data)):y(t.data)},[t,O]);const m=h.useMemo(()=>d.map((f,b)=>({key:f.name,label:b===d.length-1?s.jsx("div",{ref:$,children:s.jsx(Q.Item,{item:f,onEdit:()=>{a(!0),o(f)}})}):s.jsx(Q.Item,{item:f,onEdit:()=>{a(!0),o(f)}})})),[d,$]);return s.jsxs(s.Fragment,{children:[d.length?s.jsx(p.Menu,{style:{border:"none",maxHeight:"65vh",overflowY:"auto"},items:[...m,...x?[{key:"loading",label:s.jsx(p.Spin,{})}]:[]],selectedKeys:[l==null?void 0:l.name],onSelect:g}):s.jsx(p.Empty,{image:p.Empty.PRESENTED_IMAGE_SIMPLE}),s.jsx(c.ActionContextProvider,{value:{visible:n,setVisible:a},children:s.jsx(c.RecordProvider,{record:i,collectionName:"departments",children:s.jsx(c.SchemaComponent,{scope:{t:e},schema:xi})})})]})};Q.Item=function({item:t,onEdit:r}){const{t:n}=H(),{refreshAsync:a}=c.useResourceActionContext(),{modal:i,message:o}=p.App.useApp(),l=c.useAPIClient(),u=()=>{i.confirm({title:n("Delete"),content:n("Are you sure you want to delete it?"),onOk:()=>A(this,null,function*(){yield l.resource("roles").destroy({filterByTk:t.name}),o.success(n("Deleted successfully")),yield a()})})},d=({key:x,domEvent:_})=>{switch(_.stopPropagation(),x){case"edit":r();break;case"delete":u()}},y=S.Schema.compile(t.title,{t:n});return s.jsxs(p.Row,{children:[s.jsx(p.Col,{flex:3,style:{display:"inline-flex",alignItems:"center"},children:s.jsxs("span",{style:{whiteSpace:"nowrap",width:"120px",overflow:"hidden",textOverflow:"ellipsis"},children:[s.jsx(fe.TagOutlined,{}),s.jsx("span",{style:{marginLeft:"10px"},title:y,children:y})]})}),s.jsxs(p.Col,{children:[t.default?s.jsx(p.Tag,{color:"success",bordered:!1,children:n("Default")}):null,s.jsx(p.Dropdown,{menu:{items:[{label:n("Edit"),key:"edit"},{label:n("Delete"),key:"delete"}],onClick:d},children:s.jsx(fe.MoreOutlined,{})})]})]})};const Ze={name:"roles",filterTargetKey:"name",targetKey:"name",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Role display name")}}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Role UID")}}',type:"string","x-component":"Input"}},{type:"boolean",name:"default",interface:"boolean",uiSchema:{title:'{{t("Default role")}}',type:"boolean","x-component":"Checkbox"}}]},Si=()=>{const{t:e}=H(),t=c.usePlugin(ue),[r,n]=h.useState("permissions"),a=Array.from(t.rolesManager.list()).map(([u,d])=>({key:u,label:S.Schema.compile(d.title,{t:e}),children:d.Component?h.createElement(d.Component,{active:r===u}):null})),[i,o]=h.useState(null),l=c.useSchemaComponentContext();return s.jsx(c.SchemaComponentContext.Provider,{value:k(I({},l),{designable:!1}),children:s.jsx(D.Provider,{value:{role:i,setRole:o},children:s.jsx(p.Card,{children:s.jsxs(p.Row,{gutter:24,style:{flexWrap:"nowrap"},children:[s.jsx(p.Col,{flex:"280px",style:{borderRight:"1px solid #eee",minWidth:"250px"},children:s.jsx(c.ResourceActionProvider,{collection:Ze,request:{resource:"roles",action:"list",params:{filter:{"name.$ne":"root"},showAnonymous:!0,sort:["createdAt"],appends:[]}},children:s.jsxs(c.CollectionProvider_deprecated,{collection:Ze,children:[s.jsx(p.Row,{children:s.jsx(et,{})}),s.jsx(p.Divider,{style:{margin:"12px 0"}}),s.jsx(Q,{})]})})}),s.jsx(p.Col,{flex:"auto",style:{overflow:"hidden"},children:s.jsx(p.Tabs,{activeKey:r,onChange:u=>n(u),items:[{key:"permissions",label:e("Permissions"),children:s.jsx(ja,{active:r==="permissions"})},...a]})})]})})})})};class ue extends c.Plugin{constructor(){super(...arguments);he(this,"rolesManager",new Re)}load(){return A(this,null,function*(){this.systemSettingsManager.add("id-auth.roles",{title:this.t("Roles & Permissions"),icon:"LockOutlined",Component:Si,aclSnippet:"pm.acl.roles",sort:3})})}}v.PluginACLClient=ue,v.RolesManagerContext=D,v.default=ue,Object.defineProperties(v,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -0,0 +1 @@
1
+ export declare function useACLTranslation(): import("react-i18next").UseTranslationResponse<[string, string], undefined>;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const ActionPermissions: React.FC<{
3
+ active: boolean;
4
+ }>;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare const AvailableActionsProvider: (props: any) => React.JSX.Element;
3
+ export declare const useAvailableActions: () => any[];
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const GeneralPermissions: React.FC<{
3
+ active: boolean;
4
+ }>;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const toItems: (properties?: {}) => any[];
3
+ export declare const useMenuItems: () => any;
4
+ export declare const MenuItemsProvider: (props: any) => React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const MenuPermissions: React.FC<{
3
+ active: boolean;
4
+ }>;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const Permissions: React.FC<{
3
+ active: boolean;
4
+ }>;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const PluginPermissions: React.FC<{
3
+ active: boolean;
4
+ }>;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare const RoleResourceCollectionContext: React.Context<any>;
3
+ export declare const RolesResourcesActions: React.ForwardRefExoticComponent<Omit<Partial<any>, "ref"> & React.RefAttributes<unknown>>;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare const useRolesResourcesScopesSelectedRowKeys: () => any;
3
+ export declare const ScopeSelect: (props: any) => React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const StrategyActions: React.ForwardRefExoticComponent<Omit<Partial<any>, "ref"> & React.RefAttributes<unknown>>;
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<import("antd-style").SerializedStyles>;
@@ -0,0 +1,10 @@
1
+ import { Registry } from '@tachybase/utils/client';
2
+ export type RolesManagerOptions = {
3
+ title: string;
4
+ Component: React.ComponentType<any>;
5
+ };
6
+ export declare class RolesManager {
7
+ rolesManager: Registry<RolesManagerOptions>;
8
+ add(name: string, options: RolesManagerOptions): void;
9
+ list(): Iterable<[string, RolesManagerOptions]>;
10
+ }
@@ -0,0 +1,55 @@
1
+ import { ISchema } from '@tachybase/schema';
2
+ export declare const roleEditSchema: {
3
+ type: string;
4
+ properties: {
5
+ [x: string]: {
6
+ type: string;
7
+ 'x-component': string;
8
+ 'x-decorator': string;
9
+ 'x-decorator-props': {
10
+ useValues: (options: any) => import("@tachybase/client").UseRequestResult<unknown>;
11
+ };
12
+ title: string;
13
+ properties: {
14
+ title: {
15
+ 'x-component': string;
16
+ 'x-decorator': string;
17
+ };
18
+ name: {
19
+ 'x-component': string;
20
+ 'x-decorator': string;
21
+ 'x-disabled': boolean;
22
+ };
23
+ default: {
24
+ title: string;
25
+ 'x-component': string;
26
+ 'x-decorator': string;
27
+ 'x-content': string;
28
+ 'x-reactions': (field: any) => void;
29
+ };
30
+ footer: {
31
+ type: string;
32
+ 'x-component': string;
33
+ properties: {
34
+ cancel: {
35
+ title: string;
36
+ 'x-component': string;
37
+ 'x-component-props': {
38
+ useAction: string;
39
+ };
40
+ };
41
+ submit: {
42
+ title: string;
43
+ 'x-component': string;
44
+ 'x-component-props': {
45
+ type: string;
46
+ useAction: string;
47
+ };
48
+ };
49
+ };
50
+ };
51
+ };
52
+ };
53
+ };
54
+ };
55
+ export declare const roleCollectionsSchema: ISchema;
@@ -0,0 +1,11 @@
1
+ import { ISchema } from '@tachybase/schema';
2
+ export declare const rolesResourcesScopesCollection: {
3
+ name: string;
4
+ fields: {
5
+ type: string;
6
+ name: string;
7
+ interface: string;
8
+ uiSchema: ISchema;
9
+ }[];
10
+ };
11
+ export declare const scopesSchema: ISchema;
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ "react": "18.3.1",
3
+ "@tachybase/client": "0.23.8",
4
+ "@tachybase/schema": "0.23.8",
5
+ "antd": "5.22.5",
6
+ "@ant-design/icons": "5.5.2",
7
+ "react-i18next": "15.2.0",
8
+ "@tachybase/utils": "0.23.8",
9
+ "@tachybase/actions": "0.23.8",
10
+ "@tachybase/cache": "0.23.8",
11
+ "@tachybase/database": "0.23.8",
12
+ "@tachybase/server": "0.23.8",
13
+ "async-mutex": "0.3.2",
14
+ "lodash": "4.17.21",
15
+ "@tachybase/test": "0.23.8",
16
+ "ahooks": "3.8.4",
17
+ "@tachybase/components": "0.23.8",
18
+ "@tachybase/acl": "0.23.8"
19
+ };
@@ -0,0 +1,2 @@
1
+ export * from './server';
2
+ export { default } from './server';
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var src_exports = {};
30
+ __export(src_exports, {
31
+ default: () => import_server.default
32
+ });
33
+ module.exports = __toCommonJS(src_exports);
34
+ __reExport(src_exports, require("./server"), module.exports);
35
+ var import_server = __toESM(require("./server"));
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ ...require("./server")
39
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "New role": "New role",
3
+ "Permissions": "Permissions",
4
+ "The current user has no roles. Please try another account.": "The current user has no roles. Please try another account.",
5
+ "The user role does not exist. Please try signing in again": "The user role does not exist. Please try signing in again"
6
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "The current user has no roles. Please try another account.": "현재 사용자에게 역할이 없습니다. 다른 계정을 시도해주세요.",
3
+ "The user role does not exist. Please try signing in again": "사용자 역할이 존재하지 않습니다. 다시 로그인을 시도해주세요."
4
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "Data sources": "数据源",
3
+ "General": "通用",
4
+ "Menu": "菜单",
5
+ "New role": "新建角色",
6
+ "Permissions": "权限",
7
+ "Plugin settings": "插件设置",
8
+ "Roles & Permissions": "角色和权限",
9
+ "The current user has no roles. Please try another account.": "当前用户没有角色,请使用其他账号。",
10
+ "The user role does not exist. Please try signing in again": "用户角色不存在,请尝试重新登录。"
11
+ }
@@ -0,0 +1,7 @@
1
+ declare const availableActionResource: {
2
+ name: string;
3
+ actions: {
4
+ list(ctx: any, next: any): Promise<void>;
5
+ };
6
+ };
7
+ export { availableActionResource };