wabe 0.6.9 → 0.6.10

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 (158) hide show
  1. package/README.md +138 -32
  2. package/bucket/b.txt +1 -0
  3. package/dev/index.ts +215 -0
  4. package/dist/authentication/Session.d.ts +4 -1
  5. package/dist/authentication/interface.d.ts +16 -0
  6. package/dist/email/interface.d.ts +1 -1
  7. package/dist/graphql/resolvers.d.ts +4 -2
  8. package/dist/hooks/index.d.ts +1 -0
  9. package/dist/index.d.ts +0 -1
  10. package/dist/index.js +8713 -8867
  11. package/dist/server/index.d.ts +4 -2
  12. package/dist/utils/crypto.d.ts +7 -0
  13. package/dist/utils/helper.d.ts +4 -1
  14. package/generated/schema.graphql +16 -14
  15. package/generated/wabe.ts +4 -4
  16. package/package.json +15 -15
  17. package/src/authentication/OTP.test.ts +69 -0
  18. package/src/authentication/OTP.ts +66 -0
  19. package/src/authentication/Session.test.ts +665 -0
  20. package/src/authentication/Session.ts +529 -0
  21. package/src/authentication/defaultAuthentication.ts +214 -0
  22. package/src/authentication/index.ts +3 -0
  23. package/src/authentication/interface.ts +157 -0
  24. package/src/authentication/oauth/GitHub.test.ts +105 -0
  25. package/src/authentication/oauth/GitHub.ts +133 -0
  26. package/src/authentication/oauth/Google.test.ts +105 -0
  27. package/src/authentication/oauth/Google.ts +110 -0
  28. package/src/authentication/oauth/Oauth2Client.test.ts +225 -0
  29. package/src/authentication/oauth/Oauth2Client.ts +140 -0
  30. package/src/authentication/oauth/index.ts +2 -0
  31. package/src/authentication/oauth/utils.test.ts +35 -0
  32. package/src/authentication/oauth/utils.ts +28 -0
  33. package/src/authentication/providers/EmailOTP.test.ts +138 -0
  34. package/src/authentication/providers/EmailOTP.ts +93 -0
  35. package/src/authentication/providers/EmailPassword.test.ts +187 -0
  36. package/src/authentication/providers/EmailPassword.ts +130 -0
  37. package/src/authentication/providers/EmailPasswordSRP.test.ts +206 -0
  38. package/src/authentication/providers/EmailPasswordSRP.ts +184 -0
  39. package/src/authentication/providers/GitHub.ts +30 -0
  40. package/src/authentication/providers/Google.ts +30 -0
  41. package/src/authentication/providers/OAuth.test.ts +185 -0
  42. package/src/authentication/providers/OAuth.ts +112 -0
  43. package/src/authentication/providers/PhonePassword.test.ts +187 -0
  44. package/src/authentication/providers/PhonePassword.ts +129 -0
  45. package/src/authentication/providers/QRCodeOTP.test.ts +79 -0
  46. package/src/authentication/providers/QRCodeOTP.ts +65 -0
  47. package/src/authentication/providers/index.ts +6 -0
  48. package/src/authentication/resolvers/refreshResolver.test.ts +37 -0
  49. package/src/authentication/resolvers/refreshResolver.ts +20 -0
  50. package/src/authentication/resolvers/signInWithResolver.inte.test.ts +59 -0
  51. package/src/authentication/resolvers/signInWithResolver.test.ts +307 -0
  52. package/src/authentication/resolvers/signInWithResolver.ts +102 -0
  53. package/src/authentication/resolvers/signOutResolver.test.ts +41 -0
  54. package/src/authentication/resolvers/signOutResolver.ts +22 -0
  55. package/src/authentication/resolvers/signUpWithResolver.test.ts +186 -0
  56. package/src/authentication/resolvers/signUpWithResolver.ts +69 -0
  57. package/src/authentication/resolvers/verifyChallenge.test.ts +136 -0
  58. package/src/authentication/resolvers/verifyChallenge.ts +69 -0
  59. package/src/authentication/roles.test.ts +59 -0
  60. package/src/authentication/roles.ts +40 -0
  61. package/src/authentication/utils.test.ts +99 -0
  62. package/src/authentication/utils.ts +43 -0
  63. package/src/cache/InMemoryCache.test.ts +62 -0
  64. package/src/cache/InMemoryCache.ts +45 -0
  65. package/src/cron/index.test.ts +17 -0
  66. package/src/cron/index.ts +46 -0
  67. package/src/database/DatabaseController.test.ts +625 -0
  68. package/src/database/DatabaseController.ts +983 -0
  69. package/src/database/index.test.ts +1230 -0
  70. package/src/database/index.ts +9 -0
  71. package/src/database/interface.ts +312 -0
  72. package/src/email/DevAdapter.ts +8 -0
  73. package/src/email/EmailController.test.ts +29 -0
  74. package/src/email/EmailController.ts +13 -0
  75. package/src/email/index.ts +2 -0
  76. package/src/email/interface.ts +36 -0
  77. package/src/email/templates/sendOtpCode.ts +120 -0
  78. package/src/file/FileController.ts +28 -0
  79. package/src/file/FileDevAdapter.ts +54 -0
  80. package/src/file/hookDeleteFile.ts +27 -0
  81. package/src/file/hookReadFile.ts +70 -0
  82. package/src/file/hookUploadFile.ts +53 -0
  83. package/src/file/index.test.ts +979 -0
  84. package/src/file/index.ts +2 -0
  85. package/src/file/interface.ts +42 -0
  86. package/src/graphql/GraphQLSchema.test.ts +4399 -0
  87. package/src/graphql/GraphQLSchema.ts +928 -0
  88. package/src/graphql/index.ts +2 -0
  89. package/src/graphql/parseGraphqlSchema.ts +94 -0
  90. package/src/graphql/parser.test.ts +217 -0
  91. package/src/graphql/parser.ts +566 -0
  92. package/src/graphql/pointerAndRelationFunction.ts +200 -0
  93. package/src/graphql/resolvers.ts +467 -0
  94. package/src/graphql/tests/aggregation.test.ts +1123 -0
  95. package/src/graphql/tests/e2e.test.ts +596 -0
  96. package/src/graphql/tests/scalars.test.ts +250 -0
  97. package/src/graphql/types.ts +219 -0
  98. package/src/hooks/HookObject.test.ts +122 -0
  99. package/src/hooks/HookObject.ts +168 -0
  100. package/src/hooks/authentication.ts +76 -0
  101. package/src/hooks/createUser.test.ts +77 -0
  102. package/src/hooks/createUser.ts +10 -0
  103. package/src/hooks/defaultFields.test.ts +187 -0
  104. package/src/hooks/defaultFields.ts +40 -0
  105. package/src/hooks/deleteSession.test.ts +181 -0
  106. package/src/hooks/deleteSession.ts +20 -0
  107. package/src/hooks/hashFieldHook.test.ts +163 -0
  108. package/src/hooks/hashFieldHook.ts +97 -0
  109. package/src/hooks/index.test.ts +207 -0
  110. package/src/hooks/index.ts +430 -0
  111. package/src/hooks/permissions.test.ts +424 -0
  112. package/src/hooks/permissions.ts +113 -0
  113. package/src/hooks/protected.test.ts +551 -0
  114. package/src/hooks/protected.ts +72 -0
  115. package/src/hooks/searchableFields.test.ts +166 -0
  116. package/src/hooks/searchableFields.ts +98 -0
  117. package/src/hooks/session.test.ts +138 -0
  118. package/src/hooks/session.ts +78 -0
  119. package/src/hooks/setEmail.test.ts +216 -0
  120. package/src/hooks/setEmail.ts +35 -0
  121. package/src/hooks/setupAcl.test.ts +589 -0
  122. package/src/hooks/setupAcl.ts +29 -0
  123. package/src/index.ts +9 -0
  124. package/src/schema/Schema.test.ts +484 -0
  125. package/src/schema/Schema.ts +795 -0
  126. package/src/schema/defaultResolvers.ts +94 -0
  127. package/src/schema/index.ts +1 -0
  128. package/src/schema/resolvers/meResolver.test.ts +62 -0
  129. package/src/schema/resolvers/meResolver.ts +14 -0
  130. package/src/schema/resolvers/newFile.ts +0 -0
  131. package/src/schema/resolvers/resetPassword.test.ts +345 -0
  132. package/src/schema/resolvers/resetPassword.ts +64 -0
  133. package/src/schema/resolvers/sendEmail.test.ts +118 -0
  134. package/src/schema/resolvers/sendEmail.ts +21 -0
  135. package/src/schema/resolvers/sendOtpCode.test.ts +153 -0
  136. package/src/schema/resolvers/sendOtpCode.ts +52 -0
  137. package/src/security.test.ts +3461 -0
  138. package/src/server/defaultSessionHandler.test.ts +66 -0
  139. package/src/server/defaultSessionHandler.ts +115 -0
  140. package/src/server/generateCodegen.ts +476 -0
  141. package/src/server/index.test.ts +552 -0
  142. package/src/server/index.ts +354 -0
  143. package/src/server/interface.ts +11 -0
  144. package/src/server/routes/authHandler.ts +187 -0
  145. package/src/server/routes/index.ts +40 -0
  146. package/src/utils/crypto.test.ts +41 -0
  147. package/src/utils/crypto.ts +121 -0
  148. package/src/utils/export.ts +13 -0
  149. package/src/utils/helper.ts +195 -0
  150. package/src/utils/index.test.ts +11 -0
  151. package/src/utils/index.ts +201 -0
  152. package/src/utils/preload.ts +8 -0
  153. package/src/utils/testHelper.ts +117 -0
  154. package/tsconfig.json +32 -0
  155. package/bunfig.toml +0 -4
  156. package/dist/ai/index.d.ts +0 -1
  157. package/dist/ai/interface.d.ts +0 -9
  158. /package/dist/server/{defaultHandlers.d.ts → defaultSessionHandler.d.ts} +0 -0
