@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,250 +1,37 @@
1
- /**
2
- * Resolves a value to its backing UnifiedWrapper instance.
3
- * Accepts a proxy registered via createProxy() or a raw UnifiedWrapper instance.
4
- * Returns null for any other value.
5
- *
6
- * @param {unknown} value - Value to resolve
7
- * @returns {UnifiedWrapper|null} The backing wrapper, or null
8
- *
9
- * @example
10
- * const wrapper = resolveWrapper(someProxy);
11
- * if (wrapper) wrapper.____slothletInternal.impl = newImpl;
12
- */
13
- export function resolveWrapper(value: unknown): UnifiedWrapper | null;
14
1
  export namespace TYPE_STATES {
15
2
  let UNMATERIALIZED: symbol;
16
3
  let IN_FLIGHT: symbol;
17
4
  }
18
- /**
19
- * Unified wrapper class that handles all proxy concerns in one place:
20
- * - __impl pattern for reload support
21
- * - Lazy/eager mode materialization
22
- * - Recursive waiting proxy for deep lazy loading
23
- * - Context binding through contextManager
24
- *
25
- * @class
26
- * @extends ComponentBase
27
- * @public
28
- */
29
5
  export class UnifiedWrapper extends ComponentBase {
30
- /**
31
- * Shallow-clone a non-Proxy object implementation to prevent ___adoptImplChildren
32
- * from mutating shared module export references via its `delete this.____slothletInternal.impl[key]`
33
- * operations. When concurrent materializations (e.g., old + new wrapper during reload)
34
- * both load the same cached module, the first ___adoptImplChildren would destroy the
35
- * shared export, causing subsequent wrappers to receive empty objects.
36
- *
37
- * Returns the value unchanged if it is not a plain object, or if it IS a Proxy
38
- * (cloning a Proxy destroys its trap behavior - e.g., LG TV controllers using
39
- * numeric-index access through custom get traps).
40
- *
41
- * @param {*} value - The implementation value to (maybe) clone.
42
- * @returns {*} A shallow clone of `value` when it is a non-Proxy plain object,
43
- * otherwise the original `value`.
44
- * @static
45
- * @private
46
- */
47
- private static _cloneImpl;
48
- /**
49
- * Reconstruct a full implementation object from a wrapper whose _impl may have
50
- * been depleted by ___adoptImplChildren.
51
- *
52
- * @description
53
- * After ___adoptImplChildren runs, children are moved from _impl onto the wrapper as
54
- * own properties and deleted from _impl. This helper reconstructs the original
55
- * impl by merging the remaining _impl keys with the adopted children extracted
56
- * from the wrapper.
57
- *
58
- * Recursively walks the wrapper tree so nested objects whose _impl was also
59
- * depleted are properly reconstructed. For callable (function) impls, returns
60
- * the function directly since keepImplProperties prevents depletion.
61
- *
62
- * @param {Object} wrapper - The UnifiedWrapper instance to extract from
63
- * @returns {*} The reconstructed implementation mirroring original module exports
64
- * @static
65
- * @private
66
- */
67
- private static _extractFullImpl;
68
- /**
69
- * @param {Object} slothlet - Slothlet instance (provides contextManager, instanceID, ownership)
70
- * @param {Object} options - Configuration options
71
- * @param {string} options.mode - "lazy" or "eager"
72
- * @param {string} options.apiPath - API path for this wrapper (e.g., "math.advanced.calc")
73
- * @param {Object} [options.initialImpl=null] - Initial implementation (null for lazy mode)
74
- * @param {Function} [options.materializeFunc=null] - Async function to materialize lazy modules
75
- * @param {boolean} [options.isCallable=false] - Whether the wrapper should be callable
76
- * @param {boolean} [options.materializeOnCreate=false] - Whether to materialize on creation
77
- * @param {string} [options.filePath=null] - File path of the module source
78
- * @param {string} [options.moduleID=null] - Module identifier
79
- * @param {string} [options.sourceFolder=null] - Source folder for metadata
80
- *
81
- * @description
82
- * Creates a unified wrapper instance for a specific API path. Extends ComponentBase
83
- * to access slothlet.contextManager, slothlet.instanceID, and slothlet.handlers.ownership.
84
- *
85
- * @example
86
- * const wrapper = new UnifiedWrapper(this.slothlet, {
87
- * mode: "lazy",
88
- * apiPath: "math",
89
- * initialImpl: null,
90
- * materializeFunc: async () => import("./math.mjs")
91
- * });
92
- */
6
+ [x: number]: (____depth: any, ____options: any, ____inspect: any) => any;
7
+ static _cloneImpl(value: any): any;
8
+ static _extractFullImpl(wrapper: any): any;
93
9
  constructor(slothlet: any, { mode, apiPath, initialImpl, materializeFunc, isCallable, materializeOnCreate, filePath, moduleID, sourceFolder }: {
94
- mode: string;
95
- apiPath: string;
96
- initialImpl?: any;
97
- materializeFunc?: Function;
98
- isCallable?: boolean;
99
- materializeOnCreate?: boolean;
100
- filePath?: string;
101
- moduleID?: string;
102
- sourceFolder?: string;
10
+ mode: any;
11
+ apiPath: any;
12
+ initialImpl?: null | undefined;
13
+ materializeFunc?: null | undefined;
14
+ isCallable: any;
15
+ materializeOnCreate?: boolean | undefined;
16
+ filePath?: null | undefined;
17
+ moduleID?: null | undefined;
18
+ sourceFolder?: null | undefined;
103
19
  });
104
- /**
105
- * Internal state accessor used by framework-internal code only.
106
- * Backed by the private `#internal` field - prototype property, not an own property,
107
- * so proxy invariants never apply and getTrap can legally return undefined for it.
108
- *
109
- * Uses a private-field brand check (`#internal in this`) so the getter is safe to
110
- * invoke with any receiver - including `UnifiedWrapper.prototype` itself during a
111
- * prototype chain walk via `Object.getPrototypeOf` - without throwing a TypeError.
112
- * Without the brand check, `Object.getPrototypeOf(proxy).____slothletInternal` would
113
- * throw because the prototype object was never constructed and has no `#internal` field.
114
- * @returns {Object|undefined} Internal state container, or undefined for non-instances
115
- */
116
- get ____slothletInternal(): any | undefined;
117
- /**
118
- * Get current implementation
119
- * @returns {Object|null} Current __impl value
120
- * @public
121
- */
122
- public get __impl(): any | null;
123
- /**
124
- * Core implementation-application logic shared by ___setImpl and lazy materialization.
125
- * Clones the implementation (protecting the API cache from ___adoptImplChildren's
126
- * delete operations), clears the invalid flag, upgrades __isCallable when a
127
- * callable impl arrives on a configurable wrapper, updates __filePath for lazy
128
- * folder wrappers, and adopts children.
129
- *
130
- * @param {*} newImpl - The new implementation value.
131
- * @param {boolean} [forceReuseChildren=false] - When true, always reuse existing child
132
- * wrappers regardless of mode (used by ___setImpl to preserve live references).
133
- * @private
134
- */
135
- private _applyNewImpl;
136
- /**
137
- * Set new implementation and adopt children.
138
- * Delegates core impl work to _applyNewImpl, then emits lifecycle events
139
- * and updates materialization state.
140
- *
141
- * @param {*} newImpl - New implementation
142
- * @param {string} [moduleID] - Optional moduleID for lifecycle event (for replacements)
143
- * @param {boolean} [forceReuseChildren=false] - When true, always reuse existing child
144
- * wrappers and bypass collision-merged key guards. Use this for direct/explicit
145
- * ___setImpl calls where reference preservation is the intent. Do NOT set for
146
- * hot-reload paths (syncWrapper) where lazy refs should intentionally break.
147
- * @private
148
- */
149
- private ___setImpl;
150
- /**
151
- * Reset wrapper to un-materialized lazy state with a fresh materialization function.
152
- * Used during reload to restore lazy wrappers to their shell state instead of
153
- * eagerly loading all implementations. Preserves proxy identity so existing
154
- * references continue to work - next property access triggers materialization
155
- * from the fresh materializeFunc (which reads updated source files from disk).
156
- * @param {Function} newMaterializeFunc - Fresh materialization function from rebuild
157
- * @returns {void}
158
- * @private
159
- */
160
- private ___resetLazy;
161
- /**
162
- * Trigger materialization (lazy mode only)
163
- * @returns {Promise<void>}
164
- * @private
165
- */
166
- private ___materialize;
167
- /**
168
- * @private
169
- * @returns {Promise<void>}
170
- *
171
- * @description
172
- * Exposes lazy materialization for waiting proxies and nested wrappers.
173
- *
174
- * @example
175
- * await wrapper._materialize();
176
- */
177
- private _materialize;
178
- /**
179
- * @private
180
- * @returns {void}
181
- *
182
- * @description
183
- * Invalidates this wrapper when its parent removes the API path.
184
- *
185
- * @example
186
- * wrapper.___invalidate();
187
- */
188
- private ___invalidate;
189
- /**
190
- * @private
191
- * @returns {void}
192
- *
193
- * @description
194
- * Moves child properties off the impl and attaches them to wrapper as properties
195
- * so this wrapper only represents the current API path.
196
- *
197
- * @example
198
- * wrapper.___adoptImplChildren();
199
- */
200
- private ___adoptImplChildren;
201
- /**
202
- * @private
203
- * @param {string|symbol} key - Child property name
204
- * @param {unknown} value - Child value
205
- * @returns {Object|Function|undefined} Wrapped child proxy when applicable
206
- *
207
- * @description
208
- * Creates a child wrapper for impl values, including primitives.
209
- *
210
- * @example
211
- * const child = wrapper.___createChildWrapper("add", fn);
212
- */
213
- private ___createChildWrapper;
214
- /**
215
- * Create recursive waiting proxy for deep lazy loading
216
- * Builds property chain (e.g., ["advanced", "calc", "power"]) and waits for all parent
217
- * wrappers to materialize before accessing the final property.
218
- *
219
- * Waiting proxies are ONLY created when not materialized or in-flight.
220
- * Once materialized, we return actual cached values, not waiting proxies.
221
- * Therefore, waiting proxies always represent in-flight/unmaterialized state.
222
- *
223
- * CRITICAL: Caches waiting proxies by propChain key to ensure subsequent accesses
224
- * return the SAME proxy object, which can then delegate once materialization completes.
225
- * This matches v2's propertyProxyCache behavior.
226
- *
227
- * @private
228
- * @param {Array<string|symbol>} [propChain=[]] - Property chain to resolve.
229
- * @returns {Proxy} Proxy that waits for materialization before applying calls.
230
- */
231
- private ___createWaitingProxy;
232
- /**
233
- * Create main proxy for this wrapper
234
- * Handles lazy/eager mode logic, property access, and context binding
235
- *
236
- * @returns {Proxy} Main proxy for API
237
- * @public
238
- */
239
- public createProxy(): ProxyConstructor;
240
- lastSyncError: any;
241
- /**
242
- * Custom inspect output for Node.js util.inspect.
243
- * @returns {*} The actual implementation for inspection.
244
- */
245
- [util.inspect.custom](____depth: any, ____options: any, ____inspect: any): any;
20
+ get ____slothletInternal(): null | undefined;
21
+ get __impl(): any;
22
+ _applyNewImpl(newImpl: any, forceReuseChildren?: boolean): void;
23
+ ___setImpl(newImpl: any, moduleID?: null, forceReuseChildren?: boolean): void;
24
+ ___resetLazy(newMaterializeFunc: any): void;
25
+ ___materialize(): Promise<any>;
26
+ _materialize(): Promise<any>;
27
+ ___invalidate(): void;
28
+ ___adoptImplChildren(forceReuseChildren?: boolean): void;
29
+ ___createChildWrapper(key: any, value: any): any;
30
+ ___createWaitingProxy(propChain?: any[]): any;
31
+ createProxy(): any;
32
+ lastSyncError: unknown;
246
33
  #private;
247
34
  }
