@cldmv/slothlet-types 3.18.2 → 3.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -171,5 +171,48 @@ export class ComponentBase {
|
|
|
171
171
|
moduleID?: string | undefined;
|
|
172
172
|
error?: Error | undefined;
|
|
173
173
|
}): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Emit the public `impl:collision` lifecycle event (#441).
|
|
176
|
+
* @param {object} data - Collision payload (every field is passed explicitly by the call site).
|
|
177
|
+
* @param {string} data.apiPath - Dot-notation api path where the collision resolved.
|
|
178
|
+
* @param {"dropped"|"replaced"|"merged"|"stacked"} data.resolution - What became of the two
|
|
179
|
+
* writers: `dropped` (incoming discarded, `owner` retained), `replaced` (incoming won, `owner`
|
|
180
|
+
* shadowed), `merged` (namespace nodes combined, both retained), `stacked` (both run as a
|
|
181
|
+
* routine stack under `stackRoutines`).
|
|
182
|
+
* @param {string|null} data.incoming - moduleID of the arriving writer (`null` when unknown).
|
|
183
|
+
* @param {string|null} data.owner - moduleID of the writer that already held the path (`null`
|
|
184
|
+
* when unknown).
|
|
185
|
+
* @param {"value"|"namespace"} data.kind - Whether the colliding contribution is a value leaf
|
|
186
|
+
* or a namespace node.
|
|
187
|
+
* @param {string|null} data.collisionMode - The mode that resolved it (`skip`/`warn`/`replace`/
|
|
188
|
+
* `merge`/`merge-replace`), or `null` where a mode is not meaningful (e.g. `stacked`).
|
|
189
|
+
* @returns {void}
|
|
190
|
+
* @package
|
|
191
|
+
*
|
|
192
|
+
* @description
|
|
193
|
+
* Unlike `impl:created` — which fires post-placement for the path WINNER only, so a leaf a merge
|
|
194
|
+
* discards is never announced — `impl:collision` fires for the collision itself and carries BOTH
|
|
195
|
+
* writers, so a consumer can observe a silently dropped or shadowed leaf regardless of nesting.
|
|
196
|
+
*
|
|
197
|
+
* Fire-and-forget by design: `emit()` isolates each handler's errors and never rejects (mirroring
|
|
198
|
+
* the `impl:created` re-emit in `src/slothlet.mjs`), so a collision-decision site can announce the
|
|
199
|
+
* event without awaiting subscriber code inline and without any unhandled rejection escaping.
|
|
200
|
+
* Synchronous subscribers still run during this call (before `emit()` yields), so an observer that
|
|
201
|
+
* collects events sees them by the time the composing `await` resolves.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* this.emitImplCollision({
|
|
205
|
+
* apiPath: "shared.alpha", resolution: "dropped", incoming: "pkgB_x", owner: "pkgA_y",
|
|
206
|
+
* kind: "value", collisionMode: "merge"
|
|
207
|
+
* });
|
|
208
|
+
*/
|
|
209
|
+
emitImplCollision({ apiPath, resolution, incoming, owner, kind, collisionMode }: {
|
|
210
|
+
apiPath: string;
|
|
211
|
+
resolution: "dropped" | "replaced" | "merged" | "stacked";
|
|
212
|
+
incoming: string | null;
|
|
213
|
+
owner: string | null;
|
|
214
|
+
kind: "value" | "namespace";
|
|
215
|
+
collisionMode: string | null;
|
|
216
|
+
}): void;
|
|
174
217
|
#private;
|
|
175
218
|
}
|
|
@@ -19,7 +19,7 @@ export class Lifecycle extends ComponentBase {
|
|
|
19
19
|
maxLogSize: number;
|
|
20
20
|
/**
|
|
21
21
|
* Subscribe to lifecycle event
|
|
22
|
-
* @param {string} event - Event name (impl:created, impl:changed, impl:removed, materialized:complete
|
|
22
|
+
* @param {string} event - Event name (impl:created, impl:changed, impl:collision, impl:removed, materialized:complete)
|
|
23
23
|
* @param {Function} handler - Event handler function(eventData)
|
|
24
24
|
* @returns {Function} Unsubscribe function
|
|
25
25
|
* @public
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call/construct metadata threaded into a function condition's second argument so a rule can
|
|
3
|
+
* authorize on the resource named in the call itself, not just ambient context (#455).
|
|
4
|
+
*
|
|
5
|
+
* Provided only at the call and construct enforcement gates — where the invocation's arguments
|
|
6
|
+
* exist. Read gating, hook gating, event delivery, the internal `slothlet.*` control surface, and
|
|
7
|
+
* silent queries evaluate conditions with `callMeta === null`, so a function condition that reads
|
|
8
|
+
* `callMeta.args` must guard for its absence (or the rule must only match targets that always gate
|
|
9
|
+
* at a call/construct site).
|
|
10
|
+
*
|
|
11
|
+
* @typedef {object} PermissionCallMeta
|
|
12
|
+
* @property {Array<*>|null} args - Arguments the target leaf was called/constructed with, or null.
|
|
13
|
+
* @property {string|null} target - Concrete (post-glob) target api path of the gated call.
|
|
14
|
+
*/
|
|
1
15
|
/**
|
|
2
16
|
* Manages access control rules for API path invocations.
|
|
3
17
|
* Rules are glob-pattern-based (same syntax as hooks: *, **, ?, {a,b}, !negation).
|
|
@@ -151,13 +165,16 @@ export class PermissionManager extends ComponentBase {
|
|
|
151
165
|
* @param {string|null} [callerFilePath=null] - Caller's source file path (for self-call bypass).
|
|
152
166
|
* @param {string|null} [targetFilePath=null] - Target's source file path (for self-call bypass).
|
|
153
167
|
* @param {object|null} [runtimeContext=null] - Per-request ALS context for condition evaluation.
|
|
168
|
+
* @param {PermissionCallMeta|null} [callMeta=null] - Call/construct metadata (#455): `{ args, target }`
|
|
169
|
+
* from the invocation, forwarded to function conditions as their second argument. Null for reads,
|
|
170
|
+
* hooks, the internal control surface, and silent queries.
|
|
154
171
|
* @returns {boolean} True if access is allowed.
|
|
155
172
|
* @example
|
|
156
173
|
* if (!pm.enforceAccess("payments.charge", "db.write", "/src/pay.mjs", "/src/db.mjs")) {
|
|
157
174
|
* throw new SlothletError("PERMISSION_DENIED", { caller, target });
|
|
158
175
|
* }
|
|
159
176
|
*/
|
|
160
|
-
enforceAccess(callerPath: string, targetPath: string, callerFilePath?: string | null, targetFilePath?: string | null, runtimeContext?: object | null): boolean;
|
|
177
|
+
enforceAccess(callerPath: string, targetPath: string, callerFilePath?: string | null, targetFilePath?: string | null, runtimeContext?: object | null, callMeta?: PermissionCallMeta | null): boolean;
|
|
161
178
|
/**
|
|
162
179
|
* Enforce whether a caller may register or fire a hook of `hookType` on `hookPath`.
|
|
163
180
|
*
|
|
@@ -352,4 +369,24 @@ export class PermissionManager extends ComponentBase {
|
|
|
352
369
|
private debug;
|
|
353
370
|
#private;
|
|
354
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* Call/construct metadata threaded into a function condition's second argument so a rule can
|
|
374
|
+
* authorize on the resource named in the call itself, not just ambient context (#455).
|
|
375
|
+
*
|
|
376
|
+
* Provided only at the call and construct enforcement gates — where the invocation's arguments
|
|
377
|
+
* exist. Read gating, hook gating, event delivery, the internal `slothlet.*` control surface, and
|
|
378
|
+
* silent queries evaluate conditions with `callMeta === null`, so a function condition that reads
|
|
379
|
+
* `callMeta.args` must guard for its absence (or the rule must only match targets that always gate
|
|
380
|
+
* at a call/construct site).
|
|
381
|
+
*/
|
|
382
|
+
export type PermissionCallMeta = {
|
|
383
|
+
/**
|
|
384
|
+
* - Arguments the target leaf was called/constructed with, or null.
|
|
385
|
+
*/
|
|
386
|
+
args: Array<any> | null;
|
|
387
|
+
/**
|
|
388
|
+
* - Concrete (post-glob) target api path of the gated call.
|
|
389
|
+
*/
|
|
390
|
+
target: string | null;
|
|
391
|
+
};
|
|
355
392
|
import { ComponentBase } from "#factories/component-base";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cldmv/slothlet-types",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.0",
|
|
4
4
|
"description": "TypeScript declaration files (.d.mts) for @cldmv/slothlet. Install alongside @cldmv/slothlet for editor and type-checker support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"slothlet",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"LICENSE"
|
|
80
80
|
],
|
|
81
81
|
"peerDependencies": {
|
|
82
|
-
"@cldmv/slothlet": "3.
|
|
82
|
+
"@cldmv/slothlet": "3.20.0"
|
|
83
83
|
},
|
|
84
84
|
"peerDependenciesMeta": {
|
|
85
85
|
"@cldmv/slothlet": {
|