@cldmv/slothlet 3.3.0 → 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.
- package/README.md +6 -8
- package/REFERENCE.md +23 -0
- package/dist/lib/builders/api-assignment.mjs +1 -589
- package/dist/lib/builders/api_builder.mjs +1 -1385
- package/dist/lib/builders/builder.mjs +1 -78
- package/dist/lib/builders/modes-processor.mjs +1 -1800
- package/dist/lib/errors.mjs +9 -211
- package/dist/lib/factories/component-base.mjs +1 -80
- package/dist/lib/factories/context.mjs +1 -22
- package/dist/lib/handlers/api-cache-manager.mjs +1 -200
- package/dist/lib/handlers/api-manager.mjs +1 -2536
- package/dist/lib/handlers/context-async.mjs +1 -172
- package/dist/lib/handlers/context-live.mjs +1 -173
- package/dist/lib/handlers/hook-manager.mjs +1 -667
- package/dist/lib/handlers/lifecycle-token.mjs +1 -28
- package/dist/lib/handlers/lifecycle.mjs +1 -115
- package/dist/lib/handlers/materialize-manager.mjs +1 -48
- package/dist/lib/handlers/metadata.mjs +1 -501
- package/dist/lib/handlers/ownership.mjs +1 -322
- package/dist/lib/handlers/permission-manager.mjs +1 -392
- package/dist/lib/handlers/unified-wrapper.mjs +1 -3110
- package/dist/lib/handlers/version-manager.mjs +1 -885
- package/dist/lib/helpers/class-instance-wrapper.mjs +1 -109
- package/dist/lib/helpers/config.mjs +1 -439
- package/dist/lib/helpers/eventemitter-context.mjs +1 -349
- package/dist/lib/helpers/hint-detector.mjs +1 -47
- package/dist/lib/helpers/modes-utils.mjs +1 -37
- package/dist/lib/helpers/pattern-matcher.mjs +1 -125
- package/dist/lib/helpers/resolve-from-caller.mjs +1 -169
- package/dist/lib/helpers/sanitize.mjs +1 -340
- package/dist/lib/helpers/utilities.mjs +1 -70
- package/dist/lib/i18n/translations.mjs +1 -126
- package/dist/lib/modes/eager.mjs +1 -59
- package/dist/lib/modes/lazy.mjs +1 -81
- package/dist/lib/processors/flatten.mjs +1 -437
- package/dist/lib/processors/loader.mjs +1 -339
- package/dist/lib/processors/type-generator.mjs +1 -275
- package/dist/lib/processors/typescript.mjs +1 -172
- package/dist/lib/runtime/runtime-asynclocalstorage.mjs +1 -113
- package/dist/lib/runtime/runtime-livebindings.mjs +1 -78
- package/dist/lib/runtime/runtime.mjs +1 -102
- package/dist/slothlet.mjs +1 -817
- package/package.json +34 -31
- package/types/dist/lib/builders/api-assignment.d.mts +3 -92
- package/types/dist/lib/builders/api-assignment.d.mts.map +1 -1
- package/types/dist/lib/builders/api_builder.d.mts +102 -91
- package/types/dist/lib/builders/api_builder.d.mts.map +1 -1
- package/types/dist/lib/builders/builder.d.mts +1 -55
- package/types/dist/lib/builders/builder.d.mts.map +1 -1
- package/types/dist/lib/builders/modes-processor.d.mts +3 -27
- package/types/dist/lib/builders/modes-processor.d.mts.map +1 -1
- package/types/dist/lib/errors.d.mts +19 -109
- package/types/dist/lib/errors.d.mts.map +1 -1
- package/types/dist/lib/factories/component-base.d.mts +7 -177
- package/types/dist/lib/factories/component-base.d.mts.map +1 -1
- package/types/dist/lib/factories/context.d.mts +4 -22
- package/types/dist/lib/factories/context.d.mts.map +1 -1
- package/types/dist/lib/handlers/api-cache-manager.d.mts +20 -203
- package/types/dist/lib/handlers/api-cache-manager.d.mts.map +1 -1
- package/types/dist/lib/handlers/api-manager.d.mts +33 -408
- package/types/dist/lib/handlers/api-manager.d.mts.map +1 -1
- package/types/dist/lib/handlers/context-async.d.mts +23 -61
- package/types/dist/lib/handlers/context-async.d.mts.map +1 -1
- package/types/dist/lib/handlers/context-live.d.mts +22 -59
- package/types/dist/lib/handlers/context-live.d.mts.map +1 -1
- package/types/dist/lib/handlers/hook-manager.d.mts +46 -185
- package/types/dist/lib/handlers/hook-manager.d.mts.map +1 -1
- package/types/dist/lib/handlers/lifecycle-token.d.mts +3 -48
- package/types/dist/lib/handlers/lifecycle-token.d.mts.map +1 -1
- package/types/dist/lib/handlers/lifecycle.d.mts +5 -82
- package/types/dist/lib/handlers/lifecycle.d.mts.map +1 -1
- package/types/dist/lib/handlers/materialize-manager.d.mts +8 -70
- package/types/dist/lib/handlers/materialize-manager.d.mts.map +1 -1
- package/types/dist/lib/handlers/metadata.d.mts +17 -221
- package/types/dist/lib/handlers/metadata.d.mts.map +1 -1
- package/types/dist/lib/handlers/ownership.d.mts +44 -160
- package/types/dist/lib/handlers/ownership.d.mts.map +1 -1
- package/types/dist/lib/handlers/permission-manager.d.mts +37 -141
- package/types/dist/lib/handlers/permission-manager.d.mts.map +1 -1
- package/types/dist/lib/handlers/unified-wrapper.d.mts +26 -239
- package/types/dist/lib/handlers/unified-wrapper.d.mts.map +1 -1
- package/types/dist/lib/handlers/version-manager.d.mts +28 -225
- package/types/dist/lib/handlers/version-manager.d.mts.map +1 -1
- package/types/dist/lib/helpers/class-instance-wrapper.d.mts +2 -52
- package/types/dist/lib/helpers/class-instance-wrapper.d.mts.map +1 -1
- package/types/dist/lib/helpers/config.d.mts +125 -139
- package/types/dist/lib/helpers/config.d.mts.map +1 -1
- package/types/dist/lib/helpers/eventemitter-context.d.mts +3 -29
- package/types/dist/lib/helpers/eventemitter-context.d.mts.map +1 -1
- package/types/dist/lib/helpers/hint-detector.d.mts +2 -15
- package/types/dist/lib/helpers/hint-detector.d.mts.map +1 -1
- package/types/dist/lib/helpers/modes-utils.d.mts +3 -30
- package/types/dist/lib/helpers/modes-utils.d.mts.map +1 -1
- package/types/dist/lib/helpers/pattern-matcher.d.mts +3 -43
- package/types/dist/lib/helpers/pattern-matcher.d.mts.map +1 -1
- package/types/dist/lib/helpers/resolve-from-caller.d.mts +3 -27
- package/types/dist/lib/helpers/resolve-from-caller.d.mts.map +1 -1
- package/types/dist/lib/helpers/sanitize.d.mts +4 -92
- package/types/dist/lib/helpers/sanitize.d.mts.map +1 -1
- package/types/dist/lib/helpers/utilities.d.mts +4 -52
- package/types/dist/lib/helpers/utilities.d.mts.map +1 -1
- package/types/dist/lib/i18n/translations.d.mts +4 -37
- package/types/dist/lib/i18n/translations.d.mts.map +1 -1
- package/types/dist/lib/modes/eager.d.mts +8 -30
- package/types/dist/lib/modes/eager.d.mts.map +1 -1
- package/types/dist/lib/modes/lazy.d.mts +10 -43
- package/types/dist/lib/modes/lazy.d.mts.map +1 -1
- package/types/dist/lib/processors/flatten.d.mts +56 -107
- package/types/dist/lib/processors/flatten.d.mts.map +1 -1
- package/types/dist/lib/processors/loader.d.mts +6 -41
- package/types/dist/lib/processors/loader.d.mts.map +1 -1
- package/types/dist/lib/processors/type-generator.d.mts +2 -16
- package/types/dist/lib/processors/type-generator.d.mts.map +1 -1
- package/types/dist/lib/processors/typescript.d.mts +6 -53
- package/types/dist/lib/processors/typescript.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts +3 -71
- package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime-livebindings.d.mts +2 -37
- package/types/dist/lib/runtime/runtime-livebindings.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime.d.mts +3 -39
- package/types/dist/lib/runtime/runtime.d.mts.map +1 -1
- package/types/dist/slothlet.d.mts +3 -249
- package/types/dist/slothlet.d.mts.map +1 -1
- package/types/index.d.mts +36 -16
- package/types/index.d.mts.map +1 -0
- package/AGENT-USAGE.md +0 -736
- package/docs/API-RULES.md +0 -712
|
@@ -1,38 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @type {Proxy}
|
|
4
|
-
* @public
|
|
5
|
-
*
|
|
6
|
-
* @description
|
|
7
|
-
* A proxy that provides direct access to the current instance's API.
|
|
8
|
-
* In live mode, this directly references the active instance without AsyncLocalStorage.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* import { self } from "@cldmv/slothlet/runtime/live";
|
|
12
|
-
*
|
|
13
|
-
* export function callOtherFunction() {
|
|
14
|
-
* return self.otherFunction();
|
|
15
|
-
* }
|
|
16
|
-
*/
|
|
17
|
-
export const self: ProxyConstructor;
|
|
18
|
-
/**
|
|
19
|
-
* User-provided context object
|
|
20
|
-
* @type {Proxy}
|
|
21
|
-
* @public
|
|
22
|
-
*
|
|
23
|
-
* @description
|
|
24
|
-
* A proxy that provides access to user-provided context data.
|
|
25
|
-
* In live mode, this directly accesses the current instance's context.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* import { context } from "@cldmv/slothlet/runtime/live";
|
|
29
|
-
*
|
|
30
|
-
* export function getUserInfo() {
|
|
31
|
-
* return {
|
|
32
|
-
* userId: context.userId,
|
|
33
|
-
* userName: context.userName
|
|
34
|
-
* };
|
|
35
|
-
* }
|
|
36
|
-
*/
|
|
37
|
-
export const context: ProxyConstructor;
|
|
1
|
+
export const context: {};
|
|
2
|
+
export const self: {};
|
|
38
3
|
//# sourceMappingURL=runtime-livebindings.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-livebindings.d.mts","sourceRoot":"","sources":["../../../../dist/lib/runtime/runtime-livebindings.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-livebindings.d.mts","sourceRoot":"","sources":["../../../../dist/lib/runtime/runtime-livebindings.mjs"],"names":[],"mappings":"AAAwuB,yBAA2tB;AAAt1C,sBAA2nB"}
|
|
@@ -1,40 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* @memberof module:@cldmv/slothlet/runtime
|
|
6
|
-
* @type {object}
|
|
7
|
-
* @example
|
|
8
|
-
* import { self } from "@cldmv/slothlet/runtime";
|
|
9
|
-
* // Inside an API function:
|
|
10
|
-
* const result = await self.math.add(1, 2);
|
|
11
|
-
*/
|
|
12
|
-
export const self: object;
|
|
13
|
-
/**
|
|
14
|
-
* The current ambient context object. Seeded at instance startup via `config.context` and
|
|
15
|
-
* persists for the lifetime of the instance. `api.slothlet.context.run()` and `.scope()` can
|
|
16
|
-
* temporarily override it for the duration of a single call, after which the previous context
|
|
17
|
-
* is restored. Readable and writable.
|
|
18
|
-
*
|
|
19
|
-
* @memberof module:@cldmv/slothlet/runtime
|
|
20
|
-
* @type {object}
|
|
21
|
-
* @example
|
|
22
|
-
* import { context } from "@cldmv/slothlet/runtime";
|
|
23
|
-
* // Read the ambient context set via config.context or written by a previous call:
|
|
24
|
-
* const userId = context.userId;
|
|
25
|
-
* // context.run() overrides it only for the duration of that one call:
|
|
26
|
-
* await api.slothlet.context.run({ userId: 42 }, myFn);
|
|
27
|
-
*/
|
|
28
|
-
export const context: object;
|
|
29
|
-
/**
|
|
30
|
-
* Current Slothlet instance identifier. Unique per `slothlet()` call; useful when
|
|
31
|
-
* multiple Slothlet instances coexist and you need to identify which one is active.
|
|
32
|
-
*
|
|
33
|
-
* @memberof module:@cldmv/slothlet/runtime
|
|
34
|
-
* @type {string}
|
|
35
|
-
* @example
|
|
36
|
-
* import { instanceID } from "@cldmv/slothlet/runtime";
|
|
37
|
-
* console.log(instanceID); // e.g. "slothlet-1"
|
|
38
|
-
*/
|
|
39
|
-
export const instanceID: string;
|
|
1
|
+
export const context: {};
|
|
2
|
+
export const instanceID: {};
|
|
3
|
+
export const self: {};
|
|
40
4
|
//# sourceMappingURL=runtime.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.mts","sourceRoot":"","sources":["../../../../dist/lib/runtime/runtime.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","sourceRoot":"","sources":["../../../../dist/lib/runtime/runtime.mjs"],"names":[],"mappings":"AAA02B,yBAA4e;AAAA,4BAAoP;AAA7pC,sBAA6b"}
|
|
@@ -1,250 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* API instance with its own component graph, context store, and lifecycle.
|
|
5
|
-
* @alias module:@cldmv/slothlet
|
|
6
|
-
* @async
|
|
7
|
-
* @param {SlothletOptions} config - Configuration options
|
|
8
|
-
* @returns {Promise<SlothletAPI>} Fully loaded, proxy-based API object
|
|
9
|
-
* @public
|
|
10
|
-
* @example
|
|
11
|
-
* // Minimal usage
|
|
12
|
-
* const api = await slothlet({ dir: "./api" });
|
|
13
|
-
* const result = await api.math.add(2, 3);
|
|
14
|
-
* await api.slothlet.shutdown();
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* // Lazy mode with background materialization
|
|
18
|
-
* const api = await slothlet({
|
|
19
|
-
* dir: "./api",
|
|
20
|
-
* mode: "lazy",
|
|
21
|
-
* backgroundMaterialize: true
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* // With hooks
|
|
26
|
-
* const api = await slothlet({ dir: "./api", hook: true });
|
|
27
|
-
* api.slothlet.hook.on("before", "**", (endpoint, args) => { /* ... *\/ });
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* // Hot-reload a module at runtime
|
|
31
|
-
* await api.slothlet.api.reload("./api/math.mjs");
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* // Strict collision control
|
|
35
|
-
* const api = await slothlet({
|
|
36
|
-
* dir: "./api",
|
|
37
|
-
* api: { collision: { initial: "merge", api: "error" } }
|
|
38
|
-
* });
|
|
39
|
-
*/
|
|
40
|
-
export function slothlet(config: SlothletOptions): Promise<SlothletAPI>;
|
|
41
|
-
export default slothlet;
|
|
42
|
-
/**
|
|
43
|
-
* Configuration options passed to `slothlet()`.
|
|
44
|
-
*/
|
|
45
|
-
export type SlothletOptions = {
|
|
46
|
-
/**
|
|
47
|
-
* - Directory to scan for API modules. Relative paths are resolved from the calling file.
|
|
48
|
-
*/
|
|
49
|
-
dir: string;
|
|
50
|
-
/**
|
|
51
|
-
* - Loading strategy.
|
|
52
|
-
* - `"eager"` — all modules are loaded immediately at startup (default).
|
|
53
|
-
* - `"lazy"` — modules are loaded on first access via a Proxy.
|
|
54
|
-
* Also accepted: `"immediate"` / `"preload"` (eager aliases); `"deferred"` / `"proxy"` (lazy aliases).
|
|
55
|
-
*/
|
|
56
|
-
mode?: "eager" | "lazy";
|
|
57
|
-
/**
|
|
58
|
-
* - Context propagation runtime.
|
|
59
|
-
* - `"async"` — AsyncLocalStorage (Node.js built-in, recommended for production).
|
|
60
|
-
* - `"live"` — Experimental live bindings.
|
|
61
|
-
* Also accepted: `"asynclocalstorage"` / `"als"` / `"node"` as aliases for `"async"`.
|
|
62
|
-
*/
|
|
63
|
-
runtime?: "async" | "live";
|
|
64
|
-
/**
|
|
65
|
-
* - Directory traversal depth. `Infinity` scans all subdirectories (default). `0` scans only the root.
|
|
66
|
-
*/
|
|
67
|
-
apiDepth?: number;
|
|
68
|
-
/**
|
|
69
|
-
* - Object merged into the per-request context accessible inside API functions via `import { context } from "@cldmv/slothlet/runtime"`.
|
|
70
|
-
*/
|
|
71
|
-
context?: object | null;
|
|
72
|
-
/**
|
|
73
|
-
* - Object whose properties are merged directly onto the root API and also available as `api.slothlet.reference`.
|
|
74
|
-
*/
|
|
75
|
-
reference?: object | null;
|
|
76
|
-
/**
|
|
77
|
-
* - Controls how per-request scope data is merged. `"shallow"` merges top-level keys; `"deep"` recurses into nested objects.
|
|
78
|
-
*/
|
|
79
|
-
scope?: {
|
|
80
|
-
merge: "shallow" | "deep";
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* - API build and mutation settings.
|
|
84
|
-
*/
|
|
85
|
-
api?: {
|
|
86
|
-
collision?: string | {
|
|
87
|
-
initial: string;
|
|
88
|
-
api: string;
|
|
89
|
-
};
|
|
90
|
-
mutations?: object;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* - Hook system configuration.
|
|
94
|
-
* - `false` — disabled (default).
|
|
95
|
-
* - `true` — enabled, all endpoints.
|
|
96
|
-
* - `string` — enabled with a default glob pattern.
|
|
97
|
-
* - `object` — full control: `{ enabled: boolean, pattern?: string, suppressErrors?: boolean }`.
|
|
98
|
-
*/
|
|
99
|
-
hook?: boolean | string | object;
|
|
100
|
-
/**
|
|
101
|
-
* - Enable verbose internal logging. `true` enables all categories.
|
|
102
|
-
* Pass an object with sub-keys `builder`, `api`, `index`, `modes`, `wrapper`, `ownership`, `context` to target specific subsystems.
|
|
103
|
-
*/
|
|
104
|
-
debug?: boolean | object;
|
|
105
|
-
/**
|
|
106
|
-
* - Suppress all console output from slothlet (warnings, deprecations). Does not affect `debug`.
|
|
107
|
-
*/
|
|
108
|
-
silent?: boolean;
|
|
109
|
-
/**
|
|
110
|
-
* - Enable the `api.slothlet.diag.*` introspection namespace. Intended for testing; do not enable in production.
|
|
111
|
-
*/
|
|
112
|
-
diagnostics?: boolean;
|
|
113
|
-
/**
|
|
114
|
-
* - Enable internal tracking. Pass `true` or `{ materialization: true }` to track lazy-mode materialization progress.
|
|
115
|
-
*/
|
|
116
|
-
tracking?: boolean | object;
|
|
117
|
-
/**
|
|
118
|
-
* - When `mode: "lazy"`, immediately begins materializing all paths in the background after init.
|
|
119
|
-
*/
|
|
120
|
-
backgroundMaterialize?: boolean;
|
|
121
|
-
/**
|
|
122
|
-
* - Internationalization settings (dev-facing, process-global).
|
|
123
|
-
* `{ language: string }` — selects the locale for framework messages (e.g. `"en-us"`, `"fr-fr"`, `"ja-jp"`).
|
|
124
|
-
*/
|
|
125
|
-
i18n?: object;
|
|
126
|
-
/**
|
|
127
|
-
* - Environment variable snapshot configuration.
|
|
128
|
-
* Pass `{ include: ["KEY"] }` to capture only the listed variable names in `api.slothlet.env`.
|
|
129
|
-
* Omit (or pass `undefined`) to capture a full frozen snapshot of `process.env`.
|
|
130
|
-
* Non-string entries in `include` are silently ignored; an all-non-string array falls back to the full snapshot.
|
|
131
|
-
*/
|
|
132
|
-
env?: {
|
|
133
|
-
include?: string[];
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* - TypeScript support.
|
|
137
|
-
* - `false` — disabled (default).
|
|
138
|
-
* - `true` or `"fast"` — esbuild transpilation, no type checking.
|
|
139
|
-
* - `"strict"` — tsc compilation with type checking and `.d.ts` generation.
|
|
140
|
-
* See [TYPESCRIPT.md](docs/TYPESCRIPT.md) for the full configuration reference.
|
|
141
|
-
*/
|
|
142
|
-
typescript?: boolean | "fast" | "strict" | object;
|
|
143
|
-
/**
|
|
144
|
-
* - Version routing discriminator for versioned API paths.
|
|
145
|
-
* - **string** (e.g. `"version"`) — at dispatch time, reads that key from the calling module's version metadata to select a version tag.
|
|
146
|
-
* - **function** — called as `(allVersions, caller) => versionTag | null`; return a registered version tag to force routing, or `null`/`undefined` to fall through to the automatic default.
|
|
147
|
-
* - **omitted / `undefined`** — behaves identically to `"version"`.
|
|
148
|
-
* Only relevant when modules are registered via `api.slothlet.api.add()` with a `versionConfig` argument.
|
|
149
|
-
*/
|
|
150
|
-
versionDispatcher?: string | Function | null;
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* Bound API object returned by `slothlet()`.
|
|
154
|
-
* The root contains all loaded module exports plus the reserved `slothlet` namespace.
|
|
155
|
-
*/
|
|
156
|
-
export type SlothletAPI = {
|
|
157
|
-
/**
|
|
158
|
-
* - Like `shutdown()` but additionally invokes registered destroy hooks before teardown. %%sig: (): void%% %%example: // ESM usage via slothlet API|import slothlet from "@cldmv/slothlet";|const api = await slothlet({ dir: './api' });|await api.destroy();%% %%example: // ESM usage via slothlet API (inside async function)|async function example() {| const { default: slothlet } = await import("@cldmv/slothlet");| const api = await slothlet({ dir: './api' });| await api.destroy();|}%% %%example: // CJS usage via slothlet API (top-level)|let slothlet;|(async () => {| ({ slothlet } = await import("@cldmv/slothlet"));| const api = await slothlet({ dir: './api' });| await api.destroy();|})();%% %%example: // CJS usage via slothlet API (inside async function)|const slothlet = require("@cldmv/slothlet");|const api = await slothlet({ dir: './api' });|await api.destroy();%%
|
|
159
|
-
*/
|
|
160
|
-
destroy: () => void;
|
|
161
|
-
/**
|
|
162
|
-
* - Convenience alias for `slothlet.shutdown()`. Shuts down the instance and invokes any user-provided shutdown hook first. %%sig: (): void%% %%example: // ESM usage via slothlet API|import slothlet from "@cldmv/slothlet";|const api = await slothlet({ dir: './api' });|await api.shutdown();%% %%example: // ESM usage via slothlet API (inside async function)|async function example() {| const { default: slothlet } = await import("@cldmv/slothlet");| const api = await slothlet({ dir: './api' });| await api.shutdown();|}%% %%example: // CJS usage via slothlet API (top-level)|let slothlet;|(async () => {| ({ slothlet } = await import("@cldmv/slothlet"));| const api = await slothlet({ dir: './api' });| await api.shutdown();|})();%% %%example: // CJS usage via slothlet API (inside async function)|const slothlet = require("@cldmv/slothlet");|const api = await slothlet({ dir: './api' });|await api.shutdown();%%
|
|
163
|
-
*/
|
|
164
|
-
shutdown: () => void;
|
|
165
|
-
/**
|
|
166
|
-
* - Built-in control namespace. All framework internals live here to avoid collisions with loaded modules.
|
|
167
|
-
*/
|
|
168
|
-
slothlet: {
|
|
169
|
-
env: Readonly<Record<string, string | undefined>>;
|
|
170
|
-
api: {
|
|
171
|
-
add: Function;
|
|
172
|
-
reload: Function;
|
|
173
|
-
remove: Function;
|
|
174
|
-
};
|
|
175
|
-
context: {
|
|
176
|
-
get: Function;
|
|
177
|
-
inspect: () => any;
|
|
178
|
-
run: Function;
|
|
179
|
-
scope: Function;
|
|
180
|
-
set: Function;
|
|
181
|
-
};
|
|
182
|
-
diag?: {
|
|
183
|
-
caches?: {
|
|
184
|
-
get?: () => any;
|
|
185
|
-
getAllModuleIDs?: () => string[];
|
|
186
|
-
has?: Function;
|
|
187
|
-
};
|
|
188
|
-
context?: object;
|
|
189
|
-
describe?: Function;
|
|
190
|
-
getAPI?: () => any;
|
|
191
|
-
getOwnership?: () => any;
|
|
192
|
-
hook?: object;
|
|
193
|
-
inspect?: () => any;
|
|
194
|
-
owner?: {
|
|
195
|
-
get?: Function;
|
|
196
|
-
};
|
|
197
|
-
reference?: object;
|
|
198
|
-
SlothletWarning?: () => SlothletWarning;
|
|
199
|
-
};
|
|
200
|
-
hook: {
|
|
201
|
-
clear: Function;
|
|
202
|
-
disable: Function;
|
|
203
|
-
enable: Function;
|
|
204
|
-
list: Function;
|
|
205
|
-
off: Function;
|
|
206
|
-
on: Function;
|
|
207
|
-
remove: Function;
|
|
208
|
-
};
|
|
209
|
-
lifecycle: {
|
|
210
|
-
off: Function;
|
|
211
|
-
on: Function;
|
|
212
|
-
};
|
|
213
|
-
materialize: {
|
|
214
|
-
get: () => any;
|
|
215
|
-
materialized: boolean;
|
|
216
|
-
wait: () => Promise<void>;
|
|
217
|
-
};
|
|
218
|
-
metadata: {
|
|
219
|
-
caller: () => any | null;
|
|
220
|
-
get: Function;
|
|
221
|
-
remove: Function;
|
|
222
|
-
removeFor: Function;
|
|
223
|
-
self: () => any | null;
|
|
224
|
-
set: Function;
|
|
225
|
-
setFor: Function;
|
|
226
|
-
setGlobal: Function;
|
|
227
|
-
};
|
|
228
|
-
owner: {
|
|
229
|
-
get: Function;
|
|
230
|
-
};
|
|
231
|
-
ownership: {
|
|
232
|
-
get: Function;
|
|
233
|
-
unregister: Function;
|
|
234
|
-
};
|
|
235
|
-
versioning: {
|
|
236
|
-
list: Function;
|
|
237
|
-
setDefault: Function;
|
|
238
|
-
unregister: Function;
|
|
239
|
-
getVersionMetadata: Function;
|
|
240
|
-
setVersionMetadata: Function;
|
|
241
|
-
};
|
|
242
|
-
reference?: object;
|
|
243
|
-
reload: Function;
|
|
244
|
-
run: Function;
|
|
245
|
-
scope: Function;
|
|
246
|
-
shutdown: () => Promise<void>;
|
|
247
|
-
};
|
|
248
|
-
};
|
|
249
|
-
import { SlothletWarning } from "@cldmv/slothlet/errors";
|
|
1
|
+
declare function stdin_default(config: any): Promise<{}>;
|
|
2
|
+
export function slothlet(config: any): Promise<{}>;
|
|
3
|
+
export { stdin_default as default };
|
|
250
4
|
//# sourceMappingURL=slothlet.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slothlet.d.mts","sourceRoot":"","sources":["../../dist/slothlet.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slothlet.d.mts","sourceRoot":"","sources":["../../dist/slothlet.mjs"],"names":[],"mappings":"AAAwga,yDAA6G;AAA7G,mDAA6G"}
|
package/types/index.d.mts
CHANGED
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Creates a slothlet API instance with live-binding context and AsyncLocalStorage support.
|
|
3
|
+
* Automatically wraps all API functions with context isolation for multi-instance support.
|
|
4
|
+
* @public
|
|
5
|
+
* @async
|
|
6
|
+
*
|
|
7
|
+
* @param {object} [options={}] - Configuration options for the slothlet instance
|
|
8
|
+
* @param {string} [options.dir="api"] - Directory to load API modules from
|
|
9
|
+
* @param {boolean} [options.lazy=false] - Use lazy loading (true) or eager loading (false) - legacy option
|
|
10
|
+
* @param {string} [options.mode] - Loading mode ("lazy", "eager") or execution mode ("singleton", "vm", "worker", "fork") - takes precedence over lazy option
|
|
11
|
+
* @param {string} [options.engine="singleton"] - Execution mode (singleton, vm, worker, fork)
|
|
12
|
+
* @param {number} [options.apiDepth=Infinity] - Maximum directory depth to scan
|
|
13
|
+
* @param {boolean} [options.debug=false] - Enable debug logging
|
|
14
|
+
* @param {string} [options.api_mode="auto"] - API structure mode (auto, function, object)
|
|
15
|
+
* @param {boolean} [options.allowApiOverwrite=true] - Allow addApi to overwrite existing API endpoints
|
|
16
|
+
* @param {object} [options.context={}] - Context data for live bindings
|
|
17
|
+
* @param {object} [options.reference={}] - Reference objects to merge into API root
|
|
18
|
+
* @returns {Promise<import("./src/slothlet.mjs").SlothletAPI>} The bound API object with management methods
|
|
19
|
+
*
|
|
20
|
+
* @example // ESM
|
|
21
|
+
* import slothlet from "@cldmv/slothlet";
|
|
22
|
+
* const api = await slothlet({ dir: './api', lazy: true });
|
|
23
|
+
* const result = await api.math.add(2, 3); // 5
|
|
24
|
+
*
|
|
6
25
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
export default function slothlet(options?: {
|
|
27
|
+
dir?: string | undefined;
|
|
28
|
+
lazy?: boolean | undefined;
|
|
29
|
+
mode?: string | undefined;
|
|
30
|
+
engine?: string | undefined;
|
|
31
|
+
apiDepth?: number | undefined;
|
|
32
|
+
debug?: boolean | undefined;
|
|
33
|
+
api_mode?: string | undefined;
|
|
34
|
+
allowApiOverwrite?: boolean | undefined;
|
|
35
|
+
context?: object | undefined;
|
|
36
|
+
reference?: object | undefined;
|
|
37
|
+
}): Promise<import("./src/slothlet.mjs").SlothletAPI>;
|
|
19
38
|
export { slothlet };
|
|
39
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../index.mjs"],"names":[],"mappings":"AA+FA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,2CAlBG;IAAyB,GAAG;IACF,IAAI;IACL,IAAI;IACJ,MAAM;IACN,QAAQ;IACP,KAAK;IACN,QAAQ;IACP,iBAAiB;IAClB,OAAO;IACP,SAAS;CAClC,GAAU,OAAO,CAAC,OAAO,oBAAoB,EAAE,WAAW,CAAC,CAkB7D"}
|