@via-profit/ability 3.5.4 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,38 +1,38 @@
1
- declare class AbilityCode<Code extends string | number> {
2
- _code: Code;
3
- constructor(code: Code);
4
- get code(): Code;
5
- isEqual(compareWith: AbilityCode<Code> | null): boolean;
6
- isNotEqual(compareWith: AbilityCode<Code> | null): boolean;
7
- }
8
-
9
- type AbilityCompareCodeType = 'and' | 'or';
10
- declare class AbilityCompare extends AbilityCode<AbilityCompareCodeType> {
11
- static and: AbilityCompare;
12
- static or: AbilityCompare;
13
- }
1
+ type AbilityCompareCode = 'and' | 'or';
2
+ type AbilityCompareType = AbilityCompareCode & {
3
+ __brand: 'AbilityCompare';
4
+ };
5
+ declare const AbilityCompare: {
6
+ readonly or: AbilityCompareType;
7
+ readonly and: AbilityCompareType;
8
+ };
14
9
 
15
- type AbilityConditionCodeType = '=' | '<>' | '>' | '<' | '>=' | '<=' | 'in' | 'not in' | 'contains' | 'not contains' | 'length greater than' | 'length less than' | 'length equals' | 'always' | 'never';
16
- type AbilityConditionLiteralType = 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'in' | 'not_in' | 'greater_than' | 'less_than' | 'less_or_equal' | 'greater_or_equal' | 'length_greater_than' | 'length_less_than' | 'length_equals' | 'always' | 'never';
17
- declare class AbilityCondition extends AbilityCode<AbilityConditionCodeType> {
18
- static equals: AbilityCondition;
19
- static not_equals: AbilityCondition;
20
- static greater_than: AbilityCondition;
21
- static less_than: AbilityCondition;
22
- static less_or_equal: AbilityCondition;
23
- static greater_or_equal: AbilityCondition;
24
- static in: AbilityCondition;
25
- static not_in: AbilityCondition;
26
- static contains: AbilityCondition;
27
- static not_contains: AbilityCondition;
28
- static length_greater_than: AbilityCondition;
29
- static length_less_than: AbilityCondition;
30
- static length_equals: AbilityCondition;
31
- static always: AbilityCondition;
32
- static never: AbilityCondition;
33
- static fromLiteral(literal: AbilityConditionLiteralType): AbilityCondition;
34
- get literal(): AbilityConditionLiteralType;
35
- }
10
+ type AbilityConditionCode = '=' | '<>' | '>' | '<' | '>=' | '<=' | 'in' | 'not in' | 'contains' | 'not contains' | 'length greater than' | 'length less than' | 'length equals' | 'always' | 'never';
11
+ type AbilityConditionLiteral = 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'in' | 'not_in' | 'greater_than' | 'less_than' | 'less_or_equal' | 'greater_or_equal' | 'length_greater_than' | 'length_less_than' | 'length_equals' | 'always' | 'never';
12
+ type AbilityConditionType = AbilityConditionCode & {
13
+ __brand: 'AbilityCondition';
14
+ };
15
+ declare const AbilityCondition: {
16
+ readonly equals: AbilityConditionType;
17
+ readonly not_equals: AbilityConditionType;
18
+ readonly greater_than: AbilityConditionType;
19
+ readonly less_than: AbilityConditionType;
20
+ readonly less_or_equal: AbilityConditionType;
21
+ readonly greater_or_equal: AbilityConditionType;
22
+ readonly in: AbilityConditionType;
23
+ readonly not_in: AbilityConditionType;
24
+ readonly contains: AbilityConditionType;
25
+ readonly not_contains: AbilityConditionType;
26
+ readonly length_greater_than: AbilityConditionType;
27
+ readonly length_less_than: AbilityConditionType;
28
+ readonly length_equals: AbilityConditionType;
29
+ readonly always: AbilityConditionType;
30
+ readonly never: AbilityConditionType;
31
+ };
32
+ declare function fromLiteral(literal: AbilityConditionLiteral): AbilityConditionType;
33
+ declare function toLiteral(cond: AbilityConditionType): AbilityConditionLiteral;
34
+ declare function isConditionEqual(a: AbilityConditionType | null, b: AbilityConditionType | null): boolean;
35
+ declare function isConditionNotEqual(a: AbilityConditionType | null, b: AbilityConditionType | null): boolean;
36
36
 
