@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
@@ -5,7 +5,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.useRoleRecheck = exports.useACLRoleContext = exports.useACLContext = exports.default = exports.ACLRolesCheckProvider = exports.ACLProvider = exports.ACLMenuItemProvider = exports.ACLContext = exports.ACLCollectionProvider = exports.ACLCollectionFieldProvider = exports.ACLAllowConfigure = exports.ACLActionProvider = void 0;
8
+ exports.useACLFieldWhitelist = exports.useACLContext = exports.useACLActionParamsContext = exports.default = exports.ACLRolesCheckProvider = exports.ACLProvider = exports.ACLMenuItemProvider = exports.ACLContext = exports.ACLCollectionProvider = exports.ACLCollectionFieldProvider = exports.ACLActionProvider = exports.ACLActionParamsContext = void 0;
9
+ exports.useACLRoleContext = useACLRoleContext;
10
+ exports.useRoleRecheck = exports.useRecordPkValue = exports.useACLRolesCheck = void 0;
9
11
 
10
12
  var _react = require("@formily/react");
11
13
 
@@ -17,8 +19,12 @@ var _reactRouterDom = require("react-router-dom");
17
19
 
18
20
  var _apiClient = require("../api-client");
19
21
 
22
+ var _BlockProvider = require("../block-provider/BlockProvider");
23
+
20
24
  var _collectionManager = require("../collection-manager");
21
25
 
26
+ var _ResourceActionProvider = require("../collection-manager/ResourceActionProvider");
27
+
22
28
  var _recordProvider = require("../record-provider");
23
29
 
24
30
  var _schemaComponent = require("../schema-component");
@@ -27,6 +33,16 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
27
33
 
28
34
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
35
 
36
+ function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
37
+
38
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
39
+
40
+ 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; }
41
+
42
+ 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; }
43
+
44
+ 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; }
45
+
30
46
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
31
47
 
32
48
  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."); }
@@ -39,13 +55,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
39
55
 
40
56
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
41
57
 
42
- 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; }
43
-
44
- 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; }
45
-
46
- 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; }
47
-
48
- var ACLContext = /*#__PURE__*/(0, _react2.createContext)(null);
58
+ var ACLContext = /*#__PURE__*/(0, _react2.createContext)({});
49
59
  exports.ACLContext = ACLContext;
50
60
 
51
61
  var ACLProvider = function ACLProvider(props) {
@@ -61,7 +71,39 @@ var ACLProvider = function ACLProvider(props) {
61
71
 
62
72
  exports.ACLProvider = ACLProvider;
63
73
 
74
+ var getRouteUrl = function getRouteUrl(props) {
75
+ var _props$children;
76
+
77
+ if (props === null || props === void 0 ? void 0 : props.match) {
78
+ return props.match;
79
+ }
80
+
81
+ return props && getRouteUrl(props === null || props === void 0 ? void 0 : (_props$children = props.children) === null || _props$children === void 0 ? void 0 : _props$children.props);
82
+ };
83
+
84
+ var getRouteAclCheck = function getRouteAclCheck(match, snippets) {
85
+ var _params$name;
86
+
87
+ var url = match.url,
88
+ params = match.params;
89
+
90
+ 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'))) {
91
+ var pmAclCheck = url === '/admin/pm/list' && snippets.includes('pm');
92
+ var pluginTabByName = params === null || params === void 0 ? void 0 : params.name.split('/');
93
+ pluginTabByName.shift();
94
+ var pluginName = params.pluginName || pluginTabByName[0];
95
+ var tabName = params.tabName || pluginTabByName[1];
96
+ var pluginTabSnippet = pluginName && tabName && "!pm.".concat(pluginName, ".").concat(tabName);
97
+ var pluginTabAclCheck = pluginTabSnippet && !snippets.includes(pluginTabSnippet);
98
+ return pmAclCheck || pluginTabAclCheck;
99
+ }
100
+
101
+ return true;
102
+ };
103
+
64
104
  var ACLRolesCheckProvider = function ACLRolesCheckProvider(props) {
105
+ var route = getRouteUrl(props.children.props);
106
+
65
107
  var _useDesignable = (0, _schemaComponent.useDesignable)(),
66
108
  setDesignable = _useDesignable.setDesignable;
67
109
 
@@ -70,16 +112,16 @@ var ACLRolesCheckProvider = function ACLRolesCheckProvider(props) {
70
112
  url: 'roles:check'
71
113
  }, {
72
114
  onSuccess: function onSuccess(data) {
73
- var _data$data, _data$data2, _data$data3;
115
+ var _data$data, _data$data2;
74
116
 
75
- 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)) {
117
+ if (!(data === null || data === void 0 ? void 0 : (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.snippets.includes('ui.*'))) {
76
118
  setDesignable(false);
77
119
  }
78
120
 
79
- 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) {
80
- var _data$data4;
121
+ 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) {
122
+ var _data$data3;
81
123
 
82
- api.auth.setRole(data === null || data === void 0 ? void 0 : (_data$data4 = data.data) === null || _data$data4 === void 0 ? void 0 : _data$data4.role);
124
+ api.auth.setRole(data === null || data === void 0 ? void 0 : (_data$data3 = data.data) === null || _data$data3 === void 0 ? void 0 : _data$data3.role);
83
125
  }
84
126
  }
85
127
  });
