@aooth/arbac-moost 0.1.58 → 0.1.59

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,7 +1,6 @@
1
- import { r as AoothArbacClaims, t as ArbacUserProvider } from "../user.provider-BFHjF2vD.mjs";
1
+ import { r as AoothArbacClaims, t as ArbacUserProvider } from "../user.provider-abwC0SjM.mjs";
2
2
  import { TAtscriptAnnotatedType, TAtscriptTypeObject, TMetadataMap, TValidatorOptions, Validator } from "@atscript/typescript/utils";
3
3
  import { AoothUserCredentials } from "@aooth/user/atscript-db/model.as";
4
-
5
4
  //#region src/atscript/auto-provider.d.ts
6
5
  /**
7
6
  * Minimal atscript-db readable surface used to fetch the user record.
@@ -234,5 +233,6 @@ declare class AoothArbacUserCredentials extends AoothUserCredentials {
234
233
  /** @deprecated Example Data support is disabled. To enable, set `exampleData: true` in tsPlugin options. */
235
234
  static toExampleData?: () => any;
236
235
  }
236
+ // prettier-ignore-end
237
237
  //#endregion
238
238
  export { AoothArbacUserCredentials, type AoothCredentialMetadataSpec, type AoothUserHandleSpec, type ArbacAttenuationSpec, type ArbacUserTable, AtscriptArbacUserProvider, extractAttenuation, getAoothCredentialMetadataSpec, getAoothUserHandleSpec, getArbacAttenuationSpec, validateAttenuationTargets };
@@ -1,4 +1,4 @@
1
- import { r as __decorate, t as ArbacUserProvider } from "../user.provider-BiM5P8fl.mjs";
1
+ import { r as __decorate, t as ArbacUserProvider } from "../user.provider-CYiwr7y3.mjs";
2
2
  import { defineWook, key } from "@wooksjs/event-core";
3
3
  import { Injectable } from "moost";
4
4
  import { defineAnnotatedType, throwFeatureDisabled } from "@atscript/typescript/utils";
@@ -22,7 +22,7 @@ function uniqueStrings(values) {
22
22
  return out;
23
23
  }
24
24
  //#endregion
25
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateMetadata.js
25
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateMetadata.js
26
26
  function __decorateMetadata(k, v) {
27
27
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
28
28
  }
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as ArbacDbScope, c as enforceControlsPolicy, d as NavRelationKey, f as NavTarget, i as conjoinArbacDbScopes, l as extractUsedControlValues, m as ProjectionOf, n as ArbacUserProviderToken, o as AsArbacDbController, p as OwnFieldKey, r as AoothArbacClaims, s as applyAllowedFieldsAndSet, t as ArbacUserProvider, u as ControlsOf } from "./user.provider-BFHjF2vD.mjs";
1
+ import { a as ArbacDbScope, c as enforceControlsPolicy, d as NavRelationKey, f as NavTarget, i as conjoinArbacDbScopes, l as extractUsedControlValues, m as ProjectionOf, n as ArbacUserProviderToken, o as AsArbacDbController, p as OwnFieldKey, r as AoothArbacClaims, s as applyAllowedFieldsAndSet, t as ArbacUserProvider, u as ControlsOf } from "./user.provider-abwC0SjM.mjs";
2
2
  import { Arbac, Arbac as Arbac$1, TArbacCompiledRule, TArbacEvalResult, TArbacRole, TArbacRoleForResource, TArbacRule, arbacPatternToRegex } from "@aooth/arbac-core";
3
3
  import { TAuthGuardDef } from "@moostjs/event-http";
4
4
  import { EventContext } from "@wooksjs/event-core";
@@ -7,7 +7,6 @@ import { ControlGate, TProjection } from "@aooth/arbac";
7
7
  import { AsDbReadableController } from "@atscript/moost-db";
8
8
  import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
9
9
  import { TMetaResponse } from "@atscript/db";
10
-
11
10
  //#region src/arbac.composables.d.ts
