@cldmv/slothlet-types 3.19.0 → 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.
@@ -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.19.0",
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.19.0"
82
+ "@cldmv/slothlet": "3.20.0"
83
83
  },
84
84
  "peerDependenciesMeta": {
85
85
  "@cldmv/slothlet": {