@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,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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s.js";
|
|
2
|
-
import { GraphQlField } from "@contember/graphql-builder";
|
|
3
|
-
class ContentEntitySelection {
|
|
4
|
-
/**
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
constructor(context, selectionSet, transformFn) {
|
|
8
|
-
this.context = context;
|
|
9
|
-
this.selectionSet = selectionSet;
|
|
10
|
-
this.transformFn = transformFn;
|
|
11
|
-
}
|
|
12
|
-
$(field, argsOrSelection, selectionIn) {
|
|
13
|
-
const [args, selection] = typeof argsOrSelection === "function" || argsOrSelection instanceof ContentEntitySelection ? [{}, argsOrSelection] : [argsOrSelection ?? {}, selectionIn];
|
|
14
|
-
if (field === "__typename") {
|
|
15
|
-
return this.withField(new GraphQlField(args.as ?? null, "__typename"));
|
|
16
|
-
}
|
|
17
|
-
const fieldInfo = this.context.entity.fields[field];
|
|
18
|
-
if (!fieldInfo) {
|
|
19
|
-
if ("by" in args && field.includes("By")) {
|
|
20
|
-
if (!selection) {
|
|
21
|
-
throw new Error(`Selection is required for ${this.context.entity.name}.${field}.`);
|
|
22
|
-
}
|
|
23
|
-
return this._manyBy(field, args, selection);
|
|
24
|
-
}
|
|
25
|
-
throw new Error(`Field ${this.context.entity.name}.${field} does not exist.`);
|
|
26
|
-
}
|
|
27
|
-
if (fieldInfo.type === "column") {
|
|
28
|
-
return this._column(field, args);
|
|
29
|
-
}
|
|
30
|
-
if (fieldInfo.type === "many") {
|
|
31
|
-
if (!selection) {
|
|
32
|
-
throw new Error(`Selection is required for ${this.context.entity.name}.${field}.`);
|
|
33
|
-
}
|
|
34
|
-
return this._many(field, args, selection);
|
|
35
|
-
}
|
|
36
|
-
if (fieldInfo.type === "one") {
|
|
37
|
-
if (!selection) {
|
|
38
|
-
throw new Error(`Selection is required for ${this.context.entity.name}.${field}.`);
|
|
39
|
-
}
|
|
40
|
-
return this._one(field, args, selection);
|
|
41
|
-
}
|
|
42
|
-
throw new Error(`Unknown field type ${fieldInfo.type}.`);
|
|
43
|
-
}
|
|
44
|
-
$$() {
|
|
45
|
-
const columns = this.context.entity.scalars;
|
|
46
|
-
const nodes = [
|
|
47
|
-
...this.selectionSet,
|
|
48
|
-
...columns.map((col) => new GraphQlField(null, col))
|
|
49
|
-
];
|
|
50
|
-
return new ContentEntitySelection(this.context, nodes);
|
|
51
|
-
}
|
|
52
|
-
meta(field, flags) {
|
|
53
|
-
const metaField = this.selectionSet.find((it) => it instanceof GraphQlField && it.name === "_meta");
|
|
54
|
-
const selectionWithoutMeta = metaField ? this.selectionSet.filter((it) => it !== metaField) : this.selectionSet;
|
|
55
|
-
const flagFields = [];
|
|
56
|
-
for (const flag of flags) {
|
|
57
|
-
flagFields.push(new GraphQlField(null, flag));
|
|
58
|
-
}
|
|
59
|
-
return new ContentEntitySelection(this.context, [
|
|
60
|
-
...selectionWithoutMeta,
|
|
61
|
-
new GraphQlField(null, "_meta", void 0, [
|
|
62
|
-
...metaField?.selectionSet ?? [],
|
|
63
|
-
new GraphQlField(null, field, void 0, flagFields)
|
|
64
|
-
])
|
|
65
|
-
]);
|
|
66
|
-
}
|
|
67
|
-
transform(transform) {
|
|
68
|
-
return new ContentEntitySelection(this.context, this.selectionSet, !this.transformFn ? transform : (value, ctx) => {
|
|
69
|
-
return transform(this.transformFn(value, ctx), ctx);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
_column(name, args = {}) {
|
|
73
|
-
let fieldInfo = this.context.entity.fields[name];
|
|
74
|
-
if (!fieldInfo) {
|
|
75
|
-
throw new Error(`Field ${this.context.entity.name}.${name} does not exist.`);
|
|
76
|
-
}
|
|
77
|
-
if (fieldInfo?.type !== "column") {
|
|
78
|
-
throw new Error(`Field ${this.context.entity.name}.${name} is not a column.`);
|
|
79
|
-
}
|
|
80
|
-
const alias = args.as ?? name;
|
|
81
|
-
const field = new GraphQlField(alias, name, {});
|
|
82
|
-
return this.withField(field);
|
|
83
|
-
}
|
|
84
|
-
_many(name, args, fields) {
|
|
85
|
-
const alias = args.as ?? name;
|
|
86
|
-
const fieldInfo = this.context.entity.fields[name];
|
|
87
|
-
if (!fieldInfo) {
|
|
88
|
-
throw new Error(`Field ${this.context.entity.name}.${name} does not exist.`);
|
|
89
|
-
}
|
|
90
|
-
if (fieldInfo?.type !== "many") {
|
|
91
|
-
throw new Error(`Field ${this.context.entity.name}.${name} is not a has-many relation.`);
|
|
92
|
-
}
|
|
93
|
-
const entity = this.context.schema.entities[fieldInfo.entity];
|
|
94
|
-
const newContext = {
|
|
95
|
-
entity,
|
|
96
|
-
schema: this.context.schema
|
|
97
|
-
};
|
|
98
|
-
const entitySelection = typeof fields === "function" ? fields(new ContentEntitySelection(newContext, [])) : fields;
|
|
99
|
-
const newObjectField = new GraphQlField(
|
|
100
|
-
alias,
|
|
101
|
-
name,
|
|
102
|
-
createListArgs(entity, args),
|
|
103
|
-
entitySelection.selectionSet
|
|
104
|
-
);
|
|
105
|
-
const selectionWithField = this.withField(newObjectField);
|
|
106
|
-
const nestedTransform = entitySelection.transformFn;
|
|
107
|
-
if (!nestedTransform) {
|
|
108
|
-
return selectionWithField;
|
|
109
|
-
}
|
|
110
|
-
return this.withFieldTransform(alias, (it) => it.map(nestedTransform));
|
|
111
|
-
}
|
|
112
|
-
_manyBy(name, args, fields) {
|
|
113
|
-
const alias = args.as ?? name;
|
|
114
|
-
const byField = Object.keys(args.by)[0];
|
|
115
|
-
const relationField = name.substring(0, name.length - byField.length - 2);
|
|
116
|
-
const field = this.context.entity.fields[relationField];
|
|
117
|
-
if (!field) {
|
|
118
|
-
throw new Error(`Field ${this.context.entity.name}.${relationField} does not exist.`);
|
|
119
|
-
}
|
|
120
|
-
if (field?.type !== "many") {
|
|
121
|
-
throw new Error(`Field ${this.context.entity.name}.${relationField} is not a has-many relation.`);
|
|
122
|
-
}
|
|
123
|
-
const entity = this.context.schema.entities[field.entity];
|
|
124
|
-
const newContext = {
|
|
125
|
-
entity,
|
|
126
|
-
schema: this.context.schema
|
|
127
|
-
};
|
|
128
|
-
const fieldUpperFirst = name.charAt(0).toUpperCase() + name.slice(1);
|
|
129
|
-
const argsWithType = {
|
|
130
|
-
filter: {
|
|
131
|
-
graphQlType: `${entity.name}Where`,
|
|
132
|
-
value: args.filter
|
|
133
|
-
},
|
|
134
|
-
by: {
|
|
135
|
-
graphQlType: `${this.context.entity.name}${fieldUpperFirst}UniqueWhere!`,
|
|
136
|
-
value: args.by
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
const entitySelection = typeof fields === "function" ? fields(new ContentEntitySelection(newContext, [])) : fields;
|
|
140
|
-
const newObjectField = new GraphQlField(
|
|
141
|
-
alias,
|
|
142
|
-
name,
|
|
143
|
-
argsWithType,
|
|
144
|
-
entitySelection.selectionSet
|
|
145
|
-
);
|
|
146
|
-
const selectionWithField = this.withField(newObjectField);
|
|
147
|
-
const nestedTransform = entitySelection.transformFn;
|
|
148
|
-
if (!nestedTransform) {
|
|
149
|
-
return selectionWithField;
|
|
150
|
-
}
|
|
151
|
-
return this.withFieldTransform(alias, (it, ctx) => it !== null ? nestedTransform(it, ctx) : null);
|
|
152
|
-
}
|
|
153
|
-
_one(name, args, fields) {
|
|
154
|
-
const alias = args.as ?? name;
|
|
155
|
-
const fieldInfo = this.context.entity.fields[name];
|
|
156
|
-
if (!fieldInfo) {
|
|
157
|
-
throw new Error(`Field ${this.context.entity.name}.${name} does not exist.`);
|
|
158
|
-
}
|
|
159
|
-
if (fieldInfo?.type !== "one") {
|
|
160
|
-
throw new Error(`Field ${this.context.entity.name}.${name} is not a has-one relation.`);
|
|
161
|
-
}
|
|
162
|
-
const entity = this.context.schema.entities[fieldInfo.entity];
|
|
163
|
-
const newContext = {
|
|
164
|
-
entity,
|
|
165
|
-
schema: this.context.schema
|
|
166
|
-
};
|
|
167
|
-
const argsWithType = {
|
|
168
|
-
filter: {
|
|
169
|
-
graphQlType: `${entity.name}Where`,
|
|
170
|
-
value: args.filter
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
const entitySelection = typeof fields === "function" ? fields(new ContentEntitySelection(newContext, [])) : fields;
|
|
174
|
-
const newObjectField = new GraphQlField(
|
|
175
|
-
alias,
|
|
176
|
-
name,
|
|
177
|
-
argsWithType,
|
|
178
|
-
entitySelection.selectionSet
|
|
179
|
-
);
|
|
180
|
-
const selectionWithField = this.withField(newObjectField);
|
|
181
|
-
const nestedTransform = entitySelection.transformFn;
|
|
182
|
-
if (!nestedTransform) {
|
|
183
|
-
return selectionWithField;
|
|
184
|
-
}
|
|
185
|
-
return this.withFieldTransform(alias, (it, ctx) => it !== null ? nestedTransform(it, ctx) : null);
|
|
186
|
-
}
|
|
187
|
-
withField(field) {
|
|
188
|
-
return new ContentEntitySelection(this.context, [
|
|
189
|
-
...this.selectionSet,
|
|
190
|
-
field
|
|
191
|
-
], this.transformFn);
|
|
192
|
-
}
|
|
193
|
-
withFieldTransform(alias, transform) {
|
|
194
|
-
return new ContentEntitySelection(this.context, this.selectionSet, (value, ctx) => {
|
|
195
|
-
const transformedValue = transform(value[alias], ctx);
|
|
196
|
-
const newValue = {
|
|
197
|
-
...value,
|
|
198
|
-
[alias]: transformedValue
|
|
199
|
-
};
|
|
200
|
-
return this.transformFn ? this.transformFn(newValue, ctx) : newValue;
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
export {
|
|
205
|
-
ContentEntitySelection
|
|
206
|
-
};
|
|
207
|
-
//# sourceMappingURL=ContentEntitySelection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentEntitySelection.js","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":[],"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,IAAI,aAAa,KAAK,MAAM,MAAM,YAAY,CAAC;AAAA,IAAA;AAEtE,UAAM,YAAY,KAAK,QAAQ,OAAO,OAAO,KAAK;AAClD,QAAI,CAAC,WAAW;AACf,UAAI,QAAQ,QAAQ,MAAM,SAAS,IAAI,GAAG;AACzC,YAAI,CAAC,WAAW;AACT,gBAAA,IAAI,MAAM,6BAA6B,KAAK,QAAQ,OAAO,IAAI,IAAI,KAAK,GAAG;AAAA,QAAA;AAElF,eAAO,KAAK,QAAQ,OAAO,MAAmC,SAAS;AAAA,MAAA;AAGlE,YAAA,IAAI,MAAM,SAAS,KAAK,QAAQ,OAAO,IAAI,IAAI,KAAK,kBAAkB;AAAA,IAAA;AAEzE,Q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AqB,KAAK,UAAU,cAAc;AACxD,UAAM,kBAAkB,gBAAgB;AACxC,QAAI,CAAC,iBAAiB;AACd,aAAA;AAAA,IAAA;AAER,WAAO,KAAK,mBAAmB,OAAO,CAAC,IAAI,QAAQ,OAAO,OAAO,gBAAgB,IAAI,GAAG,IAAI,IAAI;AAAA,EAAA;AAAA,EAIzF,UAAU,OAAqB;AAC/B,WAAA,IAAI,uBAAuB,KAAK,SAAS;AAAA,MAC/C,GAAG,KAAK;AAAA,MACR;AAAA,IAAA,GACE,KAAK,WAAW;AAAA,EAAA;AAAA,EAGZ,mBAAmB,OAAe,WAA8D;AAChG,WAAA,IAAI,uBAAuB,KAAK,SAAS,KAAK,cAAc,CAAC,OAAO,QAAQ;AAClF,YAAM,mBAAmB,UAAU,MAAM,KAAK,GAAG,GAAG;AACpD,YAAM,WAAW;AAAA,QAChB,GAAG;AAAA,QACH,CAAC,KAAK,GAAG;AAAA,MACV;AACA,aAAO,KAAK,cAAc,KAAK,YAAY,UAAU,GAAG,IAAI;AAAA,IAAA,CAC5D;AAAA,EAAA;AAEH;"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
class ContentOperation {
|
|
4
|
-
/**
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
constructor(type, fieldName, args = {}, selection, parse = (it) => it) {
|
|
8
|
-
this.type = type;
|
|
9
|
-
this.fieldName = fieldName;
|
|
10
|
-
this.args = args;
|
|
11
|
-
this.selection = selection;
|
|
12
|
-
this.parse = parse;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.ContentOperation = ContentOperation;
|
|
16
|
-
//# sourceMappingURL=ContentOperation.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentOperation.cjs","sources":["../../../../../packages/client-content/src/nodes/ContentOperation.ts"],"sourcesContent":["import { GraphQlFieldTypedArgs, GraphQlSelectionSet } from '@contember/graphql-builder'\n\nexport class ContentOperation<TValue, TType extends 'query' | 'mutation'> {\n\t/**\n\t * @internal\n\t */\n\tconstructor(\n\t\t/** @internal */\n\t\tpublic readonly type: TType,\n\t\t/** @internal */\n\t\tpublic readonly fieldName: string,\n\t\t/** @internal */\n\t\tpublic readonly args: GraphQlFieldTypedArgs = {},\n\t\t/** @internal */\n\t\tpublic readonly selection?: GraphQlSelectionSet,\n\t\t/** @internal */\n\t\tpublic readonly parse: (value: any) => TValue = it => it as TValue,\n\t) {\n\t}\n}\n\nexport type ContentQuery<TValue> = ContentOperation<TValue, 'query'>\nexport type ContentMutation<TValue> = ContentOperation<TValue, 'mutation'>\n"],"names":[],"mappings":";;AAEO,MAAM,iBAA6D;AAAA;AAAA;AAAA;AAAA,EAIzE,YAEiB,MAEA,WAEA,OAA8B,CAAA,GAE9B,WAEA,QAAgC,CAAA,OAAM,IACrD;AATe,SAAA,OAAA;AAEA,SAAA,YAAA;AAEA,SAAA,OAAA;AAEA,SAAA,YAAA;AAEA,SAAA,QAAA;AAAA,EAAA;AAGlB;;"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class ContentOperation {
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
constructor(type, fieldName, args = {}, selection, parse = (it) => it) {
|
|
6
|
-
this.type = type;
|
|
7
|
-
this.fieldName = fieldName;
|
|
8
|
-
this.args = args;
|
|
9
|
-
this.selection = selection;
|
|
10
|
-
this.parse = parse;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
ContentOperation
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=ContentOperation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentOperation.js","sources":["../../../../../packages/client-content/src/nodes/ContentOperation.ts"],"sourcesContent":["import { GraphQlFieldTypedArgs, GraphQlSelectionSet } from '@contember/graphql-builder'\n\nexport class ContentOperation<TValue, TType extends 'query' | 'mutation'> {\n\t/**\n\t * @internal\n\t */\n\tconstructor(\n\t\t/** @internal */\n\t\tpublic readonly type: TType,\n\t\t/** @internal */\n\t\tpublic readonly fieldName: string,\n\t\t/** @internal */\n\t\tpublic readonly args: GraphQlFieldTypedArgs = {},\n\t\t/** @internal */\n\t\tpublic readonly selection?: GraphQlSelectionSet,\n\t\t/** @internal */\n\t\tpublic readonly parse: (value: any) => TValue = it => it as TValue,\n\t) {\n\t}\n}\n\nexport type ContentQuery<TValue> = ContentOperation<TValue, 'query'>\nexport type ContentMutation<TValue> = ContentOperation<TValue, 'mutation'>\n"],"names":[],"mappings":"AAEO,MAAM,iBAA6D;AAAA;AAAA;AAAA;AAAA,EAIzE,YAEiB,MAEA,WAEA,OAA8B,CAAA,GAE9B,WAEA,QAAgC,CAAA,OAAM,IACrD;AATe,SAAA,OAAA;AAEA,SAAA,YAAA;AAEA,SAAA,OAAA;AAEA,SAAA,YAAA;AAEA,SAAA,QAAA;AAAA,EAAA;AAGlB;"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
class ContentOperationSet {
|
|
4
|
-
constructor(selection, parse = (it) => it) {
|
|
5
|
-
this.selection = selection;
|
|
6
|
-
this.parse = parse;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.ContentOperationSet = ContentOperationSet;
|
|
10
|
-
//# sourceMappingURL=ContentOperationSet.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentOperationSet.cjs","sources":["../../../../../packages/client-content/src/utils/ContentOperationSet.ts"],"sourcesContent":["import { GraphQlSelectionSet } from '@contember/graphql-builder'\n\nexport class ContentOperationSet<TValue> {\n\tconstructor(\n\t\t/** @internal */\n\t\tpublic readonly selection: GraphQlSelectionSet,\n\t\t/** @internal */\n\t\tpublic readonly parse: (value: any) => TValue = it => it as TValue,\n\t) {\n\t}\n}\n"],"names":[],"mappings":";;AAEO,MAAM,oBAA4B;AAAA,EACxC,YAEiB,WAEA,QAAgC,CAAA,OAAM,IACrD;AAHe,SAAA,YAAA;AAEA,SAAA,QAAA;AAAA,EAAA;AAGlB;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentOperationSet.js","sources":["../../../../../packages/client-content/src/utils/ContentOperationSet.ts"],"sourcesContent":["import { GraphQlSelectionSet } from '@contember/graphql-builder'\n\nexport class ContentOperationSet<TValue> {\n\tconstructor(\n\t\t/** @internal */\n\t\tpublic readonly selection: GraphQlSelectionSet,\n\t\t/** @internal */\n\t\tpublic readonly parse: (value: any) => TValue = it => it as TValue,\n\t) {\n\t}\n}\n"],"names":[],"mappings":"AAEO,MAAM,oBAA4B;AAAA,EACxC,YAEiB,WAEA,QAAgC,CAAA,OAAM,IACrD;AAHe,SAAA,YAAA;AAEA,SAAA,QAAA;AAAA,EAAA;AAGlB;"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const createListArgs = (entity, args, type = "list") => {
|
|
4
|
-
return {
|
|
5
|
-
filter: {
|
|
6
|
-
graphQlType: `${entity.name}Where`,
|
|
7
|
-
value: args.filter
|
|
8
|
-
},
|
|
9
|
-
orderBy: {
|
|
10
|
-
graphQlType: `[${entity.name}OrderBy!]`,
|
|
11
|
-
value: args.orderBy
|
|
12
|
-
},
|
|
13
|
-
[type === "list" ? "limit" : "first"]: {
|
|
14
|
-
graphQlType: "Int",
|
|
15
|
-
value: args.limit
|
|
16
|
-
},
|
|
17
|
-
[type === "list" ? "offset" : "skip"]: {
|
|
18
|
-
graphQlType: "Int",
|
|
19
|
-
value: args.offset
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
exports.createListArgs = createListArgs;
|
|
24
|
-
//# sourceMappingURL=createListArgs.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createListArgs.cjs","sources":["../../../../../packages/client-content/src/utils/createListArgs.ts"],"sourcesContent":["import { SchemaEntityNames } from '../types'\nimport { GraphQlFieldTypedArgs } from '@contember/graphql-builder'\n\nexport const createListArgs = (entity: SchemaEntityNames<string>, args: { filter?: any; orderBy?: any; limit?: number; offset?: number }, type: 'list' | 'paginate' = 'list'): GraphQlFieldTypedArgs => {\n\treturn {\n\t\tfilter: {\n\t\t\tgraphQlType: `${entity.name}Where`,\n\t\t\tvalue: args.filter,\n\t\t},\n\t\torderBy: {\n\t\t\tgraphQlType: `[${entity.name}OrderBy!]`,\n\t\t\tvalue: args.orderBy,\n\t\t},\n\t\t[type === 'list' ? 'limit' : 'first']: {\n\t\t\tgraphQlType: 'Int',\n\t\t\tvalue: args.limit,\n\t\t},\n\t\t[type === 'list' ? 'offset' : 'skip']: {\n\t\t\tgraphQlType: 'Int',\n\t\t\tvalue: args.offset,\n\t\t},\n\t}\n}\n"],"names":[],"mappings":";;AAGO,MAAM,iBAAiB,CAAC,QAAmC,MAAwE,OAA4B,WAAkC;AAChM,SAAA;AAAA,IACN,QAAQ;AAAA,MACP,aAAa,GAAG,OAAO,IAAI;AAAA,MAC3B,OAAO,KAAK;AAAA,IACb;AAAA,IACA,SAAS;AAAA,MACR,aAAa,IAAI,OAAO,IAAI;AAAA,MAC5B,OAAO,KAAK;AAAA,IACb;AAAA,IACA,CAAC,SAAS,SAAS,UAAU,OAAO,GAAG;AAAA,MACtC,aAAa;AAAA,MACb,OAAO,KAAK;AAAA,IACb;AAAA,IACA,CAAC,SAAS,SAAS,WAAW,MAAM,GAAG;AAAA,MACtC,aAAa;AAAA,MACb,OAAO,KAAK;AAAA,IAAA;AAAA,EAEd;AACD;;"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const createListArgs = (entity, args, type = "list") => {
|
|
2
|
-
return {
|
|
3
|
-
filter: {
|
|
4
|
-
graphQlType: `${entity.name}Where`,
|
|
5
|
-
value: args.filter
|
|
6
|
-
},
|
|
7
|
-
orderBy: {
|
|
8
|
-
graphQlType: `[${entity.name}OrderBy!]`,
|
|
9
|
-
value: args.orderBy
|
|
10
|
-
},
|
|
11
|
-
[type === "list" ? "limit" : "first"]: {
|
|
12
|
-
graphQlType: "Int",
|
|
13
|
-
value: args.limit
|
|
14
|
-
},
|
|
15
|
-
[type === "list" ? "offset" : "skip"]: {
|
|
16
|
-
graphQlType: "Int",
|
|
17
|
-
value: args.offset
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export {
|
|
22
|
-
createListArgs
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=createListArgs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createListArgs.js","sources":["../../../../../packages/client-content/src/utils/createListArgs.ts"],"sourcesContent":["import { SchemaEntityNames } from '../types'\nimport { GraphQlFieldTypedArgs } from '@contember/graphql-builder'\n\nexport const createListArgs = (entity: SchemaEntityNames<string>, args: { filter?: any; orderBy?: any; limit?: number; offset?: number }, type: 'list' | 'paginate' = 'list'): GraphQlFieldTypedArgs => {\n\treturn {\n\t\tfilter: {\n\t\t\tgraphQlType: `${entity.name}Where`,\n\t\t\tvalue: args.filter,\n\t\t},\n\t\torderBy: {\n\t\t\tgraphQlType: `[${entity.name}OrderBy!]`,\n\t\t\tvalue: args.orderBy,\n\t\t},\n\t\t[type === 'list' ? 'limit' : 'first']: {\n\t\t\tgraphQlType: 'Int',\n\t\t\tvalue: args.limit,\n\t\t},\n\t\t[type === 'list' ? 'offset' : 'skip']: {\n\t\t\tgraphQlType: 'Int',\n\t\t\tvalue: args.offset,\n\t\t},\n\t}\n}\n"],"names":[],"mappings":"AAGO,MAAM,iBAAiB,CAAC,QAAmC,MAAwE,OAA4B,WAAkC;AAChM,SAAA;AAAA,IACN,QAAQ;AAAA,MACP,aAAa,GAAG,OAAO,IAAI;AAAA,MAC3B,OAAO,KAAK;AAAA,IACb;AAAA,IACA,SAAS;AAAA,MACR,aAAa,IAAI,OAAO,IAAI;AAAA,MAC5B,OAAO,KAAK;AAAA,IACb;AAAA,IACA,CAAC,SAAS,SAAS,UAAU,OAAO,GAAG;AAAA,MACtC,aAAa;AAAA,MACb,OAAO,KAAK;AAAA,IACb;AAAA,IACA,CAAC,SAAS,SAAS,WAAW,MAAM,GAAG;AAAA,MACtC,aAAa;AAAA,MACb,OAAO,KAAK;AAAA,IAAA;AAAA,EAEd;AACD;"}
|