35
+ export function resolveWrapper(value: any): any;
248
36
  import { ComponentBase } from "@cldmv/slothlet/factories/component-base";
249
- import util from "node:util";
250
37
  //# sourceMappingURL=unified-wrapper.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unified-wrapper.d.mts","sourceRoot":"","sources":["../../../../dist/lib/handlers/unified-wrapper.mjs"],"names":[],"mappings":"AAgwGA;;;;;;;;;;;GAWG;AACH,sCAPW,OAAO,GACL,cAAc,GAAC,IAAI,CAkB/B;;;;;AA5qGD;;;;;;;;;;GAUG;AACH;IAiQC;;;;;;;;;;;;;;;;OAgBG;IACH,0BA8BC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,gCA0DC;IApWD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,+IAtBG;QAAwB,IAAI,EAApB,MAAM;QACU,OAAO,EAAvB,MAAM;QACW,WAAW;QACT,eAAe;QAChB,UAAU,GAA5B,OAAO;QACW,mBAAmB,GAArC,OAAO;QACU,QAAQ,GAAzB,MAAM;QACW,QAAQ,GAAzB,MAAM;QACW,YAAY,GAA7B,MAAM;KAEd,EA4KF;IA1MD;;;;;;;;;;;OAWG;IACH,4BAFa,MAAO,SAAS,CAK5B;IA+ND;;;;OAIG;IACH,qBAHa,MAAO,IAAI,CAKvB;IAkID;;;;;;;;;;;OAWG;IACH,sBAiCC;IAED;;;;;;;;;;;;OAYG;IACH,mBAgDC;IAED;;;;;;;;;OASG;IACH,qBAmDC;IAED;;;;OAIG;IACH,uBA+FC;IAED;;;;;;;;;OASG;IACH,qBAEC;IAED;;;;;;;;;OASG;IACH,sBAiBC;IAED;;;;;;;;;;OAUG;IACH,6BA2bC;IAED;;;;;;;;;;;OAWG;IACH,8BAwIC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,8BAmpBC;IAED;;;;;;OAMG;IACH,uCA4rCC;IAvVE,mBAA0B;IAzlF7B;;;OAGG;IACH,2EAFa,GAAC,CA8Bb;;CAi5FD;8BAxuG6B,0CAA0C;iBADvD,WAAW"}
