@ztimson/utils 0.19.0 → 0.19.2
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +11 -11
- package/dist/index.mjs.map +1 -1
- package/dist/path-events.d.ts +22 -22
- package/package.json +1 -1
package/dist/path-events.d.ts
CHANGED
|
@@ -10,20 +10,20 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export type Method = '*' | 'n' | 'c' | 'r' | 'u' | 'd' | 'x';
|
|
12
12
|
/**
|
|
13
|
-
* Shorthand for creating
|
|
13
|
+
* Shorthand for creating Event from a string
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```ts
|
|
17
|
-
* const event:
|
|
17
|
+
* const event: Event = PE`users/system:*`;
|
|
18
18
|
* ```
|
|
19
19
|
*
|
|
20
|
-
* @param {TemplateStringsArray} str String that will be parsed into
|
|
20
|
+
* @param {TemplateStringsArray} str String that will be parsed into Event
|
|
21
21
|
* @param {string} args
|
|
22
|
-
* @return {PathEvent}
|
|
22
|
+
* @return {PathEvent} Event object
|
|
23
23
|
*/
|
|
24
24
|
export declare function PE(str: TemplateStringsArray, ...args: string[]): PathEvent;
|
|
25
25
|
/**
|
|
26
|
-
* Shorthand for creating
|
|
26
|
+
* Shorthand for creating Event strings, ensures paths are correct
|
|
27
27
|
*
|
|
28
28
|
* @param {TemplateStringsArray} str
|
|
29
29
|
* @param {string} args
|
|
@@ -32,8 +32,8 @@ export declare function PE(str: TemplateStringsArray, ...args: string[]): PathEv
|
|
|
32
32
|
*/
|
|
33
33
|
export declare function PES(str: TemplateStringsArray, ...args: any[]): string;
|
|
34
34
|
/**
|
|
35
|
-
* A
|
|
36
|
-
*
|
|
35
|
+
* A event broken down into its core components for easy processing
|
|
36
|
+
* Event Structure: `module/path/name:property:method`
|
|
37
37
|
* Example: `users/system:crud` or `storage/some/path/file.txt:r`
|
|
38
38
|
*/
|
|
39
39
|
export declare class PathEvent {
|
|
@@ -59,19 +59,19 @@ export declare class PathEvent {
|
|
|
59
59
|
update: boolean;
|
|
60
60
|
/** Delete method specified */
|
|
61
61
|
delete: boolean;
|
|
62
|
-
constructor(
|
|
62
|
+
constructor(Event: string | PathEvent);
|
|
63
63
|
/**
|
|
64
|
-
* Combine multiple
|
|
64
|
+
* Combine multiple events into one parsed object. Longest path takes precedent, but all subsequent methods are
|
|
65
65
|
* combined until a "none" is reached
|
|
66
66
|
*
|
|
67
|
-
* @param {string | PathEvent} paths
|
|
67
|
+
* @param {string | PathEvent} paths Events as strings or pre-parsed
|
|
68
68
|
* @return {PathEvent} Final combined permission
|
|
69
69
|
*/
|
|
70
70
|
static combine(paths: (string | PathEvent)[]): PathEvent;
|
|
71
71
|
/**
|
|
72
72
|
* Squash 2 sets of paths & return true if any overlap is found
|
|
73
73
|
*
|
|
74
|
-
* @param {string | PathEvent | (string | PathEvent)[]} target Array of
|
|
74
|
+
* @param {string | PathEvent | (string | PathEvent)[]} target Array of Events as strings or pre-parsed
|
|
75
75
|
* @param has Target must have at least one of these path
|
|
76
76
|
* @return {boolean} Whether there is any overlap
|
|
77
77
|
*/
|
|
@@ -79,7 +79,7 @@ export declare class PathEvent {
|
|
|
79
79
|
/**
|
|
80
80
|
* Squash 2 sets of paths & return true if the target has all paths
|
|
81
81
|
*
|
|
82
|
-
* @param {string | PathEvent | (string | PathEvent)[]} target Array of
|
|
82
|
+
* @param {string | PathEvent | (string | PathEvent)[]} target Array of Events as strings or pre-parsed
|
|
83
83
|
* @param has Target must have all these paths
|
|
84
84
|
* @return {boolean} Whether there is any overlap
|
|
85
85
|
*/
|
|
@@ -87,49 +87,49 @@ export declare class PathEvent {
|
|
|
87
87
|
/**
|
|
88
88
|
* Same as `has` but raises an error if there is no overlap
|
|
89
89
|
*
|
|
90
|
-
* @param {string | string[]} target Array of
|
|
90
|
+
* @param {string | string[]} target Array of Events as strings or pre-parsed
|
|
91
91
|
* @param has Target must have at least one of these path
|
|
92
92
|
*/
|
|
93
93
|
static hasFatal(target: string | PathEvent | (string | PathEvent)[], ...has: (string | PathEvent)[]): void;
|
|
94
94
|
/**
|
|
95
95
|
* Same as `hasAll` but raises an error if the target is missing any paths
|
|
96
96
|
*
|
|
97
|
-
* @param {string | string[]} target Array of
|
|
97
|
+
* @param {string | string[]} target Array of Events as strings or pre-parsed
|
|
98
98
|
* @param has Target must have all these paths
|
|
99
99
|
*/
|
|
100
100
|
static hasAllFatal(target: string | PathEvent | (string | PathEvent)[], ...has: (string | PathEvent)[]): void;
|
|
101
101
|
/**
|
|
102
|
-
* Create
|
|
102
|
+
* Create event string from its components
|
|
103
103
|
*
|
|
104
104
|
* @param {string | string[]} path Event path
|
|
105
105
|
* @param {Method} methods Event method
|
|
106
|
-
* @return {string} String representation of
|
|
106
|
+
* @return {string} String representation of Event
|
|
107
107
|
*/
|
|
108
108
|
static toString(path: string | string[], methods: Method | Method[]): string;
|
|
109
109
|
/**
|
|
110
|
-
* Create
|
|
110
|
+
* Create event string from its components
|
|
111
111
|
*
|
|
112
|
-
* @return {string} String representation of
|
|
112
|
+
* @return {string} String representation of Event
|
|
113
113
|
*/
|
|
114
114
|
toString(): string;
|
|
115
115
|
}
|
|
116
116
|
export type PathListener = (event: PathEvent, ...args: any[]) => any;
|
|
117
117
|
export type PathUnsubscribe = () => void;
|
|
118
|
-
export interface
|
|
118
|
+
export interface IPathEventEmitter {
|
|
119
119
|
emit(event: string, ...args: any[]): void;
|
|
120
120
|
off(listener: PathListener): void;
|
|
121
121
|
on(event: string, listener: PathListener): PathUnsubscribe;
|
|
122
122
|
once(event: string, listener?: PathListener): Promise<any>;
|
|
123
|
-
relayEvents(emitter:
|
|
123
|
+
relayEvents(emitter: PathEventEmitter): void;
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* Event emitter that uses paths allowing listeners to listen to different combinations of modules, paths & methods
|
|
127
127
|
*/
|
|
128
|
-
export declare class
|
|
128
|
+
export declare class PathEventEmitter implements IPathEventEmitter {
|
|
129
129
|
private listeners;
|
|
130
130
|
emit(event: string | PathEvent, ...args: any[]): void;
|
|
131
131
|
off(listener: PathListener): void;
|
|
132
132
|
on(event: string | string[], listener: PathListener): PathUnsubscribe;
|
|
133
133
|
once(event: string | string[], listener?: PathListener): Promise<any>;
|
|
134
|
-
relayEvents(emitter:
|
|
134
|
+
relayEvents(emitter: IPathEventEmitter): void;
|
|
135
135
|
}
|