@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,175 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const createListArgs = require("./utils/createListArgs.cjs");
|
|
4
|
-
const createTypedArgs = require("./utils/createTypedArgs.cjs");
|
|
5
|
-
const graphqlBuilder = require("@contember/graphql-builder");
|
|
6
|
-
const createMutationOperationSet = require("./utils/createMutationOperationSet.cjs");
|
|
7
|
-
const ContentEntitySelection = require("./nodes/ContentEntitySelection.cjs");
|
|
8
|
-
const ContentOperation = require("./nodes/ContentOperation.cjs");
|
|
9
|
-
class ContentQueryBuilder {
|
|
10
|
-
constructor(schema) {
|
|
11
|
-
this.schema = schema;
|
|
12
|
-
}
|
|
13
|
-
fragment(name, fieldsCallback) {
|
|
14
|
-
const context = this.createContext(name);
|
|
15
|
-
const entitySelection = new ContentEntitySelection.ContentEntitySelection(context, []);
|
|
16
|
-
if (!fieldsCallback) {
|
|
17
|
-
return entitySelection;
|
|
18
|
-
}
|
|
19
|
-
return fieldsCallback(entitySelection);
|
|
20
|
-
}
|
|
21
|
-
count(name, args) {
|
|
22
|
-
const context = this.createContext(name);
|
|
23
|
-
const fieldName = `paginate${name}`;
|
|
24
|
-
const typedArgs = createTypedArgs.createTypedArgs(args, {
|
|
25
|
-
filter: `${context.entity.name}Where`
|
|
26
|
-
});
|
|
27
|
-
const selectionSet = [
|
|
28
|
-
new graphqlBuilder.GraphQlField(null, "pageInfo", {}, [
|
|
29
|
-
new graphqlBuilder.GraphQlField(null, "totalCount")
|
|
30
|
-
])
|
|
31
|
-
];
|
|
32
|
-
return new ContentOperation.ContentOperation("query", fieldName, typedArgs, selectionSet, (it) => {
|
|
33
|
-
return it.pageInfo.totalCount;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
list(name, args, fields) {
|
|
37
|
-
const context = this.createContext(name);
|
|
38
|
-
const fieldName = `list${name}`;
|
|
39
|
-
const typedArgs = createListArgs.createListArgs(context.entity, args);
|
|
40
|
-
const selection = this.resolveSelection(fields, context);
|
|
41
|
-
return new ContentOperation.ContentOperation("query", fieldName, typedArgs, selection.selectionSet, (it) => {
|
|
42
|
-
const transformFn = selection.transformFn;
|
|
43
|
-
if (transformFn) {
|
|
44
|
-
return it.map((el) => transformFn(el, {
|
|
45
|
-
rootValue: it
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
return it;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
get(name, args, fields) {
|
|
52
|
-
const context = this.createContext(name);
|
|
53
|
-
const fieldName = `get${name}`;
|
|
54
|
-
const typedArgs = createTypedArgs.createTypedArgs(args, {
|
|
55
|
-
by: `${context.entity.name}UniqueWhere!`,
|
|
56
|
-
filter: `${context.entity.name}Where`
|
|
57
|
-
});
|
|
58
|
-
const selection = this.resolveSelection(fields, context);
|
|
59
|
-
return new ContentOperation.ContentOperation("query", fieldName, typedArgs, selection.selectionSet, (it) => {
|
|
60
|
-
if (it && selection.transformFn) {
|
|
61
|
-
return selection.transformFn(it, {
|
|
62
|
-
rootValue: it
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return it;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
create(name, args, fields) {
|
|
69
|
-
const entity = this.getEntity(name);
|
|
70
|
-
const typedArgs = createTypedArgs.createTypedArgs(args, {
|
|
71
|
-
data: `${entity.name}CreateInput!`
|
|
72
|
-
});
|
|
73
|
-
return this.createMutationOperation(name, "create", typedArgs, fields);
|
|
74
|
-
}
|
|
75
|
-
update(name, args, fields) {
|
|
76
|
-
const entity = this.getEntity(name);
|
|
77
|
-
const typedArgs = createTypedArgs.createTypedArgs(args, {
|
|
78
|
-
data: `${entity.name}UpdateInput!`,
|
|
79
|
-
by: `${entity.name}UniqueWhere!`,
|
|
80
|
-
filter: `${entity.name}Where`
|
|
81
|
-
});
|
|
82
|
-
return this.createMutationOperation(name, "update", typedArgs, fields);
|
|
83
|
-
}
|
|
84
|
-
upsert(name, args, fields) {
|
|
85
|
-
const entity = this.getEntity(name);
|
|
86
|
-
const typedArgs = createTypedArgs.createTypedArgs(args, {
|
|
87
|
-
update: `${entity.name}UpdateInput!`,
|
|
88
|
-
create: `${entity.name}CreateInput!`,
|
|
89
|
-
by: `${entity.name}UniqueWhere!`,
|
|
90
|
-
filter: `${entity.name}Where`
|
|
91
|
-
});
|
|
92
|
-
return this.createMutationOperation(name, "upsert", typedArgs, fields);
|
|
93
|
-
}
|
|
94
|
-
delete(name, args, fields) {
|
|
95
|
-
const entity = this.getEntity(name);
|
|
96
|
-
const typedArgs = createTypedArgs.createTypedArgs(args, {
|
|
97
|
-
by: `${entity.name}UniqueWhere!`,
|
|
98
|
-
filter: `${entity.name}Where`
|
|
99
|
-
});
|
|
100
|
-
return this.createMutationOperation(name, "delete", typedArgs, fields);
|
|
101
|
-
}
|
|
102
|
-
createMutationOperation(name, operation, args, fields) {
|
|
103
|
-
const context = this.createContext(name);
|
|
104
|
-
const fieldName = `${operation}${name}`;
|
|
105
|
-
const nodeSelection = fields ? this.resolveSelection(fields, context) : void 0;
|
|
106
|
-
const selectionSet = this.createMutationSelection(operation, nodeSelection?.selectionSet);
|
|
107
|
-
return new ContentOperation.ContentOperation("mutation", fieldName, args, selectionSet, (it) => {
|
|
108
|
-
if (!nodeSelection?.transformFn) {
|
|
109
|
-
return it;
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
...it,
|
|
113
|
-
node: it.node ? nodeSelection.transformFn(it.node, {
|
|
114
|
-
rootValue: it.node
|
|
115
|
-
}) : null
|
|
116
|
-
};
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
transaction(input, options = {}) {
|
|
120
|
-
const combined = createMutationOperationSet.createMutationOperationSet(input);
|
|
121
|
-
const transactionArgs = createTypedArgs.createTypedArgs({ options }, {
|
|
122
|
-
options: "MutationTransactionOptions"
|
|
123
|
-
});
|
|
124
|
-
const items = [
|
|
125
|
-
...this.createMutationSelection("transaction"),
|
|
126
|
-
...combined.selection
|
|
127
|
-
];
|
|
128
|
-
return new ContentOperation.ContentOperation("mutation", "transaction", transactionArgs, items, ({ ok, errorMessage, errors, validation, ...data }) => {
|
|
129
|
-
return {
|
|
130
|
-
ok,
|
|
131
|
-
errorMessage,
|
|
132
|
-
errors,
|
|
133
|
-
validation,
|
|
134
|
-
data: combined.parse(data)
|
|
135
|
-
};
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
createMutationSelection(operation, selection) {
|
|
139
|
-
const items = [
|
|
140
|
-
new graphqlBuilder.GraphQlField(null, "ok"),
|
|
141
|
-
new graphqlBuilder.GraphQlField(null, "errorMessage"),
|
|
142
|
-
new graphqlBuilder.GraphQlField(null, "errors", {}, [
|
|
143
|
-
new graphqlBuilder.GraphQlFragmentSpread("MutationError")
|
|
144
|
-
])
|
|
145
|
-
];
|
|
146
|
-
if (operation !== "delete") {
|
|
147
|
-
items.push(new graphqlBuilder.GraphQlField(null, "validation", {}, [
|
|
148
|
-
new graphqlBuilder.GraphQlFragmentSpread("ValidationResult")
|
|
149
|
-
]));
|
|
150
|
-
}
|
|
151
|
-
if (selection) {
|
|
152
|
-
items.push(new graphqlBuilder.GraphQlField(null, "node", {}, selection));
|
|
153
|
-
}
|
|
154
|
-
return items;
|
|
155
|
-
}
|
|
156
|
-
resolveSelection(fields, context) {
|
|
157
|
-
return typeof fields === "function" ? fields(new ContentEntitySelection.ContentEntitySelection(context, [])) : fields;
|
|
158
|
-
}
|
|
159
|
-
createContext(name) {
|
|
160
|
-
const entity = this.getEntity(name);
|
|
161
|
-
return {
|
|
162
|
-
entity,
|
|
163
|
-
schema: this.schema
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
getEntity(name) {
|
|
167
|
-
const entity = this.schema.entities[name];
|
|
168
|
-
if (!entity) {
|
|
169
|
-
throw new Error(`Entity ${name} not found`);
|
|
170
|
-
}
|
|
171
|
-
return entity;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
exports.ContentQueryBuilder = ContentQueryBuilder;
|
|
175
|
-
//# sourceMappingURL=ContentQueryBuilder.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentQueryBuilder.cjs","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":["ContentEntitySelection","createTypedArgs","GraphQlField","ContentOperation","createListArgs","createMutationOperationSet","GraphQlFragmentSpread"],"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,IAAIA,8CAAuB,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,YAAYC,gCAAgB,MAAM;AAAA,MACvC,QAAQ,GAAG,QAAQ,OAAO,IAAI;AAAA,IAAA,CAC9B;AACD,UAAM,eAAoC;AAAA,MACzC,IAAIC,4BAAa,MAAM,YAAY,IAAI;AAAA,QACtC,IAAIA,eAAAA,aAAa,MAAM,YAAY;AAAA,MACnC,CAAA;AAAA,IACF;AAEA,WAAO,IAAIC,iBAAiB,iBAAA,SAAS,WAAW,WAAW,cAAc,CAAM,OAAA;AAC9E,aAAO,GAAG,SAAS;AAAA,IAAA,CACnB;AAAA,EAAA;AAAA,EAIK,KAAK,MAAc,MAA4C,QA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OAAO,IAAIF,uBAAAA,uBAAuB,SAAS,EAAE,CAAC,IAAI;AAAA,EAAA;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,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;AAAA,EAAA;AAAA,EAIK,KAAK,MAAc,MAA4C,QAAwD;AACvH,UAAA,UAAU,KAAK,cAAc,IAAI;AACjC,UAAA,YAAY,OAAO,IAAI;AAC7B,UAAM,YAAY,eAAe,QAAQ,QAAQ,IAAI;AACrD,UAAM,YAAY,KAAK,iBAAiB,QAAQ,OAAO;AAEvD,WAAO,IAAI,iBA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AACZ,YAAM,IAAI,MAAM,UAAU,IAAI,YAAY;AAAA,IAAA;AAEpC,WAAA;AAAA,EAAA;AAET;"}
|
|
@@ -1,207 +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
|
-
meta(field, flags) {
|
|
55
|
-
const metaField = this.selectionSet.find((it) => it instanceof graphqlBuilder.GraphQlField && it.name === "_meta");
|
|
56
|
-
const selectionWithoutMeta = metaField ? this.selectionSet.filter((it) => it !== metaField) : this.selectionSet;
|
|
57
|
-
const flagFields = [];
|
|
58
|
-
for (const flag of flags) {
|
|
59
|
-
flagFields.push(new graphqlBuilder.GraphQlField(null, flag));
|
|
60
|
-
}
|
|
61
|
-
return new ContentEntitySelection(this.context, [
|
|
62
|
-
...selectionWithoutMeta,
|
|
63
|
-
new graphqlBuilder.GraphQlField(null, "_meta", void 0, [
|
|
64
|
-
...metaField?.selectionSet ?? [],
|
|
65
|
-
new graphqlBuilder.GraphQlField(null, field, void 0, flagFields)
|
|
66
|
-
])
|
|
67
|
-
]);
|
|
68
|
-
}
|
|
69
|
-
transform(transform) {
|
|
70
|
-
return new ContentEntitySelection(this.context, this.selectionSet, !this.transformFn ? transform : (value, ctx) => {
|
|
71
|
-
return transform(this.transformFn(value, ctx), ctx);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
_column(name, args = {}) {
|
|
75
|
-
let fieldInfo = this.context.entity.fields[name];
|
|
76
|
-
if (!fieldInfo) {
|
|
77
|
-
throw new Error(`Field ${this.context.entity.name}.${name} does not exist.`);
|
|
78
|
-
}
|
|
79
|
-
if (fieldInfo?.type !== "column") {
|
|
80
|
-
throw new Error(`Field ${this.context.entity.name}.${name} is not a column.`);
|
|
81
|
-
}
|
|
82
|
-
const alias = args.as ?? name;
|
|
83
|
-
const field = new graphqlBuilder.GraphQlField(alias, name, {});
|
|
84
|
-
return this.withField(field);
|
|
85
|
-
}
|
|
86
|
-
_many(name, args, fields) {
|
|
87
|
-
const alias = args.as ?? name;
|
|
88
|
-
const fieldInfo = this.context.entity.fields[name];
|
|
89
|
-
if (!fieldInfo) {
|
|
90
|
-
throw new Error(`Field ${this.context.entity.name}.${name} does not exist.`);
|
|
91
|
-
}
|
|
92
|
-
if (fieldInfo?.type !== "many") {
|
|
93
|
-
throw new Error(`Field ${this.context.entity.name}.${name} is not a has-many relation.`);
|
|
94
|
-
}
|
|
95
|
-
const entity = this.context.schema.entities[fieldInfo.entity];
|
|
96
|
-
const newContext = {
|
|
97
|
-
entity,
|
|
98
|
-
schema: this.context.schema
|
|
99
|
-
};
|
|
100
|
-
const entitySelection = typeof fields === "function" ? fields(new ContentEntitySelection(newContext, [])) : fields;
|
|
101
|
-
const newObjectField = new graphqlBuilder.GraphQlField(
|
|
102
|
-
alias,
|
|
103
|
-
name,
|
|
104
|
-
createListArgs.createListArgs(entity, args),
|
|
105
|
-
entitySelection.selectionSet
|
|
106
|
-
);
|
|
107
|
-
const selectionWithField = this.withField(newObjectField);
|
|
108
|
-
const nestedTransform = entitySelection.transformFn;
|
|
109
|
-
if (!nestedTransform) {
|
|
110
|
-
return selectionWithField;
|
|
111
|
-
}
|
|
112
|
-
return this.withFieldTransform(alias, (it) => it.map(nestedTransform));
|
|
113
|
-
}
|
|
114
|
-
_manyBy(name, args, fields) {
|
|
115
|
-
const alias = args.as ?? name;
|
|
116
|
-
const byField = Object.keys(args.by)[0];
|
|
117
|
-
const relationField = name.substring(0, name.length - byField.length - 2);
|
|
118
|
-
const field = this.context.entity.fields[relationField];
|
|
119
|
-
if (!field) {
|
|
120
|
-
throw new Error(`Field ${this.context.entity.name}.${relationField} does not exist.`);
|
|
121
|
-
}
|
|
122
|
-
if (field?.type !== "many") {
|
|
123
|
-
throw new Error(`Field ${this.context.entity.name}.${relationField} is not a has-many relation.`);
|
|
124
|
-
}
|
|
125
|
-
const entity = this.context.schema.entities[field.entity];
|
|
126
|
-
const newContext = {
|
|
127
|
-
entity,
|
|
128
|
-
schema: this.context.schema
|
|
129
|
-
};
|
|
130
|
-
const fieldUpperFirst = name.charAt(0).toUpperCase() + name.slice(1);
|
|
131
|
-
const argsWithType = {
|
|
132
|
-
filter: {
|
|
133
|
-
graphQlType: `${entity.name}Where`,
|
|
134
|
-
value: args.filter
|
|
135
|
-
},
|
|
136
|
-
by: {
|
|
137
|
-
graphQlType: `${this.context.entity.name}${fieldUpperFirst}UniqueWhere!`,
|
|
138
|
-
value: args.by
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
const entitySelection = typeof fields === "function" ? fields(new ContentEntitySelection(newContext, [])) : fields;
|
|
142
|
-
const newObjectField = new graphqlBuilder.GraphQlField(
|
|
143
|
-
alias,
|
|
144
|
-
name,
|
|
145
|
-
argsWithType,
|
|
146
|
-
entitySelection.selectionSet
|
|
147
|
-
);
|
|
148
|
-
const selectionWithField = this.withField(newObjectField);
|
|
149
|
-
const nestedTransform = entitySelection.transformFn;
|
|
150
|
-
if (!nestedTransform) {
|
|
151
|
-
return selectionWithField;
|
|
152
|
-
}
|
|
153
|
-
return this.withFieldTransform(alias, (it, ctx) => it !== null ? nestedTransform(it, ctx) : null);
|
|
154
|
-
}
|
|
155
|
-
_one(name, args, fields) {
|
|
156
|
-
const alias = args.as ?? name;
|
|
157
|
-
const fieldInfo = this.context.entity.fields[name];
|
|
158
|
-
if (!fieldInfo) {
|
|
159
|
-
throw new Error(`Field ${this.context.entity.name}.${name} does not exist.`);
|
|
160
|
-
}
|
|
161
|
-
if (fieldInfo?.type !== "one") {
|
|
162
|
-
throw new Error(`Field ${this.context.entity.name}.${name} is not a has-one relation.`);
|
|
163
|
-
}
|
|
164
|
-
const entity = this.context.schema.entities[fieldInfo.entity];
|
|
165
|
-
const newContext = {
|
|
166
|
-
entity,
|
|
167
|
-
schema: this.context.schema
|
|
168
|
-
};
|
|
169
|
-
const argsWithType = {
|
|
170
|
-
filter: {
|
|
171
|
-
graphQlType: `${entity.name}Where`,
|
|
172
|
-
value: args.filter
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
const entitySelection = typeof fields === "function" ? fields(new ContentEntitySelection(newContext, [])) : fields;
|
|
176
|
-
const newObjectField = new graphqlBuilder.GraphQlField(
|
|
177
|
-
alias,
|
|
178
|
-
name,
|
|
179
|
-
argsWithType,
|
|
180
|
-
entitySelection.selectionSet
|
|
181
|
-
);
|
|
182
|
-
const selectionWithField = this.withField(newObjectField);
|
|
183
|
-
const nestedTransform = entitySelection.transformFn;
|
|
184
|
-
if (!nestedTransform) {
|
|
185
|
-
return selectionWithField;
|
|
186
|
-
}
|
|
187
|
-
return this.withFieldTransform(alias, (it, ctx) => it !== null ? nestedTransform(it, ctx) : null);
|
|
188
|
-
}
|
|
189
|
-
withField(field) {
|
|
190
|
-
return new ContentEntitySelection(this.context, [
|
|
191
|
-
...this.selectionSet,
|
|
192
|
-
field
|
|
193
|
-
], this.transformFn);
|
|
194
|
-
}
|
|
195
|
-
withFieldTransform(alias, transform) {
|
|
196
|
-
return new ContentEntitySelection(this.context, this.selectionSet, (value, ctx) => {
|
|
197
|
-
const transformedValue = transform(value[alias], ctx);
|
|
198
|
-
const newValue = {
|
|
199
|
-
...value,
|
|
200
|
-
[alias]: transformedValue
|
|
201
|
-
};
|
|
202
|
-
return this.transformFn ? this.transformFn(newValue, ctx) : newValue;
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
exports.ContentEntitySelection = ContentEntitySelection;
|
|
207
|
-
//# 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\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 this.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 this.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 this.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,OAAe,iBAA6E,aAAwE;AACrK,UAAM,CAAC,MAAM,SAAS,IAAI,OAAO,oBAAoB,cAAc,2BAA2B,yBAC3F,CAAC,CAAA,GAAI,eAAe,IACpB,CAAC,mBAAmB,CAAA,GAAI,WAAW;AACtC,QAAI,UAAU,cAAc;AACpB,aAAA,KAAK,UAAU,IAAIA,eAAA,aAAa,KAAK,MAAM,MAAM,YAAY,CAAC;AAAA,IAAA;AAEtE,UAAM,YAAY,KAAK,QAAQ,OAAO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