wabe 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -60,44 +60,54 @@ export type User = {
60
60
  age?: number;
61
61
  email?: string;
62
62
  acl?: ACLObject;
63
- createdAt?: Date;
64
- updatedAt?: Date;
63
+ createdAt?: string;
64
+ updatedAt?: string;
65
65
  search?: Array<string>;
66
66
  authentication?: Authentication;
67
67
  provider?: AuthenticationProvider;
68
68
  isOauth?: boolean;
69
69
  verifiedEmail?: boolean;
70
70
  role?: Role;
71
- sessions?: Array<string>;
71
+ sessions?: Array<_Session>;
72
+ };
73
+ export type Experience = {
74
+ jobTitle: string;
75
+ companyName: string;
76
+ startDate: string;
77
+ endDate: string;
78
+ achievements?: Array<string>;
72
79
  };
73
80
  export type Post = {
74
81
  id: string;
75
82
  name: string;
76
83
  test2?: RoleEnum;
84
+ test3: Array<User>;
85
+ test4: User;
86
+ experiences?: Array<Experience>;
77
87
  acl?: ACLObject;
78
- createdAt?: Date;
79
- updatedAt?: Date;
88
+ createdAt?: string;
89
+ updatedAt?: string;
80
90
  search?: Array<string>;
81
91
  };
82
92
  export type _Session = {
83
93
  id: string;
84
94
  user: User;
85
95
  accessToken: string;
86
- accessTokenExpiresAt: Date;
96
+ accessTokenExpiresAt: string;
87
97
  refreshToken?: string;
88
- refreshTokenExpiresAt: Date;
98
+ refreshTokenExpiresAt: string;
89
99
  acl?: ACLObject;
90
- createdAt?: Date;
91
- updatedAt?: Date;
100
+ createdAt?: string;
101
+ updatedAt?: string;
92
102
  search?: Array<string>;
93
103
  };
94
104
  export type Role = {
95
105
  id: string;
96
106
  name: string;
97
- users?: Array<string>;
107
+ users?: Array<User>;
98
108
  acl?: ACLObject;
99
- createdAt?: Date;
100
- updatedAt?: Date;
109
+ createdAt?: string;
110
+ updatedAt?: string;
101
111
  search?: Array<string>;
102
112
  };
