@contember/client-content 2.1.0-alpha.3 → 2.1.0-alpha.35
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/package.json +6 -6
- package/src/ContentClient.ts +36 -9
- package/src/ContentQueryBuilder.ts +44 -35
- package/src/MutationFailedError.ts +19 -0
- package/src/TypedContentQueryBuilder.ts +0 -4
- package/src/nodes/ContentEntitySelection.ts +35 -17
- 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 +200 -60
- package/tests/cases/unit/mutation.test.ts +48 -3
- package/tests/cases/unit/query.test.ts +91 -66
- 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
- package/dist/development/index.cjs +0 -13
- package/dist/development/index.cjs.map +0 -1
- package/dist/development/index.js +0 -13
- package/dist/development/index.js.map +0 -1
- package/dist/development/src/ContentClient.cjs +0 -27
- package/dist/development/src/ContentClient.cjs.map +0 -1
- package/dist/development/src/ContentClient.js +0 -27
- package/dist/development/src/ContentClient.js.map +0 -1
- package/dist/development/src/ContentQueryBuilder.cjs +0 -175
- package/dist/development/src/ContentQueryBuilder.cjs.map +0 -1
- package/dist/development/src/ContentQueryBuilder.js +0 -175
- package/dist/development/src/ContentQueryBuilder.js.map +0 -1
- package/dist/development/src/nodes/ContentEntitySelection.cjs +0 -207
- package/dist/development/src/nodes/ContentEntitySelection.cjs.map +0 -1
- package/dist/development/src/nodes/ContentEntitySelection.js +0 -207
- package/dist/development/src/nodes/ContentEntitySelection.js.map +0 -1
- package/dist/development/src/nodes/ContentOperation.cjs +0 -16
- package/dist/development/src/nodes/ContentOperation.cjs.map +0 -1
- package/dist/development/src/nodes/ContentOperation.js +0 -16
- package/dist/development/src/nodes/ContentOperation.js.map +0 -1
- package/dist/development/src/utils/ContentOperationSet.cjs +0 -10
- package/dist/development/src/utils/ContentOperationSet.cjs.map +0 -1
- package/dist/development/src/utils/ContentOperationSet.js +0 -10
- package/dist/development/src/utils/ContentOperationSet.js.map +0 -1
- package/dist/development/src/utils/createListArgs.cjs +0 -24
- package/dist/development/src/utils/createListArgs.cjs.map +0 -1
- package/dist/development/src/utils/createListArgs.js +0 -24
- package/dist/development/src/utils/createListArgs.js.map +0 -1
- package/dist/development/src/utils/createMutationOperationSet.cjs +0 -37
- package/dist/development/src/utils/createMutationOperationSet.cjs.map +0 -1
- package/dist/development/src/utils/createMutationOperationSet.js +0 -37
- package/dist/development/src/utils/createMutationOperationSet.js.map +0 -1
- package/dist/development/src/utils/createQueryOperationSet.cjs +0 -19
- package/dist/development/src/utils/createQueryOperationSet.cjs.map +0 -1
- package/dist/development/src/utils/createQueryOperationSet.js +0 -19
- package/dist/development/src/utils/createQueryOperationSet.js.map +0 -1
- package/dist/development/src/utils/createTypedArgs.cjs +0 -17
- package/dist/development/src/utils/createTypedArgs.cjs.map +0 -1
- package/dist/development/src/utils/createTypedArgs.js +0 -17
- package/dist/development/src/utils/createTypedArgs.js.map +0 -1
- package/dist/development/src/utils/mutationFragments.cjs +0 -55
- package/dist/development/src/utils/mutationFragments.cjs.map +0 -1
- package/dist/development/src/utils/mutationFragments.js +0 -55
- package/dist/development/src/utils/mutationFragments.js.map +0 -1
- package/dist/production/index.cjs +0 -13
- package/dist/production/index.cjs.map +0 -1
- package/dist/production/index.js +0 -13
- package/dist/production/index.js.map +0 -1
- package/dist/production/src/ContentClient.cjs +0 -27
- package/dist/production/src/ContentClient.cjs.map +0 -1
- package/dist/production/src/ContentClient.js +0 -27
- package/dist/production/src/ContentClient.js.map +0 -1
- package/dist/production/src/ContentQueryBuilder.cjs +0 -175
- package/dist/production/src/ContentQueryBuilder.cjs.map +0 -1
- package/dist/production/src/ContentQueryBuilder.js +0 -175
- package/dist/production/src/ContentQueryBuilder.js.map +0 -1
- package/dist/production/src/nodes/ContentEntitySelection.cjs +0 -207
- package/dist/production/src/nodes/ContentEntitySelection.cjs.map +0 -1
- package/dist/production/src/nodes/ContentEntitySelection.js +0 -207
- package/dist/production/src/nodes/ContentEntitySelection.js.map +0 -1
- package/dist/production/src/nodes/ContentOperation.cjs +0 -16
- package/dist/production/src/nodes/ContentOperation.cjs.map +0 -1
- package/dist/production/src/nodes/ContentOperation.js +0 -16
- package/dist/production/src/nodes/ContentOperation.js.map +0 -1
- package/dist/production/src/utils/ContentOperationSet.cjs +0 -10
- package/dist/production/src/utils/ContentOperationSet.cjs.map +0 -1
- package/dist/production/src/utils/ContentOperationSet.js +0 -10
- package/dist/production/src/utils/ContentOperationSet.js.map +0 -1
- package/dist/production/src/utils/createListArgs.cjs +0 -24
- package/dist/production/src/utils/createListArgs.cjs.map +0 -1
- package/dist/production/src/utils/createListArgs.js +0 -24
- package/dist/production/src/utils/createListArgs.js.map +0 -1
- package/dist/production/src/utils/createMutationOperationSet.cjs +0 -37
- package/dist/production/src/utils/createMutationOperationSet.cjs.map +0 -1
- package/dist/production/src/utils/createMutationOperationSet.js +0 -37
- package/dist/production/src/utils/createMutationOperationSet.js.map +0 -1
- package/dist/production/src/utils/createQueryOperationSet.cjs +0 -19
- package/dist/production/src/utils/createQueryOperationSet.cjs.map +0 -1
- package/dist/production/src/utils/createQueryOperationSet.js +0 -19
- package/dist/production/src/utils/createQueryOperationSet.js.map +0 -1
- package/dist/production/src/utils/createTypedArgs.cjs +0 -17
- package/dist/production/src/utils/createTypedArgs.cjs.map +0 -1
- package/dist/production/src/utils/createTypedArgs.js +0 -17
- package/dist/production/src/utils/createTypedArgs.js.map +0 -1
- package/dist/production/src/utils/mutationFragments.cjs +0 -55
- package/dist/production/src/utils/mutationFragments.cjs.map +0 -1
- package/dist/production/src/utils/mutationFragments.js +0 -55
- package/dist/production/src/utils/mutationFragments.js.map +0 -1
- package/dist/types/ContentClient.d.ts +0 -17
- package/dist/types/ContentClient.d.ts.map +0 -1
- package/dist/types/ContentQueryBuilder.d.ts +0 -27
- package/dist/types/ContentQueryBuilder.d.ts.map +0 -1
- package/dist/types/TypedContentQueryBuilder.d.ts +0 -21
- package/dist/types/TypedContentQueryBuilder.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/nodes/ContentEntitySelection.d.ts +0 -61
- package/dist/types/nodes/ContentEntitySelection.d.ts.map +0 -1
- package/dist/types/nodes/ContentOperation.d.ts +0 -30
- package/dist/types/nodes/ContentOperation.d.ts.map +0 -1
- package/dist/types/nodes/TypedEntitySelection.d.ts +0 -53
- package/dist/types/nodes/TypedEntitySelection.d.ts.map +0 -1
- package/dist/types/nodes/index.d.ts +0 -4
- package/dist/types/nodes/index.d.ts.map +0 -1
- package/dist/types/tsconfig.tsbuildinfo +0 -1
- package/dist/types/types/Input.d.ts +0 -201
- package/dist/types/types/Input.d.ts.map +0 -1
- package/dist/types/types/Result.d.ts +0 -39
- package/dist/types/types/Result.d.ts.map +0 -1
- package/dist/types/types/Schema.d.ts +0 -46
- package/dist/types/types/Schema.d.ts.map +0 -1
- package/dist/types/types/index.d.ts +0 -4
- package/dist/types/types/index.d.ts.map +0 -1
- package/dist/types/utils/ContentOperationSet.d.ts +0 -13
- package/dist/types/utils/ContentOperationSet.d.ts.map +0 -1
- package/dist/types/utils/createListArgs.d.ts +0 -9
- package/dist/types/utils/createListArgs.d.ts.map +0 -1
- package/dist/types/utils/createMutationOperationSet.d.ts +0 -4
- package/dist/types/utils/createMutationOperationSet.d.ts.map +0 -1
- package/dist/types/utils/createQueryOperationSet.d.ts +0 -4
- package/dist/types/utils/createQueryOperationSet.d.ts.map +0 -1
- package/dist/types/utils/createTypedArgs.d.ts +0 -3
- package/dist/types/utils/createTypedArgs.d.ts.map +0 -1
- package/dist/types/utils/mutationFragments.d.ts +0 -3
- package/dist/types/utils/mutationFragments.d.ts.map +0 -1
|
@@ -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
|
package/tests/client/enums.ts
CHANGED
package/tests/client/names.ts
CHANGED
|
@@ -1,117 +1,129 @@
|
|
|
1
|
-
import { SchemaNames } from '@contember/client-content'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
1
|
+
import type { SchemaNames, SchemaEntityNames } from '@contember/client-content'
|
|
2
|
+
import type { ContemberClientEntities } from './entities'
|
|
3
|
+
import type { ContemberClientEnums } from './enums'
|
|
4
|
+
export const ContemberClientNames = {
|
|
5
|
+
entities: {
|
|
6
|
+
"Locale": {
|
|
7
|
+
"name": "Locale",
|
|
8
|
+
"fields": {
|
|
9
|
+
"id": {
|
|
10
|
+
"type": "column"
|
|
11
|
+
},
|
|
12
|
+
"code": {
|
|
13
|
+
"type": "column"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scalars": [
|
|
17
|
+
"id",
|
|
18
|
+
"code"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
"Author": {
|
|
22
|
+
"name": "Author",
|
|
23
|
+
"fields": {
|
|
24
|
+
"id": {
|
|
25
|
+
"type": "column"
|
|
26
|
+
},
|
|
27
|
+
"name": {
|
|
28
|
+
"type": "column"
|
|
29
|
+
},
|
|
30
|
+
"email": {
|
|
31
|
+
"type": "column"
|
|
32
|
+
},
|
|
33
|
+
"posts": {
|
|
34
|
+
"type": "many",
|
|
35
|
+
"entity": "Post"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"scalars": [
|
|
39
|
+
"id",
|
|
40
|
+
"name",
|
|
41
|
+
"email"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"Post": {
|
|
45
|
+
"name": "Post",
|
|
46
|
+
"fields": {
|
|
47
|
+
"id": {
|
|
48
|
+
"type": "column"
|
|
49
|
+
},
|
|
50
|
+
"publishedAt": {
|
|
51
|
+
"type": "column"
|
|
52
|
+
},
|
|
53
|
+
"tags": {
|
|
54
|
+
"type": "many",
|
|
55
|
+
"entity": "Tag"
|
|
56
|
+
},
|
|
57
|
+
"author": {
|
|
58
|
+
"type": "one",
|
|
59
|
+
"entity": "Author"
|
|
60
|
+
},
|
|
61
|
+
"locales": {
|
|
62
|
+
"type": "many",
|
|
63
|
+
"entity": "PostLocale"
|
|
64
|
+
},
|
|
65
|
+
"status": {
|
|
66
|
+
"type": "column"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"scalars": [
|
|
70
|
+
"id",
|
|
71
|
+
"publishedAt",
|
|
72
|
+
"status"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
"PostLocale": {
|
|
76
|
+
"name": "PostLocale",
|
|
77
|
+
"fields": {
|
|
78
|
+
"id": {
|
|
79
|
+
"type": "column"
|
|
80
|
+
},
|
|
81
|
+
"locale": {
|
|
82
|
+
"type": "one",
|
|
83
|
+
"entity": "Locale"
|
|
84
|
+
},
|
|
85
|
+
"title": {
|
|
86
|
+
"type": "column"
|
|
87
|
+
},
|
|
88
|
+
"content": {
|
|
89
|
+
"type": "column"
|
|
90
|
+
},
|
|
91
|
+
"post": {
|
|
92
|
+
"type": "one",
|
|
93
|
+
"entity": "Post"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"scalars": [
|
|
97
|
+
"id",
|
|
98
|
+
"title",
|
|
99
|
+
"content"
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"Tag": {
|
|
103
|
+
"name": "Tag",
|
|
104
|
+
"fields": {
|
|
105
|
+
"id": {
|
|
106
|
+
"type": "column"
|
|
107
|
+
},
|
|
108
|
+
"name": {
|
|
109
|
+
"type": "column"
|
|
110
|
+
},
|
|
111
|
+
"posts": {
|
|
112
|
+
"type": "many",
|
|
113
|
+
"entity": "Post"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"scalars": [
|
|
117
|
+
"id",
|
|
118
|
+
"name"
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
} satisfies {[K in keyof ContemberClientEntities]: SchemaEntityNames<K>},
|
|
122
|
+
enums: {
|
|
123
|
+
"PostStatus": [
|
|
124
|
+
"draft",
|
|
125
|
+
"published",
|
|
126
|
+
"archived"
|
|
127
|
+
]
|
|
128
|
+
} satisfies {[K in keyof ContemberClientEnums]: readonly ContemberClientEnums[K][]},
|
|
129
|
+
} satisfies SchemaNames
|
package/tests/generate.ts
CHANGED
package/tests/lib.ts
CHANGED
package/tests/schema.ts
CHANGED
|
@@ -5,7 +5,6 @@ namespace Schema {
|
|
|
5
5
|
code = c.stringColumn().unique().notNull()
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
export class Author {
|
|
10
9
|
name = c.stringColumn()
|
|
11
10
|
email = c.stringColumn()
|
|
@@ -17,6 +16,7 @@ namespace Schema {
|
|
|
17
16
|
tags = c.manyHasMany(Tag, 'posts')
|
|
18
17
|
author = c.manyHasOne(Author, 'posts')
|
|
19
18
|
locales = c.oneHasMany(PostLocale, 'post')
|
|
19
|
+
status = c.enumColumn(c.createEnum('draft', 'published', 'archived'))
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
@c.Unique('locale', 'post')
|
|
@@ -33,5 +33,4 @@ namespace Schema {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
37
36
|
export const schema = createSchema(Schema)
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const ContentClient = require("./src/ContentClient.cjs");
|
|
4
|
-
const ContentQueryBuilder = require("./src/ContentQueryBuilder.cjs");
|
|
5
|
-
const mutationFragments = require("./src/utils/mutationFragments.cjs");
|
|
6
|
-
const ContentEntitySelection = require("./src/nodes/ContentEntitySelection.cjs");
|
|
7
|
-
const ContentOperation = require("./src/nodes/ContentOperation.cjs");
|
|
8
|
-
exports.ContentClient = ContentClient.ContentClient;
|
|
9
|
-
exports.ContentQueryBuilder = ContentQueryBuilder.ContentQueryBuilder;
|
|
10
|
-
exports.mutationFragments = mutationFragments.mutationFragments;
|
|
11
|
-
exports.ContentEntitySelection = ContentEntitySelection.ContentEntitySelection;
|
|
12
|
-
exports.ContentOperation = ContentOperation.ContentOperation;
|
|
13
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ContentClient } from "./src/ContentClient.js";
|
|
2
|
-
import { ContentQueryBuilder } from "./src/ContentQueryBuilder.js";
|
|
3
|
-
import { mutationFragments } from "./src/utils/mutationFragments.js";
|
|
4
|
-
import { ContentEntitySelection } from "./src/nodes/ContentEntitySelection.js";
|
|
5
|
-
import { ContentOperation } from "./src/nodes/ContentOperation.js";
|
|
6
|
-
export {
|
|
7
|
-
ContentClient,
|
|
8
|
-
ContentEntitySelection,
|
|
9
|
-
ContentOperation,
|
|
10
|
-
ContentQueryBuilder,
|
|
11
|
-
mutationFragments
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const mutationFragments = require("./utils/mutationFragments.cjs");
|
|
4
|
-
const graphqlBuilder = require("@contember/graphql-builder");
|
|
5
|
-
const createMutationOperationSet = require("./utils/createMutationOperationSet.cjs");
|
|
6
|
-
const createQueryOperationSet = require("./utils/createQueryOperationSet.cjs");
|
|
7
|
-
class ContentClient {
|
|
8
|
-
constructor(client) {
|
|
9
|
-
this.client = client;
|
|
10
|
-
}
|
|
11
|
-
async query(queries, options) {
|
|
12
|
-
const printer = new graphqlBuilder.GraphQlQueryPrinter();
|
|
13
|
-
const operationSet = createQueryOperationSet.createQueryOperationSet(queries);
|
|
14
|
-
const { query, variables } = printer.printDocument("query", operationSet.selection, {});
|
|
15
|
-
const result = await this.client.execute(query, { variables, ...options });
|
|
16
|
-
return operationSet.parse(result);
|
|
17
|
-
}
|
|
18
|
-
async mutate(input, options) {
|
|
19
|
-
const operationSet = createMutationOperationSet.createMutationOperationSet(input);
|
|
20
|
-
const printer = new graphqlBuilder.GraphQlQueryPrinter();
|
|
21
|
-
const { query, variables } = printer.printDocument("mutation", operationSet.selection, mutationFragments.mutationFragments);
|
|
22
|
-
const result = await this.client.execute(query, { variables, ...options });
|
|
23
|
-
return operationSet.parse(result);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.ContentClient = ContentClient;
|
|
27
|
-
//# sourceMappingURL=ContentClient.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentClient.cjs","sources":["../../../../packages/client-content/src/ContentClient.ts"],"sourcesContent":["import { mutationFragments } from './utils/mutationFragments'\nimport { GraphQlClient, GraphQlClientRequestOptions } from '@contember/graphql-client'\nimport { GraphQlQueryPrinter } from '@contember/graphql-builder'\nimport { ContentMutation, ContentQuery } from './nodes'\nimport { createMutationOperationSet } from './utils/createMutationOperationSet'\nimport { createQueryOperationSet } from './utils/createQueryOperationSet'\n\n\nexport type QueryExecutorOptions =\n\t& GraphQlClientRequestOptions\n\nexport class ContentClient {\n\tconstructor(\n\t\tprivate readonly client: Pick<GraphQlClient, 'execute'>,\n\t) {\n\t}\n\n\n\tpublic async query<Value>(query: ContentQuery<Value>, options?: QueryExecutorOptions): Promise<Value>\n\tpublic async query<Values extends Record<string, any>>(queries: {[K in keyof Values]: ContentQuery<Values[K]>}, options?: QueryExecutorOptions): Promise<Values>\n\tpublic async query(queries: Record<string, ContentQuery<any>> | ContentQuery<any>, options?: QueryExecutorOptions): Promise<any> {\n\t\tconst printer = new GraphQlQueryPrinter()\n\t\tconst operationSet = createQueryOperationSet(queries)\n\t\tconst { query, variables } = printer.printDocument('query', operationSet.selection, {})\n\t\tconst result = await this.client.execute(query, { variables, ...options })\n\t\treturn operationSet.parse(result)\n\t}\n\n\tpublic async mutate<Value>(mutation: ContentMutation<Value>, options?: QueryExecutorOptions,): Promise<Value>\n\tpublic async mutate<Value>(mutations: ContentMutation<Value>[], options?: QueryExecutorOptions,): Promise<Value[]>\n\tpublic async mutate<Values extends Record<string, any>>(mutations: { [K in keyof Values]: ContentMutation<Values[K]> | ContentQuery<Values[K]> }, options?: QueryExecutorOptions): Promise<Values>\n\tpublic async mutate(input: Record<string, ContentMutation<any> | ContentQuery<any>> | ContentMutation<any> | ContentMutation<any>[], options?: QueryExecutorOptions): Promise<any> {\n\t\tconst operationSet = createMutationOperationSet(input)\n\n\t\tconst printer = new GraphQlQueryPrinter()\n\t\tconst { query, variables } = printer.printDocument('mutation', operationSet.selection, mutationFragments)\n\t\tconst result = await this.client.execute(query, { variables, ...options })\n\n\t\treturn operationSet.parse(result)\n\t}\n}\n"],"names":["GraphQlQueryPrinter","createQueryOperationSet","createMutationOperationSet","mutationFragments"],"mappings":";;;;;;AAWO,MAAM,cAAc;AAAA,EAC1B,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAAA;AAAA,EAOlB,MAAa,MAAM,SAAgE,SAA8C;AAC1H,UAAA,UAAU,IAAIA,mCAAoB;AAClC,UAAA,eAAeC,gDAAwB,OAAO;AAC9C,UAAA,EAAE,OAAO,UAAA,IAAc,QAAQ,cAAc,SAAS,aAAa,WAAW,EAAE;AAChF,UAAA,SAAS,MAAM,KAAK,OAAO,QAAQ,OAAO,EAAE,WAAW,GAAG,SAAS;AAClE,WAAA,aAAa,MAAM,MAAM;AAAA,EAAA;AAAA,EAMjC,MAAa,OAAO,OAAiH,SAA8C;AAC5K,UAAA,eAAeC,sDAA2B,KAAK;AAE/C,UAAA,UAAU,IAAIF,mCAAoB;AAClC,UAAA,EAAE,OAAO,UAAU,IAAI,QAAQ,cAAc,YAAY,aAAa,WAAWG,mCAAiB;AAClG,UAAA,SAAS,MAAM,KAAK,OAAO,QAAQ,OAAO,EAAE,WAAW,GAAG,SAAS;AAElE,WAAA,aAAa,MAAM,MAAM;AAAA,EAAA;AAElC;;"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { mutationFragments } from "./utils/mutationFragments.js";
|
|
2
|
-
import { GraphQlQueryPrinter } from "@contember/graphql-builder";
|
|
3
|
-
import { createMutationOperationSet } from "./utils/createMutationOperationSet.js";
|
|
4
|
-
import { createQueryOperationSet } from "./utils/createQueryOperationSet.js";
|
|
5
|
-
class ContentClient {
|
|
6
|
-
constructor(client) {
|
|
7
|
-
this.client = client;
|
|
8
|
-
}
|
|
9
|
-
async query(queries, options) {
|
|
10
|
-
const printer = new GraphQlQueryPrinter();
|
|
11
|
-
const operationSet = createQueryOperationSet(queries);
|
|
12
|
-
const { query, variables } = printer.printDocument("query", operationSet.selection, {});
|
|
13
|
-
const result = await this.client.execute(query, { variables, ...options });
|
|
14
|
-
return operationSet.parse(result);
|
|
15
|
-
}
|
|
16
|
-
async mutate(input, options) {
|
|
17
|
-
const operationSet = createMutationOperationSet(input);
|
|
18
|
-
const printer = new GraphQlQueryPrinter();
|
|
19
|
-
const { query, variables } = printer.printDocument("mutation", operationSet.selection, mutationFragments);
|
|
20
|
-
const result = await this.client.execute(query, { variables, ...options });
|
|
21
|
-
return operationSet.parse(result);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export {
|
|
25
|
-
ContentClient
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=ContentClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentClient.js","sources":["../../../../packages/client-content/src/ContentClient.ts"],"sourcesContent":["import { mutationFragments } from './utils/mutationFragments'\nimport { GraphQlClient, GraphQlClientRequestOptions } from '@contember/graphql-client'\nimport { GraphQlQueryPrinter } from '@contember/graphql-builder'\nimport { ContentMutation, ContentQuery } from './nodes'\nimport { createMutationOperationSet } from './utils/createMutationOperationSet'\nimport { createQueryOperationSet } from './utils/createQueryOperationSet'\n\n\nexport type QueryExecutorOptions =\n\t& GraphQlClientRequestOptions\n\nexport class ContentClient {\n\tconstructor(\n\t\tprivate readonly client: Pick<GraphQlClient, 'execute'>,\n\t) {\n\t}\n\n\n\tpublic async query<Value>(query: ContentQuery<Value>, options?: QueryExecutorOptions): Promise<Value>\n\tpublic async query<Values extends Record<string, any>>(queries: {[K in keyof Values]: ContentQuery<Values[K]>}, options?: QueryExecutorOptions): Promise<Values>\n\tpublic async query(queries: Record<string, ContentQuery<any>> | ContentQuery<any>, options?: QueryExecutorOptions): Promise<any> {\n\t\tconst printer = new GraphQlQueryPrinter()\n\t\tconst operationSet = createQueryOperationSet(queries)\n\t\tconst { query, variables } = printer.printDocument('query', operationSet.selection, {})\n\t\tconst result = await this.client.execute(query, { variables, ...options })\n\t\treturn operationSet.parse(result)\n\t}\n\n\tpublic async mutate<Value>(mutation: ContentMutation<Value>, options?: QueryExecutorOptions,): Promise<Value>\n\tpublic async mutate<Value>(mutations: ContentMutation<Value>[], options?: QueryExecutorOptions,): Promise<Value[]>\n\tpublic async mutate<Values extends Record<string, any>>(mutations: { [K in keyof Values]: ContentMutation<Values[K]> | ContentQuery<Values[K]> }, options?: QueryExecutorOptions): Promise<Values>\n\tpublic async mutate(input: Record<string, ContentMutation<any> | ContentQuery<any>> | ContentMutation<any> | ContentMutation<any>[], options?: QueryExecutorOptions): Promise<any> {\n\t\tconst operationSet = createMutationOperationSet(input)\n\n\t\tconst printer = new GraphQlQueryPrinter()\n\t\tconst { query, variables } = printer.printDocument('mutation', operationSet.selection, mutationFragments)\n\t\tconst result = await this.client.execute(query, { variables, ...options })\n\n\t\treturn operationSet.parse(result)\n\t}\n}\n"],"names":[],"mappings":";;;;AAWO,MAAM,cAAc;AAAA,EAC1B,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAAA;AAAA,EAOlB,MAAa,MAAM,SAAgE,SAA8C;AAC1H,UAAA,UAAU,IAAI,oBAAoB;AAClC,UAAA,eAAe,wBAAwB,OAAO;AAC9C,UAAA,EAAE,OAAO,UAAA,IAAc,QAAQ,cAAc,SAAS,aAAa,WAAW,EAAE;AAChF,UAAA,SAAS,MAAM,KAAK,OAAO,QAAQ,OAAO,EAAE,WAAW,GAAG,SAAS;AAClE,WAAA,aAAa,MAAM,MAAM;AAAA,EAAA;AAAA,EAMjC,MAAa,OAAO,OAAiH,SAA8C;AAC5K,UAAA,eAAe,2BAA2B,KAAK;AAE/C,UAAA,UAAU,IAAI,oBAAoB;AAClC,UAAA,EAAE,OAAO,UAAU,IAAI,QAAQ,cAAc,YAAY,aAAa,WAAW,iBAAiB;AAClG,UAAA,SAAS,MAAM,KAAK,OAAO,QAAQ,OAAO,EAAE,WAAW,GAAG,SAAS;AAElE,WAAA,aAAa,MAAM,MAAM;AAAA,EAAA;AAElC;"}
|