@web-ts-toolkit/access-router 0.60.0 → 0.61.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.
package/README.md CHANGED
@@ -239,16 +239,20 @@ behavior rather than route shape.
239
239
 
240
240
  ### Temporary unsafe read/list-performance switches
241
241
 
242
- **Both default to off (snapshot checks enabled).** These independent server-only
243
- settings temporarily skip repeated source snapshot comparisons on one registered model:
242
+ **All default to off (snapshot checks enabled).** Six independent server-only
243
+ settings temporarily skip specific comparisons on one registered model:
244
244
 
245
- | Flag | Applies to |
246
- | -------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
247
- | `unsafeSkipListDocumentSnapshotChecks` | Top-level `find`, generated public lists and root-list responses |
248
- | `unsafeSkipReadDocumentSnapshotChecks` | Top-level `findOne`, `findById`, public identifier/filter reads and root reads, including read-to-list retries |
245
+ | LIST flag | READ flag | Comparisons skipped |
246
+ | -------------------------------------------- | -------------------------------------------- | --------------------------------------------------------------------------------- |
247
+ | `unsafeSkipListDocumentSnapshotChecks` | `unsafeSkipReadDocumentSnapshotChecks` | Repeated source comparisons for the top-level document stage |
248
+ | `unsafeSkipListOutputSnapshotChecks` | `unsafeSkipReadOutputSnapshotChecks` | Output-value comparisons for the root and its embedded/populated/included outputs |
249
+ | `unsafeSkipListNestedDocumentSnapshotChecks` | `unsafeSkipReadNestedDocumentSnapshotChecks` | Repeated source comparisons for embedded/populated/included document stages |
249
250
 
250
- A read-to-list retry follows the **read flag**, because the initiating operation
251
- is still a single read. Changing one flag does not change the other.
251
+ LIST means top-level `find`, generated public lists and root-list entries. READ
252
+ means `findOne`, `findById`, public identifier/filter reads and root-read entries.
253
+ A read-to-list retry follows the **read flags**, because the initiating operation
254
+ is still a single read, even when its effective field access is `list`. Changing
255
+ one flag does not change any other flag.
252
256
 
253
257
  <!-- doc-example: partial -->
254
258
 
@@ -259,38 +263,52 @@ import acl from '@web-ts-toolkit/access-router';
259
263
  // TODO: revisit/remove this temporary workaround after query-performance remediation.
260
264
  acl.setModelOptions('User', {
261
265
  unsafeSkipReadDocumentSnapshotChecks: true,
262
- unsafeSkipListDocumentSnapshotChecks: false, // lists stay protected
266
+ unsafeSkipReadOutputSnapshotChecks: true,
267
+ unsafeSkipReadNestedDocumentSnapshotChecks: true,
268
+ // All three LIST flags remain false unless separately enabled.
263
269
  });
