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