@contember/client-content 2.1.0-alpha.9 → 2.1.0-beta.1
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/CLAUDE.md +52 -0
- package/dist/development/src/ContentClient.cjs +12 -0
- package/dist/development/src/ContentClient.cjs.map +1 -1
- package/dist/development/src/ContentClient.js +12 -0
- package/dist/development/src/ContentClient.js.map +1 -1
- package/dist/development/src/ContentQueryBuilder.cjs +26 -15
- package/dist/development/src/ContentQueryBuilder.cjs.map +1 -1
- package/dist/development/src/ContentQueryBuilder.js +26 -15
- package/dist/development/src/ContentQueryBuilder.js.map +1 -1
- package/dist/development/src/MutationFailedError.cjs +11 -0
- package/dist/development/src/MutationFailedError.cjs.map +1 -0
- package/dist/development/src/MutationFailedError.js +11 -0
- package/dist/development/src/MutationFailedError.js.map +1 -0
- package/dist/development/src/nodes/ContentEntitySelection.cjs +47 -12
- package/dist/development/src/nodes/ContentEntitySelection.cjs.map +1 -1
- package/dist/development/src/nodes/ContentEntitySelection.js +47 -12
- package/dist/development/src/nodes/ContentEntitySelection.js.map +1 -1
- package/dist/development/src/nodes/ContentOperation.cjs.map +1 -1
- package/dist/development/src/nodes/ContentOperation.js.map +1 -1
- package/dist/development/src/utils/ContentOperationSet.cjs.map +1 -1
- package/dist/development/src/utils/ContentOperationSet.js.map +1 -1
- package/dist/development/src/utils/createListArgs.cjs.map +1 -1
- package/dist/development/src/utils/createListArgs.js.map +1 -1
- package/dist/development/src/utils/createMutationOperationSet.cjs +8 -6
- package/dist/development/src/utils/createMutationOperationSet.cjs.map +1 -1
- package/dist/development/src/utils/createMutationOperationSet.js +8 -6
- package/dist/development/src/utils/createMutationOperationSet.js.map +1 -1
- package/dist/development/src/utils/createQueryOperationSet.cjs.map +1 -1
- package/dist/development/src/utils/createQueryOperationSet.js.map +1 -1
- package/dist/development/src/utils/createTypedArgs.cjs.map +1 -1
- package/dist/development/src/utils/createTypedArgs.js.map +1 -1
- package/dist/development/src/utils/mutationFragments.cjs.map +1 -1
- package/dist/development/src/utils/mutationFragments.js.map +1 -1
- package/dist/production/src/ContentClient.cjs +12 -0
- package/dist/production/src/ContentClient.cjs.map +1 -1
- package/dist/production/src/ContentClient.js +12 -0
- package/dist/production/src/ContentClient.js.map +1 -1
- package/dist/production/src/ContentQueryBuilder.cjs +26 -15
- package/dist/production/src/ContentQueryBuilder.cjs.map +1 -1
- package/dist/production/src/ContentQueryBuilder.js +26 -15
- package/dist/production/src/ContentQueryBuilder.js.map +1 -1
- package/dist/production/src/MutationFailedError.cjs +11 -0
- package/dist/production/src/MutationFailedError.cjs.map +1 -0
- package/dist/production/src/MutationFailedError.js +11 -0
- package/dist/production/src/MutationFailedError.js.map +1 -0
- package/dist/production/src/nodes/ContentEntitySelection.cjs +47 -12
- package/dist/production/src/nodes/ContentEntitySelection.cjs.map +1 -1
- package/dist/production/src/nodes/ContentEntitySelection.js +47 -12
- package/dist/production/src/nodes/ContentEntitySelection.js.map +1 -1
- package/dist/production/src/nodes/ContentOperation.cjs.map +1 -1
- package/dist/production/src/nodes/ContentOperation.js.map +1 -1
- package/dist/production/src/utils/ContentOperationSet.cjs.map +1 -1
- package/dist/production/src/utils/ContentOperationSet.js.map +1 -1
- package/dist/production/src/utils/createListArgs.cjs.map +1 -1
- package/dist/production/src/utils/createListArgs.js.map +1 -1
- package/dist/production/src/utils/createMutationOperationSet.cjs +8 -6
- package/dist/production/src/utils/createMutationOperationSet.cjs.map +1 -1
- package/dist/production/src/utils/createMutationOperationSet.js +8 -6
- package/dist/production/src/utils/createMutationOperationSet.js.map +1 -1
- package/dist/production/src/utils/createQueryOperationSet.cjs.map +1 -1
- package/dist/production/src/utils/createQueryOperationSet.js.map +1 -1
- package/dist/production/src/utils/createTypedArgs.cjs.map +1 -1
- package/dist/production/src/utils/createTypedArgs.js.map +1 -1
- package/dist/production/src/utils/mutationFragments.cjs.map +1 -1
- package/dist/production/src/utils/mutationFragments.js.map +1 -1
- package/dist/types/ContentClient.d.ts +10 -0
- package/dist/types/ContentClient.d.ts.map +1 -1
- package/dist/types/ContentQueryBuilder.d.ts.map +1 -1
- package/dist/types/MutationFailedError.d.ts +13 -0
- package/dist/types/MutationFailedError.d.ts.map +1 -0
- package/dist/types/TypedContentQueryBuilder.d.ts.map +1 -1
- package/dist/types/nodes/ContentEntitySelection.d.ts +4 -1
- package/dist/types/nodes/ContentEntitySelection.d.ts.map +1 -1
- package/dist/types/nodes/TypedEntitySelection.d.ts +1 -0
- package/dist/types/nodes/TypedEntitySelection.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/types/Input.d.ts.map +1 -1
- package/dist/types/types/Result.d.ts +30 -9
- package/dist/types/types/Result.d.ts.map +1 -1
- package/dist/types/utils/createListArgs.d.ts.map +1 -1
- package/dist/types/utils/createMutationOperationSet.d.ts.map +1 -1
- package/dist/types/utils/createQueryOperationSet.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/ContentClient.ts +36 -9
- package/src/ContentQueryBuilder.ts +45 -35
- package/src/MutationFailedError.ts +19 -0
- package/src/TypedContentQueryBuilder.ts +0 -4
- package/src/nodes/ContentEntitySelection.ts +67 -23
- package/src/nodes/TypedEntitySelection.ts +96 -48
- package/src/types/Input.ts +1 -9
- package/src/types/Result.ts +41 -9
- package/src/types/Schema.ts +0 -1
- package/src/utils/createListArgs.ts +5 -1
- package/src/utils/createMutationOperationSet.ts +9 -7
- package/src/utils/createQueryOperationSet.ts +0 -1
- package/tests/cases/unit/__snapshots__/mutation.test.ts.snap +952 -818
- package/tests/cases/unit/__snapshots__/query.test.ts.snap +216 -60
- package/tests/cases/unit/mutation.test.ts +48 -3
- package/tests/cases/unit/query.test.ts +103 -82
- package/tests/cases/unit/types.test.ts +31 -27
- package/tests/client/entities.ts +2 -0
- package/tests/client/enums.ts +5 -0
- package/tests/client/names.ts +129 -117
- package/tests/generate.ts +0 -1
- package/tests/lib.ts +0 -1
- package/tests/schema.ts +1 -2
|
@@ -5,7 +5,6 @@ import OrderDirection = Input.OrderDirection
|
|
|
5
5
|
import { queryBuilder } from '../../client'
|
|
6
6
|
|
|
7
7
|
describe('queries', () => {
|
|
8
|
-
|
|
9
8
|
const qb = queryBuilder
|
|
10
9
|
test('list', async () => {
|
|
11
10
|
const [client, calls] = createClient({
|
|
@@ -98,7 +97,6 @@ describe('queries', () => {
|
|
|
98
97
|
expect(calls[0].variables).toEqual({})
|
|
99
98
|
})
|
|
100
99
|
|
|
101
|
-
|
|
102
100
|
test('single query', async () => {
|
|
103
101
|
const [client, calls] = createClient({
|
|
104
102
|
value: [
|
|
@@ -129,7 +127,6 @@ describe('queries', () => {
|
|
|
129
127
|
expect(calls[0].variables).toEqual({})
|
|
130
128
|
})
|
|
131
129
|
|
|
132
|
-
|
|
133
130
|
test('nested object', async () => {
|
|
134
131
|
const [client, calls] = createClient()
|
|
135
132
|
await client.query({
|
|
@@ -142,10 +139,11 @@ describe('queries', () => {
|
|
|
142
139
|
test('nested object args', async () => {
|
|
143
140
|
const [client, calls] = createClient()
|
|
144
141
|
await client.query({
|
|
145
|
-
authors: qb.list('Author', {}, it =>
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
142
|
+
authors: qb.list('Author', {}, it =>
|
|
143
|
+
it.$$().$('posts', {
|
|
144
|
+
limit: 10,
|
|
145
|
+
filter: { tags: { name: { eq: 'foo' } } },
|
|
146
|
+
}, it => it.$$())),
|
|
149
147
|
})
|
|
150
148
|
expect(calls).toHaveLength(1)
|
|
151
149
|
expect(calls[0].query).toMatchSnapshot()
|
|
@@ -161,7 +159,6 @@ describe('queries', () => {
|
|
|
161
159
|
})
|
|
162
160
|
})
|
|
163
161
|
|
|
164
|
-
|
|
165
162
|
test('list with args', async () => {
|
|
166
163
|
const [client, calls] = createClient()
|
|
167
164
|
await client.query({
|
|
@@ -201,7 +198,6 @@ describe('queries', () => {
|
|
|
201
198
|
)
|
|
202
199
|
})
|
|
203
200
|
|
|
204
|
-
|
|
205
201
|
test('get by id', async () => {
|
|
206
202
|
const [client, calls] = createClient()
|
|
207
203
|
const result = await client.query({
|
|
@@ -232,13 +228,13 @@ describe('queries', () => {
|
|
|
232
228
|
],
|
|
233
229
|
})
|
|
234
230
|
const result = await client.query({
|
|
235
|
-
authors: qb.list('Author', {}, it =>
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
231
|
+
authors: qb.list('Author', {}, it =>
|
|
232
|
+
it
|
|
233
|
+
.$$()
|
|
234
|
+
.transform(it => ({
|
|
235
|
+
...it,
|
|
236
|
+
label: `${it.name} (${it.email})`,
|
|
237
|
+
}))),
|
|
242
238
|
})
|
|
243
239
|
expect(result as any).toStrictEqual({
|
|
244
240
|
authors: [
|
|
@@ -255,6 +251,7 @@ describe('queries', () => {
|
|
|
255
251
|
],
|
|
256
252
|
})
|
|
257
253
|
expect(calls).toHaveLength(1)
|
|
254
|
+
expect(calls).toMatchSnapshot()
|
|
258
255
|
})
|
|
259
256
|
|
|
260
257
|
test('top level get transform', async () => {
|
|
@@ -265,13 +262,13 @@ describe('queries', () => {
|
|
|
265
262
|
},
|
|
266
263
|
})
|
|
267
264
|
const result = await client.query({
|
|
268
|
-
author: qb.get('Author', { by: { id: '123' } }, it =>
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
265
|
+
author: qb.get('Author', { by: { id: '123' } }, it =>
|
|
266
|
+
it
|
|
267
|
+
.$$()
|
|
268
|
+
.transform(it => ({
|
|
269
|
+
...it,
|
|
270
|
+
label: `${it.name} (${it.email})`,
|
|
271
|
+
}))),
|
|
275
272
|
})
|
|
276
273
|
expect(result as any).toStrictEqual({
|
|
277
274
|
author: {
|
|
@@ -281,32 +278,31 @@ describe('queries', () => {
|
|
|
281
278
|
},
|
|
282
279
|
})
|
|
283
280
|
expect(calls).toHaveLength(1)
|
|
281
|
+
expect(calls).toMatchSnapshot()
|
|
284
282
|
})
|
|
285
283
|
|
|
286
|
-
|
|
287
284
|
test('nested has-many transform', async () => {
|
|
288
285
|
const [client, calls] = createClient({
|
|
289
286
|
author: {
|
|
290
287
|
name: 'John',
|
|
291
288
|
email: 'foo@localhost',
|
|
292
|
-
posts:
|
|
293
|
-
|
|
294
|
-
publishedAt: '2021-01-01T00:00:00Z',
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
},
|
|
299
|
-
],
|
|
289
|
+
posts: {
|
|
290
|
+
edges: [
|
|
291
|
+
{ node: { publishedAt: '2021-01-01T00:00:00Z' } },
|
|
292
|
+
{ node: { publishedAt: '2021-01-02T00:00:00Z' } },
|
|
293
|
+
],
|
|
294
|
+
},
|
|
300
295
|
},
|
|
301
296
|
})
|
|
302
297
|
const result = await client.query({
|
|
303
|
-
author: qb.get('Author', { by: { id: '123' } }, it =>
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
298
|
+
author: qb.get('Author', { by: { id: '123' } }, it =>
|
|
299
|
+
it
|
|
300
|
+
.$$()
|
|
301
|
+
.$('posts', {}, it =>
|
|
302
|
+
it.$$().transform(it => ({
|
|
303
|
+
...it,
|
|
304
|
+
publishYear: it.publishedAt ? new Date(it.publishedAt).getFullYear() : null,
|
|
305
|
+
})))),
|
|
310
306
|
})
|
|
311
307
|
expect(result as any).toStrictEqual({
|
|
312
308
|
author: {
|
|
@@ -325,9 +321,9 @@ describe('queries', () => {
|
|
|
325
321
|
},
|
|
326
322
|
})
|
|
327
323
|
expect(calls).toHaveLength(1)
|
|
324
|
+
expect(calls).toMatchSnapshot()
|
|
328
325
|
})
|
|
329
326
|
|
|
330
|
-
|
|
331
327
|
test('nested has-one transform', async () => {
|
|
332
328
|
const [client, calls] = createClient({
|
|
333
329
|
post: {
|
|
@@ -338,19 +334,19 @@ describe('queries', () => {
|
|
|
338
334
|
},
|
|
339
335
|
},
|
|
340
336
|
})
|
|
341
|
-
const author = qb.fragment('Author', it =>
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
337
|
+
const author = qb.fragment('Author', it =>
|
|
338
|
+
it
|
|
339
|
+
.$$()
|
|
340
|
+
.transform(it => ({
|
|
341
|
+
...it,
|
|
342
|
+
label: `${it.name} (${it.email})`,
|
|
343
|
+
})))
|
|
348
344
|
|
|
349
345
|
const result = await client.query({
|
|
350
|
-
post: qb.get('Post', { by: { id: '123' } }, it =>
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
346
|
+
post: qb.get('Post', { by: { id: '123' } }, it =>
|
|
347
|
+
it
|
|
348
|
+
.$$()
|
|
349
|
+
.$('author', author)),
|
|
354
350
|
})
|
|
355
351
|
expect(result as any).toStrictEqual({
|
|
356
352
|
post: {
|
|
@@ -362,9 +358,9 @@ describe('queries', () => {
|
|
|
362
358
|
},
|
|
363
359
|
},
|
|
364
360
|
})
|
|
361
|
+
expect(calls).toMatchSnapshot()
|
|
365
362
|
})
|
|
366
363
|
|
|
367
|
-
|
|
368
364
|
test('nested has-many-by transform', async () => {
|
|
369
365
|
const [client, calls] = createClient({
|
|
370
366
|
post: {
|
|
@@ -375,13 +371,14 @@ describe('queries', () => {
|
|
|
375
371
|
},
|
|
376
372
|
})
|
|
377
373
|
const result = await client.query({
|
|
378
|
-
post: qb.get('Post', { by: { id: '123' } }, it =>
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
374
|
+
post: qb.get('Post', { by: { id: '123' } }, it =>
|
|
375
|
+
it
|
|
376
|
+
.$$()
|
|
377
|
+
.$('localesByLocale', { by: { locale: { code: 'en' } } }, it =>
|
|
378
|
+
it.$$().transform(it => ({
|
|
379
|
+
...it,
|
|
380
|
+
label: it.title?.toUpperCase(),
|
|
381
|
+
})))),
|
|
385
382
|
})
|
|
386
383
|
expect(result as any).toStrictEqual({
|
|
387
384
|
post: {
|
|
@@ -392,6 +389,7 @@ describe('queries', () => {
|
|
|
392
389
|
},
|
|
393
390
|
},
|
|
394
391
|
})
|
|
392
|
+
expect(calls).toMatchSnapshot()
|
|
395
393
|
})
|
|
396
394
|
|
|
397
395
|
test('multiple transforms', async () => {
|
|
@@ -399,32 +397,31 @@ describe('queries', () => {
|
|
|
399
397
|
author: {
|
|
400
398
|
name: 'John',
|
|
401
399
|
email: 'foo@localhost',
|
|
402
|
-
posts:
|
|
403
|
-
|
|
404
|
-
publishedAt: '2021-01-01T00:00:00Z',
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
},
|
|
409
|
-
],
|
|
400
|
+
posts: {
|
|
401
|
+
edges: [
|
|
402
|
+
{ node: { publishedAt: '2021-01-01T00:00:00Z' } },
|
|
403
|
+
{ node: { publishedAt: '2021-01-02T00:00:00Z' } },
|
|
404
|
+
],
|
|
405
|
+
},
|
|
410
406
|
},
|
|
411
407
|
})
|
|
412
408
|
const result = await client.query({
|
|
413
|
-
author: qb.get('Author', { by: { id: '123' } }, it =>
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
409
|
+
author: qb.get('Author', { by: { id: '123' } }, it =>
|
|
410
|
+
it
|
|
411
|
+
.$$()
|
|
412
|
+
.transform(it => ({
|
|
413
|
+
...it,
|
|
414
|
+
value1: 'foo',
|
|
415
|
+
}))
|
|
416
|
+
.$('posts', {}, it =>
|
|
417
|
+
it.$$().transform(it => ({
|
|
418
|
+
...it,
|
|
419
|
+
postLabel: 'foo bar',
|
|
420
|
+
})))
|
|
421
|
+
.transform(it => ({
|
|
422
|
+
...it,
|
|
423
|
+
value2: 'bar',
|
|
424
|
+
}))),
|
|
428
425
|
})
|
|
429
426
|
expect(result as any).toStrictEqual({
|
|
430
427
|
author: {
|
|
@@ -447,4 +444,28 @@ describe('queries', () => {
|
|
|
447
444
|
expect(calls).toHaveLength(1)
|
|
448
445
|
})
|
|
449
446
|
|
|
447
|
+
test('omit', async () => {
|
|
448
|
+
const [client, calls] = createClient({
|
|
449
|
+
authors: [
|
|
450
|
+
{
|
|
451
|
+
id: '1',
|
|
452
|
+
name: 'John',
|
|
453
|
+
},
|
|
454
|
+
],
|
|
455
|
+
})
|
|
456
|
+
const result = await client.query({
|
|
457
|
+
authors: qb.list('Author', {}, it => it.$$().omit('email').$('posts', {}, it => it.$$()).omit('posts')),
|
|
458
|
+
})
|
|
459
|
+
expect(result).toStrictEqual({
|
|
460
|
+
authors: [
|
|
461
|
+
{
|
|
462
|
+
id: '1',
|
|
463
|
+
name: 'John',
|
|
464
|
+
},
|
|
465
|
+
],
|
|
466
|
+
})
|
|
467
|
+
expect(calls).toHaveLength(1)
|
|
468
|
+
expect(calls[0].query).toMatchSnapshot()
|
|
469
|
+
expect(calls[0].variables).toStrictEqual({})
|
|
470
|
+
})
|
|
450
471
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
2
|
import { describe, expect, test } from 'bun:test'
|
|
3
3
|
import { ContentClientInput } from '../../../src'
|
|
4
|
-
import { ContemberClientEntities, FragmentOf, FragmentType, queryBuilder } from '../../client'
|
|
4
|
+
import { ContemberClientEntities, FragmentOf, FragmentType, PostStatus, queryBuilder } from '../../client'
|
|
5
5
|
import { expectTypeOf } from 'expect-type'
|
|
6
6
|
|
|
7
7
|
const qb = queryBuilder
|
|
@@ -75,10 +75,11 @@ describe('ts types', () => {
|
|
|
75
75
|
test('has one field on fragment type', async () => {
|
|
76
76
|
const fragment = qb.fragment('Post', it => it.$('author', it => it.$$().$('posts', it => it.$('id'))))
|
|
77
77
|
type fragmentType = FragmentType<typeof fragment>
|
|
78
|
-
expectTypeOf<fragmentType>().toEqualTypeOf<
|
|
78
|
+
expectTypeOf<fragmentType>().toEqualTypeOf<
|
|
79
|
+
{ author: ({ id: string; name: string | null; email: string | null } & { posts: { id: string }[] }) | null }
|
|
80
|
+
>()
|
|
79
81
|
})
|
|
80
82
|
|
|
81
|
-
|
|
82
83
|
test('has one without arg', async () => {
|
|
83
84
|
qb.list('Post', {}, it => it.$('author', it => it.$$()))
|
|
84
85
|
})
|
|
@@ -88,13 +89,13 @@ describe('ts types', () => {
|
|
|
88
89
|
})
|
|
89
90
|
|
|
90
91
|
test('has one with invalid arg', async () => {
|
|
91
|
-
qb.list('Post', {}, it =>
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
qb.list('Post', {}, it =>
|
|
93
|
+
it
|
|
94
|
+
.$(
|
|
95
|
+
'author', // @ts-expect-error
|
|
96
|
+
{ filter: { foo: { eq: 'xx' } } },
|
|
97
|
+
it => it.$$(),
|
|
98
|
+
))
|
|
98
99
|
})
|
|
99
100
|
|
|
100
101
|
test('has many without arg', async () => {
|
|
@@ -102,36 +103,33 @@ describe('ts types', () => {
|
|
|
102
103
|
})
|
|
103
104
|
|
|
104
105
|
test('has many with arg', async () => {
|
|
105
|
-
qb.list('Post', {}, it => it.$('locales', { filter: { locale: { code: { eq: 'cs' } } } },
|
|
106
|
+
qb.list('Post', {}, it => it.$('locales', { filter: { locale: { code: { eq: 'cs' } } } }, it => it.$$()))
|
|
106
107
|
})
|
|
107
108
|
|
|
108
109
|
test('has many with invalid arg', async () => {
|
|
109
|
-
qb.list('Post', {}, it =>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
qb.list('Post', {}, it =>
|
|
111
|
+
it
|
|
112
|
+
.$(
|
|
113
|
+
'locales', // @ts-expect-error
|
|
114
|
+
{ filter: { locale: { eq: 'cs' } } },
|
|
115
|
+
it => it.$$(),
|
|
116
|
+
))
|
|
116
117
|
})
|
|
117
118
|
|
|
118
119
|
test('reduced has may', async () => {
|
|
119
|
-
qb.list('Post', {}, it => it.$('localesByLocale', { by: { locale: { code: 'cs' } } },
|
|
120
|
+
qb.list('Post', {}, it => it.$('localesByLocale', { by: { locale: { code: 'cs' } } }, it => it.$$()))
|
|
120
121
|
})
|
|
121
122
|
|
|
122
123
|
test('reduced has may - invalid "by"', async () => {
|
|
123
|
-
qb.list('Post',
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
// @ts-expect-error
|
|
124
|
+
qb.list('Post', {}, it =>
|
|
125
|
+
it
|
|
126
|
+
.$(
|
|
127
|
+
'localesByLocale', // @ts-expect-error
|
|
128
128
|
{ by: { locale: {} } },
|
|
129
129
|
qb.fragment('PostLocale'),
|
|
130
|
-
)
|
|
131
|
-
)
|
|
130
|
+
))
|
|
132
131
|
})
|
|
133
132
|
|
|
134
|
-
|
|
135
133
|
test('invalid field', async () => {
|
|
136
134
|
expect(() => {
|
|
137
135
|
qb.list(
|
|
@@ -142,4 +140,10 @@ describe('ts types', () => {
|
|
|
142
140
|
)
|
|
143
141
|
}).toThrow('Field Post.lorem does not exist.')
|
|
144
142
|
})
|
|
143
|
+
|
|
144
|
+
test('omit', async () => {
|
|
145
|
+
const fragment = qb.fragment('Post', it => it.$$().omit('publishedAt'))
|
|
146
|
+
type fragmentType = FragmentType<typeof fragment>
|
|
147
|
+
expectTypeOf<fragmentType>().toEqualTypeOf<{ id: string; status: PostStatus | null }>()
|
|
148
|
+
})
|
|
145
149
|
})
|
package/tests/client/entities.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PostStatus } from './enums'
|
|
1
2
|
|
|
2
3
|
export type JSONPrimitive = string | number | boolean | null
|
|
3
4
|
export type JSONValue = JSONPrimitive | JSONObject | JSONArray
|
|
@@ -47,6 +48,7 @@ export type Post <OverRelation extends string | never = never> = {
|
|
|
47
48
|
columns: {
|
|
48
49
|
id: string
|
|
49
50
|
publishedAt: string | null
|
|
51
|
+
status: PostStatus | null
|
|
50
52
|
}
|
|
51
53
|
hasOne: {
|
|
52
54
|
author: Author
|