@web-ts-toolkit/access-router 0.31.5 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -37
- package/advanced.d.mts +12 -1444
- package/advanced.d.ts +12 -1444
- package/advanced.js +1167 -269
- package/advanced.mjs +1178 -269
- package/index.d.mts +93 -1264
- package/index.d.ts +93 -1264
- package/index.js +1465 -489
- package/index.mjs +1354 -388
- package/llms.txt +34 -11
- package/package.json +10 -5
- package/parsers-D9B9dS0p.d.mts +1702 -0
- package/parsers-D9B9dS0p.d.ts +1702 -0
- package/processors.d.mts +72 -1
- package/processors.d.ts +72 -1
- package/processors.js +61 -13
- package/processors.mjs +62 -14
package/advanced.d.ts
CHANGED
|
@@ -1,1441 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import express from 'express';
|
|
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 DATA_MIDDLEWARE, w as DataBaseFilterHook, x as DataFilter, y as DataFindArgs, z as DataFindOneArgs, E as DataFindOneOptions, F as DataFindOptions, G as DataHook, H as DataHookContext, I as DataIdentifierHook, J as DataListHook, K as DataOverrideFilterHook, L as DataRequest, M as DataRequestSchemas, N as DataRouterOptions, O as DecorateAccess, P as DecorateAllAccess, Q as DeepFieldPath, R as DefaultModelRouterOptions, S as Defaults, T as DistinctArgs, U as DistinctBody, V as DocPermissionsAccess, W as ErrorResult, X as ExistsOptions, Y as ExtendedDataRouterOptions, Z as ExtendedDefaultModelRouterOptions, _ as ExtendedModelRouterOptions, $ as Filter, a0 as FilterOperator, a1 as FindAccess, a2 as FindArgs, a3 as FindByIdArgs, a4 as FindByIdOptions, a5 as FindOneArgs, a6 as FindOneOptions, a7 as FindOptions, a8 as GlobalOptions, a9 as GlobalPermissionValue, aa as GuardHook, ab as IdentifierHook, ac as Include, ad as IoTsContextEntryLike, ae as IoTsDecodeErrorLike, af as IoTsDecoderLike, ag as JoiSchemaLike, ah as JoiValidationErrorDetailLike, ai as KeyValueProjection, aj as ListQueryInput, ak as ListResult, al as MIDDLEWARE, am as MaybePromise, an as ModelBaseFilterHook, ao as ModelChangeHook, ap as ModelDeleteHook, aq as ModelDocPermissionsHook, ar as ModelDocument, as as ModelDocumentHook, at as ModelHook, au as ModelHookContext, av as ModelIdentifierHook, aw as ModelListHook, ax as ModelOverrideFilterHook, ay as ModelRequest, az as ModelRouterOptions, aA as ModelValidateHook, aB as PERMISSIONS, aC as PERMISSION_KEYS, aD as PathValue, aE as PermissionSchema, aF as Populate, aG as PopulateAccess, aH as PrepareAccess, aI as Projection, aJ as PublicCreateArgs, aK as PublicCreateOptions, aL as PublicErrorResult, aM as PublicListArgs, aN as PublicListOptions, aO as PublicListResult, aP as PublicOutput, aQ as PublicReadArgs, aR as PublicReadOptions, aS as PublicServiceResult, aT as PublicSingleResult, aU as PublicUpdateArgs, aV as PublicUpdateOptions, aW as PublicUpsertArgs, aX as PublicUpsertOptions, aY as ReadQueryInput, aZ as Request, a_ as RequestSchemaAdapter, a$ as RequestSchemaFailure, b0 as RequestSchemaIssue, b1 as RequestSchemaLike, b2 as RequestSchemaOptions, b3 as RequestSchemaResult, b4 as RequestSchemaSuccess, b5 as RequestSchemaValidator, b6 as RequestSchemas, b7 as RootDataListQueryEntry, b8 as RootDataOperation, b9 as RootDataReadByFilterQueryEntry, ba as RootDataReadByIdQueryEntry, bb as RootModelCountQueryEntry, bc as RootModelCreateQueryEntry, bd as RootModelDeleteQueryEntry, be as RootModelDistinctQueryEntry, bf as RootModelListQueryEntry, bg as RootModelNewQueryEntry, bh as RootModelOperation, bi as RootModelReadByFilterQueryEntry, bj as RootModelReadByIdQueryEntry, bk as RootModelSubBulkUpdateQueryEntry, bl as RootModelSubCreateQueryEntry, bm as RootModelSubDeleteQueryEntry, bn as RootModelSubListQueryEntry, bo as RootModelSubReadQueryEntry, bp as RootModelSubUpdateQueryEntry, bq as RootModelUpdateQueryEntry, br as RootModelUpsertQueryEntry, bs as RootOperationResult, bt as RootQueryEntry, bu as RootRouterOptions, bv as RootSubOperation, bw as RootTarget, bx as RouteGuardAccess, by as SelectAccess, bz as SelectedPopulatedPublicOutput, bA as SelectedPublicOutput, bB as ServiceResult, bC as SingleResult, bD as Sort, bE as SortOrder, bF as StandardSchemaFailure, bG as StandardSchemaInferOutput, bH as StandardSchemaIssue, bI as StandardSchemaPathSegment, bJ as StandardSchemaResult, bK as StandardSchemaSuccess, bL as StandardSchemaV1, bM as StatusCodes, bN as SubListBody, bO as SubPopulate, bP as SubQueryEntry, bQ as SubReadBody, bR as SubdocumentBulkRecord, bS as SubdocumentBulkUpdateInput, bT as SubdocumentCreateInput, bU as SubdocumentCreateOptions, bV as SubdocumentId, bW as SubdocumentListOptions, bX as SubdocumentName, bY as SubdocumentParentArgs, bZ as SubdocumentParentOptions, b_ as SubdocumentReadOptions, b$ as SubdocumentRecord, c0 as SuperstructFailureLike, c1 as SuperstructValidateLike, c2 as Task, c3 as TransformAccess, c4 as TypedFilter, c5 as UpdateByIdArgs, c6 as UpdateByIdOptions, c7 as UpdateOneArgs, c8 as UpdateOneOptions, c9 as UpdateQueryInput, ca as UpsertArgs, cb as UpsertOptions, cc as UpsertQueryInput, cd as ValibotIssueLike, ce as ValibotPathItemLike, cf as ValibotSafeParseLike, cg as ValibotSafeParseResult, ch as ValidateAccess, ci as ValidateRule, cj as Validation, ck as ValidationError, cl as VineValidationErrorLike, cm as VineValidationMessageLike, cn as VineValidatorLike, co as YupSchemaLike, cp as YupValidationErrorLike, cq as defineRequestSchema, cr as fromAjv, cs as fromArkType, ct as fromIoTs, cu as fromJoi, cv as fromStandardSchema, cw as fromSuperstruct, cx as fromValibot, cy as fromVine, cz as fromYup, cA as fromZod, cB as parseBody, cC as parseBodyWithSchema, cD as parseNestedBodyWithSchema, cE as parsePathParam, cF as parseQuery } from './parsers-D9B9dS0p.js';
|
|
3
2
|
import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[key: string]: boolean;
|
|
7
|
-
}
|
|
8
|
-
interface AccessRouterPermissionMap {
|
|
9
|
-
}
|
|
10
|
-
type AccessRouterPermissionKey = Extract<keyof AccessRouterPermissionMap, string>;
|
|
11
|
-
type PermissionName = AccessRouterPermissionKey | (string & {});
|
|
12
|
-
declare class Permission {
|
|
13
|
-
private readonly permissions;
|
|
14
|
-
private readonly permissionKeys;
|
|
15
|
-
constructor(permissions: BooleanObject);
|
|
16
|
-
get keys(): readonly string[];
|
|
17
|
-
private normalizePermissionArgs;
|
|
18
|
-
hasKey(permission: PermissionName): boolean;
|
|
19
|
-
has(permission: PermissionName): boolean;
|
|
20
|
-
hasAny(permissionOrPermissions: PermissionName | readonly PermissionName[], ...permissions: PermissionName[]): boolean;
|
|
21
|
-
hasAll(permissionOrPermissions: PermissionName | readonly PermissionName[], ...permissions: PermissionName[]): boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type AccessRouterPermissions = Permission;
|
|
25
|
-
|
|
26
|
-
declare class Base<TModel = unknown> {
|
|
27
|
-
protected req: ModelRequest;
|
|
28
|
-
protected modelName: string;
|
|
29
|
-
constructor(req: ModelRequest, modelName: string);
|
|
30
|
-
decorate<T>(doc: T, access: DecorateAccess, context: ModelHookContext): Promise<T>;
|
|
31
|
-
decorateAll<T>(docs: T[], access: DecorateAllAccess, context: ModelHookContext): Promise<T[]>;
|
|
32
|
-
genAllowedFields(doc: unknown, access: SelectAccess, baseFields?: string[]): Promise<string[]>;
|
|
33
|
-
genDocPermissions(doc: unknown, access: DocPermissionsAccess, context: ModelHookContext): Promise<Record<string, unknown>>;
|
|
34
|
-
genFilter(access?: BaseFilterAccess, filter?: Filter<TModel>): Promise<Filter<TModel>>;
|
|
35
|
-
getIdentifier(): string | null;
|
|
36
|
-
genIDFilter(id: string): Promise<Filter<TModel>>;
|
|
37
|
-
genPopulate(access?: SelectAccess, populate?: Populate | Populate[] | string | null): Promise<Populate[]>;
|
|
38
|
-
genSelect(access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise<string[]>;
|
|
39
|
-
genQuerySelect(access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise<string[]>;
|
|
40
|
-
addEmptyPermissions<T>(doc: T): T;
|
|
41
|
-
addDocPermissions<T>(doc: T, access: DocPermissionsAccess, context: ModelHookContext): Promise<T>;
|
|
42
|
-
addFieldPermissions<T extends {
|
|
43
|
-
_id?: unknown;
|
|
44
|
-
}>(doc: T, access: DocPermissionsAccess, context: ModelHookContext): Promise<T>;
|
|
45
|
-
pickAllowedFields<T>(doc: T, access: SelectAccess, baseFields?: string[]): Promise<T>;
|
|
46
|
-
trimOutputFields<T>(doc: T, access: SelectAccess, baseFields?: string[]): Promise<T>;
|
|
47
|
-
prepare<T>(allowedData: T, access: PrepareAccess, context: ModelHookContext): Promise<T>;
|
|
48
|
-
runTasks<T extends object>(docObject: T, tasks: Task | Task[]): T;
|
|
49
|
-
transform<T>(doc: T, access: TransformAccess, context: ModelHookContext): Promise<T>;
|
|
50
|
-
afterPersist<T>(doc: T, access: AfterPersistAccess, context: ModelHookContext): Promise<T>;
|
|
51
|
-
changes(doc: Record<string, unknown>, context: ModelHookContext): Promise<void>;
|
|
52
|
-
beforeDelete<T>(doc: T, context: ModelHookContext): Promise<void>;
|
|
53
|
-
afterDelete<T>(doc: T, context: ModelHookContext): Promise<void>;
|
|
54
|
-
validate(allowedData: unknown, access: ValidateAccess, context: ModelHookContext): Promise<boolean | unknown[]>;
|
|
55
|
-
checkIfModelPermissionExists(accesses: DocPermissionsAccess[]): boolean;
|
|
56
|
-
protected validateClientFilter(filter: Filter | null | undefined): string[];
|
|
57
|
-
protected processInclude(include: Include | Include[]): {
|
|
58
|
-
includes: Include[];
|
|
59
|
-
includeLocalFields: string[];
|
|
60
|
-
includePaths: string[];
|
|
61
|
-
};
|
|
62
|
-
protected includeDocs(docs: any, include: Include | Include[]): Promise<any>;
|
|
63
|
-
private includeDocsList;
|
|
64
|
-
private includeDocsCount;
|
|
65
|
-
protected parseClientData<TValue>(filter: TValue): Promise<TValue>;
|
|
66
|
-
private handleSubQuery;
|
|
67
|
-
private handleDate;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
interface FindProps {
|
|
71
|
-
filter: Filter;
|
|
72
|
-
select?: Projection;
|
|
73
|
-
sort?: Sort;
|
|
74
|
-
populate?: Populate[] | string;
|
|
75
|
-
limit?: string | number;
|
|
76
|
-
skip?: string | number;
|
|
77
|
-
lean?: boolean;
|
|
78
|
-
}
|
|
79
|
-
interface FindOneProps {
|
|
80
|
-
filter: Filter;
|
|
81
|
-
select?: Projection;
|
|
82
|
-
sort?: Sort;
|
|
83
|
-
populate?: Populate[] | string;
|
|
84
|
-
lean?: boolean;
|
|
85
|
-
}
|
|
86
|
-
type SortValue = 1 | -1 | 'asc' | 'ascending' | 'desc' | 'descending';
|
|
87
|
-
type SortType = string | [string, SortValue][] | {
|
|
88
|
-
[key: string]: SortValue;
|
|
89
|
-
} | Map<string, SortValue> | null | undefined;
|
|
90
|
-
declare class Model {
|
|
91
|
-
modelName: string;
|
|
92
|
-
model: mongoose.Model<any>;
|
|
93
|
-
constructor(modelName: string);
|
|
94
|
-
new(): any;
|
|
95
|
-
create(data: any): Promise<any>;
|
|
96
|
-
find({ filter, select, sort, populate, limit, skip, lean }: FindProps): mongoose.Query<any[], any, {}, any, "find", {}>;
|
|
97
|
-
validateSort(sort: SortType, logError?: (msg: string, ...args: unknown[]) => void): boolean;
|
|
98
|
-
findOne({ filter, select, sort, populate, lean }: FindOneProps): mongoose.Query<any, any, {}, any, "findOne", {}>;
|
|
99
|
-
exists(filter: any): mongoose.Query<any, any, {}, any, "findOne", {}>;
|
|
100
|
-
countDocuments(filter?: {}): mongoose.Query<number, any, {}, any, "countDocuments", {}>;
|
|
101
|
-
distinct(field: string, conditions?: {}): mongoose.Query<any[], any, {}, any, "distinct", {}>;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
declare class Service<TModel = unknown> extends Base<TModel> {
|
|
105
|
-
protected model: Model;
|
|
106
|
-
protected options: ModelRouterOptions<TModel>;
|
|
107
|
-
defaults: Defaults<TModel>;
|
|
108
|
-
protected baseFields: string[];
|
|
109
|
-
protected baseFieldsExt: string[];
|
|
110
|
-
private asServiceHookContext;
|
|
111
|
-
constructor(req: ModelRequest, modelName: string);
|
|
112
|
-
findOne(filter: Filter<TModel>, args?: FindOneArgs<TModel>, options?: FindOneOptions): Promise<SingleResult<TModel> | ErrorResult>;
|
|
113
|
-
findById(id: string, args?: FindByIdArgs<TModel>, options?: FindByIdOptions): Promise<SingleResult<TModel> | ErrorResult>;
|
|
114
|
-
find(filter: Filter<TModel>, args?: FindArgs<TModel>, options?: FindOptions, decorate?: Function): Promise<ListResult<TModel> | ErrorResult>;
|
|
115
|
-
create(data: any, args?: CreateArgs, options?: CreateOptions, decorate?: Function): Promise<ListResult<TModel> | ErrorResult>;
|
|
116
|
-
new(): Promise<SingleResult<TModel>>;
|
|
117
|
-
updateOne(filter: Filter<TModel>, data: any, args?: UpdateOneArgs<TModel>, options?: UpdateOneOptions, decorate?: Function): Promise<SingleResult<TModel> | ErrorResult>;
|
|
118
|
-
updateById(id: string, data: any, args?: UpdateByIdArgs<TModel>, options?: UpdateByIdOptions, decorate?: Function): Promise<SingleResult<TModel> | ErrorResult>;
|
|
119
|
-
upsert(filter: Filter<TModel>, data: any, args?: UpsertArgs<TModel>, options?: UpsertOptions, decorate?: Function): Promise<ServiceResult<TModel>>;
|
|
120
|
-
delete(id: string): Promise<SingleResult<unknown> | ErrorResult>;
|
|
121
|
-
exists(filter: Filter<TModel>, options: ExistsOptions & {
|
|
122
|
-
includeId: true;
|
|
123
|
-
}): Promise<SingleResult<unknown> | ErrorResult>;
|
|
124
|
-
exists(filter: Filter<TModel>, options?: ExistsOptions): Promise<SingleResult<boolean> | ErrorResult>;
|
|
125
|
-
distinct(field: string, args?: DistinctArgs<TModel>): Promise<ListResult<unknown> | ErrorResult>;
|
|
126
|
-
count(filter: Filter<TModel>, access?: BaseFilterAccess): Promise<SingleResult<number> | ErrorResult>;
|
|
127
|
-
getDocPermissions(doc: unknown): Record<string, unknown>;
|
|
128
|
-
private resolveFindOneArgs;
|
|
129
|
-
private resolveFindOneOptions;
|
|
130
|
-
private resolveFindByIdArgs;
|
|
131
|
-
private resolveFindByIdOptions;
|
|
132
|
-
private resolveFindArgs;
|
|
133
|
-
private resolveFindOptions;
|
|
134
|
-
private resolveCreateArgs;
|
|
135
|
-
private resolveCreateOptions;
|
|
136
|
-
private resolveUpdateOneArgs;
|
|
137
|
-
private resolveUpdateOneOptions;
|
|
138
|
-
private resolveUpdateByIdArgs;
|
|
139
|
-
private resolveUpdateByIdOptions;
|
|
140
|
-
private resolveUpsertArgs;
|
|
141
|
-
private resolveUpsertOptions;
|
|
142
|
-
private resolveExistsOptions;
|
|
143
|
-
private getFieldPermissionAccess;
|
|
144
|
-
private getAccessibleIdSet;
|
|
145
|
-
listSub(id: any, sub: any, options?: {
|
|
146
|
-
filter: Filter;
|
|
147
|
-
select: string[];
|
|
148
|
-
}): Promise<ListResult | ErrorResult>;
|
|
149
|
-
readSub(id: any, sub: any, subId: any, options?: {
|
|
150
|
-
select: string[];
|
|
151
|
-
populate: SubPopulate | SubPopulate[];
|
|
152
|
-
}): Promise<SingleResult | ErrorResult>;
|
|
153
|
-
updateSub(id: any, sub: any, subId: any, data: any): Promise<SingleResult | ErrorResult>;
|
|
154
|
-
bulkUpdateSub(id: any, sub: any, data: any): Promise<ListResult | ErrorResult>;
|
|
155
|
-
createSub(id: any, sub: any, data: any, options?: {
|
|
156
|
-
addFirst: boolean;
|
|
157
|
-
}): Promise<ListResult | ErrorResult>;
|
|
158
|
-
deleteSub(id: any, sub: any, subId: any): Promise<SingleResult | ErrorResult>;
|
|
159
|
-
getParentDoc(id: any, sub: any, args?: {
|
|
160
|
-
populate?: SubPopulate | SubPopulate[];
|
|
161
|
-
}, options?: {
|
|
162
|
-
access?: BaseFilterAccess;
|
|
163
|
-
lean?: boolean;
|
|
164
|
-
}): Promise<any>;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
declare class PublicService<TModel = unknown> extends Service<TModel> {
|
|
168
|
-
_list<TSelect extends Projection | undefined = undefined, TPopulate extends Populate[] | string | undefined = undefined>(filter: Filter<TModel>, args?: Omit<PublicListArgs, 'select' | 'populate'> & {
|
|
169
|
-
select?: TSelect;
|
|
170
|
-
populate?: TPopulate;
|
|
171
|
-
}, options?: PublicListOptions): Promise<ListResult<SelectedPopulatedPublicOutput<TModel, TSelect, TPopulate>> | ErrorResult>;
|
|
172
|
-
_create<TSelect extends Projection | undefined = undefined, TPopulate extends Populate[] | string | undefined = undefined>(data: any, args?: Omit<PublicCreateArgs, 'select' | 'populate'> & {
|
|
173
|
-
select?: TSelect;
|
|
174
|
-
populate?: TPopulate;
|
|
175
|
-
}, options?: PublicCreateOptions): Promise<ListResult<SelectedPopulatedPublicOutput<TModel, TSelect, TPopulate>> | ErrorResult>;
|
|
176
|
-
_new(): Promise<SingleResult<PublicOutput<TModel>>>;
|
|
177
|
-
_read<TSelect extends Projection | undefined = undefined, TPopulate extends Populate[] | string | undefined = undefined>(id: string, args?: Omit<PublicReadArgs, 'select' | 'populate'> & {
|
|
178
|
-
select?: TSelect;
|
|
179
|
-
populate?: TPopulate;
|
|
180
|
-
}, options?: PublicReadOptions): Promise<SingleResult<SelectedPopulatedPublicOutput<TModel, TSelect, TPopulate>> | ErrorResult>;
|
|
181
|
-
_readFilter<TSelect extends Projection | undefined = undefined, TPopulate extends Populate[] | string | undefined = undefined>(filter: Filter<TModel>, args?: Omit<PublicReadArgs, 'select' | 'populate'> & {
|
|
182
|
-
select?: TSelect;
|
|
183
|
-
populate?: TPopulate;
|
|
184
|
-
sort?: Sort;
|
|
185
|
-
}, options?: PublicReadOptions): Promise<SingleResult<SelectedPopulatedPublicOutput<TModel, TSelect, TPopulate>> | ErrorResult>;
|
|
186
|
-
_update<TSelect extends Projection | undefined = undefined, TPopulate extends Populate[] | string | undefined = undefined>(id: string, data: any, args?: Omit<PublicUpdateArgs, 'select' | 'populate'> & {
|
|
187
|
-
select?: TSelect;
|
|
188
|
-
populate?: TPopulate;
|
|
189
|
-
}, options?: PublicUpdateOptions): Promise<SingleResult<SelectedPopulatedPublicOutput<TModel, TSelect, TPopulate>> | ErrorResult>;
|
|
190
|
-
_upsert<TSelect extends Projection | undefined = undefined, TPopulate extends Populate[] | string | undefined = undefined>(data: Record<string, unknown>, args?: Omit<PublicUpsertArgs, 'select' | 'populate'> & {
|
|
191
|
-
select?: TSelect;
|
|
192
|
-
populate?: TPopulate;
|
|
193
|
-
}, options?: PublicUpsertOptions): Promise<ServiceResult<SelectedPopulatedPublicOutput<TModel, TSelect, TPopulate>> | ErrorResult>;
|
|
194
|
-
_delete(id: string): Promise<SingleResult<unknown> | ErrorResult>;
|
|
195
|
-
_distinct(field: string, options?: DistinctArgs<TModel>): Promise<ListResult<unknown> | ErrorResult>;
|
|
196
|
-
_count(filter: Filter<TModel>, access?: BaseFilterAccess): Promise<SingleResult<number> | ErrorResult>;
|
|
197
|
-
private resolvePublicListArgs;
|
|
198
|
-
private resolvePublicListOptions;
|
|
199
|
-
private resolvePublicCreateArgs;
|
|
200
|
-
private resolvePublicCreateOptions;
|
|
201
|
-
private resolvePublicReadArgs;
|
|
202
|
-
private resolvePublicReadFilterArgs;
|
|
203
|
-
private resolvePublicReadOptions;
|
|
204
|
-
private resolvePublicUpdateArgs;
|
|
205
|
-
private resolvePublicUpdateOptions;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
declare class DataService<T> {
|
|
209
|
-
protected req: DataRequest;
|
|
210
|
-
protected dataName: string;
|
|
211
|
-
protected options: DataRouterOptions<T>;
|
|
212
|
-
protected data: T[];
|
|
213
|
-
constructor(req: DataRequest, dataName: string);
|
|
214
|
-
findOne<TSelect extends Projection | undefined = undefined>(filter: DataFilter<T>, args?: DataFindOneArgs<T, TSelect>, options?: DataFindOneOptions): Promise<SingleResult<SelectedPublicOutput<T, TSelect>> | ErrorResult>;
|
|
215
|
-
findById<TSelect extends Projection | undefined = undefined>(id: string, args?: DataFindOneArgs<T, TSelect>, options?: DataFindOneOptions): Promise<SingleResult<SelectedPublicOutput<T, TSelect>> | ErrorResult>;
|
|
216
|
-
find<TSelect extends Projection | undefined = undefined>(filter: DataFilter<T>, args?: DataFindArgs<T, TSelect>, options?: DataFindOptions): Promise<ListResult<SelectedPublicOutput<T, TSelect>> | ErrorResult>;
|
|
217
|
-
decorate<TDoc>(doc: TDoc, access: DecorateAccess, context?: DataHookContext): Promise<TDoc>;
|
|
218
|
-
decorateAll<TDoc>(docs: TDoc[], access: DecorateAllAccess, context?: DataHookContext): Promise<TDoc[]>;
|
|
219
|
-
genAllowedFields(doc: unknown, access: SelectAccess, baseFields?: string[]): Promise<string[]>;
|
|
220
|
-
genFilter(access?: BaseFilterAccess, filter?: DataFilter<T>): Promise<DataFilter<T>>;
|
|
221
|
-
genIDFilter(id: string): Promise<DataFilter<T>>;
|
|
222
|
-
genSelect(access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise<string[]>;
|
|
223
|
-
genQuerySelect(access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise<string[]>;
|
|
224
|
-
pickAllowedFields<TDoc>(doc: TDoc, access: SelectAccess, baseFields?: string[]): Promise<TDoc>;
|
|
225
|
-
trimOutputFields<TDoc>(doc: TDoc, access: SelectAccess, baseFields?: string[]): Promise<TDoc>;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
type InternalModelHookContext = ModelHookContext & {
|
|
229
|
-
fieldPermissionAccess?: {
|
|
230
|
-
readIds?: Set<string>;
|
|
231
|
-
updateIds?: Set<string>;
|
|
232
|
-
};
|
|
233
|
-
};
|
|
234
|
-
declare class Core {
|
|
235
|
-
private req;
|
|
236
|
-
private caches;
|
|
237
|
-
constructor(req: AccessRouterBaseRequest);
|
|
238
|
-
getIdentifier(modelName: string): string;
|
|
239
|
-
genIDFilter<TModel = unknown>(modelName: string, id: string): Promise<Filter<TModel>>;
|
|
240
|
-
genFilter<TModel = unknown>(modelName: string, access?: BaseFilterAccess, _filter?: Filter<TModel>): Promise<Filter<TModel>>;
|
|
241
|
-
private removePrefix;
|
|
242
|
-
genAllowedFields(modelName: string, doc: unknown, access: SelectAccess, baseFields?: any[]): Promise<string[]>;
|
|
243
|
-
pickAllowedFields<T>(modelName: string, doc: T, access: SelectAccess, baseFields?: any[]): Promise<T>;
|
|
244
|
-
genSelect(modelName: string, access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: any[]): Promise<string[]>;
|
|
245
|
-
genPopulate(modelName: string, access?: SelectAccess | BaseFilterAccess, _populate?: Populate | Populate[] | string | null): Promise<(string | Populate)[]>;
|
|
246
|
-
validate(modelName: string, allowedData: unknown, access: ValidateAccess, context: ModelHookContext): Promise<boolean | unknown[]>;
|
|
247
|
-
prepare<T>(modelName: string, allowedData: T, access: PrepareAccess, context: ModelHookContext): Promise<T>;
|
|
248
|
-
transform<T>(modelName: string, doc: T, access: TransformAccess, context: ModelHookContext): Promise<T>;
|
|
249
|
-
afterPersist<T>(modelName: string, doc: T, access: AfterPersistAccess, context: ModelHookContext): Promise<T>;
|
|
250
|
-
changes(modelName: string, doc: Record<string, unknown>, context: ModelHookContext): Promise<void>;
|
|
251
|
-
beforeDelete<T>(modelName: string, doc: T, context: ModelHookContext): Promise<void>;
|
|
252
|
-
afterDelete<T>(modelName: string, doc: T, context: ModelHookContext): Promise<void>;
|
|
253
|
-
genDocPermissions(modelName: string, doc: unknown, access: DocPermissionsAccess, context: ModelHookContext): Promise<{}>;
|
|
254
|
-
addEmptyPermissions<T>(modelName: string, doc: T): T;
|
|
255
|
-
addDocPermissions<T>(modelName: string, doc: T, access: DocPermissionsAccess, context: ModelHookContext): Promise<T>;
|
|
256
|
-
addFieldPermissions<T extends {
|
|
257
|
-
_id?: unknown;
|
|
258
|
-
}>(modelName: string, doc: T, access: DocPermissionsAccess, context: InternalModelHookContext): Promise<T>;
|
|
259
|
-
decorate<T>(modelName: string, doc: T, access: DecorateAccess, context: ModelHookContext): Promise<T>;
|
|
260
|
-
decorateAll<T>(modelName: string, docs: T[], access: DecorateAllAccess, context: ModelHookContext): Promise<T[]>;
|
|
261
|
-
runTasks<T extends object>(modelName: string, docObject: T, task: Task | Task[]): T;
|
|
262
|
-
getPermissions(): Permission;
|
|
263
|
-
setPermissions(): Promise<void>;
|
|
264
|
-
canActivate(routeGuard: Validation): Promise<boolean>;
|
|
265
|
-
isAllowed(modelName: string, access: RouteGuardAccess | string): Promise<boolean>;
|
|
266
|
-
getService<TModel = unknown>(modelName: string): Service<TModel>;
|
|
267
|
-
getPublicService<TModel = unknown>(modelName: string): PublicService<TModel>;
|
|
268
|
-
service<TModel = unknown>(modelName: string): PublicService<TModel>;
|
|
269
|
-
svc<TModel = unknown>(modelName: string): PublicService<TModel>;
|
|
270
|
-
private getGlobalPermissions;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
declare class DataCore {
|
|
274
|
-
private req;
|
|
275
|
-
private caches;
|
|
276
|
-
constructor(req: AccessRouterBaseRequest);
|
|
277
|
-
genIDFilter<TData = unknown>(dataName: string, id: string): Promise<Filter<TData>>;
|
|
278
|
-
genFilter<TData = unknown>(dataName: string, access?: BaseFilterAccess, _filter?: Filter<TData>): Promise<Filter<TData>>;
|
|
279
|
-
genAllowedFields(dataName: string, _doc: unknown, access: SelectAccess, baseFields?: any[]): Promise<string[]>;
|
|
280
|
-
pickAllowedFields<TDoc>(dataName: string, doc: TDoc, access: SelectAccess, baseFields?: any[]): Promise<TDoc>;
|
|
281
|
-
genSelect(dataName: string, access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: any[]): Promise<string[]>;
|
|
282
|
-
decorate<TDoc>(dataName: string, doc: TDoc, access: DecorateAccess, context?: DataHookContext): Promise<TDoc>;
|
|
283
|
-
decorateAll<TDoc>(dataName: string, docs: TDoc[], access: DecorateAllAccess, context?: DataHookContext): Promise<TDoc[]>;
|
|
284
|
-
getPermissions(): Permission;
|
|
285
|
-
setPermissions(): Promise<void>;
|
|
286
|
-
canActivate(routeGuard: Validation): Promise<boolean>;
|
|
287
|
-
isAllowed(dataName: string, access: RouteGuardAccess | string): Promise<boolean>;
|
|
288
|
-
getService<TData = unknown>(dataName: string): DataService<TData>;
|
|
289
|
-
service<TData = unknown>(dataName: string): DataService<TData>;
|
|
290
|
-
svc<TData = unknown>(dataName: string): DataService<TData>;
|
|
291
|
-
private getGlobalPermissions;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
declare enum StatusCodes {
|
|
295
|
-
OK = 200,
|
|
296
|
-
Created = 201,
|
|
297
|
-
BadRequest = 400,
|
|
298
|
-
Unauthorized = 401,
|
|
299
|
-
Forbidden = 403,
|
|
300
|
-
NotFound = 404,
|
|
301
|
-
UnprocessableContent = 422
|
|
302
|
-
}
|
|
303
|
-
declare enum Codes {
|
|
304
|
-
Success = "success",
|
|
305
|
-
Created = "created",
|
|
306
|
-
BadRequest = "bad_request",
|
|
307
|
-
Unauthorized = "unauthorized",
|
|
308
|
-
Forbidden = "forbidden",
|
|
309
|
-
NotFound = "not_found"
|
|
310
|
-
}
|
|
311
|
-
declare enum CustomHeaders {
|
|
312
|
-
TotalCount = "wtt-total-count",
|
|
313
|
-
ReturnedCount = "wtt-returned-count",
|
|
314
|
-
Page = "wtt-page",
|
|
315
|
-
PageSize = "wtt-page-size",
|
|
316
|
-
TotalPages = "wtt-total-pages",
|
|
317
|
-
HasNextPage = "wtt-has-next-page",
|
|
318
|
-
HasPreviousPage = "wtt-has-previous-page"
|
|
319
|
-
}
|
|
320
|
-
declare enum FilterOperator {
|
|
321
|
-
SubQuery = 0,
|
|
322
|
-
Date = 1
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
interface AccessRouterRequestExtensions {
|
|
326
|
-
macl?: Core;
|
|
327
|
-
dacl?: DataCore;
|
|
328
|
-
}
|
|
329
|
-
type AccessRouterRequest = express.Request & AccessRouterRequestExtensions;
|
|
330
|
-
|
|
331
|
-
type GuardHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, permissions: AccessRouterPermissions) => boolean | Promise<boolean>;
|
|
332
|
-
type Validation = boolean | string | string[] | GuardHook;
|
|
333
|
-
type SelectAccess = 'list' | 'create' | 'read' | 'update' | string;
|
|
334
|
-
type RouteGuardAccess = 'new' | 'list' | 'read' | 'update' | 'upsert' | 'delete' | 'create' | 'distinct' | 'count' | 'subs' | string;
|
|
335
|
-
type DocPermissionsAccess = 'list' | 'create' | 'read' | 'update' | string;
|
|
336
|
-
type BaseFilterAccess = 'list' | 'read' | 'update' | 'delete' | string;
|
|
337
|
-
type DecorateAccess = 'list' | 'create' | 'read' | 'update' | string;
|
|
338
|
-
type DecorateAllAccess = 'list' | string;
|
|
339
|
-
type ValidateAccess = 'create' | 'update' | string;
|
|
340
|
-
type PrepareAccess = 'create' | 'update' | string;
|
|
341
|
-
type TransformAccess = 'update' | string;
|
|
342
|
-
type AfterPersistAccess = 'create' | 'update' | string;
|
|
343
|
-
|
|
344
|
-
interface PublicCreateArgs {
|
|
345
|
-
select?: Projection;
|
|
346
|
-
populate?: Populate[] | string;
|
|
347
|
-
tasks?: Task | Task[];
|
|
348
|
-
}
|
|
349
|
-
interface CreateArgs extends Omit<PublicCreateArgs, 'select' | 'tasks'> {
|
|
350
|
-
}
|
|
351
|
-
interface PublicCreateOptions {
|
|
352
|
-
skim?: boolean;
|
|
353
|
-
includePermissions?: boolean;
|
|
354
|
-
populateAccess?: PopulateAccess;
|
|
355
|
-
}
|
|
356
|
-
interface CreateOptions extends PublicCreateOptions {
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
interface PublicListArgs {
|
|
360
|
-
select?: Projection;
|
|
361
|
-
populate?: Populate[] | string;
|
|
362
|
-
include?: Include | Include[];
|
|
363
|
-
sort?: Sort;
|
|
364
|
-
skip?: string | number;
|
|
365
|
-
limit?: string | number;
|
|
366
|
-
page?: string | number;
|
|
367
|
-
pageSize?: string | number;
|
|
368
|
-
tasks?: Task | Task[];
|
|
369
|
-
}
|
|
370
|
-
interface PublicListOptions {
|
|
371
|
-
skim?: boolean;
|
|
372
|
-
includePermissions?: boolean;
|
|
373
|
-
includeCount?: boolean;
|
|
374
|
-
populateAccess?: PopulateAccess;
|
|
375
|
-
lean?: boolean;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
interface PublicReadArgs {
|
|
379
|
-
select?: Projection;
|
|
380
|
-
populate?: Populate[] | string;
|
|
381
|
-
include?: Include | Include[];
|
|
382
|
-
tasks?: Task | Task[];
|
|
383
|
-
}
|
|
384
|
-
interface PublicReadOptions {
|
|
385
|
-
skim?: boolean;
|
|
386
|
-
populateAccess?: PopulateAccess;
|
|
387
|
-
lean?: boolean;
|
|
388
|
-
includePermissions?: boolean;
|
|
389
|
-
tryList?: boolean;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
interface PublicUpdateArgs {
|
|
393
|
-
select?: Projection;
|
|
394
|
-
populate?: Populate[] | string;
|
|
395
|
-
tasks?: Task | Task[];
|
|
396
|
-
}
|
|
397
|
-
interface PublicUpsertArgs extends PublicUpdateArgs {
|
|
398
|
-
}
|
|
399
|
-
interface UpdateOneArgs<T = unknown> extends Omit<PublicUpdateArgs, 'select' | 'tasks'> {
|
|
400
|
-
overrides?: {
|
|
401
|
-
filter?: Filter<T>;
|
|
402
|
-
populate?: Populate[] | string;
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
interface UpdateByIdArgs<T = unknown> extends Omit<UpdateOneArgs<T>, 'overrides'> {
|
|
406
|
-
overrides?: {
|
|
407
|
-
populate?: Populate[] | string;
|
|
408
|
-
idFilter?: Filter<T>;
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
interface UpsertArgs<T = unknown> extends UpdateOneArgs<T> {
|
|
412
|
-
}
|
|
413
|
-
interface PublicUpdateOptions {
|
|
414
|
-
skim?: boolean;
|
|
415
|
-
returningAll?: boolean;
|
|
416
|
-
includePermissions?: boolean;
|
|
417
|
-
populateAccess?: PopulateAccess;
|
|
418
|
-
}
|
|
419
|
-
interface PublicUpsertOptions extends PublicUpdateOptions {
|
|
420
|
-
}
|
|
421
|
-
interface UpdateOneOptions extends Omit<PublicUpdateOptions, 'returningAll'> {
|
|
422
|
-
}
|
|
423
|
-
interface UpdateByIdOptions extends UpdateOneOptions {
|
|
424
|
-
}
|
|
425
|
-
interface UpsertOptions extends UpdateOneOptions {
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
type DataFilter<T = unknown> = Filter<T>;
|
|
429
|
-
interface DataFindOneArgs<T = unknown, TSelect extends Projection | undefined = Projection | undefined> {
|
|
430
|
-
select?: TSelect;
|
|
431
|
-
}
|
|
432
|
-
interface DataFindOneOptions {
|
|
433
|
-
access?: FindAccess;
|
|
434
|
-
}
|
|
435
|
-
interface DataFindArgs<T = unknown, TSelect extends Projection | undefined = Projection | undefined> {
|
|
436
|
-
select?: TSelect;
|
|
437
|
-
sort?: string;
|
|
438
|
-
skip?: string | number;
|
|
439
|
-
limit?: string | number;
|
|
440
|
-
page?: string | number;
|
|
441
|
-
pageSize?: string | number;
|
|
442
|
-
}
|
|
443
|
-
interface DataFindOptions {
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
interface KeyValueProjection {
|
|
447
|
-
[key: string]: 1 | -1;
|
|
448
|
-
}
|
|
449
|
-
type Projection = string[] | string | KeyValueProjection;
|
|
450
|
-
type SortOrder = -1 | 1 | 'asc' | 'ascending' | 'desc' | 'descending';
|
|
451
|
-
type Sort = string | {
|
|
452
|
-
[key: string]: SortOrder;
|
|
453
|
-
} | [string, SortOrder][] | undefined | null;
|
|
454
|
-
type Primitive = string | number | boolean | bigint | symbol | null | undefined;
|
|
455
|
-
type NonTraversable = Primitive | Date | RegExp | Function;
|
|
456
|
-
type PrevDepth = [never, 0, 1, 2, 3, 4, 5];
|
|
457
|
-
type IsUnknown<T> = unknown extends T ? ([keyof T] extends [never] ? true : false) : false;
|
|
458
|
-
type Descend<T> = T extends readonly (infer U)[] ? U : T;
|
|
459
|
-
type ArrayValue<T> = T extends readonly (infer U)[] ? U : T;
|
|
460
|
-
type ComparableValue = string | number | bigint | Date;
|
|
461
|
-
type WithDefaultId<T> = T extends object ? T & {
|
|
462
|
-
_id?: unknown;
|
|
463
|
-
} : {
|
|
464
|
-
_id?: unknown;
|
|
465
|
-
};
|
|
466
|
-
type PublicOutput<T> = T extends object ? T & Record<string, unknown> : Record<string, unknown>;
|
|
467
|
-
type ModelDocument<TModel = unknown> = mongoose.Document & TModel;
|
|
468
|
-
type TrimLeft<S extends string> = S extends ` ${infer Rest}` ? TrimLeft<Rest> : S;
|
|
469
|
-
type TrimRight<S extends string> = S extends `${infer Rest} ` ? TrimRight<Rest> : S;
|
|
470
|
-
type Trim<S extends string> = TrimLeft<TrimRight<S>>;
|
|
471
|
-
type SplitProjectionString<S extends string> = S extends `${infer Head} ${infer Tail}` ? SplitProjectionString<Head> | SplitProjectionString<Tail> : Trim<S>;
|
|
472
|
-
type ProjectionTokens<TProjection> = TProjection extends readonly string[] ? TProjection[number] : TProjection extends string ? SplitProjectionString<TProjection> : TProjection extends KeyValueProjection ? {
|
|
473
|
-
[K in Extract<keyof TProjection, string>]: TProjection[K] extends 1 ? K : never;
|
|
474
|
-
}[Extract<keyof TProjection, string>] : never;
|
|
475
|
-
type PositiveProjectionPaths<TProjection> = ProjectionTokens<TProjection> extends infer TToken ? TToken extends string ? TToken extends '' ? never : TToken extends `-${string}` ? never : TToken : never : never;
|
|
476
|
-
type UnionToIntersection<T> = (T extends unknown ? (value: T) => void : never) extends (value: infer I) => void ? I : never;
|
|
477
|
-
type Simplify<T> = {
|
|
478
|
-
[K in keyof T]: T[K];
|
|
479
|
-
} & {};
|
|
480
|
-
type DeepPickSingle<T, TPath extends string> = TPath extends `${infer Head}.${infer Tail}` ? Head extends keyof WithDefaultId<T> ? Head extends string ? {
|
|
481
|
-
[K in Head]: WithDefaultId<T>[K] extends readonly (infer U)[] ? Array<Simplify<DeepPickSingle<U, Tail>>> : WithDefaultId<T>[K] extends object ? Simplify<DeepPickSingle<WithDefaultId<T>[K], Tail>> : WithDefaultId<T>[K];
|
|
482
|
-
} : {} : {} : TPath extends keyof WithDefaultId<T> ? Pick<WithDefaultId<T>, TPath> : {};
|
|
483
|
-
type DeepPick<T, TPaths extends string> = Simplify<UnionToIntersection<DeepPickSingle<T, TPaths>>>;
|
|
484
|
-
type SelectedPublicOutput<T, TProjection> = string extends PositiveProjectionPaths<TProjection> ? PublicOutput<T> : [PositiveProjectionPaths<TProjection>] extends [never] ? PublicOutput<T> : DeepPick<T, Extract<PositiveProjectionPaths<TProjection>, string>>;
|
|
485
|
-
type PopulateInput = Populate | string;
|
|
486
|
-
type PopulateInputs<TPopulate> = TPopulate extends readonly (infer U)[] ? U : TPopulate;
|
|
487
|
-
type PopulatePath<TPopulateEntry> = TPopulateEntry extends string ? TPopulateEntry : TPopulateEntry extends {
|
|
488
|
-
path: infer TPath extends string;
|
|
489
|
-
} ? TPath : never;
|
|
490
|
-
type PopulateSelect<TPopulateEntry> = TPopulateEntry extends {
|
|
491
|
-
select?: infer TSelect;
|
|
492
|
-
} ? TSelect : undefined;
|
|
493
|
-
type PopulateLeafValue<TValue, TPopulateEntry> = TValue extends readonly (infer U)[] ? Array<SelectedPublicOutput<U, PopulateSelect<TPopulateEntry>>> : SelectedPublicOutput<TValue, PopulateSelect<TPopulateEntry>>;
|
|
494
|
-
type PopulateEntryShape<T, TPath extends string, TValue> = TPath extends `${infer Head}.${infer Tail}` ? Head extends keyof WithDefaultId<T> ? Head extends string ? {
|
|
495
|
-
[K in Head]: WithDefaultId<T>[K] extends readonly (infer U)[] ? Array<Simplify<PopulateEntryShape<U, Tail, TValue>>> : Simplify<PopulateEntryShape<WithDefaultId<T>[K], Tail, TValue>>;
|
|
496
|
-
} : {} : {} : TPath extends keyof WithDefaultId<T> ? Pick<{
|
|
497
|
-
[K in TPath]: TValue;
|
|
498
|
-
}, TPath> : {};
|
|
499
|
-
type PopulateOutputShape<T, TPopulateEntry> = PopulatePath<TPopulateEntry> extends infer TPath extends string ? PopulateEntryShape<T, TPath, PopulateLeafValue<PathValue<WithDefaultId<T>, TPath>, TPopulateEntry>> : {};
|
|
500
|
-
type PopulateOutput<T, TPopulate> = string extends PopulatePath<PopulateInputs<TPopulate>> ? {} : [PopulatePath<PopulateInputs<TPopulate>>] extends [never] ? {} : Simplify<UnionToIntersection<PopulateOutputShape<T, Extract<PopulateInputs<TPopulate>, PopulateInput>>>>;
|
|
501
|
-
type SelectedPopulatedPublicOutput<T, TProjection, TPopulate> = Simplify<SelectedPublicOutput<T, TProjection> & PopulateOutput<T, TPopulate>>;
|
|
502
|
-
type DeepFieldPath<T, Depth extends number = 4> = [Depth] extends [never] ? never : Descend<T> extends NonTraversable ? never : {
|
|
503
|
-
[K in Extract<keyof Descend<T>, string>]: K | (Descend<T>[K] extends NonTraversable ? never : Descend<T>[K] extends readonly (infer U)[] ? U extends NonTraversable ? never : `${K}.${DeepFieldPath<U, PrevDepth[Depth]>}` : Descend<T>[K] extends object ? `${K}.${DeepFieldPath<Descend<T>[K], PrevDepth[Depth]>}` : never);
|
|
504
|
-
}[Extract<keyof Descend<T>, string>];
|
|
505
|
-
type PathValue<T, TPath extends string> = TPath extends `${infer Head}.${infer Tail}` ? Head extends Extract<keyof Descend<T>, string> ? PathValue<Descend<Descend<T>[Head]>, Tail> : unknown : TPath extends Extract<keyof Descend<T>, string> ? Descend<T>[TPath] : unknown;
|
|
506
|
-
type FieldFilterOperators<T> = {
|
|
507
|
-
$eq?: T;
|
|
508
|
-
$ne?: T;
|
|
509
|
-
$in?: Array<ArrayValue<T>>;
|
|
510
|
-
$nin?: Array<ArrayValue<T>>;
|
|
511
|
-
$exists?: boolean;
|
|
512
|
-
$gt?: ArrayValue<T> extends ComparableValue ? ArrayValue<T> : never;
|
|
513
|
-
$gte?: ArrayValue<T> extends ComparableValue ? ArrayValue<T> : never;
|
|
514
|
-
$lt?: ArrayValue<T> extends ComparableValue ? ArrayValue<T> : never;
|
|
515
|
-
$lte?: ArrayValue<T> extends ComparableValue ? ArrayValue<T> : never;
|
|
516
|
-
$regex?: ArrayValue<T> extends string ? string | RegExp : never;
|
|
517
|
-
$all?: T extends readonly unknown[] ? Array<ArrayValue<T>> : never;
|
|
518
|
-
$size?: T extends readonly unknown[] ? number : never;
|
|
519
|
-
$elemMatch?: ArrayValue<T> extends object ? TypedFilter<ArrayValue<T>> : never;
|
|
520
|
-
$$sq?: unknown;
|
|
521
|
-
$$date?: unknown;
|
|
522
|
-
[key: `$${string}`]: unknown;
|
|
523
|
-
};
|
|
524
|
-
type FieldFilterValue<T> = T | FieldFilterOperators<NonNullable<T>>;
|
|
525
|
-
type LooseFilter = false | Record<string, unknown>;
|
|
526
|
-
type TypedFilterObject<T> = {
|
|
527
|
-
[K in DeepFieldPath<T>]?: FieldFilterValue<PathValue<T, K>>;
|
|
528
|
-
} & {
|
|
529
|
-
_id?: FieldFilterValue<unknown>;
|
|
530
|
-
$and?: TypedFilter<T>[];
|
|
531
|
-
$or?: TypedFilter<T>[];
|
|
532
|
-
$nor?: TypedFilter<T>[];
|
|
533
|
-
[key: `$${string}`]: unknown;
|
|
534
|
-
};
|
|
535
|
-
type TypedFilter<T> = false | TypedFilterObject<WithDefaultId<T>>;
|
|
536
|
-
type Filter<T = unknown> = IsUnknown<T> extends true ? LooseFilter : TypedFilter<T>;
|
|
537
|
-
interface Include {
|
|
538
|
-
model: string;
|
|
539
|
-
op: 'list' | 'read' | 'count';
|
|
540
|
-
path: string;
|
|
541
|
-
filter?: Filter;
|
|
542
|
-
localField: string;
|
|
543
|
-
foreignField: string;
|
|
544
|
-
args?: unknown;
|
|
545
|
-
options?: unknown;
|
|
546
|
-
}
|
|
547
|
-
type FindAccess = 'list' | 'read';
|
|
548
|
-
type PopulateAccess = 'list' | 'read';
|
|
549
|
-
interface Populate {
|
|
550
|
-
path: string;
|
|
551
|
-
select?: Projection;
|
|
552
|
-
match?: unknown;
|
|
553
|
-
access?: PopulateAccess;
|
|
554
|
-
}
|
|
555
|
-
interface SubPopulate {
|
|
556
|
-
path: string;
|
|
557
|
-
select?: Projection;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
interface KeyValue {
|
|
561
|
-
[key: string]: unknown;
|
|
562
|
-
}
|
|
563
|
-
interface Change {
|
|
564
|
-
op: 'add' | 'replace' | 'remove';
|
|
565
|
-
path: Array<string | number>;
|
|
566
|
-
value?: unknown;
|
|
567
|
-
}
|
|
568
|
-
interface ModelHookContext {
|
|
569
|
-
modelName: string;
|
|
570
|
-
mongooseModel: mongoose.Model<unknown>;
|
|
571
|
-
operation?: string;
|
|
572
|
-
originalDocumentSnapshot?: Record<string, unknown>;
|
|
573
|
-
finalDocumentSnapshot?: Record<string, unknown>;
|
|
574
|
-
currentDocument?: ModelDocument;
|
|
575
|
-
originalData?: Record<string, unknown>;
|
|
576
|
-
allowedData?: Record<string, unknown>;
|
|
577
|
-
preparedData?: Record<string, unknown>;
|
|
578
|
-
allowedFields?: string[];
|
|
579
|
-
modifiedPaths?: string[];
|
|
580
|
-
changes?: Change[];
|
|
581
|
-
docPermissions?: KeyValue;
|
|
582
|
-
resolvedQuery?: {
|
|
583
|
-
filter?: Filter;
|
|
584
|
-
select?: string[];
|
|
585
|
-
populate?: Populate[] | string;
|
|
586
|
-
sort?: Sort;
|
|
587
|
-
skip?: number;
|
|
588
|
-
limit?: number;
|
|
589
|
-
};
|
|
590
|
-
}
|
|
591
|
-
interface DataHookContext {
|
|
592
|
-
dataName?: string;
|
|
593
|
-
operation?: string;
|
|
594
|
-
resolvedQuery?: {
|
|
595
|
-
filter?: Filter;
|
|
596
|
-
select?: string[];
|
|
597
|
-
sort?: Sort;
|
|
598
|
-
skip?: number;
|
|
599
|
-
limit?: number;
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
type RootTarget = 'model' | 'data';
|
|
603
|
-
type RootSubOperation = 'subList' | 'subRead' | 'subCreate' | 'subUpdate' | 'subBulkUpdate' | 'subDelete';
|
|
604
|
-
type RootModelOperation = 'new' | 'list' | 'read' | 'create' | 'update' | 'upsert' | 'delete' | 'distinct' | 'count' | RootSubOperation;
|
|
605
|
-
type RootDataOperation = 'list' | 'read';
|
|
606
|
-
interface RootQueryEntryBase<TTarget extends RootTarget, TOp extends string> {
|
|
607
|
-
target: TTarget;
|
|
608
|
-
name: string;
|
|
609
|
-
op: TOp;
|
|
610
|
-
order?: number;
|
|
611
|
-
}
|
|
612
|
-
interface RootModelNewQueryEntry extends RootQueryEntryBase<'model', 'new'> {
|
|
613
|
-
}
|
|
614
|
-
interface RootModelListQueryEntry extends RootQueryEntryBase<'model', 'list'> {
|
|
615
|
-
filter?: Filter;
|
|
616
|
-
args?: PublicListArgs;
|
|
617
|
-
options?: PublicListOptions;
|
|
618
|
-
}
|
|
619
|
-
interface RootModelReadByIdQueryEntry extends RootQueryEntryBase<'model', 'read'> {
|
|
620
|
-
id: string;
|
|
621
|
-
args?: PublicReadArgs;
|
|
622
|
-
options?: PublicReadOptions;
|
|
623
|
-
}
|
|
624
|
-
interface RootModelReadByFilterQueryEntry extends RootQueryEntryBase<'model', 'read'> {
|
|
625
|
-
filter: Filter;
|
|
626
|
-
args?: PublicReadArgs & {
|
|
627
|
-
sort?: Sort;
|
|
628
|
-
};
|
|
629
|
-
options?: PublicReadOptions;
|
|
630
|
-
}
|
|
631
|
-
interface RootModelCreateQueryEntry extends RootQueryEntryBase<'model', 'create'> {
|
|
632
|
-
data: unknown;
|
|
633
|
-
args?: PublicCreateArgs;
|
|
634
|
-
options?: PublicCreateOptions;
|
|
635
|
-
}
|
|
636
|
-
interface RootModelUpdateQueryEntry extends RootQueryEntryBase<'model', 'update'> {
|
|
637
|
-
id: string;
|
|
638
|
-
data: unknown;
|
|
639
|
-
args?: PublicUpdateArgs;
|
|
640
|
-
options?: PublicUpdateOptions;
|
|
641
|
-
}
|
|
642
|
-
interface RootModelUpsertQueryEntry extends RootQueryEntryBase<'model', 'upsert'> {
|
|
643
|
-
data: Record<string, unknown>;
|
|
644
|
-
args?: PublicUpsertArgs;
|
|
645
|
-
options?: PublicUpsertOptions;
|
|
646
|
-
}
|
|
647
|
-
interface RootModelDeleteQueryEntry extends RootQueryEntryBase<'model', 'delete'> {
|
|
648
|
-
id: string;
|
|
649
|
-
}
|
|
650
|
-
interface RootModelSubListQueryEntry extends RootQueryEntryBase<'model', 'subList'> {
|
|
651
|
-
id: string;
|
|
652
|
-
sub: string;
|
|
653
|
-
filter?: Filter;
|
|
654
|
-
args?: {
|
|
655
|
-
select?: string[];
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
interface RootModelSubReadQueryEntry extends RootQueryEntryBase<'model', 'subRead'> {
|
|
659
|
-
id: string;
|
|
660
|
-
sub: string;
|
|
661
|
-
subId: string;
|
|
662
|
-
args?: {
|
|
663
|
-
select?: string[];
|
|
664
|
-
populate?: SubPopulate | SubPopulate[] | string | string[];
|
|
665
|
-
};
|
|
666
|
-
}
|
|
667
|
-
interface RootModelSubCreateQueryEntry extends RootQueryEntryBase<'model', 'subCreate'> {
|
|
668
|
-
id: string;
|
|
669
|
-
sub: string;
|
|
670
|
-
data: unknown;
|
|
671
|
-
}
|
|
672
|
-
interface RootModelSubUpdateQueryEntry extends RootQueryEntryBase<'model', 'subUpdate'> {
|
|
673
|
-
id: string;
|
|
674
|
-
sub: string;
|
|
675
|
-
subId: string;
|
|
676
|
-
data: unknown;
|
|
677
|
-
}
|
|
678
|
-
interface RootModelSubBulkUpdateQueryEntry extends RootQueryEntryBase<'model', 'subBulkUpdate'> {
|
|
679
|
-
id: string;
|
|
680
|
-
sub: string;
|
|
681
|
-
data: unknown;
|
|
682
|
-
}
|
|
683
|
-
interface RootModelSubDeleteQueryEntry extends RootQueryEntryBase<'model', 'subDelete'> {
|
|
684
|
-
id: string;
|
|
685
|
-
sub: string;
|
|
686
|
-
subId: string;
|
|
687
|
-
}
|
|
688
|
-
interface RootModelDistinctQueryEntry extends RootQueryEntryBase<'model', 'distinct'> {
|
|
689
|
-
field: string;
|
|
690
|
-
filter?: Filter;
|
|
691
|
-
}
|
|
692
|
-
interface RootModelCountQueryEntry extends RootQueryEntryBase<'model', 'count'> {
|
|
693
|
-
filter?: Filter;
|
|
694
|
-
options?: {
|
|
695
|
-
access?: BaseFilterAccess;
|
|
696
|
-
[key: string]: unknown;
|
|
697
|
-
};
|
|
698
|
-
}
|
|
699
|
-
interface RootDataListQueryEntry extends RootQueryEntryBase<'data', 'list'> {
|
|
700
|
-
filter?: Filter;
|
|
701
|
-
args?: DataFindArgs;
|
|
702
|
-
options?: {
|
|
703
|
-
includeCount?: boolean;
|
|
704
|
-
[key: string]: unknown;
|
|
705
|
-
};
|
|
706
|
-
}
|
|
707
|
-
interface RootDataReadByIdQueryEntry extends RootQueryEntryBase<'data', 'read'> {
|
|
708
|
-
id: string;
|
|
709
|
-
args?: DataFindOneArgs;
|
|
710
|
-
}
|
|
711
|
-
interface RootDataReadByFilterQueryEntry extends RootQueryEntryBase<'data', 'read'> {
|
|
712
|
-
filter: Filter;
|
|
713
|
-
args?: DataFindOneArgs;
|
|
714
|
-
}
|
|
715
|
-
type RootQueryEntry = RootModelNewQueryEntry | RootModelListQueryEntry | RootModelReadByIdQueryEntry | RootModelReadByFilterQueryEntry | RootModelCreateQueryEntry | RootModelUpdateQueryEntry | RootModelUpsertQueryEntry | RootModelDeleteQueryEntry | RootModelSubListQueryEntry | RootModelSubReadQueryEntry | RootModelSubCreateQueryEntry | RootModelSubUpdateQueryEntry | RootModelSubBulkUpdateQueryEntry | RootModelSubDeleteQueryEntry | RootModelDistinctQueryEntry | RootModelCountQueryEntry | RootDataListQueryEntry | RootDataReadByIdQueryEntry | RootDataReadByFilterQueryEntry;
|
|
716
|
-
interface RootOperationResult<T = unknown, TError = unknown, TInput = unknown, TQuery = unknown> {
|
|
717
|
-
index: number;
|
|
718
|
-
target: RootTarget;
|
|
719
|
-
name: string;
|
|
720
|
-
op: RootModelOperation | RootDataOperation;
|
|
721
|
-
result: ServiceResult<T, TError, TInput, TQuery>;
|
|
722
|
-
statusCode: number;
|
|
723
|
-
message: string;
|
|
724
|
-
}
|
|
725
|
-
interface SubQueryEntry {
|
|
726
|
-
model: string;
|
|
727
|
-
op: 'list' | 'read' | string;
|
|
728
|
-
id?: string;
|
|
729
|
-
filter?: Filter;
|
|
730
|
-
args?: Record<string, unknown>;
|
|
731
|
-
options?: Record<string, unknown>;
|
|
732
|
-
sqOptions?: {
|
|
733
|
-
path?: string;
|
|
734
|
-
compact?: boolean;
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
|
-
interface Task {
|
|
738
|
-
type: string;
|
|
739
|
-
args: unknown;
|
|
740
|
-
options: Record<string, unknown>;
|
|
741
|
-
}
|
|
742
|
-
interface AccessRouterBaseRequest extends AccessRouterRequest {
|
|
743
|
-
query: Record<'skip' | 'limit' | 'page' | 'page_size' | 'try_list' | 'skim' | 'include_permissions' | 'include_count' | 'include_extra_headers' | 'returning_all', string>;
|
|
744
|
-
}
|
|
745
|
-
interface ModelRequest extends AccessRouterBaseRequest {
|
|
746
|
-
macl: Core;
|
|
747
|
-
}
|
|
748
|
-
interface DataRequest extends AccessRouterBaseRequest {
|
|
749
|
-
dacl: DataCore;
|
|
750
|
-
}
|
|
751
|
-
type Request = AccessRouterBaseRequest;
|
|
752
|
-
interface ErrorResult<TError = unknown, TQuery = unknown> {
|
|
753
|
-
success: false;
|
|
754
|
-
code: Codes.BadRequest | Codes.Unauthorized | Codes.Forbidden | Codes.NotFound;
|
|
755
|
-
errors?: TError[];
|
|
756
|
-
query?: TQuery;
|
|
757
|
-
}
|
|
758
|
-
interface SingleResult<T = unknown, TInput = unknown, TQuery = unknown> {
|
|
759
|
-
success: true;
|
|
760
|
-
kind: 'single';
|
|
761
|
-
code: Codes.Success | Codes.Created;
|
|
762
|
-
data: T;
|
|
763
|
-
input?: TInput;
|
|
764
|
-
query?: TQuery;
|
|
765
|
-
context?: ModelHookContext;
|
|
766
|
-
}
|
|
767
|
-
interface ListResult<T = unknown, TInput = unknown, TQuery = unknown> {
|
|
768
|
-
success: true;
|
|
769
|
-
kind: 'list';
|
|
770
|
-
code: Codes.Success | Codes.Created;
|
|
771
|
-
data: T[];
|
|
772
|
-
count: number;
|
|
773
|
-
totalCount?: number | null;
|
|
774
|
-
input?: TInput;
|
|
775
|
-
query?: TQuery;
|
|
776
|
-
contexts?: ModelHookContext[];
|
|
777
|
-
}
|
|
778
|
-
type ServiceResult<T = unknown, TError = unknown, TInput = unknown, TQuery = unknown> = SingleResult<T, TInput, TQuery> | ListResult<T, TInput, TQuery> | ErrorResult<TError, TQuery>;
|
|
779
|
-
|
|
780
|
-
interface FindArgs<T = unknown> {
|
|
781
|
-
select?: Projection;
|
|
782
|
-
populate?: Populate[] | string;
|
|
783
|
-
include?: Include | Include[];
|
|
784
|
-
sort?: Sort;
|
|
785
|
-
skip?: string | number;
|
|
786
|
-
limit?: string | number;
|
|
787
|
-
page?: string | number;
|
|
788
|
-
pageSize?: string | number;
|
|
789
|
-
overrides?: {
|
|
790
|
-
filter?: Filter<T>;
|
|
791
|
-
select?: Projection;
|
|
792
|
-
populate?: Populate[] | string;
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
interface FindOptions {
|
|
796
|
-
skim?: boolean;
|
|
797
|
-
includePermissions?: boolean;
|
|
798
|
-
includeCount?: boolean;
|
|
799
|
-
populateAccess?: PopulateAccess;
|
|
800
|
-
lean?: boolean;
|
|
801
|
-
}
|
|
802
|
-
interface FindOneArgs<T = unknown> {
|
|
803
|
-
select?: Projection;
|
|
804
|
-
sort?: Sort;
|
|
805
|
-
populate?: Populate[] | string;
|
|
806
|
-
include?: Include | Include[];
|
|
807
|
-
overrides?: {
|
|
808
|
-
filter?: Filter<T>;
|
|
809
|
-
select?: Projection;
|
|
810
|
-
populate?: Populate[] | string;
|
|
811
|
-
};
|
|
812
|
-
}
|
|
813
|
-
interface FindOneOptions {
|
|
814
|
-
access?: FindAccess;
|
|
815
|
-
populateAccess?: PopulateAccess;
|
|
816
|
-
skim?: boolean;
|
|
817
|
-
lean?: boolean;
|
|
818
|
-
includePermissions?: boolean;
|
|
819
|
-
}
|
|
820
|
-
interface FindByIdArgs<T = unknown> {
|
|
821
|
-
select?: Projection;
|
|
822
|
-
populate?: Populate[] | string;
|
|
823
|
-
include?: Include | Include[];
|
|
824
|
-
overrides?: {
|
|
825
|
-
select?: Projection;
|
|
826
|
-
populate?: Populate[] | string;
|
|
827
|
-
idFilter?: Filter<T>;
|
|
828
|
-
};
|
|
829
|
-
}
|
|
830
|
-
interface FindByIdOptions extends FindOneOptions {
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
interface ExistsOptions {
|
|
834
|
-
access?: BaseFilterAccess;
|
|
835
|
-
includeId?: boolean;
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
839
|
-
type AccessRouterFieldKey<T> = [Extract<keyof T, string>] extends [never] ? string : Extract<keyof T, string>;
|
|
840
|
-
type IdentifierHook<TValue, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, id: string) => MaybePromise<Filter<TValue>>;
|
|
841
|
-
type GlobalPermissionValue = Record<string, boolean> | string[] | string | null | undefined;
|
|
842
|
-
type BaseFilterHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, permissions: AccessRouterPermissions) => MaybePromise<Filter | true | null | undefined>;
|
|
843
|
-
type OverrideFilterHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, filter: Filter, permissions: AccessRouterPermissions) => MaybePromise<Filter>;
|
|
844
|
-
type Hook<TValue, TContext, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, value: TValue, permissions: AccessRouterPermissions, context: TContext) => MaybePromise<TValue>;
|
|
845
|
-
type HookChain<TValue, TContext, TRequest extends AccessRouterRequest = AccessRouterRequest> = Hook<TValue, TContext, TRequest> | Array<Hook<TValue, TContext, TRequest>>;
|
|
846
|
-
type ValidateRule = boolean | unknown[];
|
|
847
|
-
type ValidateHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, allowedData: unknown, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<ValidateRule>;
|
|
848
|
-
type DocPermissionsHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, doc: unknown, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<Record<string, unknown>>;
|
|
849
|
-
type ChangeHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, previousValue: unknown, nextValue: unknown, changes: Change[], context: ModelHookContext) => MaybePromise<void>;
|
|
850
|
-
type DeleteHook<TValue = unknown, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, value: TValue, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<void>;
|
|
851
|
-
type DocumentHook<TValue, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, value: ModelDocument<TValue>, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<ModelDocument<TValue>>;
|
|
852
|
-
type DocumentHookChain<TValue, TRequest extends AccessRouterRequest = AccessRouterRequest> = DocumentHook<TValue, TRequest> | Array<DocumentHook<TValue, TRequest>>;
|
|
853
|
-
type ModelBaseFilterHook = BaseFilterHook<ModelRequest>;
|
|
854
|
-
type DataBaseFilterHook = BaseFilterHook<DataRequest>;
|
|
855
|
-
type ModelOverrideFilterHook = OverrideFilterHook<ModelRequest>;
|
|
856
|
-
type DataOverrideFilterHook = OverrideFilterHook<DataRequest>;
|
|
857
|
-
type ModelIdentifierHook<TValue = unknown> = IdentifierHook<TValue, ModelRequest>;
|
|
858
|
-
type DataIdentifierHook<TValue = unknown> = IdentifierHook<TValue, DataRequest>;
|
|
859
|
-
type ModelValidateHook = ValidateHook<ModelRequest>;
|
|
860
|
-
type ModelDocPermissionsHook = DocPermissionsHook<ModelRequest>;
|
|
861
|
-
type ModelChangeHook = ChangeHook<ModelRequest>;
|
|
862
|
-
type ModelDocumentHook<TValue = unknown> = DocumentHookChain<TValue, ModelRequest>;
|
|
863
|
-
type ModelDeleteHook<TValue = unknown> = DeleteHook<ModelDocument<TValue>, ModelRequest>;
|
|
864
|
-
type ModelHook<TValue = unknown> = HookChain<TValue, ModelHookContext, ModelRequest>;
|
|
865
|
-
type ModelListHook<TValue = unknown> = HookChain<TValue[], ModelHookContext, ModelRequest>;
|
|
866
|
-
type DataHook<TValue = unknown> = HookChain<TValue, DataHookContext, DataRequest>;
|
|
867
|
-
type DataListHook<TValue = unknown> = HookChain<TValue[], DataHookContext, DataRequest>;
|
|
868
|
-
|
|
869
|
-
type ValidationError = {
|
|
870
|
-
detail: string;
|
|
871
|
-
pointer?: string;
|
|
872
|
-
parameter?: string;
|
|
873
|
-
};
|
|
874
|
-
type RequestSchemaIssue = {
|
|
875
|
-
message: string;
|
|
876
|
-
path?: Array<string | number>;
|
|
877
|
-
};
|
|
878
|
-
type RequestSchemaSuccess<T = unknown> = {
|
|
879
|
-
success: true;
|
|
880
|
-
data: T;
|
|
881
|
-
};
|
|
882
|
-
type RequestSchemaFailure = {
|
|
883
|
-
success: false;
|
|
884
|
-
issues: RequestSchemaIssue[];
|
|
885
|
-
};
|
|
886
|
-
type RequestSchemaResult<T = unknown> = RequestSchemaSuccess<T> | RequestSchemaFailure;
|
|
887
|
-
type RequestSchemaValidator<T = unknown> = (value: unknown) => RequestSchemaResult<T> | Promise<RequestSchemaResult<T>>;
|
|
888
|
-
type RequestSchemaAdapter<T = unknown> = {
|
|
889
|
-
validate: RequestSchemaValidator<T>;
|
|
890
|
-
openapi?: Record<string, unknown>;
|
|
891
|
-
};
|
|
892
|
-
type RequestSchemaOptions = {
|
|
893
|
-
openapi?: Record<string, unknown>;
|
|
894
|
-
};
|
|
895
|
-
type StandardSchemaPathSegment = {
|
|
896
|
-
key: PropertyKey;
|
|
897
|
-
};
|
|
898
|
-
type StandardSchemaIssue = {
|
|
899
|
-
message: string;
|
|
900
|
-
path?: ReadonlyArray<PropertyKey | StandardSchemaPathSegment>;
|
|
901
|
-
};
|
|
902
|
-
type StandardSchemaSuccess<T = unknown> = {
|
|
903
|
-
value: T;
|
|
904
|
-
issues?: undefined;
|
|
905
|
-
};
|
|
906
|
-
type StandardSchemaFailure = {
|
|
907
|
-
issues: ReadonlyArray<StandardSchemaIssue>;
|
|
908
|
-
};
|
|
909
|
-
type StandardSchemaResult<T = unknown> = StandardSchemaSuccess<T> | StandardSchemaFailure;
|
|
910
|
-
type StandardSchemaV1<Input = unknown, Output = Input> = {
|
|
911
|
-
readonly '~standard': {
|
|
912
|
-
readonly version: 1;
|
|
913
|
-
readonly vendor: string;
|
|
914
|
-
readonly validate: (value: unknown, options?: {
|
|
915
|
-
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
916
|
-
}) => StandardSchemaResult<Output> | Promise<StandardSchemaResult<Output>>;
|
|
917
|
-
readonly types?: {
|
|
918
|
-
readonly input: Input;
|
|
919
|
-
readonly output: Output;
|
|
920
|
-
};
|
|
921
|
-
};
|
|
922
|
-
};
|
|
923
|
-
type StandardSchemaInferOutput<TSchema extends StandardSchemaV1> = NonNullable<TSchema['~standard']['types']>['output'];
|
|
924
|
-
type RequestSchemaLike<T = unknown> = RequestSchemaValidator<T> | RequestSchemaAdapter<T> | StandardSchemaV1;
|
|
925
|
-
type YupValidationErrorLike = {
|
|
926
|
-
message: string;
|
|
927
|
-
path?: string;
|
|
928
|
-
inner?: ReadonlyArray<YupValidationErrorLike>;
|
|
929
|
-
};
|
|
930
|
-
type YupSchemaLike<T = unknown> = {
|
|
931
|
-
validate: (value: unknown, options?: {
|
|
932
|
-
abortEarly?: boolean;
|
|
933
|
-
stripUnknown?: boolean;
|
|
934
|
-
}) => Promise<T> | T;
|
|
935
|
-
};
|
|
936
|
-
type JoiValidationErrorDetailLike = {
|
|
937
|
-
message: string;
|
|
938
|
-
path?: ReadonlyArray<string | number>;
|
|
939
|
-
};
|
|
940
|
-
type JoiSchemaLike<T = unknown> = {
|
|
941
|
-
validate: (value: unknown, options?: {
|
|
942
|
-
abortEarly?: boolean;
|
|
943
|
-
stripUnknown?: boolean;
|
|
944
|
-
}) => {
|
|
945
|
-
value: T;
|
|
946
|
-
error?: {
|
|
947
|
-
details?: ReadonlyArray<JoiValidationErrorDetailLike>;
|
|
948
|
-
};
|
|
949
|
-
} | Promise<{
|
|
950
|
-
value: T;
|
|
951
|
-
error?: {
|
|
952
|
-
details?: ReadonlyArray<JoiValidationErrorDetailLike>;
|
|
953
|
-
};
|
|
954
|
-
}>;
|
|
955
|
-
};
|
|
956
|
-
type AjvErrorObjectLike = {
|
|
957
|
-
message?: string;
|
|
958
|
-
instancePath?: string;
|
|
959
|
-
schemaPath?: string;
|
|
960
|
-
params?: {
|
|
961
|
-
missingProperty?: string;
|
|
962
|
-
};
|
|
963
|
-
};
|
|
964
|
-
type AjvValidatorLike<T = unknown> = {
|
|
965
|
-
(value: unknown): boolean | Promise<boolean>;
|
|
966
|
-
errors?: ReadonlyArray<AjvErrorObjectLike> | null;
|
|
967
|
-
};
|
|
968
|
-
type ValibotPathItemLike = {
|
|
969
|
-
key?: unknown;
|
|
970
|
-
};
|
|
971
|
-
type ValibotIssueLike = {
|
|
972
|
-
message: string;
|
|
973
|
-
path?: ReadonlyArray<ValibotPathItemLike>;
|
|
974
|
-
};
|
|
975
|
-
type ValibotSafeParseResult<T = unknown> = {
|
|
976
|
-
success: true;
|
|
977
|
-
output: T;
|
|
978
|
-
issues?: undefined;
|
|
979
|
-
} | {
|
|
980
|
-
success: false;
|
|
981
|
-
output?: undefined;
|
|
982
|
-
issues: ReadonlyArray<ValibotIssueLike>;
|
|
983
|
-
};
|
|
984
|
-
type ValibotSafeParseLike = <TSchema, TOutput = unknown>(schema: TSchema, value: unknown, config?: {
|
|
985
|
-
abortEarly?: boolean;
|
|
986
|
-
}) => ValibotSafeParseResult<TOutput> | Promise<ValibotSafeParseResult<TOutput>>;
|
|
987
|
-
type ArkTypeProblemLike = {
|
|
988
|
-
path?: ReadonlyArray<string | number>;
|
|
989
|
-
message?: string;
|
|
990
|
-
problem?: string;
|
|
991
|
-
};
|
|
992
|
-
type ArkTypeErrorsLike = ReadonlyArray<ArkTypeProblemLike> & {
|
|
993
|
-
summary?: string;
|
|
994
|
-
};
|
|
995
|
-
type ArkTypeLike<T = unknown> = {
|
|
996
|
-
(value: unknown): T | ArkTypeErrorsLike;
|
|
997
|
-
errors?: unknown;
|
|
998
|
-
};
|
|
999
|
-
type IoTsContextEntryLike = {
|
|
1000
|
-
key: string;
|
|
1001
|
-
};
|
|
1002
|
-
type IoTsDecodeErrorLike = {
|
|
1003
|
-
message?: string;
|
|
1004
|
-
context: ReadonlyArray<IoTsContextEntryLike>;
|
|
1005
|
-
};
|
|
1006
|
-
type IoTsDecoderLike<T = unknown> = {
|
|
1007
|
-
decode: (value: unknown) => {
|
|
1008
|
-
_tag: 'Left';
|
|
1009
|
-
left: ReadonlyArray<IoTsDecodeErrorLike>;
|
|
1010
|
-
} | {
|
|
1011
|
-
_tag: 'Right';
|
|
1012
|
-
right: T;
|
|
1013
|
-
};
|
|
1014
|
-
};
|
|
1015
|
-
type SuperstructFailureLike = {
|
|
1016
|
-
message?: string;
|
|
1017
|
-
path?: ReadonlyArray<string | number>;
|
|
1018
|
-
key?: string | number;
|
|
1019
|
-
branch?: ReadonlyArray<unknown>;
|
|
1020
|
-
failures?: () => ReadonlyArray<SuperstructFailureLike>;
|
|
1021
|
-
};
|
|
1022
|
-
type SuperstructValidateLike = <TStruct, TOutput = unknown>(value: unknown, struct: TStruct) => readonly [failure: SuperstructFailureLike, value: undefined] | readonly [failure: undefined, value: TOutput] | Promise<readonly [failure: SuperstructFailureLike, value: undefined] | readonly [failure: undefined, value: TOutput]>;
|
|
1023
|
-
type VineValidationMessageLike = {
|
|
1024
|
-
field: string;
|
|
1025
|
-
message: string;
|
|
1026
|
-
index?: number;
|
|
1027
|
-
};
|
|
1028
|
-
type VineValidationErrorLike = {
|
|
1029
|
-
messages: ReadonlyArray<VineValidationMessageLike>;
|
|
1030
|
-
};
|
|
1031
|
-
type VineValidatorLike<T = unknown> = {
|
|
1032
|
-
validate: (value: unknown) => Promise<T> | T;
|
|
1033
|
-
};
|
|
1034
|
-
type ListQueryInput = {
|
|
1035
|
-
skip?: string;
|
|
1036
|
-
limit?: string;
|
|
1037
|
-
page?: string;
|
|
1038
|
-
page_size?: string;
|
|
1039
|
-
skim?: 'true' | 'false';
|
|
1040
|
-
include_permissions?: 'true' | 'false';
|
|
1041
|
-
include_count?: 'true' | 'false';
|
|
1042
|
-
include_extra_headers?: 'true' | 'false';
|
|
1043
|
-
};
|
|
1044
|
-
type CreateQueryInput = {
|
|
1045
|
-
include_permissions?: 'true' | 'false';
|
|
1046
|
-
};
|
|
1047
|
-
type ReadQueryInput = {
|
|
1048
|
-
include_permissions?: 'true' | 'false';
|
|
1049
|
-
try_list?: 'true' | 'false';
|
|
1050
|
-
};
|
|
1051
|
-
type UpdateQueryInput = {
|
|
1052
|
-
returning_all?: 'true' | 'false';
|
|
1053
|
-
};
|
|
1054
|
-
type UpsertQueryInput = {
|
|
1055
|
-
returning_all?: 'true' | 'false';
|
|
1056
|
-
include_permissions?: 'true' | 'false';
|
|
1057
|
-
};
|
|
1058
|
-
type AdvancedListBody = {
|
|
1059
|
-
filter?: Filter | unknown[];
|
|
1060
|
-
select?: Projection;
|
|
1061
|
-
sort?: Sort;
|
|
1062
|
-
populate?: Populate[] | string;
|
|
1063
|
-
include?: Include | Include[];
|
|
1064
|
-
tasks?: Task | Task[];
|
|
1065
|
-
skip?: string | number;
|
|
1066
|
-
limit?: string | number;
|
|
1067
|
-
page?: string | number;
|
|
1068
|
-
pageSize?: string | number;
|
|
1069
|
-
options?: {
|
|
1070
|
-
skim?: boolean;
|
|
1071
|
-
includePermissions?: boolean;
|
|
1072
|
-
includeCount?: boolean;
|
|
1073
|
-
includeExtraHeaders?: boolean;
|
|
1074
|
-
populateAccess?: unknown;
|
|
1075
|
-
};
|
|
1076
|
-
};
|
|
1077
|
-
type CountBody = {
|
|
1078
|
-
filter?: Filter | unknown[];
|
|
1079
|
-
options?: {
|
|
1080
|
-
access?: unknown;
|
|
1081
|
-
};
|
|
1082
|
-
};
|
|
1083
|
-
type AdvancedReadFilterBody = {
|
|
1084
|
-
filter?: Filter | unknown[];
|
|
1085
|
-
select?: Projection;
|
|
1086
|
-
sort?: Sort;
|
|
1087
|
-
populate?: Populate[] | string;
|
|
1088
|
-
include?: Include | Include[];
|
|
1089
|
-
tasks?: Task | Task[];
|
|
1090
|
-
options?: {
|
|
1091
|
-
skim?: boolean;
|
|
1092
|
-
includePermissions?: boolean;
|
|
1093
|
-
tryList?: boolean;
|
|
1094
|
-
populateAccess?: unknown;
|
|
1095
|
-
};
|
|
1096
|
-
};
|
|
1097
|
-
type AdvancedReadBody = {
|
|
1098
|
-
select?: Projection;
|
|
1099
|
-
populate?: Populate[] | string;
|
|
1100
|
-
include?: Include | Include[];
|
|
1101
|
-
tasks?: Task | Task[];
|
|
1102
|
-
options?: {
|
|
1103
|
-
skim?: boolean;
|
|
1104
|
-
includePermissions?: boolean;
|
|
1105
|
-
tryList?: boolean;
|
|
1106
|
-
populateAccess?: unknown;
|
|
1107
|
-
};
|
|
1108
|
-
};
|
|
1109
|
-
type AdvancedCreateBody = {
|
|
1110
|
-
data: unknown;
|
|
1111
|
-
select?: Projection;
|
|
1112
|
-
populate?: Populate[] | string;
|
|
1113
|
-
tasks?: Task | Task[];
|
|
1114
|
-
options?: {
|
|
1115
|
-
includePermissions?: boolean;
|
|
1116
|
-
populateAccess?: unknown;
|
|
1117
|
-
};
|
|
1118
|
-
};
|
|
1119
|
-
type AdvancedUpdateBody = {
|
|
1120
|
-
data: unknown;
|
|
1121
|
-
select?: Projection;
|
|
1122
|
-
populate?: Populate[] | string;
|
|
1123
|
-
tasks?: Task | Task[];
|
|
1124
|
-
options?: {
|
|
1125
|
-
returningAll?: boolean;
|
|
1126
|
-
includePermissions?: boolean;
|
|
1127
|
-
populateAccess?: unknown;
|
|
1128
|
-
};
|
|
1129
|
-
};
|
|
1130
|
-
type AdvancedUpsertBody = {
|
|
1131
|
-
data: Record<string, unknown>;
|
|
1132
|
-
select?: Projection;
|
|
1133
|
-
populate?: Populate[] | string;
|
|
1134
|
-
tasks?: Task | Task[];
|
|
1135
|
-
options?: {
|
|
1136
|
-
returningAll?: boolean;
|
|
1137
|
-
includePermissions?: boolean;
|
|
1138
|
-
populateAccess?: unknown;
|
|
1139
|
-
};
|
|
1140
|
-
};
|
|
1141
|
-
type DistinctBody = {
|
|
1142
|
-
filter?: Filter | unknown[];
|
|
1143
|
-
};
|
|
1144
|
-
type SubListBody = {
|
|
1145
|
-
filter?: Filter;
|
|
1146
|
-
select?: string[];
|
|
1147
|
-
};
|
|
1148
|
-
type SubReadBody = {
|
|
1149
|
-
select?: string[];
|
|
1150
|
-
populate?: SubPopulate | SubPopulate[] | string | string[];
|
|
1151
|
-
};
|
|
1152
|
-
|
|
1153
|
-
interface DefaultFindOneArgs<TModel = unknown> extends Omit<FindOneArgs<TModel>, 'overrides'> {
|
|
1154
|
-
}
|
|
1155
|
-
interface DefaultFindByIdArgs<TModel = unknown> extends Omit<FindByIdArgs<TModel>, 'overrides'> {
|
|
1156
|
-
}
|
|
1157
|
-
interface DefaultFindArgs<TModel = unknown> extends Omit<FindArgs<TModel>, 'overrides'> {
|
|
1158
|
-
}
|
|
1159
|
-
type RequestSchema = RequestSchemaLike;
|
|
1160
|
-
type NestedRequestSchema = {
|
|
1161
|
-
default?: RequestSchema;
|
|
1162
|
-
data?: RequestSchema;
|
|
1163
|
-
};
|
|
1164
|
-
type SubRouteGuardOptions = Record<string, Validation | Record<string, Validation>>;
|
|
1165
|
-
interface RequestSchemas {
|
|
1166
|
-
create?: RequestSchema;
|
|
1167
|
-
update?: RequestSchema;
|
|
1168
|
-
upsert?: RequestSchema;
|
|
1169
|
-
count?: RequestSchema;
|
|
1170
|
-
distinct?: RequestSchema;
|
|
1171
|
-
advancedList?: RequestSchema;
|
|
1172
|
-
advancedReadFilter?: RequestSchema;
|
|
1173
|
-
advancedRead?: RequestSchema;
|
|
1174
|
-
advancedCreate?: RequestSchema | NestedRequestSchema;
|
|
1175
|
-
advancedCreateData?: RequestSchema;
|
|
1176
|
-
advancedUpdate?: RequestSchema | NestedRequestSchema;
|
|
1177
|
-
advancedUpdateData?: RequestSchema;
|
|
1178
|
-
advancedUpsert?: RequestSchema | NestedRequestSchema;
|
|
1179
|
-
advancedUpsertData?: RequestSchema;
|
|
1180
|
-
subList?: RequestSchema;
|
|
1181
|
-
subRead?: RequestSchema;
|
|
1182
|
-
subCreate?: RequestSchema;
|
|
1183
|
-
subUpdate?: RequestSchema;
|
|
1184
|
-
subBulkUpdate?: RequestSchema;
|
|
1185
|
-
}
|
|
1186
|
-
interface DataRequestSchemas {
|
|
1187
|
-
advancedList?: RequestSchema;
|
|
1188
|
-
advancedReadFilter?: RequestSchema;
|
|
1189
|
-
advancedRead?: RequestSchema;
|
|
1190
|
-
}
|
|
1191
|
-
interface Defaults<TModel = unknown> {
|
|
1192
|
-
findOneArgs?: DefaultFindOneArgs<TModel>;
|
|
1193
|
-
findOneOptions?: FindOneOptions;
|
|
1194
|
-
findByIdArgs?: DefaultFindByIdArgs<TModel>;
|
|
1195
|
-
findByIdOptions?: FindByIdOptions;
|
|
1196
|
-
findArgs?: DefaultFindArgs<TModel>;
|
|
1197
|
-
findOptions?: FindOptions;
|
|
1198
|
-
createArgs?: CreateArgs;
|
|
1199
|
-
createOptions?: CreateOptions;
|
|
1200
|
-
updateOneArgs?: UpdateOneArgs<TModel>;
|
|
1201
|
-
updateOneOptions?: UpdateOneOptions;
|
|
1202
|
-
upsertOptions?: UpsertOptions;
|
|
1203
|
-
updateByIdArgs?: UpdateByIdArgs<TModel>;
|
|
1204
|
-
upsertArgs?: UpsertArgs<TModel>;
|
|
1205
|
-
updateByIdOptions?: UpdateByIdOptions;
|
|
1206
|
-
existsOptions?: ExistsOptions;
|
|
1207
|
-
publicListArgs?: PublicListArgs;
|
|
1208
|
-
publicListOptions?: PublicListOptions;
|
|
1209
|
-
publicCreateArgs?: PublicCreateArgs;
|
|
1210
|
-
publicCreateOptions?: PublicCreateOptions;
|
|
1211
|
-
publicReadArgs?: PublicReadArgs;
|
|
1212
|
-
publicReadOptions?: PublicReadOptions;
|
|
1213
|
-
publicUpdateArgs?: PublicUpdateArgs;
|
|
1214
|
-
publicUpdateOptions?: PublicUpdateOptions;
|
|
1215
|
-
}
|
|
1216
|
-
interface AccessRouterLogger {
|
|
1217
|
-
debug?: (...args: unknown[]) => unknown;
|
|
1218
|
-
info?: (...args: unknown[]) => unknown;
|
|
1219
|
-
warn?: (...args: unknown[]) => unknown;
|
|
1220
|
-
error?: (...args: unknown[]) => unknown;
|
|
1221
|
-
}
|
|
1222
|
-
interface GlobalOptions {
|
|
1223
|
-
requestPermissionField?: string;
|
|
1224
|
-
globalPermissions?: (this: AccessRouterRequest, req: AccessRouterRequest) => MaybePromise<GlobalPermissionValue>;
|
|
1225
|
-
logger?: AccessRouterLogger;
|
|
1226
|
-
}
|
|
1227
|
-
interface RootRouterOptions {
|
|
1228
|
-
basePath: string;
|
|
1229
|
-
operationAccess?: Validation;
|
|
1230
|
-
}
|
|
1231
|
-
interface OperationAccess {
|
|
1232
|
-
new?: Validation;
|
|
1233
|
-
list?: Validation;
|
|
1234
|
-
create?: Validation;
|
|
1235
|
-
read?: Validation;
|
|
1236
|
-
update?: Validation;
|
|
1237
|
-
upsert?: Validation;
|
|
1238
|
-
delete?: Validation;
|
|
1239
|
-
distinct?: Validation;
|
|
1240
|
-
count?: Validation;
|
|
1241
|
-
subs?: Validation | SubRouteGuardOptions;
|
|
1242
|
-
}
|
|
1243
|
-
type PermissionRule = Validation | OperationAccess;
|
|
1244
|
-
type PermissionSchema<TField extends string = string> = Partial<Record<TField, PermissionRule>>;
|
|
1245
|
-
interface DocPermissions {
|
|
1246
|
-
list?: ModelDocPermissionsHook;
|
|
1247
|
-
create?: ModelDocPermissionsHook;
|
|
1248
|
-
read?: ModelDocPermissionsHook;
|
|
1249
|
-
update?: ModelDocPermissionsHook;
|
|
1250
|
-
}
|
|
1251
|
-
interface DefaultModelRouterOptions<TModel = unknown> {
|
|
1252
|
-
listHardLimit?: number;
|
|
1253
|
-
documentPermissionField?: string;
|
|
1254
|
-
idParam?: string;
|
|
1255
|
-
idField?: string;
|
|
1256
|
-
resolveIdFilter?: ModelIdentifierHook<TModel>;
|
|
1257
|
-
parentPath?: string;
|
|
1258
|
-
queryRouteSegment?: string;
|
|
1259
|
-
mutationRouteSegment?: string;
|
|
1260
|
-
operationAccess?: Validation | OperationAccess;
|
|
1261
|
-
modelPermissionPrefix?: string;
|
|
1262
|
-
}
|
|
1263
|
-
interface ExtendedDefaultModelRouterOptions<TModel = unknown> extends DefaultModelRouterOptions<TModel> {
|
|
1264
|
-
'operationAccess.default'?: Validation;
|
|
1265
|
-
'operationAccess.new'?: Validation;
|
|
1266
|
-
'operationAccess.list'?: Validation;
|
|
1267
|
-
'operationAccess.read'?: Validation;
|
|
1268
|
-
'operationAccess.update'?: Validation;
|
|
1269
|
-
'operationAccess.delete'?: Validation;
|
|
1270
|
-
'operationAccess.create'?: Validation;
|
|
1271
|
-
'operationAccess.distinct'?: Validation;
|
|
1272
|
-
'operationAccess.count'?: Validation;
|
|
1273
|
-
'operationAccess.subs'?: SubRouteGuardOptions;
|
|
1274
|
-
}
|
|
1275
|
-
interface ModelRouterOptions<TModel = unknown> extends DefaultModelRouterOptions<TModel> {
|
|
1276
|
-
modelName?: string;
|
|
1277
|
-
basePath?: string;
|
|
1278
|
-
permissionSchema?: PermissionSchema<AccessRouterFieldKey<TModel>>;
|
|
1279
|
-
alwaysSelectFields?: string[];
|
|
1280
|
-
docPermissions?: DocPermissions | ModelDocPermissionsHook;
|
|
1281
|
-
baseFilter?: ModelBaseFilterHook | Record<string, ModelBaseFilterHook>;
|
|
1282
|
-
overrideFilter?: ModelOverrideFilterHook | Record<string, ModelOverrideFilterHook>;
|
|
1283
|
-
decorate?: ModelHook<TModel> | Record<string, ModelHook<TModel>>;
|
|
1284
|
-
decorateAll?: ModelListHook<TModel> | Record<string, ModelListHook<TModel>>;
|
|
1285
|
-
validate?: ValidateRule | ModelValidateHook | Record<string, ValidateRule | ModelValidateHook>;
|
|
1286
|
-
prepare?: ModelHook<TModel> | Record<string, ModelHook<TModel>>;
|
|
1287
|
-
transform?: ModelDocumentHook<TModel> | Record<string, ModelDocumentHook<TModel>>;
|
|
1288
|
-
afterPersist?: ModelDocumentHook<TModel> | Record<string, ModelDocumentHook<TModel>>;
|
|
1289
|
-
onChange?: Record<string, ModelChangeHook>;
|
|
1290
|
-
beforeDelete?: ModelDeleteHook<TModel>;
|
|
1291
|
-
afterDelete?: ModelDeleteHook<TModel>;
|
|
1292
|
-
requestSchemas?: RequestSchemas;
|
|
1293
|
-
defaults?: Defaults<TModel>;
|
|
1294
|
-
}
|
|
1295
|
-
interface DataRouterOptions<TData = unknown> {
|
|
1296
|
-
data?: TData[];
|
|
1297
|
-
listHardLimit?: number;
|
|
1298
|
-
idParam?: string;
|
|
1299
|
-
idField?: string;
|
|
1300
|
-
resolveIdFilter?: DataIdentifierHook<TData>;
|
|
1301
|
-
parentPath?: string;
|
|
1302
|
-
queryRouteSegment?: string;
|
|
1303
|
-
operationAccess?: Validation | OperationAccess;
|
|
1304
|
-
dataName?: string;
|
|
1305
|
-
basePath?: string;
|
|
1306
|
-
permissionSchema?: PermissionSchema<AccessRouterFieldKey<TData>>;
|
|
1307
|
-
baseFilter?: DataBaseFilterHook | Record<string, DataBaseFilterHook>;
|
|
1308
|
-
overrideFilter?: DataOverrideFilterHook | Record<string, DataOverrideFilterHook>;
|
|
1309
|
-
decorate?: DataHook<TData> | Record<string, DataHook<TData>>;
|
|
1310
|
-
decorateAll?: DataListHook<TData> | Record<string, DataListHook<TData>>;
|
|
1311
|
-
requestSchemas?: DataRequestSchemas;
|
|
1312
|
-
}
|
|
1313
|
-
interface ExtendedModelRouterOptions<TModel = unknown> extends ModelRouterOptions<TModel>, ExtendedDefaultModelRouterOptions<TModel> {
|
|
1314
|
-
'alwaysSelectFields.default'?: string[];
|
|
1315
|
-
'alwaysSelectFields.list'?: string[];
|
|
1316
|
-
'alwaysSelectFields.create'?: string[];
|
|
1317
|
-
'alwaysSelectFields.read'?: string[];
|
|
1318
|
-
'alwaysSelectFields.update'?: string[];
|
|
1319
|
-
'docPermissions.default'?: ModelDocPermissionsHook;
|
|
1320
|
-
'docPermissions.list'?: ModelDocPermissionsHook;
|
|
1321
|
-
'docPermissions.create'?: ModelDocPermissionsHook;
|
|
1322
|
-
'docPermissions.read'?: ModelDocPermissionsHook;
|
|
1323
|
-
'docPermissions.update'?: ModelDocPermissionsHook;
|
|
1324
|
-
'baseFilter.default'?: ModelBaseFilterHook;
|
|
1325
|
-
'baseFilter.list'?: ModelBaseFilterHook;
|
|
1326
|
-
'baseFilter.read'?: ModelBaseFilterHook;
|
|
1327
|
-
'baseFilter.update'?: ModelBaseFilterHook;
|
|
1328
|
-
'baseFilter.delete'?: ModelBaseFilterHook;
|
|
1329
|
-
'overrideFilter.default'?: ModelOverrideFilterHook;
|
|
1330
|
-
'overrideFilter.list'?: ModelOverrideFilterHook;
|
|
1331
|
-
'overrideFilter.read'?: ModelOverrideFilterHook;
|
|
1332
|
-
'overrideFilter.update'?: ModelOverrideFilterHook;
|
|
1333
|
-
'overrideFilter.delete'?: ModelOverrideFilterHook;
|
|
1334
|
-
'decorate.default'?: ModelHook;
|
|
1335
|
-
'decorate.list'?: ModelHook;
|
|
1336
|
-
'decorate.create'?: ModelHook;
|
|
1337
|
-
'decorate.read'?: ModelHook;
|
|
1338
|
-
'decorate.update'?: ModelHook;
|
|
1339
|
-
'decorateAll.default'?: ModelListHook;
|
|
1340
|
-
'decorateAll.list'?: ModelListHook;
|
|
1341
|
-
'validate.default'?: ValidateRule | ModelValidateHook;
|
|
1342
|
-
'validate.create'?: ValidateRule | ModelValidateHook;
|
|
1343
|
-
'validate.update'?: ValidateRule | ModelValidateHook;
|
|
1344
|
-
'prepare.default'?: ModelHook;
|
|
1345
|
-
'prepare.create'?: ModelHook;
|
|
1346
|
-
'prepare.update'?: ModelHook;
|
|
1347
|
-
'transform.default'?: ModelDocumentHook;
|
|
1348
|
-
'transform.update'?: ModelDocumentHook;
|
|
1349
|
-
'afterPersist.default'?: ModelDocumentHook;
|
|
1350
|
-
'afterPersist.create'?: ModelDocumentHook;
|
|
1351
|
-
'afterPersist.update'?: ModelDocumentHook;
|
|
1352
|
-
onChange?: Record<string, ModelChangeHook>;
|
|
1353
|
-
'requestSchemas.create'?: RequestSchema;
|
|
1354
|
-
'requestSchemas.update'?: RequestSchema;
|
|
1355
|
-
'requestSchemas.upsert'?: RequestSchema;
|
|
1356
|
-
'requestSchemas.count'?: RequestSchema;
|
|
1357
|
-
'requestSchemas.distinct'?: RequestSchema;
|
|
1358
|
-
'requestSchemas.advancedList'?: RequestSchema;
|
|
1359
|
-
'requestSchemas.advancedReadFilter'?: RequestSchema;
|
|
1360
|
-
'requestSchemas.advancedRead'?: RequestSchema;
|
|
1361
|
-
'requestSchemas.advancedCreate.default'?: RequestSchema;
|
|
1362
|
-
'requestSchemas.advancedCreate.data'?: RequestSchema;
|
|
1363
|
-
'requestSchemas.advancedUpdate'?: RequestSchema;
|
|
1364
|
-
'requestSchemas.advancedUpdate.default'?: RequestSchema;
|
|
1365
|
-
'requestSchemas.advancedUpdate.data'?: RequestSchema;
|
|
1366
|
-
'requestSchemas.advancedUpsert.default'?: RequestSchema;
|
|
1367
|
-
'requestSchemas.advancedUpsert.data'?: RequestSchema;
|
|
1368
|
-
'requestSchemas.subList'?: RequestSchema;
|
|
1369
|
-
'requestSchemas.subRead'?: RequestSchema;
|
|
1370
|
-
'requestSchemas.subCreate'?: RequestSchema;
|
|
1371
|
-
'requestSchemas.subUpdate'?: RequestSchema;
|
|
1372
|
-
'requestSchemas.subBulkUpdate'?: RequestSchema;
|
|
1373
|
-
'defaults.findOneArgs'?: DefaultFindOneArgs<TModel>;
|
|
1374
|
-
'defaults.findOneOptions'?: FindOneOptions;
|
|
1375
|
-
'defaults.findByIdArgs'?: DefaultFindByIdArgs<TModel>;
|
|
1376
|
-
'defaults.findByIdOptions'?: FindByIdOptions;
|
|
1377
|
-
'defaults.findArgs'?: DefaultFindArgs<TModel>;
|
|
1378
|
-
'defaults.findOptions'?: FindOptions;
|
|
1379
|
-
'defaults.createArgs'?: CreateArgs;
|
|
1380
|
-
'defaults.createOptions'?: CreateOptions;
|
|
1381
|
-
'defaults.updateOneArgs'?: UpdateOneArgs<TModel>;
|
|
1382
|
-
'defaults.updateOneOptions'?: UpdateOneOptions;
|
|
1383
|
-
'defaults.updateByIdArgs'?: UpdateByIdArgs<TModel>;
|
|
1384
|
-
'defaults.updateByIdOptions'?: UpdateByIdOptions;
|
|
1385
|
-
'defaults.upsertArgs'?: UpsertArgs<TModel>;
|
|
1386
|
-
'defaults.existsOptions'?: ExistsOptions;
|
|
1387
|
-
'defaults.publicListArgs'?: PublicListArgs;
|
|
1388
|
-
'defaults.publicListOptions'?: PublicListOptions;
|
|
1389
|
-
'defaults.publicCreateArgs'?: PublicCreateArgs;
|
|
1390
|
-
'defaults.publicCreateOptions'?: PublicCreateOptions;
|
|
1391
|
-
'defaults.publicReadArgs'?: PublicReadArgs;
|
|
1392
|
-
'defaults.publicReadOptions'?: PublicReadOptions;
|
|
1393
|
-
'defaults.publicUpdateArgs'?: PublicUpdateArgs;
|
|
1394
|
-
'defaults.publicUpdateOptions'?: PublicUpdateOptions;
|
|
1395
|
-
}
|
|
1396
|
-
interface ExtendedDataRouterOptions<TData = unknown> extends DataRouterOptions<TData> {
|
|
1397
|
-
'requestSchemas.advancedList'?: RequestSchema;
|
|
1398
|
-
'requestSchemas.advancedReadFilter'?: RequestSchema;
|
|
1399
|
-
'requestSchemas.advancedRead'?: RequestSchema;
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
|
-
interface DistinctArgs<T = unknown> {
|
|
1403
|
-
filter?: Filter<T>;
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
declare const MIDDLEWARE: unique symbol;
|
|
1407
|
-
declare const DATA_MIDDLEWARE: unique symbol;
|
|
1408
|
-
declare const PERMISSIONS: unique symbol;
|
|
1409
|
-
declare const PERMISSION_KEYS: unique symbol;
|
|
1410
|
-
|
|
1411
|
-
declare function parsePathParam(value: string | string[] | undefined, parameter: string): string;
|
|
1412
|
-
declare function parseQuery<TSchema extends z.ZodTypeAny>(schema: TSchema, value: unknown): z.output<TSchema>;
|
|
1413
|
-
declare function parseBody<TSchema extends z.ZodTypeAny>(schema: TSchema, value: unknown): z.output<TSchema>;
|
|
1414
|
-
declare function parseBodyWithSchema<TSchema extends z.ZodTypeAny>(schema: TSchema, value: unknown, userSchema?: RequestSchemaLike): Promise<z.output<TSchema>>;
|
|
1415
|
-
declare function parseNestedBodyWithSchema(schema: z.ZodTypeAny, value: unknown, nestedKey: string, userSchema?: RequestSchemaLike): Promise<Record<string, unknown>>;
|
|
1416
|
-
/**
|
|
1417
|
-
* Wraps a request validator into a request schema adapter used by `access-router`.
|
|
1418
|
-
*
|
|
1419
|
-
* @example
|
|
1420
|
-
* const schema = defineRequestSchema(fromZod(z.object({ name: z.string() })));
|
|
1421
|
-
*/
|
|
1422
|
-
declare function defineRequestSchema<T = unknown>(validator: RequestSchemaValidator<T>, options?: RequestSchemaOptions): RequestSchemaAdapter<T>;
|
|
1423
|
-
/**
|
|
1424
|
-
* Adapts a Zod schema into a `RequestSchemaValidator` for `access-router`.
|
|
1425
|
-
*
|
|
1426
|
-
* @example
|
|
1427
|
-
* const validator = fromZod(z.object({ name: z.string() }));
|
|
1428
|
-
*/
|
|
1429
|
-
declare function fromZod<TSchema extends z.ZodTypeAny>(schema: TSchema): RequestSchemaValidator<z.output<TSchema>>;
|
|
1430
|
-
declare function fromStandardSchema<TSchema extends StandardSchemaV1>(schema: TSchema): RequestSchemaValidator<StandardSchemaInferOutput<TSchema>>;
|
|
1431
|
-
declare function fromYup<TSchema extends YupSchemaLike>(schema: TSchema): RequestSchemaValidator;
|
|
1432
|
-
declare function fromJoi<TSchema extends JoiSchemaLike>(schema: TSchema): RequestSchemaValidator;
|
|
1433
|
-
declare function fromAjv<TValue = unknown>(validator: AjvValidatorLike<TValue>): RequestSchemaValidator<TValue>;
|
|
1434
|
-
declare function fromValibot<TSchema, TOutput = unknown>(schema: TSchema, safeParse: ValibotSafeParseLike): RequestSchemaValidator<TOutput>;
|
|
1435
|
-
declare function fromArkType<TValue = unknown>(type: ArkTypeLike<TValue>): RequestSchemaValidator<TValue>;
|
|
1436
|
-
declare function fromIoTs<TValue = unknown>(decoder: IoTsDecoderLike<TValue>): RequestSchemaValidator<TValue>;
|
|
1437
|
-
declare function fromSuperstruct<TStruct, TOutput = unknown>(struct: TStruct, validate: SuperstructValidateLike): RequestSchemaValidator<TOutput>;
|
|
1438
|
-
declare function fromVine<TValue = unknown>(validator: VineValidatorLike<TValue>): RequestSchemaValidator<TValue>;
|
|
3
|
+
import 'mongoose';
|
|
4
|
+
import 'express';
|
|
1439
5
|
|
|
1440
6
|
declare const listQuerySchema: z.ZodObject<{
|
|
1441
7
|
skip: z.ZodOptional<z.ZodString>;
|
|
@@ -1566,9 +132,6 @@ declare const listBodySchema: z.ZodObject<{
|
|
|
1566
132
|
}, z.core.$loose>;
|
|
1567
133
|
declare const countBodySchema: z.ZodObject<{
|
|
1568
134
|
filter: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown>]>>;
|
|
1569
|
-
options: z.ZodOptional<z.ZodObject<{
|
|
1570
|
-
access: z.ZodOptional<z.ZodUnknown>;
|
|
1571
|
-
}, z.core.$loose>>;
|
|
1572
135
|
}, z.core.$loose>;
|
|
1573
136
|
declare const readFilterBodySchema: z.ZodObject<{
|
|
1574
137
|
filter: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown>]>>;
|
|
@@ -1906,6 +469,13 @@ declare const dataReadByIdBodySchema: z.ZodObject<{
|
|
|
1906
469
|
declare const rootQuerySchema: z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
1907
470
|
target: z.ZodLiteral<"model">;
|
|
1908
471
|
op: z.ZodLiteral<"new">;
|
|
472
|
+
args: z.ZodOptional<z.ZodObject<{
|
|
473
|
+
select: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<-1>]>>]>>;
|
|
474
|
+
}, z.core.$loose>>;
|
|
475
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
476
|
+
skim: z.ZodOptional<z.ZodBoolean>;
|
|
477
|
+
includePermissions: z.ZodOptional<z.ZodBoolean>;
|
|
478
|
+
}, z.core.$loose>>;
|
|
1909
479
|
name: z.ZodString;
|
|
1910
480
|
order: z.ZodOptional<z.ZodNumber>;
|
|
1911
481
|
}, z.core.$loose>, z.ZodObject<{
|
|
@@ -2323,9 +893,7 @@ declare const rootQuerySchema: z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readon
|
|
|
2323
893
|
target: z.ZodLiteral<"model">;
|
|
2324
894
|
op: z.ZodLiteral<"count">;
|
|
2325
895
|
filter: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown>]>>;
|
|
2326
|
-
options: z.ZodOptional<z.ZodObject<{
|
|
2327
|
-
access: z.ZodOptional<z.ZodUnknown>;
|
|
2328
|
-
}, z.core.$loose>>;
|
|
896
|
+
options: z.ZodOptional<z.ZodOptional<z.ZodObject<{}, z.core.$strict>>>;
|
|
2329
897
|
name: z.ZodString;
|
|
2330
898
|
order: z.ZodOptional<z.ZodNumber>;
|
|
2331
899
|
}, z.core.$loose>]>, z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -2365,4 +933,4 @@ declare const rootQuerySchema: z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readon
|
|
|
2365
933
|
order: z.ZodOptional<z.ZodNumber>;
|
|
2366
934
|
}, z.core.$loose>]>]>>;
|
|
2367
935
|
|
|
2368
|
-
export {
|
|
936
|
+
export { advancedCreateBodySchema, advancedUpdateBodySchema, advancedUpsertBodySchema, countBodySchema, createBodySchema, createQuerySchema, dataListBodySchema, dataReadByIdBodySchema, dataReadFilterBodySchema, distinctBodySchema, listBodySchema, listQuerySchema, readByIdBodySchema, readFilterBodySchema, readQuerySchema, requestSchemas, rootQuerySchema, subListBodySchema, subMutationBodySchema, subReadBodySchema, updateBodySchema, updateQuerySchema, upsertBodySchema, upsertQuerySchema };
|