@@ -105,11 +147,10 @@ var useRoleRecheck = function useRoleRecheck() {
105
147
  var ctx = (0, _react2.useContext)(ACLContext);
106
148
 
107
149
  var _useACLRoleContext = useACLRoleContext(),
108
- allowAll = _useACLRoleContext.allowAll,
109
- allowConfigure = _useACLRoleContext.allowConfigure;
150
+ allowAll = _useACLRoleContext.allowAll;
110
151
 
111
152
  return function () {
112
- if (allowAll || allowConfigure) {
153
+ if (allowAll) {
113
154
  return;
114
155
  }
115
156
 
@@ -124,108 +165,172 @@ var useACLContext = function useACLContext() {
124
165
  };
125
166
 
126
167
  exports.useACLContext = useACLContext;
168
+ var ACLActionParamsContext = /*#__PURE__*/(0, _react2.createContext)({});
169
+ exports.ACLActionParamsContext = ACLActionParamsContext;
127
170
 
128
- var useACLRoleContext = function useACLRoleContext() {
171
+ var useACLRolesCheck = function useACLRolesCheck() {
129
172
  var _ctx$data;
130
173
 
131
174
  var ctx = (0, _react2.useContext)(ACLContext);
132
- var data = (_ctx$data = ctx.data) === null || _ctx$data === void 0 ? void 0 : _ctx$data.data;
133
- return _objectSpread(_objectSpread({}, data), {}, {
134
- getActionParams: function getActionParams(path, _ref) {
135
- var _data$actionAlias, _data$resources, _data$actions, _data$strategy;
175
+ var data = ctx === null || ctx === void 0 ? void 0 : (_ctx$data = ctx.data) === null || _ctx$data === void 0 ? void 0 : _ctx$data.data;
136
176
 
137
- var skipOwnCheck = _ref.skipOwnCheck,
138
- isOwn = _ref.isOwn;
139
-
140
- var _path$split = path.split(':'),
141
- _path$split2 = _slicedToArray(_path$split, 2),
142
- resourceName = _path$split2[0],
143
- act = _path$split2[1];
144
-
145
- var currentAction = (data === null || data === void 0 ? void 0 : (_data$actionAlias = data.actionAlias) === null || _data$actionAlias === void 0 ? void 0 : _data$actionAlias[act]) || act;
146
- var hasResource = data === null || data === void 0 ? void 0 : (_data$resources = data.resources) === null || _data$resources === void 0 ? void 0 : _data$resources.includes(resourceName);
147
- 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)];
148
-
149
- if (hasResource) {
150
- if (!skipOwnCheck && (params === null || params === void 0 ? void 0 : params.own)) {
151
- return isOwn ? params : null;
152
- }
177
+ var getActionAlias = function getActionAlias(actionPath) {
178
+ var _data$actionAlias;
153
179
 
154
- return params;
155
- }
180
+ var actionName = actionPath.split(':').pop();
181
+ return (data === null || data === void 0 ? void 0 : (_data$actionAlias = data.actionAlias) === null || _data$actionAlias === void 0 ? void 0 : _data$actionAlias[actionName]) || actionName;
182
+ };
156
183
 
157
- var strategyActions = (data === null || data === void 0 ? void 0 : (_data$strategy = data.strategy) === null || _data$strategy === void 0 ? void 0 : _data$strategy.actions) || [];
158
- var strategyAction = strategyActions === null || strategyActions === void 0 ? void 0 : strategyActions.find(function (action) {
184
+ return {
185
+ data: data,
186
+ getActionAlias: getActionAlias,
187
+ inResources: function inResources(resourceName) {
188
+ var _data$resources, _data$resources$inclu;
189
+
190
+ 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);
191
+ },
192
+ getResourceActionParams: function getResourceActionParams(actionPath) {
193
+ var _data$actions, _data$actions2;
194
+
195
+ var _actionPath$split = actionPath.split(':'),
196
+ _actionPath$split2 = _slicedToArray(_actionPath$split, 1),
197
+ resourceName = _actionPath$split2[0];
198
+
199
+ var actionAlias = getActionAlias(actionPath);
200
+ 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]);
201
+ },
202
+ getStrategyActionParams: function getStrategyActionParams(actionPath) {
203
+ var _data$strategy, _data$strategy$action;
204
+
205
+ var actionAlias = getActionAlias(actionPath);
206
+ 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) {
159
207
  var _action$split = action.split(':'),
160
208
  _action$split2 = _slicedToArray(_action$split, 1),
161
209
  value = _action$split2[0];
162
210
 
163
- return value === currentAction;
211
+ return value === actionAlias;
164
212
  });
213
+ return strategyAction ? {} : null;
214
+ }
215
+ };
216
+ };
165
217
 
166
- if (!strategyAction) {
167
- return;
168
- }
218
+ exports.useACLRolesCheck = useACLRolesCheck;
169
219
 
170
- if (skipOwnCheck) {
171
- return {};
172
- }
220
+ var getIgnoreScope = function getIgnoreScope() {
221
+ var _schema$xAclAction;
173
222
 
174
- var _strategyAction$split = strategyAction.split(':'),
175
- _strategyAction$split2 = _slicedToArray(_strategyAction$split, 2),
176
- actionScope = _strategyAction$split2[1];
223
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
224
+ var schema = options.schema,
225
+ recordPkValue = options.recordPkValue;
226
+ var ignoreScope = false;
177
227
 
178
- if (actionScope === 'own') {
179
- return isOwn;
180
- }
228
+ if (options.ignoreScope) {
229
+ ignoreScope = true;
230
+ }
181
231
 
182
- return {};
183
- }
184
- });
232
+ if (schema === null || schema === void 0 ? void 0 : schema['x-acl-ignore-scope']) {
233
+ ignoreScope = true;
234
+ }
235
+
236
+ 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']) {
237
+ ignoreScope = true;
238
+ }
239
+
240
+ if (!recordPkValue) {
241
+ ignoreScope = true;
242
+ }
243
+
244
+ return ignoreScope;
185
245
  };
