@aooth/arbac-moost 0.1.73 → 0.1.75

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,8 +1,8 @@
1
- import { Mate, TClassConstructor, TMateParamMeta, TMoostMetadata } from "moost";
2
1
  import { ControlGate, TProjection, TProjectionChildren, TScopeFieldRules, TScopeFilter } from "@aooth/arbac";
3
- import { TDbRemoveGuardContext, TDbWriteAction, TDbWriteCheckContext, TDbWriteGuardContext, TMetaResponse } from "@atscript/db";
4
- import { AsDbController, TDbControlsType, TDbRequestContext } from "@atscript/moost-db";
5
- import { NavPropsOf, OwnPropsOf, TAtscriptAnnotatedType, TAtscriptDataType } from "@atscript/typescript/utils";
2
+ import { Mate, TClassConstructor, TMateParamMeta, TMoostMetadata } from "moost";
3
+ import { FilterExpr, TDbRemoveGuardContext, TDbWriteAction, TDbWriteCheckContext, TDbWriteGuardContext, TMetaResponse, UniqueryControls } from "@atscript/db";
4
+ import { AsDbController, TDbActionScopeContext, TDbControlsType, TDbRequestContext } from "@atscript/moost-db";
5
+ import { NavPropsOf, OwnPropsOf, TAtscriptAnnotatedType, TAtscriptDataType, TSerializedAnnotatedType } from "@atscript/typescript/utils";
6
6
  //#region src/arbac.mate.d.ts
7
7
  /**
8
8
  * ARBAC metadata fields attached to classes and methods by ARBAC decorators.
@@ -124,6 +124,7 @@ type ControlsOf<T> = IsUnknown<T> extends true ? Record<string, ControlGate> : {
124
124
  declare function applyAllowedFieldsAndSet(data: unknown, scopes: ArbacDbScope[], preserveFields?: readonly string[], isMergePatch?: (objectPath: string) => boolean): unknown;
125
125
  //#endregion
126
126
  //#region src/db/as-arbac-db-controller.d.ts
127
+ type TSelect = UniqueryControls["$select"];
127
128
  /**
128
129
  * Contract returned by an ARBAC role's scope predicate on a DB-backed resource.
129
130
  *
@@ -269,8 +270,20 @@ declare class AsArbacDbController<T extends TAtscriptAnnotatedType = TAtscriptAn
269
270
  * is resolved for the requested relations.
270
271
  */
271
272
  protected prepareRequest(ctx: TDbRequestContext): Promise<void>;
272
- protected transformFilter(filter: Record<string, unknown> | undefined): Record<string, unknown>;
273
- protected transformProjection(projection?: TProjection): TProjection | undefined;
273
+ /**
274
+ * The request filter ∧ the union of the scopes' `filter`s. Computed
275
+ * synchronously, but typed with moost-db's async-capable contract
276
+ * (`FilterExpr | Promise<FilterExpr>`) so a subclass may override it
277
+ * `async` — `await super.transformFilter(filter)` — and moost-db awaits it.
278
+ */
279
+ protected transformFilter(filter: Record<string, unknown> | undefined): FilterExpr | Promise<FilterExpr>;
280
+ /** A client relational predicate's operand ∧ the related rows the caller may see ({@link arbacRelationFilter}). Since 0.1.74. */
281
+ protected transformRelationFilter(path: string, filter: FilterExpr): FilterExpr | Promise<FilterExpr>;
282
+ /**
283
+ * `$select` restricted to the scopes' projection union. Synchronous, typed
284
+ * async-capable like {@link transformFilter}.
285
+ */
286
+ protected transformProjection(projection?: TSelect): TSelect | undefined | Promise<TSelect | undefined>;
274
287
  /**
275
288
  * Translate `@uniqu/url` parser failures into HTTP 400 instead of letting them
276
289
  * bubble as 500. The base `parseQueryString` calls `parseUrl()` directly with
@@ -301,6 +314,12 @@ declare class AsArbacDbController<T extends TAtscriptAnnotatedType = TAtscriptAn
301
314
  */
302
315
  protected validateControls(controls: Record<string, unknown>, type: TDbControlsType): string | undefined;
303
316
  protected applyMetaOverlay(meta: TMetaResponse): Promise<TMetaResponse>;
