@nocobase/client 0.8.1-alpha.4 → 0.9.0-alpha.2

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 (195) hide show
  1. package/es/acl/ACLProvider.d.ts +16 -2
  2. package/es/acl/ACLProvider.js +271 -100
  3. package/es/acl/Configuration/ConfigureCenter.d.ts +2 -0
  4. package/es/acl/Configuration/ConfigureCenter.js +254 -0
  5. package/es/acl/Configuration/MenuConfigure.js +2 -2
  6. package/es/acl/Configuration/PermisionProvider.d.ts +4 -0
  7. package/es/acl/Configuration/PermisionProvider.js +132 -0
  8. package/es/acl/Configuration/RoleConfigure.js +98 -23
  9. package/es/acl/Configuration/RoleTable.d.ts +1 -1
  10. package/es/acl/Configuration/RoleTable.js +6 -3
  11. package/es/acl/Configuration/RolesResourcesActions.js +2 -2
  12. package/es/acl/Configuration/index.d.ts +1 -0
  13. package/es/acl/Configuration/index.js +2 -1
  14. package/es/acl/Configuration/schemas/roleCollections.js +41 -13
  15. package/es/acl/Configuration/schemas/roles.js +42 -2
  16. package/es/acl/Configuration/schemas/scopes.js +2 -0
  17. package/es/acl/index.d.ts +1 -0
  18. package/es/acl/index.js +2 -1
  19. package/es/acl/style.less +10 -0
  20. package/es/antd-config-provider/index.d.ts +3 -1
  21. package/es/antd-config-provider/index.js +25 -6
  22. package/es/antd-config-provider/loadConstrueLocale.d.ts +1 -0
  23. package/es/antd-config-provider/loadConstrueLocale.js +293 -0
  24. package/es/api-client/APIClient.js +5 -0
  25. package/es/block-provider/FormBlockProvider.js +5 -2
  26. package/es/block-provider/KanbanBlockProvider.js +3 -3
  27. package/es/block-provider/SharedFilterProvider.d.ts +1 -0
  28. package/es/block-provider/SharedFilterProvider.js +22 -6
  29. package/es/collection-manager/CollectionHistoryProvider.js +14 -2
  30. package/es/collection-manager/hooks/useCollection.d.ts +1 -0
  31. package/es/collection-manager/hooks/useCollection.js +10 -0
  32. package/es/collection-manager/interfaces/index.d.ts +0 -1
  33. package/es/collection-manager/interfaces/index.js +0 -1
  34. package/es/collection-manager/interfaces/o2m.js +1 -0
  35. package/es/collection-manager/interfaces/properties/operators.js +7 -0
  36. package/es/collection-manager/interfaces/subTable.js +1 -0
  37. package/es/collection-manager/templates/calendar.js +5 -0
  38. package/es/formula/Expression.d.ts +2 -0
  39. package/es/formula/Expression.js +296 -0
  40. package/es/formula/Result.d.ts +2 -0
  41. package/es/formula/Result.js +91 -0
  42. package/es/formula/index.d.ts +6 -0
  43. package/es/formula/index.js +8 -0
  44. package/es/i18n/i18n.js +7 -12
  45. package/es/index.d.ts +2 -1
  46. package/es/index.js +3 -2
  47. package/es/locale/en_US.d.ts +108 -28
  48. package/es/locale/en_US.js +108 -28
  49. package/es/locale/index.d.ts +201 -4
  50. package/es/locale/index.js +191 -58
  51. package/es/locale/ja_JP.d.ts +4 -0
  52. package/es/locale/ja_JP.js +4 -0
  53. package/es/locale/zh_CN.d.ts +11 -1
  54. package/es/locale/zh_CN.js +12 -2
  55. package/es/plugin-manager/PluginManager.js +19 -13
  56. package/es/pm/PluginManagerLink.js +38 -43
  57. package/es/pm/index.d.ts +1 -0
  58. package/es/pm/index.js +84 -35
  59. package/es/record-provider/index.d.ts +1 -0
  60. package/es/record-provider/index.js +7 -4
  61. package/es/route-switch/antd/admin-layout/index.d.ts +1 -0
  62. package/es/route-switch/antd/admin-layout/index.js +4 -6
  63. package/es/schema-component/antd/action/Action.js +19 -16
  64. package/es/schema-component/antd/association-filter/AssociationFilter.Item.js +24 -23
  65. package/es/schema-component/antd/cron/Cron.d.ts +0 -1
  66. package/es/schema-component/antd/cron/Cron.js +16 -19
  67. package/es/schema-component/antd/cron/locale/index.d.ts +37 -0
  68. package/es/schema-component/antd/cron/locale/index.js +6 -0
  69. package/es/schema-component/antd/filter/useFilterActionProps.js +17 -23
  70. package/es/schema-component/antd/form-item/FormItem.js +5 -4
  71. package/es/schema-component/antd/index.d.ts +1 -2
  72. package/es/schema-component/antd/index.js +1 -2
  73. package/es/schema-component/antd/page/FixedBlock.d.ts +1 -1
  74. package/es/schema-component/antd/page/FixedBlock.js +70 -21
  75. package/es/schema-component/antd/page/Page.js +15 -10
  76. package/es/schema-component/antd/remote-select/RemoteSelect.js +12 -2
  77. package/es/schema-component/antd/table/Table.Array.js +1 -1
  78. package/es/schema-component/antd/table-v2/Table.js +13 -6
  79. package/es/schema-component/antd/table-v2/TableBlockDesigner.js +24 -8
  80. package/es/schema-component/hooks/useDesignable.d.ts +1 -1
  81. package/es/schema-component/hooks/useDesignable.js +45 -16
  82. package/es/schema-component/hooks/useFieldTitle.js +3 -1
  83. package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.d.ts +3 -0
  84. package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +1 -0
  85. package/es/schema-initializer/buttons/TableActionColumnInitializers.js +1 -0
  86. package/es/schema-initializer/utils.js +6 -9
  87. package/es/schema-templates/BlockTemplate.js +2 -2
  88. package/es/schema-templates/SchemaTemplateManagerProvider.js +1 -1
  89. package/es/system-settings/SystemSettingsShortcut.js +1 -1
  90. package/lib/acl/ACLProvider.d.ts +16 -2
  91. package/lib/acl/ACLProvider.js +283 -102
  92. package/lib/acl/Configuration/ConfigureCenter.d.ts +2 -0
  93. package/lib/acl/Configuration/ConfigureCenter.js +278 -0
  94. package/lib/acl/Configuration/MenuConfigure.js +3 -3
  95. package/lib/acl/Configuration/PermisionProvider.d.ts +4 -0
  96. package/lib/acl/Configuration/PermisionProvider.js +156 -0
  97. package/lib/acl/Configuration/RoleConfigure.js +107 -23
  98. package/lib/acl/Configuration/RoleTable.d.ts +1 -1
  99. package/lib/acl/Configuration/RoleTable.js +8 -4
  100. package/lib/acl/Configuration/RolesResourcesActions.js +2 -2
  101. package/lib/acl/Configuration/index.d.ts +1 -0
  102. package/lib/acl/Configuration/index.js +15 -1
  103. package/lib/acl/Configuration/schemas/roleCollections.js +41 -13
  104. package/lib/acl/Configuration/schemas/roles.js +47 -2
  105. package/lib/acl/Configuration/schemas/scopes.js +2 -0
  106. package/lib/acl/index.d.ts +1 -0
  107. package/lib/acl/index.js +3 -1
  108. package/lib/acl/style.less +10 -0
  109. package/lib/antd-config-provider/index.d.ts +3 -1
  110. package/lib/antd-config-provider/index.js +40 -6
  111. package/lib/antd-config-provider/loadConstrueLocale.d.ts +1 -0
  112. package/lib/antd-config-provider/loadConstrueLocale.js +304 -0
  113. package/lib/api-client/APIClient.js +5 -0
  114. package/lib/block-provider/FormBlockProvider.js +9 -3
  115. package/lib/block-provider/KanbanBlockProvider.js +3 -3
  116. package/lib/block-provider/SharedFilterProvider.d.ts +1 -0
  117. package/lib/block-provider/SharedFilterProvider.js +26 -7
  118. package/lib/collection-manager/CollectionHistoryProvider.js +14 -1
  119. package/lib/collection-manager/hooks/useCollection.d.ts +1 -0
  120. package/lib/collection-manager/hooks/useCollection.js +10 -0
  121. package/lib/collection-manager/interfaces/index.d.ts +0 -1
  122. package/lib/collection-manager/interfaces/index.js +0 -13
  123. package/lib/collection-manager/interfaces/o2m.js +1 -0
  124. package/lib/collection-manager/interfaces/properties/operators.js +7 -0
  125. package/lib/collection-manager/interfaces/subTable.js +1 -0
  126. package/lib/collection-manager/templates/calendar.js +5 -0
  127. package/lib/formula/Expression.d.ts +2 -0
  128. package/lib/formula/Expression.js +319 -0
  129. package/lib/formula/Result.d.ts +2 -0
  130. package/lib/formula/Result.js +114 -0
  131. package/lib/formula/index.d.ts +6 -0
  132. package/lib/formula/index.js +22 -0
  133. package/lib/i18n/i18n.js +7 -14
  134. package/lib/index.d.ts +2 -1
  135. package/lib/index.js +26 -13
  136. package/lib/locale/en_US.d.ts +108 -28
  137. package/lib/locale/en_US.js +108 -28
  138. package/lib/locale/index.d.ts +201 -4
  139. package/lib/locale/index.js +197 -67
  140. package/lib/locale/ja_JP.d.ts +4 -0
  141. package/lib/locale/ja_JP.js +4 -0
  142. package/lib/locale/zh_CN.d.ts +11 -1
  143. package/lib/locale/zh_CN.js +12 -2
  144. package/lib/plugin-manager/PluginManager.js +20 -13
  145. package/lib/pm/PluginManagerLink.js +37 -43
  146. package/lib/pm/index.d.ts +1 -0
  147. package/lib/pm/index.js +90 -35
  148. package/lib/record-provider/index.d.ts +1 -0
  149. package/lib/record-provider/index.js +7 -4
  150. package/lib/route-switch/antd/admin-layout/index.d.ts +1 -0
  151. package/lib/route-switch/antd/admin-layout/index.js +5 -4
  152. package/lib/schema-component/antd/action/Action.js +19 -16
  153. package/lib/schema-component/antd/association-filter/AssociationFilter.Item.js +22 -21
  154. package/lib/schema-component/antd/cron/Cron.d.ts +0 -1
  155. package/lib/schema-component/antd/cron/Cron.js +19 -24
  156. package/lib/schema-component/antd/cron/locale/index.d.ts +37 -0
  157. package/lib/schema-component/antd/cron/locale/index.js +18 -0
  158. package/lib/schema-component/antd/filter/useFilterActionProps.js +16 -23
  159. package/lib/schema-component/antd/form-item/FormItem.js +6 -4
  160. package/lib/schema-component/antd/index.d.ts +1 -2
  161. package/lib/schema-component/antd/index.js +8 -21
  162. package/lib/schema-component/antd/page/FixedBlock.d.ts +1 -1
  163. package/lib/schema-component/antd/page/FixedBlock.js +71 -21
  164. package/lib/schema-component/antd/page/Page.js +14 -9
  165. package/lib/schema-component/antd/remote-select/RemoteSelect.js +18 -3
  166. package/lib/schema-component/antd/table/Table.Array.js +1 -1
  167. package/lib/schema-component/antd/table-v2/Table.js +14 -6
  168. package/lib/schema-component/antd/table-v2/TableBlockDesigner.js +25 -8
  169. package/lib/schema-component/hooks/useDesignable.d.ts +1 -1
  170. package/lib/schema-component/hooks/useDesignable.js +47 -18
  171. package/lib/schema-component/hooks/useFieldTitle.js +4 -1
  172. package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.d.ts +3 -0
  173. package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +1 -0
  174. package/lib/schema-initializer/buttons/TableActionColumnInitializers.js +1 -0
  175. package/lib/schema-initializer/utils.js +6 -9
  176. package/lib/schema-templates/BlockTemplate.js +2 -2
  177. package/lib/schema-templates/SchemaTemplateManagerProvider.js +1 -1
  178. package/lib/system-settings/SystemSettingsShortcut.js +1 -1
  179. package/package.json +6 -11
  180. package/es/collection-manager/interfaces/formula.d.ts +0 -2
  181. package/es/collection-manager/interfaces/formula.js +0 -74
  182. package/es/schema-component/antd/formula-input/Compute.d.ts +0 -3
  183. package/es/schema-component/antd/formula-input/Compute.js +0 -55
  184. package/es/schema-component/antd/formula-input/FormulaInput.d.ts +0 -3
  185. package/es/schema-component/antd/formula-input/FormulaInput.js +0 -167
  186. package/es/schema-component/antd/formula-input/index.d.ts +0 -1
  187. package/es/schema-component/antd/formula-input/index.js +0 -7
  188. package/lib/collection-manager/interfaces/formula.d.ts +0 -2
  189. package/lib/collection-manager/interfaces/formula.js +0 -83
  190. package/lib/schema-component/antd/formula-input/Compute.d.ts +0 -3
  191. package/lib/schema-component/antd/formula-input/Compute.js +0 -79
  192. package/lib/schema-component/antd/formula-input/FormulaInput.d.ts +0 -3
  193. package/lib/schema-component/antd/formula-input/FormulaInput.js +0 -191
  194. package/lib/schema-component/antd/formula-input/index.d.ts +0 -1
  195. package/lib/schema-component/antd/formula-input/index.js +0 -18