103
113
  export type _InternalConfig = {
@@ -106,8 +116,8 @@ export type _InternalConfig = {
106
116
  configValue: string;
107
117
  description?: string;
108
118
  acl?: ACLObject;
109
- createdAt?: Date;
110
- updatedAt?: Date;
119
+ createdAt?: string;
120
+ updatedAt?: string;
111
121
  search?: Array<string>;
112
122
  };
113
123
  export type SignInWithInput = {
@@ -217,11 +227,27 @@ export type WhereConditional<T extends WabeTypes, K extends keyof T["types"]> =
217
227
  AND?: Array<WhereType<T, K>>;
218
228
  };
219
229
  export type WhereType<T extends WabeTypes, K extends keyof T["types"]> = Partial<WhereAggregation<T, K>> & WhereConditional<T, K>;
220
- export type SelectObject<T, K extends WabeTypes> = {
221
- [P in keyof T]: IsScalar<T[P]> | IsArray<T[P]> | IsObject<T[P], K> extends false ? SelectObject<Partial<T[P]>, K> | boolean : boolean;
222
- };
223
- export type SelectType<T extends WabeTypes, K extends keyof T["types"], U extends keyof T["types"][K]> = Partial<{
224
- [P in U]: IsScalar<ExtractType<T, K, P>> | IsArray<ExtractType<T, K, P>> | IsObject<ExtractType<T, K, P>, T> extends false ? SelectObject<Partial<ExtractType<T, K, P>>, T> | boolean : boolean;
230
+ export type SelectObject<T, K extends WabeTypes, Depth extends number = 3> = {
231
+ [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<[
232
+ P
233
+ ], K> extends true ? (Depth extends 0 ? boolean : SelectObject<Partial<T[P]>, K, Decrement<Depth>>) | boolean : boolean;
234
+ };
235
+ export type Decrement<N extends number> = [
236
+ -1,
237
+ 0,
238
+ 1,
239
+ 2,
240
+ 3,
241
+ 4,
242
+ 5,
243
+ 6,
244
+ 7,
245
+ 8,
246
+ 9,
247
+ 10
248
+ ][N];
249
+ export type SelectType<T extends WabeTypes, K extends keyof T["types"], U extends keyof T["types"][K], Depth extends number = 3> = Partial<{
250
+ [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;
225
251
  }>;
226
252
  export type OrderType<T extends WabeTypes, K extends keyof T["types"], U extends keyof T["types"][K]> = Record<U, "ASC" | "DESC">;
227
253
  export type OutputType<T extends WabeTypes, K extends keyof T["types"], U extends keyof T["types"][K]> = (Pick<T["types"][K], U> & {
@@ -244,6 +270,7 @@ export interface GetObjectOptions<T extends WabeTypes, K extends keyof T["types"
244
270
  context: WabeContext<any>;
245
271
  skipHooks?: boolean;
246
272
  select?: SelectType<T, K, U>;
273
+ isGraphQLCall?: boolean;
247
274
  }
248
275
  export interface GetObjectsOptions<T extends WabeTypes, K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]> {
249
276
  className: K;
@@ -254,12 +281,14 @@ export interface GetObjectsOptions<T extends WabeTypes, K extends keyof T["types
254
281
  context: WabeContext<any>;
255
282
  skipHooks?: boolean;
256
283
  select?: SelectType<T, K, W>;
284
+ isGraphQLCall?: boolean;
257
285
  }
258
286
  export interface CreateObjectOptions<T extends WabeTypes, K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]> {
259
287
  className: K;
260
288
  data: MutationData<T, K, U>;
261
289
  context: WabeContext<any>;
262
290
  select?: SelectType<T, K, W>;
291
+ isGraphQLCall?: boolean;
263
292
  }
264
293
  export interface CreateObjectsOptions<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]> {
265
294
  className: K;
@@ -269,6 +298,7 @@ export interface CreateObjectsOptions<T extends WabeTypes, K extends keyof T["ty
269
298
  order?: OrderType<T, U, X>;
270
299
  context: WabeContext<any>;
271
300
  select?: SelectType<T, K, W>;
301
+ isGraphQLCall?: boolean;
272
302
  }
273
303
  export interface UpdateObjectOptions<T extends WabeTypes, K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]> {
274
304
  className: K;
@@ -278,6 +308,7 @@ export interface UpdateObjectOptions<T extends WabeTypes, K extends keyof T["typ
278
308
  context: WabeContext<any>;
279
309
  skipHooks?: boolean;
280
310
  select?: SelectType<T, K, W>;
311
+ isGraphQLCall?: boolean;
281
312
  }
282
313
  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]> {
283
314
  className: K;
@@ -289,6 +320,7 @@ export interface UpdateObjectsOptions<T extends WabeTypes, K extends keyof T["ty
289
320
  context: WabeContext<any>;
290
321
  skipHooks?: boolean;
291
322
  select?: SelectType<T, K, W>;
323
+ isGraphQLCall?: boolean;
292
324
  }
293
325
  export interface DeleteObjectOptions<T extends WabeTypes, K extends keyof T["types"], U extends keyof T["types"][K]> {
294
326
  className: K;
@@ -296,6 +328,7 @@ export interface DeleteObjectOptions<T extends WabeTypes, K extends keyof T["typ
296
328
  where?: WhereType<T, K>;
297
329
  context: WabeContext<any>;
298
330
  select?: SelectType<T, K, U>;
331
+ isGraphQLCall?: boolean;
299
332
  }
300
333
  export interface DeleteObjectsOptions<T extends WabeTypes, K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]> {
301
334
  className: K;
@@ -305,6 +338,7 @@ export interface DeleteObjectsOptions<T extends WabeTypes, K extends keyof T["ty
305
338
  first?: number;
306
339
  context: WabeContext<any>;
307
340
  select?: SelectType<T, K, W>;
341
+ isGraphQLCall?: boolean;
308
342
  }
309
343
  export interface DatabaseAdapter<T extends WabeTypes> {
310
344
  connect(): Promise<any>;
@@ -537,7 +571,7 @@ export declare class DatabaseController<T extends WabeTypes> {
537
571
  AND?: WhereType<T, U>[] | undefined;
538
572
  }>;
539
573
  _buildWhereWithACL<K extends keyof T["types"]>(where: WhereType<T, K>, context: WabeContext<T>, operation: "write" | "read"): WhereType<T, K>;
540
- _getFinalObjectWithPointerAndRelation({ pointers, context, originClassName, object, }: {
574
+ _getFinalObjectWithPointerAndRelation({ pointers, context, originClassName, object, isGraphQLCall, }: {
541
575
  originClassName: string;
542
576
  pointers: Record<string, {
543
577
  className: string;
@@ -545,20 +579,21 @@ export declare class DatabaseController<T extends WabeTypes> {
545
579
  }>;
546
580
  context: WabeContext<any>;
547
581
  object: Record<string, any>;
582
+ isGraphQLCall?: boolean;
548
583
  }): Promise<Record<string, any>>;
549
584
  connect(): Promise<any>;
550
585
  close(): Promise<any>;
551
586
  createClassIfNotExist(className: string, context: WabeContext<T>): Promise<any>;
552
587
  count<K extends keyof T["types"]>(params: CountOptions<T, K>): Promise<number>;
553
588
  clearDatabase(): Promise<void>;
554
- getObject<K extends keyof T["types"], U extends keyof T["types"][K]>({ select, className, context, skipHooks, id, where, }: GetObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
555
- getObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>({ className, select, context, where, skipHooks, first, offset, order, }: GetObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
556
- createObject<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>({ className, context, data, select, }: CreateObjectOptions<T, K, U, W>): Promise<OutputType<T, K, W>>;
557
- 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, select, className, context, first, offset, order, }: CreateObjectsOptions<T, K, U, W, X>): Promise<OutputType<T, K, W>[]>;
558
- updateObject<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>({ id, className, context, data, select, skipHooks, }: UpdateObjectOptions<T, K, U, W>): Promise<OutputType<T, K, W>>;
559
- 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, select, data, first, offset, order, skipHooks, }: UpdateObjectsOptions<T, K, U, W, X>): Promise<OutputType<T, K, W>[]>;
560
- deleteObject<K extends keyof T["types"], U extends keyof T["types"][K]>({ context, className, id, select, }: DeleteObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
561
- deleteObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>({ className, context, select, where, first, offset, order, }: DeleteObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
589
+ getObject<K extends keyof T["types"], U extends keyof T["types"][K]>({ select, className, context, skipHooks, id, where, isGraphQLCall, }: GetObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
590
+ getObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>({ className, select, context, where, skipHooks, first, offset, order, isGraphQLCall, }: GetObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
591
+ createObject<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>({ className, context, data, select, isGraphQLCall, }: CreateObjectOptions<T, K, U, W>): Promise<OutputType<T, K, W>>;
592
+ 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, select, className, context, first, offset, order, isGraphQLCall, }: CreateObjectsOptions<T, K, U, W, X>): Promise<OutputType<T, K, W>[]>;
593
+ updateObject<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>({ id, className, context, data, select, skipHooks, isGraphQLCall, }: UpdateObjectOptions<T, K, U, W>): Promise<OutputType<T, K, W>>;
594
+ 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, select, data, first, offset, order, skipHooks, isGraphQLCall, }: UpdateObjectsOptions<T, K, U, W, X>): Promise<OutputType<T, K, W>[]>;
595
+ deleteObject<K extends keyof T["types"], U extends keyof T["types"][K]>({ context, className, id, select, isGraphQLCall, }: DeleteObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
596
+ deleteObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>({ className, context, select, where, first, offset, order, isGraphQLCall, }: DeleteObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
562
597
  }
563
598
  export declare enum DatabaseEnum {
564
599
  Mongo = "mongo"
@@ -905,23 +940,25 @@ export declare const generateCodegen: ({ schema, path, graphqlSchema, }: {
905
940
  }) => Promise<void>;
906
941
  export declare class FileDevAdapter implements FileAdapter {
907
942
  private basePath;
908
- rootPath: string;
909
- constructor(basePath: string);
943
+ private rootPath;
910
944
  uploadFile(file: File | Blob): Promise<void>;
911
- readFile(fileName: string): Promise<string | null>;
945
+ readFile(fileName: string, options?: ReadFileOptions): Promise<string | null>;
912
946
  deleteFile(fileName: string): Promise<void>;
913
947
  }
914
948
  /**
915
949
  * The file config contains the adapter to use to upload file
916
950
  * @param adapter: FileAdapter
917
951
  * @param urlCacheInSeconds: number Number of seconds to cache the url, equal to the number of seconds the url will be valid
952
+ * @param devDirectory: string The directory where the files will be uploaded
918
953
  */
919
954
  export interface FileConfig {
920
955
  adapter: FileAdapter;
921
956
  urlCacheInSeconds?: number;
957
+ devDirectory?: string;
922
958
  }
923
959
  export interface ReadFileOptions {
924
960
  urlExpiresIn?: number;
961
+ port?: number;
925
962
  }
926
963
  export interface FileAdapter {
927
964
  /**
@@ -1249,9 +1286,10 @@ export interface AIConfig {
1249
1286
  }
1250
1287
  declare class FileController implements FileAdapter {
1251
1288
  adapter: FileAdapter;
1252
- constructor(adapter: FileAdapter);
1289
+ private wabe;
1290
+ constructor(adapter: FileAdapter, wabe: Wabe<any>);
1253
1291
  uploadFile(file: File | Blob): Promise<void>;
1254
- readFile(fileName: string): string | Promise<string | null> | null;
1292
+ readFile(fileName: string, options?: ReadFileOptions): string | Promise<string | null> | null;
1255
1293
  deleteFile(fileName: string): Promise<void>;
1256
1294
  }
1257
1295
  export type SecurityConfig = {