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