@tachybase/acl 0.23.41 → 0.23.48

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.
@@ -42,10 +42,6 @@ const predicate = {
42
42
  all: {}
43
43
  };
44
44
  const _ACLAvailableStrategy = class _ACLAvailableStrategy {
45
- acl;
46
- options;
47
- actionsAsObject;
48
- allowConfigure;
49
45
  constructor(acl, options) {
50
46
  this.acl = acl;
51
47
  this.options = options;
@@ -33,11 +33,8 @@ __export(acl_resource_exports, {
33
33
  module.exports = __toCommonJS(acl_resource_exports);
34
34
  var import_lodash = __toESM(require("lodash"));
35
35
  const _ACLResource = class _ACLResource {
36
- actions = /* @__PURE__ */ new Map();
37
- acl;
38
- role;
39
- name;
40
36
  constructor(options) {
37
+ this.actions = /* @__PURE__ */ new Map();
41
38
  this.acl = options.role.acl;
42
39
  this.role = options.role;
43
40
  this.name = options.name;
package/lib/acl-role.js CHANGED
@@ -39,14 +39,13 @@ const _ACLRole = class _ACLRole {
39
39
  constructor(acl, name) {
40
40
  this.acl = acl;
41
41
  this.name = name;
42
+ this.resources = /* @__PURE__ */ new Map();
43
+ this.snippets = /* @__PURE__ */ new Set();
44
+ this._snippetCache = {
45
+ params: null,
46
+ result: null
47
+ };
42
48
  }
43
- strategy;
44
- resources = /* @__PURE__ */ new Map();
45
- snippets = /* @__PURE__ */ new Set();
46
- _snippetCache = {
47
- params: null,
48
- result: null
49
- };
50
49
  _serializeSet(set) {
51
50
  return JSON.stringify([...set].sort());
52
51
  }
package/lib/acl.js CHANGED
@@ -42,36 +42,35 @@ var import_allow_manager = require("./allow-manager");
42
42
  var import_fixed_params_manager = __toESM(require("./fixed-params-manager"));
43
43
  var import_snippet_manager = __toESM(require("./snippet-manager"));
44
44
  const _ACL = class _ACL extends import_node_events.default {
45
- /**
46
- * @internal
47
- */
48
- availableStrategy = /* @__PURE__ */ new Map();
49
- /**
50
- * @internal
51
- */
52
- allowManager = new import_allow_manager.AllowManager(this);
53
- /**
54
- * @internal
55
- */
56
- snippetManager = new import_snippet_manager.default();
57
- /**
58
- * @internal
59
- */
60
- roles = /* @__PURE__ */ new Map();
61
- /**
62
- * @internal
63
- */
64
- actionAlias = /* @__PURE__ */ new Map();
65
- /**
66
- * @internal
67
- */
68
- configResources = [];
69
- availableActions = /* @__PURE__ */ new Map();
70
- fixedParamsManager = new import_fixed_params_manager.default();
71
- middlewares;
72
- middlewareSourceMap = /* @__PURE__ */ new WeakMap();
73
45
  constructor() {
74
46
  super();
47
+ /**
48
+ * @internal
49
+ */
50
+ this.availableStrategy = /* @__PURE__ */ new Map();
51
+ /**
52
+ * @internal
53
+ */
54
+ this.allowManager = new import_allow_manager.AllowManager(this);
55
+ /**
56
+ * @internal
57
+ */
58
+ this.snippetManager = new import_snippet_manager.default();
59
+ /**
60
+ * @internal
61
+ */
62
+ this.roles = /* @__PURE__ */ new Map();
63
+ /**
64
+ * @internal
65
+ */
66
+ this.actionAlias = /* @__PURE__ */ new Map();
67
+ /**
68
+ * @internal
69
+ */
70
+ this.configResources = [];
71
+ this.availableActions = /* @__PURE__ */ new Map();
72
+ this.fixedParamsManager = new import_fixed_params_manager.default();
73
+ this.middlewareSourceMap = /* @__PURE__ */ new WeakMap();
75
74
  this.middlewares = new import_utils.Toposort();
76
75
  this.beforeGrantAction((ctx) => {
77
76
  if (import_lodash.default.isPlainObject(ctx.params) && ctx.params.own) {
@@ -24,6 +24,8 @@ module.exports = __toCommonJS(allow_manager_exports);
24
24
  const _AllowManager = class _AllowManager {
25
25
  constructor(acl) {
26
26
  this.acl = acl;
27
+ this.skipActions = /* @__PURE__ */ new Map();
28
+ this.registeredCondition = /* @__PURE__ */ new Map();
27
29
  this.registerAllowCondition("loggedIn", (ctx) => {
28
30
  return ctx.state.currentUser;
29
31
  });
@@ -43,8 +45,6 @@ const _AllowManager = class _AllowManager {
43
45
  return (_a = role.getStrategy()) == null ? void 0 : _a.allowConfigure;
44
46
  });
45
47
  }
46
- skipActions = /* @__PURE__ */ new Map();
47
- registeredCondition = /* @__PURE__ */ new Map();
48
48
  allow(resourceName, actionName, condition) {
49
49
  const actionMap = this.skipActions.get(resourceName) || /* @__PURE__ */ new Map();
50
50
  actionMap.set(actionName, condition || true);
@@ -24,7 +24,9 @@ module.exports = __toCommonJS(fixed_params_manager_exports);
24
24
  var import_utils = require("@tachybase/utils");
25
25
  const SPLIT = ":";
26
26
  const _FixedParamsManager = class _FixedParamsManager {
27
- merger = /* @__PURE__ */ new Map();
27
+ constructor() {
28
+ this.merger = /* @__PURE__ */ new Map();
29
+ }
28
30
  addParams(resource, action, merger) {
29
31
  const path = this.getActionPath(resource, action);
30
32
  this.merger.set(path, [...this.getParamsMerger(resource, action), merger]);
@@ -41,7 +41,9 @@ const _Snippet = class _Snippet {
41
41
  __name(_Snippet, "Snippet");
42
42
  let Snippet = _Snippet;
43
43
  const _SnippetManager = class _SnippetManager {
44
- snippets = /* @__PURE__ */ new Map();
44
+ constructor() {
45
+ this.snippets = /* @__PURE__ */ new Map();
46
+ }
45
47
  register(snippet) {
46
48
  this.snippets.set(snippet.name, snippet);
47
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachybase/acl",
3
- "version": "0.23.41",
3
+ "version": "0.23.48",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./lib/index.js",
@@ -9,8 +9,8 @@
9
9
  "koa-compose": "^4.1.0",
10
10
  "lodash": "4.17.21",
11
11
  "minimatch": "^5.1.6",
12
- "@tachybase/resourcer": "0.23.41",
13
- "@tachybase/utils": "0.23.41"
12
+ "@tachybase/resourcer": "0.23.48",
13
+ "@tachybase/utils": "0.23.48"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@types/lodash": "4.17.13",