exisjs 0.7.6 → 0.7.8
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/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +12 -0
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/clean.d.ts +5 -0
- package/dist/cli/commands/clean.d.ts.map +1 -0
- package/dist/cli/commands/clean.js +30 -0
- package/dist/cli/commands/clean.js.map +1 -0
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/dev.js +15 -1
- package/dist/cli/commands/dev.js.map +1 -1
- package/dist/cli/commands/generate.d.ts +6 -1
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +57 -2
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/index.js +16 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/manifest.d.ts +1 -0
- package/dist/cli/manifest.d.ts.map +1 -1
- package/dist/cli/manifest.js +161 -23
- package/dist/cli/manifest.js.map +1 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +9 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/types.d.ts +4 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/cron/expressions.d.ts +45 -0
- package/dist/cron/expressions.d.ts.map +1 -0
- package/dist/cron/expressions.js +87 -0
- package/dist/cron/expressions.js.map +1 -0
- package/dist/cron/index.d.ts +6 -0
- package/dist/cron/index.d.ts.map +1 -0
- package/dist/cron/index.js +22 -0
- package/dist/cron/index.js.map +1 -0
- package/dist/cron/job.d.ts +50 -0
- package/dist/cron/job.d.ts.map +1 -0
- package/dist/cron/job.js +247 -0
- package/dist/cron/job.js.map +1 -0
- package/dist/cron/manager.d.ts +105 -0
- package/dist/cron/manager.d.ts.map +1 -0
- package/dist/cron/manager.js +245 -0
- package/dist/cron/manager.js.map +1 -0
- package/dist/cron/parser.d.ts +22 -0
- package/dist/cron/parser.d.ts.map +1 -0
- package/dist/cron/parser.js +269 -0
- package/dist/cron/parser.js.map +1 -0
- package/dist/cron/types.d.ts +76 -0
- package/dist/cron/types.d.ts.map +1 -0
- package/dist/cron/types.js +3 -0
- package/dist/cron/types.js.map +1 -0
- package/dist/decorators/constants.d.ts +2 -0
- package/dist/decorators/constants.d.ts.map +1 -1
- package/dist/decorators/constants.js +3 -1
- package/dist/decorators/constants.js.map +1 -1
- package/dist/decorators/core.d.ts +29 -11
- package/dist/decorators/core.d.ts.map +1 -1
- package/dist/decorators/core.js +49 -11
- package/dist/decorators/core.js.map +1 -1
- package/dist/decorators/cron.d.ts +57 -0
- package/dist/decorators/cron.d.ts.map +1 -0
- package/dist/decorators/cron.js +143 -0
- package/dist/decorators/cron.js.map +1 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.d.ts.map +1 -1
- package/dist/decorators/index.js +2 -0
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/params.d.ts +97 -2
- package/dist/decorators/params.d.ts.map +1 -1
- package/dist/decorators/params.js +94 -2
- package/dist/decorators/params.js.map +1 -1
- package/dist/decorators/routing.d.ts +81 -16
- package/dist/decorators/routing.d.ts.map +1 -1
- package/dist/decorators/routing.js +81 -16
- package/dist/decorators/routing.js.map +1 -1
- package/dist/docs/content/cron.mdx +196 -0
- package/dist/docs/content/errors.mdx +58 -9
- package/dist/docs/content/structure.mdx +1 -1
- package/dist/docs/content/swagger.mdx +289 -0
- package/dist/docs/reference/cron.mdx +300 -0
- package/dist/docs/reference/decorators.mdx +8 -0
- package/dist/docs/reference/error.mdx +44 -0
- package/dist/docs/reference/swagger.mdx +226 -0
- package/dist/docs/reference/validator.mdx +1 -1
- package/dist/router/boundary.d.ts +24 -2
- package/dist/router/boundary.d.ts.map +1 -1
- package/dist/router/boundary.js +24 -2
- package/dist/router/boundary.js.map +1 -1
- package/dist/router/controller-registrar.d.ts.map +1 -1
- package/dist/router/controller-registrar.js +52 -3
- package/dist/router/controller-registrar.js.map +1 -1
- package/dist/router/route-builder.d.ts +196 -33
- package/dist/router/route-builder.d.ts.map +1 -1
- package/dist/router/route-builder.js +171 -11
- package/dist/router/route-builder.js.map +1 -1
- package/dist/router/route-scanner.d.ts +6 -0
- package/dist/router/route-scanner.d.ts.map +1 -1
- package/dist/router/route-scanner.js +69 -812
- package/dist/router/route-scanner.js.map +1 -1
- package/dist/router/router.d.ts.map +1 -1
- package/dist/router/router.js +27 -0
- package/dist/router/router.js.map +1 -1
- package/dist/router/scanner/boundary-loader.d.ts +18 -0
- package/dist/router/scanner/boundary-loader.d.ts.map +1 -0
- package/dist/router/scanner/boundary-loader.js +539 -0
- package/dist/router/scanner/boundary-loader.js.map +1 -0
- package/dist/router/scanner/cron-mounter.d.ts +15 -0
- package/dist/router/scanner/cron-mounter.d.ts.map +1 -0
- package/dist/router/scanner/cron-mounter.js +216 -0
- package/dist/router/scanner/cron-mounter.js.map +1 -0
- package/dist/router/scanner/error-mounter.d.ts +14 -0
- package/dist/router/scanner/error-mounter.d.ts.map +1 -0
- package/dist/router/scanner/error-mounter.js +200 -0
- package/dist/router/scanner/error-mounter.js.map +1 -0
- package/dist/router/scanner/fs-scanner.d.ts +25 -0
- package/dist/router/scanner/fs-scanner.d.ts.map +1 -0
- package/dist/router/scanner/fs-scanner.js +115 -0
- package/dist/router/scanner/fs-scanner.js.map +1 -0
- package/dist/router/scanner/functional-compiler.d.ts +9 -0
- package/dist/router/scanner/functional-compiler.d.ts.map +1 -0
- package/dist/router/scanner/functional-compiler.js +233 -0
- package/dist/router/scanner/functional-compiler.js.map +1 -0
- package/dist/router/scanner/index.d.ts +9 -0
- package/dist/router/scanner/index.d.ts.map +1 -0
- package/dist/router/scanner/index.js +19 -0
- package/dist/router/scanner/index.js.map +1 -0
- package/dist/router/types.d.ts +15 -0
- package/dist/router/types.d.ts.map +1 -1
- package/dist/server/app.d.ts +2 -0
- package/dist/server/app.d.ts.map +1 -1
- package/dist/server/app.js +3 -0
- package/dist/server/app.js.map +1 -1
- package/dist/server/helpers/body-parser.d.ts +18 -0
- package/dist/server/helpers/body-parser.d.ts.map +1 -0
- package/dist/server/helpers/body-parser.js +246 -0
- package/dist/server/helpers/body-parser.js.map +1 -0
- package/dist/server/helpers/cookie.d.ts +4 -0
- package/dist/server/helpers/cookie.d.ts.map +1 -0
- package/dist/server/helpers/cookie.js +61 -0
- package/dist/server/helpers/cookie.js.map +1 -0
- package/dist/server/helpers/etag.d.ts +3 -0
- package/dist/server/helpers/etag.d.ts.map +1 -0
- package/dist/server/helpers/etag.js +25 -0
- package/dist/server/helpers/etag.js.map +1 -0
- package/dist/server/helpers/index.d.ts +6 -0
- package/dist/server/helpers/index.d.ts.map +1 -0
- package/dist/server/helpers/index.js +21 -0
- package/dist/server/helpers/index.js.map +1 -0
- package/dist/server/helpers/ip.d.ts +9 -0
- package/dist/server/helpers/ip.d.ts.map +1 -0
- package/dist/server/helpers/ip.js +62 -0
- package/dist/server/helpers/ip.js.map +1 -0
- package/dist/server/helpers/stream.d.ts +4 -0
- package/dist/server/helpers/stream.d.ts.map +1 -0
- package/dist/server/helpers/stream.js +193 -0
- package/dist/server/helpers/stream.js.map +1 -0
- package/dist/server/request.d.ts +1 -139
- package/dist/server/request.d.ts.map +1 -1
- package/dist/server/request.js +19 -433
- package/dist/server/request.js.map +1 -1
- package/dist/server/response.d.ts +105 -158
- package/dist/server/response.d.ts.map +1 -1
- package/dist/server/response.js +121 -423
- package/dist/server/response.js.map +1 -1
- package/dist/swagger/decorators.d.ts +81 -0
- package/dist/swagger/decorators.d.ts.map +1 -0
- package/dist/swagger/decorators.js +172 -0
- package/dist/swagger/decorators.js.map +1 -0
- package/dist/swagger/generator.d.ts +19 -0
- package/dist/swagger/generator.d.ts.map +1 -0
- package/dist/swagger/generator.js +344 -0
- package/dist/swagger/generator.js.map +1 -0
- package/dist/swagger/index.d.ts +31 -0
- package/dist/swagger/index.d.ts.map +1 -0
- package/dist/swagger/index.js +53 -0
- package/dist/swagger/index.js.map +1 -0
- package/dist/swagger/mounter.d.ts +7 -0
- package/dist/swagger/mounter.d.ts.map +1 -0
- package/dist/swagger/mounter.js +56 -0
- package/dist/swagger/mounter.js.map +1 -0
- package/dist/swagger/types.d.ts +190 -0
- package/dist/swagger/types.d.ts.map +1 -0
- package/dist/swagger/types.js +3 -0
- package/dist/swagger/types.js.map +1 -0
- package/dist/swagger/ui.d.ts +6 -0
- package/dist/swagger/ui.d.ts.map +1 -0
- package/dist/swagger/ui.js +118 -0
- package/dist/swagger/ui.js.map +1 -0
- package/dist/validator/builder.d.ts +223 -0
- package/dist/validator/builder.d.ts.map +1 -0
- package/dist/validator/builder.js +517 -0
- package/dist/validator/builder.js.map +1 -0
- package/dist/validator/engine.d.ts +19 -0
- package/dist/validator/engine.d.ts.map +1 -0
- package/dist/validator/engine.js +568 -0
- package/dist/validator/engine.js.map +1 -0
- package/dist/validator/error.d.ts +12 -0
- package/dist/validator/error.d.ts.map +1 -0
- package/dist/validator/error.js +63 -0
- package/dist/validator/error.js.map +1 -0
- package/dist/validator/pagination.d.ts +40 -0
- package/dist/validator/pagination.d.ts.map +1 -0
- package/dist/validator/pagination.js +60 -0
- package/dist/validator/pagination.js.map +1 -0
- package/dist/validator/tex.d.ts +6 -158
- package/dist/validator/tex.d.ts.map +1 -1
- package/dist/validator/tex.js +14 -971
- package/dist/validator/tex.js.map +1 -1
- package/dist/validator/types.d.ts +83 -0
- package/dist/validator/types.d.ts.map +1 -0
- package/dist/validator/types.js +3 -0
- package/dist/validator/types.js.map +1 -0
- package/package.json +9 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
export interface OpenApiInfo {
|
|
2
|
+
title: string;
|
|
3
|
+
version: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
termsOfService?: string;
|
|
6
|
+
contact?: {
|
|
7
|
+
name?: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
email?: string;
|
|
10
|
+
};
|
|
11
|
+
license?: {
|
|
12
|
+
name: string;
|
|
13
|
+
url?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface OpenApiServer {
|
|
17
|
+
url: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
variables?: Record<string, {
|
|
20
|
+
default: string;
|
|
21
|
+
enum?: string[];
|
|
22
|
+
description?: string;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export interface OpenApiTag {
|
|
26
|
+
name: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
externalDocs?: {
|
|
29
|
+
description?: string;
|
|
30
|
+
url: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface SecuritySchemeObject {
|
|
34
|
+
type: 'apiKey' | 'http' | 'oauth2' | 'openIdConnect';
|
|
35
|
+
description?: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
in?: 'query' | 'header' | 'cookie';
|
|
38
|
+
scheme?: string;
|
|
39
|
+
bearerFormat?: string;
|
|
40
|
+
flows?: Record<string, any>;
|
|
41
|
+
openIdConnectUrl?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface SwaggerConfig {
|
|
44
|
+
/**
|
|
45
|
+
* Whether to enable the interactive API documentation and OpenAPI spec endpoint.
|
|
46
|
+
* Default: `false` (can be enabled globally or per environment).
|
|
47
|
+
*/
|
|
48
|
+
enabled?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The base URL path where the interactive documentation UI will be mounted.
|
|
51
|
+
* Default: `'/docs'`
|
|
52
|
+
*/
|
|
53
|
+
path?: string;
|
|
54
|
+
/**
|
|
55
|
+
* The URL path where the raw OpenAPI 3.1 JSON specification will be served.
|
|
56
|
+
* Default: `'/docs/json'`
|
|
57
|
+
*/
|
|
58
|
+
specPath?: string;
|
|
59
|
+
/**
|
|
60
|
+
* API Title shown in the documentation UI.
|
|
61
|
+
* Default: `'ExisJS API Documentation'`
|
|
62
|
+
*/
|
|
63
|
+
title?: string;
|
|
64
|
+
/**
|
|
65
|
+
* API Version string.
|
|
66
|
+
* Default: `'1.0.0'`
|
|
67
|
+
*/
|
|
68
|
+
version?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Detailed API description or overview markdown.
|
|
71
|
+
*/
|
|
72
|
+
description?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Terms of Service URL.
|
|
75
|
+
*/
|
|
76
|
+
termsOfService?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Contact information for the API.
|
|
79
|
+
*/
|
|
80
|
+
contact?: OpenApiInfo['contact'];
|
|
81
|
+
/**
|
|
82
|
+
* License information for the API.
|
|
83
|
+
*/
|
|
84
|
+
license?: OpenApiInfo['license'];
|
|
85
|
+
/**
|
|
86
|
+
* List of target servers (environments) for the API.
|
|
87
|
+
*/
|
|
88
|
+
servers?: OpenApiServer[];
|
|
89
|
+
/**
|
|
90
|
+
* Global list of tags with descriptions for organizing operations in groups.
|
|
91
|
+
*/
|
|
92
|
+
tags?: OpenApiTag[];
|
|
93
|
+
/**
|
|
94
|
+
* Global security requirements applied across all endpoints unless overridden.
|
|
95
|
+
*/
|
|
96
|
+
security?: Record<string, string[]>[];
|
|
97
|
+
/**
|
|
98
|
+
* Reusable security schemes (e.g. Bearer JWT, API Keys, OAuth2).
|
|
99
|
+
*/
|
|
100
|
+
securitySchemes?: Record<string, SecuritySchemeObject>;
|
|
101
|
+
/**
|
|
102
|
+
* The interactive documentation UI engine to render.
|
|
103
|
+
* Options: `'swagger-ui'` | `'scalar'` (Default: `'swagger-ui'`)
|
|
104
|
+
*/
|
|
105
|
+
ui?: 'swagger-ui' | 'scalar';
|
|
106
|
+
/**
|
|
107
|
+
* Custom CSS styling injected into the documentation UI.
|
|
108
|
+
*/
|
|
109
|
+
customCss?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Custom favicon URL for the documentation page.
|
|
112
|
+
*/
|
|
113
|
+
customFavicon?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Transform or mutate the generated OpenAPI specification before serving.
|
|
116
|
+
*/
|
|
117
|
+
transformSpec?: (spec: OpenApiSpec) => OpenApiSpec | void;
|
|
118
|
+
}
|
|
119
|
+
export interface OpenApiParameter {
|
|
120
|
+
name: string;
|
|
121
|
+
in: 'query' | 'header' | 'path' | 'cookie';
|
|
122
|
+
description?: string;
|
|
123
|
+
required?: boolean;
|
|
124
|
+
deprecated?: boolean;
|
|
125
|
+
schema: Record<string, any>;
|
|
126
|
+
example?: any;
|
|
127
|
+
}
|
|
128
|
+
export interface OpenApiRequestBody {
|
|
129
|
+
description?: string;
|
|
130
|
+
required?: boolean;
|
|
131
|
+
content: Record<string, {
|
|
132
|
+
schema: Record<string, any>;
|
|
133
|
+
example?: any;
|
|
134
|
+
}>;
|
|
135
|
+
}
|
|
136
|
+
export interface OpenApiResponse {
|
|
137
|
+
description: string;
|
|
138
|
+
headers?: Record<string, any>;
|
|
139
|
+
content?: Record<string, {
|
|
140
|
+
schema: Record<string, any>;
|
|
141
|
+
example?: any;
|
|
142
|
+
}>;
|
|
143
|
+
}
|
|
144
|
+
export interface OpenApiOperation {
|
|
145
|
+
tags?: string[];
|
|
146
|
+
summary?: string;
|
|
147
|
+
description?: string;
|
|
148
|
+
operationId?: string;
|
|
149
|
+
parameters?: OpenApiParameter[];
|
|
150
|
+
requestBody?: OpenApiRequestBody;
|
|
151
|
+
responses: Record<string, OpenApiResponse>;
|
|
152
|
+
deprecated?: boolean;
|
|
153
|
+
security?: Record<string, string[]>[];
|
|
154
|
+
externalDocs?: {
|
|
155
|
+
url: string;
|
|
156
|
+
description?: string;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
export interface OpenApiSpec {
|
|
160
|
+
openapi: string;
|
|
161
|
+
info: OpenApiInfo;
|
|
162
|
+
servers?: OpenApiServer[];
|
|
163
|
+
paths: Record<string, Record<string, OpenApiOperation>>;
|
|
164
|
+
components?: {
|
|
165
|
+
schemas?: Record<string, any>;
|
|
166
|
+
securitySchemes?: Record<string, SecuritySchemeObject>;
|
|
167
|
+
parameters?: Record<string, OpenApiParameter>;
|
|
168
|
+
responses?: Record<string, OpenApiResponse>;
|
|
169
|
+
};
|
|
170
|
+
security?: Record<string, string[]>[];
|
|
171
|
+
tags?: OpenApiTag[];
|
|
172
|
+
}
|
|
173
|
+
export interface RouteDocMetadata {
|
|
174
|
+
summary?: string;
|
|
175
|
+
description?: string;
|
|
176
|
+
tags?: string[];
|
|
177
|
+
operationId?: string;
|
|
178
|
+
deprecated?: boolean;
|
|
179
|
+
security?: Record<string, string[]>[];
|
|
180
|
+
responses?: Record<number | string, {
|
|
181
|
+
description?: string;
|
|
182
|
+
schema?: any;
|
|
183
|
+
}>;
|
|
184
|
+
externalDocs?: {
|
|
185
|
+
url: string;
|
|
186
|
+
description?: string;
|
|
187
|
+
};
|
|
188
|
+
excludeFromDocs?: boolean;
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/swagger/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;IACD,OAAO,CAAC,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,CAAC,EAAE,MAAM,CAAA;KACb,CAAA;CACF;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAChB,MAAM,EACN;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,C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AAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,CAAA;IACrC,IAAI,CAAC,EAAE,UAAU,EAAE,CAAA;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,CAAA;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC,CAAA;IAC3E,YAAY,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACpD,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/swagger/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/swagger/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAyGrE"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderDocumentationHtml = renderDocumentationHtml;
|
|
4
|
+
/**
|
|
5
|
+
* Generates the HTML markup for interactive Swagger UI or Scalar API documentation.
|
|
6
|
+
*/
|
|
7
|
+
function renderDocumentationHtml(config) {
|
|
8
|
+
const uiEngine = config.ui || 'swagger-ui';
|
|
9
|
+
const title = config.title || 'ExisJS API Documentation';
|
|
10
|
+
const specPath = config.specPath || '/docs/json';
|
|
11
|
+
const customCss = config.customCss || '';
|
|
12
|
+
const customFavicon = config.customFavicon ||
|
|
13
|
+
'https://raw.githubusercontent.com/swagger-api/swagger-ui/master/dist/favicon-32x32.png';
|
|
14
|
+
if (uiEngine === 'scalar') {
|
|
15
|
+
return `<!DOCTYPE html>
|
|
16
|
+
<html lang="en">
|
|
17
|
+
<head>
|
|
18
|
+
<meta charset="UTF-8">
|
|
19
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
20
|
+
<title>${escapeHtml(title)}</title>
|
|
21
|
+
<link rel="icon" type="image/png" href="${escapeHtml(customFavicon)}">
|
|
22
|
+
<style>
|
|
23
|
+
body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
|
|
24
|
+
${customCss}
|
|
25
|
+
</style>
|
|
26
|
+
</head>
|
|
27
|
+
<body>
|
|
28
|
+
<script
|
|
29
|
+
id="api-reference"
|
|
30
|
+
data-url="${escapeHtml(specPath)}"
|
|
31
|
+
data-configuration='{"theme":"purple","layout":"modern"}'
|
|
32
|
+
src="https://cdn.jsdelivr.net/npm/@scalar/api-reference@1.25.105/dist/browser/standalone.min.js">
|
|
33
|
+
</script>
|
|
34
|
+
</body>
|
|
35
|
+
</html>`;
|
|
36
|
+
}
|
|
37
|
+
// Default: Swagger UI
|
|
38
|
+
return `<!DOCTYPE html>
|
|
39
|
+
<html lang="en">
|
|
40
|
+
<head>
|
|
41
|
+
<meta charset="UTF-8">
|
|
42
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
43
|
+
<title>${escapeHtml(title)}</title>
|
|
44
|
+
<link rel="icon" type="image/png" href="${escapeHtml(customFavicon)}">
|
|
45
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.18.2/swagger-ui.css">
|
|
46
|
+
<style>
|
|
47
|
+
html {
|
|
48
|
+
box-sizing: border-box;
|
|
49
|
+
overflow: -moz-scrollbars-vertical;
|
|
50
|
+
overflow-y: scroll;
|
|
51
|
+
}
|
|
52
|
+
*, *:before, *:after {
|
|
53
|
+
box-sizing: inherit;
|
|
54
|
+
}
|
|
55
|
+
body {
|
|
56
|
+
margin: 0;
|
|
57
|
+
background: #fafafa;
|
|
58
|
+
}
|
|
59
|
+
.topbar {
|
|
60
|
+
display: none !important;
|
|
61
|
+
}
|
|
62
|
+
.swagger-ui .info {
|
|
63
|
+
margin: 25px 0 20px 0;
|
|
64
|
+
}
|
|
65
|
+
.swagger-ui .info .title {
|
|
66
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
|
67
|
+
font-weight: 700;
|
|
68
|
+
color: #1e293b;
|
|
69
|
+
}
|
|
70
|
+
.swagger-ui .btn.authorize {
|
|
71
|
+
background-color: #7c3aed;
|
|
72
|
+
border-color: #7c3aed;
|
|
73
|
+
color: #fff;
|
|
74
|
+
}
|
|
75
|
+
.swagger-ui .btn.authorize svg {
|
|
76
|
+
fill: #fff;
|
|
77
|
+
}
|
|
78
|
+
${customCss}
|
|
79
|
+
</style>
|
|
80
|
+
</head>
|
|
81
|
+
<body>
|
|
82
|
+
<div id="swagger-ui"></div>
|
|
83
|
+
<script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.18.2/swagger-ui-bundle.js"></script>
|
|
84
|
+
<script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.18.2/swagger-ui-standalone-preset.js"></script>
|
|
85
|
+
<script>
|
|
86
|
+
window.onload = function() {
|
|
87
|
+
window.ui = SwaggerUIBundle({
|
|
88
|
+
url: "${escapeHtml(specPath)}",
|
|
89
|
+
dom_id: '#swagger-ui',
|
|
90
|
+
deepLinking: true,
|
|
91
|
+
presets: [
|
|
92
|
+
SwaggerUIBundle.presets.apis,
|
|
93
|
+
SwaggerUIStandalonePreset
|
|
94
|
+
],
|
|
95
|
+
plugins: [
|
|
96
|
+
SwaggerUIBundle.plugins.DownloadUrl
|
|
97
|
+
],
|
|
98
|
+
layout: "StandaloneLayout",
|
|
99
|
+
displayRequestDuration: true,
|
|
100
|
+
docExpansion: "list",
|
|
101
|
+
filter: true,
|
|
102
|
+
showExtensions: true,
|
|
103
|
+
showCommonExtensions: true
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
</script>
|
|
107
|
+
</body>
|
|
108
|
+
</html>`;
|
|
109
|
+
}
|
|
110
|
+
function escapeHtml(str) {
|
|
111
|
+
return str
|
|
112
|
+
.replace(/&/g, '&')
|
|
113
|
+
.replace(/</g, '<')
|
|
114
|
+
.replace(/>/g, '>')
|
|
115
|
+
.replace(/"/g, '"')
|
|
116
|
+
.replace(/'/g, ''');
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/swagger/ui.ts"],"names":[],"mappings":";;AAKA,0DAyGC;AA5GD;;GAEG;AACH,SAAgB,uBAAuB,CAAC,MAAqB;IAC3D,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,IAAI,YAAY,CAAA;IAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,0BAA0B,CAAA;IACxD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,YAAY,CAAA;IAChD,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,EAAE,CAAA;IACxC,MAAM,aAAa,GACjB,MAAM,CAAC,aAAa;QACpB,wFAAwF,CAAA;IAE1F,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO;;;;;WAKA,UAAU,CAAC,KAAK,CAAC;4CACgB,UAAU,CAAC,aAAa,CAAC;;;MAG/D,SAAS;;;;;;gBAMC,UAAU,CAAC,QAAQ,CAAC;;;;;QAK5B,CAAA;IACN,CAAC;IAED,sBAAsB;IACtB,OAAO;;;;;WAKE,UAAU,CAAC,KAAK,CAAC;4CACgB,UAAU,CAAC,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkC/D,SAAS;;;;;;;;;;gBAUC,UAAU,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;QAoB5B,CAAA;AACR,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,GAAG;SACP,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC5B,CAAC"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { TexString, TexNumber, TexBoolean, TexArray, TexEnum, TexLiteral, TexUnion, TexDate, TexRecord, TexAny, TexFile, ResolveSchema } from './tex-types';
|
|
2
|
+
import type { TexBaseOptions, TexStringOptions, TexNumberOptions, TexBooleanOptions, TexArrayOptions, TexEnumOptions, TexObjectOptions, TexFileOptions, TexPasswordOptions, TexDateOptions } from './types';
|
|
3
|
+
import { TexEngine } from './engine';
|
|
4
|
+
/**
|
|
5
|
+
* Ultra-high performance declarative schema builder powered by the native Rust validator.
|
|
6
|
+
*/
|
|
7
|
+
export declare class TexBuilder {
|
|
8
|
+
/**
|
|
9
|
+
* Defines a string schema with built-in sanitization and security protections.
|
|
10
|
+
*
|
|
11
|
+
* @param opts Validation rules and transformations (min, max, trim, toLowerCase, escapeHtml, etc.)
|
|
12
|
+
* @returns Strongly typed string schema descriptor
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const username = tex.string({ min: 3, max: 20, trim: true, toLowerCase: true })
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
string<O extends TexStringOptions = TexStringOptions>(opts?: O): TexString<O['optional'] extends true ? true : false>;
|
|
20
|
+
/**
|
|
21
|
+
* Defines a number schema with bounds and optional auto-coercion from string query parameters.
|
|
22
|
+
*
|
|
23
|
+
* @param opts Validation rules (min, max, coerce, default)
|
|
24
|
+
* @returns Strongly typed number schema descriptor
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const age = tex.number({ min: 18, max: 120, coerce: true })
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
number<O extends TexNumberOptions = TexNumberOptions>(opts?: O): TexNumber<O['optional'] extends true ? true : false>;
|
|
32
|
+
/**
|
|
33
|
+
* Defines a boolean schema with optional string-to-boolean coercion (`"true"`, `"false"`).
|
|
34
|
+
*
|
|
35
|
+
* @param opts Validation rules (coerce, optional, default)
|
|
36
|
+
* @returns Strongly typed boolean schema descriptor
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const isActive = tex.boolean({ coerce: true, default: true })
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
boolean<O extends TexBooleanOptions = TexBooleanOptions>(opts?: O): TexBoolean<O['optional'] extends true ? true : false>;
|
|
44
|
+
/**
|
|
45
|
+
* Defines an email schema verified natively against RFC standards.
|
|
46
|
+
*
|
|
47
|
+
* @param opts Validation and formatting rules
|
|
48
|
+
* @returns Strongly typed email string schema descriptor
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const userEmail = tex.email({ trim: true, toLowerCase: true })
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
email<O extends TexStringOptions = TexStringOptions>(opts?: O): TexString<O['optional'] extends true ? true : false>;
|
|
56
|
+
/**
|
|
57
|
+
* Defines a UUID v1 or v4 schema.
|
|
58
|
+
*
|
|
59
|
+
* @param opts UUID options including optional version specification
|
|
60
|
+
* @returns Strongly typed UUID string schema descriptor
|
|
61
|
+
*/
|
|
62
|
+
uuid<O extends TexStringOptions & {
|
|
63
|
+
version?: 1 | 4;
|
|
64
|
+
} = TexStringOptions & {
|
|
65
|
+
version?: 1 | 4;
|
|
66
|
+
}>(opts?: O): TexString<O['optional'] extends true ? true : false>;
|
|
67
|
+
/**
|
|
68
|
+
* Defines a CUID (Collision-resistant Unique Identifier) schema.
|
|
69
|
+
*/
|
|
70
|
+
cuid<O extends TexStringOptions = TexStringOptions>(opts?: O): TexString<O['optional'] extends true ? true : false>;
|
|
71
|
+
/**
|
|
72
|
+
* Defines a Credit Card schema validated via the Luhn checksum algorithm.
|
|
73
|
+
*/
|
|
74
|
+
creditCard<O extends TexStringOptions = TexStringOptions>(opts?: O): TexString<O['optional'] extends true ? true : false>;
|
|
75
|
+
/**
|
|
76
|
+
* Defines a secure password schema with enforcement for length, numbers, symbols, and casing.
|
|
77
|
+
*
|
|
78
|
+
* @param opts Complexity constraints (min, requireNumbers, requireSymbols, requireUppercase, requireLowercase)
|
|
79
|
+
* @returns Strongly typed password schema descriptor
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const password = tex.password({
|
|
84
|
+
* min: 8,
|
|
85
|
+
* requireNumbers: true,
|
|
86
|
+
* requireSymbols: true,
|
|
87
|
+
* requireUppercase: true
|
|
88
|
+
* })
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
password<O extends TexPasswordOptions = TexPasswordOptions>(opts?: O): TexString<O['optional'] extends true ? true : false>;
|
|
92
|
+
/**
|
|
93
|
+
* Defines an array schema with item validation, bounds, and automatic coercion from comma-delimited strings.
|
|
94
|
+
*
|
|
95
|
+
* @param schema Schema descriptor for each item in the array
|
|
96
|
+
* @param opts Array rules (min, max, dedupe, coerce, default)
|
|
97
|
+
* @returns Strongly typed array schema descriptor
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* const tags = tex.array(tex.string({ trim: true }), { min: 1, max: 10, dedupe: true })
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
array<T, O extends TexArrayOptions<T> = TexArrayOptions<T>>(schema: T, opts?: O): TexArray<T, O['optional'] extends true ? true : false>;
|
|
105
|
+
/**
|
|
106
|
+
* Defines an enum schema restricted to an exact list of allowed string literals.
|
|
107
|
+
*
|
|
108
|
+
* @param values Array of allowed string values
|
|
109
|
+
* @param opts Enum options (optional, default)
|
|
110
|
+
* @returns Strongly typed enum schema descriptor
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* const role = tex.enum(['admin', 'user', 'guest'], { default: 'user' })
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
enum<T extends string, O extends TexEnumOptions<T> = TexEnumOptions<T>>(values: T[], opts?: O): TexEnum<T, O['optional'] extends true ? true : false>;
|
|
118
|
+
/**
|
|
119
|
+
* Defines an exact literal value schema (e.g. `'v1'`, `42`, `true`).
|
|
120
|
+
*/
|
|
121
|
+
literal<T extends string | number | boolean, O extends TexBaseOptions = TexBaseOptions>(value: T, opts?: O): TexLiteral<T, O['optional'] extends true ? true : false>;
|
|
122
|
+
/**
|
|
123
|
+
* Defines a union schema that succeeds if any of the provided candidate schemas match.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* const idOrEmail = tex.union([tex.number({ coerce: true }), tex.email()])
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
union<T extends any[], O extends TexBaseOptions = TexBaseOptions>(schemas: T, opts?: O): TexUnion<T, O['optional'] extends true ? true : false>;
|
|
131
|
+
/**
|
|
132
|
+
* Defines a date schema with bounds checking and automatic coercion from ISO strings or timestamps.
|
|
133
|
+
*
|
|
134
|
+
* @param opts Date options (minDate, maxDate, coerce, default)
|
|
135
|
+
* @returns Strongly typed Date schema descriptor
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* const createdAt = tex.date({ coerce: true, minDate: '2024-01-01' })
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
date<O extends TexDateOptions = TexDateOptions>(opts?: O): TexDate<O['optional'] extends true ? true : false>;
|
|
143
|
+
/**
|
|
144
|
+
* Defines a dynamic key-value record schema (e.g. `Record<string, T>`).
|
|
145
|
+
*/
|
|
146
|
+
record<T, O extends TexBaseOptions = TexBaseOptions>(schema: T, opts?: O): TexRecord<T, O['optional'] extends true ? true : false>;
|
|
147
|
+
/**
|
|
148
|
+
* Defines an unconstrained pass-through schema.
|
|
149
|
+
*/
|
|
150
|
+
any<O extends TexBaseOptions = TexBaseOptions>(opts?: O): TexAny<O['optional'] extends true ? true : false>;
|
|
151
|
+
/**
|
|
152
|
+
* Defines a file upload validation schema.
|
|
153
|
+
*/
|
|
154
|
+
file<O extends TexFileOptions = TexFileOptions>(opts?: O): TexFile<O['optional'] extends true ? true : false>;
|
|
155
|
+
/**
|
|
156
|
+
* Compiles an object structure into a fast `TexEngine` validator instance.
|
|
157
|
+
*
|
|
158
|
+
* @param schema Object map containing field definitions
|
|
159
|
+
* @param opts Object options (e.g. `{ strict: true }` to reject unknown fields)
|
|
160
|
+
* @returns Compiled `TexEngine` validator
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* const UserSchema = tex.object({
|
|
165
|
+
* id: tex.number({ coerce: true }),
|
|
166
|
+
* name: tex.string({ min: 2 }),
|
|
167
|
+
* email: tex.email()
|
|
168
|
+
* }, { strict: true })
|
|
169
|
+
*
|
|
170
|
+
* const user = UserSchema.parse(req.body)
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
object<T extends Record<string, any>>(schema: T, opts?: TexObjectOptions): TexEngine<ResolveSchema<T>>;
|
|
174
|
+
/**
|
|
175
|
+
* Dedicated Environment Schema parser (`tex.env`).
|
|
176
|
+
* Automatically coerces numbers, booleans, dates, and arrays from `process.env` string values,
|
|
177
|
+
* while preserving strict type validation and defaults.
|
|
178
|
+
*
|
|
179
|
+
* @param schema Environment variable schema definition
|
|
180
|
+
* @param opts Schema configuration
|
|
181
|
+
* @returns Compiled `TexEngine` tailored for environment variable parsing
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* export const env = tex.env({
|
|
186
|
+
* PORT: tex.number({ default: 3000 }),
|
|
187
|
+
* NODE_ENV: tex.enum(['development', 'production', 'test'], { default: 'development' }),
|
|
188
|
+
* DATABASE_URL: tex.string(),
|
|
189
|
+
* ENABLE_METRICS: tex.boolean({ default: false })
|
|
190
|
+
* }).parse(process.env)
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
env<T extends Record<string, any>>(schema: T, opts?: TexObjectOptions): TexEngine<ResolveSchema<T>>;
|
|
194
|
+
/**
|
|
195
|
+
* Helper that builds standard query pagination schema (`page`, `limit`, `sort`, `order`).
|
|
196
|
+
*
|
|
197
|
+
* @param options Configuration for default and maximum limit
|
|
198
|
+
* @returns Compiled pagination query validator
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* export default controller({
|
|
203
|
+
* listUsers: route.get('/', {
|
|
204
|
+
* query: tex.pagination({ defaultLimit: 25, maxLimit: 100 }),
|
|
205
|
+
* async handle({ query }) {
|
|
206
|
+
* const { skip, limit } = getPaginationSkip(query)
|
|
207
|
+
* return UserService.find(skip, limit)
|
|
208
|
+
* }
|
|
209
|
+
* })
|
|
210
|
+
* })
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
pagination(options?: {
|
|
214
|
+
defaultLimit?: number;
|
|
215
|
+
maxLimit?: number;
|
|
216
|
+
}): TexEngine<ResolveSchema<{
|
|
217
|
+
page: TexNumber<true>;
|
|
218
|
+
limit: TexNumber<true>;
|
|
219
|
+
sort: TexString<true>;
|
|
220
|
+
order: TexEnum<"asc" | "desc", true>;
|
|
221
|
+
}>>;
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/validator/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,OAAO,EACP,UAAU,EACV,QAAQ,EACR,OAAO,EACP,SAAS,EACT,MAAM,EACN,OAAO,EACP,aAAa,EACd,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,cAAc,EACf,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC;;GAEG;AACH,qBAAa,UAAU;IACrB;;;;;;;;;;OAUG;IACH,MAAM,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,EAClD,IAAI,CAAC,EAAE,CAAC,GACP,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;IAsBvD;;;;;;;;;;OAUG;IACH,MAAM,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,EAClD,IAAI,CAAC,EAAE,CAAC,GACP,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;IAavD;;;;;;;;;;OAUG;IACH,OAAO,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB,EACrD,IAAI,CAAC,EAAE,CAAC,GACP,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,IAAI,GAAG,IAAI,G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