@web-ts-toolkit/access-router 0.4.0 → 0.5.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 +59 -7
- package/advanced.d.mts +38 -39
- package/advanced.d.ts +38 -39
- package/advanced.js +5 -5
- package/advanced.mjs +5 -4
- package/index.d.mts +81 -3
- package/index.d.ts +81 -3
- package/index.js +1158 -543
- package/index.mjs +988 -383
- package/package.json +12 -8
- package/{parsers-CsyGHYQR.d.mts → parsers-Ce1grlLx.d.mts} +16 -14
- package/{parsers-CsyGHYQR.d.ts → parsers-Ce1grlLx.d.ts} +16 -14
package/index.d.ts
CHANGED
|
@@ -1,11 +1,58 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
2
|
import { Response, NextFunction, Router } from 'express';
|
|
3
|
-
import { a6 as GlobalOptions, P as DefaultModelRouterOptions, X as ExtendedDefaultModelRouterOptions, aw as ModelRouterOptions, Y as ExtendedModelRouterOptions, L as DataRouterOptions, W as ExtendedDataRouterOptions, A as AccessRouterBaseRequest, a8 as GuardHook, av as ModelRequest, J as DataRequest,
|
|
4
|
-
export {
|
|
3
|
+
import { a6 as GlobalOptions, P as DefaultModelRouterOptions, X as ExtendedDefaultModelRouterOptions, aw as ModelRouterOptions, Y as ExtendedModelRouterOptions, L as DataRouterOptions, W as ExtendedDataRouterOptions, A as AccessRouterBaseRequest, a8 as GuardHook, av as ModelRequest, J as DataRequest, cm as DataService, cn as Model, co as Service, cp as PublicService, b$ as Validation, bl as RootRouterOptions } from './parsers-Ce1grlLx.js';
|
|
4
|
+
export { cq as AccessRouterPermissionMap, cr as AccessRouterPermissions, c as AccessRouterRequest, d as AccessRouterRequestExtensions, l as AjvErrorObjectLike, m as AjvValidatorLike, n as ArkTypeErrorsLike, o as ArkTypeLike, ab as IoTsContextEntryLike, ac as IoTsDecodeErrorLike, ad as IoTsDecoderLike, ae as JoiSchemaLike, af as JoiValidationErrorDetailLike, cs as Permissions, aR as RequestSchemaAdapter, aS as RequestSchemaFailure, aT as RequestSchemaIssue, aU as RequestSchemaLike, aV as RequestSchemaOptions, aW as RequestSchemaResult, aX as RequestSchemaSuccess, aY as RequestSchemaValidator, bw as StandardSchemaFailure, bx as StandardSchemaInferOutput, by as StandardSchemaIssue, bz as StandardSchemaPathSegment, bA as StandardSchemaResult, bB as StandardSchemaSuccess, bC as StandardSchemaV1, bI as SuperstructFailureLike, bJ as SuperstructValidateLike, bV as ValibotIssueLike, bW as ValibotPathItemLike, bX as ValibotSafeParseLike, bY as ValibotSafeParseResult, c1 as VineValidationErrorLike, c2 as VineValidationMessageLike, c3 as VineValidatorLike, c4 as YupSchemaLike, c5 as YupValidationErrorLike, c6 as defineRequestSchema, c7 as fromAjv, c8 as fromArkType, c9 as fromIoTs, ca as fromJoi, cb as fromStandardSchema, cc as fromSuperstruct, cd as fromValibot, ce as fromVine, cf as fromYup, cg as fromZod } from './parsers-Ce1grlLx.js';
|
|
5
5
|
import JsonRouter from '@web-ts-toolkit/express-json-router';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'deep-diff';
|
|
8
8
|
|
|
9
|
+
type OpenApiMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
10
|
+
type OpenApiSchema = Record<string, unknown>;
|
|
11
|
+
type OpenApiSchemaSource = unknown;
|
|
12
|
+
type OpenApiParameter = {
|
|
13
|
+
name: string;
|
|
14
|
+
in: 'path' | 'query';
|
|
15
|
+
required?: boolean;
|
|
16
|
+
description?: string;
|
|
17
|
+
schema?: OpenApiSchema;
|
|
18
|
+
};
|
|
19
|
+
type OpenApiResponse = {
|
|
20
|
+
description: string;
|
|
21
|
+
content?: Record<string, {
|
|
22
|
+
schema: OpenApiSchema;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
type OpenApiResponses = Record<string, OpenApiResponse>;
|
|
26
|
+
type OpenApiRouteDescriptor = {
|
|
27
|
+
method: OpenApiMethod;
|
|
28
|
+
path: string;
|
|
29
|
+
operationId?: string;
|
|
30
|
+
summary?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
tags?: string[];
|
|
33
|
+
acl?: string;
|
|
34
|
+
deprecated?: boolean;
|
|
35
|
+
query?: OpenApiSchemaSource;
|
|
36
|
+
body?: OpenApiSchemaSource;
|
|
37
|
+
pathParams?: Record<string, OpenApiSchemaSource>;
|
|
38
|
+
responses?: OpenApiResponses;
|
|
39
|
+
};
|
|
40
|
+
type OpenApiDocumentOptions = {
|
|
41
|
+
title: string;
|
|
42
|
+
version: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
servers?: Array<{
|
|
45
|
+
url: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
}>;
|
|
48
|
+
};
|
|
49
|
+
type OpenApiRouterOptions = Partial<OpenApiDocumentOptions> & {
|
|
50
|
+
jsonPath?: string;
|
|
51
|
+
docsPath?: string | false;
|
|
52
|
+
swaggerUiCssUrl?: string;
|
|
53
|
+
swaggerUiBundleUrl?: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
9
56
|
declare class AccessRuntime {
|
|
10
57
|
private readonly globalOptions;
|
|
11
58
|
private readonly defaultModelOptions;
|
|
@@ -15,6 +62,30 @@ declare class AccessRuntime {
|
|
|
15
62
|
private readonly modelRefs;
|
|
16
63
|
private readonly modelSubs;
|
|
17
64
|
private readonly modelAtts;
|
|
65
|
+
private readonly openApiRegistry;
|
|
66
|
+
registerOpenApiRoute(route: OpenApiRouteDescriptor): void;
|
|
67
|
+
getOpenApiRoutes(): OpenApiRouteDescriptor[];
|
|
68
|
+
getOpenApiSpec(info: OpenApiDocumentOptions): {
|
|
69
|
+
openapi: string;
|
|
70
|
+
info: Omit<OpenApiDocumentOptions, "servers">;
|
|
71
|
+
servers?: OpenApiDocumentOptions["servers"];
|
|
72
|
+
paths: Record<string, Record<string, {
|
|
73
|
+
[key: `x-${string}`]: unknown;
|
|
74
|
+
operationId?: string;
|
|
75
|
+
summary?: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
tags?: string[];
|
|
78
|
+
deprecated?: boolean;
|
|
79
|
+
parameters?: OpenApiParameter[];
|
|
80
|
+
requestBody?: {
|
|
81
|
+
required?: boolean;
|
|
82
|
+
content: Record<string, {
|
|
83
|
+
schema: OpenApiSchema;
|
|
84
|
+
}>;
|
|
85
|
+
};
|
|
86
|
+
responses: OpenApiResponses;
|
|
87
|
+
}>>;
|
|
88
|
+
};
|
|
18
89
|
setGlobalOptions(options: GlobalOptions): void;
|
|
19
90
|
setGlobalOption<K extends keyof GlobalOptions>(key: K, value: GlobalOptions[K]): void;
|
|
20
91
|
getGlobalOptions(): GlobalOptions;
|
|
@@ -76,6 +147,7 @@ declare class DataRouter<TData = unknown> {
|
|
|
76
147
|
private getRequestSchema;
|
|
77
148
|
getService(req: DataRequest): DataService<TData>;
|
|
78
149
|
private assertAllowed;
|
|
150
|
+
private registerOpenApiRoute;
|
|
79
151
|
private setCollectionRoutes;
|
|
80
152
|
private setDocumentRoutes;
|
|
81
153
|
set<K extends keyof DataRouterOptions<TData>>(key: K, value: DataRouterOptions<TData>[K]): this;
|
|
@@ -112,6 +184,7 @@ declare class ModelRouter<TModel = unknown> {
|
|
|
112
184
|
getService(req: ModelRequest): Service<TModel>;
|
|
113
185
|
getPublicService(req: ModelRequest): PublicService<TModel>;
|
|
114
186
|
private assertAllowed;
|
|
187
|
+
private registerOpenApiRoute;
|
|
115
188
|
private setCollectionRoutes;
|
|
116
189
|
private setDocumentRoutes;
|
|
117
190
|
private setSubDocumentRoutes;
|
|
@@ -251,6 +324,7 @@ declare class RootRouter {
|
|
|
251
324
|
private readonly modelOperations;
|
|
252
325
|
private readonly dataOperations;
|
|
253
326
|
constructor(options?: RootRouterOptions, runtime?: AccessRuntime);
|
|
327
|
+
private registerOpenApiRoute;
|
|
254
328
|
private wrapResult;
|
|
255
329
|
private hasTarget;
|
|
256
330
|
private isAllowed;
|
|
@@ -261,6 +335,8 @@ declare class RootRouter {
|
|
|
261
335
|
get routes(): Router;
|
|
262
336
|
}
|
|
263
337
|
|
|
338
|
+
declare function createOpenApiRouter(runtime: AccessRuntime, options?: OpenApiRouterOptions): Router;
|
|
339
|
+
|
|
264
340
|
type AccessRouterInstance = ModelRouter<any> | DataRouter<any> | RootRouter;
|
|
265
341
|
type CombinedRouteInput = Router | AccessRouterInstance;
|
|
266
342
|
declare function combineRoutes(...inputs: CombinedRouteInput[]): Router;
|
|
@@ -296,6 +372,7 @@ type CreateRouter = {
|
|
|
296
372
|
type CreateDataRouter = {
|
|
297
373
|
<TData>(dataName: string, options: DataRouterOptions<TData>): DataRouter<TData>;
|
|
298
374
|
};
|
|
375
|
+
type CreateRuntimeOpenApiRouter = (options?: OpenApiRouterOptions) => Router;
|
|
299
376
|
type WttSet = {
|
|
300
377
|
<K extends keyof GlobalOptions>(key: K, value: GlobalOptions[K]): void;
|
|
301
378
|
(options: {
|
|
@@ -306,6 +383,7 @@ interface Wtt {
|
|
|
306
383
|
runtime: AccessRuntime;
|
|
307
384
|
createRouter: CreateRouter;
|
|
308
385
|
createDataRouter: CreateDataRouter;
|
|
386
|
+
createOpenApiRouter: CreateRuntimeOpenApiRouter;
|
|
309
387
|
combineRoutes: typeof combineRoutes;
|
|
310
388
|
set: WttSet;
|
|
311
389
|
setGlobalOptions: typeof setGlobalOptions;
|
|
@@ -330,4 +408,4 @@ type AccessRuntimeApi = typeof macl & Wtt;
|
|
|
330
408
|
declare function createAccessRuntime(): AccessRuntimeApi;
|
|
331
409
|
declare const acl: AccessRuntimeApi;
|
|
332
410
|
|
|
333
|
-
export { AccessRuntime, type AccessRuntimeApi, type CombinedRouteInput, DataRouter, DataRouterOptions, GlobalOptions, ModelRouter, ModelRouterOptions, RootRouter, RootRouterOptions, acl, combineRoutes, createAccessRuntime, acl as default, getDefaultModelOption, getDefaultModelOptions, getGlobalOption, getGlobalOptions, getModelJsonSchema, getModelNames, getModelOption, getModelOptions, guard, permissionsPlugin, setDefaultModelOption, setDefaultModelOptions, setGlobalOption, setGlobalOptions, setModelOption, setModelOptions };
|
|
411
|
+
export { AccessRuntime, type AccessRuntimeApi, type CombinedRouteInput, DataRouter, DataRouterOptions, GlobalOptions, ModelRouter, ModelRouterOptions, type OpenApiDocumentOptions, type OpenApiMethod, type OpenApiRouteDescriptor, type OpenApiRouterOptions, RootRouter, RootRouterOptions, acl, combineRoutes, createAccessRuntime, createOpenApiRouter, acl as default, getDefaultModelOption, getDefaultModelOptions, getGlobalOption, getGlobalOptions, getModelJsonSchema, getModelNames, getModelOption, getModelOptions, guard, permissionsPlugin, setDefaultModelOption, setDefaultModelOptions, setGlobalOption, setGlobalOptions, setModelOption, setModelOptions };
|