@via-profit/ability 2.1.0 → 3.1.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/CHANGELOG.md +129 -0
- package/CONTRIBUTING.md +14 -0
- package/LICENSE +21 -0
- package/README.md +1058 -319
- package/SECURITY.md +33 -0
- package/dist/cache/AbilityCacheAdapter.d.ts +8 -0
- package/dist/cache/AbilityInMemoryCache.d.ts +12 -0
- package/dist/core/AbilityCondition.d.ts +21 -0
- package/dist/core/AbilityExplain.d.ts +27 -0
- package/dist/core/AbilityParser.d.ts +61 -0
- package/dist/core/AbilityPolicy.d.ts +84 -0
- package/dist/core/AbilityResolver.d.ts +35 -0
- package/dist/core/AbilityResult.d.ts +27 -0
- package/dist/core/AbilityRule.d.ts +77 -0
- package/dist/{AbilityRuleSet.d.ts → core/AbilityRuleSet.d.ts} +14 -11
- package/dist/index.d.ts +19 -11
- package/dist/index.js +2097 -303
- package/dist/parsers/dsl/AbilityDSLLexer.d.ts +24 -0
- package/dist/parsers/dsl/AbilityDSLParser.d.ts +86 -0
- package/dist/parsers/dsl/AbilityDSLSyntaxError.d.ts +13 -0
- package/dist/parsers/dsl/AbilityDSLToken.d.ts +55 -0
- package/dist/parsers/json/AbilityJSONParser.d.ts +22 -0
- package/package.json +15 -4
- package/assets/ability-01.drawio.png +0 -0
- package/build/playground.js +0 -456
- package/build/playground.js.map +0 -1
- package/dist/AbilityCondition.d.ts +0 -16
- package/dist/AbilityParser.d.ts +0 -18
- package/dist/AbilityPolicy.d.ts +0 -65
- package/dist/AbilityResolver.d.ts +0 -30
- package/dist/AbilityRule.d.ts +0 -70
- /package/dist/{AbilityCode.d.ts → core/AbilityCode.d.ts} +0 -0
- /package/dist/{AbilityCompare.d.ts → core/AbilityCompare.d.ts} +0 -0
- /package/dist/{AbilityError.d.ts → core/AbilityError.d.ts} +0 -0
- /package/dist/{AbilityMatch.d.ts → core/AbilityMatch.d.ts} +0 -0
- /package/dist/{AbilityPolicyEffect.d.ts → core/AbilityPolicyEffect.d.ts} +0 -0
package/dist/AbilityRule.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import AbilityMatch from './AbilityMatch';
|
|
2
|
-
import AbilityCondition, { AbilityConditionCodeType } from './AbilityCondition';
|
|
3
|
-
export type AbilityRuleConfig = {
|
|
4
|
-
readonly id: string;
|
|
5
|
-
readonly name: string;
|
|
6
|
-
/**
|
|
7
|
-
* Subject key path like a 'user.name'
|
|
8
|
-
*/
|
|
9
|
-
readonly subject: string;
|
|
10
|
-
/**
|
|
11
|
-
* Resource key path like a 'user.name' or value
|
|
12
|
-
*/
|
|
13
|
-
readonly resource: string | number | boolean | (string | number)[];
|
|
14
|
-
readonly condition: AbilityConditionCodeType;
|
|
15
|
-
};
|
|
16
|
-
export type AbilityRuleConstructorProps = Omit<AbilityRuleConfig, 'condition'> & {
|
|
17
|
-
readonly condition: AbilityCondition;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Represents a rule that defines a condition to be checked against a subject and resource.
|
|
21
|
-
*/
|
|
22
|
-
export declare class AbilityRule<Resources extends object = object> {
|
|
23
|
-
/**
|
|
24
|
-
* Subject key path like a 'user.name'
|
|
25
|
-
*/
|
|
26
|
-
subject: string;
|
|
27
|
-
/**
|
|
28
|
-
* Resource key path like a 'user.name' or value
|
|
29
|
-
*/
|
|
30
|
-
resource: string | number | boolean | (string | number)[];
|
|
31
|
-
condition: AbilityCondition;
|
|
32
|
-
name: string;
|
|
33
|
-
id: string;
|
|
34
|
-
state: AbilityMatch;
|
|
35
|
-
/**
|
|
36
|
-
* Creates an instance of AbilityRule.
|
|
37
|
-
* @param {string} options.id - The unique identifier of the rule.
|
|
38
|
-
* @param {string} options.name - The name of the rule.
|
|
39
|
-
* @param {AbilityCondition} options.condition - The condition to evaluate.
|
|
40
|
-
* @param {string} options.subject - The subject of the rule.
|
|
41
|
-
* @param {string} options.resource - The resource to compare against.
|
|
42
|
-
* @param params
|
|
43
|
-
*/
|
|
44
|
-
constructor(params: AbilityRuleConstructorProps);
|
|
45
|
-
/**
|
|
46
|
-
* Check if the rule is matched
|
|
47
|
-
* @param resource - The resource to check
|
|
48
|
-
*/
|
|
49
|
-
check(resource: Resources | null): AbilityMatch;
|
|
50
|
-
/**
|
|
51
|
-
* Extract values from the resourceData
|
|
52
|
-
* @param resourceData - The resourceData to extract values from
|
|
53
|
-
*/
|
|
54
|
-
extractValues(resourceData: Resources | null): [
|
|
55
|
-
string | number | boolean | (string | number)[] | null | undefined,
|
|
56
|
-
string | number | boolean | (string | number)[] | null | undefined
|
|
57
|
-
];
|
|
58
|
-
/**
|
|
59
|
-
* Get the value of the object by dot notation
|
|
60
|
-
* @param resource - The object to get the value from
|
|
61
|
-
* @param desc - The dot notation string
|
|
62
|
-
*/
|
|
63
|
-
getDotNotationValue<T = unknown>(resource: unknown, desc: string): T | undefined;
|
|
64
|
-
static parse<Resources extends object>(config: AbilityRuleConfig): AbilityRule<Resources>;
|
|
65
|
-
/**
|
|
66
|
-
* Export the rule to config object
|
|
67
|
-
*/
|
|
68
|
-
export(): AbilityRuleConfig;
|
|
69
|
-
}
|
|
70
|
-
export default AbilityRule;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|