@soda-gql/core 0.0.1

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/index.cjs ADDED
@@ -0,0 +1,733 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ const require_slice = require('./slice-DhwBAhCw.cjs');
25
+ let graphql = require("graphql");
26
+ graphql = __toESM(graphql);
27
+
28
+ //#region packages/core/src/composer/build-document.ts
29
+ const buildArgumentValue = (value) => {
30
+ if (value === void 0) return null;
31
+ if (value === null) return { kind: graphql.Kind.NULL };
32
+ if (value instanceof require_slice.VarRef) return {
33
+ kind: graphql.Kind.VARIABLE,
34
+ name: {
35
+ kind: graphql.Kind.NAME,
36
+ value: value.name
37
+ }
38
+ };
39
+ if (Array.isArray(value)) return {
40
+ kind: graphql.Kind.LIST,
41
+ values: value.map((item) => buildArgumentValue(item)).filter((item) => item !== null)
42
+ };
43
+ if (typeof value === "object") return {
44
+ kind: graphql.Kind.OBJECT,
45
+ fields: Object.entries(value).map(([key, value$1]) => {
46
+ const valueNode = buildArgumentValue(value$1);
47
+ return valueNode ? {
48
+ kind: graphql.Kind.OBJECT_FIELD,
49
+ name: {
50
+ kind: graphql.Kind.NAME,
51
+ value: key
52
+ },
53
+ value: valueNode
54
+ } : null;
55
+ }).filter((item) => item !== null)
56
+ };
57
+ if (typeof value === "string") return {
58
+ kind: graphql.Kind.STRING,
59
+ value
60
+ };
61
+ if (typeof value === "number") return {
62
+ kind: !Number.isInteger(value) || value.toString().includes(".") ? graphql.Kind.FLOAT : graphql.Kind.INT,
63
+ value: value.toString()
64
+ };
65
+ if (typeof value === "boolean") return {
66
+ kind: graphql.Kind.BOOLEAN,
67
+ value
68
+ };
69
+ throw new Error(`Unknown value type: ${typeof value}`);
70
+ };
71
+ const buildArguments = (args) => Object.entries(args ?? {}).map(([name, value]) => {
72
+ const valueNode = buildArgumentValue(value);
73
+ return valueNode ? {
74
+ kind: graphql.Kind.ARGUMENT,
75
+ name: {
76
+ kind: graphql.Kind.NAME,
77
+ value: name
78
+ },
79
+ value: valueNode
80
+ } : null;
81
+ }).filter((item) => item !== null);
82
+ const buildUnionSelection = (union) => Object.entries(union).map(([typeName, object]) => {
83
+ return object ? {
84
+ kind: graphql.Kind.INLINE_FRAGMENT,
85
+ typeCondition: {
86
+ kind: graphql.Kind.NAMED_TYPE,
87
+ name: {
88
+ kind: graphql.Kind.NAME,
89
+ value: typeName
90
+ }
91
+ },
92
+ selectionSet: {
93
+ kind: graphql.Kind.SELECTION_SET,
94
+ selections: buildField(object)
95
+ }
96
+ } : null;
97
+ }).filter((item) => item !== null);
98
+ const buildField = (field) => Object.entries(field).map(([alias, { args, field: field$1, object, union }]) => ({
99
+ kind: graphql.Kind.FIELD,
100
+ name: {
101
+ kind: graphql.Kind.NAME,
102
+ value: field$1
103
+ },
104
+ alias: alias !== field$1 ? {
105
+ kind: graphql.Kind.NAME,
106
+ value: alias
107
+ } : void 0,
108
+ arguments: buildArguments(args),
109
+ selectionSet: object ? {
110
+ kind: graphql.Kind.SELECTION_SET,
111
+ selections: buildField(object)
112
+ } : union ? {
113
+ kind: graphql.Kind.SELECTION_SET,
114
+ selections: buildUnionSelection(union)
115
+ } : void 0
116
+ }));
117
+ const buildConstValueNode = (value) => {
118
+ if (value === void 0) return null;
119
+ if (value === null) return { kind: graphql.Kind.NULL };
120
+ if (typeof value === "string") return {
121
+ kind: graphql.Kind.STRING,
122
+ value
123
+ };
124
+ if (typeof value === "boolean") return {
125
+ kind: graphql.Kind.BOOLEAN,
126
+ value
127
+ };
128
+ if (typeof value === "number") return {
129
+ kind: !Number.isInteger(value) || value.toString().includes(".") ? graphql.Kind.FLOAT : graphql.Kind.INT,
130
+ value: value.toString()
131
+ };
132
+ if (Array.isArray(value)) return {
133
+ kind: graphql.Kind.LIST,
134
+ values: value.map((item) => buildConstValueNode(item)).filter((item) => item !== null)
135
+ };
136
+ if (typeof value === "object") return {
137
+ kind: graphql.Kind.OBJECT,
138
+ fields: Object.entries(value).map(([key, value$1]) => {
139
+ const valueNode = buildConstValueNode(value$1);
140
+ return valueNode ? {
141
+ kind: graphql.Kind.OBJECT_FIELD,
142
+ name: {
143
+ kind: graphql.Kind.NAME,
144
+ value: key
145
+ },
146
+ value: valueNode
147
+ } : null;
148
+ }).filter((item) => item !== null)
149
+ };
150
+ throw new Error(`Unknown value type: ${typeof value}`);
151
+ };
152
+ const buildWithTypeModifier = (modifier, buildType) => {
153
+ const baseType = buildType();
154
+ if (modifier === "?") return baseType;
155
+ let curr = {
156
+ modifier,
157
+ type: baseType
158
+ };
159
+ while (curr.modifier.length > 0) {
160
+ if (curr.modifier.startsWith("!")) {
161
+ curr = {
162
+ modifier: curr.modifier.slice(1),
163
+ type: curr.type.kind === graphql.Kind.NON_NULL_TYPE ? curr.type : {
164
+ kind: graphql.Kind.NON_NULL_TYPE,
165
+ type: curr.type
166
+ }
167
+ };
168
+ continue;
169
+ }
170
+ if (curr.modifier.startsWith("[]")) {
171
+ curr = {
172
+ modifier: curr.modifier.slice(2),
173
+ type: {
174
+ kind: graphql.Kind.LIST_TYPE,
175
+ type: curr.type
176
+ }
177
+ };
178
+ continue;
179
+ }
180
+ throw new Error(`Unknown modifier: ${curr.modifier}`);
181
+ }
182
+ return curr.type;
183
+ };
184
+ const buildVariables = (variables) => {
185
+ return Object.entries(variables).map(([name, ref]) => ({
186
+ kind: graphql.Kind.VARIABLE_DEFINITION,
187
+ variable: {
188
+ kind: graphql.Kind.VARIABLE,
189
+ name: {
190
+ kind: graphql.Kind.NAME,
191
+ value: name
192
+ }
193
+ },
194
+ defaultValue: ref.defaultValue && buildConstValueNode(ref.defaultValue.default) || void 0,
195
+ type: buildWithTypeModifier(ref.modifier, () => ({
196
+ kind: graphql.Kind.NAMED_TYPE,
197
+ name: {
198
+ kind: graphql.Kind.NAME,
199
+ value: ref.name
200
+ }
201
+ }))
202
+ }));
203
+ };
204
+ const buildOperationTypeNode = (operation) => {
205
+ switch (operation) {
206
+ case "query": return graphql.OperationTypeNode.QUERY;
207
+ case "mutation": return graphql.OperationTypeNode.MUTATION;
208
+ case "subscription": return graphql.OperationTypeNode.SUBSCRIPTION;
209
+ default: throw new Error(`Unknown operation type: ${operation}`);
210
+ }
211
+ };
212
+ const buildDocument = (options) => {
213
+ const { operationName, operationType, variables, fields } = options;
214
+ return {
215
+ kind: graphql.Kind.DOCUMENT,
216
+ definitions: [{
217
+ kind: graphql.Kind.OPERATION_DEFINITION,
218
+ operation: buildOperationTypeNode(operationType),
219
+ name: {
220
+ kind: graphql.Kind.NAME,
221
+ value: operationName
222
+ },
223
+ variableDefinitions: buildVariables(variables),
224
+ selectionSet: {
225
+ kind: graphql.Kind.SELECTION_SET,
226
+ selections: buildField(fields)
227
+ }
228
+ }]
229
+ };
230
+ };
231
+
232
+ //#endregion
233
+ //#region packages/core/src/types/element/gql-element.ts
234
+ const GQL_ELEMENT_FACTORY = Symbol("GQL_ELEMENT_FACTORY");
235
+ const GQL_ELEMENT_CONTEXT = Symbol("GQL_ELEMENT_CONTEXT");
236
+ var GqlElement = class GqlElement {
237
+ [GQL_ELEMENT_FACTORY];
238
+ [GQL_ELEMENT_CONTEXT] = null;
239
+ constructor(define$1) {
240
+ let cache = null;
241
+ this[GQL_ELEMENT_FACTORY] = (context) => {
242
+ if (cache) return cache.value;
243
+ const value = define$1(context);
244
+ cache = { value };
245
+ return value;
246
+ };
247
+ }
248
+ static setContext(element, context) {
249
+ element[GQL_ELEMENT_CONTEXT] = context;
250
+ }
251
+ static evaluate(element) {
252
+ GqlElement.get(element);
253
+ }
254
+ static get(element) {
255
+ const context = element[GQL_ELEMENT_CONTEXT];
256
+ return element[GQL_ELEMENT_FACTORY](context);
257
+ }
258
+ };
259
+
260
+ //#endregion
261
+ //#region packages/core/src/types/element/composed-operation.ts
262
+ var ComposedOperation = class ComposedOperation extends GqlElement {
263
+ constructor(define$1) {
264
+ super(define$1);
265
+ }
266
+ get operationType() {
267
+ return GqlElement.get(this).operationType;
268
+ }
269
+ get operationName() {
270
+ return GqlElement.get(this).operationName;
271
+ }
272
+ get variableNames() {
273
+ return GqlElement.get(this).variableNames;
274
+ }
275
+ get projectionPathGraph() {
276
+ return GqlElement.get(this).projectionPathGraph;
277
+ }
278
+ get document() {
279
+ return GqlElement.get(this).document;
280
+ }
281
+ get parse() {
282
+ return GqlElement.get(this).parse;
283
+ }
284
+ static create(define$1) {
285
+ return new ComposedOperation(define$1);
286
+ }
287
+ };
288
+
289
+ //#endregion
290
+ //#region packages/core/src/types/element/fields-builder.ts
291
+ const mergeFields = (fields) => Object.assign({}, ...fields);
292
+
293
+ //#endregion
294
+ //#region packages/core/src/types/element/inline-operation.ts
295
+ var InlineOperation = class InlineOperation extends GqlElement {
296
+ constructor(define$1) {
297
+ super(define$1);
298
+ }
299
+ get operationType() {
300
+ return GqlElement.get(this).operationType;
301
+ }
302
+ get operationName() {
303
+ return GqlElement.get(this).operationName;
304
+ }
305
+ get variableNames() {
306
+ return GqlElement.get(this).variableNames;
307
+ }
308
+ get documentSource() {
309
+ return GqlElement.get(this).documentSource;
310
+ }
311
+ get document() {
312
+ return GqlElement.get(this).document;
313
+ }
314
+ static create(define$1) {
315
+ return new InlineOperation(define$1);
316
+ }
317
+ };
318
+
319
+ //#endregion
320
+ //#region packages/core/src/types/element/model.ts
321
+ var Model = class Model extends GqlElement {
322
+ constructor(define$1) {
323
+ super(define$1);
324
+ }
325
+ get typename() {
326
+ return GqlElement.get(this).typename;
327
+ }
328
+ get fragment() {
329
+ return GqlElement.get(this).fragment;
330
+ }
331
+ get normalize() {
332
+ return GqlElement.get(this).normalize;
333
+ }
334
+ static create(define$1) {
335
+ return new Model(define$1);
336
+ }
337
+ };
338
+
339
+ //#endregion
340
+ //#region packages/core/src/types/element/slice.ts
341
+ var Slice = class Slice extends GqlElement {
342
+ constructor(define$1) {
343
+ super(define$1);
344
+ }
345
+ get operationType() {
346
+ return GqlElement.get(this).operationType;
347
+ }
348
+ get embed() {
349
+ return GqlElement.get(this).embed;
350
+ }
351
+ static create(define$1) {
352
+ return new Slice(define$1);
353
+ }
354
+ };
355
+
356
+ //#endregion
357
+ //#region packages/core/src/composer/projection-path-graph.ts
358
+ function createPathGraph(paths) {
359
+ const intermediate = paths.reduce((acc, { label, raw, segments: [segment, ...segments] }) => {
360
+ if (segment) (acc[segment] || (acc[segment] = [])).push({
361
+ label,
362
+ raw,
363
+ segments
364
+ });
365
+ return acc;
366
+ }, {});
367
+ return {
368
+ matches: paths.map(({ label, raw, segments }) => ({
369
+ label,
370
+ path: raw,
371
+ exact: segments.length === 0
372
+ })),
373
+ children: require_slice.mapValues(intermediate, (paths$1) => createPathGraph(paths$1))
374
+ };
375
+ }
376
+ function createPathGraphFromSliceEntries(fragments) {
377
+ return createPathGraph(Object.entries(fragments).flatMap(([label, slice]) => Array.from(new Map(slice.projection.paths.map(({ full: raw, segments }) => {
378
+ const [first, ...rest] = segments;
379
+ return [raw, {
380
+ label,
381
+ raw,
382
+ segments: [`${label}_${first}`, ...rest]
383
+ }];
384
+ })).values())));
385
+ }
386
+
387
+ //#endregion
388
+ //#region packages/core/src/composer/composed-operation.ts
389
+ const createComposedOperationComposerFactory = () => {
390
+ return (operationType) => {
391
+ return (options, builder) => {
392
+ return ComposedOperation.create(() => {
393
+ const { operationName } = options;
394
+ const variables = require_slice.mergeVarDefinitions(options.variables ?? []);
395
+ const fragments = builder({ $: require_slice.createVarRefs(variables) });
396
+ const fields = Object.fromEntries(Object.entries(fragments).flatMap(([label, { getFields: fields$1 }]) => Object.entries(fields$1).map(([key, reference]) => [`${label}_${key}`, reference])));
397
+ const projectionPathGraph = createPathGraphFromSliceEntries(fragments);
398
+ return {
399
+ operationType,
400
+ operationName,
401
+ variableNames: Object.keys(variables),
402
+ projectionPathGraph,
403
+ document: buildDocument({
404
+ operationName,
405
+ operationType,
406
+ variables,
407
+ fields
408
+ }),
409
+ parse: require_slice.createExecutionResultParser({
410
+ fragments,
411
+ projectionPathGraph
412
+ })
413
+ };
414
+ });
415
+ };
416
+ };
417
+ };
418
+
419
+ //#endregion
420
+ //#region packages/core/src/utils/wrap-by-key.ts
421
+ const wrapByKey = (name, value) => ({ [name]: value });
422
+
423
+ //#endregion
424
+ //#region packages/core/src/composer/fields-builder.ts
425
+ const cacheMapBySchema = /* @__PURE__ */ new WeakMap();
426
+ const ensureCacheMapBySchema = (schema) => {
427
+ const cachedCacheMap = cacheMapBySchema.get(schema);
428
+ if (cachedCacheMap) return cachedCacheMap;
429
+ const cacheMap = /* @__PURE__ */ new Map();
430
+ cacheMapBySchema.set(schema, cacheMap);
431
+ return cacheMap;
432
+ };
433
+ const createFieldFactories = (schema, typeName) => {
434
+ const cacheMap = ensureCacheMapBySchema(schema);
435
+ const cached = cacheMap.get(typeName);
436
+ if (cached) return cached;
437
+ const factories = createFieldFactoriesInner(schema, typeName);
438
+ cacheMap.set(typeName, factories);
439
+ return factories;
440
+ };
441
+ const createFieldFactoriesInner = (schema, typeName) => {
442
+ const typeDef = schema.object[typeName];
443
+ if (!typeDef) throw new Error(`Type ${typeName} is not defined in schema objects`);
444
+ const entries = Object.entries(typeDef.fields).map(([fieldName, type]) => {
445
+ const factory = (fieldArgs, extras) => {
446
+ const wrap = (value) => wrapByKey(extras?.alias ?? fieldName, value);
447
+ if (type.kind === "object") {
448
+ const factoryReturn = ((nest) => wrap({
449
+ parent: typeName,
450
+ field: fieldName,
451
+ type,
452
+ args: fieldArgs ?? {},
453
+ directives: extras?.directives ?? {},
454
+ object: mergeFields(nest({ f: createFieldFactories(schema, type.name) })),
455
+ union: null
456
+ }));
457
+ return factoryReturn;
458
+ }
459
+ if (type.kind === "union") {
460
+ const factoryReturn = ((nest) => wrap({
461
+ parent: typeName,
462
+ field: fieldName,
463
+ type,
464
+ args: fieldArgs ?? {},
465
+ directives: extras?.directives ?? {},
466
+ object: null,
467
+ union: require_slice.mapValues(nest, (builder, memberName) => {
468
+ if (!builder) throw new Error(`Builder is undefined for member name: ${memberName}`);
469
+ return mergeFields(builder({ f: createFieldFactories(schema, memberName) }));
470
+ })
471
+ }));
472
+ return factoryReturn;
473
+ }
474
+ if (type.kind === "scalar" || type.kind === "enum" || type.kind === "typename") return wrap({
475
+ parent: typeName,
476
+ field: fieldName,
477
+ type,
478
+ args: fieldArgs ?? {},
479
+ directives: extras?.directives ?? {},
480
+ object: null,
481
+ union: null
482
+ });
483
+ throw new Error(`Unsupported field type: ${type}`);
484
+ };
485
+ return [fieldName, factory];
486
+ });
487
+ return Object.fromEntries(entries);
488
+ };
489
+
490
+ //#endregion
491
+ //#region packages/core/src/composer/inline-operation.ts
492
+ const createInlineOperationComposerFactory = (schema) => {
493
+ return (operationType) => {
494
+ const operationTypeName = schema.operations[operationType];
495
+ if (operationTypeName === null) throw new Error(`Operation type ${operationType} is not defined in schema roots`);
496
+ return (options, fieldBuilder) => {
497
+ return InlineOperation.create(() => {
498
+ const { operationName } = options;
499
+ const variables = require_slice.mergeVarDefinitions(options.variables ?? []);
500
+ const $ = require_slice.createVarRefs(variables);
501
+ const fields = mergeFields(fieldBuilder({
502
+ f: createFieldFactories(schema, operationTypeName),
503
+ $
504
+ }));
505
+ return {
506
+ operationType,
507
+ operationName,
508
+ variableNames: Object.keys(variables),
509
+ documentSource: () => fields,
510
+ document: buildDocument({
511
+ operationName,
512
+ operationType,
513
+ variables,
514
+ fields
515
+ })
516
+ };
517
+ });
518
+ };
519
+ };
520
+ };
521
+
522
+ //#endregion
523
+ //#region packages/core/src/composer/model.ts
524
+ const createGqlModelComposers = (schema) => {
525
+ const createModelComposer = (typename) => {
526
+ return (options, builder, normalize) => Model.create(() => {
527
+ const varDefinitions = require_slice.mergeVarDefinitions(options.variables ?? []);
528
+ return {
529
+ typename,
530
+ fragment: (variables) => {
531
+ return mergeFields(builder({
532
+ f: createFieldFactories(schema, typename),
533
+ $: require_slice.createVarAssignments(varDefinitions, variables)
534
+ }));
535
+ },
536
+ normalize
537
+ };
538
+ });
539
+ };
540
+ return require_slice.mapValues(schema.object, (_, typename) => createModelComposer(typename));
541
+ };
542
+
543
+ //#endregion
544
+ //#region packages/core/src/composer/slice.ts
545
+ const createSliceComposerFactory = (schema) => {
546
+ return (operationType) => {
547
+ const operationTypeName = schema.operations[operationType];
548
+ if (operationTypeName === null) throw new Error(`Operation type ${operationType} is not defined in schema roots`);
549
+ return (options, fieldBuilder, projectionBuilder) => Slice.create(() => {
550
+ const varDefinitions = require_slice.mergeVarDefinitions(options.variables ?? []);
551
+ const projection = require_slice.handleProjectionBuilder(projectionBuilder);
552
+ return {
553
+ operationType,
554
+ embed: (variables) => {
555
+ const fields = mergeFields(fieldBuilder({
556
+ f: createFieldFactories(schema, operationTypeName),
557
+ $: require_slice.createVarAssignments(varDefinitions, variables)
558
+ }));
559
+ return {
560
+ variables,
561
+ getFields: () => fields,
562
+ projection
563
+ };
564
+ }
565
+ };
566
+ });
567
+ };
568
+ };
569
+
570
+ //#endregion
571
+ //#region packages/core/src/types/schema/type-modifier.ts
572
+ const parseModifiedTypeName = (nameAndModifier) => {
573
+ if (typeof nameAndModifier !== "string") throw new Error(`Invalid modified type name: ${nameAndModifier}`);
574
+ const [name, modifier] = nameAndModifier.split(":");
575
+ return {
576
+ name,
577
+ modifier
578
+ };
579
+ };
580
+
581
+ //#endregion
582
+ //#region packages/core/src/composer/var-builder.ts
583
+ const createVarBuilder = (schema) => {
584
+ const $ = (varName) => {
585
+ const createRefBuilder = (kind) => {
586
+ return (type, extras) => wrapByKey(varName, {
587
+ kind,
588
+ ...parseModifiedTypeName(type),
589
+ defaultValue: extras?.default ? { default: extras.default() } : null,
590
+ directives: extras?.directives ?? {}
591
+ });
592
+ };
593
+ return {
594
+ scalar: createRefBuilder("scalar"),
595
+ enum: createRefBuilder("enum"),
596
+ input: createRefBuilder("input"),
597
+ byField: (typeName, fieldName, argName) => {
598
+ const argTypeRef = schema.object[typeName]?.fields[fieldName]?.arguments[argName];
599
+ if (!argTypeRef) throw new Error(`Argument ${argName} not found in field ${fieldName} of type ${typeName}`);
600
+ return { ...argTypeRef };
601
+ }
602
+ };
603
+ };
604
+ return { $ };
605
+ };
606
+
607
+ //#endregion
608
+ //#region packages/core/src/composer/gql-composer.ts
609
+ const createGqlElementComposer = (schema) => {
610
+ const model = createGqlModelComposers(schema);
611
+ const createSliceComposer = createSliceComposerFactory(schema);
612
+ const createComposedOperationFactory = createComposedOperationComposerFactory();
613
+ const createInlineOperationComposer = createInlineOperationComposerFactory(schema);
614
+ const composers = {
615
+ model,
616
+ query: {
617
+ slice: createSliceComposer("query"),
618
+ composed: createComposedOperationFactory("query"),
619
+ inline: createInlineOperationComposer("query")
620
+ },
621
+ mutation: {
622
+ slice: createSliceComposer("mutation"),
623
+ composed: createComposedOperationFactory("mutation"),
624
+ inline: createInlineOperationComposer("mutation")
625
+ },
626
+ subscription: {
627
+ slice: createSliceComposer("subscription"),
628
+ composed: createComposedOperationFactory("subscription"),
629
+ inline: createInlineOperationComposer("subscription")
630
+ }
631
+ };
632
+ const helper = { ...createVarBuilder(schema) };
633
+ const elementComposer = (composeElement) => composeElement(composers, helper);
634
+ return elementComposer;
635
+ };
636
+
637
+ //#endregion
638
+ //#region packages/core/src/schema/type-specifier-builder.ts
639
+ const createUnsafeInputTypeSpecifierFactory = (kind) => {
640
+ return (type, extras) => ({
641
+ kind,
642
+ ...parseModifiedTypeName(type),
643
+ defaultValue: extras.default ? { default: extras.default() } : null,
644
+ directives: extras.directives ?? {}
645
+ });
646
+ };
647
+ const unsafeInputType = {
648
+ scalar: createUnsafeInputTypeSpecifierFactory("scalar"),
649
+ enum: createUnsafeInputTypeSpecifierFactory("enum"),
650
+ input: createUnsafeInputTypeSpecifierFactory("input")
651
+ };
652
+ const createUnsafeOutputTypeSpecifierFactory = (kind) => {
653
+ return (type, extras) => ({
654
+ kind,
655
+ ...parseModifiedTypeName(type),
656
+ arguments: extras.arguments ?? {},
657
+ directives: extras.directives ?? {}
658
+ });
659
+ };
660
+ const unsafeOutputType = {
661
+ scalar: createUnsafeOutputTypeSpecifierFactory("scalar"),
662
+ enum: createUnsafeOutputTypeSpecifierFactory("enum"),
663
+ object: createUnsafeOutputTypeSpecifierFactory("object"),
664
+ union: createUnsafeOutputTypeSpecifierFactory("union"),
665
+ typename: createUnsafeOutputTypeSpecifierFactory("typename")
666
+ };
667
+
668
+ //#endregion
669
+ //#region packages/core/src/schema/schema-builder.ts
670
+ const defineScalar = (name, definition) => wrapByKey(name, {
671
+ _type: require_slice.hidden(),
672
+ name,
673
+ directives: definition({ type: require_slice.hidden }).directives
674
+ });
675
+ const define = (name) => ({
676
+ enum: (values, directives) => ({
677
+ _type: require_slice.hidden(),
678
+ name,
679
+ values,
680
+ directives
681
+ }),
682
+ input: (fields, directives) => ({
683
+ name,
684
+ fields,
685
+ directives
686
+ }),
687
+ object: (fields, directives) => ({
688
+ name,
689
+ fields: {
690
+ __typename: unsafeOutputType.typename(`${name}:!`, {}),
691
+ ...fields
692
+ },
693
+ directives
694
+ }),
695
+ union: (types, directives) => ({
696
+ name,
697
+ types,
698
+ directives
699
+ })
700
+ });
701
+ const defineOperationRoots = (operationRoots) => operationRoots;
702
+
703
+ //#endregion
704
+ exports.ComposedOperation = ComposedOperation;
705
+ exports.GqlElement = GqlElement;
706
+ exports.InlineOperation = InlineOperation;
707
+ exports.Model = Model;
708
+ exports.Projection = require_slice.Projection;
709
+ exports.Slice = Slice;
710
+ exports.SlicedExecutionResultEmpty = require_slice.SlicedExecutionResultEmpty;
711
+ exports.SlicedExecutionResultError = require_slice.SlicedExecutionResultError;
712
+ exports.SlicedExecutionResultSuccess = require_slice.SlicedExecutionResultSuccess;
713
+ exports.buildArgumentValue = buildArgumentValue;
714
+ exports.buildConstValueNode = buildConstValueNode;
715
+ exports.buildDocument = buildDocument;
716
+ exports.buildOperationTypeNode = buildOperationTypeNode;
717
+ exports.buildWithTypeModifier = buildWithTypeModifier;
718
+ exports.createComposedOperationComposerFactory = createComposedOperationComposerFactory;
719
+ exports.createFieldFactories = createFieldFactories;
720
+ exports.createGqlElementComposer = createGqlElementComposer;
721
+ exports.createGqlModelComposers = createGqlModelComposers;
722
+ exports.createPathGraphFromSliceEntries = createPathGraphFromSliceEntries;
723
+ exports.createSliceComposerFactory = createSliceComposerFactory;
724
+ exports.createVarAssignments = require_slice.createVarAssignments;
725
+ exports.createVarBuilder = createVarBuilder;
726
+ exports.createVarRefs = require_slice.createVarRefs;
727
+ exports.define = define;
728
+ exports.defineOperationRoots = defineOperationRoots;
729
+ exports.defineScalar = defineScalar;
730
+ exports.mergeFields = mergeFields;
731
+ exports.mergeVarDefinitions = require_slice.mergeVarDefinitions;
732
+ exports.unsafeInputType = unsafeInputType;
733
+ exports.unsafeOutputType = unsafeOutputType;