264
270
  ```
265
271
 
266
- Set either flag to `false` with `setModelOption` to roll back for new calls.
267
- Both flags can be set in `createRouter(Model, { ... })` or `setDefaultModelOptions`
272
+ Set any flag to `false` with `setModelOption` to roll back for new calls.
273
+ All flags can be set in `createRouter(Model, { ... })` or `setDefaultModelOptions`
268
274
  before model-router creation. Starting defaults do not overwrite existing models'
269
275
  stored settings; a per-model `false` overrides a starting default of `true`.
270
276
  Prefer per-model opt-in rather than enabling it for every model. Use the owning
271
277
  `createAccessRuntime()` API instead of default `acl` for an isolated runtime.
272
278
  Only literal boolean `true` enables each flag. Enabling emits a logger warning once
273
- per model/flag transition, not per row/request. Neither is a global, per-call, HTTP/root
279
+ per model/flag transition, not per row/request. None is a global, per-call, HTTP/root
274
280
  entry, `options.authorization`, or `service.defaults` option.
275
281
 
276
- - **Skipped:** repeated comparisons of the retained projected document with its
277
- authorization snapshot on the enabled operation. List/read-origin handles and
278
- captured read-to-list retries retain their mode in later work and helper picks.
282
+ - **Independent scopes:** root-source flags do not relax descendant source checks;
283
+ nested-source flags do not relax root source or output checks; output flags do
284
+ not relax source checks. Nested flags do **not** prune child values from parent
285
+ snapshots: a still-strict parent comparison can detect child mutation.
286
+ - **Propagation:** output/nested flags use the **initiating model's captured mode**
287
+ recursively through embedded scopes, ordinary public population and includes
288
+ (including correlated includes). A target model's own flags cannot relax a
289
+ strict parent or override that captured mode. Independent service calls made
290
+ inside hooks use their own settings, not ambient parent authority.
279
291
  - **Still enforced:** row filters, document/field rules, operation gates, exact
280
- request/runtime/model/stage ownership, output-mutation/provenance checks and bounds.
281
- Initial snapshots and detached callback/grant/output copies (including native values)
282
- remain. Writes (including read-like output), dedicated subdocument operations,
283
- embedded/related stages and fresh standalone output helpers stay strict. An
284
- operation without its own opt-out stays protected.
285
- - **Risk:** source changes during callbacks or awaits will no longer invalidate
286
- cached grants/decisions. Output may be authorized using stale data even though
287
- normal permission rules run. This is a deliberate weakening of mutation protection,
288
- **not a security-equivalent fast mode**. Use only with trusted, non-mutating hooks;
289
- review your application and measure a staged rollout before production opt-in.
292
+ request/runtime/model/scope/access/stage binding, handle/output associations,
293
+ output graph identities and structural bounds on initial snapshots. Initial
294
+ source/output snapshots and detached callback/grant/output copies remain. Equal
295
+ replacement objects, forged handles and unrelated rows/calls still reject;
296
+ package-created output-copy transfers still authenticate their source.
297
+ - **Strict boundaries:** writes (including read-like output), dedicated subdocument
298
+ operations and fresh standalone output helpers remain strict. Helpers using an
299
+ originating handle retain that handle's captured mode.
300
+ - **Risk:** source mutation during callbacks/awaits can leave stale grants/decisions.
301
+ Output flags additionally allow changed scalar values, in-place Date/Buffer/BSON
302
+ mutations and other value changes that graph-identity checks cannot detect to
303
+ reuse earlier decisions. This can expose incorrectly authorized output, even
304
+ though permission rules still run. This is **not a security-equivalent fast mode**.
305
+ Use only with trusted, non-mutating hooks and output consumers; review your
306
+ application and measure a staged rollout before production opt-in.
290
307
 
291
308
  Each call captures the setting before awaits. Turning it off protects new calls,
292
- not in-flight calls, retries or existing handles. These switches do not eliminate
293
- all cloning or promise v0.51.0 performance. Restore `false` as soon as possible.
309
+ not in-flight calls, later descendants of captured calls, retries or existing
310
+ handles. These switches do not eliminate all cloning or promise v0.51.0 performance.
311
+ Measure each separately on your workload; restore `false` as soon as possible.
294
312
 
295
313
  ### Wire placement and option names
296
314
 
package/advanced.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AccessRouterBaseRequest, a as AccessRouterFieldKey, b as AccessRouterLogger, c as AccessRouterRequest, d as AccessRouterRequestExtensions, e as AdvancedCreateBody, f as AdvancedListBody, g as AdvancedReadBody, h as AdvancedReadFilterBody, i as AdvancedUpdateBody, j as AdvancedUpsertBody, k as AfterPersistAccess, l as AjvErrorObjectLike, m as AjvValidationErrorLike, n as AjvValidatorLike, o as AllowedOutputFieldOptions, p as ArkTypeErrorsLike, q as ArkTypeLike, r as ArkTypeProblemLike, s as AuthorizedListResult, t as AuthorizedSingleResult, B as BaseFilterAccess, C as Change, u as Codes, v as CorrelatedCountInclude, w as CorrelatedFilter, x as CorrelatedInclude, y as CorrelatedIncludeArgs, z as CorrelatedListInclude, D as CorrelatedReadByFilterInclude, E as CorrelatedReadByIdInclude, F as CountBody, G as CreateArgs, H as CreateAuthorization, I as CreateOptions, J as CreateQueryInput, K as CustomHeaders, L as DATA_MIDDLEWARE, M as DataBaseFilterHook, N as DataFieldOptions, O as DataFilter, P as DataFindArgs, Q as DataFindOneArgs, R as DataFindOneOptions, S as DataFindOptions, T as DataHook, U as DataHookContext, V as DataIdentifierHook, W as DataListHook, X as DataOverrideFilterHook, Y as DataRequest, Z as DataRequestSchemas, _ as DataRouterOptions, $ as DecorateAccess, a0 as DecorateAllAccess, a1 as DeepFieldPath, a2 as DefaultModelRouterOptions, a3 as Defaults, a4 as DistinctArgs, a5 as DistinctBody, a6 as DocPermissionsAccess, a7 as DocumentAuthorization, a8 as ErrorResult, a9 as ExistsOptions, aa as ExtendedDataRouterOptions, ab as ExtendedDefaultModelRouterOptions, ac as ExtendedModelRouterOptions, ad as FieldAuthorization, ae as FieldOperationAccess, af as Filter, ag as FilterOperator, ah as FindAccess, ai as FindArgs, aj as FindByIdArgs, ak as FindByIdOptions, al as FindOneArgs, am as FindOneOptions, an as FindOptions, ao as GlobalOptions, ap as GlobalPermissionValue, aq as GuardHook, ar as HydrationMode, as as IdentifierHook, at as Include, au as InputFieldAuthorization, av as InputFieldPath, aw as IoTsContextEntryLike, ax as IoTsDecodeErrorLike, ay as IoTsDecoderLike, az as JoiSchemaLike, aA as JoiValidationErrorDetailLike, aB as KeyValueProjection, aC as LegacyInclude, aD as ListQueryInput, aE as ListResult, aF as MIDDLEWARE, aG as MaybePromise, aH as ModelBaseFilterHook, aI as ModelChangeHook, aJ as ModelDeleteHook, aK as ModelDocPermissionsHook, aL as ModelDocument, aM as ModelDocumentHook, aN as ModelHook, aO as ModelHookContext, aP as ModelHydrationOptions, aQ as ModelIdentifierHook, aR as ModelListHook, aS as ModelOverrideFilterHook, aT as ModelRequest, aU as ModelRouterOptions, aV as ModelValidateHook, aW as ModelVirtualAccess, aX as ModelVirtualAccessRecord, aY as ModelVirtualContext, aZ as ModelVirtualDescriptor, a_ as ModelVirtualDoc, a$ as ModelVirtualGetter, b0 as ModelVirtualLeaf, b1 as ModelVirtualPopulateDependency, b2 as ModelVirtualPopulateInputs, b3 as ModelVirtualRecordAccess, b4 as ModelVirtuals, b5 as MutationAuthorization, b6 as NewArgs, b7 as NewOptions, b8 as OperationAccess, b9 as OperationAuthorization, ba as OutputAuthorization, bb as OutputFieldOptions, bc as OutputFieldPath, bd as OutputPlanningOptions, be as PERMISSIONS, bf as PERMISSION_KEYS, bg as PairedRouteAccess, bh as ParentRef, bi as PathValue, bj as PermissionSchema, bk as Populate, bl as PopulateAccess, bm as PopulatePlanningOptions, bn as PrepareAccess, bo as Projection, bp as PublicCreateArgs, bq as PublicCreateOptions, br as PublicErrorResult, bs as PublicListArgs, bt as PublicListOptions, bu as PublicListResult, bv as PublicOutput, bw as PublicReadArgs, bx as PublicReadOptions, by as PublicServiceResult, bz as PublicSingleResult, bA as PublicSubdocumentCreateOptions, bB as PublicSubdocumentListOptions, bC as PublicSubdocumentMutationOptions, bD as PublicSubdocumentReadOptions, bE as PublicUpdateArgs, bF as PublicUpdateOptions, bG as PublicUpsertArgs, bH as PublicUpsertOptions, bI as ReadQueryInput, bJ as RelatedAuthorization, bK as Request, bL as RequestSchemaAdapter, bM as RequestSchemaFailure, bN as RequestSchemaIssue, bO as RequestSchemaLike, bP as RequestSchemaOptions, bQ as RequestSchemaResult, bR as RequestSchemaSuccess, bS as RequestSchemaValidator, bT as RequestSchemas, bU as RootDataListQueryEntry, bV as RootDataOperation, bW as RootDataReadByFilterQueryEntry, bX as RootDataReadByIdQueryEntry, bY as RootModelCountQueryEntry, bZ as RootModelCreateQueryEntry, b_ as RootModelDeleteQueryEntry, b$ as RootModelDistinctQueryEntry, c0 as RootModelListQueryEntry, c1 as RootModelNewQueryEntry, c2 as RootModelOperation, c3 as RootModelReadByFilterQueryEntry, c4 as RootModelReadByIdQueryEntry, c5 as RootModelSubBulkUpdateQueryEntry, c6 as RootModelSubCreateQueryEntry, c7 as RootModelSubDeleteQueryEntry, c8 as RootModelSubListQueryEntry, c9 as RootModelSubReadQueryEntry, ca as RootModelSubUpdateQueryEntry, cb as RootModelUpdateQueryEntry, cc as RootModelUpsertQueryEntry, cd as RootOperationResult, ce as RootQueryEntry, cf as RootRouterOptions, cg as RootSubOperation, ch as RootTarget, ci as RouteBaseAccess, cj as RouteGuardAccess, ck as RouteVariant, cl as RouteVariantAccess, cm as RowAuthorization, cn as SelectAccess, co as SelectedPopulatedPublicOutput, cp as SelectedPublicOutput, cq as ServiceAuthorization, cr as ServiceOutputContext, cs as ServiceOutputDecorator, ct as ServiceResult, cu as SingleResult, cv as Sort, cw as SortOrder, cx as StandardSchemaFailure, cy as StandardSchemaInferOutput, cz as StandardSchemaIssue, cA as StandardSchemaPathSegment, cB as StandardSchemaResult, cC as StandardSchemaSuccess, cD as StandardSchemaV1, cE as StatusCodes, cF as SubListBody, cG as SubOperationAccess, cH as SubPopulate, cI as SubQueryEntry, cJ as SubReadBody, cK as SubRouteGuardOptions, cL as SubdocumentBulkRecord, cM as SubdocumentBulkUpdateInput, cN as SubdocumentCreateAuthorization, cO as SubdocumentCreateInput, cP as SubdocumentCreateOptions, cQ as SubdocumentCreateVisibilityAuthorization, cR as SubdocumentDeleteAuthorization, cS as SubdocumentDeleteOptions, cT as SubdocumentGateAuthorization, cU as SubdocumentId, cV as SubdocumentInputAuthorization, cW as SubdocumentListOptions, cX as SubdocumentModel, cY as SubdocumentMutationAuthorization, cZ as SubdocumentName, c_ as SubdocumentOutputAuthorization, c$ as SubdocumentParentArgs, d0 as SubdocumentParentOptions, d1 as SubdocumentReadAuthorization, d2 as SubdocumentReadOptions, d3 as SubdocumentRecord, d4 as SubdocumentUpdateOptions, d5 as SubdocumentVirtuals, d6 as SubdocumentVisibilityAuthorization, d7 as SuperstructFailureLike, d8 as SuperstructValidateLike, d9 as Task, da as TaskType, db as TransformAccess, dc as TypedFilter, dd as UpdateByIdArgs, de as UpdateByIdOptions, df as UpdateOneArgs, dg as UpdateOneOptions, dh as UpdateQueryInput, di as UpsertArgs, dj as UpsertOptions, dk as UpsertQueryInput, dl as ValibotIssueLike, dm as ValibotPathItemLike, dn as ValibotSafeParseLike, dp as ValibotSafeParseResult, dq as ValidateAccess, dr as ValidateRule, ds as Validation, dt as ValidationError, du as VineValidationErrorLike, dv as VineValidationMessageLike, dw as VineValidatorLike, dx as VirtualSubModel, dy as WithVirtuals, dz as YupSchemaLike, dA as YupValidationErrorLike, dB as defineRequestSchema, dC as fromAjv, dD as fromArkType, dE as fromIoTs, dF as fromJoi, dG as fromStandardSchema, dH as fromSuperstruct, dI as fromValibot, dJ as fromVine, dK as fromYup, dL as fromZod, dM as parseBody, dN as parseBodyWithSchema, dO as parseNestedBodyWithSchema, dP as parsePathParam, dQ as parseQuery } from './parsers-bP4gXehf.mjs';
1
+ export { A as AccessRouterBaseRequest, a as AccessRouterFieldKey, b as AccessRouterLogger, c as AccessRouterRequest, d as AccessRouterRequestExtensions, e as AdvancedCreateBody, f as AdvancedListBody, g as AdvancedReadBody, h as AdvancedReadFilterBody, i as AdvancedUpdateBody, j as AdvancedUpsertBody, k as AfterPersistAccess, l as AjvErrorObjectLike, m as AjvValidationErrorLike, n as AjvValidatorLike, o as AllowedOutputFieldOptions, p as ArkTypeErrorsLike, q as ArkTypeLike, r as ArkTypeProblemLike, s as AuthorizedListResult, t as AuthorizedSingleResult, B as BaseFilterAccess, C as Change, u as Codes, v as CorrelatedCountInclude, w as CorrelatedFilter, x as CorrelatedInclude, y as CorrelatedIncludeArgs, z as CorrelatedListInclude, D as CorrelatedReadByFilterInclude, E as CorrelatedReadByIdInclude, F as CountBody, G as CreateArgs, H as CreateAuthorization, I as CreateOptions, J as CreateQueryInput, K as CustomHeaders, L as DATA_MIDDLEWARE, M as DataBaseFilterHook, N as DataFieldOptions, O as DataFilter, P as DataFindArgs, Q as DataFindOneArgs, R as DataFindOneOptions, S as DataFindOptions, T as DataHook, U as DataHookContext, V as DataIdentifierHook, W as DataListHook, X as DataOverrideFilterHook, Y as DataRequest, Z as DataRequestSchemas, _ as DataRouterOptions, $ as DecorateAccess, a0 as DecorateAllAccess, a1 as DeepFieldPath, a2 as DefaultModelRouterOptions, a3 as Defaults, a4 as DistinctArgs, a5 as DistinctBody, a6 as DocPermissionsAccess, a7 as DocumentAuthorization, a8 as ErrorResult, a9 as ExistsOptions, aa as ExtendedDataRouterOptions, ab as ExtendedDefaultModelRouterOptions, ac as ExtendedModelRouterOptions, ad as FieldAuthorization, ae as FieldOperationAccess, af as Filter, ag as FilterOperator, ah as FindAccess, ai as FindArgs, aj as FindByIdArgs, ak as FindByIdOptions, al as FindOneArgs, am as FindOneOptions, an as FindOptions, ao as GlobalOptions, ap as GlobalPermissionValue, aq as GuardHook, ar as HydrationMode, as as IdentifierHook, at as Include, au as InputFieldAuthorization, av as InputFieldPath, aw as IoTsContextEntryLike, ax as IoTsDecodeErrorLike, ay as IoTsDecoderLike, az as JoiSchemaLike, aA as JoiValidationErrorDetailLike, aB as KeyValueProjection, aC as LegacyInclude, aD as ListQueryInput, aE as ListResult, aF as MIDDLEWARE, aG as MaybePromise, aH as ModelBaseFilterHook, aI as ModelChangeHook, aJ as ModelDeleteHook, aK as ModelDocPermissionsHook, aL as ModelDocument, aM as ModelDocumentHook, aN as ModelHook, aO as ModelHookContext, aP as ModelHydrationOptions, aQ as ModelIdentifierHook, aR as ModelListHook, aS as ModelOverrideFilterHook, aT as ModelRequest, aU as ModelRouterOptions, aV as ModelValidateHook, aW as ModelVirtualAccess, aX as ModelVirtualAccessRecord, aY as ModelVirtualContext, aZ as ModelVirtualDescriptor, a_ as ModelVirtualDoc, a$ as ModelVirtualGetter, b0 as ModelVirtualLeaf, b1 as ModelVirtualPopulateDependency, b2 as ModelVirtualPopulateInputs, b3 as ModelVirtualRecordAccess, b4 as ModelVirtuals, b5 as MutationAuthorization, b6 as NewArgs, b7 as NewOptions, b8 as OperationAccess, b9 as OperationAuthorization, ba as OutputAuthorization, bb as OutputFieldOptions, bc as OutputFieldPath, bd as OutputPlanningOptions, be as PERMISSIONS, bf as PERMISSION_KEYS, bg as PairedRouteAccess, bh as ParentRef, bi as PathValue, bj as PermissionSchema, bk as Populate, bl as PopulateAccess, bm as PopulatePlanningOptions, bn as PrepareAccess, bo as Projection, bp as PublicCreateArgs, bq as PublicCreateOptions, br as PublicErrorResult, bs as PublicListArgs, bt as PublicListOptions, bu as PublicListResult, bv as PublicOutput, bw as PublicReadArgs, bx as PublicReadOptions, by as PublicServiceResult, bz as PublicSingleResult, bA as PublicSubdocumentCreateOptions, bB as PublicSubdocumentListOptions, bC as PublicSubdocumentMutationOptions, bD as PublicSubdocumentReadOptions, bE as PublicUpdateArgs, bF as PublicUpdateOptions, bG as PublicUpsertArgs, bH as PublicUpsertOptions, bI as ReadQueryInput, bJ as RelatedAuthorization, bK as Request, bL as RequestSchemaAdapter, bM as RequestSchemaFailure, bN as RequestSchemaIssue, bO as RequestSchemaLike, bP as RequestSchemaOptions, bQ as RequestSchemaResult, bR as RequestSchemaSuccess, bS as RequestSchemaValidator, bT as RequestSchemas, bU as RootDataListQueryEntry, bV as RootDataOperation, bW as RootDataReadByFilterQueryEntry, bX as RootDataReadByIdQueryEntry, bY as RootModelCountQueryEntry, bZ as RootModelCreateQueryEntry, b_ as RootModelDeleteQueryEntry, b$ as RootModelDistinctQueryEntry, c0 as RootModelListQueryEntry, c1 as RootModelNewQueryEntry, c2 as RootModelOperation, c3 as RootModelReadByFilterQueryEntry, c4 as RootModelReadByIdQueryEntry, c5 as RootModelSubBulkUpdateQueryEntry, c6 as RootModelSubCreateQueryEntry, c7 as RootModelSubDeleteQueryEntry, c8 as RootModelSubListQueryEntry, c9 as RootModelSubReadQueryEntry, ca as RootModelSubUpdateQueryEntry, cb as RootModelUpdateQueryEntry, cc as RootModelUpsertQueryEntry, cd as RootOperationResult, ce as RootQueryEntry, cf as RootRouterOptions, cg as RootSubOperation, ch as RootTarget, ci as RouteBaseAccess, cj as RouteGuardAccess, ck as RouteVariant, cl as RouteVariantAccess, cm as RowAuthorization, cn as SelectAccess, co as SelectedPopulatedPublicOutput, cp as SelectedPublicOutput, cq as ServiceAuthorization, cr as ServiceOutputContext, cs as ServiceOutputDecorator, ct as ServiceResult, cu as SingleResult, cv as Sort, cw as SortOrder, cx as StandardSchemaFailure, cy as StandardSchemaInferOutput, cz as StandardSchemaIssue, cA as StandardSchemaPathSegment, cB as StandardSchemaResult, cC as StandardSchemaSuccess, cD as StandardSchemaV1, cE as StatusCodes, cF as SubListBody, cG as SubOperationAccess, cH as SubPopulate, cI as SubQueryEntry, cJ as SubReadBody, cK as SubRouteGuardOptions, cL as SubdocumentBulkRecord, cM as SubdocumentBulkUpdateInput, cN as SubdocumentCreateAuthorization, cO as SubdocumentCreateInput, cP as SubdocumentCreateOptions, cQ as SubdocumentCreateVisibilityAuthorization, cR as SubdocumentDeleteAuthorization, cS as SubdocumentDeleteOptions, cT as SubdocumentGateAuthorization, cU as SubdocumentId, cV as SubdocumentInputAuthorization, cW as SubdocumentListOptions, cX as SubdocumentModel, cY as SubdocumentMutationAuthorization, cZ as SubdocumentName, c_ as SubdocumentOutputAuthorization, c$ as SubdocumentParentArgs, d0 as SubdocumentParentOptions, d1 as SubdocumentReadAuthorization, d2 as SubdocumentReadOptions, d3 as SubdocumentRecord, d4 as SubdocumentUpdateOptions, d5 as SubdocumentVirtuals, d6 as SubdocumentVisibilityAuthorization, d7 as SuperstructFailureLike, d8 as SuperstructValidateLike, d9 as Task, da as TaskType, db as TransformAccess, dc as TypedFilter, dd as UpdateByIdArgs, de as UpdateByIdOptions, df as UpdateOneArgs, dg as UpdateOneOptions, dh as UpdateQueryInput, di as UpsertArgs, dj as UpsertOptions, dk as UpsertQueryInput, dl as ValibotIssueLike, dm as ValibotPathItemLike, dn as ValibotSafeParseLike, dp as ValibotSafeParseResult, dq as ValidateAccess, dr as ValidateRule, ds as Validation, dt as ValidationError, du as VineValidationErrorLike, dv as VineValidationMessageLike, dw as VineValidatorLike, dx as VirtualSubModel, dy as WithVirtuals, dz as YupSchemaLike, dA as YupValidationErrorLike, dB as defineRequestSchema, dC as fromAjv, dD as fromArkType, dE as fromIoTs, dF as fromJoi, dG as fromStandardSchema, dH as fromSuperstruct, dI as fromValibot, dJ as fromVine, dK as fromYup, dL as fromZod, dM as parseBody, dN as parseBodyWithSchema, dO as parseNestedBodyWithSchema, dP as parsePathParam, dQ as parseQuery } from './parsers-DFZ_6fGl.mjs';
2
2
  import { z } from 'zod';
3
3
  import 'mongoose';
4
4
  import 'express';
package/advanced.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AccessRouterBaseRequest, a as AccessRouterFieldKey, b as AccessRouterLogger, c as AccessRouterRequest, d as AccessRouterRequestExtensions, e as AdvancedCreateBody, f as AdvancedListBody, g as AdvancedReadBody, h as AdvancedReadFilterBody, i as AdvancedUpdateBody, j as AdvancedUpsertBody, k as AfterPersistAccess, l as AjvErrorObjectLike, m as AjvValidationErrorLike, n as AjvValidatorLike, o as AllowedOutputFieldOptions, p as ArkTypeErrorsLike, q as ArkTypeLike, r as ArkTypeProblemLike, s as AuthorizedListResult, t as AuthorizedSingleResult, B as BaseFilterAccess, C as Change, u as Codes, v as CorrelatedCountInclude, w as CorrelatedFilter, x as CorrelatedInclude, y as CorrelatedIncludeArgs, z as CorrelatedListInclude, D as CorrelatedReadByFilterInclude, E as CorrelatedReadByIdInclude, F as CountBody, G as CreateArgs, H as CreateAuthorization, I as CreateOptions, J as CreateQueryInput, K as CustomHeaders, L as DATA_MIDDLEWARE, M as DataBaseFilterHook, N as DataFieldOptions, O as DataFilter, P as DataFindArgs, Q as DataFindOneArgs, R as DataFindOneOptions, S as DataFindOptions, T as DataHook, U as DataHookContext, V as DataIdentifierHook, W as DataListHook, X as DataOverrideFilterHook, Y as DataRequest, Z as DataRequestSchemas, _ as DataRouterOptions, $ as DecorateAccess, a0 as DecorateAllAccess, a1 as DeepFieldPath, a2 as DefaultModelRouterOptions, a3 as Defaults, a4 as DistinctArgs, a5 as DistinctBody, a6 as DocPermissionsAccess, a7 as DocumentAuthorization, a8 as ErrorResult, a9 as ExistsOptions, aa as ExtendedDataRouterOptions, ab as ExtendedDefaultModelRouterOptions, ac as ExtendedModelRouterOptions, ad as FieldAuthorization, ae as FieldOperationAccess, af as Filter, ag as FilterOperator, ah as FindAccess, ai as FindArgs, aj as FindByIdArgs, ak as FindByIdOptions, al as FindOneArgs, am as FindOneOptions, an as FindOptions, ao as GlobalOptions, ap as GlobalPermissionValue, aq as GuardHook, ar as HydrationMode, as as IdentifierHook, at as Include, au as InputFieldAuthorization, av as InputFieldPath, aw as IoTsContextEntryLike, ax as IoTsDecodeErrorLike, ay as IoTsDecoderLike, az as JoiSchemaLike, aA as JoiValidationErrorDetailLike, aB as KeyValueProjection, aC as LegacyInclude, aD as ListQueryInput, aE as ListResult, aF as MIDDLEWARE, aG as MaybePromise, aH as ModelBaseFilterHook, aI as ModelChangeHook, aJ as ModelDeleteHook, aK as ModelDocPermissionsHook, aL as ModelDocument, aM as ModelDocumentHook, aN as ModelHook, aO as ModelHookContext, aP as ModelHydrationOptions, aQ as ModelIdentifierHook, aR as ModelListHook, aS as ModelOverrideFilterHook, aT as ModelRequest, aU as ModelRouterOptions, aV as ModelValidateHook, aW as ModelVirtualAccess, aX as ModelVirtualAccessRecord, aY as ModelVirtualContext, aZ as ModelVirtualDescriptor, a_ as ModelVirtualDoc, a$ as ModelVirtualGetter, b0 as ModelVirtualLeaf, b1 as ModelVirtualPopulateDependency, b2 as ModelVirtualPopulateInputs, b3 as ModelVirtualRecordAccess, b4 as ModelVirtuals, b5 as MutationAuthorization, b6 as NewArgs, b7 as NewOptions, b8 as OperationAccess, b9 as OperationAuthorization, ba as OutputAuthorization, bb as OutputFieldOptions, bc as OutputFieldPath, bd as OutputPlanningOptions, be as PERMISSIONS, bf as PERMISSION_KEYS, bg as PairedRouteAccess, bh as ParentRef, bi as PathValue, bj as PermissionSchema, bk as Populate, bl as PopulateAccess, bm as PopulatePlanningOptions, bn as PrepareAccess, bo as Projection, bp as PublicCreateArgs, bq as PublicCreateOptions, br as PublicErrorResult, bs as PublicListArgs, bt as PublicListOptions, bu as PublicListResult, bv as PublicOutput, bw as PublicReadArgs, bx as PublicReadOptions, by as PublicServiceResult, bz as PublicSingleResult, bA as PublicSubdocumentCreateOptions, bB as PublicSubdocumentListOptions, bC as PublicSubdocumentMutationOptions, bD as PublicSubdocumentReadOptions, bE as PublicUpdateArgs, bF as PublicUpdateOptions, bG as PublicUpsertArgs, bH as PublicUpsertOptions, bI as ReadQueryInput, bJ as RelatedAuthorization, bK as Request, bL as RequestSchemaAdapter, bM as RequestSchemaFailure, bN as RequestSchemaIssue, bO as RequestSchemaLike, bP as RequestSchemaOptions, bQ as RequestSchemaResult, bR as RequestSchemaSuccess, bS as RequestSchemaValidator, bT as RequestSchemas, bU as RootDataListQueryEntry, bV as RootDataOperation, bW as RootDataReadByFilterQueryEntry, bX as RootDataReadByIdQueryEntry, bY as RootModelCountQueryEntry, bZ as RootModelCreateQueryEntry, b_ as RootModelDeleteQueryEntry, b$ as RootModelDistinctQueryEntry, c0 as RootModelListQueryEntry, c1 as RootModelNewQueryEntry, c2 as RootModelOperation, c3 as RootModelReadByFilterQueryEntry, c4 as RootModelReadByIdQueryEntry, c5 as RootModelSubBulkUpdateQueryEntry, c6 as RootModelSubCreateQueryEntry, c7 as RootModelSubDeleteQueryEntry, c8 as RootModelSubListQueryEntry, c9 as RootModelSubReadQueryEntry, ca as RootModelSubUpdateQueryEntry, cb as RootModelUpdateQueryEntry, cc as RootModelUpsertQueryEntry, cd as RootOperationResult, ce as RootQueryEntry, cf as RootRouterOptions, cg as RootSubOperation, ch as RootTarget, ci as RouteBaseAccess, cj as RouteGuardAccess, ck as RouteVariant, cl as RouteVariantAccess, cm as RowAuthorization, cn as SelectAccess, co as SelectedPopulatedPublicOutput, cp as SelectedPublicOutput, cq as ServiceAuthorization, cr as ServiceOutputContext, cs as ServiceOutputDecorator, ct as ServiceResult, cu as SingleResult, cv as Sort, cw as SortOrder, cx as StandardSchemaFailure, cy as StandardSchemaInferOutput, cz as StandardSchemaIssue, cA as StandardSchemaPathSegment, cB as StandardSchemaResult, cC as StandardSchemaSuccess, cD as StandardSchemaV1, cE as StatusCodes, cF as SubListBody, cG as SubOperationAccess, cH as SubPopulate, cI as SubQueryEntry, cJ as SubReadBody, cK as SubRouteGuardOptions, cL as SubdocumentBulkRecord, cM as SubdocumentBulkUpdateInput, cN as SubdocumentCreateAuthorization, cO as SubdocumentCreateInput, cP as SubdocumentCreateOptions, cQ as SubdocumentCreateVisibilityAuthorization, cR as SubdocumentDeleteAuthorization, cS as SubdocumentDeleteOptions, cT as SubdocumentGateAuthorization, cU as SubdocumentId, cV as SubdocumentInputAuthorization, cW as SubdocumentListOptions, cX as SubdocumentModel, cY as SubdocumentMutationAuthorization, cZ as SubdocumentName, c_ as SubdocumentOutputAuthorization, c$ as SubdocumentParentArgs, d0 as SubdocumentParentOptions, d1 as SubdocumentReadAuthorization, d2 as SubdocumentReadOptions, d3 as SubdocumentRecord, d4 as SubdocumentUpdateOptions, d5 as SubdocumentVirtuals, d6 as SubdocumentVisibilityAuthorization, d7 as SuperstructFailureLike, d8 as SuperstructValidateLike, d9 as Task, da as TaskType, db as TransformAccess, dc as TypedFilter, dd as UpdateByIdArgs, de as UpdateByIdOptions, df as UpdateOneArgs, dg as UpdateOneOptions, dh as UpdateQueryInput, di as UpsertArgs, dj as UpsertOptions, dk as UpsertQueryInput, dl as ValibotIssueLike, dm as ValibotPathItemLike, dn as ValibotSafeParseLike, dp as ValibotSafeParseResult, dq as ValidateAccess, dr as ValidateRule, ds as Validation, dt as ValidationError, du as VineValidationErrorLike, dv as VineValidationMessageLike, dw as VineValidatorLike, dx as VirtualSubModel, dy as WithVirtuals, dz as YupSchemaLike, dA as YupValidationErrorLike, dB as defineRequestSchema, dC as fromAjv, dD as fromArkType, dE as fromIoTs, dF as fromJoi, dG as fromStandardSchema, dH as fromSuperstruct, dI as fromValibot, dJ as fromVine, dK as fromYup, dL as fromZod, dM as parseBody, dN as parseBodyWithSchema, dO as parseNestedBodyWithSchema, dP as parsePathParam, dQ as parseQuery } from './parsers-bP4gXehf.js';
1
+ export { A as AccessRouterBaseRequest, a as AccessRouterFieldKey, b as AccessRouterLogger, c as AccessRouterRequest, d as AccessRouterRequestExtensions, e as AdvancedCreateBody, f as AdvancedListBody, g as AdvancedReadBody, h as AdvancedReadFilterBody, i as AdvancedUpdateBody, j as AdvancedUpsertBody, k as AfterPersistAccess, l as AjvErrorObjectLike, m as AjvValidationErrorLike, n as AjvValidatorLike, o as AllowedOutputFieldOptions, p as ArkTypeErrorsLike, q as ArkTypeLike, r as ArkTypeProblemLike, s as AuthorizedListResult, t as AuthorizedSingleResult, B as BaseFilterAccess, C as Change, u as Codes, v as CorrelatedCountInclude, w as CorrelatedFilter, x as CorrelatedInclude, y as CorrelatedIncludeArgs, z as CorrelatedListInclude, D as CorrelatedReadByFilterInclude, E as CorrelatedReadByIdInclude, F as CountBody, G as CreateArgs, H as CreateAuthorization, I as CreateOptions, J as CreateQueryInput, K as CustomHeaders, L as DATA_MIDDLEWARE, M as DataBaseFilterHook, N as DataFieldOptions, O as DataFilter, P as DataFindArgs, Q as DataFindOneArgs, R as DataFindOneOptions, S as DataFindOptions, T as DataHook, U as DataHookContext, V as DataIdentifierHook, W as DataListHook, X as DataOverrideFilterHook, Y as DataRequest, Z as DataRequestSchemas, _ as DataRouterOptions, $ as DecorateAccess, a0 as DecorateAllAccess, a1 as DeepFieldPath, a2 as DefaultModelRouterOptions, a3 as Defaults, a4 as DistinctArgs, a5 as DistinctBody, a6 as DocPermissionsAccess, a7 as DocumentAuthorization, a8 as ErrorResult, a9 as ExistsOptions, aa as ExtendedDataRouterOptions, ab as ExtendedDefaultModelRouterOptions, ac as ExtendedModelRouterOptions, ad as FieldAuthorization, ae as FieldOperationAccess, af as Filter, ag as FilterOperator, ah as FindAccess, ai as FindArgs, aj as FindByIdArgs, ak as FindByIdOptions, al as FindOneArgs, am as FindOneOptions, an as FindOptions, ao as GlobalOptions, ap as GlobalPermissionValue, aq as GuardHook, ar as HydrationMode, as as IdentifierHook, at as Include, au as InputFieldAuthorization, av as InputFieldPath, aw as IoTsContextEntryLike, ax as IoTsDecodeErrorLike, ay as IoTsDecoderLike, az as JoiSchemaLike, aA as JoiValidationErrorDetailLike, aB as KeyValueProjection, aC as LegacyInclude, aD as ListQueryInput, aE as ListResult, aF as MIDDLEWARE, aG as MaybePromise, aH as ModelBaseFilterHook, aI as ModelChangeHook, aJ as ModelDeleteHook, aK as ModelDocPermissionsHook, aL as ModelDocument, aM as ModelDocumentHook, aN as ModelHook, aO as ModelHookContext, aP as ModelHydrationOptions, aQ as ModelIdentifierHook, aR as ModelListHook, aS as ModelOverrideFilterHook, aT as ModelRequest, aU as ModelRouterOptions, aV as ModelValidateHook, aW as ModelVirtualAccess, aX as ModelVirtualAccessRecord, aY as ModelVirtualContext, aZ as ModelVirtualDescriptor, a_ as ModelVirtualDoc, a$ as ModelVirtualGetter, b0 as ModelVirtualLeaf, b1 as ModelVirtualPopulateDependency, b2 as ModelVirtualPopulateInputs, b3 as ModelVirtualRecordAccess, b4 as ModelVirtuals, b5 as MutationAuthorization, b6 as NewArgs, b7 as NewOptions, b8 as OperationAccess, b9 as OperationAuthorization, ba as OutputAuthorization, bb as OutputFieldOptions, bc as OutputFieldPath, bd as OutputPlanningOptions, be as PERMISSIONS, bf as PERMISSION_KEYS, bg as PairedRouteAccess, bh as ParentRef, bi as PathValue, bj as PermissionSchema, bk as Populate, bl as PopulateAccess, bm as PopulatePlanningOptions, bn as PrepareAccess, bo as Projection, bp as PublicCreateArgs, bq as PublicCreateOptions, br as PublicErrorResult, bs as PublicListArgs, bt as PublicListOptions, bu as PublicListResult, bv as PublicOutput, bw as PublicReadArgs, bx as PublicReadOptions, by as PublicServiceResult, bz as PublicSingleResult, bA as PublicSubdocumentCreateOptions, bB as PublicSubdocumentListOptions, bC as PublicSubdocumentMutationOptions, bD as PublicSubdocumentReadOptions, bE as PublicUpdateArgs, bF as PublicUpdateOptions, bG as PublicUpsertArgs, bH as PublicUpsertOptions, bI as ReadQueryInput, bJ as RelatedAuthorization, bK as Request, bL as RequestSchemaAdapter, bM as RequestSchemaFailure, bN as RequestSchemaIssue, bO as RequestSchemaLike, bP as RequestSchemaOptions, bQ as RequestSchemaResult, bR as RequestSchemaSuccess, bS as RequestSchemaValidator, bT as RequestSchemas, bU as RootDataListQueryEntry, bV as RootDataOperation, bW as RootDataReadByFilterQueryEntry, bX as RootDataReadByIdQueryEntry, bY as RootModelCountQueryEntry, bZ as RootModelCreateQueryEntry, b_ as RootModelDeleteQueryEntry, b$ as RootModelDistinctQueryEntry, c0 as RootModelListQueryEntry, c1 as RootModelNewQueryEntry, c2 as RootModelOperation, c3 as RootModelReadByFilterQueryEntry, c4 as RootModelReadByIdQueryEntry, c5 as RootModelSubBulkUpdateQueryEntry, c6 as RootModelSubCreateQueryEntry, c7 as RootModelSubDeleteQueryEntry, c8 as RootModelSubListQueryEntry, c9 as RootModelSubReadQueryEntry, ca as RootModelSubUpdateQueryEntry, cb as RootModelUpdateQueryEntry, cc as RootModelUpsertQueryEntry, cd as RootOperationResult, ce as RootQueryEntry, cf as RootRouterOptions, cg as RootSubOperation, ch as RootTarget, ci as RouteBaseAccess, cj as RouteGuardAccess, ck as RouteVariant, cl as RouteVariantAccess, cm as RowAuthorization, cn as SelectAccess, co as SelectedPopulatedPublicOutput, cp as SelectedPublicOutput, cq as ServiceAuthorization, cr as ServiceOutputContext, cs as ServiceOutputDecorator, ct as ServiceResult, cu as SingleResult, cv as Sort, cw as SortOrder, cx as StandardSchemaFailure, cy as StandardSchemaInferOutput, cz as StandardSchemaIssue, cA as StandardSchemaPathSegment, cB as StandardSchemaResult, cC as StandardSchemaSuccess, cD as StandardSchemaV1, cE as StatusCodes, cF as SubListBody, cG as SubOperationAccess, cH as SubPopulate, cI as SubQueryEntry, cJ as SubReadBody, cK as SubRouteGuardOptions, cL as SubdocumentBulkRecord, cM as SubdocumentBulkUpdateInput, cN as SubdocumentCreateAuthorization, cO as SubdocumentCreateInput, cP as SubdocumentCreateOptions, cQ as SubdocumentCreateVisibilityAuthorization, cR as SubdocumentDeleteAuthorization, cS as SubdocumentDeleteOptions, cT as SubdocumentGateAuthorization, cU as SubdocumentId, cV as SubdocumentInputAuthorization, cW as SubdocumentListOptions, cX as SubdocumentModel, cY as SubdocumentMutationAuthorization, cZ as SubdocumentName, c_ as SubdocumentOutputAuthorization, c$ as SubdocumentParentArgs, d0 as SubdocumentParentOptions, d1 as SubdocumentReadAuthorization, d2 as SubdocumentReadOptions, d3 as SubdocumentRecord, d4 as SubdocumentUpdateOptions, d5 as SubdocumentVirtuals, d6 as SubdocumentVisibilityAuthorization, d7 as SuperstructFailureLike, d8 as SuperstructValidateLike, d9 as Task, da as TaskType, db as TransformAccess, dc as TypedFilter, dd as UpdateByIdArgs, de as UpdateByIdOptions, df as UpdateOneArgs, dg as UpdateOneOptions, dh as UpdateQueryInput, di as UpsertArgs, dj as UpsertOptions, dk as UpsertQueryInput, dl as ValibotIssueLike, dm as ValibotPathItemLike, dn as ValibotSafeParseLike, dp as ValibotSafeParseResult, dq as ValidateAccess, dr as ValidateRule, ds as Validation, dt as ValidationError, du as VineValidationErrorLike, dv as VineValidationMessageLike, dw as VineValidatorLike, dx as VirtualSubModel, dy as WithVirtuals, dz as YupSchemaLike, dA as YupValidationErrorLike, dB as defineRequestSchema, dC as fromAjv, dD as fromArkType, dE as fromIoTs, dF as fromJoi, dG as fromStandardSchema, dH as fromSuperstruct, dI as fromValibot, dJ as fromVine, dK as fromYup, dL as fromZod, dM as parseBody, dN as parseBodyWithSchema, dO as parseNestedBodyWithSchema, dP as parsePathParam, dQ as parseQuery } from './parsers-DFZ_6fGl.js';
2
2
  import { z } from 'zod';
3
3
  import 'mongoose';
4
4
  import 'express';
package/advanced.js CHANGED
@@ -131,6 +131,18 @@ var import_mongoose3 = __toESM(require("mongoose"));
131
131
  // src/validation/public-admission.ts
132
132
  var import_express_json_router = __toESM(require("@web-ts-toolkit/express-json-router"));
133
133
  var import_utils = require("@web-ts-toolkit/utils");
134
+
135
+ // src/acl/unsafe-snapshot-options.ts
136
+ var unsafeSnapshotOptions = [
137
+ "unsafeSkipListDocumentSnapshotChecks",
138
+ "unsafeSkipReadDocumentSnapshotChecks",
139
+ "unsafeSkipListOutputSnapshotChecks",
140
+ "unsafeSkipReadOutputSnapshotChecks",
141
+ "unsafeSkipListNestedDocumentSnapshotChecks",
142
+ "unsafeSkipReadNestedDocumentSnapshotChecks"
143
+ ];
144
+
145
+ // src/validation/public-admission.ts
134
146
  var privateControls = [
135
147
  "authorization",
136
148
  "overrides",
@@ -139,6 +151,7 @@ var privateControls = [
139
151
  "execution",
140
152
  "executionContext",
141
153
  "serviceExecutionContext",
154
+ "snapshotDerivation",
142
155
  "resolvedAuthorization",
143
156
  "preparedQuery",
144
157
  "preparedFilter",
@@ -147,8 +160,7 @@ var privateControls = [
147
160
  "skipParsing",
148
161
  "skipAuthorization",
149
162
  "alreadyAuthorized",
150
- "unsafeSkipListDocumentSnapshotChecks",
151
- "unsafeSkipReadDocumentSnapshotChecks",
163
+ ...unsafeSnapshotOptions,
152
164
  "operation"
153
165
  ];
154
166
  var PublicAdmissionError = class extends import_express_json_router.default.clientErrors.BadRequestError {
@@ -176,7 +188,7 @@ function assertPublicAdmission(input, kind = "envelope") {
176
188
  for (const key of privateControls) {
177
189
  if (key in record2) {
178
190
  throw new PublicAdmissionError(
179
- key === "unsafeSkipListDocumentSnapshotChecks" || key === "unsafeSkipReadDocumentSnapshotChecks" ? `Unsupported public control ${path}.${key}; this unsafe flag is server model configuration only` : `Unsupported public control ${path}.${key}; use explicit per-call internal service options for backend authorization`
191
+ key.startsWith("unsafeSkip") ? `Unsupported public control ${path}.${key}; this unsafe flag is server model configuration only` : `Unsupported public control ${path}.${key}; use explicit per-call internal service options for backend authorization`
180
192
  );
181
193
  }
182
194
  }
@@ -2069,7 +2081,11 @@ var AccessRuntime = class {
2069
2081
  operationAccess: false,
2070
2082
  modelPermissionPrefix: "",
2071
2083
  unsafeSkipListDocumentSnapshotChecks: false,
2072
- unsafeSkipReadDocumentSnapshotChecks: false
2084
+ unsafeSkipReadDocumentSnapshotChecks: false,
2085
+ unsafeSkipListOutputSnapshotChecks: false,
2086
+ unsafeSkipReadOutputSnapshotChecks: false,
2087
+ unsafeSkipListNestedDocumentSnapshotChecks: false,
2088
+ unsafeSkipReadNestedDocumentSnapshotChecks: false
2073
2089
  }).build();
2074
2090
  this.modelOptions = {};
2075
2091
  this.modelJsonSchemas = {};
@@ -2290,10 +2306,12 @@ var AccessRuntime = class {
2290
2306
  const snapshotFlagChanged = (newValue, key, target, oldValue) => {
2291
2307
  target[key] = newValue === true;
2292
2308
  if (newValue !== true || oldValue === true) return;
2293
- const operation = key === "unsafeSkipReadDocumentSnapshotChecks" ? "read" : "list";
2309
+ const operation = key.startsWith("unsafeSkipRead") ? "read" : "list";
2310
+ const category = key.includes("NestedDocument") ? "nested-document" : key.includes("Output") ? "output" : "document";
2311
+ const risk = category === "output" ? "output mutation" : "source mutation";
2294
2312
  try {
2295
2313
  this.getGlobalOption("logger")?.warn?.(
2296
- `UNSAFE: ${operation} document snapshot checks disabled; source mutation can leave stale authorization decisions. Restore ${key}=false after the temporary workaround.`,
2314
+ `UNSAFE: ${operation} ${category} snapshot checks disabled; ${risk} can leave stale authorization decisions. Restore ${key}=false after the temporary workaround.`,
2297
2315
  { modelName }
2298
2316
  );
2299
2317
  } catch {
@@ -2303,7 +2321,7 @@ var AccessRuntime = class {
2303
2321
  refreshPermissionMetadata(target);
2304
2322
  }).onchange("modelPermissionPrefix", function(_newval, _key, target) {
2305
2323
  refreshPermissionMetadata(target);
2306
- }).onchange("unsafeSkipListDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadDocumentSnapshotChecks", snapshotFlagChanged).onchange("basePath", function(newval, key, target) {
2324
+ }).onchange("unsafeSkipListDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipListOutputSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadOutputSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipListNestedDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadNestedDocumentSnapshotChecks", snapshotFlagChanged).onchange("basePath", function(newval, key, target) {
2307
2325
  target[key] = normalizeBasePath(
2308
2326
  modelName,
2309
2327
  (0, import_utils13.isString)(newval) || (0, import_utils13.isNil)(newval) ? newval : void 0
package/advanced.mjs CHANGED
@@ -49,6 +49,18 @@ import mongoose from "mongoose";
49
49
  // src/validation/public-admission.ts
50
50
  import JsonRouter from "@web-ts-toolkit/express-json-router";
51
51
  import { isPlainObject } from "@web-ts-toolkit/utils";
52
+
53
+ // src/acl/unsafe-snapshot-options.ts
54
+ var unsafeSnapshotOptions = [
55
+ "unsafeSkipListDocumentSnapshotChecks",
56
+ "unsafeSkipReadDocumentSnapshotChecks",
57
+ "unsafeSkipListOutputSnapshotChecks",
58
+ "unsafeSkipReadOutputSnapshotChecks",
59
+ "unsafeSkipListNestedDocumentSnapshotChecks",
60
+ "unsafeSkipReadNestedDocumentSnapshotChecks"
61
+ ];
62
+
63
+ // src/validation/public-admission.ts
52
64
  var privateControls = [
53
65
  "authorization",
54
66
  "overrides",
@@ -57,6 +69,7 @@ var privateControls = [
57
69
  "execution",
58
70
  "executionContext",
59
71
  "serviceExecutionContext",
72
+ "snapshotDerivation",
60
73
  "resolvedAuthorization",
61
74
  "preparedQuery",
62
75
  "preparedFilter",
@@ -65,8 +78,7 @@ var privateControls = [
65
78
  "skipParsing",
66
79
  "skipAuthorization",
67
80
  "alreadyAuthorized",
68
- "unsafeSkipListDocumentSnapshotChecks",
69
- "unsafeSkipReadDocumentSnapshotChecks",
81
+ ...unsafeSnapshotOptions,
70
82
  "operation"
71
83
  ];
72
84
  var PublicAdmissionError = class extends JsonRouter.clientErrors.BadRequestError {
@@ -94,7 +106,7 @@ function assertPublicAdmission(input, kind = "envelope") {
94
106
  for (const key of privateControls) {
95
107
  if (key in record2) {
96
108
  throw new PublicAdmissionError(
97
- key === "unsafeSkipListDocumentSnapshotChecks" || key === "unsafeSkipReadDocumentSnapshotChecks" ? `Unsupported public control ${path}.${key}; this unsafe flag is server model configuration only` : `Unsupported public control ${path}.${key}; use explicit per-call internal service options for backend authorization`
109
+ key.startsWith("unsafeSkip") ? `Unsupported public control ${path}.${key}; this unsafe flag is server model configuration only` : `Unsupported public control ${path}.${key}; use explicit per-call internal service options for backend authorization`
98
110
  );
99
111
  }
100
112
  }
@@ -2000,7 +2012,11 @@ var AccessRuntime = class {
2000
2012
  operationAccess: false,
2001
2013
  modelPermissionPrefix: "",
2002
2014
  unsafeSkipListDocumentSnapshotChecks: false,
2003
- unsafeSkipReadDocumentSnapshotChecks: false
2015
+ unsafeSkipReadDocumentSnapshotChecks: false,
2016
+ unsafeSkipListOutputSnapshotChecks: false,
2017
+ unsafeSkipReadOutputSnapshotChecks: false,
2018
+ unsafeSkipListNestedDocumentSnapshotChecks: false,
2019
+ unsafeSkipReadNestedDocumentSnapshotChecks: false
2004
2020
  }).build();
2005
2021
  this.modelOptions = {};
2006
2022
  this.modelJsonSchemas = {};
@@ -2221,10 +2237,12 @@ var AccessRuntime = class {
2221
2237
  const snapshotFlagChanged = (newValue, key, target, oldValue) => {
2222
2238
  target[key] = newValue === true;
2223
2239
  if (newValue !== true || oldValue === true) return;
2224
- const operation = key === "unsafeSkipReadDocumentSnapshotChecks" ? "read" : "list";
2240
+ const operation = key.startsWith("unsafeSkipRead") ? "read" : "list";
2241
+ const category = key.includes("NestedDocument") ? "nested-document" : key.includes("Output") ? "output" : "document";
2242
+ const risk = category === "output" ? "output mutation" : "source mutation";
2225
2243
  try {
2226
2244
  this.getGlobalOption("logger")?.warn?.(
2227
- `UNSAFE: ${operation} document snapshot checks disabled; source mutation can leave stale authorization decisions. Restore ${key}=false after the temporary workaround.`,
2245
+ `UNSAFE: ${operation} ${category} snapshot checks disabled; ${risk} can leave stale authorization decisions. Restore ${key}=false after the temporary workaround.`,
2228
2246
  { modelName }
2229
2247
  );
2230
2248
  } catch {
@@ -2234,7 +2252,7 @@ var AccessRuntime = class {
2234
2252
  refreshPermissionMetadata(target);
2235
2253
  }).onchange("modelPermissionPrefix", function(_newval, _key, target) {
2236
2254
  refreshPermissionMetadata(target);
2237
- }).onchange("unsafeSkipListDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadDocumentSnapshotChecks", snapshotFlagChanged).onchange("basePath", function(newval, key, target) {
2255
+ }).onchange("unsafeSkipListDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipListOutputSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadOutputSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipListNestedDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadNestedDocumentSnapshotChecks", snapshotFlagChanged).onchange("basePath", function(newval, key, target) {
2238
2256
  target[key] = normalizeBasePath(
2239
2257
  modelName,
2240
2258
  isString3(newval) || isNil2(newval) ? newval : void 0
package/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import mongoose, { Schema } from 'mongoose';
2
2
  import { Response, NextFunction, RequestHandler, Router } from 'express';
3
- import { A as AccessRouterBaseRequest, aq as GuardHook, aT as ModelRequest, dR as AccessRuntime, _ as DataRouterOptions, Y as DataRequest, dS as DataService, aa as ExtendedDataRouterOptions, af as Filter, bo as Projection, cv as Sort, bk as Populate, aU as ModelRouterOptions, dT as Service, dU as PublicService, b3 as ModelVirtualRecordAccess, aZ as ModelVirtualDescriptor, a$ as ModelVirtualGetter, b0 as ModelVirtualLeaf, ac as ExtendedModelRouterOptions, ds as Validation, cf as RootRouterOptions, dV as OpenApiRouterOptions, dW as OpenApiRegistryOptions, dX as OpenApiRouteDescriptor, dY as OpenApiDocumentOptions, dZ as OpenApiParameter, d_ as OpenApiSchema, d$ as OpenApiResponses, ao as GlobalOptions, a2 as DefaultModelRouterOptions, ab as ExtendedDefaultModelRouterOptions } from './parsers-bP4gXehf.mjs';
4
- export { e0 as AccessRouterPermissionMap, e1 as AccessRouterPermissions, c as AccessRouterRequest, d as AccessRouterRequestExtensions, l as AjvErrorObjectLike, n as AjvValidatorLike, o as AllowedOutputFieldOptions, p as ArkTypeErrorsLike, q as ArkTypeLike, s as AuthorizedListResult, t as AuthorizedSingleResult, H as CreateAuthorization, N as DataFieldOptions, a7 as DocumentAuthorization, ad as FieldAuthorization, ae as FieldOperationAccess, ap as GlobalPermissionValue, ar as HydrationMode, au as InputFieldAuthorization, av as InputFieldPath, aw as IoTsContextEntryLike, ax as IoTsDecodeErrorLike, ay as IoTsDecoderLike, az as JoiSchemaLike, aA as JoiValidationErrorDetailLike, aG as MaybePromise, aH as ModelBaseFilterHook, aJ as ModelDeleteHook, aK as ModelDocPermissionsHook, aM as ModelDocumentHook, aN as ModelHook, aP as ModelHydrationOptions, aQ as ModelIdentifierHook, aR as ModelListHook, aS as ModelOverrideFilterHook, aV as ModelValidateHook, aW as ModelVirtualAccess, aX as ModelVirtualAccessRecord, aY as ModelVirtualContext, a_ as ModelVirtualDoc, b1 as ModelVirtualPopulateDependency, b2 as ModelVirtualPopulateInputs, b4 as ModelVirtuals, b5 as MutationAuthorization, b6 as NewArgs, b7 as NewOptions, e2 as OpenApiMethod, b8 as OperationAccess, b9 as OperationAuthorization, ba as OutputAuthorization, bb as OutputFieldOptions, bc as OutputFieldPath, bd as OutputPlanningOptions, bg as PairedRouteAccess, bj as PermissionSchema, e3 as Permissions, bm as PopulatePlanningOptions, bA as PublicSubdocumentCreateOptions, bB as PublicSubdocumentListOptions, bC as PublicSubdocumentMutationOptions, bD as PublicSubdocumentReadOptions, bJ as RelatedAuthorization, bL as RequestSchemaAdapter, bM as RequestSchemaFailure, bN as RequestSchemaIssue, bO as RequestSchemaLike, bP as RequestSchemaOptions, bQ as RequestSchemaResult, bR as RequestSchemaSuccess, bS as RequestSchemaValidator, ci as RouteBaseAccess, cj as RouteGuardAccess, ck as RouteVariant, cl as RouteVariantAccess, cm as RowAuthorization, cq as ServiceAuthorization, cr as ServiceOutputContext, cs as ServiceOutputDecorator, cx as StandardSchemaFailure, cy as StandardSchemaInferOutput, cz as StandardSchemaIssue, cA as StandardSchemaPathSegment, cB as StandardSchemaResult, cC as StandardSchemaSuccess, cD as StandardSchemaV1, cG as SubOperationAccess, cK as SubRouteGuardOptions, cN as SubdocumentCreateAuthorization, cP as SubdocumentCreateOptions, cQ as SubdocumentCreateVisibilityAuthorization, cR as SubdocumentDeleteAuthorization, cS as SubdocumentDeleteOptions, cT as SubdocumentGateAuthorization, cV as SubdocumentInputAuthorization, cW as SubdocumentListOptions, cX as SubdocumentModel, cY as SubdocumentMutationAuthorization, cZ as SubdocumentName, c_ as SubdocumentOutputAuthorization, d1 as SubdocumentReadAuthorization, d2 as SubdocumentReadOptions, d4 as SubdocumentUpdateOptions, d5 as SubdocumentVirtuals, d6 as SubdocumentVisibilityAuthorization, d7 as SuperstructFailureLike, d8 as SuperstructValidateLike, dl as ValibotIssueLike, dm as ValibotPathItemLike, dn as ValibotSafeParseLike, dp as ValibotSafeParseResult, du as VineValidationErrorLike, dv as VineValidationMessageLike, dw as VineValidatorLike, dx as VirtualSubModel, dy as WithVirtuals, dz as YupSchemaLike, dA as YupValidationErrorLike, e4 as defaultRuntime, dB as defineRequestSchema, dC as fromAjv, dD as fromArkType, dE as fromIoTs, dF as fromJoi, dG as fromStandardSchema, dH as fromSuperstruct, dI as fromValibot, dJ as fromVine, dK as fromYup, dL as fromZod } from './parsers-bP4gXehf.mjs';
3
+ import { A as AccessRouterBaseRequest, aq as GuardHook, aT as ModelRequest, dR as AccessRuntime, _ as DataRouterOptions, Y as DataRequest, dS as DataService, aa as ExtendedDataRouterOptions, af as Filter, bo as Projection, cv as Sort, bk as Populate, aU as ModelRouterOptions, dT as Service, dU as PublicService, b3 as ModelVirtualRecordAccess, aZ as ModelVirtualDescriptor, a$ as ModelVirtualGetter, b0 as ModelVirtualLeaf, ac as ExtendedModelRouterOptions, ds as Validation, cf as RootRouterOptions, dV as OpenApiRouterOptions, dW as OpenApiRegistryOptions, dX as OpenApiRouteDescriptor, dY as OpenApiDocumentOptions, dZ as OpenApiParameter, d_ as OpenApiSchema, d$ as OpenApiResponses, ao as GlobalOptions, a2 as DefaultModelRouterOptions, ab as ExtendedDefaultModelRouterOptions } from './parsers-DFZ_6fGl.mjs';
4
+ export { e0 as AccessRouterPermissionMap, e1 as AccessRouterPermissions, c as AccessRouterRequest, d as AccessRouterRequestExtensions, l as AjvErrorObjectLike, n as AjvValidatorLike, o as AllowedOutputFieldOptions, p as ArkTypeErrorsLike, q as ArkTypeLike, s as AuthorizedListResult, t as AuthorizedSingleResult, H as CreateAuthorization, N as DataFieldOptions, a7 as DocumentAuthorization, ad as FieldAuthorization, ae as FieldOperationAccess, ap as GlobalPermissionValue, ar as HydrationMode, au as InputFieldAuthorization, av as InputFieldPath, aw as IoTsContextEntryLike, ax as IoTsDecodeErrorLike, ay as IoTsDecoderLike, az as JoiSchemaLike, aA as JoiValidationErrorDetailLike, aG as MaybePromise, aH as ModelBaseFilterHook, aJ as ModelDeleteHook, aK as ModelDocPermissionsHook, aM as ModelDocumentHook, aN as ModelHook, aP as ModelHydrationOptions, aQ as ModelIdentifierHook, aR as ModelListHook, aS as ModelOverrideFilterHook, aV as ModelValidateHook, aW as ModelVirtualAccess, aX as ModelVirtualAccessRecord, aY as ModelVirtualContext, a_ as ModelVirtualDoc, b1 as ModelVirtualPopulateDependency, b2 as ModelVirtualPopulateInputs, b4 as ModelVirtuals, b5 as MutationAuthorization, b6 as NewArgs, b7 as NewOptions, e2 as OpenApiMethod, b8 as OperationAccess, b9 as OperationAuthorization, ba as OutputAuthorization, bb as OutputFieldOptions, bc as OutputFieldPath, bd as OutputPlanningOptions, bg as PairedRouteAccess, bj as PermissionSchema, e3 as Permissions, bm as PopulatePlanningOptions, bA as PublicSubdocumentCreateOptions, bB as PublicSubdocumentListOptions, bC as PublicSubdocumentMutationOptions, bD as PublicSubdocumentReadOptions, bJ as RelatedAuthorization, bL as RequestSchemaAdapter, bM as RequestSchemaFailure, bN as RequestSchemaIssue, bO as RequestSchemaLike, bP as RequestSchemaOptions, bQ as RequestSchemaResult, bR as RequestSchemaSuccess, bS as RequestSchemaValidator, ci as RouteBaseAccess, cj as RouteGuardAccess, ck as RouteVariant, cl as RouteVariantAccess, cm as RowAuthorization, cq as ServiceAuthorization, cr as ServiceOutputContext, cs as ServiceOutputDecorator, cx as StandardSchemaFailure, cy as StandardSchemaInferOutput, cz as StandardSchemaIssue, cA as StandardSchemaPathSegment, cB as StandardSchemaResult, cC as StandardSchemaSuccess, cD as StandardSchemaV1, cG as SubOperationAccess, cK as SubRouteGuardOptions, cN as SubdocumentCreateAuthorization, cP as SubdocumentCreateOptions, cQ as SubdocumentCreateVisibilityAuthorization, cR as SubdocumentDeleteAuthorization, cS as SubdocumentDeleteOptions, cT as SubdocumentGateAuthorization, cV as SubdocumentInputAuthorization, cW as SubdocumentListOptions, cX as SubdocumentModel, cY as SubdocumentMutationAuthorization, cZ as SubdocumentName, c_ as SubdocumentOutputAuthorization, d1 as SubdocumentReadAuthorization, d2 as SubdocumentReadOptions, d4 as SubdocumentUpdateOptions, d5 as SubdocumentVirtuals, d6 as SubdocumentVisibilityAuthorization, d7 as SuperstructFailureLike, d8 as SuperstructValidateLike, dl as ValibotIssueLike, dm as ValibotPathItemLike, dn as ValibotSafeParseLike, dp as ValibotSafeParseResult, du as VineValidationErrorLike, dv as VineValidationMessageLike, dw as VineValidatorLike, dx as VirtualSubModel, dy as WithVirtuals, dz as YupSchemaLike, dA as YupValidationErrorLike, e4 as defaultRuntime, dB as defineRequestSchema, dC as fromAjv, dD as fromArkType, dE as fromIoTs, dF as fromJoi, dG as fromStandardSchema, dH as fromSuperstruct, dI as fromValibot, dJ as fromVine, dK as fromYup, dL as fromZod } from './parsers-DFZ_6fGl.mjs';
5
5
  import JsonRouter from '@web-ts-toolkit/express-json-router';
6
6
  import 'zod';
7
7
 
package/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import mongoose, { Schema } from 'mongoose';
2
2
  import { Response, NextFunction, RequestHandler, Router } from 'express';
3
- import { A as AccessRouterBaseRequest, aq as GuardHook, aT as ModelRequest, dR as AccessRuntime, _ as DataRouterOptions, Y as DataRequest, dS as DataService, aa as ExtendedDataRouterOptions, af as Filter, bo as Projection, cv as Sort, bk as Populate, aU as ModelRouterOptions, dT as Service, dU as PublicService, b3 as ModelVirtualRecordAccess, aZ as ModelVirtualDescriptor, a$ as ModelVirtualGetter, b0 as ModelVirtualLeaf, ac as ExtendedModelRouterOptions, ds as Validation, cf as RootRouterOptions, dV as OpenApiRouterOptions, dW as OpenApiRegistryOptions, dX as OpenApiRouteDescriptor, dY as OpenApiDocumentOptions, dZ as OpenApiParameter, d_ as OpenApiSchema, d$ as OpenApiResponses, ao as GlobalOptions, a2 as DefaultModelRouterOptions, ab as ExtendedDefaultModelRouterOptions } from './parsers-bP4gXehf.js';
4
- export { e0 as AccessRouterPermissionMap, e1 as AccessRouterPermissions, c as AccessRouterRequest, d as AccessRouterRequestExtensions, l as AjvErrorObjectLike, n as AjvValidatorLike, o as AllowedOutputFieldOptions, p as ArkTypeErrorsLike, q as ArkTypeLike, s as AuthorizedListResult, t as AuthorizedSingleResult, H as CreateAuthorization, N as DataFieldOptions, a7 as DocumentAuthorization, ad as FieldAuthorization, ae as FieldOperationAccess, ap as GlobalPermissionValue, ar as HydrationMode, au as InputFieldAuthorization, av as InputFieldPath, aw as IoTsContextEntryLike, ax as IoTsDecodeErrorLike, ay as IoTsDecoderLike, az as JoiSchemaLike, aA as JoiValidationErrorDetailLike, aG as MaybePromise, aH as ModelBaseFilterHook, aJ as ModelDeleteHook, aK as ModelDocPermissionsHook, aM as ModelDocumentHook, aN as ModelHook, aP as ModelHydrationOptions, aQ as ModelIdentifierHook, aR as ModelListHook, aS as ModelOverrideFilterHook, aV as ModelValidateHook, aW as ModelVirtualAccess, aX as ModelVirtualAccessRecord, aY as ModelVirtualContext, a_ as ModelVirtualDoc, b1 as ModelVirtualPopulateDependency, b2 as ModelVirtualPopulateInputs, b4 as ModelVirtuals, b5 as MutationAuthorization, b6 as NewArgs, b7 as NewOptions, e2 as OpenApiMethod, b8 as OperationAccess, b9 as OperationAuthorization, ba as OutputAuthorization, bb as OutputFieldOptions, bc as OutputFieldPath, bd as OutputPlanningOptions, bg as PairedRouteAccess, bj as PermissionSchema, e3 as Permissions, bm as PopulatePlanningOptions, bA as PublicSubdocumentCreateOptions, bB as PublicSubdocumentListOptions, bC as PublicSubdocumentMutationOptions, bD as PublicSubdocumentReadOptions, bJ as RelatedAuthorization, bL as RequestSchemaAdapter, bM as RequestSchemaFailure, bN as RequestSchemaIssue, bO as RequestSchemaLike, bP as RequestSchemaOptions, bQ as RequestSchemaResult, bR as RequestSchemaSuccess, bS as RequestSchemaValidator, ci as RouteBaseAccess, cj as RouteGuardAccess, ck as RouteVariant, cl as RouteVariantAccess, cm as RowAuthorization, cq as ServiceAuthorization, cr as ServiceOutputContext, cs as ServiceOutputDecorator, cx as StandardSchemaFailure, cy as StandardSchemaInferOutput, cz as StandardSchemaIssue, cA as StandardSchemaPathSegment, cB as StandardSchemaResult, cC as StandardSchemaSuccess, cD as StandardSchemaV1, cG as SubOperationAccess, cK as SubRouteGuardOptions, cN as SubdocumentCreateAuthorization, cP as SubdocumentCreateOptions, cQ as SubdocumentCreateVisibilityAuthorization, cR as SubdocumentDeleteAuthorization, cS as SubdocumentDeleteOptions, cT as SubdocumentGateAuthorization, cV as SubdocumentInputAuthorization, cW as SubdocumentListOptions, cX as SubdocumentModel, cY as SubdocumentMutationAuthorization, cZ as SubdocumentName, c_ as SubdocumentOutputAuthorization, d1 as SubdocumentReadAuthorization, d2 as SubdocumentReadOptions, d4 as SubdocumentUpdateOptions, d5 as SubdocumentVirtuals, d6 as SubdocumentVisibilityAuthorization, d7 as SuperstructFailureLike, d8 as SuperstructValidateLike, dl as ValibotIssueLike, dm as ValibotPathItemLike, dn as ValibotSafeParseLike, dp as ValibotSafeParseResult, du as VineValidationErrorLike, dv as VineValidationMessageLike, dw as VineValidatorLike, dx as VirtualSubModel, dy as WithVirtuals, dz as YupSchemaLike, dA as YupValidationErrorLike, e4 as defaultRuntime, dB as defineRequestSchema, dC as fromAjv, dD as fromArkType, dE as fromIoTs, dF as fromJoi, dG as fromStandardSchema, dH as fromSuperstruct, dI as fromValibot, dJ as fromVine, dK as fromYup, dL as fromZod } from './parsers-bP4gXehf.js';
3
+ import { A as AccessRouterBaseRequest, aq as GuardHook, aT as ModelRequest, dR as AccessRuntime, _ as DataRouterOptions, Y as DataRequest, dS as DataService, aa as ExtendedDataRouterOptions, af as Filter, bo as Projection, cv as Sort, bk as Populate, aU as ModelRouterOptions, dT as Service, dU as PublicService, b3 as ModelVirtualRecordAccess, aZ as ModelVirtualDescriptor, a$ as ModelVirtualGetter, b0 as ModelVirtualLeaf, ac as ExtendedModelRouterOptions, ds as Validation, cf as RootRouterOptions, dV as OpenApiRouterOptions, dW as OpenApiRegistryOptions, dX as OpenApiRouteDescriptor, dY as OpenApiDocumentOptions, dZ as OpenApiParameter, d_ as OpenApiSchema, d$ as OpenApiResponses, ao as GlobalOptions, a2 as DefaultModelRouterOptions, ab as ExtendedDefaultModelRouterOptions } from './parsers-DFZ_6fGl.js';
4
+ export { e0 as AccessRouterPermissionMap, e1 as AccessRouterPermissions, c as AccessRouterRequest, d as AccessRouterRequestExtensions, l as AjvErrorObjectLike, n as AjvValidatorLike, o as AllowedOutputFieldOptions, p as ArkTypeErrorsLike, q as ArkTypeLike, s as AuthorizedListResult, t as AuthorizedSingleResult, H as CreateAuthorization, N as DataFieldOptions, a7 as DocumentAuthorization, ad as FieldAuthorization, ae as FieldOperationAccess, ap as GlobalPermissionValue, ar as HydrationMode, au as InputFieldAuthorization, av as InputFieldPath, aw as IoTsContextEntryLike, ax as IoTsDecodeErrorLike, ay as IoTsDecoderLike, az as JoiSchemaLike, aA as JoiValidationErrorDetailLike, aG as MaybePromise, aH as ModelBaseFilterHook, aJ as ModelDeleteHook, aK as ModelDocPermissionsHook, aM as ModelDocumentHook, aN as ModelHook, aP as ModelHydrationOptions, aQ as ModelIdentifierHook, aR as ModelListHook, aS as ModelOverrideFilterHook, aV as ModelValidateHook, aW as ModelVirtualAccess, aX as ModelVirtualAccessRecord, aY as ModelVirtualContext, a_ as ModelVirtualDoc, b1 as ModelVirtualPopulateDependency, b2 as ModelVirtualPopulateInputs, b4 as ModelVirtuals, b5 as MutationAuthorization, b6 as NewArgs, b7 as NewOptions, e2 as OpenApiMethod, b8 as OperationAccess, b9 as OperationAuthorization, ba as OutputAuthorization, bb as OutputFieldOptions, bc as OutputFieldPath, bd as OutputPlanningOptions, bg as PairedRouteAccess, bj as PermissionSchema, e3 as Permissions, bm as PopulatePlanningOptions, bA as PublicSubdocumentCreateOptions, bB as PublicSubdocumentListOptions, bC as PublicSubdocumentMutationOptions, bD as PublicSubdocumentReadOptions, bJ as RelatedAuthorization, bL as RequestSchemaAdapter, bM as RequestSchemaFailure, bN as RequestSchemaIssue, bO as RequestSchemaLike, bP as RequestSchemaOptions, bQ as RequestSchemaResult, bR as RequestSchemaSuccess, bS as RequestSchemaValidator, ci as RouteBaseAccess, cj as RouteGuardAccess, ck as RouteVariant, cl as RouteVariantAccess, cm as RowAuthorization, cq as ServiceAuthorization, cr as ServiceOutputContext, cs as ServiceOutputDecorator, cx as StandardSchemaFailure, cy as StandardSchemaInferOutput, cz as StandardSchemaIssue, cA as StandardSchemaPathSegment, cB as StandardSchemaResult, cC as StandardSchemaSuccess, cD as StandardSchemaV1, cG as SubOperationAccess, cK as SubRouteGuardOptions, cN as SubdocumentCreateAuthorization, cP as SubdocumentCreateOptions, cQ as SubdocumentCreateVisibilityAuthorization, cR as SubdocumentDeleteAuthorization, cS as SubdocumentDeleteOptions, cT as SubdocumentGateAuthorization, cV as SubdocumentInputAuthorization, cW as SubdocumentListOptions, cX as SubdocumentModel, cY as SubdocumentMutationAuthorization, cZ as SubdocumentName, c_ as SubdocumentOutputAuthorization, d1 as SubdocumentReadAuthorization, d2 as SubdocumentReadOptions, d4 as SubdocumentUpdateOptions, d5 as SubdocumentVirtuals, d6 as SubdocumentVisibilityAuthorization, d7 as SuperstructFailureLike, d8 as SuperstructValidateLike, dl as ValibotIssueLike, dm as ValibotPathItemLike, dn as ValibotSafeParseLike, dp as ValibotSafeParseResult, du as VineValidationErrorLike, dv as VineValidationMessageLike, dw as VineValidatorLike, dx as VirtualSubModel, dy as WithVirtuals, dz as YupSchemaLike, dA as YupValidationErrorLike, e4 as defaultRuntime, dB as defineRequestSchema, dC as fromAjv, dD as fromArkType, dE as fromIoTs, dF as fromJoi, dG as fromStandardSchema, dH as fromSuperstruct, dI as fromValibot, dJ as fromVine, dK as fromYup, dL as fromZod } from './parsers-DFZ_6fGl.js';
5
5
  import JsonRouter from '@web-ts-toolkit/express-json-router';
6
6
  import 'zod';
7
7
 
package/index.js CHANGED
@@ -29,6 +29,21 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
29
  ));
30
30
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
31
 
32
+ // src/acl/unsafe-snapshot-options.ts
33
+ var unsafeSnapshotOptions;
34
+ var init_unsafe_snapshot_options = __esm({
35
+ "src/acl/unsafe-snapshot-options.ts"() {
36
+ unsafeSnapshotOptions = [
37
+ "unsafeSkipListDocumentSnapshotChecks",
38
+ "unsafeSkipReadDocumentSnapshotChecks",
39
+ "unsafeSkipListOutputSnapshotChecks",
40
+ "unsafeSkipReadOutputSnapshotChecks",
41
+ "unsafeSkipListNestedDocumentSnapshotChecks",
42
+ "unsafeSkipReadNestedDocumentSnapshotChecks"
43
+ ];
44
+ }
45
+ });
46
+
32
47
  // src/validation/public-admission.ts
33
48
  function assertPublicAdmission(input, kind = "envelope") {
34
49
  const pending = [{ value: input, kind, path: "request" }];
@@ -48,7 +63,7 @@ function assertPublicAdmission(input, kind = "envelope") {
48
63
  for (const key of privateControls) {
49
64
  if (key in record3) {
50
65
  throw new PublicAdmissionError(
51
- key === "unsafeSkipListDocumentSnapshotChecks" || key === "unsafeSkipReadDocumentSnapshotChecks" ? `Unsupported public control ${path}.${key}; this unsafe flag is server model configuration only` : `Unsupported public control ${path}.${key}; use explicit per-call internal service options for backend authorization`
66
+ key.startsWith("unsafeSkip") ? `Unsupported public control ${path}.${key}; this unsafe flag is server model configuration only` : `Unsupported public control ${path}.${key}; use explicit per-call internal service options for backend authorization`
52
67
  );
53
68
  }
54
69
  }
@@ -133,6 +148,7 @@ var init_public_admission = __esm({
133
148
  "src/validation/public-admission.ts"() {
134
149
  import_express_json_router = __toESM(require("@web-ts-toolkit/express-json-router"));
135
150
  import_utils = require("@web-ts-toolkit/utils");
151
+ init_unsafe_snapshot_options();
136
152
  privateControls = [
137
153
  "authorization",
138
154
  "overrides",
@@ -141,6 +157,7 @@ var init_public_admission = __esm({
141
157
  "execution",
142
158
  "executionContext",
143
159
  "serviceExecutionContext",
160
+ "snapshotDerivation",
144
161
  "resolvedAuthorization",
145
162
  "preparedQuery",
146
163
  "preparedFilter",
@@ -149,8 +166,7 @@ var init_public_admission = __esm({
149
166
  "skipParsing",
150
167
  "skipAuthorization",
151
168
  "alreadyAuthorized",
152
- "unsafeSkipListDocumentSnapshotChecks",
153
- "unsafeSkipReadDocumentSnapshotChecks",
169
+ ...unsafeSnapshotOptions,
154
170
  "operation"
155
171
  ];
156
172
  PublicAdmissionError = class extends import_express_json_router.default.clientErrors.BadRequestError {
@@ -2846,7 +2862,11 @@ var init_runtime = __esm({
2846
2862
  operationAccess: false,
2847
2863
  modelPermissionPrefix: "",
2848
2864
  unsafeSkipListDocumentSnapshotChecks: false,
2849
- unsafeSkipReadDocumentSnapshotChecks: false
2865
+ unsafeSkipReadDocumentSnapshotChecks: false,
2866
+ unsafeSkipListOutputSnapshotChecks: false,
2867
+ unsafeSkipReadOutputSnapshotChecks: false,
2868
+ unsafeSkipListNestedDocumentSnapshotChecks: false,
2869
+ unsafeSkipReadNestedDocumentSnapshotChecks: false
2850
2870
  }).build();
2851
2871
  this.modelOptions = {};
2852
2872
  this.modelJsonSchemas = {};
@@ -3067,10 +3087,12 @@ var init_runtime = __esm({
3067
3087
  const snapshotFlagChanged = (newValue, key, target, oldValue) => {
3068
3088
  target[key] = newValue === true;
3069
3089
  if (newValue !== true || oldValue === true) return;
3070
- const operation = key === "unsafeSkipReadDocumentSnapshotChecks" ? "read" : "list";
3090
+ const operation = key.startsWith("unsafeSkipRead") ? "read" : "list";
3091
+ const category = key.includes("NestedDocument") ? "nested-document" : key.includes("Output") ? "output" : "document";
3092
+ const risk = category === "output" ? "output mutation" : "source mutation";
3071
3093
  try {
3072
3094
  this.getGlobalOption("logger")?.warn?.(
3073
- `UNSAFE: ${operation} document snapshot checks disabled; source mutation can leave stale authorization decisions. Restore ${key}=false after the temporary workaround.`,
3095
+ `UNSAFE: ${operation} ${category} snapshot checks disabled; ${risk} can leave stale authorization decisions. Restore ${key}=false after the temporary workaround.`,
3074
3096
  { modelName }
3075
3097
  );
3076
3098
  } catch {
@@ -3080,7 +3102,7 @@ var init_runtime = __esm({
3080
3102
  refreshPermissionMetadata(target);
3081
3103
  }).onchange("modelPermissionPrefix", function(_newval, _key, target) {
3082
3104
  refreshPermissionMetadata(target);
3083
- }).onchange("unsafeSkipListDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadDocumentSnapshotChecks", snapshotFlagChanged).onchange("basePath", function(newval, key, target) {
3105
+ }).onchange("unsafeSkipListDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipListOutputSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadOutputSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipListNestedDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadNestedDocumentSnapshotChecks", snapshotFlagChanged).onchange("basePath", function(newval, key, target) {
3084
3106
  target[key] = normalizeBasePath(
3085
3107
  modelName,
3086
3108
  (0, import_utils17.isString)(newval) || (0, import_utils17.isNil)(newval) ? newval : void 0
@@ -3725,6 +3747,33 @@ function assertAuthorizationBinding(call, binding) {
3725
3747
  authorizationError("request/runtime/model/scope binding mismatch");
3726
3748
  }
3727
3749
  }
3750
+ function queryOutputAccess(access) {
3751
+ return (access.operation === "read" || access.operation === "list") && (access.rowAccess === "read" || access.rowAccess === "list") && access.outputAccess === access.rowAccess && access.virtualAccess === access.rowAccess && access.docPermissionsAccess === access.rowAccess;
3752
+ }
3753
+ function nestedQueryResponse(input, access) {
3754
+ const edge = input.snapshotDerivation;
3755
+ if (!edge || !input.parent) return false;
3756
+ assertAuthorizationBinding(input.parent, edge.parentBinding);
3757
+ const parent = callRecord(input.parent);
3758
+ if (!parent.responseSnapshots || (input.applicability ?? "service") !== "service" || !queryOutputAccess(access) || !queryOutputAccess(parent.output.access))
3759
+ return false;
3760
+ if (edge.kind === "retry") {
3761
+ if (!parent.nestedResponse || access.operation !== "read" || parent.output.access.operation !== "read")
3762
+ return false;
3763
+ assertAuthorizationBinding(input.parent, input.binding);
3764
+ return true;
3765
+ }
3766
+ if (edge.kind === "related") {
3767
+ const target = parent.relatedTargets.find((target2) => target2.path === edge.path);
3768
+ return !!target && target.kind !== "count" && target.modelName === input.binding.modelName && scope(input.binding).length === 0;
3769
+ }
3770
+ if (edge.kind !== "embedded") return false;
3771
+ assertAuthorizationBinding(input.parent, { ...input.binding, scopePath: parent.binding.scopePath });
3772
+ const childScope = scope(input.binding), parentScope = scope(parent.binding);
3773
+ return childScope.length > parentScope.length && parentScope.every((part, index) => childScope[index] === part) && Object.keys(parent.output.access).every(
3774
+ (key) => access[key] === parent.output.access[key]
3775
+ );
3776
+ }
3728
3777
  function resolveServiceAuthorization(input) {
3729
3778
  const raw = copyAuthorizationValue(input.authorization);
3730
3779
  const configuration = copyAuthorizationValue(input.configuration, true);
@@ -3752,6 +3801,15 @@ function resolveServiceAuthorization(input) {
3752
3801
  const readAccess = outputAccess.rowAccess;
3753
3802
  const readResponse = input.readResponse === true && (input.applicability ?? "service") === "service" && scopePath.length === 0 && outputAccess.operation === "read" && (readAccess === "read" || readAccess === "list") && outputAccess.outputAccess === readAccess && outputAccess.virtualAccess === readAccess && outputAccess.docPermissionsAccess === readAccess && (input.parent === void 0 || callRecord(input.parent).readResponse);
3754
3803
  if (readResponse && input.parent) assertAuthorizationBinding(input.parent, input.binding);
3804
+ const nestedResponse = nestedQueryResponse(input, outputAccess);
3805
+ const listResponse = input.listResponse === true && input.parent === void 0 && (input.applicability ?? "service") === "service" && scopePath.length === 0 && outputAccess.operation === "list" && outputAccess.rowAccess === "list" && queryOutputAccess(outputAccess);
3806
+ const responseSnapshots = input.parent && (nestedResponse || readResponse) ? callRecord(input.parent).responseSnapshots : listResponse ? Object.freeze({
3807
+ skipOutput: configuration.unsafeSkipListOutputSnapshotChecks === true,
3808
+ skipNested: configuration.unsafeSkipListNestedDocumentSnapshotChecks === true
3809
+ }) : readResponse ? Object.freeze({
3810
+ skipOutput: configuration.unsafeSkipReadOutputSnapshotChecks === true,
3811
+ skipNested: configuration.unsafeSkipReadNestedDocumentSnapshotChecks === true
3812
+ }) : void 0;
3755
3813
  const call = Object.freeze(/* @__PURE__ */ Object.create(null));
3756
3814
  calls.set(call, {
3757
3815
  binding: Object.freeze({ ...input.binding, scopePath: Object.freeze(scopePath) }),
@@ -3764,7 +3822,10 @@ function resolveServiceAuthorization(input) {
3764
3822
  permissions,
3765
3823
  provenance: input.parent ? callRecord(input.parent).provenance : call,
3766
3824
  readResponse,
3767
- validateDocumentSnapshots: !(input.listResponse === true && input.parent === void 0 && (input.applicability ?? "service") === "service" && outputAccess.operation === "list" && outputAccess.rowAccess === "list" && outputAccess.outputAccess === "list" && scopePath.length === 0 && configuration.unsafeSkipListDocumentSnapshotChecks === true || readResponse && configuration.unsafeSkipReadDocumentSnapshotChecks === true)
3825
+ nestedResponse,
3826
+ responseSnapshots,
3827
+ validateOutputSnapshots: responseSnapshots?.skipOutput !== true,
3828
+ validateDocumentSnapshots: !(input.listResponse === true && input.parent === void 0 && (input.applicability ?? "service") === "service" && outputAccess.operation === "list" && outputAccess.rowAccess === "list" && outputAccess.outputAccess === "list" && scopePath.length === 0 && configuration.unsafeSkipListDocumentSnapshotChecks === true || readResponse && configuration.unsafeSkipReadDocumentSnapshotChecks === true || nestedResponse && responseSnapshots?.skipNested === true)
3768
3829
  });
3769
3830
  return call;
3770
3831
  }
@@ -3789,6 +3850,10 @@ function requiresDocumentSnapshotChecks(call, binding) {
3789
3850
  assertAuthorizationBinding(call, binding);
3790
3851
  return callRecord(call).validateDocumentSnapshots;
3791
3852
  }
3853
+ function requiresOutputSnapshotChecks(call, binding) {
3854
+ assertAuthorizationBinding(call, binding);
3855
+ return callRecord(call).validateOutputSnapshots;
3856
+ }
3792
3857
  function readServiceAuthorizationHydration(call, binding) {
3793
3858
  assertAuthorizationBinding(call, binding);
3794
3859
  return copyAuthorizationValue({ hydration: callRecord(call).configuration.hydration }, true);
@@ -4955,7 +5020,7 @@ function tryStaticRequestFieldPaths(handle, binding, access) {
4955
5020
  return decisions && [...decisions].filter(([, allowed]) => allowed).map(([field]) => field);
4956
5021
  }
4957
5022
  function unchangedOutput(output, record3) {
4958
- if (!matchesAuthorizationSnapshot(output, record3.snapshot)) return false;
5023
+ if (record3.validateSnapshot && !matchesAuthorizationSnapshot(output, record3.snapshot)) return false;
4959
5024
  const identities = outputIdentities(output);
4960
5025
  return identities.length === record3.identities.length && identities.every((identity, i) => identity === record3.identities[i]);
4961
5026
  }
@@ -4983,7 +5048,8 @@ function associateDocumentAuthorization(handle, binding, output) {
4983
5048
  outputs.set(output, {
4984
5049
  handle,
4985
5050
  snapshot: copyAuthorizationValue(output, "document"),
4986
- identities: outputIdentities(output)
5051
+ identities: outputIdentities(output),
5052
+ validateSnapshot: requiresOutputSnapshotChecks(stage.call, binding)
4987
5053
  });
4988
5054
  }
4989
5055
  function transferDocumentAuthorization(handle, use, copy) {
@@ -5188,6 +5254,10 @@ function captureModelAuthorizationConfiguration(runtime, modelName, options = ru
5188
5254
  disableFieldPermissions: options.disableFieldPermissions,
5189
5255
  unsafeSkipListDocumentSnapshotChecks: options.unsafeSkipListDocumentSnapshotChecks === true,
5190
5256
  unsafeSkipReadDocumentSnapshotChecks: options.unsafeSkipReadDocumentSnapshotChecks === true,
5257
+ unsafeSkipListOutputSnapshotChecks: options.unsafeSkipListOutputSnapshotChecks === true,
5258
+ unsafeSkipReadOutputSnapshotChecks: options.unsafeSkipReadOutputSnapshotChecks === true,
5259
+ unsafeSkipListNestedDocumentSnapshotChecks: options.unsafeSkipListNestedDocumentSnapshotChecks === true,
5260
+ unsafeSkipReadNestedDocumentSnapshotChecks: options.unsafeSkipReadNestedDocumentSnapshotChecks === true,
5191
5261
  overrideFilter: options.overrideFilter,
5192
5262
  baseFilter: options.baseFilter,
5193
5263
  idField: options.idField,
@@ -6409,7 +6479,8 @@ function authorizeEmbeddedOutputPlan(parent, child) {
6409
6479
  ...view,
6410
6480
  requestPermissions: getAuthorizationPermissions(parent.authorization, parent.authorizationBinding),
6411
6481
  authorization: serviceAuthorizationInput(view.authorization, view.relatedTargets),
6412
- parent: parent.authorization
6482
+ parent: parent.authorization,
6483
+ snapshotDerivation: { kind: "embedded", parentBinding: parent.authorizationBinding }
6413
6484
  });
6414
6485
  return { ...child, authorization, authorizationBinding: binding };
6415
6486
  }
@@ -8160,7 +8231,7 @@ function getServiceExecutors(receiver) {
8160
8231
  if (!registered) authorizationError("unregistered service receiver");
8161
8232
  return registered;
8162
8233
  }
8163
- function createServiceExecution(receiver, access, authorization, applicability = "service", relatedTargets = [], parent, configuration, requestPermissions, hydration = access.operation === "list" ? "find" : "findOne") {
8234
+ function createServiceExecution(receiver, access, authorization, applicability = "service", relatedTargets = [], parent, configuration, requestPermissions, hydration = access.operation === "list" ? "find" : "findOne", snapshotDerivation) {
8164
8235
  const registered = getServiceExecutors(receiver);
8165
8236
  const receiving = registered.binding();
8166
8237
  const binding = Object.freeze({ ...receiving, scopePath: Object.freeze([...receiving.scopePath ?? []]) });
@@ -8174,7 +8245,8 @@ function createServiceExecution(receiver, access, authorization, applicability =
8174
8245
  configuration: configuration ?? registered.configuration(),
8175
8246
  requestPermissions: requestPermissions ?? registered.permissions(),
8176
8247
  listResponse: access.operation === "list" && parent === void 0,
8177
- readResponse: access.operation === "read" && parent === void 0
8248
+ readResponse: access.operation === "read" && parent === void 0,
8249
+ snapshotDerivation
8178
8250
  });
8179
8251
  const execution = Object.freeze(/* @__PURE__ */ Object.create(null));
8180
8252
  executions.set(
@@ -8231,7 +8303,8 @@ function deriveServiceExecution(receiver, parent, access, applicability = "servi
8231
8303
  parent: record3.authorization,
8232
8304
  // The resolver authenticates root-read provenance and the unchanged owner tuple.
8233
8305
  // Effective list access is still a read; write branches cannot inherit this marker.
8234
- readResponse: record3.access.operation === "read" && access.operation === "read"
8306
+ readResponse: record3.access.operation === "read" && access.operation === "read",
8307
+ snapshotDerivation: { kind: "retry", parentBinding: record3.binding }
8235
8308
  });
8236
8309
  const execution = Object.freeze(/* @__PURE__ */ Object.create(null));
8237
8310
  executions.set(
@@ -8504,7 +8577,7 @@ function createRelatedExecution(receiver, access, parent, binding, path) {
8504
8577
  const captured = readServiceAuthorization(parent, binding);
8505
8578
  const target = captured.relatedTargets.find((entry) => entry.path === path);
8506
8579
  const policy = captured.authorization.related[path];
8507
- if (policy && (!target || target.modelName !== getServiceExecutors(receiver).binding().modelName))
8580
+ if ((target || policy) && (!target || target.modelName !== getServiceExecutors(receiver).binding().modelName))
8508
8581
  authorizationError(`related model mismatch: ${path}`);
8509
8582
  const execution = createServiceExecution(
8510
8583
  receiver,
@@ -8514,7 +8587,9 @@ function createRelatedExecution(receiver, access, parent, binding, path) {
8514
8587
  target?.relatedTargets ?? [],
8515
8588
  parent,
8516
8589
  target?.configuration,
8517
- getAuthorizationPermissions(parent, binding)
8590
+ getAuthorizationPermissions(parent, binding),
8591
+ access.operation === "list" ? "find" : "findOne",
8592
+ { kind: "related", parentBinding: binding, path }
8518
8593
  );
8519
8594
  return target?.queryIntent ? withExecutionQueryIntent(receiver, execution, target.queryIntent) : execution;
8520
8595
  }
@@ -10018,6 +10093,7 @@ init_document_authorization();
10018
10093
  init_output_field_filter();
10019
10094
  init_field_authorization();
10020
10095
  init_authorization_snapshot();
10096
+ init_unsafe_snapshot_options();
10021
10097
  init_public_admission();
10022
10098
 
10023
10099
  // src/acl/subdocument-output.ts
@@ -11209,7 +11285,7 @@ var Service = class extends Base {
11209
11285
  ["options", options]
11210
11286
  ]) {
11211
11287
  if (value !== null && (typeof value === "object" || typeof value === "function")) {
11212
- for (const key of ["unsafeSkipListDocumentSnapshotChecks", "unsafeSkipReadDocumentSnapshotChecks"]) {
11288
+ for (const key of unsafeSnapshotOptions) {
11213
11289
  if (key in value) authorizationError(`${slot}.${key} is server model configuration only`);
11214
11290
  }
11215
11291
  }
package/index.mjs CHANGED
@@ -8,6 +8,21 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
 
11
+ // src/acl/unsafe-snapshot-options.ts
12
+ var unsafeSnapshotOptions;
13
+ var init_unsafe_snapshot_options = __esm({
14
+ "src/acl/unsafe-snapshot-options.ts"() {
15
+ unsafeSnapshotOptions = [
16
+ "unsafeSkipListDocumentSnapshotChecks",
17
+ "unsafeSkipReadDocumentSnapshotChecks",
18
+ "unsafeSkipListOutputSnapshotChecks",
19
+ "unsafeSkipReadOutputSnapshotChecks",
20
+ "unsafeSkipListNestedDocumentSnapshotChecks",
21
+ "unsafeSkipReadNestedDocumentSnapshotChecks"
22
+ ];
23
+ }
24
+ });
25
+
11
26
  // src/validation/public-admission.ts
12
27
  import JsonRouter from "@web-ts-toolkit/express-json-router";
13
28
  import { isPlainObject } from "@web-ts-toolkit/utils";
@@ -29,7 +44,7 @@ function assertPublicAdmission(input, kind = "envelope") {
29
44
  for (const key of privateControls) {
30
45
  if (key in record3) {
31
46
  throw new PublicAdmissionError(
32
- key === "unsafeSkipListDocumentSnapshotChecks" || key === "unsafeSkipReadDocumentSnapshotChecks" ? `Unsupported public control ${path}.${key}; this unsafe flag is server model configuration only` : `Unsupported public control ${path}.${key}; use explicit per-call internal service options for backend authorization`
47
+ key.startsWith("unsafeSkip") ? `Unsupported public control ${path}.${key}; this unsafe flag is server model configuration only` : `Unsupported public control ${path}.${key}; use explicit per-call internal service options for backend authorization`
33
48
  );
34
49
  }
35
50
  }
@@ -112,6 +127,7 @@ function requestOnlyServiceOptions(options) {
112
127
  var privateControls, PublicAdmissionError, listArgs, readArgs, listOptions, readOptions, requestAuthorization;
113
128
  var init_public_admission = __esm({
114
129
  "src/validation/public-admission.ts"() {
130
+ init_unsafe_snapshot_options();
115
131
  privateControls = [
116
132
  "authorization",
117
133
  "overrides",
@@ -120,6 +136,7 @@ var init_public_admission = __esm({
120
136
  "execution",
121
137
  "executionContext",
122
138
  "serviceExecutionContext",
139
+ "snapshotDerivation",
123
140
  "resolvedAuthorization",
124
141
  "preparedQuery",
125
142
  "preparedFilter",
@@ -128,8 +145,7 @@ var init_public_admission = __esm({
128
145
  "skipParsing",
129
146
  "skipAuthorization",
130
147
  "alreadyAuthorized",
131
- "unsafeSkipListDocumentSnapshotChecks",
132
- "unsafeSkipReadDocumentSnapshotChecks",
148
+ ...unsafeSnapshotOptions,
133
149
  "operation"
134
150
  ];
135
151
  PublicAdmissionError = class extends JsonRouter.clientErrors.BadRequestError {
@@ -2837,7 +2853,11 @@ var init_runtime = __esm({
2837
2853
  operationAccess: false,
2838
2854
  modelPermissionPrefix: "",
2839
2855
  unsafeSkipListDocumentSnapshotChecks: false,
2840
- unsafeSkipReadDocumentSnapshotChecks: false
2856
+ unsafeSkipReadDocumentSnapshotChecks: false,
2857
+ unsafeSkipListOutputSnapshotChecks: false,
2858
+ unsafeSkipReadOutputSnapshotChecks: false,
2859
+ unsafeSkipListNestedDocumentSnapshotChecks: false,
2860
+ unsafeSkipReadNestedDocumentSnapshotChecks: false
2841
2861
  }).build();
2842
2862
  this.modelOptions = {};
2843
2863
  this.modelJsonSchemas = {};
@@ -3058,10 +3078,12 @@ var init_runtime = __esm({
3058
3078
  const snapshotFlagChanged = (newValue, key, target, oldValue) => {
3059
3079
  target[key] = newValue === true;
3060
3080
  if (newValue !== true || oldValue === true) return;
3061
- const operation = key === "unsafeSkipReadDocumentSnapshotChecks" ? "read" : "list";
3081
+ const operation = key.startsWith("unsafeSkipRead") ? "read" : "list";
3082
+ const category = key.includes("NestedDocument") ? "nested-document" : key.includes("Output") ? "output" : "document";
3083
+ const risk = category === "output" ? "output mutation" : "source mutation";
3062
3084
  try {
3063
3085
  this.getGlobalOption("logger")?.warn?.(
3064
- `UNSAFE: ${operation} document snapshot checks disabled; source mutation can leave stale authorization decisions. Restore ${key}=false after the temporary workaround.`,
3086
+ `UNSAFE: ${operation} ${category} snapshot checks disabled; ${risk} can leave stale authorization decisions. Restore ${key}=false after the temporary workaround.`,
3065
3087
  { modelName }
3066
3088
  );
3067
3089
  } catch {
@@ -3071,7 +3093,7 @@ var init_runtime = __esm({
3071
3093
  refreshPermissionMetadata(target);
3072
3094
  }).onchange("modelPermissionPrefix", function(_newval, _key, target) {
3073
3095
  refreshPermissionMetadata(target);
3074
- }).onchange("unsafeSkipListDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadDocumentSnapshotChecks", snapshotFlagChanged).onchange("basePath", function(newval, key, target) {
3096
+ }).onchange("unsafeSkipListDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipListOutputSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadOutputSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipListNestedDocumentSnapshotChecks", snapshotFlagChanged).onchange("unsafeSkipReadNestedDocumentSnapshotChecks", snapshotFlagChanged).onchange("basePath", function(newval, key, target) {
3075
3097
  target[key] = normalizeBasePath(
3076
3098
  modelName,
3077
3099
  isString4(newval) || isNil2(newval) ? newval : void 0
@@ -3716,6 +3738,33 @@ function assertAuthorizationBinding(call, binding) {
3716
3738
  authorizationError("request/runtime/model/scope binding mismatch");
3717
3739
  }
3718
3740
  }
3741
+ function queryOutputAccess(access) {
3742
+ return (access.operation === "read" || access.operation === "list") && (access.rowAccess === "read" || access.rowAccess === "list") && access.outputAccess === access.rowAccess && access.virtualAccess === access.rowAccess && access.docPermissionsAccess === access.rowAccess;
3743
+ }
3744
+ function nestedQueryResponse(input, access) {
3745
+ const edge = input.snapshotDerivation;
3746
+ if (!edge || !input.parent) return false;
3747
+ assertAuthorizationBinding(input.parent, edge.parentBinding);
3748
+ const parent = callRecord(input.parent);
3749
+ if (!parent.responseSnapshots || (input.applicability ?? "service") !== "service" || !queryOutputAccess(access) || !queryOutputAccess(parent.output.access))
3750
+ return false;
3751
+ if (edge.kind === "retry") {
3752
+ if (!parent.nestedResponse || access.operation !== "read" || parent.output.access.operation !== "read")
3753
+ return false;
3754
+ assertAuthorizationBinding(input.parent, input.binding);
3755
+ return true;
3756
+ }
3757
+ if (edge.kind === "related") {
3758
+ const target = parent.relatedTargets.find((target2) => target2.path === edge.path);
3759
+ return !!target && target.kind !== "count" && target.modelName === input.binding.modelName && scope(input.binding).length === 0;
3760
+ }
3761
+ if (edge.kind !== "embedded") return false;
3762
+ assertAuthorizationBinding(input.parent, { ...input.binding, scopePath: parent.binding.scopePath });
3763
+ const childScope = scope(input.binding), parentScope = scope(parent.binding);
3764
+ return childScope.length > parentScope.length && parentScope.every((part, index) => childScope[index] === part) && Object.keys(parent.output.access).every(
3765
+ (key) => access[key] === parent.output.access[key]
3766
+ );
3767
+ }
3719
3768
  function resolveServiceAuthorization(input) {
3720
3769
  const raw = copyAuthorizationValue(input.authorization);
3721
3770
  const configuration = copyAuthorizationValue(input.configuration, true);
@@ -3743,6 +3792,15 @@ function resolveServiceAuthorization(input) {
3743
3792
  const readAccess = outputAccess.rowAccess;
3744
3793
  const readResponse = input.readResponse === true && (input.applicability ?? "service") === "service" && scopePath.length === 0 && outputAccess.operation === "read" && (readAccess === "read" || readAccess === "list") && outputAccess.outputAccess === readAccess && outputAccess.virtualAccess === readAccess && outputAccess.docPermissionsAccess === readAccess && (input.parent === void 0 || callRecord(input.parent).readResponse);
3745
3794
  if (readResponse && input.parent) assertAuthorizationBinding(input.parent, input.binding);
3795
+ const nestedResponse = nestedQueryResponse(input, outputAccess);
3796
+ const listResponse = input.listResponse === true && input.parent === void 0 && (input.applicability ?? "service") === "service" && scopePath.length === 0 && outputAccess.operation === "list" && outputAccess.rowAccess === "list" && queryOutputAccess(outputAccess);
3797
+ const responseSnapshots = input.parent && (nestedResponse || readResponse) ? callRecord(input.parent).responseSnapshots : listResponse ? Object.freeze({
3798
+ skipOutput: configuration.unsafeSkipListOutputSnapshotChecks === true,
3799
+ skipNested: configuration.unsafeSkipListNestedDocumentSnapshotChecks === true
3800
+ }) : readResponse ? Object.freeze({
3801
+ skipOutput: configuration.unsafeSkipReadOutputSnapshotChecks === true,
3802
+ skipNested: configuration.unsafeSkipReadNestedDocumentSnapshotChecks === true
3803
+ }) : void 0;
3746
3804
  const call = Object.freeze(/* @__PURE__ */ Object.create(null));
3747
3805
  calls.set(call, {
3748
3806
  binding: Object.freeze({ ...input.binding, scopePath: Object.freeze(scopePath) }),
@@ -3755,7 +3813,10 @@ function resolveServiceAuthorization(input) {
3755
3813
  permissions,
3756
3814
  provenance: input.parent ? callRecord(input.parent).provenance : call,
3757
3815
  readResponse,
3758
- validateDocumentSnapshots: !(input.listResponse === true && input.parent === void 0 && (input.applicability ?? "service") === "service" && outputAccess.operation === "list" && outputAccess.rowAccess === "list" && outputAccess.outputAccess === "list" && scopePath.length === 0 && configuration.unsafeSkipListDocumentSnapshotChecks === true || readResponse && configuration.unsafeSkipReadDocumentSnapshotChecks === true)
3816
+ nestedResponse,
3817
+ responseSnapshots,
3818
+ validateOutputSnapshots: responseSnapshots?.skipOutput !== true,
3819
+ validateDocumentSnapshots: !(input.listResponse === true && input.parent === void 0 && (input.applicability ?? "service") === "service" && outputAccess.operation === "list" && outputAccess.rowAccess === "list" && outputAccess.outputAccess === "list" && scopePath.length === 0 && configuration.unsafeSkipListDocumentSnapshotChecks === true || readResponse && configuration.unsafeSkipReadDocumentSnapshotChecks === true || nestedResponse && responseSnapshots?.skipNested === true)
3759
3820
  });
3760
3821
  return call;
3761
3822
  }
@@ -3780,6 +3841,10 @@ function requiresDocumentSnapshotChecks(call, binding) {
3780
3841
  assertAuthorizationBinding(call, binding);
3781
3842
  return callRecord(call).validateDocumentSnapshots;
3782
3843
  }
3844
+ function requiresOutputSnapshotChecks(call, binding) {
3845
+ assertAuthorizationBinding(call, binding);
3846
+ return callRecord(call).validateOutputSnapshots;
3847
+ }
3783
3848
  function readServiceAuthorizationHydration(call, binding) {
3784
3849
  assertAuthorizationBinding(call, binding);
3785
3850
  return copyAuthorizationValue({ hydration: callRecord(call).configuration.hydration }, true);
@@ -4948,7 +5013,7 @@ function tryStaticRequestFieldPaths(handle, binding, access) {
4948
5013
  return decisions && [...decisions].filter(([, allowed]) => allowed).map(([field]) => field);
4949
5014
  }
4950
5015
  function unchangedOutput(output, record3) {
4951
- if (!matchesAuthorizationSnapshot(output, record3.snapshot)) return false;
5016
+ if (record3.validateSnapshot && !matchesAuthorizationSnapshot(output, record3.snapshot)) return false;
4952
5017
  const identities = outputIdentities(output);
4953
5018
  return identities.length === record3.identities.length && identities.every((identity, i) => identity === record3.identities[i]);
4954
5019
  }
@@ -4976,7 +5041,8 @@ function associateDocumentAuthorization(handle, binding, output) {
4976
5041
  outputs.set(output, {
4977
5042
  handle,
4978
5043
  snapshot: copyAuthorizationValue(output, "document"),
4979
- identities: outputIdentities(output)
5044
+ identities: outputIdentities(output),
5045
+ validateSnapshot: requiresOutputSnapshotChecks(stage.call, binding)
4980
5046
  });
4981
5047
  }
4982
5048
  function transferDocumentAuthorization(handle, use, copy) {
@@ -5180,6 +5246,10 @@ function captureModelAuthorizationConfiguration(runtime, modelName, options = ru
5180
5246
  disableFieldPermissions: options.disableFieldPermissions,
5181
5247
  unsafeSkipListDocumentSnapshotChecks: options.unsafeSkipListDocumentSnapshotChecks === true,
5182
5248
  unsafeSkipReadDocumentSnapshotChecks: options.unsafeSkipReadDocumentSnapshotChecks === true,
5249
+ unsafeSkipListOutputSnapshotChecks: options.unsafeSkipListOutputSnapshotChecks === true,
5250
+ unsafeSkipReadOutputSnapshotChecks: options.unsafeSkipReadOutputSnapshotChecks === true,
5251
+ unsafeSkipListNestedDocumentSnapshotChecks: options.unsafeSkipListNestedDocumentSnapshotChecks === true,
5252
+ unsafeSkipReadNestedDocumentSnapshotChecks: options.unsafeSkipReadNestedDocumentSnapshotChecks === true,
5183
5253
  overrideFilter: options.overrideFilter,
5184
5254
  baseFilter: options.baseFilter,
5185
5255
  idField: options.idField,
@@ -6411,7 +6481,8 @@ function authorizeEmbeddedOutputPlan(parent, child) {
6411
6481
  ...view,
6412
6482
  requestPermissions: getAuthorizationPermissions(parent.authorization, parent.authorizationBinding),
6413
6483
  authorization: serviceAuthorizationInput(view.authorization, view.relatedTargets),
6414
- parent: parent.authorization
6484
+ parent: parent.authorization,
6485
+ snapshotDerivation: { kind: "embedded", parentBinding: parent.authorizationBinding }
6415
6486
  });
6416
6487
  return { ...child, authorization, authorizationBinding: binding };
6417
6488
  }
@@ -8132,7 +8203,7 @@ function getServiceExecutors(receiver) {
8132
8203
  if (!registered) authorizationError("unregistered service receiver");
8133
8204
  return registered;
8134
8205
  }
8135
- function createServiceExecution(receiver, access, authorization, applicability = "service", relatedTargets = [], parent, configuration, requestPermissions, hydration = access.operation === "list" ? "find" : "findOne") {
8206
+ function createServiceExecution(receiver, access, authorization, applicability = "service", relatedTargets = [], parent, configuration, requestPermissions, hydration = access.operation === "list" ? "find" : "findOne", snapshotDerivation) {
8136
8207
  const registered = getServiceExecutors(receiver);
8137
8208
  const receiving = registered.binding();
8138
8209
  const binding = Object.freeze({ ...receiving, scopePath: Object.freeze([...receiving.scopePath ?? []]) });
@@ -8146,7 +8217,8 @@ function createServiceExecution(receiver, access, authorization, applicability =
8146
8217
  configuration: configuration ?? registered.configuration(),
8147
8218
  requestPermissions: requestPermissions ?? registered.permissions(),
8148
8219
  listResponse: access.operation === "list" && parent === void 0,
8149
- readResponse: access.operation === "read" && parent === void 0
8220
+ readResponse: access.operation === "read" && parent === void 0,
8221
+ snapshotDerivation
8150
8222
  });
8151
8223
  const execution = Object.freeze(/* @__PURE__ */ Object.create(null));
8152
8224
  executions.set(
@@ -8203,7 +8275,8 @@ function deriveServiceExecution(receiver, parent, access, applicability = "servi
8203
8275
  parent: record3.authorization,
8204
8276
  // The resolver authenticates root-read provenance and the unchanged owner tuple.
8205
8277
  // Effective list access is still a read; write branches cannot inherit this marker.
8206
- readResponse: record3.access.operation === "read" && access.operation === "read"
8278
+ readResponse: record3.access.operation === "read" && access.operation === "read",
8279
+ snapshotDerivation: { kind: "retry", parentBinding: record3.binding }
8207
8280
  });
8208
8281
  const execution = Object.freeze(/* @__PURE__ */ Object.create(null));
8209
8282
  executions.set(
@@ -8476,7 +8549,7 @@ function createRelatedExecution(receiver, access, parent, binding, path) {
8476
8549
  const captured = readServiceAuthorization(parent, binding);
8477
8550
  const target = captured.relatedTargets.find((entry) => entry.path === path);
8478
8551
  const policy = captured.authorization.related[path];
8479
- if (policy && (!target || target.modelName !== getServiceExecutors(receiver).binding().modelName))
8552
+ if ((target || policy) && (!target || target.modelName !== getServiceExecutors(receiver).binding().modelName))
8480
8553
  authorizationError(`related model mismatch: ${path}`);
8481
8554
  const execution = createServiceExecution(
8482
8555
  receiver,
@@ -8486,7 +8559,9 @@ function createRelatedExecution(receiver, access, parent, binding, path) {
8486
8559
  target?.relatedTargets ?? [],
8487
8560
  parent,
8488
8561
  target?.configuration,
8489
- getAuthorizationPermissions(parent, binding)
8562
+ getAuthorizationPermissions(parent, binding),
8563
+ access.operation === "list" ? "find" : "findOne",
8564
+ { kind: "related", parentBinding: binding, path }
8490
8565
  );
8491
8566
  return target?.queryIntent ? withExecutionQueryIntent(receiver, execution, target.queryIntent) : execution;
8492
8567
  }
@@ -10002,6 +10077,7 @@ init_document_authorization();
10002
10077
  init_output_field_filter();
10003
10078
  init_field_authorization();
10004
10079
  init_authorization_snapshot();
10080
+ init_unsafe_snapshot_options();
10005
10081
  init_public_admission();
10006
10082
 
10007
10083
  // src/acl/subdocument-output.ts
@@ -11193,7 +11269,7 @@ var Service = class extends Base {
11193
11269
  ["options", options]
11194
11270
  ]) {
11195
11271
  if (value !== null && (typeof value === "object" || typeof value === "function")) {
11196
- for (const key of ["unsafeSkipListDocumentSnapshotChecks", "unsafeSkipReadDocumentSnapshotChecks"]) {
11272
+ for (const key of unsafeSnapshotOptions) {
11197
11273
  if (key in value) authorizationError(`${slot}.${key} is server model configuration only`);
11198
11274
  }
11199
11275
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@web-ts-toolkit/access-router",
3
3
  "description": "ACL-aware Express routers and in-memory data services for Mongoose-backed APIs",
4
4
  "homepage": "https://web-ts-toolkit.pages.dev/docs/packages/access-router",
5
- "version": "0.60.0",
5
+ "version": "0.61.0",
6
6
  "sideEffects": [
7
7
  "./**/index.js",
8
8
  "./**/index.mjs",
@@ -57,8 +57,8 @@
57
57
  "node": ">=22"
58
58
  },
59
59
  "dependencies": {
60
- "@web-ts-toolkit/express-json-router": "0.60.0",
61
- "@web-ts-toolkit/utils": "0.60.0",
60
+ "@web-ts-toolkit/express-json-router": "0.61.0",
61
+ "@web-ts-toolkit/utils": "0.61.0",
62
62
  "just-diff": "^6.0.2",
63
63
  "mongoose-schema-jsonschema": "^4.0.1",
64
64
  "sift": "^17.1.3",
@@ -1024,8 +1024,13 @@ declare const documentAuthorizationBrand: unique symbol;
1024
1024
  * row/call/access or pre-/post-write stages cannot establish validity and reject.
1025
1025
  * A list/read handle with its server unsafeSkipListDocumentSnapshotChecks or
1026
1026
  * unsafeSkipReadDocumentSnapshotChecks flag enabled retains that weakened source-
1027
- * mutation policy; output mutation/ownership checks still apply. Turning a setting
1027
+ * mutation policy; independent output-value/ownership checks still apply. Turning a setting
1028
1028
  * off affects new calls, not an existing handle or captured read-to-list retry.
1029
+ * Independent unsafeSkipListOutputSnapshotChecks / unsafeSkipReadOutputSnapshotChecks
1030
+ * can also retain weakened output-value checks (graph identities still checked).
1031
+ * unsafeSkipListNestedDocumentSnapshotChecks / unsafeSkipReadNestedDocumentSnapshotChecks
1032
+ * retain weakened source checks on query descendants, using the initiating model's
1033
+ * mode. In-place value mutations can therefore reuse stale grants/decisions.
1029
1034
  */
1030
1035
  interface DocumentAuthorization {
1031
1036
  readonly [documentAuthorizationBrand]: true;
@@ -1162,6 +1167,10 @@ interface AuthorizationConfiguration {
1162
1167
  /** Captured server model option; alone it never issues relaxed document authority. */
1163
1168
  readonly unsafeSkipListDocumentSnapshotChecks?: boolean;
1164
1169
  readonly unsafeSkipReadDocumentSnapshotChecks?: boolean;
1170
+ readonly unsafeSkipListOutputSnapshotChecks?: boolean;
1171
+ readonly unsafeSkipReadOutputSnapshotChecks?: boolean;
1172
+ readonly unsafeSkipListNestedDocumentSnapshotChecks?: boolean;
1173
+ readonly unsafeSkipReadNestedDocumentSnapshotChecks?: boolean;
1165
1174
  /** Opaque terminal private-input capture. Never related authority or public document metadata. */
1166
1175
  readonly virtualPopulateSnapshot?: VirtualPopulateSnapshotToken;
1167
1176
  /** Runtime-owned private input admission mode, not public output/related authority. */
@@ -3450,9 +3459,10 @@ interface DefaultModelRouterOptions<TModel = unknown> {
3450
3459
  * skips repeated projected-document snapshot comparisons for this model's top-level
3451
3460
  * `find`/public/root list responses. Captured before awaits; list-origin handles keep
3452
3461
  * that mode. Single reads use the independent unsafeSkipReadDocumentSnapshotChecks
3453
- * setting. Writes, embedded/related stages and fresh standalone helpers stay strict.
3462
+ * setting. Embedded/related source stages and output values have separate flags.
3463
+ * Writes and fresh standalone helpers stay strict.
3454
3464
  *
3455
- * Row/field permissions, exact ownership/binding, output provenance/mutation checks
3465
+ * Row/field permissions, exact ownership/binding, independent output-value checks
3456
3466
  * and detached callback/grant copies still run. However, source changes during a
3457
3467
  * callback/await are no longer detected: stale grants/decisions may authorize output.
3458
3468
  * Use only with trusted non-mutating application hooks, measure before rollout, and
@@ -3467,15 +3477,63 @@ interface DefaultModelRouterOptions<TModel = unknown> {
3467
3477
  * this setting, not unsafeSkipListDocumentSnapshotChecks. Captured before awaits;
3468
3478
  * read-origin handles and retries keep that mode. List operations use their own flag.
3469
3479
  *
3470
- * Permission rules, exact ownership/binding, output-mutation/provenance checks and
3480
+ * Permission rules, exact ownership/binding, independent output-value checks and
3471
3481
  * detached callback/grant copies still run. Source changes during callbacks/awaits
3472
3482
  * can leave stale grants/decisions and incorrectly authorized output. Use only with
3473
3483
  * trusted non-mutating hooks, measure before rollout and restore `false` promptly.
3474
- * Writes (including read-like output), embedded/related stages and fresh helpers
3475
- * remain strict. Enabling warns once per model/flag transition. Server model or
3476
- * model-starting-default configuration only; never method defaults or wire options.
3484
+ * Embedded/related source stages use separate nested flags. Writes (including
3485
+ * read-like output) and fresh helpers stay strict. Warns per model/flag transition.
3486
+ * Server model or model-starting-default configuration only; never method defaults
3487
+ * or wire options.
3477
3488
  */
3478
3489
  unsafeSkipReadDocumentSnapshotChecks?: boolean;
3490
+ /**
3491
+ * TEMPORARY UNSAFE (default `false`): skip output VALUE snapshot comparisons in
3492
+ * top-level LIST responses and their embedded/populated/included descendants.
3493
+ * Exact output associations, graph identities, bindings and permission rules remain;
3494
+ * scalar/native in-place mutations can now reuse stale decisions and expose data.
3495
+ * Source checks are independent. Initial snapshots and detached copies remain.
3496
+ * Captured before awaits; handles keep this mode after rollback. Only literal `true`
3497
+ * in server model/starting-default configuration enables it and warns on transition.
3498
+ * READ/retries use unsafeSkipReadOutputSnapshotChecks; writes and fresh helpers stay
3499
+ * strict. Never set from request/per-call/method defaults. Revisit/remove promptly.
3500
+ */
3501
+ unsafeSkipListOutputSnapshotChecks?: boolean;
3502
+ /**
3503
+ * TEMPORARY UNSAFE (default `false`): READ equivalent of unsafeSkipListOutputSnapshotChecks,
3504
+ * including findOne/findById, public/root reads, read-to-list retries and their
3505
+ * embedded/populated/included outputs. Uses the initiating READ model's captured
3506
+ * setting, not LIST or target-model settings. Value mutations may reuse stale
3507
+ * decisions; exact ownership/graph identities and permissions still run. Server
3508
+ * model/starting-default literal `true` only; warns on enablement. Retained handles
3509
+ * keep their mode. Writes/fresh helpers stay strict. Revisit/remove promptly.
3510
+ */
3511
+ unsafeSkipReadOutputSnapshotChecks?: boolean;
3512
+ /**
3513
+ * TEMPORARY UNSAFE (default `false`): skip repeated SOURCE snapshot comparisons for
3514
+ * embedded/populated/included document stages reached from a top-level LIST.
3515
+ * The initiating model's captured setting applies recursively, not target-model
3516
+ * flags. Parent source and all output-value checks remain independently configured;
3517
+ * parent snapshots still include nested values. Permission rules, exact binding,
3518
+ * initial snapshots and detached copies remain. Child mutation can leave stale
3519
+ * grants/decisions and expose data. Only server model/starting-default literal `true`
3520
+ * enables it; warns on transition. Rollback affects new calls, not captured descendants
3521
+ * or handles. READ uses its own flag; writes, dedicated subdocument operations and
3522
+ * fresh helpers stay strict. Never derive from requests. Revisit/remove promptly.
3523
+ */
3524
+ unsafeSkipListNestedDocumentSnapshotChecks?: boolean;
3525
+ /**
3526
+ * TEMPORARY UNSAFE (default `false`): READ equivalent of
3527
+ * unsafeSkipListNestedDocumentSnapshotChecks, including read-to-list retries.
3528
+ * Recursively skips embedded/populated/included SOURCE comparisons using the
3529
+ * initiating READ model's captured setting, independently of LIST, root source
3530
+ * and output-value flags. Parent comparisons may still observe child mutation.
3531
+ * Stale grants/decisions can expose data; permissions, identities and detached copies
3532
+ * remain. Server model/starting-default literal `true` only; warns on enablement.
3533
+ * Writes/dedicated subdocument operations/fresh helpers stay strict; retained handles
3534
+ * keep their mode after rollback. Never set from requests. Revisit/remove promptly.
3535
+ */
3536
+ unsafeSkipReadNestedDocumentSnapshotChecks?: boolean;
3479
3537
  }
3480
3538
  interface ExtendedDefaultModelRouterOptions<TModel = unknown> extends DefaultModelRouterOptions<TModel> {
3481
3539
  'hydration.publicList'?: HydrationMode;
@@ -1024,8 +1024,13 @@ declare const documentAuthorizationBrand: unique symbol;
1024
1024
  * row/call/access or pre-/post-write stages cannot establish validity and reject.
1025
1025
  * A list/read handle with its server unsafeSkipListDocumentSnapshotChecks or
1026
1026
  * unsafeSkipReadDocumentSnapshotChecks flag enabled retains that weakened source-
1027
- * mutation policy; output mutation/ownership checks still apply. Turning a setting
1027
+ * mutation policy; independent output-value/ownership checks still apply. Turning a setting
1028
1028
  * off affects new calls, not an existing handle or captured read-to-list retry.
1029
+ * Independent unsafeSkipListOutputSnapshotChecks / unsafeSkipReadOutputSnapshotChecks
1030
+ * can also retain weakened output-value checks (graph identities still checked).
1031
+ * unsafeSkipListNestedDocumentSnapshotChecks / unsafeSkipReadNestedDocumentSnapshotChecks
1032
+ * retain weakened source checks on query descendants, using the initiating model's
1033
+ * mode. In-place value mutations can therefore reuse stale grants/decisions.
1029
1034
  */
1030
1035
  interface DocumentAuthorization {
1031
1036
  readonly [documentAuthorizationBrand]: true;
@@ -1162,6 +1167,10 @@ interface AuthorizationConfiguration {
1162
1167
  /** Captured server model option; alone it never issues relaxed document authority. */
1163
1168
  readonly unsafeSkipListDocumentSnapshotChecks?: boolean;
1164
1169
  readonly unsafeSkipReadDocumentSnapshotChecks?: boolean;
1170
+ readonly unsafeSkipListOutputSnapshotChecks?: boolean;
1171
+ readonly unsafeSkipReadOutputSnapshotChecks?: boolean;
1172
+ readonly unsafeSkipListNestedDocumentSnapshotChecks?: boolean;
1173
+ readonly unsafeSkipReadNestedDocumentSnapshotChecks?: boolean;
1165
1174
  /** Opaque terminal private-input capture. Never related authority or public document metadata. */
1166
1175
  readonly virtualPopulateSnapshot?: VirtualPopulateSnapshotToken;
1167
1176
  /** Runtime-owned private input admission mode, not public output/related authority. */
@@ -3450,9 +3459,10 @@ interface DefaultModelRouterOptions<TModel = unknown> {
3450
3459
  * skips repeated projected-document snapshot comparisons for this model's top-level
3451
3460
  * `find`/public/root list responses. Captured before awaits; list-origin handles keep
3452
3461
  * that mode. Single reads use the independent unsafeSkipReadDocumentSnapshotChecks
3453
- * setting. Writes, embedded/related stages and fresh standalone helpers stay strict.
3462
+ * setting. Embedded/related source stages and output values have separate flags.
3463
+ * Writes and fresh standalone helpers stay strict.
3454
3464
  *
3455
- * Row/field permissions, exact ownership/binding, output provenance/mutation checks
3465
+ * Row/field permissions, exact ownership/binding, independent output-value checks
3456
3466
  * and detached callback/grant copies still run. However, source changes during a
3457
3467
  * callback/await are no longer detected: stale grants/decisions may authorize output.
3458
3468
  * Use only with trusted non-mutating application hooks, measure before rollout, and
@@ -3467,15 +3477,63 @@ interface DefaultModelRouterOptions<TModel = unknown> {
3467
3477
  * this setting, not unsafeSkipListDocumentSnapshotChecks. Captured before awaits;
3468
3478
  * read-origin handles and retries keep that mode. List operations use their own flag.
3469
3479
  *
3470
- * Permission rules, exact ownership/binding, output-mutation/provenance checks and
3480
+ * Permission rules, exact ownership/binding, independent output-value checks and
3471
3481
  * detached callback/grant copies still run. Source changes during callbacks/awaits
3472
3482
  * can leave stale grants/decisions and incorrectly authorized output. Use only with
3473
3483
  * trusted non-mutating hooks, measure before rollout and restore `false` promptly.
3474
- * Writes (including read-like output), embedded/related stages and fresh helpers
3475
- * remain strict. Enabling warns once per model/flag transition. Server model or
3476
- * model-starting-default configuration only; never method defaults or wire options.
3484
+ * Embedded/related source stages use separate nested flags. Writes (including
3485
+ * read-like output) and fresh helpers stay strict. Warns per model/flag transition.
3486
+ * Server model or model-starting-default configuration only; never method defaults
3487
+ * or wire options.
3477
3488
  */
3478
3489
  unsafeSkipReadDocumentSnapshotChecks?: boolean;
3490
+ /**
3491
+ * TEMPORARY UNSAFE (default `false`): skip output VALUE snapshot comparisons in
3492
+ * top-level LIST responses and their embedded/populated/included descendants.
3493
+ * Exact output associations, graph identities, bindings and permission rules remain;
3494
+ * scalar/native in-place mutations can now reuse stale decisions and expose data.
3495
+ * Source checks are independent. Initial snapshots and detached copies remain.
3496
+ * Captured before awaits; handles keep this mode after rollback. Only literal `true`
3497
+ * in server model/starting-default configuration enables it and warns on transition.
3498
+ * READ/retries use unsafeSkipReadOutputSnapshotChecks; writes and fresh helpers stay
3499
+ * strict. Never set from request/per-call/method defaults. Revisit/remove promptly.
3500
+ */
3501
+ unsafeSkipListOutputSnapshotChecks?: boolean;
3502
+ /**
3503
+ * TEMPORARY UNSAFE (default `false`): READ equivalent of unsafeSkipListOutputSnapshotChecks,
3504
+ * including findOne/findById, public/root reads, read-to-list retries and their
3505
+ * embedded/populated/included outputs. Uses the initiating READ model's captured
3506
+ * setting, not LIST or target-model settings. Value mutations may reuse stale
3507
+ * decisions; exact ownership/graph identities and permissions still run. Server
3508
+ * model/starting-default literal `true` only; warns on enablement. Retained handles
3509
+ * keep their mode. Writes/fresh helpers stay strict. Revisit/remove promptly.
3510
+ */
3511
+ unsafeSkipReadOutputSnapshotChecks?: boolean;
3512
+ /**
3513
+ * TEMPORARY UNSAFE (default `false`): skip repeated SOURCE snapshot comparisons for
3514
+ * embedded/populated/included document stages reached from a top-level LIST.
3515
+ * The initiating model's captured setting applies recursively, not target-model
3516
+ * flags. Parent source and all output-value checks remain independently configured;
3517
+ * parent snapshots still include nested values. Permission rules, exact binding,
3518
+ * initial snapshots and detached copies remain. Child mutation can leave stale
3519
+ * grants/decisions and expose data. Only server model/starting-default literal `true`
3520
+ * enables it; warns on transition. Rollback affects new calls, not captured descendants
3521
+ * or handles. READ uses its own flag; writes, dedicated subdocument operations and
3522
+ * fresh helpers stay strict. Never derive from requests. Revisit/remove promptly.
3523
+ */
3524
+ unsafeSkipListNestedDocumentSnapshotChecks?: boolean;
3525
+ /**
3526
+ * TEMPORARY UNSAFE (default `false`): READ equivalent of
3527
+ * unsafeSkipListNestedDocumentSnapshotChecks, including read-to-list retries.
3528
+ * Recursively skips embedded/populated/included SOURCE comparisons using the
3529
+ * initiating READ model's captured setting, independently of LIST, root source
3530
+ * and output-value flags. Parent comparisons may still observe child mutation.
3531
+ * Stale grants/decisions can expose data; permissions, identities and detached copies
3532
+ * remain. Server model/starting-default literal `true` only; warns on enablement.
3533
+ * Writes/dedicated subdocument operations/fresh helpers stay strict; retained handles
3534
+ * keep their mode after rollback. Never set from requests. Revisit/remove promptly.
3535
+ */
3536
+ unsafeSkipReadNestedDocumentSnapshotChecks?: boolean;
3479
3537
  }
3480
3538
  interface ExtendedDefaultModelRouterOptions<TModel = unknown> extends DefaultModelRouterOptions<TModel> {
3481
3539
  'hydration.publicList'?: HydrationMode;