@@ -1,13 +1,27 @@
1
+ import { Schema } from '@formily/react';
1
2
  import React from 'react';
2
3
  export declare const ACLContext: React.Context<any>;
3
4
  export declare const ACLProvider: (props: any) => JSX.Element;
4
5
  export declare const ACLRolesCheckProvider: (props: any) => JSX.Element;
5
6
  export declare const useRoleRecheck: () => () => void;
6
7
  export declare const useACLContext: () => any;
7
- export declare const useACLRoleContext: () => any;
8
- export declare const ACLAllowConfigure: (props: any) => JSX.Element;
8
+ export declare const ACLActionParamsContext: React.Context<any>;
9
+ export declare const useACLRolesCheck: () => {
10
+ data: any;
11
+ getActionAlias: (actionPath: string) => any;
12
+ inResources: (resourceName: string) => any;
13
+ getResourceActionParams: (actionPath: string) => any;
14
+ getStrategyActionParams: (actionPath: string) => {};
15
+ };
16
+ export declare function useACLRoleContext(): any;
9
17
  export declare const ACLCollectionProvider: (props: any) => JSX.Element;
18
+ export declare const useACLActionParamsContext: () => any;
19
+ export declare const useRecordPkValue: () => any;
10
20
  export declare const ACLActionProvider: (props: any) => JSX.Element;
