@ztimson/utils 0.27.9 → 0.27.11
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/cache.d.ts +11 -52
- package/dist/index.cjs +182 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +182 -107
- package/dist/index.mjs.map +1 -1
- package/dist/path-events.d.ts +37 -10
- package/package.json +1 -1
package/dist/path-events.d.ts
CHANGED
|
@@ -35,9 +35,10 @@ export declare function PES(str: TemplateStringsArray, ...args: any[]): string;
|
|
|
35
35
|
export declare class PathError extends Error {
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* A
|
|
39
|
-
* Event Structure: `module/path/name:
|
|
38
|
+
* A event broken down into its core components for easy processing
|
|
39
|
+
* Event Structure: `module/path/name:method`
|
|
40
40
|
* Example: `users/system:crud` or `storage/some/path/file.txt:r`
|
|
41
|
+
* Supports glob patterns: `users/*:r` or `storage/**:rw`
|
|
41
42
|
*/
|
|
42
43
|
export declare class PathEvent {
|
|
43
44
|
/** First directory in path */
|
|
@@ -46,12 +47,18 @@ export declare class PathEvent {
|
|
|
46
47
|
fullPath: string;
|
|
47
48
|
/** Path including the name, excluding the module */
|
|
48
49
|
path: string;
|
|
49
|
-
/** Last
|
|
50
|
+
/** Last segment of path */
|
|
50
51
|
name: string;
|
|
51
52
|
/** List of methods */
|
|
52
53
|
methods: ASet<Method>;
|
|
54
|
+
/** Whether this path contains glob patterns */
|
|
55
|
+
hasGlob: boolean;
|
|
53
56
|
/** Internal cache for PathEvent instances to avoid redundant parsing */
|
|
54
57
|
private static pathEventCache;
|
|
58
|
+
/** Cache for compiled permissions (path + required permissions → result) */
|
|
59
|
+
private static permissionCache;
|
|
60
|
+
/** Max size for permission cache before LRU eviction */
|
|
61
|
+
private static readonly MAX_PERMISSION_CACHE_SIZE;
|
|
55
62
|
/** All/Wildcard specified */
|
|
56
63
|
get all(): boolean;
|
|
57
64
|
set all(v: boolean);
|
|
@@ -61,6 +68,9 @@ export declare class PathEvent {
|
|
|
61
68
|
/** Create method specified */
|
|
62
69
|
get create(): boolean;
|
|
63
70
|
set create(v: boolean);
|
|
71
|
+
/** Execute method specified */
|
|
72
|
+
get execute(): boolean;
|
|
73
|
+
set execute(v: boolean);
|
|
64
74
|
/** Read method specified */
|
|
65
75
|
get read(): boolean;
|
|
66
76
|
set read(v: boolean);
|
|
@@ -73,6 +83,18 @@ export declare class PathEvent {
|
|
|
73
83
|
constructor(e: string | PathEvent);
|
|
74
84
|
/** Clear the cache of all PathEvents */
|
|
75
85
|
static clearCache(): void;
|
|
86
|
+
/** Clear the permission cache */
|
|
87
|
+
static clearPermissionCache(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Score a path for specificity ranking (lower = more specific = higher priority)
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
private static scoreSpecificity;
|
|
93
|
+
/**
|
|
94
|
+
* Check if a path matches a glob pattern
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
private static pathMatchesGlob;
|
|
76
98
|
/**
|
|
77
99
|
* Combine multiple events into one parsed object. Longest path takes precedent, but all subsequent methods are
|
|
78
100
|
* combined until a "none" is reached
|
|
@@ -85,10 +107,15 @@ export declare class PathEvent {
|
|
|
85
107
|
* Filter a set of paths based on the target
|
|
86
108
|
*
|
|
87
109
|
* @param {string | PathEvent | (string | PathEvent)[]} target Array of events that will filtered
|
|
88
|
-
* @param filter {...PathEvent} Must
|
|
89
|
-
* @return {
|
|
110
|
+
* @param filter {...PathEvent} Must contain one of
|
|
111
|
+
* @return {PathEvent[]} Filtered results
|
|
90
112
|
*/
|
|
91
113
|
static filter(target: string | PathEvent | (string | PathEvent)[], ...filter: (string | PathEvent)[]): PathEvent[];
|
|
114
|
+
/**
|
|
115
|
+
* Check if a filter pattern matches a target path
|
|
116
|
+
* @private
|
|
117
|
+
*/
|
|
118
|
+
private static matches;
|
|
92
119
|
/**
|
|
93
120
|
* Squash 2 sets of paths & return true if any overlap is found
|
|
94
121
|
*
|
|
@@ -102,20 +129,20 @@ export declare class PathEvent {
|
|
|
102
129
|
*
|
|
103
130
|
* @param {string | PathEvent | (string | PathEvent)[]} target Array of Events as strings or pre-parsed
|
|
104
131
|
* @param has Target must have all these paths
|
|
105
|
-
* @return {boolean} Whether
|
|
132
|
+
* @return {boolean} Whether all are present
|
|
106
133
|
*/
|
|
107
134
|
static hasAll(target: string | PathEvent | (string | PathEvent)[], ...has: (string | PathEvent)[]): boolean;
|
|
108
135
|
/**
|
|
109
136
|
* Same as `has` but raises an error if there is no overlap
|
|
110
137
|
*
|
|
111
|
-
* @param {string | string[]} target Array of Events as strings or pre-parsed
|
|
138
|
+
* @param {string | PathEvent | (string | PathEvent)[]} target Array of Events as strings or pre-parsed
|
|
112
139
|
* @param has Target must have at least one of these path
|
|
113
140
|
*/
|
|
114
141
|
static hasFatal(target: string | PathEvent | (string | PathEvent)[], ...has: (string | PathEvent)[]): void;
|
|
115
142
|
/**
|
|
116
143
|
* Same as `hasAll` but raises an error if the target is missing any paths
|
|
117
144
|
*
|
|
118
|
-
* @param {string | string[]} target Array of Events as strings or pre-parsed
|
|
145
|
+
* @param {string | PathEvent | (string | PathEvent)[]} target Array of Events as strings or pre-parsed
|
|
119
146
|
* @param has Target must have all these paths
|
|
120
147
|
*/
|
|
121
148
|
static hasAllFatal(target: string | PathEvent | (string | PathEvent)[], ...has: (string | PathEvent)[]): void;
|
|
@@ -138,7 +165,7 @@ export declare class PathEvent {
|
|
|
138
165
|
* Squash 2 sets of paths & return true if the target has all paths
|
|
139
166
|
*
|
|
140
167
|
* @param has Target must have all these paths
|
|
141
|
-
* @return {boolean} Whether
|
|
168
|
+
* @return {boolean} Whether all are present
|
|
142
169
|
*/
|
|
143
170
|
hasAll(...has: (string | PathEvent)[]): boolean;
|
|
144
171
|
/**
|
|
@@ -157,7 +184,7 @@ export declare class PathEvent {
|
|
|
157
184
|
* Filter a set of paths based on this event
|
|
158
185
|
*
|
|
159
186
|
* @param {string | PathEvent | (string | PathEvent)[]} target Array of events that will filtered
|
|
160
|
-
* @return {
|
|
187
|
+
* @return {PathEvent[]} Filtered results
|
|
161
188
|
*/
|
|
162
189
|
filter(target: string | PathEvent | (string | PathEvent)[]): PathEvent[];
|
|
163
190
|
/**
|