@web-ts-toolkit/access-router 0.38.0 → 0.40.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 +51 -5
- package/advanced.d.mts +3 -3
- package/advanced.d.ts +3 -3
- package/advanced.js +170 -85
- package/advanced.mjs +144 -59
- package/index.d.mts +198 -3
- package/index.d.ts +198 -3
- package/index.js +519 -306
- package/index.mjs +540 -328
- package/llms.txt +25 -5
- package/package.json +3 -3
- package/{parsers--DZcTstL.d.mts → parsers-PMWujHUV.d.mts} +32 -204
- package/{parsers--DZcTstL.d.ts → parsers-PMWujHUV.d.ts} +32 -204
- package/processors.d.mts +20 -8
- package/processors.d.ts +20 -8
|
@@ -24,204 +24,8 @@ declare class Permission {
|
|
|
24
24
|
type Permissions = Permission;
|
|
25
25
|
type AccessRouterPermissions = Permission;
|
|
26
26
|
|
|
27
|
-
type OpenApiMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
28
|
-
type OpenApiSchema = Record<string, unknown>;
|
|
29
|
-
type OpenApiSchemaSource = unknown;
|
|
30
|
-
type OpenApiParameter = {
|
|
31
|
-
name: string;
|
|
32
|
-
in: 'path' | 'query';
|
|
33
|
-
required?: boolean;
|
|
34
|
-
description?: string;
|
|
35
|
-
schema?: OpenApiSchema;
|
|
36
|
-
};
|
|
37
|
-
type OpenApiResponse = {
|
|
38
|
-
description: string;
|
|
39
|
-
content?: Record<string, {
|
|
40
|
-
schema: OpenApiSchema;
|
|
41
|
-
}>;
|
|
42
|
-
};
|
|
43
|
-
type OpenApiResponses = Record<string, OpenApiResponse>;
|
|
44
|
-
type OpenApiRouteDescriptor = {
|
|
45
|
-
method: OpenApiMethod;
|
|
46
|
-
path: string;
|
|
47
|
-
operationId?: string;
|
|
48
|
-
summary?: string;
|
|
49
|
-
description?: string;
|
|
50
|
-
tags?: string[];
|
|
51
|
-
acl?: string;
|
|
52
|
-
deprecated?: boolean;
|
|
53
|
-
query?: OpenApiSchemaSource;
|
|
54
|
-
body?: OpenApiSchemaSource;
|
|
55
|
-
pathParams?: Record<string, OpenApiSchemaSource>;
|
|
56
|
-
responses?: OpenApiResponses;
|
|
57
|
-
/**
|
|
58
|
-
* When true, replaces an existing registration with the same method/path
|
|
59
|
-
* even when the descriptors differ. When false (default), conflicting
|
|
60
|
-
* registrations throw at registration time so consumers can detect
|
|
61
|
-
* accidental route shadowing.
|
|
62
|
-
*/
|
|
63
|
-
allowReplace?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* When true, this exact descriptor is idempotent and registering the same
|
|
66
|
-
* method/path with an equivalent descriptor again is silently accepted.
|
|
67
|
-
* Differing re-registrations still throw unless {@link allowReplace} is set.
|
|
68
|
-
* Additionally, an idempotent descriptor may share its operationId with
|
|
69
|
-
* another idempotent descriptor mounted at a different path on the same
|
|
70
|
-
* registry, so reserved operations (e.g. the root batch route) can be
|
|
71
|
-
* exposed from multiple base paths without triggering strict-mode
|
|
72
|
-
* duplicate-operationId rejection.
|
|
73
|
-
*/
|
|
74
|
-
idempotent?: boolean;
|
|
75
|
-
};
|
|
76
|
-
type OpenApiRegistryOptions = {
|
|
77
|
-
/**
|
|
78
|
-
* Throw when the same method/path is registered twice with differing
|
|
79
|
-
* descriptors, instead of silently replacing. Default: true (strict).
|
|
80
|
-
* The {@link AccessRuntime} registry is constructed in strict mode by
|
|
81
|
-
* default; construct {@link OpenApiRegistry} directly with
|
|
82
|
-
* `rejectConflicts: false` for legacy replacement semantics.
|
|
83
|
-
*/
|
|
84
|
-
rejectConflicts?: boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Throw when the same operationId is registered more than once, including
|
|
87
|
-
* when {@link OpenApiRouteDescriptor.allowReplace} is set. Default: true.
|
|
88
|
-
*/
|
|
89
|
-
rejectDuplicateOperationIds?: boolean;
|
|
90
|
-
};
|
|
91
|
-
type OpenApiDocumentOptions = {
|
|
92
|
-
title: string;
|
|
93
|
-
version: string;
|
|
94
|
-
description?: string;
|
|
95
|
-
servers?: Array<{
|
|
96
|
-
url: string;
|
|
97
|
-
description?: string;
|
|
98
|
-
}>;
|
|
99
|
-
};
|
|
100
|
-
type OpenApiRouterOptions = Partial<OpenApiDocumentOptions> & {
|
|
101
|
-
jsonPath?: string;
|
|
102
|
-
docsPath?: string | false;
|
|
103
|
-
swaggerUiCssUrl?: string;
|
|
104
|
-
swaggerUiBundleUrl?: string;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
declare class AccessRuntime {
|
|
108
|
-
constructor();
|
|
109
|
-
private readonly globalOptions;
|
|
110
|
-
private readonly defaultModelOptions;
|
|
111
|
-
private readonly modelOptions;
|
|
112
|
-
private readonly modelJsonSchemas;
|
|
113
|
-
private readonly dataOptions;
|
|
114
|
-
private readonly modelRefs;
|
|
115
|
-
private readonly modelSubs;
|
|
116
|
-
private readonly modelAtts;
|
|
117
|
-
private readonly modelInstances;
|
|
118
|
-
private readonly openApiRegistry;
|
|
119
|
-
registerModelInstance(modelName: string, model: mongoose.Model<unknown>): void;
|
|
120
|
-
hasModelInstance(modelName: string): boolean;
|
|
121
|
-
getModelInstance(modelName: string): mongoose.Model<unknown> | null;
|
|
122
|
-
registerOpenApiRoute(route: OpenApiRouteDescriptor): void;
|
|
123
|
-
/**
|
|
124
|
-
* Enable strict OpenAPI collision detection for the remainder of this
|
|
125
|
-
* runtime's lifetime. After this call, conflicting method/path
|
|
126
|
-
* registrations and duplicate operationIds throw {@link OpenApiCollisionError}
|
|
127
|
-
* instead of silently replacing. Existing already-registered routes are
|
|
128
|
-
* not retroactively re-validated.
|
|
129
|
-
*/
|
|
130
|
-
enableOpenApiCollisionDetection(): void;
|
|
131
|
-
getOpenApiRoutes(): OpenApiRouteDescriptor[];
|
|
132
|
-
clearOpenApiRoutes(): void;
|
|
133
|
-
getOpenApiSpec(info: OpenApiDocumentOptions): {
|
|
134
|
-
openapi: string;
|
|
135
|
-
info: Omit<OpenApiDocumentOptions, "servers">;
|
|
136
|
-
servers?: OpenApiDocumentOptions["servers"];
|
|
137
|
-
paths: Record<string, Record<string, {
|
|
138
|
-
[key: `x-${string}`]: unknown;
|
|
139
|
-
operationId?: string;
|
|
140
|
-
summary?: string;
|
|
141
|
-
description?: string;
|
|
142
|
-
tags?: string[];
|
|
143
|
-
deprecated?: boolean;
|
|
144
|
-
parameters?: OpenApiParameter[];
|
|
145
|
-
requestBody?: {
|
|
146
|
-
required?: boolean;
|
|
147
|
-
content: Record<string, {
|
|
148
|
-
schema: OpenApiSchema;
|
|
149
|
-
}>;
|
|
150
|
-
};
|
|
151
|
-
responses: OpenApiResponses;
|
|
152
|
-
}>>;
|
|
153
|
-
};
|
|
154
|
-
setGlobalOptions(options: GlobalOptions): void;
|
|
155
|
-
setGlobalOption<K extends keyof GlobalOptions>(key: K, value: GlobalOptions[K]): void;
|
|
156
|
-
getGlobalOptions(): GlobalOptions;
|
|
157
|
-
getGlobalOption<K extends keyof GlobalOptions>(key: K, defaultValue?: GlobalOptions[K]): GlobalOptions[K];
|
|
158
|
-
setDefaultModelOptions(options: DefaultModelRouterOptions): void;
|
|
159
|
-
setDefaultModelOption<K extends keyof ExtendedDefaultModelRouterOptions>(key: K, value: ExtendedDefaultModelRouterOptions[K]): void;
|
|
160
|
-
getDefaultModelOptions(): DefaultModelRouterOptions<unknown>;
|
|
161
|
-
getDefaultModelOption<K extends keyof ExtendedDefaultModelRouterOptions>(key: K, defaultValue?: ExtendedDefaultModelRouterOptions[K]): ExtendedDefaultModelRouterOptions<unknown>[K];
|
|
162
|
-
private createModelOptions;
|
|
163
|
-
private getOrCreateModelOptions;
|
|
164
|
-
setModelOptions<TModel = unknown>(modelName: string, options: ModelRouterOptions<TModel>): void;
|
|
165
|
-
setModelOption<K extends keyof ExtendedModelRouterOptions<TModel>, TModel = unknown>(modelName: string, key: K, value: ExtendedModelRouterOptions<TModel>[K]): void;
|
|
166
|
-
getModelOptions<TModel = unknown>(modelName: string): ModelRouterOptions<TModel>;
|
|
167
|
-
getModelOption<K extends keyof ExtendedModelRouterOptions<TModel>, TModel = unknown>(modelName: string, key: K | string, defaultValue?: ExtendedModelRouterOptions<TModel>[K]): ExtendedModelRouterOptions<TModel>[K];
|
|
168
|
-
getExactModelOption<K extends keyof ExtendedModelRouterOptions<TModel>, TModel = unknown>(modelName: string, key: K | string): ExtendedModelRouterOptions<TModel>[K];
|
|
169
|
-
getModelNames(): string[];
|
|
170
|
-
hasModel(modelName: string): boolean;
|
|
171
|
-
getModelJsonSchema(modelName: string): Record<string, unknown>;
|
|
172
|
-
private createDataOptions;
|
|
173
|
-
private getOrCreateDataOptions;
|
|
174
|
-
setDataOptions<TData = unknown>(dataName: string, options: DataRouterOptions<TData>): void;
|
|
175
|
-
setDataOption<K extends keyof DataRouterOptions<TData>, TData = unknown>(dataName: string, key: K, value: DataRouterOptions<TData>[K]): void;
|
|
176
|
-
getDataOptions<TData = unknown>(dataName: string): DataRouterOptions<TData>;
|
|
177
|
-
getDataOption<K extends keyof DataRouterOptions<TData>, TData = unknown>(dataName: string, key: K | string, defaultValue?: DataRouterOptions<TData>[K]): DataRouterOptions<TData>[K];
|
|
178
|
-
getExactDataOption<K extends keyof ExtendedDataRouterOptions<TData>, TData = unknown>(dataName: string, key: K | string): ExtendedDataRouterOptions<TData>[K];
|
|
179
|
-
getDataNames(): string[];
|
|
180
|
-
ensureModelMeta(modelName: string): void;
|
|
181
|
-
getModelRef(modelName: string, refPath: string): string | null;
|
|
182
|
-
getModelSub(modelName: string): string[];
|
|
183
|
-
getModelAtt(modelName: string): string[];
|
|
184
|
-
}
|
|
185
|
-
declare const defaultRuntime: AccessRuntime;
|
|
186
|
-
|
|
187
|
-
interface FindProps {
|
|
188
|
-
filter: Filter;
|
|
189
|
-
select?: Projection;
|
|
190
|
-
sort?: Sort;
|
|
191
|
-
populate?: Populate[] | string;
|
|
192
|
-
limit?: string | number;
|
|
193
|
-
hardLimit?: number;
|
|
194
|
-
skip?: string | number;
|
|
195
|
-
lean?: boolean;
|
|
196
|
-
}
|
|
197
|
-
interface FindOneProps {
|
|
198
|
-
filter: Filter;
|
|
199
|
-
select?: Projection;
|
|
200
|
-
sort?: Sort;
|
|
201
|
-
populate?: Populate[] | string;
|
|
202
|
-
lean?: boolean;
|
|
203
|
-
}
|
|
204
|
-
type SortValue = 1 | -1 | 'asc' | 'ascending' | 'desc' | 'descending';
|
|
205
|
-
type SortType = string | [string, SortValue][] | {
|
|
206
|
-
[key: string]: SortValue;
|
|
207
|
-
} | Map<string, SortValue> | null | undefined;
|
|
208
|
-
declare class Model {
|
|
209
|
-
modelName: string;
|
|
210
|
-
model: mongoose.Model<any>;
|
|
211
|
-
runtime: AccessRuntime | null;
|
|
212
|
-
constructor(modelName: string, runtime?: AccessRuntime);
|
|
213
|
-
new(): any;
|
|
214
|
-
create(data: unknown): Promise<any>;
|
|
215
|
-
find({ filter, select, sort, populate, limit, hardLimit, skip, lean }: FindProps): mongoose.Query<any[], any, {}, any, "find", {}>;
|
|
216
|
-
validateSort(sort: SortType, logError?: (msg: string, ...args: unknown[]) => void): boolean;
|
|
217
|
-
findOne({ filter, select, sort, populate, lean }: FindOneProps): mongoose.Query<any, any, {}, any, "findOne", {}>;
|
|
218
|
-
exists(filter: Filter): ReturnType<typeof Model.prototype.findOne> | null;
|
|
219
|
-
countDocuments(filter?: {}): mongoose.Query<number, any, {}, any, "countDocuments", {}>;
|
|
220
|
-
distinct(field: string, conditions?: {}): mongoose.Query<any[], any, {}, any, "distinct", {}>;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
27
|
declare class Service<TModel = unknown> extends Base<TModel> {
|
|
224
|
-
protected model:
|
|
28
|
+
protected model: any;
|
|
225
29
|
protected options: ModelRouterOptions<TModel>;
|
|
226
30
|
defaults: Defaults<TModel>;
|
|
227
31
|
protected baseFields: string[];
|
|
@@ -231,7 +35,9 @@ declare class Service<TModel = unknown> extends Base<TModel> {
|
|
|
231
35
|
select: string;
|
|
232
36
|
populate: unknown;
|
|
233
37
|
lean: boolean;
|
|
234
|
-
}):
|
|
38
|
+
}): any;
|
|
39
|
+
protected createModelAdapter(modelName: string): any;
|
|
40
|
+
protected getModelRouterOptions(modelName: string): ModelRouterOptions<TModel>;
|
|
235
41
|
private asServiceHookContext;
|
|
236
42
|
private beginOp;
|
|
237
43
|
private completeOp;
|
|
@@ -259,6 +65,7 @@ declare class Service<TModel = unknown> extends Base<TModel> {
|
|
|
259
65
|
protected authorizeDistinctField(field: string): Promise<ErrorResult | null>;
|
|
260
66
|
distinct(field: string, args?: DistinctArgs<TModel>): Promise<ListResult<unknown> | ErrorResult>;
|
|
261
67
|
count(filter: Filter<TModel>, access?: BaseFilterAccess): Promise<SingleResult<number> | ErrorResult>;
|
|
68
|
+
countByFieldValues(foreignField: string, values: unknown[], filter?: Filter<TModel>, access?: BaseFilterAccess): Promise<SingleResult<Map<string, Set<string>>> | ErrorResult>;
|
|
262
69
|
getDocPermissions(doc: unknown): Record<string, unknown>;
|
|
263
70
|
private resolveFindOneArgs;
|
|
264
71
|
private resolveFindOneOptions;
|
|
@@ -622,6 +429,14 @@ interface RequestComplexityOptions {
|
|
|
622
429
|
maxIncludeCount?: number;
|
|
623
430
|
maxSubQueryCount?: number;
|
|
624
431
|
maxBulkConcurrency?: number;
|
|
432
|
+
maxHookConcurrency?: number;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
declare class RequestConcurrencyScheduler {
|
|
436
|
+
readonly limit: number;
|
|
437
|
+
constructor(limit: number);
|
|
438
|
+
map<TInput, TOutput>(items: TInput[], iteratee: (item: TInput, index: number, scheduled: true) => Promise<TOutput>): Promise<TOutput[]>;
|
|
439
|
+
run<TOutput>(iteratee: (scheduled: true) => Promise<TOutput>): Promise<TOutput>;
|
|
625
440
|
}
|
|
626
441
|
|
|
627
442
|
type CrossResourceModelOperation = 'list' | 'read' | 'count';
|
|
@@ -636,7 +451,7 @@ declare class Base<TModel = unknown> {
|
|
|
636
451
|
genFilter(access?: BaseFilterAccess, filter?: Filter<TModel>): Promise<Filter<TModel>>;
|
|
637
452
|
getIdentifier(): string | null;
|
|
638
453
|
genIDFilter(id: string): Promise<Filter<TModel>>;
|
|
639
|
-
genPopulate(access?: SelectAccess, populate?: Populate | Populate[] | string | null): Promise<Populate[]>;
|
|
454
|
+
genPopulate(access?: SelectAccess, populate?: Populate | Populate[] | string | null, subPaths?: string[]): Promise<Populate[]>;
|
|
640
455
|
genSelect(access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise<string[]>;
|
|
641
456
|
genQuerySelect(access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise<string[]>;
|
|
642
457
|
addEmptyPermissions<T>(doc: T): T;
|
|
@@ -665,10 +480,18 @@ declare class Base<TModel = unknown> {
|
|
|
665
480
|
includeLocalFields: string[];
|
|
666
481
|
includePaths: string[];
|
|
667
482
|
};
|
|
483
|
+
private getForeignKeyValues;
|
|
484
|
+
private getForeignKey;
|
|
485
|
+
private buildForeignKeyIndex;
|
|
486
|
+
private getIndexedMatches;
|
|
487
|
+
private getIndexedCount;
|
|
488
|
+
private sanitizeIncludeArgs;
|
|
489
|
+
private assertIncludeForeignField;
|
|
668
490
|
protected includeDocs<TDoc>(docs: TDoc | TDoc[], include: Include | Include[]): Promise<TDoc | TDoc[]>;
|
|
491
|
+
private includeDocsRead;
|
|
669
492
|
private includeDocsList;
|
|
670
493
|
private includeDocsCount;
|
|
671
|
-
protected parseClientData<TValue>(filter: TValue): Promise<TValue>;
|
|
494
|
+
protected parseClientData<TValue>(filter: TValue, scheduler?: RequestConcurrencyScheduler, scheduled?: boolean): Promise<TValue>;
|
|
672
495
|
private handleSubQuery;
|
|
673
496
|
private handleDate;
|
|
674
497
|
}
|
|
@@ -684,6 +507,7 @@ declare class DataService<T> {
|
|
|
684
507
|
find<TSelect extends Projection | undefined = undefined>(filter: DataFilter<T>, args?: DataFindArgs<T, TSelect>, options?: DataFindOptions): Promise<ListResult<SelectedPublicOutput<T, TSelect>> | ErrorResult>;
|
|
685
508
|
decorate<TDoc>(doc: TDoc, access: DecorateAccess, context?: DataHookContext): Promise<TDoc>;
|
|
686
509
|
decorateAll<TDoc>(docs: TDoc[], access: DecorateAllAccess, context?: DataHookContext): Promise<TDoc[]>;
|
|
510
|
+
getRequestComplexity(): Required<RequestComplexityOptions>;
|
|
687
511
|
genAllowedFields(doc: unknown, access: SelectAccess, baseFields?: string[]): Promise<string[]>;
|
|
688
512
|
genFilter(access?: BaseFilterAccess, filter?: DataFilter<T>): Promise<DataFilter<T>>;
|
|
689
513
|
genIDFilter(id: string): Promise<DataFilter<T>>;
|
|
@@ -691,7 +515,6 @@ declare class DataService<T> {
|
|
|
691
515
|
genQuerySelect(access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise<string[]>;
|
|
692
516
|
pickAllowedFields<TDoc>(doc: TDoc, access: SelectAccess, baseFields?: string[]): Promise<TDoc>;
|
|
693
517
|
trimOutputFields<TDoc>(doc: TDoc, access: SelectAccess, baseFields?: string[]): Promise<TDoc>;
|
|
694
|
-
private validateSortFields;
|
|
695
518
|
}
|
|
696
519
|
|
|
697
520
|
type InternalModelHookContext = ModelHookContext & {
|
|
@@ -711,7 +534,7 @@ declare class Core {
|
|
|
711
534
|
genAllowedFields(modelName: string, doc: unknown, access: SelectAccess, baseFields?: string[]): Promise<string[]>;
|
|
712
535
|
pickAllowedFields<T>(modelName: string, doc: T, access: SelectAccess, baseFields?: string[]): Promise<T>;
|
|
713
536
|
genSelect(modelName: string, access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise<string[]>;
|
|
714
|
-
genPopulate(modelName: string, access?: SelectAccess | BaseFilterAccess, _populate?: Populate | Populate[] | string | null): Promise<(string | Populate)[]>;
|
|
537
|
+
genPopulate(modelName: string, access?: SelectAccess | BaseFilterAccess, _populate?: Populate | Populate[] | string | null, subPaths?: string[]): Promise<(string | Populate)[]>;
|
|
715
538
|
validate(modelName: string, allowedData: unknown, access: ValidateAccess, context: ModelHookContext): Promise<boolean | unknown[]>;
|
|
716
539
|
prepare<T>(modelName: string, allowedData: T, access: PrepareAccess, context: ModelHookContext): Promise<T>;
|
|
717
540
|
transform<T>(modelName: string, doc: T, access: TransformAccess, context: ModelHookContext): Promise<T>;
|
|
@@ -901,7 +724,7 @@ interface DataFindOneOptions {
|
|
|
901
724
|
}
|
|
902
725
|
interface DataFindArgs<T = unknown, TSelect extends Projection | undefined = Projection | undefined> {
|
|
903
726
|
select?: TSelect;
|
|
904
|
-
sort?:
|
|
727
|
+
sort?: Sort;
|
|
905
728
|
skip?: string | number;
|
|
906
729
|
limit?: string | number;
|
|
907
730
|
page?: string | number;
|
|
@@ -1536,6 +1359,11 @@ interface ModelRouterOptions<TModel = unknown> extends DefaultModelRouterOptions
|
|
|
1536
1359
|
defaults?: Defaults<TModel>;
|
|
1537
1360
|
}
|
|
1538
1361
|
interface DataRouterOptions<TData = unknown> {
|
|
1362
|
+
/**
|
|
1363
|
+
* In-memory records are owned by the router as an immutable configured snapshot.
|
|
1364
|
+
* Mutating this array or its records after configuration does not change served data;
|
|
1365
|
+
* use `setDataOption(name, 'data', nextRecords)` or `router.data(nextRecords)` to replace it.
|
|
1366
|
+
*/
|
|
1539
1367
|
data?: TData[];
|
|
1540
1368
|
listHardLimit?: number;
|
|
1541
1369
|
idParam?: string;
|
|
@@ -1701,4 +1529,4 @@ declare function fromIoTs<TValue = unknown>(decoder: IoTsDecoderLike<TValue>): R
|
|
|
1701
1529
|
declare function fromSuperstruct<TStruct, TOutput = unknown>(struct: TStruct, validate: SuperstructValidateLike): RequestSchemaValidator<TOutput>;
|
|
1702
1530
|
declare function fromVine<TValue = unknown>(validator: VineValidatorLike<TValue>): RequestSchemaValidator<TValue>;
|
|
1703
1531
|
|
|
1704
|
-
export { type Filter as $, type AccessRouterBaseRequest as A, type BaseFilterAccess as B, type Change as C, DATA_MIDDLEWARE as D, type DataFindOneOptions as E, type DataFindOptions as F, type DataHook as G, type DataHookContext as H, type DataIdentifierHook as I, type DataListHook as J, type DataOverrideFilterHook as K, type DataRequest as L, type DataRequestSchemas as M, type DataRouterOptions as N, type DecorateAccess as O, type DecorateAllAccess as P, type DeepFieldPath as Q, type DefaultModelRouterOptions as R, type Defaults as S, type DistinctArgs as T, type DistinctBody as U, type DocPermissionsAccess as V, type ErrorResult as W, type ExistsOptions as X, type ExtendedDataRouterOptions as Y, type ExtendedDefaultModelRouterOptions as Z, type ExtendedModelRouterOptions as _, type AccessRouterFieldKey as a, type RequestSchemaFailure as a$, FilterOperator as a0, type FindAccess as a1, type FindArgs as a2, type FindByIdArgs as a3, type FindByIdOptions as a4, type FindOneArgs as a5, type FindOneOptions as a6, type FindOptions as a7, type GlobalOptions as a8, type GlobalPermissionValue as a9, type ModelValidateHook as aA, PERMISSIONS as aB, PERMISSION_KEYS as aC, type PathValue as aD, type PermissionSchema as aE, type Populate as aF, type PopulateAccess as aG, type PrepareAccess as aH, type Projection as aI, type PublicCreateArgs as aJ, type PublicCreateOptions as aK, type PublicErrorResult as aL, type PublicListArgs as aM, type PublicListOptions as aN, type PublicListResult as aO, type PublicOutput as aP, type PublicReadArgs as aQ, type PublicReadOptions as aR, type PublicServiceResult as aS, type PublicSingleResult as aT, type PublicUpdateArgs as aU, type PublicUpdateOptions as aV, type PublicUpsertArgs as aW, type PublicUpsertOptions as aX, type ReadQueryInput as aY, type Request as aZ, type RequestSchemaAdapter as a_, type GuardHook as aa, type IdentifierHook as ab, type Include as ac, type IoTsContextEntryLike as ad, type IoTsDecodeErrorLike as ae, type IoTsDecoderLike as af, type JoiSchemaLike as ag, type JoiValidationErrorDetailLike as ah, type KeyValueProjection as ai, type ListQueryInput as aj, type ListResult as ak, MIDDLEWARE as al, type MaybePromise as am, type ModelBaseFilterHook as an, type ModelChangeHook as ao, type ModelDeleteHook as ap, type ModelDocPermissionsHook as aq, type ModelDocument as ar, type ModelDocumentHook as as, type ModelHook as at, type ModelHookContext as au, type ModelIdentifierHook as av, type ModelListHook as aw, type ModelOverrideFilterHook as ax, type ModelRequest as ay, type ModelRouterOptions as az, type AccessRouterLogger as b, type SubdocumentRecord as b$, type RequestSchemaIssue as b0, type RequestSchemaLike as b1, type RequestSchemaOptions as b2, type RequestSchemaResult as b3, type RequestSchemaSuccess as b4, type RequestSchemaValidator as b5, type RequestSchemas as b6, type RootDataListQueryEntry as b7, type RootDataOperation as b8, type RootDataReadByFilterQueryEntry as b9, type SelectedPublicOutput as bA, type ServiceResult as bB, type SingleResult as bC, type Sort as bD, type SortOrder as bE, type StandardSchemaFailure as bF, type StandardSchemaInferOutput as bG, type StandardSchemaIssue as bH, type StandardSchemaPathSegment as bI, type StandardSchemaResult as bJ, type StandardSchemaSuccess as bK, type StandardSchemaV1 as bL, StatusCodes as bM, type SubListBody as bN, type SubPopulate as bO, type SubQueryEntry as bP, type SubReadBody as bQ, type SubdocumentBulkRecord as bR, type SubdocumentBulkUpdateInput as bS, type SubdocumentCreateInput as bT, type SubdocumentCreateOptions as bU, type SubdocumentId as bV, type SubdocumentListOptions as bW, type SubdocumentName as bX, type SubdocumentParentArgs as bY, type SubdocumentParentOptions as bZ, type SubdocumentReadOptions as b_, type RootDataReadByIdQueryEntry as ba, type RootModelCountQueryEntry as bb, type RootModelCreateQueryEntry as bc, type RootModelDeleteQueryEntry as bd, type RootModelDistinctQueryEntry as be, type RootModelListQueryEntry as bf, type RootModelNewQueryEntry as bg, type RootModelOperation as bh, type RootModelReadByFilterQueryEntry as bi, type RootModelReadByIdQueryEntry as bj, type RootModelSubBulkUpdateQueryEntry as bk, type RootModelSubCreateQueryEntry as bl, type RootModelSubDeleteQueryEntry as bm, type RootModelSubListQueryEntry as bn, type RootModelSubReadQueryEntry as bo, type RootModelSubUpdateQueryEntry as bp, type RootModelUpdateQueryEntry as bq, type RootModelUpsertQueryEntry as br, type RootOperationResult as bs, type RootQueryEntry as bt, type RootRouterOptions as bu, type RootSubOperation as bv, type RootTarget as bw, type RouteGuardAccess as bx, type SelectAccess as by, type SelectedPopulatedPublicOutput as bz, type AccessRouterRequest as c, type SuperstructFailureLike as c0, type SuperstructValidateLike as c1, type Task as c2, type TransformAccess as c3, type TypedFilter as c4, type UpdateByIdArgs as c5, type UpdateByIdOptions as c6, type UpdateOneArgs as c7, type UpdateOneOptions as c8, type UpdateQueryInput as c9, fromZod as cA, parseBody as cB, parseBodyWithSchema as cC, parseNestedBodyWithSchema as cD, parsePathParam as cE, parseQuery as cF,
|
|
1532
|
+
export { type Filter as $, type AccessRouterBaseRequest as A, type BaseFilterAccess as B, type Change as C, DATA_MIDDLEWARE as D, type DataFindOneOptions as E, type DataFindOptions as F, type DataHook as G, type DataHookContext as H, type DataIdentifierHook as I, type DataListHook as J, type DataOverrideFilterHook as K, type DataRequest as L, type DataRequestSchemas as M, type DataRouterOptions as N, type DecorateAccess as O, type DecorateAllAccess as P, type DeepFieldPath as Q, type DefaultModelRouterOptions as R, type Defaults as S, type DistinctArgs as T, type DistinctBody as U, type DocPermissionsAccess as V, type ErrorResult as W, type ExistsOptions as X, type ExtendedDataRouterOptions as Y, type ExtendedDefaultModelRouterOptions as Z, type ExtendedModelRouterOptions as _, type AccessRouterFieldKey as a, type RequestSchemaFailure as a$, FilterOperator as a0, type FindAccess as a1, type FindArgs as a2, type FindByIdArgs as a3, type FindByIdOptions as a4, type FindOneArgs as a5, type FindOneOptions as a6, type FindOptions as a7, type GlobalOptions as a8, type GlobalPermissionValue as a9, type ModelValidateHook as aA, PERMISSIONS as aB, PERMISSION_KEYS as aC, type PathValue as aD, type PermissionSchema as aE, type Populate as aF, type PopulateAccess as aG, type PrepareAccess as aH, type Projection as aI, type PublicCreateArgs as aJ, type PublicCreateOptions as aK, type PublicErrorResult as aL, type PublicListArgs as aM, type PublicListOptions as aN, type PublicListResult as aO, type PublicOutput as aP, type PublicReadArgs as aQ, type PublicReadOptions as aR, type PublicServiceResult as aS, type PublicSingleResult as aT, type PublicUpdateArgs as aU, type PublicUpdateOptions as aV, type PublicUpsertArgs as aW, type PublicUpsertOptions as aX, type ReadQueryInput as aY, type Request as aZ, type RequestSchemaAdapter as a_, type GuardHook as aa, type IdentifierHook as ab, type Include as ac, type IoTsContextEntryLike as ad, type IoTsDecodeErrorLike as ae, type IoTsDecoderLike as af, type JoiSchemaLike as ag, type JoiValidationErrorDetailLike as ah, type KeyValueProjection as ai, type ListQueryInput as aj, type ListResult as ak, MIDDLEWARE as al, type MaybePromise as am, type ModelBaseFilterHook as an, type ModelChangeHook as ao, type ModelDeleteHook as ap, type ModelDocPermissionsHook as aq, type ModelDocument as ar, type ModelDocumentHook as as, type ModelHook as at, type ModelHookContext as au, type ModelIdentifierHook as av, type ModelListHook as aw, type ModelOverrideFilterHook as ax, type ModelRequest as ay, type ModelRouterOptions as az, type AccessRouterLogger as b, type SubdocumentRecord as b$, type RequestSchemaIssue as b0, type RequestSchemaLike as b1, type RequestSchemaOptions as b2, type RequestSchemaResult as b3, type RequestSchemaSuccess as b4, type RequestSchemaValidator as b5, type RequestSchemas as b6, type RootDataListQueryEntry as b7, type RootDataOperation as b8, type RootDataReadByFilterQueryEntry as b9, type SelectedPublicOutput as bA, type ServiceResult as bB, type SingleResult as bC, type Sort as bD, type SortOrder as bE, type StandardSchemaFailure as bF, type StandardSchemaInferOutput as bG, type StandardSchemaIssue as bH, type StandardSchemaPathSegment as bI, type StandardSchemaResult as bJ, type StandardSchemaSuccess as bK, type StandardSchemaV1 as bL, StatusCodes as bM, type SubListBody as bN, type SubPopulate as bO, type SubQueryEntry as bP, type SubReadBody as bQ, type SubdocumentBulkRecord as bR, type SubdocumentBulkUpdateInput as bS, type SubdocumentCreateInput as bT, type SubdocumentCreateOptions as bU, type SubdocumentId as bV, type SubdocumentListOptions as bW, type SubdocumentName as bX, type SubdocumentParentArgs as bY, type SubdocumentParentOptions as bZ, type SubdocumentReadOptions as b_, type RootDataReadByIdQueryEntry as ba, type RootModelCountQueryEntry as bb, type RootModelCreateQueryEntry as bc, type RootModelDeleteQueryEntry as bd, type RootModelDistinctQueryEntry as be, type RootModelListQueryEntry as bf, type RootModelNewQueryEntry as bg, type RootModelOperation as bh, type RootModelReadByFilterQueryEntry as bi, type RootModelReadByIdQueryEntry as bj, type RootModelSubBulkUpdateQueryEntry as bk, type RootModelSubCreateQueryEntry as bl, type RootModelSubDeleteQueryEntry as bm, type RootModelSubListQueryEntry as bn, type RootModelSubReadQueryEntry as bo, type RootModelSubUpdateQueryEntry as bp, type RootModelUpdateQueryEntry as bq, type RootModelUpsertQueryEntry as br, type RootOperationResult as bs, type RootQueryEntry as bt, type RootRouterOptions as bu, type RootSubOperation as bv, type RootTarget as bw, type RouteGuardAccess as bx, type SelectAccess as by, type SelectedPopulatedPublicOutput as bz, type AccessRouterRequest as c, type SuperstructFailureLike as c0, type SuperstructValidateLike as c1, type Task as c2, type TransformAccess as c3, type TypedFilter as c4, type UpdateByIdArgs as c5, type UpdateByIdOptions as c6, type UpdateOneArgs as c7, type UpdateOneOptions as c8, type UpdateQueryInput as c9, fromZod as cA, parseBody as cB, parseBodyWithSchema as cC, parseNestedBodyWithSchema as cD, parsePathParam as cE, parseQuery as cF, DataService as cG, Service as cH, PublicService as cI, type AccessRouterPermissionMap as cJ, type AccessRouterPermissions as cK, type Permissions as cL, type UpsertArgs as ca, type UpsertOptions as cb, type UpsertQueryInput as cc, type ValibotIssueLike as cd, type ValibotPathItemLike as ce, type ValibotSafeParseLike as cf, type ValibotSafeParseResult as cg, type ValidateAccess as ch, type ValidateRule as ci, type Validation as cj, type ValidationError as ck, type VineValidationErrorLike as cl, type VineValidationMessageLike as cm, type VineValidatorLike as cn, type YupSchemaLike as co, type YupValidationErrorLike as cp, defineRequestSchema as cq, fromAjv as cr, fromArkType as cs, fromIoTs as ct, fromJoi as cu, fromStandardSchema as cv, fromSuperstruct as cw, fromValibot as cx, fromVine as cy, fromYup as cz, 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, Codes as q, type CountBody as r, type CreateArgs as s, type CreateOptions as t, type CreateQueryInput as u, CustomHeaders as v, type DataBaseFilterHook as w, type DataFilter as x, type DataFindArgs as y, type DataFindOneArgs as z };
|
package/processors.d.mts
CHANGED
|
@@ -14,15 +14,14 @@ interface ProcessCopy {
|
|
|
14
14
|
* `src: 'pear.items'` -> depopulate `docObject.pear.items`
|
|
15
15
|
*
|
|
16
16
|
* Empty strings are treated as safe no-ops. Unsafe segments
|
|
17
|
-
* (`__proto__`, `prototype`, `constructor`) throw a descriptive
|
|
18
|
-
* `ProcessorPathError`.
|
|
17
|
+
* (`__proto__`, `prototype`, `constructor`) throw a descriptive `Error`.
|
|
19
18
|
*/
|
|
20
19
|
src: string;
|
|
21
20
|
/**
|
|
22
21
|
* Dotted destination path on `docObject` where the moved objects will be
|
|
23
22
|
* written. Unsafe segments (`__proto__`, `prototype`, `constructor`)
|
|
24
|
-
* throw a descriptive `
|
|
25
|
-
*
|
|
23
|
+
* throw a descriptive `Error`. Empty and missing destinations are safe
|
|
24
|
+
* no-ops.
|
|
26
25
|
*/
|
|
27
26
|
dest: string;
|
|
28
27
|
}
|
|
@@ -42,12 +41,21 @@ interface CopyAndDepopulateOptions {
|
|
|
42
41
|
* original populated value. Defaults to `'_id'`.
|
|
43
42
|
*
|
|
44
43
|
* For nested populated arrays, every leaf record must carry this field.
|
|
45
|
-
* Records missing the id field throw a descriptive `
|
|
44
|
+
* Records missing the id field throw a descriptive `Error`.
|
|
46
45
|
* Primitive array members (non-record scalars) cannot be depopulated and
|
|
47
46
|
* are left in place as a safe no-op.
|
|
48
47
|
*/
|
|
49
48
|
idField?: string;
|
|
50
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Conservative default output for {@link copyAndDepopulate}.
|
|
52
|
+
*
|
|
53
|
+
* The exact transformed shape depends on runtime path strings, so the default
|
|
54
|
+
* type intentionally does not claim that populated input leaves still have
|
|
55
|
+
* their original object shape. Provide an explicit output type argument when
|
|
56
|
+
* the operation set is known by the caller.
|
|
57
|
+
*/
|
|
58
|
+
type CopyAndDepopulateOutput = Record<string, unknown>;
|
|
51
59
|
/**
|
|
52
60
|
* Hardened processor that relocates populated documents to a destination
|
|
53
61
|
* path and replaces the original location with their proposed
|
|
@@ -75,8 +83,12 @@ interface CopyAndDepopulateOptions {
|
|
|
75
83
|
* `Object.prototype` or any object's prototype.
|
|
76
84
|
* - Empty `src` or `dest` strings are safe no-ops.
|
|
77
85
|
*
|
|
78
|
-
* @typeParam
|
|
86
|
+
* @typeParam Output - Object shape produced by the depopulation. Defaults to a
|
|
87
|
+
* conservative record because `src` and `dest` are runtime paths.
|
|
88
|
+
*
|
|
89
|
+
* @throws Error when an operation path contains `__proto__`, `prototype`, or
|
|
90
|
+
* `constructor`, or when a populated record is missing the configured id field.
|
|
79
91
|
*/
|
|
80
|
-
declare const copyAndDepopulate: <
|
|
92
|
+
declare const copyAndDepopulate: <Output extends object = CopyAndDepopulateOutput>(docObject: object, operations: ProcessCopy[], options?: CopyAndDepopulateOptions) => Output;
|
|
81
93
|
|
|
82
|
-
export { type CopyAndDepopulateOptions, type ProcessCopy, copyAndDepopulate };
|
|
94
|
+
export { type CopyAndDepopulateOptions, type CopyAndDepopulateOutput, type ProcessCopy, copyAndDepopulate };
|
package/processors.d.ts
CHANGED
|
@@ -14,15 +14,14 @@ interface ProcessCopy {
|
|
|
14
14
|
* `src: 'pear.items'` -> depopulate `docObject.pear.items`
|
|
15
15
|
*
|
|
16
16
|
* Empty strings are treated as safe no-ops. Unsafe segments
|
|
17
|
-
* (`__proto__`, `prototype`, `constructor`) throw a descriptive
|
|
18
|
-
* `ProcessorPathError`.
|
|
17
|
+
* (`__proto__`, `prototype`, `constructor`) throw a descriptive `Error`.
|
|
19
18
|
*/
|
|
20
19
|
src: string;
|
|
21
20
|
/**
|
|
22
21
|
* Dotted destination path on `docObject` where the moved objects will be
|
|
23
22
|
* written. Unsafe segments (`__proto__`, `prototype`, `constructor`)
|
|
24
|
-
* throw a descriptive `
|
|
25
|
-
*
|
|
23
|
+
* throw a descriptive `Error`. Empty and missing destinations are safe
|
|
24
|
+
* no-ops.
|
|
26
25
|
*/
|
|
27
26
|
dest: string;
|
|
28
27
|
}
|
|
@@ -42,12 +41,21 @@ interface CopyAndDepopulateOptions {
|
|
|
42
41
|
* original populated value. Defaults to `'_id'`.
|
|
43
42
|
*
|
|
44
43
|
* For nested populated arrays, every leaf record must carry this field.
|
|
45
|
-
* Records missing the id field throw a descriptive `
|
|
44
|
+
* Records missing the id field throw a descriptive `Error`.
|
|
46
45
|
* Primitive array members (non-record scalars) cannot be depopulated and
|
|
47
46
|
* are left in place as a safe no-op.
|
|
48
47
|
*/
|
|
49
48
|
idField?: string;
|
|
50
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Conservative default output for {@link copyAndDepopulate}.
|
|
52
|
+
*
|
|
53
|
+
* The exact transformed shape depends on runtime path strings, so the default
|
|
54
|
+
* type intentionally does not claim that populated input leaves still have
|
|
55
|
+
* their original object shape. Provide an explicit output type argument when
|
|
56
|
+
* the operation set is known by the caller.
|
|
57
|
+
*/
|
|
58
|
+
type CopyAndDepopulateOutput = Record<string, unknown>;
|
|
51
59
|
/**
|
|
52
60
|
* Hardened processor that relocates populated documents to a destination
|
|
53
61
|
* path and replaces the original location with their proposed
|
|
@@ -75,8 +83,12 @@ interface CopyAndDepopulateOptions {
|
|
|
75
83
|
* `Object.prototype` or any object's prototype.
|
|
76
84
|
* - Empty `src` or `dest` strings are safe no-ops.
|
|
77
85
|
*
|
|
78
|
-
* @typeParam
|
|
86
|
+
* @typeParam Output - Object shape produced by the depopulation. Defaults to a
|
|
87
|
+
* conservative record because `src` and `dest` are runtime paths.
|
|
88
|
+
*
|
|
89
|
+
* @throws Error when an operation path contains `__proto__`, `prototype`, or
|
|
90
|
+
* `constructor`, or when a populated record is missing the configured id field.
|
|
79
91
|
*/
|
|
80
|
-
declare const copyAndDepopulate: <
|
|
92
|
+
declare const copyAndDepopulate: <Output extends object = CopyAndDepopulateOutput>(docObject: object, operations: ProcessCopy[], options?: CopyAndDepopulateOptions) => Output;
|
|
81
93
|
|
|
82
|
-
export { type CopyAndDepopulateOptions, type ProcessCopy, copyAndDepopulate };
|
|
94
|
+
export { type CopyAndDepopulateOptions, type CopyAndDepopulateOutput, type ProcessCopy, copyAndDepopulate };
|