21
+ export declare const useACLFieldWhitelist: () => {
22
+ whitelist: any[];
23
+ schemaInWhitelist(fieldSchema: Schema): boolean;
24
+ };
11
25
  export declare const ACLCollectionFieldProvider: (props: any) => JSX.Element;
12
26
  export declare const ACLMenuItemProvider: (props: any) => JSX.Element;
13
27
  export default ACLProvider;
@@ -1,3 +1,13 @@
1
+ function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
2
+
3
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
+
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
+
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
+
9
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+
1
11
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
12
 
3
13
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -10,21 +20,17 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
10
20
 
11
21
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
22
 
13
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
-
15
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
-
17
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
-
19
- import { useFieldSchema } from '@formily/react';
23
+ import { useField, useFieldSchema } from '@formily/react';
20
24
  import { Spin } from 'antd';
21
- import React, { createContext, useContext } from 'react';
25
+ import React, { createContext, useContext, useEffect } from 'react';
22
26
  import { Redirect } from 'react-router-dom';
23
27
  import { useAPIClient, useRequest } from '../api-client';
28
+ import { useBlockRequestContext } from '../block-provider/BlockProvider';
24
29
  import { useCollection } from '../collection-manager';
25
- import { useRecordIsOwn } from '../record-provider';
30
+ import { useResourceActionContext } from '../collection-manager/ResourceActionProvider';
31
+ import { useRecord } from '../record-provider';
26
32
  import { SchemaComponentOptions, useDesignable } from '../schema-component';
