@contember/client-content 2.1.0-alpha.30 → 2.1.0-alpha.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/package.json +6 -6
  2. package/src/ContentClient.ts +23 -16
  3. package/src/ContentQueryBuilder.ts +44 -35
  4. package/src/MutationFailedError.ts +8 -6
  5. package/src/TypedContentQueryBuilder.ts +0 -4
  6. package/src/nodes/ContentEntitySelection.ts +19 -14
  7. package/src/nodes/TypedEntitySelection.ts +92 -48
  8. package/src/types/Input.ts +1 -9
  9. package/src/types/Schema.ts +0 -1
  10. package/src/utils/createListArgs.ts +5 -1
  11. package/src/utils/createMutationOperationSet.ts +9 -7
  12. package/src/utils/createQueryOperationSet.ts +0 -1
  13. package/tests/cases/unit/__snapshots__/mutation.test.ts.snap +814 -878
  14. package/tests/cases/unit/__snapshots__/query.test.ts.snap +84 -77
  15. package/tests/cases/unit/mutation.test.ts +0 -4
  16. package/tests/cases/unit/query.test.ts +62 -67
  17. package/tests/cases/unit/types.test.ts +26 -28
  18. package/tests/client/entities.ts +2 -0
  19. package/tests/client/enums.ts +5 -0
  20. package/tests/client/names.ts +129 -117
  21. package/tests/generate.ts +0 -1
  22. package/tests/lib.ts +0 -1
  23. package/tests/schema.ts +1 -2
  24. package/dist/development/index.cjs +0 -13
  25. package/dist/development/index.cjs.map +0 -1
  26. package/dist/development/index.js +0 -13
  27. package/dist/development/index.js.map +0 -1
  28. package/dist/development/src/ContentClient.cjs +0 -39
  29. package/dist/development/src/ContentClient.cjs.map +0 -1
  30. package/dist/development/src/ContentClient.js +0 -39
  31. package/dist/development/src/ContentClient.js.map +0 -1
  32. package/dist/development/src/ContentQueryBuilder.cjs +0 -175
  33. package/dist/development/src/ContentQueryBuilder.cjs.map +0 -1
  34. package/dist/development/src/ContentQueryBuilder.js +0 -175
  35. package/dist/development/src/ContentQueryBuilder.js.map +0 -1
  36. package/dist/development/src/MutationFailedError.cjs +0 -11
  37. package/dist/development/src/MutationFailedError.cjs.map +0 -1
  38. package/dist/development/src/MutationFailedError.js +0 -11
  39. package/dist/development/src/MutationFailedError.js.map +0 -1
  40. package/dist/development/src/nodes/ContentEntitySelection.cjs +0 -219
  41. package/dist/development/src/nodes/ContentEntitySelection.cjs.map +0 -1
  42. package/dist/development/src/nodes/ContentEntitySelection.js +0 -219
  43. package/dist/development/src/nodes/ContentEntitySelection.js.map +0 -1
  44. package/dist/development/src/nodes/ContentOperation.cjs +0 -16
  45. package/dist/development/src/nodes/ContentOperation.cjs.map +0 -1
  46. package/dist/development/src/nodes/ContentOperation.js +0 -16
  47. package/dist/development/src/nodes/ContentOperation.js.map +0 -1
  48. package/dist/development/src/utils/ContentOperationSet.cjs +0 -10
  49. package/dist/development/src/utils/ContentOperationSet.cjs.map +0 -1
  50. package/dist/development/src/utils/ContentOperationSet.js +0 -10
  51. package/dist/development/src/utils/ContentOperationSet.js.map +0 -1
  52. package/dist/development/src/utils/createListArgs.cjs +0 -24
  53. package/dist/development/src/utils/createListArgs.cjs.map +0 -1
  54. package/dist/development/src/utils/createListArgs.js +0 -24
  55. package/dist/development/src/utils/createListArgs.js.map +0 -1
  56. package/dist/development/src/utils/createMutationOperationSet.cjs +0 -37
  57. package/dist/development/src/utils/createMutationOperationSet.cjs.map +0 -1
  58. package/dist/development/src/utils/createMutationOperationSet.js +0 -37
  59. package/dist/development/src/utils/createMutationOperationSet.js.map +0 -1
  60. package/dist/development/src/utils/createQueryOperationSet.cjs +0 -19
  61. package/dist/development/src/utils/createQueryOperationSet.cjs.map +0 -1
  62. package/dist/development/src/utils/createQueryOperationSet.js +0 -19
  63. package/dist/development/src/utils/createQueryOperationSet.js.map +0 -1
  64. package/dist/development/src/utils/createTypedArgs.cjs +0 -17
  65. package/dist/development/src/utils/createTypedArgs.cjs.map +0 -1
  66. package/dist/development/src/utils/createTypedArgs.js +0 -17
  67. package/dist/development/src/utils/createTypedArgs.js.map +0 -1
  68. package/dist/development/src/utils/mutationFragments.cjs +0 -55
  69. package/dist/development/src/utils/mutationFragments.cjs.map +0 -1
  70. package/dist/development/src/utils/mutationFragments.js +0 -55
  71. package/dist/development/src/utils/mutationFragments.js.map +0 -1
  72. package/dist/production/index.cjs +0 -13
  73. package/dist/production/index.cjs.map +0 -1
  74. package/dist/production/index.js +0 -13
  75. package/dist/production/index.js.map +0 -1
  76. package/dist/production/src/ContentClient.cjs +0 -39
  77. package/dist/production/src/ContentClient.cjs.map +0 -1
  78. package/dist/production/src/ContentClient.js +0 -39
  79. package/dist/production/src/ContentClient.js.map +0 -1
  80. package/dist/production/src/ContentQueryBuilder.cjs +0 -175
  81. package/dist/production/src/ContentQueryBuilder.cjs.map +0 -1
  82. package/dist/production/src/ContentQueryBuilder.js +0 -175
  83. package/dist/production/src/ContentQueryBuilder.js.map +0 -1
  84. package/dist/production/src/MutationFailedError.cjs +0 -11
  85. package/dist/production/src/MutationFailedError.cjs.map +0 -1
  86. package/dist/production/src/MutationFailedError.js +0 -11
  87. package/dist/production/src/MutationFailedError.js.map +0 -1
  88. package/dist/production/src/nodes/ContentEntitySelection.cjs +0 -219
  89. package/dist/production/src/nodes/ContentEntitySelection.cjs.map +0 -1
  90. package/dist/production/src/nodes/ContentEntitySelection.js +0 -219
  91. package/dist/production/src/nodes/ContentEntitySelection.js.map +0 -1
  92. package/dist/production/src/nodes/ContentOperation.cjs +0 -16
  93. package/dist/production/src/nodes/ContentOperation.cjs.map +0 -1
  94. package/dist/production/src/nodes/ContentOperation.js +0 -16
  95. package/dist/production/src/nodes/ContentOperation.js.map +0 -1
  96. package/dist/production/src/utils/ContentOperationSet.cjs +0 -10
  97. package/dist/production/src/utils/ContentOperationSet.cjs.map +0 -1
  98. package/dist/production/src/utils/ContentOperationSet.js +0 -10
  99. package/dist/production/src/utils/ContentOperationSet.js.map +0 -1
  100. package/dist/production/src/utils/createListArgs.cjs +0 -24
  101. package/dist/production/src/utils/createListArgs.cjs.map +0 -1
  102. package/dist/production/src/utils/createListArgs.js +0 -24
  103. package/dist/production/src/utils/createListArgs.js.map +0 -1
  104. package/dist/production/src/utils/createMutationOperationSet.cjs +0 -37
  105. package/dist/production/src/utils/createMutationOperationSet.cjs.map +0 -1
  106. package/dist/production/src/utils/createMutationOperationSet.js +0 -37
  107. package/dist/production/src/utils/createMutationOperationSet.js.map +0 -1
  108. package/dist/production/src/utils/createQueryOperationSet.cjs +0 -19
  109. package/dist/production/src/utils/createQueryOperationSet.cjs.map +0 -1
  110. package/dist/production/src/utils/createQueryOperationSet.js +0 -19
  111. package/dist/production/src/utils/createQueryOperationSet.js.map +0 -1
  112. package/dist/production/src/utils/createTypedArgs.cjs +0 -17
  113. package/dist/production/src/utils/createTypedArgs.cjs.map +0 -1
  114. package/dist/production/src/utils/createTypedArgs.js +0 -17
  115. package/dist/production/src/utils/createTypedArgs.js.map +0 -1
  116. package/dist/production/src/utils/mutationFragments.cjs +0 -55
  117. package/dist/production/src/utils/mutationFragments.cjs.map +0 -1
  118. package/dist/production/src/utils/mutationFragments.js +0 -55
  119. package/dist/production/src/utils/mutationFragments.js.map +0 -1
  120. package/dist/types/ContentClient.d.ts +0 -27
  121. package/dist/types/ContentClient.d.ts.map +0 -1
  122. package/dist/types/ContentQueryBuilder.d.ts +0 -27
  123. package/dist/types/ContentQueryBuilder.d.ts.map +0 -1
  124. package/dist/types/MutationFailedError.d.ts +0 -13
  125. package/dist/types/MutationFailedError.d.ts.map +0 -1
  126. package/dist/types/TypedContentQueryBuilder.d.ts +0 -21
  127. package/dist/types/TypedContentQueryBuilder.d.ts.map +0 -1
  128. package/dist/types/index.d.ts +0 -7
  129. package/dist/types/index.d.ts.map +0 -1
  130. package/dist/types/nodes/ContentEntitySelection.d.ts +0 -62
  131. package/dist/types/nodes/ContentEntitySelection.d.ts.map +0 -1
  132. package/dist/types/nodes/ContentOperation.d.ts +0 -30
  133. package/dist/types/nodes/ContentOperation.d.ts.map +0 -1
  134. package/dist/types/nodes/TypedEntitySelection.d.ts +0 -54
  135. package/dist/types/nodes/TypedEntitySelection.d.ts.map +0 -1
  136. package/dist/types/nodes/index.d.ts +0 -4
  137. package/dist/types/nodes/index.d.ts.map +0 -1
  138. package/dist/types/tsconfig.tsbuildinfo +0 -1
  139. package/dist/types/types/Input.d.ts +0 -201
  140. package/dist/types/types/Input.d.ts.map +0 -1
  141. package/dist/types/types/Result.d.ts +0 -60
  142. package/dist/types/types/Result.d.ts.map +0 -1
  143. package/dist/types/types/Schema.d.ts +0 -46
  144. package/dist/types/types/Schema.d.ts.map +0 -1
  145. package/dist/types/types/index.d.ts +0 -4
  146. package/dist/types/types/index.d.ts.map +0 -1
  147. package/dist/types/utils/ContentOperationSet.d.ts +0 -13
  148. package/dist/types/utils/ContentOperationSet.d.ts.map +0 -1
  149. package/dist/types/utils/createListArgs.d.ts +0 -9
  150. package/dist/types/utils/createListArgs.d.ts.map +0 -1
  151. package/dist/types/utils/createMutationOperationSet.d.ts +0 -4
  152. package/dist/types/utils/createMutationOperationSet.d.ts.map +0 -1
  153. package/dist/types/utils/createQueryOperationSet.d.ts +0 -4
  154. package/dist/types/utils/createQueryOperationSet.d.ts.map +0 -1
  155. package/dist/types/utils/createTypedArgs.d.ts +0 -3
  156. package/dist/types/utils/createTypedArgs.d.ts.map +0 -1
  157. package/dist/types/utils/mutationFragments.d.ts +0 -3
  158. package/dist/types/utils/mutationFragments.d.ts.map +0 -1
