@buildplease/apikit 1.0.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/LICENSE +21 -0
- package/bin/apikit.mjs +17 -0
- package/dist/cli/index.mjs +7 -0
- package/dist/src/index.cjs +1 -0
- package/dist/src/index.d.cts +3049 -0
- package/dist/src/index.d.mts +3049 -0
- package/dist/src/index.mjs +1 -0
- package/dist/src-node-test/index.cjs +1 -0
- package/dist/src-node-test/index.d.cts +35 -0
- package/dist/src-node-test/index.d.mts +35 -0
- package/dist/src-node-test/index.mjs +1 -0
- package/package.json +95 -0
- package/resources/index.ts +1 -0
|
@@ -0,0 +1,3049 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { Assembly, JSONSerializable, UnitFormatterController } from "@buildplease/core";
|
|
3
|
+
import fastifyCookie, { SerializeOptions } from "@fastify/cookie";
|
|
4
|
+
import { IncomingHttpHeaders } from "http";
|
|
5
|
+
import fastifyBasicAuth, { FastifyBasicAuthOptions } from "@fastify/basic-auth";
|
|
6
|
+
import fastifyCors, { FastifyCorsOptions } from "@fastify/cors";
|
|
7
|
+
import { InitOptions, TOptions } from "i18next";
|
|
8
|
+
import { Logger, LoggerTransportOptions } from "@buildplease/core/node";
|
|
9
|
+
import { FastifyInstance, FastifyReply, FastifyRequest, FastifySchema, RouteOptions } from "fastify";
|
|
10
|
+
import fastifyMultipart, { FastifyMultipartAttachFieldsToBodyOptions, FastifyMultipartBaseOptions, FastifyMultipartOptions } from "@fastify/multipart";
|
|
11
|
+
import fastifyStatic, { FastifyStaticOptions } from "@fastify/static";
|
|
12
|
+
import { AvifOptions, FormatEnum, GifOptions, HeifOptions, Jp2Options, JpegOptions, JxlOptions, PngOptions, ResizeOptions, Sharp, TiffOptions, WebpOptions } from "sharp";
|
|
13
|
+
import { Readable } from "stream";
|
|
14
|
+
import fp from "fastify-plugin";
|
|
15
|
+
import fastifyUnderPressure from "@fastify/under-pressure";
|
|
16
|
+
import fastifyView from "@fastify/view";
|
|
17
|
+
import fastifyIp from "fastify-ip";
|
|
18
|
+
import fastifyMetrics from "fastify-metrics";
|
|
19
|
+
import { ZodType, z } from "zod";
|
|
20
|
+
export * from "@buildplease/core";
|
|
21
|
+
export * from "@buildplease/core/node";
|
|
22
|
+
//#region src/request/request-log-metadata.d.ts
|
|
23
|
+
declare class RequestLogMetadata {
|
|
24
|
+
private readonly metadata;
|
|
25
|
+
constructor(metadata: Partial<RequestMetadata>);
|
|
26
|
+
toJSON(): object | undefined;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/http/cookie.d.ts
|
|
30
|
+
type CookieOptions = SerializeOptions;
|
|
31
|
+
interface CookieMutation {
|
|
32
|
+
name?: string;
|
|
33
|
+
value?: string;
|
|
34
|
+
options?: CookieOptions;
|
|
35
|
+
}
|
|
36
|
+
declare class Cookie {
|
|
37
|
+
private _name;
|
|
38
|
+
private _value;
|
|
39
|
+
private _options;
|
|
40
|
+
constructor(name: string, value: string, options?: CookieOptions);
|
|
41
|
+
get name(): string;
|
|
42
|
+
get value(): string;
|
|
43
|
+
get options(): Readonly<CookieOptions>;
|
|
44
|
+
mutate(mutation: CookieMutation): this;
|
|
45
|
+
serialize(): string;
|
|
46
|
+
toString(): string;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/http/http-headers.d.ts
|
|
50
|
+
declare const HttpHeaders: {
|
|
51
|
+
readonly accept: "accept";
|
|
52
|
+
readonly acceptLanguage: "accept-language";
|
|
53
|
+
readonly authorization: "authorization";
|
|
54
|
+
readonly cacheControl: "cache-control";
|
|
55
|
+
readonly contentType: "content-type";
|
|
56
|
+
readonly cookie: "cookie";
|
|
57
|
+
readonly setCookie: "set-cookie";
|
|
58
|
+
readonly userAgent: "user-agent";
|
|
59
|
+
};
|
|
60
|
+
interface HttpHeaders extends IncomingHttpHeaders {}
|
|
61
|
+
type HttpHeaderValues = { [K in keyof HttpHeaders as string extends K ? never : number extends K ? never : K]: HttpHeaders[K]; };
|
|
62
|
+
type HttpHeaderKey = Extract<keyof HttpHeaderValues, string>;
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/http/http-method.d.ts
|
|
65
|
+
declare enum HttpMethod {
|
|
66
|
+
POST = "POST",
|
|
67
|
+
PUT = "PUT",
|
|
68
|
+
PATCH = "PATCH",
|
|
69
|
+
GET = "GET",
|
|
70
|
+
DELETE = "DELETE",
|
|
71
|
+
OPTIONS = "OPTIONS"
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/http/http-response.d.ts
|
|
75
|
+
declare enum ResponseType {
|
|
76
|
+
JSON = "JSON",
|
|
77
|
+
File = "File"
|
|
78
|
+
}
|
|
79
|
+
declare abstract class HttpResponse {
|
|
80
|
+
readonly statusCode: number;
|
|
81
|
+
readonly headers?: HttpHeaders;
|
|
82
|
+
abstract readonly responseType: ResponseType;
|
|
83
|
+
constructor({ statusCode, headers }: {
|
|
84
|
+
statusCode: number;
|
|
85
|
+
headers?: HttpHeaders;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
declare class JSONHttpResponse extends HttpResponse {
|
|
89
|
+
readonly data: any;
|
|
90
|
+
readonly responseType = ResponseType.JSON;
|
|
91
|
+
constructor({ statusCode, data, headers }: {
|
|
92
|
+
statusCode: number;
|
|
93
|
+
data: any;
|
|
94
|
+
headers?: HttpHeaders;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
declare class FileHttpResponse extends HttpResponse {
|
|
98
|
+
readonly filePath: string;
|
|
99
|
+
readonly shouldRender: boolean;
|
|
100
|
+
readonly data?: any;
|
|
101
|
+
readonly responseType = ResponseType.File;
|
|
102
|
+
constructor({ statusCode, filePath, shouldRender, headers, data }: {
|
|
103
|
+
statusCode: number;
|
|
104
|
+
filePath: string;
|
|
105
|
+
shouldRender: boolean;
|
|
106
|
+
headers?: HttpHeaders;
|
|
107
|
+
data?: any;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/request/request-metadata.d.ts
|
|
112
|
+
interface RequestMetadata {
|
|
113
|
+
requestId: string;
|
|
114
|
+
method: string;
|
|
115
|
+
url: string;
|
|
116
|
+
protocol: string;
|
|
117
|
+
query: any;
|
|
118
|
+
params: any;
|
|
119
|
+
ip: string;
|
|
120
|
+
headers: HttpHeaders;
|
|
121
|
+
locale: string;
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/request/request-scope.d.ts
|
|
125
|
+
interface RequestScopeData {
|
|
126
|
+
metadata: RequestMetadata;
|
|
127
|
+
}
|
|
128
|
+
interface IRequestScope {
|
|
129
|
+
readonly metadata: RequestMetadata;
|
|
130
|
+
readonly locale: string;
|
|
131
|
+
readonly requestId: string;
|
|
132
|
+
run<T>(data: RequestScopeData, callback: () => T): T;
|
|
133
|
+
}
|
|
134
|
+
declare const RequestScope: IRequestScope;
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region types/fastify.d.ts
|
|
137
|
+
declare module 'fastify' {
|
|
138
|
+
interface FastifyRequest {
|
|
139
|
+
metadata: RequestMetadata;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/configuration/core/build-metadata.d.ts
|
|
144
|
+
interface BuildMetadata {
|
|
145
|
+
readonly name: {
|
|
146
|
+
readonly original: string;
|
|
147
|
+
readonly base: string;
|
|
148
|
+
};
|
|
149
|
+
readonly version: string;
|
|
150
|
+
readonly id: string;
|
|
151
|
+
readonly createdAt: string;
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/configuration/core/field.d.ts
|
|
155
|
+
interface ConfigurationField<Output, Required extends boolean = true, Input = Output> {
|
|
156
|
+
readonly required: Required;
|
|
157
|
+
readonly hasDefault: boolean;
|
|
158
|
+
readonly defaultValue?: Output;
|
|
159
|
+
parse(value: unknown, path: string): Output;
|
|
160
|
+
optional(): ConfigurationField<Output | undefined, false, Input | undefined | null>;
|
|
161
|
+
default(value: Output): ConfigurationField<Output, false, Input>;
|
|
162
|
+
map<NextOutput>(transform: (value: Output) => NextOutput): ConfigurationField<NextOutput, Required, Input>;
|
|
163
|
+
}
|
|
164
|
+
declare const field: {
|
|
165
|
+
string(): ConfigurationField<string, true, string>;
|
|
166
|
+
number(): ConfigurationField<number, true, string | number>;
|
|
167
|
+
boolean(): ConfigurationField<boolean, true, string | boolean>;
|
|
168
|
+
array<Item, ItemInput>(item: ConfigurationField<Item, boolean, ItemInput>): ConfigurationField<readonly Item[], true, readonly ItemInput[]>;
|
|
169
|
+
custom<T>(): ConfigurationField<T, true, T>;
|
|
170
|
+
};
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/configuration/core/environments.d.ts
|
|
173
|
+
interface EnvironmentDefinition {
|
|
174
|
+
readonly file: string;
|
|
175
|
+
readonly fileDir?: string;
|
|
176
|
+
}
|
|
177
|
+
interface EnvironmentConfig<Name extends string = string> {
|
|
178
|
+
readonly name: Name;
|
|
179
|
+
readonly file: string;
|
|
180
|
+
readonly fileDir: string;
|
|
181
|
+
}
|
|
182
|
+
type EnvironmentRegistry = Record<string, EnvironmentDefinition>;
|
|
183
|
+
declare function defineEnvironments<const Environments extends EnvironmentRegistry>(environments: Environments): Environments;
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/configuration/core/source.d.ts
|
|
186
|
+
type ConfigurationSourceKind = 'env' | 'by-environment' | 'compute' | 'static';
|
|
187
|
+
interface ConfigurationResolveContext<EnvironmentName extends string = string> {
|
|
188
|
+
readonly environment: EnvironmentConfig<EnvironmentName>;
|
|
189
|
+
readonly buildMetadata: BuildMetadata;
|
|
190
|
+
}
|
|
191
|
+
interface ConfigurationSource<Output = unknown> {
|
|
192
|
+
readonly kind: ConfigurationSourceKind;
|
|
193
|
+
readonly options: unknown;
|
|
194
|
+
readonly transforms: readonly ConfigurationSourceTransform[];
|
|
195
|
+
map<NextOutput>(transform: (value: Output, context: ConfigurationResolveContext) => NextOutput | Promise<NextOutput>): ConfigurationSource<NextOutput>;
|
|
196
|
+
}
|
|
197
|
+
declare function defineSource<const Environments extends Record<string, unknown>>(_environments: Environments): {
|
|
198
|
+
env(name: string): ConfigurationSource<string>;
|
|
199
|
+
byEnvironment<const Cases extends { readonly [Key in keyof Environments & string]: unknown; }>(cases: Cases): ConfigurationSource<InferSourceOutput<Cases[keyof Environments & string]>>;
|
|
200
|
+
compute<Output>(compute: (context: ConfigurationResolveContext<keyof Environments & string>) => Output | Promise<Output>): ConfigurationSource<Output>;
|
|
201
|
+
static<Output>(value: Output): ConfigurationSource<Output>;
|
|
202
|
+
};
|
|
203
|
+
type ConfigurationSourceTransform = (value: unknown, context: ConfigurationResolveContext) => unknown | Promise<unknown>;
|
|
204
|
+
type InferSourceOutput<T> = T extends ConfigurationSource<infer Output> ? Output : T extends ((...args: any[]) => any) ? T : T extends readonly [unknown, ...unknown[]] ? { readonly [Key in keyof T]: InferSourceOutput<T[Key]>; } : T extends readonly (infer Item)[] ? readonly InferSourceOutput<Item>[] : T extends object ? { readonly [Key in keyof T]: InferSourceOutput<T[Key]>; } : T;
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/configuration/core/configuration.d.ts
|
|
207
|
+
type ConfigurationSchema = ConfigurationField<any, boolean, any> | {
|
|
208
|
+
readonly [key: string]: ConfigurationSchema;
|
|
209
|
+
};
|
|
210
|
+
type InferSchemaOutput<Schema> = Schema extends ConfigurationField<infer Output, any, any> ? Output : Schema extends object ? { readonly [Key in keyof Schema]: InferSchemaOutput<Schema[Key]>; } : never;
|
|
211
|
+
type InferSchemaInput<Schema> = Schema extends ConfigurationField<any, any, infer Input> ? Input : Schema extends object ? { readonly [Key in RequiredSchemaKeys<Schema>]: InferSchemaInput<Schema[Key]>; } & { readonly [Key in OptionalSchemaKeys<Schema>]?: InferSchemaInput<Schema[Key]>; } : never;
|
|
212
|
+
type ConfigurationValueInput<T> = ConfigurationSource<T | undefined> | (T extends unknown ? ConfigurationValueInputValue<T> : never);
|
|
213
|
+
type ConfigurationInputFromSchema<Schema> = ConfigurationSource<InferSchemaInput<Schema> | undefined> | (Schema extends ConfigurationField<any, any, infer Input> ? ConfigurationValueInput<Input> : Schema extends object ? { readonly [Key in RequiredSchemaKeys<Schema>]: ConfigurationInputFromSchema<Schema[Key]>; } & { readonly [Key in OptionalSchemaKeys<Schema>]?: ConfigurationInputFromSchema<Schema[Key]>; } : never);
|
|
214
|
+
interface ConfigurationContract<Output, Schema extends ConfigurationSchema = ConfigurationSchema> {
|
|
215
|
+
readonly key: string;
|
|
216
|
+
readonly schema: Schema;
|
|
217
|
+
(input: ConfigurationInputFromSchema<Schema>): ConfigurationBinding<Output, Schema>;
|
|
218
|
+
}
|
|
219
|
+
interface ConfigurationBinding<Output = unknown, Schema extends ConfigurationSchema = ConfigurationSchema> {
|
|
220
|
+
readonly contract: ConfigurationContract<Output, Schema>;
|
|
221
|
+
readonly input: ConfigurationInputFromSchema<Schema>;
|
|
222
|
+
}
|
|
223
|
+
type InferConfiguration<Contract> = Contract extends ConfigurationContract<infer Output, any> ? Output : never;
|
|
224
|
+
declare function defineConfiguration<const Schema extends ConfigurationSchema>(key: string, schema: Schema): ConfigurationContract<InferSchemaOutput<Schema>, Schema>;
|
|
225
|
+
type ConfigurationValueInputValue<T> = T extends ((...args: any[]) => any) ? T : T extends readonly [unknown, ...unknown[]] ? { readonly [Key in keyof T]: ConfigurationValueInput<T[Key]>; } : T extends readonly (infer Item)[] ? readonly ConfigurationValueInput<Item>[] : T extends object ? { readonly [Key in keyof T]: ConfigurationValueInput<T[Key]>; } : T;
|
|
226
|
+
type IsSchemaInputRequired<Schema> = Schema extends ConfigurationField<any, infer Required, any> ? Required : Schema extends object ? RequiredSchemaKeys<Schema> extends never ? false : true : true;
|
|
227
|
+
type RequiredSchemaKeys<Schema extends object> = { [Key in keyof Schema]-?: IsSchemaInputRequired<Schema[Key]> extends true ? Key : never; }[keyof Schema];
|
|
228
|
+
type OptionalSchemaKeys<Schema extends object> = { [Key in keyof Schema]-?: IsSchemaInputRequired<Schema[Key]> extends true ? never : Key; }[keyof Schema];
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/configuration/configs/basic-auth.d.ts
|
|
231
|
+
type BasicAuthAuthenticate = FastifyBasicAuthOptions['authenticate'];
|
|
232
|
+
declare const BasicAuthConfiguration: ConfigurationContract<{
|
|
233
|
+
readonly enabled: boolean;
|
|
234
|
+
readonly authenticate: boolean | {
|
|
235
|
+
realm?: string | ((req: import("fastify").FastifyRequest) => string);
|
|
236
|
+
header?: string;
|
|
237
|
+
} | undefined;
|
|
238
|
+
readonly proxyMode: boolean;
|
|
239
|
+
readonly header: string | undefined;
|
|
240
|
+
readonly strictCredentials: boolean | undefined;
|
|
241
|
+
readonly username: string | undefined;
|
|
242
|
+
readonly password: string | undefined;
|
|
243
|
+
}, {
|
|
244
|
+
readonly enabled: ConfigurationField<boolean, false, string | boolean>;
|
|
245
|
+
readonly authenticate: ConfigurationField<boolean | {
|
|
246
|
+
realm?: string | ((req: import("fastify").FastifyRequest) => string);
|
|
247
|
+
header?: string;
|
|
248
|
+
} | undefined, false, boolean | {
|
|
249
|
+
realm?: string | ((req: import("fastify").FastifyRequest) => string);
|
|
250
|
+
header?: string;
|
|
251
|
+
} | undefined>;
|
|
252
|
+
readonly proxyMode: ConfigurationField<boolean, false, string | boolean>;
|
|
253
|
+
readonly header: ConfigurationField<string | undefined, false, string | null | undefined>;
|
|
254
|
+
readonly strictCredentials: ConfigurationField<boolean | undefined, false, string | boolean | null | undefined>;
|
|
255
|
+
readonly username: ConfigurationField<string | undefined, false, string | null | undefined>;
|
|
256
|
+
readonly password: ConfigurationField<string | undefined, false, string | null | undefined>;
|
|
257
|
+
}>;
|
|
258
|
+
type BasicAuthConfig = InferConfiguration<typeof BasicAuthConfiguration>;
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/configuration/configs/build.d.ts
|
|
261
|
+
declare const BuildConfiguration: ConfigurationContract<{
|
|
262
|
+
readonly outDir: string;
|
|
263
|
+
}, {
|
|
264
|
+
readonly outDir: ConfigurationField<string, false, string>;
|
|
265
|
+
}>;
|
|
266
|
+
type BuildConfig = InferConfiguration<typeof BuildConfiguration>;
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region src/configuration/configs/cors.d.ts
|
|
269
|
+
type CorsOptions = FastifyCorsOptions;
|
|
270
|
+
declare const CorsConfiguration: ConfigurationContract<{
|
|
271
|
+
readonly enabled: boolean;
|
|
272
|
+
readonly allowAllOrigins: boolean;
|
|
273
|
+
readonly includeWwwSubdomain: boolean;
|
|
274
|
+
readonly options: FastifyCorsOptions;
|
|
275
|
+
}, {
|
|
276
|
+
readonly enabled: ConfigurationField<boolean, false, string | boolean>;
|
|
277
|
+
readonly allowAllOrigins: ConfigurationField<boolean, false, string | boolean>;
|
|
278
|
+
readonly includeWwwSubdomain: ConfigurationField<boolean, false, string | boolean>;
|
|
279
|
+
readonly options: ConfigurationField<FastifyCorsOptions, false, FastifyCorsOptions>;
|
|
280
|
+
}>;
|
|
281
|
+
type CorsConfig = InferConfiguration<typeof CorsConfiguration>;
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/configuration/configs/email.d.ts
|
|
284
|
+
declare const EmailConfiguration: ConfigurationContract<{
|
|
285
|
+
readonly enabled: boolean;
|
|
286
|
+
readonly templatesPath: string;
|
|
287
|
+
readonly globals: Record<string, unknown>;
|
|
288
|
+
readonly smtp: {
|
|
289
|
+
readonly host: string | undefined;
|
|
290
|
+
readonly port: number | undefined;
|
|
291
|
+
readonly secure: boolean | undefined;
|
|
292
|
+
readonly user: string | undefined;
|
|
293
|
+
readonly password: string | undefined;
|
|
294
|
+
};
|
|
295
|
+
}, {
|
|
296
|
+
readonly enabled: ConfigurationField<boolean, false, string | boolean>;
|
|
297
|
+
readonly templatesPath: ConfigurationField<string, false, string>;
|
|
298
|
+
readonly globals: ConfigurationField<Record<string, unknown>, false, Record<string, unknown>>;
|
|
299
|
+
readonly smtp: {
|
|
300
|
+
readonly host: ConfigurationField<string | undefined, false, string | null | undefined>;
|
|
301
|
+
readonly port: ConfigurationField<number | undefined, false, string | number | null | undefined>;
|
|
302
|
+
readonly secure: ConfigurationField<boolean | undefined, false, string | boolean | null | undefined>;
|
|
303
|
+
readonly user: ConfigurationField<string | undefined, false, string | null | undefined>;
|
|
304
|
+
readonly password: ConfigurationField<string | undefined, false, string | null | undefined>;
|
|
305
|
+
};
|
|
306
|
+
}>;
|
|
307
|
+
type EmailConfig = InferConfiguration<typeof EmailConfiguration>;
|
|
308
|
+
//#endregion
|
|
309
|
+
//#region src/configuration/configs/health.d.ts
|
|
310
|
+
declare const HealthConfiguration: ConfigurationContract<{
|
|
311
|
+
readonly enabled: boolean;
|
|
312
|
+
readonly url: string;
|
|
313
|
+
readonly pressure: {
|
|
314
|
+
readonly maxEventLoopDelay: number;
|
|
315
|
+
readonly maxHeapUsedBytes: number;
|
|
316
|
+
readonly maxRssBytes: number;
|
|
317
|
+
readonly maxEventLoopUtilization: number;
|
|
318
|
+
};
|
|
319
|
+
}, {
|
|
320
|
+
readonly enabled: ConfigurationField<boolean, false, string | boolean>;
|
|
321
|
+
readonly url: ConfigurationField<string, false, string>;
|
|
322
|
+
readonly pressure: {
|
|
323
|
+
readonly maxEventLoopDelay: ConfigurationField<number, false, string | number>;
|
|
324
|
+
readonly maxHeapUsedBytes: ConfigurationField<number, false, string | number>;
|
|
325
|
+
readonly maxRssBytes: ConfigurationField<number, false, string | number>;
|
|
326
|
+
readonly maxEventLoopUtilization: ConfigurationField<number, false, string | number>;
|
|
327
|
+
};
|
|
328
|
+
}>;
|
|
329
|
+
type HealthConfig = InferConfiguration<typeof HealthConfiguration>;
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region src/configuration/configs/i18n.d.ts
|
|
332
|
+
interface I18nDirectoryEntry {
|
|
333
|
+
readonly path: string;
|
|
334
|
+
readonly namespace?: string;
|
|
335
|
+
}
|
|
336
|
+
interface I18nFileEntry {
|
|
337
|
+
readonly locale: string;
|
|
338
|
+
readonly path: string;
|
|
339
|
+
readonly namespace?: string;
|
|
340
|
+
}
|
|
341
|
+
type I18nInitOptions = InitOptions<object>;
|
|
342
|
+
type I18nFallbackLanguages = Extract<NonNullable<I18nInitOptions['fallbackLng']>, string | readonly string[]>;
|
|
343
|
+
type I18nLoadMode = NonNullable<I18nInitOptions['load']>;
|
|
344
|
+
type I18nPreload = NonNullable<I18nInitOptions['preload']>;
|
|
345
|
+
declare const I18nConfiguration: ConfigurationContract<{
|
|
346
|
+
readonly resources: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
347
|
+
readonly directories: readonly I18nDirectoryEntry[];
|
|
348
|
+
readonly files: readonly I18nFileEntry[];
|
|
349
|
+
readonly defaultLanguage: string;
|
|
350
|
+
readonly fallbackLanguages: I18nFallbackLanguages;
|
|
351
|
+
readonly supportedLanguages: readonly string[];
|
|
352
|
+
readonly load: I18nLoadMode;
|
|
353
|
+
readonly preload: I18nPreload;
|
|
354
|
+
readonly nonExplicitSupportedLngs: boolean;
|
|
355
|
+
readonly lowerCaseLng: boolean;
|
|
356
|
+
readonly cleanCode: boolean;
|
|
357
|
+
readonly namespaces: readonly string[] | undefined;
|
|
358
|
+
readonly defaultNamespace: string;
|
|
359
|
+
readonly keySeparator: string;
|
|
360
|
+
readonly nsSeparator: string;
|
|
361
|
+
readonly pluralSeparator: string;
|
|
362
|
+
readonly contextSeparator: string;
|
|
363
|
+
}, {
|
|
364
|
+
readonly resources: ConfigurationField<Readonly<Record<string, Readonly<Record<string, unknown>>>>, false, Readonly<Record<string, Readonly<Record<string, unknown>>>>>;
|
|
365
|
+
readonly directories: ConfigurationField<readonly I18nDirectoryEntry[], false, readonly I18nDirectoryEntry[]>;
|
|
366
|
+
readonly files: ConfigurationField<readonly I18nFileEntry[], false, readonly I18nFileEntry[]>;
|
|
367
|
+
readonly defaultLanguage: ConfigurationField<string, false, string>;
|
|
368
|
+
readonly fallbackLanguages: ConfigurationField<I18nFallbackLanguages, false, I18nFallbackLanguages>;
|
|
369
|
+
readonly supportedLanguages: ConfigurationField<readonly string[], false, readonly string[]>;
|
|
370
|
+
readonly load: ConfigurationField<I18nLoadMode, false, I18nLoadMode>;
|
|
371
|
+
readonly preload: ConfigurationField<I18nPreload, false, I18nPreload>;
|
|
372
|
+
readonly nonExplicitSupportedLngs: ConfigurationField<boolean, false, string | boolean>;
|
|
373
|
+
readonly lowerCaseLng: ConfigurationField<boolean, false, string | boolean>;
|
|
374
|
+
readonly cleanCode: ConfigurationField<boolean, false, string | boolean>;
|
|
375
|
+
readonly namespaces: ConfigurationField<readonly string[] | undefined, false, readonly string[] | null | undefined>;
|
|
376
|
+
readonly defaultNamespace: ConfigurationField<string, false, string>;
|
|
377
|
+
readonly keySeparator: ConfigurationField<string, false, string>;
|
|
378
|
+
readonly nsSeparator: ConfigurationField<string, false, string>;
|
|
379
|
+
readonly pluralSeparator: ConfigurationField<string, false, string>;
|
|
380
|
+
readonly contextSeparator: ConfigurationField<string, false, string>;
|
|
381
|
+
}>;
|
|
382
|
+
type I18nConfig = InferConfiguration<typeof I18nConfiguration>;
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/configuration/configs/logger.d.ts
|
|
385
|
+
interface LoggerRequestOptions {
|
|
386
|
+
/**
|
|
387
|
+
* @description Additional request paths skipped by the ApiKit request logger.
|
|
388
|
+
*
|
|
389
|
+
* ApiKit skips enabled internal endpoints automatically:
|
|
390
|
+
* - `health.url`
|
|
391
|
+
* - `metrics.endpoint`
|
|
392
|
+
*
|
|
393
|
+
* Matching is path-based and ignores query strings.
|
|
394
|
+
*
|
|
395
|
+
* @default []
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* ```ts
|
|
399
|
+
* logger: {
|
|
400
|
+
* enabled: true,
|
|
401
|
+
* transports: [{ type: 'file', path: from.env('LOGGER_PATH') }],
|
|
402
|
+
* request: {
|
|
403
|
+
* ignoredPaths: ['/internal/ping'],
|
|
404
|
+
* },
|
|
405
|
+
* }
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
readonly ignoredPaths?: readonly string[];
|
|
409
|
+
}
|
|
410
|
+
type LoggerConfigurationValue = {
|
|
411
|
+
readonly enabled: false;
|
|
412
|
+
readonly transports?: never;
|
|
413
|
+
readonly request?: never;
|
|
414
|
+
} | {
|
|
415
|
+
readonly enabled: true;
|
|
416
|
+
readonly transports: readonly [LoggerTransportOptions, ...LoggerTransportOptions[]];
|
|
417
|
+
readonly request?: LoggerRequestOptions;
|
|
418
|
+
};
|
|
419
|
+
declare const LoggerConfiguration: ConfigurationContract<LoggerConfigurationValue, ConfigurationField<LoggerConfigurationValue, false, LoggerConfigurationValue>>;
|
|
420
|
+
type LoggerConfig = InferConfiguration<typeof LoggerConfiguration>;
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region src/configuration/configs/metrics.d.ts
|
|
423
|
+
type MetricsEndpoint = string | null | RouteOptions;
|
|
424
|
+
interface MetricsDefaultConfig {
|
|
425
|
+
readonly enabled: boolean;
|
|
426
|
+
}
|
|
427
|
+
interface MetricsRouteConfig {
|
|
428
|
+
readonly enabled?: boolean | {
|
|
429
|
+
readonly histogram?: boolean;
|
|
430
|
+
readonly summary?: boolean;
|
|
431
|
+
};
|
|
432
|
+
readonly registeredRoutesOnly?: boolean;
|
|
433
|
+
readonly groupStatusCodes?: boolean;
|
|
434
|
+
readonly routeBlacklist?: readonly (string | RegExp)[];
|
|
435
|
+
readonly methodBlacklist?: readonly string[];
|
|
436
|
+
readonly invalidRouteGroup?: string;
|
|
437
|
+
}
|
|
438
|
+
declare const MetricsConfiguration: ConfigurationContract<{
|
|
439
|
+
readonly enabled: boolean;
|
|
440
|
+
readonly endpoint: MetricsEndpoint;
|
|
441
|
+
readonly name: string;
|
|
442
|
+
readonly defaultMetrics: MetricsDefaultConfig;
|
|
443
|
+
readonly routeMetrics: MetricsRouteConfig;
|
|
444
|
+
readonly clearRegisterOnInit: boolean;
|
|
445
|
+
}, {
|
|
446
|
+
readonly enabled: ConfigurationField<boolean, false, string | boolean>;
|
|
447
|
+
readonly endpoint: ConfigurationField<MetricsEndpoint, false, MetricsEndpoint>;
|
|
448
|
+
readonly name: ConfigurationField<string, false, string>;
|
|
449
|
+
readonly defaultMetrics: ConfigurationField<MetricsDefaultConfig, false, MetricsDefaultConfig>;
|
|
450
|
+
readonly routeMetrics: ConfigurationField<MetricsRouteConfig, false, MetricsRouteConfig>;
|
|
451
|
+
readonly clearRegisterOnInit: ConfigurationField<boolean, false, string | boolean>;
|
|
452
|
+
}>;
|
|
453
|
+
type MetricsConfig = InferConfiguration<typeof MetricsConfiguration>;
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region src/configuration/configs/multipart.d.ts
|
|
456
|
+
type MultipartOptions = FastifyMultipartBaseOptions | FastifyMultipartOptions | FastifyMultipartAttachFieldsToBodyOptions;
|
|
457
|
+
declare const MultipartConfiguration: ConfigurationContract<{
|
|
458
|
+
readonly enabled: boolean;
|
|
459
|
+
readonly options: MultipartOptions;
|
|
460
|
+
}, {
|
|
461
|
+
readonly enabled: ConfigurationField<boolean, false, string | boolean>;
|
|
462
|
+
readonly options: ConfigurationField<MultipartOptions, false, MultipartOptions>;
|
|
463
|
+
}>;
|
|
464
|
+
type MultipartConfig = InferConfiguration<typeof MultipartConfiguration>;
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/configuration/configs/notification.d.ts
|
|
467
|
+
interface TelegramNotificationConfig {
|
|
468
|
+
readonly token: string;
|
|
469
|
+
readonly chatId: string;
|
|
470
|
+
}
|
|
471
|
+
interface NotificationChannelsConfig {
|
|
472
|
+
readonly telegram?: TelegramNotificationConfig;
|
|
473
|
+
}
|
|
474
|
+
type NotificationConfigurationValue = {
|
|
475
|
+
readonly enabled: false;
|
|
476
|
+
readonly channels?: never;
|
|
477
|
+
} | {
|
|
478
|
+
readonly enabled: true;
|
|
479
|
+
readonly channels: NotificationChannelsConfig;
|
|
480
|
+
};
|
|
481
|
+
declare const NotificationConfiguration: ConfigurationContract<NotificationConfigurationValue, ConfigurationField<NotificationConfigurationValue, false, NotificationConfigurationValue>>;
|
|
482
|
+
type NotificationConfig = InferConfiguration<typeof NotificationConfiguration>;
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region src/configuration/configs/server.d.ts
|
|
485
|
+
type TrustProxy = boolean | string | number | string[] | ((address: string, hop: number) => boolean);
|
|
486
|
+
declare const ServerConfiguration: ConfigurationContract<{
|
|
487
|
+
readonly identifier: string;
|
|
488
|
+
readonly debug: boolean;
|
|
489
|
+
readonly host: string;
|
|
490
|
+
readonly port: number;
|
|
491
|
+
readonly trustProxy: TrustProxy;
|
|
492
|
+
}, {
|
|
493
|
+
readonly identifier: ConfigurationField<string, true, string>;
|
|
494
|
+
readonly debug: ConfigurationField<boolean, false, string | boolean>;
|
|
495
|
+
readonly host: ConfigurationField<string, true, string>;
|
|
496
|
+
readonly port: ConfigurationField<number, true, string | number>;
|
|
497
|
+
readonly trustProxy: ConfigurationField<TrustProxy, false, TrustProxy>;
|
|
498
|
+
}>;
|
|
499
|
+
type ServerConfig = InferConfiguration<typeof ServerConfiguration>;
|
|
500
|
+
//#endregion
|
|
501
|
+
//#region src/configuration/configs/static-files.d.ts
|
|
502
|
+
type StaticFilesDotfilesMode = NonNullable<FastifyStaticOptions['dotfiles']>;
|
|
503
|
+
declare const StaticFilesConfiguration: ConfigurationContract<{
|
|
504
|
+
readonly enabled: boolean;
|
|
505
|
+
readonly publicDirectory: string | undefined;
|
|
506
|
+
readonly routePrefix: string;
|
|
507
|
+
readonly maxAge: number;
|
|
508
|
+
readonly dotfiles: StaticFilesDotfilesMode;
|
|
509
|
+
readonly etag: boolean;
|
|
510
|
+
readonly immutable: boolean;
|
|
511
|
+
readonly decorateReply: boolean;
|
|
512
|
+
readonly preCompressed: boolean;
|
|
513
|
+
}, {
|
|
514
|
+
readonly enabled: ConfigurationField<boolean, false, string | boolean>;
|
|
515
|
+
readonly publicDirectory: ConfigurationField<string | undefined, false, string | null | undefined>;
|
|
516
|
+
readonly routePrefix: ConfigurationField<string, false, string>;
|
|
517
|
+
readonly maxAge: ConfigurationField<number, false, string | number>;
|
|
518
|
+
readonly dotfiles: ConfigurationField<StaticFilesDotfilesMode, false, StaticFilesDotfilesMode>;
|
|
519
|
+
readonly etag: ConfigurationField<boolean, false, string | boolean>;
|
|
520
|
+
readonly immutable: ConfigurationField<boolean, false, string | boolean>;
|
|
521
|
+
readonly decorateReply: ConfigurationField<boolean, false, string | boolean>;
|
|
522
|
+
readonly preCompressed: ConfigurationField<boolean, false, string | boolean>;
|
|
523
|
+
}>;
|
|
524
|
+
type StaticFilesConfig = InferConfiguration<typeof StaticFilesConfiguration>;
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region src/configuration/config.d.ts
|
|
527
|
+
interface DefineApiKitInput {
|
|
528
|
+
readonly build?: InputOf<typeof BuildConfiguration>;
|
|
529
|
+
readonly server: InputOf<typeof ServerConfiguration>;
|
|
530
|
+
readonly logger?: InputOf<typeof LoggerConfiguration>;
|
|
531
|
+
readonly metrics?: InputOf<typeof MetricsConfiguration>;
|
|
532
|
+
readonly health?: InputOf<typeof HealthConfiguration>;
|
|
533
|
+
readonly email?: InputOf<typeof EmailConfiguration>;
|
|
534
|
+
readonly notification?: InputOf<typeof NotificationConfiguration>;
|
|
535
|
+
readonly i18n?: InputOf<typeof I18nConfiguration>;
|
|
536
|
+
readonly staticFiles?: InputOf<typeof StaticFilesConfiguration>;
|
|
537
|
+
readonly basicAuth?: InputOf<typeof BasicAuthConfiguration>;
|
|
538
|
+
readonly cors?: InputOf<typeof CorsConfiguration>;
|
|
539
|
+
readonly multipart?: InputOf<typeof MultipartConfiguration>;
|
|
540
|
+
readonly configurations?: readonly ExtensionConfigurationBinding[];
|
|
541
|
+
}
|
|
542
|
+
interface ApiKitConfig<Environments extends EnvironmentRegistry = EnvironmentRegistry> extends DefineApiKitInput {
|
|
543
|
+
readonly environments: Environments;
|
|
544
|
+
readonly configurations: readonly ExtensionConfigurationBinding[];
|
|
545
|
+
}
|
|
546
|
+
type InputOf<Contract extends ConfigurationContract<any, ConfigurationSchema>> = Contract extends ConfigurationContract<any, infer Schema> ? ConfigurationInputFromSchema<Schema> : never;
|
|
547
|
+
type ExtensionConfigurationBinding = ConfigurationBinding<any, any>;
|
|
548
|
+
//#endregion
|
|
549
|
+
//#region src/configuration/controller.d.ts
|
|
550
|
+
interface ApiKitController {
|
|
551
|
+
get build(): BuildMetadata;
|
|
552
|
+
get isDebug(): boolean;
|
|
553
|
+
get environment(): EnvironmentConfig;
|
|
554
|
+
get logger(): LoggerConfig;
|
|
555
|
+
get server(): ServerConfig;
|
|
556
|
+
get metrics(): MetricsConfig;
|
|
557
|
+
get health(): HealthConfig;
|
|
558
|
+
get email(): EmailConfig;
|
|
559
|
+
get notification(): NotificationConfig;
|
|
560
|
+
get i18n(): I18nConfig;
|
|
561
|
+
get staticFiles(): StaticFilesConfig;
|
|
562
|
+
get basicAuth(): BasicAuthConfig;
|
|
563
|
+
get cors(): CorsConfig;
|
|
564
|
+
get multipart(): MultipartConfig;
|
|
565
|
+
get<T>(configuration: ConfigurationContract<T, any>): T;
|
|
566
|
+
optional<T>(configuration: ConfigurationContract<T, any>): T | undefined;
|
|
567
|
+
}
|
|
568
|
+
declare class ApiKitControllerImpl implements ApiKitController {
|
|
569
|
+
get build(): BuildMetadata;
|
|
570
|
+
get isDebug(): boolean;
|
|
571
|
+
get environment(): EnvironmentConfig;
|
|
572
|
+
get logger(): LoggerConfig;
|
|
573
|
+
get server(): ServerConfig;
|
|
574
|
+
get metrics(): MetricsConfig;
|
|
575
|
+
get health(): HealthConfig;
|
|
576
|
+
get email(): EmailConfig;
|
|
577
|
+
get notification(): NotificationConfig;
|
|
578
|
+
get i18n(): I18nConfig;
|
|
579
|
+
get staticFiles(): StaticFilesConfig;
|
|
580
|
+
get basicAuth(): BasicAuthConfig;
|
|
581
|
+
get cors(): CorsConfig;
|
|
582
|
+
get multipart(): MultipartConfig;
|
|
583
|
+
get<T>(configuration: ConfigurationContract<T, any>): T;
|
|
584
|
+
optional<T>(configuration: ConfigurationContract<T, any>): T | undefined;
|
|
585
|
+
}
|
|
586
|
+
//#endregion
|
|
587
|
+
//#region src/configuration/define.d.ts
|
|
588
|
+
declare function defineApiKit<const Environments extends EnvironmentRegistry>(environments: Environments, input: DefineApiKitInput): ApiKitConfig<Environments>;
|
|
589
|
+
//#endregion
|
|
590
|
+
//#region src/configuration/load-context.d.ts
|
|
591
|
+
interface LoadApiKitContextOptions {
|
|
592
|
+
readonly environment: string;
|
|
593
|
+
readonly config?: string;
|
|
594
|
+
}
|
|
595
|
+
declare function loadApiKitContext(options: LoadApiKitContextOptions): Promise<void>;
|
|
596
|
+
//#endregion
|
|
597
|
+
//#region types/global.d.ts
|
|
598
|
+
declare global {
|
|
599
|
+
var apikit: {
|
|
600
|
+
build: BuildMetadata;
|
|
601
|
+
environmentConfig: EnvironmentConfig;
|
|
602
|
+
loggerConfig: LoggerConfig;
|
|
603
|
+
serverConfig: ServerConfig;
|
|
604
|
+
metricsConfig: MetricsConfig;
|
|
605
|
+
healthConfig: HealthConfig;
|
|
606
|
+
emailConfig: EmailConfig;
|
|
607
|
+
notificationConfig: NotificationConfig;
|
|
608
|
+
i18nConfig: I18nConfig;
|
|
609
|
+
staticFilesConfig: StaticFilesConfig;
|
|
610
|
+
basicAuthConfig: BasicAuthConfig;
|
|
611
|
+
corsConfig: CorsConfig;
|
|
612
|
+
multipartConfig: MultipartConfig;
|
|
613
|
+
configurations: ReadonlyMap<string, unknown>;
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region src/database/mongodb-query.d.ts
|
|
618
|
+
type MongoDbQuery<T> = MongoDbFieldQuery<T> & MongoDbLogicalOperators<T>;
|
|
619
|
+
type MongoDbFieldQuery<T> = { [K in keyof T]?: MongoDbFieldValue<T[K]>; };
|
|
620
|
+
type MongoDbFieldValue<V> = V | MongoDbComparisonOperators<V> | (V extends object ? MongoDbFieldQuery<V> : never);
|
|
621
|
+
type MongoDbLogicalOperators<T> = {
|
|
622
|
+
$and?: MongoDbQuery<T>[];
|
|
623
|
+
$or?: MongoDbQuery<T>[];
|
|
624
|
+
$nor?: MongoDbQuery<T>[];
|
|
625
|
+
$not?: MongoDbQuery<T>;
|
|
626
|
+
$expr?: Record<string, any>;
|
|
627
|
+
};
|
|
628
|
+
type MongoDbComparisonOperators<V> = {
|
|
629
|
+
$eq?: V;
|
|
630
|
+
$ne?: V;
|
|
631
|
+
$gt?: V;
|
|
632
|
+
$gte?: V;
|
|
633
|
+
$lt?: V;
|
|
634
|
+
$lte?: V;
|
|
635
|
+
$in?: V[];
|
|
636
|
+
$nin?: V[];
|
|
637
|
+
$exists?: boolean;
|
|
638
|
+
$regex?: V extends string ? string | RegExp : never;
|
|
639
|
+
};
|
|
640
|
+
interface MongoDbUpdateOptions {
|
|
641
|
+
/**
|
|
642
|
+
* If true, creates a new document when no document matches the query.
|
|
643
|
+
* Equivalent to `INSERT if not exists`.
|
|
644
|
+
*/
|
|
645
|
+
upsert?: boolean;
|
|
646
|
+
/**
|
|
647
|
+
* If true, returns the updated document.
|
|
648
|
+
* If false, returns the document as it was before the update.
|
|
649
|
+
* Defaults to `true` in most framework layers.
|
|
650
|
+
*/
|
|
651
|
+
new?: boolean;
|
|
652
|
+
/**
|
|
653
|
+
* If true, applies schema-level validations before applying the update.
|
|
654
|
+
* Useful for ensuring data consistency.
|
|
655
|
+
*/
|
|
656
|
+
runValidators?: boolean;
|
|
657
|
+
/**
|
|
658
|
+
* If true, replaces the entire document instead of performing a `$set` update.
|
|
659
|
+
* Use this with caution — all unspecified fields will be removed.
|
|
660
|
+
*/
|
|
661
|
+
overwrite?: boolean;
|
|
662
|
+
/**
|
|
663
|
+
* If true, returns a plain JavaScript object instead of a Mongoose document.
|
|
664
|
+
* Improves performance if you don’t need Mongoose features like getters or methods.
|
|
665
|
+
*/
|
|
666
|
+
lean?: boolean;
|
|
667
|
+
/**
|
|
668
|
+
* Selects specific fields to include (`1`) or exclude (`0`) in the returned document.
|
|
669
|
+
* Example: `{ name: 1, email: 1 }` or `{ password: 0 }`
|
|
670
|
+
*/
|
|
671
|
+
projection?: Record<string, 0 | 1>;
|
|
672
|
+
/**
|
|
673
|
+
* Controls how unknown fields are handled.
|
|
674
|
+
* - `true`: strip unknown fields (default mongoose behavior)
|
|
675
|
+
* - `false`: allow unknown fields
|
|
676
|
+
* - `'throw'`: raise an error on unknown fields
|
|
677
|
+
*/
|
|
678
|
+
strict?: boolean | 'throw';
|
|
679
|
+
/**
|
|
680
|
+
* When used with `upsert: true`, applies schema defaults
|
|
681
|
+
* to newly inserted documents.
|
|
682
|
+
*/
|
|
683
|
+
setDefaultsOnInsert?: boolean;
|
|
684
|
+
/**
|
|
685
|
+
* Overrides schema-level timestamps for this operation.
|
|
686
|
+
* Set to `false` to skip updating `updatedAt` / `createdAt`.
|
|
687
|
+
*/
|
|
688
|
+
timestamps?: boolean;
|
|
689
|
+
/**
|
|
690
|
+
* If true, returns the raw MongoDB result object
|
|
691
|
+
* instead of the mapped document.
|
|
692
|
+
*/
|
|
693
|
+
rawResult?: boolean;
|
|
694
|
+
/**
|
|
695
|
+
* Maximum time in milliseconds the server should spend
|
|
696
|
+
* processing this update before aborting.
|
|
697
|
+
*/
|
|
698
|
+
maxTimeMS?: number;
|
|
699
|
+
}
|
|
700
|
+
//#endregion
|
|
701
|
+
//#region src/database/mongodb-query-formatter.d.ts
|
|
702
|
+
/**
|
|
703
|
+
* Flattens a potentially nested MongoDbQuery<T> into a single-level filter object.
|
|
704
|
+
*
|
|
705
|
+
* - Skips any `undefined` values.
|
|
706
|
+
* - Skips any empty plain objects (`{}`).
|
|
707
|
+
* - Preserves MongoDB operators (keys starting with `$`).
|
|
708
|
+
* - Flattens nested fields into dot-notation (e.g. `{ a: { b: 5 } }` → `{ "a.b": 5 }`).
|
|
709
|
+
*/
|
|
710
|
+
interface MongoDbQueryFormatter {
|
|
711
|
+
/**
|
|
712
|
+
* @template T
|
|
713
|
+
* @param query
|
|
714
|
+
* Possibly nested query filters.
|
|
715
|
+
* @returns
|
|
716
|
+
* A flat filter with no `undefined` or empty-object keys.
|
|
717
|
+
*/
|
|
718
|
+
format<T>(query: MongoDbQuery<T>): Record<string, any>;
|
|
719
|
+
}
|
|
720
|
+
declare class MongoDbQueryFormatterImpl implements MongoDbQueryFormatter {
|
|
721
|
+
/**
|
|
722
|
+
* Flattens the provided query object into a single-level map.
|
|
723
|
+
*
|
|
724
|
+
* @template T
|
|
725
|
+
* @param query
|
|
726
|
+
* Possibly nested query filters.
|
|
727
|
+
* @returns
|
|
728
|
+
* A flat filter with no `undefined` or empty-object keys.
|
|
729
|
+
*/
|
|
730
|
+
format<T>(query: MongoDbQuery<T>): Record<string, any>;
|
|
731
|
+
/**
|
|
732
|
+
* Recursively traverses `input` to build a flat filter map.
|
|
733
|
+
*
|
|
734
|
+
* - Skips `undefined` values.
|
|
735
|
+
* - Skips empty plain objects (`{}`).
|
|
736
|
+
* - Preserves MongoDB operator keys (starting with `$`).
|
|
737
|
+
* - Flattens nested objects (without operators) into dot-notation keys.
|
|
738
|
+
*
|
|
739
|
+
* @param input
|
|
740
|
+
* The current subtree to flatten.
|
|
741
|
+
* @param path
|
|
742
|
+
* Dot-notation prefix (empty for top-level).
|
|
743
|
+
* @returns
|
|
744
|
+
* The accumulated flat filter for this branch.
|
|
745
|
+
*/
|
|
746
|
+
private flattenRecursive;
|
|
747
|
+
/**
|
|
748
|
+
* Checks if a key is a MongoDB operator (starts with `$`).
|
|
749
|
+
*
|
|
750
|
+
* @param key
|
|
751
|
+
* @returns
|
|
752
|
+
* True if the key begins with `$`.
|
|
753
|
+
*/
|
|
754
|
+
private isOperator;
|
|
755
|
+
/**
|
|
756
|
+
* Determines whether `obj` has any keys that start with `$`.
|
|
757
|
+
*
|
|
758
|
+
* @param obj
|
|
759
|
+
* @returns
|
|
760
|
+
* True if at least one key begins with `$`.
|
|
761
|
+
*/
|
|
762
|
+
private containsOperator;
|
|
763
|
+
/**
|
|
764
|
+
* Checks if `val` is a plain object (i.e., `{ ... }`).
|
|
765
|
+
* Returns false for arrays, Date objects, and other non-plain values.
|
|
766
|
+
*
|
|
767
|
+
* @param val
|
|
768
|
+
* @returns
|
|
769
|
+
* True if `val` is a non-null object whose prototype is `Object.prototype`.
|
|
770
|
+
*/
|
|
771
|
+
private isPlainObject;
|
|
772
|
+
/**
|
|
773
|
+
* Handles the contents of a MongoDB operator clause:
|
|
774
|
+
*
|
|
775
|
+
* - For `$expr`, return as-is (aggregation expression).
|
|
776
|
+
* - If the operator’s value is an array (e.g. `$or: [ {...}, {...} ]`),
|
|
777
|
+
* flatten each element recursively.
|
|
778
|
+
* - If the operator’s value is a nested object (e.g. `$gt: 5`), flatten that object.
|
|
779
|
+
* - Otherwise, return the primitive/RegExp as-is.
|
|
780
|
+
*
|
|
781
|
+
* @param key
|
|
782
|
+
* The operator name (e.g. `"$or"`, `"$gt"`).
|
|
783
|
+
* @param value
|
|
784
|
+
* The operator’s value.
|
|
785
|
+
* @returns
|
|
786
|
+
* The processed operator value.
|
|
787
|
+
*/
|
|
788
|
+
private processOperator;
|
|
789
|
+
}
|
|
790
|
+
//#endregion
|
|
791
|
+
//#region src/di/symbols.d.ts
|
|
792
|
+
declare const ApiKitSymbols: {
|
|
793
|
+
DI: {
|
|
794
|
+
Configuration: {
|
|
795
|
+
Controller: symbol;
|
|
796
|
+
};
|
|
797
|
+
Database: {
|
|
798
|
+
MongoDB: {
|
|
799
|
+
QueryFormatter: symbol;
|
|
800
|
+
};
|
|
801
|
+
};
|
|
802
|
+
Email: {
|
|
803
|
+
Controller: symbol;
|
|
804
|
+
};
|
|
805
|
+
File: {
|
|
806
|
+
TemporaryRepository: symbol;
|
|
807
|
+
};
|
|
808
|
+
Validation: {
|
|
809
|
+
Controller: symbol;
|
|
810
|
+
DtoController: symbol;
|
|
811
|
+
};
|
|
812
|
+
OpenAPI: {
|
|
813
|
+
SchemaController: symbol;
|
|
814
|
+
};
|
|
815
|
+
I18n: {
|
|
816
|
+
Controller: symbol;
|
|
817
|
+
};
|
|
818
|
+
Notification: {
|
|
819
|
+
Controller: symbol;
|
|
820
|
+
};
|
|
821
|
+
Normalization: {
|
|
822
|
+
Controller: symbol;
|
|
823
|
+
};
|
|
824
|
+
Formatter: {
|
|
825
|
+
Controller: symbol;
|
|
826
|
+
MultipartController: symbol;
|
|
827
|
+
};
|
|
828
|
+
Generator: {
|
|
829
|
+
RandomValueGenerator: symbol;
|
|
830
|
+
};
|
|
831
|
+
Image: {
|
|
832
|
+
NormalizationController: symbol;
|
|
833
|
+
};
|
|
834
|
+
Server: {
|
|
835
|
+
Controller: symbol;
|
|
836
|
+
RequestController: symbol;
|
|
837
|
+
ResponseController: symbol;
|
|
838
|
+
};
|
|
839
|
+
Security: {
|
|
840
|
+
CryptographyController: symbol;
|
|
841
|
+
};
|
|
842
|
+
};
|
|
843
|
+
};
|
|
844
|
+
//#endregion
|
|
845
|
+
//#region src/email/email-controller.d.ts
|
|
846
|
+
interface EmailController {
|
|
847
|
+
sendEmail(template: EmailTemplate): Promise<void>;
|
|
848
|
+
}
|
|
849
|
+
declare class EmailControllerImpl implements EmailController {
|
|
850
|
+
private readonly configuration;
|
|
851
|
+
private readonly logger;
|
|
852
|
+
private transporter?;
|
|
853
|
+
private readonly templatesPath;
|
|
854
|
+
private readonly isEnabled;
|
|
855
|
+
private readonly smtpConfig;
|
|
856
|
+
constructor(configuration: ApiKitController, logger: Logger);
|
|
857
|
+
sendEmail(template: EmailTemplate): Promise<void>;
|
|
858
|
+
private getOrCreateTransporter;
|
|
859
|
+
private renderTemplate;
|
|
860
|
+
private makeFilePath;
|
|
861
|
+
private makeGlobals;
|
|
862
|
+
private sanitizeTemplatePath;
|
|
863
|
+
}
|
|
864
|
+
//#endregion
|
|
865
|
+
//#region src/email/email-template.d.ts
|
|
866
|
+
/**
|
|
867
|
+
* Represents the resolved structure of an email template.
|
|
868
|
+
*
|
|
869
|
+
* @template TData - Type of the data passed to the template.
|
|
870
|
+
*/
|
|
871
|
+
interface EmailTemplate<TData extends object = object> {
|
|
872
|
+
data: TData;
|
|
873
|
+
recipient: string;
|
|
874
|
+
sender: string;
|
|
875
|
+
subject: string;
|
|
876
|
+
templatePath: string;
|
|
877
|
+
fallbackPath?: string;
|
|
878
|
+
replyTo?: string;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Input used to construct an email template.
|
|
882
|
+
*
|
|
883
|
+
* @template TData - Type of the data passed to the template.
|
|
884
|
+
*/
|
|
885
|
+
type EmailTemplateInput<TData extends object> = {
|
|
886
|
+
data: TData;
|
|
887
|
+
recipient: string;
|
|
888
|
+
sender?: string;
|
|
889
|
+
replyTo?: string;
|
|
890
|
+
subject?: string;
|
|
891
|
+
};
|
|
892
|
+
/**
|
|
893
|
+
* Abstract base class to simplify creating email templates.
|
|
894
|
+
*
|
|
895
|
+
* @template TData - Type of the data passed to the template.
|
|
896
|
+
*/
|
|
897
|
+
declare abstract class BaseEmailTemplate<TData extends object> implements EmailTemplate<TData> {
|
|
898
|
+
data: TData;
|
|
899
|
+
recipient: string;
|
|
900
|
+
sender: string;
|
|
901
|
+
subject: string;
|
|
902
|
+
replyTo?: string;
|
|
903
|
+
constructor(input: EmailTemplateInput<TData>);
|
|
904
|
+
/**
|
|
905
|
+
* Provides the relative path to the EJS template file.
|
|
906
|
+
*/
|
|
907
|
+
abstract get templatePath(): string;
|
|
908
|
+
/**
|
|
909
|
+
* Provides an optional fallback path to the EJS template.
|
|
910
|
+
*/
|
|
911
|
+
get fallbackPath(): string | undefined;
|
|
912
|
+
/**
|
|
913
|
+
* Provides a default sender if none is explicitly passed.
|
|
914
|
+
*/
|
|
915
|
+
protected abstract defaultSender(): string;
|
|
916
|
+
/**
|
|
917
|
+
* Provides a default subject if none is explicitly passed.
|
|
918
|
+
*/
|
|
919
|
+
protected abstract defaultSubject(): string;
|
|
920
|
+
}
|
|
921
|
+
//#endregion
|
|
922
|
+
//#region src/error/api-error.d.ts
|
|
923
|
+
type ApiErrorDetails = unknown;
|
|
924
|
+
interface ApiErrorProperties {
|
|
925
|
+
code: string;
|
|
926
|
+
message: string;
|
|
927
|
+
statusCode: number;
|
|
928
|
+
details?: ApiErrorDetails;
|
|
929
|
+
}
|
|
930
|
+
declare class ApiError extends Error implements ApiErrorProperties, JSONSerializable {
|
|
931
|
+
private _code;
|
|
932
|
+
private _statusCode;
|
|
933
|
+
private _details?;
|
|
934
|
+
constructor({ code, message, statusCode, details }: ApiErrorProperties);
|
|
935
|
+
get code(): string;
|
|
936
|
+
get statusCode(): number;
|
|
937
|
+
get details(): ApiErrorDetails | undefined;
|
|
938
|
+
toJSON(): any;
|
|
939
|
+
private formatDetails;
|
|
940
|
+
}
|
|
941
|
+
//#endregion
|
|
942
|
+
//#region src/error/api-error-definition.d.ts
|
|
943
|
+
/**
|
|
944
|
+
* @description Metadata attached to a localized API error response.
|
|
945
|
+
*/
|
|
946
|
+
interface ApiErrorDefinition {
|
|
947
|
+
/**
|
|
948
|
+
* @description L10n key used for the public error message.
|
|
949
|
+
*/
|
|
950
|
+
message: string;
|
|
951
|
+
/**
|
|
952
|
+
* @description Machine-readable error code.
|
|
953
|
+
*/
|
|
954
|
+
code: string;
|
|
955
|
+
/**
|
|
956
|
+
* @description Associated HTTP status code.
|
|
957
|
+
*/
|
|
958
|
+
statusCode: number;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* @description Recursive object structure for organizing API error definitions.
|
|
962
|
+
*/
|
|
963
|
+
type ApiErrorTree = {
|
|
964
|
+
[key: string]: ApiErrorTree | ApiErrorDefinition;
|
|
965
|
+
};
|
|
966
|
+
/**
|
|
967
|
+
* @description Dot-separated path to an API error definition in a nested error tree.
|
|
968
|
+
*/
|
|
969
|
+
type ApiErrorPath<TTree extends ApiErrorTree> = { [TKey in keyof TTree & string]: TTree[TKey] extends ApiErrorDefinition ? TKey : TTree[TKey] extends ApiErrorTree ? `${TKey}.${ApiErrorPath<TTree[TKey]>}` : never; }[keyof TTree & string];
|
|
970
|
+
declare function isApiErrorDefinition(value: ApiErrorTree | ApiErrorDefinition | undefined): value is ApiErrorDefinition;
|
|
971
|
+
//#endregion
|
|
972
|
+
//#region src/i18n/i18n-controller.d.ts
|
|
973
|
+
interface ParseLocaleOptions {
|
|
974
|
+
/**
|
|
975
|
+
* If true, always ignore region (e.g., "en-GB" → "en").
|
|
976
|
+
* Useful when you only ship base locales.
|
|
977
|
+
* @default true
|
|
978
|
+
*/
|
|
979
|
+
ignoreRegion?: boolean;
|
|
980
|
+
}
|
|
981
|
+
interface I18nController {
|
|
982
|
+
/** Initializes i18next with merged built-in and consumer-provided translations. */
|
|
983
|
+
prepare(): Promise<void>;
|
|
984
|
+
/**
|
|
985
|
+
* Determines the client’s preferred language from an Accept-Language header,
|
|
986
|
+
* honoring quality values (q=) and falling back to the configured default language.
|
|
987
|
+
*
|
|
988
|
+
* Matching strategy:
|
|
989
|
+
* - When `ignoreRegion` is false: prefer exact region (e.g., "en-gb"),
|
|
990
|
+
* then fall back to base ("en").
|
|
991
|
+
* - When `ignoreRegion` is true: always match by base only ("en-gb" → "en").
|
|
992
|
+
*
|
|
993
|
+
* @param input Full Accept-Language header, e.g. "fr-CA,fr;q=0.8,en-US;q=0.6,en;q=0.4".
|
|
994
|
+
* @param options Matching behavior.
|
|
995
|
+
* @returns Best matching language code.
|
|
996
|
+
*/
|
|
997
|
+
parseLocale(input?: string, options?: ParseLocaleOptions): string;
|
|
998
|
+
}
|
|
999
|
+
declare class I18nControllerImpl implements I18nController {
|
|
1000
|
+
private readonly configurationController;
|
|
1001
|
+
constructor(configurationController: ApiKitController);
|
|
1002
|
+
prepare(): Promise<void>;
|
|
1003
|
+
parseLocale(input?: string, options?: ParseLocaleOptions): string;
|
|
1004
|
+
private makeOptions;
|
|
1005
|
+
private makeConfig;
|
|
1006
|
+
private makeNamespaces;
|
|
1007
|
+
}
|
|
1008
|
+
//#endregion
|
|
1009
|
+
//#region src/i18n/i18n-provider.d.ts
|
|
1010
|
+
interface I18nOptions extends TOptions {}
|
|
1011
|
+
declare class I18nProvider {
|
|
1012
|
+
/**
|
|
1013
|
+
* Translates a key using i18next.
|
|
1014
|
+
*
|
|
1015
|
+
* @param key - Translation key (e.g., 'errors.INVALID_EMAIL')
|
|
1016
|
+
* @param options - Optional interpolation and config
|
|
1017
|
+
*/
|
|
1018
|
+
static t(key: string, options?: TOptions): string;
|
|
1019
|
+
/**
|
|
1020
|
+
* Returns the current effective locale.
|
|
1021
|
+
*/
|
|
1022
|
+
static get currentLocale(): string;
|
|
1023
|
+
/**
|
|
1024
|
+
* Check if a locale is supported by the runtime i18n configuration.
|
|
1025
|
+
*
|
|
1026
|
+
* @param locale Any locale tag (e.g., "en", "en-GB", "sk-SK").
|
|
1027
|
+
* @param options
|
|
1028
|
+
* - ignoreRegion: if true (default), allow matching just the base language.
|
|
1029
|
+
* e.g., if "en" is supported, "en-GB" is considered supported.
|
|
1030
|
+
*/
|
|
1031
|
+
static isSupportedLanguage(locale?: string, options?: {
|
|
1032
|
+
ignoreRegion?: boolean;
|
|
1033
|
+
}): boolean;
|
|
1034
|
+
}
|
|
1035
|
+
//#endregion
|
|
1036
|
+
//#region src/i18n/i18n-factory.d.ts
|
|
1037
|
+
/**
|
|
1038
|
+
* @description Options used when resolving localized text.
|
|
1039
|
+
*/
|
|
1040
|
+
interface I18nFactoryOptions {
|
|
1041
|
+
/**
|
|
1042
|
+
* @description Explicit message override returned instead of resolving the L10n key.
|
|
1043
|
+
* @default null
|
|
1044
|
+
*/
|
|
1045
|
+
overrideMessage?: string | null;
|
|
1046
|
+
/**
|
|
1047
|
+
* @description i18next options passed to the active i18n provider.
|
|
1048
|
+
* @default undefined
|
|
1049
|
+
*/
|
|
1050
|
+
i18n?: I18nOptions;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* @description Resolves L10n keys into localized text.
|
|
1054
|
+
*
|
|
1055
|
+
* @example
|
|
1056
|
+
* ```ts
|
|
1057
|
+
* const message = I18nFactory.make('messages.account.email_code_sent');
|
|
1058
|
+
* ```
|
|
1059
|
+
*
|
|
1060
|
+
* @example
|
|
1061
|
+
* ```ts
|
|
1062
|
+
* const message = I18nFactory.make(L10n.Errors.Common.NotFound, {
|
|
1063
|
+
* i18n: { resource: 'account' },
|
|
1064
|
+
* });
|
|
1065
|
+
* ```
|
|
1066
|
+
*/
|
|
1067
|
+
declare class I18nFactory {
|
|
1068
|
+
/**
|
|
1069
|
+
* @description Resolves an L10n key into localized text.
|
|
1070
|
+
*
|
|
1071
|
+
* @param key L10n key, for example `errors.common.not_found`.
|
|
1072
|
+
* @param options Optional override or i18next options.
|
|
1073
|
+
* @returns Localized text from the active i18n provider.
|
|
1074
|
+
*/
|
|
1075
|
+
static make(key: string, options?: I18nFactoryOptions): string;
|
|
1076
|
+
/**
|
|
1077
|
+
* @description Resolves an L10n key into localized text.
|
|
1078
|
+
*
|
|
1079
|
+
* @param key L10n key, for example `errors.common.not_found`.
|
|
1080
|
+
* @param options Optional override or i18next options.
|
|
1081
|
+
* @returns Localized text from the active i18n provider.
|
|
1082
|
+
*/
|
|
1083
|
+
static translateKey(key: string, options?: I18nFactoryOptions): string;
|
|
1084
|
+
}
|
|
1085
|
+
//#endregion
|
|
1086
|
+
//#region src/error/api-error-factory.d.ts
|
|
1087
|
+
/**
|
|
1088
|
+
* @description Options for creating a localized API error.
|
|
1089
|
+
*/
|
|
1090
|
+
interface ApiErrorFactoryOptions {
|
|
1091
|
+
/**
|
|
1092
|
+
* @description Explicit message override returned instead of resolving the error L10n key.
|
|
1093
|
+
* @default null
|
|
1094
|
+
*/
|
|
1095
|
+
overrideMessage?: string | null;
|
|
1096
|
+
/**
|
|
1097
|
+
* @description Technical details returned in the API error payload.
|
|
1098
|
+
* @default undefined
|
|
1099
|
+
*/
|
|
1100
|
+
details?: ApiErrorDetails;
|
|
1101
|
+
/**
|
|
1102
|
+
* @description i18next options passed to the active i18n provider.
|
|
1103
|
+
* @default undefined
|
|
1104
|
+
*/
|
|
1105
|
+
i18n?: I18nOptions;
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* @description Factory API for creating standardized, localized API errors.
|
|
1109
|
+
*/
|
|
1110
|
+
interface ApiErrorFactory<TCodes extends ApiErrorTree> {
|
|
1111
|
+
/**
|
|
1112
|
+
* @description Error metadata tree owned by this factory.
|
|
1113
|
+
*/
|
|
1114
|
+
readonly codes: TCodes;
|
|
1115
|
+
/**
|
|
1116
|
+
* @description Creates an API error from a typed path in this factory's error tree.
|
|
1117
|
+
*
|
|
1118
|
+
* @param path Dot-separated path to an error definition, for example `Validation.BAD_REQUEST`.
|
|
1119
|
+
* @param options Optional message override, details, or i18next options.
|
|
1120
|
+
* @returns Configured `ApiError` instance.
|
|
1121
|
+
*/
|
|
1122
|
+
make(path: ApiErrorPath<TCodes>, options?: ApiErrorFactoryOptions): ApiError;
|
|
1123
|
+
/**
|
|
1124
|
+
* @description Creates a new factory with custom error metadata merged over this factory.
|
|
1125
|
+
*
|
|
1126
|
+
* @param extra Custom error metadata tree.
|
|
1127
|
+
* @returns Factory with merged error metadata.
|
|
1128
|
+
*/
|
|
1129
|
+
extend<TExtra extends ApiErrorTree>(extra: TExtra): ApiErrorFactory<TCodes & TExtra>;
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* @description Factory for creating standardized, localized API errors.
|
|
1133
|
+
*
|
|
1134
|
+
* @example
|
|
1135
|
+
* ```ts
|
|
1136
|
+
* throw ApiErrorFactory.make('Validation.BAD_REQUEST');
|
|
1137
|
+
* ```
|
|
1138
|
+
*
|
|
1139
|
+
* @example
|
|
1140
|
+
* ```ts
|
|
1141
|
+
* export const AccountErrors = defineErrors({
|
|
1142
|
+
* BLOCKED: {
|
|
1143
|
+
* message: L10n.Errors.Account.Blocked,
|
|
1144
|
+
* code: 'account_blocked',
|
|
1145
|
+
* statusCode: 403,
|
|
1146
|
+
* },
|
|
1147
|
+
* });
|
|
1148
|
+
*
|
|
1149
|
+
* export const ErrorFactory = ApiErrorFactory.extend({ Account: AccountErrors });
|
|
1150
|
+
* throw ErrorFactory.make('Account.BLOCKED');
|
|
1151
|
+
* ```
|
|
1152
|
+
*/
|
|
1153
|
+
declare const ApiErrorFactory: ApiErrorFactory<{
|
|
1154
|
+
readonly Common: {
|
|
1155
|
+
NOT_FOUND: {
|
|
1156
|
+
message: "apikit.errors.common.not_found";
|
|
1157
|
+
code: string;
|
|
1158
|
+
statusCode: number;
|
|
1159
|
+
};
|
|
1160
|
+
UNKNOWN_ERROR: {
|
|
1161
|
+
message: "apikit.errors.common.unknown_error";
|
|
1162
|
+
code: string;
|
|
1163
|
+
statusCode: number;
|
|
1164
|
+
};
|
|
1165
|
+
UNABLE_TO_PROCESS_REQUEST: {
|
|
1166
|
+
message: "apikit.errors.common.unable_to_process_request";
|
|
1167
|
+
code: string;
|
|
1168
|
+
statusCode: number;
|
|
1169
|
+
};
|
|
1170
|
+
RESOURCE_ALREADY_EXISTS: {
|
|
1171
|
+
message: "apikit.errors.common.already_exists";
|
|
1172
|
+
code: string;
|
|
1173
|
+
statusCode: number;
|
|
1174
|
+
};
|
|
1175
|
+
};
|
|
1176
|
+
readonly Server: {
|
|
1177
|
+
INTERNAL_SERVER_ERROR: {
|
|
1178
|
+
message: "apikit.errors.server.internal";
|
|
1179
|
+
code: string;
|
|
1180
|
+
statusCode: number;
|
|
1181
|
+
};
|
|
1182
|
+
SERVICE_UNAVAILABLE: {
|
|
1183
|
+
message: "apikit.errors.server.unavailable";
|
|
1184
|
+
code: string;
|
|
1185
|
+
statusCode: number;
|
|
1186
|
+
};
|
|
1187
|
+
DEPENDENCY_FAILED: {
|
|
1188
|
+
message: "apikit.errors.server.dependency_failed";
|
|
1189
|
+
code: string;
|
|
1190
|
+
statusCode: number;
|
|
1191
|
+
};
|
|
1192
|
+
TIMEOUT: {
|
|
1193
|
+
message: "apikit.errors.server.timeout";
|
|
1194
|
+
code: string;
|
|
1195
|
+
statusCode: number;
|
|
1196
|
+
};
|
|
1197
|
+
};
|
|
1198
|
+
readonly Limit: {
|
|
1199
|
+
TOO_MANY_REQUESTS: {
|
|
1200
|
+
message: "apikit.errors.limit.too_many_requests";
|
|
1201
|
+
code: string;
|
|
1202
|
+
statusCode: number;
|
|
1203
|
+
};
|
|
1204
|
+
};
|
|
1205
|
+
readonly Authorization: {
|
|
1206
|
+
UNAUTHORIZED: {
|
|
1207
|
+
message: "apikit.errors.auth.unauthorized";
|
|
1208
|
+
code: string;
|
|
1209
|
+
statusCode: number;
|
|
1210
|
+
};
|
|
1211
|
+
FORBIDDEN: {
|
|
1212
|
+
message: "apikit.errors.auth.forbidden";
|
|
1213
|
+
code: string;
|
|
1214
|
+
statusCode: number;
|
|
1215
|
+
};
|
|
1216
|
+
};
|
|
1217
|
+
readonly Validation: {
|
|
1218
|
+
BAD_REQUEST: {
|
|
1219
|
+
message: "apikit.errors.validation.bad_request";
|
|
1220
|
+
code: string;
|
|
1221
|
+
statusCode: number;
|
|
1222
|
+
};
|
|
1223
|
+
INVALID_JSON_SYNTAX: {
|
|
1224
|
+
message: "apikit.errors.validation.invalid_json_syntax";
|
|
1225
|
+
code: string;
|
|
1226
|
+
statusCode: number;
|
|
1227
|
+
};
|
|
1228
|
+
INVALID_PROPERTIES: {
|
|
1229
|
+
message: "apikit.errors.validation.invalid_properties";
|
|
1230
|
+
code: string;
|
|
1231
|
+
statusCode: number;
|
|
1232
|
+
};
|
|
1233
|
+
INVALID_FORMAT: {
|
|
1234
|
+
message: "apikit.errors.validation.invalid_format";
|
|
1235
|
+
code: string;
|
|
1236
|
+
statusCode: number;
|
|
1237
|
+
};
|
|
1238
|
+
INVALID_DATE_FORMAT: {
|
|
1239
|
+
message: "apikit.errors.validation.invalid_date_format";
|
|
1240
|
+
code: string;
|
|
1241
|
+
statusCode: number;
|
|
1242
|
+
};
|
|
1243
|
+
INVALID_PASSWORD: {
|
|
1244
|
+
message: "apikit.errors.validation.invalid_password";
|
|
1245
|
+
code: string;
|
|
1246
|
+
statusCode: number;
|
|
1247
|
+
};
|
|
1248
|
+
INVALID_PASSWORD_NEW_SAME_AS_OLD: {
|
|
1249
|
+
message: "apikit.errors.validation.invalid_password_new_same_as_old";
|
|
1250
|
+
code: string;
|
|
1251
|
+
statusCode: number;
|
|
1252
|
+
};
|
|
1253
|
+
INVALID_PHONE_NUMBER_FORMAT: {
|
|
1254
|
+
message: "apikit.errors.validation.invalid_phone_number_format";
|
|
1255
|
+
code: string;
|
|
1256
|
+
statusCode: number;
|
|
1257
|
+
};
|
|
1258
|
+
INVALID_PHONE_NEW_SAME_AS_OLD: {
|
|
1259
|
+
message: "apikit.errors.validation.invalid_phone_new_same_as_old";
|
|
1260
|
+
code: string;
|
|
1261
|
+
statusCode: number;
|
|
1262
|
+
};
|
|
1263
|
+
INVALID_EMAIL_FORMAT: {
|
|
1264
|
+
message: "apikit.errors.validation.invalid_email_format";
|
|
1265
|
+
code: string;
|
|
1266
|
+
statusCode: number;
|
|
1267
|
+
};
|
|
1268
|
+
INVALID_EMAIL_NEW_SAME_AS_OLD: {
|
|
1269
|
+
message: "apikit.errors.validation.invalid_email_new_same_as_old";
|
|
1270
|
+
code: string;
|
|
1271
|
+
statusCode: number;
|
|
1272
|
+
};
|
|
1273
|
+
};
|
|
1274
|
+
readonly Format: {
|
|
1275
|
+
UNSUPPORTED_FORMAT: {
|
|
1276
|
+
message: "apikit.errors.format.unsupported";
|
|
1277
|
+
code: string;
|
|
1278
|
+
statusCode: number;
|
|
1279
|
+
};
|
|
1280
|
+
MAX_SIZE_EXCEEDED: {
|
|
1281
|
+
message: "apikit.errors.format.max_size_exceeded";
|
|
1282
|
+
code: string;
|
|
1283
|
+
statusCode: number;
|
|
1284
|
+
};
|
|
1285
|
+
};
|
|
1286
|
+
readonly Image: {
|
|
1287
|
+
MAX_SIZE_EXCEEDED: {
|
|
1288
|
+
message: "apikit.errors.image.max_size_exceeded";
|
|
1289
|
+
code: string;
|
|
1290
|
+
statusCode: number;
|
|
1291
|
+
};
|
|
1292
|
+
};
|
|
1293
|
+
}>;
|
|
1294
|
+
//#endregion
|
|
1295
|
+
//#region src/error/api-error-codes.d.ts
|
|
1296
|
+
/**
|
|
1297
|
+
* @description Defines a validated, nested API error metadata tree.
|
|
1298
|
+
*
|
|
1299
|
+
* @template T Recursive tree where every leaf is an `ApiErrorDefinition`.
|
|
1300
|
+
* @param errors Nested API error metadata tree.
|
|
1301
|
+
* @returns The same tree, typed for later reuse.
|
|
1302
|
+
*
|
|
1303
|
+
* @example
|
|
1304
|
+
* ```ts
|
|
1305
|
+
* export const AccountErrors = defineErrors({
|
|
1306
|
+
* BLOCKED: {
|
|
1307
|
+
* message: L10n.Errors.Account.Blocked,
|
|
1308
|
+
* code: 'account_blocked',
|
|
1309
|
+
* statusCode: 403,
|
|
1310
|
+
* },
|
|
1311
|
+
* });
|
|
1312
|
+
* ```
|
|
1313
|
+
*/
|
|
1314
|
+
declare function defineErrors<T extends ApiErrorTree>(errors: T): T;
|
|
1315
|
+
declare const CommonErrors: {
|
|
1316
|
+
NOT_FOUND: {
|
|
1317
|
+
message: "apikit.errors.common.not_found";
|
|
1318
|
+
code: string;
|
|
1319
|
+
statusCode: number;
|
|
1320
|
+
};
|
|
1321
|
+
UNKNOWN_ERROR: {
|
|
1322
|
+
message: "apikit.errors.common.unknown_error";
|
|
1323
|
+
code: string;
|
|
1324
|
+
statusCode: number;
|
|
1325
|
+
};
|
|
1326
|
+
UNABLE_TO_PROCESS_REQUEST: {
|
|
1327
|
+
message: "apikit.errors.common.unable_to_process_request";
|
|
1328
|
+
code: string;
|
|
1329
|
+
statusCode: number;
|
|
1330
|
+
};
|
|
1331
|
+
RESOURCE_ALREADY_EXISTS: {
|
|
1332
|
+
message: "apikit.errors.common.already_exists";
|
|
1333
|
+
code: string;
|
|
1334
|
+
statusCode: number;
|
|
1335
|
+
};
|
|
1336
|
+
};
|
|
1337
|
+
declare const ServerErrors: {
|
|
1338
|
+
INTERNAL_SERVER_ERROR: {
|
|
1339
|
+
message: "apikit.errors.server.internal";
|
|
1340
|
+
code: string;
|
|
1341
|
+
statusCode: number;
|
|
1342
|
+
};
|
|
1343
|
+
SERVICE_UNAVAILABLE: {
|
|
1344
|
+
message: "apikit.errors.server.unavailable";
|
|
1345
|
+
code: string;
|
|
1346
|
+
statusCode: number;
|
|
1347
|
+
};
|
|
1348
|
+
DEPENDENCY_FAILED: {
|
|
1349
|
+
message: "apikit.errors.server.dependency_failed";
|
|
1350
|
+
code: string;
|
|
1351
|
+
statusCode: number;
|
|
1352
|
+
};
|
|
1353
|
+
TIMEOUT: {
|
|
1354
|
+
message: "apikit.errors.server.timeout";
|
|
1355
|
+
code: string;
|
|
1356
|
+
statusCode: number;
|
|
1357
|
+
};
|
|
1358
|
+
};
|
|
1359
|
+
declare const LimitErrors: {
|
|
1360
|
+
TOO_MANY_REQUESTS: {
|
|
1361
|
+
message: "apikit.errors.limit.too_many_requests";
|
|
1362
|
+
code: string;
|
|
1363
|
+
statusCode: number;
|
|
1364
|
+
};
|
|
1365
|
+
};
|
|
1366
|
+
declare const AuthorizationErrors: {
|
|
1367
|
+
UNAUTHORIZED: {
|
|
1368
|
+
message: "apikit.errors.auth.unauthorized";
|
|
1369
|
+
code: string;
|
|
1370
|
+
statusCode: number;
|
|
1371
|
+
};
|
|
1372
|
+
FORBIDDEN: {
|
|
1373
|
+
message: "apikit.errors.auth.forbidden";
|
|
1374
|
+
code: string;
|
|
1375
|
+
statusCode: number;
|
|
1376
|
+
};
|
|
1377
|
+
};
|
|
1378
|
+
declare const ValidationErrors: {
|
|
1379
|
+
BAD_REQUEST: {
|
|
1380
|
+
message: "apikit.errors.validation.bad_request";
|
|
1381
|
+
code: string;
|
|
1382
|
+
statusCode: number;
|
|
1383
|
+
};
|
|
1384
|
+
INVALID_JSON_SYNTAX: {
|
|
1385
|
+
message: "apikit.errors.validation.invalid_json_syntax";
|
|
1386
|
+
code: string;
|
|
1387
|
+
statusCode: number;
|
|
1388
|
+
};
|
|
1389
|
+
INVALID_PROPERTIES: {
|
|
1390
|
+
message: "apikit.errors.validation.invalid_properties";
|
|
1391
|
+
code: string;
|
|
1392
|
+
statusCode: number;
|
|
1393
|
+
};
|
|
1394
|
+
INVALID_FORMAT: {
|
|
1395
|
+
message: "apikit.errors.validation.invalid_format";
|
|
1396
|
+
code: string;
|
|
1397
|
+
statusCode: number;
|
|
1398
|
+
};
|
|
1399
|
+
INVALID_DATE_FORMAT: {
|
|
1400
|
+
message: "apikit.errors.validation.invalid_date_format";
|
|
1401
|
+
code: string;
|
|
1402
|
+
statusCode: number;
|
|
1403
|
+
};
|
|
1404
|
+
INVALID_PASSWORD: {
|
|
1405
|
+
message: "apikit.errors.validation.invalid_password";
|
|
1406
|
+
code: string;
|
|
1407
|
+
statusCode: number;
|
|
1408
|
+
};
|
|
1409
|
+
INVALID_PASSWORD_NEW_SAME_AS_OLD: {
|
|
1410
|
+
message: "apikit.errors.validation.invalid_password_new_same_as_old";
|
|
1411
|
+
code: string;
|
|
1412
|
+
statusCode: number;
|
|
1413
|
+
};
|
|
1414
|
+
INVALID_PHONE_NUMBER_FORMAT: {
|
|
1415
|
+
message: "apikit.errors.validation.invalid_phone_number_format";
|
|
1416
|
+
code: string;
|
|
1417
|
+
statusCode: number;
|
|
1418
|
+
};
|
|
1419
|
+
INVALID_PHONE_NEW_SAME_AS_OLD: {
|
|
1420
|
+
message: "apikit.errors.validation.invalid_phone_new_same_as_old";
|
|
1421
|
+
code: string;
|
|
1422
|
+
statusCode: number;
|
|
1423
|
+
};
|
|
1424
|
+
INVALID_EMAIL_FORMAT: {
|
|
1425
|
+
message: "apikit.errors.validation.invalid_email_format";
|
|
1426
|
+
code: string;
|
|
1427
|
+
statusCode: number;
|
|
1428
|
+
};
|
|
1429
|
+
INVALID_EMAIL_NEW_SAME_AS_OLD: {
|
|
1430
|
+
message: "apikit.errors.validation.invalid_email_new_same_as_old";
|
|
1431
|
+
code: string;
|
|
1432
|
+
statusCode: number;
|
|
1433
|
+
};
|
|
1434
|
+
};
|
|
1435
|
+
declare const FormatErrors: {
|
|
1436
|
+
UNSUPPORTED_FORMAT: {
|
|
1437
|
+
message: "apikit.errors.format.unsupported";
|
|
1438
|
+
code: string;
|
|
1439
|
+
statusCode: number;
|
|
1440
|
+
};
|
|
1441
|
+
MAX_SIZE_EXCEEDED: {
|
|
1442
|
+
message: "apikit.errors.format.max_size_exceeded";
|
|
1443
|
+
code: string;
|
|
1444
|
+
statusCode: number;
|
|
1445
|
+
};
|
|
1446
|
+
};
|
|
1447
|
+
declare const ImageErrors: {
|
|
1448
|
+
MAX_SIZE_EXCEEDED: {
|
|
1449
|
+
message: "apikit.errors.image.max_size_exceeded";
|
|
1450
|
+
code: string;
|
|
1451
|
+
statusCode: number;
|
|
1452
|
+
};
|
|
1453
|
+
};
|
|
1454
|
+
declare const ApiErrorCodes: {
|
|
1455
|
+
readonly Common: {
|
|
1456
|
+
NOT_FOUND: {
|
|
1457
|
+
message: "apikit.errors.common.not_found";
|
|
1458
|
+
code: string;
|
|
1459
|
+
statusCode: number;
|
|
1460
|
+
};
|
|
1461
|
+
UNKNOWN_ERROR: {
|
|
1462
|
+
message: "apikit.errors.common.unknown_error";
|
|
1463
|
+
code: string;
|
|
1464
|
+
statusCode: number;
|
|
1465
|
+
};
|
|
1466
|
+
UNABLE_TO_PROCESS_REQUEST: {
|
|
1467
|
+
message: "apikit.errors.common.unable_to_process_request";
|
|
1468
|
+
code: string;
|
|
1469
|
+
statusCode: number;
|
|
1470
|
+
};
|
|
1471
|
+
RESOURCE_ALREADY_EXISTS: {
|
|
1472
|
+
message: "apikit.errors.common.already_exists";
|
|
1473
|
+
code: string;
|
|
1474
|
+
statusCode: number;
|
|
1475
|
+
};
|
|
1476
|
+
};
|
|
1477
|
+
readonly Server: {
|
|
1478
|
+
INTERNAL_SERVER_ERROR: {
|
|
1479
|
+
message: "apikit.errors.server.internal";
|
|
1480
|
+
code: string;
|
|
1481
|
+
statusCode: number;
|
|
1482
|
+
};
|
|
1483
|
+
SERVICE_UNAVAILABLE: {
|
|
1484
|
+
message: "apikit.errors.server.unavailable";
|
|
1485
|
+
code: string;
|
|
1486
|
+
statusCode: number;
|
|
1487
|
+
};
|
|
1488
|
+
DEPENDENCY_FAILED: {
|
|
1489
|
+
message: "apikit.errors.server.dependency_failed";
|
|
1490
|
+
code: string;
|
|
1491
|
+
statusCode: number;
|
|
1492
|
+
};
|
|
1493
|
+
TIMEOUT: {
|
|
1494
|
+
message: "apikit.errors.server.timeout";
|
|
1495
|
+
code: string;
|
|
1496
|
+
statusCode: number;
|
|
1497
|
+
};
|
|
1498
|
+
};
|
|
1499
|
+
readonly Limit: {
|
|
1500
|
+
TOO_MANY_REQUESTS: {
|
|
1501
|
+
message: "apikit.errors.limit.too_many_requests";
|
|
1502
|
+
code: string;
|
|
1503
|
+
statusCode: number;
|
|
1504
|
+
};
|
|
1505
|
+
};
|
|
1506
|
+
readonly Authorization: {
|
|
1507
|
+
UNAUTHORIZED: {
|
|
1508
|
+
message: "apikit.errors.auth.unauthorized";
|
|
1509
|
+
code: string;
|
|
1510
|
+
statusCode: number;
|
|
1511
|
+
};
|
|
1512
|
+
FORBIDDEN: {
|
|
1513
|
+
message: "apikit.errors.auth.forbidden";
|
|
1514
|
+
code: string;
|
|
1515
|
+
statusCode: number;
|
|
1516
|
+
};
|
|
1517
|
+
};
|
|
1518
|
+
readonly Validation: {
|
|
1519
|
+
BAD_REQUEST: {
|
|
1520
|
+
message: "apikit.errors.validation.bad_request";
|
|
1521
|
+
code: string;
|
|
1522
|
+
statusCode: number;
|
|
1523
|
+
};
|
|
1524
|
+
INVALID_JSON_SYNTAX: {
|
|
1525
|
+
message: "apikit.errors.validation.invalid_json_syntax";
|
|
1526
|
+
code: string;
|
|
1527
|
+
statusCode: number;
|
|
1528
|
+
};
|
|
1529
|
+
INVALID_PROPERTIES: {
|
|
1530
|
+
message: "apikit.errors.validation.invalid_properties";
|
|
1531
|
+
code: string;
|
|
1532
|
+
statusCode: number;
|
|
1533
|
+
};
|
|
1534
|
+
INVALID_FORMAT: {
|
|
1535
|
+
message: "apikit.errors.validation.invalid_format";
|
|
1536
|
+
code: string;
|
|
1537
|
+
statusCode: number;
|
|
1538
|
+
};
|
|
1539
|
+
INVALID_DATE_FORMAT: {
|
|
1540
|
+
message: "apikit.errors.validation.invalid_date_format";
|
|
1541
|
+
code: string;
|
|
1542
|
+
statusCode: number;
|
|
1543
|
+
};
|
|
1544
|
+
INVALID_PASSWORD: {
|
|
1545
|
+
message: "apikit.errors.validation.invalid_password";
|
|
1546
|
+
code: string;
|
|
1547
|
+
statusCode: number;
|
|
1548
|
+
};
|
|
1549
|
+
INVALID_PASSWORD_NEW_SAME_AS_OLD: {
|
|
1550
|
+
message: "apikit.errors.validation.invalid_password_new_same_as_old";
|
|
1551
|
+
code: string;
|
|
1552
|
+
statusCode: number;
|
|
1553
|
+
};
|
|
1554
|
+
INVALID_PHONE_NUMBER_FORMAT: {
|
|
1555
|
+
message: "apikit.errors.validation.invalid_phone_number_format";
|
|
1556
|
+
code: string;
|
|
1557
|
+
statusCode: number;
|
|
1558
|
+
};
|
|
1559
|
+
INVALID_PHONE_NEW_SAME_AS_OLD: {
|
|
1560
|
+
message: "apikit.errors.validation.invalid_phone_new_same_as_old";
|
|
1561
|
+
code: string;
|
|
1562
|
+
statusCode: number;
|
|
1563
|
+
};
|
|
1564
|
+
INVALID_EMAIL_FORMAT: {
|
|
1565
|
+
message: "apikit.errors.validation.invalid_email_format";
|
|
1566
|
+
code: string;
|
|
1567
|
+
statusCode: number;
|
|
1568
|
+
};
|
|
1569
|
+
INVALID_EMAIL_NEW_SAME_AS_OLD: {
|
|
1570
|
+
message: "apikit.errors.validation.invalid_email_new_same_as_old";
|
|
1571
|
+
code: string;
|
|
1572
|
+
statusCode: number;
|
|
1573
|
+
};
|
|
1574
|
+
};
|
|
1575
|
+
readonly Format: {
|
|
1576
|
+
UNSUPPORTED_FORMAT: {
|
|
1577
|
+
message: "apikit.errors.format.unsupported";
|
|
1578
|
+
code: string;
|
|
1579
|
+
statusCode: number;
|
|
1580
|
+
};
|
|
1581
|
+
MAX_SIZE_EXCEEDED: {
|
|
1582
|
+
message: "apikit.errors.format.max_size_exceeded";
|
|
1583
|
+
code: string;
|
|
1584
|
+
statusCode: number;
|
|
1585
|
+
};
|
|
1586
|
+
};
|
|
1587
|
+
readonly Image: {
|
|
1588
|
+
MAX_SIZE_EXCEEDED: {
|
|
1589
|
+
message: "apikit.errors.image.max_size_exceeded";
|
|
1590
|
+
code: string;
|
|
1591
|
+
statusCode: number;
|
|
1592
|
+
};
|
|
1593
|
+
};
|
|
1594
|
+
};
|
|
1595
|
+
//#endregion
|
|
1596
|
+
//#region src/formatter/format-type.d.ts
|
|
1597
|
+
/**
|
|
1598
|
+
* Wraps both raw MIME strings (e.g. "image/png") and file extensions (e.g. "png", "foo.png")
|
|
1599
|
+
* into a validated media-type. Throws if the input cannot be resolved.
|
|
1600
|
+
*
|
|
1601
|
+
* @param {string} input
|
|
1602
|
+
* Either a raw media-type ("type/subtype") or a filename/extension
|
|
1603
|
+
* (e.g. "foo.png", ".png", "png"). If unrecognized, throws a Format error.
|
|
1604
|
+
*
|
|
1605
|
+
* @example
|
|
1606
|
+
* // Using FormatErrors from defineErrors:
|
|
1607
|
+
* import { defineErrors } from '@buildplease/apikit';
|
|
1608
|
+
*
|
|
1609
|
+
* export const FormatErrors = defineErrors({
|
|
1610
|
+
* UNSUPPORTED_FORMAT: {
|
|
1611
|
+
* code: 'UNSUPPORTED_FORMAT',
|
|
1612
|
+
* message: L10n.Errors.Format.Unsupported,
|
|
1613
|
+
* statusCode: 400,
|
|
1614
|
+
* },
|
|
1615
|
+
* });
|
|
1616
|
+
*
|
|
1617
|
+
* // Create from a filename extension
|
|
1618
|
+
* const fmt1 = new FormatType('foo.png');
|
|
1619
|
+
* console.log(fmt1.value); // "image/png"
|
|
1620
|
+
* console.log(fmt1.extension); // "png"
|
|
1621
|
+
*
|
|
1622
|
+
* @example
|
|
1623
|
+
* // Create directly from a MIME string
|
|
1624
|
+
* const fmt2 = new FormatType('application/json');
|
|
1625
|
+
* console.log(fmt2.value); // "application/json"
|
|
1626
|
+
* console.log(fmt2.extension); // "json"
|
|
1627
|
+
*
|
|
1628
|
+
* @example
|
|
1629
|
+
* // Compare two formats for equality
|
|
1630
|
+
* const a = new FormatType('png');
|
|
1631
|
+
* const b = new FormatType('image/png');
|
|
1632
|
+
* console.log(a.equals(b)); // true
|
|
1633
|
+
*
|
|
1634
|
+
* @example
|
|
1635
|
+
* // Catch error when extension lookup fails
|
|
1636
|
+
* try {
|
|
1637
|
+
* const fmt = new FormatType('application/octet-stream');
|
|
1638
|
+
* console.log(fmt.extension);
|
|
1639
|
+
* } catch {
|
|
1640
|
+
* // FormatErrors.UNSUPPORTED_FORMAT was thrown
|
|
1641
|
+
* throw ApiErrorFactory.make('Format.UNSUPPORTED_FORMAT');
|
|
1642
|
+
* }
|
|
1643
|
+
*
|
|
1644
|
+
* @example
|
|
1645
|
+
* // Validate a Content-Type header in an HTTP handler
|
|
1646
|
+
* function handleUpload(contentTypeHeader: string) {
|
|
1647
|
+
* try {
|
|
1648
|
+
* const fmt = new FormatType(contentTypeHeader);
|
|
1649
|
+
* // downstream: use fmt.extension to decide where to store or how to process
|
|
1650
|
+
* } catch {
|
|
1651
|
+
* // rethrow a standardized error for unsupported formats
|
|
1652
|
+
* throw ApiErrorFactory.make('Format.UNSUPPORTED_FORMAT');
|
|
1653
|
+
* }
|
|
1654
|
+
* }
|
|
1655
|
+
*/
|
|
1656
|
+
declare class FormatType {
|
|
1657
|
+
private readonly mimeType;
|
|
1658
|
+
constructor(input: string);
|
|
1659
|
+
/**
|
|
1660
|
+
* The validated media-type string (e.g. "image/png").
|
|
1661
|
+
*/
|
|
1662
|
+
get value(): string;
|
|
1663
|
+
/**
|
|
1664
|
+
* The canonical file extension for this media type (e.g. "png" for "image/png").
|
|
1665
|
+
*
|
|
1666
|
+
* @throws {Error}
|
|
1667
|
+
* ApiErrorFactory.make('Format.UNSUPPORTED_FORMAT') if no extension is found.
|
|
1668
|
+
*
|
|
1669
|
+
* @example
|
|
1670
|
+
* const fmt = new FormatType('image/gif');
|
|
1671
|
+
* console.log(fmt.extension); // "gif"
|
|
1672
|
+
*/
|
|
1673
|
+
get extension(): string;
|
|
1674
|
+
/**
|
|
1675
|
+
* Compares this FormatType with another by their media-type strings.
|
|
1676
|
+
*
|
|
1677
|
+
* @param {FormatType} other
|
|
1678
|
+
* Another FormatType to compare against.
|
|
1679
|
+
*
|
|
1680
|
+
* @returns {boolean}
|
|
1681
|
+
* True if both instances resolve to the same media-type; false otherwise.
|
|
1682
|
+
*
|
|
1683
|
+
* @example
|
|
1684
|
+
* const f1 = new FormatType('jpg');
|
|
1685
|
+
* const f2 = new FormatType('image/jpeg');
|
|
1686
|
+
* console.log(f1.equals(f2)); // true
|
|
1687
|
+
*
|
|
1688
|
+
* @example
|
|
1689
|
+
* const f3 = new FormatType('text/html');
|
|
1690
|
+
* console.log(f2.equals(f3)); // false
|
|
1691
|
+
*/
|
|
1692
|
+
equals(other: FormatType): boolean;
|
|
1693
|
+
}
|
|
1694
|
+
//#endregion
|
|
1695
|
+
//#region src/formatter/formatter-controller.d.ts
|
|
1696
|
+
/**
|
|
1697
|
+
* FormatterController is responsible for creating Formatter instances.
|
|
1698
|
+
* Use FormatterController to apply transformations and filters to any data
|
|
1699
|
+
* object in a fluent, chainable manner.
|
|
1700
|
+
*/
|
|
1701
|
+
interface FormatterController {
|
|
1702
|
+
/**
|
|
1703
|
+
* Creates a new Formatter for the provided input value.
|
|
1704
|
+
* @param input - The value to format (object, array, primitive, etc.).
|
|
1705
|
+
*/
|
|
1706
|
+
format<T>(input: T): Formatter<T>;
|
|
1707
|
+
}
|
|
1708
|
+
/**
|
|
1709
|
+
* Formatter<T> provides a fluent API for transforming and filtering
|
|
1710
|
+
* values of type T. Supports:
|
|
1711
|
+
* - apply(): field-level transformations or full-object mapping
|
|
1712
|
+
* - filter(): deep removal of undefined or unwanted values
|
|
1713
|
+
* - exec(): retrieve the final formatted result
|
|
1714
|
+
*
|
|
1715
|
+
* @typeParam T - The type of the value being formatted.
|
|
1716
|
+
*/
|
|
1717
|
+
declare class Formatter<T> {
|
|
1718
|
+
private value;
|
|
1719
|
+
/**
|
|
1720
|
+
* @param value - The initial value to be processed.
|
|
1721
|
+
*/
|
|
1722
|
+
constructor(value: T);
|
|
1723
|
+
/**
|
|
1724
|
+
* Applies transformations to the current value.
|
|
1725
|
+
* @param transformationsOrTransformer - Field map or full-object transformer.
|
|
1726
|
+
* @returns The same Formatter instance for chaining.
|
|
1727
|
+
*/
|
|
1728
|
+
apply(transformationsOrTransformer: Partial<Record<keyof T, (value: any) => any>> | ((value: T) => T | null | undefined)): Formatter<T | null | undefined>;
|
|
1729
|
+
/**
|
|
1730
|
+
* Recursively filters out values based on the provided predicate.
|
|
1731
|
+
* Works deeply on arrays and plain objects, while treating custom
|
|
1732
|
+
* class instances and primitives as leaves.
|
|
1733
|
+
* @param predicate - Function to test each leaf value.
|
|
1734
|
+
* @returns The same Formatter instance for chaining.
|
|
1735
|
+
*/
|
|
1736
|
+
filter(predicate?: (value: any) => boolean): this;
|
|
1737
|
+
/**
|
|
1738
|
+
* Retrieves the formatted and filtered result.
|
|
1739
|
+
* @returns The processed value of type T.
|
|
1740
|
+
*/
|
|
1741
|
+
exec(): T;
|
|
1742
|
+
/**
|
|
1743
|
+
* Applies multiple field-level transformations in a single step.
|
|
1744
|
+
* @param transformations - Object mapping keys to transformer functions.
|
|
1745
|
+
*/
|
|
1746
|
+
private applyTransformations;
|
|
1747
|
+
}
|
|
1748
|
+
declare class FormatterControllerImpl implements FormatterController {
|
|
1749
|
+
format<T>(input: T): Formatter<T>;
|
|
1750
|
+
}
|
|
1751
|
+
//#endregion
|
|
1752
|
+
//#region src/formatter/multipart-formatter-controller.d.ts
|
|
1753
|
+
interface MultipartFormatterController {
|
|
1754
|
+
/**
|
|
1755
|
+
* Normalize multipart fields into JSON-compatible values.
|
|
1756
|
+
*
|
|
1757
|
+
* - "true"/"false" → boolean
|
|
1758
|
+
* - Numeric strings → number
|
|
1759
|
+
* - Valid JSON → parsed
|
|
1760
|
+
* - Fallback → plain string
|
|
1761
|
+
*
|
|
1762
|
+
* @param input Raw multipart fields as { [key: string]: unknown }
|
|
1763
|
+
* @returns Normalized fields as { [key: string]: unknown }
|
|
1764
|
+
*/
|
|
1765
|
+
normalizeFields(input: Record<string, unknown>): Record<string, unknown>;
|
|
1766
|
+
}
|
|
1767
|
+
declare class MultipartFormatterControllerImpl implements MultipartFormatterController {
|
|
1768
|
+
normalizeFields(input: Record<string, unknown>): Record<string, unknown>;
|
|
1769
|
+
private normalizeValue;
|
|
1770
|
+
}
|
|
1771
|
+
//#endregion
|
|
1772
|
+
//#region src/file/temporary-file-repository.d.ts
|
|
1773
|
+
interface TemporaryFileRepository {
|
|
1774
|
+
/**
|
|
1775
|
+
* Absolute path to the OS temporary directory used as a root for all operations.
|
|
1776
|
+
*/
|
|
1777
|
+
get rootDirectory(): string;
|
|
1778
|
+
/**
|
|
1779
|
+
* Ensure a subdirectory under the temp root exists.
|
|
1780
|
+
*
|
|
1781
|
+
* @param relativePath - A subpath like `request-id/cover`. Treated as relative to the temp root.
|
|
1782
|
+
* @returns Absolute path to the created/existing directory.
|
|
1783
|
+
* @throws If the directory cannot be created.
|
|
1784
|
+
*/
|
|
1785
|
+
createDirectory(relativePath: string): Promise<string>;
|
|
1786
|
+
/**
|
|
1787
|
+
* Remove a directory (recursively) under the temp root.
|
|
1788
|
+
*
|
|
1789
|
+
* @param relativePath - A subpath like `request-id/cover`. Treated as relative to the temp root.
|
|
1790
|
+
* @returns Resolves when deletion completes. No-op if it doesn’t exist.
|
|
1791
|
+
* @throws If the deletion fails.
|
|
1792
|
+
*/
|
|
1793
|
+
deleteDirectory(relativePath: string): Promise<void>;
|
|
1794
|
+
/**
|
|
1795
|
+
* Persist a file under the temp root.
|
|
1796
|
+
*
|
|
1797
|
+
* The final filename will be `<filename>.<type.extension>`.
|
|
1798
|
+
*
|
|
1799
|
+
* @param filename - Basename without extension (e.g., `cover`, `preview_0`).
|
|
1800
|
+
* @param content - Buffer or Readable stream to write.
|
|
1801
|
+
* @param type - Output type providing the file extension.
|
|
1802
|
+
* @param relativeDirectory - Subdirectory under the temp root (e.g., `request-id/cover`).
|
|
1803
|
+
* @returns Absolute file path written on disk.
|
|
1804
|
+
* @throws If writing fails or content type is unsupported.
|
|
1805
|
+
*/
|
|
1806
|
+
save(filename: string, content: NodeJS.ReadableStream | Buffer, type: FormatType, relativeDirectory: string): Promise<string>;
|
|
1807
|
+
/**
|
|
1808
|
+
* Remove a file under the temp root.
|
|
1809
|
+
*
|
|
1810
|
+
* @param relativeFilePath - Subpath like `request-id/cover/cover.jpeg`.
|
|
1811
|
+
* @returns Resolves when deletion completes. No-op if it doesn’t exist.
|
|
1812
|
+
* @throws If the deletion fails.
|
|
1813
|
+
*/
|
|
1814
|
+
delete(relativeFilePath: string): Promise<void>;
|
|
1815
|
+
}
|
|
1816
|
+
declare class TemporaryFileRepositoryImpl implements TemporaryFileRepository {
|
|
1817
|
+
private readonly logger;
|
|
1818
|
+
private readonly rootDir;
|
|
1819
|
+
constructor(logger: Logger);
|
|
1820
|
+
get rootDirectory(): string;
|
|
1821
|
+
createDirectory(relativePath: string): Promise<string>;
|
|
1822
|
+
deleteDirectory(relativePath: string): Promise<void>;
|
|
1823
|
+
save(filename: string, content: NodeJS.ReadableStream | Buffer, type: FormatType, relativeDirectory: string): Promise<string>;
|
|
1824
|
+
delete(relativeFilePath: string): Promise<void>;
|
|
1825
|
+
/**
|
|
1826
|
+
* Resolve a user-provided relative path against the repository root,
|
|
1827
|
+
* normalize it, and reject traversal outside the root.
|
|
1828
|
+
*/
|
|
1829
|
+
private safeJoin;
|
|
1830
|
+
}
|
|
1831
|
+
//#endregion
|
|
1832
|
+
//#region src/generator/random-value-generator-options.d.ts
|
|
1833
|
+
/**
|
|
1834
|
+
* @description Built-in alphabet presets for random string generation.
|
|
1835
|
+
*/
|
|
1836
|
+
type RandomValueAlphabetPreset = 'decimal' | 'lowercase' | 'uppercase' | 'letters' | 'alphanumeric' | 'hex' | 'base64' | 'base64url';
|
|
1837
|
+
/**
|
|
1838
|
+
* @description Custom alphabet used for random string generation.
|
|
1839
|
+
* @example
|
|
1840
|
+
* ```ts
|
|
1841
|
+
* const alphabet = { characters: 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789' };
|
|
1842
|
+
* ```
|
|
1843
|
+
*/
|
|
1844
|
+
interface RandomValueCustomAlphabet {
|
|
1845
|
+
/**
|
|
1846
|
+
* @description Characters that may appear in the generated string.
|
|
1847
|
+
*/
|
|
1848
|
+
characters: string;
|
|
1849
|
+
}
|
|
1850
|
+
/**
|
|
1851
|
+
* @description Alphabet used for random string generation.
|
|
1852
|
+
*/
|
|
1853
|
+
type RandomValueAlphabet = RandomValueAlphabetPreset | RandomValueCustomAlphabet;
|
|
1854
|
+
/**
|
|
1855
|
+
* @description Options for random integer generation.
|
|
1856
|
+
*/
|
|
1857
|
+
interface GenerateNumberOptions {
|
|
1858
|
+
/**
|
|
1859
|
+
* @description Inclusive lower bound.
|
|
1860
|
+
*/
|
|
1861
|
+
min: number;
|
|
1862
|
+
/**
|
|
1863
|
+
* @description Inclusive upper bound.
|
|
1864
|
+
*/
|
|
1865
|
+
max: number;
|
|
1866
|
+
}
|
|
1867
|
+
/**
|
|
1868
|
+
* @description Options for random string generation.
|
|
1869
|
+
*/
|
|
1870
|
+
interface GenerateStringOptions {
|
|
1871
|
+
/**
|
|
1872
|
+
* @description Exact output length in characters.
|
|
1873
|
+
* @default 8
|
|
1874
|
+
*/
|
|
1875
|
+
length?: number;
|
|
1876
|
+
/**
|
|
1877
|
+
* @description Alphabet used to generate the string.
|
|
1878
|
+
* @default 'alphanumeric'
|
|
1879
|
+
*/
|
|
1880
|
+
alphabet?: RandomValueAlphabet;
|
|
1881
|
+
}
|
|
1882
|
+
//#endregion
|
|
1883
|
+
//#region src/generator/random-value-generator.d.ts
|
|
1884
|
+
/**
|
|
1885
|
+
* @description Generator limits used by `RandomValueGeneratorImpl`.
|
|
1886
|
+
*/
|
|
1887
|
+
declare const RANDOM_VALUE_GENERATOR_LIMITS: {
|
|
1888
|
+
readonly maxStringLength: 4096;
|
|
1889
|
+
readonly randomIntegerRangeLimit: number;
|
|
1890
|
+
};
|
|
1891
|
+
/**
|
|
1892
|
+
* @description Default options for `RandomValueGenerator.generateString`.
|
|
1893
|
+
*/
|
|
1894
|
+
declare const DEFAULT_GENERATE_STRING_OPTIONS: {
|
|
1895
|
+
readonly length: 8;
|
|
1896
|
+
readonly alphabet: "alphanumeric";
|
|
1897
|
+
};
|
|
1898
|
+
/**
|
|
1899
|
+
* @description Crypto-safe random primitive value generator.
|
|
1900
|
+
*/
|
|
1901
|
+
interface RandomValueGenerator {
|
|
1902
|
+
/**
|
|
1903
|
+
* @description Generates a random integer inside an inclusive range.
|
|
1904
|
+
* @example
|
|
1905
|
+
* ```ts
|
|
1906
|
+
* generator.generateNumber({ min: 1000, max: 9999 });
|
|
1907
|
+
* ```
|
|
1908
|
+
* @throws Error when `min`, `max`, or the requested range is invalid.
|
|
1909
|
+
*/
|
|
1910
|
+
generateNumber(options: GenerateNumberOptions): number;
|
|
1911
|
+
/**
|
|
1912
|
+
* @description Generates a random string from an alphabet.
|
|
1913
|
+
* @default DEFAULT_GENERATE_STRING_OPTIONS
|
|
1914
|
+
* @example
|
|
1915
|
+
* ```ts
|
|
1916
|
+
* generator.generateString({ length: 6, alphabet: 'decimal' });
|
|
1917
|
+
* ```
|
|
1918
|
+
* @example
|
|
1919
|
+
* ```ts
|
|
1920
|
+
* generator.generateString({ length: 64, alphabet: 'base64url' });
|
|
1921
|
+
* ```
|
|
1922
|
+
* @throws Error when `length` or `alphabet` is invalid.
|
|
1923
|
+
*/
|
|
1924
|
+
generateString(options?: GenerateStringOptions): string;
|
|
1925
|
+
/**
|
|
1926
|
+
* @description Generates a random UUID v4 string.
|
|
1927
|
+
* @example
|
|
1928
|
+
* ```ts
|
|
1929
|
+
* generator.generateUuidV4();
|
|
1930
|
+
* ```
|
|
1931
|
+
*/
|
|
1932
|
+
generateUuidV4(): string;
|
|
1933
|
+
/**
|
|
1934
|
+
* @description Generates a time-ordered UUID v7 string.
|
|
1935
|
+
* @example
|
|
1936
|
+
* ```ts
|
|
1937
|
+
* generator.generateUuidV7();
|
|
1938
|
+
* ```
|
|
1939
|
+
*/
|
|
1940
|
+
generateUuidV7(): string;
|
|
1941
|
+
}
|
|
1942
|
+
declare class RandomValueGeneratorImpl implements RandomValueGenerator {
|
|
1943
|
+
generateNumber(options: GenerateNumberOptions): number;
|
|
1944
|
+
generateString(options?: GenerateStringOptions): string;
|
|
1945
|
+
generateUuidV4(): string;
|
|
1946
|
+
generateUuidV7(): string;
|
|
1947
|
+
private resolveAlphabet;
|
|
1948
|
+
private assertGenerateNumberOptions;
|
|
1949
|
+
private assertStringLength;
|
|
1950
|
+
private assertAlphabet;
|
|
1951
|
+
}
|
|
1952
|
+
//#endregion
|
|
1953
|
+
//#region src/l10n/resources.d.ts
|
|
1954
|
+
declare const ApiKitL10nResource: import("@buildplease/core").L10nResource<{
|
|
1955
|
+
readonly en: {
|
|
1956
|
+
readonly apikit: {
|
|
1957
|
+
errors: {
|
|
1958
|
+
common: {
|
|
1959
|
+
not_found: string;
|
|
1960
|
+
unable_to_process_request: string;
|
|
1961
|
+
unknown_error: string;
|
|
1962
|
+
already_exists: string;
|
|
1963
|
+
};
|
|
1964
|
+
server: {
|
|
1965
|
+
internal: string;
|
|
1966
|
+
unavailable: string;
|
|
1967
|
+
dependency_failed: string;
|
|
1968
|
+
timeout: string;
|
|
1969
|
+
};
|
|
1970
|
+
limit: {
|
|
1971
|
+
too_many_requests: string;
|
|
1972
|
+
};
|
|
1973
|
+
auth: {
|
|
1974
|
+
unauthorized: string;
|
|
1975
|
+
forbidden: string;
|
|
1976
|
+
};
|
|
1977
|
+
validation: {
|
|
1978
|
+
bad_request: string;
|
|
1979
|
+
invalid_json_syntax: string;
|
|
1980
|
+
invalid_properties: string;
|
|
1981
|
+
invalid_format: string;
|
|
1982
|
+
invalid_date_format: string;
|
|
1983
|
+
invalid_password: string;
|
|
1984
|
+
invalid_password_new_same_as_old: string;
|
|
1985
|
+
invalid_phone_number_format: string;
|
|
1986
|
+
invalid_phone_new_same_as_old: string;
|
|
1987
|
+
invalid_email_format: string;
|
|
1988
|
+
invalid_email_new_same_as_old: string;
|
|
1989
|
+
};
|
|
1990
|
+
format: {
|
|
1991
|
+
unsupported: string;
|
|
1992
|
+
max_size_exceeded: string;
|
|
1993
|
+
};
|
|
1994
|
+
image: {
|
|
1995
|
+
max_size_exceeded: string;
|
|
1996
|
+
};
|
|
1997
|
+
};
|
|
1998
|
+
};
|
|
1999
|
+
readonly core: {
|
|
2000
|
+
common: {
|
|
2001
|
+
actions: {
|
|
2002
|
+
save: string;
|
|
2003
|
+
cancel: string;
|
|
2004
|
+
delete: string;
|
|
2005
|
+
confirm: string;
|
|
2006
|
+
close: string;
|
|
2007
|
+
back: string;
|
|
2008
|
+
next: string;
|
|
2009
|
+
};
|
|
2010
|
+
date_time: {
|
|
2011
|
+
relative: {
|
|
2012
|
+
today: string;
|
|
2013
|
+
tomorrow: string;
|
|
2014
|
+
yesterday: string;
|
|
2015
|
+
};
|
|
2016
|
+
interval: {
|
|
2017
|
+
second: {
|
|
2018
|
+
one: string;
|
|
2019
|
+
few: string;
|
|
2020
|
+
many: string;
|
|
2021
|
+
other: string;
|
|
2022
|
+
};
|
|
2023
|
+
minute: {
|
|
2024
|
+
one: string;
|
|
2025
|
+
few: string;
|
|
2026
|
+
many: string;
|
|
2027
|
+
other: string;
|
|
2028
|
+
};
|
|
2029
|
+
hour: {
|
|
2030
|
+
one: string;
|
|
2031
|
+
few: string;
|
|
2032
|
+
many: string;
|
|
2033
|
+
other: string;
|
|
2034
|
+
};
|
|
2035
|
+
day: {
|
|
2036
|
+
one: string;
|
|
2037
|
+
few: string;
|
|
2038
|
+
many: string;
|
|
2039
|
+
other: string;
|
|
2040
|
+
};
|
|
2041
|
+
week: {
|
|
2042
|
+
one: string;
|
|
2043
|
+
few: string;
|
|
2044
|
+
many: string;
|
|
2045
|
+
other: string;
|
|
2046
|
+
};
|
|
2047
|
+
month: {
|
|
2048
|
+
one: string;
|
|
2049
|
+
few: string;
|
|
2050
|
+
many: string;
|
|
2051
|
+
other: string;
|
|
2052
|
+
};
|
|
2053
|
+
year: {
|
|
2054
|
+
one: string;
|
|
2055
|
+
few: string;
|
|
2056
|
+
many: string;
|
|
2057
|
+
other: string;
|
|
2058
|
+
};
|
|
2059
|
+
};
|
|
2060
|
+
weekday: {
|
|
2061
|
+
monday: string;
|
|
2062
|
+
tuesday: string;
|
|
2063
|
+
wednesday: string;
|
|
2064
|
+
thursday: string;
|
|
2065
|
+
friday: string;
|
|
2066
|
+
saturday: string;
|
|
2067
|
+
sunday: string;
|
|
2068
|
+
};
|
|
2069
|
+
month: {
|
|
2070
|
+
january: string;
|
|
2071
|
+
february: string;
|
|
2072
|
+
march: string;
|
|
2073
|
+
april: string;
|
|
2074
|
+
may: string;
|
|
2075
|
+
june: string;
|
|
2076
|
+
july: string;
|
|
2077
|
+
august: string;
|
|
2078
|
+
september: string;
|
|
2079
|
+
october: string;
|
|
2080
|
+
november: string;
|
|
2081
|
+
december: string;
|
|
2082
|
+
};
|
|
2083
|
+
};
|
|
2084
|
+
validation: {
|
|
2085
|
+
opening_hours: {
|
|
2086
|
+
time_required: string;
|
|
2087
|
+
time_range_incomplete: string;
|
|
2088
|
+
};
|
|
2089
|
+
};
|
|
2090
|
+
};
|
|
2091
|
+
};
|
|
2092
|
+
};
|
|
2093
|
+
readonly sk: {
|
|
2094
|
+
readonly apikit: {
|
|
2095
|
+
errors: {
|
|
2096
|
+
common: {
|
|
2097
|
+
not_found: string;
|
|
2098
|
+
unable_to_process_request: string;
|
|
2099
|
+
unknown_error: string;
|
|
2100
|
+
already_exists: string;
|
|
2101
|
+
};
|
|
2102
|
+
server: {
|
|
2103
|
+
internal: string;
|
|
2104
|
+
unavailable: string;
|
|
2105
|
+
dependency_failed: string;
|
|
2106
|
+
timeout: string;
|
|
2107
|
+
};
|
|
2108
|
+
limit: {
|
|
2109
|
+
too_many_requests: string;
|
|
2110
|
+
};
|
|
2111
|
+
auth: {
|
|
2112
|
+
unauthorized: string;
|
|
2113
|
+
forbidden: string;
|
|
2114
|
+
};
|
|
2115
|
+
validation: {
|
|
2116
|
+
bad_request: string;
|
|
2117
|
+
invalid_json_syntax: string;
|
|
2118
|
+
invalid_properties: string;
|
|
2119
|
+
invalid_format: string;
|
|
2120
|
+
invalid_date_format: string;
|
|
2121
|
+
invalid_password: string;
|
|
2122
|
+
invalid_password_new_same_as_old: string;
|
|
2123
|
+
invalid_phone_number_format: string;
|
|
2124
|
+
invalid_phone_new_same_as_old: string;
|
|
2125
|
+
invalid_email_format: string;
|
|
2126
|
+
invalid_email_new_same_as_old: string;
|
|
2127
|
+
};
|
|
2128
|
+
format: {
|
|
2129
|
+
unsupported: string;
|
|
2130
|
+
max_size_exceeded: string;
|
|
2131
|
+
};
|
|
2132
|
+
image: {
|
|
2133
|
+
max_size_exceeded: string;
|
|
2134
|
+
};
|
|
2135
|
+
};
|
|
2136
|
+
};
|
|
2137
|
+
readonly core: {
|
|
2138
|
+
common: {
|
|
2139
|
+
actions: {
|
|
2140
|
+
save: string;
|
|
2141
|
+
cancel: string;
|
|
2142
|
+
delete: string;
|
|
2143
|
+
confirm: string;
|
|
2144
|
+
close: string;
|
|
2145
|
+
back: string;
|
|
2146
|
+
next: string;
|
|
2147
|
+
};
|
|
2148
|
+
date_time: {
|
|
2149
|
+
relative: {
|
|
2150
|
+
today: string;
|
|
2151
|
+
tomorrow: string;
|
|
2152
|
+
yesterday: string;
|
|
2153
|
+
};
|
|
2154
|
+
interval: {
|
|
2155
|
+
second: {
|
|
2156
|
+
one: string;
|
|
2157
|
+
few: string;
|
|
2158
|
+
many: string;
|
|
2159
|
+
other: string;
|
|
2160
|
+
};
|
|
2161
|
+
minute: {
|
|
2162
|
+
one: string;
|
|
2163
|
+
few: string;
|
|
2164
|
+
many: string;
|
|
2165
|
+
other: string;
|
|
2166
|
+
};
|
|
2167
|
+
hour: {
|
|
2168
|
+
one: string;
|
|
2169
|
+
few: string;
|
|
2170
|
+
many: string;
|
|
2171
|
+
other: string;
|
|
2172
|
+
};
|
|
2173
|
+
day: {
|
|
2174
|
+
one: string;
|
|
2175
|
+
few: string;
|
|
2176
|
+
many: string;
|
|
2177
|
+
other: string;
|
|
2178
|
+
};
|
|
2179
|
+
week: {
|
|
2180
|
+
one: string;
|
|
2181
|
+
few: string;
|
|
2182
|
+
many: string;
|
|
2183
|
+
other: string;
|
|
2184
|
+
};
|
|
2185
|
+
month: {
|
|
2186
|
+
one: string;
|
|
2187
|
+
few: string;
|
|
2188
|
+
many: string;
|
|
2189
|
+
other: string;
|
|
2190
|
+
};
|
|
2191
|
+
year: {
|
|
2192
|
+
one: string;
|
|
2193
|
+
few: string;
|
|
2194
|
+
many: string;
|
|
2195
|
+
other: string;
|
|
2196
|
+
};
|
|
2197
|
+
};
|
|
2198
|
+
weekday: {
|
|
2199
|
+
monday: string;
|
|
2200
|
+
tuesday: string;
|
|
2201
|
+
wednesday: string;
|
|
2202
|
+
thursday: string;
|
|
2203
|
+
friday: string;
|
|
2204
|
+
saturday: string;
|
|
2205
|
+
sunday: string;
|
|
2206
|
+
};
|
|
2207
|
+
month: {
|
|
2208
|
+
january: string;
|
|
2209
|
+
february: string;
|
|
2210
|
+
march: string;
|
|
2211
|
+
april: string;
|
|
2212
|
+
may: string;
|
|
2213
|
+
june: string;
|
|
2214
|
+
july: string;
|
|
2215
|
+
august: string;
|
|
2216
|
+
september: string;
|
|
2217
|
+
october: string;
|
|
2218
|
+
november: string;
|
|
2219
|
+
december: string;
|
|
2220
|
+
};
|
|
2221
|
+
};
|
|
2222
|
+
validation: {
|
|
2223
|
+
opening_hours: {
|
|
2224
|
+
time_required: string;
|
|
2225
|
+
time_range_incomplete: string;
|
|
2226
|
+
};
|
|
2227
|
+
};
|
|
2228
|
+
};
|
|
2229
|
+
};
|
|
2230
|
+
};
|
|
2231
|
+
readonly cs: {
|
|
2232
|
+
readonly apikit: {
|
|
2233
|
+
errors: {
|
|
2234
|
+
common: {
|
|
2235
|
+
not_found: string;
|
|
2236
|
+
unable_to_process_request: string;
|
|
2237
|
+
unknown_error: string;
|
|
2238
|
+
already_exists: string;
|
|
2239
|
+
};
|
|
2240
|
+
server: {
|
|
2241
|
+
internal: string;
|
|
2242
|
+
unavailable: string;
|
|
2243
|
+
dependency_failed: string;
|
|
2244
|
+
timeout: string;
|
|
2245
|
+
};
|
|
2246
|
+
limit: {
|
|
2247
|
+
too_many_requests: string;
|
|
2248
|
+
};
|
|
2249
|
+
auth: {
|
|
2250
|
+
unauthorized: string;
|
|
2251
|
+
forbidden: string;
|
|
2252
|
+
};
|
|
2253
|
+
validation: {
|
|
2254
|
+
bad_request: string;
|
|
2255
|
+
invalid_json_syntax: string;
|
|
2256
|
+
invalid_properties: string;
|
|
2257
|
+
invalid_format: string;
|
|
2258
|
+
invalid_date_format: string;
|
|
2259
|
+
invalid_password: string;
|
|
2260
|
+
invalid_password_new_same_as_old: string;
|
|
2261
|
+
invalid_phone_number_format: string;
|
|
2262
|
+
invalid_phone_new_same_as_old: string;
|
|
2263
|
+
invalid_email_format: string;
|
|
2264
|
+
invalid_email_new_same_as_old: string;
|
|
2265
|
+
};
|
|
2266
|
+
format: {
|
|
2267
|
+
unsupported: string;
|
|
2268
|
+
max_size_exceeded: string;
|
|
2269
|
+
};
|
|
2270
|
+
image: {
|
|
2271
|
+
max_size_exceeded: string;
|
|
2272
|
+
};
|
|
2273
|
+
};
|
|
2274
|
+
};
|
|
2275
|
+
readonly core: {
|
|
2276
|
+
common: {
|
|
2277
|
+
actions: {
|
|
2278
|
+
save: string;
|
|
2279
|
+
cancel: string;
|
|
2280
|
+
delete: string;
|
|
2281
|
+
confirm: string;
|
|
2282
|
+
close: string;
|
|
2283
|
+
back: string;
|
|
2284
|
+
next: string;
|
|
2285
|
+
};
|
|
2286
|
+
date_time: {
|
|
2287
|
+
relative: {
|
|
2288
|
+
today: string;
|
|
2289
|
+
tomorrow: string;
|
|
2290
|
+
yesterday: string;
|
|
2291
|
+
};
|
|
2292
|
+
interval: {
|
|
2293
|
+
second: {
|
|
2294
|
+
one: string;
|
|
2295
|
+
few: string;
|
|
2296
|
+
many: string;
|
|
2297
|
+
other: string;
|
|
2298
|
+
};
|
|
2299
|
+
minute: {
|
|
2300
|
+
one: string;
|
|
2301
|
+
few: string;
|
|
2302
|
+
many: string;
|
|
2303
|
+
other: string;
|
|
2304
|
+
};
|
|
2305
|
+
hour: {
|
|
2306
|
+
one: string;
|
|
2307
|
+
few: string;
|
|
2308
|
+
many: string;
|
|
2309
|
+
other: string;
|
|
2310
|
+
};
|
|
2311
|
+
day: {
|
|
2312
|
+
one: string;
|
|
2313
|
+
few: string;
|
|
2314
|
+
many: string;
|
|
2315
|
+
other: string;
|
|
2316
|
+
};
|
|
2317
|
+
week: {
|
|
2318
|
+
one: string;
|
|
2319
|
+
few: string;
|
|
2320
|
+
many: string;
|
|
2321
|
+
other: string;
|
|
2322
|
+
};
|
|
2323
|
+
month: {
|
|
2324
|
+
one: string;
|
|
2325
|
+
few: string;
|
|
2326
|
+
many: string;
|
|
2327
|
+
other: string;
|
|
2328
|
+
};
|
|
2329
|
+
year: {
|
|
2330
|
+
one: string;
|
|
2331
|
+
few: string;
|
|
2332
|
+
many: string;
|
|
2333
|
+
other: string;
|
|
2334
|
+
};
|
|
2335
|
+
};
|
|
2336
|
+
weekday: {
|
|
2337
|
+
monday: string;
|
|
2338
|
+
tuesday: string;
|
|
2339
|
+
wednesday: string;
|
|
2340
|
+
thursday: string;
|
|
2341
|
+
friday: string;
|
|
2342
|
+
saturday: string;
|
|
2343
|
+
sunday: string;
|
|
2344
|
+
};
|
|
2345
|
+
month: {
|
|
2346
|
+
january: string;
|
|
2347
|
+
february: string;
|
|
2348
|
+
march: string;
|
|
2349
|
+
april: string;
|
|
2350
|
+
may: string;
|
|
2351
|
+
june: string;
|
|
2352
|
+
july: string;
|
|
2353
|
+
august: string;
|
|
2354
|
+
september: string;
|
|
2355
|
+
october: string;
|
|
2356
|
+
november: string;
|
|
2357
|
+
december: string;
|
|
2358
|
+
};
|
|
2359
|
+
};
|
|
2360
|
+
validation: {
|
|
2361
|
+
opening_hours: {
|
|
2362
|
+
time_required: string;
|
|
2363
|
+
time_range_incomplete: string;
|
|
2364
|
+
};
|
|
2365
|
+
};
|
|
2366
|
+
};
|
|
2367
|
+
};
|
|
2368
|
+
};
|
|
2369
|
+
}>;
|
|
2370
|
+
declare const ApiKitL10n: {
|
|
2371
|
+
readonly Apikit: {
|
|
2372
|
+
readonly Errors: {
|
|
2373
|
+
readonly Common: {
|
|
2374
|
+
readonly NotFound: "apikit.errors.common.not_found";
|
|
2375
|
+
readonly UnableToProcessRequest: "apikit.errors.common.unable_to_process_request";
|
|
2376
|
+
readonly UnknownError: "apikit.errors.common.unknown_error";
|
|
2377
|
+
readonly AlreadyExists: "apikit.errors.common.already_exists";
|
|
2378
|
+
};
|
|
2379
|
+
readonly Server: {
|
|
2380
|
+
readonly Internal: "apikit.errors.server.internal";
|
|
2381
|
+
readonly Unavailable: "apikit.errors.server.unavailable";
|
|
2382
|
+
readonly DependencyFailed: "apikit.errors.server.dependency_failed";
|
|
2383
|
+
readonly Timeout: "apikit.errors.server.timeout";
|
|
2384
|
+
};
|
|
2385
|
+
readonly Limit: {
|
|
2386
|
+
readonly TooManyRequests: "apikit.errors.limit.too_many_requests";
|
|
2387
|
+
};
|
|
2388
|
+
readonly Auth: {
|
|
2389
|
+
readonly Unauthorized: "apikit.errors.auth.unauthorized";
|
|
2390
|
+
readonly Forbidden: "apikit.errors.auth.forbidden";
|
|
2391
|
+
};
|
|
2392
|
+
readonly Validation: {
|
|
2393
|
+
readonly BadRequest: "apikit.errors.validation.bad_request";
|
|
2394
|
+
readonly InvalidJsonSyntax: "apikit.errors.validation.invalid_json_syntax";
|
|
2395
|
+
readonly InvalidProperties: "apikit.errors.validation.invalid_properties";
|
|
2396
|
+
readonly InvalidFormat: "apikit.errors.validation.invalid_format";
|
|
2397
|
+
readonly InvalidDateFormat: "apikit.errors.validation.invalid_date_format";
|
|
2398
|
+
readonly InvalidPassword: "apikit.errors.validation.invalid_password";
|
|
2399
|
+
readonly InvalidPasswordNewSameAsOld: "apikit.errors.validation.invalid_password_new_same_as_old";
|
|
2400
|
+
readonly InvalidPhoneNumberFormat: "apikit.errors.validation.invalid_phone_number_format";
|
|
2401
|
+
readonly InvalidPhoneNewSameAsOld: "apikit.errors.validation.invalid_phone_new_same_as_old";
|
|
2402
|
+
readonly InvalidEmailFormat: "apikit.errors.validation.invalid_email_format";
|
|
2403
|
+
readonly InvalidEmailNewSameAsOld: "apikit.errors.validation.invalid_email_new_same_as_old";
|
|
2404
|
+
};
|
|
2405
|
+
readonly Format: {
|
|
2406
|
+
readonly Unsupported: "apikit.errors.format.unsupported";
|
|
2407
|
+
readonly MaxSizeExceeded: "apikit.errors.format.max_size_exceeded";
|
|
2408
|
+
};
|
|
2409
|
+
readonly Image: {
|
|
2410
|
+
readonly MaxSizeExceeded: "apikit.errors.image.max_size_exceeded";
|
|
2411
|
+
};
|
|
2412
|
+
};
|
|
2413
|
+
};
|
|
2414
|
+
readonly Core: {
|
|
2415
|
+
readonly Common: {
|
|
2416
|
+
readonly Validation: {
|
|
2417
|
+
readonly OpeningHours: {
|
|
2418
|
+
readonly TimeRequired: "core.common.validation.opening_hours.time_required";
|
|
2419
|
+
readonly TimeRangeIncomplete: "core.common.validation.opening_hours.time_range_incomplete";
|
|
2420
|
+
};
|
|
2421
|
+
};
|
|
2422
|
+
readonly Actions: {
|
|
2423
|
+
readonly Save: "core.common.actions.save";
|
|
2424
|
+
readonly Cancel: "core.common.actions.cancel";
|
|
2425
|
+
readonly Delete: "core.common.actions.delete";
|
|
2426
|
+
readonly Confirm: "core.common.actions.confirm";
|
|
2427
|
+
readonly Close: "core.common.actions.close";
|
|
2428
|
+
readonly Back: "core.common.actions.back";
|
|
2429
|
+
readonly Next: "core.common.actions.next";
|
|
2430
|
+
};
|
|
2431
|
+
readonly DateTime: {
|
|
2432
|
+
readonly Relative: {
|
|
2433
|
+
readonly Today: "core.common.date_time.relative.today";
|
|
2434
|
+
readonly Tomorrow: "core.common.date_time.relative.tomorrow";
|
|
2435
|
+
readonly Yesterday: "core.common.date_time.relative.yesterday";
|
|
2436
|
+
};
|
|
2437
|
+
readonly Interval: {
|
|
2438
|
+
readonly Month: {
|
|
2439
|
+
readonly One: "core.common.date_time.interval.month.one";
|
|
2440
|
+
readonly Few: "core.common.date_time.interval.month.few";
|
|
2441
|
+
readonly Many: "core.common.date_time.interval.month.many";
|
|
2442
|
+
readonly Other: "core.common.date_time.interval.month.other";
|
|
2443
|
+
};
|
|
2444
|
+
readonly Day: {
|
|
2445
|
+
readonly One: "core.common.date_time.interval.day.one";
|
|
2446
|
+
readonly Few: "core.common.date_time.interval.day.few";
|
|
2447
|
+
readonly Many: "core.common.date_time.interval.day.many";
|
|
2448
|
+
readonly Other: "core.common.date_time.interval.day.other";
|
|
2449
|
+
};
|
|
2450
|
+
readonly Second: {
|
|
2451
|
+
readonly One: "core.common.date_time.interval.second.one";
|
|
2452
|
+
readonly Few: "core.common.date_time.interval.second.few";
|
|
2453
|
+
readonly Many: "core.common.date_time.interval.second.many";
|
|
2454
|
+
readonly Other: "core.common.date_time.interval.second.other";
|
|
2455
|
+
};
|
|
2456
|
+
readonly Minute: {
|
|
2457
|
+
readonly One: "core.common.date_time.interval.minute.one";
|
|
2458
|
+
readonly Few: "core.common.date_time.interval.minute.few";
|
|
2459
|
+
readonly Many: "core.common.date_time.interval.minute.many";
|
|
2460
|
+
readonly Other: "core.common.date_time.interval.minute.other";
|
|
2461
|
+
};
|
|
2462
|
+
readonly Hour: {
|
|
2463
|
+
readonly One: "core.common.date_time.interval.hour.one";
|
|
2464
|
+
readonly Few: "core.common.date_time.interval.hour.few";
|
|
2465
|
+
readonly Many: "core.common.date_time.interval.hour.many";
|
|
2466
|
+
readonly Other: "core.common.date_time.interval.hour.other";
|
|
2467
|
+
};
|
|
2468
|
+
readonly Week: {
|
|
2469
|
+
readonly One: "core.common.date_time.interval.week.one";
|
|
2470
|
+
readonly Few: "core.common.date_time.interval.week.few";
|
|
2471
|
+
readonly Many: "core.common.date_time.interval.week.many";
|
|
2472
|
+
readonly Other: "core.common.date_time.interval.week.other";
|
|
2473
|
+
};
|
|
2474
|
+
readonly Year: {
|
|
2475
|
+
readonly One: "core.common.date_time.interval.year.one";
|
|
2476
|
+
readonly Few: "core.common.date_time.interval.year.few";
|
|
2477
|
+
readonly Many: "core.common.date_time.interval.year.many";
|
|
2478
|
+
readonly Other: "core.common.date_time.interval.year.other";
|
|
2479
|
+
};
|
|
2480
|
+
};
|
|
2481
|
+
readonly Weekday: {
|
|
2482
|
+
readonly Monday: "core.common.date_time.weekday.monday";
|
|
2483
|
+
readonly Tuesday: "core.common.date_time.weekday.tuesday";
|
|
2484
|
+
readonly Wednesday: "core.common.date_time.weekday.wednesday";
|
|
2485
|
+
readonly Thursday: "core.common.date_time.weekday.thursday";
|
|
2486
|
+
readonly Friday: "core.common.date_time.weekday.friday";
|
|
2487
|
+
readonly Saturday: "core.common.date_time.weekday.saturday";
|
|
2488
|
+
readonly Sunday: "core.common.date_time.weekday.sunday";
|
|
2489
|
+
};
|
|
2490
|
+
readonly Month: {
|
|
2491
|
+
readonly January: "core.common.date_time.month.january";
|
|
2492
|
+
readonly February: "core.common.date_time.month.february";
|
|
2493
|
+
readonly March: "core.common.date_time.month.march";
|
|
2494
|
+
readonly April: "core.common.date_time.month.april";
|
|
2495
|
+
readonly May: "core.common.date_time.month.may";
|
|
2496
|
+
readonly June: "core.common.date_time.month.june";
|
|
2497
|
+
readonly July: "core.common.date_time.month.july";
|
|
2498
|
+
readonly August: "core.common.date_time.month.august";
|
|
2499
|
+
readonly September: "core.common.date_time.month.september";
|
|
2500
|
+
readonly October: "core.common.date_time.month.october";
|
|
2501
|
+
readonly November: "core.common.date_time.month.november";
|
|
2502
|
+
readonly December: "core.common.date_time.month.december";
|
|
2503
|
+
};
|
|
2504
|
+
};
|
|
2505
|
+
};
|
|
2506
|
+
};
|
|
2507
|
+
};
|
|
2508
|
+
//#endregion
|
|
2509
|
+
//#region src/image/image-options.d.ts
|
|
2510
|
+
/**
|
|
2511
|
+
* Runtime Sharp pipeline instance.
|
|
2512
|
+
*/
|
|
2513
|
+
type SharpInstance = Sharp;
|
|
2514
|
+
/**
|
|
2515
|
+
* Sharp format key accepted by the normalization pipeline.
|
|
2516
|
+
*/
|
|
2517
|
+
type SharpFormat = Extract<keyof FormatEnum, string>;
|
|
2518
|
+
/**
|
|
2519
|
+
* Shared options applied to every image configuration.
|
|
2520
|
+
*/
|
|
2521
|
+
type Base = {
|
|
2522
|
+
maximumSize?: number;
|
|
2523
|
+
allowedInputFormats?: SharpFormat[];
|
|
2524
|
+
/**
|
|
2525
|
+
* Direct passthrough for Sharp configuration.
|
|
2526
|
+
*
|
|
2527
|
+
* @remarks
|
|
2528
|
+
* If any normalization constraints (`minWidth`, `maxWidth`, `minAspectRatio`, `maxAspectRatio`)
|
|
2529
|
+
* are provided, they take precedence. When no constraints are provided, `resize` is applied.
|
|
2530
|
+
*/
|
|
2531
|
+
sharp?: {
|
|
2532
|
+
/** Optional resize transformation applied before encoding. Mirrors `sharp.resize()` options. */
|
|
2533
|
+
resize?: ResizeOptions;
|
|
2534
|
+
/**
|
|
2535
|
+
* Low-level hook executed after framework transforms and before output.
|
|
2536
|
+
* Must return the same Sharp pipeline instance (mutated) or a new pipeline.
|
|
2537
|
+
*
|
|
2538
|
+
* @example
|
|
2539
|
+
* ```ts
|
|
2540
|
+
* configure: s => s.rotate().withMetadata()
|
|
2541
|
+
* ```
|
|
2542
|
+
*/
|
|
2543
|
+
configure?: (instance: SharpInstance) => SharpInstance;
|
|
2544
|
+
};
|
|
2545
|
+
};
|
|
2546
|
+
/** Mapping of encoder-specific options keyed by output format. */
|
|
2547
|
+
type OutputOptionsMap = {
|
|
2548
|
+
jpeg: JpegOptions;
|
|
2549
|
+
png: PngOptions;
|
|
2550
|
+
webp: WebpOptions;
|
|
2551
|
+
avif: AvifOptions;
|
|
2552
|
+
heif: HeifOptions;
|
|
2553
|
+
tiff: TiffOptions;
|
|
2554
|
+
jp2: Jp2Options;
|
|
2555
|
+
jxl: JxlOptions;
|
|
2556
|
+
gif: GifOptions;
|
|
2557
|
+
};
|
|
2558
|
+
/**
|
|
2559
|
+
* Image normalization options describing validation and encoding.
|
|
2560
|
+
*/
|
|
2561
|
+
type ImageOptions = { [F in keyof OutputOptionsMap]: Base & {
|
|
2562
|
+
/**
|
|
2563
|
+
* Target encoder/format for the processed output.
|
|
2564
|
+
* Determines the allowed type of `sharp.toFormat` options below.
|
|
2565
|
+
*/
|
|
2566
|
+
outputFormat: F;
|
|
2567
|
+
/**
|
|
2568
|
+
* Sharp passthrough:
|
|
2569
|
+
* - `resize` (honored only when no normalization constraints are present)
|
|
2570
|
+
* - `toFormat` options (passed to `sharp.toFormat(outputFormat, toFormat)`).
|
|
2571
|
+
*/
|
|
2572
|
+
sharp?: Base['sharp'] & {
|
|
2573
|
+
/** Options passed to `sharp.toFormat(outputFormat, toFormat)` */
|
|
2574
|
+
toFormat?: OutputOptionsMap[F];
|
|
2575
|
+
};
|
|
2576
|
+
}; }[keyof OutputOptionsMap] & {
|
|
2577
|
+
/** Minimum target width (e.g., 320). */
|
|
2578
|
+
minWidth?: number;
|
|
2579
|
+
/** Maximum target width (e.g., 1080). */
|
|
2580
|
+
maxWidth?: number;
|
|
2581
|
+
/** Minimum supported aspect ratio (width/height), e.g., 0.8 (4:5). */
|
|
2582
|
+
minAspectRatio?: number;
|
|
2583
|
+
/** Maximum supported aspect ratio (width/height), e.g., 1.91 (1.91:1). */
|
|
2584
|
+
maxAspectRatio?: number;
|
|
2585
|
+
/** Aspect-ratio comparison tolerance (e.g., 0.01). */
|
|
2586
|
+
aspectRatioTolerance?: number;
|
|
2587
|
+
};
|
|
2588
|
+
//#endregion
|
|
2589
|
+
//#region src/image/image-normalization-controller.d.ts
|
|
2590
|
+
interface ImageNormalizationController {
|
|
2591
|
+
processBufferToBuffer(input: Buffer, options?: ImageOptions): Promise<{
|
|
2592
|
+
buffer: Buffer;
|
|
2593
|
+
type: FormatType;
|
|
2594
|
+
}>;
|
|
2595
|
+
processBufferToStream(input: Buffer, options?: ImageOptions): Promise<{
|
|
2596
|
+
stream: Readable;
|
|
2597
|
+
type: FormatType;
|
|
2598
|
+
}>;
|
|
2599
|
+
processStreamToBuffer(input: Readable, options?: ImageOptions): Promise<{
|
|
2600
|
+
buffer: Buffer;
|
|
2601
|
+
type: FormatType;
|
|
2602
|
+
}>;
|
|
2603
|
+
processStreamToStream(input: Readable, options?: ImageOptions): Promise<{
|
|
2604
|
+
stream: Readable;
|
|
2605
|
+
type: FormatType;
|
|
2606
|
+
}>;
|
|
2607
|
+
}
|
|
2608
|
+
declare class ImageNormalizationControllerImpl implements ImageNormalizationController {
|
|
2609
|
+
private readonly formatter;
|
|
2610
|
+
constructor(formatter: UnitFormatterController);
|
|
2611
|
+
processBufferToBuffer(input: Buffer, options?: ImageOptions): Promise<{
|
|
2612
|
+
buffer: Buffer<ArrayBuffer>;
|
|
2613
|
+
type: FormatType;
|
|
2614
|
+
}>;
|
|
2615
|
+
processBufferToStream(input: Buffer, options?: ImageOptions): Promise<{
|
|
2616
|
+
stream: Readable;
|
|
2617
|
+
type: FormatType;
|
|
2618
|
+
}>;
|
|
2619
|
+
processStreamToBuffer(input: Readable, options?: ImageOptions): Promise<{
|
|
2620
|
+
buffer: Buffer<ArrayBuffer>;
|
|
2621
|
+
type: FormatType;
|
|
2622
|
+
}>;
|
|
2623
|
+
processStreamToStream(input: Readable, options?: ImageOptions): Promise<{
|
|
2624
|
+
stream: Readable;
|
|
2625
|
+
type: FormatType;
|
|
2626
|
+
}>;
|
|
2627
|
+
private transform;
|
|
2628
|
+
private validateInputFormat;
|
|
2629
|
+
private validateMaximumSize;
|
|
2630
|
+
private toSharpFormat;
|
|
2631
|
+
private toFormatType;
|
|
2632
|
+
private getFormatInfo;
|
|
2633
|
+
private asReadable;
|
|
2634
|
+
private applyNormalization;
|
|
2635
|
+
private validateConstraints;
|
|
2636
|
+
private pickTargetAspectRatio;
|
|
2637
|
+
private makeDefaultOptions;
|
|
2638
|
+
}
|
|
2639
|
+
//#endregion
|
|
2640
|
+
//#region src/normalization/normalization-controller.d.ts
|
|
2641
|
+
interface NormalizationController {
|
|
2642
|
+
normalizeEmail(email: string): string;
|
|
2643
|
+
normalizePhoneToE164(phoneNumber: string): string;
|
|
2644
|
+
normalizePhoneToInternational(phoneNumber: string): string;
|
|
2645
|
+
normalizePhoneToNational(phoneNumber: string): string;
|
|
2646
|
+
}
|
|
2647
|
+
declare class NormalizationControllerImpl implements NormalizationController {
|
|
2648
|
+
normalizeEmail(email: string): string;
|
|
2649
|
+
normalizePhoneToE164(phoneNumber: string): string;
|
|
2650
|
+
normalizePhoneToInternational(phoneNumber: string): string;
|
|
2651
|
+
normalizePhoneToNational(phoneNumber: string): string;
|
|
2652
|
+
}
|
|
2653
|
+
//#endregion
|
|
2654
|
+
//#region src/notification/notification-channel.d.ts
|
|
2655
|
+
declare enum NotificationChannel {
|
|
2656
|
+
Telegram = "telegram"
|
|
2657
|
+
}
|
|
2658
|
+
//#endregion
|
|
2659
|
+
//#region src/notification/notification-message.d.ts
|
|
2660
|
+
interface NotificationMessage {
|
|
2661
|
+
readonly title?: string;
|
|
2662
|
+
readonly message: string;
|
|
2663
|
+
}
|
|
2664
|
+
//#endregion
|
|
2665
|
+
//#region src/notification/channels/telegram/telegram-notification-request.d.ts
|
|
2666
|
+
interface TelegramNotificationRequest {
|
|
2667
|
+
readonly type: NotificationChannel.Telegram;
|
|
2668
|
+
readonly payload: NotificationMessage;
|
|
2669
|
+
}
|
|
2670
|
+
//#endregion
|
|
2671
|
+
//#region src/notification/notification-request.d.ts
|
|
2672
|
+
type NotificationChannelRequest = TelegramNotificationRequest;
|
|
2673
|
+
interface NotificationRequest {
|
|
2674
|
+
readonly channels: readonly [NotificationChannelRequest, ...NotificationChannelRequest[]];
|
|
2675
|
+
}
|
|
2676
|
+
//#endregion
|
|
2677
|
+
//#region src/notification/notification-result.d.ts
|
|
2678
|
+
type NotificationDeliveryStatus = 'sent' | 'failed';
|
|
2679
|
+
interface NotificationDeliveryResult {
|
|
2680
|
+
readonly channel: NotificationChannel;
|
|
2681
|
+
readonly status: NotificationDeliveryStatus;
|
|
2682
|
+
}
|
|
2683
|
+
interface NotificationResult {
|
|
2684
|
+
readonly deliveries: readonly NotificationDeliveryResult[];
|
|
2685
|
+
}
|
|
2686
|
+
//#endregion
|
|
2687
|
+
//#region src/notification/notification-controller.d.ts
|
|
2688
|
+
interface NotificationSendOptions {
|
|
2689
|
+
readonly throwOnFailure?: boolean;
|
|
2690
|
+
}
|
|
2691
|
+
interface NotificationController {
|
|
2692
|
+
send(request: NotificationRequest, options?: NotificationSendOptions): Promise<NotificationResult>;
|
|
2693
|
+
}
|
|
2694
|
+
//#endregion
|
|
2695
|
+
//#region src/openapi/controller.d.ts
|
|
2696
|
+
interface OpenAPISchemaController {
|
|
2697
|
+
makeResponse(description: string, contents: Partial<Record<OpenAPIMediaType, OpenAPISchemaMediaType>>, headers?: OpenAPISchemaHeaders): OpenAPISchemaResponse;
|
|
2698
|
+
}
|
|
2699
|
+
declare class OpenAPISchemaControllerImpl implements OpenAPISchemaController {
|
|
2700
|
+
makeResponse(description: string, contents: Partial<Record<OpenAPIMediaType, OpenAPISchemaMediaType>>, headers?: OpenAPISchemaHeaders): OpenAPISchemaResponse;
|
|
2701
|
+
private constructContent;
|
|
2702
|
+
private constructExamples;
|
|
2703
|
+
private constructHeaders;
|
|
2704
|
+
}
|
|
2705
|
+
//#endregion
|
|
2706
|
+
//#region src/openapi/example.d.ts
|
|
2707
|
+
interface OpenAPISchemaExample {
|
|
2708
|
+
summary: string;
|
|
2709
|
+
value: any;
|
|
2710
|
+
}
|
|
2711
|
+
//#endregion
|
|
2712
|
+
//#region src/openapi/headers.d.ts
|
|
2713
|
+
interface OpenAPISchemaHeader {
|
|
2714
|
+
description?: string;
|
|
2715
|
+
type: string;
|
|
2716
|
+
format?: string;
|
|
2717
|
+
}
|
|
2718
|
+
type OpenAPISchemaHeaders = Partial<Record<string, OpenAPISchemaHeader>>;
|
|
2719
|
+
//#endregion
|
|
2720
|
+
//#region src/openapi/media-type.d.ts
|
|
2721
|
+
type OpenAPIMediaType = 'application/json' | 'application/xml' | 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain; charset=utf-8' | 'text/html' | 'application/pdf' | 'image/png' | 'application/vnd.mycompany.myapp.v2+json' | 'application/vnd.ms-excel' | 'application/vnd.openstreetmap.data+xml' | 'application/vnd.github-issue.text+json' | 'application/vnd.github.v3.diff' | 'image/vnd.djvu';
|
|
2722
|
+
interface OpenAPISchemaMediaType {
|
|
2723
|
+
schema: any;
|
|
2724
|
+
examples?: Record<string, OpenAPISchemaExample>;
|
|
2725
|
+
}
|
|
2726
|
+
//#endregion
|
|
2727
|
+
//#region src/openapi/response.d.ts
|
|
2728
|
+
interface OpenAPISchemaResponse {
|
|
2729
|
+
description: string;
|
|
2730
|
+
content: Record<OpenAPIMediaType, {
|
|
2731
|
+
schema: any;
|
|
2732
|
+
examples?: Record<string, any>;
|
|
2733
|
+
}>;
|
|
2734
|
+
headers?: OpenAPISchemaHeaders;
|
|
2735
|
+
}
|
|
2736
|
+
//#endregion
|
|
2737
|
+
//#region src/security/cryptography-options.d.ts
|
|
2738
|
+
/**
|
|
2739
|
+
* @description Supported output encodings for cryptographic digest and MAC values.
|
|
2740
|
+
*/
|
|
2741
|
+
type CryptographyOutputEncoding = 'hex' | 'base64url';
|
|
2742
|
+
/**
|
|
2743
|
+
* @description Supported digest algorithms.
|
|
2744
|
+
*/
|
|
2745
|
+
type DigestAlgorithm = 'sha256' | 'sha384' | 'sha512';
|
|
2746
|
+
/**
|
|
2747
|
+
* @description Options for cryptographic digest generation.
|
|
2748
|
+
*/
|
|
2749
|
+
interface DigestOptions {
|
|
2750
|
+
/**
|
|
2751
|
+
* @description Digest algorithm.
|
|
2752
|
+
*/
|
|
2753
|
+
algorithm: DigestAlgorithm;
|
|
2754
|
+
/**
|
|
2755
|
+
* @description Encoded output format.
|
|
2756
|
+
*/
|
|
2757
|
+
outputEncoding: CryptographyOutputEncoding;
|
|
2758
|
+
}
|
|
2759
|
+
/**
|
|
2760
|
+
* @description Supported message authentication code algorithms.
|
|
2761
|
+
*/
|
|
2762
|
+
type MacAlgorithm = 'hmac-sha256' | 'hmac-sha384' | 'hmac-sha512';
|
|
2763
|
+
/**
|
|
2764
|
+
* @description Options for message authentication code generation and verification.
|
|
2765
|
+
*/
|
|
2766
|
+
interface MacOptions {
|
|
2767
|
+
/**
|
|
2768
|
+
* @description Message authentication code algorithm.
|
|
2769
|
+
*/
|
|
2770
|
+
algorithm: MacAlgorithm;
|
|
2771
|
+
/**
|
|
2772
|
+
* @description Secret key used by the MAC algorithm.
|
|
2773
|
+
*/
|
|
2774
|
+
secret: string;
|
|
2775
|
+
/**
|
|
2776
|
+
* @description Encoded output format.
|
|
2777
|
+
*/
|
|
2778
|
+
outputEncoding: CryptographyOutputEncoding;
|
|
2779
|
+
}
|
|
2780
|
+
/**
|
|
2781
|
+
* @description Supported password hash algorithms.
|
|
2782
|
+
*/
|
|
2783
|
+
type PasswordHashAlgorithm = 'argon2id';
|
|
2784
|
+
/**
|
|
2785
|
+
* @description Options for password hashing.
|
|
2786
|
+
*/
|
|
2787
|
+
interface PasswordHashOptions {
|
|
2788
|
+
/**
|
|
2789
|
+
* @description Password hash algorithm.
|
|
2790
|
+
*/
|
|
2791
|
+
algorithm: PasswordHashAlgorithm;
|
|
2792
|
+
/**
|
|
2793
|
+
* @description Argon2 memory cost in KiB.
|
|
2794
|
+
*/
|
|
2795
|
+
memoryCost: number;
|
|
2796
|
+
/**
|
|
2797
|
+
* @description Argon2 iteration count.
|
|
2798
|
+
*/
|
|
2799
|
+
timeCost: number;
|
|
2800
|
+
/**
|
|
2801
|
+
* @description Argon2 parallelism factor.
|
|
2802
|
+
*/
|
|
2803
|
+
parallelism: number;
|
|
2804
|
+
}
|
|
2805
|
+
//#endregion
|
|
2806
|
+
//#region src/security/cryptography-controller.d.ts
|
|
2807
|
+
/**
|
|
2808
|
+
* @description Generic cryptography primitives for Node runtime code.
|
|
2809
|
+
*/
|
|
2810
|
+
interface CryptographyController {
|
|
2811
|
+
/**
|
|
2812
|
+
* @description Generates a digest for a UTF-8 string value.
|
|
2813
|
+
*/
|
|
2814
|
+
digest(value: string, options: DigestOptions): string;
|
|
2815
|
+
/**
|
|
2816
|
+
* @description Generates a message authentication code for a UTF-8 string value.
|
|
2817
|
+
*/
|
|
2818
|
+
mac(value: string, options: MacOptions): string;
|
|
2819
|
+
/**
|
|
2820
|
+
* @description Verifies a message authentication code in constant time when lengths match.
|
|
2821
|
+
*/
|
|
2822
|
+
verifyMac(value: string, expected: string, options: MacOptions): boolean;
|
|
2823
|
+
/**
|
|
2824
|
+
* @description Hashes a password using the selected password hashing algorithm.
|
|
2825
|
+
*/
|
|
2826
|
+
hashPassword(password: string, options: PasswordHashOptions): Promise<string>;
|
|
2827
|
+
/**
|
|
2828
|
+
* @description Verifies a password against an encoded password hash.
|
|
2829
|
+
*/
|
|
2830
|
+
verifyPassword(password: string, hash: string): Promise<boolean>;
|
|
2831
|
+
/**
|
|
2832
|
+
* @description Compares two strings in constant time when lengths match.
|
|
2833
|
+
*/
|
|
2834
|
+
timingSafeEqual(left: string, right: string): boolean;
|
|
2835
|
+
}
|
|
2836
|
+
declare class CryptographyControllerImpl implements CryptographyController {
|
|
2837
|
+
digest(value: string, options: DigestOptions): string;
|
|
2838
|
+
mac(value: string, options: MacOptions): string;
|
|
2839
|
+
verifyMac(value: string, expected: string, options: MacOptions): boolean;
|
|
2840
|
+
hashPassword(password: string, options: PasswordHashOptions): Promise<string>;
|
|
2841
|
+
verifyPassword(password: string, hash: string): Promise<boolean>;
|
|
2842
|
+
timingSafeEqual(left: string, right: string): boolean;
|
|
2843
|
+
private encode;
|
|
2844
|
+
private resolveDigestAlgorithm;
|
|
2845
|
+
private resolveMacAlgorithm;
|
|
2846
|
+
}
|
|
2847
|
+
//#endregion
|
|
2848
|
+
//#region src/security/token.d.ts
|
|
2849
|
+
declare class Token<T extends Record<string, unknown> = any> {
|
|
2850
|
+
private readonly _value;
|
|
2851
|
+
private readonly _payload;
|
|
2852
|
+
constructor(value: string, payload: T);
|
|
2853
|
+
get value(): string;
|
|
2854
|
+
get payload(): T;
|
|
2855
|
+
getField<K extends keyof T>(key: K): T[K] | undefined;
|
|
2856
|
+
}
|
|
2857
|
+
//#endregion
|
|
2858
|
+
//#region src/server/plugins/index.d.ts
|
|
2859
|
+
declare const FastifyPlugins: {
|
|
2860
|
+
readonly basicAuth: import("fastify").FastifyPluginAsync<ServerPluginBaseOptions>;
|
|
2861
|
+
readonly cookie: import("fastify").FastifyPluginAsync;
|
|
2862
|
+
readonly cors: import("fastify").FastifyPluginAsync<ServerPluginBaseOptions>;
|
|
2863
|
+
readonly health: import("fastify").FastifyPluginAsync<ServerPluginBaseOptions>;
|
|
2864
|
+
readonly ip: import("fastify").FastifyPluginAsync;
|
|
2865
|
+
readonly metrics: import("fastify").FastifyPluginAsync<ServerPluginBaseOptions>;
|
|
2866
|
+
readonly multipart: import("fastify").FastifyPluginAsync<ServerPluginBaseOptions>;
|
|
2867
|
+
readonly requestLogger: import("fastify").FastifyPluginAsync<ServerPluginBaseOptions>;
|
|
2868
|
+
readonly requestMetadata: import("fastify").FastifyPluginAsync<ServerPluginBaseOptions>;
|
|
2869
|
+
readonly requestScope: import("fastify").FastifyPluginAsync<ServerPluginBaseOptions>;
|
|
2870
|
+
readonly staticFiles: import("fastify").FastifyPluginAsync<ServerPluginBaseOptions>;
|
|
2871
|
+
readonly view: import("fastify").FastifyPluginAsync;
|
|
2872
|
+
};
|
|
2873
|
+
//#endregion
|
|
2874
|
+
//#region src/server/endpoint.d.ts
|
|
2875
|
+
interface Endpoint {
|
|
2876
|
+
method: HttpMethod;
|
|
2877
|
+
url: string;
|
|
2878
|
+
schema(server: FastifyInstance): FastifySchema;
|
|
2879
|
+
handle: (request: FastifyRequest) => Promise<HttpResponse>;
|
|
2880
|
+
}
|
|
2881
|
+
//#endregion
|
|
2882
|
+
//#region src/server/server-controller.d.ts
|
|
2883
|
+
interface ServerPluginBaseOptions {
|
|
2884
|
+
i18nController: I18nController;
|
|
2885
|
+
logger: Logger;
|
|
2886
|
+
apikitController: ApiKitController;
|
|
2887
|
+
}
|
|
2888
|
+
type ServerPluginOptions<TExtras extends object = {}> = ServerPluginBaseOptions & TExtras;
|
|
2889
|
+
type ServerPluginExternalHook = (instance: FastifyInstance, options: ServerPluginOptions) => Promise<void>;
|
|
2890
|
+
interface ServerController {
|
|
2891
|
+
get instance(): FastifyInstance;
|
|
2892
|
+
preparePlugins(externalHook?: ServerPluginExternalHook): Promise<void>;
|
|
2893
|
+
prepare(shutdownHook?: () => Promise<void>): Promise<void>;
|
|
2894
|
+
start(): Promise<void>;
|
|
2895
|
+
}
|
|
2896
|
+
declare class ServerControllerImpl implements ServerController {
|
|
2897
|
+
private i18n;
|
|
2898
|
+
private logger;
|
|
2899
|
+
private configuration;
|
|
2900
|
+
private server;
|
|
2901
|
+
constructor(i18n: I18nController, logger: Logger, configuration: ApiKitController);
|
|
2902
|
+
get instance(): FastifyInstance;
|
|
2903
|
+
preparePlugins(externalHook?: ServerPluginExternalHook): Promise<void>;
|
|
2904
|
+
prepare(shutdownHook?: () => Promise<void>): Promise<void>;
|
|
2905
|
+
start(): Promise<void>;
|
|
2906
|
+
private configureErrorHandler;
|
|
2907
|
+
private configureShutdownHandler;
|
|
2908
|
+
}
|
|
2909
|
+
//#endregion
|
|
2910
|
+
//#region src/server/request-controller.d.ts
|
|
2911
|
+
type HttpReplyPromise = (request: FastifyRequest, options: object) => Promise<HttpResponse>;
|
|
2912
|
+
type HttpOrVoidReplyPromise = (request: FastifyRequest, options?: object) => Promise<HttpResponse | void>;
|
|
2913
|
+
interface RequestController {
|
|
2914
|
+
handler(controllerFn: HttpReplyPromise, options?: object): (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
|
|
2915
|
+
preHandler(controllerFn: HttpOrVoidReplyPromise, options?: object): (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
|
|
2916
|
+
}
|
|
2917
|
+
declare class RequestControllerImpl implements RequestController {
|
|
2918
|
+
private logger;
|
|
2919
|
+
private responseController;
|
|
2920
|
+
constructor(logger: Logger, responseController: ResponseController);
|
|
2921
|
+
handler(controllerFn: HttpReplyPromise, options?: object): (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
|
|
2922
|
+
preHandler(controllerFn: HttpOrVoidReplyPromise, options?: object): (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
|
|
2923
|
+
private logError;
|
|
2924
|
+
}
|
|
2925
|
+
//#endregion
|
|
2926
|
+
//#region src/server/response-controller.d.ts
|
|
2927
|
+
interface ResponseController {
|
|
2928
|
+
sendResponse(request: FastifyRequest, reply: FastifyReply, response: HttpResponse): Promise<void>;
|
|
2929
|
+
}
|
|
2930
|
+
declare class ResponseControllerImpl implements ResponseController {
|
|
2931
|
+
private logger;
|
|
2932
|
+
constructor(logger: Logger);
|
|
2933
|
+
sendResponse(request: FastifyRequest, reply: FastifyReply, response: HttpResponse): Promise<void>;
|
|
2934
|
+
private sendJSONResponse;
|
|
2935
|
+
private sendFileResponse;
|
|
2936
|
+
private createResponseHeaders;
|
|
2937
|
+
}
|
|
2938
|
+
//#endregion
|
|
2939
|
+
//#region src/validation/dto-validation-controller.d.ts
|
|
2940
|
+
interface DtoValidationController {
|
|
2941
|
+
/**
|
|
2942
|
+
* Synchronously parse & validate `data` with a Zod schema.
|
|
2943
|
+
*
|
|
2944
|
+
* - The return type is inferred from `schema` via `z.infer<S>`.
|
|
2945
|
+
* - Callers do NOT need to pass any generics.
|
|
2946
|
+
*
|
|
2947
|
+
* @param schema Zod schema to validate against.
|
|
2948
|
+
* @param data Raw input to validate.
|
|
2949
|
+
* @returns The parsed value typed as `z.infer<S>`.
|
|
2950
|
+
* @throws ApiError("Validation.INVALID_PROPERTIES") on validation failure.
|
|
2951
|
+
*
|
|
2952
|
+
* @example
|
|
2953
|
+
* import { z } from 'zod';
|
|
2954
|
+
*
|
|
2955
|
+
* const LoginSchema = z.object({
|
|
2956
|
+
* email: z.string().email(),
|
|
2957
|
+
* password: z.string().min(6),
|
|
2958
|
+
* });
|
|
2959
|
+
*
|
|
2960
|
+
* // Inferred type: { email: string; password: string }
|
|
2961
|
+
* const login = validator.validate(LoginSchema, rawBody);
|
|
2962
|
+
*/
|
|
2963
|
+
validate<S extends ZodType<any, any, any>>(schema: S, data: unknown): z.infer<S>;
|
|
2964
|
+
/**
|
|
2965
|
+
* Asynchronously parse & validate `data` with a Zod schema.
|
|
2966
|
+
*
|
|
2967
|
+
* - The return type is inferred from `schema` via `z.infer<S>`.
|
|
2968
|
+
* - Callers do NOT need to pass any generics.
|
|
2969
|
+
*
|
|
2970
|
+
* @param schema Zod schema to validate against.
|
|
2971
|
+
* @param data Raw input to validate.
|
|
2972
|
+
* @returns Promise resolving to `z.infer<S>`.
|
|
2973
|
+
* @throws ApiError("Validation.INVALID_PROPERTIES") on validation failure.
|
|
2974
|
+
*
|
|
2975
|
+
* @example
|
|
2976
|
+
* import { z } from 'zod';
|
|
2977
|
+
*
|
|
2978
|
+
* const RegisterSchema = z.object({
|
|
2979
|
+
* username: z.string().min(1),
|
|
2980
|
+
* email: z.string().email(),
|
|
2981
|
+
* password: z.string().min(8),
|
|
2982
|
+
* });
|
|
2983
|
+
*
|
|
2984
|
+
* // Inferred type: { username: string; email: string; password: string }
|
|
2985
|
+
* const user = await validator.validateAsync(RegisterSchema, requestBody);
|
|
2986
|
+
*/
|
|
2987
|
+
validateAsync<S extends ZodType<any, any, any>>(schema: S, data: unknown): Promise<z.infer<S>>;
|
|
2988
|
+
}
|
|
2989
|
+
declare class DtoValidationControllerImpl implements DtoValidationController {
|
|
2990
|
+
private configuration;
|
|
2991
|
+
private logger;
|
|
2992
|
+
constructor(configuration: ApiKitController, logger: Logger);
|
|
2993
|
+
validate<Output>(schema: ZodType<Output, any, any>, data: unknown): Output;
|
|
2994
|
+
validateAsync<Output>(schema: ZodType<Output, any, any>, data: unknown): Promise<Output>;
|
|
2995
|
+
private handleError;
|
|
2996
|
+
private buildValidationDetails;
|
|
2997
|
+
private buildValidationMessage;
|
|
2998
|
+
}
|
|
2999
|
+
//#endregion
|
|
3000
|
+
//#region src/validation/validation-controller.d.ts
|
|
3001
|
+
interface ValidationController {
|
|
3002
|
+
isValidEmail(email?: string | null): boolean;
|
|
3003
|
+
isValidEmailThrowing(email?: string | null): void;
|
|
3004
|
+
isValidPhoneNumber(phoneNumber?: string | null, countryCode?: string): boolean;
|
|
3005
|
+
isValidPhoneNumberThrowing(phoneNumber?: string | null, countryCode?: string): void;
|
|
3006
|
+
isValidCode(code?: string | null): boolean;
|
|
3007
|
+
isValidCodeThrowing(code?: string | null): void;
|
|
3008
|
+
isEmail(input?: string | null): boolean;
|
|
3009
|
+
isEmailThrowing(input?: string | null): void;
|
|
3010
|
+
isPhoneNumber(input?: string | null): boolean;
|
|
3011
|
+
isPhoneNumberThrowing(input?: string | null): void;
|
|
3012
|
+
isNumber(input?: any): boolean;
|
|
3013
|
+
isNumberThrowing(input?: any): void;
|
|
3014
|
+
isString(input?: string | null): boolean;
|
|
3015
|
+
isStringThrowing(input?: string | null): void;
|
|
3016
|
+
isEmptyString(input?: string | null): boolean;
|
|
3017
|
+
isEmptyStringThrowing(input?: string | null): void;
|
|
3018
|
+
isNonEmptyString(input?: string | null): boolean;
|
|
3019
|
+
isNonEmptyStringThrowing(input?: string | null): string;
|
|
3020
|
+
isValidDate(dateString?: string | null): boolean;
|
|
3021
|
+
isValidDateThrowing(dateString?: string | null): Date;
|
|
3022
|
+
}
|
|
3023
|
+
declare class ValidationControllerImpl implements ValidationController {
|
|
3024
|
+
isValidEmail(email?: string | null): boolean;
|
|
3025
|
+
isValidEmailThrowing(email?: string | null): void;
|
|
3026
|
+
isValidPhoneNumber(phoneNumber?: string | null, countryCode?: string): boolean;
|
|
3027
|
+
isValidPhoneNumberThrowing(phoneNumber?: string | null, countryCode?: string): void;
|
|
3028
|
+
isValidCode(code?: string | null): boolean;
|
|
3029
|
+
isValidCodeThrowing(code?: string | null): void;
|
|
3030
|
+
isEmail(input?: string | null): boolean;
|
|
3031
|
+
isEmailThrowing(input?: string | null): void;
|
|
3032
|
+
isPhoneNumber(input?: string | null): boolean;
|
|
3033
|
+
isPhoneNumberThrowing(input?: string | null): void;
|
|
3034
|
+
isNumber(input?: any): boolean;
|
|
3035
|
+
isNumberThrowing(input?: any): void;
|
|
3036
|
+
isString(input?: string | null): boolean;
|
|
3037
|
+
isStringThrowing(input?: string | null): void;
|
|
3038
|
+
isEmptyString(input?: string | null): boolean;
|
|
3039
|
+
isEmptyStringThrowing(input?: string | null): void;
|
|
3040
|
+
isNonEmptyString(input?: string | null): boolean;
|
|
3041
|
+
isNonEmptyStringThrowing(input?: string | null): string;
|
|
3042
|
+
isValidDate(dateString?: string | null): boolean;
|
|
3043
|
+
isValidDateThrowing(dateString?: string | null): Date;
|
|
3044
|
+
}
|
|
3045
|
+
//#endregion
|
|
3046
|
+
//#region src/index.d.ts
|
|
3047
|
+
declare function apikitAssembly(): Assembly[];
|
|
3048
|
+
//#endregion
|
|
3049
|
+
export { ApiError, ApiErrorCodes, ApiErrorDefinition, ApiErrorDetails, ApiErrorFactory, ApiErrorFactoryOptions, ApiErrorPath, ApiErrorProperties, ApiErrorTree, ApiKitConfig, ApiKitController, ApiKitControllerImpl, ApiKitL10n, ApiKitL10nResource, ApiKitSymbols, AuthorizationErrors, BaseEmailTemplate, BasicAuthAuthenticate, BasicAuthConfig, BasicAuthConfiguration, BuildConfig, BuildConfiguration, type BuildMetadata, CommonErrors, type ConfigurationContract, type ConfigurationField, type ConfigurationResolveContext, Cookie, CookieMutation, CookieOptions, CorsConfig, CorsConfiguration, CorsOptions, CryptographyController, CryptographyControllerImpl, CryptographyOutputEncoding, DEFAULT_GENERATE_STRING_OPTIONS, DefineApiKitInput, DigestAlgorithm, DigestOptions, DtoValidationController, DtoValidationControllerImpl, EmailConfig, EmailConfiguration, EmailController, EmailControllerImpl, EmailTemplate, EmailTemplateInput, Endpoint, type EnvironmentConfig, type EnvironmentDefinition, type EnvironmentRegistry, FastifyPlugins, FileHttpResponse, FormatErrors, FormatType, Formatter, FormatterController, FormatterControllerImpl, GenerateNumberOptions, GenerateStringOptions, HealthConfig, HealthConfiguration, HttpHeaderKey, HttpHeaderValues, HttpHeaders, HttpMethod, HttpResponse, I18nConfig, I18nConfiguration, I18nController, I18nControllerImpl, I18nDirectoryEntry, I18nFactory, I18nFactoryOptions, I18nFallbackLanguages, I18nFileEntry, I18nLoadMode, I18nOptions, I18nPreload, I18nProvider, IRequestScope, ImageErrors, ImageNormalizationController, ImageNormalizationControllerImpl, ImageOptions, type InferConfiguration, JSONHttpResponse, LimitErrors, LoadApiKitContextOptions, LoggerConfig, LoggerConfiguration, LoggerConfigurationValue, LoggerRequestOptions, MacAlgorithm, MacOptions, MetricsConfig, MetricsConfiguration, MetricsDefaultConfig, MetricsEndpoint, MetricsRouteConfig, MongoDbComparisonOperators, MongoDbFieldQuery, MongoDbFieldValue, MongoDbLogicalOperators, MongoDbQuery, MongoDbQueryFormatter, MongoDbQueryFormatterImpl, MongoDbUpdateOptions, MultipartConfig, MultipartConfiguration, MultipartFormatterController, MultipartFormatterControllerImpl, MultipartOptions, NormalizationController, NormalizationControllerImpl, NotificationChannel, NotificationChannelRequest, NotificationChannelsConfig, NotificationConfig, NotificationConfiguration, NotificationConfigurationValue, NotificationController, NotificationDeliveryResult, NotificationDeliveryStatus, NotificationMessage, NotificationRequest, NotificationResult, NotificationSendOptions, OpenAPIMediaType, OpenAPISchemaController, OpenAPISchemaControllerImpl, OpenAPISchemaExample, OpenAPISchemaHeader, OpenAPISchemaHeaders, OpenAPISchemaMediaType, OpenAPISchemaResponse, ParseLocaleOptions, PasswordHashAlgorithm, PasswordHashOptions, RANDOM_VALUE_GENERATOR_LIMITS, RandomValueAlphabet, RandomValueAlphabetPreset, RandomValueCustomAlphabet, RandomValueGenerator, RandomValueGeneratorImpl, RequestController, RequestControllerImpl, RequestLogMetadata, RequestMetadata, RequestScope, RequestScopeData, ResponseController, ResponseControllerImpl, ResponseType, ServerConfig, ServerConfiguration, ServerController, ServerControllerImpl, ServerErrors, ServerPluginBaseOptions, ServerPluginExternalHook, ServerPluginOptions, SharpFormat, SharpInstance, StaticFilesConfig, StaticFilesConfiguration, StaticFilesDotfilesMode, TelegramNotificationConfig, TelegramNotificationRequest, TemporaryFileRepository, TemporaryFileRepositoryImpl, Token, TrustProxy, ValidationController, ValidationControllerImpl, ValidationErrors, apikitAssembly, defineApiKit, defineConfiguration, defineEnvironments, defineErrors, defineSource, fastifyBasicAuth, fastifyCookie, fastifyCors, fastifyIp, fastifyMetrics, fastifyMultipart, fastifyStatic, fastifyUnderPressure, fastifyView, field, fp, isApiErrorDefinition, loadApiKitContext };
|