@web-ts-toolkit/access-router 0.29.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 +104 -103
- package/index.mjs +8 -4
- 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"));
|
|
@@ -2094,7 +2094,7 @@ var Service = class extends Base {
|
|
|
2094
2094
|
return resolveExistsOptions(this, options);
|
|
2095
2095
|
}
|
|
2096
2096
|
async getFieldPermissionAccess(ids) {
|
|
2097
|
-
const uniqueIds = (0, import_utils13.
|
|
2097
|
+
const uniqueIds = (0, import_utils13.compact)((0, import_utils13.uniqBy)(ids, (id) => String(id)).map((id) => String(id)));
|
|
2098
2098
|
if (uniqueIds.length === 0) {
|
|
2099
2099
|
return {
|
|
2100
2100
|
readIds: /* @__PURE__ */ new Set(),
|
|
@@ -2572,9 +2572,10 @@ var Cache = class {
|
|
|
2572
2572
|
};
|
|
2573
2573
|
|
|
2574
2574
|
// src/core-shared.ts
|
|
2575
|
-
var
|
|
2575
|
+
var import_utils18 = require("@web-ts-toolkit/utils");
|
|
2576
2576
|
|
|
2577
2577
|
// src/permission.ts
|
|
2578
|
+
var import_utils17 = require("@web-ts-toolkit/utils");
|
|
2578
2579
|
var Permission = class {
|
|
2579
2580
|
constructor(permissions) {
|
|
2580
2581
|
this.permissions = { ...permissions };
|
|
@@ -2590,7 +2591,7 @@ var Permission = class {
|
|
|
2590
2591
|
return [permissionOrPermissions].concat(permissions);
|
|
2591
2592
|
}
|
|
2592
2593
|
hasKey(permission) {
|
|
2593
|
-
return
|
|
2594
|
+
return (0, import_utils17.hasOwn)(this.permissions, permission);
|
|
2594
2595
|
}
|
|
2595
2596
|
has(permission) {
|
|
2596
2597
|
return this.permissions[permission] === true;
|
|
@@ -2610,10 +2611,10 @@ var permission_default = Permission;
|
|
|
2610
2611
|
|
|
2611
2612
|
// src/core-shared.ts
|
|
2612
2613
|
function isAndFilter(filter2) {
|
|
2613
|
-
return !!filter2 && (0,
|
|
2614
|
+
return !!filter2 && (0, import_utils18.isPlainObject)(filter2) && Object.keys(filter2).length === 1 && (0, import_utils18.isArray)(filter2.$and);
|
|
2614
2615
|
}
|
|
2615
2616
|
function isMergeableClause(filter2) {
|
|
2616
|
-
return !!filter2 && (0,
|
|
2617
|
+
return !!filter2 && (0, import_utils18.isPlainObject)(filter2) && Object.keys(filter2).every((key) => !key.startsWith("$"));
|
|
2617
2618
|
}
|
|
2618
2619
|
function optimizeAndFilter(clausesInput) {
|
|
2619
2620
|
const clauses = [];
|
|
@@ -2628,7 +2629,7 @@ function optimizeAndFilter(clausesInput) {
|
|
|
2628
2629
|
}
|
|
2629
2630
|
}
|
|
2630
2631
|
const dedupedClauses = clauses.filter(
|
|
2631
|
-
(clause, index) => clauses.findIndex((item) => (0,
|
|
2632
|
+
(clause, index) => clauses.findIndex((item) => (0, import_utils18.isEqual)(item, clause)) === index
|
|
2632
2633
|
);
|
|
2633
2634
|
const mergedClause = {};
|
|
2634
2635
|
const remainingClauses = [];
|
|
@@ -2640,7 +2641,7 @@ function optimizeAndFilter(clausesInput) {
|
|
|
2640
2641
|
}
|
|
2641
2642
|
let canMerge = true;
|
|
2642
2643
|
for (const [key, value] of Object.entries(clause)) {
|
|
2643
|
-
if (
|
|
2644
|
+
if ((0, import_utils18.hasOwn)(mergedClause, key) && !(0, import_utils18.isEqual)(mergedClause[key], value)) {
|
|
2644
2645
|
canMerge = false;
|
|
2645
2646
|
break;
|
|
2646
2647
|
}
|
|
@@ -2651,24 +2652,24 @@ function optimizeAndFilter(clausesInput) {
|
|
|
2651
2652
|
}
|
|
2652
2653
|
Object.assign(mergedClause, clause);
|
|
2653
2654
|
}
|
|
2654
|
-
const finalClauses = (0,
|
|
2655
|
+
const finalClauses = (0, import_utils18.isEmpty)(mergedClause) ? remainingClauses : [mergedClause, ...remainingClauses];
|
|
2655
2656
|
if (finalClauses.length === 0) return null;
|
|
2656
2657
|
if (finalClauses.length === 1) return finalClauses[0];
|
|
2657
2658
|
return { $and: finalClauses };
|
|
2658
2659
|
}
|
|
2659
2660
|
function normalizeFilter(filter2) {
|
|
2660
2661
|
if (filter2 === false) return false;
|
|
2661
|
-
if (!filter2 || !(0,
|
|
2662
|
+
if (!filter2 || !(0, import_utils18.isPlainObject)(filter2) || (0, import_utils18.isEmpty)(filter2)) return null;
|
|
2662
2663
|
if (!isAndFilter(filter2)) {
|
|
2663
2664
|
return filter2;
|
|
2664
2665
|
}
|
|
2665
2666
|
return optimizeAndFilter(filter2.$and);
|
|
2666
2667
|
}
|
|
2667
2668
|
async function resolveIdentifierFilter(req, idField, resolveIdFilter, id) {
|
|
2668
|
-
if ((0,
|
|
2669
|
+
if ((0, import_utils18.isFunction)(resolveIdFilter)) {
|
|
2669
2670
|
return await resolveIdFilter.call(req, id);
|
|
2670
2671
|
}
|
|
2671
|
-
if ((0,
|
|
2672
|
+
if ((0, import_utils18.isString)(idField)) {
|
|
2672
2673
|
return { [idField]: id };
|
|
2673
2674
|
}
|
|
2674
2675
|
return { _id: id };
|
|
@@ -2684,11 +2685,11 @@ async function resolveAccessFilter({
|
|
|
2684
2685
|
}) {
|
|
2685
2686
|
let nextFilter = normalizeFilter(filter2);
|
|
2686
2687
|
const overrideFilterFn = getOption(`overrideFilter.${access}`, null);
|
|
2687
|
-
if ((0,
|
|
2688
|
+
if ((0, import_utils18.isFunction)(overrideFilterFn)) {
|
|
2688
2689
|
nextFilter = normalizeFilter(await overrideFilterFn.call(req, nextFilter, permissions));
|
|
2689
2690
|
}
|
|
2690
2691
|
const baseFilterFn = getOption(`baseFilter.${access}`, null);
|
|
2691
|
-
if (!(0,
|
|
2692
|
+
if (!(0, import_utils18.isFunction)(baseFilterFn)) return nextFilter || {};
|
|
2692
2693
|
const baseFilter = normalizeFilter(
|
|
2693
2694
|
cache.has(cacheKey) ? cache.get(cacheKey) : await baseFilterFn.call(req, permissions)
|
|
2694
2695
|
);
|
|
@@ -2708,33 +2709,33 @@ async function setRequestPermissions(req) {
|
|
|
2708
2709
|
const requestPermissionField = getGlobalOption("requestPermissionField");
|
|
2709
2710
|
if (req[requestPermissionField]) return;
|
|
2710
2711
|
const globalPermissions = getGlobalOption("globalPermissions");
|
|
2711
|
-
if (!(0,
|
|
2712
|
+
if (!(0, import_utils18.isFunction)(globalPermissions)) return;
|
|
2712
2713
|
const permissions = await globalPermissions.call(req, req);
|
|
2713
|
-
if ((0,
|
|
2714
|
-
else if ((0,
|
|
2715
|
-
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 };
|
|
2716
2717
|
}
|
|
2717
2718
|
async function evaluateRouteGuard(req, permissions, routeGuard) {
|
|
2718
2719
|
const phas = (key) => permissions.has(key);
|
|
2719
2720
|
const { stringHandler, arrayHandler } = createValidator(phas);
|
|
2720
|
-
if ((0,
|
|
2721
|
+
if ((0, import_utils18.isBoolean)(routeGuard)) {
|
|
2721
2722
|
return routeGuard === true;
|
|
2722
2723
|
}
|
|
2723
|
-
if ((0,
|
|
2724
|
+
if ((0, import_utils18.isString)(routeGuard)) {
|
|
2724
2725
|
return stringHandler(routeGuard);
|
|
2725
2726
|
}
|
|
2726
|
-
if ((0,
|
|
2727
|
+
if ((0, import_utils18.isArray)(routeGuard)) {
|
|
2727
2728
|
return arrayHandler(routeGuard);
|
|
2728
2729
|
}
|
|
2729
|
-
if ((0,
|
|
2730
|
+
if ((0, import_utils18.isFunction)(routeGuard)) {
|
|
2730
2731
|
return routeGuard.call(req, permissions);
|
|
2731
2732
|
}
|
|
2732
2733
|
return false;
|
|
2733
2734
|
}
|
|
2734
2735
|
async function callHookChain(req, hook, doc, permissions, context) {
|
|
2735
|
-
const hooks = (0,
|
|
2736
|
+
const hooks = (0, import_utils18.castArray)(hook);
|
|
2736
2737
|
for (let x = 0; x < hooks.length; x++) {
|
|
2737
|
-
if ((0,
|
|
2738
|
+
if ((0, import_utils18.isFunction)(hooks[x])) {
|
|
2738
2739
|
doc = await hooks[x].call(req, doc, permissions, context);
|
|
2739
2740
|
}
|
|
2740
2741
|
}
|
|
@@ -2757,13 +2758,13 @@ async function collectSchemaFields({
|
|
|
2757
2758
|
if (baseFields.includes(key)) continue;
|
|
2758
2759
|
const val = permissionSchema[key];
|
|
2759
2760
|
const value = val && val[access] || val;
|
|
2760
|
-
if ((0,
|
|
2761
|
+
if ((0, import_utils18.isBoolean)(value)) {
|
|
2761
2762
|
if (value) fields.push(key);
|
|
2762
|
-
} else if ((0,
|
|
2763
|
+
} else if ((0, import_utils18.isString)(value)) {
|
|
2763
2764
|
if (stringHandler(value)) fields.push(key);
|
|
2764
|
-
} else if ((0,
|
|
2765
|
+
} else if ((0, import_utils18.isArray)(value)) {
|
|
2765
2766
|
if (arrayHandler(value)) fields.push(key);
|
|
2766
|
-
} else if ((0,
|
|
2767
|
+
} else if ((0, import_utils18.isFunction)(value)) {
|
|
2767
2768
|
if (await value.call(req, ...functionArgs)) fields.push(key);
|
|
2768
2769
|
}
|
|
2769
2770
|
}
|
|
@@ -2852,7 +2853,7 @@ async function runDecorateAllHook({
|
|
|
2852
2853
|
}
|
|
2853
2854
|
|
|
2854
2855
|
// src/acl/select-resolution.ts
|
|
2855
|
-
var
|
|
2856
|
+
var import_utils19 = require("@web-ts-toolkit/utils");
|
|
2856
2857
|
async function collectAllowedFieldsForRequest({
|
|
2857
2858
|
req,
|
|
2858
2859
|
permissionSchema,
|
|
@@ -2920,15 +2921,15 @@ async function resolveSelectForRequest({
|
|
|
2920
2921
|
const excludeall = normalizedSelect.every((v) => v.startsWith("-"));
|
|
2921
2922
|
if (excludeall) {
|
|
2922
2923
|
normalizedSelect = normalizedSelect.map((v) => v.substring(1));
|
|
2923
|
-
fields = (0,
|
|
2924
|
+
fields = (0, import_utils19.difference)(fields, normalizedSelect);
|
|
2924
2925
|
if (excludeid) fields.push("-_id");
|
|
2925
2926
|
} else {
|
|
2926
|
-
fields = (0,
|
|
2927
|
+
fields = (0, import_utils19.intersection)(normalizedSelect, fields.concat(excludeid ? "-_id" : "_id"));
|
|
2927
2928
|
}
|
|
2928
2929
|
}
|
|
2929
2930
|
return fields.concat(alwaysSelectFields);
|
|
2930
2931
|
}
|
|
2931
|
-
return (0,
|
|
2932
|
+
return (0, import_utils19.intersection)(normalizedSelect, fields);
|
|
2932
2933
|
}
|
|
2933
2934
|
|
|
2934
2935
|
// src/core.ts
|
|
@@ -2942,10 +2943,10 @@ var Core = class {
|
|
|
2942
2943
|
getIdentifier(modelName) {
|
|
2943
2944
|
const resolveIdFilter = getModelOption(modelName, "resolveIdFilter");
|
|
2944
2945
|
const idField = getModelOption(modelName, "idField");
|
|
2945
|
-
if ((0,
|
|
2946
|
+
if ((0, import_utils20.isFunction)(resolveIdFilter)) {
|
|
2946
2947
|
return null;
|
|
2947
2948
|
}
|
|
2948
|
-
if ((0,
|
|
2949
|
+
if ((0, import_utils20.isString)(idField)) {
|
|
2949
2950
|
return idField;
|
|
2950
2951
|
}
|
|
2951
2952
|
return "_id";
|
|
@@ -3023,11 +3024,11 @@ var Core = class {
|
|
|
3023
3024
|
async genPopulate(modelName, access = "read", _populate = null) {
|
|
3024
3025
|
if (!_populate) return [];
|
|
3025
3026
|
let populate = Array.isArray(_populate) ? _populate : [_populate];
|
|
3026
|
-
populate = (0,
|
|
3027
|
+
populate = (0, import_utils20.compact)(
|
|
3027
3028
|
await Promise.all(
|
|
3028
3029
|
populate.map(async (p) => {
|
|
3029
|
-
const populateAccess = !(0,
|
|
3030
|
-
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 } : {
|
|
3031
3032
|
path: p.path,
|
|
3032
3033
|
select: normalizeSelect(p.select)
|
|
3033
3034
|
};
|
|
@@ -3047,10 +3048,10 @@ var Core = class {
|
|
|
3047
3048
|
}
|
|
3048
3049
|
async validate(modelName, allowedData, access, context) {
|
|
3049
3050
|
const validate = getModelOption(modelName, `validate.${access}`, null);
|
|
3050
|
-
if ((0,
|
|
3051
|
+
if ((0, import_utils20.isFunction)(validate)) {
|
|
3051
3052
|
const permissions = this.getGlobalPermissions();
|
|
3052
3053
|
return validate.call(this.req, allowedData, permissions, context);
|
|
3053
|
-
} else if ((0,
|
|
3054
|
+
} else if ((0, import_utils20.isBoolean)(validate) || (0, import_utils20.isArray)(validate)) {
|
|
3054
3055
|
return validate;
|
|
3055
3056
|
} else {
|
|
3056
3057
|
return true;
|
|
@@ -3075,7 +3076,7 @@ var Core = class {
|
|
|
3075
3076
|
const changeOptions = getModelOption(modelName, `onChange`, {});
|
|
3076
3077
|
for (let x = 0; x < context.modifiedPaths.length; x++) {
|
|
3077
3078
|
const mpath = context.modifiedPaths[x];
|
|
3078
|
-
if ((0,
|
|
3079
|
+
if ((0, import_utils20.isFunction)(changeOptions[mpath])) {
|
|
3079
3080
|
await changeOptions[mpath].call(
|
|
3080
3081
|
this.req,
|
|
3081
3082
|
context.originalDocumentSnapshot[mpath],
|
|
@@ -3099,7 +3100,7 @@ var Core = class {
|
|
|
3099
3100
|
async genDocPermissions(modelName, doc, access, context) {
|
|
3100
3101
|
const docPermissionsFn = getModelOption(modelName, `docPermissions.${access}`, null);
|
|
3101
3102
|
let docPermissions = {};
|
|
3102
|
-
if ((0,
|
|
3103
|
+
if ((0, import_utils20.isFunction)(docPermissionsFn)) {
|
|
3103
3104
|
const permissions = this.getGlobalPermissions();
|
|
3104
3105
|
try {
|
|
3105
3106
|
docPermissions = await docPermissionsFn.call(this.req, doc, permissions, context);
|
|
@@ -3147,7 +3148,7 @@ var Core = class {
|
|
|
3147
3148
|
readExists ? this.genAllowedFields(modelName, doc, "read") : [],
|
|
3148
3149
|
updateExists ? this.genAllowedFields(modelName, doc, "update") : []
|
|
3149
3150
|
]);
|
|
3150
|
-
const viewObj = (0,
|
|
3151
|
+
const viewObj = (0, import_utils20.reduce)(
|
|
3151
3152
|
views,
|
|
3152
3153
|
(ret, view) => {
|
|
3153
3154
|
ret[view] = true;
|
|
@@ -3155,7 +3156,7 @@ var Core = class {
|
|
|
3155
3156
|
},
|
|
3156
3157
|
{}
|
|
3157
3158
|
);
|
|
3158
|
-
const editObj = (0,
|
|
3159
|
+
const editObj = (0, import_utils20.reduce)(
|
|
3159
3160
|
edits,
|
|
3160
3161
|
(ret, view) => {
|
|
3161
3162
|
ret[view] = true;
|
|
@@ -3179,9 +3180,9 @@ var Core = class {
|
|
|
3179
3180
|
return runDecorateAllHook({ req: this.req, hook: decorateAll, docs, permissions, context });
|
|
3180
3181
|
}
|
|
3181
3182
|
runTasks(modelName, docObject, task) {
|
|
3182
|
-
const tasks = (0,
|
|
3183
|
+
const tasks = (0, import_utils20.compact)((0, import_utils20.castArray)(task));
|
|
3183
3184
|
if (tasks.length === 0) return docObject;
|
|
3184
|
-
(0,
|
|
3185
|
+
(0, import_utils20.forEach)(tasks, (task2) => {
|
|
3185
3186
|
const { type, args, options } = task2;
|
|
3186
3187
|
switch (type) {
|
|
3187
3188
|
case "COPY_AND_DEPOPULATE":
|
|
@@ -3212,9 +3213,9 @@ var Core = class {
|
|
|
3212
3213
|
}
|
|
3213
3214
|
const [, field, op] = keys2;
|
|
3214
3215
|
const subOption = getExactModelOption(modelName, `operationAccess.${access}`);
|
|
3215
|
-
if ((0,
|
|
3216
|
+
if ((0, import_utils20.isUndefined)(subOption)) {
|
|
3216
3217
|
const subFieldOption = getExactModelOption(modelName, `operationAccess.subs.${field}`);
|
|
3217
|
-
if ((0,
|
|
3218
|
+
if ((0, import_utils20.isUndefined)(subFieldOption)) {
|
|
3218
3219
|
const opOption = getModelOption(modelName, `operationAccess.${op}`);
|
|
3219
3220
|
return this.canActivate(opOption);
|
|
3220
3221
|
}
|
|
@@ -3264,25 +3265,25 @@ function guard(condition) {
|
|
|
3264
3265
|
const permissions = req[PERMISSIONS];
|
|
3265
3266
|
let cond = condition;
|
|
3266
3267
|
let phas = (key) => permissions.has(key);
|
|
3267
|
-
if ((0,
|
|
3268
|
+
if ((0, import_utils21.isPlainObject)(condition)) {
|
|
3268
3269
|
const { modelName, id, condition: _cond } = condition;
|
|
3269
3270
|
const svc = req.macl.getPublicService(modelName);
|
|
3270
3271
|
const select = getModelOption(modelName, `alwaysSelectFields.read`, void 0);
|
|
3271
|
-
let _id = (0,
|
|
3272
|
-
if ((0,
|
|
3272
|
+
let _id = (0, import_utils21.isString)(id) ? id : null;
|
|
3273
|
+
if ((0, import_utils21.isPlainObject)(id)) {
|
|
3273
3274
|
const { type = "param", key } = id;
|
|
3274
3275
|
if (type === "param") {
|
|
3275
3276
|
const paramValue = req.params[key];
|
|
3276
|
-
_id = (0,
|
|
3277
|
+
_id = (0, import_utils21.isArray)(paramValue) ? paramValue[0] ?? null : paramValue ?? null;
|
|
3277
3278
|
} else if (type === "query") {
|
|
3278
3279
|
const _qval = req.query[key];
|
|
3279
|
-
if ((0,
|
|
3280
|
+
if ((0, import_utils21.isArray)(_qval)) _id = _qval.length > 0 ? _qval[0] : null;
|
|
3280
3281
|
else _id = _qval;
|
|
3281
3282
|
} else {
|
|
3282
3283
|
_id = null;
|
|
3283
3284
|
}
|
|
3284
3285
|
}
|
|
3285
|
-
if (!(0,
|
|
3286
|
+
if (!(0, import_utils21.isString)(_id) || !_id) {
|
|
3286
3287
|
return next(new import_express_json_router2.default.clientErrors.BadRequestError());
|
|
3287
3288
|
}
|
|
3288
3289
|
const result = await svc._read(_id, { select });
|
|
@@ -3294,11 +3295,11 @@ function guard(condition) {
|
|
|
3294
3295
|
cond = _cond;
|
|
3295
3296
|
}
|
|
3296
3297
|
const { stringHandler, arrayHandler } = createValidator(phas);
|
|
3297
|
-
if ((0,
|
|
3298
|
+
if ((0, import_utils21.isString)(cond)) {
|
|
3298
3299
|
if (stringHandler(cond)) return next();
|
|
3299
|
-
} else if ((0,
|
|
3300
|
+
} else if ((0, import_utils21.isArray)(cond)) {
|
|
3300
3301
|
if (arrayHandler(cond)) return next();
|
|
3301
|
-
} else if ((0,
|
|
3302
|
+
} else if ((0, import_utils21.isFunction)(cond)) {
|
|
3302
3303
|
const result = await cond.call(req, permissions);
|
|
3303
3304
|
if (!!result) return next();
|
|
3304
3305
|
}
|
|
@@ -3311,7 +3312,7 @@ var import_express2 = __toESM(require("express"));
|
|
|
3311
3312
|
|
|
3312
3313
|
// src/routers/model-router.ts
|
|
3313
3314
|
var import_express_json_router5 = __toESM(require("@web-ts-toolkit/express-json-router"));
|
|
3314
|
-
var
|
|
3315
|
+
var import_utils25 = require("@web-ts-toolkit/utils");
|
|
3315
3316
|
|
|
3316
3317
|
// src/routers/router-mutation.ts
|
|
3317
3318
|
var MODEL_BUILD_TIME_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -4251,7 +4252,7 @@ var rootDataQueryEntrySchema = import_zod5.z.union([
|
|
|
4251
4252
|
var rootQuerySchema = import_zod5.z.array(import_zod5.z.union([rootModelQueryEntrySchema, rootDataQueryEntrySchema]));
|
|
4252
4253
|
|
|
4253
4254
|
// src/routers/shared.ts
|
|
4254
|
-
var
|
|
4255
|
+
var import_utils22 = require("@web-ts-toolkit/utils");
|
|
4255
4256
|
|
|
4256
4257
|
// src/routers/model-router-collection-routes.ts
|
|
4257
4258
|
function setModelCollectionRoutes(context) {
|
|
@@ -4269,14 +4270,14 @@ function setModelCollectionRoutes(context) {
|
|
|
4269
4270
|
await context.assertAllowed(req, "list");
|
|
4270
4271
|
const { skip, limit, page, page_size, skim, include_permissions, include_count, include_extra_headers } = parseQuery(requestSchemas.listQuery, req.query);
|
|
4271
4272
|
const svc = context.getPublicService(req);
|
|
4272
|
-
const includeCount = (0,
|
|
4273
|
-
const includeExtraHeaders = (0,
|
|
4273
|
+
const includeCount = (0, import_utils22.parseBooleanString)(include_count);
|
|
4274
|
+
const includeExtraHeaders = (0, import_utils22.parseBooleanString)(include_extra_headers);
|
|
4274
4275
|
const result = await svc._list(
|
|
4275
4276
|
{},
|
|
4276
4277
|
{ skip, limit, page, pageSize: page_size },
|
|
4277
4278
|
{
|
|
4278
|
-
skim: (0,
|
|
4279
|
-
includePermissions: (0,
|
|
4279
|
+
skim: (0, import_utils22.parseBooleanString)(skim),
|
|
4280
|
+
includePermissions: (0, import_utils22.parseBooleanString)(include_permissions),
|
|
4280
4281
|
includeCount
|
|
4281
4282
|
}
|
|
4282
4283
|
);
|
|
@@ -4331,7 +4332,7 @@ function setModelCollectionRoutes(context) {
|
|
|
4331
4332
|
context.getRequestSchema("requestSchemas.create")
|
|
4332
4333
|
);
|
|
4333
4334
|
const svc = context.getPublicService(req);
|
|
4334
|
-
const result = await svc._create(data, {}, { includePermissions: (0,
|
|
4335
|
+
const result = await svc._create(data, {}, { includePermissions: (0, import_utils22.parseBooleanString)(include_permissions) });
|
|
4335
4336
|
handleResultError(result);
|
|
4336
4337
|
return formatModelCreatedResponse(result);
|
|
4337
4338
|
});
|
|
@@ -4365,7 +4366,7 @@ function setModelCollectionRoutes(context) {
|
|
|
4365
4366
|
data,
|
|
4366
4367
|
{ select, populate, tasks },
|
|
4367
4368
|
{
|
|
4368
|
-
includePermissions: includePermissions ?? (0,
|
|
4369
|
+
includePermissions: includePermissions ?? (0, import_utils22.parseBooleanString)(include_permissions),
|
|
4369
4370
|
populateAccess
|
|
4370
4371
|
}
|
|
4371
4372
|
);
|
|
@@ -4459,8 +4460,8 @@ function setModelDocumentRoutes(context) {
|
|
|
4459
4460
|
id,
|
|
4460
4461
|
{},
|
|
4461
4462
|
{
|
|
4462
|
-
includePermissions: (0,
|
|
4463
|
-
tryList: (0,
|
|
4463
|
+
includePermissions: (0, import_utils22.parseBooleanString)(include_permissions),
|
|
4464
|
+
tryList: (0, import_utils22.parseBooleanString)(try_list)
|
|
4464
4465
|
}
|
|
4465
4466
|
);
|
|
4466
4467
|
handleResultError(result);
|
|
@@ -4545,8 +4546,8 @@ function setModelDocumentRoutes(context) {
|
|
|
4545
4546
|
data,
|
|
4546
4547
|
{},
|
|
4547
4548
|
{
|
|
4548
|
-
returningAll: (0,
|
|
4549
|
-
includePermissions: (0,
|
|
4549
|
+
returningAll: (0, import_utils22.parseBooleanString)(returning_all),
|
|
4550
|
+
includePermissions: (0, import_utils22.parseBooleanString)(include_permissions)
|
|
4550
4551
|
}
|
|
4551
4552
|
);
|
|
4552
4553
|
handleResultError(result);
|
|
@@ -4584,8 +4585,8 @@ function setModelDocumentRoutes(context) {
|
|
|
4584
4585
|
data,
|
|
4585
4586
|
{ select, populate, tasks },
|
|
4586
4587
|
{
|
|
4587
|
-
returningAll: returningAll ?? (0,
|
|
4588
|
-
includePermissions: includePermissions ?? (0,
|
|
4588
|
+
returningAll: returningAll ?? (0, import_utils22.parseBooleanString)(returning_all),
|
|
4589
|
+
includePermissions: includePermissions ?? (0, import_utils22.parseBooleanString)(include_permissions),
|
|
4589
4590
|
populateAccess
|
|
4590
4591
|
}
|
|
4591
4592
|
);
|
|
@@ -4613,8 +4614,8 @@ function setModelDocumentRoutes(context) {
|
|
|
4613
4614
|
body,
|
|
4614
4615
|
{},
|
|
4615
4616
|
{
|
|
4616
|
-
returningAll: (0,
|
|
4617
|
-
includePermissions: (0,
|
|
4617
|
+
returningAll: (0, import_utils22.parseBooleanString)(returning_all),
|
|
4618
|
+
includePermissions: (0, import_utils22.parseBooleanString)(include_permissions)
|
|
4618
4619
|
}
|
|
4619
4620
|
);
|
|
4620
4621
|
handleResultError(result);
|
|
@@ -4650,8 +4651,8 @@ function setModelDocumentRoutes(context) {
|
|
|
4650
4651
|
data,
|
|
4651
4652
|
{ select, populate, tasks },
|
|
4652
4653
|
{
|
|
4653
|
-
returningAll: returningAll ?? (0,
|
|
4654
|
-
includePermissions: includePermissions ?? (0,
|
|
4654
|
+
returningAll: returningAll ?? (0, import_utils22.parseBooleanString)(returning_all),
|
|
4655
|
+
includePermissions: includePermissions ?? (0, import_utils22.parseBooleanString)(include_permissions),
|
|
4655
4656
|
populateAccess
|
|
4656
4657
|
}
|
|
4657
4658
|
);
|
|
@@ -4717,7 +4718,7 @@ function setModelDocumentRoutes(context) {
|
|
|
4717
4718
|
}
|
|
4718
4719
|
|
|
4719
4720
|
// src/routers/model-router-subdocument-routes.ts
|
|
4720
|
-
var
|
|
4721
|
+
var import_utils23 = require("@web-ts-toolkit/utils");
|
|
4721
4722
|
function setModelSubDocumentRoutes(context) {
|
|
4722
4723
|
const subs = getModelSub(context.modelName);
|
|
4723
4724
|
for (let x = 0; x < subs.length; x++) {
|
|
@@ -4808,7 +4809,7 @@ function setModelSubDocumentRoutes(context) {
|
|
|
4808
4809
|
context.getRequestSchema("requestSchemas.subRead")
|
|
4809
4810
|
);
|
|
4810
4811
|
const populate = body.populate;
|
|
4811
|
-
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 ?? [];
|
|
4812
4813
|
const svc = context.getPublicService(req);
|
|
4813
4814
|
const result = await svc.readSub(id, sub, subId, { select: body.select ?? [], populate: normalizedPopulate });
|
|
4814
4815
|
handleResultError(result);
|
|
@@ -4886,11 +4887,11 @@ function setModelSubDocumentRoutes(context) {
|
|
|
4886
4887
|
}
|
|
4887
4888
|
|
|
4888
4889
|
// src/openapi/route-registration.ts
|
|
4889
|
-
var
|
|
4890
|
+
var import_utils24 = require("@web-ts-toolkit/utils");
|
|
4890
4891
|
function registerOpenApiRoute(runtime, basePath, defaultTag, route) {
|
|
4891
4892
|
runtime.registerOpenApiRoute({
|
|
4892
4893
|
...route,
|
|
4893
|
-
path: (0,
|
|
4894
|
+
path: (0, import_utils24.normalizeUrlPath)(basePath + route.path),
|
|
4894
4895
|
tags: route.tags ?? [defaultTag]
|
|
4895
4896
|
});
|
|
4896
4897
|
}
|
|
@@ -4898,8 +4899,8 @@ function registerOpenApiRoute(runtime, basePath, defaultTag, route) {
|
|
|
4898
4899
|
// src/routers/model-router.ts
|
|
4899
4900
|
var clientErrors2 = import_express_json_router5.default.clientErrors;
|
|
4900
4901
|
function setOption(parentKey, optionKey, option) {
|
|
4901
|
-
const key = (0,
|
|
4902
|
-
const value = (0,
|
|
4902
|
+
const key = (0, import_utils25.isUndefined)(option) ? parentKey : `${parentKey}.${optionKey}`;
|
|
4903
|
+
const value = (0, import_utils25.isUndefined)(option) ? optionKey : option;
|
|
4903
4904
|
assertMutableRouterOption("model", key);
|
|
4904
4905
|
this.runtime.setModelOption(this.modelName, key, value);
|
|
4905
4906
|
return this;
|
|
@@ -5060,7 +5061,7 @@ var ModelRouter = class {
|
|
|
5060
5061
|
this.runtime.setModelOptions(modelName, initialOptions);
|
|
5061
5062
|
attachRuntimeToModel(modelName, this.runtime);
|
|
5062
5063
|
this.options = this.runtime.getModelOptions(modelName);
|
|
5063
|
-
this.fullBasePath = (0,
|
|
5064
|
+
this.fullBasePath = (0, import_utils25.normalizeUrlPath)(this.options.parentPath + this.options.basePath);
|
|
5064
5065
|
this.modelName = modelName;
|
|
5065
5066
|
this.router = new import_express_json_router5.default(this.options.basePath, createSetCore(this.runtime), accessRouterResponseHandler);
|
|
5066
5067
|
this.model = new model_default(modelName);
|
|
@@ -5132,13 +5133,13 @@ var ModelRouter = class {
|
|
|
5132
5133
|
}
|
|
5133
5134
|
logEndpoints() {
|
|
5134
5135
|
runWithRuntime(this.runtime, () => {
|
|
5135
|
-
(0,
|
|
5136
|
-
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)}`);
|
|
5137
5138
|
});
|
|
5138
5139
|
});
|
|
5139
5140
|
}
|
|
5140
5141
|
set(keyOrOptions, value) {
|
|
5141
|
-
if (arguments.length === 2 && (0,
|
|
5142
|
+
if (arguments.length === 2 && (0, import_utils25.isString)(keyOrOptions)) {
|
|
5142
5143
|
assertMutableRouterOption("model", keyOrOptions);
|
|
5143
5144
|
this.runtime.setModelOption(
|
|
5144
5145
|
this.modelName,
|
|
@@ -5146,7 +5147,7 @@ var ModelRouter = class {
|
|
|
5146
5147
|
value
|
|
5147
5148
|
);
|
|
5148
5149
|
}
|
|
5149
|
-
if (arguments.length === 1 && (0,
|
|
5150
|
+
if (arguments.length === 1 && (0, import_utils25.isPlainObject)(keyOrOptions)) {
|
|
5150
5151
|
assertMutableRouterOptions("model", keyOrOptions);
|
|
5151
5152
|
this.runtime.setModelOptions(this.modelName, keyOrOptions);
|
|
5152
5153
|
}
|
|
@@ -5169,7 +5170,7 @@ var ModelRouter = class {
|
|
|
5169
5170
|
|
|
5170
5171
|
// src/routers/root-router.ts
|
|
5171
5172
|
var import_express_json_router6 = __toESM(require("@web-ts-toolkit/express-json-router"));
|
|
5172
|
-
var
|
|
5173
|
+
var import_utils26 = require("@web-ts-toolkit/utils");
|
|
5173
5174
|
|
|
5174
5175
|
// src/core-data.ts
|
|
5175
5176
|
var DataCore = class {
|
|
@@ -5342,7 +5343,7 @@ var createErrorResult = (code, detail) => ({
|
|
|
5342
5343
|
code,
|
|
5343
5344
|
errors: [{ detail }]
|
|
5344
5345
|
});
|
|
5345
|
-
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 ?? [];
|
|
5346
5347
|
var RootRouter = class {
|
|
5347
5348
|
constructor(options = { basePath: "", operationAccess: true }, runtime = defaultRuntime) {
|
|
5348
5349
|
this.modelOperations = {
|
|
@@ -5416,7 +5417,7 @@ var RootRouter = class {
|
|
|
5416
5417
|
this.setRoutes();
|
|
5417
5418
|
}
|
|
5418
5419
|
registerOpenApiRoute(route) {
|
|
5419
|
-
registerOpenApiRoute(this.runtime, (0,
|
|
5420
|
+
registerOpenApiRoute(this.runtime, (0, import_utils26.normalizeUrlPath)(this.basename), "root", route);
|
|
5420
5421
|
}
|
|
5421
5422
|
wrapResult(index, item, result) {
|
|
5422
5423
|
return {
|
|
@@ -5477,7 +5478,7 @@ var RootRouter = class {
|
|
|
5477
5478
|
groupItemsByOrder(items) {
|
|
5478
5479
|
return items.reduce((acc, item, index) => {
|
|
5479
5480
|
let order = 0;
|
|
5480
|
-
if ((0,
|
|
5481
|
+
if ((0, import_utils26.isNumber)(item.order)) {
|
|
5481
5482
|
order = item.order < 0 ? 0 : item.order;
|
|
5482
5483
|
}
|
|
5483
5484
|
if (!acc[order]) {
|
|
@@ -5501,7 +5502,7 @@ var RootRouter = class {
|
|
|
5501
5502
|
const arrResult = await Promise.all(groupedItems[x].map(({ item, index }) => this.processOp(req, item, index)));
|
|
5502
5503
|
results.push(...arrResult);
|
|
5503
5504
|
}
|
|
5504
|
-
return (0,
|
|
5505
|
+
return (0, import_utils26.orderBy)(results, ["index"], ["asc"]);
|
|
5505
5506
|
});
|
|
5506
5507
|
this.registerOpenApiRoute({
|
|
5507
5508
|
method: "post",
|
|
@@ -5518,11 +5519,11 @@ var RootRouter = class {
|
|
|
5518
5519
|
|
|
5519
5520
|
// src/routers/data-router.ts
|
|
5520
5521
|
var import_express_json_router7 = __toESM(require("@web-ts-toolkit/express-json-router"));
|
|
5521
|
-
var
|
|
5522
|
+
var import_utils27 = require("@web-ts-toolkit/utils");
|
|
5522
5523
|
var clientErrors4 = import_express_json_router7.default.clientErrors;
|
|
5523
5524
|
function setOption2(parentKey, optionKey, option) {
|
|
5524
|
-
const key = (0,
|
|
5525
|
-
const value = (0,
|
|
5525
|
+
const key = (0, import_utils27.isUndefined)(option) ? parentKey : `${parentKey}.${optionKey}`;
|
|
5526
|
+
const value = (0, import_utils27.isUndefined)(option) ? optionKey : option;
|
|
5526
5527
|
assertMutableRouterOption("data", key);
|
|
5527
5528
|
this.runtime.setDataOption(this.dataName, key, value);
|
|
5528
5529
|
return this;
|
|
@@ -5558,7 +5559,7 @@ var DataRouter = class {
|
|
|
5558
5559
|
this.runtime = runtime;
|
|
5559
5560
|
this.runtime.setDataOptions(dataName, initialOptions);
|
|
5560
5561
|
this.options = this.runtime.getDataOptions(dataName);
|
|
5561
|
-
this.fullBasePath = (0,
|
|
5562
|
+
this.fullBasePath = (0, import_utils27.normalizeUrlPath)(this.options.parentPath + this.options.basePath);
|
|
5562
5563
|
this.dataName = dataName;
|
|
5563
5564
|
this.router = new import_express_json_router7.default(this.options.basePath, createSetDataCore(this.runtime), accessRouterResponseHandler);
|
|
5564
5565
|
this.setCollectionRoutes();
|
|
@@ -5591,8 +5592,8 @@ var DataRouter = class {
|
|
|
5591
5592
|
req.query
|
|
5592
5593
|
);
|
|
5593
5594
|
const svc = this.getService(req);
|
|
5594
|
-
const includeCount = (0,
|
|
5595
|
-
const includeExtraHeaders = (0,
|
|
5595
|
+
const includeCount = (0, import_utils22.parseBooleanString)(include_count);
|
|
5596
|
+
const includeExtraHeaders = (0, import_utils22.parseBooleanString)(include_extra_headers);
|
|
5596
5597
|
const result = await svc.find(
|
|
5597
5598
|
{},
|
|
5598
5599
|
{ skip, limit, page, pageSize: page_size },
|
|
@@ -5710,11 +5711,11 @@ var DataRouter = class {
|
|
|
5710
5711
|
});
|
|
5711
5712
|
}
|
|
5712
5713
|
set(keyOrOptions, value) {
|
|
5713
|
-
if (arguments.length === 2 && (0,
|
|
5714
|
+
if (arguments.length === 2 && (0, import_utils27.isString)(keyOrOptions)) {
|
|
5714
5715
|
assertMutableRouterOption("data", keyOrOptions);
|
|
5715
5716
|
this.runtime.setDataOption(this.dataName, keyOrOptions, value);
|
|
5716
5717
|
}
|
|
5717
|
-
if (arguments.length === 1 && (0,
|
|
5718
|
+
if (arguments.length === 1 && (0, import_utils27.isPlainObject)(keyOrOptions)) {
|
|
5718
5719
|
assertMutableRouterOptions("data", keyOrOptions);
|
|
5719
5720
|
this.runtime.setDataOptions(this.dataName, keyOrOptions);
|
|
5720
5721
|
}
|
|
@@ -5834,7 +5835,7 @@ function createRuntimeApi(runtime) {
|
|
|
5834
5835
|
wtt2.runtime = runtime;
|
|
5835
5836
|
wtt2.createRouter = function(modelName, options) {
|
|
5836
5837
|
const resolvedModelName = typeof modelName === "string" ? modelName : modelName && "modelName" in modelName ? modelName.modelName : modelName;
|
|
5837
|
-
return (0,
|
|
5838
|
+
return (0, import_utils28.isUndefined)(options) ? new RootRouter(modelName, runtime) : new ModelRouter(resolvedModelName, options, runtime);
|
|
5838
5839
|
};
|
|
5839
5840
|
wtt2.createDataRouter = function(dataName, options) {
|
|
5840
5841
|
return new DataRouter(dataName, options, runtime);
|
|
@@ -5844,10 +5845,10 @@ function createRuntimeApi(runtime) {
|
|
|
5844
5845
|
};
|
|
5845
5846
|
wtt2.combineRoutes = combineRoutes;
|
|
5846
5847
|
wtt2.set = function(keyOrOptions, value) {
|
|
5847
|
-
if (arguments.length === 2 && (0,
|
|
5848
|
+
if (arguments.length === 2 && (0, import_utils28.isString)(keyOrOptions)) {
|
|
5848
5849
|
return runtime.setGlobalOption(keyOrOptions, value);
|
|
5849
5850
|
}
|
|
5850
|
-
if (arguments.length === 1 && (0,
|
|
5851
|
+
if (arguments.length === 1 && (0, import_utils28.isPlainObject)(keyOrOptions)) {
|
|
5851
5852
|
return runtime.setGlobalOptions(keyOrOptions);
|
|
5852
5853
|
}
|
|
5853
5854
|
};
|
package/index.mjs
CHANGED
|
@@ -1236,12 +1236,14 @@ var Base = class {
|
|
|
1236
1236
|
// src/services/service.ts
|
|
1237
1237
|
import {
|
|
1238
1238
|
castArray as castArray2,
|
|
1239
|
+
compact as compact2,
|
|
1239
1240
|
isArray as isArray6,
|
|
1240
1241
|
isBoolean as isBoolean3,
|
|
1241
1242
|
isFunction as isFunction3,
|
|
1242
1243
|
omit,
|
|
1243
1244
|
pick as pick4,
|
|
1244
|
-
uniq as uniq2
|
|
1245
|
+
uniq as uniq2,
|
|
1246
|
+
uniqBy
|
|
1245
1247
|
} from "@web-ts-toolkit/utils";
|
|
1246
1248
|
import { diff } from "just-diff";
|
|
1247
1249
|
|
|
@@ -2065,7 +2067,7 @@ var Service = class extends Base {
|
|
|
2065
2067
|
return resolveExistsOptions(this, options);
|
|
2066
2068
|
}
|
|
2067
2069
|
async getFieldPermissionAccess(ids) {
|
|
2068
|
-
const uniqueIds =
|
|
2070
|
+
const uniqueIds = compact2(uniqBy(ids, (id) => String(id)).map((id) => String(id)));
|
|
2069
2071
|
if (uniqueIds.length === 0) {
|
|
2070
2072
|
return {
|
|
2071
2073
|
readIds: /* @__PURE__ */ new Set(),
|
|
@@ -2546,6 +2548,7 @@ var Cache = class {
|
|
|
2546
2548
|
import {
|
|
2547
2549
|
castArray as castArray4,
|
|
2548
2550
|
arrayToRecord,
|
|
2551
|
+
hasOwn as hasOwn2,
|
|
2549
2552
|
isArray as isArray8,
|
|
2550
2553
|
isBoolean as isBoolean4,
|
|
2551
2554
|
isEmpty as isEmpty2,
|
|
@@ -2556,6 +2559,7 @@ import {
|
|
|
2556
2559
|
} from "@web-ts-toolkit/utils";
|
|
2557
2560
|
|
|
2558
2561
|
// src/permission.ts
|
|
2562
|
+
import { hasOwn } from "@web-ts-toolkit/utils";
|
|
2559
2563
|
var Permission = class {
|
|
2560
2564
|
constructor(permissions) {
|
|
2561
2565
|
this.permissions = { ...permissions };
|
|
@@ -2571,7 +2575,7 @@ var Permission = class {
|
|
|
2571
2575
|
return [permissionOrPermissions].concat(permissions);
|
|
2572
2576
|
}
|
|
2573
2577
|
hasKey(permission) {
|
|
2574
|
-
return
|
|
2578
|
+
return hasOwn(this.permissions, permission);
|
|
2575
2579
|
}
|
|
2576
2580
|
has(permission) {
|
|
2577
2581
|
return this.permissions[permission] === true;
|
|
@@ -2621,7 +2625,7 @@ function optimizeAndFilter(clausesInput) {
|
|
|
2621
2625
|
}
|
|
2622
2626
|
let canMerge = true;
|
|
2623
2627
|
for (const [key, value] of Object.entries(clause)) {
|
|
2624
|
-
if (
|
|
2628
|
+
if (hasOwn2(mergedClause, key) && !isEqual(mergedClause[key], value)) {
|
|
2625
2629
|
canMerge = false;
|
|
2626
2630
|
break;
|
|
2627
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;
|