@cldmv/slothlet 3.2.3 → 3.3.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.
Files changed (138) hide show
  1. package/README.md +22 -9
  2. package/REFERENCE.md +23 -0
  3. package/dist/lib/builders/api-assignment.mjs +1 -589
  4. package/dist/lib/builders/api_builder.mjs +1 -1155
  5. package/dist/lib/builders/builder.mjs +1 -78
  6. package/dist/lib/builders/modes-processor.mjs +1 -1800
  7. package/dist/lib/errors.mjs +9 -211
  8. package/dist/lib/factories/component-base.mjs +1 -80
  9. package/dist/lib/factories/context.mjs +1 -22
  10. package/dist/lib/handlers/api-cache-manager.mjs +1 -200
  11. package/dist/lib/handlers/api-manager.mjs +1 -2513
  12. package/dist/lib/handlers/context-async.mjs +1 -168
  13. package/dist/lib/handlers/context-live.mjs +1 -168
  14. package/dist/lib/handlers/hook-manager.mjs +1 -773
  15. package/dist/lib/handlers/lifecycle-token.mjs +1 -28
  16. package/dist/lib/handlers/lifecycle.mjs +1 -115
  17. package/dist/lib/handlers/materialize-manager.mjs +1 -48
  18. package/dist/lib/handlers/metadata.mjs +1 -501
  19. package/dist/lib/handlers/ownership.mjs +1 -322
  20. package/dist/lib/handlers/permission-manager.mjs +17 -0
  21. package/dist/lib/handlers/unified-wrapper.mjs +1 -3042
  22. package/dist/lib/handlers/version-manager.mjs +1 -885
  23. package/dist/lib/helpers/class-instance-wrapper.mjs +1 -109
  24. package/dist/lib/helpers/config.mjs +1 -355
  25. package/dist/lib/helpers/eventemitter-context.mjs +1 -349
  26. package/dist/lib/helpers/hint-detector.mjs +1 -47
  27. package/dist/lib/helpers/modes-utils.mjs +1 -37
  28. package/dist/lib/helpers/pattern-matcher.mjs +17 -0
  29. package/dist/lib/helpers/resolve-from-caller.mjs +1 -169
  30. package/dist/lib/helpers/sanitize.mjs +1 -340
  31. package/dist/lib/helpers/utilities.mjs +1 -70
  32. package/dist/lib/i18n/languages/de-de.json +21 -1
  33. package/dist/lib/i18n/languages/en-gb.json +21 -1
  34. package/dist/lib/i18n/languages/en-us.json +21 -1
  35. package/dist/lib/i18n/languages/es-mx.json +21 -1
  36. package/dist/lib/i18n/languages/fr-fr.json +21 -1
  37. package/dist/lib/i18n/languages/hi-in.json +21 -1
  38. package/dist/lib/i18n/languages/ja-jp.json +21 -1
  39. package/dist/lib/i18n/languages/ko-kr.json +21 -1
  40. package/dist/lib/i18n/languages/pt-br.json +21 -1
  41. package/dist/lib/i18n/languages/ru-ru.json +21 -1
  42. package/dist/lib/i18n/languages/zh-cn.json +21 -1
  43. package/dist/lib/i18n/translations.mjs +1 -126
  44. package/dist/lib/modes/eager.mjs +1 -59
  45. package/dist/lib/modes/lazy.mjs +1 -81
  46. package/dist/lib/processors/flatten.mjs +1 -437
  47. package/dist/lib/processors/loader.mjs +1 -339
  48. package/dist/lib/processors/type-generator.mjs +1 -275
  49. package/dist/lib/processors/typescript.mjs +1 -172
  50. package/dist/lib/runtime/runtime-asynclocalstorage.mjs +1 -113
  51. package/dist/lib/runtime/runtime-livebindings.mjs +1 -78
  52. package/dist/lib/runtime/runtime.mjs +1 -102
  53. package/dist/slothlet.mjs +1 -808
  54. package/package.json +37 -31
  55. package/types/dist/lib/builders/api-assignment.d.mts +3 -92
  56. package/types/dist/lib/builders/api-assignment.d.mts.map +1 -1
  57. package/types/dist/lib/builders/api_builder.d.mts +102 -91
  58. package/types/dist/lib/builders/api_builder.d.mts.map +1 -1
  59. package/types/dist/lib/builders/builder.d.mts +1 -55
  60. package/types/dist/lib/builders/builder.d.mts.map +1 -1
  61. package/types/dist/lib/builders/modes-processor.d.mts +3 -27
  62. package/types/dist/lib/builders/modes-processor.d.mts.map +1 -1
  63. package/types/dist/lib/errors.d.mts +19 -109
  64. package/types/dist/lib/errors.d.mts.map +1 -1
  65. package/types/dist/lib/factories/component-base.d.mts +7 -177
  66. package/types/dist/lib/factories/component-base.d.mts.map +1 -1
  67. package/types/dist/lib/factories/context.d.mts +4 -22
  68. package/types/dist/lib/factories/context.d.mts.map +1 -1
  69. package/types/dist/lib/handlers/api-cache-manager.d.mts +20 -203
  70. package/types/dist/lib/handlers/api-cache-manager.d.mts.map +1 -1
  71. package/types/dist/lib/handlers/api-manager.d.mts +33 -408
  72. package/types/dist/lib/handlers/api-manager.d.mts.map +1 -1
  73. package/types/dist/lib/handlers/context-async.d.mts +23 -61
  74. package/types/dist/lib/handlers/context-async.d.mts.map +1 -1
  75. package/types/dist/lib/handlers/context-live.d.mts +22 -59
  76. package/types/dist/lib/handlers/context-live.d.mts.map +1 -1
  77. package/types/dist/lib/handlers/hook-manager.d.mts +46 -185
  78. package/types/dist/lib/handlers/hook-manager.d.mts.map +1 -1
  79. package/types/dist/lib/handlers/lifecycle-token.d.mts +3 -48
  80. package/types/dist/lib/handlers/lifecycle-token.d.mts.map +1 -1
  81. package/types/dist/lib/handlers/lifecycle.d.mts +5 -82
  82. package/types/dist/lib/handlers/lifecycle.d.mts.map +1 -1
  83. package/types/dist/lib/handlers/materialize-manager.d.mts +8 -70
  84. package/types/dist/lib/handlers/materialize-manager.d.mts.map +1 -1
  85. package/types/dist/lib/handlers/metadata.d.mts +17 -221
  86. package/types/dist/lib/handlers/metadata.d.mts.map +1 -1
  87. package/types/dist/lib/handlers/ownership.d.mts +44 -160
  88. package/types/dist/lib/handlers/ownership.d.mts.map +1 -1
  89. package/types/dist/lib/handlers/permission-manager.d.mts +47 -0
  90. package/types/dist/lib/handlers/permission-manager.d.mts.map +1 -0
  91. package/types/dist/lib/handlers/unified-wrapper.d.mts +26 -239
  92. package/types/dist/lib/handlers/unified-wrapper.d.mts.map +1 -1
  93. package/types/dist/lib/handlers/version-manager.d.mts +28 -225
  94. package/types/dist/lib/handlers/version-manager.d.mts.map +1 -1
  95. package/types/dist/lib/helpers/class-instance-wrapper.d.mts +2 -52
  96. package/types/dist/lib/helpers/class-instance-wrapper.d.mts.map +1 -1
  97. package/types/dist/lib/helpers/config.d.mts +125 -123
  98. package/types/dist/lib/helpers/config.d.mts.map +1 -1
  99. package/types/dist/lib/helpers/eventemitter-context.d.mts +3 -29
  100. package/types/dist/lib/helpers/eventemitter-context.d.mts.map +1 -1
  101. package/types/dist/lib/helpers/hint-detector.d.mts +2 -15
  102. package/types/dist/lib/helpers/hint-detector.d.mts.map +1 -1
  103. package/types/dist/lib/helpers/modes-utils.d.mts +3 -30
  104. package/types/dist/lib/helpers/modes-utils.d.mts.map +1 -1
  105. package/types/dist/lib/helpers/pattern-matcher.d.mts +4 -0
  106. package/types/dist/lib/helpers/pattern-matcher.d.mts.map +1 -0
  107. package/types/dist/lib/helpers/resolve-from-caller.d.mts +3 -27
  108. package/types/dist/lib/helpers/resolve-from-caller.d.mts.map +1 -1
  109. package/types/dist/lib/helpers/sanitize.d.mts +4 -92
  110. package/types/dist/lib/helpers/sanitize.d.mts.map +1 -1
  111. package/types/dist/lib/helpers/utilities.d.mts +4 -52
  112. package/types/dist/lib/helpers/utilities.d.mts.map +1 -1
  113. package/types/dist/lib/i18n/translations.d.mts +4 -37
  114. package/types/dist/lib/i18n/translations.d.mts.map +1 -1
  115. package/types/dist/lib/modes/eager.d.mts +8 -30
  116. package/types/dist/lib/modes/eager.d.mts.map +1 -1
  117. package/types/dist/lib/modes/lazy.d.mts +10 -43
  118. package/types/dist/lib/modes/lazy.d.mts.map +1 -1
  119. package/types/dist/lib/processors/flatten.d.mts +56 -107
  120. package/types/dist/lib/processors/flatten.d.mts.map +1 -1
  121. package/types/dist/lib/processors/loader.d.mts +6 -41
  122. package/types/dist/lib/processors/loader.d.mts.map +1 -1
  123. package/types/dist/lib/processors/type-generator.d.mts +2 -16
  124. package/types/dist/lib/processors/type-generator.d.mts.map +1 -1
  125. package/types/dist/lib/processors/typescript.d.mts +6 -53
  126. package/types/dist/lib/processors/typescript.d.mts.map +1 -1
  127. package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts +3 -71
  128. package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts.map +1 -1
  129. package/types/dist/lib/runtime/runtime-livebindings.d.mts +2 -37
  130. package/types/dist/lib/runtime/runtime-livebindings.d.mts.map +1 -1
  131. package/types/dist/lib/runtime/runtime.d.mts +3 -39
  132. package/types/dist/lib/runtime/runtime.d.mts.map +1 -1
  133. package/types/dist/slothlet.d.mts +3 -249
  134. package/types/dist/slothlet.d.mts.map +1 -1
  135. package/types/index.d.mts +36 -16
  136. package/types/index.d.mts.map +1 -0
  137. package/AGENT-USAGE.md +0 -736
  138. package/docs/API-RULES.md +0 -712
