wabe 0.6.3 → 0.6.5

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.
Files changed (90) hide show
  1. package/README.md +2 -1
  2. package/dist/ai/index.d.ts +1 -0
  3. package/dist/ai/interface.d.ts +9 -0
  4. package/dist/authentication/OTP.d.ts +8 -0
  5. package/dist/authentication/Session.d.ts +21 -0
  6. package/dist/authentication/defaultAuthentication.d.ts +3 -0
  7. package/dist/authentication/index.d.ts +2 -0
  8. package/dist/authentication/interface.d.ts +118 -0
  9. package/dist/authentication/oauth/GitHub.d.ts +13 -0
  10. package/dist/authentication/oauth/Google.d.ts +13 -0
  11. package/dist/authentication/oauth/Oauth2Client.d.ts +33 -0
  12. package/dist/authentication/oauth/index.d.ts +2 -0
  13. package/dist/authentication/oauth/utils.d.ts +14 -0
  14. package/dist/authentication/providers/EmailOTP.d.ts +11 -0
  15. package/dist/authentication/providers/EmailPassword.d.ts +13 -0
  16. package/dist/authentication/providers/GitHub.d.ts +12 -0
  17. package/dist/authentication/providers/Google.d.ts +12 -0
  18. package/dist/authentication/providers/OAuth.d.ts +6 -0
  19. package/dist/authentication/providers/PhonePassword.d.ts +13 -0
  20. package/dist/authentication/providers/index.d.ts +5 -0
  21. package/dist/authentication/resolvers/refreshResolver.d.ts +1 -0
  22. package/dist/authentication/resolvers/signInWithResolver.d.ts +1 -0
  23. package/dist/authentication/resolvers/signOutResolver.d.ts +1 -0
  24. package/dist/authentication/resolvers/signUpWithResolver.d.ts +1 -0
  25. package/dist/authentication/resolvers/verifyChallenge.d.ts +1 -0
  26. package/dist/authentication/roles.d.ts +1 -0
  27. package/dist/authentication/srp/processSRPChallenge.d.ts +1 -0
  28. package/dist/authentication/srp/signInWithSRP.d.ts +1 -0
  29. package/dist/authentication/srp/signUpWithSRP.d.ts +1 -0
  30. package/dist/authentication/utils.d.ts +8 -0
  31. package/dist/cron/index.d.ts +32 -0
  32. package/dist/database/adapters/MongoAdapter.d.ts +64 -0
  33. package/dist/database/adapters/adaptersInterface.d.ts +263 -0
  34. package/dist/database/adapters/index.d.ts +2 -0
  35. package/dist/database/controllers/DatabaseController.d.ts +90 -0
  36. package/dist/database/controllers/index.d.ts +1 -0
  37. package/dist/database/index.d.ts +10 -0
  38. package/dist/email/DevAdapter.d.ts +4 -0
  39. package/dist/email/EmailController.d.ts +6 -0
  40. package/dist/email/index.d.ts +2 -0
  41. package/dist/email/interface.d.ts +35 -0
  42. package/dist/email/templates/sendOtpCode.d.ts +1 -0
  43. package/dist/files/FileController.d.ts +10 -0
  44. package/dist/files/FileDevAdapter.d.ts +8 -0
  45. package/dist/files/hookDeleteFile.d.ts +1 -0
  46. package/dist/files/hookReadFile.d.ts +1 -0
  47. package/dist/files/hookUploadFile.d.ts +2 -0
  48. package/dist/files/index.d.ts +2 -0
  49. package/dist/files/interface.d.ts +30 -0
  50. package/dist/graphql/GraphQLSchema.d.ts +75 -0
  51. package/dist/graphql/index.d.ts +2 -0
  52. package/dist/graphql/parser.d.ts +38 -0
  53. package/dist/graphql/pointerAndRelationFunction.d.ts +20 -0
  54. package/dist/graphql/resolvers.d.ts +20 -0
  55. package/dist/graphql/types.d.ts +18 -0
  56. package/dist/hooks/HookObject.d.ts +39 -0
  57. package/dist/hooks/authentication.d.ts +2 -0
  58. package/dist/hooks/defaultFields.d.ts +3 -0
  59. package/dist/hooks/deleteSession.d.ts +1 -0
  60. package/dist/hooks/index.d.ts +41 -0
  61. package/dist/hooks/permissions.d.ts +6 -0
  62. package/dist/hooks/protected.d.ts +3 -0
  63. package/dist/hooks/searchableFields.d.ts +3 -0
  64. package/dist/hooks/session.d.ts +3 -0
  65. package/dist/hooks/setEmail.d.ts +2 -0
  66. package/dist/hooks/setupAcl.d.ts +2 -0
  67. package/dist/index.d.ts +11 -1459
  68. package/dist/index.js +486 -76812
  69. package/dist/payment/DevAdapter.d.ts +17 -0
  70. package/dist/payment/PaymentController.d.ts +19 -0
  71. package/dist/payment/index.d.ts +2 -0
  72. package/dist/payment/interface.d.ts +235 -0
  73. package/dist/schema/Schema.d.ts +164 -0
  74. package/dist/schema/defaultResolvers.d.ts +7 -0
  75. package/dist/schema/index.d.ts +1 -0
  76. package/dist/schema/resolvers/meResolver.d.ts +1 -0
  77. package/dist/schema/resolvers/resetPassword.d.ts +1 -0
  78. package/dist/schema/resolvers/sendEmail.d.ts +1 -0
  79. package/dist/schema/resolvers/sendOtpCode.d.ts +1 -0
  80. package/dist/server/defaultHandlers.d.ts +1 -0
  81. package/dist/server/generateCodegen.d.ts +1 -0
  82. package/dist/server/index.d.ts +77 -0
  83. package/dist/server/routes/authHandler.d.ts +2 -0
  84. package/dist/server/routes/index.d.ts +8 -0
  85. package/dist/utils/export.d.ts +2 -0
  86. package/dist/utils/helper.d.ts +21 -0
  87. package/dist/utils/index.d.ts +17 -0
  88. package/generated/schema.graphql +126 -21
  89. package/generated/wabe.ts +135 -25
  90. package/package.json +8 -7