27
- export var ACLContext = /*#__PURE__*/createContext(null);
33
+ export var ACLContext = /*#__PURE__*/createContext({});
28
34
  export var ACLProvider = function ACLProvider(props) {
29
35
  return /*#__PURE__*/React.createElement(SchemaComponentOptions, {
30
36
  components: {
@@ -35,7 +41,40 @@ export var ACLProvider = function ACLProvider(props) {
35
41
  }
36
42
  }, props.children);
37
43
  };
44
+
45
+ var getRouteUrl = function getRouteUrl(props) {
46
+ var _props$children;
47
+
48
+ if (props === null || props === void 0 ? void 0 : props.match) {
49
+ return props.match;
50
+ }
51
+
52
+ return props && getRouteUrl(props === null || props === void 0 ? void 0 : (_props$children = props.children) === null || _props$children === void 0 ? void 0 : _props$children.props);
53
+ };
54
+
55
+ var getRouteAclCheck = function getRouteAclCheck(match, snippets) {
56
+ var _params$name;
57
+
58
+ var url = match.url,
59
+ params = match.params;
60
+
61
+ if (url === '/admin/pm/list' || (params === null || params === void 0 ? void 0 : params.pluginName) || (params === null || params === void 0 ? void 0 : (_params$name = params.name) === null || _params$name === void 0 ? void 0 : _params$name.includes('settings'))) {
62
+ var pmAclCheck = url === '/admin/pm/list' && snippets.includes('pm');
63
+ var pluginTabByName = params === null || params === void 0 ? void 0 : params.name.split('/');
64
+ pluginTabByName.shift();
65
+ var pluginName = params.pluginName || pluginTabByName[0];
66
+ var tabName = params.tabName || pluginTabByName[1];
67
+ var pluginTabSnippet = pluginName && tabName && "!pm.".concat(pluginName, ".").concat(tabName);
68
+ var pluginTabAclCheck = pluginTabSnippet && !snippets.includes(pluginTabSnippet);
69
+ return pmAclCheck || pluginTabAclCheck;
70
+ }
71
+
72
+ return true;
73
+ };
74
+
38
75
  export var ACLRolesCheckProvider = function ACLRolesCheckProvider(props) {
76
+ var route = getRouteUrl(props.children.props);
77
+
39
78
  var _useDesignable = useDesignable(),
40
79
  setDesignable = _useDesignable.setDesignable;
41
80
 
@@ -44,16 +83,16 @@ export var ACLRolesCheckProvider = function ACLRolesCheckProvider(props) {
44
83
  url: 'roles:check'
45
84
  }, {
46
85
  onSuccess: function onSuccess(data) {
47
- var _data$data, _data$data2, _data$data3;
86
+ var _data$data, _data$data2;
48
87
 
49
- if (!(data === null || data === void 0 ? void 0 : (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.allowConfigure) && !(data === null || data === void 0 ? void 0 : (_data$data2 = data.data) === null || _data$data2 === void 0 ? void 0 : _data$data2.allowAll)) {
88
+ if (!(data === null || data === void 0 ? void 0 : (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.snippets.includes('ui.*'))) {
50
89
  setDesignable(false);
51
90
  }
52
91
 
53
- if ((data === null || data === void 0 ? void 0 : (_data$data3 = data.data) === null || _data$data3 === void 0 ? void 0 : _data$data3.role) !== api.auth.role) {
54
- var _data$data4;
92
+ if ((data === null || data === void 0 ? void 0 : (_data$data2 = data.data) === null || _data$data2 === void 0 ? void 0 : _data$data2.role) !== api.auth.role) {
93
+ var _data$data3;
55
94
 
56
- api.auth.setRole(data === null || data === void 0 ? void 0 : (_data$data4 = data.data) === null || _data$data4 === void 0 ? void 0 : _data$data4.role);
95
+ api.auth.setRole(data === null || data === void 0 ? void 0 : (_data$data3 = data.data) === null || _data$data3 === void 0 ? void 0 : _data$data3.role);
57
96
  }
58
97
  }
59
98
  });
@@ -76,11 +115,10 @@ export var useRoleRecheck = function useRoleRecheck() {
76
115
  var ctx = useContext(ACLContext);
77
116
 
78
117
  var _useACLRoleContext = useACLRoleContext(),
79
- allowAll = _useACLRoleContext.allowAll,
80
- allowConfigure = _useACLRoleContext.allowConfigure;
118
+ allowAll = _useACLRoleContext.allowAll;
81
119
 
82
120
  return function () {
83
- if (allowAll || allowConfigure) {
121
+ if (allowAll) {
84
122
  return;
85
123
  }
86
124
 
@@ -90,101 +128,167 @@ export var useRoleRecheck = function useRoleRecheck() {
90
128
  export var useACLContext = function useACLContext() {
91
129
  return useContext(ACLContext);
92
130
  };
93
- export var useACLRoleContext = function useACLRoleContext() {
131
+ export var ACLActionParamsContext = /*#__PURE__*/createContext({});
132
+ export var useACLRolesCheck = function useACLRolesCheck() {
94
133
  var _ctx$data;
95
134
 
96
135
  var ctx = useContext(ACLContext);
97
- var data = (_ctx$data = ctx.data) === null || _ctx$data === void 0 ? void 0 : _ctx$data.data;
98
- return _objectSpread(_objectSpread({}, data), {}, {
99
- getActionParams: function getActionParams(path, _ref) {
100
- var _data$actionAlias, _data$resources, _data$actions, _data$strategy;
101
-
102
- var skipOwnCheck = _ref.skipOwnCheck,
103
- isOwn = _ref.isOwn;
136
+ var data = ctx === null || ctx === void 0 ? void 0 : (_ctx$data = ctx.data) === null || _ctx$data === void 0 ? void 0 : _ctx$data.data;
104
137
 
105
- var _path$split = path.split(':'),
106
- _path$split2 = _slicedToArray(_path$split, 2),
107
- resourceName = _path$split2[0],
108
- act = _path$split2[1];
109
-
110
- var currentAction = (data === null || data === void 0 ? void 0 : (_data$actionAlias = data.actionAlias) === null || _data$actionAlias === void 0 ? void 0 : _data$actionAlias[act]) || act;
111
- var hasResource = data === null || data === void 0 ? void 0 : (_data$resources = data.resources) === null || _data$resources === void 0 ? void 0 : _data$resources.includes(resourceName);
112
- var params = data === null || data === void 0 ? void 0 : (_data$actions = data.actions) === null || _data$actions === void 0 ? void 0 : _data$actions["".concat(resourceName, ":").concat(currentAction)];
113
-
114
- if (hasResource) {
115
- if (!skipOwnCheck && (params === null || params === void 0 ? void 0 : params.own)) {
116
- return isOwn ? params : null;
117
- }
138
+ var getActionAlias = function getActionAlias(actionPath) {
139
+ var _data$actionAlias;
118
140
 
119
- return params;
120
- }
141
+ var actionName = actionPath.split(':').pop();
142
+ return (data === null || data === void 0 ? void 0 : (_data$actionAlias = data.actionAlias) === null || _data$actionAlias === void 0 ? void 0 : _data$actionAlias[actionName]) || actionName;
143
+ };
121
144
 
122
- var strategyActions = (data === null || data === void 0 ? void 0 : (_data$strategy = data.strategy) === null || _data$strategy === void 0 ? void 0 : _data$strategy.actions) || [];
123
- var strategyAction = strategyActions === null || strategyActions === void 0 ? void 0 : strategyActions.find(function (action) {
145
+ return {
146
+ data: data,
147
+ getActionAlias: getActionAlias,
148
+ inResources: function inResources(resourceName) {
149
+ var _data$resources, _data$resources$inclu;
150
+
151
+ return data === null || data === void 0 ? void 0 : (_data$resources = data.resources) === null || _data$resources === void 0 ? void 0 : (_data$resources$inclu = _data$resources.includes) === null || _data$resources$inclu === void 0 ? void 0 : _data$resources$inclu.call(_data$resources, resourceName);
152
+ },
153
+ getResourceActionParams: function getResourceActionParams(actionPath) {
154
+ var _data$actions, _data$actions2;
155
+
156
+ var _actionPath$split = actionPath.split(':'),
157
+ _actionPath$split2 = _slicedToArray(_actionPath$split, 1),
158
+ resourceName = _actionPath$split2[0];
159
+
160
+ var actionAlias = getActionAlias(actionPath);
161
+ return (data === null || data === void 0 ? void 0 : (_data$actions = data.actions) === null || _data$actions === void 0 ? void 0 : _data$actions["".concat(resourceName, ":").concat(actionAlias)]) || (data === null || data === void 0 ? void 0 : (_data$actions2 = data.actions) === null || _data$actions2 === void 0 ? void 0 : _data$actions2[actionPath]);
162
+ },
163
+ getStrategyActionParams: function getStrategyActionParams(actionPath) {
164
+ var _data$strategy, _data$strategy$action;
165
+
166
+ var actionAlias = getActionAlias(actionPath);
167
+ var strategyAction = data === null || data === void 0 ? void 0 : (_data$strategy = data.strategy) === null || _data$strategy === void 0 ? void 0 : (_data$strategy$action = _data$strategy.actions) === null || _data$strategy$action === void 0 ? void 0 : _data$strategy$action.find(function (action) {
124
168
  var _action$split = action.split(':'),
125
169
  _action$split2 = _slicedToArray(_action$split, 1),
126
170
  value = _action$split2[0];
127
171
 
128
- return value === currentAction;
172
+ return value === actionAlias;
129
173
  });
174
+ return strategyAction ? {} : null;
175
+ }
176
+ };
177
+ };
178
+
179
+ var getIgnoreScope = function getIgnoreScope() {
180
+ var _schema$xAclAction;
181
+
182
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
183
+ var schema = options.schema,
184
+ recordPkValue = options.recordPkValue;
185
+ var ignoreScope = false;
186
+
187
+ if (options.ignoreScope) {
188
+ ignoreScope = true;
189
+ }
190
+
191
+ if (schema === null || schema === void 0 ? void 0 : schema['x-acl-ignore-scope']) {
192
+ ignoreScope = true;
193
+ }
194
+
195
+ if (schema === null || schema === void 0 ? void 0 : (_schema$xAclAction = schema['x-acl-action-props']) === null || _schema$xAclAction === void 0 ? void 0 : _schema$xAclAction['skipScopeCheck']) {
196
+ ignoreScope = true;
197
+ }
198
+
199
+ if (!recordPkValue) {
200
+ ignoreScope = true;
201
+ }
130
202
 
131
- if (!strategyAction) {
132
- return;
203
+ return ignoreScope;
204
+ };
205
+
206
+ var useAllowedActions = function useAllowedActions() {
207
+ var _result$service, _result$service$data, _result$service$data$;
208
+
209
+ var result = useBlockRequestContext() || {
210
+ service: useResourceActionContext()
211
+ };
212
+ return result === null || result === void 0 ? void 0 : (_result$service = result.service) === null || _result$service === void 0 ? void 0 : (_result$service$data = _result$service.data) === null || _result$service$data === void 0 ? void 0 : (_result$service$data$ = _result$service$data.meta) === null || _result$service$data$ === void 0 ? void 0 : _result$service$data$.allowedActions;
213
+ };
214
+
215
+ var useResourceName = function useResourceName() {
216
+ var _result$props, _result$service2, _result$service2$defa;
217
+
218
+ var result = useBlockRequestContext() || {
219
+ service: useResourceActionContext()
220
+ };
221
+ return (result === null || result === void 0 ? void 0 : (_result$props = result.props) === null || _result$props === void 0 ? void 0 : _result$props.resource) || (result === null || result === void 0 ? void 0 : (_result$service2 = result.service) === null || _result$service2 === void 0 ? void 0 : (_result$service2$defa = _result$service2.defaultRequest) === null || _result$service2$defa === void 0 ? void 0 : _result$service2$defa.resource);
222
+ };
223
+
224
+ export function useACLRoleContext() {
225
+ var _useACLRolesCheck = useACLRolesCheck(),
226
+ data = _useACLRolesCheck.data,
227
+ getActionAlias = _useACLRolesCheck.getActionAlias,
228
+ inResources = _useACLRolesCheck.inResources,
229
+ getResourceActionParams = _useACLRolesCheck.getResourceActionParams,
230
+ getStrategyActionParams = _useACLRolesCheck.getStrategyActionParams;
231
+
232
+ var allowedActions = useAllowedActions();
233
+
234
+ var verifyScope = function verifyScope(actionName, recordPkValue) {
235
+ var actionAlias = getActionAlias(actionName);
236
+
237
+ if (!Array.isArray(allowedActions === null || allowedActions === void 0 ? void 0 : allowedActions[actionAlias])) {
238
+ return null;
239
+ }
240
+
241
+ return allowedActions[actionAlias].includes(recordPkValue);
242
+ };
243
+
244
+ return _objectSpread(_objectSpread({}, data), {}, {
245
+ parseAction: function parseAction(actionPath) {
246
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
247
+
248
+ var _actionPath$split3 = actionPath.split(':'),
249
+ _actionPath$split4 = _slicedToArray(_actionPath$split3, 2),
250
+ resourceName = _actionPath$split4[0],
251
+ actionName = _actionPath$split4[1];
252
+
253
+ if (!getIgnoreScope(options)) {
254
+ var r = verifyScope(actionName, options.recordPkValue);
255
+
256
+ if (r !== null) {
257
+ return r ? {} : null;
258
+ }
133
259
  }
134
260
 
135
- if (skipOwnCheck) {
261
+ if (data === null || data === void 0 ? void 0 : data.allowAll) {
136
262
  return {};
137
263
  }
138
264
 
139
- var _strategyAction$split = strategyAction.split(':'),
140
- _strategyAction$split2 = _slicedToArray(_strategyAction$split, 2),
141
- actionScope = _strategyAction$split2[1];
142
-
143
- if (actionScope === 'own') {
144
- return isOwn;
265
+ if (inResources(resourceName)) {
266
+ return getResourceActionParams(actionPath);
145
267
  }
146
268
 
147
- return {};
269
+ return getStrategyActionParams(actionPath);
148
270
  }
149
271
  });
150
- };
151
- export var ACLAllowConfigure = function ACLAllowConfigure(props) {
272
+ }
273
+ export var ACLCollectionProvider = function ACLCollectionProvider(props) {
152
274
  var _useACLRoleContext2 = useACLRoleContext(),
153
275
  allowAll = _useACLRoleContext2.allowAll,
154
- allowConfigure = _useACLRoleContext2.allowConfigure;
276
+ parseAction = _useACLRoleContext2.parseAction;
155
277
 
156
- if (allowAll || allowConfigure) {
157
- return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
158
- }
278
+ var schema = useFieldSchema();
159
279
 
160
- return null;
161
- };
162
- var ACLActionParamsContext = /*#__PURE__*/createContext({});
163
- export var ACLCollectionProvider = function ACLCollectionProvider(props) {
164
- var _fieldSchema$xAclAc;
165
-
166
- var _useACLRoleContext3 = useACLRoleContext(),
167
- allowAll = _useACLRoleContext3.allowAll,
168
- allowConfigure = _useACLRoleContext3.allowConfigure,
169
- getActionParams = _useACLRoleContext3.getActionParams;
170
-
171
- var fieldSchema = useFieldSchema();
172
- var isOwn = useRecordIsOwn();
173
-
174
- if (allowAll || allowConfigure) {
280
+ if (allowAll) {
175
281
  return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
176
282
  }
177
283
 
178
- var path = fieldSchema['x-acl-action'];
179
- var skipScopeCheck = (_fieldSchema$xAclAc = fieldSchema['x-acl-action-props']) === null || _fieldSchema$xAclAc === void 0 ? void 0 : _fieldSchema$xAclAc.skipScopeCheck;
284
+ var actionPath = schema['x-acl-action'];
180
285
 
181
- if (!path) {
286
+ if (!actionPath) {
182
287
  return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
183
288
  }
184
289
 
185
- var params = getActionParams(path, {
186
- isOwn: isOwn,
187
- skipOwnCheck: skipScopeCheck === false ? false : true
290
+ var params = parseAction(actionPath, {
291
+ schema: schema
188
292
  });
189
293
 
190
294
  if (!params) {
@@ -195,30 +299,42 @@ export var ACLCollectionProvider = function ACLCollectionProvider(props) {
195
299
  value: params
196
300
  }, props.children);
197
301
  };
302
+ export var useACLActionParamsContext = function useACLActionParamsContext() {
303
+ return useContext(ACLActionParamsContext);
304
+ };
305
+ export var useRecordPkValue = function useRecordPkValue() {
306
+ var _useCollection = useCollection(),
307
+ getPrimaryKey = _useCollection.getPrimaryKey;
308
+
309
+ var record = useRecord();
310
+ var primaryKey = getPrimaryKey();
311
+ return record === null || record === void 0 ? void 0 : record[primaryKey];
312
+ };
198
313
  export var ACLActionProvider = function ACLActionProvider(props) {
199
- var _fieldSchema$xAclAc2;
314
+ var recordPkValue = useRecordPkValue();
315
+ var resource = useResourceName();
200
316
 
201
- var _useCollection = useCollection(),
202
- name = _useCollection.name;
317
+ var _useACLRoleContext3 = useACLRoleContext(),
318
+ parseAction = _useACLRoleContext3.parseAction;
203
319
 
204
- var fieldSchema = useFieldSchema();
205
- var isOwn = useRecordIsOwn();
320
+ var schema = useFieldSchema();
321
+ var actionPath = schema['x-acl-action'];
206
322
 
207
- var _useACLRoleContext4 = useACLRoleContext(),
208
- allowAll = _useACLRoleContext4.allowAll,
209
- allowConfigure = _useACLRoleContext4.allowConfigure,
210
- getActionParams = _useACLRoleContext4.getActionParams;
323
+ if (!actionPath && resource && schema['x-action']) {
324
+ actionPath = "".concat(resource, ":").concat(schema['x-action']);
325
+ }
326
+
327
+ if (!actionPath.includes(':')) {
328
+ actionPath = "".concat(resource, ":").concat(actionPath);
329
+ }
211
330
 
212
- if (!name || allowAll || allowConfigure) {
331
+ if (!actionPath) {
213
332
  return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
214
333
  }
215
334
 
216
- var actionName = fieldSchema['x-action'];
217
- var path = fieldSchema['x-acl-action'] || "".concat(name, ":").concat(actionName);
218
- var skipScopeCheck = (_fieldSchema$xAclAc2 = fieldSchema['x-acl-action-props']) === null || _fieldSchema$xAclAc2 === void 0 ? void 0 : _fieldSchema$xAclAc2.skipScopeCheck;
219
- var params = getActionParams(path, {
220
- skipOwnCheck: skipScopeCheck,
221
- isOwn: isOwn
335
+ var params = parseAction(actionPath, {
336
+ schema: schema,
337
+ recordPkValue: recordPkValue
222
338
  });
223
339
 
224
340
  if (!params) {
@@ -229,19 +345,74 @@ export var ACLActionProvider = function ACLActionProvider(props) {
229
345
  value: params
230
346
  }, props.children);
231
347
  };
348
+ export var useACLFieldWhitelist = function useACLFieldWhitelist() {
349
+ var params = useContext(ACLActionParamsContext);
350
+ var whitelist = [].concat((params === null || params === void 0 ? void 0 : params.whitelist) || []).concat((params === null || params === void 0 ? void 0 : params.fields) || []).concat((params === null || params === void 0 ? void 0 : params.appends) || []);
351
+ return {
352
+ whitelist: whitelist,
353
+ schemaInWhitelist: function schemaInWhitelist(fieldSchema) {
354
+ if (whitelist.length === 0) {
355
+ return true;
356
+ }
357
+
358
+ if (!fieldSchema) {
359
+ return true;
360
+ }
361
+
362
+ if (!fieldSchema['x-collection-field']) {
363
+ return true;
364
+ }
365
+
366
+ var _fieldSchema$xCollec = fieldSchema['x-collection-field'].split('.'),
367
+ _fieldSchema$xCollec2 = _toArray(_fieldSchema$xCollec),
368
+ keys = _fieldSchema$xCollec2.slice(1);
369
+
370
+ return whitelist === null || whitelist === void 0 ? void 0 : whitelist.includes(keys.join('.'));
371
+ }
372
+ };
373
+ };
232
374
  export var ACLCollectionFieldProvider = function ACLCollectionFieldProvider(props) {
375
+ var fieldSchema = useFieldSchema();
376
+ var field = useField();
377
+
378
+ var _useACLRoleContext4 = useACLRoleContext(),
379
+ allowAll = _useACLRoleContext4.allowAll;
380
+
381
+ if (allowAll) {
382
+ return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
383
+ }
384
+
385
+ if (!fieldSchema['x-collection-field']) {
386
+ return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
387
+ }
388
+
389
+ var _useACLFieldWhitelist = useACLFieldWhitelist(),
390
+ whitelist = _useACLFieldWhitelist.whitelist;
391
+
392
+ var allowed = whitelist.length > 0 ? whitelist.includes(fieldSchema.name) : true;
393
+ useEffect(function () {
394
+ if (!allowed) {
395
+ field.required = false;
396
+ field.display = 'hidden';
397
+ }
398
+ }, [allowed]);
399
+
400
+ if (!allowed) {
401
+ return null;
402
+ }
403
+
233
404
  return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
234
405
  };
235
406
  export var ACLMenuItemProvider = function ACLMenuItemProvider(props) {
236
407
  var _useACLRoleContext5 = useACLRoleContext(),
237
408
  allowAll = _useACLRoleContext5.allowAll,
238
- allowConfigure = _useACLRoleContext5.allowConfigure,
239
409
  _useACLRoleContext5$a = _useACLRoleContext5.allowMenuItemIds,
240
- allowMenuItemIds = _useACLRoleContext5$a === void 0 ? [] : _useACLRoleContext5$a;
410
+ allowMenuItemIds = _useACLRoleContext5$a === void 0 ? [] : _useACLRoleContext5$a,
411
+ snippets = _useACLRoleContext5.snippets;
241
412
 
242
413
  var fieldSchema = useFieldSchema();
243
414
 
244
- if (allowAll || allowConfigure) {
415
+ if (allowAll || snippets.includes('ui.*')) {
245
416
  return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
246
417
  }
247
418
 
@@ -0,0 +1,2 @@
1
+ export declare const SettingCenterProvider: (props: any) => JSX.Element;
2
+ export declare const SettingsCenterConfigure: () => JSX.Element;