@cldmv/slothlet-types 3.15.2 → 3.16.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.
Files changed (58) hide show
  1. package/lib/builders/api-assignment.d.mts +125 -4
  2. package/lib/builders/api_builder.d.mts +104 -7
  3. package/lib/builders/builder.d.mts +82 -1
  4. package/lib/builders/modes-processor.d.mts +66 -3
  5. package/lib/errors.d.mts +114 -19
  6. package/lib/factories/component-base.d.mts +171 -8
  7. package/lib/factories/context.d.mts +22 -4
  8. package/lib/handlers/api-cache-manager.d.mts +209 -20
  9. package/lib/handlers/api-manager.d.mts +539 -38
  10. package/lib/handlers/context-async.d.mts +92 -25
  11. package/lib/handlers/context-live.d.mts +117 -30
  12. package/lib/handlers/framework-internals.d.mts +33 -2
  13. package/lib/handlers/hook-manager.d.mts +306 -73
  14. package/lib/handlers/lifecycle-token.d.mts +48 -3
  15. package/lib/handlers/lifecycle.d.mts +86 -5
  16. package/lib/handlers/materialize-manager.d.mts +76 -8
  17. package/lib/handlers/metadata.d.mts +238 -18
  18. package/lib/handlers/module-manager.d.mts +169 -21
  19. package/lib/handlers/ownership.d.mts +376 -45
  20. package/lib/handlers/permission-manager.d.mts +283 -46
  21. package/lib/handlers/routine-manager.d.mts +425 -0
  22. package/lib/handlers/trusted-root.d.mts +45 -4
  23. package/lib/handlers/unified-wrapper.d.mts +287 -26
  24. package/lib/handlers/version-manager.d.mts +236 -29
  25. package/lib/helpers/caller-pinning.d.mts +21 -2
  26. package/lib/helpers/class-instance-wrapper.d.mts +56 -2
  27. package/lib/helpers/config.d.mts +311 -161
  28. package/lib/helpers/defaults.d.mts +40 -0
  29. package/lib/helpers/eventemitter-context.d.mts +29 -3
  30. package/lib/helpers/eventtarget-context.d.mts +19 -1
  31. package/lib/helpers/eventtarget-property-context.d.mts +21 -0
  32. package/lib/helpers/generate-manifest.d.mts +174 -7
  33. package/lib/helpers/hint-detector.d.mts +22 -2
  34. package/lib/helpers/manifest-resolver.d.mts +100 -1
  35. package/lib/helpers/modes-utils.d.mts +30 -3
  36. package/lib/helpers/module-discovery.d.mts +80 -7
  37. package/lib/helpers/module-manifest-validator.d.mts +36 -13
  38. package/lib/helpers/module-sort.d.mts +64 -1
  39. package/lib/helpers/observer-context.d.mts +21 -0
  40. package/lib/helpers/pattern-matcher.d.mts +43 -3
  41. package/lib/helpers/platform.d.mts +109 -10
  42. package/lib/helpers/resolve-from-caller.d.mts +27 -3
  43. package/lib/helpers/sanitize.d.mts +92 -4
  44. package/lib/helpers/scheduler-context.d.mts +21 -1
  45. package/lib/helpers/utilities.d.mts +52 -4
  46. package/lib/i18n/translations.d.mts +50 -5
  47. package/lib/modes/eager.d.mts +46 -8
  48. package/lib/modes/lazy.d.mts +57 -10
  49. package/lib/processors/flatten.d.mts +116 -56
  50. package/lib/processors/loader.d.mts +77 -10
  51. package/lib/processors/type-generator.d.mts +16 -2
  52. package/lib/processors/typescript.d.mts +169 -13
  53. package/lib/runtime/runtime-asynclocalstorage.d.mts +71 -3
  54. package/lib/runtime/runtime-livebindings.d.mts +37 -2
  55. package/lib/runtime/runtime.d.mts +39 -3
  56. package/lib/typegen/typegen.d.mts +34 -2
  57. package/package.json +5 -23
  58. package/slothlet.d.mts +428 -3
