@restura/core 0.1.0-alpha.1 → 0.1.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,3 +1,1501 @@
1
- declare function isEven(value: number): boolean;
1
+ import winston from 'winston';
2
+ import * as express from 'express';
3
+ import { z } from 'zod';
4
+ import { PoolConfig, Pool } from 'pg';
5
+ import { IncomingHttpHeaders } from 'http2';
2
6
 
3
- export { isEven };
7
+ declare const logger: winston.Logger;
8
+
9
+ interface RsErrorInternalData {
10
+ err: ErrorCode;
11
+ msg: string;
12
+ stack: string;
13
+ status: number;
14
+ message?: string;
15
+ }
16
+ declare enum HtmlStatusCodes {
17
+ BAD_REQUEST = 400,
18
+ UNAUTHORIZED = 401,
19
+ FORBIDDEN = 403,
20
+ NOT_FOUND = 404,
21
+ METHOD_NOT_ALLOWED = 405,
22
+ CONFLICT = 409,
23
+ VERSION_OUT_OF_DATE = 418,// Technically this is the I'm a teapot code that was a joke.
24
+ SERVER_ERROR = 500,
25
+ SERVICE_UNAVAILABLE = 503,
26
+ NETWORK_CONNECT_TIMEOUT = 599
27
+ }
28
+ type ErrorCode = 'UNKNOWN_ERROR' | 'NOT_FOUND' | 'EMAIL_TAKEN' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'CONFLICT' | 'UPDATE_FORBIDDEN' | 'CREATE_FORBIDDEN' | 'DELETE_FORBIDDEN' | 'DELETE_FAILURE' | 'BAD_REQUEST' | 'INVALID_TOKEN' | 'INCORRECT_EMAIL_OR_PASSWORD' | 'DUPLICATE_TOKEN' | 'DUPLICATE_USERNAME' | 'DUPLICATE_EMAIL' | 'DUPLICATE' | 'EMAIL_NOT_VERIFIED' | 'UPDATE_WITHOUT_ID' | 'CONNECTION_ERROR' | 'INVALID_PAYMENT' | 'DECLINED_PAYMENT' | 'INTEGRATION_ERROR' | 'CANNOT_RESERVE' | 'REFUND_FAILURE' | 'INVALID_INVOICE' | 'INVALID_COUPON' | 'SERVICE_UNAVAILABLE' | 'METHOD_UNALLOWED' | 'LOGIN_EXPIRED' | 'THIRD_PARTY_ERROR' | 'ACCESS_DENIED' | 'DATABASE_ERROR' | 'SCHEMA_ERROR';
29
+ declare class RsError {
30
+ err: ErrorCode;
31
+ msg: string;
32
+ status?: number;
33
+ stack: string;
34
+ constructor(errCode: ErrorCode, message?: string);
35
+ static htmlStatus(code: ErrorCode): number;
36
+ static isRsError(error: any): error is RsError;
37
+ }
38
+
39
+ declare const resturaConfigSchema: z.ZodObject<{
40
+ authToken: z.ZodString;
41
+ sendErrorStackTrace: z.ZodDefault<z.ZodBoolean>;
42
+ schemaFilePath: z.ZodDefault<z.ZodString>;
43
+ customApiFolderPath: z.ZodDefault<z.ZodString>;
44
+ generatedTypesPath: z.ZodDefault<z.ZodString>;
45
+ }, "strip", z.ZodTypeAny, {
46
+ authToken: string;
47
+ sendErrorStackTrace: boolean;
48
+ schemaFilePath: string;
49
+ customApiFolderPath: string;
50
+ generatedTypesPath: string;
51
+ }, {
52
+ authToken: string;
53
+ sendErrorStackTrace?: boolean | undefined;
54
+ schemaFilePath?: string | undefined;
55
+ customApiFolderPath?: string | undefined;
56
+ generatedTypesPath?: string | undefined;
57
+ }>;
58
+ type ResturaConfigSchema = z.infer<typeof resturaConfigSchema>;
59
+
60
+ declare const resturaZodSchema: z.ZodObject<{
61
+ database: z.ZodArray<z.ZodObject<{
62
+ name: z.ZodString;
63
+ columns: z.ZodArray<z.ZodObject<{
64
+ name: z.ZodString;
65
+ type: z.ZodUnion<[z.ZodEnum<["SMALLINT", "INTEGER", "BIGINT", "DECIMAL", "NUMERIC", "REAL", "DOUBLE PRECISION", "SERIAL", "BIGSERIAL"]>, z.ZodEnum<["CHAR", "VARCHAR", "TEXT", "BYTEA"]>, z.ZodEnum<["DATE", "TIMESTAMP", "TIMESTAMPTZ", "TIME", "INTERVAL"]>, z.ZodEnum<["BOOLEAN", "TINYINT", "SMALLINT", "MEDIUMINT", "INTEGER", "BIGINT", "DECIMAL", "FLOAT", "DOUBLE"]>, z.ZodEnum<["CHAR", "VARCHAR", "TINYTEXT", "TINYBLOB", "TEXT", "BLOB", "MEDIUMTEXT", "MEDIUMBLOB", "LONGTEXT", "JSON", "LONGBLOB", "ENUM"]>, z.ZodEnum<["DATE", "DATETIME", "TIME", "TIMESTAMP"]>]>;
66
+ isNullable: z.ZodBoolean;
67
+ roles: z.ZodArray<z.ZodString, "many">;
68
+ comment: z.ZodOptional<z.ZodString>;
69
+ default: z.ZodOptional<z.ZodString>;
70
+ value: z.ZodOptional<z.ZodString>;
71
+ isPrimary: z.ZodOptional<z.ZodBoolean>;
72
+ isUnique: z.ZodOptional<z.ZodBoolean>;
73
+ hasAutoIncrement: z.ZodOptional<z.ZodBoolean>;
74
+ length: z.ZodOptional<z.ZodNumber>;
75
+ }, "strict", z.ZodTypeAny, {
76
+ type: "SMALLINT" | "INTEGER" | "BIGINT" | "DECIMAL" | "NUMERIC" | "REAL" | "DOUBLE PRECISION" | "SERIAL" | "BIGSERIAL" | "CHAR" | "VARCHAR" | "TEXT" | "BYTEA" | "DATE" | "TIMESTAMP" | "TIMESTAMPTZ" | "TIME" | "INTERVAL" | "BOOLEAN" | "TINYINT" | "MEDIUMINT" | "FLOAT" | "DOUBLE" | "TINYTEXT" | "TINYBLOB" | "BLOB" | "MEDIUMTEXT" | "MEDIUMBLOB" | "LONGTEXT" | "JSON" | "LONGBLOB" | "ENUM" | "DATETIME";
77
+ name: string;
78
+ isNullable: boolean;
79
+ roles: string[];
80
+ length?: number | undefined;
81
+ value?: string | undefined;
82
+ default?: string | undefined;
83
+ comment?: string | undefined;
84
+ isPrimary?: boolean | undefined;
85
+ isUnique?: boolean | undefined;
86
+ hasAutoIncrement?: boolean | undefined;
87
+ }, {
88
+ type: "SMALLINT" | "INTEGER" | "BIGINT" | "DECIMAL" | "NUMERIC" | "REAL" | "DOUBLE PRECISION" | "SERIAL" | "BIGSERIAL" | "CHAR" | "VARCHAR" | "TEXT" | "BYTEA" | "DATE" | "TIMESTAMP" | "TIMESTAMPTZ" | "TIME" | "INTERVAL" | "BOOLEAN" | "TINYINT" | "MEDIUMINT" | "FLOAT" | "DOUBLE" | "TINYTEXT" | "TINYBLOB" | "BLOB" | "MEDIUMTEXT" | "MEDIUMBLOB" | "LONGTEXT" | "JSON" | "LONGBLOB" | "ENUM" | "DATETIME";
89
+ name: string;
90
+ isNullable: boolean;
91
+ roles: string[];
92
+ length?: number | undefined;
93
+ value?: string | undefined;
94
+ default?: string | undefined;
95
+ comment?: string | undefined;
96
+ isPrimary?: boolean | undefined;
97
+ isUnique?: boolean | undefined;
98
+ hasAutoIncrement?: boolean | undefined;
99
+ }>, "many">;
100
+ indexes: z.ZodArray<z.ZodObject<{
101
+ name: z.ZodString;
102
+ columns: z.ZodArray<z.ZodString, "many">;
103
+ isUnique: z.ZodBoolean;
104
+ isPrimaryKey: z.ZodBoolean;
105
+ order: z.ZodEnum<["ASC", "DESC"]>;
106
+ }, "strict", z.ZodTypeAny, {
107
+ order: "ASC" | "DESC";
108
+ name: string;
109
+ isUnique: boolean;
110
+ columns: string[];
111
+ isPrimaryKey: boolean;
112
+ }, {
113
+ order: "ASC" | "DESC";
114
+ name: string;
115
+ isUnique: boolean;
116
+ columns: string[];
117
+ isPrimaryKey: boolean;
118
+ }>, "many">;
119
+ foreignKeys: z.ZodArray<z.ZodObject<{
120
+ name: z.ZodString;
121
+ column: z.ZodString;
122
+ refTable: z.ZodString;
123
+ refColumn: z.ZodString;
124
+ onDelete: z.ZodEnum<["CASCADE", "SET NULL", "RESTRICT", "NO ACTION", "SET DEFAULT"]>;
125
+ onUpdate: z.ZodEnum<["CASCADE", "SET NULL", "RESTRICT", "NO ACTION", "SET DEFAULT"]>;
126
+ }, "strict", z.ZodTypeAny, {
127
+ name: string;
128
+ column: string;
129
+ refTable: string;
130
+ refColumn: string;
131
+ onDelete: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION" | "SET DEFAULT";
132
+ onUpdate: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION" | "SET DEFAULT";
133
+ }, {
134
+ name: string;
135
+ column: string;
136
+ refTable: string;
137
+ refColumn: string;
138
+ onDelete: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION" | "SET DEFAULT";
139
+ onUpdate: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION" | "SET DEFAULT";
140
+ }>, "many">;
141
+ checkConstraints: z.ZodArray<z.ZodObject<{
142
+ name: z.ZodString;
143
+ check: z.ZodString;
144
+ }, "strict", z.ZodTypeAny, {
145
+ name: string;
146
+ check: string;
147
+ }, {
148
+ name: string;
149
+ check: string;
150
+ }>, "many">;
151
+ roles: z.ZodArray<z.ZodString, "many">;
152
+ }, "strict", z.ZodTypeAny, {
153
+ name: string;
154
+ roles: string[];
155
+ columns: {
156
+ type: "SMALLINT" | "INTEGER" | "BIGINT" | "DECIMAL" | "NUMERIC" | "REAL" | "DOUBLE PRECISION" | "SERIAL" | "BIGSERIAL" | "CHAR" | "VARCHAR" | "TEXT" | "BYTEA" | "DATE" | "TIMESTAMP" | "TIMESTAMPTZ" | "TIME" | "INTERVAL" | "BOOLEAN" | "TINYINT" | "MEDIUMINT" | "FLOAT" | "DOUBLE" | "TINYTEXT" | "TINYBLOB" | "BLOB" | "MEDIUMTEXT" | "MEDIUMBLOB" | "LONGTEXT" | "JSON" | "LONGBLOB" | "ENUM" | "DATETIME";
157
+ name: string;
158
+ isNullable: boolean;
159
+ roles: string[];
160
+ length?: number | undefined;
161
+ value?: string | undefined;
162
+ default?: string | undefined;
163
+ comment?: string | undefined;
164
+ isPrimary?: boolean | undefined;
165
+ isUnique?: boolean | undefined;
166
+ hasAutoIncrement?: boolean | undefined;
167
+ }[];
168
+ indexes: {
169
+ order: "ASC" | "DESC";
170
+ name: string;
171
+ isUnique: boolean;
172
+ columns: string[];
173
+ isPrimaryKey: boolean;
174
+ }[];
175
+ foreignKeys: {
176
+ name: string;
177
+ column: string;
178
+ refTable: string;
179
+ refColumn: string;
180
+ onDelete: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION" | "SET DEFAULT";
181
+ onUpdate: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION" | "SET DEFAULT";
182
+ }[];
183
+ checkConstraints: {
184
+ name: string;
185
+ check: string;
186
+ }[];
187
+ }, {
188
+ name: string;
189
+ roles: string[];
190
+ columns: {
191
+ type: "SMALLINT" | "INTEGER" | "BIGINT" | "DECIMAL" | "NUMERIC" | "REAL" | "DOUBLE PRECISION" | "SERIAL" | "BIGSERIAL" | "CHAR" | "VARCHAR" | "TEXT" | "BYTEA" | "DATE" | "TIMESTAMP" | "TIMESTAMPTZ" | "TIME" | "INTERVAL" | "BOOLEAN" | "TINYINT" | "MEDIUMINT" | "FLOAT" | "DOUBLE" | "TINYTEXT" | "TINYBLOB" | "BLOB" | "MEDIUMTEXT" | "MEDIUMBLOB" | "LONGTEXT" | "JSON" | "LONGBLOB" | "ENUM" | "DATETIME";
192
+ name: string;
193
+ isNullable: boolean;
194
+ roles: string[];
195
+ length?: number | undefined;
196
+ value?: string | undefined;
197
+ default?: string | undefined;
198
+ comment?: string | undefined;
199
+ isPrimary?: boolean | undefined;
200
+ isUnique?: boolean | undefined;
201
+ hasAutoIncrement?: boolean | undefined;
202
+ }[];
203
+ indexes: {
204
+ order: "ASC" | "DESC";
205
+ name: string;
206
+ isUnique: boolean;
207
+ columns: string[];
208
+ isPrimaryKey: boolean;
209
+ }[];
210
+ foreignKeys: {
211
+ name: string;
212
+ column: string;
213
+ refTable: string;
214
+ refColumn: string;
215
+ onDelete: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION" | "SET DEFAULT";
216
+ onUpdate: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION" | "SET DEFAULT";
217
+ }[];
218
+ checkConstraints: {
219
+ name: string;
220
+ check: string;
221
+ }[];
222
+ }>, "many">;
223
+ endpoints: z.ZodArray<z.ZodObject<{
224
+ name: z.ZodString;
225
+ description: z.ZodString;
226
+ baseUrl: z.ZodString;
227
+ routes: z.ZodArray<z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
228
+ method: z.ZodEnum<["GET", "POST", "PUT", "PATCH", "DELETE"]>;
229
+ name: z.ZodString;
230
+ description: z.ZodString;
231
+ path: z.ZodString;
232
+ roles: z.ZodArray<z.ZodString, "many">;
233
+ }, {
234
+ type: z.ZodEnum<["ONE", "ARRAY", "PAGED"]>;
235
+ table: z.ZodString;
236
+ joins: z.ZodArray<z.ZodObject<{
237
+ table: z.ZodString;
238
+ localColumnName: z.ZodOptional<z.ZodString>;
239
+ foreignColumnName: z.ZodOptional<z.ZodString>;
240
+ custom: z.ZodOptional<z.ZodString>;
241
+ type: z.ZodEnum<["LEFT", "INNER"]>;
242
+ alias: z.ZodOptional<z.ZodString>;
243
+ }, "strict", z.ZodTypeAny, {
244
+ type: "LEFT" | "INNER";
245
+ table: string;
246
+ custom?: string | undefined;
247
+ localColumnName?: string | undefined;
248
+ foreignColumnName?: string | undefined;
249
+ alias?: string | undefined;
250
+ }, {
251
+ type: "LEFT" | "INNER";
252
+ table: string;
253
+ custom?: string | undefined;
254
+ localColumnName?: string | undefined;
255
+ foreignColumnName?: string | undefined;
256
+ alias?: string | undefined;
257
+ }>, "many">;
258
+ assignments: z.ZodArray<z.ZodObject<{
259
+ name: z.ZodString;
260
+ value: z.ZodString;
261
+ }, "strict", z.ZodTypeAny, {
262
+ value: string;
263
+ name: string;
264
+ }, {
265
+ value: string;
266
+ name: string;
267
+ }>, "many">;
268
+ where: z.ZodArray<z.ZodObject<{
269
+ tableName: z.ZodOptional<z.ZodString>;
270
+ columnName: z.ZodOptional<z.ZodString>;
271
+ operator: z.ZodOptional<z.ZodEnum<["=", "<", ">", "<=", ">=", "!=", "LIKE", "IN", "NOT IN", "STARTS WITH", "ENDS WITH"]>>;
272
+ value: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
273
+ custom: z.ZodOptional<z.ZodString>;
274
+ conjunction: z.ZodOptional<z.ZodEnum<["AND", "OR"]>>;
275
+ }, "strict", z.ZodTypeAny, {
276
+ value?: string | number | undefined;
277
+ custom?: string | undefined;
278
+ columnName?: string | undefined;
279
+ tableName?: string | undefined;
280
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
281
+ conjunction?: "AND" | "OR" | undefined;
282
+ }, {
283
+ value?: string | number | undefined;
284
+ custom?: string | undefined;
285
+ columnName?: string | undefined;
286
+ tableName?: string | undefined;
287
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
288
+ conjunction?: "AND" | "OR" | undefined;
289
+ }>, "many">;
290
+ request: z.ZodArray<z.ZodObject<{
291
+ name: z.ZodString;
292
+ required: z.ZodBoolean;
293
+ isNullable: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
294
+ validator: z.ZodArray<z.ZodObject<{
295
+ type: z.ZodEnum<["TYPE_CHECK", "MIN", "MAX", "ONE_OF"]>;
296
+ value: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodNumber, z.ZodArray<z.ZodNumber, "many">]>;
297
+ }, "strict", z.ZodTypeAny, {
298
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
299
+ value: string | number | string[] | number[];
300
+ }, {
301
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
302
+ value: string | number | string[] | number[];
303
+ }>, "many">;
304
+ }, "strict", z.ZodTypeAny, {
305
+ name: string;
306
+ required: boolean;
307
+ isNullable: boolean;
308
+ validator: {
309
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
310
+ value: string | number | string[] | number[];
311
+ }[];
312
+ }, {
313
+ name: string;
314
+ required: boolean;
315
+ validator: {
316
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
317
+ value: string | number | string[] | number[];
318
+ }[];
319
+ isNullable?: boolean | undefined;
320
+ }>, "many">;
321
+ response: z.ZodArray<z.ZodObject<{
322
+ name: z.ZodString;
323
+ selector: z.ZodOptional<z.ZodString>;
324
+ subquery: z.ZodOptional<z.ZodObject<{
325
+ table: z.ZodString;
326
+ joins: z.ZodArray<z.ZodObject<{
327
+ table: z.ZodString;
328
+ localColumnName: z.ZodOptional<z.ZodString>;
329
+ foreignColumnName: z.ZodOptional<z.ZodString>;
330
+ custom: z.ZodOptional<z.ZodString>;
331
+ type: z.ZodEnum<["LEFT", "INNER"]>;
332
+ alias: z.ZodOptional<z.ZodString>;
333
+ }, "strict", z.ZodTypeAny, {
334
+ type: "LEFT" | "INNER";
335
+ table: string;
336
+ custom?: string | undefined;
337
+ localColumnName?: string | undefined;
338
+ foreignColumnName?: string | undefined;
339
+ alias?: string | undefined;
340
+ }, {
341
+ type: "LEFT" | "INNER";
342
+ table: string;
343
+ custom?: string | undefined;
344
+ localColumnName?: string | undefined;
345
+ foreignColumnName?: string | undefined;
346
+ alias?: string | undefined;
347
+ }>, "many">;
348
+ where: z.ZodArray<z.ZodObject<{
349
+ tableName: z.ZodOptional<z.ZodString>;
350
+ columnName: z.ZodOptional<z.ZodString>;
351
+ operator: z.ZodOptional<z.ZodEnum<["=", "<", ">", "<=", ">=", "!=", "LIKE", "IN", "NOT IN", "STARTS WITH", "ENDS WITH"]>>;
352
+ value: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
353
+ custom: z.ZodOptional<z.ZodString>;
354
+ conjunction: z.ZodOptional<z.ZodEnum<["AND", "OR"]>>;
355
+ }, "strict", z.ZodTypeAny, {
356
+ value?: string | number | undefined;
357
+ custom?: string | undefined;
358
+ columnName?: string | undefined;
359
+ tableName?: string | undefined;
360
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
361
+ conjunction?: "AND" | "OR" | undefined;
362
+ }, {
363
+ value?: string | number | undefined;
364
+ custom?: string | undefined;
365
+ columnName?: string | undefined;
366
+ tableName?: string | undefined;
367
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
368
+ conjunction?: "AND" | "OR" | undefined;
369
+ }>, "many">;
370
+ properties: z.ZodArray<z.ZodLazy<z.ZodType<any, z.ZodTypeDef, any>>, "many">;
371
+ groupBy: z.ZodOptional<z.ZodObject<{
372
+ columnName: z.ZodString;
373
+ tableName: z.ZodString;
374
+ }, "strict", z.ZodTypeAny, {
375
+ columnName: string;
376
+ tableName: string;
377
+ }, {
378
+ columnName: string;
379
+ tableName: string;
380
+ }>>;
381
+ orderBy: z.ZodOptional<z.ZodObject<{
382
+ columnName: z.ZodString;
383
+ order: z.ZodEnum<["ASC", "DESC"]>;
384
+ tableName: z.ZodString;
385
+ }, "strict", z.ZodTypeAny, {
386
+ columnName: string;
387
+ order: "ASC" | "DESC";
388
+ tableName: string;
389
+ }, {
390
+ columnName: string;
391
+ order: "ASC" | "DESC";
392
+ tableName: string;
393
+ }>>;
394
+ }, "strip", z.ZodTypeAny, {
395
+ table: string;
396
+ joins: {
397
+ type: "LEFT" | "INNER";
398
+ table: string;
399
+ custom?: string | undefined;
400
+ localColumnName?: string | undefined;
401
+ foreignColumnName?: string | undefined;
402
+ alias?: string | undefined;
403
+ }[];
404
+ where: {
405
+ value?: string | number | undefined;
406
+ custom?: string | undefined;
407
+ columnName?: string | undefined;
408
+ tableName?: string | undefined;
409
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
410
+ conjunction?: "AND" | "OR" | undefined;
411
+ }[];
412
+ properties: any[];
413
+ groupBy?: {
414
+ columnName: string;
415
+ tableName: string;
416
+ } | undefined;
417
+ orderBy?: {
418
+ columnName: string;
419
+ order: "ASC" | "DESC";
420
+ tableName: string;
421
+ } | undefined;
422
+ }, {
423
+ table: string;
424
+ joins: {
425
+ type: "LEFT" | "INNER";
426
+ table: string;
427
+ custom?: string | undefined;
428
+ localColumnName?: string | undefined;
429
+ foreignColumnName?: string | undefined;
430
+ alias?: string | undefined;
431
+ }[];
432
+ where: {
433
+ value?: string | number | undefined;
434
+ custom?: string | undefined;
435
+ columnName?: string | undefined;
436
+ tableName?: string | undefined;
437
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
438
+ conjunction?: "AND" | "OR" | undefined;
439
+ }[];
440
+ properties: any[];
441
+ groupBy?: {
442
+ columnName: string;
443
+ tableName: string;
444
+ } | undefined;
445
+ orderBy?: {
446
+ columnName: string;
447
+ order: "ASC" | "DESC";
448
+ tableName: string;
449
+ } | undefined;
450
+ }>>;
451
+ }, "strict", z.ZodTypeAny, {
452
+ name: string;
453
+ selector?: string | undefined;
454
+ subquery?: {
455
+ table: string;
456
+ joins: {
457
+ type: "LEFT" | "INNER";
458
+ table: string;
459
+ custom?: string | undefined;
460
+ localColumnName?: string | undefined;
461
+ foreignColumnName?: string | undefined;
462
+ alias?: string | undefined;
463
+ }[];
464
+ where: {
465
+ value?: string | number | undefined;
466
+ custom?: string | undefined;
467
+ columnName?: string | undefined;
468
+ tableName?: string | undefined;
469
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
470
+ conjunction?: "AND" | "OR" | undefined;
471
+ }[];
472
+ properties: any[];
473
+ groupBy?: {
474
+ columnName: string;
475
+ tableName: string;
476
+ } | undefined;
477
+ orderBy?: {
478
+ columnName: string;
479
+ order: "ASC" | "DESC";
480
+ tableName: string;
481
+ } | undefined;
482
+ } | undefined;
483
+ }, {
484
+ name: string;
485
+ selector?: string | undefined;
486
+ subquery?: {
487
+ table: string;
488
+ joins: {
489
+ type: "LEFT" | "INNER";
490
+ table: string;
491
+ custom?: string | undefined;
492
+ localColumnName?: string | undefined;
493
+ foreignColumnName?: string | undefined;
494
+ alias?: string | undefined;
495
+ }[];
496
+ where: {
497
+ value?: string | number | undefined;
498
+ custom?: string | undefined;
499
+ columnName?: string | undefined;
500
+ tableName?: string | undefined;
501
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
502
+ conjunction?: "AND" | "OR" | undefined;
503
+ }[];
504
+ properties: any[];
505
+ groupBy?: {
506
+ columnName: string;
507
+ tableName: string;
508
+ } | undefined;
509
+ orderBy?: {
510
+ columnName: string;
511
+ order: "ASC" | "DESC";
512
+ tableName: string;
513
+ } | undefined;
514
+ } | undefined;
515
+ }>, "many">;
516
+ groupBy: z.ZodOptional<z.ZodObject<{
517
+ columnName: z.ZodString;
518
+ tableName: z.ZodString;
519
+ }, "strict", z.ZodTypeAny, {
520
+ columnName: string;
521
+ tableName: string;
522
+ }, {
523
+ columnName: string;
524
+ tableName: string;
525
+ }>>;
526
+ orderBy: z.ZodOptional<z.ZodObject<{
527
+ columnName: z.ZodString;
528
+ order: z.ZodEnum<["ASC", "DESC"]>;
529
+ tableName: z.ZodString;
530
+ }, "strict", z.ZodTypeAny, {
531
+ columnName: string;
532
+ order: "ASC" | "DESC";
533
+ tableName: string;
534
+ }, {
535
+ columnName: string;
536
+ order: "ASC" | "DESC";
537
+ tableName: string;
538
+ }>>;
539
+ }>, "strict", z.ZodTypeAny, {
540
+ path: string;
541
+ type: "ONE" | "ARRAY" | "PAGED";
542
+ name: string;
543
+ table: string;
544
+ joins: {
545
+ type: "LEFT" | "INNER";
546
+ table: string;
547
+ custom?: string | undefined;
548
+ localColumnName?: string | undefined;
549
+ foreignColumnName?: string | undefined;
550
+ alias?: string | undefined;
551
+ }[];
552
+ where: {
553
+ value?: string | number | undefined;
554
+ custom?: string | undefined;
555
+ columnName?: string | undefined;
556
+ tableName?: string | undefined;
557
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
558
+ conjunction?: "AND" | "OR" | undefined;
559
+ }[];
560
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
561
+ description: string;
562
+ roles: string[];
563
+ assignments: {
564
+ value: string;
565
+ name: string;
566
+ }[];
567
+ request: {
568
+ name: string;
569
+ required: boolean;
570
+ isNullable: boolean;
571
+ validator: {
572
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
573
+ value: string | number | string[] | number[];
574
+ }[];
575
+ }[];
576
+ response: {
577
+ name: string;
578
+ selector?: string | undefined;
579
+ subquery?: {
580
+ table: string;
581
+ joins: {
582
+ type: "LEFT" | "INNER";
583
+ table: string;
584
+ custom?: string | undefined;
585
+ localColumnName?: string | undefined;
586
+ foreignColumnName?: string | undefined;
587
+ alias?: string | undefined;
588
+ }[];
589
+ where: {
590
+ value?: string | number | undefined;
591
+ custom?: string | undefined;
592
+ columnName?: string | undefined;
593
+ tableName?: string | undefined;
594
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
595
+ conjunction?: "AND" | "OR" | undefined;
596
+ }[];
597
+ properties: any[];
598
+ groupBy?: {
599
+ columnName: string;
600
+ tableName: string;
601
+ } | undefined;
602
+ orderBy?: {
603
+ columnName: string;
604
+ order: "ASC" | "DESC";
605
+ tableName: string;
606
+ } | undefined;
607
+ } | undefined;
608
+ }[];
609
+ groupBy?: {
610
+ columnName: string;
611
+ tableName: string;
612
+ } | undefined;
613
+ orderBy?: {
614
+ columnName: string;
615
+ order: "ASC" | "DESC";
616
+ tableName: string;
617
+ } | undefined;
618
+ }, {
619
+ path: string;
620
+ type: "ONE" | "ARRAY" | "PAGED";
621
+ name: string;
622
+ table: string;
623
+ joins: {
624
+ type: "LEFT" | "INNER";
625
+ table: string;
626
+ custom?: string | undefined;
627
+ localColumnName?: string | undefined;
628
+ foreignColumnName?: string | undefined;
629
+ alias?: string | undefined;
630
+ }[];
631
+ where: {
632
+ value?: string | number | undefined;
633
+ custom?: string | undefined;
634
+ columnName?: string | undefined;
635
+ tableName?: string | undefined;
636
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
637
+ conjunction?: "AND" | "OR" | undefined;
638
+ }[];
639
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
640
+ description: string;
641
+ roles: string[];
642
+ assignments: {
643
+ value: string;
644
+ name: string;
645
+ }[];
646
+ request: {
647
+ name: string;
648
+ required: boolean;
649
+ validator: {
650
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
651
+ value: string | number | string[] | number[];
652
+ }[];
653
+ isNullable?: boolean | undefined;
654
+ }[];
655
+ response: {
656
+ name: string;
657
+ selector?: string | undefined;
658
+ subquery?: {
659
+ table: string;
660
+ joins: {
661
+ type: "LEFT" | "INNER";
662
+ table: string;
663
+ custom?: string | undefined;
664
+ localColumnName?: string | undefined;
665
+ foreignColumnName?: string | undefined;
666
+ alias?: string | undefined;
667
+ }[];
668
+ where: {
669
+ value?: string | number | undefined;
670
+ custom?: string | undefined;
671
+ columnName?: string | undefined;
672
+ tableName?: string | undefined;
673
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
674
+ conjunction?: "AND" | "OR" | undefined;
675
+ }[];
676
+ properties: any[];
677
+ groupBy?: {
678
+ columnName: string;
679
+ tableName: string;
680
+ } | undefined;
681
+ orderBy?: {
682
+ columnName: string;
683
+ order: "ASC" | "DESC";
684
+ tableName: string;
685
+ } | undefined;
686
+ } | undefined;
687
+ }[];
688
+ groupBy?: {
689
+ columnName: string;
690
+ tableName: string;
691
+ } | undefined;
692
+ orderBy?: {
693
+ columnName: string;
694
+ order: "ASC" | "DESC";
695
+ tableName: string;
696
+ } | undefined;
697
+ }>, z.ZodObject<z.objectUtil.extendShape<{
698
+ method: z.ZodEnum<["GET", "POST", "PUT", "PATCH", "DELETE"]>;
699
+ name: z.ZodString;
700
+ description: z.ZodString;
701
+ path: z.ZodString;
702
+ roles: z.ZodArray<z.ZodString, "many">;
703
+ }, {
704
+ type: z.ZodEnum<["CUSTOM_ONE", "CUSTOM_ARRAY", "CUSTOM_PAGED"]>;
705
+ responseType: z.ZodUnion<[z.ZodString, z.ZodEnum<["string", "number", "boolean"]>]>;
706
+ requestType: z.ZodOptional<z.ZodString>;
707
+ request: z.ZodOptional<z.ZodArray<z.ZodObject<{
708
+ name: z.ZodString;
709
+ required: z.ZodBoolean;
710
+ isNullable: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
711
+ validator: z.ZodArray<z.ZodObject<{
712
+ type: z.ZodEnum<["TYPE_CHECK", "MIN", "MAX", "ONE_OF"]>;
713
+ value: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodNumber, z.ZodArray<z.ZodNumber, "many">]>;
714
+ }, "strict", z.ZodTypeAny, {
715
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
716
+ value: string | number | string[] | number[];
717
+ }, {
718
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
719
+ value: string | number | string[] | number[];
720
+ }>, "many">;
721
+ }, "strict", z.ZodTypeAny, {
722
+ name: string;
723
+ required: boolean;
724
+ isNullable: boolean;
725
+ validator: {
726
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
727
+ value: string | number | string[] | number[];
728
+ }[];
729
+ }, {
730
+ name: string;
731
+ required: boolean;
732
+ validator: {
733
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
734
+ value: string | number | string[] | number[];
735
+ }[];
736
+ isNullable?: boolean | undefined;
737
+ }>, "many">>;
738
+ table: z.ZodUndefined;
739
+ joins: z.ZodUndefined;
740
+ assignments: z.ZodUndefined;
741
+ fileUploadType: z.ZodOptional<z.ZodEnum<["SINGLE", "MULTIPLE"]>>;
742
+ }>, "strict", z.ZodTypeAny, {
743
+ path: string;
744
+ type: "CUSTOM_ONE" | "CUSTOM_ARRAY" | "CUSTOM_PAGED";
745
+ name: string;
746
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
747
+ description: string;
748
+ roles: string[];
749
+ responseType: string;
750
+ table?: undefined;
751
+ joins?: undefined;
752
+ assignments?: undefined;
753
+ request?: {
754
+ name: string;
755
+ required: boolean;
756
+ isNullable: boolean;
757
+ validator: {
758
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
759
+ value: string | number | string[] | number[];
760
+ }[];
761
+ }[] | undefined;
762
+ requestType?: string | undefined;
763
+ fileUploadType?: "SINGLE" | "MULTIPLE" | undefined;
764
+ }, {
765
+ path: string;
766
+ type: "CUSTOM_ONE" | "CUSTOM_ARRAY" | "CUSTOM_PAGED";
767
+ name: string;
768
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
769
+ description: string;
770
+ roles: string[];
771
+ responseType: string;
772
+ table?: undefined;
773
+ joins?: undefined;
774
+ assignments?: undefined;
775
+ request?: {
776
+ name: string;
777
+ required: boolean;
778
+ validator: {
779
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
780
+ value: string | number | string[] | number[];
781
+ }[];
782
+ isNullable?: boolean | undefined;
783
+ }[] | undefined;
784
+ requestType?: string | undefined;
785
+ fileUploadType?: "SINGLE" | "MULTIPLE" | undefined;
786
+ }>]>, "many">;
787
+ }, "strict", z.ZodTypeAny, {
788
+ name: string;
789
+ description: string;
790
+ baseUrl: string;
791
+ routes: ({
792
+ path: string;
793
+ type: "ONE" | "ARRAY" | "PAGED";
794
+ name: string;
795
+ table: string;
796
+ joins: {
797
+ type: "LEFT" | "INNER";
798
+ table: string;
799
+ custom?: string | undefined;
800
+ localColumnName?: string | undefined;
801
+ foreignColumnName?: string | undefined;
802
+ alias?: string | undefined;
803
+ }[];
804
+ where: {
805
+ value?: string | number | undefined;
806
+ custom?: string | undefined;
807
+ columnName?: string | undefined;
808
+ tableName?: string | undefined;
809
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
810
+ conjunction?: "AND" | "OR" | undefined;
811
+ }[];
812
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
813
+ description: string;
814
+ roles: string[];
815
+ assignments: {
816
+ value: string;
817
+ name: string;
818
+ }[];
819
+ request: {
820
+ name: string;
821
+ required: boolean;
822
+ isNullable: boolean;
823
+ validator: {
824
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
825
+ value: string | number | string[] | number[];
826
+ }[];
827
+ }[];
828
+ response: {
829
+ name: string;
830
+ selector?: string | undefined;
831
+ subquery?: {
832
+ table: string;
833
+ joins: {
834
+ type: "LEFT" | "INNER";
835
+ table: string;
836
+ custom?: string | undefined;
837
+ localColumnName?: string | undefined;
838
+ foreignColumnName?: string | undefined;
839
+ alias?: string | undefined;
840
+ }[];
841
+ where: {
842
+ value?: string | number | undefined;
843
+ custom?: string | undefined;
844
+ columnName?: string | undefined;
845
+ tableName?: string | undefined;
846
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
847
+ conjunction?: "AND" | "OR" | undefined;
848
+ }[];
849
+ properties: any[];
850
+ groupBy?: {
851
+ columnName: string;
852
+ tableName: string;
853
+ } | undefined;
854
+ orderBy?: {
855
+ columnName: string;
856
+ order: "ASC" | "DESC";
857
+ tableName: string;
858
+ } | undefined;
859
+ } | undefined;
860
+ }[];
861
+ groupBy?: {
862
+ columnName: string;
863
+ tableName: string;
864
+ } | undefined;
865
+ orderBy?: {
866
+ columnName: string;
867
+ order: "ASC" | "DESC";
868
+ tableName: string;
869
+ } | undefined;
870
+ } | {
871
+ path: string;
872
+ type: "CUSTOM_ONE" | "CUSTOM_ARRAY" | "CUSTOM_PAGED";
873
+ name: string;
874
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
875
+ description: string;
876
+ roles: string[];
877
+ responseType: string;
878
+ table?: undefined;
879
+ joins?: undefined;
880
+ assignments?: undefined;
881
+ request?: {
882
+ name: string;
883
+ required: boolean;
884
+ isNullable: boolean;
885
+ validator: {
886
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
887
+ value: string | number | string[] | number[];
888
+ }[];
889
+ }[] | undefined;
890
+ requestType?: string | undefined;
891
+ fileUploadType?: "SINGLE" | "MULTIPLE" | undefined;
892
+ })[];
893
+ }, {
894
+ name: string;
895
+ description: string;
896
+ baseUrl: string;
897
+ routes: ({
898
+ path: string;
899
+ type: "ONE" | "ARRAY" | "PAGED";
900
+ name: string;
901
+ table: string;
902
+ joins: {
903
+ type: "LEFT" | "INNER";
904
+ table: string;
905
+ custom?: string | undefined;
906
+ localColumnName?: string | undefined;
907
+ foreignColumnName?: string | undefined;
908
+ alias?: string | undefined;
909
+ }[];
910
+ where: {
911
+ value?: string | number | undefined;
912
+ custom?: string | undefined;
913
+ columnName?: string | undefined;
914
+ tableName?: string | undefined;
915
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
916
+ conjunction?: "AND" | "OR" | undefined;
917
+ }[];
918
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
919
+ description: string;
920
+ roles: string[];
921
+ assignments: {
922
+ value: string;
923
+ name: string;
924
+ }[];
925
+ request: {
926
+ name: string;
927
+ required: boolean;
928
+ validator: {
929
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
930
+ value: string | number | string[] | number[];
931
+ }[];
932
+ isNullable?: boolean | undefined;
933
+ }[];
934
+ response: {
935
+ name: string;
936
+ selector?: string | undefined;
937
+ subquery?: {
938
+ table: string;
939
+ joins: {
940
+ type: "LEFT" | "INNER";
941
+ table: string;
942
+ custom?: string | undefined;
943
+ localColumnName?: string | undefined;
944
+ foreignColumnName?: string | undefined;
945
+ alias?: string | undefined;
946
+ }[];
947
+ where: {
948
+ value?: string | number | undefined;
949
+ custom?: string | undefined;
950
+ columnName?: string | undefined;
951
+ tableName?: string | undefined;
952
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
953
+ conjunction?: "AND" | "OR" | undefined;
954
+ }[];
955
+ properties: any[];
956
+ groupBy?: {
957
+ columnName: string;
958
+ tableName: string;
959
+ } | undefined;
960
+ orderBy?: {
961
+ columnName: string;
962
+ order: "ASC" | "DESC";
963
+ tableName: string;
964
+ } | undefined;
965
+ } | undefined;
966
+ }[];
967
+ groupBy?: {
968
+ columnName: string;
969
+ tableName: string;
970
+ } | undefined;
971
+ orderBy?: {
972
+ columnName: string;
973
+ order: "ASC" | "DESC";
974
+ tableName: string;
975
+ } | undefined;
976
+ } | {
977
+ path: string;
978
+ type: "CUSTOM_ONE" | "CUSTOM_ARRAY" | "CUSTOM_PAGED";
979
+ name: string;
980
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
981
+ description: string;
982
+ roles: string[];
983
+ responseType: string;
984
+ table?: undefined;
985
+ joins?: undefined;
986
+ assignments?: undefined;
987
+ request?: {
988
+ name: string;
989
+ required: boolean;
990
+ validator: {
991
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
992
+ value: string | number | string[] | number[];
993
+ }[];
994
+ isNullable?: boolean | undefined;
995
+ }[] | undefined;
996
+ requestType?: string | undefined;
997
+ fileUploadType?: "SINGLE" | "MULTIPLE" | undefined;
998
+ })[];
999
+ }>, "many">;
1000
+ globalParams: z.ZodArray<z.ZodString, "many">;
1001
+ roles: z.ZodArray<z.ZodString, "many">;
1002
+ customTypes: z.ZodString;
1003
+ }, "strict", z.ZodTypeAny, {
1004
+ roles: string[];
1005
+ database: {
1006
+ name: string;
1007
+ roles: string[];
1008
+ columns: {
1009
+ type: "SMALLINT" | "INTEGER" | "BIGINT" | "DECIMAL" | "NUMERIC" | "REAL" | "DOUBLE PRECISION" | "SERIAL" | "BIGSERIAL" | "CHAR" | "VARCHAR" | "TEXT" | "BYTEA" | "DATE" | "TIMESTAMP" | "TIMESTAMPTZ" | "TIME" | "INTERVAL" | "BOOLEAN" | "TINYINT" | "MEDIUMINT" | "FLOAT" | "DOUBLE" | "TINYTEXT" | "TINYBLOB" | "BLOB" | "MEDIUMTEXT" | "MEDIUMBLOB" | "LONGTEXT" | "JSON" | "LONGBLOB" | "ENUM" | "DATETIME";
1010
+ name: string;
1011
+ isNullable: boolean;
1012
+ roles: string[];
1013
+ length?: number | undefined;
1014
+ value?: string | undefined;
1015
+ default?: string | undefined;
1016
+ comment?: string | undefined;
1017
+ isPrimary?: boolean | undefined;
1018
+ isUnique?: boolean | undefined;
1019
+ hasAutoIncrement?: boolean | undefined;
1020
+ }[];
1021
+ indexes: {
1022
+ order: "ASC" | "DESC";
1023
+ name: string;
1024
+ isUnique: boolean;
1025
+ columns: string[];
1026
+ isPrimaryKey: boolean;
1027
+ }[];
1028
+ foreignKeys: {
1029
+ name: string;
1030
+ column: string;
1031
+ refTable: string;
1032
+ refColumn: string;
1033
+ onDelete: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION" | "SET DEFAULT";
1034
+ onUpdate: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION" | "SET DEFAULT";
1035
+ }[];
1036
+ checkConstraints: {
1037
+ name: string;
1038
+ check: string;
1039
+ }[];
1040
+ }[];
1041
+ endpoints: {
1042
+ name: string;
1043
+ description: string;
1044
+ baseUrl: string;
1045
+ routes: ({
1046
+ path: string;
1047
+ type: "ONE" | "ARRAY" | "PAGED";
1048
+ name: string;
1049
+ table: string;
1050
+ joins: {
1051
+ type: "LEFT" | "INNER";
1052
+ table: string;
1053
+ custom?: string | undefined;
1054
+ localColumnName?: string | undefined;
1055
+ foreignColumnName?: string | undefined;
1056
+ alias?: string | undefined;
1057
+ }[];
1058
+ where: {
1059
+ value?: string | number | undefined;
1060
+ custom?: string | undefined;
1061
+ columnName?: string | undefined;
1062
+ tableName?: string | undefined;
1063
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
1064
+ conjunction?: "AND" | "OR" | undefined;
1065
+ }[];
1066
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
1067
+ description: string;
1068
+ roles: string[];
1069
+ assignments: {
1070
+ value: string;
1071
+ name: string;
1072
+ }[];
1073
+ request: {
1074
+ name: string;
1075
+ required: boolean;
1076
+ isNullable: boolean;
1077
+ validator: {
1078
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
1079
+ value: string | number | string[] | number[];
1080
+ }[];
1081
+ }[];
1082
+ response: {
1083
+ name: string;
1084
+ selector?: string | undefined;
1085
+ subquery?: {
1086
+ table: string;
1087
+ joins: {
1088
+ type: "LEFT" | "INNER";
1089
+ table: string;
1090
+ custom?: string | undefined;
1091
+ localColumnName?: string | undefined;
1092
+ foreignColumnName?: string | undefined;
1093
+ alias?: string | undefined;
1094
+ }[];
1095
+ where: {
1096
+ value?: string | number | undefined;
1097
+ custom?: string | undefined;
1098
+ columnName?: string | undefined;
1099
+ tableName?: string | undefined;
1100
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
1101
+ conjunction?: "AND" | "OR" | undefined;
1102
+ }[];
1103
+ properties: any[];
1104
+ groupBy?: {
1105
+ columnName: string;
1106
+ tableName: string;
1107
+ } | undefined;
1108
+ orderBy?: {
1109
+ columnName: string;
1110
+ order: "ASC" | "DESC";
1111
+ tableName: string;
1112
+ } | undefined;
1113
+ } | undefined;
1114
+ }[];
1115
+ groupBy?: {
1116
+ columnName: string;
1117
+ tableName: string;
1118
+ } | undefined;
1119
+ orderBy?: {
1120
+ columnName: string;
1121
+ order: "ASC" | "DESC";
1122
+ tableName: string;
1123
+ } | undefined;
1124
+ } | {
1125
+ path: string;
1126
+ type: "CUSTOM_ONE" | "CUSTOM_ARRAY" | "CUSTOM_PAGED";
1127
+ name: string;
1128
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
1129
+ description: string;
1130
+ roles: string[];
1131
+ responseType: string;
1132
+ table?: undefined;
1133
+ joins?: undefined;
1134
+ assignments?: undefined;
1135
+ request?: {
1136
+ name: string;
1137
+ required: boolean;
1138
+ isNullable: boolean;
1139
+ validator: {
1140
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
1141
+ value: string | number | string[] | number[];
1142
+ }[];
1143
+ }[] | undefined;
1144
+ requestType?: string | undefined;
1145
+ fileUploadType?: "SINGLE" | "MULTIPLE" | undefined;
1146
+ })[];
1147
+ }[];
1148
+ globalParams: string[];
1149
+ customTypes: string;
1150
+ }, {
1151
+ roles: string[];
1152
+ database: {
1153
+ name: string;
1154
+ roles: string[];
1155
+ columns: {
1156
+ type: "SMALLINT" | "INTEGER" | "BIGINT" | "DECIMAL" | "NUMERIC" | "REAL" | "DOUBLE PRECISION" | "SERIAL" | "BIGSERIAL" | "CHAR" | "VARCHAR" | "TEXT" | "BYTEA" | "DATE" | "TIMESTAMP" | "TIMESTAMPTZ" | "TIME" | "INTERVAL" | "BOOLEAN" | "TINYINT" | "MEDIUMINT" | "FLOAT" | "DOUBLE" | "TINYTEXT" | "TINYBLOB" | "BLOB" | "MEDIUMTEXT" | "MEDIUMBLOB" | "LONGTEXT" | "JSON" | "LONGBLOB" | "ENUM" | "DATETIME";
1157
+ name: string;
1158
+ isNullable: boolean;
1159
+ roles: string[];
1160
+ length?: number | undefined;
1161
+ value?: string | undefined;
1162
+ default?: string | undefined;
1163
+ comment?: string | undefined;
1164
+ isPrimary?: boolean | undefined;
1165
+ isUnique?: boolean | undefined;
1166
+ hasAutoIncrement?: boolean | undefined;
1167
+ }[];
1168
+ indexes: {
1169
+ order: "ASC" | "DESC";
1170
+ name: string;
1171
+ isUnique: boolean;
1172
+ columns: string[];
1173
+ isPrimaryKey: boolean;
1174
+ }[];
1175
+ foreignKeys: {
1176
+ name: string;
1177
+ column: string;
1178
+ refTable: string;
1179
+ refColumn: string;
1180
+ onDelete: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION" | "SET DEFAULT";
1181
+ onUpdate: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION" | "SET DEFAULT";
1182
+ }[];
1183
+ checkConstraints: {
1184
+ name: string;
1185
+ check: string;
1186
+ }[];
1187
+ }[];
1188
+ endpoints: {
1189
+ name: string;
1190
+ description: string;
1191
+ baseUrl: string;
1192
+ routes: ({
1193
+ path: string;
1194
+ type: "ONE" | "ARRAY" | "PAGED";
1195
+ name: string;
1196
+ table: string;
1197
+ joins: {
1198
+ type: "LEFT" | "INNER";
1199
+ table: string;
1200
+ custom?: string | undefined;
1201
+ localColumnName?: string | undefined;
1202
+ foreignColumnName?: string | undefined;
1203
+ alias?: string | undefined;
1204
+ }[];
1205
+ where: {
1206
+ value?: string | number | undefined;
1207
+ custom?: string | undefined;
1208
+ columnName?: string | undefined;
1209
+ tableName?: string | undefined;
1210
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
1211
+ conjunction?: "AND" | "OR" | undefined;
1212
+ }[];
1213
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
1214
+ description: string;
1215
+ roles: string[];
1216
+ assignments: {
1217
+ value: string;
1218
+ name: string;
1219
+ }[];
1220
+ request: {
1221
+ name: string;
1222
+ required: boolean;
1223
+ validator: {
1224
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
1225
+ value: string | number | string[] | number[];
1226
+ }[];
1227
+ isNullable?: boolean | undefined;
1228
+ }[];
1229
+ response: {
1230
+ name: string;
1231
+ selector?: string | undefined;
1232
+ subquery?: {
1233
+ table: string;
1234
+ joins: {
1235
+ type: "LEFT" | "INNER";
1236
+ table: string;
1237
+ custom?: string | undefined;
1238
+ localColumnName?: string | undefined;
1239
+ foreignColumnName?: string | undefined;
1240
+ alias?: string | undefined;
1241
+ }[];
1242
+ where: {
1243
+ value?: string | number | undefined;
1244
+ custom?: string | undefined;
1245
+ columnName?: string | undefined;
1246
+ tableName?: string | undefined;
1247
+ operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
1248
+ conjunction?: "AND" | "OR" | undefined;
1249
+ }[];
1250
+ properties: any[];
1251
+ groupBy?: {
1252
+ columnName: string;
1253
+ tableName: string;
1254
+ } | undefined;
1255
+ orderBy?: {
1256
+ columnName: string;
1257
+ order: "ASC" | "DESC";
1258
+ tableName: string;
1259
+ } | undefined;
1260
+ } | undefined;
1261
+ }[];
1262
+ groupBy?: {
1263
+ columnName: string;
1264
+ tableName: string;
1265
+ } | undefined;
1266
+ orderBy?: {
1267
+ columnName: string;
1268
+ order: "ASC" | "DESC";
1269
+ tableName: string;
1270
+ } | undefined;
1271
+ } | {
1272
+ path: string;
1273
+ type: "CUSTOM_ONE" | "CUSTOM_ARRAY" | "CUSTOM_PAGED";
1274
+ name: string;
1275
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
1276
+ description: string;
1277
+ roles: string[];
1278
+ responseType: string;
1279
+ table?: undefined;
1280
+ joins?: undefined;
1281
+ assignments?: undefined;
1282
+ request?: {
1283
+ name: string;
1284
+ required: boolean;
1285
+ validator: {
1286
+ type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
1287
+ value: string | number | string[] | number[];
1288
+ }[];
1289
+ isNullable?: boolean | undefined;
1290
+ }[] | undefined;
1291
+ requestType?: string | undefined;
1292
+ fileUploadType?: "SINGLE" | "MULTIPLE" | undefined;
1293
+ })[];
1294
+ }[];
1295
+ globalParams: string[];
1296
+ customTypes: string;
1297
+ }>;
1298
+ type ResturaSchema = z.infer<typeof resturaZodSchema>;
1299
+
1300
+ interface SchemaChangeValue {
1301
+ name: string;
1302
+ changeType: 'NEW' | 'MODIFIED' | 'DELETED';
1303
+ }
1304
+ interface SchemaPreview {
1305
+ commands: string;
1306
+ endPoints: SchemaChangeValue[];
1307
+ globalParams: SchemaChangeValue[];
1308
+ roles: SchemaChangeValue[];
1309
+ customTypes: boolean;
1310
+ }
1311
+ interface LoginDetails {
1312
+ token: string;
1313
+ refreshToken: string;
1314
+ expiresOn: string;
1315
+ user: {
1316
+ firstName: string;
1317
+ lastName: string;
1318
+ email: string;
1319
+ };
1320
+ }
1321
+ type ValidatorString = 'boolean' | 'string' | 'number' | 'object' | 'any';
1322
+ interface ResponseType {
1323
+ isOptional?: boolean;
1324
+ isArray?: boolean;
1325
+ validator: ValidatorString | ResponseTypeMap | string[];
1326
+ }
1327
+ interface ResponseTypeMap {
1328
+ [property: string]: ResponseType;
1329
+ }
1330
+ type StandardOrderTypes = 'ASC' | 'DESC' | 'RAND' | 'NONE';
1331
+ type ConjunctionTypes = 'AND' | 'OR';
1332
+ type MatchTypes = 'exact' | 'fuzzy' | 'like' | 'greaterThan' | 'greaterThanEqual' | 'lessThan' | 'lessThanEqual';
1333
+ interface RsResponseData<T> {
1334
+ data: T;
1335
+ }
1336
+ interface RsErrorData {
1337
+ err: string;
1338
+ msg: string;
1339
+ stack?: string;
1340
+ }
1341
+ interface RsPagedResponseData<T> extends RsResponseData<T> {
1342
+ total: number;
1343
+ }
1344
+ interface PageQuery {
1345
+ page: number;
1346
+ perPage: number;
1347
+ sortBy: string;
1348
+ sortOrder: StandardOrderTypes;
1349
+ filter?: string;
1350
+ [key: string]: string | number | boolean | object | null | undefined;
1351
+ }
1352
+ interface AuthenticationUserDetails {
1353
+ role: string;
1354
+ userId?: number;
1355
+ [key: string]: string | number | boolean | object | null | undefined;
1356
+ }
1357
+ type ValidAuthenticationCallback = (userDetails: AuthenticationUserDetails) => void;
1358
+ type AuthenticateHandler = (req: RsRequest<unknown>, res: RsResponse<unknown>, onValid: ValidAuthenticationCallback) => Promise<void>;
1359
+
1360
+ interface RsHeaders extends IncomingHttpHeaders {
1361
+ 'x-auth-token'?: string;
1362
+ }
1363
+ type ApiMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
1364
+ type RequesterDetails<T extends object = {}> = {
1365
+ role: string;
1366
+ host: string;
1367
+ ipAddress: string;
1368
+ userId?: number;
1369
+ isSystemUser?: boolean;
1370
+ } & T;
1371
+ interface RsRequest<T = unknown, U extends object = Record<string, never>> extends express.Request {
1372
+ requesterDetails: RequesterDetails<U>;
1373
+ data: T;
1374
+ }
1375
+ type DynamicObject<T = unknown> = {
1376
+ [key: string]: T;
1377
+ };
1378
+ interface RsResponse<T = unknown> extends express.Response {
1379
+ sendData: (data: T, statusCode?: number) => void;
1380
+ sendNoWrap: (data: T, statusCode?: number) => void;
1381
+ sendError: (err: ErrorCode, msg: string, htmlStatusCode?: HtmlStatusCodes, stack?: string) => void;
1382
+ sendPaginated: (pagedData: RsPagedResponseData<T>, statusCode?: number) => void;
1383
+ _contentLength?: number;
1384
+ }
1385
+ type RsRouteHandler<T = unknown, U = unknown> = (req: RsRequest<T>, res: RsResponse<U>, next?: express.NextFunction) => Promise<void>;
1386
+ interface AsyncExpressApplication {
1387
+ get: (url: string, handler: RsRouteHandler, nextFunction?: RsRouteHandler) => Promise<void> | void;
1388
+ post: (url: string, handler: RsRouteHandler, nextFunction?: RsRouteHandler) => Promise<void> | void;
1389
+ put: (url: string, handler: RsRouteHandler, nextFunction?: RsRouteHandler) => Promise<void> | void;
1390
+ patch: (url: string, handler: RsRouteHandler, nextFunction?: RsRouteHandler) => Promise<void> | void;
1391
+ delete: (url: string, handler: RsRouteHandler, nextFunction?: RsRouteHandler) => Promise<void> | void;
1392
+ }
1393
+
1394
+ declare class PsqlPool {
1395
+ poolConfig: PoolConfig;
1396
+ pool: Pool;
1397
+ constructor(poolConfig: PoolConfig);
1398
+ queryOne(query: string, options: any[], requesterDetails: RequesterDetails): Promise<any>;
1399
+ runQuery(query: string, options: any[], requesterDetails: RequesterDetails): Promise<any[]>;
1400
+ private logSqlStatement;
1401
+ }
1402
+
1403
+ declare class ResturaEngine {
1404
+ resturaConfig: ResturaConfigSchema;
1405
+ private resturaRouter;
1406
+ private publicEndpoints;
1407
+ private expressApp;
1408
+ private schema;
1409
+ private responseValidator;
1410
+ private authenticationHandler;
1411
+ private customTypeValidation;
1412
+ private psqlConnectionPool;
1413
+ private psqlEngine;
1414
+ /**
1415
+ * Initializes the Restura engine with the provided Express application.
1416
+ *
1417
+ * @param app - The Express application instance to initialize with Restura.
1418
+ * @returns A promise that resolves when the initialization is complete.
1419
+ */
1420
+ init(app: express.Application, authenticationHandler: AuthenticateHandler, psqlConnectionPool: PsqlPool): Promise<void>;
1421
+ /**
1422
+ * Determines if a given endpoint is public based on the HTTP method and full URL. This
1423
+ * is determined on whether the endpoint in the schema has no roles assigned to it.
1424
+ *
1425
+ * @param method - The HTTP method (e.g., 'GET', 'POST', 'PUT', 'PATCH', 'DELETE').
1426
+ * @param fullUrl - The full URL of the endpoint.
1427
+ * @returns A boolean indicating whether the endpoint is public.
1428
+ */
1429
+ isEndpointPublic(method: string, fullUrl: string): boolean;
1430
+ /**
1431
+ * Checks if an endpoint exists for a given HTTP method and full URL.
1432
+ *
1433
+ * @param method - The HTTP method to check (e.g., 'GET', 'POST', 'PUT', 'PATCH', 'DELETE').
1434
+ * @param fullUrl - The full URL of the endpoint to check.
1435
+ * @returns `true` if the endpoint exists, otherwise `false`.
1436
+ */
1437
+ doesEndpointExist(method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', fullUrl: string): boolean;
1438
+ /**
1439
+ * Generates an API from the provided schema and writes it to the specified output file.
1440
+ *
1441
+ * @param outputFile - The path to the file where the generated API will be written.
1442
+ * @param providedSchema - The schema from which the API will be generated.
1443
+ * @returns A promise that resolves when the API has been successfully generated and written to the output file.
1444
+ */
1445
+ generateApiFromSchema(outputFile: string, providedSchema: ResturaSchema): Promise<void>;
1446
+ /**
1447
+ * Generates a model from the provided schema and writes it to the specified output file.
1448
+ *
1449
+ * @param outputFile - The path to the file where the generated model will be written.
1450
+ * @param providedSchema - The schema from which the model will be generated.
1451
+ * @returns A promise that resolves when the model has been successfully written to the output file.
1452
+ */
1453
+ generateModelFromSchema(outputFile: string, providedSchema: ResturaSchema): Promise<void>;
1454
+ /**
1455
+ * Retrieves the latest file system schema for Restura.
1456
+ *
1457
+ * @returns {Promise<ResturaSchema>} A promise that resolves to the latest Restura schema.
1458
+ * @throws {Error} If the schema file is missing or the schema is not valid.
1459
+ */
1460
+ getLatestFileSystemSchema(): Promise<ResturaSchema>;
1461
+ /**
1462
+ * Asynchronously generates and retrieves hashes for the provided schema and related generated files.
1463
+ *
1464
+ * @param providedSchema - The schema for which hashes need to be generated.
1465
+ * @returns A promise that resolves to an object containing:
1466
+ * - `schemaHash`: The hash of the provided schema.
1467
+ * - `apiCreatedSchemaHash`: The hash extracted from the generated `api.d.ts` file.
1468
+ * - `modelCreatedSchemaHash`: The hash extracted from the generated `models.d.ts` file.
1469
+ */
1470
+ getHashes(providedSchema: ResturaSchema): Promise<{
1471
+ schemaHash: string;
1472
+ apiCreatedSchemaHash: string;
1473
+ modelCreatedSchemaHash: string;
1474
+ }>;
1475
+ private reloadEndpoints;
1476
+ private validateGeneratedTypesFolder;
1477
+ private resturaAuthentication;
1478
+ private previewCreateSchema;
1479
+ private updateSchema;
1480
+ private updateTypes;
1481
+ private getSchema;
1482
+ private getSchemaAndTypes;
1483
+ private executeRouteLogic;
1484
+ private isCustomRoute;
1485
+ private runCustomRouteLogic;
1486
+ private generateHashForSchema;
1487
+ private storeFileSystemSchema;
1488
+ private resetPublicEndpoints;
1489
+ private validateAuthorization;
1490
+ private getRouteData;
1491
+ }
1492
+ declare const restura: ResturaEngine;
1493
+
1494
+ declare function escapeColumnName(columnName: string | undefined): string;
1495
+ declare function questionMarksToOrderedParams(query: string): string;
1496
+ declare function insertObjectQuery(table: string, obj: DynamicObject): string;
1497
+ declare function updateObjectQuery(table: string, obj: DynamicObject, whereStatement: string): string;
1498
+ declare function isValueNumber(value: unknown): value is number;
1499
+ declare function SQL(strings: any, ...values: any): any;
1500
+
1501
+ export { type ApiMethod, type AsyncExpressApplication, type AuthenticateHandler, type AuthenticationUserDetails, type ConjunctionTypes, type DynamicObject, type ErrorCode, HtmlStatusCodes, type LoginDetails, type MatchTypes, type PageQuery, PsqlPool, type RequesterDetails, type ResponseType, type ResponseTypeMap, RsError, type RsErrorData, type RsErrorInternalData, type RsHeaders, type RsPagedResponseData, type RsRequest, type RsResponse, type RsResponseData, type RsRouteHandler, SQL, type SchemaChangeValue, type SchemaPreview, type StandardOrderTypes, type ValidAuthenticationCallback, type ValidatorString, escapeColumnName, insertObjectQuery, isValueNumber, logger, questionMarksToOrderedParams, restura, updateObjectQuery };