@cldmv/slothlet 2.11.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENT-USAGE.md +355 -325
- package/README.md +554 -238
- package/dist/lib/builders/api-assignment.mjs +605 -0
- package/dist/lib/builders/api_builder.mjs +1073 -0
- package/dist/lib/builders/builder.mjs +94 -0
- package/dist/lib/builders/modes-processor.mjs +1816 -0
- package/dist/lib/errors.mjs +227 -0
- package/dist/lib/factories/component-base.mjs +96 -0
- package/dist/lib/factories/context.mjs +38 -0
- package/dist/lib/handlers/api-cache-manager.mjs +216 -0
- package/dist/lib/handlers/api-manager.mjs +2364 -0
- package/dist/lib/handlers/context-async.mjs +184 -0
- package/dist/lib/handlers/context-live.mjs +184 -0
- package/dist/lib/handlers/hook-manager.mjs +789 -0
- package/dist/lib/handlers/lifecycle-token.mjs +44 -0
- package/dist/lib/handlers/lifecycle.mjs +131 -0
- package/dist/lib/handlers/materialize-manager.mjs +64 -0
- package/dist/lib/handlers/metadata.mjs +500 -0
- package/dist/lib/handlers/ownership.mjs +338 -0
- package/dist/lib/handlers/unified-wrapper.mjs +3031 -0
- package/dist/lib/helpers/class-instance-wrapper.mjs +125 -0
- package/dist/lib/helpers/config.mjs +343 -0
- package/dist/lib/helpers/eventemitter-context.mjs +365 -0
- package/dist/lib/helpers/hint-detector.mjs +63 -0
- package/dist/lib/helpers/modes-utils.mjs +53 -0
- package/dist/lib/helpers/resolve-from-caller.mjs +123 -117
- package/dist/lib/helpers/sanitize.mjs +247 -168
- package/dist/lib/helpers/utilities.mjs +46 -81
- package/dist/lib/i18n/languages/de-de.json +377 -0
- package/dist/lib/i18n/languages/en-gb.json +377 -0
- package/dist/lib/i18n/languages/en-us.json +377 -0
- package/dist/lib/i18n/languages/es-mx.json +377 -0
- package/dist/lib/i18n/languages/fr-fr.json +377 -0
- package/dist/lib/i18n/languages/hi-in.json +377 -0
- package/dist/lib/i18n/languages/ja-jp.json +377 -0
- package/dist/lib/i18n/languages/ko-kr.json +377 -0
- package/dist/lib/i18n/languages/pt-br.json +377 -0
- package/dist/lib/i18n/languages/ru-ru.json +377 -0
- package/dist/lib/i18n/languages/zh-cn.json +377 -0
- package/dist/lib/i18n/translations.mjs +140 -0
- package/dist/lib/modes/eager.mjs +75 -0
- package/dist/lib/modes/lazy.mjs +97 -0
- package/dist/lib/processors/flatten.mjs +453 -0
- package/dist/lib/processors/loader.mjs +355 -0
- package/dist/lib/processors/type-generator.mjs +291 -0
- package/dist/lib/processors/typescript.mjs +188 -0
- package/dist/lib/runtime/runtime-asynclocalstorage.mjs +80 -522
- package/dist/lib/runtime/runtime-livebindings.mjs +45 -390
- package/dist/lib/runtime/runtime.mjs +39 -159
- package/dist/slothlet.mjs +525 -744
- package/docs/API-RULES.md +338 -486
- package/index.cjs +4 -4
- package/index.mjs +82 -45
- package/package.json +143 -30
- package/types/dist/lib/builders/api-assignment.d.mts +97 -0
- package/types/dist/lib/builders/api-assignment.d.mts.map +1 -0
- package/types/dist/lib/builders/api_builder.d.mts +96 -0
- package/types/dist/lib/builders/api_builder.d.mts.map +1 -0
- package/types/dist/lib/builders/builder.d.mts +60 -0
- package/types/dist/lib/builders/builder.d.mts.map +1 -0
- package/types/dist/lib/builders/modes-processor.d.mts +32 -0
- package/types/dist/lib/builders/modes-processor.d.mts.map +1 -0
- package/types/dist/lib/errors.d.mts +118 -0
- package/types/dist/lib/errors.d.mts.map +1 -0
- package/types/dist/lib/factories/component-base.d.mts +182 -0
- package/types/dist/lib/factories/component-base.d.mts.map +1 -0
- package/types/dist/lib/factories/context.d.mts +26 -0
- package/types/dist/lib/factories/context.d.mts.map +1 -0
- package/types/dist/lib/handlers/api-cache-manager.d.mts +208 -0
- package/types/dist/lib/handlers/api-cache-manager.d.mts.map +1 -0
- package/types/dist/lib/handlers/api-manager.d.mts +392 -0
- package/types/dist/lib/handlers/api-manager.d.mts.map +1 -0
- package/types/dist/lib/handlers/context-async.d.mts +66 -0
- package/types/dist/lib/handlers/context-async.d.mts.map +1 -0
- package/types/dist/lib/handlers/context-live.d.mts +65 -0
- package/types/dist/lib/handlers/context-live.d.mts.map +1 -0
- package/types/dist/lib/handlers/hook-manager.d.mts +199 -0
- package/types/dist/lib/handlers/hook-manager.d.mts.map +1 -0
- package/types/dist/lib/handlers/lifecycle-token.d.mts +49 -0
- package/types/dist/lib/handlers/lifecycle-token.d.mts.map +1 -0
- package/types/dist/lib/handlers/lifecycle.d.mts +90 -0
- package/types/dist/lib/handlers/lifecycle.d.mts.map +1 -0
- package/types/dist/lib/handlers/materialize-manager.d.mts +75 -0
- package/types/dist/lib/handlers/materialize-manager.d.mts.map +1 -0
- package/types/dist/lib/handlers/metadata.d.mts +215 -0
- package/types/dist/lib/handlers/metadata.d.mts.map +1 -0
- package/types/dist/lib/handlers/ownership.d.mts +170 -0
- package/types/dist/lib/handlers/ownership.d.mts.map +1 -0
- package/types/dist/lib/handlers/unified-wrapper.d.mts +250 -0
- package/types/dist/lib/handlers/unified-wrapper.d.mts.map +1 -0
- package/types/dist/lib/helpers/class-instance-wrapper.d.mts +54 -0
- package/types/dist/lib/helpers/class-instance-wrapper.d.mts.map +1 -0
- package/types/dist/lib/helpers/config.d.mts +96 -0
- package/types/dist/lib/helpers/config.d.mts.map +1 -0
- package/types/dist/lib/helpers/eventemitter-context.d.mts +31 -0
- package/types/dist/lib/helpers/eventemitter-context.d.mts.map +1 -0
- package/types/dist/lib/helpers/hint-detector.d.mts +20 -0
- package/types/dist/lib/helpers/hint-detector.d.mts.map +1 -0
- package/types/dist/lib/helpers/modes-utils.d.mts +35 -0
- package/types/dist/lib/helpers/modes-utils.d.mts.map +1 -0
- package/types/dist/lib/helpers/resolve-from-caller.d.mts +29 -145
- package/types/dist/lib/helpers/resolve-from-caller.d.mts.map +1 -1
- package/types/dist/lib/helpers/sanitize.d.mts +95 -94
- package/types/dist/lib/helpers/sanitize.d.mts.map +1 -1
- package/types/dist/lib/helpers/utilities.d.mts +53 -116
- package/types/dist/lib/helpers/utilities.d.mts.map +1 -1
- package/types/dist/lib/i18n/translations.d.mts +39 -0
- package/types/dist/lib/i18n/translations.d.mts.map +1 -0
- package/types/dist/lib/modes/eager.d.mts +36 -0
- package/types/dist/lib/modes/eager.d.mts.map +1 -0
- package/types/dist/lib/modes/lazy.d.mts +49 -0
- package/types/dist/lib/modes/lazy.d.mts.map +1 -0
- package/types/dist/lib/processors/flatten.d.mts +114 -0
- package/types/dist/lib/processors/flatten.d.mts.map +1 -0
- package/types/dist/lib/processors/loader.d.mts +47 -0
- package/types/dist/lib/processors/loader.d.mts.map +1 -0
- package/types/dist/lib/processors/type-generator.d.mts +19 -0
- package/types/dist/lib/processors/type-generator.d.mts.map +1 -0
- package/types/dist/lib/processors/typescript.d.mts +55 -0
- package/types/dist/lib/processors/typescript.d.mts.map +1 -0
- package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts +47 -42
- package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime-livebindings.d.mts +34 -65
- package/types/dist/lib/runtime/runtime-livebindings.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime.d.mts +39 -9
- package/types/dist/lib/runtime/runtime.d.mts.map +1 -1
- package/types/dist/slothlet.d.mts +184 -111
- package/types/dist/slothlet.d.mts.map +1 -1
- package/types/index.d.mts +1 -3
- package/dist/lib/engine/README.md +0 -21
- package/dist/lib/engine/slothlet_child.mjs +0 -59
- package/dist/lib/engine/slothlet_engine.mjs +0 -372
- package/dist/lib/engine/slothlet_esm.mjs +0 -230
- package/dist/lib/engine/slothlet_helpers.mjs +0 -455
- package/dist/lib/engine/slothlet_worker.mjs +0 -149
- package/dist/lib/helpers/als-eventemitter.mjs +0 -256
- package/dist/lib/helpers/api_builder/add_api.mjs +0 -553
- package/dist/lib/helpers/api_builder/analysis.mjs +0 -532
- package/dist/lib/helpers/api_builder/construction.mjs +0 -495
- package/dist/lib/helpers/api_builder/decisions.mjs +0 -748
- package/dist/lib/helpers/api_builder/metadata.mjs +0 -248
- package/dist/lib/helpers/api_builder.mjs +0 -41
- package/dist/lib/helpers/auto-wrap.mjs +0 -62
- package/dist/lib/helpers/hooks.mjs +0 -389
- package/dist/lib/helpers/instance-manager.mjs +0 -111
- package/dist/lib/helpers/metadata-api.mjs +0 -201
- package/dist/lib/helpers/multidefault.mjs +0 -216
- package/dist/lib/modes/slothlet_eager.mjs +0 -154
- package/dist/lib/modes/slothlet_lazy.mjs +0 -594
- package/docs/API-RULES-CONDITIONS.md +0 -712
- package/types/dist/lib/engine/slothlet_child.d.mts +0 -2
- package/types/dist/lib/engine/slothlet_child.d.mts.map +0 -1
- package/types/dist/lib/engine/slothlet_engine.d.mts +0 -31
- package/types/dist/lib/engine/slothlet_engine.d.mts.map +0 -1
- package/types/dist/lib/engine/slothlet_esm.d.mts +0 -19
- package/types/dist/lib/engine/slothlet_esm.d.mts.map +0 -1
- package/types/dist/lib/engine/slothlet_helpers.d.mts +0 -25
- package/types/dist/lib/engine/slothlet_helpers.d.mts.map +0 -1
- package/types/dist/lib/engine/slothlet_worker.d.mts +0 -2
- package/types/dist/lib/engine/slothlet_worker.d.mts.map +0 -1
- package/types/dist/lib/helpers/als-eventemitter.d.mts +0 -56
- package/types/dist/lib/helpers/als-eventemitter.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/add_api.d.mts +0 -102
- package/types/dist/lib/helpers/api_builder/add_api.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/analysis.d.mts +0 -189
- package/types/dist/lib/helpers/api_builder/analysis.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/construction.d.mts +0 -107
- package/types/dist/lib/helpers/api_builder/construction.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/decisions.d.mts +0 -213
- package/types/dist/lib/helpers/api_builder/decisions.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/metadata.d.mts +0 -99
- package/types/dist/lib/helpers/api_builder/metadata.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder.d.mts +0 -6
- package/types/dist/lib/helpers/api_builder.d.mts.map +0 -1
- package/types/dist/lib/helpers/auto-wrap.d.mts +0 -49
- package/types/dist/lib/helpers/auto-wrap.d.mts.map +0 -1
- package/types/dist/lib/helpers/hooks.d.mts +0 -342
- package/types/dist/lib/helpers/hooks.d.mts.map +0 -1
- package/types/dist/lib/helpers/instance-manager.d.mts +0 -41
- package/types/dist/lib/helpers/instance-manager.d.mts.map +0 -1
- package/types/dist/lib/helpers/metadata-api.d.mts +0 -132
- package/types/dist/lib/helpers/metadata-api.d.mts.map +0 -1
- package/types/dist/lib/helpers/multidefault.d.mts +0 -90
- package/types/dist/lib/helpers/multidefault.d.mts.map +0 -1
- package/types/dist/lib/modes/slothlet_eager.d.mts +0 -65
- package/types/dist/lib/modes/slothlet_eager.d.mts.map +0 -1
- package/types/dist/lib/modes/slothlet_lazy.d.mts +0 -31
- package/types/dist/lib/modes/slothlet_lazy.d.mts.map +0 -1
- package/types/index.d.mts.map +0 -1
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-flattening decision logic that determines whether a module should be flattened
|
|
3
|
-
* based on filename matching, export patterns, and context.
|
|
4
|
-
*
|
|
5
|
-
* @function getFlatteningDecision
|
|
6
|
-
* @internal
|
|
7
|
-
* @package
|
|
8
|
-
* @param {object} options - Flattening analysis options
|
|
9
|
-
* @param {object} options.mod - The loaded module object
|
|
10
|
-
* @param {string} options.fileName - Original filename (without extension)
|
|
11
|
-
* @param {string} options.apiPathKey - Sanitized API key for the module
|
|
12
|
-
* @param {boolean} options.hasMultipleDefaultExports - Whether multiple default exports exist in the container
|
|
13
|
-
* @param {boolean} options.isSelfReferential - Whether this is a self-referential export
|
|
14
|
-
* @param {boolean} [options.moduleHasDefault] - Whether this specific module has a default export.
|
|
15
|
-
* Should use originalAnalysis.hasDefault when available for accuracy, as !!mod.default
|
|
16
|
-
* may be inaccurate after processModuleFromAnalysis modifies module structure.
|
|
17
|
-
* @param {string} [options.categoryName] - Container/category name for context
|
|
18
|
-
* @param {number} [options.totalModules=1] - Total number of modules in container
|
|
19
|
-
* @param {boolean} [options.debug=false] - Enable debug logging
|
|
20
|
-
* @returns {{
|
|
21
|
-
* shouldFlatten: boolean,
|
|
22
|
-
* flattenToRoot: boolean,
|
|
23
|
-
* flattenToCategory: boolean,
|
|
24
|
-
* preserveAsNamespace: boolean,
|
|
25
|
-
* useAutoFlattening: boolean,
|
|
26
|
-
* reason: string
|
|
27
|
-
* }} Flattening decision result
|
|
28
|
-
*
|
|
29
|
-
* @description
|
|
30
|
-
* Determines flattening behavior based on slothlet's established rules:
|
|
31
|
-
*
|
|
32
|
-
* 1. Self-referential exports: Never flatten (preserve as namespace)
|
|
33
|
-
* 2. Multi-default context: Flatten modules WITHOUT defaults, preserve WITH defaults
|
|
34
|
-
* 3. Single named export matching filename: Auto-flatten to use export directly
|
|
35
|
-
* 4. Filename matches container: Flatten contents to container level
|
|
36
|
-
* 5. Traditional context: Preserve as namespace unless auto-flattening applies
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* // Internal usage - single named export matching filename
|
|
40
|
-
* const decision = getFlatteningDecision({
|
|
41
|
-
* mod: { math: { add: fn, multiply: fn } },
|
|
42
|
-
* fileName: "math", apiPathKey: "math",
|
|
43
|
-
* hasMultipleDefaultExports: false, isSelfReferential: false
|
|
44
|
-
* });
|
|
45
|
-
* // Returns: { shouldFlatten: true, useAutoFlattening: true, reason: "auto-flatten single named export" }
|
|
46
|
-
*/
|
|
47
|
-
export function getFlatteningDecision(options: {
|
|
48
|
-
mod: object;
|
|
49
|
-
fileName: string;
|
|
50
|
-
apiPathKey: string;
|
|
51
|
-
hasMultipleDefaultExports: boolean;
|
|
52
|
-
isSelfReferential: boolean;
|
|
53
|
-
moduleHasDefault?: boolean;
|
|
54
|
-
categoryName?: string;
|
|
55
|
-
totalModules?: number;
|
|
56
|
-
debug?: boolean;
|
|
57
|
-
}): {
|
|
58
|
-
shouldFlatten: boolean;
|
|
59
|
-
flattenToRoot: boolean;
|
|
60
|
-
flattenToCategory: boolean;
|
|
61
|
-
preserveAsNamespace: boolean;
|
|
62
|
-
useAutoFlattening: boolean;
|
|
63
|
-
reason: string;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Handles function name preference logic for better API naming.
|
|
67
|
-
*
|
|
68
|
-
* @function applyFunctionNamePreference
|
|
69
|
-
* @internal
|
|
70
|
-
* @package
|
|
71
|
-
* @param {object} options - Name preference options
|
|
72
|
-
* @param {object} options.mod - The loaded module object
|
|
73
|
-
* @param {string} options.fileName - Original filename (without extension)
|
|
74
|
-
* @param {string} options.apiPathKey - Sanitized API key
|
|
75
|
-
* @param {object} options.categoryModules - Target category modules object
|
|
76
|
-
* @param {function} options.toapiPathKey - Function to sanitize names to API keys
|
|
77
|
-
* @param {boolean} [options.debug=false] - Enable debug logging
|
|
78
|
-
* @returns {{hasPreferredName: boolean, preferredKey: string}} Name preference result
|
|
79
|
-
*
|
|
80
|
-
* @description
|
|
81
|
-
* Implements slothlet's function name preference logic where the original function name
|
|
82
|
-
* is preferred over the sanitized filename when they represent the same semantic meaning
|
|
83
|
-
* but have different capitalization (e.g., autoIP vs autoIp, parseJSON vs parseJson).
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* // Internal usage in _buildCategory
|
|
87
|
-
* const preference = applyFunctionNamePreference({
|
|
88
|
-
* mod: { autoIP: function autoIP() {} },
|
|
89
|
-
* fileName: "auto-ip", apiPathKey: "autoIp",
|
|
90
|
-
* categoryModules, toapiPathKey: this._toapiPathKey, debug: true
|
|
91
|
-
* });
|
|
92
|
-
* // Returns: { hasPreferredName: true, preferredKey: "autoIP" }
|
|
93
|
-
*/
|
|
94
|
-
export function applyFunctionNamePreference(options: {
|
|
95
|
-
mod: object;
|
|
96
|
-
fileName: string;
|
|
97
|
-
apiPathKey: string;
|
|
98
|
-
categoryModules: object;
|
|
99
|
-
toapiPathKey: Function;
|
|
100
|
-
debug?: boolean;
|
|
101
|
-
}): {
|
|
102
|
-
hasPreferredName: boolean;
|
|
103
|
-
preferredKey: string;
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Processes a single module and applies it to the target API object based on flattening decisions.
|
|
107
|
-
*
|
|
108
|
-
* @function processModuleForAPI
|
|
109
|
-
* @internal
|
|
110
|
-
* @package
|
|
111
|
-
* @param {object} options - Module processing options
|
|
112
|
-
* @param {object} options.mod - The loaded module object
|
|
113
|
-
* @param {string} options.fileName - Original filename (without extension)
|
|
114
|
-
* @param {string} options.apiPathKey - Sanitized API key for the module
|
|
115
|
-
* @param {boolean} options.hasMultipleDefaultExports - Whether multiple default exports exist
|
|
116
|
-
* @param {boolean} options.isSelfReferential - Whether this is a self-referential export
|
|
117
|
-
* @param {object} options.api - Target API object to modify (could be root api or categoryModules)
|
|
118
|
-
* @param {function} [options.getRootDefault] - Function to get current root default function
|
|
119
|
-
* @param {function} [options.setRootDefault] - Function to set the root default function
|
|
120
|
-
* @param {object} [options.context] - Processing context
|
|
121
|
-
* @param {boolean} [options.context.debug=false] - Enable debug logging
|
|
122
|
-
* @param {string} [options.context.mode="unknown"] - Processing mode (root, subfolder, eager, lazy)
|
|
123
|
-
* @param {string} [options.context.categoryName] - Container/category name
|
|
124
|
-
* @param {number} [options.context.totalModules=1] - Total modules in container
|
|
125
|
-
* @returns {{
|
|
126
|
-
* processed: boolean,
|
|
127
|
-
* rootDefaultSet: boolean,
|
|
128
|
-
* flattened: boolean,
|
|
129
|
-
* namespaced: boolean,
|
|
130
|
-
* apiAssignments: Record<string, any>
|
|
131
|
-
* }} Processing result
|
|
132
|
-
*
|
|
133
|
-
* @description
|
|
134
|
-
* Unified module processing logic that handles:
|
|
135
|
-
* 1. Function default exports (multi-default, self-referential, traditional root contributor)
|
|
136
|
-
* 2. Object/named exports with flattening decisions
|
|
137
|
-
* 3. Export merging and namespace assignments
|
|
138
|
-
* 4. Function name preference logic
|
|
139
|
-
* 5. Root default function management
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* // Internal usage for root-level processing
|
|
143
|
-
* const result = processModuleForAPI({
|
|
144
|
-
* mod, fileName, apiPathKey, hasMultipleDefaultExports, isSelfReferential, api,
|
|
145
|
-
* getRootDefault: () => rootDefaultFunction,
|
|
146
|
-
* setRootDefault: (fn) => { rootDefaultFunction = fn; },
|
|
147
|
-
* context: { debug: true, mode: "root", totalModules: 3 },
|
|
148
|
-
* originalAnalysis: { hasDefault: true, namedExportsCount: 2 }
|
|
149
|
-
* });
|
|
150
|
-
*/
|
|
151
|
-
export function processModuleForAPI(options: {
|
|
152
|
-
mod: object;
|
|
153
|
-
fileName: string;
|
|
154
|
-
apiPathKey: string;
|
|
155
|
-
hasMultipleDefaultExports: boolean;
|
|
156
|
-
isSelfReferential: boolean;
|
|
157
|
-
api: object;
|
|
158
|
-
getRootDefault?: Function;
|
|
159
|
-
setRootDefault?: Function;
|
|
160
|
-
context?: {
|
|
161
|
-
debug?: boolean;
|
|
162
|
-
mode?: string;
|
|
163
|
-
categoryName?: string;
|
|
164
|
-
totalModules?: number;
|
|
165
|
-
};
|
|
166
|
-
}): {
|
|
167
|
-
processed: boolean;
|
|
168
|
-
rootDefaultSet: boolean;
|
|
169
|
-
flattened: boolean;
|
|
170
|
-
namespaced: boolean;
|
|
171
|
-
apiAssignments: Record<string, any>;
|
|
172
|
-
};
|
|
173
|
-
/**
|
|
174
|
-
* Centralized category building decisions - contains ALL logic for directory/category processing.
|
|
175
|
-
* This function analyzes a directory and returns decisions about how to structure the API,
|
|
176
|
-
* but doesn't actually build the API (allowing eager/lazy modes to implement differently).
|
|
177
|
-
*
|
|
178
|
-
* @function buildCategoryDecisions
|
|
179
|
-
* @internal
|
|
180
|
-
* @package
|
|
181
|
-
* @param {string} categoryPath - Path to the category directory
|
|
182
|
-
* @param {object} options - Configuration options
|
|
183
|
-
* @param {number} [options.currentDepth=0] - Current nesting depth
|
|
184
|
-
* @param {number} [options.maxDepth=Infinity] - Maximum nesting depth
|
|
185
|
-
* @param {string} [options.mode="eager"] - Loading mode ("eager" or "lazy")
|
|
186
|
-
* @param {Function} [options.subdirHandler] - Handler for subdirectories (lazy mode)
|
|
187
|
-
* @param {object} options.instance - Slothlet instance with _toapiPathKey, _shouldIncludeFile, config
|
|
188
|
-
* @returns {Promise<object>} Category building decisions and data
|
|
189
|
-
*
|
|
190
|
-
* @example
|
|
191
|
-
* // ESM usage
|
|
192
|
-
* import { buildCategoryDecisions } from "@cldmv/slothlet/helpers/api_builder_decisions";
|
|
193
|
-
* const decisions = await buildCategoryDecisions("/path/to/category", {
|
|
194
|
-
* currentDepth: 1,
|
|
195
|
-
* instance: slothletInstance
|
|
196
|
-
* });
|
|
197
|
-
*
|
|
198
|
-
* @example
|
|
199
|
-
* // CJS usage
|
|
200
|
-
* const { buildCategoryDecisions } = require("@cldmv/slothlet/helpers/api_builder_decisions");
|
|
201
|
-
* const decisions = await buildCategoryDecisions("/path/to/category", {
|
|
202
|
-
* currentDepth: 1,
|
|
203
|
-
* instance: slothletInstance
|
|
204
|
-
* });
|
|
205
|
-
*/
|
|
206
|
-
export function buildCategoryDecisions(categoryPath: string, options?: {
|
|
207
|
-
currentDepth?: number;
|
|
208
|
-
maxDepth?: number;
|
|
209
|
-
mode?: string;
|
|
210
|
-
subdirHandler?: Function;
|
|
211
|
-
instance: object;
|
|
212
|
-
}): Promise<object>;
|
|
213
|
-
//# sourceMappingURL=decisions.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decisions.d.mts","sourceRoot":"","sources":["../../../../../dist/lib/helpers/api_builder/decisions.mjs"],"names":[],"mappings":"AAwCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,+CAtCG;IAAwB,GAAG,EAAnB,MAAM;IACU,QAAQ,EAAxB,MAAM;IACU,UAAU,EAA1B,MAAM;IACW,yBAAyB,EAA1C,OAAO;IACU,iBAAiB,EAAlC,OAAO;IACW,gBAAgB,GAAlC,OAAO;IAGU,YAAY,GAA7B,MAAM;IACW,YAAY,GAA7B,MAAM;IACY,KAAK,GAAvB,OAAO;CACf,GAAU;IACR,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAA;CACf,CAyHH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qDAtBG;IAAwB,GAAG,EAAnB,MAAM;IACU,QAAQ,EAAxB,MAAM;IACU,UAAU,EAA1B,MAAM;IACU,eAAe,EAA/B,MAAM;IACY,YAAY;IACZ,KAAK,GAAvB,OAAO;CACf,GAAU;IAAC,gBAAgB,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAC,CA4D7D;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,6CAvCG;IAAwB,GAAG,EAAnB,MAAM;IACU,QAAQ,EAAxB,MAAM;IACU,UAAU,EAA1B,MAAM;IACW,yBAAyB,EAA1C,OAAO;IACU,iBAAiB,EAAlC,OAAO;IACS,GAAG,EAAnB,MAAM;IACa,cAAc;IACd,cAAc;IAChB,OAAO,GAChC;QAAkC,KAAK,GAA/B,OAAO;QACkB,IAAI,GAA7B,MAAM;QACmB,YAAY,GAArC,MAAM;QACmB,YAAY,GAArC,MAAM;KACd;CAAA,GAAU;IACR,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CACpC,CAsLH;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qDAzBW,MAAM,YAEd;IAAyB,YAAY,GAA7B,MAAM;IACW,QAAQ,GAAzB,MAAM;IACW,IAAI,GAArB,MAAM;IACa,aAAa;IAChB,QAAQ,EAAxB,MAAM;CACd,GAAU,OAAO,CAAC,MAAM,CAAC,CA2Z3B"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Project: @cldmv/slothlet
|
|
3
|
-
* @Filename: /src/lib/helpers/api_builder/metadata.mjs
|
|
4
|
-
* @Date: 2025-12-31 00:00:00 -08:00
|
|
5
|
-
* @Author: Nate Hyson <CLDMV>
|
|
6
|
-
* @Email: <Shinrai@users.noreply.github.com>
|
|
7
|
-
* -----
|
|
8
|
-
* @Last modified by: Nate Hyson <CLDMV> (Shinrai@users.noreply.github.com)
|
|
9
|
-
* @Last modified time: 2025-12-31 22:30:16 -08:00 (1767249016)
|
|
10
|
-
* -----
|
|
11
|
-
* @Copyright: Copyright (c) 2013-2025 Catalyzed Motivation Inc. All rights reserved.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* @fileoverview Metadata management utilities for API functions.
|
|
15
|
-
* @module @cldmv/slothlet/lib/helpers/api_builder/metadata
|
|
16
|
-
* @memberof module:@cldmv/slothlet.lib.helpers.api_builder
|
|
17
|
-
* @internal
|
|
18
|
-
* @private
|
|
19
|
-
*
|
|
20
|
-
* @description
|
|
21
|
-
* Provides utilities for tagging functions with immutable metadata, cleaning stale metadata
|
|
22
|
-
* from cached modules, and creating immutable metadata objects with deep freezing.
|
|
23
|
-
*
|
|
24
|
-
* Key Features:
|
|
25
|
-
* - Immutable metadata with Proxy-based enforcement
|
|
26
|
-
* - Deep freezing of nested objects and arrays
|
|
27
|
-
* - Recursive traversal for tagging/cleaning object trees
|
|
28
|
-
* - CommonJS cache-aware metadata cleanup
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* Creates an immutable-but-extensible metadata proxy object.
|
|
32
|
-
*
|
|
33
|
-
* @function createImmutableMetadata
|
|
34
|
-
* @param {object} initial - Initial metadata properties
|
|
35
|
-
* @returns {object} Object with immutable existing properties but allows adding new ones
|
|
36
|
-
*
|
|
37
|
-
* @description
|
|
38
|
-
* Creates an object that enforces immutability of existing properties while allowing
|
|
39
|
-
* new properties to be added. This prevents tampering with security-critical metadata
|
|
40
|
-
* while allowing runtime extension of metadata for additional context.
|
|
41
|
-
*
|
|
42
|
-
* Security features:
|
|
43
|
-
* - Existing properties cannot be modified (non-writable, non-configurable after first set)
|
|
44
|
-
* - Properties cannot be deleted
|
|
45
|
-
* - New properties can be added, which then become immutable
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* const meta = createImmutableMetadata({ trusted: true, version: "1.0" });
|
|
49
|
-
* meta.author = "Alice"; // OK - new property
|
|
50
|
-
* meta.author = "Bob"; // FAIL - cannot modify after setting
|
|
51
|
-
* meta.trusted = false; // FAIL - cannot modify existing property
|
|
52
|
-
* delete meta.version; // FAIL - cannot delete properties
|
|
53
|
-
*/
|
|
54
|
-
export function createImmutableMetadata(initial?: object): object;
|
|
55
|
-
/**
|
|
56
|
-
* Removes metadata from all functions in an object tree.
|
|
57
|
-
*
|
|
58
|
-
* @function cleanMetadata
|
|
59
|
-
* @param {object|Function} obj - Object or function to clean
|
|
60
|
-
* @param {WeakSet} [visited] - Visited objects tracker to prevent infinite recursion
|
|
61
|
-
* @returns {void}
|
|
62
|
-
*
|
|
63
|
-
* @description
|
|
64
|
-
* Traverses an object/function tree and removes __metadata and __sourceFolder properties.
|
|
65
|
-
* This is needed when reloading CommonJS modules that cache function object references.
|
|
66
|
-
*/
|
|
67
|
-
export function cleanMetadata(obj: object | Function, visited?: WeakSet<any>): void;
|
|
68
|
-
/**
|
|
69
|
-
* Recursively tags all functions in an object tree with metadata.
|
|
70
|
-
*
|
|
71
|
-
* @function tagLoadedFunctions
|
|
72
|
-
* @param {object|Function} obj - Object or function to tag
|
|
73
|
-
* @param {object} metadata - Metadata object to attach
|
|
74
|
-
* @param {string} baseDir - Base directory path for relative file tracking
|
|
75
|
-
* @param {WeakSet} [visited] - Visited objects tracker to prevent infinite recursion
|
|
76
|
-
* @returns {void}
|
|
77
|
-
*
|
|
78
|
-
* @description
|
|
79
|
-
* Traverses an object/function tree and attaches immutable metadata to all functions.
|
|
80
|
-
* Also tracks source file information (__sourceFile, __sourceLine) for stack trace
|
|
81
|
-
* matching. Only tags functions that don't already have metadata (non-overwriting).
|
|
82
|
-
*
|
|
83
|
-
* Attached properties:
|
|
84
|
-
* - __metadata: Immutable metadata proxy with all user-provided metadata
|
|
85
|
-
* - __sourceFolder: Absolute path to the folder the module was loaded from
|
|
86
|
-
* - __sourceFile: Absolute file path (for stack trace matching)
|
|
87
|
-
* - __sourceLine: Line number where function is defined (for stack trace matching)
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* const modules = { math: { add: (a, b) => a + b } };
|
|
91
|
-
* tagLoadedFunctions(modules, {
|
|
92
|
-
* trusted: true,
|
|
93
|
-
* version: "1.0.0",
|
|
94
|
-
* author: "Alice"
|
|
95
|
-
* }, "/path/to/plugins");
|
|
96
|
-
* // Now modules.math.add.__metadata.trusted === true
|
|
97
|
-
*/
|
|
98
|
-
export function tagLoadedFunctions(obj: object | Function, metadata: object, baseDir: string, visited?: WeakSet<any>): void;
|
|
99
|
-
//# sourceMappingURL=metadata.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.mts","sourceRoot":"","sources":["../../../../../dist/lib/helpers/api_builder/metadata.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,kDApBW,MAAM,GACJ,MAAM,CAmJlB;AAED;;;;;;;;;;;GAWG;AACH,mCARW,MAAM,WAAS,2BAEb,IAAI,CAyChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wCA1BW,MAAM,WAAS,YACf,MAAM,WACN,MAAM,2BAEJ,IAAI,CA+EhB"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { addApiFromFolder } from "@cldmv/slothlet/helpers/api_builder/add_api";
|
|
2
|
-
export { isLikelySerializable, analyzeModule, processModuleFromAnalysis, analyzeDirectoryStructure, getCategoryBuildingDecisions } from "@cldmv/slothlet/helpers/api_builder/analysis";
|
|
3
|
-
export { getFlatteningDecision, applyFunctionNamePreference, processModuleForAPI, buildCategoryDecisions } from "@cldmv/slothlet/helpers/api_builder/decisions";
|
|
4
|
-
export { buildCategoryStructure, buildRootAPI, toapiPathKey, shouldIncludeFile } from "@cldmv/slothlet/helpers/api_builder/construction";
|
|
5
|
-
export { safeDefine, deepMerge, mutateLiveBindingFunction } from "@cldmv/slothlet/helpers/utilities";
|
|
6
|
-
//# sourceMappingURL=api_builder.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api_builder.d.mts","sourceRoot":"","sources":["../../../../dist/lib/helpers/api_builder.mjs"],"names":[],"mappings":""}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Project: @cldmv/slothlet
|
|
3
|
-
* @Filename: /src/lib/helpers/auto-wrap.mjs
|
|
4
|
-
* @Date: 2025-10-21 13:32:36 -07:00 (1761078756)
|
|
5
|
-
* @Author: Nate Hyson <CLDMV>
|
|
6
|
-
* @Email: <Shinrai@users.noreply.github.com>
|
|
7
|
-
* -----
|
|
8
|
-
* @Last modified by: Nate Hyson <CLDMV> (Shinrai@users.noreply.github.com)
|
|
9
|
-
* @Last modified time: 2025-10-22 06:59:17 -07:00 (1761141557)
|
|
10
|
-
* -----
|
|
11
|
-
* @Copyright: Copyright (c) 2013-2025 Catalyzed Motivation Inc. All rights reserved.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* @fileoverview Helper for automatically wrapping Node.js EventEmitter instances within API modules.
|
|
15
|
-
* Internal file (not exported in package.json).
|
|
16
|
-
* @module @cldmv/slothlet/src/lib/helpers/auto-wrap
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* Automatically wrap Node.js EventEmitter constructors when called within slothlet API context.
|
|
20
|
-
* This ensures that EventEmitter instances created inside API modules preserve AsyncLocalStorage context.
|
|
21
|
-
* @function autoWrapEventEmitters
|
|
22
|
-
* @package
|
|
23
|
-
* @param {NetModule} nodeModule - The Node.js module to wrap (e.g., require("node:net"))
|
|
24
|
-
* @returns {NetModule} Wrapped module with auto-wrapping constructors
|
|
25
|
-
*
|
|
26
|
-
* @description
|
|
27
|
-
* Wraps Node.js module functions that return EventEmitter instances so they automatically
|
|
28
|
-
* return wrapped instances when called within slothlet API context.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* // Usage in API modules:
|
|
32
|
-
* import { autoWrapEventEmitters } from "@cldmv/slothlet/src/lib/helpers/auto-wrap";
|
|
33
|
-
* import originalNet from "node:net";
|
|
34
|
-
* const net = autoWrapEventEmitters(originalNet);
|
|
35
|
-
* // Now net.createServer() returns wrapped instances automatically
|
|
36
|
-
*/
|
|
37
|
-
export function autoWrapEventEmitters(nodeModule: NetModule): NetModule;
|
|
38
|
-
/**
|
|
39
|
-
* Lazily get the pre-wrapped net module for convenient use in API modules.
|
|
40
|
-
* @function getNet
|
|
41
|
-
* @package
|
|
42
|
-
* @returns {Promise<NetModule>} Promise resolving to the wrapped net module
|
|
43
|
-
* @example
|
|
44
|
-
* const net = await getNet();
|
|
45
|
-
*/
|
|
46
|
-
export function getNet(): Promise<NetModule>;
|
|
47
|
-
export type NetModule = typeof import("node:net");
|
|
48
|
-
export type NetServer = import("node:net").Server;
|
|
49
|
-
//# sourceMappingURL=auto-wrap.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-wrap.d.mts","sourceRoot":"","sources":["../../../../dist/lib/helpers/auto-wrap.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,kDAdW,SAAS,GACP,SAAS,CA6CrB;AAED;;;;;;;GAOG;AACH,0BAJa,OAAO,CAAC,SAAS,CAAC,CAO9B;wBAGY,cAAc,UAAU,CAAC;wBACzB,OAAO,UAAU,EAAE,MAAM"}
|