1
+ {"version":3,"file":"unified-wrapper.d.mts","sourceRoot":"","sources":["../../../../dist/lib/handlers/unified-wrapper.mjs"],"names":[],"mappings":";;;;AAA+vC;;IAA6jH,mCAAsc;IAAA,2CAAy/B;IAA32J;;;;;;;;;;OAAq1F;IAA56F,6CAAuF;IAAy3G,kBAAmD;IAA+7C,gEAAqyB;IAAA,8EAAgsC;IAAA,4CAA2kC;IAAA,+BAAs4D;IAAA,6BAA4C;IAAA,sBAA8T;IAAA,yDAAq6P;IAAA,iDAA2sG;IAAA,8CAA20Y;IAAA,mBAA4xwB;IAA3oO,uBAAwB;;CAAonO;AAAA,gDAA8N;8BAAt12D,0CAA0C"}
@@ -1,232 +1,35 @@
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
- */
12
1
  export class VersionManager extends ComponentBase {
13
2
  static slothletProperty: string;
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;
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
+ list(logicalPath: any): {
11
+ versions: {};
12
+ default: any;
50
13
  } | undefined;
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
- * Return a snapshot of all registered versions and the default tag for a logical path.
96
- *
97
- * @param {string} logicalPath - Logical API path.
98
- * @returns {{ versions: object, default: string | null } | undefined} Snapshot object, or `undefined` if the path is not registered.
99
- * @example
100
- * versionManager.list("auth"); // { versions: { v1: {...}, v2: {...} }, default: "v2" }
101
- * versionManager.list("unknown"); // undefined
102
- */
103
- list(logicalPath: string): {
104
- versions: object;
105
- default: string | null;
106
- } | undefined;
107
- /**
108
- * Explicitly override the default version for a logical path at runtime.
109
- * Clears any previous explicit defaults and marks only the specified tag.
110
- *
111
- * @param {string} logicalPath - Logical API path.
112
- * @param {string} versionTag - Version tag to set as default.
113
- * @returns {void}
114
- * @throws {SlothletError} When the version tag is not registered for the path.
115
- * @example
116
- * versionManager.setDefault("auth", "v1");
117
- */
118
- setDefault(logicalPath: string, versionTag: string): void;
119
- /**
120
- * Determine the default version tag for a logical path.
121
- *
122
- * Algorithm:
123
- * 1. Return the first version entry with `isDefault === true`.
124
- * 2. Otherwise, normalise all tags, sort descending, return highest.
125
- * 3. Return `null` when no versions are registered.
126
- *
127
- * @param {string} logicalPath - Logical API path.
128
- * @returns {string | null} The default version tag, or `null`.
129
- * @example
130
- * // Given: ["v1", "v3", "v8", "v2"]
131
- * versionManager.getDefaultVersion("auth"); // "v8"
132
- */
133
- getDefaultVersion(logicalPath: string): string | null;
134
- /**
135
- * Run the configured discriminator and return the winning version tag.
136
- *
137
- * When the configured `versionDispatcher` is a string, reads that key from
138
- * `caller.versionMetadata`. When it is a function, calls it with `(allVersions, caller)`.
139
- *
140
- * @param {string} logicalPath - Logical API path.
141
- * @param {object} allVersions - Pre-built allVersions arg (see `buildAllVersionsArg`).
142
- * @param {object} caller - Pre-built caller arg (see `buildCallerArg`).
143
- * @returns {string | null} Resolved version tag, or `null` to fall through to default.
144
- * @example
145
- * const tag = versionManager.resolveForPath("auth", allVersions, caller); // "v2"
146
- */
147
- resolveForPath(logicalPath: string, allVersions: object, caller: object): string | null;
148
- /**
149
- * Build the `allVersions` argument passed to function discriminators.
150
- *
151
- * Each key is a version tag; each value contains `version`, `default`, `metadata`
152
- * (regular Metadata system data), and `versionMetadata` (VersionManager-only store).
153
- *
154
- * @param {string} logicalPath - Logical API path.
155
- * @returns {object} Map-like object keyed by version tag.
156
- * @example
157
- * versionManager.buildAllVersionsArg("auth");
158
- * // { v1: { version: "v1", default: true, metadata: {...}, versionMetadata: {...} } }
159
- */
160
- buildAllVersionsArg(logicalPath: string): object;
161
- /**
162
- * Build the `caller` argument passed to function discriminators.
163
- *
164
- * Returns `null` for version-specific fields when the caller is not a registered
165
- * versioned module.
166
- *
167
- * @param {object | null | undefined} callerWrapper - The caller's UnifiedWrapper proxy.
168
- * @returns {{ version: string|null, default: boolean|null, metadata: object, versionMetadata: object|null }}
169
- * @example
170
- * versionManager.buildCallerArg(callerWrapper);
171
- * // { version: "v2", default: false, metadata: {...}, versionMetadata: {...} }
172
- */
173
- buildCallerArg(callerWrapper: object | null | undefined): {
174
- version: string | null;
175
- default: boolean | null;
176
- metadata: object;
177
- versionMetadata: object | null;
14
+ setDefault(logicalPath: any, versionTag: any): void;
15
+ getDefaultVersion(logicalPath: any): any;
16
+ resolveForPath(logicalPath: any, allVersions: any, caller: any): any;
17
+ buildAllVersionsArg(logicalPath: any): {};
18
+ buildCallerArg(callerWrapper: any): {
19
+ version: null;
20
+ default: null;
21
+ metadata: any;
22
+ versionMetadata: null;
23
+ } | {
24
+ version: any;
25
+ default: boolean;
26
+ metadata: any;
27
+ versionMetadata: any;
178
28
  };
179
- /**
180
- * Create a native Proxy that dispatches property accesses to the correct versioned path.
181
- *
182
- * The dispatcher handles all property categories defined in the spec (framework
183
- * internal keys, stable framework accessors, `then`, symbols, routing, etc.).
184
- *
185
- * @param {string} logicalPath - Logical API path this dispatcher covers.
186
- * @returns {object} A Proxy instance for version-dispatched property access. The returned
187
- * value is a Proxy wrapping a frozen plain-object target; it is NOT the Proxy constructor.
188
- * @example
189
- * const proxy = versionManager.createDispatcher("auth");
190
- * proxy.login; // resolves version then returns api.v2.auth.login
191
- */
192
- createDispatcher(logicalPath: string): object;
193
- /**
194
- * Rebuild (or create) the dispatcher proxy for a logical path and mount it
195
- * on both `api` and `boundApi`.
196
- *
197
- * @param {string} logicalPath - Logical API path.
198
- * @returns {void}
199
- * @example
200
- * versionManager.updateDispatcher("auth");
201
- */
202
- updateDispatcher(logicalPath: string): void;
203
- /**
204
- * Tear down the dispatcher for a logical path, removing it from the API tree.
205
- *
206
- * @param {string} logicalPath - Logical API path.
207
- * @returns {void}
208
- * @example
209
- * versionManager.teardownDispatcher("auth");
210
- */
211
- teardownDispatcher(logicalPath: string): void;
212
- /**
213
- * Called after a versioned module is reloaded.
214
- * Refreshes internal metadata and rebuilds the dispatcher for the affected path.
215
- *
216
- * @param {string} moduleID - Module ID that was reloaded.
217
- * @returns {void}
218
- * @example
219
- * versionManager.onVersionedModuleReload("auth_abc");
220
- */
221
- onVersionedModuleReload(moduleID: string): void;
222
- /**
223
- * Clear all internal state.
224
- * Called automatically by the shutdown sequence.
225
- *
226
- * @returns {void}
227
- * @example
228
- * versionManager.shutdown();
229
- */
29
+ createDispatcher(logicalPath: any): any;
30
+ updateDispatcher(logicalPath: any): void;
31
+ teardownDispatcher(logicalPath: any): void;
32
+ onVersionedModuleReload(moduleID: any): void;
230
33
  shutdown(): void;
231
34
  #private;
232
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"version-manager.d.mts","sourceRoot":"","sources":["../../../../dist/lib/handlers/version-manager.mjs"],"names":[],"mappings":"AAsGA;;;;;;;;;;GAUG;AACH;IACC,gCAA2C;IA8B3C;;;;;;;;;;;OAWG;IACH,6BATW,MAAM,cACN,MAAM,YACN,MAAM,eACN,MAAM,aACN,OAAO,GACL,IAAI,CAyDhB;IAED;;;;;;;;;OASG;IACH,+BANW,MAAM,cACN,MAAM,GACJ,OAAO,CAqCnB;IAED;;;;;;;;OAQG;IACH,iCALW,MAAM,GACJ;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAMnE;IAED;;;;;;;;OAQG;IACH,2BALW,MAAM,GACJ,OAAO,CAMnB;IAED;;;;;;;;OAQG;IACH,6BALW,MAAM,GACJ,MAAM,GAAG,SAAS,CAM9B;IAED;;;;;;;;OAQG;IACH,sCANW,MAAM,cACN,MAAM,GACJ,MAAM,GAAG,SAAS,CAU9B;IAED;;;;;;;;;;;OAWG;IACH,sCARW,MAAM,cACN,MAAM,SACN,MAAM,GACJ,IAAI,CAwBhB;IAED;;;;;;;;OAQG;IACH,kBANW,MAAM,GACJ;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,SAAS,CAcpE;IAED;;;;;;;;;;OAUG;IACH,wBAPW,MAAM,cACN,MAAM,GACJ,IAAI,CAwBhB;IAID;;;;;;;;;;;;;OAaG;IACH,+BANW,MAAM,GACJ,MAAM,GAAG,IAAI,CAqCzB;IAID;;;;;;;;;;;;OAYG;IACH,4BAPW,MAAM,eACN,MAAM,UACN,MAAM,GACJ,MAAM,GAAG,IAAI,CAkDzB;IAID;;;;;;;;;;;OAWG;IACH,iCANW,MAAM,GACJ,MAAM,CAmClB;IAED;;;;;;;;;;;OAWG;IACH,8BANW,MAAM,GAAG,IAAI,GAAG,SAAS,GACvB;QAAE,OAAO,EAAE,MAAM,GAAC,IAAI,CAAC;QAAC,OAAO,EAAE,OAAO,GAAC,IAAI,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,GAAC,IAAI,CAAA;KAAE,CAkC3G;IA0DD;;;;;;;;;;;;OAYG;IACH,8BAPW,MAAM,GACJ,MAAM,CA6elB;IAED;;;;;;;;OAQG;IACH,8BALW,MAAM,GACJ,IAAI,CAiChB;IAED;;;;;;;OAOG;IACH,gCALW,MAAM,GACJ,IAAI,CAkBhB;IAID;;;;;;;;OAQG;IACH,kCALW,MAAM,GACJ,IAAI,CAmBhB;IAED;;;;;;;OAOG;IACH,YAJa,IAAI,CAShB;;CACD;8BAttC6B,0CAA0C"}
1
+ {"version":3,"file":"version-manager.d.mts","sourceRoot":"","sources":["../../../../dist/lib/handlers/version-manager.mjs"],"names":[],"mappings":"AAA2jB;IAA2C,gCAAyC;IAAoG,0GAAu4B;IAAA,8DAA8kB;IAAA,2CAA+E;IAAA,yCAAqE;IAAA,uCAAgF;IAAA,iEAAwO;IAAA,8EAA8d;IAAA;;;kBAA+N;IAAA,oDAA8Z;IAAA,yCAAihB;IAAA,qEAAyxB;IAAA,0CAA+gB;IAAA;;;;;;;;;;MAAurB;IAAsc,wCAA4+K;IAAA,yCAA8kB;IAAA,2CAAwU;IAAA,6CAA2Q;IAAA,iBAAmI;;CAAC;8BAA93a,0CAA0C"}
@@ -1,54 +1,4 @@
1
- /**
2
- * @function runtime_shouldWrapMethod
3
- * @package
4
- * @param {*} value - The value to check
5
- * @param {string|symbol} prop - The property name
6
- * @returns {boolean} True if the method should be wrapped
7
- *
8
- * @description
9
- * Determines if a method should be wrapped with context preservation.
10
- * Excludes constructors, Object.prototype methods, and internal methods.
11
- *
12
- * @example
13
- * runtime_shouldWrapMethod(myInstance.method, "method"); // true
14
- * runtime_shouldWrapMethod(myInstance.constructor, "constructor"); // false
15
- */
16
- export function runtime_shouldWrapMethod(value: any, prop: string | symbol): boolean;
17
- /**
18
- * @function runtime_isClassInstance
19
- * @package
20
- * @param {*} val - The value to check
21
- * @returns {boolean} True if the value is a class instance that should be wrapped
22
- *
23
- * @description
24
- * Determines if a value is a class instance (not a plain object, array, or primitive)
25
- * that should have its methods wrapped to preserve AsyncLocalStorage context.
26
- * Uses systematic exclusion lists for better maintainability.
27
- *
28
- * @example
29
- * // Check if value is a class instance
30
- * const isInstance = runtime_isClassInstance(new MyClass());
31
- */
32
1
  export function runtime_isClassInstance(val: any): boolean;
33
- /**
34
- * @function runtime_wrapClassInstance
35
- * @package
36
- * @param {object} instance - The class instance to wrap
37
- * @param {object} contextManager - The context manager (async or live)
38
- * @param {string} instanceID - The slothlet instance ID
39
- * @param {WeakMap} instanceCache - The cache for wrapped instances
40
- * @returns {Proxy} A proxied instance with context-aware method calls
41
- *
42
- * @description
43
- * Wraps a class instance so that all method calls maintain the AsyncLocalStorage context.
44
- * This ensures that calls to methods on returned class instances preserve the slothlet
45
- * context for runtime imports like `self` and `context`.
46
- *
47
- * V3 Adaptation: Uses contextManager.runInContext() instead of V2's runWithCtx().
48
- *
49
- * @example
50
- * // Wrap a class instance to preserve context
51
- * const wrappedInstance = runtime_wrapClassInstance(instance, contextManager, instanceID, instanceCache);
52
- */
53
- export function runtime_wrapClassInstance(instance: object, contextManager: object, instanceID: string, instanceCache: WeakMap<any, any>): ProxyConstructor;
2
+ export function runtime_shouldWrapMethod(value: any, prop: any): boolean;
3
+ export function runtime_wrapClassInstance(instance: any, contextManager: any, instanceID: any, instanceCache: any): any;
54
4
  //# sourceMappingURL=class-instance-wrapper.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"class-instance-wrapper.d.mts","sourceRoot":"","sources":["../../../../dist/lib/helpers/class-instance-wrapper.mjs"],"names":[],"mappings":"AA0CA;;;;;;;;;;;;;;GAcG;AACH,gDAZW,GAAC,QACD,MAAM,GAAC,MAAM,GACX,OAAO,CAkBnB;AAED;;;;;;;;;;;;;;GAcG;AACH,6CAZW,GAAC,GACC,OAAO,CA6BnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,oDAjBW,MAAM,kBACN,MAAM,cACN,MAAM,sDA8EhB"}
1
+ {"version":3,"file":"class-instance-wrapper.d.mts","sourceRoot":"","sources":["../../../../dist/lib/helpers/class-instance-wrapper.mjs"],"names":[],"mappings":"AAA2X,2DAAmT;AAAre,yEAAkL;AAAmT,wHAAwkC"}