37
37
  declare class AbilityError extends Error {
38
38
  constructor(message: string, options?: ErrorOptions);
@@ -41,16 +41,22 @@ declare class AbilityParserError extends Error {
41
41
  constructor(message: string, options?: ErrorOptions);
42
42
  }
43
43
 
44
- type AbilityMatchCodeType = 'pending' | 'match' | 'mismatch';
45
- declare class AbilityMatch extends AbilityCode<AbilityMatchCodeType> {
46
- static pending: AbilityMatch;
47
- static match: AbilityMatch;
48
- static mismatch: AbilityMatch;
49
- }
44
+ type AbilityMatchCode = 'pending' | 'match' | 'mismatch' | 'except-mismatch' | 'disabled';
45
+ type AbilityMatchType = AbilityMatchCode & {
46
+ __brand: 'AbilityMatch';
47
+ };
48
+ declare const AbilityMatch: {
49
+ readonly pending: AbilityMatchType;
50
+ readonly match: AbilityMatchType;
51
+ readonly mismatch: AbilityMatchType;
52
+ readonly exceptMismatch: AbilityMatchType;
53
+ readonly disabled: AbilityMatchType;
54
+ };
50
55
 
51
56
  type AbilityRuleConfig = {
52
57
  readonly id?: string | null;
53
58
  readonly name?: string | null;
59
+ readonly description?: string | null;
54
60
  /**
55
61
  * Subject key path like a 'user.name'
56
62
  */
@@ -59,15 +65,16 @@ type AbilityRuleConfig = {
59
65
  * Resource key path like a 'user.name' or value
60
66
  */
61
67
  readonly resource: string | number | boolean | null | (string | number | boolean | null)[];
62
- readonly condition: AbilityConditionCodeType;
68
+ readonly condition: AbilityConditionType;
69
+ readonly disabled?: boolean;
63
70
  };
64
71
  type AbilityRuleConstructorProps = Omit<AbilityRuleConfig, 'condition'> & {
65
- readonly condition: AbilityCondition;
72
+ readonly condition: AbilityConditionType;
66
73
  };
67
74
  /**
68
75
  * Represents a rule that defines a condition to be checked against a subject and resource.
69
76
  */
70
- declare class AbilityRule<Resources extends object = object, Environment = unknown> {
77
+ declare class AbilityRule<Resources extends object = object, Environment extends object = object> {
71
78
  /**
72
79
  * Subject key path like a 'user.name'
73
80
  */
@@ -76,10 +83,12 @@ declare class AbilityRule<Resources extends object = object, Environment = unkno
76
83
  * Resource key path like a 'user.name' or value
77
84
  */
78
85
  resource: AbilityRuleConfig['resource'];
79
- condition: AbilityCondition;
86
+ condition: AbilityConditionType;
80
87
  name: string;
88
+ description?: string | null;
81
89
  id: string;
82
- state: AbilityMatch;
90
+ state: AbilityMatchType;
91
+ disabled: boolean;
83
92
  /**
84
93
  * Creates an instance of AbilityRule.
85
94
  * @param {string} params.id - The unique identifier of the rule.
@@ -87,26 +96,29 @@ declare class AbilityRule<Resources extends object = object, Environment = unkno
87
96
  * @param {AbilityCondition} params.condition - The condition to evaluate.
88
97
  * @param {string} params.subject - The subject of the rule.
89
98
  * @param {string} params.resource - The resource to compare against.
99
+ * @param {boolean} params.disabled - Disabling flag.
90
100
  * @param params
91
101
  */
92
102
  constructor(params: AbilityRuleConstructorProps);
93
- private isPrimitive;
94
- private isNumber;
95
- private isString;
96
- private valueLen;
97
- private operatorHandlers;
103
+ static isPrimitive(v: unknown): v is string | number | boolean | null;
104
+ static isNumber(v: unknown): v is number;
105
+ static isString(v: unknown): v is string;
106
+ static valueLen: (v: unknown) => number | null;
107
+ static operatorHandlers: { [K in AbilityConditionLiteral]: (a: unknown, b: unknown) => boolean; };
98
108
  /**
99
109
  * Check if the rule is matched
100
110
  * @param resource - The resource to check
101
111
  * @param environment
102
112
  */
103
- check(resource: Resources | null, environment?: Environment): AbilityMatch;
113
+ check(resource: Resources | null, environment?: Environment): AbilityMatchType;
104
114
  /**
105
115
  * Extract values from the resourceData
106
116
  * @param resourceData - The resourceData to extract values from
107
117
  * @param environment - Environment data
108
118
  */
109
119
  extractValues(resourceData: Resources | null, environment?: Environment | null): [AbilityRuleConfig['resource'] | undefined, AbilityRuleConfig['resource'] | undefined];
120
+ private static readonly _pathCache;
121
+ private static _parsePath;
110
122
  /**
111
123
  * Get the value of the object by dot notation
112
124
  * @param resource - The object to get the value from
@@ -117,86 +129,99 @@ declare class AbilityRule<Resources extends object = object, Environment = unkno
117
129
  copyWith(props: Partial<{
118
130
  id: string | null;
119
131
  name: string | null;
132
+ description: string | null;
120
133
  subject: string;
121
134
  resource: AbilityRuleConfig['resource'];
122
- condition: AbilityCondition;
135
+ condition: AbilityConditionType;
123
136
  }>): AbilityRule<Resources, Environment>;
124
- static equals<Resources extends object = object, Environment = unknown>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
125
- static notEquals<Resources extends object = object, Environment = unknown>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
126
- static contains<Resources extends object = object, Environment = unknown>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
127
- static notContains<Resources extends object = object, Environment = unknown>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
128
- static notIn<Resources extends object = object, Environment = unknown>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
129
- static in<Resources extends object = object, Environment = unknown>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
130
- static notEqual<Resources extends object = object, Environment = unknown>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
131
- static lessThan<Resources extends object = object, Environment = unknown>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
132
- static lessOrEqual<Resources extends object = object, Environment = unknown>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
133
- static moreThan<Resources extends object = object, Environment = unknown>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
134
- static moreOrEqual<Resources extends object = object, Environment = unknown>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
137
+ static equals<Resources extends object = object, Environment extends object = object>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
138
+ static notEquals<Resources extends object = object, Environment extends object = object>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
139
+ static contains<Resources extends object = object, Environment extends object = object>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
140
+ static notContains<Resources extends object = object, Environment extends object = object>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
141
+ static notIn<Resources extends object = object, Environment extends object = object>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
142
+ static in<Resources extends object = object, Environment extends object = object>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
143
+ static notEqual<Resources extends object = object, Environment extends object = object>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
144
+ static lessThan<Resources extends object = object, Environment extends object = object>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
145
+ static lessOrEqual<Resources extends object = object, Environment extends object = object>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
146
+ static moreThan<Resources extends object = object, Environment extends object = object>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
147
+ static moreOrEqual<Resources extends object = object, Environment extends object = object>(subject: string, resource: AbilityRuleConfig['resource']): AbilityRule<Resources, Environment>;
135
148
  }
136
149
 
137
150
  type AbilityRuleSetConfig = {
138
151
  readonly id?: string | null;
139
152
  readonly name?: string | null;
140
- readonly compareMethod: AbilityCompareCodeType;
153
+ readonly description?: string | null;
154
+ readonly compareMethod: AbilityCompareType;
141
155
  readonly rules: readonly AbilityRuleConfig[];
156
+ readonly disabled?: boolean;
142
157
  };
143
158
  type AbilityRuleSetConstructorProps = {
144
159
  readonly id?: string | null;
145
160
  readonly name?: string | null;
146
- readonly compareMethod: AbilityCompare;
161
+ readonly description?: string | null;
162
+ readonly compareMethod: AbilityCompareType;
163
+ readonly isExcept?: boolean;
164
+ readonly disabled?: boolean;
147
165
  };
148
- declare class AbilityRuleSet<Resources extends ResourceObject = Record<string, unknown>, Environment = unknown> {
149
- state: AbilityMatch;
166
+ declare class AbilityRuleSet<R extends ResourceObject = Record<string, unknown>, E extends EnvironmentObject = Record<string, unknown>> {
167
+ state: AbilityMatchType;
150
168
  /**
151
169
  * List of rules
152
170
  */
153
- rules: AbilityRule<Resources, Environment>[];
171
+ rules: AbilityRule<R, E>[];
154
172
  /**
155
173
  * Rules compare method.\
156
174
  * For the «and» method the rule will be permitted if all\
157
175
  * rules will be returns «permit» status and for the «or» - if\
158
176
  * one of the rules returns as «permit»
159
177
  */
160
- compareMethod: AbilityCompare;
178
+ compareMethod: AbilityCompareType;
161
179
  /**
162
180
  * Group name
163
181
  */
164
182
  name: string;
183
+ description?: string | null;
165
184
  /**
166
185
  * Group ID
167
186
  */
168
187
  id: string;
188
+ readonly isExcept?: boolean;
189
+ disabled: boolean;
169
190
  constructor(params: AbilityRuleSetConstructorProps);
170
- addRule(rule: AbilityRule<Resources, Environment>): this;
171
- addRules(rules: AbilityRule<Resources, Environment>[]): this;
172
- check(resources: Resources | null, environment?: Environment): AbilityMatch;
191
+ addRule(rule: AbilityRule<R, E>): this;
192
+ addRules(rules: AbilityRule<R, E>[]): this;
193
+ check(resources: R | null, environment?: E): AbilityMatchType;
173
194
  toString(): string;
174
195
  copyWith(props: Partial<{
175
196
  id: string | null;
176
197
  name: string | null;
177
- compareMethod: AbilityCompare;
178
- rules: AbilityRule<Resources, Environment>[];
179
- }>): AbilityRuleSet<Resources, Environment>;
180
- static and(rules: AbilityRule[]): AbilityRuleSet<Record<string, unknown>, unknown>;
181
- static or(rules: AbilityRule[]): AbilityRuleSet<Record<string, unknown>, unknown>;
198
+ description: string | null;
199
+ compareMethod: AbilityCompareType;
200
+ rules: AbilityRule<R, E>[];
201
+ }>): AbilityRuleSet<R, E>;
202
+ static and(rules: AbilityRule[]): AbilityRuleSet<Record<string, unknown>, Record<string, unknown>>;
203
+ static or(rules: AbilityRule[]): AbilityRuleSet<Record<string, unknown>, Record<string, unknown>>;
182
204
  }
183
205
 
184
- type AbilityPolicyEffectCodeType = 'deny' | 'permit';
185
- declare class AbilityPolicyEffect extends AbilityCode<AbilityPolicyEffectCodeType> {
186
- static deny: AbilityPolicyEffect;
187
- static permit: AbilityPolicyEffect;
188
- }
206
+ type AbilityPolicyEffectCode = 'deny' | 'permit';
207
+ type AbilityPolicyEffectType = AbilityPolicyEffectCode & {
208
+ __brand: 'AbilityPolicyEffect';
209
+ };
210
+ declare const AbilityPolicyEffect: {
211
+ readonly deny: AbilityPolicyEffectType;
212
+ readonly permit: AbilityPolicyEffectType;
213
+ };
189
214
 
190
215
  type AbilityExplainConfig = {
191
216
  readonly type: AbilityExplainType;
192
217
  readonly name: string;
193
- readonly match: AbilityMatch;
218
+ readonly match: AbilityMatchType;
194
219
  };
195
220
  declare class AbilityExplain {
196
221
  readonly type: AbilityExplainType;
197
222
  readonly children: AbilityExplain[];
198
223
  readonly name: string;
199
- readonly match: AbilityMatch;
224
+ readonly match: AbilityMatchType;
200
225
  constructor(config: AbilityExplainConfig, children?: AbilityExplain[]);
201
226
  toString(indent?: number): string;
202
227
  }
@@ -211,42 +236,51 @@ declare class AbilityExplainPolicy extends AbilityExplain {
211
236
  }
212
237
  type AbilityExplainType = 'policy' | 'rule' | 'ruleSet';
213
238
 
214
- type AbilityPolicyConfig = {
239
+ type AbilityPolicyConfig<TTag extends string = string> = {
215
240
  readonly permission: string;
216
- readonly effect: AbilityPolicyEffectCodeType;
217
- readonly compareMethod: AbilityCompareCodeType;
241
+ readonly effect: AbilityPolicyEffectType;
242
+ readonly compareMethod: AbilityCompareType;
218
243
  readonly ruleSet: readonly AbilityRuleSetConfig[];
219
244
  readonly id: string;
220
245
  readonly name: string;
246
+ readonly description?: string | null;
247
+ readonly priority: number;
248
+ readonly disabled?: boolean;
249
+ readonly tags?: readonly TTag[];
221
250
  };
222
- type AbilityPolicyConstructorProps = {
223
- id: string;
224
- name: string;
251
+ type AbilityPolicyConstructorProps<TTag extends string = string> = {
252
+ id: string | null;
253
+ name: string | null;
254
+ description?: string | null;
225
255
  permission: string;
226
- effect: AbilityPolicyEffect;
227
- compareMethod?: AbilityCompare;
256
+ effect: AbilityPolicyEffectType;
257
+ compareMethod?: AbilityCompareType;
258
+ priority?: number | null;
259
+ disabled?: boolean;
260
+ tags?: readonly TTag[];
228
261
  };
229
- declare class AbilityPolicy<Resource extends ResourceObject = Record<string, unknown>, Environment = unknown> {
230
- matchState: AbilityMatch;
262
+ declare class AbilityPolicy<R extends ResourceObject = Record<string, unknown>, E extends EnvironmentObject = Record<string, unknown>, TTag extends string = string> {
263
+ matchState: AbilityMatchType;
231
264
  /**
232
265
  * List of rules
233
266
  */
234
- ruleSet: AbilityRuleSet<Resource, Environment>[];
267
+ ruleSet: AbilityRuleSet<R, E>[];
235
268
  /**
236
269
  * Policy effect
237
270
  */
238
- effect: AbilityPolicyEffect;
271
+ effect: AbilityPolicyEffectType;
239
272
  /**
240
273
  * Rules compare method.\
241
274
  * For the «and» method the rule will be permitted if all\
242
275
  * rules will be returns «permit» status and for the «or» - if\
243
276
  * one of the rules returns as «permit»
244
277
  */
245
- compareMethod: AbilityCompare;
278
+ compareMethod: AbilityCompareType;
246
279
  /**
247
280
  * Policy name
248
281
  */
249
282
  name: string;
283
+ description?: string | null;
250
284
  /**
251
285
  * Policy ID
252
286
  */
@@ -256,32 +290,41 @@ declare class AbilityPolicy<Resource extends ResourceObject = Record<string, unk
256
290
  * will select only those from all passed policies that fall under the specified permission key.
257
291
  */
258
292
  permission: string;
293
+ priority: number;
294
+ disabled: boolean;
295
+ tags: readonly TTag[];
259
296
  constructor(params: AbilityPolicyConstructorProps);
260
297
  /**
261
298
  * Add rule set to the policy
262
299
  * @param ruleSet - The rule set to add
263
300
  */
264
- addRuleSet(ruleSet: AbilityRuleSet<Resource, Environment>): this;
301
+ addRuleSet(ruleSet: AbilityRuleSet<R, E>): this;
265
302
  /**
266
303
  * Add rule set to the policy
267
304
  * @param ruleSets - The array of rule set to add
268
305
  */
269
- addRuleSets(ruleSets: readonly AbilityRuleSet<Resource, Environment>[]): this;
306
+ addRuleSets(ruleSets: readonly AbilityRuleSet<R, E>[]): this;
307
+ /**
308
+ * Extract all rules of all ruleSets of this policy
309
+ */
310
+ extractRules(): readonly AbilityRule[];
270
311
  /**
271
312
  * Check if the policy is matched
272
313
  * @param resource - The resource to check
273
314
  * @param environment - The user environment object
274
315
  */
275
- check(resource: Resource, environment?: Environment): AbilityMatch;
316
+ check(resource: R, environment?: E): AbilityMatchType;
276
317
  explain(): AbilityExplain;
277
318
  copyWith(props: Partial<{
278
319
  id: string;
279
320
  name: string;
321
+ description?: string | null;
322
+ priority: number;
280
323
  permission: string;
281
- effect: AbilityPolicyEffect;
282
- compareMethod: AbilityCompare;
283
- ruleSet: AbilityRuleSet<Resource, Environment>[];
284
- }>): AbilityPolicy<Resource, Environment>;
324
+ effect: AbilityPolicyEffectType;
325
+ compareMethod: AbilityCompareType;
326
+ ruleSet: AbilityRuleSet<R, E>[];
327
+ }>): AbilityPolicy<R, E>;
285
328
  }
286
329
 
287
330
  type Primitive = string | number | boolean | null | undefined;
@@ -289,6 +332,7 @@ type NestedDict<T = Primitive> = {
289
332
  [key: string]: NestedDict<T> | T;
290
333
  };
291
334
  type ResourceObject = Record<string, unknown>;
335
+ type EnvironmentObject = Record<string, unknown>;
292
336
  type ResourcesMap = Record<string, ResourceObject>;
293
337
  declare class AbilityTypeGenerator {
294
338
  readonly policies: readonly AbilityPolicy[];
@@ -298,6 +342,7 @@ declare class AbilityTypeGenerator {
298
342
  * @returns A generated type definitions.
299
343
  */
300
344
  generateTypeDefs(): string;
345
+ private isPath;
301
346
  /**
302
347
  * Determines TypeScript type based on the rule
303
348
  * @param rule - The rule to analyze
@@ -310,6 +355,7 @@ declare class AbilityTypeGenerator {
310
355
  * @returns TypeScript array type as string
311
356
  */
312
357
  private getArrayType;
358
+ private getInArrayType;
313
359
  /**
314
360
  * Gets primitive TypeScript type for a value
315
361
  * @param value - The value to analyze
@@ -326,6 +372,8 @@ declare class AbilityTypeGenerator {
326
372
  /**
327
373
  * Formats type structure into a string
328
374
  * @param structure - Nested type structure
375
+ * @param environment
376
+ * @param allTags
329
377
  * @returns Formatted TypeScript type definition string
330
378
  */
331
379
  private formatTypeDefinitions;
@@ -338,19 +386,24 @@ declare class AbilityTypeGenerator {
338
386
  private formatNestedObject;
339
387
  }
340
388
 
341
- type AbilityResultStateCodeType = 'allow' | 'deny' | 'neutral';
342
- declare class AbilityResultState extends AbilityCode<AbilityResultStateCodeType> {
343
- static allow: AbilityResultState;
344
- static deny: AbilityResultState;
345
- static neutral: AbilityResultState;
389
+ declare abstract class AbilityStrategy<Resource extends ResourceObject = Record<string, unknown>, Environment extends EnvironmentObject = Record<string, unknown>> {
390
+ readonly policies: readonly AbilityPolicy<Resource, Environment>[];
391
+ private readonly matched;
392
+ constructor(policies: readonly AbilityPolicy<Resource, Environment>[]);
393
+ abstract evaluate(): AbilityPolicyEffectType;
394
+ matchedPolicies(): readonly AbilityPolicy<Resource, Environment, string>[];
395
+ protected firstMatched(): AbilityPolicy<Resource, Environment> | null;
396
+ protected lastMatched(): AbilityPolicy<Resource, Environment> | null;
397
+ protected hasPermit(): boolean;
398
+ protected hasDeny(): boolean;
399
+ isAllowed(): boolean;
400
+ isDenied(): boolean;
346
401
  }
347
402
 
348
- declare class AbilityResult<Resource extends ResourceObject = Record<string, unknown>> {
349
- /**
350
- * Already checked policies (after call the policy.check())
351
- */
352
- readonly policies: readonly AbilityPolicy<Resource>[];
353
- constructor(policies: readonly AbilityPolicy<Resource>[]);
403
+ declare class AbilityResult<R extends ResourceObject = Record<string, unknown>, E extends EnvironmentObject = Record<string, unknown>> {
404
+ protected readonly effect: AbilityPolicyEffectType;
405
+ protected readonly strategy: AbilityStrategy<R, E>;
406
+ constructor(effect: AbilityPolicyEffectType, strategy: AbilityStrategy<R, E>);
354
407
  /**
355
408
  * Returns a list of explanations for each policy involved in the ability evaluation.
356
409
  * Each item describes how a specific policy contributed to the final permission result.
@@ -358,19 +411,25 @@ declare class AbilityResult<Resource extends ResourceObject = Record<string, unk
358
411
  * Useful for debugging, logging, or building UI tools that visualize permission logic.
359
412
  */
360
413
  explain(): readonly AbilityExplain[];
361
- getLastMatchedPolicy(): AbilityPolicy<Resource> | null;
362
- getFinalState(): AbilityResultState;
363
414
  isAllowed(): boolean;
364
415
  isDenied(): boolean;
365
416
  }
366
417
 
367
- declare class AbilityResolver<Resources extends ResourcesMap, Environment = unknown> {
368
- private policies;
418
+ interface AbilityResolverOptions<TTags extends string> {
419
+ tags?: readonly TTags[];
420
+ }
421
+ type ExtractResources<P> = P extends AbilityPolicy<infer R, any, any> ? R : never;
422
+ type ExtractEnvironment<P> = P extends AbilityPolicy<any, infer E, any> ? E : never;
423
+ type ExtractResourceByPermission<P, Perm extends string> = P extends AbilityPolicy<infer R, any, any> ? (Perm extends keyof R ? R[Perm] : never) : never;
424
+ type ExtractEnvironmentByPermission<P, Perm extends string> = P extends AbilityPolicy<any, infer E, any> ? (Perm extends keyof E ? E[Perm] : never) : never;
425
+ declare class AbilityResolver<P extends AbilityPolicy<any, any, any>, S extends AbilityStrategy<P extends AbilityPolicy<infer R, infer E, any> ? R : never, P extends AbilityPolicy<any, infer E, any> ? E : never>, TTags extends string = P extends AbilityPolicy<any, any, infer T> ? T : never> {
426
+ private readonly StrategyClass;
427
+ private readonly policyEntries;
369
428
  constructor(
370
429
  /**
371
430
  * `Important!` The incorrect Resources type was intentionally passed to AbilityPolicy so that TypeScript could suggest the name of the permission and the structure of its resource in the parse method.
372
431
  */
373
- policyOrListOfPolicies: readonly AbilityPolicy<Resources>[] | AbilityPolicy<Resources>);
432
+ policyOrListOfPolicies: readonly P[] | P, strategy: new (policies: readonly P[]) => S, options?: AbilityResolverOptions<TTags>);
374
433
  /**
375
434
  * Resolve policy for the resource and permission key
376
435
  *
@@ -378,14 +437,17 @@ declare class AbilityResolver<Resources extends ResourcesMap, Environment = unkn
378
437
  * @param resource - Resource
379
438
  * @param environment
380
439
  */
381
- resolve<Permission extends keyof Resources>(permission: Permission, resource: Resources[Permission], environment?: Environment): AbilityResult<Resources[Permission]>;
382
- enforce<Permission extends keyof Resources>(permission: Permission, resource: Resources[Permission], environment?: Environment): void | never;
440
+ resolve<Permission extends keyof ExtractResources<P> & string>(permission: Permission, resource: ExtractResourceByPermission<P, Permission>, environment?: ExtractEnvironmentByPermission<P, Permission>): AbilityResult<ExtractResourceByPermission<P, Permission>, ExtractEnvironment<P>>;
441
+ enforce<Permission extends keyof ExtractResources<P> & string>(permission: Permission, resource: ExtractResourceByPermission<P, Permission>, environment?: ExtractEnvironmentByPermission<P, Permission>): void | never;
383
442
  /**
384
443
  * Check if the permission key is contained in another permission key
385
444
  * @param permissionA - The first permission to check
386
445
  * @param permissionB - The second permission to check
387
446
  */
388
447
  static isInPermissionContain(permissionA: string, permissionB: string): boolean;
448
+ private toArray;
449
+ private normalizePermission;
450
+ private static matchPermissions;
389
451
  }
390
452
 
391
453
  declare class AbilityJSONParser {
@@ -394,13 +456,13 @@ declare class AbilityJSONParser {
394
456
  * @param configs - Array of policy configurations
395
457
  * @returns Array of AbilityPolicy instances
396
458
  */
397
- static parse<Resource extends ResourceObject, Environment = unknown>(configs: readonly AbilityPolicyConfig[]): AbilityPolicy<Resource, Environment>[];
398
- static parsePolicy<Resource extends ResourceObject = Record<string, unknown>, Environment = unknown>(config: AbilityPolicyConfig): AbilityPolicy<Resource, Environment>;
399
- static parseRule<Resources extends object, Environment = unknown>(config: AbilityRuleConfig): AbilityRule<Resources, Environment>;
459
+ static parse<Resource extends ResourceObject>(configs: readonly AbilityPolicyConfig[]): AbilityPolicy<Resource>[];
460
+ static parsePolicy<Resource extends ResourceObject = Record<string, unknown>>(config: AbilityPolicyConfig): AbilityPolicy<Resource>;
461
+ static parseRule<Resources extends object>(config: AbilityRuleConfig): AbilityRule<Resources>;
400
462
  /**
401
463
  * Parse the config JSON format to Group class instance
402
464
  */
403
- static parseRuleSet<Resource extends ResourceObject = Record<string, unknown>, Environment = unknown>(config: AbilityRuleSetConfig): AbilityRuleSet<Resource, Environment>;
465
+ static parseRuleSet<Resource extends ResourceObject = Record<string, unknown>>(config: AbilityRuleSetConfig): AbilityRuleSet<Resource>;
404
466
  static ruleToJSON(rule: AbilityRule): AbilityRuleConfig;
405
467
  static ruleSetToJSON(ruleSet: AbilityRuleSet): AbilityRuleSetConfig;
406
468
  static policyToJSON(policy: AbilityPolicy): AbilityPolicyConfig;
@@ -423,17 +485,17 @@ declare class AbilityJSONParser {
423
485
  * Operators can be simple (equals, contains, in) or
424
486
  * composed (is null, is not null, greater than, less than or equal, etc.).
425
487
  */
426
- declare class AbilityDSLParser<Resource extends ResourceObject = Record<string, unknown>, Environment = unknown> {
427
- private dsl;
428
- private tokens;
429
- private pos;
430
- private annotationBuffer;
488
+ declare class AbilityDSLParser<R extends ResourceObject = Record<string, unknown>, E extends EnvironmentObject = Record<string, unknown>, T extends string = string> {
489
+ private readonly dsl;
490
+ private stream;
491
+ private annBuffer;
492
+ private aliasBuffer;
431
493
  constructor(dsl: string);
432
494
  /**
433
495
  * Main entry point: tokenize the input and parse all policies.
434
496
  * @returns Array of AbilityPolicy instances.
435
497
  */
436
- parse(): readonly AbilityPolicy<Resource, Environment>[];
498
+ parse(): readonly AbilityPolicy<R, E, T>[];
437
499
  /**
438
500
  * Parses a single policy from the current token position.
439
501
  *
@@ -449,6 +511,7 @@ declare class AbilityDSLParser<Resource extends ResourceObject = Record<string,
449
511
  * Parses a single group, e.g. "all of:" or "any of:", and returns a RuleSet.
450
512
  */
451
513
  private parseGroup;
514
+ private parseExceptGroup;
452
515
  /**
453
516
  * Parses a single rule: subject operator value
454
517
  */
@@ -476,76 +539,69 @@ declare class AbilityDSLParser<Resource extends ResourceObject = Record<string,
476
539
  */
477
540
  private parseArray;
478
541
  private consumeLeadingComments;
479
- private processCommentToken;
542
+ private consumeLeadingAliases;
543
+ private consumeLeadingAnnotations;
480
544
  private takeAnnotations;
481
- private syntaxError;
482
- private suggest;
483
- private levenshteinDistance;
484
- private consumeOneOf;
485
- private consume;
486
- private check;
487
545
  private isStartOfPolicy;
488
546
  private isStartOfGroup;
489
- private advance;
490
- private peek;
491
- private isAtEnd;
547
+ private isStartOfExcept;
548
+ private isStartOfAlias;
492
549
  }
493
550
 
494
- type TokenType = 'EFFECT' | 'IF' | 'PERMISSION' | 'IDENTIFIER' | 'COLON' | 'COMMA' | 'DOT' | 'LBRACKET' | 'RBRACKET' | 'ALL' | 'ANY' | 'OF' | 'EOF' | 'COMMENT' | 'EQ' | 'CONTAINS' | 'IN' | 'NOT_IN' | 'NOT_CONTAINS' | 'GT' | 'GTE' | 'LT' | 'LTE' | 'NULL' | 'EQ_NULL' | 'NOT_EQ_NULL' | 'NOT_EQ' | 'LEN_GT' | 'LEN_LT' | 'LEN_EQ' | 'ALWAYS' | 'NEVER' | 'STRING' | 'NUMBER' | 'BOOLEAN' | 'SYMBOL' | 'KEYWORD' | 'UNKNOWN';
495
- /**
496
- * Represents a single token produced by the Ability DSL lexer.
497
- * Each token carries a type (e.g., EFFECT, IDENTIFIER, STRING) and its raw string value.
498
- */
499
- declare class AbilityDSLToken<Code extends TokenType = TokenType> extends AbilityCode<Code> {
500
- /** The literal text of the token as it appeared in the input (e.g., "permit", "user.roles", "admin"). */
551
+ type TokenTypeCode = 'EFFECT' | 'IF' | 'PERMISSION' | 'IDENTIFIER' | 'COLON' | 'COMMA' | 'DOT' | 'LBRACKET' | 'RBRACKET' | 'ALL' | 'ANY' | 'OF' | 'EOF' | 'COMMENT' | 'EQ' | 'CONTAINS' | 'IN' | 'NOT_IN' | 'NOT_CONTAINS' | 'GT' | 'GTE' | 'LT' | 'LTE' | 'NULL' | 'EQ_NULL' | 'NOT_EQ_NULL' | 'NOT_EQ' | 'LEN_GT' | 'LEN_LT' | 'LEN_EQ' | 'ALWAYS' | 'NEVER' | 'EXCEPT' | 'ANNOTATION' | 'STRING' | 'NUMBER' | 'BOOLEAN' | 'SYMBOL' | 'KEYWORD' | 'ALIAS' | 'UNKNOWN';
552
+ type TokenType = TokenTypeCode & {
553
+ __brand: 'TokenType';
554
+ };
555
+ declare const TokenTypes: {
556
+ readonly EFFECT: TokenType;
557
+ readonly IF: TokenType;
558
+ readonly PERMISSION: TokenType;
559
+ readonly IDENTIFIER: TokenType;
560
+ readonly COLON: TokenType;
561
+ readonly COMMA: TokenType;
562
+ readonly DOT: TokenType;
563
+ readonly LBRACKET: TokenType;
564
+ readonly RBRACKET: TokenType;
565
+ readonly ALL: TokenType;
566
+ readonly ANY: TokenType;
567
+ readonly OF: TokenType;
568
+ readonly EOF: TokenType;
569
+ readonly COMMENT: TokenType;
570
+ readonly EQ: TokenType;
571
+ readonly CONTAINS: TokenType;
572
+ readonly IN: TokenType;
573
+ readonly NOT_IN: TokenType;
574
+ readonly NOT_CONTAINS: TokenType;
575
+ readonly GT: TokenType;
576
+ readonly GTE: TokenType;
577
+ readonly LT: TokenType;
578
+ readonly LTE: TokenType;
579
+ readonly NULL: TokenType;
580
+ readonly EQ_NULL: TokenType;
581
+ readonly NOT_EQ_NULL: TokenType;
582
+ readonly NOT_EQ: TokenType;
583
+ readonly LEN_GT: TokenType;
584
+ readonly LEN_LT: TokenType;
585
+ readonly LEN_EQ: TokenType;
586
+ readonly ALWAYS: TokenType;
587
+ readonly NEVER: TokenType;
588
+ readonly EXCEPT: TokenType;
589
+ readonly ANNOTATION: TokenType;
590
+ readonly STRING: TokenType;
591
+ readonly NUMBER: TokenType;
592
+ readonly BOOLEAN: TokenType;
593
+ readonly SYMBOL: TokenType;
594
+ readonly KEYWORD: TokenType;
595
+ readonly ALIAS: TokenType;
596
+ readonly UNKNOWN: TokenType;
597
+ };
598
+ declare class AbilityDSLToken {
599
+ readonly type: TokenType;
501
600
  readonly value: string;
502
- /** The line number in DSL */
503
601
  readonly line: number;
504
- /** The column in dsl */
505
602
  readonly column: number;
506
- constructor(type: Code, value: string, line: number, column: number);
507
- /**
508
- * Returns a human-readable representation of the token, useful for debugging.
509
- * Example output: "AbilityDSLToken([EFFECT] permit"
510
- */
603
+ constructor(type: TokenType, value: string, line: number, column: number);
511
604
  toString(): string;
512
- static readonly EFFECT: TokenType;
513
- static readonly IF: TokenType;
514
- static readonly PERMISSION: TokenType;
515
- static readonly IDENTIFIER: TokenType;
516
- static readonly COLON: TokenType;
517
- static readonly COMMA: TokenType;
518
- static readonly DOT: TokenType;
519
- static readonly LBRACKET: TokenType;
520
- static readonly RBRACKET: TokenType;
521
- static readonly ALL: TokenType;
522
- static readonly ANY: TokenType;
523
- static readonly OF: TokenType;
524
- static readonly EOF: TokenType;
525
- static readonly COMMENT: TokenType;
526
- static readonly EQ: TokenType;
527
- static readonly CONTAINS: TokenType;
528
- static readonly IN: TokenType;
529
- static readonly NOT_IN: TokenType;
530
- static readonly NOT_CONTAINS: TokenType;
531
- static readonly GT: TokenType;
532
- static readonly GTE: TokenType;
533
- static readonly LT: TokenType;
534
- static readonly LTE: TokenType;
535
- static readonly NULL: TokenType;
536
- static readonly EQ_NULL: TokenType;
537
- static readonly NOT_EQ_NULL: TokenType;
538
- static readonly LEN_GT: TokenType;
539
- static readonly LEN_LT: TokenType;
540
- static readonly LEN_EQ: TokenType;
541
- static readonly NOT_EQ: TokenType;
542
- static readonly ALWAYS: TokenType;
543
- static readonly NEVER: TokenType;
544
- static readonly STRING: TokenType;
545
- static readonly NUMBER: TokenType;
546
- static readonly BOOLEAN: TokenType;
547
- static readonly SYMBOL: TokenType;
548
- static readonly KEYWORD: TokenType;
549
605
  }
550
606
 
551
607
  declare class AbilityDSLLexer {
@@ -558,6 +614,7 @@ declare class AbilityDSLLexer {
558
614
  constructor(input: string);
559
615
  tokenize(): AbilityDSLToken[];
560
616
  private readComment;
617
+ private readAnnotation;
561
618
  private readString;
562
619
  private readNumber;
563
620
  private readSymbol;
@@ -572,5 +629,175 @@ declare class AbilityDSLLexer {
572
629
  private isAtEnd;
573
630
  }
574
631
 
575
- export { AbilityCode, AbilityCompare, AbilityCondition, AbilityDSLLexer, AbilityDSLParser, AbilityDSLToken, AbilityError, AbilityExplain, AbilityExplainPolicy, AbilityExplainRule, AbilityExplainRuleSet, AbilityJSONParser, AbilityMatch, AbilityParserError, AbilityPolicy, AbilityPolicyEffect, AbilityResolver, AbilityResult, AbilityResultState, AbilityRule, AbilityRuleSet, AbilityTypeGenerator };
576
- export type { AbilityCompareCodeType, AbilityConditionCodeType, AbilityConditionLiteralType, AbilityExplainConfig, AbilityExplainType, AbilityMatchCodeType, AbilityPolicyConfig, AbilityPolicyConstructorProps, AbilityPolicyEffectCodeType, AbilityResultStateCodeType, AbilityRuleConfig, AbilityRuleConstructorProps, AbilityRuleSetConfig, AbilityRuleSetConstructorProps, NestedDict, Primitive, ResourceObject, ResourcesMap, TokenType };
632
+ declare function ability<R extends ResourceObject = Record<string, unknown>, E extends EnvironmentObject = Record<string, unknown>, T extends string = string>(strings: TemplateStringsArray, ...expr: any[]): readonly AbilityPolicy<R, E, T>[];
633
+
634
+ /**
635
+ * AllMustPermitStrategy
636
+ *
637
+ * This strategy requires *every applicable policy* to return "permit".
638
+ * If at least one policy returns "deny" or "not applicable", the final result is "deny".
639
+ *
640
+ * Use this strategy when:
641
+ * - You want strict, conservative access control.
642
+ * - All rules must explicitly allow the action.
643
+ *
644
+ * Example:
645
+ * Policies:
646
+ * P1 → permit
647
+ * P2 → permit
648
+ * P3 → deny
649
+ * Result: deny (because not all policies permitted)
650
+ */
651
+ declare class AllMustPermitStrategy<R extends ResourceObject, E extends EnvironmentObject = Record<string, unknown>> extends AbilityStrategy<R, E> {
652
+ evaluate(): AbilityPolicyEffectType;
653
+ }
654
+
655
+ /**
656
+ * AnyPermitStrategy
657
+ *
658
+ * This strategy returns "permit" as soon as *any* applicable policy permits the action.
659
+ * If no policy permits, the result is "deny".
660
+ *
661
+ * Use this strategy when:
662
+ * - You want optimistic access control.
663
+ * - A single positive rule should be enough to grant access.
664
+ *
665
+ * Example:
666
+ * Policies:
667
+ * P1 → deny
668
+ * P2 → permit
669
+ * P3 → deny
670
+ * Result: permit (because at least one policy permitted)
671
+ */
672
+ declare class AnyPermitStrategy<R extends ResourceObject, E extends EnvironmentObject = Record<string, unknown>> extends AbilityStrategy<R, E> {
673
+ evaluate(): AbilityPolicyEffectType;
674
+ }
675
+
676
+ /**
677
+ * DenyOverridesStrategy
678
+ *
679
+ * This strategy gives absolute priority to "deny".
680
+ * If any applicable policy returns "deny", the final result is "deny".
681
+ * Otherwise, if at least one policy permits, the result is "permit".
682
+ *
683
+ * Use this strategy when:
684
+ * - Security is critical.
685
+ * - A single denial must block access.
686
+ *
687
+ * Example:
688
+ * Policies:
689
+ * P1 → permit
690
+ * P2 → deny
691
+ * P3 → permit
692
+ * Result: deny (because deny overrides everything)
693
+ */
694
+ declare class DenyOverridesStrategy<R extends ResourceObject, E extends EnvironmentObject = Record<string, unknown>> extends AbilityStrategy<R, E> {
695
+ evaluate(): AbilityPolicyEffectType;
696
+ }
697
+
698
+ /**
699
+ * FirstMatchStrategy
700
+ *
701
+ * This strategy evaluates policies in order and returns the result of the *first applicable* policy.
702
+ * Remaining policies are ignored.
703
+ *
704
+ * Use this strategy when:
705
+ * - Policy order matters.
706
+ * - You want predictable, sequential rule evaluation.
707
+ *
708
+ * Example:
709
+ * Policies:
710
+ * P1 → not applicable
711
+ * P2 → permit
712
+ * P3 → deny
713
+ * Result: permit (P2 is the first applicable)
714
+ */
715
+ declare class FirstMatchStrategy<R extends ResourceObject, E extends EnvironmentObject = Record<string, unknown>> extends AbilityStrategy<R, E> {
716
+ evaluate(): AbilityPolicyEffectType;
717
+ }
718
+
719
+ /**
720
+ * OnlyOneApplicableStrategy
721
+ *
722
+ * This strategy requires that *exactly one* policy is applicable.
723
+ * If zero or more than one policy applies, the result is "deny".
724
+ *
725
+ * Use this strategy when:
726
+ * - Policies must be mutually exclusive.
727
+ * - You want to detect ambiguous or conflicting rules.
728
+ *
729
+ * Example:
730
+ * Policies:
731
+ * P1 → applicable
732
+ * P2 → applicable
733
+ * Result: deny (more than one applicable policy)
734
+ */
735
+ declare class OnlyOneApplicableStrategy<R extends ResourceObject, E extends EnvironmentObject = Record<string, unknown>> extends AbilityStrategy<R, E> {
736
+ evaluate(): AbilityPolicyEffectType;
737
+ }
738
+
739
+ /**
740
+ * PermitOverridesStrategy
741
+ *
742
+ * This strategy gives priority to "permit".
743
+ * If any applicable policy permits, the final result is "permit".
744
+ * Deny is returned only if no policy permits.
745
+ *
746
+ * Use this strategy when:
747
+ * - You want permissive behavior.
748
+ * - A single positive rule should override denials.
749
+ *
750
+ * Example:
751
+ * Policies:
752
+ * P1 → deny
753
+ * P2 → permit
754
+ * P3 → deny
755
+ * Result: permit (permit overrides deny)
756
+ */
757
+ declare class PermitOverridesStrategy<R extends ResourceObject, E extends EnvironmentObject = Record<string, unknown>> extends AbilityStrategy<R, E> {
758
+ evaluate(): AbilityPolicyEffectType;
759
+ }
760
+
761
+ /**
762
+ * SequentialLastMatchStrategy
763
+ *
764
+ * This strategy evaluates all applicable policies in order and returns the result of the *last* applicable one.
765
+ *
766
+ * Use this strategy when:
767
+ * - Later policies should override earlier ones.
768
+ * - You want a "last rule wins" behavior.
769
+ *
770
+ * Example:
771
+ * Policies:
772
+ * P1 → permit
773
+ * P2 → deny
774
+ * P3 → permit
775
+ * Result: permit (P3 is the last applicable)
776
+ */
777
+ declare class SequentialLastMatchStrategy<R extends ResourceObject, E extends EnvironmentObject = Record<string, unknown>> extends AbilityStrategy<R, E> {
778
+ evaluate(): AbilityPolicyEffectType;
779
+ }
780
+
781
+ /**
782
+ * PriorityStrategy
783
+ *
784
+ * This strategy evaluates policies based on their numeric priority.
785
+ * The policy with the highest priority (lowest number or highest number depending on implementation)
786
+ * determines the final result.
787
+ *
788
+ * Use this strategy when:
789
+ * - Policies have explicit priority levels.
790
+ * - You want deterministic resolution based on ranking.
791
+ *
792
+ * Example:
793
+ * Policies:
794
+ * P1 (priority 10) → deny
795
+ * P2 (priority 1) → permit
796
+ * Result: permit (P2 has higher priority)
797
+ */
798
+ declare class PriorityStrategy<R extends ResourceObject, E extends EnvironmentObject = Record<string, unknown>> extends AbilityStrategy<R, E> {
799
+ evaluate(): AbilityPolicyEffectType;
800
+ }
801
+
802
+ export { AbilityCompare, AbilityCondition, AbilityDSLLexer, AbilityDSLParser, AbilityDSLToken, AbilityError, AbilityExplain, AbilityExplainPolicy, AbilityExplainRule, AbilityExplainRuleSet, AbilityJSONParser, AbilityMatch, AbilityParserError, AbilityPolicy, AbilityPolicyEffect, AbilityResolver, AbilityResult, AbilityRule, AbilityRuleSet, AbilityStrategy, AbilityTypeGenerator, AllMustPermitStrategy, AnyPermitStrategy, DenyOverridesStrategy, FirstMatchStrategy, OnlyOneApplicableStrategy, PermitOverridesStrategy, PriorityStrategy, SequentialLastMatchStrategy, TokenTypes, ability, fromLiteral, isConditionEqual, isConditionNotEqual, toLiteral };
803
+ export type { AbilityCompareType, AbilityConditionCode, AbilityConditionLiteral, AbilityConditionType, AbilityExplainConfig, AbilityExplainType, AbilityMatchType, AbilityPolicyConfig, AbilityPolicyConstructorProps, AbilityPolicyEffectType, AbilityResolverOptions, AbilityRuleConfig, AbilityRuleConstructorProps, AbilityRuleSetConfig, AbilityRuleSetConstructorProps, EnvironmentObject, NestedDict, Primitive, ResourceObject, ResourcesMap, TokenType, TokenTypeCode };