186
246
 
187
- exports.useACLRoleContext = useACLRoleContext;
247
+ var useAllowedActions = function useAllowedActions() {
248
+ var _result$service, _result$service$data, _result$service$data$;
188
249
 
189
- var ACLAllowConfigure = function ACLAllowConfigure(props) {
190
- var _useACLRoleContext2 = useACLRoleContext(),
191
- allowAll = _useACLRoleContext2.allowAll,
192
- allowConfigure = _useACLRoleContext2.allowConfigure;
250
+ var result = (0, _BlockProvider.useBlockRequestContext)() || {
251
+ service: (0, _ResourceActionProvider.useResourceActionContext)()
252
+ };
253
+ 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;
254
+ };
193
255
 
194
- if (allowAll || allowConfigure) {
195
- return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
196
- }
256
+ var useResourceName = function useResourceName() {
257
+ var _result$props, _result$service2, _result$service2$defa;
197
258
 
198
- return null;
259
+ var result = (0, _BlockProvider.useBlockRequestContext)() || {
260
+ service: (0, _ResourceActionProvider.useResourceActionContext)()
261
+ };
262
+ 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);
199
263
  };
200
264
 
201
- exports.ACLAllowConfigure = ACLAllowConfigure;
202
- var ACLActionParamsContext = /*#__PURE__*/(0, _react2.createContext)({});
265
+ function useACLRoleContext() {
266
+ var _useACLRolesCheck = useACLRolesCheck(),
267
+ data = _useACLRolesCheck.data,
268
+ getActionAlias = _useACLRolesCheck.getActionAlias,
269
+ inResources = _useACLRolesCheck.inResources,
270
+ getResourceActionParams = _useACLRolesCheck.getResourceActionParams,
271
+ getStrategyActionParams = _useACLRolesCheck.getStrategyActionParams;
203
272
 
204
- var ACLCollectionProvider = function ACLCollectionProvider(props) {
205
- var _fieldSchema$xAclAc;
273
+ var allowedActions = useAllowedActions();
206
274
 
207
- var _useACLRoleContext3 = useACLRoleContext(),
208
- allowAll = _useACLRoleContext3.allowAll,
209
- allowConfigure = _useACLRoleContext3.allowConfigure,
210
- getActionParams = _useACLRoleContext3.getActionParams;
275
+ var verifyScope = function verifyScope(actionName, recordPkValue) {
276
+ var actionAlias = getActionAlias(actionName);
211
277
 
212
- var fieldSchema = (0, _react.useFieldSchema)();
213
- var isOwn = (0, _recordProvider.useRecordIsOwn)();
278
+ if (!Array.isArray(allowedActions === null || allowedActions === void 0 ? void 0 : allowedActions[actionAlias])) {
279
+ return null;
280
+ }
214
281
 
215
- if (allowAll || allowConfigure) {
282
+ return allowedActions[actionAlias].includes(recordPkValue);
283
+ };
284
+
285
+ return _objectSpread(_objectSpread({}, data), {}, {
286
+ parseAction: function parseAction(actionPath) {
287
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
288
+
289
+ var _actionPath$split3 = actionPath.split(':'),
290
+ _actionPath$split4 = _slicedToArray(_actionPath$split3, 2),
291
+ resourceName = _actionPath$split4[0],
292
+ actionName = _actionPath$split4[1];
293
+
294
+ if (!getIgnoreScope(options)) {
295
+ var r = verifyScope(actionName, options.recordPkValue);
296
+
297
+ if (r !== null) {
298
+ return r ? {} : null;
299
+ }
300
+ }
301
+
302
+ if (data === null || data === void 0 ? void 0 : data.allowAll) {
303
+ return {};
304
+ }
305
+
306
+ if (inResources(resourceName)) {
307
+ return getResourceActionParams(actionPath);
308
+ }
309
+
310
+ return getStrategyActionParams(actionPath);
311
+ }
312
+ });
313
+ }
314
+
315
+ var ACLCollectionProvider = function ACLCollectionProvider(props) {
316
+ var _useACLRoleContext2 = useACLRoleContext(),
317
+ allowAll = _useACLRoleContext2.allowAll,
318
+ parseAction = _useACLRoleContext2.parseAction;
319
+
320
+ var schema = (0, _react.useFieldSchema)();
321
+
322
+ if (allowAll) {
216
323
  return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
217
324
  }
218
325
 
219
- var path = fieldSchema['x-acl-action'];
220
- var skipScopeCheck = (_fieldSchema$xAclAc = fieldSchema['x-acl-action-props']) === null || _fieldSchema$xAclAc === void 0 ? void 0 : _fieldSchema$xAclAc.skipScopeCheck;
326
+ var actionPath = schema['x-acl-action'];
221
327
 
222
- if (!path) {
328
+ if (!actionPath) {
223
329
  return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
224
330
  }
225
331
 
226
- var params = getActionParams(path, {
227
- isOwn: isOwn,
228
- skipOwnCheck: skipScopeCheck === false ? false : true
332
+ var params = parseAction(actionPath, {
333
+ schema: schema
229
334
  });
230
335
 
231
336
  if (!params) {
@@ -239,30 +344,48 @@ var ACLCollectionProvider = function ACLCollectionProvider(props) {
239
344
 
240
345
  exports.ACLCollectionProvider = ACLCollectionProvider;
241
346
 
242
- var ACLActionProvider = function ACLActionProvider(props) {
243
- var _fieldSchema$xAclAc2;
347
+ var useACLActionParamsContext = function useACLActionParamsContext() {
348
+ return (0, _react2.useContext)(ACLActionParamsContext);
349
+ };
350
+
351
+ exports.useACLActionParamsContext = useACLActionParamsContext;
244
352
 
353
+ var useRecordPkValue = function useRecordPkValue() {
245
354
  var _useCollection = (0, _collectionManager.useCollection)(),
246
- name = _useCollection.name;
355
+ getPrimaryKey = _useCollection.getPrimaryKey;
247
356
 
248
- var fieldSchema = (0, _react.useFieldSchema)();
249
- var isOwn = (0, _recordProvider.useRecordIsOwn)();
357
+ var record = (0, _recordProvider.useRecord)();
358
+ var primaryKey = getPrimaryKey();
359
+ return record === null || record === void 0 ? void 0 : record[primaryKey];
360
+ };
250
361
 
251
- var _useACLRoleContext4 = useACLRoleContext(),
252
- allowAll = _useACLRoleContext4.allowAll,
253
- allowConfigure = _useACLRoleContext4.allowConfigure,
254
- getActionParams = _useACLRoleContext4.getActionParams;
362
+ exports.useRecordPkValue = useRecordPkValue;
363
+
364
+ var ACLActionProvider = function ACLActionProvider(props) {
365
+ var recordPkValue = useRecordPkValue();
366
+ var resource = useResourceName();
367
+
368
+ var _useACLRoleContext3 = useACLRoleContext(),
369
+ parseAction = _useACLRoleContext3.parseAction;
370
+
371
+ var schema = (0, _react.useFieldSchema)();
372
+ var actionPath = schema['x-acl-action'];
255
373
 
256
- if (!name || allowAll || allowConfigure) {
374
+ if (!actionPath && resource && schema['x-action']) {
375
+ actionPath = "".concat(resource, ":").concat(schema['x-action']);
376
+ }
377
+
378
+ if (!actionPath.includes(':')) {
379
+ actionPath = "".concat(resource, ":").concat(actionPath);
380
+ }
381
+
382
+ if (!actionPath) {
257
383
  return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
258
384
  }
259
385
 
260
- var actionName = fieldSchema['x-action'];
261
- var path = fieldSchema['x-acl-action'] || "".concat(name, ":").concat(actionName);
262
- var skipScopeCheck = (_fieldSchema$xAclAc2 = fieldSchema['x-acl-action-props']) === null || _fieldSchema$xAclAc2 === void 0 ? void 0 : _fieldSchema$xAclAc2.skipScopeCheck;
263
- var params = getActionParams(path, {
264
- skipOwnCheck: skipScopeCheck,
265
- isOwn: isOwn
386
+ var params = parseAction(actionPath, {
387
+ schema: schema,
388
+ recordPkValue: recordPkValue
266
389
  });
267
390
 
268
391
  if (!params) {
@@ -276,7 +399,65 @@ var ACLActionProvider = function ACLActionProvider(props) {
276
399
 
277
400
  exports.ACLActionProvider = ACLActionProvider;
278
401
 
402
+ var useACLFieldWhitelist = function useACLFieldWhitelist() {
403
+ var params = (0, _react2.useContext)(ACLActionParamsContext);
404
+ 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) || []);
405
+ return {
406
+ whitelist: whitelist,
407
+ schemaInWhitelist: function schemaInWhitelist(fieldSchema) {
408
+ if (whitelist.length === 0) {
409
+ return true;
410
+ }
411
+
412
+ if (!fieldSchema) {
413
+ return true;
414
+ }
415
+
416
+ if (!fieldSchema['x-collection-field']) {
417
+ return true;
418
+ }
419
+
420
+ var _fieldSchema$xCollec = fieldSchema['x-collection-field'].split('.'),
421
+ _fieldSchema$xCollec2 = _toArray(_fieldSchema$xCollec),
422
+ keys = _fieldSchema$xCollec2.slice(1);
423
+
424
+ return whitelist === null || whitelist === void 0 ? void 0 : whitelist.includes(keys.join('.'));
425
+ }
426
+ };
427
+ };
428
+
429
+ exports.useACLFieldWhitelist = useACLFieldWhitelist;
430
+
279
431
  var ACLCollectionFieldProvider = function ACLCollectionFieldProvider(props) {
432
+ var fieldSchema = (0, _react.useFieldSchema)();
433
+ var field = (0, _react.useField)();
434
+
435
+ var _useACLRoleContext4 = useACLRoleContext(),
436
+ allowAll = _useACLRoleContext4.allowAll;
437
+
438
+ if (allowAll) {
439
+ return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
440
+ }
441
+
442
+ if (!fieldSchema['x-collection-field']) {
443
+ return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
444
+ }
445
+
446
+ var _useACLFieldWhitelist = useACLFieldWhitelist(),
447
+ whitelist = _useACLFieldWhitelist.whitelist;
448
+
449
+ var allowed = whitelist.length > 0 ? whitelist.includes(fieldSchema.name) : true;
450
+ (0, _react2.useEffect)(function () {
451
+ if (!allowed) {
452
+ field.required = false;
453
+ field.display = 'hidden';
454
+ }
455
+ }, [allowed]);
456
+
457
+ if (!allowed) {
458
+ return null;
459
+ }
460
+
280
461
  return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
281
462
  };
282
463
 
@@ -285,13 +466,13 @@ exports.ACLCollectionFieldProvider = ACLCollectionFieldProvider;
285
466
  var ACLMenuItemProvider = function ACLMenuItemProvider(props) {
286
467
  var _useACLRoleContext5 = useACLRoleContext(),
287
468
  allowAll = _useACLRoleContext5.allowAll,
288
- allowConfigure = _useACLRoleContext5.allowConfigure,
289
469
  _useACLRoleContext5$a = _useACLRoleContext5.allowMenuItemIds,
290
- allowMenuItemIds = _useACLRoleContext5$a === void 0 ? [] : _useACLRoleContext5$a;
470
+ allowMenuItemIds = _useACLRoleContext5$a === void 0 ? [] : _useACLRoleContext5$a,
471
+ snippets = _useACLRoleContext5.snippets;
291
472
 
292
473
  var fieldSchema = (0, _react.useFieldSchema)();
293
474
 
294
- if (allowAll || allowConfigure) {
475
+ if (allowAll || snippets.includes('ui.*')) {
295
476
  return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
296
477
  }
297
478
 
@@ -0,0 +1,2 @@
1
+ export declare const SettingCenterProvider: (props: any) => JSX.Element;
2
+ export declare const SettingsCenterConfigure: () => JSX.Element;