@@ -1,39 +1,300 @@
1
+ /**
2
+ * Whether a property name belongs to the framework rather than to a module's exports.
3
+ *
4
+ * @param {string|symbol} key - Property name to classify.
5
+ * @returns {boolean} True when the name is reserved by the framework.
6
+ * @public
7
+ *
8
+ * @description
9
+ * Matched against the framework's own reserved names — `INTERNAL_KEYS` (wrapper state and control
10
+ * props) plus {@link IMPL_METADATA_KEYS} — never by underscore prefix. The documented hidden-entry
11
+ * rule (docs/MODULE-STRUCTURE.md) hides `.`/`__`-prefixed FILES and FOLDERS; it says nothing about
12
+ * export names, and a module that writes `export const __priv` has deliberately put that member on
13
+ * its surface. Treating the prefix as internal silently dropped such exports from the composed api
14
+ * in lazy mode while eager served them.
15
+ *
16
+ * @example
17
+ * isFrameworkReservedKey("__childFilePaths"); // true
18
+ * isFrameworkReservedKey("__priv"); // false — a module's own export
19
+ */
20
+ export function isFrameworkReservedKey(key: string | symbol): boolean;
21
+ /**
22
+ * Resolves a value to its backing UnifiedWrapper instance.
23
+ * Accepts a proxy registered via createProxy() or a raw UnifiedWrapper instance.
24
+ * Returns null for any other value.
25
+ *
26
+ * @param {unknown} value - Value to resolve
27
+ * @returns {UnifiedWrapper|null} The backing wrapper, or null
28
+ *
29
+ * @example
30
+ * const wrapper = resolveWrapper(someProxy);
31
+ * if (wrapper) wrapper.____slothletInternal.impl = newImpl;
32
+ */
33
+ export function resolveWrapper(value: unknown): UnifiedWrapper | null;
34
+ /**
35
+ * Framework metadata that rides on a module implementation but is not an api member.
36
+ *
37
+ * Matched by EXACT name rather than an `__` prefix: a user module may legitimately export an
38
+ * underscore-prefixed member, and dropping those would make the composed surface lie. Shared so
39
+ * enumeration and the collision-merge paths filter exactly the same set.
40
+ * @type {Set<string>}
41
+ * @public
42
+ */
1
43
  export const IMPL_METADATA_KEYS: Set<string>;
2
44
  export namespace TYPE_STATES {
3
45
  let UNMATERIALIZED: symbol;
4
46
  let IN_FLIGHT: symbol;
5
47
  }
