wabe 0.5.22 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/index.d.ts +93 -21
- package/dist/index.js +3350 -564
- package/generated/schema.graphql +133 -45
- package/generated/wabe.ts +124 -34
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://wabe.dev"><img src="https://
|
|
2
|
+
<a href="https://wabe.dev"><img src="https://wabe.dev/assets/logo.png" alt="Wabe logo" height=170></a>
|
|
3
3
|
</p>
|
|
4
|
-
<h1 align="center">Wabe</h1>
|
|
5
4
|
|
|
6
5
|
<div align="center">
|
|
7
6
|
<a href="https://wabe.dev">Documentation</a>
|
package/dist/index.d.ts
CHANGED
|
@@ -55,8 +55,10 @@ declare enum RoleEnum {
|
|
|
55
55
|
Client = "Client"
|
|
56
56
|
}
|
|
57
57
|
declare enum AuthenticationProvider {
|
|
58
|
+
github = "github",
|
|
58
59
|
google = "google",
|
|
59
|
-
emailPassword = "emailPassword"
|
|
60
|
+
emailPassword = "emailPassword",
|
|
61
|
+
phonePassword = "phonePassword"
|
|
60
62
|
}
|
|
61
63
|
declare enum SecondaryFactor {
|
|
62
64
|
EmailOTP = "EmailOTP"
|
|
@@ -65,6 +67,7 @@ export type User = {
|
|
|
65
67
|
id: Scalars["ID"]["output"];
|
|
66
68
|
name?: Scalars["String"]["output"];
|
|
67
69
|
age?: Scalars["Int"]["output"];
|
|
70
|
+
email?: Scalars["Email"]["output"];
|
|
68
71
|
acl?: UserACLObject;
|
|
69
72
|
createdAt?: Scalars["Date"]["output"];
|
|
70
73
|
updatedAt?: Scalars["Date"]["output"];
|
|
@@ -72,7 +75,6 @@ export type User = {
|
|
|
72
75
|
authentication?: UserAuthentication;
|
|
73
76
|
provider?: AuthenticationProvider;
|
|
74
77
|
isOauth?: Scalars["Boolean"]["output"];
|
|
75
|
-
email?: Scalars["Email"]["output"];
|
|
76
78
|
verifiedEmail?: Scalars["Boolean"]["output"];
|
|
77
79
|
role?: Role;
|
|
78
80
|
sessions?: _SessionConnection;
|
|
@@ -92,8 +94,14 @@ export type UserACLObjectRolesACL = {
|
|
|
92
94
|
write: Scalars["Boolean"]["output"];
|
|
93
95
|
};
|
|
94
96
|
export type UserAuthentication = {
|
|
97
|
+
phonePassword?: UserAuthenticationPhonePassword;
|
|
95
98
|
emailPassword?: UserAuthenticationEmailPassword;
|
|
96
99
|
google?: UserAuthenticationGoogle;
|
|
100
|
+
github?: UserAuthenticationGithub;
|
|
101
|
+
};
|
|
102
|
+
export type UserAuthenticationPhonePassword = {
|
|
103
|
+
phone: Scalars["Phone"]["output"];
|
|
104
|
+
password: Scalars["String"]["output"];
|
|
97
105
|
};
|
|
98
106
|
export type UserAuthenticationEmailPassword = {
|
|
99
107
|
email: Scalars["Email"]["output"];
|
|
@@ -102,7 +110,11 @@ export type UserAuthenticationEmailPassword = {
|
|
|
102
110
|
export type UserAuthenticationGoogle = {
|
|
103
111
|
email: Scalars["Email"]["output"];
|
|
104
112
|
verifiedEmail: Scalars["Boolean"]["output"];
|
|
105
|
-
|
|
113
|
+
};
|
|
114
|
+
export type UserAuthenticationGithub = {
|
|
115
|
+
email: Scalars["Email"]["output"];
|
|
116
|
+
avatarUrl: Scalars["String"]["output"];
|
|
117
|
+
username: Scalars["String"]["output"];
|
|
106
118
|
};
|
|
107
119
|
export type _SessionConnection = {
|
|
108
120
|
totalCount?: Scalars["Int"]["output"];
|
|
@@ -114,7 +126,6 @@ export type _SessionEdge = {
|
|
|
114
126
|
export type Post = {
|
|
115
127
|
id: Scalars["ID"]["output"];
|
|
116
128
|
name: Scalars["String"]["output"];
|
|
117
|
-
test?: Scalars["File"]["output"];
|
|
118
129
|
test2?: RoleEnum;
|
|
119
130
|
acl?: PostACLObject;
|
|
120
131
|
createdAt?: Scalars["Date"]["output"];
|
|
@@ -219,11 +230,17 @@ export type SignInWithInput = {
|
|
|
219
230
|
authentication: SignInWithAuthenticationInput;
|
|
220
231
|
};
|
|
221
232
|
export type SignInWithAuthenticationInput = {
|
|
233
|
+
phonePassword?: SignInWithAuthenticationPhonePasswordInput;
|
|
222
234
|
emailPassword?: SignInWithAuthenticationEmailPasswordInput;
|
|
223
235
|
google?: SignInWithAuthenticationGoogleInput;
|
|
236
|
+
github?: SignInWithAuthenticationGithubInput;
|
|
224
237
|
otp?: SignInWithAuthenticationOtpInput;
|
|
225
238
|
secondaryFactor?: SecondaryFactor;
|
|
226
239
|
};
|
|
240
|
+
export type SignInWithAuthenticationPhonePasswordInput = {
|
|
241
|
+
phone: Scalars["Phone"]["input"];
|
|
242
|
+
password: Scalars["String"]["input"];
|
|
243
|
+
};
|
|
227
244
|
export type SignInWithAuthenticationEmailPasswordInput = {
|
|
228
245
|
email: Scalars["Email"]["input"];
|
|
229
246
|
password: Scalars["String"]["input"];
|
|
@@ -232,6 +249,10 @@ export type SignInWithAuthenticationGoogleInput = {
|
|
|
232
249
|
authorizationCode: Scalars["String"]["input"];
|
|
233
250
|
codeVerifier: Scalars["String"]["input"];
|
|
234
251
|
};
|
|
252
|
+
export type SignInWithAuthenticationGithubInput = {
|
|
253
|
+
authorizationCode: Scalars["String"]["input"];
|
|
254
|
+
codeVerifier: Scalars["String"]["input"];
|
|
255
|
+
};
|
|
235
256
|
export type SignInWithAuthenticationOtpInput = {
|
|
236
257
|
code?: Scalars["String"]["input"];
|
|
237
258
|
};
|
|
@@ -239,11 +260,17 @@ export type SignUpWithInput = {
|
|
|
239
260
|
authentication: SignUpWithAuthenticationInput;
|
|
240
261
|
};
|
|
241
262
|
export type SignUpWithAuthenticationInput = {
|
|
263
|
+
phonePassword?: SignUpWithAuthenticationPhonePasswordInput;
|
|
242
264
|
emailPassword?: SignUpWithAuthenticationEmailPasswordInput;
|
|
243
265
|
google?: SignUpWithAuthenticationGoogleInput;
|
|
266
|
+
github?: SignUpWithAuthenticationGithubInput;
|
|
244
267
|
otp?: SignUpWithAuthenticationOtpInput;
|
|
245
268
|
secondaryFactor?: SecondaryFactor;
|
|
246
269
|
};
|
|
270
|
+
export type SignUpWithAuthenticationPhonePasswordInput = {
|
|
271
|
+
phone: Scalars["Phone"]["input"];
|
|
272
|
+
password: Scalars["String"]["input"];
|
|
273
|
+
};
|
|
247
274
|
export type SignUpWithAuthenticationEmailPasswordInput = {
|
|
248
275
|
email: Scalars["Email"]["input"];
|
|
249
276
|
password: Scalars["String"]["input"];
|
|
@@ -252,10 +279,14 @@ export type SignUpWithAuthenticationGoogleInput = {
|
|
|
252
279
|
authorizationCode: Scalars["String"]["input"];
|
|
253
280
|
codeVerifier: Scalars["String"]["input"];
|
|
254
281
|
};
|
|
282
|
+
export type SignUpWithAuthenticationGithubInput = {
|
|
283
|
+
authorizationCode: Scalars["String"]["input"];
|
|
284
|
+
codeVerifier: Scalars["String"]["input"];
|
|
285
|
+
};
|
|
255
286
|
export type SignUpWithAuthenticationOtpInput = {
|
|
256
287
|
code?: Scalars["String"]["input"];
|
|
257
288
|
};
|
|
258
|
-
export type WabeSchemaScalars = "
|
|
289
|
+
export type WabeSchemaScalars = "";
|
|
259
290
|
export type WabeSchemaEnums = {
|
|
260
291
|
RoleEnum: RoleEnum;
|
|
261
292
|
AuthenticationProvider: AuthenticationProvider;
|
|
@@ -351,6 +382,7 @@ export interface UpdateObjectOptions<T extends WabeTypes, K extends keyof T["typ
|
|
|
351
382
|
data: MutationData<T, K, U>;
|
|
352
383
|
fields: Array<W | "*">;
|
|
353
384
|
context: WabeContext<any>;
|
|
385
|
+
skipHooks?: boolean;
|
|
354
386
|
}
|
|
355
387
|
export interface UpdateObjectsOptions<T extends WabeTypes, K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K], X extends keyof T["types"][K]> {
|
|
356
388
|
className: K;
|
|
@@ -361,6 +393,7 @@ export interface UpdateObjectsOptions<T extends WabeTypes, K extends keyof T["ty
|
|
|
361
393
|
offset?: number;
|
|
362
394
|
first?: number;
|
|
363
395
|
context: WabeContext<any>;
|
|
396
|
+
skipHooks?: boolean;
|
|
364
397
|
}
|
|
365
398
|
export interface DeleteObjectOptions<T extends WabeTypes, K extends keyof T["types"], U extends keyof T["types"][K]> {
|
|
366
399
|
className: K;
|
|
@@ -618,8 +651,8 @@ export declare class DatabaseController<T extends WabeTypes> {
|
|
|
618
651
|
getObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>({ className, fields, context, where, skipHooks, first, offset, order, }: GetObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
|
|
619
652
|
createObject<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>({ className, context, data, fields, }: CreateObjectOptions<T, K, U, W>): Promise<OutputType<T, K, W>>;
|
|
620
653
|
createObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K], X extends keyof T["types"][K]>({ data, fields, className, context, first, offset, order, }: CreateObjectsOptions<T, K, U, W, X>): Promise<OutputType<T, K, W>[]>;
|
|
621
|
-
updateObject<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>({ id, className, context, data, fields, }: UpdateObjectOptions<T, K, U, W>): Promise<OutputType<T, K, W>>;
|
|
622
|
-
updateObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K], X extends keyof T["types"][K]>({ className, where, context, fields, data, first, offset, order, }: UpdateObjectsOptions<T, K, U, W, X>): Promise<OutputType<T, K, W>[]>;
|
|
654
|
+
updateObject<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>({ id, className, context, data, fields, skipHooks, }: UpdateObjectOptions<T, K, U, W>): Promise<OutputType<T, K, W>>;
|
|
655
|
+
updateObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K], X extends keyof T["types"][K]>({ className, where, context, fields, data, first, offset, order, skipHooks, }: UpdateObjectsOptions<T, K, U, W, X>): Promise<OutputType<T, K, W>[]>;
|
|
623
656
|
deleteObject<K extends keyof T["types"], U extends keyof T["types"][K]>({ context, className, id, fields, }: DeleteObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
|
|
624
657
|
deleteObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>({ className, context, fields, where, first, offset, order, }: DeleteObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
|
|
625
658
|
}
|
|
@@ -658,9 +691,10 @@ export declare const _findHooksByPriority: <T extends unknown>({ className, oper
|
|
|
658
691
|
priority: number;
|
|
659
692
|
config: WabeConfig<any>;
|
|
660
693
|
}) => Promise<Hook<any, any>[]>;
|
|
661
|
-
export declare const initializeHook: <T extends WabeTypes, K extends keyof T["types"]>({ className, newData, context, }: {
|
|
694
|
+
export declare const initializeHook: <T extends WabeTypes, K extends keyof T["types"]>({ className, newData, context, fields, }: {
|
|
662
695
|
className: K;
|
|
663
696
|
newData?: MutationData<DevWabeTypes, any, any>;
|
|
697
|
+
fields: string[];
|
|
664
698
|
context: WabeContext<any>;
|
|
665
699
|
}) => {
|
|
666
700
|
runOnSingleObject: (options: {
|
|
@@ -695,13 +729,15 @@ declare class HookObject<T extends WabeTypes, K extends keyof WabeTypes["types"]
|
|
|
695
729
|
context: WabeContext<T>;
|
|
696
730
|
object: OutputType<T, K, keyof T["types"][K]>;
|
|
697
731
|
originalObject: OutputType<T, K, keyof T["types"][K]> | undefined;
|
|
698
|
-
|
|
732
|
+
fields: Array<keyof T["types"][K]>;
|
|
733
|
+
constructor({ newData, className, operationType, context, object, originalObject, fields, }: {
|
|
699
734
|
className: K;
|
|
700
735
|
newData?: MutationData<T, K, keyof T["types"][K]>;
|
|
701
736
|
operationType: OperationType;
|
|
702
737
|
context: WabeContext<T>;
|
|
703
738
|
object: OutputType<T, K, keyof T["types"][K]>;
|
|
704
739
|
originalObject?: OutputType<T, K, keyof T["types"][K]>;
|
|
740
|
+
fields: Array<keyof T["types"][K]>;
|
|
705
741
|
});
|
|
706
742
|
getUser(): User | null | undefined;
|
|
707
743
|
isFieldUpdated(field: keyof T["types"][K]): boolean | undefined;
|
|
@@ -710,7 +746,7 @@ declare class HookObject<T extends WabeTypes, K extends keyof WabeTypes["types"]
|
|
|
710
746
|
fetch(): Promise<OutputType<T, K, keyof T["types"][K]>>;
|
|
711
747
|
addACL(type: "users" | "roles", options: AddACLOpptions): Promise<void>;
|
|
712
748
|
}
|
|
713
|
-
export type WabePrimaryTypes = "String" | "Int" | "Float" | "Boolean" | "Email" | "Date" | "File";
|
|
749
|
+
export type WabePrimaryTypes = "String" | "Int" | "Float" | "Boolean" | "Email" | "Phone" | "Date" | "File";
|
|
714
750
|
export type WabeCustomTypes = "Array" | "Object";
|
|
715
751
|
export type WabeRelationTypes = "Pointer" | "Relation";
|
|
716
752
|
export type WabeFieldTypes = WabeCustomTypes | WabePrimaryTypes | WabeRelationTypes;
|
|
@@ -774,7 +810,7 @@ export type TypeFieldCustomEnums<T extends WabeTypes> = {
|
|
|
774
810
|
description?: string;
|
|
775
811
|
defaultValue?: any;
|
|
776
812
|
};
|
|
777
|
-
export type TypeField<T extends WabeTypes> = TypeFieldBase<string, "String"> | TypeFieldBase<number, "Int"> | TypeFieldBase<number, "Float"> | TypeFieldBase<boolean, "Boolean"> | TypeFieldBase<Date, "Date"> | TypeFieldBase<string, "Email"> | TypeFieldArray<T> | TypeFieldObject<T> | TypeFieldPointer<T> | TypeFieldRelation<T> | TypeFieldFile | TypeFieldCustomScalars<T> | TypeFieldCustomEnums<T>;
|
|
813
|
+
export type TypeField<T extends WabeTypes> = TypeFieldBase<string, "String"> | TypeFieldBase<number, "Int"> | TypeFieldBase<number, "Float"> | TypeFieldBase<boolean, "Boolean"> | TypeFieldBase<Date, "Date"> | TypeFieldBase<string, "Email"> | TypeFieldBase<string, "Phone"> | TypeFieldArray<T> | TypeFieldObject<T> | TypeFieldPointer<T> | TypeFieldRelation<T> | TypeFieldFile | TypeFieldCustomScalars<T> | TypeFieldCustomEnums<T>;
|
|
778
814
|
export type SchemaFields<T extends WabeTypes> = Record<string, TypeField<T>>;
|
|
779
815
|
export type ResolverType<T extends WabeTypes> = {
|
|
780
816
|
required?: boolean;
|
|
@@ -877,7 +913,7 @@ export declare class Schema<T extends WabeTypes> {
|
|
|
877
913
|
}
|
|
878
914
|
export declare enum ProviderEnum {
|
|
879
915
|
google = "google",
|
|
880
|
-
|
|
916
|
+
github = "github"
|
|
881
917
|
}
|
|
882
918
|
export interface ProviderConfig {
|
|
883
919
|
clientId: string;
|
|
@@ -932,6 +968,8 @@ export interface AuthenticationConfig<T extends WabeTypes> {
|
|
|
932
968
|
roles?: RoleConfig;
|
|
933
969
|
successRedirectPath?: string;
|
|
934
970
|
failureRedirectPath?: string;
|
|
971
|
+
frontDomain?: string;
|
|
972
|
+
backDomain?: string;
|
|
935
973
|
providers?: Partial<Record<ProviderEnum, ProviderConfig>>;
|
|
936
974
|
customAuthenticationMethods?: CustomAuthenticationMethods<T>[];
|
|
937
975
|
}
|
|
@@ -946,8 +984,10 @@ export interface Provider {
|
|
|
946
984
|
refreshToken(options: refreshTokenOptions): Promise<void>;
|
|
947
985
|
}
|
|
948
986
|
declare enum AuthenticationProvider$1 {
|
|
987
|
+
GitHub = "github",
|
|
949
988
|
Google = "google",
|
|
950
|
-
EmailPassword = "emailPassword"
|
|
989
|
+
EmailPassword = "emailPassword",
|
|
990
|
+
PhonePassword = "phonePassword"
|
|
951
991
|
}
|
|
952
992
|
export interface WabeRoute {
|
|
953
993
|
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
@@ -959,17 +999,39 @@ export declare const generateCodegen: ({ schema, path, graphqlSchema, }: {
|
|
|
959
999
|
path: string;
|
|
960
1000
|
graphqlSchema: GraphQLSchema;
|
|
961
1001
|
}) => Promise<void>;
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1002
|
+
export declare class FileDevAdapter implements FileAdapter {
|
|
1003
|
+
private basePath;
|
|
1004
|
+
constructor(basePath: string);
|
|
1005
|
+
uploadFile(file: File | Blob): Promise<void>;
|
|
1006
|
+
readFile(fileName: string): Promise<string | null>;
|
|
1007
|
+
deleteFile(fileName: string): Promise<void>;
|
|
1008
|
+
}
|
|
968
1009
|
/**
|
|
969
1010
|
* The file config contains the adapter to use to upload file
|
|
1011
|
+
* @param adapter: FileAdapter
|
|
1012
|
+
* @param urlCacheInSeconds: number Number of seconds to cache the url, equal to the number of seconds the url will be valid
|
|
970
1013
|
*/
|
|
971
1014
|
export interface FileConfig {
|
|
972
|
-
adapter:
|
|
1015
|
+
adapter: FileAdapter;
|
|
1016
|
+
urlCacheInSeconds?: number;
|
|
1017
|
+
}
|
|
1018
|
+
export interface ReadFileOptions {
|
|
1019
|
+
urlExpiresIn?: number;
|
|
1020
|
+
}
|
|
1021
|
+
export interface FileAdapter {
|
|
1022
|
+
/**
|
|
1023
|
+
* Upload a file and returns the url of the file
|
|
1024
|
+
* @param file: File
|
|
1025
|
+
*/
|
|
1026
|
+
uploadFile(file: File | Blob): Promise<void>;
|
|
1027
|
+
/**
|
|
1028
|
+
* Read a file and returns the url of the file
|
|
1029
|
+
* @param fileName: string
|
|
1030
|
+
* @param urlExpiresIn: number Number of seconds to expire the url
|
|
1031
|
+
* @returns The url of file or null if the file doesn't exist
|
|
1032
|
+
*/
|
|
1033
|
+
readFile(fileName: string, options?: ReadFileOptions): Promise<string | null> | string | null;
|
|
1034
|
+
deleteFile(fileName: string): Promise<void>;
|
|
973
1035
|
}
|
|
974
1036
|
export type HtmlTemplates = {
|
|
975
1037
|
sendOTPCode: (options: {
|
|
@@ -1280,15 +1342,24 @@ export interface AIAdapter {
|
|
|
1280
1342
|
export interface AIConfig {
|
|
1281
1343
|
adapter: AIAdapter;
|
|
1282
1344
|
}
|
|
1345
|
+
declare class FileController implements FileAdapter {
|
|
1346
|
+
adapter: FileAdapter;
|
|
1347
|
+
constructor(adapter: FileAdapter);
|
|
1348
|
+
uploadFile(file: File | Blob): Promise<void>;
|
|
1349
|
+
readFile(fileName: string): string | Promise<string | null> | null;
|
|
1350
|
+
deleteFile(fileName: string): Promise<void>;
|
|
1351
|
+
}
|
|
1283
1352
|
export type SecurityConfig = {
|
|
1284
1353
|
corsOptions?: CorsOptions;
|
|
1285
1354
|
rateLimit?: RateLimitOptions;
|
|
1286
1355
|
};
|
|
1287
1356
|
export interface WabeConfig<T extends WabeTypes> {
|
|
1288
1357
|
port: number;
|
|
1358
|
+
isProduction?: boolean;
|
|
1289
1359
|
hostname?: string;
|
|
1290
1360
|
security?: SecurityConfig;
|
|
1291
1361
|
schema?: SchemaInterface<T>;
|
|
1362
|
+
graphqlSchema?: GraphQLSchema;
|
|
1292
1363
|
database: DatabaseConfig;
|
|
1293
1364
|
codegen?: {
|
|
1294
1365
|
enabled: true;
|
|
@@ -1317,12 +1388,13 @@ export type WabeControllers<T extends WabeTypes> = {
|
|
|
1317
1388
|
database: DatabaseController<T>;
|
|
1318
1389
|
email?: EmailController;
|
|
1319
1390
|
payment?: PaymentController;
|
|
1391
|
+
file?: FileController;
|
|
1320
1392
|
};
|
|
1321
1393
|
export declare class Wabe<T extends WabeTypes> {
|
|
1322
1394
|
server: Wobe<WobeCustomContext<T>>;
|
|
1323
1395
|
config: WabeConfig<T>;
|
|
1324
1396
|
controllers: WabeControllers<T>;
|
|
1325
|
-
constructor({ port, hostname, security, schema, database, authentication, rootKey, codegen, hooks, file, email, payment, routes, }: WabeConfig<T>);
|
|
1397
|
+
constructor({ isProduction, port, hostname, security, schema, database, authentication, rootKey, codegen, hooks, file, email, payment, routes, }: WabeConfig<T>);
|
|
1326
1398
|
loadRoleEnum(): void;
|
|
1327
1399
|
loadAuthenticationMethods(): void;
|
|
1328
1400
|
loadHooks(): void;
|