wabe 0.5.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 +70 -0
- package/bunfig.toml +4 -0
- package/dist/generated/wabe.d.ts +1287 -0
- package/dist/index.d.ts +921 -0
- package/dist/index.js +108814 -0
- package/generated/schema.graphql +1236 -0
- package/generated/wabe.ts +1518 -0
- package/package.json +53 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,921 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
import { Wobe, WobeHandler, WobeResponse } from 'wobe';
|
|
4
|
+
|
|
5
|
+
export type Maybe<T> = T | null;
|
|
6
|
+
export type InputMaybe<T> = Maybe<T>;
|
|
7
|
+
/** All built-in and custom scalars, mapped to their actual values */
|
|
8
|
+
export type Scalars = {
|
|
9
|
+
ID: {
|
|
10
|
+
input: string;
|
|
11
|
+
output: string;
|
|
12
|
+
};
|
|
13
|
+
String: {
|
|
14
|
+
input: string;
|
|
15
|
+
output: string;
|
|
16
|
+
};
|
|
17
|
+
Boolean: {
|
|
18
|
+
input: boolean;
|
|
19
|
+
output: boolean;
|
|
20
|
+
};
|
|
21
|
+
Int: {
|
|
22
|
+
input: number;
|
|
23
|
+
output: number;
|
|
24
|
+
};
|
|
25
|
+
Float: {
|
|
26
|
+
input: number;
|
|
27
|
+
output: number;
|
|
28
|
+
};
|
|
29
|
+
/** Phone custom scalar type */
|
|
30
|
+
Phone: {
|
|
31
|
+
input: any;
|
|
32
|
+
output: any;
|
|
33
|
+
};
|
|
34
|
+
/** Date scalar type */
|
|
35
|
+
Date: {
|
|
36
|
+
input: any;
|
|
37
|
+
output: any;
|
|
38
|
+
};
|
|
39
|
+
/** Email scalar type */
|
|
40
|
+
Email: {
|
|
41
|
+
input: any;
|
|
42
|
+
output: any;
|
|
43
|
+
};
|
|
44
|
+
/** File scalar type */
|
|
45
|
+
File: {
|
|
46
|
+
input: any;
|
|
47
|
+
output: any;
|
|
48
|
+
};
|
|
49
|
+
/** Search scalar to tokenize and search for all searchable fields */
|
|
50
|
+
Search: {
|
|
51
|
+
input: any;
|
|
52
|
+
output: any;
|
|
53
|
+
};
|
|
54
|
+
/** The Any scalar type is used in operations and types that involve any type of value. */
|
|
55
|
+
Any: {
|
|
56
|
+
input: any;
|
|
57
|
+
output: any;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
declare enum AuthenticationProvider {
|
|
61
|
+
Google = "Google"
|
|
62
|
+
}
|
|
63
|
+
declare enum SecondaryFactor {
|
|
64
|
+
EmailOtp = "EmailOTP"
|
|
65
|
+
}
|
|
66
|
+
/** User class */
|
|
67
|
+
export type User = {
|
|
68
|
+
__typename?: "User";
|
|
69
|
+
id: Scalars["ID"]["output"];
|
|
70
|
+
name?: Maybe<Scalars["String"]["output"]>;
|
|
71
|
+
age?: Maybe<Scalars["Int"]["output"]>;
|
|
72
|
+
acl?: Maybe<UserAclObject>;
|
|
73
|
+
createdAt?: Maybe<Scalars["Date"]["output"]>;
|
|
74
|
+
updatedAt?: Maybe<Scalars["Date"]["output"]>;
|
|
75
|
+
search?: Maybe<Array<Maybe<Scalars["String"]["output"]>>>;
|
|
76
|
+
authentication?: Maybe<UserAuthentication>;
|
|
77
|
+
provider?: Maybe<AuthenticationProvider>;
|
|
78
|
+
isOauth?: Maybe<Scalars["Boolean"]["output"]>;
|
|
79
|
+
email?: Maybe<Scalars["Email"]["output"]>;
|
|
80
|
+
verifiedEmail?: Maybe<Scalars["Boolean"]["output"]>;
|
|
81
|
+
role?: Maybe<Role>;
|
|
82
|
+
sessions?: Maybe<_SessionConnection>;
|
|
83
|
+
};
|
|
84
|
+
export type UserAclObject = {
|
|
85
|
+
__typename?: "UserACLObject";
|
|
86
|
+
users?: Maybe<Array<Maybe<UserAclObjectUsersAcl>>>;
|
|
87
|
+
roles?: Maybe<Array<Maybe<UserAclObjectRolesAcl>>>;
|
|
88
|
+
};
|
|
89
|
+
export type UserAclObjectUsersAcl = {
|
|
90
|
+
__typename?: "UserACLObjectUsersACL";
|
|
91
|
+
userId: Scalars["String"]["output"];
|
|
92
|
+
read: Scalars["Boolean"]["output"];
|
|
93
|
+
write: Scalars["Boolean"]["output"];
|
|
94
|
+
};
|
|
95
|
+
export type UserAclObjectRolesAcl = {
|
|
96
|
+
__typename?: "UserACLObjectRolesACL";
|
|
97
|
+
roleId: Scalars["String"]["output"];
|
|
98
|
+
read: Scalars["Boolean"]["output"];
|
|
99
|
+
write: Scalars["Boolean"]["output"];
|
|
100
|
+
};
|
|
101
|
+
export type UserAuthentication = {
|
|
102
|
+
__typename?: "UserAuthentication";
|
|
103
|
+
emailPassword?: Maybe<UserAuthenticationEmailPassword>;
|
|
104
|
+
google?: Maybe<UserAuthenticationGoogle>;
|
|
105
|
+
};
|
|
106
|
+
export type UserAuthenticationEmailPassword = {
|
|
107
|
+
__typename?: "UserAuthenticationEmailPassword";
|
|
108
|
+
email: Scalars["Email"]["output"];
|
|
109
|
+
password: Scalars["String"]["output"];
|
|
110
|
+
};
|
|
111
|
+
export type UserAuthenticationGoogle = {
|
|
112
|
+
__typename?: "UserAuthenticationGoogle";
|
|
113
|
+
email: Scalars["Email"]["output"];
|
|
114
|
+
verifiedEmail: Scalars["Boolean"]["output"];
|
|
115
|
+
idToken: Scalars["String"]["output"];
|
|
116
|
+
};
|
|
117
|
+
export type _SessionConnection = {
|
|
118
|
+
__typename?: "_SessionConnection";
|
|
119
|
+
totalCount?: Maybe<Scalars["Int"]["output"]>;
|
|
120
|
+
edges?: Maybe<Array<Maybe<_SessionEdge>>>;
|
|
121
|
+
};
|
|
122
|
+
export type _SessionEdge = {
|
|
123
|
+
__typename?: "_SessionEdge";
|
|
124
|
+
node: _Session;
|
|
125
|
+
};
|
|
126
|
+
export type Post = {
|
|
127
|
+
__typename?: "Post";
|
|
128
|
+
id: Scalars["ID"]["output"];
|
|
129
|
+
name: Scalars["String"]["output"];
|
|
130
|
+
test?: Maybe<Scalars["File"]["output"]>;
|
|
131
|
+
acl?: Maybe<PostAclObject>;
|
|
132
|
+
createdAt?: Maybe<Scalars["Date"]["output"]>;
|
|
133
|
+
updatedAt?: Maybe<Scalars["Date"]["output"]>;
|
|
134
|
+
search?: Maybe<Array<Maybe<Scalars["String"]["output"]>>>;
|
|
135
|
+
};
|
|
136
|
+
export type PostAclObject = {
|
|
137
|
+
__typename?: "PostACLObject";
|
|
138
|
+
users?: Maybe<Array<Maybe<PostAclObjectUsersAcl>>>;
|
|
139
|
+
roles?: Maybe<Array<Maybe<PostAclObjectRolesAcl>>>;
|
|
140
|
+
};
|
|
141
|
+
export type PostAclObjectUsersAcl = {
|
|
142
|
+
__typename?: "PostACLObjectUsersACL";
|
|
143
|
+
userId: Scalars["String"]["output"];
|
|
144
|
+
read: Scalars["Boolean"]["output"];
|
|
145
|
+
write: Scalars["Boolean"]["output"];
|
|
146
|
+
};
|
|
147
|
+
export type PostAclObjectRolesAcl = {
|
|
148
|
+
__typename?: "PostACLObjectRolesACL";
|
|
149
|
+
roleId: Scalars["String"]["output"];
|
|
150
|
+
read: Scalars["Boolean"]["output"];
|
|
151
|
+
write: Scalars["Boolean"]["output"];
|
|
152
|
+
};
|
|
153
|
+
export type _Session = {
|
|
154
|
+
__typename?: "_Session";
|
|
155
|
+
id: Scalars["ID"]["output"];
|
|
156
|
+
user?: Maybe<User>;
|
|
157
|
+
accessToken: Scalars["String"]["output"];
|
|
158
|
+
accessTokenExpiresAt: Scalars["Date"]["output"];
|
|
159
|
+
refreshToken?: Maybe<Scalars["String"]["output"]>;
|
|
160
|
+
refreshTokenExpiresAt: Scalars["Date"]["output"];
|
|
161
|
+
acl?: Maybe<_SessionAclObject>;
|
|
162
|
+
createdAt?: Maybe<Scalars["Date"]["output"]>;
|
|
163
|
+
updatedAt?: Maybe<Scalars["Date"]["output"]>;
|
|
164
|
+
search?: Maybe<Array<Maybe<Scalars["String"]["output"]>>>;
|
|
165
|
+
};
|
|
166
|
+
export type _SessionAclObject = {
|
|
167
|
+
__typename?: "_SessionACLObject";
|
|
168
|
+
users?: Maybe<Array<Maybe<_SessionAclObjectUsersAcl>>>;
|
|
169
|
+
roles?: Maybe<Array<Maybe<_SessionAclObjectRolesAcl>>>;
|
|
170
|
+
};
|
|
171
|
+
export type _SessionAclObjectUsersAcl = {
|
|
172
|
+
__typename?: "_SessionACLObjectUsersACL";
|
|
173
|
+
userId: Scalars["String"]["output"];
|
|
174
|
+
read: Scalars["Boolean"]["output"];
|
|
175
|
+
write: Scalars["Boolean"]["output"];
|
|
176
|
+
};
|
|
177
|
+
export type _SessionAclObjectRolesAcl = {
|
|
178
|
+
__typename?: "_SessionACLObjectRolesACL";
|
|
179
|
+
roleId: Scalars["String"]["output"];
|
|
180
|
+
read: Scalars["Boolean"]["output"];
|
|
181
|
+
write: Scalars["Boolean"]["output"];
|
|
182
|
+
};
|
|
183
|
+
export type Role = {
|
|
184
|
+
__typename?: "Role";
|
|
185
|
+
id: Scalars["ID"]["output"];
|
|
186
|
+
name: Scalars["String"]["output"];
|
|
187
|
+
users?: Maybe<UserConnection>;
|
|
188
|
+
acl?: Maybe<RoleAclObject>;
|
|
189
|
+
createdAt?: Maybe<Scalars["Date"]["output"]>;
|
|
190
|
+
updatedAt?: Maybe<Scalars["Date"]["output"]>;
|
|
191
|
+
search?: Maybe<Array<Maybe<Scalars["String"]["output"]>>>;
|
|
192
|
+
};
|
|
193
|
+
export type UserConnection = {
|
|
194
|
+
__typename?: "UserConnection";
|
|
195
|
+
totalCount?: Maybe<Scalars["Int"]["output"]>;
|
|
196
|
+
edges?: Maybe<Array<Maybe<UserEdge>>>;
|
|
197
|
+
};
|
|
198
|
+
export type UserEdge = {
|
|
199
|
+
__typename?: "UserEdge";
|
|
200
|
+
node: User;
|
|
201
|
+
};
|
|
202
|
+
export type RoleAclObject = {
|
|
203
|
+
__typename?: "RoleACLObject";
|
|
204
|
+
users?: Maybe<Array<Maybe<RoleAclObjectUsersAcl>>>;
|
|
205
|
+
roles?: Maybe<Array<Maybe<RoleAclObjectRolesAcl>>>;
|
|
206
|
+
};
|
|
207
|
+
export type RoleAclObjectUsersAcl = {
|
|
208
|
+
__typename?: "RoleACLObjectUsersACL";
|
|
209
|
+
userId: Scalars["String"]["output"];
|
|
210
|
+
read: Scalars["Boolean"]["output"];
|
|
211
|
+
write: Scalars["Boolean"]["output"];
|
|
212
|
+
};
|
|
213
|
+
export type RoleAclObjectRolesAcl = {
|
|
214
|
+
__typename?: "RoleACLObjectRolesACL";
|
|
215
|
+
roleId: Scalars["String"]["output"];
|
|
216
|
+
read: Scalars["Boolean"]["output"];
|
|
217
|
+
write: Scalars["Boolean"]["output"];
|
|
218
|
+
};
|
|
219
|
+
export type SignInWithInput = {
|
|
220
|
+
authentication?: InputMaybe<SignInWithAuthenticationInput>;
|
|
221
|
+
};
|
|
222
|
+
export type SignInWithAuthenticationInput = {
|
|
223
|
+
emailPassword?: InputMaybe<SignInWithAuthenticationEmailPasswordInput>;
|
|
224
|
+
google?: InputMaybe<SignInWithAuthenticationGoogleInput>;
|
|
225
|
+
otp?: InputMaybe<SignInWithAuthenticationOtpInput>;
|
|
226
|
+
secondaryFactor?: InputMaybe<SecondaryFactor>;
|
|
227
|
+
};
|
|
228
|
+
export type SignInWithAuthenticationEmailPasswordInput = {
|
|
229
|
+
email: Scalars["Email"]["input"];
|
|
230
|
+
password: Scalars["String"]["input"];
|
|
231
|
+
};
|
|
232
|
+
export type SignInWithAuthenticationGoogleInput = {
|
|
233
|
+
authorizationCode: Scalars["String"]["input"];
|
|
234
|
+
codeVerifier: Scalars["String"]["input"];
|
|
235
|
+
};
|
|
236
|
+
export type SignInWithAuthenticationOtpInput = {
|
|
237
|
+
code?: InputMaybe<Scalars["String"]["input"]>;
|
|
238
|
+
};
|
|
239
|
+
export type SignUpWithInput = {
|
|
240
|
+
authentication?: InputMaybe<SignUpWithAuthenticationInput>;
|
|
241
|
+
};
|
|
242
|
+
export type SignUpWithAuthenticationInput = {
|
|
243
|
+
emailPassword?: InputMaybe<SignUpWithAuthenticationEmailPasswordInput>;
|
|
244
|
+
google?: InputMaybe<SignUpWithAuthenticationGoogleInput>;
|
|
245
|
+
otp?: InputMaybe<SignUpWithAuthenticationOtpInput>;
|
|
246
|
+
secondaryFactor?: InputMaybe<SecondaryFactor>;
|
|
247
|
+
};
|
|
248
|
+
export type SignUpWithAuthenticationEmailPasswordInput = {
|
|
249
|
+
email: Scalars["Email"]["input"];
|
|
250
|
+
password: Scalars["String"]["input"];
|
|
251
|
+
};
|
|
252
|
+
export type SignUpWithAuthenticationGoogleInput = {
|
|
253
|
+
authorizationCode: Scalars["String"]["input"];
|
|
254
|
+
codeVerifier: Scalars["String"]["input"];
|
|
255
|
+
};
|
|
256
|
+
export type SignUpWithAuthenticationOtpInput = {
|
|
257
|
+
code?: InputMaybe<Scalars["String"]["input"]>;
|
|
258
|
+
};
|
|
259
|
+
export type WabeSchemaScalars = "Phone";
|
|
260
|
+
export type WabeSchemaEnums = "AuthenticationProvider" | "SecondaryFactor";
|
|
261
|
+
export type WabeSchemaTypes = {
|
|
262
|
+
User: User;
|
|
263
|
+
Post: Post;
|
|
264
|
+
_Session: _Session;
|
|
265
|
+
Role: Role;
|
|
266
|
+
};
|
|
267
|
+
export interface WabeContext<T extends WabeTypes> {
|
|
268
|
+
response?: WobeResponse;
|
|
269
|
+
user?: User | null;
|
|
270
|
+
sessionId?: string;
|
|
271
|
+
isRoot: boolean;
|
|
272
|
+
wabe: Wabe<T>;
|
|
273
|
+
}
|
|
274
|
+
export type WhereAggregation<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T]> = Record<K | "id", {
|
|
275
|
+
equalTo?: any;
|
|
276
|
+
notEqualTo?: any;
|
|
277
|
+
greaterThan?: any;
|
|
278
|
+
lessThan?: any;
|
|
279
|
+
greaterThanOrEqualTo?: any;
|
|
280
|
+
lessThanOrEqualTo?: any;
|
|
281
|
+
in?: any[];
|
|
282
|
+
notIn?: any[];
|
|
283
|
+
contains?: any;
|
|
284
|
+
notContains?: any;
|
|
285
|
+
}>;
|
|
286
|
+
export type WhereConditional<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T]> = {
|
|
287
|
+
OR?: Array<WhereType<T, K>>;
|
|
288
|
+
AND?: Array<WhereType<T, K>>;
|
|
289
|
+
};
|
|
290
|
+
export type WhereType<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T]> = Partial<WhereAggregation<T, K>> & WhereConditional<T, K>;
|
|
291
|
+
export interface AdapterOptions {
|
|
292
|
+
databaseUrl: string;
|
|
293
|
+
databaseName: string;
|
|
294
|
+
}
|
|
295
|
+
export type MutationData<T extends keyof WabeTypes["types"]> = Record<keyof WabeTypes["types"][T], any>;
|
|
296
|
+
export interface CountOptions<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T]> {
|
|
297
|
+
className: T;
|
|
298
|
+
where?: WhereType<T, K>;
|
|
299
|
+
context: WabeContext<any>;
|
|
300
|
+
}
|
|
301
|
+
export interface GetObjectOptions<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T]> {
|
|
302
|
+
className: T;
|
|
303
|
+
id: string;
|
|
304
|
+
where?: WhereType<T, K>;
|
|
305
|
+
fields: Array<K | "*">;
|
|
306
|
+
context: WabeContext<any>;
|
|
307
|
+
skipHooks?: boolean;
|
|
308
|
+
}
|
|
309
|
+
export interface GetObjectsOptions<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T], W extends keyof WabeTypes["types"][T]> {
|
|
310
|
+
className: T;
|
|
311
|
+
where?: WhereType<T, W>;
|
|
312
|
+
fields: Array<K | "*">;
|
|
313
|
+
offset?: number;
|
|
314
|
+
first?: number;
|
|
315
|
+
context: WabeContext<any>;
|
|
316
|
+
skipHooks?: boolean;
|
|
317
|
+
}
|
|
318
|
+
export interface CreateObjectOptions<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T], W extends keyof WabeTypes["types"][T]> {
|
|
319
|
+
className: T;
|
|
320
|
+
data: MutationData<W>;
|
|
321
|
+
fields: Array<K | "*">;
|
|
322
|
+
context: WabeContext<any>;
|
|
323
|
+
}
|
|
324
|
+
export interface CreateObjectsOptions<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T], W extends keyof WabeTypes["types"][T]> {
|
|
325
|
+
className: T;
|
|
326
|
+
data: Array<MutationData<W>>;
|
|
327
|
+
fields: Array<K | "*">;
|
|
328
|
+
offset?: number;
|
|
329
|
+
first?: number;
|
|
330
|
+
context: WabeContext<any>;
|
|
331
|
+
}
|
|
332
|
+
export interface UpdateObjectOptions<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T], W extends keyof WabeTypes["types"][T]> {
|
|
333
|
+
className: T;
|
|
334
|
+
id: string;
|
|
335
|
+
where?: WhereType<T, W>;
|
|
336
|
+
data: MutationData<W>;
|
|
337
|
+
fields: Array<K | "*">;
|
|
338
|
+
context: WabeContext<any>;
|
|
339
|
+
}
|
|
340
|
+
export interface UpdateObjectsOptions<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T], W extends keyof WabeTypes["types"][T]> {
|
|
341
|
+
className: T;
|
|
342
|
+
where: WhereType<T, W>;
|
|
343
|
+
data: MutationData<W>;
|
|
344
|
+
fields: Array<K | "*">;
|
|
345
|
+
offset?: number;
|
|
346
|
+
first?: number;
|
|
347
|
+
context: WabeContext<any>;
|
|
348
|
+
}
|
|
349
|
+
export interface DeleteObjectOptions<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T], W extends keyof WabeTypes["types"][T]> {
|
|
350
|
+
className: T;
|
|
351
|
+
id: string;
|
|
352
|
+
where?: WhereType<T, W>;
|
|
353
|
+
fields: Array<K | "*">;
|
|
354
|
+
context: WabeContext<any>;
|
|
355
|
+
}
|
|
356
|
+
export interface DeleteObjectsOptions<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T], W extends keyof WabeTypes["types"][T]> {
|
|
357
|
+
className: T;
|
|
358
|
+
where: WhereType<T, W>;
|
|
359
|
+
fields: Array<K | "*">;
|
|
360
|
+
offset?: number;
|
|
361
|
+
first?: number;
|
|
362
|
+
context: WabeContext<any>;
|
|
363
|
+
}
|
|
364
|
+
export type OutputType<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T]> = Pick<WabeTypes["types"][T], K> & {
|
|
365
|
+
id: string;
|
|
366
|
+
};
|
|
367
|
+
export interface DatabaseAdapter {
|
|
368
|
+
connect(): Promise<any>;
|
|
369
|
+
close(): Promise<any>;
|
|
370
|
+
createClassIfNotExist(className: string, context: WabeContext<any>): Promise<any>;
|
|
371
|
+
clearDatabase(): Promise<void>;
|
|
372
|
+
count<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T]>(params: CountOptions<T, K>): Promise<number>;
|
|
373
|
+
getObject<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T]>(params: GetObjectOptions<T, K>): Promise<OutputType<T, K>>;
|
|
374
|
+
getObjects<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T], W extends keyof WabeTypes["types"][T]>(params: GetObjectsOptions<T, K, W>): Promise<OutputType<T, K>[]>;
|
|
375
|
+
createObject<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T], W extends keyof WabeTypes["types"][T]>(params: CreateObjectOptions<T, K, W>): Promise<OutputType<T, K>>;
|
|
376
|
+
createObjects<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T], W extends keyof WabeTypes["types"][T]>(params: CreateObjectsOptions<T, K, W>): Promise<OutputType<T, K>[]>;
|
|
377
|
+
updateObject<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T], W extends keyof WabeTypes["types"][T]>(params: UpdateObjectOptions<T, K, W>): Promise<OutputType<T, K>>;
|
|
378
|
+
updateObjects<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T], W extends keyof WabeTypes["types"][T]>(params: UpdateObjectsOptions<T, K, W>): Promise<OutputType<T, K>[]>;
|
|
379
|
+
deleteObject<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T], W extends keyof WabeTypes["types"][T]>(params: DeleteObjectOptions<T, K, W>): Promise<void>;
|
|
380
|
+
deleteObjects<T extends keyof WabeTypes["types"], K extends keyof WabeTypes["types"][T], W extends keyof WabeTypes["types"][T]>(params: DeleteObjectsOptions<T, K, W>): Promise<void>;
|
|
381
|
+
}
|
|
382
|
+
export declare const buildMongoWhereQuery: <T extends unknown, K extends keyof Record<any, any>[T]>(where?: WhereType<T, K>) => Record<string, any>;
|
|
383
|
+
export declare class MongoAdapter<T extends WabeTypes> implements DatabaseAdapter {
|
|
384
|
+
options: AdapterOptions;
|
|
385
|
+
database?: Db;
|
|
386
|
+
private client;
|
|
387
|
+
constructor(options: AdapterOptions);
|
|
388
|
+
connect(): Promise<MongoClient>;
|
|
389
|
+
close(): Promise<void>;
|
|
390
|
+
createClassIfNotExist(className: keyof T["types"], context: WabeContext<T>): Promise<import("mongodb").Collection<import("bson").Document>>;
|
|
391
|
+
count<U extends keyof T["types"], K extends keyof T["types"][U]>(params: CountOptions<U, K>): Promise<number>;
|
|
392
|
+
clearDatabase(): Promise<void>;
|
|
393
|
+
getObject<U extends keyof T["types"], K extends keyof T["types"][U]>(params: GetObjectOptions<U, K>): Promise<OutputType<U, K>>;
|
|
394
|
+
getObjects<U extends keyof T["types"], K extends keyof T["types"][U], W extends keyof T["types"][U]>(params: GetObjectsOptions<U, K, W>): Promise<OutputType<U, K>[]>;
|
|
395
|
+
createObject<U extends keyof T["types"], K extends keyof T["types"][U], W extends keyof T["types"][U]>(params: CreateObjectOptions<U, K, W>): Promise<OutputType<U, K>>;
|
|
396
|
+
createObjects<U extends keyof T["types"], K extends keyof T["types"][U], W extends keyof T["types"][U]>(params: CreateObjectsOptions<U, K, W>): Promise<OutputType<U, K>[]>;
|
|
397
|
+
updateObject<U extends keyof T["types"], K extends keyof T["types"][U], W extends keyof T["types"][U]>(params: UpdateObjectOptions<U, K, W>): Promise<OutputType<U, K>>;
|
|
398
|
+
updateObjects<U extends keyof T["types"], K extends keyof T["types"][U], W extends keyof T["types"][U]>(params: UpdateObjectsOptions<U, K, W>): Promise<OutputType<U, K>[]>;
|
|
399
|
+
deleteObject<U extends keyof T["types"], K extends keyof T["types"][U], W extends keyof T["types"][U]>(params: DeleteObjectOptions<U, K, W>): Promise<void>;
|
|
400
|
+
deleteObjects<U extends keyof T["types"], K extends keyof T["types"][U], W extends keyof T["types"][U]>(params: DeleteObjectsOptions<U, K, W>): Promise<void>;
|
|
401
|
+
}
|
|
402
|
+
export interface InMemoryCacheOptions {
|
|
403
|
+
/**
|
|
404
|
+
* Interval in ms to clear the cache
|
|
405
|
+
*/
|
|
406
|
+
interval: number;
|
|
407
|
+
}
|
|
408
|
+
declare class InMemoryCache<T> {
|
|
409
|
+
private options;
|
|
410
|
+
private store;
|
|
411
|
+
intervalId: Timer | undefined;
|
|
412
|
+
constructor(options: InMemoryCacheOptions);
|
|
413
|
+
_init(): void;
|
|
414
|
+
set(key: string, value: T): void;
|
|
415
|
+
get(key: string): T | undefined;
|
|
416
|
+
clear(): void;
|
|
417
|
+
stop(): void;
|
|
418
|
+
}
|
|
419
|
+
export type PointerObject = Record<string, {
|
|
420
|
+
pointerClass?: string;
|
|
421
|
+
fieldsOfPointerClass: Array<string>;
|
|
422
|
+
}>;
|
|
423
|
+
export interface PointerFields {
|
|
424
|
+
pointersFieldsId: string[];
|
|
425
|
+
pointers: PointerObject;
|
|
426
|
+
}
|
|
427
|
+
export declare class DatabaseController<T extends WabeTypes> {
|
|
428
|
+
adapter: DatabaseAdapter;
|
|
429
|
+
inMemoryCache: InMemoryCache<OutputType<any, any> | undefined>;
|
|
430
|
+
constructor(adapter: DatabaseAdapter);
|
|
431
|
+
connect(): Promise<any>;
|
|
432
|
+
close(): Promise<any>;
|
|
433
|
+
createClassIfNotExist(className: string, context: WabeContext<T>): Promise<any>;
|
|
434
|
+
_getPointerObject(className: keyof T["types"], fields: string[], context: WabeContext<T>): PointerFields;
|
|
435
|
+
_isRelationField<U extends keyof T["types"]>(originClassName: U, context: WabeContext<T>, pointerClassName?: string): boolean | undefined;
|
|
436
|
+
_isPointerField<U extends keyof T["types"]>(originClassName: U, context: WabeContext<T>, pointerClassName?: string): boolean | undefined;
|
|
437
|
+
_getFinalObjectWithPointer<U extends keyof T["types"], K extends keyof T["types"][U]>(objectData: OutputType<U, K> | null, pointersObject: PointerObject, originClassName: U, context: WabeContext<T>): Promise<Record<any, any>>;
|
|
438
|
+
_getWhereObjectWithPointerOrRelation<U extends keyof T["types"], K extends keyof T["types"][U]>(className: U, where: WhereType<U, K>, context: WabeContext<T>): Promise<Partial<{
|
|
439
|
+
[P in "id" | K]: {
|
|
440
|
+
equalTo?: any;
|
|
441
|
+
notEqualTo?: any;
|
|
442
|
+
greaterThan?: any;
|
|
443
|
+
lessThan?: any;
|
|
444
|
+
greaterThanOrEqualTo?: any;
|
|
445
|
+
lessThanOrEqualTo?: any;
|
|
446
|
+
in?: any[] | undefined;
|
|
447
|
+
notIn?: any[] | undefined;
|
|
448
|
+
contains?: any;
|
|
449
|
+
notContains?: any;
|
|
450
|
+
};
|
|
451
|
+
}> & {
|
|
452
|
+
OR?: WhereType<U, K>[] | undefined;
|
|
453
|
+
AND?: WhereType<U, K>[] | undefined;
|
|
454
|
+
}>;
|
|
455
|
+
_buildWhereWithACL<U extends keyof T["types"], K extends keyof T["types"][U]>(where: WhereType<U, K>, context: WabeContext<T>, operation: "write" | "read"): WhereType<U, K>;
|
|
456
|
+
_buildCacheKey<U extends keyof T["types"]>(className: U, id: string, fields: Array<string>): string;
|
|
457
|
+
count<U extends keyof T["types"], K extends keyof T["types"][U]>(params: CountOptions<U, K>): Promise<number>;
|
|
458
|
+
clearDatabase(): Promise<void>;
|
|
459
|
+
getObject<U extends keyof T["types"], K extends keyof T["types"][U]>({ fields, className, context, skipHooks, id, where, }: GetObjectOptions<U, K>): Promise<OutputType<U, K>>;
|
|
460
|
+
getObjects<U extends keyof T["types"], K extends keyof T["types"][U], W extends keyof T["types"][U]>({ className, fields, context, where, skipHooks, first, offset, }: GetObjectsOptions<U, K, W>): Promise<OutputType<U, K>[]>;
|
|
461
|
+
createObject<U extends keyof T["types"], K extends keyof T["types"][U], W extends keyof T["types"][U]>({ className, context, data, fields }: CreateObjectOptions<U, K, W>): Promise<OutputType<U, K>>;
|
|
462
|
+
createObjects<U extends keyof T["types"], K extends keyof T["types"][U], W extends keyof T["types"][U]>({ data, fields, className, context, first, offset, }: CreateObjectsOptions<U, K, W>): Promise<OutputType<U, K>[]>;
|
|
463
|
+
updateObject<U extends keyof T["types"], K extends keyof T["types"][U], W extends keyof T["types"][U]>({ id, className, context, data, fields }: UpdateObjectOptions<U, K, W>): Promise<OutputType<keyof T["types"], K>>;
|
|
464
|
+
updateObjects<U extends keyof T["types"], K extends keyof T["types"][U], W extends keyof T["types"][U]>({ className, where, context, fields, data, first, offset, }: UpdateObjectsOptions<U, K, W>): Promise<OutputType<U, K>[]>;
|
|
465
|
+
deleteObject<U extends keyof T["types"], K extends keyof T["types"][U], W extends keyof T["types"][U]>({ context, className, id, fields }: DeleteObjectOptions<U, K, W>): Promise<OutputType<U, K>>;
|
|
466
|
+
deleteObjects<U extends keyof T["types"], K extends keyof T["types"][U], W extends keyof T["types"][U]>({ className, context, fields, where, first, offset, }: DeleteObjectsOptions<U, K, W>): Promise<OutputType<U, K>[]>;
|
|
467
|
+
}
|
|
468
|
+
export declare enum DatabaseEnum {
|
|
469
|
+
Mongo = "mongo"
|
|
470
|
+
}
|
|
471
|
+
export interface DatabaseConfig {
|
|
472
|
+
type: DatabaseEnum;
|
|
473
|
+
url: string;
|
|
474
|
+
name: string;
|
|
475
|
+
}
|
|
476
|
+
export type WabePrimaryTypes = "String" | "Int" | "Float" | "Boolean" | "Email" | "Date" | "File";
|
|
477
|
+
export type WabeCustomTypes = "Array" | "Object";
|
|
478
|
+
export type WabeRelationTypes = "Pointer" | "Relation";
|
|
479
|
+
export type WabeFieldTypes = WabeCustomTypes | WabePrimaryTypes | WabeRelationTypes;
|
|
480
|
+
export type WabeObject<T extends WabeTypes> = {
|
|
481
|
+
name: string;
|
|
482
|
+
fields: SchemaFields<T>;
|
|
483
|
+
description?: string;
|
|
484
|
+
required?: boolean;
|
|
485
|
+
};
|
|
486
|
+
export type TypeFieldBase<U, K extends WabeFieldTypes> = {
|
|
487
|
+
type: K;
|
|
488
|
+
required?: boolean;
|
|
489
|
+
description?: string;
|
|
490
|
+
defaultValue?: U;
|
|
491
|
+
};
|
|
492
|
+
export type TypeFieldArray<T extends WabeTypes> = {
|
|
493
|
+
type: "Array";
|
|
494
|
+
required?: boolean;
|
|
495
|
+
requiredValue?: boolean;
|
|
496
|
+
description?: string;
|
|
497
|
+
defaultValue?: any[];
|
|
498
|
+
} & ({
|
|
499
|
+
typeValue: WabePrimaryTypes;
|
|
500
|
+
} | {
|
|
501
|
+
typeValue: "Object";
|
|
502
|
+
object: WabeObject<T>;
|
|
503
|
+
});
|
|
504
|
+
export type TypeFieldObject<T extends WabeTypes> = {
|
|
505
|
+
type: "Object";
|
|
506
|
+
required?: boolean;
|
|
507
|
+
description?: string;
|
|
508
|
+
object: WabeObject<T>;
|
|
509
|
+
defaultValue?: any;
|
|
510
|
+
};
|
|
511
|
+
export type TypeFieldPointer<T extends WabeTypes> = {
|
|
512
|
+
type: "Pointer";
|
|
513
|
+
required?: boolean;
|
|
514
|
+
description?: string;
|
|
515
|
+
class: keyof T["types"];
|
|
516
|
+
};
|
|
517
|
+
export type TypeFieldRelation<T extends WabeTypes> = {
|
|
518
|
+
type: "Relation";
|
|
519
|
+
required?: boolean;
|
|
520
|
+
description?: string;
|
|
521
|
+
class: keyof T["types"];
|
|
522
|
+
};
|
|
523
|
+
export type TypeFieldFile = {
|
|
524
|
+
type: "File";
|
|
525
|
+
required?: boolean;
|
|
526
|
+
description?: string;
|
|
527
|
+
};
|
|
528
|
+
export type TypeFieldCustomScalars<T extends WabeTypes> = {
|
|
529
|
+
type: T["scalars"];
|
|
530
|
+
required?: boolean;
|
|
531
|
+
description?: string;
|
|
532
|
+
defaultValue?: any;
|
|
533
|
+
};
|
|
534
|
+
export type TypeFieldCustomEnums<T extends WabeTypes> = {
|
|
535
|
+
type: T["enums"];
|
|
536
|
+
required?: boolean;
|
|
537
|
+
description?: string;
|
|
538
|
+
defaultValue?: any;
|
|
539
|
+
};
|
|
540
|
+
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>;
|
|
541
|
+
export type SchemaFields<T extends WabeTypes> = Record<string, TypeField<T>>;
|
|
542
|
+
export type QueryResolver<T extends WabeTypes> = {
|
|
543
|
+
required?: boolean;
|
|
544
|
+
description?: string;
|
|
545
|
+
args?: SchemaFields<T>;
|
|
546
|
+
resolve: (...args: any) => any;
|
|
547
|
+
} & ({
|
|
548
|
+
type: WabePrimaryTypes;
|
|
549
|
+
} | {
|
|
550
|
+
type: "Object";
|
|
551
|
+
outputObject: ClassInterface<T>;
|
|
552
|
+
} | {
|
|
553
|
+
type: "Array";
|
|
554
|
+
typeValue: WabePrimaryTypes;
|
|
555
|
+
});
|
|
556
|
+
export type MutationResolver<T extends WabeTypes> = {
|
|
557
|
+
required?: boolean;
|
|
558
|
+
description?: string;
|
|
559
|
+
args?: {
|
|
560
|
+
input: SchemaFields<T>;
|
|
561
|
+
};
|
|
562
|
+
resolve: (...args: any) => any;
|
|
563
|
+
} & ({
|
|
564
|
+
type: WabePrimaryTypes;
|
|
565
|
+
} | {
|
|
566
|
+
type: "Object";
|
|
567
|
+
outputObject: ClassInterface<T>;
|
|
568
|
+
} | {
|
|
569
|
+
type: "Array";
|
|
570
|
+
typeValue: WabePrimaryTypes;
|
|
571
|
+
});
|
|
572
|
+
export type TypeResolver<T extends WabeTypes> = {
|
|
573
|
+
queries?: {
|
|
574
|
+
[key: string]: QueryResolver<T>;
|
|
575
|
+
};
|
|
576
|
+
mutations?: {
|
|
577
|
+
[key: string]: MutationResolver<T>;
|
|
578
|
+
};
|
|
579
|
+
};
|
|
580
|
+
export type PermissionsOperations = "create" | "read" | "update" | "delete";
|
|
581
|
+
export interface PermissionProperties {
|
|
582
|
+
requireAuthentication?: boolean;
|
|
583
|
+
/**
|
|
584
|
+
* An empty array means that none role is authorized (except root client)
|
|
585
|
+
*/
|
|
586
|
+
authorizedRoles?: Array<string>;
|
|
587
|
+
}
|
|
588
|
+
export type ClassPermissions = Partial<Record<PermissionsOperations, PermissionProperties>>;
|
|
589
|
+
export type SearchableFields = Array<string>;
|
|
590
|
+
export type ClassIndexes = Array<{
|
|
591
|
+
field: string;
|
|
592
|
+
order: "ASC" | "DESC";
|
|
593
|
+
unique?: boolean;
|
|
594
|
+
}>;
|
|
595
|
+
export interface ClassInterface<T extends WabeTypes> {
|
|
596
|
+
name: string;
|
|
597
|
+
fields: SchemaFields<T>;
|
|
598
|
+
description?: string;
|
|
599
|
+
permissions?: ClassPermissions;
|
|
600
|
+
searchableFields?: SearchableFields;
|
|
601
|
+
indexes?: ClassIndexes;
|
|
602
|
+
}
|
|
603
|
+
export interface ScalarInterface {
|
|
604
|
+
name: string;
|
|
605
|
+
description?: string;
|
|
606
|
+
parseValue?: (value: any) => any;
|
|
607
|
+
serialize?: (value: any) => any;
|
|
608
|
+
parseLiteral?: (ast: any) => any;
|
|
609
|
+
}
|
|
610
|
+
export interface EnumInterface {
|
|
611
|
+
name: string;
|
|
612
|
+
values: Record<string, string>;
|
|
613
|
+
description?: string;
|
|
614
|
+
}
|
|
615
|
+
export interface SchemaInterface<T extends WabeTypes> {
|
|
616
|
+
classes?: ClassInterface<T>[];
|
|
617
|
+
scalars?: ScalarInterface[];
|
|
618
|
+
enums?: EnumInterface[];
|
|
619
|
+
resolvers?: TypeResolver<T>;
|
|
620
|
+
}
|
|
621
|
+
export declare class Schema<T extends WabeTypes> {
|
|
622
|
+
schema: SchemaInterface<T>;
|
|
623
|
+
private config;
|
|
624
|
+
constructor(config: WabeConfig<T>);
|
|
625
|
+
defaultEnum(): EnumInterface[];
|
|
626
|
+
mergeResolvers(defaultResolvers: TypeResolver<T>): TypeResolver<T>;
|
|
627
|
+
defaultResolvers(): TypeResolver<T>;
|
|
628
|
+
sessionClass(): ClassInterface<T>;
|
|
629
|
+
roleClass(): ClassInterface<T>;
|
|
630
|
+
userClass(): ClassInterface<T>;
|
|
631
|
+
defaultFields(): SchemaFields<T>;
|
|
632
|
+
mergeClass(newClass: ClassInterface<T>[]): ClassInterface<T>[];
|
|
633
|
+
defaultClass(schema?: SchemaInterface<T>): ClassInterface<T>[];
|
|
634
|
+
}
|
|
635
|
+
export declare enum ProviderEnum {
|
|
636
|
+
google = "google",
|
|
637
|
+
x = "x"
|
|
638
|
+
}
|
|
639
|
+
export interface ProviderConfig {
|
|
640
|
+
clientId: string;
|
|
641
|
+
clientSecret: string;
|
|
642
|
+
}
|
|
643
|
+
export type AuthenticationEventsOptions<T> = {
|
|
644
|
+
input: T;
|
|
645
|
+
context: WabeContext<any>;
|
|
646
|
+
};
|
|
647
|
+
export type ProviderInterface<T = any> = {
|
|
648
|
+
onSignIn: (options: AuthenticationEventsOptions<T>) => Promise<{
|
|
649
|
+
user: Partial<User>;
|
|
650
|
+
oauth?: {
|
|
651
|
+
refreshToken: string;
|
|
652
|
+
accessToken: string;
|
|
653
|
+
accessTokenExpiresAt: Date;
|
|
654
|
+
refreshTokenExpiresAt: Date;
|
|
655
|
+
};
|
|
656
|
+
}>;
|
|
657
|
+
onSignUp: (options: AuthenticationEventsOptions<T>) => Promise<{
|
|
658
|
+
authenticationDataToSave: any;
|
|
659
|
+
}>;
|
|
660
|
+
};
|
|
661
|
+
export type SecondaryProviderInterface<T = any> = {
|
|
662
|
+
onSendChallenge: () => Promise<void>;
|
|
663
|
+
onVerifyChallenge: (options: T) => Promise<boolean>;
|
|
664
|
+
};
|
|
665
|
+
export type CustomAuthenticationMethods<T extends WabeTypes, U = ProviderInterface | SecondaryProviderInterface, K = SchemaFields<T>, W = SchemaFields<T>> = {
|
|
666
|
+
name: string;
|
|
667
|
+
input: K;
|
|
668
|
+
dataToStore?: W;
|
|
669
|
+
provider: U;
|
|
670
|
+
isSecondaryFactor?: boolean;
|
|
671
|
+
};
|
|
672
|
+
export type RoleConfig = Array<string>;
|
|
673
|
+
export interface SessionConfig {
|
|
674
|
+
/**
|
|
675
|
+
* The time in milliseconds that the access token will expire
|
|
676
|
+
*/
|
|
677
|
+
accessTokenExpiresIn?: number;
|
|
678
|
+
/**
|
|
679
|
+
* The time in milliseconds that the refresh token will expire
|
|
680
|
+
*/
|
|
681
|
+
refreshTokenExpiresIn?: number;
|
|
682
|
+
/**
|
|
683
|
+
* Set to true to automatically store the session tokens in cookies
|
|
684
|
+
*/
|
|
685
|
+
cookieSession?: boolean;
|
|
686
|
+
}
|
|
687
|
+
export interface AuthenticationConfig<T extends WabeTypes> {
|
|
688
|
+
session?: SessionConfig;
|
|
689
|
+
roles?: RoleConfig;
|
|
690
|
+
successRedirectPath?: string;
|
|
691
|
+
failureRedirectPath?: string;
|
|
692
|
+
providers?: Partial<Record<ProviderEnum, ProviderConfig>>;
|
|
693
|
+
customAuthenticationMethods?: CustomAuthenticationMethods<T>[];
|
|
694
|
+
}
|
|
695
|
+
export interface CreateTokenFromAuthorizationCodeOptions {
|
|
696
|
+
code: string;
|
|
697
|
+
}
|
|
698
|
+
export interface refreshTokenOptions {
|
|
699
|
+
refreshToken: string;
|
|
700
|
+
}
|
|
701
|
+
export interface Provider {
|
|
702
|
+
createTokenFromAuthorizationCode(options: CreateTokenFromAuthorizationCodeOptions): Promise<void>;
|
|
703
|
+
refreshToken(options: refreshTokenOptions): Promise<void>;
|
|
704
|
+
}
|
|
705
|
+
declare enum AuthenticationProvider$1 {
|
|
706
|
+
Google = "Google"
|
|
707
|
+
}
|
|
708
|
+
export interface WabeRoute {
|
|
709
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
710
|
+
path: string;
|
|
711
|
+
handler: WobeHandler<WobeCustomContext<any>>;
|
|
712
|
+
}
|
|
713
|
+
declare class HookObject<T extends WabeTypes, K = keyof T["types"]> {
|
|
714
|
+
className: string;
|
|
715
|
+
private newData;
|
|
716
|
+
private operationType;
|
|
717
|
+
context: WabeContext<T>;
|
|
718
|
+
object: Record<keyof WabeTypes["types"][T], any>;
|
|
719
|
+
constructor({ newData, className, operationType, context, object, }: {
|
|
720
|
+
className: K;
|
|
721
|
+
newData?: MutationData<T>;
|
|
722
|
+
operationType: OperationType;
|
|
723
|
+
context: WabeContext<T>;
|
|
724
|
+
object: Record<keyof WabeTypes["types"][T], any>;
|
|
725
|
+
});
|
|
726
|
+
getUser(): User | null | undefined;
|
|
727
|
+
isFieldUpdate(field: keyof WabeTypes["types"][T]): boolean | undefined;
|
|
728
|
+
upsertNewData(field: keyof WabeTypes["types"][T], value: any): void;
|
|
729
|
+
getNewData(): MutationData<T>;
|
|
730
|
+
}
|
|
731
|
+
export declare enum OperationType {
|
|
732
|
+
AfterCreate = "AfterCreate",
|
|
733
|
+
AfterUpdate = "afterUpdate",
|
|
734
|
+
AfterDelete = "afterDelete",
|
|
735
|
+
AfterRead = "afterRead",
|
|
736
|
+
BeforeCreate = "beforeInsert",
|
|
737
|
+
BeforeUpdate = "beforeUpdate",
|
|
738
|
+
BeforeDelete = "beforeDelete",
|
|
739
|
+
BeforeRead = "beforeRead"
|
|
740
|
+
}
|
|
741
|
+
export type Hook<T extends WabeTypes> = {
|
|
742
|
+
operationType: OperationType;
|
|
743
|
+
className?: T;
|
|
744
|
+
priority: number;
|
|
745
|
+
callback: (hookObject: HookObject<T>) => Promise<void> | void;
|
|
746
|
+
};
|
|
747
|
+
export type TypedNewData<T extends keyof WabeTypes["types"]> = Record<keyof WabeTypes["types"][T], any>;
|
|
748
|
+
export declare const _findHooksByPriority: <T extends unknown>({ className, operationType, priority, config, }: {
|
|
749
|
+
operationType: OperationType;
|
|
750
|
+
className: T;
|
|
751
|
+
priority: number;
|
|
752
|
+
config: WabeConfig<any>;
|
|
753
|
+
}) => Promise<Hook<any>[]>;
|
|
754
|
+
export declare const initializeHook: <T extends unknown>({ className, newData, context, }: {
|
|
755
|
+
className: T;
|
|
756
|
+
newData?: TypedNewData<any> | undefined;
|
|
757
|
+
context: WabeContext<any>;
|
|
758
|
+
}) => {
|
|
759
|
+
runOnSingleObject: ({ operationType, id, object: inputObject, }: {
|
|
760
|
+
operationType: OperationType;
|
|
761
|
+
id?: string | undefined;
|
|
762
|
+
object?: OutputType<any, any> | undefined;
|
|
763
|
+
}) => Promise<{
|
|
764
|
+
object: undefined;
|
|
765
|
+
newData: {};
|
|
766
|
+
} | {
|
|
767
|
+
object: OutputType<any, any>;
|
|
768
|
+
newData: MutationData<any>;
|
|
769
|
+
}>;
|
|
770
|
+
runOnMultipleObjects: ({ operationType, where, objects: inputObjects, }: {
|
|
771
|
+
operationType: OperationType;
|
|
772
|
+
where?: WhereType<any, any> | undefined;
|
|
773
|
+
objects?: OutputType<any, any>[] | undefined;
|
|
774
|
+
}) => Promise<{
|
|
775
|
+
objects: OutputType<any, any>[];
|
|
776
|
+
newData: MutationData<any>[];
|
|
777
|
+
}>;
|
|
778
|
+
};
|
|
779
|
+
export declare const getDefaultHooks: () => Hook<any>[];
|
|
780
|
+
export type DevWabeTypes = {
|
|
781
|
+
types: WabeSchemaTypes;
|
|
782
|
+
scalars: WabeSchemaScalars;
|
|
783
|
+
enums: WabeSchemaEnums;
|
|
784
|
+
};
|
|
785
|
+
export declare const generateCodegen: ({ schema, path, graphqlSchema, }: {
|
|
786
|
+
schema: SchemaInterface<any>;
|
|
787
|
+
path: string;
|
|
788
|
+
graphqlSchema: GraphQLSchema;
|
|
789
|
+
}) => Promise<void>;
|
|
790
|
+
/**
|
|
791
|
+
* A file adpater that upload a file and returns the url of the file
|
|
792
|
+
* @param file: File
|
|
793
|
+
* @returns The url of the uploaded file
|
|
794
|
+
*/
|
|
795
|
+
export type WabeFileAdapter = (file: File) => Promise<string>;
|
|
796
|
+
/**
|
|
797
|
+
* The file config contains the adapter to use to upload file
|
|
798
|
+
*/
|
|
799
|
+
export interface FileConfig {
|
|
800
|
+
adapter: WabeFileAdapter;
|
|
801
|
+
}
|
|
802
|
+
export interface WabeConfig<T extends WabeTypes> {
|
|
803
|
+
port: number;
|
|
804
|
+
schema?: SchemaInterface<T>;
|
|
805
|
+
database: DatabaseConfig;
|
|
806
|
+
codegen?: {
|
|
807
|
+
enabled: true;
|
|
808
|
+
path: string;
|
|
809
|
+
} | {
|
|
810
|
+
enabled?: false;
|
|
811
|
+
};
|
|
812
|
+
authentication?: AuthenticationConfig<T>;
|
|
813
|
+
routes?: WabeRoute[];
|
|
814
|
+
rootKey: string;
|
|
815
|
+
hooks?: Hook<any>[];
|
|
816
|
+
file?: FileConfig;
|
|
817
|
+
}
|
|
818
|
+
export type WabeTypes = {
|
|
819
|
+
types: Record<any, any>;
|
|
820
|
+
scalars: string;
|
|
821
|
+
enums: string;
|
|
822
|
+
};
|
|
823
|
+
export type WobeCustomContext<T extends WabeTypes> = {
|
|
824
|
+
wabe: WabeContext<T>;
|
|
825
|
+
};
|
|
826
|
+
export declare class Wabe<T extends WabeTypes> {
|
|
827
|
+
server: Wobe<WobeCustomContext<T>>;
|
|
828
|
+
config: WabeConfig<T>;
|
|
829
|
+
controllers: {
|
|
830
|
+
database: DatabaseController<T>;
|
|
831
|
+
};
|
|
832
|
+
constructor({ port, schema, database, authentication, rootKey, codegen, hooks, file, }: WabeConfig<T>);
|
|
833
|
+
loadAuthenticationMethods(): void;
|
|
834
|
+
loadHooks(): void;
|
|
835
|
+
loadDefaultRoutes(): void;
|
|
836
|
+
start(): Promise<void>;
|
|
837
|
+
close(): Promise<void>;
|
|
838
|
+
}
|
|
839
|
+
export declare const signInWithResolver: (_: any, { input, }: {
|
|
840
|
+
input: SignInWithInput;
|
|
841
|
+
}, context: WabeContext<DevWabeTypes>) => Promise<{
|
|
842
|
+
accessToken: null;
|
|
843
|
+
refreshToken: null;
|
|
844
|
+
id: string;
|
|
845
|
+
} | {
|
|
846
|
+
accessToken: string;
|
|
847
|
+
refreshToken: string;
|
|
848
|
+
id: string;
|
|
849
|
+
}>;
|
|
850
|
+
export declare const signUpWithResolver: (_: any, { input, }: {
|
|
851
|
+
input: SignUpWithInput;
|
|
852
|
+
}, context: WabeContext<any>) => Promise<{
|
|
853
|
+
accessToken: string;
|
|
854
|
+
refreshToken: string;
|
|
855
|
+
id: any;
|
|
856
|
+
}>;
|
|
857
|
+
export interface TokenResponseBody {
|
|
858
|
+
access_token: string;
|
|
859
|
+
token_type?: string;
|
|
860
|
+
expires_in?: number;
|
|
861
|
+
refresh_token?: string;
|
|
862
|
+
scope?: string;
|
|
863
|
+
}
|
|
864
|
+
export declare class OAuth2Client {
|
|
865
|
+
clientId: string;
|
|
866
|
+
private authorizeEndpoint;
|
|
867
|
+
private tokenEndpoint;
|
|
868
|
+
private redirectURI;
|
|
869
|
+
constructor(clientId: string, authorizeEndpoint: string, tokenEndpoint: string, redirectURI: string);
|
|
870
|
+
createAuthorizationURL(options?: {
|
|
871
|
+
state?: string;
|
|
872
|
+
codeVerifier?: string;
|
|
873
|
+
scopes?: string[];
|
|
874
|
+
}): Promise<URL>;
|
|
875
|
+
validateAuthorizationCode<_TokenResponseBody extends TokenResponseBody>(authorizationCode: string, options?: {
|
|
876
|
+
codeVerifier?: string;
|
|
877
|
+
credentials?: string;
|
|
878
|
+
authenticateWith?: "http_basic_auth" | "request_body";
|
|
879
|
+
}): Promise<_TokenResponseBody>;
|
|
880
|
+
refreshAccessToken<_TokenResponseBody extends TokenResponseBody>(refreshToken: string, options?: {
|
|
881
|
+
credentials?: string;
|
|
882
|
+
authenticateWith?: "http_basic_auth" | "request_body";
|
|
883
|
+
scopes?: string[];
|
|
884
|
+
}): Promise<_TokenResponseBody>;
|
|
885
|
+
_sendTokenRequest<_TokenResponseBody extends TokenResponseBody>(body: URLSearchParams, options?: {
|
|
886
|
+
credentials?: string;
|
|
887
|
+
authenticateWith?: "http_basic_auth" | "request_body";
|
|
888
|
+
}): Promise<_TokenResponseBody>;
|
|
889
|
+
}
|
|
890
|
+
export interface Tokens {
|
|
891
|
+
accessToken: string;
|
|
892
|
+
refreshToken?: string | null;
|
|
893
|
+
accessTokenExpiresAt?: Date;
|
|
894
|
+
refreshTokenExpiresAt?: Date | null;
|
|
895
|
+
idToken?: string;
|
|
896
|
+
}
|
|
897
|
+
export interface OAuth2ProviderWithPKCE {
|
|
898
|
+
createAuthorizationURL(state: string, codeVerifier: string): Promise<URL>;
|
|
899
|
+
validateAuthorizationCode(code: string, codeVerifier: string): Promise<Tokens>;
|
|
900
|
+
refreshAccessToken?(refreshToken: string): Promise<Tokens>;
|
|
901
|
+
}
|
|
902
|
+
export declare class Google implements OAuth2ProviderWithPKCE {
|
|
903
|
+
private client;
|
|
904
|
+
private clientSecret;
|
|
905
|
+
constructor(config: WabeConfig<any>);
|
|
906
|
+
createAuthorizationURL(state: string, codeVerifier: string, options?: {
|
|
907
|
+
scopes?: string[];
|
|
908
|
+
}): Promise<URL>;
|
|
909
|
+
validateAuthorizationCode(code: string, codeVerifier: string): Promise<Tokens>;
|
|
910
|
+
refreshAccessToken(refreshToken: string): Promise<Tokens>;
|
|
911
|
+
getUserInfo(accessToken: string, idToken: string): Promise<{
|
|
912
|
+
email: any;
|
|
913
|
+
verifiedEmail: any;
|
|
914
|
+
}>;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
export {
|
|
918
|
+
AuthenticationProvider$1 as AuthenticationProvider,
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
export {};
|