wabe 0.6.11 → 0.6.13

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