@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.
Files changed (149) hide show
  1. package/package.json +6 -6
  2. package/src/ContentClient.ts +36 -9
  3. package/src/ContentQueryBuilder.ts +44 -35
  4. package/src/MutationFailedError.ts +19 -0
  5. package/src/TypedContentQueryBuilder.ts +0 -4
  6. package/src/nodes/ContentEntitySelection.ts +35 -17
  7. package/src/nodes/TypedEntitySelection.ts +96 -48
  8. package/src/types/Input.ts +1 -9
  9. package/src/types/Result.ts +41 -9
  10. package/src/types/Schema.ts +0 -1
  11. package/src/utils/createListArgs.ts +5 -1
  12. package/src/utils/createMutationOperationSet.ts +9 -7
  13. package/src/utils/createQueryOperationSet.ts +0 -1
  14. package/tests/cases/unit/__snapshots__/mutation.test.ts.snap +952 -818
  15. package/tests/cases/unit/__snapshots__/query.test.ts.snap +200 -60
  16. package/tests/cases/unit/mutation.test.ts +48 -3
  17. package/tests/cases/unit/query.test.ts +91 -66
  18. package/tests/cases/unit/types.test.ts +31 -27
  19. package/tests/client/entities.ts +2 -0
  20. package/tests/client/enums.ts +5 -0
  21. package/tests/client/names.ts +129 -117
  22. package/tests/generate.ts +0 -1
  23. package/tests/lib.ts +0 -1
  24. package/tests/schema.ts +1 -2
  25. package/dist/development/index.cjs +0 -13
  26. package/dist/development/index.cjs.map +0 -1
  27. package/dist/development/index.js +0 -13
  28. package/dist/development/index.js.map +0 -1
  29. package/dist/development/src/ContentClient.cjs +0 -27
  30. package/dist/development/src/ContentClient.cjs.map +0 -1
  31. package/dist/development/src/ContentClient.js +0 -27
  32. package/dist/development/src/ContentClient.js.map +0 -1
  33. package/dist/development/src/ContentQueryBuilder.cjs +0 -175
  34. package/dist/development/src/ContentQueryBuilder.cjs.map +0 -1
  35. package/dist/development/src/ContentQueryBuilder.js +0 -175
  36. package/dist/development/src/ContentQueryBuilder.js.map +0 -1
  37. package/dist/development/src/nodes/ContentEntitySelection.cjs +0 -207
  38. package/dist/development/src/nodes/ContentEntitySelection.cjs.map +0 -1
  39. package/dist/development/src/nodes/ContentEntitySelection.js +0 -207
  40. package/dist/development/src/nodes/ContentEntitySelection.js.map +0 -1
  41. package/dist/development/src/nodes/ContentOperation.cjs +0 -16
  42. package/dist/development/src/nodes/ContentOperation.cjs.map +0 -1
  43. package/dist/development/src/nodes/ContentOperation.js +0 -16
  44. package/dist/development/src/nodes/ContentOperation.js.map +0 -1
  45. package/dist/development/src/utils/ContentOperationSet.cjs +0 -10
  46. package/dist/development/src/utils/ContentOperationSet.cjs.map +0 -1
  47. package/dist/development/src/utils/ContentOperationSet.js +0 -10
  48. package/dist/development/src/utils/ContentOperationSet.js.map +0 -1
  49. package/dist/development/src/utils/createListArgs.cjs +0 -24
  50. package/dist/development/src/utils/createListArgs.cjs.map +0 -1
  51. package/dist/development/src/utils/createListArgs.js +0 -24
  52. package/dist/development/src/utils/createListArgs.js.map +0 -1
  53. package/dist/development/src/utils/createMutationOperationSet.cjs +0 -37
  54. package/dist/development/src/utils/createMutationOperationSet.cjs.map +0 -1
  55. package/dist/development/src/utils/createMutationOperationSet.js +0 -37
  56. package/dist/development/src/utils/createMutationOperationSet.js.map +0 -1
  57. package/dist/development/src/utils/createQueryOperationSet.cjs +0 -19
  58. package/dist/development/src/utils/createQueryOperationSet.cjs.map +0 -1
  59. package/dist/development/src/utils/createQueryOperationSet.js +0 -19
  60. package/dist/development/src/utils/createQueryOperationSet.js.map +0 -1
  61. package/dist/development/src/utils/createTypedArgs.cjs +0 -17
  62. package/dist/development/src/utils/createTypedArgs.cjs.map +0 -1
  63. package/dist/development/src/utils/createTypedArgs.js +0 -17
  64. package/dist/development/src/utils/createTypedArgs.js.map +0 -1
  65. package/dist/development/src/utils/mutationFragments.cjs +0 -55
  66. package/dist/development/src/utils/mutationFragments.cjs.map +0 -1
  67. package/dist/development/src/utils/mutationFragments.js +0 -55
  68. package/dist/development/src/utils/mutationFragments.js.map +0 -1
  69. package/dist/production/index.cjs +0 -13
  70. package/dist/production/index.cjs.map +0 -1
  71. package/dist/production/index.js +0 -13
  72. package/dist/production/index.js.map +0 -1
  73. package/dist/production/src/ContentClient.cjs +0 -27
  74. package/dist/production/src/ContentClient.cjs.map +0 -1
  75. package/dist/production/src/ContentClient.js +0 -27
  76. package/dist/production/src/ContentClient.js.map +0 -1
  77. package/dist/production/src/ContentQueryBuilder.cjs +0 -175
  78. package/dist/production/src/ContentQueryBuilder.cjs.map +0 -1
  79. package/dist/production/src/ContentQueryBuilder.js +0 -175
  80. package/dist/production/src/ContentQueryBuilder.js.map +0 -1
  81. package/dist/production/src/nodes/ContentEntitySelection.cjs +0 -207
  82. package/dist/production/src/nodes/ContentEntitySelection.cjs.map +0 -1
  83. package/dist/production/src/nodes/ContentEntitySelection.js +0 -207
  84. package/dist/production/src/nodes/ContentEntitySelection.js.map +0 -1
  85. package/dist/production/src/nodes/ContentOperation.cjs +0 -16
  86. package/dist/production/src/nodes/ContentOperation.cjs.map +0 -1
  87. package/dist/production/src/nodes/ContentOperation.js +0 -16
  88. package/dist/production/src/nodes/ContentOperation.js.map +0 -1
  89. package/dist/production/src/utils/ContentOperationSet.cjs +0 -10
  90. package/dist/production/src/utils/ContentOperationSet.cjs.map +0 -1
  91. package/dist/production/src/utils/ContentOperationSet.js +0 -10
  92. package/dist/production/src/utils/ContentOperationSet.js.map +0 -1
  93. package/dist/production/src/utils/createListArgs.cjs +0 -24
  94. package/dist/production/src/utils/createListArgs.cjs.map +0 -1
  95. package/dist/production/src/utils/createListArgs.js +0 -24
  96. package/dist/production/src/utils/createListArgs.js.map +0 -1
  97. package/dist/production/src/utils/createMutationOperationSet.cjs +0 -37
  98. package/dist/production/src/utils/createMutationOperationSet.cjs.map +0 -1
  99. package/dist/production/src/utils/createMutationOperationSet.js +0 -37
  100. package/dist/production/src/utils/createMutationOperationSet.js.map +0 -1
  101. package/dist/production/src/utils/createQueryOperationSet.cjs +0 -19
  102. package/dist/production/src/utils/createQueryOperationSet.cjs.map +0 -1
  103. package/dist/production/src/utils/createQueryOperationSet.js +0 -19
  104. package/dist/production/src/utils/createQueryOperationSet.js.map +0 -1
  105. package/dist/production/src/utils/createTypedArgs.cjs +0 -17
  106. package/dist/production/src/utils/createTypedArgs.cjs.map +0 -1
  107. package/dist/production/src/utils/createTypedArgs.js +0 -17
  108. package/dist/production/src/utils/createTypedArgs.js.map +0 -1
  109. package/dist/production/src/utils/mutationFragments.cjs +0 -55
  110. package/dist/production/src/utils/mutationFragments.cjs.map +0 -1
  111. package/dist/production/src/utils/mutationFragments.js +0 -55
  112. package/dist/production/src/utils/mutationFragments.js.map +0 -1
  113. package/dist/types/ContentClient.d.ts +0 -17
  114. package/dist/types/ContentClient.d.ts.map +0 -1
  115. package/dist/types/ContentQueryBuilder.d.ts +0 -27
  116. package/dist/types/ContentQueryBuilder.d.ts.map +0 -1
  117. package/dist/types/TypedContentQueryBuilder.d.ts +0 -21
  118. package/dist/types/TypedContentQueryBuilder.d.ts.map +0 -1
  119. package/dist/types/index.d.ts +0 -7
  120. package/dist/types/index.d.ts.map +0 -1
  121. package/dist/types/nodes/ContentEntitySelection.d.ts +0 -61
  122. package/dist/types/nodes/ContentEntitySelection.d.ts.map +0 -1
  123. package/dist/types/nodes/ContentOperation.d.ts +0 -30
  124. package/dist/types/nodes/ContentOperation.d.ts.map +0 -1
  125. package/dist/types/nodes/TypedEntitySelection.d.ts +0 -53
  126. package/dist/types/nodes/TypedEntitySelection.d.ts.map +0 -1
  127. package/dist/types/nodes/index.d.ts +0 -4
  128. package/dist/types/nodes/index.d.ts.map +0 -1
  129. package/dist/types/tsconfig.tsbuildinfo +0 -1
  130. package/dist/types/types/Input.d.ts +0 -201
  131. package/dist/types/types/Input.d.ts.map +0 -1
  132. package/dist/types/types/Result.d.ts +0 -39
  133. package/dist/types/types/Result.d.ts.map +0 -1
  134. package/dist/types/types/Schema.d.ts +0 -46
  135. package/dist/types/types/Schema.d.ts.map +0 -1
  136. package/dist/types/types/index.d.ts +0 -4
  137. package/dist/types/types/index.d.ts.map +0 -1
  138. package/dist/types/utils/ContentOperationSet.d.ts +0 -13
  139. package/dist/types/utils/ContentOperationSet.d.ts.map +0 -1
  140. package/dist/types/utils/createListArgs.d.ts +0 -9
  141. package/dist/types/utils/createListArgs.d.ts.map +0 -1
  142. package/dist/types/utils/createMutationOperationSet.d.ts +0 -4
  143. package/dist/types/utils/createMutationOperationSet.d.ts.map +0 -1
  144. package/dist/types/utils/createQueryOperationSet.d.ts +0 -4
  145. package/dist/types/utils/createQueryOperationSet.d.ts.map +0 -1
  146. package/dist/types/utils/createTypedArgs.d.ts +0 -3
  147. package/dist/types/utils/createTypedArgs.d.ts.map +0 -1
  148. package/dist/types/utils/mutationFragments.d.ts +0 -3
  149. 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<{ author: ({ id: string; name: string | null; email: string | null } & { posts: { id: string }[] }) | null }>()
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 => it
92
- .$('author',
93
- // @ts-expect-error
94
- { filter: { foo: { eq: 'xx' } } },
95
- it => it.$$(),
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' } } } }, it => it.$$()))
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 => it
110
- .$('locales',
111
- // @ts-expect-error
112
- { filter: { locale: { eq: 'cs' } } },
113
- it => it.$$(),
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' } } }, it => it.$$()))
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
- it => it
126
- .$('localesByLocale',
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
  })
@@ -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
@@ -1,3 +1,8 @@
1
+ export type PostStatus =
2
+ | "draft"
3
+ | "published"
4
+ | "archived"
1
5
  export type ContemberClientEnums = {
6
+ PostStatus: PostStatus
2
7
  }
3
8
 
@@ -1,117 +1,129 @@
1
- import { SchemaNames } from '@contember/client-content'
2
- export const ContemberClientNames: SchemaNames = {
3
- "entities": {
4
- "Locale": {
5
- "name": "Locale",
6
- "fields": {
7
- "id": {
8
- "type": "column"
9
- },
10
- "code": {
11
- "type": "column"
12
- }
13
- },
14
- "scalars": [
15
- "id",
16
- "code"
17
- ]
18
- },
19
- "Author": {
20
- "name": "Author",
21
- "fields": {
22
- "id": {
23
- "type": "column"
24
- },
25
- "name": {
26
- "type": "column"
27
- },
28
- "email": {
29
- "type": "column"
30
- },
31
- "posts": {
32
- "type": "many",
33
- "entity": "Post"
34
- }
35
- },
36
- "scalars": [
37
- "id",
38
- "name",
39
- "email"
40
- ]
41
- },
42
- "Post": {
43
- "name": "Post",
44
- "fields": {
45
- "id": {
46
- "type": "column"
47
- },
48
- "publishedAt": {
49
- "type": "column"
50
- },
51
- "tags": {
52
- "type": "many",
53
- "entity": "Tag"
54
- },
55
- "author": {
56
- "type": "one",
57
- "entity": "Author"
58
- },
59
- "locales": {
60
- "type": "many",
61
- "entity": "PostLocale"
62
- }
63
- },
64
- "scalars": [
65
- "id",
66
- "publishedAt"
67
- ]
68
- },
69
- "PostLocale": {
70
- "name": "PostLocale",
71
- "fields": {
72
- "id": {
73
- "type": "column"
74
- },
75
- "locale": {
76
- "type": "one",
77
- "entity": "Locale"
78
- },
79
- "title": {
80
- "type": "column"
81
- },
82
- "content": {
83
- "type": "column"
84
- },
85
- "post": {
86
- "type": "one",
87
- "entity": "Post"
88
- }
89
- },
90
- "scalars": [
91
- "id",
92
- "title",
93
- "content"
94
- ]
95
- },
96
- "Tag": {
97
- "name": "Tag",
98
- "fields": {
99
- "id": {
100
- "type": "column"
101
- },
102
- "name": {
103
- "type": "column"
104
- },
105
- "posts": {
106
- "type": "many",
107
- "entity": "Post"
108
- }
109
- },
110
- "scalars": [
111
- "id",
112
- "name"
113
- ]
114
- }
115
- },
116
- "enums": {}
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
@@ -10,4 +10,3 @@ await fs.mkdir(dir, { recursive: true })
10
10
  for (const [name, content] of Object.entries(result)) {
11
11
  await fs.writeFile(join(dir, name), content, 'utf8')
12
12
  }
13
-
package/tests/lib.ts CHANGED
@@ -13,4 +13,3 @@ export const createClient = (result?: any) => {
13
13
  })
14
14
  return [client, calls] as const
15
15
  }
16
-
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;"}