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