12
11
  interface ArbacBindings {
13
12
  getScopes: <TScope extends object>() => TScope[] | undefined;
@@ -248,6 +247,19 @@ declare function metaAlwaysVisibleFields(controller: object, source: {
248
247
  * addressing).
249
248
  */
250
249
  declare function applyArbacMetaOverlay(meta: TMetaResponse, alwaysVisible: ReadonlySet<string>): Promise<TMetaResponse>;
250
+ /**
251
+ * Test-friendly internal helper — exported for unit tests and helper
252
+ * composition; regular consumers should not call this directly.
253
+ *
254
+ * Method names of an instance, walking the full prototype chain via property
255
+ * DESCRIPTORS. Deliberately NOT moost's `getInstanceOwnMethods`: that helper
256
+ * evaluates `instance[name]` for every property to test "is it a function",
257
+ * which fires accessors — and moost-db's inherited `.table` getter THROWS for
258
+ * view-bound controllers, turning every `/meta` request into a 500. Accessor
259
+ * properties are skipped entirely (a getter-valued property is not a method
260
+ * and can never carry `@DbAction` metadata).
261
+ */
262
+ declare function collectMethodNames(instance: object): string[];
251
263
  //#endregion
252
264
  //#region src/moost-arbac.d.ts
253
265
  /**
@@ -263,4 +275,4 @@ declare function applyArbacMetaOverlay(meta: TMetaResponse, alwaysVisible: Reado
263
275
  */
264
276
  declare class MoostArbac<TUserAttrs extends object, TScope extends object> extends Arbac$1<TUserAttrs, TScope> {}
265
277
  //#endregion
266
- export { type AoothArbacClaims, Arbac, ArbacAction, ArbacAuthorize, ArbacDbScope, ArbacResource, ArbacUserProvider, ArbacUserProviderToken, AsArbacDbController, AsArbacDbReadableController, type ControlGate, type ControlsOf, MetaVisibility, MoostArbac, type NavRelationKey, type NavTarget, type OwnFieldKey, type ProjectionOf, type TArbacCompiledRule, type TArbacEvalResult, TArbacMeta, type TArbacRole, type TArbacRoleForResource, type TArbacRule, applyAllowedFieldsAndSet, applyArbacMetaOverlay, arbacAuthorizeInterceptor, arbacPatternToRegex, collectWithGrantNames, collectWritableFields, conjoinArbacDbScopes, enforceControlsPolicy, extractUsedControlValues, getArbacMate, isMetaFieldVisible, isScopedFieldVisible, metaAlwaysVisibleFields, pruneMetaByVisibility, unionScopeProjection, useArbac };
278
+ export { type AoothArbacClaims, Arbac, ArbacAction, ArbacAuthorize, ArbacDbScope, ArbacResource, ArbacUserProvider, ArbacUserProviderToken, AsArbacDbController, AsArbacDbReadableController, type ControlGate, type ControlsOf, MetaVisibility, MoostArbac, type NavRelationKey, type NavTarget, type OwnFieldKey, type ProjectionOf, type TArbacCompiledRule, type TArbacEvalResult, TArbacMeta, type TArbacRole, type TArbacRoleForResource, type TArbacRule, applyAllowedFieldsAndSet, applyArbacMetaOverlay, arbacAuthorizeInterceptor, arbacPatternToRegex, collectMethodNames, collectWithGrantNames, collectWritableFields, conjoinArbacDbScopes, enforceControlsPolicy, extractUsedControlValues, getArbacMate, isMetaFieldVisible, isScopedFieldVisible, metaAlwaysVisibleFields, pruneMetaByVisibility, unionScopeProjection, useArbac };
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { n as ArbacUserProviderToken, r as __decorate, t as ArbacUserProvider } from "./user.provider-BiM5P8fl.mjs";
1
+ import { n as ArbacUserProviderToken, r as __decorate, t as ArbacUserProvider } from "./user.provider-CYiwr7y3.mjs";
2
2
  import { Arbac, Arbac as Arbac$1, arbacPatternToRegex } from "@aooth/arbac-core";
3
3
  import { Authenticate, HttpError } from "@moostjs/event-http";
4
4
  import { current, key } from "@wooksjs/event-core";
5
- import { Inherit, Injectable, TInterceptorPriority, defineBeforeInterceptor, getConstructor, getInstanceOwnMethods, getMoostMate, useControllerContext, useLogger } from "moost";
5
+ import { Inherit, Injectable, TInterceptorPriority, defineBeforeInterceptor, getConstructor, getMoostMate, useControllerContext, useLogger } from "moost";
6
6
  import { conjoinScopeFilters, intersectControlsPolicy, isFieldAllowed, mergeScopeFilters, restrictProjection, unionControlsPolicy, unionProjections } from "@aooth/arbac";
7
7
  import { AsDbController, AsDbReadableController } from "@atscript/moost-db";
8
8
  //#region src/attenuation.ts
@@ -436,7 +436,7 @@ function metaAlwaysVisibleFields(controller, source) {
436
436
  const ctor = controller.constructor;
437
437
  let set = alwaysVisibleFieldsCache.get(ctor);
438
438
  if (!set) {
439
- set = new Set([...source.primaryKeys, ...source.preferredId]);
439
+ set = /* @__PURE__ */ new Set([...source.primaryKeys, ...source.preferredId]);
440
440
  alwaysVisibleFieldsCache.set(ctor, set);
441
441
  }
442
442
  return set;
@@ -448,7 +448,7 @@ function metaAlwaysVisibleFields(controller, source) {
448
448
  * fails closed (a principal whose only read grant is the new op still gets
449
449
  * a pruned envelope rather than the full field map).
450
450
  */
451
- const WRITE_CRUD_OPS = new Set([
451
+ const WRITE_CRUD_OPS = /* @__PURE__ */ new Set([
452
452
  "insert",
453
453
  "update",
454
454
  "replace",
@@ -528,8 +528,7 @@ function collectActionMetaByName() {
528
528
  const map = /* @__PURE__ */ new Map();
529
529
  const ctrlMeta = cc.getControllerMeta();
530
530
  for (const entry of ctrlMeta?.atscript_db_actions ?? []) map.set(entry.name, {});
531
- for (const methodName of getInstanceOwnMethods(instance)) {
532
- if (typeof methodName !== "string") continue;
531
+ for (const methodName of collectMethodNames(instance)) {
533
532
  const m = cc.getMethodMeta(methodName);
534
533
  if (!m) continue;
535
534
  const actionMeta = m.atscript_db_action;
@@ -541,6 +540,31 @@ function collectActionMetaByName() {
541
540
  actionMetaByClassCache.set(ctor, map);
542
541
  return map;
543
542
  }
543
+ /**
544
+ * Test-friendly internal helper — exported for unit tests and helper
545
+ * composition; regular consumers should not call this directly.
546
+ *
547
+ * Method names of an instance, walking the full prototype chain via property
548
+ * DESCRIPTORS. Deliberately NOT moost's `getInstanceOwnMethods`: that helper
549
+ * evaluates `instance[name]` for every property to test "is it a function",
550
+ * which fires accessors — and moost-db's inherited `.table` getter THROWS for
551
+ * view-bound controllers, turning every `/meta` request into a 500. Accessor
552
+ * properties are skipped entirely (a getter-valued property is not a method
553
+ * and can never carry `@DbAction` metadata).
554
+ */
555
+ function collectMethodNames(instance) {
556
+ const names = /* @__PURE__ */ new Set();
557
+ let obj = instance;
558
+ while (obj && obj !== Object.prototype) {
559
+ for (const name of Object.getOwnPropertyNames(obj)) {
560
+ if (name === "constructor") continue;
561
+ const desc = Object.getOwnPropertyDescriptor(obj, name);
562
+ if (desc && typeof desc.value === "function") names.add(name);
563
+ }
564
+ obj = Object.getPrototypeOf(obj);
565
+ }
566
+ return [...names];
567
+ }
544
568
  //#endregion
545
569
  //#region src/db/shared-read-helpers.ts
546
570
  /** Filter that matches no rows; used when ARBAC denies the request. */
@@ -716,7 +740,7 @@ let AsArbacDbController = class AsArbacDbController extends AsDbController {
716
740
  applyArbacRelationScopes(controls, scopes);
717
741
  }
718
742
  applyMetaOverlay(meta) {
719
- return applyArbacMetaOverlay(meta, metaAlwaysVisibleFields(this, this.table));
743
+ return applyArbacMetaOverlay(meta, metaAlwaysVisibleFields(this, this.readable));
720
744
  }
721
745
  /**
722
746
  * Field-existence check, scope-aware (BUG-3 twin of the `/meta` pruning
@@ -733,7 +757,7 @@ let AsArbacDbController = class AsArbacDbController extends AsDbController {
733
757
  * exact action being executed.
734
758
  */
735
759
  hasField(path) {
736
- return super.hasField(path) && isScopedFieldVisible(readCachedScopes(), path, metaAlwaysVisibleFields(this, this.table));
760
+ return super.hasField(path) && isScopedFieldVisible(readCachedScopes(), path, metaAlwaysVisibleFields(this, this.readable));
737
761
  }
738
762
  async onWrite(action, data) {
739
763
  const scopes = readCachedScopes();
@@ -748,17 +772,17 @@ let AsArbacDbController = class AsArbacDbController extends AsDbController {
748
772
  const scopeFilter = mergeScopeFilters(scopes.map((s) => s.filter ?? {}));
749
773
  if (!scopeFilter) return;
750
774
  const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
751
- const idFilters = ids.map((id) => this.table.resolveIdFilter(id));
775
+ const idFilters = ids.map((id) => this.readable.resolveIdFilter(id));
752
776
  if (idFilters.some((f) => !f)) throw new HttpError(404, "Not found");
753
777
  const idFilter = idFilters.length === 1 ? idFilters[0] : { $or: idFilters };
754
- if (await this.table.count({ filter: { $and: [idFilter, scopeFilter] } }) < ids.length) throw new HttpError(404, "Not found");
778
+ if (await this.readable.count({ filter: { $and: [idFilter, scopeFilter] } }) < ids.length) throw new HttpError(404, "Not found");
755
779
  }
756
780
  identifierFields() {
757
781
  const ctor = this.constructor;
758
782
  const cached = identifierFieldsCache.get(ctor);
759
783
  if (cached) return cached;
760
784
  const out = /* @__PURE__ */ new Set();
761
- for (const ident of this.table.identifications) for (const f of ident.fields) out.add(f);
785
+ for (const ident of this.readable.identifications) for (const f of ident.fields) out.add(f);
762
786
  const arr = [...out];
763
787
  identifierFieldsCache.set(ctor, arr);
764
788
  return arr;
@@ -921,4 +945,4 @@ let AsArbacDbReadableController = class AsArbacDbReadableController extends AsDb
921
945
  };
922
946
  AsArbacDbReadableController = __decorate([Inherit()], AsArbacDbReadableController);
923
947
  //#endregion
924
- export { Arbac, ArbacAction, ArbacAuthorize, ArbacResource, ArbacUserProvider, ArbacUserProviderToken, AsArbacDbController, AsArbacDbReadableController, MoostArbac, applyAllowedFieldsAndSet, applyArbacMetaOverlay, arbacAuthorizeInterceptor, arbacPatternToRegex, collectWithGrantNames, collectWritableFields, conjoinArbacDbScopes, enforceControlsPolicy, extractUsedControlValues, getArbacMate, isMetaFieldVisible, isScopedFieldVisible, metaAlwaysVisibleFields, pruneMetaByVisibility, unionScopeProjection, useArbac };
948
+ export { Arbac, ArbacAction, ArbacAuthorize, ArbacResource, ArbacUserProvider, ArbacUserProviderToken, AsArbacDbController, AsArbacDbReadableController, MoostArbac, applyAllowedFieldsAndSet, applyArbacMetaOverlay, arbacAuthorizeInterceptor, arbacPatternToRegex, collectMethodNames, collectWithGrantNames, collectWritableFields, conjoinArbacDbScopes, enforceControlsPolicy, extractUsedControlValues, getArbacMate, isMetaFieldVisible, isScopedFieldVisible, metaAlwaysVisibleFields, pruneMetaByVisibility, unionScopeProjection, useArbac };
package/dist/plugin.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { TAtscriptPlugin } from "@atscript/core";
2
-
3
2
  //#region src/plugin.d.ts
4
3
  /**
5
4
  * Registers the `@arbac.*` annotation namespace for `@aooth/arbac-moost`:
@@ -1,4 +1,4 @@
1
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
1
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
2
2
  function __decorate(decorators, target, key, desc) {
3
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3,7 +3,6 @@ import { ControlGate, TProjection, TScopeFilter } from "@aooth/arbac";
3
3
  import { AsDbController } from "@atscript/moost-db";
4
4
  import { NavPropsOf, OwnPropsOf, TAtscriptAnnotatedType } from "@atscript/typescript/utils";
5
5
  import { TMetaResponse } from "@atscript/db";
6
-
7
6
  //#region src/db/scope-types.d.ts
8
7
  /**
9
8
  * Unwrap a `NavPropsOf<T>[K]` value to its target model type:
@@ -125,7 +124,7 @@ interface ArbacDbScope<T = unknown> {
125
124
  * keep the untyped escape hatch. Lives here (not in `scope-types.ts`)
126
125
  * because it must reference `ArbacDbScope` recursively.
127
126
  */
128
- type WithOf<T> = unknown extends T ? Record<string, ArbacDbScope> : { [K in NavRelationKey<T>]?: K extends keyof NavPropsOf<T> ? ArbacDbScope<NavTarget<NavPropsOf<T>[K]>> : ArbacDbScope };
127
+ type WithOf<T> = unknown extends T ? Record<string, ArbacDbScope> : { [K in NavRelationKey<T>]?: K extends keyof NavPropsOf<T> ? ArbacDbScope<NavTarget<NavPropsOf<T>[K]>> : ArbacDbScope; };
129
128
  declare class AsArbacDbController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType> extends AsDbController<T> {
130
129
  protected transformFilter(filter: Record<string, unknown> | undefined): Promise<Record<string, unknown>>;
131
130
  protected transformProjection(projection?: TProjection): TProjection | undefined | Promise<TProjection | undefined>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aooth/arbac-moost",
3
- "version": "0.1.58",
3
+ "version": "0.1.59",
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
- "@aooth/arbac": "0.1.58",
64
- "@aooth/user": "0.1.58",
65
- "@aooth/arbac-core": "0.1.58"
63
+ "@aooth/arbac": "0.1.59",
64
+ "@aooth/arbac-core": "0.1.59",
65
+ "@aooth/user": "0.1.59"
66
66
  },
67
67
  "devDependencies": {
68
- "@atscript/core": "^0.1.85",
69
- "@atscript/db": "^0.1.124",
70
- "@atscript/db-sql-tools": "^0.1.124",
71
- "@atscript/db-sqlite": "^0.1.124",
72
- "@atscript/moost-db": "^0.1.124",
73
- "@atscript/typescript": "^0.1.85",
74
- "@moostjs/event-http": "^0.6.33",
68
+ "@atscript/core": "^0.1.86",
69
+ "@atscript/db": "^0.1.125",
70
+ "@atscript/db-sql-tools": "^0.1.125",
71
+ "@atscript/db-sqlite": "^0.1.125",
72
+ "@atscript/moost-db": "^0.1.125",
73
+ "@atscript/typescript": "^0.1.86",
74
+ "@moostjs/event-http": "^0.6.34",
75
75
  "@types/better-sqlite3": "^7.6.13",
76
76
  "@uniqu/core": "^0.1.7",
77
77
  "better-sqlite3": "^12.6.2",
78
- "unplugin-atscript": "^0.1.85"
78
+ "unplugin-atscript": "^0.1.86"
79
79
  },
80
80
  "peerDependencies": {
81
- "@atscript/db": "^0.1.124",
82
- "@atscript/moost-db": "^0.1.124",
83
- "@atscript/typescript": "^0.1.85",
84
- "@moostjs/event-http": "^0.6.33",
81
+ "@atscript/db": "^0.1.125",
82
+ "@atscript/moost-db": "^0.1.125",
83
+ "@atscript/typescript": "^0.1.86",
84
+ "@moostjs/event-http": "^0.6.34",
85
85
  "@wooksjs/event-core": "^0.7.21",
86
86
  "@wooksjs/event-http": "^0.7.21",
87
- "moost": "^0.6.33"
87
+ "moost": "^0.6.34"
88
88
  },
89
89
  "peerDependenciesMeta": {
90
90
  "@atscript/db": {