@restura/core 0.1.0-alpha.7 → 0.1.0-alpha.9
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 +187 -33
- package/dist/index.d.ts +187 -33
- package/dist/index.js +1138 -271
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1128 -270
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -5
- package/dist/acorn-SW5GI5G7.mjs +0 -3016
- package/dist/acorn-SW5GI5G7.mjs.map +0 -1
- package/dist/angular-FYEH6QOL.mjs +0 -1547
- package/dist/angular-FYEH6QOL.mjs.map +0 -1
- package/dist/babel-V6GZHMYX.mjs +0 -6911
- package/dist/babel-V6GZHMYX.mjs.map +0 -1
- package/dist/chunk-TL4KRYOF.mjs +0 -58
- package/dist/chunk-TL4KRYOF.mjs.map +0 -1
- package/dist/estree-67ZCSSSI.mjs +0 -4396
- package/dist/estree-67ZCSSSI.mjs.map +0 -1
- package/dist/flow-SJW7PRXX.mjs +0 -26365
- package/dist/flow-SJW7PRXX.mjs.map +0 -1
- package/dist/glimmer-PF2X22V2.mjs +0 -2995
- package/dist/glimmer-PF2X22V2.mjs.map +0 -1
- package/dist/graphql-NOJ5HX7K.mjs +0 -1253
- package/dist/graphql-NOJ5HX7K.mjs.map +0 -1
- package/dist/html-ROPIWVPQ.mjs +0 -2780
- package/dist/html-ROPIWVPQ.mjs.map +0 -1
- package/dist/index.cjs +0 -34
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -3
- package/dist/markdown-PFYT4MSP.mjs +0 -3423
- package/dist/markdown-PFYT4MSP.mjs.map +0 -1
- package/dist/meriyah-5NLZXLMA.mjs +0 -2356
- package/dist/meriyah-5NLZXLMA.mjs.map +0 -1
- package/dist/postcss-ITO6IEN5.mjs +0 -5027
- package/dist/postcss-ITO6IEN5.mjs.map +0 -1
- package/dist/typescript-6IE7K56Q.mjs +0 -13392
- package/dist/typescript-6IE7K56Q.mjs.map +0 -1
- package/dist/yaml-DB2OVPLH.mjs +0 -4230
- package/dist/yaml-DB2OVPLH.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,23 +1,58 @@
|
|
|
1
1
|
import winston from 'winston';
|
|
2
2
|
import * as express from 'express';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
+
import { PoolConfig, Pool } from 'pg';
|
|
5
|
+
import { IncomingHttpHeaders } from 'http2';
|
|
4
6
|
|
|
5
7
|
declare const logger: winston.Logger;
|
|
6
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
|
+
|
|
7
39
|
declare const resturaConfigSchema: z.ZodObject<{
|
|
8
40
|
authToken: z.ZodString;
|
|
9
41
|
sendErrorStackTrace: z.ZodDefault<z.ZodBoolean>;
|
|
10
42
|
schemaFilePath: z.ZodDefault<z.ZodString>;
|
|
43
|
+
customApiFolderPath: z.ZodDefault<z.ZodString>;
|
|
11
44
|
generatedTypesPath: z.ZodDefault<z.ZodString>;
|
|
12
45
|
}, "strip", z.ZodTypeAny, {
|
|
13
46
|
authToken: string;
|
|
14
47
|
sendErrorStackTrace: boolean;
|
|
15
48
|
schemaFilePath: string;
|
|
49
|
+
customApiFolderPath: string;
|
|
16
50
|
generatedTypesPath: string;
|
|
17
51
|
}, {
|
|
18
52
|
authToken: string;
|
|
19
53
|
sendErrorStackTrace?: boolean | undefined;
|
|
20
54
|
schemaFilePath?: string | undefined;
|
|
55
|
+
customApiFolderPath?: string | undefined;
|
|
21
56
|
generatedTypesPath?: string | undefined;
|
|
22
57
|
}>;
|
|
23
58
|
type ResturaConfigSchema = z.infer<typeof resturaConfigSchema>;
|
|
@@ -234,18 +269,18 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
234
269
|
tableName: z.ZodOptional<z.ZodString>;
|
|
235
270
|
columnName: z.ZodOptional<z.ZodString>;
|
|
236
271
|
operator: z.ZodOptional<z.ZodEnum<["=", "<", ">", "<=", ">=", "!=", "LIKE", "IN", "NOT IN", "STARTS WITH", "ENDS WITH"]>>;
|
|
237
|
-
value: z.ZodOptional<z.ZodString
|
|
272
|
+
value: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
238
273
|
custom: z.ZodOptional<z.ZodString>;
|
|
239
274
|
conjunction: z.ZodOptional<z.ZodEnum<["AND", "OR"]>>;
|
|
240
275
|
}, "strict", z.ZodTypeAny, {
|
|
241
|
-
value?: string | undefined;
|
|
276
|
+
value?: string | number | undefined;
|
|
242
277
|
custom?: string | undefined;
|
|
243
278
|
columnName?: string | undefined;
|
|
244
279
|
tableName?: string | undefined;
|
|
245
280
|
operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
|
|
246
281
|
conjunction?: "AND" | "OR" | undefined;
|
|
247
282
|
}, {
|
|
248
|
-
value?: string | undefined;
|
|
283
|
+
value?: string | number | undefined;
|
|
249
284
|
custom?: string | undefined;
|
|
250
285
|
columnName?: string | undefined;
|
|
251
286
|
tableName?: string | undefined;
|
|
@@ -311,18 +346,18 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
311
346
|
tableName: z.ZodOptional<z.ZodString>;
|
|
312
347
|
columnName: z.ZodOptional<z.ZodString>;
|
|
313
348
|
operator: z.ZodOptional<z.ZodEnum<["=", "<", ">", "<=", ">=", "!=", "LIKE", "IN", "NOT IN", "STARTS WITH", "ENDS WITH"]>>;
|
|
314
|
-
value: z.ZodOptional<z.ZodString
|
|
349
|
+
value: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
315
350
|
custom: z.ZodOptional<z.ZodString>;
|
|
316
351
|
conjunction: z.ZodOptional<z.ZodEnum<["AND", "OR"]>>;
|
|
317
352
|
}, "strict", z.ZodTypeAny, {
|
|
318
|
-
value?: string | undefined;
|
|
353
|
+
value?: string | number | undefined;
|
|
319
354
|
custom?: string | undefined;
|
|
320
355
|
columnName?: string | undefined;
|
|
321
356
|
tableName?: string | undefined;
|
|
322
357
|
operator?: "=" | "<" | ">" | "<=" | ">=" | "!=" | "LIKE" | "IN" | "NOT IN" | "STARTS WITH" | "ENDS WITH" | undefined;
|
|
323
358
|
conjunction?: "AND" | "OR" | undefined;
|
|
324
359
|
}, {
|
|
325
|
-
value?: string | undefined;
|
|
360
|
+
value?: string | number | undefined;
|
|
326
361
|
custom?: string | undefined;
|
|
327
362
|
columnName?: string | undefined;
|
|
328
363
|
tableName?: string | undefined;
|
|
@@ -364,7 +399,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
364
399
|
alias?: string | undefined;
|
|
365
400
|
}[];
|
|
366
401
|
where: {
|
|
367
|
-
value?: string | undefined;
|
|
402
|
+
value?: string | number | undefined;
|
|
368
403
|
custom?: string | undefined;
|
|
369
404
|
columnName?: string | undefined;
|
|
370
405
|
tableName?: string | undefined;
|
|
@@ -392,7 +427,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
392
427
|
alias?: string | undefined;
|
|
393
428
|
}[];
|
|
394
429
|
where: {
|
|
395
|
-
value?: string | undefined;
|
|
430
|
+
value?: string | number | undefined;
|
|
396
431
|
custom?: string | undefined;
|
|
397
432
|
columnName?: string | undefined;
|
|
398
433
|
tableName?: string | undefined;
|
|
@@ -424,7 +459,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
424
459
|
alias?: string | undefined;
|
|
425
460
|
}[];
|
|
426
461
|
where: {
|
|
427
|
-
value?: string | undefined;
|
|
462
|
+
value?: string | number | undefined;
|
|
428
463
|
custom?: string | undefined;
|
|
429
464
|
columnName?: string | undefined;
|
|
430
465
|
tableName?: string | undefined;
|
|
@@ -456,7 +491,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
456
491
|
alias?: string | undefined;
|
|
457
492
|
}[];
|
|
458
493
|
where: {
|
|
459
|
-
value?: string | undefined;
|
|
494
|
+
value?: string | number | undefined;
|
|
460
495
|
custom?: string | undefined;
|
|
461
496
|
columnName?: string | undefined;
|
|
462
497
|
tableName?: string | undefined;
|
|
@@ -512,7 +547,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
512
547
|
alias?: string | undefined;
|
|
513
548
|
}[];
|
|
514
549
|
where: {
|
|
515
|
-
value?: string | undefined;
|
|
550
|
+
value?: string | number | undefined;
|
|
516
551
|
custom?: string | undefined;
|
|
517
552
|
columnName?: string | undefined;
|
|
518
553
|
tableName?: string | undefined;
|
|
@@ -548,7 +583,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
548
583
|
alias?: string | undefined;
|
|
549
584
|
}[];
|
|
550
585
|
where: {
|
|
551
|
-
value?: string | undefined;
|
|
586
|
+
value?: string | number | undefined;
|
|
552
587
|
custom?: string | undefined;
|
|
553
588
|
columnName?: string | undefined;
|
|
554
589
|
tableName?: string | undefined;
|
|
@@ -590,7 +625,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
590
625
|
alias?: string | undefined;
|
|
591
626
|
}[];
|
|
592
627
|
where: {
|
|
593
|
-
value?: string | undefined;
|
|
628
|
+
value?: string | number | undefined;
|
|
594
629
|
custom?: string | undefined;
|
|
595
630
|
columnName?: string | undefined;
|
|
596
631
|
tableName?: string | undefined;
|
|
@@ -626,7 +661,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
626
661
|
alias?: string | undefined;
|
|
627
662
|
}[];
|
|
628
663
|
where: {
|
|
629
|
-
value?: string | undefined;
|
|
664
|
+
value?: string | number | undefined;
|
|
630
665
|
custom?: string | undefined;
|
|
631
666
|
columnName?: string | undefined;
|
|
632
667
|
tableName?: string | undefined;
|
|
@@ -692,6 +727,9 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
692
727
|
name: string;
|
|
693
728
|
required: boolean;
|
|
694
729
|
}>, "many">>;
|
|
730
|
+
table: z.ZodUndefined;
|
|
731
|
+
joins: z.ZodUndefined;
|
|
732
|
+
assignments: z.ZodUndefined;
|
|
695
733
|
fileUploadType: z.ZodOptional<z.ZodEnum<["SINGLE", "MULTIPLE"]>>;
|
|
696
734
|
}>, "strict", z.ZodTypeAny, {
|
|
697
735
|
path: string;
|
|
@@ -701,6 +739,9 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
701
739
|
description: string;
|
|
702
740
|
roles: string[];
|
|
703
741
|
responseType: string;
|
|
742
|
+
table?: undefined;
|
|
743
|
+
joins?: undefined;
|
|
744
|
+
assignments?: undefined;
|
|
704
745
|
request?: {
|
|
705
746
|
validator: {
|
|
706
747
|
type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
|
|
@@ -719,6 +760,9 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
719
760
|
description: string;
|
|
720
761
|
roles: string[];
|
|
721
762
|
responseType: string;
|
|
763
|
+
table?: undefined;
|
|
764
|
+
joins?: undefined;
|
|
765
|
+
assignments?: undefined;
|
|
722
766
|
request?: {
|
|
723
767
|
validator: {
|
|
724
768
|
type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
|
|
@@ -748,7 +792,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
748
792
|
alias?: string | undefined;
|
|
749
793
|
}[];
|
|
750
794
|
where: {
|
|
751
|
-
value?: string | undefined;
|
|
795
|
+
value?: string | number | undefined;
|
|
752
796
|
custom?: string | undefined;
|
|
753
797
|
columnName?: string | undefined;
|
|
754
798
|
tableName?: string | undefined;
|
|
@@ -784,7 +828,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
784
828
|
alias?: string | undefined;
|
|
785
829
|
}[];
|
|
786
830
|
where: {
|
|
787
|
-
value?: string | undefined;
|
|
831
|
+
value?: string | number | undefined;
|
|
788
832
|
custom?: string | undefined;
|
|
789
833
|
columnName?: string | undefined;
|
|
790
834
|
tableName?: string | undefined;
|
|
@@ -820,6 +864,9 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
820
864
|
description: string;
|
|
821
865
|
roles: string[];
|
|
822
866
|
responseType: string;
|
|
867
|
+
table?: undefined;
|
|
868
|
+
joins?: undefined;
|
|
869
|
+
assignments?: undefined;
|
|
823
870
|
request?: {
|
|
824
871
|
validator: {
|
|
825
872
|
type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
|
|
@@ -849,7 +896,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
849
896
|
alias?: string | undefined;
|
|
850
897
|
}[];
|
|
851
898
|
where: {
|
|
852
|
-
value?: string | undefined;
|
|
899
|
+
value?: string | number | undefined;
|
|
853
900
|
custom?: string | undefined;
|
|
854
901
|
columnName?: string | undefined;
|
|
855
902
|
tableName?: string | undefined;
|
|
@@ -885,7 +932,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
885
932
|
alias?: string | undefined;
|
|
886
933
|
}[];
|
|
887
934
|
where: {
|
|
888
|
-
value?: string | undefined;
|
|
935
|
+
value?: string | number | undefined;
|
|
889
936
|
custom?: string | undefined;
|
|
890
937
|
columnName?: string | undefined;
|
|
891
938
|
tableName?: string | undefined;
|
|
@@ -921,6 +968,9 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
921
968
|
description: string;
|
|
922
969
|
roles: string[];
|
|
923
970
|
responseType: string;
|
|
971
|
+
table?: undefined;
|
|
972
|
+
joins?: undefined;
|
|
973
|
+
assignments?: undefined;
|
|
924
974
|
request?: {
|
|
925
975
|
validator: {
|
|
926
976
|
type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
|
|
@@ -992,7 +1042,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
992
1042
|
alias?: string | undefined;
|
|
993
1043
|
}[];
|
|
994
1044
|
where: {
|
|
995
|
-
value?: string | undefined;
|
|
1045
|
+
value?: string | number | undefined;
|
|
996
1046
|
custom?: string | undefined;
|
|
997
1047
|
columnName?: string | undefined;
|
|
998
1048
|
tableName?: string | undefined;
|
|
@@ -1028,7 +1078,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
1028
1078
|
alias?: string | undefined;
|
|
1029
1079
|
}[];
|
|
1030
1080
|
where: {
|
|
1031
|
-
value?: string | undefined;
|
|
1081
|
+
value?: string | number | undefined;
|
|
1032
1082
|
custom?: string | undefined;
|
|
1033
1083
|
columnName?: string | undefined;
|
|
1034
1084
|
tableName?: string | undefined;
|
|
@@ -1064,6 +1114,9 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
1064
1114
|
description: string;
|
|
1065
1115
|
roles: string[];
|
|
1066
1116
|
responseType: string;
|
|
1117
|
+
table?: undefined;
|
|
1118
|
+
joins?: undefined;
|
|
1119
|
+
assignments?: undefined;
|
|
1067
1120
|
request?: {
|
|
1068
1121
|
validator: {
|
|
1069
1122
|
type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
|
|
@@ -1134,7 +1187,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
1134
1187
|
alias?: string | undefined;
|
|
1135
1188
|
}[];
|
|
1136
1189
|
where: {
|
|
1137
|
-
value?: string | undefined;
|
|
1190
|
+
value?: string | number | undefined;
|
|
1138
1191
|
custom?: string | undefined;
|
|
1139
1192
|
columnName?: string | undefined;
|
|
1140
1193
|
tableName?: string | undefined;
|
|
@@ -1170,7 +1223,7 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
1170
1223
|
alias?: string | undefined;
|
|
1171
1224
|
}[];
|
|
1172
1225
|
where: {
|
|
1173
|
-
value?: string | undefined;
|
|
1226
|
+
value?: string | number | undefined;
|
|
1174
1227
|
custom?: string | undefined;
|
|
1175
1228
|
columnName?: string | undefined;
|
|
1176
1229
|
tableName?: string | undefined;
|
|
@@ -1206,6 +1259,9 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
1206
1259
|
description: string;
|
|
1207
1260
|
roles: string[];
|
|
1208
1261
|
responseType: string;
|
|
1262
|
+
table?: undefined;
|
|
1263
|
+
joins?: undefined;
|
|
1264
|
+
assignments?: undefined;
|
|
1209
1265
|
request?: {
|
|
1210
1266
|
validator: {
|
|
1211
1267
|
type: "TYPE_CHECK" | "MIN" | "MAX" | "ONE_OF";
|
|
@@ -1223,21 +1279,108 @@ declare const resturaZodSchema: z.ZodObject<{
|
|
|
1223
1279
|
}>;
|
|
1224
1280
|
type ResturaSchema = z.infer<typeof resturaZodSchema>;
|
|
1225
1281
|
|
|
1226
|
-
interface
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
ipAddress: string;
|
|
1282
|
+
interface SchemaChangeValue {
|
|
1283
|
+
name: string;
|
|
1284
|
+
changeType: 'NEW' | 'MODIFIED' | 'DELETED';
|
|
1230
1285
|
}
|
|
1231
|
-
interface
|
|
1232
|
-
|
|
1286
|
+
interface SchemaPreview {
|
|
1287
|
+
commands: string;
|
|
1288
|
+
endPoints: SchemaChangeValue[];
|
|
1289
|
+
globalParams: SchemaChangeValue[];
|
|
1290
|
+
roles: SchemaChangeValue[];
|
|
1291
|
+
customTypes: boolean;
|
|
1292
|
+
}
|
|
1293
|
+
interface LoginDetails {
|
|
1294
|
+
token: string;
|
|
1295
|
+
refreshToken: string;
|
|
1296
|
+
expiresOn: string;
|
|
1297
|
+
user: {
|
|
1298
|
+
firstName: string;
|
|
1299
|
+
lastName: string;
|
|
1300
|
+
email: string;
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
type ValidatorString = 'boolean' | 'string' | 'number' | 'object' | 'any';
|
|
1304
|
+
interface ResponseType {
|
|
1305
|
+
isOptional?: boolean;
|
|
1306
|
+
isArray?: boolean;
|
|
1307
|
+
validator: ValidatorString | ResponseTypeMap | string[];
|
|
1308
|
+
}
|
|
1309
|
+
interface ResponseTypeMap {
|
|
1310
|
+
[property: string]: ResponseType;
|
|
1311
|
+
}
|
|
1312
|
+
type StandardOrderTypes = 'ASC' | 'DESC' | 'RAND' | 'NONE';
|
|
1313
|
+
type ConjunctionTypes = 'AND' | 'OR';
|
|
1314
|
+
type MatchTypes = 'exact' | 'fuzzy' | 'like' | 'greaterThan' | 'greaterThanEqual' | 'lessThan' | 'lessThanEqual';
|
|
1315
|
+
interface RsResponseData<T> {
|
|
1233
1316
|
data: T;
|
|
1234
1317
|
}
|
|
1318
|
+
interface RsErrorData {
|
|
1319
|
+
err: string;
|
|
1320
|
+
msg: string;
|
|
1321
|
+
stack?: string;
|
|
1322
|
+
}
|
|
1323
|
+
interface RsPagedResponseData<T> extends RsResponseData<T> {
|
|
1324
|
+
total: number;
|
|
1325
|
+
}
|
|
1326
|
+
interface PageQuery {
|
|
1327
|
+
page: number;
|
|
1328
|
+
perPage: number;
|
|
1329
|
+
sortBy: string;
|
|
1330
|
+
sortOrder: StandardOrderTypes;
|
|
1331
|
+
filter?: string;
|
|
1332
|
+
[key: string]: string | number | boolean | object | null | undefined;
|
|
1333
|
+
}
|
|
1334
|
+
interface AuthenticationUserDetails {
|
|
1335
|
+
role: string;
|
|
1336
|
+
userId?: number;
|
|
1337
|
+
[key: string]: string | number | boolean | object | null | undefined;
|
|
1338
|
+
}
|
|
1339
|
+
type ValidAuthenticationCallback = (userDetails: AuthenticationUserDetails) => void;
|
|
1340
|
+
type AuthenticateHandler = (req: RsRequest<unknown>, res: RsResponse<unknown>, onValid: ValidAuthenticationCallback) => Promise<void>;
|
|
1235
1341
|
|
|
1236
|
-
interface
|
|
1342
|
+
interface RsHeaders extends IncomingHttpHeaders {
|
|
1343
|
+
'x-auth-token'?: string;
|
|
1344
|
+
}
|
|
1345
|
+
type ApiMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
|
|
1346
|
+
type RequesterDetails<T extends object = {}> = {
|
|
1237
1347
|
role: string;
|
|
1238
|
-
|
|
1348
|
+
host: string;
|
|
1349
|
+
ipAddress: string;
|
|
1350
|
+
userId?: number;
|
|
1351
|
+
isSystemUser?: boolean;
|
|
1352
|
+
} & T;
|
|
1353
|
+
interface RsRequest<T = unknown, U extends object = Record<string, never>> extends express.Request {
|
|
1354
|
+
requesterDetails: RequesterDetails<U>;
|
|
1355
|
+
data: T;
|
|
1356
|
+
}
|
|
1357
|
+
type DynamicObject<T = unknown> = {
|
|
1358
|
+
[key: string]: T;
|
|
1359
|
+
};
|
|
1360
|
+
interface RsResponse<T = unknown> extends express.Response {
|
|
1361
|
+
sendData: (data: T, statusCode?: number) => void;
|
|
1362
|
+
sendNoWrap: (data: T, statusCode?: number) => void;
|
|
1363
|
+
sendError: (err: ErrorCode, msg: string, htmlStatusCode?: HtmlStatusCodes, stack?: string) => void;
|
|
1364
|
+
sendPaginated: (pagedData: RsPagedResponseData<T>, statusCode?: number) => void;
|
|
1365
|
+
_contentLength?: number;
|
|
1366
|
+
}
|
|
1367
|
+
type RsRouteHandler<T = unknown, U = unknown> = (req: RsRequest<T>, res: RsResponse<U>, next?: express.NextFunction) => Promise<void>;
|
|
1368
|
+
interface AsyncExpressApplication {
|
|
1369
|
+
get: (url: string, handler: RsRouteHandler, nextFunction?: RsRouteHandler) => Promise<void> | void;
|
|
1370
|
+
post: (url: string, handler: RsRouteHandler, nextFunction?: RsRouteHandler) => Promise<void> | void;
|
|
1371
|
+
put: (url: string, handler: RsRouteHandler, nextFunction?: RsRouteHandler) => Promise<void> | void;
|
|
1372
|
+
patch: (url: string, handler: RsRouteHandler, nextFunction?: RsRouteHandler) => Promise<void> | void;
|
|
1373
|
+
delete: (url: string, handler: RsRouteHandler, nextFunction?: RsRouteHandler) => Promise<void> | void;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
declare class PsqlPool {
|
|
1377
|
+
poolConfig: PoolConfig;
|
|
1378
|
+
pool: Pool;
|
|
1379
|
+
constructor(poolConfig: PoolConfig);
|
|
1380
|
+
queryOne(query: string, options: any[], requesterDetails: RequesterDetails): Promise<any>;
|
|
1381
|
+
runQuery(query: string, options: any[], requesterDetails: RequesterDetails): Promise<any[]>;
|
|
1382
|
+
private logSqlStatement;
|
|
1239
1383
|
}
|
|
1240
|
-
type AuthenticateHandler = (req: RsRequest<unknown>, onValid: (userDetails: RoleWithOptionalUserDetails) => void, onReject: (errorMessage: string) => void) => Promise<void>;
|
|
1241
1384
|
|
|
1242
1385
|
declare class ResturaEngine {
|
|
1243
1386
|
resturaConfig: ResturaConfigSchema;
|
|
@@ -1247,13 +1390,16 @@ declare class ResturaEngine {
|
|
|
1247
1390
|
private schema;
|
|
1248
1391
|
private responseValidator;
|
|
1249
1392
|
private authenticationHandler;
|
|
1393
|
+
private customTypeValidation;
|
|
1394
|
+
private psqlConnectionPool;
|
|
1395
|
+
private psqlEngine;
|
|
1250
1396
|
/**
|
|
1251
1397
|
* Initializes the Restura engine with the provided Express application.
|
|
1252
1398
|
*
|
|
1253
1399
|
* @param app - The Express application instance to initialize with Restura.
|
|
1254
1400
|
* @returns A promise that resolves when the initialization is complete.
|
|
1255
1401
|
*/
|
|
1256
|
-
init(app: express.Application, authenticationHandler: AuthenticateHandler): Promise<void>;
|
|
1402
|
+
init(app: express.Application, authenticationHandler: AuthenticateHandler, psqlConnectionPool: PsqlPool): Promise<void>;
|
|
1257
1403
|
/**
|
|
1258
1404
|
* Determines if a given endpoint is public based on the HTTP method and full URL. This
|
|
1259
1405
|
* is determined on whether the endpoint in the schema has no roles assigned to it.
|
|
@@ -1318,6 +1464,7 @@ declare class ResturaEngine {
|
|
|
1318
1464
|
private getSchemaAndTypes;
|
|
1319
1465
|
private executeRouteLogic;
|
|
1320
1466
|
private isCustomRoute;
|
|
1467
|
+
private runCustomRouteLogic;
|
|
1321
1468
|
private generateHashForSchema;
|
|
1322
1469
|
private storeFileSystemSchema;
|
|
1323
1470
|
private resetPublicEndpoints;
|
|
@@ -1326,4 +1473,11 @@ declare class ResturaEngine {
|
|
|
1326
1473
|
}
|
|
1327
1474
|
declare const restura: ResturaEngine;
|
|
1328
1475
|
|
|
1329
|
-
|
|
1476
|
+
declare function escapeColumnName(columnName: string | undefined): string;
|
|
1477
|
+
declare function questionMarksToOrderedParams(query: string): string;
|
|
1478
|
+
declare function insertObjectQuery(table: string, obj: DynamicObject): string;
|
|
1479
|
+
declare function updateObjectQuery(table: string, obj: DynamicObject, whereStatement: string): string;
|
|
1480
|
+
declare function isValueNumber(value: unknown): value is number;
|
|
1481
|
+
declare function SQL(strings: any, ...values: any): any;
|
|
1482
|
+
|
|
1483
|
+
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 };
|