@@ -0,0 +1,263 @@
1
+ import type { WabeContext } from "../../server/interface";
2
+ import type { WabeTypes } from "../../server";
3
+ type IsScalar<T> = T extends string | number | boolean | Date ? true : false;
4
+ type IsArray<T> = T extends Array<any> ? true : false;
5
+ type IsObject<
6
+ T,
7
+ K extends WabeTypes
8
+ > = T extends object ? T extends K["types"][keyof K["types"]] ? false : true : false;
9
+ type ExtractType<
10
+ T extends WabeTypes,
11
+ ClassName extends keyof T["types"],
12
+ FieldName extends keyof T["types"][ClassName]
13
+ > = T["types"][ClassName][FieldName];
14
+ type ExtractWhereType<
15
+ T extends WabeTypes,
16
+ ClassName extends keyof T["where"],
17
+ FieldName extends keyof T["where"][ClassName]
18
+ > = T["where"][ClassName][FieldName];
19
+ type WhereScalar<T> = {
20
+ equalTo?: T
21
+ notEqualTo?: T
22
+ greaterThan?: T
23
+ lessThan?: T
24
+ greaterThanOrEqualTo?: T
25
+ lessThanOrEqualTo?: T
26
+ in?: T[]
27
+ notIn?: T[]
28
+ contains?: T
29
+ notContains?: T
30
+ };
31
+ type WhereObject<T> = { [P in keyof T] : IsScalar<T[P]> extends false ? WhereObject<Partial<T[P]>> : WhereScalar<T[P]> };
32
+ type WhereAggregation<
33
+ T extends WabeTypes,
34
+ K = keyof T["where"]
35
+ > = { [P in keyof T["where"][K]] : IsScalar<ExtractWhereType<T, K, P>> extends false ? WhereObject<Partial<ExtractWhereType<T, K, P>>> : WhereScalar<ExtractWhereType<T, K, P>> };
36
+ type WhereConditional<
37
+ T extends WabeTypes,
38
+ K = keyof T["where"]
39
+ > = {
40
+ OR?: Array<WhereType<T, K>>
41
+ AND?: Array<WhereType<T, K>>
42
+ };
43
+ export type WhereType<
44
+ T extends WabeTypes,
45
+ K = keyof T["where"]
46
+ > = Partial<WhereAggregation<T, K>> & WhereConditional<T, K>;
47
+ type SelectObject<
48
+ T,
49
+ K extends WabeTypes,
50
+ Depth extends number = 3
51
+ > = { [P in keyof T] : IsScalar<T[P]> extends true ? boolean : IsArray<T[P]> extends true ? T[P] extends Array<infer Item> ? (Depth extends 0 ? boolean : SelectObject<Partial<Item>, K, Decrement<Depth>>) | boolean : boolean : IsObject<[P], K> extends true ? (Depth extends 0 ? boolean : SelectObject<Partial<T[P]>, K, Decrement<Depth>>) | boolean : boolean };
52
+ type Decrement<N extends number> = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10][N];
53
+ export type SelectType<
54
+ T extends WabeTypes,
55
+ K extends keyof T["types"],
56
+ U extends keyof T["types"][K],
57
+ Depth extends number = 3
58
+ > = Partial<{ [P in U] : IsScalar<ExtractType<T, K, P>> extends true ? boolean : IsArray<ExtractType<T, K, P>> extends true ? ExtractType<T, K, P> extends Array<infer Item> ? (Depth extends 0 ? boolean : SelectObject<Partial<Item>, T, Decrement<Depth>>) | boolean : boolean : ExtractType<T, K, P> extends object ? (Depth extends 0 ? boolean : SelectObject<Partial<ExtractType<T, K, P>>, T, Decrement<Depth>>) | boolean : boolean }>;
59
+ export type OrderType<
60
+ T extends WabeTypes,
61
+ K extends keyof T["types"],
62
+ U extends keyof T["types"][K]
63
+ > = Record<U, "ASC" | "DESC">;
64
+ export type OutputType<
65
+ T extends WabeTypes,
66
+ K extends keyof T["types"],
67
+ U extends keyof T["types"][K]
68
+ > = (Pick<T["types"][K], U> & {
69
+ id: string
70
+ }) | null;
71
+ export interface AdapterOptions {
72
+ databaseUrl: string;
73
+ databaseName: string;
74
+ }
75
+ export type MutationData<
76
+ T extends WabeTypes,
77
+ K extends keyof T["types"],
78
+ U extends keyof T["types"][K]
79
+ > = Record<U, any>;
80
+ export interface CountOptions<
81
+ T extends WabeTypes,
82
+ K extends keyof T["types"]
83
+ > {
84
+ className: K;
85
+ where?: WhereType<T, K>;
86
+ context: WabeContext<any>;
87
+ }
88
+ export interface GetObjectOptions<
89
+ T extends WabeTypes,
90
+ K extends keyof T["types"],
91
+ U extends keyof T["types"][K]
92
+ > {
93
+ className: K;
94
+ id: string;
95
+ where?: WhereType<T, K>;
96
+ context: WabeContext<any>;
97
+ skipHooks?: boolean;
98
+ select?: SelectType<T, K, U>;
99
+ isGraphQLCall?: boolean;
100
+ }
101
+ export interface GetObjectsOptions<
102
+ T extends WabeTypes,
103
+ K extends keyof T["types"],
104
+ U extends keyof T["types"][K],
105
+ W extends keyof T["types"][K]
106
+ > {
107
+ className: K;
108
+ where?: WhereType<T, K>;
109
+ order?: OrderType<T, K, U>;
110
+ offset?: number;
111
+ first?: number;
112
+ context: WabeContext<any>;
113
+ skipHooks?: boolean;
114
+ select?: SelectType<T, K, W>;
115
+ isGraphQLCall?: boolean;
116
+ }
117
+ export interface CreateObjectOptions<
118
+ T extends WabeTypes,
119
+ K extends keyof T["types"],
120
+ U extends keyof T["types"][K],
121
+ W extends keyof T["types"][K]
122
+ > {
123
+ className: K;
124
+ data: MutationData<T, K, U>;
125
+ context: WabeContext<any>;
126
+ select?: SelectType<T, K, W>;
127
+ isGraphQLCall?: boolean;
128
+ }
129
+ export interface CreateObjectsOptions<
130
+ T extends WabeTypes,
131
+ K extends keyof T["types"],
132
+ U extends keyof T["types"][K],
133
+ W extends keyof T["types"][K],
134
+ X extends keyof T["types"][K]
135
+ > {
136
+ className: K;
137
+ data: Array<MutationData<T, K, U>>;
138
+ offset?: number;
139
+ first?: number;
140
+ order?: OrderType<T, U, X>;
141
+ context: WabeContext<any>;
142
+ select?: SelectType<T, K, W>;
143
+ isGraphQLCall?: boolean;
144
+ }
145
+ export interface UpdateObjectOptions<
146
+ T extends WabeTypes,
147
+ K extends keyof T["types"],
148
+ U extends keyof T["types"][K],
149
+ W extends keyof T["types"][K]
150
+ > {
151
+ className: K;
152
+ id: string;
153
+ where?: WhereType<T, K>;
154
+ data: MutationData<T, K, U>;
155
+ context: WabeContext<any>;
156
+ skipHooks?: boolean;
157
+ select?: SelectType<T, K, W>;
158
+ isGraphQLCall?: boolean;
159
+ }
160
+ export interface UpdateObjectsOptions<
161
+ T extends WabeTypes,
162
+ K extends keyof T["types"],
163
+ U extends keyof T["types"][K],
164
+ W extends keyof T["types"][K],
165
+ X extends keyof T["types"][K]
166
+ > {
167
+ className: K;
168
+ where: WhereType<T, K>;
169
+ order?: OrderType<T, K, X>;
170
+ data: MutationData<T, K, U>;
171
+ offset?: number;
172
+ first?: number;
173
+ context: WabeContext<any>;
174
+ skipHooks?: boolean;
175
+ select?: SelectType<T, K, W>;
176
+ isGraphQLCall?: boolean;
177
+ }
178
+ export interface DeleteObjectOptions<
179
+ T extends WabeTypes,
180
+ K extends keyof T["types"],
181
+ U extends keyof T["types"][K]
182
+ > {
183
+ className: K;
184
+ id: string;
185
+ where?: WhereType<T, K>;
186
+ context: WabeContext<any>;
187
+ select?: SelectType<T, K, U>;
188
+ isGraphQLCall?: boolean;
189
+ }
190
+ export interface DeleteObjectsOptions<
191
+ T extends WabeTypes,
192
+ K extends keyof T["types"],
193
+ U extends keyof T["types"][K],
194
+ W extends keyof T["types"][K]
195
+ > {
196
+ className: K;
197
+ where: WhereType<T, K>;
198
+ order?: OrderType<T, K, U>;
199
+ offset?: number;
200
+ first?: number;
201
+ context: WabeContext<any>;
202
+ select?: SelectType<T, K, W>;
203
+ isGraphQLCall?: boolean;
204
+ }
205
+ export interface DatabaseAdapter<T extends WabeTypes> {
206
+ connect(): Promise<any>;
207
+ close(): Promise<any>;
208
+ createClassIfNotExist(className: string, context: WabeContext<any>): Promise<any>;
209
+ clearDatabase(): Promise<void>;
210
+ count<
211
+ T extends WabeTypes,
212
+ K extends keyof T["types"]
213
+ >(params: CountOptions<T, K>): Promise<number>;
214
+ getObject<
215
+ K extends keyof T["types"],
216
+ U extends keyof T["types"][K]
217
+ >(params: GetObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
218
+ getObjects<
219
+ K extends keyof T["types"],
220
+ U extends keyof T["types"][K],
221
+ W extends keyof T["types"][K]
222
+ >(params: GetObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
223
+ createObject<
224
+ K extends keyof T["types"],
225
+ U extends keyof T["types"][K],
226
+ W extends keyof T["types"][K]
227
+ >(params: CreateObjectOptions<T, K, U, W>): Promise<{
228
+ id: string
229
+ }>;
230
+ createObjects<
231
+ K extends keyof T["types"],
232
+ U extends keyof T["types"][K],
233
+ W extends keyof T["types"][K],
234
+ X extends keyof T["types"][K]
235
+ >(params: CreateObjectsOptions<T, K, U, W, X>): Promise<Array<{
236
+ id: string
237
+ }>>;
238
+ updateObject<
239
+ K extends keyof T["types"],
240
+ U extends keyof T["types"][K],
241
+ W extends keyof T["types"][K]
242
+ >(params: UpdateObjectOptions<T, K, U, W>): Promise<{
243
+ id: string
244
+ }>;
245
+ updateObjects<
246
+ K extends keyof T["types"],
247
+ U extends keyof T["types"][K],
248
+ W extends keyof T["types"][K],
249
+ X extends keyof T["types"][K]
250
+ >(params: UpdateObjectsOptions<T, K, U, W, X>): Promise<Array<{
251
+ id: string
252
+ }>>;
253
+ deleteObject<
254
+ K extends keyof T["types"],
255
+ U extends keyof T["types"][K]
256
+ >(params: DeleteObjectOptions<T, K, U>): Promise<void>;
257
+ deleteObjects<
258
+ K extends keyof T["types"],
259
+ U extends keyof T["types"][K],
260
+ W extends keyof T["types"][K]
261
+ >(params: DeleteObjectsOptions<T, K, U, W>): Promise<void>;
262
+ }
263
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./MongoAdapter";
2
+ export * from "./adaptersInterface";
@@ -0,0 +1,90 @@
1
+ import type { WabeTypes } from "../..";
2
+ import type { WabeContext } from "../../server/interface";
3
+ import type { CountOptions, CreateObjectOptions, CreateObjectsOptions, DatabaseAdapter, DeleteObjectOptions, DeleteObjectsOptions, GetObjectOptions, GetObjectsOptions, OutputType, UpdateObjectOptions, UpdateObjectsOptions, WhereType } from "../adapters/adaptersInterface";
4
+ export type Select = Record<string, boolean>;
5
+ type SelectWithObject = Record<string, object | boolean>;
6
+ export declare class DatabaseController<T extends WabeTypes> {
7
+ adapter: DatabaseAdapter<T>;
8
+ constructor(adapter: DatabaseAdapter<T>);
9
+ _getSelectMinusPointersAndRelations({ className, context, select }: {
10
+ className: keyof T["types"]
11
+ context: WabeContext<T>
12
+ select?: SelectWithObject
13
+ }): {
14
+ pointers: Record<string, {
15
+ className: string
16
+ select: Select
17
+ }>
18
+ selectWithoutPointers: Select
19
+ };
20
+ _isRelationField({ pointerField, currentClassName, context, originClassName }: {
21
+ pointerField: string
22
+ originClassName: string
23
+ context: WabeContext<T>
24
+ currentClassName?: string
25
+ });
26
+ _isPointerField({ pointerField, currentClassName, context, originClassName }: {
27
+ originClassName: string
28
+ context: WabeContext<T>
29
+ pointerField: string
30
+ currentClassName?: string
31
+ });
32
+ _getWhereObjectWithPointerOrRelation<U extends keyof T["types"]>(className: U, where: WhereType<T, U>, context: WabeContext<T>);
33
+ _buildWhereWithACL<K extends keyof T["types"]>(where: WhereType<T, K>, context: WabeContext<T>, operation: "write" | "read"): WhereType<T, K>;
34
+ _getFinalObjectWithPointerAndRelation({ pointers, context, originClassName, object, isGraphQLCall }: {
35
+ originClassName: string
36
+ pointers: Record<string, {
37
+ className: string
38
+ select: Select
39
+ }>
40
+ context: WabeContext<any>
41
+ object: Record<string, any>
42
+ isGraphQLCall?: boolean
43
+ });
44
+ connect(): Promise<any>;
45
+ close(): Promise<any>;
46
+ createClassIfNotExist(className: string, context: WabeContext<T>): Promise<any>;
47
+ count<K extends keyof T["types"]>({ className, context, where }: CountOptions<T, K>): Promise<number>;
48
+ clearDatabase(): Promise<void>;
49
+ getObject<
50
+ K extends keyof T["types"],
51
+ U extends keyof T["types"][K]
52
+ >({ select, className, context, skipHooks, id, where, isGraphQLCall }: GetObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
53
+ getObjects<
54
+ K extends keyof T["types"],
55
+ U extends keyof T["types"][K],
56
+ W extends keyof T["types"][K]
57
+ >({ className, select, context, where, skipHooks, first, offset, order, isGraphQLCall }: GetObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
58
+ createObject<
59
+ K extends keyof T["types"],
60
+ U extends keyof T["types"][K],
61
+ W extends keyof T["types"][K]
62
+ >({ className, context, data, select, isGraphQLCall }: CreateObjectOptions<T, K, U, W>): Promise<OutputType<T, K, W>>;
63
+ createObjects<
64
+ K extends keyof T["types"],
65
+ U extends keyof T["types"][K],
66
+ W extends keyof T["types"][K],
67
+ X extends keyof T["types"][K]
68
+ >({ data, select, className, context, first, offset, order, isGraphQLCall }: CreateObjectsOptions<T, K, U, W, X>): Promise<OutputType<T, K, W>[]>;
69
+ updateObject<
70
+ K extends keyof T["types"],
71
+ U extends keyof T["types"][K],
72
+ W extends keyof T["types"][K]
73
+ >({ id, className, context, data, select, skipHooks, isGraphQLCall }: UpdateObjectOptions<T, K, U, W>): Promise<OutputType<T, K, W>>;
74
+ updateObjects<
75
+ K extends keyof T["types"],
76
+ U extends keyof T["types"][K],
77
+ W extends keyof T["types"][K],
78
+ X extends keyof T["types"][K]
79
+ >({ className, where, context, select, data, first, offset, order, skipHooks, isGraphQLCall }: UpdateObjectsOptions<T, K, U, W, X>): Promise<OutputType<T, K, W>[]>;
80
+ deleteObject<
81
+ K extends keyof T["types"],
82
+ U extends keyof T["types"][K]
83
+ >({ context, className, id, select, isGraphQLCall }: DeleteObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
84
+ deleteObjects<
85
+ K extends keyof T["types"],
86
+ U extends keyof T["types"][K],
87
+ W extends keyof T["types"][K]
88
+ >({ className, context, select, where, first, offset, order, isGraphQLCall }: DeleteObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
89
+ }
90
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./DatabaseController";
@@ -0,0 +1,10 @@
1
+ export declare enum DatabaseEnum {
2
+ Mongo = "mongo",
3
+ }
4
+ export interface DatabaseConfig {
5
+ type: DatabaseEnum;
6
+ url: string;
7
+ name: string;
8
+ }
9
+ export * from "./adapters";
10
+ export * from "./controllers";
@@ -0,0 +1,4 @@
1
+ import type { EmailAdapter } from "./interface";
2
+ export declare class EmailDevAdapter implements EmailAdapter {
3
+ send();
4
+ }
@@ -0,0 +1,6 @@
1
+ import type { EmailAdapter, EmailSendOptions } from "./interface";
2
+ export declare class EmailController implements EmailAdapter {
3
+ adapter: EmailAdapter;
4
+ constructor(adapter: EmailAdapter);
5
+ send(options: EmailSendOptions);
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./interface";
2
+ export * from "./DevAdapter";
@@ -0,0 +1,35 @@
1
+ export type HtmlTemplates = {
2
+ sendOTPCode: {
3
+ fn: (options: {
4
+ otp: string
5
+ }) => string | Promise<string>
6
+ subject: string
7
+ }
8
+ };
9
+ export interface EmailSendOptions {
10
+ from: string;
11
+ to: Array<string>;
12
+ subject: string;
13
+ node?: React.ReactNode;
14
+ html?: string;
15
+ text?: string;
16
+ }
17
+ export interface EmailAdapter {
18
+ /**
19
+ * Send an email using the provided adapter
20
+ * @param options Mail options (expeditor, recipient, subject ...)
21
+ * @return The id of the email sended, throw an error if something wrong
22
+ */
23
+ send(options: EmailSendOptions): Promise<string>;
24
+ }
25
+ /**
26
+ * Configuration for the email in Wabe
27
+ * @property adapter The adapter to use to send emails
28
+ * @property mainEmail The email to use as sender for emails sent by Wabe
29
+ * @property templates The html templates to use for a specific email. If not provided, Wabe will use the default templates
30
+ */
31
+ export interface EmailConfig {
32
+ adapter: EmailAdapter;
33
+ mainEmail?: string;
34
+ htmlTemplates?: HtmlTemplates;
35
+ }
@@ -0,0 +1 @@
1
+ export declare const sendOtpCodeTemplate: (otp: string) => string;
@@ -0,0 +1,10 @@
1
+ import type { Wabe } from "../server";
2
+ import type { FileAdapter, ReadFileOptions } from "./interface";
3
+ export declare class FileController implements FileAdapter {
4
+ adapter: FileAdapter;
5
+ private wabe;
6
+ constructor(adapter: FileAdapter, wabe: Wabe<any>);
7
+ uploadFile(file: File | Blob);
8
+ readFile(fileName: string, options?: ReadFileOptions);
9
+ deleteFile(fileName: string);
10
+ }
@@ -0,0 +1,8 @@
1
+ import type { FileAdapter, ReadFileOptions } from ".";
2
+ export declare class FileDevAdapter implements FileAdapter {
3
+ private basePath;
4
+ private rootPath;
5
+ uploadFile(file: File | Blob): Promise<void>;
6
+ readFile(fileName: string, options?: ReadFileOptions): Promise<string | null>;
7
+ deleteFile(fileName: string): Promise<void>;
8
+ }
@@ -0,0 +1 @@
1
+ export declare const defaultAfterDeleteFile: unknown;
@@ -0,0 +1 @@
1
+ export declare const defaultAfterReadFile: unknown;
@@ -0,0 +1,2 @@
1
+ export declare const defaultBeforeCreateUpload: unknown;
2
+ export declare const defaultBeforeUpdateUpload: unknown;
@@ -0,0 +1,2 @@
1
+ export * from "./FileDevAdapter";
2
+ export * from "./interface";
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The file config contains the adapter to use to upload file
3
+ * @param adapter: FileAdapter
4
+ * @param urlCacheInSeconds: number Number of seconds to cache the url, equal to the number of seconds the url will be valid
5
+ * @param devDirectory: string The directory where the files will be uploaded
6
+ */
7
+ export interface FileConfig {
8
+ adapter: FileAdapter;
9
+ urlCacheInSeconds?: number;
10
+ devDirectory?: string;
11
+ }
12
+ export interface ReadFileOptions {
13
+ urlExpiresIn?: number;
14
+ port?: number;
15
+ }
16
+ export interface FileAdapter {
17
+ /**
18
+ * Upload a file and returns the url of the file
19
+ * @param file: File
20
+ */
21
+ uploadFile(file: File | Blob): Promise<void>;
22
+ /**
23
+ * Read a file and returns the url of the file
24
+ * @param fileName: string
25
+ * @param urlExpiresIn: number Number of seconds to expire the url
26
+ * @returns The url of file or null if the file doesn't exist
27
+ */
28
+ readFile(fileName: string, options?: ReadFileOptions): Promise<string | null> | string | null;
29
+ deleteFile(fileName: string): Promise<void>;
30
+ }
@@ -0,0 +1,75 @@
1
+ import { GraphQLEnumType, type GraphQLFieldConfig, GraphQLInputObjectType, GraphQLObjectType, type GraphQLOutputType } from "graphql";
2
+ import type { ClassInterface, MutationResolver, QueryResolver, Schema, SchemaFields } from "../schema";
3
+ import type { DevWabeTypes } from "../utils/helper";
4
+ import { type GraphqlParserFactory } from "./parser";
5
+ type AllPossibleObject = "object" | "inputObject" | "whereInputObject" | "connectionObject" | "pointerInputObject" | "relationInputObject" | "updateInputObject" | "createInputObject" | "orderEnumType";
6
+ export type AllObjects = Record<string, Partial<Record<AllPossibleObject, any>>>;
7
+ export declare class GraphQLSchema {
8
+ private schemas;
9
+ private allObjects;
10
+ constructor(schemas: Schema<any>);
11
+ createSchema(): {};
12
+ createFileObjects(): unknown;
13
+ createScalars();
14
+ createOrderEnumType(wabeClass: ClassInterface<DevWabeTypes>);
15
+ createEnums();
16
+ createObject({ wabeClass, graphqlParser }: {
17
+ wabeClass: ClassInterface<DevWabeTypes>
18
+ graphqlParser: GraphqlParserFactory<DevWabeTypes>
19
+ });
20
+ createPointerInputObject({ wabeClass, inputCreateFields }: {
21
+ wabeClass: ClassInterface<DevWabeTypes>
22
+ inputCreateFields: GraphQLInputObjectType
23
+ });
24
+ createRelationInputObject({ wabeClass, inputCreateFields }: {
25
+ wabeClass: ClassInterface<DevWabeTypes>
26
+ inputCreateFields: GraphQLInputObjectType
27
+ });
28
+ createInputObject({ wabeClass, graphqlParser }: {
29
+ wabeClass: ClassInterface<DevWabeTypes>
30
+ graphqlParser: GraphqlParserFactory<DevWabeTypes>
31
+ });
32
+ createCreateInputObject({ wabeClass, graphqlParser }: {
33
+ wabeClass: ClassInterface<DevWabeTypes>
34
+ graphqlParser: GraphqlParserFactory<DevWabeTypes>
35
+ });
36
+ createUpdateInputObject({ wabeClass, graphqlParser }: {
37
+ wabeClass: ClassInterface<DevWabeTypes>
38
+ graphqlParser: GraphqlParserFactory<DevWabeTypes>
39
+ });
40
+ createWhereInputObject({ wabeClass, graphqlParser }: {
41
+ wabeClass: ClassInterface<DevWabeTypes>
42
+ graphqlParser: GraphqlParserFactory<DevWabeTypes>
43
+ });
44
+ createConnectionObject({ object, wabeClass }: {
45
+ object: GraphQLObjectType
46
+ wabeClass: ClassInterface<DevWabeTypes>
47
+ });
48
+ createCompleteObject(graphqlParser: GraphqlParserFactory<DevWabeTypes>, wabeClass: ClassInterface<DevWabeTypes>);
49
+ _getGraphQLOutputType(currentQueryOrMutation: QueryResolver<DevWabeTypes> | MutationResolver<DevWabeTypes>, graphqlParser: GraphqlParserFactory<DevWabeTypes>, currentArgs: SchemaFields<DevWabeTypes>): GraphQLOutputType | undefined;
50
+ createCustomMutations({ resolvers, graphqlParser }: {
51
+ resolvers: Record<string, MutationResolver<DevWabeTypes>>
52
+ graphqlParser: GraphqlParserFactory<DevWabeTypes>
53
+ });
54
+ createCustomQueries({ resolvers, graphqlParser }: {
55
+ resolvers: Record<string, QueryResolver<DevWabeTypes>>
56
+ graphqlParser: GraphqlParserFactory<DevWabeTypes>
57
+ });
58
+ createDefaultQueries({ className, whereInputType, object, connectionObject, orderEnumType }: {
59
+ className: string
60
+ whereInputType: GraphQLInputObjectType
61
+ object: GraphQLObjectType
62
+ connectionObject: GraphQLObjectType
63
+ orderEnumType: GraphQLEnumType
64
+ }): Record<string, GraphQLFieldConfig<any, any, any>>;
65
+ createDefaultMutations({ className, object, defaultUpdateInputType, defaultCreateInputType, whereInputType, connectionObject, orderEnumType }: {
66
+ className: string
67
+ defaultUpdateInputType: GraphQLInputObjectType
68
+ defaultCreateInputType: GraphQLInputObjectType
69
+ whereInputType: GraphQLInputObjectType
70
+ object: GraphQLObjectType
71
+ connectionObject: GraphQLObjectType
72
+ orderEnumType: GraphQLEnumType
73
+ }): Record<string, GraphQLFieldConfig<any, any, any>>;
74
+ }
75
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./types";
2
+ export * from "./GraphQLSchema";
@@ -0,0 +1,38 @@
1
+ import { type GraphQLEnumType, GraphQLInputObjectType, type GraphQLScalarType } from "graphql";
2
+ import { type AllObjects } from "../graphql";
3
+ import type { ClassInterface, SchemaFields, WabePrimaryTypes } from "../schema";
4
+ import type { WabeTypes } from "../server";
5
+ import type { DevWabeTypes } from "../utils/helper";
6
+ type GraphqlObjectType = "Object" | "InputObject" | "CreateFieldsInput" | "UpdateFieldsInput" | "WhereInputObject";
7
+ type ParseObjectOptions = {
8
+ required?: boolean
9
+ description?: string
10
+ objectToParse: ClassInterface<any>
11
+ nameOfTheObject: string
12
+ };
13
+ export declare const templateScalarType: Record<WabePrimaryTypes, GraphQLScalarType>;
14
+ export declare const templateWhereInput: Record<WabePrimaryTypes | "Array", GraphQLInputObjectType>;
15
+ interface GraphqlParserFactoryOptions {
16
+ graphqlObjectType: GraphqlObjectType;
17
+ allObjects: AllObjects;
18
+ schemaFields: SchemaFields<DevWabeTypes>;
19
+ }
20
+ interface GraphqlParserConstructorOptions {
21
+ scalars: GraphQLScalarType[];
22
+ enums: GraphQLEnumType[];
23
+ }
24
+ export type GraphqlParserFactory<T extends WabeTypes> = (options: GraphqlParserFactoryOptions) => {
25
+ _parseWabeObject(options: ParseObjectOptions): any
26
+ _parseWabeWhereInputObject(options: ParseObjectOptions): any
27
+ _parseWabeInputObject(options: ParseObjectOptions): any
28
+ _parseWabeUpdateInputObject(options: ParseObjectOptions): any
29
+ getGraphqlType(options: {
30
+ type: WabePrimaryTypes | "Array" | T["enums"] | T["scalars"]
31
+ typeValue?: WabePrimaryTypes
32
+ isWhereType?: boolean
33
+ }): any
34
+ getGraphqlFields(nameOfTheObject: string): any
35
+ };
36
+ export type GraphqlParserConstructor = <T extends WabeTypes>(options: GraphqlParserConstructorOptions) => GraphqlParserFactory<T>;
37
+ export declare const GraphqlParser: GraphqlParserConstructor;
38
+ export {};
@@ -0,0 +1,20 @@
1
+ type CreateAndLink = any;
2
+ type Link = string;
3
+ type Unlink = boolean;
4
+ type Add = Array<string>;
5
+ type Remove = Array<string>;
6
+ type CreateAndAdd = Array<any>;
7
+ export type TypeOfExecution = "create" | "update" | "updateMany";
8
+ export type InputFields = Record<string, {
9
+ createAndLink?: CreateAndLink
10
+ link?: Link
11
+ unlink?: Unlink
12
+ add?: Add
13
+ remove?: Remove
14
+ createAndAdd?: CreateAndAdd
15
+ } | string>;
16
+ export declare const createAndLink: unknown;
17
+ export declare const createAndAdd: unknown;
18
+ export declare const add: unknown;
19
+ export declare const remove: unknown;
20
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { SelectionSetNode } from "graphql";
2
+ import type { WabeContext } from "../server/interface";
3
+ export declare const extractFieldsFromSetNode: (selectionSet: SelectionSetNode, className: string) => Record<string, any>;
4
+ export declare const getFieldsOfClassName: ({ fields, className, context }: {
5
+ fields: string[]
6
+ className: string
7
+ context: WabeContext<any>
8
+ }) => {
9
+ classFields: string[]
10
+ othersFields: string[]
11
+ };
12
+ export declare const executeRelationOnFields: unknown;
13
+ export declare const queryForOneObject: unknown;
14
+ export declare const queryForMultipleObject: unknown;
15
+ export declare const mutationToCreateObject: unknown;
16
+ export declare const mutationToCreateMultipleObjects: unknown;
17
+ export declare const mutationToUpdateObject: unknown;
18
+ export declare const mutationToUpdateMultipleObjects: unknown;
19
+ export declare const mutationToDeleteObject: unknown;
20
+ export declare const mutationToDeleteMultipleObjects: unknown;