@web-ts-toolkit/access-router 0.59.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
@@ -237,6 +237,79 @@ Express routes. `parentPath` supplies the external prefix for route metadata/log
237
237
  mount that prefix in Express yourself. Live `idField`/`resolveIdFilter` change lookup
238
238
  behavior rather than route shape.
239
239
 
240
+ ### Temporary unsafe read/list-performance switches
241
+
242
+ **All default to off (snapshot checks enabled).** Six independent server-only
243
+ settings temporarily skip specific comparisons on one registered model:
244
+
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 |
250
+
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.
256
+
257
+ <!-- doc-example: partial -->
258
+
259
+ ```ts
260
+ import acl from '@web-ts-toolkit/access-router';
261
+
262
+ // User must already be registered on this runtime. Never take this value from a request.
263
+ // TODO: revisit/remove this temporary workaround after query-performance remediation.
264
+ acl.setModelOptions('User', {
265
+ unsafeSkipReadDocumentSnapshotChecks: true,
266
+ unsafeSkipReadOutputSnapshotChecks: true,
267
+ unsafeSkipReadNestedDocumentSnapshotChecks: true,
268
+ // All three LIST flags remain false unless separately enabled.
269
+ });
270
+ ```
271
+
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`
274
+ before model-router creation. Starting defaults do not overwrite existing models'
275
+ stored settings; a per-model `false` overrides a starting default of `true`.
276
+ Prefer per-model opt-in rather than enabling it for every model. Use the owning
277
+ `createAccessRuntime()` API instead of default `acl` for an isolated runtime.
278
+ Only literal boolean `true` enables each flag. Enabling emits a logger warning once
279
+ per model/flag transition, not per row/request. None is a global, per-call, HTTP/root
280
+ entry, `options.authorization`, or `service.defaults` option.
281
+
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.
291
+ - **Still enforced:** row filters, document/field rules, operation gates, exact
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.
307
+
308
+ Each call captures the setting before awaits. Turning it off protects new calls,
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.
312
+
240
313
  ### Wire placement and option names
241
314
 
242
315
  | Intent | Basic GET query | Advanced body | Root entry |
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-CngKnVjW.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-CngKnVjW.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,6 +160,7 @@ var privateControls = [
147
160
  "skipParsing",
148
161
  "skipAuthorization",
149
162
  "alreadyAuthorized",
163
+ ...unsafeSnapshotOptions,
150
164
  "operation"
151
165
  ];
152
166
  var PublicAdmissionError = class extends import_express_json_router.default.clientErrors.BadRequestError {
@@ -174,7 +188,7 @@ function assertPublicAdmission(input, kind = "envelope") {
174
188
  for (const key of privateControls) {
175
189
  if (key in record2) {
176
190
  throw new PublicAdmissionError(
177
- `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`
178
192
  );
179
193
  }
180
194
  }
@@ -2065,7 +2079,13 @@ var AccessRuntime = class {
2065
2079
  queryRouteSegment: "__query",
2066
2080
  mutationRouteSegment: "__mutation",
2067
2081
  operationAccess: false,
2068
- modelPermissionPrefix: ""
2082
+ modelPermissionPrefix: "",
2083
+ unsafeSkipListDocumentSnapshotChecks: false,
2084
+ unsafeSkipReadDocumentSnapshotChecks: false,
2085
+ unsafeSkipListOutputSnapshotChecks: false,
2086
+ unsafeSkipReadOutputSnapshotChecks: false,
2087
+ unsafeSkipListNestedDocumentSnapshotChecks: false,
2088
+ unsafeSkipReadNestedDocumentSnapshotChecks: false
2069
2089
  }).build();
2070
2090
  this.modelOptions = {};
2071
2091
  this.modelJsonSchemas = {};
@@ -2283,11 +2303,25 @@ var AccessRuntime = class {
2283
2303
  ...defaultModelOptions,
2284
2304
  modelName
2285
2305
  });
2306
+ const snapshotFlagChanged = (newValue, key, target, oldValue) => {
2307
+ target[key] = newValue === true;
2308
+ if (newValue !== true || oldValue === true) return;
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";
2312
+ try {
2313
+ this.getGlobalOption("logger")?.warn?.(
2314
+ `UNSAFE: ${operation} ${category} snapshot checks disabled; ${risk} can leave stale authorization decisions. Restore ${key}=false after the temporary workaround.`,
2315
+ { modelName }
2316
+ );
2317
+ } catch {
2318
+ }
2319
+ };
2286
2320
  manager.onchange("permissionSchema", function(_newval, _key, target) {
2287
2321
  refreshPermissionMetadata(target);
2288
2322
  }).onchange("modelPermissionPrefix", function(_newval, _key, target) {
2289
2323
  refreshPermissionMetadata(target);
2290
- }).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) {
2291
2325
  target[key] = normalizeBasePath(
2292
2326
  modelName,
2293
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,6 +78,7 @@ var privateControls = [
65
78
  "skipParsing",
66
79
  "skipAuthorization",
67
80
  "alreadyAuthorized",
81
+ ...unsafeSnapshotOptions,
68
82
  "operation"
69
83
  ];
70
84
  var PublicAdmissionError = class extends JsonRouter.clientErrors.BadRequestError {
@@ -92,7 +106,7 @@ function assertPublicAdmission(input, kind = "envelope") {
92
106
  for (const key of privateControls) {
93
107
  if (key in record2) {
94
108
  throw new PublicAdmissionError(
95
- `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`
96
110
  );
97
111
  }
98
112
  }
@@ -1996,7 +2010,13 @@ var AccessRuntime = class {
1996
2010
  queryRouteSegment: "__query",
1997
2011
  mutationRouteSegment: "__mutation",
1998
2012
  operationAccess: false,
1999
- modelPermissionPrefix: ""
2013
+ modelPermissionPrefix: "",
2014
+ unsafeSkipListDocumentSnapshotChecks: false,
2015
+ unsafeSkipReadDocumentSnapshotChecks: false,
2016
+ unsafeSkipListOutputSnapshotChecks: false,
2017
+ unsafeSkipReadOutputSnapshotChecks: false,
2018
+ unsafeSkipListNestedDocumentSnapshotChecks: false,
2019
+ unsafeSkipReadNestedDocumentSnapshotChecks: false
2000
2020
  }).build();
2001
2021
  this.modelOptions = {};
2002
2022
  this.modelJsonSchemas = {};
@@ -2214,11 +2234,25 @@ var AccessRuntime = class {
2214
2234
  ...defaultModelOptions,
2215
2235
  modelName
2216
2236
  });
2237
+ const snapshotFlagChanged = (newValue, key, target, oldValue) => {
2238
+ target[key] = newValue === true;
2239
+ if (newValue !== true || oldValue === true) return;
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";
2243
+ try {
2244
+ this.getGlobalOption("logger")?.warn?.(
2245
+ `UNSAFE: ${operation} ${category} snapshot checks disabled; ${risk} can leave stale authorization decisions. Restore ${key}=false after the temporary workaround.`,
2246
+ { modelName }
2247
+ );
2248
+ } catch {
2249
+ }
2250
+ };
2217
2251
  manager.onchange("permissionSchema", function(_newval, _key, target) {
2218
2252
  refreshPermissionMetadata(target);
2219
2253
  }).onchange("modelPermissionPrefix", function(_newval, _key, target) {
2220
2254
  refreshPermissionMetadata(target);
2221
- }).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) {
2222
2256
  target[key] = normalizeBasePath(
2223
2257
  modelName,
2224
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-CngKnVjW.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-CngKnVjW.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-CngKnVjW.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-CngKnVjW.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
- `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,6 +166,7 @@ var init_public_admission = __esm({
149
166
  "skipParsing",
150
167
  "skipAuthorization",
151
168
  "alreadyAuthorized",
169
+ ...unsafeSnapshotOptions,
152
170
  "operation"
153
171
  ];
154
172
  PublicAdmissionError = class extends import_express_json_router.default.clientErrors.BadRequestError {
@@ -2842,7 +2860,13 @@ var init_runtime = __esm({
2842
2860
  queryRouteSegment: "__query",
2843
2861
  mutationRouteSegment: "__mutation",
2844
2862
  operationAccess: false,
2845
- modelPermissionPrefix: ""
2863
+ modelPermissionPrefix: "",
2864
+ unsafeSkipListDocumentSnapshotChecks: false,
2865
+ unsafeSkipReadDocumentSnapshotChecks: false,
2866
+ unsafeSkipListOutputSnapshotChecks: false,
2867
+ unsafeSkipReadOutputSnapshotChecks: false,
2868
+ unsafeSkipListNestedDocumentSnapshotChecks: false,
2869
+ unsafeSkipReadNestedDocumentSnapshotChecks: false
2846
2870
  }).build();
2847
2871
  this.modelOptions = {};
2848
2872
  this.modelJsonSchemas = {};
@@ -3060,11 +3084,25 @@ var init_runtime = __esm({
3060
3084
  ...defaultModelOptions,
3061
3085
  modelName
3062
3086
  });
3087
+ const snapshotFlagChanged = (newValue, key, target, oldValue) => {
3088
+ target[key] = newValue === true;
3089
+ if (newValue !== true || oldValue === true) return;
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";
3093
+ try {
3094
+ this.getGlobalOption("logger")?.warn?.(
3095
+ `UNSAFE: ${operation} ${category} snapshot checks disabled; ${risk} can leave stale authorization decisions. Restore ${key}=false after the temporary workaround.`,
3096
+ { modelName }
3097
+ );
3098
+ } catch {
3099
+ }
3100
+ };
3063
3101
  manager.onchange("permissionSchema", function(_newval, _key, target) {
3064
3102
  refreshPermissionMetadata(target);
3065
3103
  }).onchange("modelPermissionPrefix", function(_newval, _key, target) {
3066
3104
  refreshPermissionMetadata(target);
3067
- }).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) {
3068
3106
  target[key] = normalizeBasePath(
3069
3107
  modelName,
3070
3108
  (0, import_utils17.isString)(newval) || (0, import_utils17.isNil)(newval) ? newval : void 0
@@ -3709,6 +3747,33 @@ function assertAuthorizationBinding(call, binding) {
3709
3747
  authorizationError("request/runtime/model/scope binding mismatch");
3710
3748
  }
3711
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
+ }
3712
3777
  function resolveServiceAuthorization(input) {
3713
3778
  const raw = copyAuthorizationValue(input.authorization);
3714
3779
  const configuration = copyAuthorizationValue(input.configuration, true);
@@ -3733,6 +3798,18 @@ function resolveServiceAuthorization(input) {
3733
3798
  );
3734
3799
  for (const value of Object.values(permissions)) if (value && typeof value === "object") Object.freeze(value);
3735
3800
  Object.freeze(permissions);
3801
+ const readAccess = outputAccess.rowAccess;
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);
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;
3736
3813
  const call = Object.freeze(/* @__PURE__ */ Object.create(null));
3737
3814
  calls.set(call, {
3738
3815
  binding: Object.freeze({ ...input.binding, scopePath: Object.freeze(scopePath) }),
@@ -3743,7 +3820,12 @@ function resolveServiceAuthorization(input) {
3743
3820
  // normalizeFields constructs only mode strings and validated string paths.
3744
3821
  output: Object.freeze({ access: outputAccess, catalog, outputFields: policy.outputFields }),
3745
3822
  permissions,
3746
- provenance: input.parent ? callRecord(input.parent).provenance : call
3823
+ provenance: input.parent ? callRecord(input.parent).provenance : call,
3824
+ readResponse,
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)
3747
3829
  });
3748
3830
  return call;
3749
3831
  }
@@ -3764,6 +3846,14 @@ function readServiceAuthorizationAccess(call, binding) {
3764
3846
  assertAuthorizationBinding(call, binding);
3765
3847
  return callRecord(call).output.access;
3766
3848
  }
3849
+ function requiresDocumentSnapshotChecks(call, binding) {
3850
+ assertAuthorizationBinding(call, binding);
3851
+ return callRecord(call).validateDocumentSnapshots;
3852
+ }
3853
+ function requiresOutputSnapshotChecks(call, binding) {
3854
+ assertAuthorizationBinding(call, binding);
3855
+ return callRecord(call).validateOutputSnapshots;
3856
+ }
3767
3857
  function readServiceAuthorizationHydration(call, binding) {
3768
3858
  assertAuthorizationBinding(call, binding);
3769
3859
  return copyAuthorizationValue({ hydration: callRecord(call).configuration.hydration }, true);
@@ -4690,6 +4780,7 @@ function lookupDocumentOwner(handle) {
4690
4780
  return record3;
4691
4781
  }
4692
4782
  function validateStageOwner(record3) {
4783
+ if (!record3.validateSnapshot) return;
4693
4784
  if (!matchesAuthorizationSnapshot(record3.input, record3.snapshot)) authorizationError("changed document snapshot");
4694
4785
  }
4695
4786
  function validateDocumentOwner(handle) {
@@ -4709,7 +4800,8 @@ function createDocumentAuthorizationStage(call, binding, projectedSnapshot) {
4709
4800
  call,
4710
4801
  binding: ownedBinding,
4711
4802
  input: projectedSnapshot,
4712
- snapshot
4803
+ snapshot,
4804
+ validateSnapshot: requiresDocumentSnapshotChecks(call, binding)
4713
4805
  });
4714
4806
  return stage;
4715
4807
  }
@@ -4717,7 +4809,7 @@ function assertDocumentAuthorizationStage(stage, call, binding, projectedSnapsho
4717
4809
  const record3 = lookupStageOwner(stage);
4718
4810
  validateStageOwner(record3);
4719
4811
  assertAuthorizationBinding(record3.call, binding);
4720
- if (record3.call !== call || record3.input !== projectedSnapshot || !matchesAuthorizationSnapshot(projectedSnapshot, record3.snapshot)) {
4812
+ if (record3.call !== call || record3.input !== projectedSnapshot || record3.validateSnapshot && !matchesAuthorizationSnapshot(projectedSnapshot, record3.snapshot)) {
4721
4813
  authorizationError("document call/stage/snapshot mismatch");
4722
4814
  }
4723
4815
  }
@@ -4928,7 +5020,7 @@ function tryStaticRequestFieldPaths(handle, binding, access) {
4928
5020
  return decisions && [...decisions].filter(([, allowed]) => allowed).map(([field]) => field);
4929
5021
  }
4930
5022
  function unchangedOutput(output, record3) {
4931
- if (!matchesAuthorizationSnapshot(output, record3.snapshot)) return false;
5023
+ if (record3.validateSnapshot && !matchesAuthorizationSnapshot(output, record3.snapshot)) return false;
4932
5024
  const identities = outputIdentities(output);
4933
5025
  return identities.length === record3.identities.length && identities.every((identity, i) => identity === record3.identities[i]);
4934
5026
  }
@@ -4956,7 +5048,8 @@ function associateDocumentAuthorization(handle, binding, output) {
4956
5048
  outputs.set(output, {
4957
5049
  handle,
4958
5050
  snapshot: copyAuthorizationValue(output, "document"),
4959
- identities: outputIdentities(output)
5051
+ identities: outputIdentities(output),
5052
+ validateSnapshot: requiresOutputSnapshotChecks(stage.call, binding)
4960
5053
  });
4961
5054
  }
4962
5055
  function transferDocumentAuthorization(handle, use, copy) {
@@ -5159,6 +5252,12 @@ function captureModelAuthorizationConfiguration(runtime, modelName, options = ru
5159
5252
  exposedDocPermissionKeys: options.exposedDocPermissionKeys,
5160
5253
  stripPermissionsField: options.stripPermissionsField,
5161
5254
  disableFieldPermissions: options.disableFieldPermissions,
5255
+ unsafeSkipListDocumentSnapshotChecks: options.unsafeSkipListDocumentSnapshotChecks === true,
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,
5162
5261
  overrideFilter: options.overrideFilter,
5163
5262
  baseFilter: options.baseFilter,
5164
5263
  idField: options.idField,
@@ -6380,7 +6479,8 @@ function authorizeEmbeddedOutputPlan(parent, child) {
6380
6479
  ...view,
6381
6480
  requestPermissions: getAuthorizationPermissions(parent.authorization, parent.authorizationBinding),
6382
6481
  authorization: serviceAuthorizationInput(view.authorization, view.relatedTargets),
6383
- parent: parent.authorization
6482
+ parent: parent.authorization,
6483
+ snapshotDerivation: { kind: "embedded", parentBinding: parent.authorizationBinding }
6384
6484
  });
6385
6485
  return { ...child, authorization, authorizationBinding: binding };
6386
6486
  }
@@ -8131,7 +8231,7 @@ function getServiceExecutors(receiver) {
8131
8231
  if (!registered) authorizationError("unregistered service receiver");
8132
8232
  return registered;
8133
8233
  }
8134
- 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) {
8135
8235
  const registered = getServiceExecutors(receiver);
8136
8236
  const receiving = registered.binding();
8137
8237
  const binding = Object.freeze({ ...receiving, scopePath: Object.freeze([...receiving.scopePath ?? []]) });
@@ -8143,7 +8243,10 @@ function createServiceExecution(receiver, access, authorization, applicability =
8143
8243
  relatedTargets,
8144
8244
  parent,
8145
8245
  configuration: configuration ?? registered.configuration(),
8146
- requestPermissions: requestPermissions ?? registered.permissions()
8246
+ requestPermissions: requestPermissions ?? registered.permissions(),
8247
+ listResponse: access.operation === "list" && parent === void 0,
8248
+ readResponse: access.operation === "read" && parent === void 0,
8249
+ snapshotDerivation
8147
8250
  });
8148
8251
  const execution = Object.freeze(/* @__PURE__ */ Object.create(null));
8149
8252
  executions.set(
@@ -8197,7 +8300,11 @@ function deriveServiceExecution(receiver, parent, access, applicability = "servi
8197
8300
  relatedTargets: captured.relatedTargets,
8198
8301
  configuration: captured.configuration,
8199
8302
  requestPermissions: getAuthorizationPermissions(record3.authorization, record3.binding),
8200
- parent: record3.authorization
8303
+ parent: record3.authorization,
8304
+ // The resolver authenticates root-read provenance and the unchanged owner tuple.
8305
+ // Effective list access is still a read; write branches cannot inherit this marker.
8306
+ readResponse: record3.access.operation === "read" && access.operation === "read",
8307
+ snapshotDerivation: { kind: "retry", parentBinding: record3.binding }
8201
8308
  });
8202
8309
  const execution = Object.freeze(/* @__PURE__ */ Object.create(null));
8203
8310
  executions.set(
@@ -8470,7 +8577,7 @@ function createRelatedExecution(receiver, access, parent, binding, path) {
8470
8577
  const captured = readServiceAuthorization(parent, binding);
8471
8578
  const target = captured.relatedTargets.find((entry) => entry.path === path);
8472
8579
  const policy = captured.authorization.related[path];
8473
- if (policy && (!target || target.modelName !== getServiceExecutors(receiver).binding().modelName))
8580
+ if ((target || policy) && (!target || target.modelName !== getServiceExecutors(receiver).binding().modelName))
8474
8581
  authorizationError(`related model mismatch: ${path}`);
8475
8582
  const execution = createServiceExecution(
8476
8583
  receiver,
@@ -8480,7 +8587,9 @@ function createRelatedExecution(receiver, access, parent, binding, path) {
8480
8587
  target?.relatedTargets ?? [],
8481
8588
  parent,
8482
8589
  target?.configuration,
8483
- getAuthorizationPermissions(parent, binding)
8590
+ getAuthorizationPermissions(parent, binding),
8591
+ access.operation === "list" ? "find" : "findOne",
8592
+ { kind: "related", parentBinding: binding, path }
8484
8593
  );
8485
8594
  return target?.queryIntent ? withExecutionQueryIntent(receiver, execution, target.queryIntent) : execution;
8486
8595
  }
@@ -9984,6 +10093,7 @@ init_document_authorization();
9984
10093
  init_output_field_filter();
9985
10094
  init_field_authorization();
9986
10095
  init_authorization_snapshot();
10096
+ init_unsafe_snapshot_options();
9987
10097
  init_public_admission();
9988
10098
 
9989
10099
  // src/acl/subdocument-output.ts
@@ -11174,6 +11284,11 @@ var Service = class extends Base {
11174
11284
  ["args", args],
11175
11285
  ["options", options]
11176
11286
  ]) {
11287
+ if (value !== null && (typeof value === "object" || typeof value === "function")) {
11288
+ for (const key of unsafeSnapshotOptions) {
11289
+ if (key in value) authorizationError(`${slot}.${key} is server model configuration only`);
11290
+ }
11291
+ }
11177
11292
  if (value !== null && (typeof value === "object" || typeof value === "function") && "authorization" in value && (slot === "args" || !authorizationOptions)) {
11178
11293
  authorizationError(`${slot}.authorization is unsupported here; inputFields requires model mutation options`);
11179
11294
  }
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
- `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,6 +145,7 @@ var init_public_admission = __esm({
128
145
  "skipParsing",
129
146
  "skipAuthorization",
130
147
  "alreadyAuthorized",
148
+ ...unsafeSnapshotOptions,
131
149
  "operation"
132
150
  ];
133
151
  PublicAdmissionError = class extends JsonRouter.clientErrors.BadRequestError {
@@ -2833,7 +2851,13 @@ var init_runtime = __esm({
2833
2851
  queryRouteSegment: "__query",
2834
2852
  mutationRouteSegment: "__mutation",
2835
2853
  operationAccess: false,
2836
- modelPermissionPrefix: ""
2854
+ modelPermissionPrefix: "",
2855
+ unsafeSkipListDocumentSnapshotChecks: false,
2856
+ unsafeSkipReadDocumentSnapshotChecks: false,
2857
+ unsafeSkipListOutputSnapshotChecks: false,
2858
+ unsafeSkipReadOutputSnapshotChecks: false,
2859
+ unsafeSkipListNestedDocumentSnapshotChecks: false,
2860
+ unsafeSkipReadNestedDocumentSnapshotChecks: false
2837
2861
  }).build();
2838
2862
  this.modelOptions = {};
2839
2863
  this.modelJsonSchemas = {};
@@ -3051,11 +3075,25 @@ var init_runtime = __esm({
3051
3075
  ...defaultModelOptions,
3052
3076
  modelName
3053
3077
  });
3078
+ const snapshotFlagChanged = (newValue, key, target, oldValue) => {
3079
+ target[key] = newValue === true;
3080
+ if (newValue !== true || oldValue === true) return;
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";
3084
+ try {
3085
+ this.getGlobalOption("logger")?.warn?.(
3086
+ `UNSAFE: ${operation} ${category} snapshot checks disabled; ${risk} can leave stale authorization decisions. Restore ${key}=false after the temporary workaround.`,
3087
+ { modelName }
3088
+ );
3089
+ } catch {
3090
+ }
3091
+ };
3054
3092
  manager.onchange("permissionSchema", function(_newval, _key, target) {
3055
3093
  refreshPermissionMetadata(target);
3056
3094
  }).onchange("modelPermissionPrefix", function(_newval, _key, target) {
3057
3095
  refreshPermissionMetadata(target);
3058
- }).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) {
3059
3097
  target[key] = normalizeBasePath(
3060
3098
  modelName,
3061
3099
  isString4(newval) || isNil2(newval) ? newval : void 0
@@ -3700,6 +3738,33 @@ function assertAuthorizationBinding(call, binding) {
3700
3738
  authorizationError("request/runtime/model/scope binding mismatch");
3701
3739
  }
3702
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
+ }
3703
3768
  function resolveServiceAuthorization(input) {
3704
3769
  const raw = copyAuthorizationValue(input.authorization);
3705
3770
  const configuration = copyAuthorizationValue(input.configuration, true);
@@ -3724,6 +3789,18 @@ function resolveServiceAuthorization(input) {
3724
3789
  );
3725
3790
  for (const value of Object.values(permissions)) if (value && typeof value === "object") Object.freeze(value);
3726
3791
  Object.freeze(permissions);
3792
+ const readAccess = outputAccess.rowAccess;
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);
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;
3727
3804
  const call = Object.freeze(/* @__PURE__ */ Object.create(null));
3728
3805
  calls.set(call, {
3729
3806
  binding: Object.freeze({ ...input.binding, scopePath: Object.freeze(scopePath) }),
@@ -3734,7 +3811,12 @@ function resolveServiceAuthorization(input) {
3734
3811
  // normalizeFields constructs only mode strings and validated string paths.
3735
3812
  output: Object.freeze({ access: outputAccess, catalog, outputFields: policy.outputFields }),
3736
3813
  permissions,
3737
- provenance: input.parent ? callRecord(input.parent).provenance : call
3814
+ provenance: input.parent ? callRecord(input.parent).provenance : call,
3815
+ readResponse,
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)
3738
3820
  });
3739
3821
  return call;
3740
3822
  }
@@ -3755,6 +3837,14 @@ function readServiceAuthorizationAccess(call, binding) {
3755
3837
  assertAuthorizationBinding(call, binding);
3756
3838
  return callRecord(call).output.access;
3757
3839
  }
3840
+ function requiresDocumentSnapshotChecks(call, binding) {
3841
+ assertAuthorizationBinding(call, binding);
3842
+ return callRecord(call).validateDocumentSnapshots;
3843
+ }
3844
+ function requiresOutputSnapshotChecks(call, binding) {
3845
+ assertAuthorizationBinding(call, binding);
3846
+ return callRecord(call).validateOutputSnapshots;
3847
+ }
3758
3848
  function readServiceAuthorizationHydration(call, binding) {
3759
3849
  assertAuthorizationBinding(call, binding);
3760
3850
  return copyAuthorizationValue({ hydration: callRecord(call).configuration.hydration }, true);
@@ -4683,6 +4773,7 @@ function lookupDocumentOwner(handle) {
4683
4773
  return record3;
4684
4774
  }
4685
4775
  function validateStageOwner(record3) {
4776
+ if (!record3.validateSnapshot) return;
4686
4777
  if (!matchesAuthorizationSnapshot(record3.input, record3.snapshot)) authorizationError("changed document snapshot");
4687
4778
  }
4688
4779
  function validateDocumentOwner(handle) {
@@ -4702,7 +4793,8 @@ function createDocumentAuthorizationStage(call, binding, projectedSnapshot) {
4702
4793
  call,
4703
4794
  binding: ownedBinding,
4704
4795
  input: projectedSnapshot,
4705
- snapshot
4796
+ snapshot,
4797
+ validateSnapshot: requiresDocumentSnapshotChecks(call, binding)
4706
4798
  });
4707
4799
  return stage;
4708
4800
  }
@@ -4710,7 +4802,7 @@ function assertDocumentAuthorizationStage(stage, call, binding, projectedSnapsho
4710
4802
  const record3 = lookupStageOwner(stage);
4711
4803
  validateStageOwner(record3);
4712
4804
  assertAuthorizationBinding(record3.call, binding);
4713
- if (record3.call !== call || record3.input !== projectedSnapshot || !matchesAuthorizationSnapshot(projectedSnapshot, record3.snapshot)) {
4805
+ if (record3.call !== call || record3.input !== projectedSnapshot || record3.validateSnapshot && !matchesAuthorizationSnapshot(projectedSnapshot, record3.snapshot)) {
4714
4806
  authorizationError("document call/stage/snapshot mismatch");
4715
4807
  }
4716
4808
  }
@@ -4921,7 +5013,7 @@ function tryStaticRequestFieldPaths(handle, binding, access) {
4921
5013
  return decisions && [...decisions].filter(([, allowed]) => allowed).map(([field]) => field);
4922
5014
  }
4923
5015
  function unchangedOutput(output, record3) {
4924
- if (!matchesAuthorizationSnapshot(output, record3.snapshot)) return false;
5016
+ if (record3.validateSnapshot && !matchesAuthorizationSnapshot(output, record3.snapshot)) return false;
4925
5017
  const identities = outputIdentities(output);
4926
5018
  return identities.length === record3.identities.length && identities.every((identity, i) => identity === record3.identities[i]);
4927
5019
  }
@@ -4949,7 +5041,8 @@ function associateDocumentAuthorization(handle, binding, output) {
4949
5041
  outputs.set(output, {
4950
5042
  handle,
4951
5043
  snapshot: copyAuthorizationValue(output, "document"),
4952
- identities: outputIdentities(output)
5044
+ identities: outputIdentities(output),
5045
+ validateSnapshot: requiresOutputSnapshotChecks(stage.call, binding)
4953
5046
  });
4954
5047
  }
4955
5048
  function transferDocumentAuthorization(handle, use, copy) {
@@ -5151,6 +5244,12 @@ function captureModelAuthorizationConfiguration(runtime, modelName, options = ru
5151
5244
  exposedDocPermissionKeys: options.exposedDocPermissionKeys,
5152
5245
  stripPermissionsField: options.stripPermissionsField,
5153
5246
  disableFieldPermissions: options.disableFieldPermissions,
5247
+ unsafeSkipListDocumentSnapshotChecks: options.unsafeSkipListDocumentSnapshotChecks === true,
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,
5154
5253
  overrideFilter: options.overrideFilter,
5155
5254
  baseFilter: options.baseFilter,
5156
5255
  idField: options.idField,
@@ -6382,7 +6481,8 @@ function authorizeEmbeddedOutputPlan(parent, child) {
6382
6481
  ...view,
6383
6482
  requestPermissions: getAuthorizationPermissions(parent.authorization, parent.authorizationBinding),
6384
6483
  authorization: serviceAuthorizationInput(view.authorization, view.relatedTargets),
6385
- parent: parent.authorization
6484
+ parent: parent.authorization,
6485
+ snapshotDerivation: { kind: "embedded", parentBinding: parent.authorizationBinding }
6386
6486
  });
6387
6487
  return { ...child, authorization, authorizationBinding: binding };
6388
6488
  }
@@ -8103,7 +8203,7 @@ function getServiceExecutors(receiver) {
8103
8203
  if (!registered) authorizationError("unregistered service receiver");
8104
8204
  return registered;
8105
8205
  }
8106
- 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) {
8107
8207
  const registered = getServiceExecutors(receiver);
8108
8208
  const receiving = registered.binding();
8109
8209
  const binding = Object.freeze({ ...receiving, scopePath: Object.freeze([...receiving.scopePath ?? []]) });
@@ -8115,7 +8215,10 @@ function createServiceExecution(receiver, access, authorization, applicability =
8115
8215
  relatedTargets,
8116
8216
  parent,
8117
8217
  configuration: configuration ?? registered.configuration(),
8118
- requestPermissions: requestPermissions ?? registered.permissions()
8218
+ requestPermissions: requestPermissions ?? registered.permissions(),
8219
+ listResponse: access.operation === "list" && parent === void 0,
8220
+ readResponse: access.operation === "read" && parent === void 0,
8221
+ snapshotDerivation
8119
8222
  });
8120
8223
  const execution = Object.freeze(/* @__PURE__ */ Object.create(null));
8121
8224
  executions.set(
@@ -8169,7 +8272,11 @@ function deriveServiceExecution(receiver, parent, access, applicability = "servi
8169
8272
  relatedTargets: captured.relatedTargets,
8170
8273
  configuration: captured.configuration,
8171
8274
  requestPermissions: getAuthorizationPermissions(record3.authorization, record3.binding),
8172
- parent: record3.authorization
8275
+ parent: record3.authorization,
8276
+ // The resolver authenticates root-read provenance and the unchanged owner tuple.
8277
+ // Effective list access is still a read; write branches cannot inherit this marker.
8278
+ readResponse: record3.access.operation === "read" && access.operation === "read",
8279
+ snapshotDerivation: { kind: "retry", parentBinding: record3.binding }
8173
8280
  });
8174
8281
  const execution = Object.freeze(/* @__PURE__ */ Object.create(null));
8175
8282
  executions.set(
@@ -8442,7 +8549,7 @@ function createRelatedExecution(receiver, access, parent, binding, path) {
8442
8549
  const captured = readServiceAuthorization(parent, binding);
8443
8550
  const target = captured.relatedTargets.find((entry) => entry.path === path);
8444
8551
  const policy = captured.authorization.related[path];
8445
- if (policy && (!target || target.modelName !== getServiceExecutors(receiver).binding().modelName))
8552
+ if ((target || policy) && (!target || target.modelName !== getServiceExecutors(receiver).binding().modelName))
8446
8553
  authorizationError(`related model mismatch: ${path}`);
8447
8554
  const execution = createServiceExecution(
8448
8555
  receiver,
@@ -8452,7 +8559,9 @@ function createRelatedExecution(receiver, access, parent, binding, path) {
8452
8559
  target?.relatedTargets ?? [],
8453
8560
  parent,
8454
8561
  target?.configuration,
8455
- getAuthorizationPermissions(parent, binding)
8562
+ getAuthorizationPermissions(parent, binding),
8563
+ access.operation === "list" ? "find" : "findOne",
8564
+ { kind: "related", parentBinding: binding, path }
8456
8565
  );
8457
8566
  return target?.queryIntent ? withExecutionQueryIntent(receiver, execution, target.queryIntent) : execution;
8458
8567
  }
@@ -9968,6 +10077,7 @@ init_document_authorization();
9968
10077
  init_output_field_filter();
9969
10078
  init_field_authorization();
9970
10079
  init_authorization_snapshot();
10080
+ init_unsafe_snapshot_options();
9971
10081
  init_public_admission();
9972
10082
 
9973
10083
  // src/acl/subdocument-output.ts
@@ -11158,6 +11268,11 @@ var Service = class extends Base {
11158
11268
  ["args", args],
11159
11269
  ["options", options]
11160
11270
  ]) {
11271
+ if (value !== null && (typeof value === "object" || typeof value === "function")) {
11272
+ for (const key of unsafeSnapshotOptions) {
11273
+ if (key in value) authorizationError(`${slot}.${key} is server model configuration only`);
11274
+ }
11275
+ }
11161
11276
  if (value !== null && (typeof value === "object" || typeof value === "function") && "authorization" in value && (slot === "args" || !authorizationOptions)) {
11162
11277
  authorizationError(`${slot}.authorization is unsupported here; inputFields requires model mutation options`);
11163
11278
  }
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.59.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.59.0",
61
- "@web-ts-toolkit/utils": "0.59.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",
@@ -1022,6 +1022,15 @@ declare const documentAuthorizationBrand: unique symbol;
1022
1022
  * and permission metadata are trimmed. Use the original unchanged output or a
1023
1023
  * package-created helper subset; caller spreads, matching IDs, changed values, another
1024
1024
  * row/call/access or pre-/post-write stages cannot establish validity and reject.
1025
+ * A list/read handle with its server unsafeSkipListDocumentSnapshotChecks or
1026
+ * unsafeSkipReadDocumentSnapshotChecks flag enabled retains that weakened source-
1027
+ * mutation policy; independent output-value/ownership checks still apply. Turning a setting
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.
1025
1034
  */
1026
1035
  interface DocumentAuthorization {
1027
1036
  readonly [documentAuthorizationBrand]: true;
@@ -1155,6 +1164,13 @@ interface AuthorizationFieldCatalog {
1155
1164
  }
1156
1165
  interface AuthorizationConfiguration {
1157
1166
  readonly catalog: AuthorizationFieldCatalog;
1167
+ /** Captured server model option; alone it never issues relaxed document authority. */
1168
+ readonly unsafeSkipListDocumentSnapshotChecks?: boolean;
1169
+ readonly unsafeSkipReadDocumentSnapshotChecks?: boolean;
1170
+ readonly unsafeSkipListOutputSnapshotChecks?: boolean;
1171
+ readonly unsafeSkipReadOutputSnapshotChecks?: boolean;
1172
+ readonly unsafeSkipListNestedDocumentSnapshotChecks?: boolean;
1173
+ readonly unsafeSkipReadNestedDocumentSnapshotChecks?: boolean;
1158
1174
  /** Opaque terminal private-input capture. Never related authority or public document metadata. */
1159
1175
  readonly virtualPopulateSnapshot?: VirtualPopulateSnapshotToken;
1160
1176
  /** Runtime-owned private input admission mode, not public output/related authority. */
@@ -3438,6 +3454,86 @@ interface DefaultModelRouterOptions<TModel = unknown> {
3438
3454
  * `includePermissions`. Defaults to `false`.
3439
3455
  */
3440
3456
  disableFieldPermissions?: boolean;
3457
+ /**
3458
+ * TEMPORARY UNSAFE performance escape hatch (default `false`). Only literal `true`
3459
+ * skips repeated projected-document snapshot comparisons for this model's top-level
3460
+ * `find`/public/root list responses. Captured before awaits; list-origin handles keep
3461
+ * that mode. Single reads use the independent unsafeSkipReadDocumentSnapshotChecks
3462
+ * setting. Embedded/related source stages and output values have separate flags.
3463
+ * Writes and fresh standalone helpers stay strict.
3464
+ *
3465
+ * Row/field permissions, exact ownership/binding, independent output-value checks
3466
+ * and detached callback/grant copies still run. However, source changes during a
3467
+ * callback/await are no longer detected: stale grants/decisions may authorize output.
3468
+ * Use only with trusted non-mutating application hooks, measure before rollout, and
3469
+ * restore `false` as soon as possible. Enabling logs a warning once per model transition.
3470
+ * Server model configuration only, never service.defaults, per-call or wire options.
3471
+ */
3472
+ unsafeSkipListDocumentSnapshotChecks?: boolean;
3473
+ /**
3474
+ * TEMPORARY UNSAFE single-read escape hatch (default `false`). Only literal `true`
3475
+ * skips repeated projected-document snapshot comparisons in top-level findOne,
3476
+ * findById, public identifier/filter reads and root reads. Read-to-list retries use
3477
+ * this setting, not unsafeSkipListDocumentSnapshotChecks. Captured before awaits;
3478
+ * read-origin handles and retries keep that mode. List operations use their own flag.
3479
+ *
3480
+ * Permission rules, exact ownership/binding, independent output-value checks and
3481
+ * detached callback/grant copies still run. Source changes during callbacks/awaits
3482
+ * can leave stale grants/decisions and incorrectly authorized output. Use only with
3483
+ * trusted non-mutating hooks, measure before rollout and restore `false` promptly.
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.
3488
+ */
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;
3441
3537
  }
3442
3538
  interface ExtendedDefaultModelRouterOptions<TModel = unknown> extends DefaultModelRouterOptions<TModel> {
3443
3539
  'hydration.publicList'?: HydrationMode;
@@ -1022,6 +1022,15 @@ declare const documentAuthorizationBrand: unique symbol;
1022
1022
  * and permission metadata are trimmed. Use the original unchanged output or a
1023
1023
  * package-created helper subset; caller spreads, matching IDs, changed values, another
1024
1024
  * row/call/access or pre-/post-write stages cannot establish validity and reject.
1025
+ * A list/read handle with its server unsafeSkipListDocumentSnapshotChecks or
1026
+ * unsafeSkipReadDocumentSnapshotChecks flag enabled retains that weakened source-
1027
+ * mutation policy; independent output-value/ownership checks still apply. Turning a setting
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.
1025
1034
  */
1026
1035
  interface DocumentAuthorization {
1027
1036
  readonly [documentAuthorizationBrand]: true;
@@ -1155,6 +1164,13 @@ interface AuthorizationFieldCatalog {
1155
1164
  }
1156
1165
  interface AuthorizationConfiguration {
1157
1166
  readonly catalog: AuthorizationFieldCatalog;
1167
+ /** Captured server model option; alone it never issues relaxed document authority. */
1168
+ readonly unsafeSkipListDocumentSnapshotChecks?: boolean;
1169
+ readonly unsafeSkipReadDocumentSnapshotChecks?: boolean;
1170
+ readonly unsafeSkipListOutputSnapshotChecks?: boolean;
1171
+ readonly unsafeSkipReadOutputSnapshotChecks?: boolean;
1172
+ readonly unsafeSkipListNestedDocumentSnapshotChecks?: boolean;
1173
+ readonly unsafeSkipReadNestedDocumentSnapshotChecks?: boolean;
1158
1174
  /** Opaque terminal private-input capture. Never related authority or public document metadata. */
1159
1175
  readonly virtualPopulateSnapshot?: VirtualPopulateSnapshotToken;
1160
1176
  /** Runtime-owned private input admission mode, not public output/related authority. */
@@ -3438,6 +3454,86 @@ interface DefaultModelRouterOptions<TModel = unknown> {
3438
3454
  * `includePermissions`. Defaults to `false`.
3439
3455
  */
3440
3456
  disableFieldPermissions?: boolean;
3457
+ /**
3458
+ * TEMPORARY UNSAFE performance escape hatch (default `false`). Only literal `true`
3459
+ * skips repeated projected-document snapshot comparisons for this model's top-level
3460
+ * `find`/public/root list responses. Captured before awaits; list-origin handles keep
3461
+ * that mode. Single reads use the independent unsafeSkipReadDocumentSnapshotChecks
3462
+ * setting. Embedded/related source stages and output values have separate flags.
3463
+ * Writes and fresh standalone helpers stay strict.
3464
+ *
3465
+ * Row/field permissions, exact ownership/binding, independent output-value checks
3466
+ * and detached callback/grant copies still run. However, source changes during a
3467
+ * callback/await are no longer detected: stale grants/decisions may authorize output.
3468
+ * Use only with trusted non-mutating application hooks, measure before rollout, and
3469
+ * restore `false` as soon as possible. Enabling logs a warning once per model transition.
3470
+ * Server model configuration only, never service.defaults, per-call or wire options.
3471
+ */
3472
+ unsafeSkipListDocumentSnapshotChecks?: boolean;
3473
+ /**
3474
+ * TEMPORARY UNSAFE single-read escape hatch (default `false`). Only literal `true`
3475
+ * skips repeated projected-document snapshot comparisons in top-level findOne,
3476
+ * findById, public identifier/filter reads and root reads. Read-to-list retries use
3477
+ * this setting, not unsafeSkipListDocumentSnapshotChecks. Captured before awaits;
3478
+ * read-origin handles and retries keep that mode. List operations use their own flag.
3479
+ *
3480
+ * Permission rules, exact ownership/binding, independent output-value checks and
3481
+ * detached callback/grant copies still run. Source changes during callbacks/awaits
3482
+ * can leave stale grants/decisions and incorrectly authorized output. Use only with
3483
+ * trusted non-mutating hooks, measure before rollout and restore `false` promptly.
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.
3488
+ */
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;
3441
3537
  }
3442
3538
  interface ExtendedDefaultModelRouterOptions<TModel = unknown> extends DefaultModelRouterOptions<TModel> {
3443
3539
  'hydration.publicList'?: HydrationMode;