@@ -1,420 +1,45 @@
1
- /**
2
- * Manages runtime API component lifecycle (add/remove/reload).
3
- * @class ApiManager
4
- * @extends ComponentBase
5
- * @package
6
- *
7
- * @description
8
- * Class-based handler for managing API components at runtime. Tracks add history,
9
- * removed module IDs, and initial configuration per instance. Extends ComponentBase
10
- * for common Slothlet property access (config, debug, api, error classes, etc.).
11
- *
12
- * @example
13
- * const manager = new ApiManager(slothlet);
14
- * await manager.addApiComponent({ apiPath: "plugins", folderPath: "./plugins" });
15
- */
16
1
  export class ApiManager extends ComponentBase {
17
2
  static slothletProperty: string;
18
3
  state: {
19
- addHistory: any[];
4
+ addHistory: never[];
20
5
  initialConfig: any;
21
- operationHistory: any[];
6
+ operationHistory: never[];
22
7
  };
23
- /**
24
- * Normalize and validate an API path.
25
- * @param {string|string[]} apiPath - Dot-delimited API path, array of path segments, or empty/null for root.
26
- * @returns {{ apiPath: string, parts: string[] }} Normalized path data.
27
- * @throws {SlothletError} When apiPath is invalid.
28
- * @private
29
- *
30
- * @description
31
- * Ensures the API path is valid. Accepts:
32
- * - String: "some.path" → parts: ["some", "path"]
33
- * - Array: ["some", "path"] → parts: ["some", "path"]
34
- * - Empty string, null, or undefined → root level (parts: [])
35
- * Non-empty paths must contain no empty segments.
36
- *
37
- * @example
38
- * const { apiPath, parts } = this.normalizeApiPath("plugins.tools");
39
- * const { apiPath, parts } = this.normalizeApiPath(["plugins", "tools"]);
40
- * const { apiPath, parts } = this.normalizeApiPath(""); // Root level: parts = []
41
- */
42
- private normalizeApiPath;
43
- /**
44
- * Resolve and validate a path (file or directory) from caller context.
45
- * @param {string} inputPath - File or folder path provided by caller.
46
- * @returns {Promise<{resolvedPath: string, isDirectory: boolean, isFile: boolean}>} Path info.
47
- * @throws {SlothletError} When the path does not exist.
48
- * @private
49
- *
50
- * @description
51
- * Resolves relative paths from the caller and verifies the path exists.
52
- * Supports both files (.mjs, .cjs, .js) and directories.
53
- *
54
- * @example
55
- * const { resolvedPath, isDirectory, isFile } = await this.resolvePath("./plugins");
56
- * const { resolvedPath, isDirectory, isFile } = await this.resolvePath("./module.mjs");
57
- */
58
- private resolvePath;
59
- /**
60
- * Resolve and validate a folder path from caller context.
61
- * @param {string} folderPath - Folder path provided by caller.
62
- * @returns {Promise<string>} Absolute folder path.
63
- * @throws {SlothletError} When the folder does not exist or is not a directory.
64
- * @private
65
- *
66
- * @description
67
- * Resolves relative paths from the caller and verifies the folder exists.
68
- *
69
- * @deprecated Use resolvePath() instead for file/directory support.
70
- *
71
- * @example
72
- * const resolved = await this.resolveFolderPath("./plugins");
73
- */
74
- private resolveFolderPath;
75
- /**
76
- * Build a default moduleID when none is provided.
77
- * @param {string} apiPath - API path for this module.
78
- * @param {string} resolvedFolderPath - Absolute folder path.
79
- * @returns {string} Stable module identifier.
80
- * @private
81
- *
82
- * @description
83
- * Generates a stable moduleID using the apiPath and resolved folder path.
84
- *
85
- * @example
86
- * const moduleID = this.buildDefaultModuleId("plugins", "/abs/path/plugins");
87
- */
88
- private buildDefaultModuleId;
89
- /**
90
- * Read the current value at an API path.
91
- * @param {function|object} root - API root object.
92
- * @param {string[]} parts - Path segments.
93
- * @returns {unknown} Current value or undefined.
94
- * @private
95
- *
96
- * @description
97
- * Traverses the API graph by path segments and returns the value if found.
98
- *
99
- * @example
100
- * const value = this.getValueAtPath(api, ["plugins", "tools"]);
101
- */
102
- private getValueAtPath;
103
- /**
104
- * Ensure parent path exists and return the parent object.
105
- * @param {function|object} root - API root object.
106
- * @param {string[]} parts - Path segments.
107
- * @returns {function|object} Parent container for the final segment.
108
- * @throws {SlothletError} When a non-object path segment blocks creation.
109
- * @private
110
- *
111
- * @description
112
- * Walks through the path segments, creating missing objects as needed.
113
- *
114
- * @example
115
- * const parent = this.ensureParentPath(api, ["plugins", "tools"]);
116
- */
117
- private ensureParentPath;
118
- /**
119
- * Determine whether a value is a UnifiedWrapper proxy.
120
- * @param {unknown} value - Value to inspect.
121
- * @returns {boolean} True when value looks like a wrapper proxy.
122
- * @private
123
- *
124
- * @description
125
- * Checks for wrapper markers that are exposed on UnifiedWrapper proxies.
126
- *
127
- * @example
128
- * if (this.isWrapperProxy(api.plugins)) {
129
- * // Update wrapper implementation
130
- * }
131
- */
132
- private isWrapperProxy;
133
- /**
134
- * Synchronize an existing wrapper proxy with a new wrapper.
135
- * @param {function|object} existingProxy - Existing wrapper proxy.
136
- * @param {function|object} nextProxy - New wrapper proxy.
137
- * @param {object} config - Configuration object for debug logging.
138
- * @returns {Promise<boolean>} True when a wrapper update occurred.
139
- * @private
140
- *
141
- * @description
142
- * Copies materialization behavior and implementation from the new proxy into the existing
143
- * proxy to preserve references during reload operations.
144
- *
145
- * @example
146
- * await this.syncWrapper(existingProxy, nextProxy, this.____config);
147
- */
148
- private syncWrapper;
149
- /**
150
- * Recursively mutate an existing API value to match a new value.
151
- * @param {function|object} existingValue - Existing value to mutate.
152
- * @param {unknown} nextValue - New value to apply.
153
- * @param {object} options - Mutation options.
154
- * @param {boolean} options.removeMissing - Remove properties not present in nextValue.
155
- * @param {object} config - Configuration object for debug logging.
156
- * @returns {Promise<void>}
157
- * @private
158
- *
159
- * @description
160
- * Uses unified mergeApiObjects logic from api_assignment.mjs to ensure consistent
161
- * merge behavior between initial build and hot reload.
162
- *
163
- * @example
164
- * await this.mutateApiValue(existing, next, { removeMissing: true }, this.____config);
165
- */
166
- private mutateApiValue;
167
- /**
168
- * Set a value at a path within an API root.
169
- * @param {function|object} root - API root object.
170
- * @param {string[]} parts - Path segments.
171
- * @param {unknown} value - New value to assign.
172
- * @param {object} options - Assignment options.
173
- * @param {boolean} options.mutateExisting - Mutate existing values in place.
174
- * @param {boolean} options.allowOverwrite - Allow overwriting existing values.
175
- * @param {string} [options.collisionMode] - Collision handling mode (skip/warn/replace/merge/error).
176
- * @returns {Promise<boolean>} True if value was set, false if skipped due to collision.
177
- * @throws {SlothletError} When overwrite is not allowed or collision mode is "error".
178
- * @private
179
- *
180
- * @description
181
- * Writes a new value at the requested path with configurable collision handling.
182
- * Supports five collision modes:
183
- * - skip: Silently ignore collision, keep existing
184
- * - warn: Warn about collision, keep existing
185
- * - replace: Replace existing value completely
186
- * - merge: Merge properties (preserve original + add new)
187
- * - error: Throw error on collision
188
- *
189
- * @example
190
- * await this.setValueAtPath(api, ["plugins"], newApi, {
191
- * mutateExisting: true,
192
- * allowOverwrite: true,
193
- * collisionMode: "merge"
194
- * });
195
- */
196
- private setValueAtPath;
197
- /**
198
- * Delete a value at a path and prune empty parents.
199
- * @param {function|object} root - API root object.
200
- * @param {string[]} parts - Path segments.
201
- * @returns {Promise<boolean>} True when a value was deleted.
202
- * @private
203
- *
204
- * @description
205
- * Removes the property at the provided path and cleans up any empty parent objects.
206
- *
207
- * @example
208
- * const deleted = await await this.deletePath(api, ["plugins", "tools"]);
209
- */
210
- private deletePath;
211
- /**
212
- * Restore a path from api.slothlet.api.add history or core load.
213
- * @param {string} apiPath - API path to restore.
214
- * @param {?string} moduleID - ModuleId to restore.
215
- * @returns {Promise<void>}
216
- * @private
217
- *
218
- * @description
219
- * Attempts to reapply a previous api.slothlet.api.add entry or rebuild the core API for the path.
220
- *
221
- * @example
222
- * await this.restoreApiPath("plugins", "plugins-core");
223
- */
224
- private restoreApiPath;
225
- /**
226
- * Add new API modules at runtime.
227
- * @param {object} params - Add parameters.
228
- * @param {string} params.apiPath - API path to attach.
229
- * @param {string|string[]} params.folderPath - File path, folder path, or array of paths to load.
230
- * @param {Record<string, unknown>} [params.options={}] - Add options (including optional metadata).
231
- * @returns {Promise<string|string[]>} Module ID or array of module IDs.
232
- * @throws {SlothletError} When the instance is not loaded or inputs are invalid.
233
- * @package
234
- *
235
- * @description
236
- * Loads modules from a folder, file, or array of files/folders using the instance configuration
237
- * and merges the resulting API under the specified apiPath.
238
- *
239
- * Supports three input types:
240
- * 1. Single directory path (original behavior)
241
- * 2. Single file path (.mjs, .cjs, .js)
242
- * 3. Array of file and/or directory paths
243
- *
244
- * When an array is provided, each path is processed sequentially,
245
- * honoring collision settings, metadata, and ownership for each.
246
- *
247
- * @example
248
- * // Directory
249
- * await manager.addApiComponent({
250
- * apiPath: "plugins",
251
- * folderPath: "./plugins",
252
- * options: { moduleID: "plugins-core", metadata: { version: "1.0.0" } }
253
- * });
254
- *
255
- * @example
256
- * // Single file
257
- * await manager.addApiComponent({
258
- * apiPath: "utils",
259
- * folderPath: "./helpers/string-utils.mjs",
260
- * options: { metadata: { author: "team" } }
261
- * });
262
- *
263
- * @example
264
- * // Array of files and folders
265
- * await manager.addApiComponent({
266
- * apiPath: "extensions",
267
- * folderPath: ["./ext/plugin1.mjs", "./ext/plugin2.mjs", "./ext/utils"],
268
- * options: { collisionMode: "merge" }
269
- * });
270
- */
271
- addApiComponent(params: {
8
+ normalizeApiPath(apiPath: any): {
272
9
  apiPath: string;
273
- folderPath: string | string[];
274
- options?: Record<string, unknown>;
275
- }): Promise<string | string[]>;
276
- /**
277
- * Roll back a failed versioned add.
278
- *
279
- * @description
280
- * Called when `versionManager.registerVersion()` throws after the API tree, cache,
281
- * ownership, and history have already been mutated by `addApiComponent()`. Scrubs
282
- * the orphaned "add" entry from `operationHistory`, then delegates tree/cache/ownership
283
- * and `addHistory` cleanup to `removeApiComponent({ recordHistory: false })` so that
284
- * no spurious "remove" entry is pushed into `operationHistory`.
285
- *
286
- * The rollback is best-effort: if `removeApiComponent` itself throws the error is
287
- * swallowed and the caller re-throws the original registration error.
288
- *
289
- * @param {object} opts - Rollback context.
290
- * @param {string} opts.moduleID - The moduleID of the just-added component.
291
- * @param {string} opts.effectivePath - The effective (versioned) mount path, e.g. "v1.auth".
292
- * @param {string} opts.normalizedPath - The logical path, e.g. "auth".
293
- * @returns {Promise<void>}
294
- * @package
295
- *
296
- * @example
297
- * await this._rollbackFailedVersionedAdd({ moduleID, effectivePath, normalizedPath });
298
- */
10
+ parts: any[];
11
+ };
12
+ resolvePath(inputPath: any): Promise<{
13
+ resolvedPath: any;
14
+ isDirectory: any;
15
+ isFile: any;
16
+ }>;
17
+ resolveFolderPath(folderPath: any): Promise<any>;
18
+ buildDefaultModuleId(apiPath: any, ____resolvedFolderPath: any): string;
19
+ getValueAtPath(root: any, parts: any): any;
20
+ ensureParentPath(root: any, parts: any, options?: {}): any;
21
+ isWrapperProxy(value: any): boolean;
22
+ syncWrapper(existingProxy: any, nextProxy: any, config: any, collisionMode?: string, moduleID?: null): Promise<boolean>;
23
+ mutateApiValue(existingValue: any, nextValue: any, options: any, config: any): Promise<any>;
24
+ setValueAtPath(root: any, parts: any, value: any, options: any): Promise<boolean>;
25
+ deletePath(root: any, parts: any): Promise<boolean>;
26
+ restoreApiPath(apiPath: any, moduleID: any): Promise<void>;
27
+ addApiComponent(params: any): any;
299
28
  _rollbackFailedVersionedAdd({ moduleID, effectivePath, normalizedPath }: {
300
- moduleID: string;
301
- effectivePath: string;
302
- normalizedPath: string;
29
+ moduleID: any;
30
+ effectivePath: any;
31
+ normalizedPath: any;
303
32
  }): Promise<void>;
304
- /**
305
- * Remove API modules at runtime.
306
- * @param {string} pathOrModuleId - API path (with dots) or module ID (with underscore) to remove.
307
- * @returns {Promise<void>}
308
- * @throws {SlothletError} When inputs are invalid.
309
- * @package
310
- *
311
- * @description
312
- * Removes an API subtree by apiPath or removes all paths owned by a moduleID.
313
- * Automatically detects whether the parameter is a moduleID (contains underscore) or apiPath.
314
- *
315
- * @example
316
- * await manager.removeApiComponent("plugins.tools"); // Remove by API path
317
- *
318
- * @example
319
- * await manager.removeApiComponent("plugins_abc123"); // Remove by module ID
320
- */
321
- removeApiComponent(pathOrModuleId: string, options?: {}): Promise<void>;
322
- /**
323
- * Reload API modules using cache system.
324
- * @param {object} params - Reload parameters.
325
- * @param {?string} params.apiPath - API path to reload.
326
- * @param {?string} params.moduleID - ModuleId to reload.
327
- * @returns {Promise<void>}
328
- * @package
329
- *
330
- * @description
331
- * Reloads modules from disk using cached parameters. For moduleID reload, rebuilds
332
- * entire cache and restores all paths. For apiPath reload, rebuilds all contributing
333
- * moduleID caches and merges implementations.
334
- *
335
- * @example
336
- * await manager.reloadApiComponent({ moduleID: "plugins_abc123" });
337
- * await manager.reloadApiComponent({ apiPath: "plugins" });
338
- */
339
- reloadApiComponent(params: {
340
- apiPath: string | null;
341
- moduleID: string | null;
33
+ removeApiComponent(pathOrModuleId: any, options?: {}): Promise<boolean>;
34
+ reloadApiComponent(params: any): Promise<void>;
35
+ _reloadByModuleID(moduleID: any, { forceReplace }?: {
36
+ forceReplace?: boolean | undefined;
342
37
  }): Promise<void>;
343
- /**
344
- * Reload by moduleID - rebuild cache and restore all paths
345
- * @param {string} moduleID - Module identifier
346
- * @param {Object} [options] - Reload options
347
- * @param {boolean} [options.forceReplace=true] - Force replace mode on existing wrappers.
348
- * When true, temporarily overrides collision mode to "replace" so the fresh impl
349
- * fully replaces the old one. When false, the wrapper's original collision mode is
350
- * preserved, allowing merge behavior for multi-cache rebuilds.
351
- * @returns {Promise<void>}
352
- * @private
353
- */
354
- private _reloadByModuleID;
355
- /**
356
- * Reload by API path - find affected caches, rebuild them, update impls.
357
- *
358
- * Accepts "." for base module. For other paths, the resolution order is:
359
- * 1. Exact cache endpoint match
360
- * 2. Child caches (endpoints under the path)
361
- * 3. Ownership history (modules that registered the exact path)
362
- * 4. Parent cache (most specific cache whose scope covers the path)
363
- *
364
- * @param {string} apiPath - API path or "." for base module
365
- * @param {Object} [options] - Optional reload options
366
- * @param {Object} [options.metadata] - Metadata to merge for the reloaded path after rebuild
367
- * @returns {Promise<void>}
368
- * @private
369
- */
370
- private _reloadByApiPath;
371
- /**
372
- * Find all cache entries that need to be rebuilt for a given API path.
373
- *
374
- * Resolution order:
375
- * 1. "." or "" or null → base module cache(s) (endpoint ".")
376
- * 2. Exact endpoint match → that specific cache
377
- * 3. Child caches → caches whose endpoint is under the given path
378
- * 4. Ownership history → modules that registered the exact path
379
- * 5. Parent cache → most specific cache whose scope covers the path
380
- *
381
- * @param {string} apiPath - The API path to find caches for
382
- * @returns {string[]} Array of moduleIDs to reload
383
- * @private
384
- */
385
- private _findAffectedCaches;
386
- /**
387
- * Collect user-set custom properties from a proxy/wrapper that are NOT in the fresh API.
388
- * Custom properties are those set by the user at runtime (e.g., api.custom.testFlag = true)
389
- * that should survive a selective reload.
390
- * @param {Object} existingProxy - The existing proxy/wrapper to collect from
391
- * @param {Object} freshApi - The fresh API from rebuild (keys to exclude)
392
- * @returns {Object} Map of custom property names to their values
393
- * @private
394
- */
395
- private _collectCustomProperties;
396
- /**
397
- * Restore previously collected custom properties onto a proxy/wrapper after reload.
398
- * @param {Object} proxy - The proxy to restore properties onto
399
- * @param {Object} customProps - Map of property names to values from _collectCustomProperties
400
- * @private
401
- */
402
- private _restoreCustomProperties;
403
- /**
404
- * Restore API from fresh rebuild by updating existing wrapper.
405
- * For non-root endpoints, updates the wrapper's implementation without replacing structure.
406
- * For root endpoints, merges keys directly as addApiComponent does.
407
- * @param {object} freshApi - Fresh API from rebuild
408
- * @param {string} endpoint - Original endpoint path
409
- * @param {string} moduleID - Module identifier
410
- * @param {string} collisionMode - Collision handling mode
411
- * @param {boolean} [forceReplace=true] - When true, temporarily overrides wrapper collision
412
- * mode to "replace" so fresh impl fully replaces old. When false, preserves original
413
- * collision mode for proper merge behavior in multi-cache rebuilds.
414
- * @returns {Promise<void>}
415
- * @private
416
- */
417
- private _restoreApiTree;
38
+ _reloadByApiPath(apiPath: any, options?: {}): Promise<void>;
39
+ _findAffectedCaches(apiPath: any): any[];
40
+ _collectCustomProperties(existingProxy: any, freshApi: any): {};
41
+ _restoreCustomProperties(proxy: any, customProps: any): void;
42
+ _restoreApiTree(freshApi: any, endpoint: any, moduleID: any, collisionMode: any, forceReplace?: boolean): Promise<void>;
418
43
  }
419
44
  import { ComponentBase } from "@cldmv/slothlet/factories/component-base";
420
45
  //# sourceMappingURL=api-manager.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-manager.d.mts","sourceRoot":"","sources":["../../../../dist/lib/handlers/api-manager.mjs"],"names":[],"mappings":"AAmDA;;;;;;;;;;;;;;GAcG;AACH;IACC,gCAAuC;IAgBtC;;;;MAMC;IAGF;;;;;;;;;;;;;;;;;;OAkBG;IACH,yBAuFC;IAED;;;;;;;;;;;;;;OAcG;IACH,oBA+BC;IAED;;;;;;;;;;;;;;OAcG;IACH,0BA4BC;IAED;;;;;;;;;;;;OAYG;IACH,6BAIC;IAED;;;;;;;;;;;;OAYG;IACH,uBASC;IAED;;;;;;;;;;;;;OAaG;IACH,yBAkCC;IAED;;;;;;;;;;;;;OAaG;IACH,uBAEC;IAED;;;;;;;;;;;;;;OAcG;IACH,oBAmNC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,uBAkGC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,uBA8GC;IAED;;;;;;;;;;;;OAYG;IACH,mBAmGC;IACD;;;;;;;;;;;;OAYG;IACH,uBAwEC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACH,wBA3CG;QAAuB,OAAO,EAAtB,MAAM;QACkB,UAAU,EAAlC,MAAM,GAAC,MAAM,EAAE;QACkB,OAAO,GAAxC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;KAC/B,GAAU,OAAO,CAAC,MAAM,GAAC,MAAM,EAAE,CAAC,CAijBpC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,yEATG;QAAqB,QAAQ,EAArB,MAAM;QACO,aAAa,EAA1B,MAAM;QACO,cAAc,EAA3B,MAAM;KACd,GAAU,OAAO,CAAC,IAAI,CAAC,CAuCzB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,mCAfW,MAAM,iBACJ,OAAO,CAAC,IAAI,CAAC,CA2ZzB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,2BAdG;QAAwB,OAAO,EAAtB,MAAM,OAAA;QACS,QAAQ,EAAvB,MAAM,OAAA;KACf,GAAU,OAAO,CAAC,IAAI,CAAC,CAuCzB;IAED;;;;;;;;;;OAUG;IACH,0BAsEC;IAED;;;;;;;;;;;;;;OAcG;IACH,yBAsFC;IAED;;;;;;;;;;;;;OAaG;IACH,4BA0FC;IAED;;;;;;;;OAQG;IACH,iCAuDC;IAED;;;;;OAKG;IACH,iCAeC;IAED;;;;;;;;;;;;;OAaG;IACH,wBAwVC;CACD;8BAvzF6B,0CAA0C"}
1
+ {"version":3,"file":"api-manager.d.mts","sourceRoot":"","sources":["../../../../dist/lib/handlers/api-manager.mjs"],"names":[],"mappings":"AAAiQ;IAAuC,gCAAqC;IAAsC;;;;MAAmF;IAAC;;;MAAwwD;IAAA;;;;OAAwhB;IAAA,iDAAwmB;IAAA,wEAAiL;IAAA,2CAA6L;IAAA,2DAAqxB;IAAA,oCAA0H;IAAA,wHAAsyI;IAAA,4FAA4vE;IAAA,kFAAivE;IAAA,oDAAsjE;IAAA,2DAA+zC;IAAA,kCAAmrS;IAAA;;;;sBAAshB;IAAA,wEAA+4Q;IAAA,+CAA2e;IAAA;;sBAAkwC;IAAA,4DAA0mD;IAAA,yCAAi3C;IAAA,gEAAynB;IAAA,6DAA6L;IAAA,wHAAquM;CAAC;8BAA948C,0CAA0C"}
@@ -1,66 +1,28 @@
1
- /**
2
- * AsyncLocalStorage-based context manager for async runtime
3
- * Uses ALS for full context isolation across async operations
4
- * @public
5
- */
6
1
  export class AsyncContextManager {
7
- als: AsyncLocalStorage<any>;
2
+ als: any;
8
3
  instances: Map<any, any>;
9
- /**
10
- * Register the EventEmitter context checker
11
- * Must be called AFTER EventEmitter patching is enabled
12
- * @public
13
- */
14
- public registerEventEmitterContextChecker(): void;
15
- /**
16
- * Initialize context for a new instance
17
- * @param {string} instanceID - Unique instance identifier
18
- * @param {Object} config - Instance configuration
19
- * @returns {Object} Created context store
20
- * @public
21
- */
22
- public initialize(instanceID: string, config?: any): any;
23
- /**
24
- * Run function with instance context active
25
- * @param {string} instanceID - Instance to run in context of
26
- * @param {Function} fn - Function to execute
27
- * @param {*} thisArg - this binding for function
28
- * @param {Array} args - Arguments to pass to function
29
- * @param {Object} [currentWrapper] - Current wrapper being executed (for metadata.self())
30
- * @returns {*} Result of function execution
31
- * @public
32
- */
33
- public runInContext(instanceID: string, fn: Function, thisArg: any, args: any[], currentWrapper?: any): any;
34
- /**
35
- * Get current active context
36
- * @returns {Object} Current context store
37
- * @throws {SlothletError} If no active context
38
- * @public
39
- */
40
- public getContext(): any;
41
- /**
42
- * Try to get context (returns undefined instead of throwing)
43
- * @returns {Object|undefined} Current context store or undefined
44
- * @public
45
- */
46
- public tryGetContext(): any | undefined;
47
- /**
48
- * Cleanup instance context
49
- * @param {string} instanceID - Instance to cleanup
50
- * @public
51
- */
52
- public cleanup(instanceID: string): void;
53
- /**
54
- * Get diagnostic information
55
- * @returns {Object} Diagnostic data
56
- * @public
57
- */
58
- public getDiagnostics(): any;
4
+ registerEventEmitterContextChecker(): void;
5
+ initialize(instanceID: any, config?: {}): {
6
+ instanceID: any;
7
+ self: {};
8
+ context: {};
9
+ config: {};
10
+ createdAt: number;
11
+ };
12
+ runInContext(instanceID: any, fn: any, thisArg: any, args: any, currentWrapper: any): any;
13
+ getContext(): any;
14
+ tryGetContext(): any;
15
+ cleanup(instanceID: any): void;
16
+ getDiagnostics(): {
17
+ type: string;
18
+ activeStore: any;
19
+ instances: {
20
+ id: any;
21
+ createdAt: any;
22
+ contextKeys: string[];
23
+ selfKeys: string[];
24
+ }[];
25
+ };
59
26
  }
60
- /**
61
- * Singleton async context manager
62
- * @public
63
- */
64
27
  export const asyncContextManager: AsyncContextManager;
65
- import { AsyncLocalStorage } from "node:async_hooks";
66
28
  //# sourceMappingURL=context-async.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-async.d.mts","sourceRoot":"","sources":["../../../../dist/lib/handlers/context-async.mjs"],"names":[],"mappings":"AAuBA;;;;GAIG;AACH;IAEE,4BAAkC;IAClC,yBAA0B;IAG3B;;;;OAIG;IACH,kDAKC;IAED;;;;;;OAMG;IACH,8BALW,MAAM,qBAoBhB;IAED;;;;;;;;;OASG;IACH,gCARW,MAAM,yBAEN,GAAC,sCAGC,GAAC,CA4Eb;IAED;;;;;OAKG;IACH,yBAMC;IAED;;;;OAIG;IACH,wBAHa,MAAO,SAAS,CAK5B;IAED;;;;OAIG;IACH,2BAHW,MAAM,QAoBhB;IAED;;;;OAIG;IACH,6BAWC;CACD;AAED;;;GAGG;AACH,sDAA6D;kCA/M3B,kBAAkB"}
1
+ {"version":3,"file":"context-async.d.mts","sourceRoot":"","sources":["../../../../dist/lib/handlers/context-async.mjs"],"names":[],"mappings":"AAA+R;IAAwC,SAA8B;IAAC,yBAAsB;IAAC,2CAA2I;IAAA;;;;;;MAAqS;IAAA,0FAA60C;IAAA,kBAAuJ;IAAA,qBAA2C;IAAA,+BAAyS;IAAA;;;;;;;;;MAAmQ;CAAC;AAAA,sDAAkD"}
@@ -1,65 +1,28 @@
1
- /**
2
- * Live bindings context manager (direct global state)
3
- * Uses direct instance tracking without AsyncLocalStorage overhead
4
- * @public
5
- */
6
1
  export class LiveContextManager {
7
2
  instances: Map<any, any>;
8
3
  currentInstanceID: any;
9
- /**
10
- * Register the EventEmitter context checker
11
- * Must be called AFTER EventEmitter patching is enabled
12
- * @public
13
- */
14
- public registerEventEmitterContextChecker(): void;
15
- /**
16
- * Initialize context for a new instance
17
- * @param {string} instanceID - Unique instance identifier
18
- * @param {Object} config - Instance configuration
19
- * @returns {Object} Created context store
20
- * @public
21
- */
22
- public initialize(instanceID: string, config?: any): any;
23
- /**
24
- * Run function with instance context active (live mode)
25
- * @param {string} instanceID - Instance to run in context of
26
- * @param {Function} fn - Function to execute
27
- * @param {*} thisArg - this binding for function
28
- * @param {Array} args - Arguments to pass to function
29
- * @param {Object} [currentWrapper] - Current wrapper being executed (for metadata.self())
30
- * @returns {*} Result of function execution
31
- * @public
32
- */
33
- public runInContext(instanceID: string, fn: Function, thisArg: any, args: any[], currentWrapper?: any): any;
34
- /**
35
- * Get current active context
36
- * @returns {Object} Current context store
37
- * @throws {SlothletError} If no active context
38
- * @public
39
- */
40
- public getContext(): any;
41
- /**
42
- * Try to get context (returns undefined instead of throwing)
43
- * @returns {Object|undefined} Current context store or undefined
44
- * @public
45
- */
46
- public tryGetContext(): any | undefined;
47
- /**
48
- * Cleanup instance context
49
- * @param {string} instanceID - Instance to cleanup
50
- * @public
51
- */
52
- public cleanup(instanceID: string): void;
53
- /**
54
- * Get diagnostic information
55
- * @returns {Object} Diagnostic data
56
- * @public
57
- */
58
- public getDiagnostics(): any;
4
+ registerEventEmitterContextChecker(): void;
5
+ initialize(instanceID: any, config?: {}): {
6
+ instanceID: any;
7
+ self: {};
8
+ context: {};
9
+ config: {};
10
+ createdAt: number;
11
+ };
12
+ runInContext(instanceID: any, fn: any, thisArg: any, args: any, currentWrapper: any): any;
13
+ getContext(): any;
14
+ tryGetContext(): any;
15
+ cleanup(instanceID: any): void;
16
+ getDiagnostics(): {
17
+ type: string;
18
+ currentInstanceID: any;
19
+ instances: {
20
+ id: any;
21
+ createdAt: any;
22
+ contextKeys: string[];
23
+ selfKeys: string[];
24
+ }[];
25
+ };
59
26
  }
60
- /**
61
- * Singleton live context manager
62
- * @public
63
- */
64
27
  export const liveContextManager: LiveContextManager;
65
28
  //# sourceMappingURL=context-live.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-live.d.mts","sourceRoot":"","sources":["../../../../dist/lib/handlers/context-live.mjs"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH;IAEE,yBAA0B;IAC1B,uBAA6B;IAG9B;;;;OAIG;IACH,kDAIC;IAED;;;;;;OAMG;IACH,8BALW,MAAM,qBA0BhB;IAED;;;;;;;;;OASG;IACH,gCARW,MAAM,yBAEN,GAAC,sCAGC,GAAC,CAoDb;IAED;;;;;OAKG;IACH,yBAmBC;IAED;;;;OAIG;IACH,wBAHa,MAAO,SAAS,CAQ5B;IAED;;;;OAIG;IACH,2BAHW,MAAM,QAyBhB;IAED;;;;OAIG;IACH,6BAWC;CACD;AAED;;;GAGG;AACH,oDAA2D"}
1
+ {"version":3,"file":"context-live.d.mts","sourceRoot":"","sources":["../../../../dist/lib/handlers/context-live.mjs"],"names":[],"mappings":"AAAiI;IAAuC,yBAAsB;IAAC,uBAA2B;IAAC,2CAAsG;IAAA;;;;;;MAAmW;IAAA,0FAA4mC;IAAA,kBAA8X;IAAA,qBAA4G;IAAA,+BAA8W;IAAA;;;;;;;;;MAAyP;CAAC;AAAA,oDAAgD"}