@cldmv/slothlet 3.3.0 → 3.4.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/README.md +9 -10
- package/REFERENCE.md +23 -0
- package/dist/lib/builders/api-assignment.mjs +1 -589
- package/dist/lib/builders/api_builder.mjs +1 -1385
- package/dist/lib/builders/builder.mjs +1 -78
- package/dist/lib/builders/modes-processor.mjs +1 -1800
- package/dist/lib/errors.mjs +9 -211
- package/dist/lib/factories/component-base.mjs +1 -80
- package/dist/lib/factories/context.mjs +1 -22
- package/dist/lib/handlers/api-cache-manager.mjs +1 -200
- package/dist/lib/handlers/api-manager.mjs +1 -2536
- package/dist/lib/handlers/context-async.mjs +1 -172
- package/dist/lib/handlers/context-live.mjs +1 -173
- package/dist/lib/handlers/hook-manager.mjs +1 -667
- package/dist/lib/handlers/lifecycle-token.mjs +1 -28
- package/dist/lib/handlers/lifecycle.mjs +1 -115
- package/dist/lib/handlers/materialize-manager.mjs +1 -48
- package/dist/lib/handlers/metadata.mjs +1 -501
- package/dist/lib/handlers/ownership.mjs +1 -322
- package/dist/lib/handlers/permission-manager.mjs +1 -392
- package/dist/lib/handlers/unified-wrapper.mjs +1 -3110
- package/dist/lib/handlers/version-manager.mjs +1 -885
- package/dist/lib/helpers/class-instance-wrapper.mjs +1 -109
- package/dist/lib/helpers/config.mjs +1 -439
- package/dist/lib/helpers/eventemitter-context.mjs +1 -349
- package/dist/lib/helpers/hint-detector.mjs +1 -47
- package/dist/lib/helpers/modes-utils.mjs +1 -37
- package/dist/lib/helpers/pattern-matcher.mjs +1 -125
- package/dist/lib/helpers/resolve-from-caller.mjs +1 -169
- package/dist/lib/helpers/sanitize.mjs +1 -340
- package/dist/lib/helpers/utilities.mjs +1 -70
- package/dist/lib/i18n/languages/de-de.json +1 -0
- package/dist/lib/i18n/languages/en-gb.json +1 -0
- package/dist/lib/i18n/languages/en-us.json +1 -0
- package/dist/lib/i18n/languages/es-es.json +412 -0
- package/dist/lib/i18n/languages/es-mx.json +1 -0
- package/dist/lib/i18n/languages/fr-fr.json +1 -0
- package/dist/lib/i18n/languages/hi-in.json +2 -1
- package/dist/lib/i18n/languages/ja-jp.json +1 -0
- package/dist/lib/i18n/languages/ko-kr.json +1 -0
- package/dist/lib/i18n/languages/pt-br.json +21 -20
- package/dist/lib/i18n/languages/ru-ru.json +2 -1
- package/dist/lib/i18n/languages/zh-cn.json +6 -5
- package/dist/lib/i18n/translations.mjs +1 -126
- package/dist/lib/modes/eager.mjs +1 -59
- package/dist/lib/modes/lazy.mjs +1 -81
- package/dist/lib/processors/flatten.mjs +1 -437
- package/dist/lib/processors/loader.mjs +1 -339
- package/dist/lib/processors/type-generator.mjs +1 -275
- package/dist/lib/processors/typescript.mjs +1 -172
- package/dist/lib/runtime/runtime-asynclocalstorage.mjs +1 -113
- package/dist/lib/runtime/runtime-livebindings.mjs +1 -78
- package/dist/lib/runtime/runtime.mjs +1 -102
- package/dist/slothlet.mjs +1 -817
- package/package.json +35 -31
- package/types/dist/lib/builders/api-assignment.d.mts +3 -92
- package/types/dist/lib/builders/api-assignment.d.mts.map +1 -1
- package/types/dist/lib/builders/api_builder.d.mts +102 -91
- package/types/dist/lib/builders/api_builder.d.mts.map +1 -1
- package/types/dist/lib/builders/builder.d.mts +1 -55
- package/types/dist/lib/builders/builder.d.mts.map +1 -1
- package/types/dist/lib/builders/modes-processor.d.mts +3 -27
- package/types/dist/lib/builders/modes-processor.d.mts.map +1 -1
- package/types/dist/lib/errors.d.mts +19 -109
- package/types/dist/lib/errors.d.mts.map +1 -1
- package/types/dist/lib/factories/component-base.d.mts +7 -177
- package/types/dist/lib/factories/component-base.d.mts.map +1 -1
- package/types/dist/lib/factories/context.d.mts +4 -22
- package/types/dist/lib/factories/context.d.mts.map +1 -1
- package/types/dist/lib/handlers/api-cache-manager.d.mts +20 -203
- package/types/dist/lib/handlers/api-cache-manager.d.mts.map +1 -1
- package/types/dist/lib/handlers/api-manager.d.mts +34 -408
- package/types/dist/lib/handlers/api-manager.d.mts.map +1 -1
- package/types/dist/lib/handlers/context-async.d.mts +23 -61
- package/types/dist/lib/handlers/context-async.d.mts.map +1 -1
- package/types/dist/lib/handlers/context-live.d.mts +22 -59
- package/types/dist/lib/handlers/context-live.d.mts.map +1 -1
- package/types/dist/lib/handlers/hook-manager.d.mts +46 -185
- package/types/dist/lib/handlers/hook-manager.d.mts.map +1 -1
- package/types/dist/lib/handlers/lifecycle-token.d.mts +3 -48
- package/types/dist/lib/handlers/lifecycle-token.d.mts.map +1 -1
- package/types/dist/lib/handlers/lifecycle.d.mts +5 -82
- package/types/dist/lib/handlers/lifecycle.d.mts.map +1 -1
- package/types/dist/lib/handlers/materialize-manager.d.mts +8 -70
- package/types/dist/lib/handlers/materialize-manager.d.mts.map +1 -1
- package/types/dist/lib/handlers/metadata.d.mts +17 -221
- package/types/dist/lib/handlers/metadata.d.mts.map +1 -1
- package/types/dist/lib/handlers/ownership.d.mts +44 -160
- package/types/dist/lib/handlers/ownership.d.mts.map +1 -1
- package/types/dist/lib/handlers/permission-manager.d.mts +40 -141
- package/types/dist/lib/handlers/permission-manager.d.mts.map +1 -1
- package/types/dist/lib/handlers/unified-wrapper.d.mts +26 -239
- package/types/dist/lib/handlers/unified-wrapper.d.mts.map +1 -1
- package/types/dist/lib/handlers/version-manager.d.mts +28 -225
- package/types/dist/lib/handlers/version-manager.d.mts.map +1 -1
- package/types/dist/lib/helpers/class-instance-wrapper.d.mts +2 -52
- package/types/dist/lib/helpers/class-instance-wrapper.d.mts.map +1 -1
- package/types/dist/lib/helpers/config.d.mts +125 -139
- package/types/dist/lib/helpers/config.d.mts.map +1 -1
- package/types/dist/lib/helpers/eventemitter-context.d.mts +3 -29
- package/types/dist/lib/helpers/eventemitter-context.d.mts.map +1 -1
- package/types/dist/lib/helpers/hint-detector.d.mts +2 -15
- package/types/dist/lib/helpers/hint-detector.d.mts.map +1 -1
- package/types/dist/lib/helpers/modes-utils.d.mts +3 -30
- package/types/dist/lib/helpers/modes-utils.d.mts.map +1 -1
- package/types/dist/lib/helpers/pattern-matcher.d.mts +3 -43
- package/types/dist/lib/helpers/pattern-matcher.d.mts.map +1 -1
- package/types/dist/lib/helpers/resolve-from-caller.d.mts +3 -27
- package/types/dist/lib/helpers/resolve-from-caller.d.mts.map +1 -1
- package/types/dist/lib/helpers/sanitize.d.mts +4 -92
- package/types/dist/lib/helpers/sanitize.d.mts.map +1 -1
- package/types/dist/lib/helpers/utilities.d.mts +4 -52
- package/types/dist/lib/helpers/utilities.d.mts.map +1 -1
- package/types/dist/lib/i18n/translations.d.mts +4 -37
- package/types/dist/lib/i18n/translations.d.mts.map +1 -1
- package/types/dist/lib/modes/eager.d.mts +8 -30
- package/types/dist/lib/modes/eager.d.mts.map +1 -1
- package/types/dist/lib/modes/lazy.d.mts +10 -43
- package/types/dist/lib/modes/lazy.d.mts.map +1 -1
- package/types/dist/lib/processors/flatten.d.mts +56 -107
- package/types/dist/lib/processors/flatten.d.mts.map +1 -1
- package/types/dist/lib/processors/loader.d.mts +6 -41
- package/types/dist/lib/processors/loader.d.mts.map +1 -1
- package/types/dist/lib/processors/type-generator.d.mts +2 -16
- package/types/dist/lib/processors/type-generator.d.mts.map +1 -1
- package/types/dist/lib/processors/typescript.d.mts +6 -53
- package/types/dist/lib/processors/typescript.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts +3 -71
- package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime-livebindings.d.mts +2 -37
- package/types/dist/lib/runtime/runtime-livebindings.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime.d.mts +3 -39
- package/types/dist/lib/runtime/runtime.d.mts.map +1 -1
- package/types/dist/slothlet.d.mts +3 -249
- package/types/dist/slothlet.d.mts.map +1 -1
- package/types/index.d.mts +36 -16
- package/types/index.d.mts.map +1 -0
- package/AGENT-USAGE.md +0 -736
- package/docs/API-RULES.md +0 -712
|
@@ -1,229 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Metadata handler for introspection of function metadata
|
|
3
|
-
* @class Metadata
|
|
4
|
-
* @extends ComponentBase
|
|
5
|
-
* @package
|
|
6
|
-
*/
|
|
7
1
|
export class Metadata extends ComponentBase {
|
|
8
2
|
static slothletProperty: string;
|
|
9
|
-
_instanceId:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* @param {Function|Object} target - Wrapper or function to tag
|
|
22
|
-
* @param {Object} systemData - System metadata (filePath, apiPath, moduleID, sourceFolder)
|
|
23
|
-
* @param {symbol} token - Must be `LIFECYCLE_TOKEN` — the unforgeable module-private Symbol
|
|
24
|
-
* @private
|
|
25
|
-
*/
|
|
26
|
-
private tagSystemMetadata;
|
|
27
|
-
/**
|
|
28
|
-
* Get system metadata only (without user metadata)
|
|
29
|
-
* @param {Function|Object} target - Wrapper or function
|
|
30
|
-
* @returns {Object|null} System metadata or null
|
|
31
|
-
* @package
|
|
32
|
-
*/
|
|
33
|
-
getSystemMetadata(target: Function | any): any | null;
|
|
34
|
-
/**
|
|
35
|
-
* Get metadata for a target (combines system + user)
|
|
36
|
-
* For wrappers: checks current impl to ensure metadata is current
|
|
37
|
-
* @param {Function|Object} target - Wrapper or function
|
|
38
|
-
* @returns {Object} Combined metadata (deeply frozen)
|
|
39
|
-
* @public
|
|
40
|
-
*/
|
|
41
|
-
public getMetadata(target: Function | any): any;
|
|
42
|
-
/**
|
|
43
|
-
* Set global user metadata (applies to all functions)
|
|
44
|
-
* @param {string} key - Metadata key
|
|
45
|
-
* @param {unknown} value - Metadata value
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
public setGlobalMetadata(key: string, value: unknown): void;
|
|
49
|
-
/**
|
|
50
|
-
* Add/update user metadata for specific function
|
|
51
|
-
* @param {Function} target - Function to tag with metadata
|
|
52
|
-
* @param {string} key - Metadata key
|
|
53
|
-
* @param {unknown} value - Metadata value
|
|
54
|
-
* @public
|
|
55
|
-
*/
|
|
56
|
-
public setUserMetadata(target: Function, key: string, value: unknown): void;
|
|
57
|
-
/**
|
|
58
|
-
* Remove user metadata from specific function
|
|
59
|
-
* @param {Function} target - Function to remove metadata from
|
|
60
|
-
* @param {string|string[]|Object<string, string[]>} [key] - Optional key(s) to remove (removes all if omitted). Can be:
|
|
61
|
-
* - string: Remove single key
|
|
62
|
-
* - string[]: Remove multiple keys (each element must be a string)
|
|
63
|
-
* - {key: string[]}: Remove nested keys from object values
|
|
64
|
-
* @public
|
|
65
|
-
*/
|
|
66
|
-
public removeUserMetadata(target: Function, key?: string | string[] | {
|
|
67
|
-
[x: string]: string[];
|
|
68
|
-
}): void;
|
|
69
|
-
/**
|
|
70
|
-
* Register user metadata keyed by an identifier (moduleID or API path)
|
|
71
|
-
*
|
|
72
|
-
* @description
|
|
73
|
-
* Stores user-provided metadata in `#userMetadataStore` under the given
|
|
74
|
-
* `identifier`. The identifier is treated opaquely — callers pass either a
|
|
75
|
-
* generated moduleID (e.g. `base_slothlet`) or a dot-notation API path
|
|
76
|
-
* (e.g. `math`). `getMetadata()` retrieves entries using the same key via
|
|
77
|
-
* both the moduleID lookup and `collectMetadataFromParents`, so storing
|
|
78
|
-
* under a single key is sufficient for both cases.
|
|
79
|
-
*
|
|
80
|
-
* Multiple calls to the same identifier are merged; later calls override
|
|
81
|
-
* earlier ones for conflicting keys.
|
|
82
|
-
*
|
|
83
|
-
* @param {string} identifier - Module ID or dot-notation API path
|
|
84
|
-
* @param {Object} metadata - User metadata object to merge
|
|
85
|
-
* @package
|
|
86
|
-
*/
|
|
87
|
-
registerUserMetadata(identifier: string, metadata: any): void;
|
|
88
|
-
/**
|
|
89
|
-
* Remove all user metadata for an apiPath
|
|
90
|
-
*
|
|
91
|
-
* @description
|
|
92
|
-
* Cleanup method to remove all user metadata associated with an apiPath.
|
|
93
|
-
* Used during api.remove() or cleanup operations.
|
|
94
|
-
*
|
|
95
|
-
* @param {string} apiPath - API path to remove
|
|
96
|
-
* @package
|
|
97
|
-
*/
|
|
98
|
-
removeUserMetadataByApiPath(apiPath: string): void;
|
|
99
|
-
/**
|
|
100
|
-
* Set metadata for all functions reachable at an API path.
|
|
101
|
-
*
|
|
102
|
-
* @description
|
|
103
|
-
* Stores metadata keyed by `apiPath` so that every function whose system
|
|
104
|
-
* `apiPath` starts with (or equals) the given path inherits the values via
|
|
105
|
-
* `collectMetadataFromParents()` in `getMetadata()`.
|
|
106
|
-
*
|
|
107
|
-
* Accepts either a single key/value pair or a plain object to merge.
|
|
108
|
-
* Multiple calls to the same path are merged; later calls override earlier
|
|
109
|
-
* ones for conflicting keys.
|
|
110
|
-
*
|
|
111
|
-
* Priority (lowest → highest): global → setForPath → set() → system.
|
|
112
|
-
*
|
|
113
|
-
* @param {string} apiPath - Dot-notation path (e.g. `"math"`, `"math.add"`)
|
|
114
|
-
* @param {string|Object} keyOrObj - Key string (with `value`) OR metadata object to merge
|
|
115
|
-
* @param {unknown} [value] - Value when `keyOrObj` is a string key
|
|
116
|
-
* @public
|
|
117
|
-
*/
|
|
118
|
-
public setPathMetadata(apiPath: string, keyOrObj: string | any, value?: unknown): void;
|
|
119
|
-
/**
|
|
120
|
-
* Get the user metadata collected from the path store for a given API path.
|
|
121
|
-
*
|
|
122
|
-
* @description
|
|
123
|
-
* Traverses from root segment to leaf, merging parent → child metadata — the same
|
|
124
|
-
* traversal used by `collectMetadataFromParents` inside `getMetadata()`. Does not
|
|
125
|
-
* include immutable system metadata; only user-supplied path store entries are returned.
|
|
126
|
-
*
|
|
127
|
-
* @param {string} apiPath - Dot-notation API path (e.g. `"v1.auth"`, `"math"`).
|
|
128
|
-
* @returns {Object} Merged user metadata for the path (not frozen).
|
|
129
|
-
* @public
|
|
130
|
-
* @example
|
|
131
|
-
* metadata.getPathMetadata("v1.auth"); // { stable: true, category: "auth" }
|
|
132
|
-
*/
|
|
133
|
-
public getPathMetadata(apiPath: string): any;
|
|
134
|
-
/**
|
|
135
|
-
* Remove metadata keys (or all metadata) for an API path.
|
|
136
|
-
*
|
|
137
|
-
* @description
|
|
138
|
-
* Removes one specific key, multiple keys, or ALL user metadata stored under
|
|
139
|
-
* the given `apiPath` key in the path store.
|
|
140
|
-
* Only affects metadata set via `setForPath()` / `registerUserMetadata()` for
|
|
141
|
-
* this exact path segment - it does not walk descendant paths.
|
|
142
|
-
*
|
|
143
|
-
* @param {string} apiPath - Dot-notation path (e.g. `"math"`, `"math.add"`)
|
|
144
|
-
* @param {string|string[]} [key] - Key(s) to remove. Omit to remove all metadata for the path.
|
|
145
|
-
* @public
|
|
146
|
-
*/
|
|
147
|
-
public removePathMetadata(apiPath: string, key?: string | string[]): void;
|
|
148
|
-
/**
|
|
149
|
-
* Export user-managed metadata state for preservation across reload.
|
|
150
|
-
*
|
|
151
|
-
* @description
|
|
152
|
-
* Captures `#globalUserMetadata` and all entries in `#userMetadataStore`
|
|
153
|
-
* so they can be restored to a fresh Metadata instance after reload.
|
|
154
|
-
* Called by `slothlet.reload()` BEFORE `load()` destroys this instance.
|
|
155
|
-
*
|
|
156
|
-
* @returns {{ globalMetadata: Object, userMetadataStore: Map }} Snapshot of user state
|
|
157
|
-
* @package
|
|
158
|
-
*/
|
|
3
|
+
_instanceId: null;
|
|
4
|
+
tagSystemMetadata(target: any, systemData: any, token: any): void;
|
|
5
|
+
getSystemMetadata(target: any): any;
|
|
6
|
+
getMetadata(target: any): any;
|
|
7
|
+
setGlobalMetadata(key: any, value: any): void;
|
|
8
|
+
setUserMetadata(target: any, key: any, value: any): void;
|
|
9
|
+
removeUserMetadata(target: any, key: any): void;
|
|
10
|
+
registerUserMetadata(identifier: any, metadata: any): void;
|
|
11
|
+
removeUserMetadataByApiPath(apiPath: any): void;
|
|
12
|
+
setPathMetadata(apiPath: any, keyOrObj: any, value: any): void;
|
|
13
|
+
getPathMetadata(apiPath: any): {};
|
|
14
|
+
removePathMetadata(apiPath: any, key: any): void;
|
|
159
15
|
exportUserState(): {
|
|
160
|
-
globalMetadata:
|
|
16
|
+
globalMetadata: {};
|
|
161
17
|
userMetadataStore: Map<any, any>;
|
|
162
18
|
};
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
* Merges previously exported state into the new (empty) Metadata instance.
|
|
168
|
-
* Called by `slothlet.reload()` AFTER `load()` creates the new instance and
|
|
169
|
-
* BEFORE operation-history replay so that `registerUserMetadata()` from replay
|
|
170
|
-
* can properly merge over the restored base state.
|
|
171
|
-
*
|
|
172
|
-
* Merge priority: existing (from load) > saved state.
|
|
173
|
-
* This means replay-registered api.add metadata overrides restored values
|
|
174
|
-
* for the same key, which is the desired behaviour.
|
|
175
|
-
*
|
|
176
|
-
* @param {{ globalMetadata: Object, userMetadataStore: Map }} state - Previously exported state
|
|
177
|
-
* @package
|
|
178
|
-
*/
|
|
179
|
-
importUserState(state: {
|
|
180
|
-
globalMetadata: any;
|
|
181
|
-
userMetadataStore: Map<any, any>;
|
|
182
|
-
}): void;
|
|
183
|
-
/**
|
|
184
|
-
* Get metadata of any function by API path.
|
|
185
|
-
*
|
|
186
|
-
* Traverses `this.slothlet.api` using the dot-notation path, materializes
|
|
187
|
-
* lazy wrappers as needed, then returns the combined metadata for the
|
|
188
|
-
* resolved target via `getMetadata()`.
|
|
189
|
-
*
|
|
190
|
-
* Called by the `api.slothlet.metadata.get()` closure injected in
|
|
191
|
-
* `slothlet.injectRuntimeMetadataFunctions()`.
|
|
192
|
-
*
|
|
193
|
-
* @param {string} path - Dot-notation API path (e.g. `"math.add"`)
|
|
194
|
-
* @returns {Promise<object|null>} Combined metadata or null
|
|
195
|
-
* @public
|
|
196
|
-
*/
|
|
197
|
-
public get(path: string): Promise<object | null>;
|
|
198
|
-
/**
|
|
199
|
-
* Get metadata for the currently-executing API function.
|
|
200
|
-
*
|
|
201
|
-
* Reads `currentWrapper` from the active context-manager store — the same
|
|
202
|
-
* fast synchronous path used by the unified wrapper's `apply` trap.
|
|
203
|
-
* Throws `RUNTIME_NO_ACTIVE_CONTEXT` when called outside of a slothlet
|
|
204
|
-
* execution context.
|
|
205
|
-
*
|
|
206
|
-
* Called by the `api.slothlet.metadata.self()` closure injected in
|
|
207
|
-
* `slothlet.injectRuntimeMetadataFunctions()`.
|
|
208
|
-
*
|
|
209
|
-
* @returns {object} Combined metadata for the current function
|
|
210
|
-
* @public
|
|
211
|
-
*/
|
|
212
|
-
public self(): object;
|
|
213
|
-
/**
|
|
214
|
-
* Get metadata for the API function that called the current function.
|
|
215
|
-
*
|
|
216
|
-
* Reads `callerWrapper` from the active context-manager store.
|
|
217
|
-
* Returns `null` when there is no caller in context (e.g. the function
|
|
218
|
-
* was invoked directly from outside the API).
|
|
219
|
-
*
|
|
220
|
-
* Called by the `api.slothlet.metadata.caller()` closure injected in
|
|
221
|
-
* `slothlet.injectRuntimeMetadataFunctions()`.
|
|
222
|
-
*
|
|
223
|
-
* @returns {object|null} Combined metadata for the calling function, or null
|
|
224
|
-
* @public
|
|
225
|
-
*/
|
|
226
|
-
public caller(): object | null;
|
|
19
|
+
importUserState(state: any): void;
|
|
20
|
+
get(path: any): Promise<any>;
|
|
21
|
+
self(): any;
|
|
22
|
+
caller(): any;
|
|
227
23
|
#private;
|
|
228
24
|
}
|
|
229
25
|
import { ComponentBase } from "@cldmv/slothlet/factories/component-base";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.mts","sourceRoot":"","sources":["../../../../dist/lib/handlers/metadata.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"metadata.d.mts","sourceRoot":"","sources":["../../../../dist/lib/handlers/metadata.mjs"],"names":[],"mappings":"AAA2M;IAAqC,gCAAmC;IAA8E,kBAAiB;IAA4U,kEAA2zB;IAAA,oCAA4N;IAAA,8BAAgkC;IAAA,8CAAiE;IAAA,yDAA26B;IAAA,gDAA0mD;IAAA,2DAAkd;IAAA,gDAAgG;IAAA,+DAA4kB;IAAA,kCAAyX;IAAA,iDAAijB;IAAA;;;MAA8P;IAAA,kCAA2jB;IAAA,6BAA8kB;IAAA,YAAkO;IAAA,cAAoJ;;CAAC;8BAAxnS,0CAA0C"}
|
|
@@ -1,170 +1,54 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Summary result of an unregister operation.
|
|
3
|
-
* @typedef {Object} UnregisterResult
|
|
4
|
-
* @property {string[]} removed - API paths that were removed.
|
|
5
|
-
* @property {Object[]} rolledBack - Entries that were rolled back to a previous owner.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Tracks which modules own which API paths for hot reload and rollback
|
|
9
|
-
* @class OwnershipManager
|
|
10
|
-
* @extends ComponentBase
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
1
|
export class OwnershipManager extends ComponentBase {
|
|
14
2
|
static slothletProperty: string;
|
|
15
|
-
constructor(slothlet: any);
|
|
16
3
|
moduleToPath: Map<any, any>;
|
|
17
4
|
pathToModule: Map<any, any>;
|
|
18
5
|
_unregisteredModules: Set<any>;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* @param {string} options.moduleID - Module identifier
|
|
23
|
-
* @param {string} options.apiPath - API path being registered
|
|
24
|
-
* @param {*} options.value - The actual function/object being registered
|
|
25
|
-
* @param {string} [options.source="core"] - Source of registration
|
|
26
|
-
* @param {string} [options.collisionMode="error"] - Collision mode: skip, warn, error, merge, replace
|
|
27
|
-
* @param {Object} [options.config] - Config object for silent mode check
|
|
28
|
-
* @param {string} [options.filePath=null] - File path of the module source (for metadata tracking)
|
|
29
|
-
* @returns {Object|null} Registration entry or null if skipped
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
public register({ moduleID, apiPath, value, source, collisionMode, config, filePath }: {
|
|
33
|
-
moduleID: string;
|
|
34
|
-
apiPath: string;
|
|
6
|
+
register({ moduleID, apiPath, value, source, collisionMode, config, filePath }: {
|
|
7
|
+
moduleID: any;
|
|
8
|
+
apiPath: any;
|
|
35
9
|
value: any;
|
|
36
|
-
source?: string;
|
|
37
|
-
collisionMode?: string;
|
|
38
|
-
config?:
|
|
39
|
-
filePath?:
|
|
40
|
-
}): any
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
* Removes all paths owned by the provided moduleID and reports removals and rollbacks.
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* const result = ownership.unregister("module-a");
|
|
51
|
-
*/
|
|
52
|
-
public unregister(moduleID: string): UnregisterResult;
|
|
53
|
-
/**
|
|
54
|
-
* @param {string} apiPath - API path to modify.
|
|
55
|
-
* @param {string|null} [moduleID=null] - Module to remove (defaults to current owner).
|
|
56
|
-
* @returns {{ action: "delete"|"none"|"restore", removedModuleId: string|null,
|
|
57
|
-
* restoreModuleId: string|null }} Action taken for the path.
|
|
58
|
-
* @public
|
|
59
|
-
*
|
|
60
|
-
* @description
|
|
61
|
-
* Removes a module owner from a specific API path. If the current owner is removed and
|
|
62
|
-
* previous owners exist, the path is restored to the previous owner.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* const result = ownership.removePath("plugins.tools", "module-a");
|
|
66
|
-
*/
|
|
67
|
-
public removePath(apiPath: string, moduleID?: string | null): {
|
|
68
|
-
action: "delete" | "none" | "restore";
|
|
69
|
-
removedModuleId: string | null;
|
|
70
|
-
restoreModuleId: string | null;
|
|
10
|
+
source?: string | undefined;
|
|
11
|
+
collisionMode?: string | undefined;
|
|
12
|
+
config?: null | undefined;
|
|
13
|
+
filePath?: null | undefined;
|
|
14
|
+
}): any;
|
|
15
|
+
unregister(moduleID: any): {
|
|
16
|
+
removed: any[];
|
|
17
|
+
rolledBack: {
|
|
18
|
+
apiPath: any;
|
|
19
|
+
restoredTo: any;
|
|
20
|
+
}[];
|
|
71
21
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
* @param {string} moduleID - Module to check
|
|
103
|
-
* @param {string} apiPath - API path to check
|
|
104
|
-
* @returns {boolean} True if module owns path
|
|
105
|
-
* @public
|
|
106
|
-
*/
|
|
107
|
-
public ownsPath(moduleID: string, apiPath: string): boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Get diagnostic info about ownership
|
|
110
|
-
* @returns {Object} Diagnostic information
|
|
111
|
-
* @public
|
|
112
|
-
*/
|
|
113
|
-
public getDiagnostics(): any;
|
|
114
|
-
/**
|
|
115
|
-
* Get ownership info for a specific API path
|
|
116
|
-
* @param {string} apiPath - API path to check
|
|
117
|
-
* @returns {Set<string>|null} Set of moduleIDs that own this path, or null if path not found
|
|
118
|
-
* @public
|
|
119
|
-
*/
|
|
120
|
-
public getPathOwnership(apiPath: string): Set<string> | null;
|
|
121
|
-
/**
|
|
122
|
-
* Recursively register API subtree with ownership
|
|
123
|
-
* @param {object} api - API object or subtree
|
|
124
|
-
* @param {string} moduleID - Module identifier (owner)
|
|
125
|
-
* @param {string} path - Current API path
|
|
126
|
-
* @param {WeakSet} [visited] - Visited objects (prevents circular refs)
|
|
127
|
-
* @returns {void}
|
|
128
|
-
* @public
|
|
129
|
-
*
|
|
130
|
-
* @description
|
|
131
|
-
* Registers entire API subtree structure with ownership manager.
|
|
132
|
-
* Used during load, reload, and api.add to establish ownership relationships.
|
|
133
|
-
*
|
|
134
|
-
* @example
|
|
135
|
-
* ownership.registerSubtree(api, "base_abc123", "");
|
|
136
|
-
*/
|
|
137
|
-
public registerSubtree(api: object, moduleID: string, path: string, visited?: WeakSet<any>): void;
|
|
138
|
-
/**
|
|
139
|
-
* Clear all ownership data
|
|
140
|
-
* @public
|
|
141
|
-
*/
|
|
142
|
-
public clear(): void;
|
|
143
|
-
/**
|
|
144
|
-
* Export ownership state for preservation during reload
|
|
145
|
-
* @returns {Object} Serializable ownership state
|
|
146
|
-
* @public
|
|
147
|
-
*/
|
|
148
|
-
public exportState(): any;
|
|
149
|
-
/**
|
|
150
|
-
* Import ownership state from exported data
|
|
151
|
-
* @param {Object} state - Previously exported state
|
|
152
|
-
* @public
|
|
153
|
-
*/
|
|
154
|
-
public importState(state: any): void;
|
|
22
|
+
removePath(apiPath: any, moduleID?: null): {
|
|
23
|
+
action: string;
|
|
24
|
+
removedModuleId: any;
|
|
25
|
+
restoreModuleId: any;
|
|
26
|
+
};
|
|
27
|
+
getCurrentOwner(apiPath: any): any;
|
|
28
|
+
getCurrentValue(apiPath: any): any;
|
|
29
|
+
getModulePaths(moduleID: any): any[];
|
|
30
|
+
getPathHistory(apiPath: any): any;
|
|
31
|
+
ownsPath(moduleID: any, apiPath: any): any;
|
|
32
|
+
getDiagnostics(): {
|
|
33
|
+
totalModules: number;
|
|
34
|
+
totalPaths: number;
|
|
35
|
+
modules: {
|
|
36
|
+
moduleID: any;
|
|
37
|
+
pathCount: any;
|
|
38
|
+
}[];
|
|
39
|
+
conflictedPaths: {
|
|
40
|
+
apiPath: any;
|
|
41
|
+
ownerStack: any;
|
|
42
|
+
}[];
|
|
43
|
+
};
|
|
44
|
+
getPathOwnership(apiPath: any): Set<any> | null;
|
|
45
|
+
registerSubtree(api: any, moduleID: any, path: any, visited?: WeakSet<object>): void;
|
|
46
|
+
clear(): void;
|
|
47
|
+
exportState(): {
|
|
48
|
+
moduleToPath: any[][];
|
|
49
|
+
pathToModule: [any, any][];
|
|
50
|
+
};
|
|
51
|
+
importState(state: any): void;
|
|
155
52
|
}
|
|
156
|
-
/**
|
|
157
|
-
* Summary result of an unregister operation.
|
|
158
|
-
*/
|
|
159
|
-
export type UnregisterResult = {
|
|
160
|
-
/**
|
|
161
|
-
* - API paths that were removed.
|
|
162
|
-
*/
|
|
163
|
-
removed: string[];
|
|
164
|
-
/**
|
|
165
|
-
* - Entries that were rolled back to a previous owner.
|
|
166
|
-
*/
|
|
167
|
-
rolledBack: any[];
|
|
168
|
-
};
|
|
169
53
|
import { ComponentBase } from "@cldmv/slothlet/factories/component-base";
|
|
170
54
|
//# sourceMappingURL=ownership.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ownership.d.mts","sourceRoot":"","sources":["../../../../dist/lib/handlers/ownership.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ownership.d.mts","sourceRoot":"","sources":["../../../../dist/lib/handlers/ownership.mjs"],"names":[],"mappings":"AAAyI;IAA6C,gCAAoC;IAAsC,4BAAyB;IAAC,4BAAyB;IAAC,+BAAiC;IAAC;;;;;;;;YAAqlD;IAAA;;;;;;MAAud;IAAA;;;;MAAszB;IAAA,mCAAyI;IAAA,mCAA+M;IAAA,qCAAgF;IAAA,kCAAkE;IAAA,2CAA6G;IAAA;;;;;;;;;;;MAA6W;IAAA,gDAA+J;IAAA,qFAAstB;IAAA,cAA8F;IAAA;;;MAA0K;IAAA,8BAAkM;CAAC;8BAAn6K,0CAA0C"}
|
|
@@ -1,150 +1,49 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manages access control rules for API path invocations.
|
|
3
|
-
* Rules are glob-pattern-based (same syntax as hooks: *, **, ?, {a,b}, !negation).
|
|
4
|
-
* Self-calls (same moduleID) always bypass the permission system.
|
|
5
|
-
*
|
|
6
|
-
* @class PermissionManager
|
|
7
|
-
* @extends ComponentBase
|
|
8
|
-
*/
|
|
9
1
|
export class PermissionManager extends ComponentBase {
|
|
10
|
-
/**
|
|
11
|
-
* Property name for auto-discovery by _initializeComponents.
|
|
12
|
-
* @type {string}
|
|
13
|
-
* @static
|
|
14
|
-
*/
|
|
15
2
|
static slothletProperty: string;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
removeRule(ruleId: string, callerModuleID?: string | null): boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Check whether a caller path is allowed to access a target path.
|
|
49
|
-
* This is the main enforcement method called from applyTrap.
|
|
50
|
-
*
|
|
51
|
-
* @param {string} callerPath - The calling module's API path.
|
|
52
|
-
* @param {string} targetPath - The target API path being accessed.
|
|
53
|
-
* @param {string|null} [callerFilePath=null] - Caller's source file path (for self-call bypass).
|
|
54
|
-
* @param {string|null} [targetFilePath=null] - Target's source file path (for self-call bypass).
|
|
55
|
-
* @returns {boolean} True if access is allowed.
|
|
56
|
-
* @example
|
|
57
|
-
* const allowed = pm.checkAccess("payments.charge", "db.write", "/src/pay.mjs", "/src/db.mjs");
|
|
58
|
-
*/
|
|
59
|
-
checkAccess(callerPath: string, targetPath: string, callerFilePath?: string | null, targetFilePath?: string | null): boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Get all rules that match a given target path.
|
|
62
|
-
*
|
|
63
|
-
* @param {string} targetPath - Target API path to check.
|
|
64
|
-
* @returns {Array<object>} Array of matching rule objects (serialized).
|
|
65
|
-
* @example
|
|
66
|
-
* const rules = pm.getRulesForPath("db.write");
|
|
67
|
-
*/
|
|
68
|
-
getRulesForPath(targetPath: string): Array<object>;
|
|
69
|
-
/**
|
|
70
|
-
* Get all rules owned by a given module.
|
|
71
|
-
*
|
|
72
|
-
* @param {string} moduleID - Module ID to look up.
|
|
73
|
-
* @returns {Array<object>} Array of rule objects (serialized).
|
|
74
|
-
* @example
|
|
75
|
-
* const rules = pm.getRulesByModule("mod_abc123");
|
|
76
|
-
*/
|
|
77
|
-
getRulesByModule(moduleID: string): Array<object>;
|
|
78
|
-
/**
|
|
79
|
-
* Get all rules where the caller pattern matches a given caller path.
|
|
80
|
-
* Used by `self.rules()` to show what rules affect the calling module.
|
|
81
|
-
*
|
|
82
|
-
* @param {string} callerPath - Caller API path.
|
|
83
|
-
* @returns {Array<object>} Array of matching rule objects (serialized).
|
|
84
|
-
* @example
|
|
85
|
-
* const rules = pm.getRulesForCaller("payments.charge");
|
|
86
|
-
*/
|
|
87
|
-
getRulesForCaller(callerPath: string): Array<object>;
|
|
88
|
-
/**
|
|
89
|
-
* Enable the permission system globally.
|
|
90
|
-
*
|
|
91
|
-
* @returns {void}
|
|
92
|
-
* @example
|
|
93
|
-
* pm.enable();
|
|
94
|
-
*/
|
|
3
|
+
addRule(rule: any, ownerModuleID?: null, ruleId?: null): string;
|
|
4
|
+
removeRule(ruleId: any, callerModuleID?: null): boolean;
|
|
5
|
+
checkAccess(callerPath: any, targetPath: any, callerFilePath?: null, targetFilePath?: null, runtimeContext?: null): any;
|
|
6
|
+
getRulesForPath(targetPath: any): {
|
|
7
|
+
id: any;
|
|
8
|
+
caller: any;
|
|
9
|
+
target: any;
|
|
10
|
+
effect: any;
|
|
11
|
+
condition: any;
|
|
12
|
+
ownerModuleID: any;
|
|
13
|
+
registeredAt: any;
|
|
14
|
+
}[];
|
|
15
|
+
getRulesByModule(moduleID: any): {
|
|
16
|
+
id: any;
|
|
17
|
+
caller: any;
|
|
18
|
+
target: any;
|
|
19
|
+
effect: any;
|
|
20
|
+
condition: any;
|
|
21
|
+
ownerModuleID: any;
|
|
22
|
+
registeredAt: any;
|
|
23
|
+
}[];
|
|
24
|
+
getRulesForCaller(callerPath: any): {
|
|
25
|
+
id: any;
|
|
26
|
+
caller: any;
|
|
27
|
+
target: any;
|
|
28
|
+
effect: any;
|
|
29
|
+
condition: any;
|
|
30
|
+
ownerModuleID: any;
|
|
31
|
+
registeredAt: any;
|
|
32
|
+
}[];
|
|
95
33
|
enable(): void;
|
|
96
|
-
/**
|
|
97
|
-
* Disable the permission system globally (all calls allowed).
|
|
98
|
-
*
|
|
99
|
-
* @returns {void}
|
|
100
|
-
* @example
|
|
101
|
-
* pm.disable();
|
|
102
|
-
*/
|
|
103
34
|
disable(): void;
|
|
104
|
-
/**
|
|
105
|
-
* Whether the permission system is currently enabled.
|
|
106
|
-
*
|
|
107
|
-
* @returns {boolean} True if enabled.
|
|
108
|
-
* @example
|
|
109
|
-
* if (pm.isEnabled()) { ... }
|
|
110
|
-
*/
|
|
111
35
|
isEnabled(): boolean;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
* Re-register rules exported by {@link exportRules}.
|
|
122
|
-
* Called after a full reload to restore programmatic rules.
|
|
123
|
-
*
|
|
124
|
-
* @param {Array<object>} registrations - Snapshot returned by exportRules().
|
|
125
|
-
* @returns {void}
|
|
126
|
-
* @example
|
|
127
|
-
* pm.importRules(snapshot);
|
|
128
|
-
*/
|
|
129
|
-
importRules(registrations: Array<object>): void;
|
|
130
|
-
/**
|
|
131
|
-
* Cleanup permission manager on shutdown.
|
|
132
|
-
* Clears all internal state.
|
|
133
|
-
*
|
|
134
|
-
* @returns {Promise<void>}
|
|
135
|
-
* @example
|
|
136
|
-
* await pm.shutdown();
|
|
137
|
-
*/
|
|
36
|
+
exportRules(): {
|
|
37
|
+
rule: {
|
|
38
|
+
caller: any;
|
|
39
|
+
target: any;
|
|
40
|
+
effect: any;
|
|
41
|
+
};
|
|
42
|
+
ownerModuleID: any;
|
|
43
|
+
}[];
|
|
44
|
+
importRules(registrations: any): void;
|
|
138
45
|
shutdown(): Promise<void>;
|
|
139
|
-
|
|
140
|
-
* Emit a debug message. Delegates to slothlet.debug().
|
|
141
|
-
*
|
|
142
|
-
* @param {string} category - Debug category.
|
|
143
|
-
* @param {object} data - Debug data.
|
|
144
|
-
* @returns {void}
|
|
145
|
-
* @private
|
|
146
|
-
*/
|
|
147
|
-
private debug;
|
|
46
|
+
debug(category: any, data: any): void;
|
|
148
47
|
#private;
|
|
149
48
|
}
|
|
150
49
|
import { ComponentBase } from "@cldmv/slothlet/factories/component-base";
|