@@ -0,0 +1,1123 @@
1
+ import {
2
+ beforeAll,
3
+ afterAll,
4
+ describe,
5
+ it,
6
+ expect,
7
+ beforeEach,
8
+ afterEach,
9
+ } from 'bun:test'
10
+ import { type GraphQLClient, gql } from 'graphql-request'
11
+ import type { Wabe } from '../../server'
12
+ import { type DevWabeTypes, getGraphqlClient } from '../../utils/helper'
13
+ import { setupTests, closeTests } from '../../utils/testHelper'
14
+
15
+ const graphql = {
16
+ users: gql`
17
+ query users($where: UserWhereInput) {
18
+ users(where: $where) {
19
+ edges {
20
+ node {
21
+ id
22
+ name
23
+ age
24
+ isAdmin
25
+ floatValue
26
+ }
27
+ }
28
+ }
29
+ }
30
+ `,
31
+ createUsers: gql`
32
+ mutation createUsers($input: CreateUsersInput!) {
33
+ createUsers(input: $input) {
34
+ edges {
35
+ node {
36
+ id
37
+ name
38
+ age
39
+ isAdmin
40
+ floatValue
41
+ }
42
+ }
43
+ }
44
+ }
45
+ `,
46
+ }
47
+
48
+ describe('GraphQL : aggregation', () => {
49
+ let wabe: Wabe<DevWabeTypes>
50
+ let port: number
51
+ let client: GraphQLClient
52
+
53
+ const now = new Date()
54
+
55
+ beforeAll(async () => {
56
+ const setup = await setupTests()
57
+ wabe = setup.wabe
58
+ port = setup.port
59
+ client = getGraphqlClient(port)
60
+ })
61
+
62
+ beforeEach(async () => {
63
+ await client.request<any>(graphql.createUsers, {
64
+ input: {
65
+ fields: [
66
+ {
67
+ name: 'Lucas',
68
+ age: 20,
69
+ isAdmin: true,
70
+ floatValue: 1.5,
71
+ birthDate: now,
72
+ arrayValue: ['a', 'b'],
73
+ email: 'lucas@mail.fr',
74
+ },
75
+ {
76
+ name: 'Jeanne',
77
+ age: 18,
78
+ isAdmin: false,
79
+ floatValue: 2.5,
80
+ birthDate: new Date(Date.now() + 100000),
81
+ arrayValue: ['c', 'd'],
82
+ email: 'jean.doe@mail.fr',
83
+ },
84
+ ],
85
+ },
86
+ })
87
+ })
88
+
89
+ afterEach(async () => {
90
+ await wabe.controllers.database.clearDatabase()
91
+ })
92
+
93
+ afterAll(async () => {
94
+ await closeTests(wabe)
95
+ })
96
+
97
+ it("should support Array's aggregation", async () => {
98
+ expect(
99
+ await client.request<any>(graphql.users, {
100
+ where: {
101
+ arrayValue: { contains: ['a'] },
102
+ },
103
+ }),
104
+ ).toEqual({
105
+ users: {
106
+ edges: [
107
+ {
108
+ node: {
109
+ id: expect.anything(),
110
+ name: 'Lucas',
111
+ age: 20,
112
+ isAdmin: true,
113
+ floatValue: 1.5,
114
+ },
115
+ },
116
+ ],
117
+ },
118
+ })
119
+
120
+ expect(
121
+ await client.request<any>(graphql.users, {
122
+ where: {
123
+ arrayValue: { notContains: 'a' },
124
+ },
125
+ }),
126
+ ).toEqual({
127
+ users: {
128
+ edges: [
129
+ {
130
+ node: {
131
+ id: expect.anything(),
132
+ name: 'Jeanne',
133
+ age: 18,
134
+ isAdmin: false,
135
+ floatValue: 2.5,
136
+ },
137
+ },
138
+ ],
139
+ },
140
+ })
141
+
142
+ expect(
143
+ await client.request<any>(graphql.users, {
144
+ where: {
145
+ arrayValue: { equalTo: ['a', 'b'] },
146
+ },
147
+ }),
148
+ ).toEqual({
149
+ users: {
150
+ edges: [
151
+ {
152
+ node: {
153
+ id: expect.anything(),
154
+ name: 'Lucas',
155
+ age: 20,
156
+ isAdmin: true,
157
+ floatValue: 1.5,
158
+ },
159
+ },
160
+ ],
161
+ },
162
+ })
163
+
164
+ expect(
165
+ await client.request<any>(graphql.users, {
166
+ where: {
167
+ arrayValue: { notEqualTo: ['a', 'b'] },
168
+ },
169
+ }),
170
+ ).toEqual({
171
+ users: {
172
+ edges: [
173
+ {
174
+ node: {
175
+ id: expect.anything(),
176
+ name: 'Jeanne',
177
+ age: 18,
178
+ isAdmin: false,
179
+ floatValue: 2.5,
180
+ },
181
+ },
182
+ ],
183
+ },
184
+ })
185
+
186
+ expect(
187
+ await client.request<any>(graphql.users, {
188
+ where: {
189
+ arrayValue: { equalTo: ['z', 'w'] },
190
+ },
191
+ }),
192
+ ).toEqual({
193
+ users: { edges: [] },
194
+ })
195
+
196
+ expect(
197
+ await client.request<any>(graphql.users, {
198
+ where: {
199
+ arrayValue: { contains: ['z'] },
200
+ },
201
+ }),
202
+ ).toEqual({
203
+ users: { edges: [] },
204
+ })
205
+ })
206
+
207
+ it("should support DateScalarType's aggregation", async () => {
208
+ expect(
209
+ await client.request<any>(graphql.users, {
210
+ where: {
211
+ birthDate: { equalTo: now },
212
+ },
213
+ }),
214
+ ).toEqual({
215
+ users: {
216
+ edges: [
217
+ {
218
+ node: {
219
+ id: expect.anything(),
220
+ name: 'Lucas',
221
+ age: 20,
222
+ isAdmin: true,
223
+ floatValue: 1.5,
224
+ },
225
+ },
226
+ ],
227
+ },
228
+ })
229
+
230
+ expect(
231
+ await client.request<any>(graphql.users, {
232
+ where: {
233
+ birthDate: { notEqualTo: now },
234
+ },
235
+ }),
236
+ ).toEqual({
237
+ users: {
238
+ edges: [
239
+ {
240
+ node: {
241
+ id: expect.anything(),
242
+ name: 'Jeanne',
243
+ age: 18,
244
+ isAdmin: false,
245
+ floatValue: 2.5,
246
+ },
247
+ },
248
+ ],
249
+ },
250
+ })
251
+
252
+ expect(
253
+ await client.request<any>(graphql.users, {
254
+ where: {
255
+ birthDate: { lessThan: new Date(now.getTime() + 1000) },
256
+ },
257
+ }),
258
+ ).toEqual({
259
+ users: {
260
+ edges: [
261
+ {
262
+ node: {
263
+ id: expect.anything(),
264
+ name: 'Lucas',
265
+ age: 20,
266
+ isAdmin: true,
267
+ floatValue: 1.5,
268
+ },
269
+ },
270
+ ],
271
+ },
272
+ })
273
+
274
+ expect(
275
+ await client.request<any>(graphql.users, {
276
+ where: {
277
+ birthDate: { lessThanOrEqualTo: now },
278
+ },
279
+ }),
280
+ ).toEqual({
281
+ users: {
282
+ edges: [
283
+ {
284
+ node: {
285
+ id: expect.anything(),
286
+ name: 'Lucas',
287
+ age: 20,
288
+ isAdmin: true,
289
+ floatValue: 1.5,
290
+ },
291
+ },
292
+ ],
293
+ },
294
+ })
295
+
296
+ expect(
297
+ await client.request<any>(graphql.users, {
298
+ where: {
299
+ birthDate: { greaterThan: now },
300
+ },
301
+ }),
302
+ ).toEqual({
303
+ users: {
304
+ edges: [
305
+ {
306
+ node: {
307
+ id: expect.anything(),
308
+ name: 'Jeanne',
309
+ age: 18,
310
+ isAdmin: false,
311
+ floatValue: 2.5,
312
+ },
313
+ },
314
+ ],
315
+ },
316
+ })
317
+
318
+ expect(
319
+ await client.request<any>(graphql.users, {
320
+ where: {
321
+ birthDate: { greaterThanOrEqualTo: now },
322
+ },
323
+ }),
324
+ ).toEqual({
325
+ users: {
326
+ edges: expect.arrayContaining([
327
+ {
328
+ node: {
329
+ id: expect.anything(),
330
+ name: 'Lucas',
331
+ age: 20,
332
+ isAdmin: true,
333
+ floatValue: 1.5,
334
+ },
335
+ },
336
+ {
337
+ node: {
338
+ id: expect.anything(),
339
+ name: 'Jeanne',
340
+ age: 18,
341
+ isAdmin: false,
342
+ floatValue: 2.5,
343
+ },
344
+ },
345
+ ]),
346
+ },
347
+ })
348
+
349
+ expect(
350
+ await client.request<any>(graphql.users, {
351
+ where: {
352
+ birthDate: { in: [now] },
353
+ },
354
+ }),
355
+ ).toEqual({
356
+ users: {
357
+ edges: [
358
+ {
359
+ node: {
360
+ id: expect.anything(),
361
+ name: 'Lucas',
362
+ age: 20,
363
+ isAdmin: true,
364
+ floatValue: 1.5,
365
+ },
366
+ },
367
+ ],
368
+ },
369
+ })
370
+
371
+ expect(
372
+ await client.request<any>(graphql.users, {
373
+ where: {
374
+ birthDate: { notIn: [now] },
375
+ },
376
+ }),
377
+ ).toEqual({
378
+ users: {
379
+ edges: [
380
+ {
381
+ node: {
382
+ id: expect.anything(),
383
+ name: 'Jeanne',
384
+ age: 18,
385
+ isAdmin: false,
386
+ floatValue: 2.5,
387
+ },
388
+ },
389
+ ],
390
+ },
391
+ })
392
+ })
393
+
394
+ it("should support EmailScalayType's aggregation", async () => {
395
+ expect(
396
+ await client.request<any>(graphql.users, {
397
+ where: {
398
+ email: { equalTo: 'lucas@mail.fr' },
399
+ },
400
+ }),
401
+ ).toEqual({
402
+ users: {
403
+ edges: [
404
+ {
405
+ node: {
406
+ id: expect.anything(),
407
+ name: 'Lucas',
408
+ age: 20,
409
+ isAdmin: true,
410
+ floatValue: 1.5,
411
+ },
412
+ },
413
+ ],
414
+ },
415
+ })
416
+
417
+ expect(
418
+ await client.request<any>(graphql.users, {
419
+ where: {
420
+ email: { notEqualTo: 'lucas@mail.fr' },
421
+ },
422
+ }),
423
+ ).toEqual({
424
+ users: {
425
+ edges: [
426
+ {
427
+ node: {
428
+ id: expect.anything(),
429
+ name: 'Jeanne',
430
+ age: 18,
431
+ isAdmin: false,
432
+ floatValue: 2.5,
433
+ },
434
+ },
435
+ ],
436
+ },
437
+ })
438
+
439
+ expect(
440
+ await client.request<any>(graphql.users, {
441
+ where: {
442
+ email: { in: ['lucas@mail.fr'] },
443
+ },
444
+ }),
445
+ ).toEqual({
446
+ users: {
447
+ edges: [
448
+ {
449
+ node: {
450
+ id: expect.anything(),
451
+ name: 'Lucas',
452
+ age: 20,
453
+ isAdmin: true,
454
+ floatValue: 1.5,
455
+ },
456
+ },
457
+ ],
458
+ },
459
+ })
460
+
461
+ expect(
462
+ await client.request<any>(graphql.users, {
463
+ where: {
464
+ email: { notIn: ['lucas@mail.fr'] },
465
+ },
466
+ }),
467
+ ).toEqual({
468
+ users: {
469
+ edges: [
470
+ {
471
+ node: {
472
+ id: expect.anything(),
473
+ name: 'Jeanne',
474
+ age: 18,
475
+ isAdmin: false,
476
+ floatValue: 2.5,
477
+ },
478
+ },
479
+ ],
480
+ },
481
+ })
482
+ })
483
+
484
+ it("should support Int's aggregation", async () => {
485
+ expect(
486
+ await client.request<any>(graphql.users, {
487
+ where: {
488
+ age: { equalTo: 20 },
489
+ },
490
+ }),
491
+ ).toEqual({
492
+ users: {
493
+ edges: [
494
+ {
495
+ node: {
496
+ id: expect.anything(),
497
+ name: 'Lucas',
498
+ age: 20,
499
+ isAdmin: true,
500
+ floatValue: 1.5,
501
+ },
502
+ },
503
+ ],
504
+ },
505
+ })
506
+
507
+ expect(
508
+ await client.request<any>(graphql.users, {
509
+ where: {
510
+ age: { notEqualTo: 20 },
511
+ },
512
+ }),
513
+ ).toEqual({
514
+ users: {
515
+ edges: [
516
+ {
517
+ node: {
518
+ id: expect.anything(),
519
+ name: 'Jeanne',
520
+ age: 18,
521
+ isAdmin: false,
522
+ floatValue: 2.5,
523
+ },
524
+ },
525
+ ],
526
+ },
527
+ })
528
+
529
+ expect(
530
+ await client.request<any>(graphql.users, {
531
+ where: {
532
+ age: { lessThan: 20 },
533
+ },
534
+ }),
535
+ ).toEqual({
536
+ users: {
537
+ edges: [
538
+ {
539
+ node: {
540
+ id: expect.anything(),
541
+ name: 'Jeanne',
542
+ age: 18,
543
+ isAdmin: false,
544
+ floatValue: 2.5,
545
+ },
546
+ },
547
+ ],
548
+ },
549
+ })
550
+
551
+ expect(
552
+ await client.request<any>(graphql.users, {
553
+ where: {
554
+ age: { lessThanOrEqualTo: 20 },
555
+ },
556
+ }),
557
+ ).toEqual({
558
+ users: {
559
+ edges: expect.arrayContaining([
560
+ {
561
+ node: {
562
+ id: expect.anything(),
563
+ name: 'Lucas',
564
+ age: 20,
565
+ isAdmin: true,
566
+ floatValue: 1.5,
567
+ },
568
+ },
569
+ {
570
+ node: {
571
+ id: expect.anything(),
572
+ name: 'Jeanne',
573
+ age: 18,
574
+ isAdmin: false,
575
+ floatValue: 2.5,
576
+ },
577
+ },
578
+ ]),
579
+ },
580
+ })
581
+
582
+ expect(
583
+ await client.request<any>(graphql.users, {
584
+ where: {
585
+ age: { greaterThan: 18 },
586
+ },
587
+ }),
588
+ ).toEqual({
589
+ users: {
590
+ edges: [
591
+ {
592
+ node: {
593
+ id: expect.anything(),
594
+ name: 'Lucas',
595
+ age: 20,
596
+ isAdmin: true,
597
+ floatValue: 1.5,
598
+ },
599
+ },
600
+ ],
601
+ },
602
+ })
603
+
604
+ expect(
605
+ await client.request<any>(graphql.users, {
606
+ where: {
607
+ age: { greaterThanOrEqualTo: 18 },
608
+ },
609
+ }),
610
+ ).toEqual({
611
+ users: {
612
+ edges: expect.arrayContaining([
613
+ {
614
+ node: {
615
+ id: expect.anything(),
616
+ name: 'Lucas',
617
+ age: 20,
618
+ isAdmin: true,
619
+ floatValue: 1.5,
620
+ },
621
+ },
622
+ {
623
+ node: {
624
+ id: expect.anything(),
625
+ name: 'Jeanne',
626
+ age: 18,
627
+ isAdmin: false,
628
+ floatValue: 2.5,
629
+ },
630
+ },
631
+ ]),
632
+ },
633
+ })
634
+
635
+ expect(
636
+ await client.request<any>(graphql.users, {
637
+ where: {
638
+ age: { in: [20] },
639
+ },
640
+ }),
641
+ ).toEqual({
642
+ users: {
643
+ edges: [
644
+ {
645
+ node: {
646
+ id: expect.anything(),
647
+ name: 'Lucas',
648
+ age: 20,
649
+ isAdmin: true,
650
+ floatValue: 1.5,
651
+ },
652
+ },
653
+ ],
654
+ },
655
+ })
656
+
657
+ expect(
658
+ await client.request<any>(graphql.users, {
659
+ where: {
660
+ age: { notIn: [20] },
661
+ },
662
+ }),
663
+ ).toEqual({
664
+ users: {
665
+ edges: [
666
+ {
667
+ node: {
668
+ id: expect.anything(),
669
+ name: 'Jeanne',
670
+ age: 18,
671
+ isAdmin: false,
672
+ floatValue: 2.5,
673
+ },
674
+ },
675
+ ],
676
+ },
677
+ })
678
+ })
679
+
680
+ it("should support Boolean's aggregation", async () => {
681
+ expect(
682
+ await client.request<any>(graphql.users, {
683
+ where: {
684
+ isAdmin: { equalTo: true },
685
+ },
686
+ }),
687
+ ).toEqual({
688
+ users: {
689
+ edges: [
690
+ {
691
+ node: {
692
+ id: expect.anything(),
693
+ name: 'Lucas',
694
+ age: 20,
695
+ isAdmin: true,
696
+ floatValue: 1.5,
697
+ },
698
+ },
699
+ ],
700
+ },
701
+ })
702
+
703
+ expect(
704
+ await client.request<any>(graphql.users, {
705
+ where: {
706
+ isAdmin: { notEqualTo: true },
707
+ },
708
+ }),
709
+ ).toEqual({
710
+ users: {
711
+ edges: [
712
+ {
713
+ node: {
714
+ id: expect.anything(),
715
+ name: 'Jeanne',
716
+ age: 18,
717
+ isAdmin: false,
718
+ floatValue: 2.5,
719
+ },
720
+ },
721
+ ],
722
+ },
723
+ })
724
+
725
+ expect(
726
+ await client.request<any>(graphql.users, {
727
+ where: {
728
+ isAdmin: { in: [true] },
729
+ },
730
+ }),
731
+ ).toEqual({
732
+ users: {
733
+ edges: [
734
+ {
735
+ node: {
736
+ id: expect.anything(),
737
+ name: 'Lucas',
738
+ age: 20,
739
+ isAdmin: true,
740
+ floatValue: 1.5,
741
+ },
742
+ },
743
+ ],
744
+ },
745
+ })
746
+
747
+ expect(
748
+ await client.request<any>(graphql.users, {
749
+ where: {
750
+ isAdmin: { notIn: [true] },
751
+ },
752
+ }),
753
+ ).toEqual({
754
+ users: {
755
+ edges: [
756
+ {
757
+ node: {
758
+ id: expect.anything(),
759
+ name: 'Jeanne',
760
+ age: 18,
761
+ isAdmin: false,
762
+ floatValue: 2.5,
763
+ },
764
+ },
765
+ ],
766
+ },
767
+ })
768
+ })
769
+
770
+ it("should support Float's aggregation", async () => {
771
+ expect(
772
+ await client.request<any>(graphql.users, {
773
+ where: {
774
+ floatValue: { equalTo: 1.5 },
775
+ },
776
+ }),
777
+ ).toEqual({
778
+ users: {
779
+ edges: [
780
+ {
781
+ node: {
782
+ id: expect.anything(),
783
+ name: 'Lucas',
784
+ age: 20,
785
+ isAdmin: true,
786
+ floatValue: 1.5,
787
+ },
788
+ },
789
+ ],
790
+ },
791
+ })
792
+
793
+ expect(
794
+ await client.request<any>(graphql.users, {
795
+ where: {
796
+ floatValue: { notEqualTo: 1.5 },
797
+ },
798
+ }),
799
+ ).toEqual({
800
+ users: {
801
+ edges: [
802
+ {
803
+ node: {
804
+ id: expect.anything(),
805
+ name: 'Jeanne',
806
+ age: 18,
807
+ isAdmin: false,
808
+ floatValue: 2.5,
809
+ },
810
+ },
811
+ ],
812
+ },
813
+ })
814
+
815
+ expect(
816
+ await client.request<any>(graphql.users, {
817
+ where: {
818
+ floatValue: { lessThan: 2.5 },
819
+ },
820
+ }),
821
+ ).toEqual({
822
+ users: {
823
+ edges: [
824
+ {
825
+ node: {
826
+ id: expect.anything(),
827
+ name: 'Lucas',
828
+ age: 20,
829
+ isAdmin: true,
830
+ floatValue: 1.5,
831
+ },
832
+ },
833
+ ],
834
+ },
835
+ })
836
+
837
+ expect(
838
+ await client.request<any>(graphql.users, {
839
+ where: {
840
+ floatValue: { lessThanOrEqualTo: 2.5 },
841
+ },
842
+ }),
843
+ ).toEqual({
844
+ users: {
845
+ edges: expect.arrayContaining([
846
+ {
847
+ node: {
848
+ id: expect.anything(),
849
+ name: 'Lucas',
850
+ age: 20,
851
+ isAdmin: true,
852
+ floatValue: 1.5,
853
+ },
854
+ },
855
+ {
856
+ node: {
857
+ id: expect.anything(),
858
+ name: 'Jeanne',
859
+ age: 18,
860
+ isAdmin: false,
861
+ floatValue: 2.5,
862
+ },
863
+ },
864
+ ]),
865
+ },
866
+ })
867
+
868
+ expect(
869
+ await client.request<any>(graphql.users, {
870
+ where: {
871
+ floatValue: { greaterThan: 1.5 },
872
+ },
873
+ }),
874
+ ).toEqual({
875
+ users: {
876
+ edges: [
877
+ {
878
+ node: {
879
+ id: expect.anything(),
880
+ name: 'Jeanne',
881
+ age: 18,
882
+ isAdmin: false,
883
+ floatValue: 2.5,
884
+ },
885
+ },
886
+ ],
887
+ },
888
+ })
889
+
890
+ expect(
891
+ await client.request<any>(graphql.users, {
892
+ where: {
893
+ floatValue: { greaterThanOrEqualTo: 2.5 },
894
+ },
895
+ }),
896
+ ).toEqual({
897
+ users: {
898
+ edges: [
899
+ {
900
+ node: {
901
+ id: expect.anything(),
902
+ name: 'Jeanne',
903
+ age: 18,
904
+ isAdmin: false,
905
+ floatValue: 2.5,
906
+ },
907
+ },
908
+ ],
909
+ },
910
+ })
911
+
912
+ expect(
913
+ await client.request<any>(graphql.users, {
914
+ where: {
915
+ floatValue: { in: [1.5] },
916
+ },
917
+ }),
918
+ ).toEqual({
919
+ users: {
920
+ edges: [
921
+ {
922
+ node: {
923
+ id: expect.anything(),
924
+ name: 'Lucas',
925
+ age: 20,
926
+ isAdmin: true,
927
+ floatValue: 1.5,
928
+ },
929
+ },
930
+ ],
931
+ },
932
+ })
933
+
934
+ expect(
935
+ await client.request<any>(graphql.users, {
936
+ where: {
937
+ floatValue: { notIn: [1.5] },
938
+ },
939
+ }),
940
+ ).toEqual({
941
+ users: {
942
+ edges: [
943
+ {
944
+ node: {
945
+ id: expect.anything(),
946
+ name: 'Jeanne',
947
+ age: 18,
948
+ isAdmin: false,
949
+ floatValue: 2.5,
950
+ },
951
+ },
952
+ ],
953
+ },
954
+ })
955
+ })
956
+
957
+ it("should support String's aggregation", async () => {
958
+ expect(
959
+ await client.request<any>(graphql.users, {
960
+ where: {
961
+ name: { notEqualTo: 'Lucas' },
962
+ },
963
+ }),
964
+ ).toEqual({
965
+ users: {
966
+ edges: [
967
+ {
968
+ node: {
969
+ id: expect.anything(),
970
+ name: 'Jeanne',
971
+ age: 18,
972
+ isAdmin: false,
973
+ floatValue: 2.5,
974
+ },
975
+ },
976
+ ],
977
+ },
978
+ })
979
+
980
+ expect(
981
+ await client.request<any>(graphql.users, {
982
+ where: {
983
+ name: { equalTo: 'Lucas' },
984
+ },
985
+ }),
986
+ ).toEqual({
987
+ users: {
988
+ edges: [
989
+ {
990
+ node: {
991
+ id: expect.anything(),
992
+ name: 'Lucas',
993
+ age: 20,
994
+ isAdmin: true,
995
+ floatValue: 1.5,
996
+ },
997
+ },
998
+ ],
999
+ },
1000
+ })
1001
+
1002
+ expect(
1003
+ await client.request<any>(graphql.users, {
1004
+ where: {
1005
+ name: { in: ['Lucas'] },
1006
+ },
1007
+ }),
1008
+ ).toEqual({
1009
+ users: {
1010
+ edges: [
1011
+ {
1012
+ node: {
1013
+ id: expect.anything(),
1014
+ name: 'Lucas',
1015
+ age: 20,
1016
+ isAdmin: true,
1017
+ floatValue: 1.5,
1018
+ },
1019
+ },
1020
+ ],
1021
+ },
1022
+ })
1023
+
1024
+ expect(
1025
+ await client.request<any>(graphql.users, {
1026
+ where: {
1027
+ name: { notIn: ['Lucas'] },
1028
+ },
1029
+ }),
1030
+ ).toEqual({
1031
+ users: {
1032
+ edges: [
1033
+ {
1034
+ node: {
1035
+ id: expect.anything(),
1036
+ name: 'Jeanne',
1037
+ age: 18,
1038
+ isAdmin: false,
1039
+ floatValue: 2.5,
1040
+ },
1041
+ },
1042
+ ],
1043
+ },
1044
+ })
1045
+ })
1046
+
1047
+ it('should support OR statement', async () => {
1048
+ const { users } = await client.request<any>(graphql.users, {
1049
+ where: {
1050
+ OR: [{ age: { equalTo: 20 } }, { age: { equalTo: 18 } }],
1051
+ },
1052
+ })
1053
+
1054
+ expect(users.edges).toEqual(
1055
+ expect.arrayContaining([
1056
+ {
1057
+ node: {
1058
+ id: expect.anything(),
1059
+ name: 'Lucas',
1060
+ age: 20,
1061
+ isAdmin: true,
1062
+ floatValue: 1.5,
1063
+ },
1064
+ },
1065
+ {
1066
+ node: {
1067
+ id: expect.anything(),
1068
+ name: 'Jeanne',
1069
+ age: 18,
1070
+ isAdmin: false,
1071
+ floatValue: 2.5,
1072
+ },
1073
+ },
1074
+ ]),
1075
+ )
1076
+
1077
+ const { users: users2 } = await client.request<any>(graphql.users, {
1078
+ where: {
1079
+ OR: [{ age: { equalTo: 20 } }, { age: { equalTo: 19 } }],
1080
+ },
1081
+ })
1082
+
1083
+ expect(users2.edges).toEqual([
1084
+ {
1085
+ node: {
1086
+ id: expect.anything(),
1087
+ name: 'Lucas',
1088
+ age: 20,
1089
+ isAdmin: true,
1090
+ floatValue: 1.5,
1091
+ },
1092
+ },
1093
+ ])
1094
+ })
1095
+
1096
+ it('should support AND statement', async () => {
1097
+ const { users } = await client.request<any>(graphql.users, {
1098
+ where: {
1099
+ AND: [{ age: { equalTo: 20 } }, { age: { equalTo: 18 } }],
1100
+ },
1101
+ })
1102
+
1103
+ expect(users.edges).toEqual([])
1104
+
1105
+ const { users: users2 } = await client.request<any>(graphql.users, {
1106
+ where: {
1107
+ AND: [{ age: { equalTo: 20 } }, { isAdmin: { equalTo: true } }],
1108
+ },
1109
+ })
1110
+
1111
+ expect(users2.edges).toEqual([
1112
+ {
1113
+ node: {
1114
+ id: expect.anything(),
1115
+ name: 'Lucas',
1116
+ age: 20,
1117
+ isAdmin: true,
1118
+ floatValue: 1.5,
1119
+ },
1120
+ },
1121
+ ])
1122
+ })
1123
+ })