317
+ /**
318
+ * `GET /meta/form/:name` under the `/meta` overlay's pointer rule: a form
319
+ * prop's `ref` / `ui.valueHelp` binding to a table the caller cannot read
320
+ * (or whose named fields they cannot see) is stripped.
321
+ */
322
+ metaForm(name: string): Promise<TSerializedAnnotatedType>;
304
323
  /**
305
324
  * `GET /meta/form/:name` serves a form only when the caller may run at
306
325
  * least one of the actions taking it as input (else the unknown-form 404).
@@ -308,10 +327,22 @@ declare class AsArbacDbController<T extends TAtscriptAnnotatedType = TAtscriptAn
308
327
  protected authorizeForm(_name: string, actionNames: readonly string[]): Promise<boolean>;
309
328
  /**
310
329
  * The rows each `@DbAction` may run on: the caller's grant on that action
311
- * (see `arbacActionRowScope`). Enforced by the action gate and reflected
312
- * in `$actions` and `GET /meta/actions/:id`. Since 0.1.72.
330
+ * ({@link arbacActionRowScope} — several grants union, attenuation
331
+ * intersects). Enforced by the action gate and reflected in `$actions` and
332
+ * `GET /meta/actions/:id`. Since 0.1.72.
333
+ *
334
+ * The grant does not depend on `ctx` (the candidate rows, since 0.1.74).
335
+ * To bound an action further by the candidates, override and AND your
336
+ * filter onto `super`'s — it must never replace it:
337
+ *
338
+ * ```ts
339
+ * protected async actionRowScope(name: string, ctx: TDbActionScopeContext) {
340
+ * const grant = await super.actionRowScope(name, ctx);
341
+ * return conjoinScopeFilters(grant, await myCandidateScope(name, ctx));
342
+ * }
343
+ * ```
313
344
  */
314
- protected actionRowScope(name: string): Promise<Record<string, unknown> | undefined>;
345
+ protected actionRowScope(name: string, _ctx?: TDbActionScopeContext): Promise<Record<string, unknown> | undefined>;
315
346
  /**
316
347
  * The row-level actions `$actions` and `GET /meta/actions/:id` may list:
317
348
  * those the caller holds a grant on (the `/meta` overlay's rule, without
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aooth/arbac-moost",
3
- "version": "0.1.73",
3
+ "version": "0.1.75",
4
4
  "description": "Moost RBAC integration for aoothjs (migrated from @moostjs/arbac)",
5
5
  "keywords": [
6
6
  "abac",
@@ -60,31 +60,31 @@
60
60
  "access": "public"
61
61
  },
62
62
  "dependencies": {
63
- "@uniqu/core": "^0.1.11",
64
- "@aooth/arbac": "0.1.73",
65
- "@aooth/arbac-core": "0.1.73",
66
- "@aooth/user": "0.1.73"
63
+ "@uniqu/core": "^0.1.13",
64
+ "@aooth/arbac": "0.1.75",
65
+ "@aooth/user": "0.1.75",
66
+ "@aooth/arbac-core": "0.1.75"
67
67
  },
68
68
  "devDependencies": {
69
- "@atscript/core": "^0.1.98",
70
- "@atscript/db": "^0.1.146",
71
- "@atscript/db-sql-tools": "^0.1.146",
72
- "@atscript/db-sqlite": "^0.1.146",
73
- "@atscript/moost-db": "^0.1.146",
74
- "@atscript/typescript": "^0.1.98",
75
- "@moostjs/event-http": "^0.6.42",
69
+ "@atscript/core": "^0.1.100",
70
+ "@atscript/db": "^0.1.148",
71
+ "@atscript/db-sql-tools": "^0.1.148",
72
+ "@atscript/db-sqlite": "^0.1.148",
73
+ "@atscript/moost-db": "^0.1.148",
74
+ "@atscript/typescript": "^0.1.100",
75
+ "@moostjs/event-http": "^0.6.45",
76
76
  "@types/better-sqlite3": "^7.6.13",
77
77
  "better-sqlite3": "^12.6.2",
78
- "unplugin-atscript": "^0.1.98"
78
+ "unplugin-atscript": "^0.1.100"
79
79
  },
80
80
  "peerDependencies": {
81
- "@atscript/db": "^0.1.146",
82
- "@atscript/moost-db": "^0.1.146",
83
- "@atscript/typescript": "^0.1.98",
84
- "@moostjs/event-http": "^0.6.42",
85
- "@wooksjs/event-core": "^0.7.25",
86
- "@wooksjs/event-http": "^0.7.25",
87
- "moost": "^0.6.42"
81
+ "@atscript/db": "^0.1.148",
82
+ "@atscript/moost-db": "^0.1.148",
83
+ "@atscript/typescript": "^0.1.100",
84
+ "@moostjs/event-http": "^0.6.45",
85
+ "@wooksjs/event-core": "^0.7.26",
86
+ "@wooksjs/event-http": "^0.7.26",
87
+ "moost": "^0.6.45"
88
88
  },
89
89
  "peerDependenciesMeta": {
90
90
  "@atscript/db": {