@@ -1,175 +0,0 @@
1
- import { createListArgs } from "./utils/createListArgs.js";
2
- import { createTypedArgs } from "./utils/createTypedArgs.js";
3
- import { GraphQlField, GraphQlFragmentSpread } from "@contember/graphql-builder";
4
- import { createMutationOperationSet } from "./utils/createMutationOperationSet.js";
5
- import { ContentEntitySelection } from "./nodes/ContentEntitySelection.js";
6
- import { ContentOperation } from "./nodes/ContentOperation.js";
7
- class ContentQueryBuilder {
8
- constructor(schema) {
9
- this.schema = schema;
10
- }
11
- fragment(name, fieldsCallback) {
12
- const context = this.createContext(name);
13
- const entitySelection = new ContentEntitySelection(context, []);
14
- if (!fieldsCallback) {
15
- return entitySelection;
16
- }
17
- return fieldsCallback(entitySelection);
18
- }
19
- count(name, args) {
20
- const context = this.createContext(name);
21
- const fieldName = `paginate${name}`;
22
- const typedArgs = createTypedArgs(args, {
23
- filter: `${context.entity.name}Where`
24
- });
25
- const selectionSet = [
26
- new GraphQlField(null, "pageInfo", {}, [
27
- new GraphQlField(null, "totalCount")
28
- ])
29
- ];
30
- return new ContentOperation("query", fieldName, typedArgs, selectionSet, (it) => {
31
- return it.pageInfo.totalCount;
32
- });
33
- }
34
- list(name, args, fields) {
35
- const context = this.createContext(name);
36
- const fieldName = `list${name}`;
37
- const typedArgs = createListArgs(context.entity, args);
38
- const selection = this.resolveSelection(fields, context);
39
- return new ContentOperation("query", fieldName, typedArgs, selection.selectionSet, (it) => {
40
- const transformFn = selection.transformFn;
41
- if (transformFn) {
42
- return it.map((el) => transformFn(el, {
43
- rootValue: it
44
- }));
45
- }
46
- return it;
47
- });
48
- }
49
- get(name, args, fields) {
50
- const context = this.createContext(name);
51
- const fieldName = `get${name}`;
52
- const typedArgs = createTypedArgs(args, {
53
- by: `${context.entity.name}UniqueWhere!`,
54
- filter: `${context.entity.name}Where`
55
- });
56
- const selection = this.resolveSelection(fields, context);
57
- return new ContentOperation("query", fieldName, typedArgs, selection.selectionSet, (it) => {
58
- if (it && selection.transformFn) {
59
- return selection.transformFn(it, {
60
- rootValue: it
61
- });
62
- }
63
- return it;
64
- });
65
- }
66
- create(name, args, fields) {
67
- const entity = this.getEntity(name);
68
- const typedArgs = createTypedArgs(args, {
69
- data: `${entity.name}CreateInput!`
70
- });
71
- return this.createMutationOperation(name, "create", typedArgs, fields);
72
- }
73
- update(name, args, fields) {
74
- const entity = this.getEntity(name);
75
- const typedArgs = createTypedArgs(args, {
76
- data: `${entity.name}UpdateInput!`,
77
- by: `${entity.name}UniqueWhere!`,
78
- filter: `${entity.name}Where`
79
- });
80
- return this.createMutationOperation(name, "update", typedArgs, fields);
81
- }
82
- upsert(name, args, fields) {
83
- const entity = this.getEntity(name);
84
- const typedArgs = createTypedArgs(args, {
85
- update: `${entity.name}UpdateInput!`,
86
- create: `${entity.name}CreateInput!`,
87
- by: `${entity.name}UniqueWhere!`,
88
- filter: `${entity.name}Where`
89
- });
90
- return this.createMutationOperation(name, "upsert", typedArgs, fields);
91
- }
92
- delete(name, args, fields) {
93
- const entity = this.getEntity(name);
94
- const typedArgs = createTypedArgs(args, {
95
- by: `${entity.name}UniqueWhere!`,
96
- filter: `${entity.name}Where`
97
- });
98
- return this.createMutationOperation(name, "delete", typedArgs, fields);
99
- }
100
- createMutationOperation(name, operation, args, fields) {
101
- const context = this.createContext(name);
102
- const fieldName = `${operation}${name}`;
103
- const nodeSelection = fields ? this.resolveSelection(fields, context) : void 0;
104
- const selectionSet = this.createMutationSelection(operation, nodeSelection?.selectionSet);
105
- return new ContentOperation("mutation", fieldName, args, selectionSet, (it) => {
106
- if (!nodeSelection?.transformFn) {
107
- return it;
108
- }
109
- return {
110
- ...it,
111
- node: it.node ? nodeSelection.transformFn(it.node, {
112
- rootValue: it.node
113
- }) : null
114
- };
115
- });
116
- }
117
- transaction(input, options = {}) {
118
- const combined = createMutationOperationSet(input);
119
- const transactionArgs = createTypedArgs({ options }, {
120
- options: "MutationTransactionOptions"
121
- });
122
- const items = [
123
- ...this.createMutationSelection("transaction"),
124
- ...combined.selection
125
- ];
126
- return new ContentOperation("mutation", "transaction", transactionArgs, items, ({ ok, errorMessage, errors, validation, ...data }) => {
127
- return {
128
- ok,
129
- errorMessage,
130
- errors,
131
- validation,
132
- data: combined.parse(data)
133
- };
134
- });
135
- }
136
- createMutationSelection(operation, selection) {
137
- const items = [
138
- new GraphQlField(null, "ok"),
139
- new GraphQlField(null, "errorMessage"),
140
- new GraphQlField(null, "errors", {}, [
141
- new GraphQlFragmentSpread("MutationError")
142
- ])
143
- ];
144
- if (operation !== "delete") {
145
- items.push(new GraphQlField(null, "validation", {}, [
146
- new GraphQlFragmentSpread("ValidationResult")
147
- ]));
148
- }
149
- if (selection) {
150
- items.push(new GraphQlField(null, "node", {}, selection));
151
- }
152
- return items;
153
- }
154
- resolveSelection(fields, context) {
155
- return typeof fields === "function" ? fields(new ContentEntitySelection(context, [])) : fields;
156
- }
157
- createContext(name) {
158
- const entity = this.getEntity(name);
159
- return {
160
- entity,
161
- schema: this.schema
162
- };
163
- }
164
- getEntity(name) {
165
- const entity = this.schema.entities[name];
166
- if (!entity) {
167
- throw new Error(`Entity ${name} not found`);
168
- }
169
- return entity;
170
- }
171
- }
172
- export {
173
- ContentQueryBuilder
174
- };
175
- //# sourceMappingURL=ContentQueryBuilder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContentQueryBuilder.js","sources":["../../../../packages/client-content/src/ContentQueryBuilder.ts"],"sourcesContent":["import { ContentClientInput, MutationResult, SchemaNames, TransactionResult } from './types'\nimport { ContentEntitySelection, ContentEntitySelectionCallback, ContentEntitySelectionContext, ContentMutation, ContentOperation, ContentQuery } from './nodes'\nimport { createListArgs } from './utils/createListArgs'\nimport { createTypedArgs } from './utils/createTypedArgs'\nimport { Input } from '@contember/schema'\nimport { GraphQlField, GraphQlFieldTypedArgs, GraphQlFragmentSpread, GraphQlSelectionSet } from '@contember/graphql-builder'\nimport { createMutationOperationSet } from './utils/createMutationOperationSet'\n\nexport type EntitySelectionOrCallback =\n\t| ContentEntitySelection\n\t| ContentEntitySelectionCallback\n\nexport type MutationTransactionOptions = {\n\tdeferForeignKeyConstraints?: boolean\n\tdeferUniqueConstraints?: boolean\n}\n\ntype MutationOperation = 'create' | 'update' | 'delete' | 'upsert' | 'transaction'\n\nexport class ContentQueryBuilder {\n\tconstructor(private readonly schema: SchemaNames) {\n\t}\n\n\n\tpublic fragment(name: string, fieldsCallback?: ContentEntitySelectionCallback): ContentEntitySelection {\n\t\tconst context = this.createContext(name)\n\n\t\tconst entitySelection = new ContentEntitySelection(context, [])\n\t\tif (!fieldsCallback) {\n\t\t\treturn entitySelection\n\t\t}\n\t\treturn fieldsCallback(entitySelection)\n\t}\n\n\n\n\tpublic count(name: string, args: Pick<ContentClientInput.AnyListQueryInput, 'filter'>): ContentQuery<number> {\n\t\tconst context = this.createContext(name)\n\t\tconst fieldName = `paginate${name}`\n\t\tconst typedArgs = createTypedArgs(args, {\n\t\t\tfilter: `${context.entity.name}Where`,\n\t\t})\n\t\tconst selectionSet: GraphQlSelectionSet = [\n\t\t\tnew GraphQlField(null, 'pageInfo', {}, [\n\t\t\t\tnew GraphQlField(null, 'totalCount'),\n\t\t\t]),\n\t\t]\n\n\t\treturn new ContentOperation('query', fieldName, typedArgs, selectionSet, it => {\n\t\t\treturn it.pageInfo.totalCount\n\t\t})\n\t}\n\n\n\tpublic list(name: string, args: ContentClientInput.AnyListQueryInput, fields: EntitySelectionOrCallback): ContentQuery<any[]> {\n\t\tconst context = this.createContext(name)\n\t\tconst fieldName = `list${name}`\n\t\tconst typedArgs = createListArgs(context.entity, args)\n\t\tconst selection = this.resolveSelection(fields, context)\n\n\t\treturn new ContentOperation('query', fieldName, typedArgs, selection.selectionSet, it => {\n\t\t\tconst transformFn = selection.transformFn\n\t\t\tif (transformFn) {\n\t\t\t\treturn it.map((el: any) => transformFn(el, {\n\t\t\t\t\trootValue: it,\n\t\t\t\t}))\n\t\t\t}\n\t\t\treturn it\n\t\t})\n\t}\n\n\n\tpublic get(name: string, args: Input.UniqueQueryInput, fields: EntitySelectionOrCallback): ContentQuery<Record<string, unknown> | null> {\n\t\tconst context = this.createContext(name)\n\t\tconst fieldName = `get${name}`\n\t\tconst typedArgs = createTypedArgs(args, {\n\t\t\tby: `${context.entity.name}UniqueWhere!`,\n\t\t\tfilter: `${context.entity.name}Where`,\n\t\t})\n\t\tconst selection = this.resolveSelection(fields, context)\n\n\t\treturn new ContentOperation('query', fieldName, typedArgs, selection.selectionSet, it => {\n\t\t\tif (it && selection.transformFn) {\n\t\t\t\treturn selection.transformFn(it, {\n\t\t\t\t\trootValue: it,\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn it\n\t\t})\n\t}\n\n\n\tpublic create(name: string, args: Input.CreateInput, fields?: EntitySelectionOrCallback): ContentMutation<MutationResult> {\n\n\t\tconst entity = this.getEntity(name)\n\t\tconst typedArgs = createTypedArgs(args, {\n\t\t\tdata: `${entity.name}CreateInput!`,\n\t\t})\n\n\t\treturn this.createMutationOperation(name, 'create', typedArgs, fields)\n\t}\n\n\tpublic update(name: string, args: Input.UpdateInput, fields?: EntitySelectionOrCallback): ContentMutation<MutationResult> {\n\n\t\tconst entity = this.getEntity(name)\n\t\tconst typedArgs = createTypedArgs(args, {\n\t\t\tdata: `${entity.name}UpdateInput!`,\n\t\t\tby: `${entity.name}UniqueWhere!`,\n\t\t\tfilter: `${entity.name}Where`,\n\t\t})\n\t\treturn this.createMutationOperation(name, 'update', typedArgs, fields)\n\t}\n\n\n\tpublic upsert(name: string, args: Input.UpsertInput, fields?: EntitySelectionOrCallback): ContentMutation<MutationResult> {\n\n\t\tconst entity = this.getEntity(name)\n\t\tconst typedArgs = createTypedArgs(args, {\n\t\t\tupdate: `${entity.name}UpdateInput!`,\n\t\t\tcreate: `${entity.name}CreateInput!`,\n\t\t\tby: `${entity.name}UniqueWhere!`,\n\t\t\tfilter: `${entity.name}Where`,\n\t\t})\n\t\treturn this.createMutationOperation(name, 'upsert', typedArgs, fields)\n\t}\n\n\n\tpublic delete(name: string, args: Input.UniqueQueryInput, fields?: EntitySelectionOrCallback): ContentMutation<MutationResult> {\n\n\t\tconst entity = this.getEntity(name)\n\t\tconst typedArgs = createTypedArgs(args, {\n\t\t\tby: `${entity.name}UniqueWhere!`,\n\t\t\tfilter: `${entity.name}Where`,\n\t\t})\n\t\treturn this.createMutationOperation(name, 'delete', typedArgs, fields)\n\t}\n\n\n\tprivate createMutationOperation(name: string, operation: MutationOperation, args: GraphQlFieldTypedArgs, fields?: EntitySelectionOrCallback): ContentMutation<MutationResult> {\n\n\t\tconst context = this.createContext(name)\n\t\tconst fieldName = `${operation}${name}`\n\t\tconst nodeSelection = fields ? this.resolveSelection(fields, context) : undefined\n\t\tconst selectionSet = this.createMutationSelection(operation, nodeSelection?.selectionSet)\n\n\t\treturn new ContentOperation('mutation', fieldName, args, selectionSet, it => {\n\t\t\tif (!nodeSelection?.transformFn) {\n\t\t\t\treturn it\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...it,\n\t\t\t\tnode: it.node ? nodeSelection.transformFn(it.node, {\n\t\t\t\t\trootValue: it.node,\n\t\t\t\t}) : null,\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic transaction(\n\t\tinput: Record<string, ContentMutation<any> | ContentQuery<any>> | ContentMutation<any> | ContentMutation<any>[],\n\t\toptions: MutationTransactionOptions = {},\n\t): ContentMutation<TransactionResult<any>> {\n\t\tconst combined = createMutationOperationSet(input)\n\n\t\tconst transactionArgs = createTypedArgs({ options }, {\n\t\t\toptions: 'MutationTransactionOptions',\n\t\t})\n\t\tconst items = [\n\t\t\t...this.createMutationSelection('transaction'),\n\t\t\t...combined.selection,\n\t\t]\n\t\treturn new ContentOperation<TransactionResult<any>, 'mutation'>('mutation', 'transaction', transactionArgs, items, ({ ok, errorMessage, errors, validation, ...data }) => {\n\t\t\treturn {\n\t\t\t\tok,\n\t\t\t\terrorMessage,\n\t\t\t\terrors,\n\t\t\t\tvalidation,\n\t\t\t\tdata: combined.parse(data),\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate createMutationSelection(operation: MutationOperation, selection?: GraphQlSelectionSet): GraphQlSelectionSet {\n\t\tconst items: GraphQlSelectionSet = [\n\t\t\tnew GraphQlField(null, 'ok'),\n\t\t\tnew GraphQlField(null, 'errorMessage'),\n\t\t\tnew GraphQlField(null, 'errors', {}, [\n\t\t\t\tnew GraphQlFragmentSpread('MutationError'),\n\t\t\t]),\n\t\t]\n\t\tif (operation !== 'delete') {\n\t\t\titems.push(new GraphQlField(null, 'validation', {}, [\n\t\t\t\tnew GraphQlFragmentSpread('ValidationResult'),\n\t\t\t]))\n\t\t}\n\t\tif (selection) {\n\t\t\titems.push(new GraphQlField(null, 'node', {}, selection))\n\t\t}\n\t\treturn items\n\t}\n\n\n\tprivate resolveSelection(\n\t\tfields: EntitySelectionOrCallback,\n\t\tcontext: ContentEntitySelectionContext<string>,\n\t) {\n\t\treturn (typeof fields === 'function' ? fields(new ContentEntitySelection(context, [])) : fields)\n\t}\n\n\tprivate createContext(\n\t\tname: string,\n\t): ContentEntitySelectionContext<string> {\n\t\tconst entity = this.getEntity(name)\n\t\treturn {\n\t\t\tentity: entity,\n\t\t\tschema: this.schema,\n\t\t}\n\t}\n\n\tprivate getEntity(name: string) {\n\t\tconst entity = this.schema.entities[name]\n\t\tif (!entity) {\n\t\t\tthrow new Error(`Entity ${name} not found`)\n\t\t}\n\t\treturn entity\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAmBO,MAAM,oBAAoB;AAAA,EAChC,YAA6B,QAAqB;AAArB,SAAA,SAAA;AAAA,EAAA;AAAA,EAItB,SAAS,MAAc,gBAAyE;AAChG,UAAA,UAAU,KAAK,cAAc,IAAI;AAEvC,UAAM,kBAAkB,IAAI,uBAAuB,SAAS,CAAA,CAAE;AAC9D,QAAI,CAAC,gBAAgB;AACb,aAAA;AAAA,IAAA;AAER,WAAO,eAAe,eAAe;AAAA,EAAA;AAAA,EAK/B,MAAM,MAAc,MAAkF;AACtG,UAAA,UAAU,KAAK,cAAc,IAAI;AACjC,UAAA,YAAY,WAAW,IAAI;AAC3B,UAAA,YAAY,gBAAgB,MAAM;AAAA,MACvC,QAAQ,GAAG,QAAQ,OAAO,IAAI;AAAA,IAAA,CAC9B;AACD,UAAM,eAAoC;AAAA,MACzC,IAAI,aAAa,MAAM,YAAY,IAAI;AAAA,QACtC,IAAI,aAAa,MAAM,YAAY;AAAA,MACnC,CAAA;AAAA,IACF;AAEA,WAAO,IAAI,iBAAiB,SAAS,WAAW,WAAW,cAAc,CAAM,OAAA;AAC9E,aAAO,GAAG,SAAS;AAAA,IAAA,CACnB;AA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AAA;AAAA,EAGlF,cACP,MACwC;AAClC,UAAA,SAAS,KAAK,UAAU,IAAI;AAC3B,WAAA;AAAA,MACN;AAAA,MACA,QAAQ,KAAK;AAAA,IACd;AAAA,EAAA;AAAA,EAGO,UAAU,MAAc;AAC/B,UAAM,SAAS,KAAK,OAAO,SAAS,IAAI;AACxC,QAAI,CAAC,QAAQ;AACZ,YAAM,IAAI,MAAM,UAAU,IAAI,YAAY;AAAA,IAAA;AAEpC,WAAA;AAAA,EAAA;AAET;"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- class MutationFailedError extends Error {
4
- constructor(message, request, result) {
5
- super(message);
6
- this.request = request;
7
- this.result = result;
8
- }
9
- }
10
- exports.MutationFailedError = MutationFailedError;
11
- //# sourceMappingURL=MutationFailedError.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MutationFailedError.cjs","sources":["../../../../packages/client-content/src/MutationFailedError.ts"],"sourcesContent":["import { MutationError, ValidationResult } from './types'\nimport { ContentMutation } from './nodes'\n\nexport class MutationFailedError<Value extends {\n\treadonly ok: false\n\treadonly errorMessage: string\n\treadonly errors: MutationError[]\n\treadonly validation: ValidationResult\n}> extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly request: ContentMutation<Value>,\n\t\tpublic readonly result: Value,\n\t) {\n\t\tsuper(message)\n\t}\n}\n"],"names":[],"mappings":";;AAGO,MAAM,4BAKF,MAAM;AAAA,EAChB,YACC,SACgB,SACA,QACf;AACD,UAAM,OAAO;AAHG,SAAA,UAAA;AACA,SAAA,SAAA;AAAA,EAAA;AAIlB;;"}
@@ -1,11 +0,0 @@
1
- class MutationFailedError extends Error {
2
- constructor(message, request, result) {
3
- super(message);
4
- this.request = request;
5
- this.result = result;
6
- }
7
- }
8
- export {
9
- MutationFailedError
10
- };
11
- //# sourceMappingURL=MutationFailedError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MutationFailedError.js","sources":["../../../../packages/client-content/src/MutationFailedError.ts"],"sourcesContent":["import { MutationError, ValidationResult } from './types'\nimport { ContentMutation } from './nodes'\n\nexport class MutationFailedError<Value extends {\n\treadonly ok: false\n\treadonly errorMessage: string\n\treadonly errors: MutationError[]\n\treadonly validation: ValidationResult\n}> extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly request: ContentMutation<Value>,\n\t\tpublic readonly result: Value,\n\t) {\n\t\tsuper(message)\n\t}\n}\n"],"names":[],"mappings":"AAGO,MAAM,4BAKF,MAAM;AAAA,EAChB,YACC,SACgB,SACA,QACf;AACD,UAAM,OAAO;AAHG,SAAA,UAAA;AACA,SAAA,SAAA;AAAA,EAAA;AAIlB;"}
@@ -1,219 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const createListArgs = require("../utils/createListArgs.cjs");
4
- const graphqlBuilder = require("@contember/graphql-builder");
5
- class ContentEntitySelection {
6
- /**
7
- * @internal
8
- */
9
- constructor(context, selectionSet, transformFn) {
10
- this.context = context;
11
- this.selectionSet = selectionSet;
12
- this.transformFn = transformFn;
13
- }
14
- $(field, argsOrSelection, selectionIn) {
15
- const [args, selection] = typeof argsOrSelection === "function" || argsOrSelection instanceof ContentEntitySelection ? [{}, argsOrSelection] : [argsOrSelection ?? {}, selectionIn];
16
- if (field === "__typename") {
17
- return this.withField(new graphqlBuilder.GraphQlField(args.as ?? null, "__typename"));
18
- }
19
- const fieldInfo = this.context.entity.fields[field];
20
- if (!fieldInfo) {
21
- if ("by" in args && field.includes("By")) {
22
- if (!selection) {
23
- throw new Error(`Selection is required for ${this.context.entity.name}.${field}.`);
24
- }
25
- return this._manyBy(field, args, selection);
26
- }
27
- throw new Error(`Field ${this.context.entity.name}.${field} does not exist.`);
28
- }
29
- if (fieldInfo.type === "column") {
30
- return this._column(field, args);
31
- }
32
- if (fieldInfo.type === "many") {
33
- if (!selection) {
34
- throw new Error(`Selection is required for ${this.context.entity.name}.${field}.`);
35
- }
36
- return this._many(field, args, selection);
37
- }
38
- if (fieldInfo.type === "one") {
39
- if (!selection) {
40
- throw new Error(`Selection is required for ${this.context.entity.name}.${field}.`);
41
- }
42
- return this._one(field, args, selection);
43
- }
44
- throw new Error(`Unknown field type ${fieldInfo.type}.`);
45
- }
46
- $$() {
47
- const columns = this.context.entity.scalars;
48
- const nodes = [
49
- ...this.selectionSet,
50
- ...columns.map((col) => new graphqlBuilder.GraphQlField(null, col))
51
- ];
52
- return new ContentEntitySelection(this.context, nodes);
53
- }
54
- omit(...fields) {
55
- return new ContentEntitySelection(
56
- this.context,
57
- this.selectionSet.filter((it) => {
58
- if (!(it instanceof graphqlBuilder.GraphQlField)) {
59
- return true;
60
- }
61
- const alias = it.alias ?? it.name;
62
- return !fields.includes(alias);
63
- })
64
- );
65
- }
66
- meta(field, flags) {
67
- const metaField = this.selectionSet.find((it) => it instanceof graphqlBuilder.GraphQlField && it.name === "_meta");
68
- const selectionWithoutMeta = metaField ? this.selectionSet.filter((it) => it !== metaField) : this.selectionSet;
69
- const flagFields = [];
70
- for (const flag of flags) {
71
- flagFields.push(new graphqlBuilder.GraphQlField(null, flag));
72
- }
73
- return new ContentEntitySelection(this.context, [
74
- ...selectionWithoutMeta,
75
- new graphqlBuilder.GraphQlField(null, "_meta", void 0, [
76
- ...metaField?.selectionSet ?? [],
77
- new graphqlBuilder.GraphQlField(null, field, void 0, flagFields)
78
- ])
79
- ]);
80
- }
81
- transform(transform) {
82
- return new ContentEntitySelection(this.context, this.selectionSet, !this.transformFn ? transform : (value, ctx) => {
83
- return transform(this.transformFn(value, ctx), ctx);
84
- });
85
- }
86
- _column(name, args = {}) {
87
- let fieldInfo = this.context.entity.fields[name];
88
- if (!fieldInfo) {
89
- throw new Error(`Field ${this.context.entity.name}.${name} does not exist.`);
90
- }
91
- if (fieldInfo?.type !== "column") {
92
- throw new Error(`Field ${this.context.entity.name}.${name} is not a column.`);
93
- }
94
- const alias = args.as ?? name;
95
- const field = new graphqlBuilder.GraphQlField(alias, name, {});
96
- return this.withField(field);
97
- }
98
- _many(name, args, fields) {
99
- const alias = args.as ?? name;
100
- const fieldInfo = this.context.entity.fields[name];
101
- if (!fieldInfo) {
102
- throw new Error(`Field ${this.context.entity.name}.${name} does not exist.`);
103
- }
104
- if (fieldInfo?.type !== "many") {
105
- throw new Error(`Field ${this.context.entity.name}.${name} is not a has-many relation.`);
106
- }
107
- const entity = this.context.schema.entities[fieldInfo.entity];
108
- const newContext = {
109
- entity,
110
- schema: this.context.schema
111
- };
112
- const entitySelection = typeof fields === "function" ? fields(new ContentEntitySelection(newContext, [])) : fields;
113
- const newObjectField = new graphqlBuilder.GraphQlField(
114
- alias,
115
- name,
116
- createListArgs.createListArgs(entity, args),
117
- entitySelection.selectionSet
118
- );
119
- const selectionWithField = this.withField(newObjectField);
120
- const nestedTransform = entitySelection.transformFn;
121
- if (!nestedTransform) {
122
- return selectionWithField;
123
- }
124
- return selectionWithField.withFieldTransform(alias, (it) => it.map(nestedTransform));
125
- }
126
- _manyBy(name, args, fields) {
127
- const alias = args.as ?? name;
128
- const byField = Object.keys(args.by)[0];
129
- const relationField = name.substring(0, name.length - byField.length - 2);
130
- const field = this.context.entity.fields[relationField];
131
- if (!field) {
132
- throw new Error(`Field ${this.context.entity.name}.${relationField} does not exist.`);
133
- }
134
- if (field?.type !== "many") {
135
- throw new Error(`Field ${this.context.entity.name}.${relationField} is not a has-many relation.`);
136
- }
137
- const entity = this.context.schema.entities[field.entity];
138
- const newContext = {
139
- entity,
140
- schema: this.context.schema
141
- };
142
- const fieldUpperFirst = name.charAt(0).toUpperCase() + name.slice(1);
143
- const argsWithType = {
144
- filter: {
145
- graphQlType: `${entity.name}Where`,
146
- value: args.filter
147
- },
148
- by: {
149
- graphQlType: `${this.context.entity.name}${fieldUpperFirst}UniqueWhere!`,
150
- value: args.by
151
- }
152
- };
153
- const entitySelection = typeof fields === "function" ? fields(new ContentEntitySelection(newContext, [])) : fields;
154
- const newObjectField = new graphqlBuilder.GraphQlField(
155
- alias,
156
- name,
157
- argsWithType,
158
- entitySelection.selectionSet
159
- );
160
- const selectionWithField = this.withField(newObjectField);
161
- const nestedTransform = entitySelection.transformFn;
162
- if (!nestedTransform) {
163
- return selectionWithField;
164
- }
165
- return selectionWithField.withFieldTransform(alias, (it, ctx) => it !== null ? nestedTransform(it, ctx) : null);
166
- }
167
- _one(name, args, fields) {
168
- const alias = args.as ?? name;
169
- const fieldInfo = this.context.entity.fields[name];
170
- if (!fieldInfo) {
171
- throw new Error(`Field ${this.context.entity.name}.${name} does not exist.`);
172
- }
173
- if (fieldInfo?.type !== "one") {
174
- throw new Error(`Field ${this.context.entity.name}.${name} is not a has-one relation.`);
175
- }
176
- const entity = this.context.schema.entities[fieldInfo.entity];
177
- const newContext = {
178
- entity,
179
- schema: this.context.schema
180
- };
181
- const argsWithType = {
182
- filter: {
183
- graphQlType: `${entity.name}Where`,
184
- value: args.filter
185
- }
186
- };
187
- const entitySelection = typeof fields === "function" ? fields(new ContentEntitySelection(newContext, [])) : fields;
188
- const newObjectField = new graphqlBuilder.GraphQlField(
189
- alias,
190
- name,
191
- argsWithType,
192
- entitySelection.selectionSet
193
- );
194
- const selectionWithField = this.withField(newObjectField);
195
- const nestedTransform = entitySelection.transformFn;
196
- if (!nestedTransform) {
197
- return selectionWithField;
198
- }
199
- return selectionWithField.withFieldTransform(alias, (it, ctx) => it !== null ? nestedTransform(it, ctx) : null);
200
- }
201
- withField(field) {
202
- return new ContentEntitySelection(this.context, [
203
- ...this.selectionSet,
204
- field
205
- ], this.transformFn);
206
- }
207
- withFieldTransform(alias, transform) {
208
- return new ContentEntitySelection(this.context, this.selectionSet, (value, ctx) => {
209
- const transformedValue = transform(value[alias], ctx);
210
- const newValue = {
211
- ...value,
212
- [alias]: transformedValue
213
- };
214
- return this.transformFn ? this.transformFn(newValue, ctx) : newValue;
215
- });
216
- }
217
- }
218
- exports.ContentEntitySelection = ContentEntitySelection;
219
- //# sourceMappingURL=ContentEntitySelection.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContentEntitySelection.cjs","sources":["../../../../../packages/client-content/src/nodes/ContentEntitySelection.ts"],"sourcesContent":["import { createListArgs } from '../utils/createListArgs'\nimport { ContentClientInput, SchemaEntityNames, SchemaNames } from '../types'\nimport { Input } from '@contember/schema'\nimport { GraphQlField, GraphQlFieldTypedArgs, GraphQlSelectionSet } from '@contember/graphql-builder'\n\n/**\n * @internal\n */\nexport type ContentEntitySelectionContext<Name extends string> = {\n\tentity: SchemaEntityNames<Name>\n\tschema: SchemaNames\n}\n\nexport type ContentEntitySelectionCallback = (select: ContentEntitySelection) => ContentEntitySelection\n\nexport type EntitySelectionCommonInput<Alias extends string | null = string | null> = { as?: Alias }\nexport type EntitySelectionManyArgs<Alias extends string | null = string | null> = ContentClientInput.AnyListQueryInput & EntitySelectionCommonInput<Alias>\nexport type EntitySelectionManyByArgs<Alias extends string | null = string | null> = { by: Input.UniqueWhere; filter?: Input.Where } & EntitySelectionCommonInput<Alias>\nexport type EntitySelectionOneArgs<Alias extends string | null = string | null> = { filter?: Input.Where } & EntitySelectionCommonInput<Alias>\nexport type EntitySelectionColumnArgs<Alias extends string | null = string | null> = EntitySelectionCommonInput<Alias>\n\nexport type EntitySelectionAnyArgs =\n\t| EntitySelectionColumnArgs\n\t| EntitySelectionManyArgs\n\t| EntitySelectionManyByArgs\n\t| EntitySelectionOneArgs\n\nexport type ContentEntitySelectionOrCallback = ContentEntitySelectionCallback | ContentEntitySelection\n\n\nexport type ContentTransformContext = {\n\trootValue: unknown\n}\n\nexport class ContentEntitySelection {\n\n\t/**\n\t * @internal\n\t */\n\tconstructor(\n\t\t/** @internal */\n\t\tpublic readonly context: ContentEntitySelectionContext<string>,\n\t\t/** @internal */\n\t\tpublic readonly selectionSet: GraphQlSelectionSet,\n\t\t/** @internal */\n\t\tpublic readonly transformFn?: (value: any, ctx: ContentTransformContext) => any,\n\t) {\n\t}\n\n\n\t$(field: string, args?: EntitySelectionColumnArgs): ContentEntitySelection\n\t$(field: string, args: EntitySelectionManyArgs, selection: ContentEntitySelectionOrCallback): ContentEntitySelection\n\t$(field: string, args: EntitySelectionManyByArgs, selection: ContentEntitySelectionOrCallback): ContentEntitySelection\n\t$(field: string, args: EntitySelectionOneArgs, selection: ContentEntitySelectionOrCallback): ContentEntitySelection\n\t$(field: string, selection: ContentEntitySelectionOrCallback): ContentEntitySelection\n\n\t$(field: string, argsOrSelection?: EntitySelectionAnyArgs | ContentEntitySelectionOrCallback, selectionIn?: ContentEntitySelectionOrCallback): ContentEntitySelection {\n\t\tconst [args, selection] = typeof argsOrSelection === 'function' || argsOrSelection instanceof ContentEntitySelection\n\t\t\t? [{}, argsOrSelection]\n\t\t\t: [argsOrSelection ?? {}, selectionIn]\n\t\tif (field === '__typename') {\n\t\t\treturn this.withField(new GraphQlField(args.as ?? null, '__typename'))\n\t\t}\n\t\tconst fieldInfo = this.context.entity.fields[field]\n\t\tif (!fieldInfo) {\n\t\t\tif ('by' in args && field.includes('By')) {\n\t\t\t\tif (!selection) {\n\t\t\t\t\tthrow new Error(`Selection is required for ${this.context.entity.name}.${field}.`)\n\t\t\t\t}\n\t\t\t\treturn this._manyBy(field, args as EntitySelectionManyByArgs, selection)\n\t\t\t}\n\n\t\t\tthrow new Error(`Field ${this.context.entity.name}.${field} does not exist.`)\n\t\t}\n\t\tif (fieldInfo.type === 'column') {\n\t\t\treturn this._column(field, args as EntitySelectionColumnArgs)\n\t\t}\n\t\tif (fieldInfo.type === 'many') {\n\t\t\tif (!selection) {\n\t\t\t\tthrow new Error(`Selection is required for ${this.context.entity.name}.${field}.`)\n\t\t\t}\n\t\t\treturn this._many(field, args as EntitySelectionManyArgs, selection)\n\t\t}\n\t\tif (fieldInfo.type === 'one') {\n\t\t\tif (!selection) {\n\t\t\t\tthrow new Error(`Selection is required for ${this.context.entity.name}.${field}.`)\n\t\t\t}\n\t\t\treturn this._one(field, args as EntitySelectionOneArgs, selection)\n\t\t}\n\t\tthrow new Error(`Unknown field type ${fieldInfo.type}.`)\n\t}\n\n\t$$(): ContentEntitySelection {\n\t\tconst columns = this.context.entity.scalars\n\t\tconst nodes = [\n\t\t\t...this.selectionSet,\n\t\t\t...columns.map(col => new GraphQlField(null, col)),\n\t\t]\n\t\treturn new ContentEntitySelection(this.context, nodes)\n\t}\n\n\tomit(...fields: string[]): ContentEntitySelection {\n\t\treturn new ContentEntitySelection(\n\t\t\tthis.context,\n\t\t\tthis.selectionSet.filter(it => {\n\t\t\t\tif (!(it instanceof GraphQlField)) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\tconst alias = it.alias ?? it.name\n\t\t\t\treturn !fields.includes(alias)\n\t\t\t}),\n\t\t)\n\t}\n\n\tmeta(field: string, flags: ('readable' | 'updatable')[]): ContentEntitySelection {\n\t\tconst metaField = this.selectionSet.find((it): it is GraphQlField => it instanceof GraphQlField && it.name === '_meta')\n\t\tconst selectionWithoutMeta = metaField ? this.selectionSet.filter(it => it !== metaField) : this.selectionSet\n\n\t\tconst flagFields: GraphQlField[] = []\n\t\tfor (const flag of flags) {\n\t\t\tflagFields.push(new GraphQlField(null, flag))\n\t\t}\n\n\t\treturn new ContentEntitySelection(this.context, [\n\t\t\t...selectionWithoutMeta,\n\t\t\tnew GraphQlField(null, '_meta', undefined, [\n\t\t\t\t...metaField?.selectionSet ?? [],\n\t\t\t\tnew GraphQlField(null, field, undefined, flagFields),\n\t\t\t]),\n\t\t])\n\t}\n\n\n\ttransform(transform: (value: any, context: ContentTransformContext) => any): ContentEntitySelection {\n\t\treturn new ContentEntitySelection(this.context, this.selectionSet, !this.transformFn ? transform : (value, ctx) => {\n\t\t\treturn transform(this.transformFn!(value, ctx), ctx)\n\t\t})\n\t}\n\n\tprivate _column(\n\t\tname: string,\n\t\targs: EntitySelectionCommonInput = {},\n\t): ContentEntitySelection {\n\t\tlet fieldInfo = this.context.entity.fields[name]\n\t\tif (!fieldInfo) {\n\t\t\tthrow new Error(`Field ${this.context.entity.name}.${name} does not exist.`)\n\t\t}\n\t\tif (fieldInfo?.type !== 'column') {\n\t\t\tthrow new Error(`Field ${this.context.entity.name}.${name} is not a column.`)\n\t\t}\n\n\t\tconst alias = args.as ?? name\n\n\t\tconst field = new GraphQlField(alias, name, {})\n\t\treturn this.withField(field)\n\t}\n\n\n\tprivate _many(\n\t\tname: string,\n\t\targs: EntitySelectionManyArgs,\n\t\tfields:\n\t\t\t| ContentEntitySelectionCallback\n\t\t\t| ContentEntitySelection,\n\t): ContentEntitySelection{\n\t\tconst alias = args.as ?? name\n\t\tconst fieldInfo = this.context.entity.fields[name]\n\t\tif (!fieldInfo) {\n\t\t\tthrow new Error(`Field ${this.context.entity.name}.${name} does not exist.`)\n\t\t}\n\t\tif (fieldInfo?.type !== 'many') {\n\t\t\tthrow new Error(`Field ${this.context.entity.name}.${name} is not a has-many relation.`)\n\t\t}\n\t\tconst entity = this.context.schema.entities[fieldInfo.entity]\n\n\t\tconst newContext = {\n\t\t\tentity: entity,\n\t\t\tschema: this.context.schema,\n\t\t}\n\n\t\tconst entitySelection = typeof fields === 'function' ? fields(new ContentEntitySelection(newContext, [])) : fields\n\t\tconst newObjectField = new GraphQlField(\n\t\t\talias,\n\t\t\tname,\n\t\t\tcreateListArgs(entity, args),\n\t\t\tentitySelection.selectionSet,\n\t\t)\n\t\tconst selectionWithField = this.withField(newObjectField)\n\t\tconst nestedTransform = entitySelection.transformFn\n\t\tif (!nestedTransform) {\n\t\t\treturn selectionWithField\n\t\t}\n\t\treturn selectionWithField.withFieldTransform(alias, it => it.map(nestedTransform))\n\t}\n\n\n\tprivate _manyBy(\n\t\tname: string,\n\t\targs: EntitySelectionManyByArgs,\n\t\tfields:\n\t\t\t| ContentEntitySelectionCallback\n\t\t\t| ContentEntitySelection,\n\t): ContentEntitySelection {\n\t\tconst alias = args.as ?? name\n\t\tconst byField = Object.keys(args.by)[0]\n\t\tconst relationField = name.substring(0, name.length - byField.length - 2)\n\n\t\tconst field = this.context.entity.fields[relationField]\n\t\tif (!field) {\n\t\t\tthrow new Error(`Field ${this.context.entity.name}.${relationField} does not exist.`)\n\t\t}\n\t\tif (field?.type !== 'many') {\n\t\t\tthrow new Error(`Field ${this.context.entity.name}.${relationField} is not a has-many relation.`)\n\t\t}\n\t\tconst entity = this.context.schema.entities[field.entity]\n\t\tconst newContext = {\n\t\t\tentity: entity,\n\t\t\tschema: this.context.schema,\n\t\t}\n\t\tconst fieldUpperFirst = name.charAt(0).toUpperCase() + name.slice(1)\n\n\t\tconst argsWithType: GraphQlFieldTypedArgs = {\n\t\t\tfilter: {\n\t\t\t\tgraphQlType: `${entity.name}Where`,\n\t\t\t\tvalue: args.filter,\n\t\t\t},\n\t\t\tby: {\n\t\t\t\tgraphQlType: `${this.context.entity.name}${fieldUpperFirst}UniqueWhere!`,\n\t\t\t\tvalue: args.by,\n\t\t\t},\n\t\t}\n\n\t\tconst entitySelection = typeof fields === 'function' ? fields(new ContentEntitySelection(newContext, []) as any) : fields\n\t\tconst newObjectField = new GraphQlField(\n\t\t\talias,\n\t\t\tname,\n\t\t\targsWithType,\n\t\t\tentitySelection.selectionSet,\n\t\t)\n\t\tconst selectionWithField = this.withField(newObjectField)\n\t\tconst nestedTransform = entitySelection.transformFn\n\t\tif (!nestedTransform) {\n\t\t\treturn selectionWithField\n\t\t}\n\t\treturn selectionWithField.withFieldTransform(alias, (it, ctx) => it !== null ? nestedTransform(it, ctx) : null)\n\t}\n\n\tprivate _one(\n\t\tname: string,\n\t\targs: EntitySelectionOneArgs,\n\t\tfields:\n\t\t\t| ContentEntitySelectionCallback\n\t\t\t| ContentEntitySelection,\n\t): ContentEntitySelection {\n\t\tconst alias = args.as ?? name\n\t\tconst fieldInfo = this.context.entity.fields[name]\n\t\tif (!fieldInfo) {\n\t\t\tthrow new Error(`Field ${this.context.entity.name}.${name} does not exist.`)\n\t\t}\n\t\tif (fieldInfo?.type !== 'one') {\n\t\t\tthrow new Error(`Field ${this.context.entity.name}.${name} is not a has-one relation.`)\n\t\t}\n\t\tconst entity = this.context.schema.entities[fieldInfo.entity]\n\n\t\tconst newContext: ContentEntitySelectionContext<(typeof entity)['name']> = {\n\t\t\tentity: entity,\n\t\t\tschema: this.context.schema,\n\t\t}\n\t\tconst argsWithType: GraphQlFieldTypedArgs = {\n\t\t\tfilter: {\n\t\t\t\tgraphQlType: `${entity.name}Where`,\n\t\t\t\tvalue: args.filter,\n\t\t\t},\n\t\t}\n\t\tconst entitySelection = typeof fields === 'function'\n\t\t\t? fields(new ContentEntitySelection(newContext, []) as any)\n\t\t\t: fields\n\t\tconst newObjectField = new GraphQlField(\n\t\t\talias,\n\t\t\tname,\n\t\t\targsWithType,\n\t\t\tentitySelection.selectionSet,\n\t\t)\n\t\tconst selectionWithField = this.withField(newObjectField)\n\t\tconst nestedTransform = entitySelection.transformFn\n\t\tif (!nestedTransform) {\n\t\t\treturn selectionWithField\n\t\t}\n\t\treturn selectionWithField.withFieldTransform(alias, (it, ctx) => it !== null ? nestedTransform(it, ctx) : null)\n\t}\n\n\n\tprivate withField(field: GraphQlField) {\n\t\treturn new ContentEntitySelection(this.context, [\n\t\t\t...this.selectionSet,\n\t\t\tfield,\n\t\t], this.transformFn)\n\t}\n\n\tprivate withFieldTransform(alias: string, transform: (value: any, ctx: ContentTransformContext) => any) {\n\t\treturn new ContentEntitySelection(this.context, this.selectionSet, (value, ctx) => {\n\t\t\tconst transformedValue = transform(value[alias], ctx)\n\t\t\tconst newValue = {\n\t\t\t\t...value,\n\t\t\t\t[alias]: transformedValue,\n\t\t\t}\n\t\t\treturn this.transformFn ? this.transformFn(newValue, ctx) : newValue\n\t\t})\n\t}\n}\n"],"names":["GraphQlField","createListArgs"],"mappings":";;;;AAkCO,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA,EAKnC,YAEiB,SAEA,cAEA,aACf;AALe,SAAA,UAAA;AAEA,SAAA,eAAA;AAEA,SAAA,cAAA;AAAA,EAAA;AAAA,EAWjB,EAAE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