48
+ /**
49
+ * Unified wrapper class that handles all proxy concerns in one place:
50
+ * - __impl pattern for reload support
51
+ * - Lazy/eager mode materialization
52
+ * - Recursive waiting proxy for deep lazy loading
53
+ * - Context binding through contextManager
54
+ *
55
+ * @class
56
+ * @extends ComponentBase
57
+ * @public
58
+ */
6
59
  export class UnifiedWrapper extends ComponentBase {
7
- static _cloneImpl(value: any): any;
8
- static _extractFullImpl(wrapper: any): any;
9
- constructor(slothlet: any, { mode, apiPath, initialImpl, materializeFunc, isCallable, materializeOnCreate, filePath, moduleID, sourceFolder, __adoptVisited, deferChildAdopt }: {
10
- mode: any;
11
- apiPath: any;
12
- initialImpl?: null | undefined;
13
- materializeFunc?: null | undefined;
14
- isCallable: any;
60
+ /**
61
+ * Shallow-clone a non-Proxy object implementation to prevent ___adoptImplChildren
62
+ * from mutating shared module export references via its `delete this.____slothletInternal.impl[key]`
63
+ * operations. When concurrent materializations (e.g., old + new wrapper during reload)
64
+ * both load the same cached module, the first ___adoptImplChildren would destroy the
65
+ * shared export, causing subsequent wrappers to receive empty objects.
66
+ *
67
+ * Returns the value unchanged if it is not a plain object, or if it IS a Proxy
68
+ * (cloning a Proxy destroys its trap behavior - e.g., LG TV controllers using
69
+ * numeric-index access through custom get traps).
70
+ *
71
+ * @param {*} value - The implementation value to (maybe) clone.
72
+ * @returns {*} A shallow clone of `value` when it is a non-Proxy plain object,
73
+ * otherwise the original `value`.
74
+ * @static
75
+ * @private
76
+ */
77
+ private static _cloneImpl;
78
+ /**
79
+ * Reconstruct a full implementation object from a wrapper whose _impl may have
80
+ * been depleted by ___adoptImplChildren.
81
+ *
82
+ * @description
83
+ * After ___adoptImplChildren runs, children are moved from _impl onto the wrapper as
84
+ * own properties and deleted from _impl. This helper reconstructs the original
85
+ * impl by merging the remaining _impl keys with the adopted children extracted
86
+ * from the wrapper.
87
+ *
88
+ * Recursively walks the wrapper tree so nested objects whose _impl was also
89
+ * depleted are properly reconstructed. For callable (function) impls, returns
90
+ * the function directly since keepImplProperties prevents depletion.
91
+ *
92
+ * @param {Object} wrapper - The UnifiedWrapper instance to extract from
93
+ * @returns {*} The reconstructed implementation mirroring original module exports
94
+ * @static
95
+ * @private
96
+ */
97
+ private static _extractFullImpl;
98
+ /**
99
+ * @param {Object} slothlet - Slothlet instance (provides contextManager, instanceID, ownership)
100
+ * @param {Object} options - Configuration options
101
+ * @param {string} options.mode - "lazy" or "eager"
102
+ * @param {string} options.apiPath - API path for this wrapper (e.g., "math.advanced.calc")
103
+ * @param {Function|Object|null} [options.initialImpl=null] - Initial implementation (null for lazy mode)
104
+ * @param {Function} [options.materializeFunc=null] - Async function to materialize lazy modules
105
+ * @param {boolean} [options.isCallable=false] - Whether the wrapper should be callable
106
+ * @param {boolean} [options.materializeOnCreate=false] - Whether to materialize on creation
107
+ * @param {string} [options.filePath=null] - File path of the module source
108
+ * @param {string} [options.moduleID=null] - Module identifier
109
+ * @param {string} [options.sourceFolder=null] - Source folder for metadata
110
+ * @param {WeakSet<object>|null} [options.__adoptVisited=null] - Internal: one-shot cycle-guard set
111
+ * threaded through the eager child-adoption recursion so a self-referential value cannot recurse
112
+ * forever (#330). Set only on nested wrappers built during a single adopt traversal; null for a
113
+ * normal (root / reload) construction.
114
+ * @param {boolean} [options.deferChildAdopt=false] - Internal: defer eager child adoption to first
115
+ * getTrap access (and propagate the deferral to descendants). Used for wrap-on-set of a
116
+ * user-assigned object so an arbitrarily deep runtime-grafted chain is wrapped one level per
117
+ * access instead of recursing synchronously through every level at assignment and overflowing
118
+ * the stack (#329 / #247 unbounded depth).
119
+ *
120
+ * @description
121
+ * Creates a unified wrapper instance for a specific API path. Extends ComponentBase
122
+ * to access slothlet.contextManager, slothlet.instanceID, and slothlet.handlers.ownership.
123
+ *
124
+ * @example
125
+ * const wrapper = new UnifiedWrapper(this.slothlet, {
126
+ * mode: "lazy",
127
+ * apiPath: "math",
128
+ * initialImpl: null,
129
+ * materializeFunc: async () => import("./math.mjs")
130
+ * });
131
+ */
132
+ constructor(slothlet: Object, { mode, apiPath, initialImpl, materializeFunc, isCallable, materializeOnCreate, filePath, moduleID, sourceFolder, __adoptVisited, deferChildAdopt }: {
133
+ mode: string;
134
+ apiPath: string;
135
+ initialImpl?: Object | Function | null | undefined;
136
+ materializeFunc?: Function | undefined;
137
+ isCallable?: boolean | undefined;
15
138
  materializeOnCreate?: boolean | undefined;
16
- filePath?: null | undefined;
17
- moduleID?: null | undefined;
18
- sourceFolder?: null | undefined;
19
- __adoptVisited?: null | undefined;
139
+ filePath?: string | undefined;
140
+ moduleID?: string | undefined;
141
+ sourceFolder?: string | undefined;
142
+ __adoptVisited?: WeakSet<object> | null | undefined;
20
143
  deferChildAdopt?: boolean | undefined;
21
144
  });
22
- get ____slothletInternal(): null | undefined;
145
+ /**
146
+ * Internal state accessor used by framework-internal code only.
147
+ * Backed by the private `#internal` field - prototype property, not an own property,
148
+ * so proxy invariants never apply and getTrap can legally return undefined for it.
149
+ *
150
+ * Uses a private-field brand check (`#internal in this`) so the getter is safe to
151
+ * invoke with any receiver - including `UnifiedWrapper.prototype` itself during a
152
+ * prototype chain walk via `Object.getPrototypeOf` - without throwing a TypeError.
153
+ * Without the brand check, `Object.getPrototypeOf(proxy).____slothletInternal` would
154
+ * throw because the prototype object was never constructed and has no `#internal` field.
155
+ * @returns {Record<string, any>|undefined} Internal state container, or undefined for non-instances
156
+ */
157
+ get ____slothletInternal(): Record<string, any> | undefined;
158
+ /**
159
+ * Custom inspect output for Node.js `util.inspect`.
160
+ *
161
+ * Defined as an ordinary named method and wired to the `util.inspect.custom`
162
+ * symbol via a prototype assignment after the class. A computed
163
+ * `[util.inspect.custom]` member in the class body makes tsc emit a spurious
164
+ * numeric index signature (`[x: number]`) into the generated `.d.mts`; an
165
+ * ordinary named method emits cleanly instead.
166
+ * @returns {*} The actual implementation for inspection.
167
+ * @internal
168
+ */
23
169
  ____inspectCustom(____depth: any, ____options: any, ____inspect: any): any;
24
- get __impl(): any;
25
- _applyNewImpl(newImpl: any, forceReuseChildren?: boolean): void;
26
- ___setImpl(newImpl: any, moduleID?: null, forceReuseChildren?: boolean): void;
27
- ___resetLazy(newMaterializeFunc: any): void;
28
- ___materialize(): Promise<any>;
29
- _materialize(): Promise<any>;
30
- ___invalidate(): void;
31
- ___adoptImplChildren(forceReuseChildren?: boolean): void;
32
- ___createChildWrapper(key: any, value: any, visited?: null, deferChildAdopt?: boolean): any;
33
- ___createWaitingProxy(propChain?: any[]): any;
34
- createProxy(): any;
170
+ /**
171
+ * Get current implementation
172
+ * @returns {Function|Object|null} Current __impl value
173
+ * @public
174
+ */
175
+ public get __impl(): Function | Object | null;
176
+ /**
177
+ * Core implementation-application logic shared by ___setImpl and lazy materialization.
178
+ * Clones the implementation (protecting the API cache from ___adoptImplChildren's
179
+ * delete operations), clears the invalid flag, upgrades __isCallable when a
180
+ * callable impl arrives on a configurable wrapper, updates __filePath for lazy
181
+ * folder wrappers, and adopts children.
182
+ *
183
+ * @param {*} newImpl - The new implementation value.
184
+ * @param {boolean} [forceReuseChildren=false] - When true, always reuse existing child
185
+ * wrappers regardless of mode (used by ___setImpl to preserve live references).
186
+ * @private
187
+ */
188
+ private _applyNewImpl;
189
+ /**
190
+ * Set new implementation and adopt children.
191
+ * Delegates core impl work to _applyNewImpl, then emits lifecycle events
192
+ * and updates materialization state.
193
+ *
194
+ * @param {*} newImpl - New implementation
195
+ * @param {string} [moduleID] - Optional moduleID for lifecycle event (for replacements)
196
+ * @param {boolean} [forceReuseChildren=false] - When true, always reuse existing child
197
+ * wrappers and bypass collision-merged key guards. Use this for direct/explicit
198
+ * ___setImpl calls where reference preservation is the intent. Do NOT set for
199
+ * hot-reload paths (syncWrapper) where lazy refs should intentionally break.
200
+ * @private
201
+ */
202
+ private ___setImpl;
203
+ /**
204
+ * Reset wrapper to un-materialized lazy state with a fresh materialization function.
205
+ * Used during reload to restore lazy wrappers to their shell state instead of
206
+ * eagerly loading all implementations. Preserves proxy identity so existing
207
+ * references continue to work - next property access triggers materialization
208
+ * from the fresh materializeFunc (which reads updated source files from disk).
209
+ * @param {Function} newMaterializeFunc - Fresh materialization function from rebuild
210
+ * @returns {void}
211
+ * @private
212
+ */
213
+ private ___resetLazy;
214
+ /**
215
+ * Trigger materialization (lazy mode only)
216
+ * @returns {Promise<void>}
217
+ * @private
218
+ */
219
+ private ___materialize;
220
+ /**
221
+ * @private
222
+ * @returns {Promise<void>}
223
+ *
224
+ * @description
225
+ * Exposes lazy materialization for waiting proxies and nested wrappers.
226
+ *
227
+ * @example
228
+ * await wrapper._materialize();
229
+ */
230
+ private _materialize;
231
+ /**
232
+ * @private
233
+ * @returns {void}
234
+ *
235
+ * @description
236
+ * Invalidates this wrapper when its parent removes the API path.
237
+ *
238
+ * @example
239
+ * wrapper.___invalidate();
240
+ */
241
+ private ___invalidate;
242
+ /**
243
+ * @private
244
+ * @returns {void}
245
+ *
246
+ * @description
247
+ * Moves child properties off the impl and attaches them to wrapper as properties
248
+ * so this wrapper only represents the current API path.
249
+ *
250
+ * @example
251
+ * wrapper.___adoptImplChildren();
252
+ */
253
+ private ___adoptImplChildren;
254
+ /**
255
+ * @private
256
+ * @param {string|symbol} key - Child property name
257
+ * @param {unknown} value - Child value
258
+ * @param {WeakSet<object>|null} [visited=null] - Cycle-guard set threaded through an eager adopt
259
+ * traversal so a self-referential value cannot recurse forever (#330); null outside a traversal.
260
+ * @param {boolean} [deferChildAdopt=false] - Defer the child's own eager adoption to first getTrap
261
+ * access, so a deep wrap-on-set graft is wrapped one level per access instead of recursively (#329).
262
+ * @returns {Object|Function|null|undefined} Wrapped child proxy, or null/undefined when the value is
263
+ * stored unwrapped (opaque built-ins, null, cycle bail-out) or is undefined.
264
+ *
265
+ * @description
266
+ * Creates a child wrapper for impl values, including primitives.
267
+ *
268
+ * @example
269
+ * const child = wrapper.___createChildWrapper("add", fn);
270
+ */
271
+ private ___createChildWrapper;
272
+ /**
273
+ * Create recursive waiting proxy for deep lazy loading
274
+ * Builds property chain (e.g., ["advanced", "calc", "power"]) and waits for all parent
275
+ * wrappers to materialize before accessing the final property.
276
+ *
277
+ * Waiting proxies are ONLY created when not materialized or in-flight.
278
+ * Once materialized, we return actual cached values, not waiting proxies.
279
+ * Therefore, waiting proxies always represent in-flight/unmaterialized state.
280
+ *
281
+ * CRITICAL: Caches waiting proxies by propChain key to ensure subsequent accesses
282
+ * return the SAME proxy object, which can then delegate once materialization completes.
283
+ * This matches v2's propertyProxyCache behavior.
284
+ *
285
+ * @private
286
+ * @param {Array<string|symbol>} [propChain=[]] - Property chain to resolve.
287
+ * @returns {Proxy} Proxy that waits for materialization before applying calls.
288
+ */
289
+ private ___createWaitingProxy;
290
+ /**
291
+ * Create main proxy for this wrapper
292
+ * Handles lazy/eager mode logic, property access, and context binding
293
+ *
294
+ * @returns {Proxy} Main proxy for API
295
+ * @public
296
+ */
297
+ public createProxy(): ProxyConstructor;
35
298
  #private;
36
299
  }
37
- export function isFrameworkReservedKey(key: any): boolean;
38
- export function resolveWrapper(value: any): any;
39
300
  import { ComponentBase } from "#factories/component-base";
@@ -1,36 +1,243 @@
1
+ /**
2
+ * Manages versioned API paths and their dispatcher proxies.
3
+ *
4
+ * Allows the same logical API path (e.g. `auth`) to be registered under multiple
5
+ * version tags (e.g. `v1`, `v2`). A dispatcher proxy lives at the logical path and
6
+ * routes property accesses to the correct versioned namespace at call time.
7
+ *
8
+ * @class VersionManager
9
+ * @extends ComponentBase
10
+ * @package
11
+ */
1
12
  export class VersionManager extends ComponentBase {
2
13
  static slothletProperty: string;
3
- registerVersion(logicalPath: any, versionTag: any, moduleID: any, versionMeta: any, isDefault: any): void;
4
- unregisterVersion(logicalPath: any, versionTag: any): boolean;
5
- getVersionKeyForModule(moduleID: any): any;
6
- hasDispatcher(logicalPath: any): boolean;
7
- getVersionMetadata(moduleID: any): any;
8
- getVersionMetadataByPath(logicalPath: any, versionTag: any): any;
9
- setVersionMetadataByPath(logicalPath: any, versionTag: any, patch: any): void;
10
- findLogicalPathFor(path: any): any;
11
- list(logicalPath: any): {
12
- versions: {};
13
- default: any;
14
+ /**
15
+ * Register a new version for a logical path and rebuild the dispatcher.
16
+ *
17
+ * @param {string} logicalPath - Logical API path (e.g. `"auth"`).
18
+ * @param {string} versionTag - Version tag (e.g. `"v1"`).
19
+ * @param {string} moduleID - Module ID of the mounted versioned module.
20
+ * @param {object} versionMeta - User-supplied version metadata (stored in VersionManager only).
21
+ * @param {boolean} isDefault - Whether this version should be the explicit default.
22
+ * @returns {void}
23
+ * @example
24
+ * versionManager.registerVersion("auth", "v1", "auth_abc", { stable: true }, true);
25
+ */
26
+ registerVersion(logicalPath: string, versionTag: string, moduleID: string, versionMeta: object, isDefault: boolean): void;
27
+ /**
28
+ * Unregister a version for a logical path.
29
+ * Rebuilds or tears down the dispatcher accordingly.
30
+ *
31
+ * @param {string} logicalPath - Logical API path.
32
+ * @param {string} versionTag - Version tag to remove.
33
+ * @returns {boolean} `true` when the version was found and removed.
34
+ * @example
35
+ * versionManager.unregisterVersion("auth", "v2");
36
+ */
37
+ unregisterVersion(logicalPath: string, versionTag: string): boolean;
38
+ /**
39
+ * Get the version key (logicalPath + versionTag) for a given module ID.
40
+ * Used as a reverse lookup during remove operations.
41
+ *
42
+ * @param {string} moduleID - Module ID.
43
+ * @returns {{ logicalPath: string, versionTag: string } | undefined}
44
+ * @example
45
+ * versionManager.getVersionKeyForModule("auth_abc123"); // { logicalPath: "auth", versionTag: "v1" }
46
+ */
47
+ getVersionKeyForModule(moduleID: string): {
48
+ logicalPath: string;
49
+ versionTag: string;
14
50
  } | undefined;
15
- setDefault(logicalPath: any, versionTag: any): void;
16
- getDefaultVersion(logicalPath: any): any;
17
- resolveForPath(logicalPath: any, allVersions: any, caller: any): any;
18
- buildAllVersionsArg(logicalPath: any): {};
19
- buildCallerArg(callerWrapper: any): {
20
- version: null;
21
- default: null;
22
- metadata: any;
23
- versionMetadata: null;
24
- } | {
25
- version: any;
26
- default: boolean;
27
- metadata: any;
28
- versionMetadata: any;
51
+ /**
52
+ * Returns `true` when a live dispatcher proxy is tracked for the given logical path.
53
+ * Used by ApiManager to detect whether a removed path was a logical dispatcher.
54
+ *
55
+ * @param {string} logicalPath - Logical API path (e.g. `"auth"`).
56
+ * @returns {boolean}
57
+ * @example
58
+ * versionManager.hasDispatcher("auth"); // true
59
+ */
60
+ hasDispatcher(logicalPath: string): boolean;
61
+ /**
62
+ * Retrieve the VersionManager-only metadata object stored for a module ID.
63
+ * Used internally by `buildAllVersionsArg` and `buildCallerArg`.
64
+ *
65
+ * @param {string} moduleID - Opaque module ID.
66
+ * @returns {object | undefined} Stored version metadata or `undefined`.
67
+ * @example
68
+ * versionManager.getVersionMetadata("auth_abc123"); // { version: "v1", logicalPath: "auth", stable: true }
69
+ */
70
+ getVersionMetadata(moduleID: string): object | undefined;
71
+ /**
72
+ * Retrieve the VersionManager-only metadata for a logical path and version tag.
73
+ *
74
+ * @param {string} logicalPath - Logical API path (e.g. `"auth"`).
75
+ * @param {string} versionTag - Version tag (e.g. `"v1"`, `"2.3.0"`).
76
+ * @returns {object | undefined} Stored version metadata or `undefined` if not registered.
77
+ * @example
78
+ * versionManager.getVersionMetadataByPath("auth", "v1"); // { version: "v1", logicalPath: "auth", stable: true }
79
+ */
80
+ getVersionMetadataByPath(logicalPath: string, versionTag: string): object | undefined;
81
+ /**
82
+ * Patch (merge) the VersionManager-only metadata for a registered logical path and version tag at runtime.
83
+ * The injected `version` and `logicalPath` keys always win over any user-supplied fields in `patch`.
84
+ *
85
+ * @param {string} logicalPath - Logical API path (e.g. `"auth"`).
86
+ * @param {string} versionTag - Version tag (e.g. `"v1"`, `"2.3.0"`).
87
+ * @param {object} patch - Plain object of keys to merge into the stored version metadata.
88
+ * @returns {void}
89
+ * @throws {SlothletError} When the logical path or version tag is not registered.
90
+ * @example
91
+ * versionManager.setVersionMetadataByPath("auth", "v1", { stable: true });
92
+ */
93
+ setVersionMetadataByPath(logicalPath: string, versionTag: string, patch: object): void;
94
+ /**
95
+ * Find the registered logical path that covers a dotted api pattern.
96
+ *
97
+ * @param {string} path - Dotted api path or hook pattern (e.g. "auth.login").
98
+ * @returns {string | null} The longest registered logical path that is a segment-prefix of
99
+ * `path`, or `null` when no registered version covers it.
100
+ * @public
101
+ * @example
102
+ * versionManager.findLogicalPathFor("auth.login"); // "auth"
103
+ */
104
+ public findLogicalPathFor(path: string): string | null;
105
+ /**
106
+ * Return a snapshot of all registered versions and the default tag for a logical path.
107
+ *
108
+ * @param {string} logicalPath - Logical API path.
109
+ * @returns {{ versions: object, default: string | null } | undefined} Snapshot object, or `undefined` if the path is not registered.
110
+ * @example
111
+ * versionManager.list("auth"); // { versions: { v1: {...}, v2: {...} }, default: "v2" }
112
+ * versionManager.list("unknown"); // undefined
113
+ */
114
+ list(logicalPath: string): {
115
+ versions: object;
116
+ default: string | null;
117
+ } | undefined;
118
+ /**
119
+ * Explicitly override the default version for a logical path at runtime.
120
+ * Clears any previous explicit defaults and marks only the specified tag.
121
+ *
122
+ * @param {string} logicalPath - Logical API path.
123
+ * @param {string} versionTag - Version tag to set as default.
124
+ * @returns {void}
125
+ * @throws {SlothletError} When the version tag is not registered for the path.
126
+ * @example
127
+ * versionManager.setDefault("auth", "v1");
128
+ */
129
+ setDefault(logicalPath: string, versionTag: string): void;
130
+ /**
131
+ * Determine the default version tag for a logical path.
132
+ *
133
+ * Algorithm:
134
+ * 1. Return the first version entry with `isDefault === true`.
135
+ * 2. Otherwise, normalise all tags, sort descending, return highest.
136
+ * 3. Return `null` when no versions are registered.
137
+ *
138
+ * @param {string} logicalPath - Logical API path.
139
+ * @returns {string | null} The default version tag, or `null`.
140
+ * @example
141
+ * // Given: ["v1", "v3", "v8", "v2"]
142
+ * versionManager.getDefaultVersion("auth"); // "v8"
143
+ */
144
+ getDefaultVersion(logicalPath: string): string | null;
145
+ /**
146
+ * Run the configured discriminator and return the winning version tag.
147
+ *
148
+ * When the configured `versionDispatcher` is a string, reads that key from
149
+ * `caller.versionMetadata`. When it is a function, calls it with `(allVersions, caller)`.
150
+ *
151
+ * @param {string} logicalPath - Logical API path.
152
+ * @param {object} allVersions - Pre-built allVersions arg (see `buildAllVersionsArg`).
153
+ * @param {object} caller - Pre-built caller arg (see `buildCallerArg`).
154
+ * @returns {string | null} Resolved version tag, or `null` to fall through to default.
155
+ * @example
156
+ * const tag = versionManager.resolveForPath("auth", allVersions, caller); // "v2"
157
+ */
158
+ resolveForPath(logicalPath: string, allVersions: object, caller: object): string | null;
159
+ /**
160
+ * Build the `allVersions` argument passed to function discriminators.
161
+ *
162
+ * Each key is a version tag; each value contains `version`, `default`, `metadata`
163
+ * (regular Metadata system data), and `versionMetadata` (VersionManager-only store).
164
+ *
165
+ * @param {string} logicalPath - Logical API path.
166
+ * @returns {object} Map-like object keyed by version tag.
167
+ * @example
168
+ * versionManager.buildAllVersionsArg("auth");
169
+ * // { v1: { version: "v1", default: true, metadata: {...}, versionMetadata: {...} } }
170
+ */
171
+ buildAllVersionsArg(logicalPath: string): object;
172
+ /**
173
+ * Build the `caller` argument passed to function discriminators.
174
+ *
175
+ * Returns `null` for version-specific fields when the caller is not a registered
176
+ * versioned module.
177
+ *
178
+ * @param {object | null | undefined} callerWrapper - The caller's UnifiedWrapper proxy.
179
+ * @returns {{ version: string|null, default: boolean|null, metadata: object, versionMetadata: object|null }}
180
+ * @example
181
+ * versionManager.buildCallerArg(callerWrapper);
182
+ * // { version: "v2", default: false, metadata: {...}, versionMetadata: {...} }
183
+ */
184
+ buildCallerArg(callerWrapper: object | null | undefined): {
185
+ version: string | null;
186
+ default: boolean | null;
187
+ metadata: object;
188
+ versionMetadata: object | null;
29
189
  };
30
- createDispatcher(logicalPath: any): any;
31
- updateDispatcher(logicalPath: any): void;
32
- teardownDispatcher(logicalPath: any): void;
33
- onVersionedModuleReload(moduleID: any): void;
190
+ /**
191
+ * Create a native Proxy that dispatches property accesses to the correct versioned path.
192
+ *
193
+ * The dispatcher handles all property categories defined in the spec (framework
194
+ * internal keys, stable framework accessors, `then`, symbols, routing, etc.).
195
+ *
196
+ * @param {string} logicalPath - Logical API path this dispatcher covers.
197
+ * @returns {object} A Proxy instance for version-dispatched property access. The returned
198
+ * value is a Proxy wrapping a frozen plain-object target; it is NOT the Proxy constructor.
199
+ * @example
200
+ * const proxy = versionManager.createDispatcher("auth");
201
+ * proxy.login; // resolves version then returns api.v2.auth.login
202
+ */
203
+ createDispatcher(logicalPath: string): object;
204
+ /**
205
+ * Rebuild (or create) the dispatcher proxy for a logical path and mount it
206
+ * on both `api` and `boundApi`.
207
+ *
208
+ * @param {string} logicalPath - Logical API path.
209
+ * @returns {void}
210
+ * @example
211
+ * versionManager.updateDispatcher("auth");
212
+ */
213
+ updateDispatcher(logicalPath: string): void;
214
+ /**
215
+ * Tear down the dispatcher for a logical path, removing it from the API tree.
216
+ *
217
+ * @param {string} logicalPath - Logical API path.
218
+ * @returns {void}
219
+ * @example
220
+ * versionManager.teardownDispatcher("auth");
221
+ */
222
+ teardownDispatcher(logicalPath: string): void;
223
+ /**
224
+ * Called after a versioned module is reloaded.
225
+ * Refreshes internal metadata and rebuilds the dispatcher for the affected path.
226
+ *
227
+ * @param {string} moduleID - Module ID that was reloaded.
228
+ * @returns {void}
229
+ * @example
230
+ * versionManager.onVersionedModuleReload("auth_abc");
231
+ */
232
+ onVersionedModuleReload(moduleID: string): void;
233
+ /**
234
+ * Clear all internal state.
235
+ * Called automatically by the shutdown sequence.
236
+ *
237
+ * @returns {void}
238
+ * @example
239
+ * versionManager.shutdown();
240
+ */
34
241
  shutdown(): void;
35
242
  #private;
36
243
  }
@@ -1,2 +1,21 @@
1
- export function pinToCurrentCaller(callback: any): any;
2
- export function setApiCallerPinner(strategy: any): void;
1
+ /**
2
+ * Register the strategy for binding a callback to whoever scheduled it.
3
+ *
4
+ * @param {Function|null} strategy - Takes a callback and returns a replacement that re-enters the
5
+ * registering module's context when it runs. `null` clears the registration.
6
+ * @returns {void}
7
+ * @internal
8
+ */
9
+ export function setApiCallerPinner(strategy: Function | null): void;
10
+ /**
11
+ * Bind a callback to the caller active right now, if the runtime supplies a way to.
12
+ *
13
+ * Called by each scheduling boundary at registration time. Returns the callback unchanged when no
14
+ * pinner is registered (the async runtime) or when there is no caller to pin (the host scheduling
15
+ * its own work), so the boundary pays nothing outside a module call.
16
+ *
17
+ * @param {Function} callback - Callback about to be deferred.
18
+ * @returns {Function} The callback, bound to the current caller where one exists.
19
+ * @internal
20
+ */
21
+ export function pinToCurrentCaller(callback: Function): Function;