@contember/client-content 1.3.0-alpha.9 → 2.0.0-alpha.2
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/dist/development/ContentQueryBuilder.cjs +64 -36
- package/dist/development/ContentQueryBuilder.cjs.map +1 -1
- package/dist/development/ContentQueryBuilder.js +64 -36
- package/dist/development/ContentQueryBuilder.js.map +1 -1
- package/dist/development/index.cjs +2 -0
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +3 -1
- package/dist/development/index.js.map +1 -1
- package/dist/development/nodes/ContentEntitySelection.cjs +36 -5
- package/dist/development/nodes/ContentEntitySelection.cjs.map +1 -1
- package/dist/development/nodes/ContentEntitySelection.js +36 -5
- package/dist/development/nodes/ContentEntitySelection.js.map +1 -1
- package/dist/development/utils/createTypedArgs.cjs +3 -0
- package/dist/development/utils/createTypedArgs.cjs.map +1 -1
- package/dist/development/utils/createTypedArgs.js +3 -0
- package/dist/development/utils/createTypedArgs.js.map +1 -1
- package/dist/production/ContentQueryBuilder.cjs +64 -36
- package/dist/production/ContentQueryBuilder.cjs.map +1 -1
- package/dist/production/ContentQueryBuilder.js +64 -36
- package/dist/production/ContentQueryBuilder.js.map +1 -1
- package/dist/production/index.cjs +2 -0
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +3 -1
- package/dist/production/index.js.map +1 -1
- package/dist/production/nodes/ContentEntitySelection.cjs +36 -5
- package/dist/production/nodes/ContentEntitySelection.cjs.map +1 -1
- package/dist/production/nodes/ContentEntitySelection.js +36 -5
- package/dist/production/nodes/ContentEntitySelection.js.map +1 -1
- package/dist/production/utils/createTypedArgs.cjs +3 -0
- package/dist/production/utils/createTypedArgs.cjs.map +1 -1
- package/dist/production/utils/createTypedArgs.js +3 -0
- package/dist/production/utils/createTypedArgs.js.map +1 -1
- package/dist/types/ContentQueryBuilder.d.ts +3 -1
- package/dist/types/ContentQueryBuilder.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/nodes/ContentEntitySelection.d.ts +10 -1
- package/dist/types/nodes/ContentEntitySelection.d.ts.map +1 -1
- package/dist/types/nodes/TypedEntitySelection.d.ts +44 -34
- package/dist/types/nodes/TypedEntitySelection.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/types/Input.d.ts +66 -6
- package/dist/types/types/Input.d.ts.map +1 -1
- package/dist/types/types/Schema.d.ts +3 -3
- package/dist/types/types/Schema.d.ts.map +1 -1
- package/dist/types/utils/createTypedArgs.d.ts.map +1 -1
- package/package.json +7 -4
- package/src/ContentQueryBuilder.ts +74 -51
- package/src/index.ts +1 -0
- package/src/nodes/ContentEntitySelection.ts +43 -4
- package/src/nodes/TypedEntitySelection.ts +87 -86
- package/src/types/Input.ts +72 -7
- package/src/types/Schema.ts +3 -3
- package/src/utils/createTypedArgs.ts +3 -0
|
@@ -6,9 +6,10 @@ class ContentEntitySelection {
|
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
|
-
constructor(context, selectionSet) {
|
|
9
|
+
constructor(context, selectionSet, transformFn) {
|
|
10
10
|
this.context = context;
|
|
11
11
|
this.selectionSet = selectionSet;
|
|
12
|
+
this.transformFn = transformFn;
|
|
12
13
|
}
|
|
13
14
|
$(field, argsOrSelection, selectionIn) {
|
|
14
15
|
const [args, selection] = typeof argsOrSelection === "function" || argsOrSelection instanceof ContentEntitySelection ? [{}, argsOrSelection] : [argsOrSelection ?? {}, selectionIn];
|
|
@@ -50,6 +51,11 @@ class ContentEntitySelection {
|
|
|
50
51
|
];
|
|
51
52
|
return new ContentEntitySelection(this.context, nodes);
|
|
52
53
|
}
|
|
54
|
+
transform(transform) {
|
|
55
|
+
return new ContentEntitySelection(this.context, this.selectionSet, !this.transformFn ? transform : (value, ctx) => {
|
|
56
|
+
return transform(this.transformFn(value, ctx), ctx);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
53
59
|
_column(name, args = {}) {
|
|
54
60
|
let fieldInfo = this.context.entity.fields[name];
|
|
55
61
|
if (!fieldInfo) {
|
|
@@ -83,7 +89,12 @@ class ContentEntitySelection {
|
|
|
83
89
|
createListArgs.createListArgs(entity, args),
|
|
84
90
|
entitySelection.selectionSet
|
|
85
91
|
);
|
|
86
|
-
|
|
92
|
+
const selectionWithField = this.withField(newObjectField);
|
|
93
|
+
const nestedTransform = entitySelection.transformFn;
|
|
94
|
+
if (!nestedTransform) {
|
|
95
|
+
return selectionWithField;
|
|
96
|
+
}
|
|
97
|
+
return this.withFieldTransform(alias, (it) => it.map(nestedTransform));
|
|
87
98
|
}
|
|
88
99
|
_manyBy(name, args, fields) {
|
|
89
100
|
const alias = args.as ?? name;
|
|
@@ -119,7 +130,12 @@ class ContentEntitySelection {
|
|
|
119
130
|
argsWithType,
|
|
120
131
|
entitySelection.selectionSet
|
|
121
132
|
);
|
|
122
|
-
|
|
133
|
+
const selectionWithField = this.withField(newObjectField);
|
|
134
|
+
const nestedTransform = entitySelection.transformFn;
|
|
135
|
+
if (!nestedTransform) {
|
|
136
|
+
return selectionWithField;
|
|
137
|
+
}
|
|
138
|
+
return this.withFieldTransform(alias, (it, ctx) => it !== null ? nestedTransform(it, ctx) : null);
|
|
123
139
|
}
|
|
124
140
|
_one(name, args, fields) {
|
|
125
141
|
const alias = args.as ?? name;
|
|
@@ -148,13 +164,28 @@ class ContentEntitySelection {
|
|
|
148
164
|
argsWithType,
|
|
149
165
|
entitySelection.selectionSet
|
|
150
166
|
);
|
|
151
|
-
|
|
167
|
+
const selectionWithField = this.withField(newObjectField);
|
|
168
|
+
const nestedTransform = entitySelection.transformFn;
|
|
169
|
+
if (!nestedTransform) {
|
|
170
|
+
return selectionWithField;
|
|
171
|
+
}
|
|
172
|
+
return this.withFieldTransform(alias, (it, ctx) => it !== null ? nestedTransform(it, ctx) : null);
|
|
152
173
|
}
|
|
153
174
|
withField(field) {
|
|
154
175
|
return new ContentEntitySelection(this.context, [
|
|
155
176
|
...this.selectionSet,
|
|
156
177
|
field
|
|
157
|
-
]);
|
|
178
|
+
], this.transformFn);
|
|
179
|
+
}
|
|
180
|
+
withFieldTransform(alias, transform) {
|
|
181
|
+
return new ContentEntitySelection(this.context, this.selectionSet, (value, ctx) => {
|
|
182
|
+
const transformedValue = transform(value[alias], ctx);
|
|
183
|
+
const newValue = {
|
|
184
|
+
...value,
|
|
185
|
+
[alias]: transformedValue
|
|
186
|
+
};
|
|
187
|
+
return this.transformFn ? this.transformFn(newValue, ctx) : newValue;
|
|
188
|
+
});
|
|
158
189
|
}
|
|
159
190
|
}
|
|
160
191
|
exports.ContentEntitySelection = ContentEntitySelection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentEntitySelection.cjs","sources":["../../../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 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) {\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\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\treturn this.withField(newObjectField)\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\treturn this.withField(newObjectField)\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\treturn this.withField(newObjectField)\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])\n\t}\n}\n"],"names":["GraphQlField","createListArgs"],"mappings":";;;;AA8BO,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA,EAKnC,YAEiB,SAEA,cACf;AAHe,SAAA,UAAA;AAEA,SAAA,eAAA;AAAA,EAEjB;AAAA,EASA,EAAE,OAAe,iBAA6E,aAAwE;AACrK,UAAM,CAAC,MAAM,SAAS,IAAI,OAAO,oBAAoB,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,MACA,MACA,QAGyB;AACnB,UAAA,QAAQ,KAAK,MAAM;AACzB,UAAM,YAAY,KAAK,QAAQ,OAAO,OAAO,IAAI;AACjD,QAAI,CAAC,WAAW;AACT,YAAA,IAAI,MAAM,SAAS,KAAK,QAAQ,OAAO,IAAI,IAAI,IAAI,kBAAkB;AAAA,IAC5E;AACI,QAAA,WAAW,SAAS,OAAO;AACxB,YAAA,IAAI,MAAM,SAAS,KAAK,QAAQ,OAAO,IAAI,IAAI,IAAI,6BAA6B;AAAA,IACvF;AACA,UAAM,SAAS,KAAK,QAAQ,OAAO,SAAS,UAAU,MAAM;AAE5D,UAAM,aAAqE;AAAA,MAC1E;AAAA,MACA,QAAQ,KAAK,QAAQ;AAAA,IAAA;AAEtB,UAAM,eAAsC;AAAA,MAC3C,QAAQ;AAAA,QACP,aAAa,GAAG,OAAO,IAAI;AAAA,QAC3B,OAAO,KAAK;AAAA,MACb;AAAA,IAAA;AAEK,UAAA,kBAAkB,OAAO,WAAW,aACvC,OAAO,IAAI,uBAAuB,YAAY,CAAA,CAAE,CAAQ,IACxD;AACH,UAAM,iBAAiB,IAAIA,eAAA;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,IAAA;AAEV,WAAA,KAAK,UAAU,cAAc;AAAA,EACrC;AAAA,EAGQ,UAAU,OAAqB;AAC/B,WAAA,IAAI,uBAAuB,KAAK,SAAS;AAAA,MAC/C,GAAG,KAAK;AAAA,MACR;AAAA,IAAA,CACA;AAAA,EACF;AACD;;"}
|
|
1
|
+
{"version":3,"file":"ContentEntitySelection.cjs","sources":["../../../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\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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A,IAAA;AAEtB,UAAM,eAAsC;AAAA,MAC3C,QAAQ;AAAA,QACP,aAAa,GAAG,OAAO,IAAI;AAAA,QAC3B,OAAO,KAAK;AAAA,MACb;AAAA,IAAA;AAEK,UAAA,kBAAkB,OAAO,WAAW,aACvC,OAAO,IAAI,uBAAuB,YAAY,CAAA,CAAE,CAAQ,IACxD;AACH,UAAM,iBAAiB,IAAIA,eAAA;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,IAAA;AAEX,UAAA,qBAAqB,KAAK,UAAU,cAAc;AACxD,UAAM,kBAAkB,gBAAgB;AACxC,QAAI,CAAC,iBAAiB;AACd,aAAA;AAAA,IACR;AACA,WAAO,KAAK,mBAAmB,OAAO,CAAC,IAAI,QAAQ,OAAO,OAAO,gBAAgB,IAAI,GAAG,IAAI,IAAI;AAAA,EACjG;AAAA,EAGQ,UAAU,OAAqB;AAC/B,WAAA,IAAI,uBAAuB,KAAK,SAAS;AAAA,MAC/C,GAAG,KAAK;AAAA,MACR;AAAA,IAAA,GACE,KAAK,WAAW;AAAA,EACpB;AAAA,EAEQ,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,MAAA;AAEV,aAAO,KAAK,cAAc,KAAK,YAAY,UAAU,GAAG,IAAI;AAAA,IAAA,CAC5D;AAAA,EACF;AACD;;"}
|
|
@@ -4,9 +4,10 @@ class ContentEntitySelection {
|
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
|
-
constructor(context, selectionSet) {
|
|
7
|
+
constructor(context, selectionSet, transformFn) {
|
|
8
8
|
this.context = context;
|
|
9
9
|
this.selectionSet = selectionSet;
|
|
10
|
+
this.transformFn = transformFn;
|
|
10
11
|
}
|
|
11
12
|
$(field, argsOrSelection, selectionIn) {
|
|
12
13
|
const [args, selection] = typeof argsOrSelection === "function" || argsOrSelection instanceof ContentEntitySelection ? [{}, argsOrSelection] : [argsOrSelection ?? {}, selectionIn];
|
|
@@ -48,6 +49,11 @@ class ContentEntitySelection {
|
|
|
48
49
|
];
|
|
49
50
|
return new ContentEntitySelection(this.context, nodes);
|
|
50
51
|
}
|
|
52
|
+
transform(transform) {
|
|
53
|
+
return new ContentEntitySelection(this.context, this.selectionSet, !this.transformFn ? transform : (value, ctx) => {
|
|
54
|
+
return transform(this.transformFn(value, ctx), ctx);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
51
57
|
_column(name, args = {}) {
|
|
52
58
|
let fieldInfo = this.context.entity.fields[name];
|
|
53
59
|
if (!fieldInfo) {
|
|
@@ -81,7 +87,12 @@ class ContentEntitySelection {
|
|
|
81
87
|
createListArgs(entity, args),
|
|
82
88
|
entitySelection.selectionSet
|
|
83
89
|
);
|
|
84
|
-
|
|
90
|
+
const selectionWithField = this.withField(newObjectField);
|
|
91
|
+
const nestedTransform = entitySelection.transformFn;
|
|
92
|
+
if (!nestedTransform) {
|
|
93
|
+
return selectionWithField;
|
|
94
|
+
}
|
|
95
|
+
return this.withFieldTransform(alias, (it) => it.map(nestedTransform));
|
|
85
96
|
}
|
|
86
97
|
_manyBy(name, args, fields) {
|
|
87
98
|
const alias = args.as ?? name;
|
|
@@ -117,7 +128,12 @@ class ContentEntitySelection {
|
|
|
117
128
|
argsWithType,
|
|
118
129
|
entitySelection.selectionSet
|
|
119
130
|
);
|
|
120
|
-
|
|
131
|
+
const selectionWithField = this.withField(newObjectField);
|
|
132
|
+
const nestedTransform = entitySelection.transformFn;
|
|
133
|
+
if (!nestedTransform) {
|
|
134
|
+
return selectionWithField;
|
|
135
|
+
}
|
|
136
|
+
return this.withFieldTransform(alias, (it, ctx) => it !== null ? nestedTransform(it, ctx) : null);
|
|
121
137
|
}
|
|
122
138
|
_one(name, args, fields) {
|
|
123
139
|
const alias = args.as ?? name;
|
|
@@ -146,13 +162,28 @@ class ContentEntitySelection {
|
|
|
146
162
|
argsWithType,
|
|
147
163
|
entitySelection.selectionSet
|
|
148
164
|
);
|
|
149
|
-
|
|
165
|
+
const selectionWithField = this.withField(newObjectField);
|
|
166
|
+
const nestedTransform = entitySelection.transformFn;
|
|
167
|
+
if (!nestedTransform) {
|
|
168
|
+
return selectionWithField;
|
|
169
|
+
}
|
|
170
|
+
return this.withFieldTransform(alias, (it, ctx) => it !== null ? nestedTransform(it, ctx) : null);
|
|
150
171
|
}
|
|
151
172
|
withField(field) {
|
|
152
173
|
return new ContentEntitySelection(this.context, [
|
|
153
174
|
...this.selectionSet,
|
|
154
175
|
field
|
|
155
|
-
]);
|
|
176
|
+
], this.transformFn);
|
|
177
|
+
}
|
|
178
|
+
withFieldTransform(alias, transform) {
|
|
179
|
+
return new ContentEntitySelection(this.context, this.selectionSet, (value, ctx) => {
|
|
180
|
+
const transformedValue = transform(value[alias], ctx);
|
|
181
|
+
const newValue = {
|
|
182
|
+
...value,
|
|
183
|
+
[alias]: transformedValue
|
|
184
|
+
};
|
|
185
|
+
return this.transformFn ? this.transformFn(newValue, ctx) : newValue;
|
|
186
|
+
});
|
|
156
187
|
}
|
|
157
188
|
}
|
|
158
189
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentEntitySelection.js","sources":["../../../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 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) {\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\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\treturn this.withField(newObjectField)\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\treturn this.withField(newObjectField)\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\treturn this.withField(newObjectField)\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])\n\t}\n}\n"],"names":[],"mappings":";;AA8BO,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA,EAKnC,YAEiB,SAEA,cACf;AAHe,SAAA,UAAA;AAEA,SAAA,eAAA;AAAA,EAEjB;AAAA,EASA,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,IACtE;AACA,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,QAClF;AACA,eAAO,KAAK,QAAQ,OAAO,MAAmC,SAAS;AAAA,MACxE;AAEM,YAAA,IAAI,MAAM,SAAS,KAAK,QAAQ,OAAO,IAAI,IAAI,KAAK,kBAAkB;AAAA,IAC7E;AACI,QAAA,UAAU,SAAS,UAAU;AACzB,aAAA,KAAK,QAAQ,OAAO,IAAiC;AAAA,IAC7D;AACI,QAAA,UAAU,SAAS,QAAQ;AAC9B,UAAI,CAAC,WAAW;AACT,cAAA,IAAI,MAAM,6BAA6B,KAAK,QAAQ,OAAO,IAAI,IAAI,KAAK,GAAG;AAAA,MAClF;AACA,aAAO,KAAK,MAAM,OAAO,MAAiC,SAAS;AAAA,IACpE;AACI,QAAA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G,KAAK;AAAA,MACR;AAAA,IAAA,CACA;AAAA,EACF;AACD;"}
|
|
1
|
+
{"version":3,"file":"ContentEntitySelection.js","sources":["../../../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\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,EAEjB;AAAA,EASA,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,IACtE;AACA,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,QAClF;AACA,eAAO,KAAK,QAAQ,OAAO,MAAmC,SAAS;AAAA,MACxE;AAEM,YAAA,IAAI,MAAM,SAAS,KAAK,QAAQ,OAAO,IAAI,IAAI,KAAK,kBAAkB;AAAA,IAC7E;AACI,QAAA,UAAU,SAAS,UAAU;AACzB,aAAA,KAAK,QAAQ,OAAO,IAAiC;AAAA,IAC7D;AACI,QAAA,UAAU,SA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AAG,IAAI;AAAA,IAAA,CAC5D;AAAA,EACF;AACD;"}
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const createTypedArgs = (args, types) => {
|
|
4
4
|
const typedArgs = {};
|
|
5
5
|
for (const key in args) {
|
|
6
|
+
if (!types.hasOwnProperty(key)) {
|
|
7
|
+
throw new Error(`Unknown argument ${key}`);
|
|
8
|
+
}
|
|
6
9
|
typedArgs[key] = {
|
|
7
10
|
graphQlType: types[key],
|
|
8
11
|
value: args[key]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTypedArgs.cjs","sources":["../../../src/utils/createTypedArgs.ts"],"sourcesContent":["import { GraphQlFieldTypedArgs } from '@contember/graphql-builder'\n\nexport const createTypedArgs = <TArgs extends Record<string, any>>(\n\targs: TArgs,\n\ttypes: { [key in keyof TArgs]: string },\n): GraphQlFieldTypedArgs => {\n\tconst typedArgs: GraphQlFieldTypedArgs = {}\n\tfor (const key in args) {\n\t\ttypedArgs[key] = {\n\t\t\tgraphQlType: types[key],\n\t\t\tvalue: args[key],\n\t\t}\n\t}\n\treturn typedArgs\n}\n"],"names":[],"mappings":";;AAEa,MAAA,kBAAkB,CAC9B,MACA,UAC2B;AAC3B,QAAM,YAAmC,CAAA;AACzC,aAAW,OAAO,MAAM;AACvB,cAAU,GAAG,IAAI;AAAA,MAChB,aAAa,MAAM,GAAG;AAAA,MACtB,OAAO,KAAK,GAAG;AAAA,IAAA;AAAA,EAEjB;AACO,SAAA;AACR;;"}
|
|
1
|
+
{"version":3,"file":"createTypedArgs.cjs","sources":["../../../src/utils/createTypedArgs.ts"],"sourcesContent":["import { GraphQlFieldTypedArgs } from '@contember/graphql-builder'\n\nexport const createTypedArgs = <TArgs extends Record<string, any>>(\n\targs: TArgs,\n\ttypes: { [key in keyof TArgs]: string },\n): GraphQlFieldTypedArgs => {\n\tconst typedArgs: GraphQlFieldTypedArgs = {}\n\tfor (const key in args) {\n\t\tif (!types.hasOwnProperty(key)) {\n\t\t\tthrow new Error(`Unknown argument ${key}`)\n\t\t}\n\t\ttypedArgs[key] = {\n\t\t\tgraphQlType: types[key],\n\t\t\tvalue: args[key],\n\t\t}\n\t}\n\treturn typedArgs\n}\n"],"names":[],"mappings":";;AAEa,MAAA,kBAAkB,CAC9B,MACA,UAC2B;AAC3B,QAAM,YAAmC,CAAA;AACzC,aAAW,OAAO,MAAM;AACvB,QAAI,CAAC,MAAM,eAAe,GAAG,GAAG;AAC/B,YAAM,IAAI,MAAM,oBAAoB,GAAG,EAAE;AAAA,IAC1C;AACA,cAAU,GAAG,IAAI;AAAA,MAChB,aAAa,MAAM,GAAG;AAAA,MACtB,OAAO,KAAK,GAAG;AAAA,IAAA;AAAA,EAEjB;AACO,SAAA;AACR;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTypedArgs.js","sources":["../../../src/utils/createTypedArgs.ts"],"sourcesContent":["import { GraphQlFieldTypedArgs } from '@contember/graphql-builder'\n\nexport const createTypedArgs = <TArgs extends Record<string, any>>(\n\targs: TArgs,\n\ttypes: { [key in keyof TArgs]: string },\n): GraphQlFieldTypedArgs => {\n\tconst typedArgs: GraphQlFieldTypedArgs = {}\n\tfor (const key in args) {\n\t\ttypedArgs[key] = {\n\t\t\tgraphQlType: types[key],\n\t\t\tvalue: args[key],\n\t\t}\n\t}\n\treturn typedArgs\n}\n"],"names":[],"mappings":"AAEa,MAAA,kBAAkB,CAC9B,MACA,UAC2B;AAC3B,QAAM,YAAmC,CAAA;AACzC,aAAW,OAAO,MAAM;AACvB,cAAU,GAAG,IAAI;AAAA,MAChB,aAAa,MAAM,GAAG;AAAA,MACtB,OAAO,KAAK,GAAG;AAAA,IAAA;AAAA,EAEjB;AACO,SAAA;AACR;"}
|
|
1
|
+
{"version":3,"file":"createTypedArgs.js","sources":["../../../src/utils/createTypedArgs.ts"],"sourcesContent":["import { GraphQlFieldTypedArgs } from '@contember/graphql-builder'\n\nexport const createTypedArgs = <TArgs extends Record<string, any>>(\n\targs: TArgs,\n\ttypes: { [key in keyof TArgs]: string },\n): GraphQlFieldTypedArgs => {\n\tconst typedArgs: GraphQlFieldTypedArgs = {}\n\tfor (const key in args) {\n\t\tif (!types.hasOwnProperty(key)) {\n\t\t\tthrow new Error(`Unknown argument ${key}`)\n\t\t}\n\t\ttypedArgs[key] = {\n\t\t\tgraphQlType: types[key],\n\t\t\tvalue: args[key],\n\t\t}\n\t}\n\treturn typedArgs\n}\n"],"names":[],"mappings":"AAEa,MAAA,kBAAkB,CAC9B,MACA,UAC2B;AAC3B,QAAM,YAAmC,CAAA;AACzC,aAAW,OAAO,MAAM;AACvB,QAAI,CAAC,MAAM,eAAe,GAAG,GAAG;AAC/B,YAAM,IAAI,MAAM,oBAAoB,GAAG,EAAE;AAAA,IAC1C;AACA,cAAU,GAAG,IAAI;AAAA,MAChB,aAAa,MAAM,GAAG;AAAA,MACtB,OAAO,KAAK,GAAG;AAAA,IAAA;AAAA,EAEjB;AACO,SAAA;AACR;"}
|
|
@@ -17,9 +17,11 @@ export declare class ContentQueryBuilder {
|
|
|
17
17
|
update(name: string, args: Input.UpdateInput, fields?: EntitySelectionOrCallback): ContentMutation<MutationResult>;
|
|
18
18
|
upsert(name: string, args: Input.UpsertInput, fields?: EntitySelectionOrCallback): ContentMutation<MutationResult>;
|
|
19
19
|
delete(name: string, args: Input.UniqueQueryInput, fields?: EntitySelectionOrCallback): ContentMutation<MutationResult>;
|
|
20
|
+
private createMutationOperation;
|
|
20
21
|
transaction(input: Record<string, ContentMutation<any> | ContentQuery<any>> | ContentMutation<any> | ContentMutation<any>[], options?: MutationTransactionOptions): ContentMutation<TransactionResult<any>>;
|
|
21
22
|
private createMutationSelection;
|
|
22
|
-
private
|
|
23
|
+
private resolveSelection;
|
|
23
24
|
private createContext;
|
|
25
|
+
private getEntity;
|
|
24
26
|
}
|
|
25
27
|
//# sourceMappingURL=ContentQueryBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentQueryBuilder.d.ts","sourceRoot":"","sources":["../../src/ContentQueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC5F,OAAO,
|
|
1
|
+
{"version":3,"file":"ContentQueryBuilder.d.ts","sourceRoot":"","sources":["../../src/ContentQueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC5F,OAAO,EAAE,sBAAsB,EAAE,8BAA8B,EAAiC,eAAe,EAAoB,YAAY,EAAE,MAAM,SAAS,CAAA;AAGhK,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAIzC,MAAM,MAAM,yBAAyB,GAClC,sBAAsB,GACtB,8BAA8B,CAAA;AAEjC,MAAM,MAAM,0BAA0B,GAAG;IACxC,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC,sBAAsB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AAID,qBAAa,mBAAmB;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,WAAW;IAIzC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,8BAA8B,GAAG,sBAAsB;IAY/F,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,QAAQ,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC;IAkBrG,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,CAAC,iBAAiB,EAAE,MAAM,EAAE,yBAAyB,GAAG,YAAY,CAAC,GAAG,EAAE,CAAC;IAkBtH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,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AAc,4BAA4B,CAAA;AAC1C,cAAc,uBAAuB,CAAA;AACrC,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uBAAuB,CAAA;AACrC,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,2BAA2B,CAAA"}
|
|
@@ -23,11 +23,16 @@ export type EntitySelectionOneArgs<Alias extends string | null = string | null>
|
|
|
23
23
|
export type EntitySelectionColumnArgs<Alias extends string | null = string | null> = EntitySelectionCommonInput<Alias>;
|
|
24
24
|
export type EntitySelectionAnyArgs = EntitySelectionColumnArgs | EntitySelectionManyArgs | EntitySelectionManyByArgs | EntitySelectionOneArgs;
|
|
25
25
|
export type ContentEntitySelectionOrCallback = ContentEntitySelectionCallback | ContentEntitySelection;
|
|
26
|
+
export type ContentTransformContext = {
|
|
27
|
+
rootValue: unknown;
|
|
28
|
+
};
|
|
26
29
|
export declare class ContentEntitySelection {
|
|
27
30
|
/** @internal */
|
|
28
31
|
readonly context: ContentEntitySelectionContext<string>;
|
|
29
32
|
/** @internal */
|
|
30
33
|
readonly selectionSet: GraphQlSelectionSet;
|
|
34
|
+
/** @internal */
|
|
35
|
+
readonly transformFn?: ((value: any, ctx: ContentTransformContext) => any) | undefined;
|
|
31
36
|
/**
|
|
32
37
|
* @internal
|
|
33
38
|
*/
|
|
@@ -35,17 +40,21 @@ export declare class ContentEntitySelection {
|
|
|
35
40
|
/** @internal */
|
|
36
41
|
context: ContentEntitySelectionContext<string>,
|
|
37
42
|
/** @internal */
|
|
38
|
-
selectionSet: GraphQlSelectionSet
|
|
43
|
+
selectionSet: GraphQlSelectionSet,
|
|
44
|
+
/** @internal */
|
|
45
|
+
transformFn?: ((value: any, ctx: ContentTransformContext) => any) | undefined);
|
|
39
46
|
$(field: string, args?: EntitySelectionColumnArgs): ContentEntitySelection;
|
|
40
47
|
$(field: string, args: EntitySelectionManyArgs, selection: ContentEntitySelectionOrCallback): ContentEntitySelection;
|
|
41
48
|
$(field: string, args: EntitySelectionManyByArgs, selection: ContentEntitySelectionOrCallback): ContentEntitySelection;
|
|
42
49
|
$(field: string, args: EntitySelectionOneArgs, selection: ContentEntitySelectionOrCallback): ContentEntitySelection;
|
|
43
50
|
$(field: string, selection: ContentEntitySelectionOrCallback): ContentEntitySelection;
|
|
44
51
|
$$(): ContentEntitySelection;
|
|
52
|
+
transform(transform: (value: any, context: ContentTransformContext) => any): ContentEntitySelection;
|
|
45
53
|
private _column;
|
|
46
54
|
private _many;
|
|
47
55
|
private _manyBy;
|
|
48
56
|
private _one;
|
|
49
57
|
private withField;
|
|
58
|
+
private withFieldTransform;
|
|
50
59
|
}
|
|
51
60
|
//# sourceMappingURL=ContentEntitySelection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentEntitySelection.d.ts","sourceRoot":"","sources":["../../../src/nodes/ContentEntitySelection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC7E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAuC,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAErG;;GAEG;AACH,MAAM,MAAM,6BAA6B,CAAC,IAAI,SAAS,MAAM,IAAI;IAChE,MAAM,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAC/B,MAAM,EAAE,WAAW,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG,CAAC,MAAM,EAAE,sBAAsB,KAAK,sBAAsB,CAAA;AAEvG,MAAM,MAAM,0BAA0B,CAAC,KAAK,SAAS,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,IAAI;IAAE,EA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Z,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,kBAAkB;CAU1B"}
|
|
@@ -1,42 +1,52 @@
|
|
|
1
|
-
import { EntityTypeLike, SchemaTypeLike } from '../types
|
|
1
|
+
import { EntityTypeLike, SchemaTypeLike } from '../types';
|
|
2
2
|
import { ContentClientInput } from '../types';
|
|
3
|
-
|
|
3
|
+
import { ContentEntitySelectionContext } from './ContentEntitySelection';
|
|
4
4
|
export interface TypedEntitySelection<TSchema extends SchemaTypeLike, TEntityName extends string, TEntity extends EntityTypeLike, TValue> {
|
|
5
|
+
/** @internal */
|
|
6
|
+
readonly context: ContentEntitySelectionContext<TEntityName>;
|
|
5
7
|
$$(): TypedEntitySelection<TSchema, TEntityName, TEntity, TValue & {
|
|
6
8
|
[key in keyof TEntity['columns']]: TEntity['columns'][key];
|
|
7
9
|
}>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[key in TAlias extends null ? TKey : TAlias]: TEntity['columns'][key];
|
|
12
|
-
}>;
|
|
13
|
-
$<TNestedValue, TNestedKey extends keyof TEntity['hasMany'] & string, TAlias extends string | null = null>(name: TNestedKey, args: ContentClientInput.HasManyRelationInput<TEntity['hasMany'][TNestedKey]> & {
|
|
14
|
-
as?: TAlias;
|
|
15
|
-
}, fields: TypedEntitySelectionCallback<TSchema, TEntity['hasMany'][TNestedKey]['name'], TEntity['hasMany'][TNestedKey], TNestedValue> | TypedEntitySelection<TSchema, TEntity['hasMany'][TNestedKey]['name'], TEntity['hasMany'][TNestedKey], TNestedValue>): TypedEntitySelection<TSchema, TEntityName, TEntity, TValue & {
|
|
16
|
-
[key in TAlias extends null ? TNestedKey : TAlias]: TNestedValue[];
|
|
17
|
-
}>;
|
|
18
|
-
$<TNestedValue, TNestedKey extends keyof TEntity['hasMany'] & string, TAlias extends string | null = null>(name: TNestedKey, fields: TypedEntitySelectionCallback<TSchema, TEntity['hasMany'][TNestedKey]['name'], TEntity['hasMany'][TNestedKey], TNestedValue> | TypedEntitySelection<TSchema, TEntity['hasMany'][TNestedKey]['name'], TEntity['hasMany'][TNestedKey], TNestedValue>): TypedEntitySelection<TSchema, TEntityName, TEntity, TValue & {
|
|
19
|
-
[key in TAlias extends null ? TNestedKey : TAlias]: TNestedValue[];
|
|
20
|
-
}>;
|
|
21
|
-
$<TNestedValue, TNestedKey extends keyof TEntity['hasManyBy'] & string, TAlias extends string | null = null>(name: TNestedKey, args: ContentClientInput.HasManyByRelationInput<TEntity['hasManyBy'][TNestedKey]['entity'], TEntity['hasManyBy'][TNestedKey]['by']> & {
|
|
22
|
-
as?: TAlias;
|
|
23
|
-
}, fields: TypedEntitySelectionCallback<TSchema, TEntity['hasManyBy'][TNestedKey]['entity']['name'], TEntity['hasManyBy'][TNestedKey]['entity'], TNestedValue> | TypedEntitySelection<TSchema, TEntity['hasManyBy'][TNestedKey]['entity']['name'], TEntity['hasManyBy'][TNestedKey]['entity'], TNestedValue>): TypedEntitySelection<TSchema, TEntityName, TEntity, TValue & {
|
|
24
|
-
[key in TAlias extends null ? TNestedKey : TAlias]: null | TNestedValue;
|
|
25
|
-
}>;
|
|
26
|
-
$<TNestedValue, TNestedKey extends keyof TEntity['hasManyBy'] & string, TAlias extends string | null = null>(name: TNestedKey, fields: TypedEntitySelectionCallback<TSchema, TEntity['hasManyBy'][TNestedKey]['entity']['name'], TEntity['hasManyBy'][TNestedKey]['entity'], TNestedValue> | TypedEntitySelection<TSchema, TEntity['hasManyBy'][TNestedKey]['entity']['name'], TEntity['hasManyBy'][TNestedKey]['entity'], TNestedValue>): TypedEntitySelection<TSchema, TEntityName, TEntity, TValue & {
|
|
27
|
-
[key in TAlias extends null ? TNestedKey : TAlias]: null | TNestedValue;
|
|
28
|
-
}>;
|
|
29
|
-
$<TNestedValue extends {
|
|
30
|
-
[K in string]: unknown;
|
|
31
|
-
}, TNestedKey extends keyof TEntity['hasOne'] & string, TAlias extends string | null = null>(name: TNestedKey, args: ContentClientInput.HasOneRelationInput<TEntity['hasOne'][TNestedKey]> & {
|
|
32
|
-
as?: TAlias;
|
|
33
|
-
}, fields: TypedEntitySelectionCallback<TSchema, TEntity['hasOne'][TNestedKey]['name'], TEntity['hasOne'][TNestedKey], TNestedValue> | TypedEntitySelection<TSchema, TEntity['hasOne'][TNestedKey]['name'], TEntity['hasOne'][TNestedKey], TNestedValue>): TypedEntitySelection<TSchema, TEntityName, TEntity, TValue & {
|
|
34
|
-
[key in TAlias extends null ? TNestedKey : TAlias]: TNestedValue | null;
|
|
35
|
-
}>;
|
|
36
|
-
$<TNestedValue extends {
|
|
37
|
-
[K in string]: unknown;
|
|
38
|
-
}, TNestedKey extends keyof TEntity['hasOne'] & string, TAlias extends string | null = null>(name: TNestedKey, fields: TypedEntitySelectionCallback<TSchema, TEntity['hasOne'][TNestedKey]['name'], TEntity['hasOne'][TNestedKey], TNestedValue> | TypedEntitySelection<TSchema, TEntity['hasOne'][TNestedKey]['name'], TEntity['hasOne'][TNestedKey], TNestedValue>): TypedEntitySelection<TSchema, TEntityName, TEntity, TValue & {
|
|
39
|
-
[key in TAlias extends null ? TNestedKey : TAlias]: TNestedValue | null;
|
|
10
|
+
transform<T>(cb: (value: TValue) => T): TypedEntitySelection<TSchema, TEntityName, TEntity, T>;
|
|
11
|
+
$<TNestedValue, TKey extends (keyof TEntity['columns'] | keyof TEntity['hasMany'] | keyof TEntity['hasManyBy'] | keyof TEntity['hasOne']) & string, TAlias extends string | null = null>(name: TKey, ...args: TypedEntitySelectionParams<TSchema, TEntity, TKey, TNestedValue, TAlias>): TypedEntitySelection<TSchema, TEntityName, TEntity, TValue & {
|
|
12
|
+
[key in TAlias extends null ? TKey : TAlias]: TypedEntitySelectionResult<TEntity, TKey, TNestedValue>;
|
|
40
13
|
}>;
|
|
41
14
|
}
|
|
15
|
+
export type TypedEntitySelectionCallback<TSchema extends SchemaTypeLike, EntityName extends string, TEntity extends EntityTypeLike, TValue> = (select: TypedEntitySelection<TSchema, EntityName, TEntity, {}>) => TypedEntitySelection<TSchema, EntityName, TEntity, TValue>;
|
|
16
|
+
export type TypedHasManyArgs<TEntity extends EntityTypeLike, TKey extends keyof TEntity['hasMany'] & string, TAlias extends string | null = null> = ContentClientInput.HasManyRelationInput<TEntity['hasMany'][TKey]> & {
|
|
17
|
+
as?: TAlias;
|
|
18
|
+
};
|
|
19
|
+
export type TypedHasManyFields<TSchema extends SchemaTypeLike, TEntity extends EntityTypeLike, TKey extends keyof TEntity['hasMany'] & string, TNestedValue> = TypedEntitySelectionCallback<TSchema, TEntity['hasMany'][TKey]['name'], TEntity['hasMany'][TKey], TNestedValue> | TypedEntitySelection<TSchema, TEntity['hasMany'][TKey]['name'], TEntity['hasMany'][TKey], TNestedValue>;
|
|
20
|
+
export type TypedHasManyParams<TSchema extends SchemaTypeLike, TEntity extends EntityTypeLike, TKey extends keyof TEntity['hasMany'] & string, TNestedValue, TAlias extends string | null = null> = [
|
|
21
|
+
args: TypedHasManyArgs<TEntity, TKey, TAlias>,
|
|
22
|
+
fields: TypedHasManyFields<TSchema, TEntity, TKey, TNestedValue>
|
|
23
|
+
] | [
|
|
24
|
+
fields: TypedHasManyFields<TSchema, TEntity, TKey, TNestedValue>
|
|
25
|
+
];
|
|
26
|
+
export type TypedHasManyByArgs<TEntity extends EntityTypeLike, TKey extends keyof TEntity['hasManyBy'] & string, TAlias extends string | null = null> = ContentClientInput.HasManyByRelationInput<TEntity['hasManyBy'][TKey]['entity'], TEntity['hasManyBy'][TKey]['by']> & {
|
|
27
|
+
as?: TAlias;
|
|
28
|
+
};
|
|
29
|
+
export type TypedHasManyByFields<TSchema extends SchemaTypeLike, TEntity extends EntityTypeLike, TKey extends keyof TEntity['hasManyBy'] & string, TNestedValue> = TypedEntitySelectionCallback<TSchema, TEntity['hasManyBy'][TKey]['entity']['name'], TEntity['hasManyBy'][TKey]['entity'], TNestedValue> | TypedEntitySelection<TSchema, TEntity['hasManyBy'][TKey]['entity']['name'], TEntity['hasManyBy'][TKey]['entity'], TNestedValue>;
|
|
30
|
+
export type TypedHasManyByParams<TSchema extends SchemaTypeLike, TEntity extends EntityTypeLike, TKey extends keyof TEntity['hasManyBy'] & string, TNestedValue, TAlias extends string | null = null> = [
|
|
31
|
+
args: TypedHasManyByArgs<TEntity, TKey, TAlias>,
|
|
32
|
+
fields: TypedHasManyByFields<TSchema, TEntity, TKey, TNestedValue>
|
|
33
|
+
];
|
|
34
|
+
export type TypedHasOneArgs<TEntity extends EntityTypeLike, TKey extends keyof TEntity['hasOne'] & string, TAlias extends string | null = null> = ContentClientInput.HasOneRelationInput<TEntity['hasOne'][TKey]> & {
|
|
35
|
+
as?: TAlias;
|
|
36
|
+
};
|
|
37
|
+
export type TypedHasOneFields<TSchema extends SchemaTypeLike, TEntity extends EntityTypeLike, TKey extends keyof TEntity['hasOne'] & string, TNestedValue> = TypedEntitySelectionCallback<TSchema, TEntity['hasOne'][TKey]['name'], TEntity['hasOne'][TKey], TNestedValue> | TypedEntitySelection<TSchema, TEntity['hasOne'][TKey]['name'], TEntity['hasOne'][TKey], TNestedValue>;
|
|
38
|
+
export type TypedHasOneParams<TSchema extends SchemaTypeLike, TEntity extends EntityTypeLike, TKey extends keyof TEntity['hasOne'] & string, TNestedValue, TAlias extends string | null = null> = [
|
|
39
|
+
args: TypedHasOneArgs<TEntity, TKey, TAlias>,
|
|
40
|
+
fields: TypedHasOneFields<TSchema, TEntity, TKey, TNestedValue>
|
|
41
|
+
] | [
|
|
42
|
+
fields: TypedHasOneFields<TSchema, TEntity, TKey, TNestedValue>
|
|
43
|
+
];
|
|
44
|
+
export type TypedColumnArgs<TAlias extends string | null = null> = {
|
|
45
|
+
as?: TAlias;
|
|
46
|
+
};
|
|
47
|
+
export type TypedColumnParams<TAlias extends string | null = null> = [
|
|
48
|
+
args: TypedColumnArgs<TAlias>
|
|
49
|
+
] | [];
|
|
50
|
+
export type TypedEntitySelectionParams<TSchema extends SchemaTypeLike, TEntity extends EntityTypeLike, TKey extends string, TNestedValue, TAlias extends string | null = null> = TKey extends keyof TEntity['columns'] ? TypedColumnParams<TAlias> : TKey extends keyof TEntity['hasMany'] ? TypedHasManyParams<TSchema, TEntity, TKey, TNestedValue, TAlias> : TKey extends keyof TEntity['hasManyBy'] ? TypedHasManyByParams<TSchema, TEntity, TKey, TNestedValue, TAlias> : TKey extends keyof TEntity['hasOne'] ? TypedHasOneParams<TSchema, TEntity, TKey, TNestedValue, TAlias> : never;
|
|
51
|
+
export type TypedEntitySelectionResult<TEntity extends EntityTypeLike, TKey extends string, TValue> = TKey extends keyof TEntity['columns'] ? TEntity['columns'][TKey] : TKey extends keyof TEntity['hasMany'] ? TValue[] : TKey extends keyof TEntity['hasManyBy'] ? null | TValue : TKey extends keyof TEntity['hasOne'] ? null | TValue : never;
|
|
42
52
|
//# sourceMappingURL=TypedEntitySelection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedEntitySelection.d.ts","sourceRoot":"","sources":["../../../src/nodes/TypedEntitySelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"TypedEntitySelection.d.ts","sourceRoot":"","sources":["../../../src/nodes/TypedEntitySelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAA;AAGxE,MAAM,WAAW,oBAAoB,CAAC,OAAO,SAAS,cAAc,EAAE,WAAW,SAAS,MAAM,EAAE,OAAO,SAAS,cAAc,EAAE,MAAM;IAEvI,gBAAgB;IAChB,QAAQ,CAAC,OAAO,EAAE,6BAA6B,CAAC,WAAW,CAAC,CAAC;IAE7D,EAAE,IAAI,oBAAoB,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG;SACjE,GAAG,IAAI,MAAM,O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