@web-ts-toolkit/access-router 0.28.0 → 0.30.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/advanced.d.mts +1 -1
- package/advanced.d.ts +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +131 -118
- package/index.mjs +35 -19
- package/package.json +3 -3
- package/{parsers-Cj4r_G4g.d.mts → parsers-B8bwUDPv.d.mts} +1 -1
- package/{parsers-Cj4r_G4g.d.ts → parsers-B8bwUDPv.d.ts} +1 -1
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 AjvValidatorLike, n as ArkTypeErrorsLike, o as ArkTypeLike, p as ArkTypeProblemLike, B as BaseFilterAccess, C as Change, q as Codes, r as CountBody, s as CreateArgs, t as CreateOptions, u as CreateQueryInput, v as CustomHeaders, D as DataBaseFilterHook, w as DataFilter, x as DataFindArgs, y as DataFindOneArgs, z as DataFindOneOptions, E as DataFindOptions, F as DataHook, G as DataHookContext, H as DataIdentifierHook, I as DataListHook, J as DataOverrideFilterHook, K as DataRequest, L as DataRequestSchemas, M as DataRouterOptions, N as DecorateAccess, O as DecorateAllAccess, P as DeepFieldPath, Q as DefaultModelRouterOptions, R as Defaults, S as DistinctArgs, T as DistinctBody, U as DocPermissionsAccess, V as ErrorResult, W as ExistsOptions, X as ExtendedDataRouterOptions, Y as ExtendedDefaultModelRouterOptions, Z as ExtendedModelRouterOptions, _ as Filter, $ as FilterOperator, a0 as FindAccess, a1 as FindArgs, a2 as FindByIdArgs, a3 as FindByIdOptions, a4 as FindOneArgs, a5 as FindOneOptions, a6 as FindOptions, a7 as GlobalOptions, a8 as GlobalPermissionValue, a9 as GuardHook, aa as IdentifierHook, ab as Include, ac as IoTsContextEntryLike, ad as IoTsDecodeErrorLike, ae as IoTsDecoderLike, af as JoiSchemaLike, ag as JoiValidationErrorDetailLike, ah as KeyValueProjection, ai as ListQueryInput, aj as ListResult, ak as MaybePromise, al as ModelBaseFilterHook, am as ModelChangeHook, an as ModelDeleteHook, ao as ModelDocPermissionsHook, ap as ModelDocument, aq as ModelDocumentHook, ar as ModelHook, as as ModelHookContext, at as ModelIdentifierHook, au as ModelListHook, av as ModelOverrideFilterHook, aw as ModelRequest, ax as ModelRouterOptions, ay as ModelValidateHook, az as PathValue, aA as PermissionSchema, aB as Populate, aC as PopulateAccess, aD as PrepareAccess, aE as Projection, aF as PublicCreateArgs, aG as PublicCreateOptions, aH as PublicListArgs, aI as PublicListOptions, aJ as PublicOutput, aK as PublicReadArgs, aL as PublicReadOptions, aM as PublicUpdateArgs, aN as PublicUpdateOptions, aO as PublicUpsertArgs, aP as PublicUpsertOptions, aQ as ReadQueryInput, aR as Request, aS as RequestSchemaAdapter, aT as RequestSchemaFailure, aU as RequestSchemaIssue, aV as RequestSchemaLike, aW as RequestSchemaOptions, aX as RequestSchemaResult, aY as RequestSchemaSuccess, aZ as RequestSchemaValidator, a_ as RequestSchemas, a$ as RootDataListQueryEntry, b0 as RootDataOperation, b1 as RootDataReadByFilterQueryEntry, b2 as RootDataReadByIdQueryEntry, b3 as RootModelCountQueryEntry, b4 as RootModelCreateQueryEntry, b5 as RootModelDeleteQueryEntry, b6 as RootModelDistinctQueryEntry, b7 as RootModelListQueryEntry, b8 as RootModelNewQueryEntry, b9 as RootModelOperation, ba as RootModelReadByFilterQueryEntry, bb as RootModelReadByIdQueryEntry, bc as RootModelSubBulkUpdateQueryEntry, bd as RootModelSubCreateQueryEntry, be as RootModelSubDeleteQueryEntry, bf as RootModelSubListQueryEntry, bg as RootModelSubReadQueryEntry, bh as RootModelSubUpdateQueryEntry, bi as RootModelUpdateQueryEntry, bj as RootModelUpsertQueryEntry, bk as RootOperationResult, bl as RootQueryEntry, bm as RootRouterOptions, bn as RootSubOperation, bo as RootTarget, bp as RouteGuardAccess, bq as SelectAccess, br as SelectedPopulatedPublicOutput, bs as SelectedPublicOutput, bt as ServiceResult, bu as SingleResult, bv as Sort, bw as SortOrder, bx as StandardSchemaFailure, by as StandardSchemaInferOutput, bz as StandardSchemaIssue, bA as StandardSchemaPathSegment, bB as StandardSchemaResult, bC as StandardSchemaSuccess, bD as StandardSchemaV1, bE as StatusCodes, bF as SubListBody, bG as SubPopulate, bH as SubQueryEntry, bI as SubReadBody, bJ as SuperstructFailureLike, bK as SuperstructValidateLike, bL as Task, bM as TransformAccess, bN as TypedFilter, bO as UpdateByIdArgs, bP as UpdateByIdOptions, bQ as UpdateOneArgs, bR as UpdateOneOptions, bS as UpdateQueryInput, bT as UpsertArgs, bU as UpsertOptions, bV as UpsertQueryInput, bW as ValibotIssueLike, bX as ValibotPathItemLike, bY as ValibotSafeParseLike, bZ as ValibotSafeParseResult, b_ as ValidateAccess, b$ as ValidateRule, c0 as Validation, c1 as ValidationError, c2 as VineValidationErrorLike, c3 as VineValidationMessageLike, c4 as VineValidatorLike, c5 as YupSchemaLike, c6 as YupValidationErrorLike, c7 as defineRequestSchema, c8 as fromAjv, c9 as fromArkType, ca as fromIoTs, cb as fromJoi, cc as fromStandardSchema, cd as fromSuperstruct, ce as fromValibot, cf as fromVine, cg as fromYup, ch as fromZod, ci as parseBody, cj as parseBodyWithSchema, ck as parseNestedBodyWithSchema, cl as parsePathParam, cm as parseQuery } from './parsers-
|
|
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 AjvValidatorLike, n as ArkTypeErrorsLike, o as ArkTypeLike, p as ArkTypeProblemLike, B as BaseFilterAccess, C as Change, q as Codes, r as CountBody, s as CreateArgs, t as CreateOptions, u as CreateQueryInput, v as CustomHeaders, D as DataBaseFilterHook, w as DataFilter, x as DataFindArgs, y as DataFindOneArgs, z as DataFindOneOptions, E as DataFindOptions, F as DataHook, G as DataHookContext, H as DataIdentifierHook, I as DataListHook, J as DataOverrideFilterHook, K as DataRequest, L as DataRequestSchemas, M as DataRouterOptions, N as DecorateAccess, O as DecorateAllAccess, P as DeepFieldPath, Q as DefaultModelRouterOptions, R as Defaults, S as DistinctArgs, T as DistinctBody, U as DocPermissionsAccess, V as ErrorResult, W as ExistsOptions, X as ExtendedDataRouterOptions, Y as ExtendedDefaultModelRouterOptions, Z as ExtendedModelRouterOptions, _ as Filter, $ as FilterOperator, a0 as FindAccess, a1 as FindArgs, a2 as FindByIdArgs, a3 as FindByIdOptions, a4 as FindOneArgs, a5 as FindOneOptions, a6 as FindOptions, a7 as GlobalOptions, a8 as GlobalPermissionValue, a9 as GuardHook, aa as IdentifierHook, ab as Include, ac as IoTsContextEntryLike, ad as IoTsDecodeErrorLike, ae as IoTsDecoderLike, af as JoiSchemaLike, ag as JoiValidationErrorDetailLike, ah as KeyValueProjection, ai as ListQueryInput, aj as ListResult, ak as MaybePromise, al as ModelBaseFilterHook, am as ModelChangeHook, an as ModelDeleteHook, ao as ModelDocPermissionsHook, ap as ModelDocument, aq as ModelDocumentHook, ar as ModelHook, as as ModelHookContext, at as ModelIdentifierHook, au as ModelListHook, av as ModelOverrideFilterHook, aw as ModelRequest, ax as ModelRouterOptions, ay as ModelValidateHook, az as PathValue, aA as PermissionSchema, aB as Populate, aC as PopulateAccess, aD as PrepareAccess, aE as Projection, aF as PublicCreateArgs, aG as PublicCreateOptions, aH as PublicListArgs, aI as PublicListOptions, aJ as PublicOutput, aK as PublicReadArgs, aL as PublicReadOptions, aM as PublicUpdateArgs, aN as PublicUpdateOptions, aO as PublicUpsertArgs, aP as PublicUpsertOptions, aQ as ReadQueryInput, aR as Request, aS as RequestSchemaAdapter, aT as RequestSchemaFailure, aU as RequestSchemaIssue, aV as RequestSchemaLike, aW as RequestSchemaOptions, aX as RequestSchemaResult, aY as RequestSchemaSuccess, aZ as RequestSchemaValidator, a_ as RequestSchemas, a$ as RootDataListQueryEntry, b0 as RootDataOperation, b1 as RootDataReadByFilterQueryEntry, b2 as RootDataReadByIdQueryEntry, b3 as RootModelCountQueryEntry, b4 as RootModelCreateQueryEntry, b5 as RootModelDeleteQueryEntry, b6 as RootModelDistinctQueryEntry, b7 as RootModelListQueryEntry, b8 as RootModelNewQueryEntry, b9 as RootModelOperation, ba as RootModelReadByFilterQueryEntry, bb as RootModelReadByIdQueryEntry, bc as RootModelSubBulkUpdateQueryEntry, bd as RootModelSubCreateQueryEntry, be as RootModelSubDeleteQueryEntry, bf as RootModelSubListQueryEntry, bg as RootModelSubReadQueryEntry, bh as RootModelSubUpdateQueryEntry, bi as RootModelUpdateQueryEntry, bj as RootModelUpsertQueryEntry, bk as RootOperationResult, bl as RootQueryEntry, bm as RootRouterOptions, bn as RootSubOperation, bo as RootTarget, bp as RouteGuardAccess, bq as SelectAccess, br as SelectedPopulatedPublicOutput, bs as SelectedPublicOutput, bt as ServiceResult, bu as SingleResult, bv as Sort, bw as SortOrder, bx as StandardSchemaFailure, by as StandardSchemaInferOutput, bz as StandardSchemaIssue, bA as StandardSchemaPathSegment, bB as StandardSchemaResult, bC as StandardSchemaSuccess, bD as StandardSchemaV1, bE as StatusCodes, bF as SubListBody, bG as SubPopulate, bH as SubQueryEntry, bI as SubReadBody, bJ as SuperstructFailureLike, bK as SuperstructValidateLike, bL as Task, bM as TransformAccess, bN as TypedFilter, bO as UpdateByIdArgs, bP as UpdateByIdOptions, bQ as UpdateOneArgs, bR as UpdateOneOptions, bS as UpdateQueryInput, bT as UpsertArgs, bU as UpsertOptions, bV as UpsertQueryInput, bW as ValibotIssueLike, bX as ValibotPathItemLike, bY as ValibotSafeParseLike, bZ as ValibotSafeParseResult, b_ as ValidateAccess, b$ as ValidateRule, c0 as Validation, c1 as ValidationError, c2 as VineValidationErrorLike, c3 as VineValidationMessageLike, c4 as VineValidatorLike, c5 as YupSchemaLike, c6 as YupValidationErrorLike, c7 as defineRequestSchema, c8 as fromAjv, c9 as fromArkType, ca as fromIoTs, cb as fromJoi, cc as fromStandardSchema, cd as fromSuperstruct, ce as fromValibot, cf as fromVine, cg as fromYup, ch as fromZod, ci as parseBody, cj as parseBodyWithSchema, ck as parseNestedBodyWithSchema, cl as parsePathParam, cm as parseQuery } from './parsers-B8bwUDPv.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 AjvValidatorLike, n as ArkTypeErrorsLike, o as ArkTypeLike, p as ArkTypeProblemLike, B as BaseFilterAccess, C as Change, q as Codes, r as CountBody, s as CreateArgs, t as CreateOptions, u as CreateQueryInput, v as CustomHeaders, D as DataBaseFilterHook, w as DataFilter, x as DataFindArgs, y as DataFindOneArgs, z as DataFindOneOptions, E as DataFindOptions, F as DataHook, G as DataHookContext, H as DataIdentifierHook, I as DataListHook, J as DataOverrideFilterHook, K as DataRequest, L as DataRequestSchemas, M as DataRouterOptions, N as DecorateAccess, O as DecorateAllAccess, P as DeepFieldPath, Q as DefaultModelRouterOptions, R as Defaults, S as DistinctArgs, T as DistinctBody, U as DocPermissionsAccess, V as ErrorResult, W as ExistsOptions, X as ExtendedDataRouterOptions, Y as ExtendedDefaultModelRouterOptions, Z as ExtendedModelRouterOptions, _ as Filter, $ as FilterOperator, a0 as FindAccess, a1 as FindArgs, a2 as FindByIdArgs, a3 as FindByIdOptions, a4 as FindOneArgs, a5 as FindOneOptions, a6 as FindOptions, a7 as GlobalOptions, a8 as GlobalPermissionValue, a9 as GuardHook, aa as IdentifierHook, ab as Include, ac as IoTsContextEntryLike, ad as IoTsDecodeErrorLike, ae as IoTsDecoderLike, af as JoiSchemaLike, ag as JoiValidationErrorDetailLike, ah as KeyValueProjection, ai as ListQueryInput, aj as ListResult, ak as MaybePromise, al as ModelBaseFilterHook, am as ModelChangeHook, an as ModelDeleteHook, ao as ModelDocPermissionsHook, ap as ModelDocument, aq as ModelDocumentHook, ar as ModelHook, as as ModelHookContext, at as ModelIdentifierHook, au as ModelListHook, av as ModelOverrideFilterHook, aw as ModelRequest, ax as ModelRouterOptions, ay as ModelValidateHook, az as PathValue, aA as PermissionSchema, aB as Populate, aC as PopulateAccess, aD as PrepareAccess, aE as Projection, aF as PublicCreateArgs, aG as PublicCreateOptions, aH as PublicListArgs, aI as PublicListOptions, aJ as PublicOutput, aK as PublicReadArgs, aL as PublicReadOptions, aM as PublicUpdateArgs, aN as PublicUpdateOptions, aO as PublicUpsertArgs, aP as PublicUpsertOptions, aQ as ReadQueryInput, aR as Request, aS as RequestSchemaAdapter, aT as RequestSchemaFailure, aU as RequestSchemaIssue, aV as RequestSchemaLike, aW as RequestSchemaOptions, aX as RequestSchemaResult, aY as RequestSchemaSuccess, aZ as RequestSchemaValidator, a_ as RequestSchemas, a$ as RootDataListQueryEntry, b0 as RootDataOperation, b1 as RootDataReadByFilterQueryEntry, b2 as RootDataReadByIdQueryEntry, b3 as RootModelCountQueryEntry, b4 as RootModelCreateQueryEntry, b5 as RootModelDeleteQueryEntry, b6 as RootModelDistinctQueryEntry, b7 as RootModelListQueryEntry, b8 as RootModelNewQueryEntry, b9 as RootModelOperation, ba as RootModelReadByFilterQueryEntry, bb as RootModelReadByIdQueryEntry, bc as RootModelSubBulkUpdateQueryEntry, bd as RootModelSubCreateQueryEntry, be as RootModelSubDeleteQueryEntry, bf as RootModelSubListQueryEntry, bg as RootModelSubReadQueryEntry, bh as RootModelSubUpdateQueryEntry, bi as RootModelUpdateQueryEntry, bj as RootModelUpsertQueryEntry, bk as RootOperationResult, bl as RootQueryEntry, bm as RootRouterOptions, bn as RootSubOperation, bo as RootTarget, bp as RouteGuardAccess, bq as SelectAccess, br as SelectedPopulatedPublicOutput, bs as SelectedPublicOutput, bt as ServiceResult, bu as SingleResult, bv as Sort, bw as SortOrder, bx as StandardSchemaFailure, by as StandardSchemaInferOutput, bz as StandardSchemaIssue, bA as StandardSchemaPathSegment, bB as StandardSchemaResult, bC as StandardSchemaSuccess, bD as StandardSchemaV1, bE as StatusCodes, bF as SubListBody, bG as SubPopulate, bH as SubQueryEntry, bI as SubReadBody, bJ as SuperstructFailureLike, bK as SuperstructValidateLike, bL as Task, bM as TransformAccess, bN as TypedFilter, bO as UpdateByIdArgs, bP as UpdateByIdOptions, bQ as UpdateOneArgs, bR as UpdateOneOptions, bS as UpdateQueryInput, bT as UpsertArgs, bU as UpsertOptions, bV as UpsertQueryInput, bW as ValibotIssueLike, bX as ValibotPathItemLike, bY as ValibotSafeParseLike, bZ as ValibotSafeParseResult, b_ as ValidateAccess, b$ as ValidateRule, c0 as Validation, c1 as ValidationError, c2 as VineValidationErrorLike, c3 as VineValidationMessageLike, c4 as VineValidatorLike, c5 as YupSchemaLike, c6 as YupValidationErrorLike, c7 as defineRequestSchema, c8 as fromAjv, c9 as fromArkType, ca as fromIoTs, cb as fromJoi, cc as fromStandardSchema, cd as fromSuperstruct, ce as fromValibot, cf as fromVine, cg as fromYup, ch as fromZod, ci as parseBody, cj as parseBodyWithSchema, ck as parseNestedBodyWithSchema, cl as parsePathParam, cm as parseQuery } from './parsers-
|
|
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 AjvValidatorLike, n as ArkTypeErrorsLike, o as ArkTypeLike, p as ArkTypeProblemLike, B as BaseFilterAccess, C as Change, q as Codes, r as CountBody, s as CreateArgs, t as CreateOptions, u as CreateQueryInput, v as CustomHeaders, D as DataBaseFilterHook, w as DataFilter, x as DataFindArgs, y as DataFindOneArgs, z as DataFindOneOptions, E as DataFindOptions, F as DataHook, G as DataHookContext, H as DataIdentifierHook, I as DataListHook, J as DataOverrideFilterHook, K as DataRequest, L as DataRequestSchemas, M as DataRouterOptions, N as DecorateAccess, O as DecorateAllAccess, P as DeepFieldPath, Q as DefaultModelRouterOptions, R as Defaults, S as DistinctArgs, T as DistinctBody, U as DocPermissionsAccess, V as ErrorResult, W as ExistsOptions, X as ExtendedDataRouterOptions, Y as ExtendedDefaultModelRouterOptions, Z as ExtendedModelRouterOptions, _ as Filter, $ as FilterOperator, a0 as FindAccess, a1 as FindArgs, a2 as FindByIdArgs, a3 as FindByIdOptions, a4 as FindOneArgs, a5 as FindOneOptions, a6 as FindOptions, a7 as GlobalOptions, a8 as GlobalPermissionValue, a9 as GuardHook, aa as IdentifierHook, ab as Include, ac as IoTsContextEntryLike, ad as IoTsDecodeErrorLike, ae as IoTsDecoderLike, af as JoiSchemaLike, ag as JoiValidationErrorDetailLike, ah as KeyValueProjection, ai as ListQueryInput, aj as ListResult, ak as MaybePromise, al as ModelBaseFilterHook, am as ModelChangeHook, an as ModelDeleteHook, ao as ModelDocPermissionsHook, ap as ModelDocument, aq as ModelDocumentHook, ar as ModelHook, as as ModelHookContext, at as ModelIdentifierHook, au as ModelListHook, av as ModelOverrideFilterHook, aw as ModelRequest, ax as ModelRouterOptions, ay as ModelValidateHook, az as PathValue, aA as PermissionSchema, aB as Populate, aC as PopulateAccess, aD as PrepareAccess, aE as Projection, aF as PublicCreateArgs, aG as PublicCreateOptions, aH as PublicListArgs, aI as PublicListOptions, aJ as PublicOutput, aK as PublicReadArgs, aL as PublicReadOptions, aM as PublicUpdateArgs, aN as PublicUpdateOptions, aO as PublicUpsertArgs, aP as PublicUpsertOptions, aQ as ReadQueryInput, aR as Request, aS as RequestSchemaAdapter, aT as RequestSchemaFailure, aU as RequestSchemaIssue, aV as RequestSchemaLike, aW as RequestSchemaOptions, aX as RequestSchemaResult, aY as RequestSchemaSuccess, aZ as RequestSchemaValidator, a_ as RequestSchemas, a$ as RootDataListQueryEntry, b0 as RootDataOperation, b1 as RootDataReadByFilterQueryEntry, b2 as RootDataReadByIdQueryEntry, b3 as RootModelCountQueryEntry, b4 as RootModelCreateQueryEntry, b5 as RootModelDeleteQueryEntry, b6 as RootModelDistinctQueryEntry, b7 as RootModelListQueryEntry, b8 as RootModelNewQueryEntry, b9 as RootModelOperation, ba as RootModelReadByFilterQueryEntry, bb as RootModelReadByIdQueryEntry, bc as RootModelSubBulkUpdateQueryEntry, bd as RootModelSubCreateQueryEntry, be as RootModelSubDeleteQueryEntry, bf as RootModelSubListQueryEntry, bg as RootModelSubReadQueryEntry, bh as RootModelSubUpdateQueryEntry, bi as RootModelUpdateQueryEntry, bj as RootModelUpsertQueryEntry, bk as RootOperationResult, bl as RootQueryEntry, bm as RootRouterOptions, bn as RootSubOperation, bo as RootTarget, bp as RouteGuardAccess, bq as SelectAccess, br as SelectedPopulatedPublicOutput, bs as SelectedPublicOutput, bt as ServiceResult, bu as SingleResult, bv as Sort, bw as SortOrder, bx as StandardSchemaFailure, by as StandardSchemaInferOutput, bz as StandardSchemaIssue, bA as StandardSchemaPathSegment, bB as StandardSchemaResult, bC as StandardSchemaSuccess, bD as StandardSchemaV1, bE as StatusCodes, bF as SubListBody, bG as SubPopulate, bH as SubQueryEntry, bI as SubReadBody, bJ as SuperstructFailureLike, bK as SuperstructValidateLike, bL as Task, bM as TransformAccess, bN as TypedFilter, bO as UpdateByIdArgs, bP as UpdateByIdOptions, bQ as UpdateOneArgs, bR as UpdateOneOptions, bS as UpdateQueryInput, bT as UpsertArgs, bU as UpsertOptions, bV as UpsertQueryInput, bW as ValibotIssueLike, bX as ValibotPathItemLike, bY as ValibotSafeParseLike, bZ as ValibotSafeParseResult, b_ as ValidateAccess, b$ as ValidateRule, c0 as Validation, c1 as ValidationError, c2 as VineValidationErrorLike, c3 as VineValidationMessageLike, c4 as VineValidatorLike, c5 as YupSchemaLike, c6 as YupValidationErrorLike, c7 as defineRequestSchema, c8 as fromAjv, c9 as fromArkType, ca as fromIoTs, cb as fromJoi, cc as fromStandardSchema, cd as fromSuperstruct, ce as fromValibot, cf as fromVine, cg as fromYup, ch as fromZod, ci as parseBody, cj as parseBodyWithSchema, ck as parseNestedBodyWithSchema, cl as parsePathParam, cm as parseQuery } from './parsers-B8bwUDPv.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import 'mongoose';
|
|
4
4
|
import 'express';
|
package/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
2
|
import { Response, NextFunction, Router } from 'express';
|
|
3
|
-
import { a7 as GlobalOptions, Q as DefaultModelRouterOptions, Y as ExtendedDefaultModelRouterOptions, ax as ModelRouterOptions, Z as ExtendedModelRouterOptions, M as DataRouterOptions, X as ExtendedDataRouterOptions, A as AccessRouterBaseRequest, a9 as GuardHook, aw as ModelRequest, K as DataRequest, cn as DataService, co as Model, cp as Service, cq as PublicService, c0 as Validation, bm as RootRouterOptions } from './parsers-
|
|
4
|
-
export { cr as AccessRouterPermissionMap, cs as AccessRouterPermissions, c as AccessRouterRequest, d as AccessRouterRequestExtensions, l as AjvErrorObjectLike, m as AjvValidatorLike, n as ArkTypeErrorsLike, o as ArkTypeLike, ac as IoTsContextEntryLike, ad as IoTsDecodeErrorLike, ae as IoTsDecoderLike, af as JoiSchemaLike, ag as JoiValidationErrorDetailLike, ct as Permissions, aS as RequestSchemaAdapter, aT as RequestSchemaFailure, aU as RequestSchemaIssue, aV as RequestSchemaLike, aW as RequestSchemaOptions, aX as RequestSchemaResult, aY as RequestSchemaSuccess, aZ as RequestSchemaValidator, bx as StandardSchemaFailure, by as StandardSchemaInferOutput, bz as StandardSchemaIssue, bA as StandardSchemaPathSegment, bB as StandardSchemaResult, bC as StandardSchemaSuccess, bD as StandardSchemaV1, bJ as SuperstructFailureLike, bK as SuperstructValidateLike, bW as ValibotIssueLike, bX as ValibotPathItemLike, bY as ValibotSafeParseLike, bZ as ValibotSafeParseResult, c2 as VineValidationErrorLike, c3 as VineValidationMessageLike, c4 as VineValidatorLike, c5 as YupSchemaLike, c6 as YupValidationErrorLike, c7 as defineRequestSchema, c8 as fromAjv, c9 as fromArkType, ca as fromIoTs, cb as fromJoi, cc as fromStandardSchema, cd as fromSuperstruct, ce as fromValibot, cf as fromVine, cg as fromYup, ch as fromZod } from './parsers-
|
|
3
|
+
import { a7 as GlobalOptions, Q as DefaultModelRouterOptions, Y as ExtendedDefaultModelRouterOptions, ax as ModelRouterOptions, Z as ExtendedModelRouterOptions, M as DataRouterOptions, X as ExtendedDataRouterOptions, A as AccessRouterBaseRequest, a9 as GuardHook, aw as ModelRequest, K as DataRequest, cn as DataService, co as Model, cp as Service, cq as PublicService, c0 as Validation, bm as RootRouterOptions } from './parsers-B8bwUDPv.mjs';
|
|
4
|
+
export { cr as AccessRouterPermissionMap, cs as AccessRouterPermissions, c as AccessRouterRequest, d as AccessRouterRequestExtensions, l as AjvErrorObjectLike, m as AjvValidatorLike, n as ArkTypeErrorsLike, o as ArkTypeLike, ac as IoTsContextEntryLike, ad as IoTsDecodeErrorLike, ae as IoTsDecoderLike, af as JoiSchemaLike, ag as JoiValidationErrorDetailLike, ct as Permissions, aS as RequestSchemaAdapter, aT as RequestSchemaFailure, aU as RequestSchemaIssue, aV as RequestSchemaLike, aW as RequestSchemaOptions, aX as RequestSchemaResult, aY as RequestSchemaSuccess, aZ as RequestSchemaValidator, bx as StandardSchemaFailure, by as StandardSchemaInferOutput, bz as StandardSchemaIssue, bA as StandardSchemaPathSegment, bB as StandardSchemaResult, bC as StandardSchemaSuccess, bD as StandardSchemaV1, bJ as SuperstructFailureLike, bK as SuperstructValidateLike, bW as ValibotIssueLike, bX as ValibotPathItemLike, bY as ValibotSafeParseLike, bZ as ValibotSafeParseResult, c2 as VineValidationErrorLike, c3 as VineValidationMessageLike, c4 as VineValidatorLike, c5 as YupSchemaLike, c6 as YupValidationErrorLike, c7 as defineRequestSchema, c8 as fromAjv, c9 as fromArkType, ca as fromIoTs, cb as fromJoi, cc as fromStandardSchema, cd as fromSuperstruct, ce as fromValibot, cf as fromVine, cg as fromYup, ch as fromZod } from './parsers-B8bwUDPv.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 from 'mongoose';
|
|
2
2
|
import { Response, NextFunction, Router } from 'express';
|
|
3
|
-
import { a7 as GlobalOptions, Q as DefaultModelRouterOptions, Y as ExtendedDefaultModelRouterOptions, ax as ModelRouterOptions, Z as ExtendedModelRouterOptions, M as DataRouterOptions, X as ExtendedDataRouterOptions, A as AccessRouterBaseRequest, a9 as GuardHook, aw as ModelRequest, K as DataRequest, cn as DataService, co as Model, cp as Service, cq as PublicService, c0 as Validation, bm as RootRouterOptions } from './parsers-
|
|
4
|
-
export { cr as AccessRouterPermissionMap, cs as AccessRouterPermissions, c as AccessRouterRequest, d as AccessRouterRequestExtensions, l as AjvErrorObjectLike, m as AjvValidatorLike, n as ArkTypeErrorsLike, o as ArkTypeLike, ac as IoTsContextEntryLike, ad as IoTsDecodeErrorLike, ae as IoTsDecoderLike, af as JoiSchemaLike, ag as JoiValidationErrorDetailLike, ct as Permissions, aS as RequestSchemaAdapter, aT as RequestSchemaFailure, aU as RequestSchemaIssue, aV as RequestSchemaLike, aW as RequestSchemaOptions, aX as RequestSchemaResult, aY as RequestSchemaSuccess, aZ as RequestSchemaValidator, bx as StandardSchemaFailure, by as StandardSchemaInferOutput, bz as StandardSchemaIssue, bA as StandardSchemaPathSegment, bB as StandardSchemaResult, bC as StandardSchemaSuccess, bD as StandardSchemaV1, bJ as SuperstructFailureLike, bK as SuperstructValidateLike, bW as ValibotIssueLike, bX as ValibotPathItemLike, bY as ValibotSafeParseLike, bZ as ValibotSafeParseResult, c2 as VineValidationErrorLike, c3 as VineValidationMessageLike, c4 as VineValidatorLike, c5 as YupSchemaLike, c6 as YupValidationErrorLike, c7 as defineRequestSchema, c8 as fromAjv, c9 as fromArkType, ca as fromIoTs, cb as fromJoi, cc as fromStandardSchema, cd as fromSuperstruct, ce as fromValibot, cf as fromVine, cg as fromYup, ch as fromZod } from './parsers-
|
|
3
|
+
import { a7 as GlobalOptions, Q as DefaultModelRouterOptions, Y as ExtendedDefaultModelRouterOptions, ax as ModelRouterOptions, Z as ExtendedModelRouterOptions, M as DataRouterOptions, X as ExtendedDataRouterOptions, A as AccessRouterBaseRequest, a9 as GuardHook, aw as ModelRequest, K as DataRequest, cn as DataService, co as Model, cp as Service, cq as PublicService, c0 as Validation, bm as RootRouterOptions } from './parsers-B8bwUDPv.js';
|
|
4
|
+
export { cr as AccessRouterPermissionMap, cs as AccessRouterPermissions, c as AccessRouterRequest, d as AccessRouterRequestExtensions, l as AjvErrorObjectLike, m as AjvValidatorLike, n as ArkTypeErrorsLike, o as ArkTypeLike, ac as IoTsContextEntryLike, ad as IoTsDecodeErrorLike, ae as IoTsDecoderLike, af as JoiSchemaLike, ag as JoiValidationErrorDetailLike, ct as Permissions, aS as RequestSchemaAdapter, aT as RequestSchemaFailure, aU as RequestSchemaIssue, aV as RequestSchemaLike, aW as RequestSchemaOptions, aX as RequestSchemaResult, aY as RequestSchemaSuccess, aZ as RequestSchemaValidator, bx as StandardSchemaFailure, by as StandardSchemaInferOutput, bz as StandardSchemaIssue, bA as StandardSchemaPathSegment, bB as StandardSchemaResult, bC as StandardSchemaSuccess, bD as StandardSchemaV1, bJ as SuperstructFailureLike, bK as SuperstructValidateLike, bW as ValibotIssueLike, bX as ValibotPathItemLike, bY as ValibotSafeParseLike, bZ as ValibotSafeParseResult, c2 as VineValidationErrorLike, c3 as VineValidationMessageLike, c4 as VineValidatorLike, c5 as YupSchemaLike, c6 as YupValidationErrorLike, c7 as defineRequestSchema, c8 as fromAjv, c9 as fromArkType, ca as fromIoTs, cb as fromJoi, cc as fromStandardSchema, cd as fromSuperstruct, ce as fromValibot, cf as fromVine, cg as fromYup, ch as fromZod } from './parsers-B8bwUDPv.js';
|
|
5
5
|
import JsonRouter from '@web-ts-toolkit/express-json-router';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
package/index.js
CHANGED
|
@@ -67,14 +67,14 @@ __export(index_exports, {
|
|
|
67
67
|
setModelOptions: () => setModelOptions
|
|
68
68
|
});
|
|
69
69
|
module.exports = __toCommonJS(index_exports);
|
|
70
|
-
var
|
|
70
|
+
var import_utils28 = require("@web-ts-toolkit/utils");
|
|
71
71
|
|
|
72
72
|
// src/middleware.ts
|
|
73
73
|
var import_express_json_router2 = __toESM(require("@web-ts-toolkit/express-json-router"));
|
|
74
|
-
var
|
|
74
|
+
var import_utils21 = require("@web-ts-toolkit/utils");
|
|
75
75
|
|
|
76
76
|
// src/core.ts
|
|
77
|
-
var
|
|
77
|
+
var import_utils20 = require("@web-ts-toolkit/utils");
|
|
78
78
|
|
|
79
79
|
// src/runtime.ts
|
|
80
80
|
var import_mongoose3 = __toESM(require("mongoose"));
|
|
@@ -90,9 +90,6 @@ var filterCollection = (collection, predicate) => {
|
|
|
90
90
|
var findElement = (collection, predicate) => {
|
|
91
91
|
return (0, import_utils.find)(collection, (0, import_sift.default)(predicate));
|
|
92
92
|
};
|
|
93
|
-
var matchElement = (element, predicate) => {
|
|
94
|
-
return (0, import_sift.default)(predicate)(element);
|
|
95
|
-
};
|
|
96
93
|
var findElementById = (collection, id) => {
|
|
97
94
|
return findElement(collection, { _id: id });
|
|
98
95
|
};
|
|
@@ -1195,16 +1192,33 @@ var Base = class {
|
|
|
1195
1192
|
return docs;
|
|
1196
1193
|
}
|
|
1197
1194
|
async includeDocsCount(docs, include) {
|
|
1198
|
-
const { model, path, localField, foreignField, filter: _filters } = include;
|
|
1195
|
+
const { model, path, localField, foreignField, filter: _filters, args = {}, options = {} } = include;
|
|
1199
1196
|
const svc = this.req.macl.getPublicService(model);
|
|
1200
1197
|
if (!svc) return docs;
|
|
1198
|
+
const includeLocalValues = [];
|
|
1199
|
+
(0, import_utils11.forEach)(docs, (doc) => {
|
|
1200
|
+
includeLocalValues.push((0, import_utils11.get)(doc, localField));
|
|
1201
|
+
});
|
|
1202
|
+
const filter2 = { ..._filters ?? {}, [foreignField]: { $in: (0, import_utils11.flatten)(includeLocalValues) } };
|
|
1203
|
+
const result = await svc.find(
|
|
1204
|
+
filter2,
|
|
1205
|
+
{
|
|
1206
|
+
...args,
|
|
1207
|
+
select: [foreignField]
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
...options,
|
|
1211
|
+
lean: true,
|
|
1212
|
+
includePermissions: false,
|
|
1213
|
+
includeCount: false
|
|
1214
|
+
}
|
|
1215
|
+
);
|
|
1216
|
+
if (!result.success) return docs;
|
|
1201
1217
|
for (let y = 0; y < docs.length; y++) {
|
|
1202
1218
|
const doc = docs[y];
|
|
1203
1219
|
const localValue = (0, import_utils11.get)(doc, localField);
|
|
1204
|
-
const
|
|
1205
|
-
|
|
1206
|
-
if (!result.success) continue;
|
|
1207
|
-
setDocValue(doc, path, result.data);
|
|
1220
|
+
const filterFn = (row) => (0, import_utils11.intersectionBy)((0, import_utils11.castArray)(localValue), (0, import_utils11.castArray)((0, import_utils11.get)(row, foreignField)), String).length > 0;
|
|
1221
|
+
setDocValue(doc, path, result.data.filter(filterFn).length);
|
|
1208
1222
|
}
|
|
1209
1223
|
return docs;
|
|
1210
1224
|
}
|
|
@@ -1946,14 +1960,12 @@ var Service = class extends Base {
|
|
|
1946
1960
|
const { populate, overrides } = this.resolveUpsertArgs(args);
|
|
1947
1961
|
const { skim, includePermissions, populateAccess } = this.resolveUpsertOptions(options);
|
|
1948
1962
|
const { filter: overrideFilter, populate: overridePopulate } = overrides ?? {};
|
|
1949
|
-
const
|
|
1963
|
+
const _filter = await (overrideFilter || this.genFilter("update", filter2));
|
|
1964
|
+
const query = { filter: _filter };
|
|
1965
|
+
logger.debug(JSON.stringify({ op: "upsert", query }));
|
|
1966
|
+
if (_filter === false) return { success: false, code: "forbidden" /* Forbidden */, query };
|
|
1967
|
+
const theone = await this.model.findOne({ filter: _filter });
|
|
1950
1968
|
if (theone) {
|
|
1951
|
-
const _filter = await (overrideFilter || this.genFilter("update", filter2));
|
|
1952
|
-
const query = { filter: _filter };
|
|
1953
|
-
logger.debug(JSON.stringify({ op: "upsert", query }));
|
|
1954
|
-
if (_filter === false) return { success: false, code: "forbidden" /* Forbidden */, query };
|
|
1955
|
-
const matched = matchElement(theone, _filter);
|
|
1956
|
-
if (!matched) return { success: false, code: "forbidden" /* Forbidden */, query };
|
|
1957
1969
|
return this.updateOne(
|
|
1958
1970
|
null,
|
|
1959
1971
|
data,
|
|
@@ -2082,7 +2094,7 @@ var Service = class extends Base {
|
|
|
2082
2094
|
return resolveExistsOptions(this, options);
|
|
2083
2095
|
}
|
|
2084
2096
|
async getFieldPermissionAccess(ids) {
|
|
2085
|
-
const uniqueIds = (0, import_utils13.
|
|
2097
|
+
const uniqueIds = (0, import_utils13.compact)((0, import_utils13.uniqBy)(ids, (id) => String(id)).map((id) => String(id)));
|
|
2086
2098
|
if (uniqueIds.length === 0) {
|
|
2087
2099
|
return {
|
|
2088
2100
|
readIds: /* @__PURE__ */ new Set(),
|
|
@@ -2560,9 +2572,10 @@ var Cache = class {
|
|
|
2560
2572
|
};
|
|
2561
2573
|
|
|
2562
2574
|
// src/core-shared.ts
|
|
2563
|
-
var
|
|
2575
|
+
var import_utils18 = require("@web-ts-toolkit/utils");
|
|
2564
2576
|
|
|
2565
2577
|
// src/permission.ts
|
|
2578
|
+
var import_utils17 = require("@web-ts-toolkit/utils");
|
|
2566
2579
|
var Permission = class {
|
|
2567
2580
|
constructor(permissions) {
|
|
2568
2581
|
this.permissions = { ...permissions };
|
|
@@ -2578,7 +2591,7 @@ var Permission = class {
|
|
|
2578
2591
|
return [permissionOrPermissions].concat(permissions);
|
|
2579
2592
|
}
|
|
2580
2593
|
hasKey(permission) {
|
|
2581
|
-
return
|
|
2594
|
+
return (0, import_utils17.hasOwn)(this.permissions, permission);
|
|
2582
2595
|
}
|
|
2583
2596
|
has(permission) {
|
|
2584
2597
|
return this.permissions[permission] === true;
|
|
@@ -2598,10 +2611,10 @@ var permission_default = Permission;
|
|
|
2598
2611
|
|
|
2599
2612
|
// src/core-shared.ts
|
|
2600
2613
|
function isAndFilter(filter2) {
|
|
2601
|
-
return !!filter2 && (0,
|
|
2614
|
+
return !!filter2 && (0, import_utils18.isPlainObject)(filter2) && Object.keys(filter2).length === 1 && (0, import_utils18.isArray)(filter2.$and);
|
|
2602
2615
|
}
|
|
2603
2616
|
function isMergeableClause(filter2) {
|
|
2604
|
-
return !!filter2 && (0,
|
|
2617
|
+
return !!filter2 && (0, import_utils18.isPlainObject)(filter2) && Object.keys(filter2).every((key) => !key.startsWith("$"));
|
|
2605
2618
|
}
|
|
2606
2619
|
function optimizeAndFilter(clausesInput) {
|
|
2607
2620
|
const clauses = [];
|
|
@@ -2616,7 +2629,7 @@ function optimizeAndFilter(clausesInput) {
|
|
|
2616
2629
|
}
|
|
2617
2630
|
}
|
|
2618
2631
|
const dedupedClauses = clauses.filter(
|
|
2619
|
-
(clause, index) => clauses.findIndex((item) => (0,
|
|
2632
|
+
(clause, index) => clauses.findIndex((item) => (0, import_utils18.isEqual)(item, clause)) === index
|
|
2620
2633
|
);
|
|
2621
2634
|
const mergedClause = {};
|
|
2622
2635
|
const remainingClauses = [];
|
|
@@ -2628,7 +2641,7 @@ function optimizeAndFilter(clausesInput) {
|
|
|
2628
2641
|
}
|
|
2629
2642
|
let canMerge = true;
|
|
2630
2643
|
for (const [key, value] of Object.entries(clause)) {
|
|
2631
|
-
if (
|
|
2644
|
+
if ((0, import_utils18.hasOwn)(mergedClause, key) && !(0, import_utils18.isEqual)(mergedClause[key], value)) {
|
|
2632
2645
|
canMerge = false;
|
|
2633
2646
|
break;
|
|
2634
2647
|
}
|
|
@@ -2639,24 +2652,24 @@ function optimizeAndFilter(clausesInput) {
|
|
|
2639
2652
|
}
|
|
2640
2653
|
Object.assign(mergedClause, clause);
|
|
2641
2654
|
}
|
|
2642
|
-
const finalClauses = (0,
|
|
2655
|
+
const finalClauses = (0, import_utils18.isEmpty)(mergedClause) ? remainingClauses : [mergedClause, ...remainingClauses];
|
|
2643
2656
|
if (finalClauses.length === 0) return null;
|
|
2644
2657
|
if (finalClauses.length === 1) return finalClauses[0];
|
|
2645
2658
|
return { $and: finalClauses };
|
|
2646
2659
|
}
|
|
2647
2660
|
function normalizeFilter(filter2) {
|
|
2648
2661
|
if (filter2 === false) return false;
|
|
2649
|
-
if (!filter2 || !(0,
|
|
2662
|
+
if (!filter2 || !(0, import_utils18.isPlainObject)(filter2) || (0, import_utils18.isEmpty)(filter2)) return null;
|
|
2650
2663
|
if (!isAndFilter(filter2)) {
|
|
2651
2664
|
return filter2;
|
|
2652
2665
|
}
|
|
2653
2666
|
return optimizeAndFilter(filter2.$and);
|
|
2654
2667
|
}
|
|
2655
2668
|
async function resolveIdentifierFilter(req, idField, resolveIdFilter, id) {
|
|
2656
|
-
if ((0,
|
|
2669
|
+
if ((0, import_utils18.isFunction)(resolveIdFilter)) {
|
|
2657
2670
|
return await resolveIdFilter.call(req, id);
|
|
2658
2671
|
}
|
|
2659
|
-
if ((0,
|
|
2672
|
+
if ((0, import_utils18.isString)(idField)) {
|
|
2660
2673
|
return { [idField]: id };
|
|
2661
2674
|
}
|
|
2662
2675
|
return { _id: id };
|
|
@@ -2672,11 +2685,11 @@ async function resolveAccessFilter({
|
|
|
2672
2685
|
}) {
|
|
2673
2686
|
let nextFilter = normalizeFilter(filter2);
|
|
2674
2687
|
const overrideFilterFn = getOption(`overrideFilter.${access}`, null);
|
|
2675
|
-
if ((0,
|
|
2688
|
+
if ((0, import_utils18.isFunction)(overrideFilterFn)) {
|
|
2676
2689
|
nextFilter = normalizeFilter(await overrideFilterFn.call(req, nextFilter, permissions));
|
|
2677
2690
|
}
|
|
2678
2691
|
const baseFilterFn = getOption(`baseFilter.${access}`, null);
|
|
2679
|
-
if (!(0,
|
|
2692
|
+
if (!(0, import_utils18.isFunction)(baseFilterFn)) return nextFilter || {};
|
|
2680
2693
|
const baseFilter = normalizeFilter(
|
|
2681
2694
|
cache.has(cacheKey) ? cache.get(cacheKey) : await baseFilterFn.call(req, permissions)
|
|
2682
2695
|
);
|
|
@@ -2696,33 +2709,33 @@ async function setRequestPermissions(req) {
|
|
|
2696
2709
|
const requestPermissionField = getGlobalOption("requestPermissionField");
|
|
2697
2710
|
if (req[requestPermissionField]) return;
|
|
2698
2711
|
const globalPermissions = getGlobalOption("globalPermissions");
|
|
2699
|
-
if (!(0,
|
|
2712
|
+
if (!(0, import_utils18.isFunction)(globalPermissions)) return;
|
|
2700
2713
|
const permissions = await globalPermissions.call(req, req);
|
|
2701
|
-
if ((0,
|
|
2702
|
-
else if ((0,
|
|
2703
|
-
else if ((0,
|
|
2714
|
+
if ((0, import_utils18.isPlainObject)(permissions)) req[requestPermissionField] = permissions;
|
|
2715
|
+
else if ((0, import_utils18.isArray)(permissions)) req[requestPermissionField] = (0, import_utils18.arrayToRecord)(permissions);
|
|
2716
|
+
else if ((0, import_utils18.isString)(permissions)) req[requestPermissionField] = { [permissions]: true };
|
|
2704
2717
|
}
|
|
2705
2718
|
async function evaluateRouteGuard(req, permissions, routeGuard) {
|
|
2706
2719
|
const phas = (key) => permissions.has(key);
|
|
2707
2720
|
const { stringHandler, arrayHandler } = createValidator(phas);
|
|
2708
|
-
if ((0,
|
|
2721
|
+
if ((0, import_utils18.isBoolean)(routeGuard)) {
|
|
2709
2722
|
return routeGuard === true;
|
|
2710
2723
|
}
|
|
2711
|
-
if ((0,
|
|
2724
|
+
if ((0, import_utils18.isString)(routeGuard)) {
|
|
2712
2725
|
return stringHandler(routeGuard);
|
|
2713
2726
|
}
|
|
2714
|
-
if ((0,
|
|
2727
|
+
if ((0, import_utils18.isArray)(routeGuard)) {
|
|
2715
2728
|
return arrayHandler(routeGuard);
|
|
2716
2729
|
}
|
|
2717
|
-
if ((0,
|
|
2730
|
+
if ((0, import_utils18.isFunction)(routeGuard)) {
|
|
2718
2731
|
return routeGuard.call(req, permissions);
|
|
2719
2732
|
}
|
|
2720
2733
|
return false;
|
|
2721
2734
|
}
|
|
2722
2735
|
async function callHookChain(req, hook, doc, permissions, context) {
|
|
2723
|
-
const hooks = (0,
|
|
2736
|
+
const hooks = (0, import_utils18.castArray)(hook);
|
|
2724
2737
|
for (let x = 0; x < hooks.length; x++) {
|
|
2725
|
-
if ((0,
|
|
2738
|
+
if ((0, import_utils18.isFunction)(hooks[x])) {
|
|
2726
2739
|
doc = await hooks[x].call(req, doc, permissions, context);
|
|
2727
2740
|
}
|
|
2728
2741
|
}
|
|
@@ -2745,13 +2758,13 @@ async function collectSchemaFields({
|
|
|
2745
2758
|
if (baseFields.includes(key)) continue;
|
|
2746
2759
|
const val = permissionSchema[key];
|
|
2747
2760
|
const value = val && val[access] || val;
|
|
2748
|
-
if ((0,
|
|
2761
|
+
if ((0, import_utils18.isBoolean)(value)) {
|
|
2749
2762
|
if (value) fields.push(key);
|
|
2750
|
-
} else if ((0,
|
|
2763
|
+
} else if ((0, import_utils18.isString)(value)) {
|
|
2751
2764
|
if (stringHandler(value)) fields.push(key);
|
|
2752
|
-
} else if ((0,
|
|
2765
|
+
} else if ((0, import_utils18.isArray)(value)) {
|
|
2753
2766
|
if (arrayHandler(value)) fields.push(key);
|
|
2754
|
-
} else if ((0,
|
|
2767
|
+
} else if ((0, import_utils18.isFunction)(value)) {
|
|
2755
2768
|
if (await value.call(req, ...functionArgs)) fields.push(key);
|
|
2756
2769
|
}
|
|
2757
2770
|
}
|
|
@@ -2840,7 +2853,7 @@ async function runDecorateAllHook({
|
|
|
2840
2853
|
}
|
|
2841
2854
|
|
|
2842
2855
|
// src/acl/select-resolution.ts
|
|
2843
|
-
var
|
|
2856
|
+
var import_utils19 = require("@web-ts-toolkit/utils");
|
|
2844
2857
|
async function collectAllowedFieldsForRequest({
|
|
2845
2858
|
req,
|
|
2846
2859
|
permissionSchema,
|
|
@@ -2908,15 +2921,15 @@ async function resolveSelectForRequest({
|
|
|
2908
2921
|
const excludeall = normalizedSelect.every((v) => v.startsWith("-"));
|
|
2909
2922
|
if (excludeall) {
|
|
2910
2923
|
normalizedSelect = normalizedSelect.map((v) => v.substring(1));
|
|
2911
|
-
fields = (0,
|
|
2924
|
+
fields = (0, import_utils19.difference)(fields, normalizedSelect);
|
|
2912
2925
|
if (excludeid) fields.push("-_id");
|
|
2913
2926
|
} else {
|
|
2914
|
-
fields = (0,
|
|
2927
|
+
fields = (0, import_utils19.intersection)(normalizedSelect, fields.concat(excludeid ? "-_id" : "_id"));
|
|
2915
2928
|
}
|
|
2916
2929
|
}
|
|
2917
2930
|
return fields.concat(alwaysSelectFields);
|
|
2918
2931
|
}
|
|
2919
|
-
return (0,
|
|
2932
|
+
return (0, import_utils19.intersection)(normalizedSelect, fields);
|
|
2920
2933
|
}
|
|
2921
2934
|
|
|
2922
2935
|
// src/core.ts
|
|
@@ -2930,10 +2943,10 @@ var Core = class {
|
|
|
2930
2943
|
getIdentifier(modelName) {
|
|
2931
2944
|
const resolveIdFilter = getModelOption(modelName, "resolveIdFilter");
|
|
2932
2945
|
const idField = getModelOption(modelName, "idField");
|
|
2933
|
-
if ((0,
|
|
2946
|
+
if ((0, import_utils20.isFunction)(resolveIdFilter)) {
|
|
2934
2947
|
return null;
|
|
2935
2948
|
}
|
|
2936
|
-
if ((0,
|
|
2949
|
+
if ((0, import_utils20.isString)(idField)) {
|
|
2937
2950
|
return idField;
|
|
2938
2951
|
}
|
|
2939
2952
|
return "_id";
|
|
@@ -3011,11 +3024,11 @@ var Core = class {
|
|
|
3011
3024
|
async genPopulate(modelName, access = "read", _populate = null) {
|
|
3012
3025
|
if (!_populate) return [];
|
|
3013
3026
|
let populate = Array.isArray(_populate) ? _populate : [_populate];
|
|
3014
|
-
populate = (0,
|
|
3027
|
+
populate = (0, import_utils20.compact)(
|
|
3015
3028
|
await Promise.all(
|
|
3016
3029
|
populate.map(async (p) => {
|
|
3017
|
-
const populateAccess = !(0,
|
|
3018
|
-
const ret = (0,
|
|
3030
|
+
const populateAccess = !(0, import_utils20.isString)(p) && p.access ? p.access : access;
|
|
3031
|
+
const ret = (0, import_utils20.isString)(p) ? { path: p } : {
|
|
3019
3032
|
path: p.path,
|
|
3020
3033
|
select: normalizeSelect(p.select)
|
|
3021
3034
|
};
|
|
@@ -3035,10 +3048,10 @@ var Core = class {
|
|
|
3035
3048
|
}
|
|
3036
3049
|
async validate(modelName, allowedData, access, context) {
|
|
3037
3050
|
const validate = getModelOption(modelName, `validate.${access}`, null);
|
|
3038
|
-
if ((0,
|
|
3051
|
+
if ((0, import_utils20.isFunction)(validate)) {
|
|
3039
3052
|
const permissions = this.getGlobalPermissions();
|
|
3040
3053
|
return validate.call(this.req, allowedData, permissions, context);
|
|
3041
|
-
} else if ((0,
|
|
3054
|
+
} else if ((0, import_utils20.isBoolean)(validate) || (0, import_utils20.isArray)(validate)) {
|
|
3042
3055
|
return validate;
|
|
3043
3056
|
} else {
|
|
3044
3057
|
return true;
|
|
@@ -3063,7 +3076,7 @@ var Core = class {
|
|
|
3063
3076
|
const changeOptions = getModelOption(modelName, `onChange`, {});
|
|
3064
3077
|
for (let x = 0; x < context.modifiedPaths.length; x++) {
|
|
3065
3078
|
const mpath = context.modifiedPaths[x];
|
|
3066
|
-
if ((0,
|
|
3079
|
+
if ((0, import_utils20.isFunction)(changeOptions[mpath])) {
|
|
3067
3080
|
await changeOptions[mpath].call(
|
|
3068
3081
|
this.req,
|
|
3069
3082
|
context.originalDocumentSnapshot[mpath],
|
|
@@ -3087,7 +3100,7 @@ var Core = class {
|
|
|
3087
3100
|
async genDocPermissions(modelName, doc, access, context) {
|
|
3088
3101
|
const docPermissionsFn = getModelOption(modelName, `docPermissions.${access}`, null);
|
|
3089
3102
|
let docPermissions = {};
|
|
3090
|
-
if ((0,
|
|
3103
|
+
if ((0, import_utils20.isFunction)(docPermissionsFn)) {
|
|
3091
3104
|
const permissions = this.getGlobalPermissions();
|
|
3092
3105
|
try {
|
|
3093
3106
|
docPermissions = await docPermissionsFn.call(this.req, doc, permissions, context);
|
|
@@ -3135,7 +3148,7 @@ var Core = class {
|
|
|
3135
3148
|
readExists ? this.genAllowedFields(modelName, doc, "read") : [],
|
|
3136
3149
|
updateExists ? this.genAllowedFields(modelName, doc, "update") : []
|
|
3137
3150
|
]);
|
|
3138
|
-
const viewObj = (0,
|
|
3151
|
+
const viewObj = (0, import_utils20.reduce)(
|
|
3139
3152
|
views,
|
|
3140
3153
|
(ret, view) => {
|
|
3141
3154
|
ret[view] = true;
|
|
@@ -3143,7 +3156,7 @@ var Core = class {
|
|
|
3143
3156
|
},
|
|
3144
3157
|
{}
|
|
3145
3158
|
);
|
|
3146
|
-
const editObj = (0,
|
|
3159
|
+
const editObj = (0, import_utils20.reduce)(
|
|
3147
3160
|
edits,
|
|
3148
3161
|
(ret, view) => {
|
|
3149
3162
|
ret[view] = true;
|
|
@@ -3167,9 +3180,9 @@ var Core = class {
|
|
|
3167
3180
|
return runDecorateAllHook({ req: this.req, hook: decorateAll, docs, permissions, context });
|
|
3168
3181
|
}
|
|
3169
3182
|
runTasks(modelName, docObject, task) {
|
|
3170
|
-
const tasks = (0,
|
|
3183
|
+
const tasks = (0, import_utils20.compact)((0, import_utils20.castArray)(task));
|
|
3171
3184
|
if (tasks.length === 0) return docObject;
|
|
3172
|
-
(0,
|
|
3185
|
+
(0, import_utils20.forEach)(tasks, (task2) => {
|
|
3173
3186
|
const { type, args, options } = task2;
|
|
3174
3187
|
switch (type) {
|
|
3175
3188
|
case "COPY_AND_DEPOPULATE":
|
|
@@ -3200,9 +3213,9 @@ var Core = class {
|
|
|
3200
3213
|
}
|
|
3201
3214
|
const [, field, op] = keys2;
|
|
3202
3215
|
const subOption = getExactModelOption(modelName, `operationAccess.${access}`);
|
|
3203
|
-
if ((0,
|
|
3216
|
+
if ((0, import_utils20.isUndefined)(subOption)) {
|
|
3204
3217
|
const subFieldOption = getExactModelOption(modelName, `operationAccess.subs.${field}`);
|
|
3205
|
-
if ((0,
|
|
3218
|
+
if ((0, import_utils20.isUndefined)(subFieldOption)) {
|
|
3206
3219
|
const opOption = getModelOption(modelName, `operationAccess.${op}`);
|
|
3207
3220
|
return this.canActivate(opOption);
|
|
3208
3221
|
}
|
|
@@ -3252,25 +3265,25 @@ function guard(condition) {
|
|
|
3252
3265
|
const permissions = req[PERMISSIONS];
|
|
3253
3266
|
let cond = condition;
|
|
3254
3267
|
let phas = (key) => permissions.has(key);
|
|
3255
|
-
if ((0,
|
|
3268
|
+
if ((0, import_utils21.isPlainObject)(condition)) {
|
|
3256
3269
|
const { modelName, id, condition: _cond } = condition;
|
|
3257
3270
|
const svc = req.macl.getPublicService(modelName);
|
|
3258
3271
|
const select = getModelOption(modelName, `alwaysSelectFields.read`, void 0);
|
|
3259
|
-
let _id = (0,
|
|
3260
|
-
if ((0,
|
|
3272
|
+
let _id = (0, import_utils21.isString)(id) ? id : null;
|
|
3273
|
+
if ((0, import_utils21.isPlainObject)(id)) {
|
|
3261
3274
|
const { type = "param", key } = id;
|
|
3262
3275
|
if (type === "param") {
|
|
3263
3276
|
const paramValue = req.params[key];
|
|
3264
|
-
_id = (0,
|
|
3277
|
+
_id = (0, import_utils21.isArray)(paramValue) ? paramValue[0] ?? null : paramValue ?? null;
|
|
3265
3278
|
} else if (type === "query") {
|
|
3266
3279
|
const _qval = req.query[key];
|
|
3267
|
-
if ((0,
|
|
3280
|
+
if ((0, import_utils21.isArray)(_qval)) _id = _qval.length > 0 ? _qval[0] : null;
|
|
3268
3281
|
else _id = _qval;
|
|
3269
3282
|
} else {
|
|
3270
3283
|
_id = null;
|
|
3271
3284
|
}
|
|
3272
3285
|
}
|
|
3273
|
-
if (!(0,
|
|
3286
|
+
if (!(0, import_utils21.isString)(_id) || !_id) {
|
|
3274
3287
|
return next(new import_express_json_router2.default.clientErrors.BadRequestError());
|
|
3275
3288
|
}
|
|
3276
3289
|
const result = await svc._read(_id, { select });
|
|
@@ -3282,11 +3295,11 @@ function guard(condition) {
|
|
|
3282
3295
|
cond = _cond;
|
|
3283
3296
|
}
|
|
3284
3297
|
const { stringHandler, arrayHandler } = createValidator(phas);
|
|
3285
|
-
if ((0,
|
|
3298
|
+
if ((0, import_utils21.isString)(cond)) {
|
|
3286
3299
|
if (stringHandler(cond)) return next();
|
|
3287
|
-
} else if ((0,
|
|
3300
|
+
} else if ((0, import_utils21.isArray)(cond)) {
|
|
3288
3301
|
if (arrayHandler(cond)) return next();
|
|
3289
|
-
} else if ((0,
|
|
3302
|
+
} else if ((0, import_utils21.isFunction)(cond)) {
|
|
3290
3303
|
const result = await cond.call(req, permissions);
|
|
3291
3304
|
if (!!result) return next();
|
|
3292
3305
|
}
|
|
@@ -3299,7 +3312,7 @@ var import_express2 = __toESM(require("express"));
|
|
|
3299
3312
|
|
|
3300
3313
|
// src/routers/model-router.ts
|
|
3301
3314
|
var import_express_json_router5 = __toESM(require("@web-ts-toolkit/express-json-router"));
|
|
3302
|
-
var
|
|
3315
|
+
var import_utils25 = require("@web-ts-toolkit/utils");
|
|
3303
3316
|
|
|
3304
3317
|
// src/routers/router-mutation.ts
|
|
3305
3318
|
var MODEL_BUILD_TIME_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -4239,7 +4252,7 @@ var rootDataQueryEntrySchema = import_zod5.z.union([
|
|
|
4239
4252
|
var rootQuerySchema = import_zod5.z.array(import_zod5.z.union([rootModelQueryEntrySchema, rootDataQueryEntrySchema]));
|
|
4240
4253
|
|
|
4241
4254
|
// src/routers/shared.ts
|
|
4242
|
-
var
|
|
4255
|
+
var import_utils22 = require("@web-ts-toolkit/utils");
|
|
4243
4256
|
|
|
4244
4257
|
// src/routers/model-router-collection-routes.ts
|
|
4245
4258
|
function setModelCollectionRoutes(context) {
|
|
@@ -4257,14 +4270,14 @@ function setModelCollectionRoutes(context) {
|
|
|
4257
4270
|
await context.assertAllowed(req, "list");
|
|
4258
4271
|
const { skip, limit, page, page_size, skim, include_permissions, include_count, include_extra_headers } = parseQuery(requestSchemas.listQuery, req.query);
|
|
4259
4272
|
const svc = context.getPublicService(req);
|
|
4260
|
-
const includeCount = (0,
|
|
4261
|
-
const includeExtraHeaders = (0,
|
|
4273
|
+
const includeCount = (0, import_utils22.parseBooleanString)(include_count);
|
|
4274
|
+
const includeExtraHeaders = (0, import_utils22.parseBooleanString)(include_extra_headers);
|
|
4262
4275
|
const result = await svc._list(
|
|
4263
4276
|
{},
|
|
4264
4277
|
{ skip, limit, page, pageSize: page_size },
|
|
4265
4278
|
{
|
|
4266
|
-
skim: (0,
|
|
4267
|
-
includePermissions: (0,
|
|
4279
|
+
skim: (0, import_utils22.parseBooleanString)(skim),
|
|
4280
|
+
includePermissions: (0, import_utils22.parseBooleanString)(include_permissions),
|
|
4268
4281
|
includeCount
|
|
4269
4282
|
}
|
|
4270
4283
|
);
|
|
@@ -4319,7 +4332,7 @@ function setModelCollectionRoutes(context) {
|
|
|
4319
4332
|
context.getRequestSchema("requestSchemas.create")
|
|
4320
4333
|
);
|
|
4321
4334
|
const svc = context.getPublicService(req);
|
|
4322
|
-
const result = await svc._create(data, {}, { includePermissions: (0,
|
|
4335
|
+
const result = await svc._create(data, {}, { includePermissions: (0, import_utils22.parseBooleanString)(include_permissions) });
|
|
4323
4336
|
handleResultError(result);
|
|
4324
4337
|
return formatModelCreatedResponse(result);
|
|
4325
4338
|
});
|
|
@@ -4353,7 +4366,7 @@ function setModelCollectionRoutes(context) {
|
|
|
4353
4366
|
data,
|
|
4354
4367
|
{ select, populate, tasks },
|
|
4355
4368
|
{
|
|
4356
|
-
includePermissions: includePermissions ?? (0,
|
|
4369
|
+
includePermissions: includePermissions ?? (0, import_utils22.parseBooleanString)(include_permissions),
|
|
4357
4370
|
populateAccess
|
|
4358
4371
|
}
|
|
4359
4372
|
);
|
|
@@ -4447,8 +4460,8 @@ function setModelDocumentRoutes(context) {
|
|
|
4447
4460
|
id,
|
|
4448
4461
|
{},
|
|
4449
4462
|
{
|
|
4450
|
-
includePermissions: (0,
|
|
4451
|
-
tryList: (0,
|
|
4463
|
+
includePermissions: (0, import_utils22.parseBooleanString)(include_permissions),
|
|
4464
|
+
tryList: (0, import_utils22.parseBooleanString)(try_list)
|
|
4452
4465
|
}
|
|
4453
4466
|
);
|
|
4454
4467
|
handleResultError(result);
|
|
@@ -4533,8 +4546,8 @@ function setModelDocumentRoutes(context) {
|
|
|
4533
4546
|
data,
|
|
4534
4547
|
{},
|
|
4535
4548
|
{
|
|
4536
|
-
returningAll: (0,
|
|
4537
|
-
includePermissions: (0,
|
|
4549
|
+
returningAll: (0, import_utils22.parseBooleanString)(returning_all),
|
|
4550
|
+
includePermissions: (0, import_utils22.parseBooleanString)(include_permissions)
|
|
4538
4551
|
}
|
|
4539
4552
|
);
|
|
4540
4553
|
handleResultError(result);
|
|
@@ -4572,8 +4585,8 @@ function setModelDocumentRoutes(context) {
|
|
|
4572
4585
|
data,
|
|
4573
4586
|
{ select, populate, tasks },
|
|
4574
4587
|
{
|
|
4575
|
-
returningAll: returningAll ?? (0,
|
|
4576
|
-
includePermissions: includePermissions ?? (0,
|
|
4588
|
+
returningAll: returningAll ?? (0, import_utils22.parseBooleanString)(returning_all),
|
|
4589
|
+
includePermissions: includePermissions ?? (0, import_utils22.parseBooleanString)(include_permissions),
|
|
4577
4590
|
populateAccess
|
|
4578
4591
|
}
|
|
4579
4592
|
);
|
|
@@ -4601,8 +4614,8 @@ function setModelDocumentRoutes(context) {
|
|
|
4601
4614
|
body,
|
|
4602
4615
|
{},
|
|
4603
4616
|
{
|
|
4604
|
-
returningAll: (0,
|
|
4605
|
-
includePermissions: (0,
|
|
4617
|
+
returningAll: (0, import_utils22.parseBooleanString)(returning_all),
|
|
4618
|
+
includePermissions: (0, import_utils22.parseBooleanString)(include_permissions)
|
|
4606
4619
|
}
|
|
4607
4620
|
);
|
|
4608
4621
|
handleResultError(result);
|
|
@@ -4638,8 +4651,8 @@ function setModelDocumentRoutes(context) {
|
|
|
4638
4651
|
data,
|
|
4639
4652
|
{ select, populate, tasks },
|
|
4640
4653
|
{
|
|
4641
|
-
returningAll: returningAll ?? (0,
|
|
4642
|
-
includePermissions: includePermissions ?? (0,
|
|
4654
|
+
returningAll: returningAll ?? (0, import_utils22.parseBooleanString)(returning_all),
|
|
4655
|
+
includePermissions: includePermissions ?? (0, import_utils22.parseBooleanString)(include_permissions),
|
|
4643
4656
|
populateAccess
|
|
4644
4657
|
}
|
|
4645
4658
|
);
|
|
@@ -4705,7 +4718,7 @@ function setModelDocumentRoutes(context) {
|
|
|
4705
4718
|
}
|
|
4706
4719
|
|
|
4707
4720
|
// src/routers/model-router-subdocument-routes.ts
|
|
4708
|
-
var
|
|
4721
|
+
var import_utils23 = require("@web-ts-toolkit/utils");
|
|
4709
4722
|
function setModelSubDocumentRoutes(context) {
|
|
4710
4723
|
const subs = getModelSub(context.modelName);
|
|
4711
4724
|
for (let x = 0; x < subs.length; x++) {
|
|
@@ -4796,7 +4809,7 @@ function setModelSubDocumentRoutes(context) {
|
|
|
4796
4809
|
context.getRequestSchema("requestSchemas.subRead")
|
|
4797
4810
|
);
|
|
4798
4811
|
const populate = body.populate;
|
|
4799
|
-
const normalizedPopulate = Array.isArray(populate) ? populate.map((item) => (0,
|
|
4812
|
+
const normalizedPopulate = Array.isArray(populate) ? populate.map((item) => (0, import_utils23.isString)(item) ? { path: item } : item) : (0, import_utils23.isString)(populate) ? { path: populate } : populate ?? [];
|
|
4800
4813
|
const svc = context.getPublicService(req);
|
|
4801
4814
|
const result = await svc.readSub(id, sub, subId, { select: body.select ?? [], populate: normalizedPopulate });
|
|
4802
4815
|
handleResultError(result);
|
|
@@ -4874,11 +4887,11 @@ function setModelSubDocumentRoutes(context) {
|
|
|
4874
4887
|
}
|
|
4875
4888
|
|
|
4876
4889
|
// src/openapi/route-registration.ts
|
|
4877
|
-
var
|
|
4890
|
+
var import_utils24 = require("@web-ts-toolkit/utils");
|
|
4878
4891
|
function registerOpenApiRoute(runtime, basePath, defaultTag, route) {
|
|
4879
4892
|
runtime.registerOpenApiRoute({
|
|
4880
4893
|
...route,
|
|
4881
|
-
path: (0,
|
|
4894
|
+
path: (0, import_utils24.normalizeUrlPath)(basePath + route.path),
|
|
4882
4895
|
tags: route.tags ?? [defaultTag]
|
|
4883
4896
|
});
|
|
4884
4897
|
}
|
|
@@ -4886,8 +4899,8 @@ function registerOpenApiRoute(runtime, basePath, defaultTag, route) {
|
|
|
4886
4899
|
// src/routers/model-router.ts
|
|
4887
4900
|
var clientErrors2 = import_express_json_router5.default.clientErrors;
|
|
4888
4901
|
function setOption(parentKey, optionKey, option) {
|
|
4889
|
-
const key = (0,
|
|
4890
|
-
const value = (0,
|
|
4902
|
+
const key = (0, import_utils25.isUndefined)(option) ? parentKey : `${parentKey}.${optionKey}`;
|
|
4903
|
+
const value = (0, import_utils25.isUndefined)(option) ? optionKey : option;
|
|
4891
4904
|
assertMutableRouterOption("model", key);
|
|
4892
4905
|
this.runtime.setModelOption(this.modelName, key, value);
|
|
4893
4906
|
return this;
|
|
@@ -5048,7 +5061,7 @@ var ModelRouter = class {
|
|
|
5048
5061
|
this.runtime.setModelOptions(modelName, initialOptions);
|
|
5049
5062
|
attachRuntimeToModel(modelName, this.runtime);
|
|
5050
5063
|
this.options = this.runtime.getModelOptions(modelName);
|
|
5051
|
-
this.fullBasePath = (0,
|
|
5064
|
+
this.fullBasePath = (0, import_utils25.normalizeUrlPath)(this.options.parentPath + this.options.basePath);
|
|
5052
5065
|
this.modelName = modelName;
|
|
5053
5066
|
this.router = new import_express_json_router5.default(this.options.basePath, createSetCore(this.runtime), accessRouterResponseHandler);
|
|
5054
5067
|
this.model = new model_default(modelName);
|
|
@@ -5120,13 +5133,13 @@ var ModelRouter = class {
|
|
|
5120
5133
|
}
|
|
5121
5134
|
logEndpoints() {
|
|
5122
5135
|
runWithRuntime(this.runtime, () => {
|
|
5123
|
-
(0,
|
|
5124
|
-
logger.info(`${(0,
|
|
5136
|
+
(0, import_utils25.forEach)(this.router.endpoints, ({ method, path }) => {
|
|
5137
|
+
logger.info(`${(0, import_utils25.padEnd)(method, 6)} ${(0, import_utils25.normalizeUrlPath)(this.options.parentPath + path)}`);
|
|
5125
5138
|
});
|
|
5126
5139
|
});
|
|
5127
5140
|
}
|
|
5128
5141
|
set(keyOrOptions, value) {
|
|
5129
|
-
if (arguments.length === 2 && (0,
|
|
5142
|
+
if (arguments.length === 2 && (0, import_utils25.isString)(keyOrOptions)) {
|
|
5130
5143
|
assertMutableRouterOption("model", keyOrOptions);
|
|
5131
5144
|
this.runtime.setModelOption(
|
|
5132
5145
|
this.modelName,
|
|
@@ -5134,7 +5147,7 @@ var ModelRouter = class {
|
|
|
5134
5147
|
value
|
|
5135
5148
|
);
|
|
5136
5149
|
}
|
|
5137
|
-
if (arguments.length === 1 && (0,
|
|
5150
|
+
if (arguments.length === 1 && (0, import_utils25.isPlainObject)(keyOrOptions)) {
|
|
5138
5151
|
assertMutableRouterOptions("model", keyOrOptions);
|
|
5139
5152
|
this.runtime.setModelOptions(this.modelName, keyOrOptions);
|
|
5140
5153
|
}
|
|
@@ -5157,7 +5170,7 @@ var ModelRouter = class {
|
|
|
5157
5170
|
|
|
5158
5171
|
// src/routers/root-router.ts
|
|
5159
5172
|
var import_express_json_router6 = __toESM(require("@web-ts-toolkit/express-json-router"));
|
|
5160
|
-
var
|
|
5173
|
+
var import_utils26 = require("@web-ts-toolkit/utils");
|
|
5161
5174
|
|
|
5162
5175
|
// src/core-data.ts
|
|
5163
5176
|
var DataCore = class {
|
|
@@ -5330,7 +5343,7 @@ var createErrorResult = (code, detail) => ({
|
|
|
5330
5343
|
code,
|
|
5331
5344
|
errors: [{ detail }]
|
|
5332
5345
|
});
|
|
5333
|
-
var normalizeSubPopulate = (populate) => Array.isArray(populate) ? populate.map((item) => (0,
|
|
5346
|
+
var normalizeSubPopulate = (populate) => Array.isArray(populate) ? populate.map((item) => (0, import_utils26.isString)(item) ? { path: item } : item) : (0, import_utils26.isString)(populate) ? { path: populate } : populate ?? [];
|
|
5334
5347
|
var RootRouter = class {
|
|
5335
5348
|
constructor(options = { basePath: "", operationAccess: true }, runtime = defaultRuntime) {
|
|
5336
5349
|
this.modelOperations = {
|
|
@@ -5404,7 +5417,7 @@ var RootRouter = class {
|
|
|
5404
5417
|
this.setRoutes();
|
|
5405
5418
|
}
|
|
5406
5419
|
registerOpenApiRoute(route) {
|
|
5407
|
-
registerOpenApiRoute(this.runtime, (0,
|
|
5420
|
+
registerOpenApiRoute(this.runtime, (0, import_utils26.normalizeUrlPath)(this.basename), "root", route);
|
|
5408
5421
|
}
|
|
5409
5422
|
wrapResult(index, item, result) {
|
|
5410
5423
|
return {
|
|
@@ -5465,7 +5478,7 @@ var RootRouter = class {
|
|
|
5465
5478
|
groupItemsByOrder(items) {
|
|
5466
5479
|
return items.reduce((acc, item, index) => {
|
|
5467
5480
|
let order = 0;
|
|
5468
|
-
if ((0,
|
|
5481
|
+
if ((0, import_utils26.isNumber)(item.order)) {
|
|
5469
5482
|
order = item.order < 0 ? 0 : item.order;
|
|
5470
5483
|
}
|
|
5471
5484
|
if (!acc[order]) {
|
|
@@ -5489,7 +5502,7 @@ var RootRouter = class {
|
|
|
5489
5502
|
const arrResult = await Promise.all(groupedItems[x].map(({ item, index }) => this.processOp(req, item, index)));
|
|
5490
5503
|
results.push(...arrResult);
|
|
5491
5504
|
}
|
|
5492
|
-
return (0,
|
|
5505
|
+
return (0, import_utils26.orderBy)(results, ["index"], ["asc"]);
|
|
5493
5506
|
});
|
|
5494
5507
|
this.registerOpenApiRoute({
|
|
5495
5508
|
method: "post",
|
|
@@ -5506,11 +5519,11 @@ var RootRouter = class {
|
|
|
5506
5519
|
|
|
5507
5520
|
// src/routers/data-router.ts
|
|
5508
5521
|
var import_express_json_router7 = __toESM(require("@web-ts-toolkit/express-json-router"));
|
|
5509
|
-
var
|
|
5522
|
+
var import_utils27 = require("@web-ts-toolkit/utils");
|
|
5510
5523
|
var clientErrors4 = import_express_json_router7.default.clientErrors;
|
|
5511
5524
|
function setOption2(parentKey, optionKey, option) {
|
|
5512
|
-
const key = (0,
|
|
5513
|
-
const value = (0,
|
|
5525
|
+
const key = (0, import_utils27.isUndefined)(option) ? parentKey : `${parentKey}.${optionKey}`;
|
|
5526
|
+
const value = (0, import_utils27.isUndefined)(option) ? optionKey : option;
|
|
5514
5527
|
assertMutableRouterOption("data", key);
|
|
5515
5528
|
this.runtime.setDataOption(this.dataName, key, value);
|
|
5516
5529
|
return this;
|
|
@@ -5546,7 +5559,7 @@ var DataRouter = class {
|
|
|
5546
5559
|
this.runtime = runtime;
|
|
5547
5560
|
this.runtime.setDataOptions(dataName, initialOptions);
|
|
5548
5561
|
this.options = this.runtime.getDataOptions(dataName);
|
|
5549
|
-
this.fullBasePath = (0,
|
|
5562
|
+
this.fullBasePath = (0, import_utils27.normalizeUrlPath)(this.options.parentPath + this.options.basePath);
|
|
5550
5563
|
this.dataName = dataName;
|
|
5551
5564
|
this.router = new import_express_json_router7.default(this.options.basePath, createSetDataCore(this.runtime), accessRouterResponseHandler);
|
|
5552
5565
|
this.setCollectionRoutes();
|
|
@@ -5579,8 +5592,8 @@ var DataRouter = class {
|
|
|
5579
5592
|
req.query
|
|
5580
5593
|
);
|
|
5581
5594
|
const svc = this.getService(req);
|
|
5582
|
-
const includeCount = (0,
|
|
5583
|
-
const includeExtraHeaders = (0,
|
|
5595
|
+
const includeCount = (0, import_utils22.parseBooleanString)(include_count);
|
|
5596
|
+
const includeExtraHeaders = (0, import_utils22.parseBooleanString)(include_extra_headers);
|
|
5584
5597
|
const result = await svc.find(
|
|
5585
5598
|
{},
|
|
5586
5599
|
{ skip, limit, page, pageSize: page_size },
|
|
@@ -5698,11 +5711,11 @@ var DataRouter = class {
|
|
|
5698
5711
|
});
|
|
5699
5712
|
}
|
|
5700
5713
|
set(keyOrOptions, value) {
|
|
5701
|
-
if (arguments.length === 2 && (0,
|
|
5714
|
+
if (arguments.length === 2 && (0, import_utils27.isString)(keyOrOptions)) {
|
|
5702
5715
|
assertMutableRouterOption("data", keyOrOptions);
|
|
5703
5716
|
this.runtime.setDataOption(this.dataName, keyOrOptions, value);
|
|
5704
5717
|
}
|
|
5705
|
-
if (arguments.length === 1 && (0,
|
|
5718
|
+
if (arguments.length === 1 && (0, import_utils27.isPlainObject)(keyOrOptions)) {
|
|
5706
5719
|
assertMutableRouterOptions("data", keyOrOptions);
|
|
5707
5720
|
this.runtime.setDataOptions(this.dataName, keyOrOptions);
|
|
5708
5721
|
}
|
|
@@ -5822,7 +5835,7 @@ function createRuntimeApi(runtime) {
|
|
|
5822
5835
|
wtt2.runtime = runtime;
|
|
5823
5836
|
wtt2.createRouter = function(modelName, options) {
|
|
5824
5837
|
const resolvedModelName = typeof modelName === "string" ? modelName : modelName && "modelName" in modelName ? modelName.modelName : modelName;
|
|
5825
|
-
return (0,
|
|
5838
|
+
return (0, import_utils28.isUndefined)(options) ? new RootRouter(modelName, runtime) : new ModelRouter(resolvedModelName, options, runtime);
|
|
5826
5839
|
};
|
|
5827
5840
|
wtt2.createDataRouter = function(dataName, options) {
|
|
5828
5841
|
return new DataRouter(dataName, options, runtime);
|
|
@@ -5832,10 +5845,10 @@ function createRuntimeApi(runtime) {
|
|
|
5832
5845
|
};
|
|
5833
5846
|
wtt2.combineRoutes = combineRoutes;
|
|
5834
5847
|
wtt2.set = function(keyOrOptions, value) {
|
|
5835
|
-
if (arguments.length === 2 && (0,
|
|
5848
|
+
if (arguments.length === 2 && (0, import_utils28.isString)(keyOrOptions)) {
|
|
5836
5849
|
return runtime.setGlobalOption(keyOrOptions, value);
|
|
5837
5850
|
}
|
|
5838
|
-
if (arguments.length === 1 && (0,
|
|
5851
|
+
if (arguments.length === 1 && (0, import_utils28.isPlainObject)(keyOrOptions)) {
|
|
5839
5852
|
return runtime.setGlobalOptions(keyOrOptions);
|
|
5840
5853
|
}
|
|
5841
5854
|
};
|
package/index.mjs
CHANGED
|
@@ -43,9 +43,6 @@ var filterCollection = (collection, predicate) => {
|
|
|
43
43
|
var findElement = (collection, predicate) => {
|
|
44
44
|
return find(collection, sift(predicate));
|
|
45
45
|
};
|
|
46
|
-
var matchElement = (element, predicate) => {
|
|
47
|
-
return sift(predicate)(element);
|
|
48
|
-
};
|
|
49
46
|
var findElementById = (collection, id) => {
|
|
50
47
|
return findElement(collection, { _id: id });
|
|
51
48
|
};
|
|
@@ -1158,16 +1155,33 @@ var Base = class {
|
|
|
1158
1155
|
return docs;
|
|
1159
1156
|
}
|
|
1160
1157
|
async includeDocsCount(docs, include) {
|
|
1161
|
-
const { model, path, localField, foreignField, filter: _filters } = include;
|
|
1158
|
+
const { model, path, localField, foreignField, filter: _filters, args = {}, options = {} } = include;
|
|
1162
1159
|
const svc = this.req.macl.getPublicService(model);
|
|
1163
1160
|
if (!svc) return docs;
|
|
1161
|
+
const includeLocalValues = [];
|
|
1162
|
+
forEach3(docs, (doc) => {
|
|
1163
|
+
includeLocalValues.push(get4(doc, localField));
|
|
1164
|
+
});
|
|
1165
|
+
const filter2 = { ..._filters ?? {}, [foreignField]: { $in: flatten(includeLocalValues) } };
|
|
1166
|
+
const result = await svc.find(
|
|
1167
|
+
filter2,
|
|
1168
|
+
{
|
|
1169
|
+
...args,
|
|
1170
|
+
select: [foreignField]
|
|
1171
|
+
},
|
|
1172
|
+
{
|
|
1173
|
+
...options,
|
|
1174
|
+
lean: true,
|
|
1175
|
+
includePermissions: false,
|
|
1176
|
+
includeCount: false
|
|
1177
|
+
}
|
|
1178
|
+
);
|
|
1179
|
+
if (!result.success) return docs;
|
|
1164
1180
|
for (let y = 0; y < docs.length; y++) {
|
|
1165
1181
|
const doc = docs[y];
|
|
1166
1182
|
const localValue = get4(doc, localField);
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1169
|
-
if (!result.success) continue;
|
|
1170
|
-
setDocValue(doc, path, result.data);
|
|
1183
|
+
const filterFn = (row) => intersectionBy(castArray(localValue), castArray(get4(row, foreignField)), String).length > 0;
|
|
1184
|
+
setDocValue(doc, path, result.data.filter(filterFn).length);
|
|
1171
1185
|
}
|
|
1172
1186
|
return docs;
|
|
1173
1187
|
}
|
|
@@ -1222,12 +1236,14 @@ var Base = class {
|
|
|
1222
1236
|
// src/services/service.ts
|
|
1223
1237
|
import {
|
|
1224
1238
|
castArray as castArray2,
|
|
1239
|
+
compact as compact2,
|
|
1225
1240
|
isArray as isArray6,
|
|
1226
1241
|
isBoolean as isBoolean3,
|
|
1227
1242
|
isFunction as isFunction3,
|
|
1228
1243
|
omit,
|
|
1229
1244
|
pick as pick4,
|
|
1230
|
-
uniq as uniq2
|
|
1245
|
+
uniq as uniq2,
|
|
1246
|
+
uniqBy
|
|
1231
1247
|
} from "@web-ts-toolkit/utils";
|
|
1232
1248
|
import { diff } from "just-diff";
|
|
1233
1249
|
|
|
@@ -1917,14 +1933,12 @@ var Service = class extends Base {
|
|
|
1917
1933
|
const { populate, overrides } = this.resolveUpsertArgs(args);
|
|
1918
1934
|
const { skim, includePermissions, populateAccess } = this.resolveUpsertOptions(options);
|
|
1919
1935
|
const { filter: overrideFilter, populate: overridePopulate } = overrides ?? {};
|
|
1920
|
-
const
|
|
1936
|
+
const _filter = await (overrideFilter || this.genFilter("update", filter2));
|
|
1937
|
+
const query = { filter: _filter };
|
|
1938
|
+
logger.debug(JSON.stringify({ op: "upsert", query }));
|
|
1939
|
+
if (_filter === false) return { success: false, code: "forbidden" /* Forbidden */, query };
|
|
1940
|
+
const theone = await this.model.findOne({ filter: _filter });
|
|
1921
1941
|
if (theone) {
|
|
1922
|
-
const _filter = await (overrideFilter || this.genFilter("update", filter2));
|
|
1923
|
-
const query = { filter: _filter };
|
|
1924
|
-
logger.debug(JSON.stringify({ op: "upsert", query }));
|
|
1925
|
-
if (_filter === false) return { success: false, code: "forbidden" /* Forbidden */, query };
|
|
1926
|
-
const matched = matchElement(theone, _filter);
|
|
1927
|
-
if (!matched) return { success: false, code: "forbidden" /* Forbidden */, query };
|
|
1928
1942
|
return this.updateOne(
|
|
1929
1943
|
null,
|
|
1930
1944
|
data,
|
|
@@ -2053,7 +2067,7 @@ var Service = class extends Base {
|
|
|
2053
2067
|
return resolveExistsOptions(this, options);
|
|
2054
2068
|
}
|
|
2055
2069
|
async getFieldPermissionAccess(ids) {
|
|
2056
|
-
const uniqueIds =
|
|
2070
|
+
const uniqueIds = compact2(uniqBy(ids, (id) => String(id)).map((id) => String(id)));
|
|
2057
2071
|
if (uniqueIds.length === 0) {
|
|
2058
2072
|
return {
|
|
2059
2073
|
readIds: /* @__PURE__ */ new Set(),
|
|
@@ -2534,6 +2548,7 @@ var Cache = class {
|
|
|
2534
2548
|
import {
|
|
2535
2549
|
castArray as castArray4,
|
|
2536
2550
|
arrayToRecord,
|
|
2551
|
+
hasOwn as hasOwn2,
|
|
2537
2552
|
isArray as isArray8,
|
|
2538
2553
|
isBoolean as isBoolean4,
|
|
2539
2554
|
isEmpty as isEmpty2,
|
|
@@ -2544,6 +2559,7 @@ import {
|
|
|
2544
2559
|
} from "@web-ts-toolkit/utils";
|
|
2545
2560
|
|
|
2546
2561
|
// src/permission.ts
|
|
2562
|
+
import { hasOwn } from "@web-ts-toolkit/utils";
|
|
2547
2563
|
var Permission = class {
|
|
2548
2564
|
constructor(permissions) {
|
|
2549
2565
|
this.permissions = { ...permissions };
|
|
@@ -2559,7 +2575,7 @@ var Permission = class {
|
|
|
2559
2575
|
return [permissionOrPermissions].concat(permissions);
|
|
2560
2576
|
}
|
|
2561
2577
|
hasKey(permission) {
|
|
2562
|
-
return
|
|
2578
|
+
return hasOwn(this.permissions, permission);
|
|
2563
2579
|
}
|
|
2564
2580
|
has(permission) {
|
|
2565
2581
|
return this.permissions[permission] === true;
|
|
@@ -2609,7 +2625,7 @@ function optimizeAndFilter(clausesInput) {
|
|
|
2609
2625
|
}
|
|
2610
2626
|
let canMerge = true;
|
|
2611
2627
|
for (const [key, value] of Object.entries(clause)) {
|
|
2612
|
-
if (
|
|
2628
|
+
if (hasOwn2(mergedClause, key) && !isEqual(mergedClause[key], value)) {
|
|
2613
2629
|
canMerge = false;
|
|
2614
2630
|
break;
|
|
2615
2631
|
}
|
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.
|
|
5
|
+
"version": "0.30.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"keywords": [
|
|
8
8
|
"express",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"node": ">=20"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@web-ts-toolkit/express-json-router": "0.
|
|
44
|
-
"@web-ts-toolkit/utils": "0.
|
|
43
|
+
"@web-ts-toolkit/express-json-router": "0.30.0",
|
|
44
|
+
"@web-ts-toolkit/utils": "0.30.0",
|
|
45
45
|
"just-diff": "^6.0.2",
|
|
46
46
|
"mongoose-schema-jsonschema": "^4.0.1",
|
|
47
47
|
"sift": "^17.1.3",
|
|
@@ -15,7 +15,7 @@ declare class Permission {
|
|
|
15
15
|
constructor(permissions: BooleanObject);
|
|
16
16
|
get keys(): readonly string[];
|
|
17
17
|
private normalizePermissionArgs;
|
|
18
|
-
hasKey(permission: PermissionName):
|
|
18
|
+
hasKey(permission: PermissionName): boolean;
|
|
19
19
|
has(permission: PermissionName): boolean;
|
|
20
20
|
hasAny(permissionOrPermissions: PermissionName | readonly PermissionName[], ...permissions: PermissionName[]): boolean;
|
|
21
21
|
hasAll(permissionOrPermissions: PermissionName | readonly PermissionName[], ...permissions: PermissionName[]): boolean;
|
|
@@ -15,7 +15,7 @@ declare class Permission {
|
|
|
15
15
|
constructor(permissions: BooleanObject);
|
|
16
16
|
get keys(): readonly string[];
|
|
17
17
|
private normalizePermissionArgs;
|
|
18
|
-
hasKey(permission: PermissionName):
|
|
18
|
+
hasKey(permission: PermissionName): boolean;
|
|
19
19
|
has(permission: PermissionName): boolean;
|
|
20
20
|
hasAny(permissionOrPermissions: PermissionName | readonly PermissionName[], ...permissions: PermissionName[]): boolean;
|
|
21
21
|
hasAll(permissionOrPermissions: PermissionName | readonly PermissionName[], ...permissions: PermissionName[]): boolean;
|