@fern-api/fern-api-dev 5.104.0 → 5.105.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.cjs +1091 -92
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -38761,11 +38761,11 @@ var require_errors = __commonJS({
38761
38761
  gen.code((0, codegen_1._)`${names_1.default.errors}++`);
38762
38762
  }
38763
38763
  function returnErrors(it3, errs) {
38764
- const { gen, validateName: validateName3, schemaEnv } = it3;
38764
+ const { gen, validateName: validateName4, schemaEnv } = it3;
38765
38765
  if (schemaEnv.$async) {
38766
38766
  gen.throw((0, codegen_1._)`new ${it3.ValidationError}(${errs})`);
38767
38767
  } else {
38768
- gen.assign((0, codegen_1._)`${validateName3}.errors`, errs);
38768
+ gen.assign((0, codegen_1._)`${validateName4}.errors`, errs);
38769
38769
  gen.return(false);
38770
38770
  }
38771
38771
  }
@@ -38834,13 +38834,13 @@ var require_boolSchema = __commonJS({
38834
38834
  message: "boolean schema is false"
38835
38835
  };
38836
38836
  function topBoolOrEmptySchema(it3) {
38837
- const { gen, schema, validateName: validateName3 } = it3;
38837
+ const { gen, schema, validateName: validateName4 } = it3;
38838
38838
  if (schema === false) {
38839
38839
  falseSchemaError(it3, false);
38840
38840
  } else if (typeof schema == "object" && schema.$async === true) {
38841
38841
  gen.return(names_1.default.data);
38842
38842
  } else {
38843
- gen.assign((0, codegen_1._)`${validateName3}.errors`, null);
38843
+ gen.assign((0, codegen_1._)`${validateName4}.errors`, null);
38844
38844
  gen.return(true);
38845
38845
  }
38846
38846
  }
@@ -39789,15 +39789,15 @@ var require_validate = __commonJS({
39789
39789
  validateFunction(it3, () => (0, boolSchema_1.topBoolOrEmptySchema)(it3));
39790
39790
  }
39791
39791
  exports2.validateFunctionCode = validateFunctionCode;
39792
- function validateFunction({ gen, validateName: validateName3, schema, schemaEnv, opts }, body) {
39792
+ function validateFunction({ gen, validateName: validateName4, schema, schemaEnv, opts }, body) {
39793
39793
  if (opts.code.es5) {
39794
- gen.func(validateName3, (0, codegen_1._)`${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => {
39794
+ gen.func(validateName4, (0, codegen_1._)`${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => {
39795
39795
  gen.code((0, codegen_1._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
39796
39796
  destructureValCxtES5(gen, opts);
39797
39797
  gen.code(body);
39798
39798
  });
39799
39799
  } else {
39800
- gen.func(validateName3, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
39800
+ gen.func(validateName4, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
39801
39801
  }
39802
39802
  }
39803
39803
  function destructureValCxt(opts) {
@@ -39836,8 +39836,8 @@ var require_validate = __commonJS({
39836
39836
  return;
39837
39837
  }
39838
39838
  function resetEvaluated(it3) {
39839
- const { gen, validateName: validateName3 } = it3;
39840
- it3.evaluated = gen.const("evaluated", (0, codegen_1._)`${validateName3}.evaluated`);
39839
+ const { gen, validateName: validateName4 } = it3;
39840
+ it3.evaluated = gen.const("evaluated", (0, codegen_1._)`${validateName4}.evaluated`);
39841
39841
  gen.if((0, codegen_1._)`${it3.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1._)`${it3.evaluated}.props`, (0, codegen_1._)`undefined`));
39842
39842
  gen.if((0, codegen_1._)`${it3.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1._)`${it3.evaluated}.items`, (0, codegen_1._)`undefined`));
39843
39843
  }
@@ -39919,11 +39919,11 @@ var require_validate = __commonJS({
39919
39919
  }
39920
39920
  }
39921
39921
  function returnResults(it3) {
39922
- const { gen, schemaEnv, validateName: validateName3, ValidationError: ValidationError5, opts } = it3;
39922
+ const { gen, schemaEnv, validateName: validateName4, ValidationError: ValidationError5, opts } = it3;
39923
39923
  if (schemaEnv.$async) {
39924
39924
  gen.if((0, codegen_1._)`${names_1.default.errors} === 0`, () => gen.return(names_1.default.data), () => gen.throw((0, codegen_1._)`new ${ValidationError5}(${names_1.default.vErrors})`));
39925
39925
  } else {
39926
- gen.assign((0, codegen_1._)`${validateName3}.errors`, names_1.default.vErrors);
39926
+ gen.assign((0, codegen_1._)`${validateName4}.errors`, names_1.default.vErrors);
39927
39927
  if (opts.unevaluated)
39928
39928
  assignEvaluated(it3);
39929
39929
  gen.return((0, codegen_1._)`${names_1.default.errors} === 0`);
@@ -40348,8 +40348,8 @@ var require_compile = __commonJS({
40348
40348
  code: (0, codegen_1._)`require("ajv/dist/runtime/validation_error").default`
40349
40349
  });
40350
40350
  }
40351
- const validateName3 = gen.scopeName("validate");
40352
- sch.validateName = validateName3;
40351
+ const validateName4 = gen.scopeName("validate");
40352
+ sch.validateName = validateName4;
40353
40353
  const schemaCxt = {
40354
40354
  gen,
40355
40355
  allErrors: this.opts.allErrors,
@@ -40363,7 +40363,7 @@ var require_compile = __commonJS({
40363
40363
  dataTypes: [],
40364
40364
  definedProperties: /* @__PURE__ */ new Set(),
40365
40365
  topSchemaRef: gen.scopeValue("schema", this.opts.code.source === true ? { ref: sch.schema, code: (0, codegen_1.stringify)(sch.schema) } : { ref: sch.schema }),
40366
- validateName: validateName3,
40366
+ validateName: validateName4,
40367
40367
  ValidationError: _ValidationError,
40368
40368
  schema: sch.schema,
40369
40369
  schemaEnv: sch,
@@ -40386,14 +40386,14 @@ var require_compile = __commonJS({
40386
40386
  sourceCode = this.opts.code.process(sourceCode, sch);
40387
40387
  const makeValidate = new Function(`${names_1.default.self}`, `${names_1.default.scope}`, sourceCode);
40388
40388
  const validate3 = makeValidate(this, this.scope.get());
40389
- this.scope.value(validateName3, { ref: validate3 });
40389
+ this.scope.value(validateName4, { ref: validate3 });
40390
40390
  validate3.errors = null;
40391
40391
  validate3.schema = sch.schema;
40392
40392
  validate3.schemaEnv = sch;
40393
40393
  if (sch.$async)
40394
40394
  validate3.$async = true;
40395
40395
  if (this.opts.code.source === true) {
40396
- validate3.source = { validateName: validateName3, validateCode, scopeValues: gen._values };
40396
+ validate3.source = { validateName: validateName4, validateCode, scopeValues: gen._values };
40397
40397
  }
40398
40398
  if (this.opts.unevaluated) {
40399
40399
  const { props, items } = schemaCxt;
@@ -42007,7 +42007,7 @@ var require_ref = __commonJS({
42007
42007
  schemaType: "string",
42008
42008
  code(cxt) {
42009
42009
  const { gen, schema: $ref, it: it3 } = cxt;
42010
- const { baseId, schemaEnv: env5, validateName: validateName3, opts, self: self2 } = it3;
42010
+ const { baseId, schemaEnv: env5, validateName: validateName4, opts, self: self2 } = it3;
42011
42011
  const { root: root6 } = env5;
42012
42012
  if (($ref === "#" || $ref === "#/") && baseId === root6.baseId)
42013
42013
  return callRootRef();
@@ -42019,7 +42019,7 @@ var require_ref = __commonJS({
42019
42019
  return inlineRefSchema(schOrEnv);
42020
42020
  function callRootRef() {
42021
42021
  if (env5 === root6)
42022
- return callRef(cxt, validateName3, env5, env5.$async);
42022
+ return callRef(cxt, validateName4, env5, env5.$async);
42023
42023
  const rootName = gen.scopeValue("root", { ref: root6 });
42024
42024
  return callRef(cxt, (0, codegen_1._)`${rootName}.validate`, root6, root6.$async);
42025
42025
  }
@@ -180798,11 +180798,11 @@ var require_errors2 = __commonJS({
180798
180798
  gen.code((0, codegen_1._)`${names_1.default.errors}++`);
180799
180799
  }
180800
180800
  function returnErrors(it3, errs) {
180801
- const { gen, validateName: validateName3, schemaEnv } = it3;
180801
+ const { gen, validateName: validateName4, schemaEnv } = it3;
180802
180802
  if (schemaEnv.$async) {
180803
180803
  gen.throw((0, codegen_1._)`new ${it3.ValidationError}(${errs})`);
180804
180804
  } else {
180805
- gen.assign((0, codegen_1._)`${validateName3}.errors`, errs);
180805
+ gen.assign((0, codegen_1._)`${validateName4}.errors`, errs);
180806
180806
  gen.return(false);
180807
180807
  }
180808
180808
  }
@@ -180872,13 +180872,13 @@ var require_boolSchema2 = __commonJS({
180872
180872
  message: "boolean schema is false"
180873
180873
  };
180874
180874
  function topBoolOrEmptySchema(it3) {
180875
- const { gen, schema, validateName: validateName3 } = it3;
180875
+ const { gen, schema, validateName: validateName4 } = it3;
180876
180876
  if (schema === false) {
180877
180877
  falseSchemaError(it3, false);
180878
180878
  } else if (typeof schema == "object" && schema.$async === true) {
180879
180879
  gen.return(names_1.default.data);
180880
180880
  } else {
180881
- gen.assign((0, codegen_1._)`${validateName3}.errors`, null);
180881
+ gen.assign((0, codegen_1._)`${validateName4}.errors`, null);
180882
180882
  gen.return(true);
180883
180883
  }
180884
180884
  }
@@ -181699,15 +181699,15 @@ var require_validate2 = __commonJS({
181699
181699
  }
181700
181700
  validateFunction(it3, () => (0, boolSchema_1.topBoolOrEmptySchema)(it3));
181701
181701
  }
181702
- function validateFunction({ gen, validateName: validateName3, schema, schemaEnv, opts }, body) {
181702
+ function validateFunction({ gen, validateName: validateName4, schema, schemaEnv, opts }, body) {
181703
181703
  if (opts.code.es5) {
181704
- gen.func(validateName3, (0, codegen_1._)`${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => {
181704
+ gen.func(validateName4, (0, codegen_1._)`${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => {
181705
181705
  gen.code((0, codegen_1._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
181706
181706
  destructureValCxtES5(gen, opts);
181707
181707
  gen.code(body);
181708
181708
  });
181709
181709
  } else {
181710
- gen.func(validateName3, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
181710
+ gen.func(validateName4, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
181711
181711
  }
181712
181712
  }
181713
181713
  function destructureValCxt(opts) {
@@ -181748,8 +181748,8 @@ var require_validate2 = __commonJS({
181748
181748
  return;
181749
181749
  }
181750
181750
  function resetEvaluated(it3) {
181751
- const { gen, validateName: validateName3 } = it3;
181752
- it3.evaluated = gen.const("evaluated", (0, codegen_1._)`${validateName3}.evaluated`);
181751
+ const { gen, validateName: validateName4 } = it3;
181752
+ it3.evaluated = gen.const("evaluated", (0, codegen_1._)`${validateName4}.evaluated`);
181753
181753
  gen.if((0, codegen_1._)`${it3.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1._)`${it3.evaluated}.props`, (0, codegen_1._)`undefined`));
181754
181754
  gen.if((0, codegen_1._)`${it3.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1._)`${it3.evaluated}.items`, (0, codegen_1._)`undefined`));
181755
181755
  }
@@ -181831,11 +181831,11 @@ var require_validate2 = __commonJS({
181831
181831
  }
181832
181832
  }
181833
181833
  function returnResults(it3) {
181834
- const { gen, schemaEnv, validateName: validateName3, ValidationError: ValidationError5, opts } = it3;
181834
+ const { gen, schemaEnv, validateName: validateName4, ValidationError: ValidationError5, opts } = it3;
181835
181835
  if (schemaEnv.$async) {
181836
181836
  gen.if((0, codegen_1._)`${names_1.default.errors} === 0`, () => gen.return(names_1.default.data), () => gen.throw((0, codegen_1._)`new ${ValidationError5}(${names_1.default.vErrors})`));
181837
181837
  } else {
181838
- gen.assign((0, codegen_1._)`${validateName3}.errors`, names_1.default.vErrors);
181838
+ gen.assign((0, codegen_1._)`${validateName4}.errors`, names_1.default.vErrors);
181839
181839
  if (opts.unevaluated)
181840
181840
  assignEvaluated(it3);
181841
181841
  gen.return((0, codegen_1._)`${names_1.default.errors} === 0`);
@@ -182262,8 +182262,8 @@ var require_compile2 = __commonJS({
182262
182262
  code: (0, codegen_1._)`require("ajv/dist/runtime/validation_error").default`
182263
182263
  });
182264
182264
  }
182265
- const validateName3 = gen.scopeName("validate");
182266
- sch.validateName = validateName3;
182265
+ const validateName4 = gen.scopeName("validate");
182266
+ sch.validateName = validateName4;
182267
182267
  const schemaCxt = {
182268
182268
  gen,
182269
182269
  allErrors: this.opts.allErrors,
@@ -182277,7 +182277,7 @@ var require_compile2 = __commonJS({
182277
182277
  dataTypes: [],
182278
182278
  definedProperties: /* @__PURE__ */ new Set(),
182279
182279
  topSchemaRef: gen.scopeValue("schema", this.opts.code.source === true ? { ref: sch.schema, code: (0, codegen_1.stringify)(sch.schema) } : { ref: sch.schema }),
182280
- validateName: validateName3,
182280
+ validateName: validateName4,
182281
182281
  ValidationError: _ValidationError,
182282
182282
  schema: sch.schema,
182283
182283
  schemaEnv: sch,
@@ -182300,14 +182300,14 @@ var require_compile2 = __commonJS({
182300
182300
  sourceCode = this.opts.code.process(sourceCode, sch);
182301
182301
  const makeValidate = new Function(`${names_1.default.self}`, `${names_1.default.scope}`, sourceCode);
182302
182302
  const validate3 = makeValidate(this, this.scope.get());
182303
- this.scope.value(validateName3, { ref: validate3 });
182303
+ this.scope.value(validateName4, { ref: validate3 });
182304
182304
  validate3.errors = null;
182305
182305
  validate3.schema = sch.schema;
182306
182306
  validate3.schemaEnv = sch;
182307
182307
  if (sch.$async)
182308
182308
  validate3.$async = true;
182309
182309
  if (this.opts.code.source === true) {
182310
- validate3.source = { validateName: validateName3, validateCode, scopeValues: gen._values };
182310
+ validate3.source = { validateName: validateName4, validateCode, scopeValues: gen._values };
182311
182311
  }
182312
182312
  if (this.opts.unevaluated) {
182313
182313
  const { props, items } = schemaCxt;
@@ -183485,7 +183485,7 @@ var require_ref2 = __commonJS({
183485
183485
  schemaType: "string",
183486
183486
  code(cxt) {
183487
183487
  const { gen, schema: $ref, it: it3 } = cxt;
183488
- const { baseId, schemaEnv: env5, validateName: validateName3, opts, self: self2 } = it3;
183488
+ const { baseId, schemaEnv: env5, validateName: validateName4, opts, self: self2 } = it3;
183489
183489
  const { root: root6 } = env5;
183490
183490
  if (($ref === "#" || $ref === "#/") && baseId === root6.baseId)
183491
183491
  return callRootRef();
@@ -183497,7 +183497,7 @@ var require_ref2 = __commonJS({
183497
183497
  return inlineRefSchema(schOrEnv);
183498
183498
  function callRootRef() {
183499
183499
  if (env5 === root6)
183500
- return callRef(cxt, validateName3, env5, env5.$async);
183500
+ return callRef(cxt, validateName4, env5, env5.$async);
183501
183501
  const rootName = gen.scopeValue("root", { ref: root6 });
183502
183502
  return callRef(cxt, (0, codegen_1._)`${rootName}.validate`, root6, root6.$async);
183503
183503
  }
@@ -200171,6 +200171,19 @@ var init_Source5 = __esm({
200171
200171
  });
200172
200172
 
200173
200173
  // ../../commons/api-workspace-commons/lib/Spec.js
200174
+ function groupGraphQLSpecsByNamespace(specs) {
200175
+ const grouped = /* @__PURE__ */ new Map();
200176
+ for (const spec of specs) {
200177
+ const key2 = spec.namespace ?? "";
200178
+ const existing = grouped.get(key2);
200179
+ if (existing != null) {
200180
+ existing.push(spec);
200181
+ } else {
200182
+ grouped.set(key2, [spec]);
200183
+ }
200184
+ }
200185
+ return grouped;
200186
+ }
200174
200187
  var init_Spec = __esm({
200175
200188
  "../../commons/api-workspace-commons/lib/Spec.js"() {
200176
200189
  "use strict";
@@ -345513,13 +345526,21 @@ var require_swagger2openapi = __commonJS({
345513
345526
  });
345514
345527
 
345515
345528
  // ../workspace/lazy-fern-workspace/lib/utils/convertOpenAPIV2ToV3.js
345516
- async function convertOpenAPIV2ToV3(openAPI) {
345529
+ async function convertOpenAPIV2ToV3(openAPI, options2) {
345530
+ let strictError;
345517
345531
  try {
345518
345532
  const conversionResult = await (0, import_swagger2openapi.convertObj)(openAPI, {});
345519
345533
  return conversionResult.openapi;
345520
- } catch (e2) {
345534
+ } catch (error50) {
345535
+ strictError = error50;
345536
+ }
345537
+ try {
345538
+ const conversionResult = await (0, import_swagger2openapi.convertObj)(openAPI, { patch: true });
345539
+ options2?.context?.logger.warn(`OpenAPI v2 (Swagger) document is not strictly valid and was converted in lenient (patch) mode: ${strictError instanceof Error ? strictError.message : String(strictError)}`);
345540
+ return conversionResult.openapi;
345541
+ } catch {
345521
345542
  throw new CliError({
345522
- message: `Failed to convert OpenAPI v2 (Swagger) spec to OpenAPI v3: ${e2 instanceof Error ? e2.message : String(e2)}`,
345543
+ message: `Failed to convert OpenAPI v2 (Swagger) spec to OpenAPI v3: ${strictError instanceof Error ? strictError.message : String(strictError)}`,
345523
345544
  code: CliError.Code.ParseError
345524
345545
  });
345525
345546
  }
@@ -346428,7 +346449,7 @@ var init_OpenAPILoader = __esm({
346428
346449
  if (!openAPI.schemes || openAPI.schemes.length === 0) {
346429
346450
  openAPI.schemes = ["https"];
346430
346451
  }
346431
- const convertedOpenAPI = await convertOpenAPIV2ToV3(openAPI);
346452
+ const convertedOpenAPI = await convertOpenAPIV2ToV3(openAPI, { context: context3 });
346432
346453
  return {
346433
346454
  type: "openapi",
346434
346455
  value: convertedOpenAPI,
@@ -365696,6 +365717,9 @@ function getNullableType(type7) {
365696
365717
  return isNonNullType(type7) ? type7.ofType : type7;
365697
365718
  }
365698
365719
  }
365720
+ function isNamedType(type7) {
365721
+ return isScalarType(type7) || isObjectType(type7) || isInterfaceType(type7) || isUnionType(type7) || isEnumType(type7) || isInputObjectType(type7);
365722
+ }
365699
365723
  function getNamedType(type7) {
365700
365724
  if (type7) {
365701
365725
  let unwrappedType = type7;
@@ -366260,6 +366284,18 @@ var init_definition = __esm({
366260
366284
  });
366261
366285
 
366262
366286
  // ../../../node_modules/.pnpm/graphql@16.13.2/node_modules/graphql/utilities/typeComparators.mjs
366287
+ function isEqualType(typeA, typeB) {
366288
+ if (typeA === typeB) {
366289
+ return true;
366290
+ }
366291
+ if (isNonNullType(typeA) && isNonNullType(typeB)) {
366292
+ return isEqualType(typeA.ofType, typeB.ofType);
366293
+ }
366294
+ if (isListType2(typeA) && isListType2(typeB)) {
366295
+ return isEqualType(typeA.ofType, typeB.ofType);
366296
+ }
366297
+ return false;
366298
+ }
366263
366299
  function isTypeSubTypeOf(schema, maybeSubType, superType) {
366264
366300
  if (maybeSubType === superType) {
366265
366301
  return true;
@@ -367304,6 +367340,15 @@ var init_introspection = __esm({
367304
367340
  });
367305
367341
 
367306
367342
  // ../../../node_modules/.pnpm/graphql@16.13.2/node_modules/graphql/type/schema.mjs
367343
+ function isSchema(schema) {
367344
+ return instanceOf(schema, GraphQLSchema);
367345
+ }
367346
+ function assertSchema(schema) {
367347
+ if (!isSchema(schema)) {
367348
+ throw new Error(`Expected ${inspect4(schema)} to be a GraphQL schema.`);
367349
+ }
367350
+ return schema;
367351
+ }
367307
367352
  function collectReferencedTypes(type7, typeSet) {
367308
367353
  const namedType = getNamedType(type7);
367309
367354
  if (!typeSet.has(namedType)) {
@@ -367336,6 +367381,7 @@ var init_schema2 = __esm({
367336
367381
  "use strict";
367337
367382
  init_devAssert();
367338
367383
  init_inspect();
367384
+ init_instanceOf();
367339
367385
  init_isObjectLike2();
367340
367386
  init_toObjMap();
367341
367387
  init_ast2();
@@ -367518,6 +367564,464 @@ var init_schema2 = __esm({
367518
367564
  }
367519
367565
  });
367520
367566
 
367567
+ // ../../../node_modules/.pnpm/graphql@16.13.2/node_modules/graphql/type/validate.mjs
367568
+ function validateSchema2(schema) {
367569
+ assertSchema(schema);
367570
+ if (schema.__validationErrors) {
367571
+ return schema.__validationErrors;
367572
+ }
367573
+ const context3 = new SchemaValidationContext(schema);
367574
+ validateRootTypes(context3);
367575
+ validateDirectives(context3);
367576
+ validateTypes(context3);
367577
+ const errors4 = context3.getErrors();
367578
+ schema.__validationErrors = errors4;
367579
+ return errors4;
367580
+ }
367581
+ function validateRootTypes(context3) {
367582
+ const schema = context3.schema;
367583
+ const queryType = schema.getQueryType();
367584
+ if (!queryType) {
367585
+ context3.reportError("Query root type must be provided.", schema.astNode);
367586
+ } else if (!isObjectType(queryType)) {
367587
+ var _getOperationTypeNode;
367588
+ context3.reportError(
367589
+ `Query root type must be Object type, it cannot be ${inspect4(
367590
+ queryType
367591
+ )}.`,
367592
+ (_getOperationTypeNode = getOperationTypeNode(
367593
+ schema,
367594
+ OperationTypeNode.QUERY
367595
+ )) !== null && _getOperationTypeNode !== void 0 ? _getOperationTypeNode : queryType.astNode
367596
+ );
367597
+ }
367598
+ const mutationType = schema.getMutationType();
367599
+ if (mutationType && !isObjectType(mutationType)) {
367600
+ var _getOperationTypeNode2;
367601
+ context3.reportError(
367602
+ `Mutation root type must be Object type if provided, it cannot be ${inspect4(mutationType)}.`,
367603
+ (_getOperationTypeNode2 = getOperationTypeNode(
367604
+ schema,
367605
+ OperationTypeNode.MUTATION
367606
+ )) !== null && _getOperationTypeNode2 !== void 0 ? _getOperationTypeNode2 : mutationType.astNode
367607
+ );
367608
+ }
367609
+ const subscriptionType = schema.getSubscriptionType();
367610
+ if (subscriptionType && !isObjectType(subscriptionType)) {
367611
+ var _getOperationTypeNode3;
367612
+ context3.reportError(
367613
+ `Subscription root type must be Object type if provided, it cannot be ${inspect4(subscriptionType)}.`,
367614
+ (_getOperationTypeNode3 = getOperationTypeNode(
367615
+ schema,
367616
+ OperationTypeNode.SUBSCRIPTION
367617
+ )) !== null && _getOperationTypeNode3 !== void 0 ? _getOperationTypeNode3 : subscriptionType.astNode
367618
+ );
367619
+ }
367620
+ }
367621
+ function getOperationTypeNode(schema, operation) {
367622
+ var _flatMap$find;
367623
+ return (_flatMap$find = [schema.astNode, ...schema.extensionASTNodes].flatMap(
367624
+ // FIXME: https://github.com/graphql/graphql-js/issues/2203
367625
+ (schemaNode) => {
367626
+ var _schemaNode$operation;
367627
+ return (
367628
+ /* c8 ignore next */
367629
+ (_schemaNode$operation = schemaNode === null || schemaNode === void 0 ? void 0 : schemaNode.operationTypes) !== null && _schemaNode$operation !== void 0 ? _schemaNode$operation : []
367630
+ );
367631
+ }
367632
+ ).find((operationNode) => operationNode.operation === operation)) === null || _flatMap$find === void 0 ? void 0 : _flatMap$find.type;
367633
+ }
367634
+ function validateDirectives(context3) {
367635
+ for (const directive of context3.schema.getDirectives()) {
367636
+ if (!isDirective(directive)) {
367637
+ context3.reportError(
367638
+ `Expected directive but got: ${inspect4(directive)}.`,
367639
+ directive === null || directive === void 0 ? void 0 : directive.astNode
367640
+ );
367641
+ continue;
367642
+ }
367643
+ validateName3(context3, directive);
367644
+ if (directive.locations.length === 0) {
367645
+ context3.reportError(
367646
+ `Directive @${directive.name} must include 1 or more locations.`,
367647
+ directive.astNode
367648
+ );
367649
+ }
367650
+ for (const arg of directive.args) {
367651
+ validateName3(context3, arg);
367652
+ if (!isInputType(arg.type)) {
367653
+ context3.reportError(
367654
+ `The type of @${directive.name}(${arg.name}:) must be Input Type but got: ${inspect4(arg.type)}.`,
367655
+ arg.astNode
367656
+ );
367657
+ }
367658
+ if (isRequiredArgument(arg) && arg.deprecationReason != null) {
367659
+ var _arg$astNode;
367660
+ context3.reportError(
367661
+ `Required argument @${directive.name}(${arg.name}:) cannot be deprecated.`,
367662
+ [
367663
+ getDeprecatedDirectiveNode(arg.astNode),
367664
+ (_arg$astNode = arg.astNode) === null || _arg$astNode === void 0 ? void 0 : _arg$astNode.type
367665
+ ]
367666
+ );
367667
+ }
367668
+ }
367669
+ }
367670
+ }
367671
+ function validateName3(context3, node4) {
367672
+ if (node4.name.startsWith("__")) {
367673
+ context3.reportError(
367674
+ `Name "${node4.name}" must not begin with "__", which is reserved by GraphQL introspection.`,
367675
+ node4.astNode
367676
+ );
367677
+ }
367678
+ }
367679
+ function validateTypes(context3) {
367680
+ const validateInputObjectCircularRefs = createInputObjectCircularRefsValidator(context3);
367681
+ const typeMap = context3.schema.getTypeMap();
367682
+ for (const type7 of Object.values(typeMap)) {
367683
+ if (!isNamedType(type7)) {
367684
+ context3.reportError(
367685
+ `Expected GraphQL named type but got: ${inspect4(type7)}.`,
367686
+ type7.astNode
367687
+ );
367688
+ continue;
367689
+ }
367690
+ if (!isIntrospectionType(type7)) {
367691
+ validateName3(context3, type7);
367692
+ }
367693
+ if (isObjectType(type7)) {
367694
+ validateFields(context3, type7);
367695
+ validateInterfaces(context3, type7);
367696
+ } else if (isInterfaceType(type7)) {
367697
+ validateFields(context3, type7);
367698
+ validateInterfaces(context3, type7);
367699
+ } else if (isUnionType(type7)) {
367700
+ validateUnionMembers(context3, type7);
367701
+ } else if (isEnumType(type7)) {
367702
+ validateEnumValues(context3, type7);
367703
+ } else if (isInputObjectType(type7)) {
367704
+ validateInputFields(context3, type7);
367705
+ validateInputObjectCircularRefs(type7);
367706
+ }
367707
+ }
367708
+ }
367709
+ function validateFields(context3, type7) {
367710
+ const fields = Object.values(type7.getFields());
367711
+ if (fields.length === 0) {
367712
+ context3.reportError(`Type ${type7.name} must define one or more fields.`, [
367713
+ type7.astNode,
367714
+ ...type7.extensionASTNodes
367715
+ ]);
367716
+ }
367717
+ for (const field5 of fields) {
367718
+ validateName3(context3, field5);
367719
+ if (!isOutputType(field5.type)) {
367720
+ var _field$astNode;
367721
+ context3.reportError(
367722
+ `The type of ${type7.name}.${field5.name} must be Output Type but got: ${inspect4(field5.type)}.`,
367723
+ (_field$astNode = field5.astNode) === null || _field$astNode === void 0 ? void 0 : _field$astNode.type
367724
+ );
367725
+ }
367726
+ for (const arg of field5.args) {
367727
+ const argName = arg.name;
367728
+ validateName3(context3, arg);
367729
+ if (!isInputType(arg.type)) {
367730
+ var _arg$astNode2;
367731
+ context3.reportError(
367732
+ `The type of ${type7.name}.${field5.name}(${argName}:) must be Input Type but got: ${inspect4(arg.type)}.`,
367733
+ (_arg$astNode2 = arg.astNode) === null || _arg$astNode2 === void 0 ? void 0 : _arg$astNode2.type
367734
+ );
367735
+ }
367736
+ if (isRequiredArgument(arg) && arg.deprecationReason != null) {
367737
+ var _arg$astNode3;
367738
+ context3.reportError(
367739
+ `Required argument ${type7.name}.${field5.name}(${argName}:) cannot be deprecated.`,
367740
+ [
367741
+ getDeprecatedDirectiveNode(arg.astNode),
367742
+ (_arg$astNode3 = arg.astNode) === null || _arg$astNode3 === void 0 ? void 0 : _arg$astNode3.type
367743
+ ]
367744
+ );
367745
+ }
367746
+ }
367747
+ }
367748
+ }
367749
+ function validateInterfaces(context3, type7) {
367750
+ const ifaceTypeNames = /* @__PURE__ */ Object.create(null);
367751
+ for (const iface of type7.getInterfaces()) {
367752
+ if (!isInterfaceType(iface)) {
367753
+ context3.reportError(
367754
+ `Type ${inspect4(type7)} must only implement Interface types, it cannot implement ${inspect4(iface)}.`,
367755
+ getAllImplementsInterfaceNodes(type7, iface)
367756
+ );
367757
+ continue;
367758
+ }
367759
+ if (type7 === iface) {
367760
+ context3.reportError(
367761
+ `Type ${type7.name} cannot implement itself because it would create a circular reference.`,
367762
+ getAllImplementsInterfaceNodes(type7, iface)
367763
+ );
367764
+ continue;
367765
+ }
367766
+ if (ifaceTypeNames[iface.name]) {
367767
+ context3.reportError(
367768
+ `Type ${type7.name} can only implement ${iface.name} once.`,
367769
+ getAllImplementsInterfaceNodes(type7, iface)
367770
+ );
367771
+ continue;
367772
+ }
367773
+ ifaceTypeNames[iface.name] = true;
367774
+ validateTypeImplementsAncestors(context3, type7, iface);
367775
+ validateTypeImplementsInterface(context3, type7, iface);
367776
+ }
367777
+ }
367778
+ function validateTypeImplementsInterface(context3, type7, iface) {
367779
+ const typeFieldMap = type7.getFields();
367780
+ for (const ifaceField of Object.values(iface.getFields())) {
367781
+ const fieldName = ifaceField.name;
367782
+ const typeField = typeFieldMap[fieldName];
367783
+ if (!typeField) {
367784
+ context3.reportError(
367785
+ `Interface field ${iface.name}.${fieldName} expected but ${type7.name} does not provide it.`,
367786
+ [ifaceField.astNode, type7.astNode, ...type7.extensionASTNodes]
367787
+ );
367788
+ continue;
367789
+ }
367790
+ if (!isTypeSubTypeOf(context3.schema, typeField.type, ifaceField.type)) {
367791
+ var _ifaceField$astNode, _typeField$astNode;
367792
+ context3.reportError(
367793
+ `Interface field ${iface.name}.${fieldName} expects type ${inspect4(ifaceField.type)} but ${type7.name}.${fieldName} is type ${inspect4(typeField.type)}.`,
367794
+ [
367795
+ (_ifaceField$astNode = ifaceField.astNode) === null || _ifaceField$astNode === void 0 ? void 0 : _ifaceField$astNode.type,
367796
+ (_typeField$astNode = typeField.astNode) === null || _typeField$astNode === void 0 ? void 0 : _typeField$astNode.type
367797
+ ]
367798
+ );
367799
+ }
367800
+ for (const ifaceArg of ifaceField.args) {
367801
+ const argName = ifaceArg.name;
367802
+ const typeArg = typeField.args.find((arg) => arg.name === argName);
367803
+ if (!typeArg) {
367804
+ context3.reportError(
367805
+ `Interface field argument ${iface.name}.${fieldName}(${argName}:) expected but ${type7.name}.${fieldName} does not provide it.`,
367806
+ [ifaceArg.astNode, typeField.astNode]
367807
+ );
367808
+ continue;
367809
+ }
367810
+ if (!isEqualType(ifaceArg.type, typeArg.type)) {
367811
+ var _ifaceArg$astNode, _typeArg$astNode;
367812
+ context3.reportError(
367813
+ `Interface field argument ${iface.name}.${fieldName}(${argName}:) expects type ${inspect4(ifaceArg.type)} but ${type7.name}.${fieldName}(${argName}:) is type ${inspect4(typeArg.type)}.`,
367814
+ [
367815
+ (_ifaceArg$astNode = ifaceArg.astNode) === null || _ifaceArg$astNode === void 0 ? void 0 : _ifaceArg$astNode.type,
367816
+ (_typeArg$astNode = typeArg.astNode) === null || _typeArg$astNode === void 0 ? void 0 : _typeArg$astNode.type
367817
+ ]
367818
+ );
367819
+ }
367820
+ }
367821
+ for (const typeArg of typeField.args) {
367822
+ const argName = typeArg.name;
367823
+ const ifaceArg = ifaceField.args.find((arg) => arg.name === argName);
367824
+ if (!ifaceArg && isRequiredArgument(typeArg)) {
367825
+ context3.reportError(
367826
+ `Object field ${type7.name}.${fieldName} includes required argument ${argName} that is missing from the Interface field ${iface.name}.${fieldName}.`,
367827
+ [typeArg.astNode, ifaceField.astNode]
367828
+ );
367829
+ }
367830
+ }
367831
+ }
367832
+ }
367833
+ function validateTypeImplementsAncestors(context3, type7, iface) {
367834
+ const ifaceInterfaces = type7.getInterfaces();
367835
+ for (const transitive of iface.getInterfaces()) {
367836
+ if (!ifaceInterfaces.includes(transitive)) {
367837
+ context3.reportError(
367838
+ transitive === type7 ? `Type ${type7.name} cannot implement ${iface.name} because it would create a circular reference.` : `Type ${type7.name} must implement ${transitive.name} because it is implemented by ${iface.name}.`,
367839
+ [
367840
+ ...getAllImplementsInterfaceNodes(iface, transitive),
367841
+ ...getAllImplementsInterfaceNodes(type7, iface)
367842
+ ]
367843
+ );
367844
+ }
367845
+ }
367846
+ }
367847
+ function validateUnionMembers(context3, union23) {
367848
+ const memberTypes = union23.getTypes();
367849
+ if (memberTypes.length === 0) {
367850
+ context3.reportError(
367851
+ `Union type ${union23.name} must define one or more member types.`,
367852
+ [union23.astNode, ...union23.extensionASTNodes]
367853
+ );
367854
+ }
367855
+ const includedTypeNames = /* @__PURE__ */ Object.create(null);
367856
+ for (const memberType of memberTypes) {
367857
+ if (includedTypeNames[memberType.name]) {
367858
+ context3.reportError(
367859
+ `Union type ${union23.name} can only include type ${memberType.name} once.`,
367860
+ getUnionMemberTypeNodes(union23, memberType.name)
367861
+ );
367862
+ continue;
367863
+ }
367864
+ includedTypeNames[memberType.name] = true;
367865
+ if (!isObjectType(memberType)) {
367866
+ context3.reportError(
367867
+ `Union type ${union23.name} can only include Object types, it cannot include ${inspect4(memberType)}.`,
367868
+ getUnionMemberTypeNodes(union23, String(memberType))
367869
+ );
367870
+ }
367871
+ }
367872
+ }
367873
+ function validateEnumValues(context3, enumType2) {
367874
+ const enumValues = enumType2.getValues();
367875
+ if (enumValues.length === 0) {
367876
+ context3.reportError(
367877
+ `Enum type ${enumType2.name} must define one or more values.`,
367878
+ [enumType2.astNode, ...enumType2.extensionASTNodes]
367879
+ );
367880
+ }
367881
+ for (const enumValue of enumValues) {
367882
+ validateName3(context3, enumValue);
367883
+ }
367884
+ }
367885
+ function validateInputFields(context3, inputObj) {
367886
+ const fields = Object.values(inputObj.getFields());
367887
+ if (fields.length === 0) {
367888
+ context3.reportError(
367889
+ `Input Object type ${inputObj.name} must define one or more fields.`,
367890
+ [inputObj.astNode, ...inputObj.extensionASTNodes]
367891
+ );
367892
+ }
367893
+ for (const field5 of fields) {
367894
+ validateName3(context3, field5);
367895
+ if (!isInputType(field5.type)) {
367896
+ var _field$astNode2;
367897
+ context3.reportError(
367898
+ `The type of ${inputObj.name}.${field5.name} must be Input Type but got: ${inspect4(field5.type)}.`,
367899
+ (_field$astNode2 = field5.astNode) === null || _field$astNode2 === void 0 ? void 0 : _field$astNode2.type
367900
+ );
367901
+ }
367902
+ if (isRequiredInputField(field5) && field5.deprecationReason != null) {
367903
+ var _field$astNode3;
367904
+ context3.reportError(
367905
+ `Required input field ${inputObj.name}.${field5.name} cannot be deprecated.`,
367906
+ [
367907
+ getDeprecatedDirectiveNode(field5.astNode),
367908
+ (_field$astNode3 = field5.astNode) === null || _field$astNode3 === void 0 ? void 0 : _field$astNode3.type
367909
+ ]
367910
+ );
367911
+ }
367912
+ if (inputObj.isOneOf) {
367913
+ validateOneOfInputObjectField(inputObj, field5, context3);
367914
+ }
367915
+ }
367916
+ }
367917
+ function validateOneOfInputObjectField(type7, field5, context3) {
367918
+ if (isNonNullType(field5.type)) {
367919
+ var _field$astNode4;
367920
+ context3.reportError(
367921
+ `OneOf input field ${type7.name}.${field5.name} must be nullable.`,
367922
+ (_field$astNode4 = field5.astNode) === null || _field$astNode4 === void 0 ? void 0 : _field$astNode4.type
367923
+ );
367924
+ }
367925
+ if (field5.defaultValue !== void 0) {
367926
+ context3.reportError(
367927
+ `OneOf input field ${type7.name}.${field5.name} cannot have a default value.`,
367928
+ field5.astNode
367929
+ );
367930
+ }
367931
+ }
367932
+ function createInputObjectCircularRefsValidator(context3) {
367933
+ const visitedTypes = /* @__PURE__ */ Object.create(null);
367934
+ const fieldPath = [];
367935
+ const fieldPathIndexByTypeName = /* @__PURE__ */ Object.create(null);
367936
+ return detectCycleRecursive;
367937
+ function detectCycleRecursive(inputObj) {
367938
+ if (visitedTypes[inputObj.name]) {
367939
+ return;
367940
+ }
367941
+ visitedTypes[inputObj.name] = true;
367942
+ fieldPathIndexByTypeName[inputObj.name] = fieldPath.length;
367943
+ const fields = Object.values(inputObj.getFields());
367944
+ for (const field5 of fields) {
367945
+ if (isNonNullType(field5.type) && isInputObjectType(field5.type.ofType)) {
367946
+ const fieldType = field5.type.ofType;
367947
+ const cycleIndex = fieldPathIndexByTypeName[fieldType.name];
367948
+ fieldPath.push(field5);
367949
+ if (cycleIndex === void 0) {
367950
+ detectCycleRecursive(fieldType);
367951
+ } else {
367952
+ const cyclePath = fieldPath.slice(cycleIndex);
367953
+ const pathStr = cyclePath.map((fieldObj) => fieldObj.name).join(".");
367954
+ context3.reportError(
367955
+ `Cannot reference Input Object "${fieldType.name}" within itself through a series of non-null fields: "${pathStr}".`,
367956
+ cyclePath.map((fieldObj) => fieldObj.astNode)
367957
+ );
367958
+ }
367959
+ fieldPath.pop();
367960
+ }
367961
+ }
367962
+ fieldPathIndexByTypeName[inputObj.name] = void 0;
367963
+ }
367964
+ }
367965
+ function getAllImplementsInterfaceNodes(type7, iface) {
367966
+ const { astNode, extensionASTNodes } = type7;
367967
+ const nodes = astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes;
367968
+ return nodes.flatMap((typeNode) => {
367969
+ var _typeNode$interfaces;
367970
+ return (
367971
+ /* c8 ignore next */
367972
+ (_typeNode$interfaces = typeNode.interfaces) !== null && _typeNode$interfaces !== void 0 ? _typeNode$interfaces : []
367973
+ );
367974
+ }).filter((ifaceNode) => ifaceNode.name.value === iface.name);
367975
+ }
367976
+ function getUnionMemberTypeNodes(union23, typeName) {
367977
+ const { astNode, extensionASTNodes } = union23;
367978
+ const nodes = astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes;
367979
+ return nodes.flatMap((unionNode) => {
367980
+ var _unionNode$types;
367981
+ return (
367982
+ /* c8 ignore next */
367983
+ (_unionNode$types = unionNode.types) !== null && _unionNode$types !== void 0 ? _unionNode$types : []
367984
+ );
367985
+ }).filter((typeNode) => typeNode.name.value === typeName);
367986
+ }
367987
+ function getDeprecatedDirectiveNode(definitionNode) {
367988
+ var _definitionNode$direc;
367989
+ return definitionNode === null || definitionNode === void 0 ? void 0 : (_definitionNode$direc = definitionNode.directives) === null || _definitionNode$direc === void 0 ? void 0 : _definitionNode$direc.find(
367990
+ (node4) => node4.name.value === GraphQLDeprecatedDirective.name
367991
+ );
367992
+ }
367993
+ var SchemaValidationContext;
367994
+ var init_validate2 = __esm({
367995
+ "../../../node_modules/.pnpm/graphql@16.13.2/node_modules/graphql/type/validate.mjs"() {
367996
+ "use strict";
367997
+ init_inspect();
367998
+ init_GraphQLError();
367999
+ init_ast2();
368000
+ init_typeComparators();
368001
+ init_definition();
368002
+ init_directives();
368003
+ init_introspection();
368004
+ init_schema2();
368005
+ SchemaValidationContext = class {
368006
+ constructor(schema) {
368007
+ this._errors = [];
368008
+ this.schema = schema;
368009
+ }
368010
+ reportError(message, nodes) {
368011
+ const _nodes = Array.isArray(nodes) ? nodes.filter(Boolean) : nodes;
368012
+ this._errors.push(
368013
+ new GraphQLError(message, {
368014
+ nodes: _nodes
368015
+ })
368016
+ );
368017
+ }
368018
+ getErrors() {
368019
+ return this._errors;
368020
+ }
368021
+ };
368022
+ }
368023
+ });
368024
+
367521
368025
  // ../../../node_modules/.pnpm/graphql@16.13.2/node_modules/graphql/utilities/typeFromAST.mjs
367522
368026
  function typeFromAST(schema, typeNode) {
367523
368027
  switch (typeNode.kind) {
@@ -370605,7 +371109,7 @@ function assertValidSDL(documentAST) {
370605
371109
  }
370606
371110
  }
370607
371111
  var QueryDocumentKeysToValidate;
370608
- var init_validate2 = __esm({
371112
+ var init_validate3 = __esm({
370609
371113
  "../../../node_modules/.pnpm/graphql@16.13.2/node_modules/graphql/validation/validate.mjs"() {
370610
371114
  "use strict";
370611
371115
  init_mapValue();
@@ -370625,6 +371129,18 @@ var init_type3 = __esm({
370625
371129
  "../../../node_modules/.pnpm/graphql@16.13.2/node_modules/graphql/type/index.mjs"() {
370626
371130
  "use strict";
370627
371131
  init_definition();
371132
+ init_directives();
371133
+ init_validate2();
371134
+ }
371135
+ });
371136
+
371137
+ // ../../../node_modules/.pnpm/graphql@16.13.2/node_modules/graphql/language/index.mjs
371138
+ var init_language = __esm({
371139
+ "../../../node_modules/.pnpm/graphql@16.13.2/node_modules/graphql/language/index.mjs"() {
371140
+ "use strict";
371141
+ init_kinds();
371142
+ init_parser();
371143
+ init_printer();
370628
371144
  }
370629
371145
  });
370630
371146
 
@@ -371533,25 +372049,14 @@ function buildASTSchema(documentAST, options2) {
371533
372049
  ];
371534
372050
  return new GraphQLSchema({ ...config5, directives });
371535
372051
  }
371536
- function buildSchema(source2, options2) {
371537
- const document4 = parse9(source2, {
371538
- noLocation: options2 === null || options2 === void 0 ? void 0 : options2.noLocation,
371539
- allowLegacyFragmentVariables: options2 === null || options2 === void 0 ? void 0 : options2.allowLegacyFragmentVariables
371540
- });
371541
- return buildASTSchema(document4, {
371542
- assumeValidSDL: options2 === null || options2 === void 0 ? void 0 : options2.assumeValidSDL,
371543
- assumeValid: options2 === null || options2 === void 0 ? void 0 : options2.assumeValid
371544
- });
371545
- }
371546
372052
  var init_buildASTSchema = __esm({
371547
372053
  "../../../node_modules/.pnpm/graphql@16.13.2/node_modules/graphql/utilities/buildASTSchema.mjs"() {
371548
372054
  "use strict";
371549
372055
  init_devAssert();
371550
372056
  init_kinds();
371551
- init_parser();
371552
372057
  init_directives();
371553
372058
  init_schema2();
371554
- init_validate2();
372059
+ init_validate3();
371555
372060
  init_extendSchema();
371556
372061
  }
371557
372062
  });
@@ -371762,10 +372267,445 @@ var init_graphql = __esm({
371762
372267
  "../../../node_modules/.pnpm/graphql@16.13.2/node_modules/graphql/index.mjs"() {
371763
372268
  "use strict";
371764
372269
  init_type3();
372270
+ init_language();
371765
372271
  init_utilities2();
371766
372272
  }
371767
372273
  });
371768
372274
 
372275
+ // ../api-importers/graphql/lib/mergeGraphQlDocuments.js
372276
+ function mergeGraphQlDocuments(sources) {
372277
+ const conflicts2 = [];
372278
+ const types4 = /* @__PURE__ */ new Map();
372279
+ const directiveDefinitions = /* @__PURE__ */ new Map();
372280
+ const operationTypes = /* @__PURE__ */ new Map();
372281
+ const otherDefinitions = [];
372282
+ const inaccessible = { types: /* @__PURE__ */ new Set(), seen: false };
372283
+ for (const source2 of sources) {
372284
+ for (const definition3 of parseSource(source2).definitions) {
372285
+ if (definition3.kind === Kind.DIRECTIVE_DEFINITION) {
372286
+ const directiveName = definition3.name.value;
372287
+ if (FEDERATION_DIRECTIVES.has(directiveName)) {
372288
+ continue;
372289
+ }
372290
+ const owner = directiveDefinitions.get(directiveName);
372291
+ if (owner == null) {
372292
+ directiveDefinitions.set(directiveName, { definition: definition3, filePath: source2.filePath });
372293
+ } else if (print(owner.definition) !== print(definition3)) {
372294
+ conflicts2.push({
372295
+ typeName: `@${directiveName}`,
372296
+ memberName: "<declaration>",
372297
+ kept: owner.filePath,
372298
+ dropped: source2.filePath
372299
+ });
372300
+ }
372301
+ continue;
372302
+ }
372303
+ if (definition3.kind === Kind.SCHEMA_DEFINITION || definition3.kind === Kind.SCHEMA_EXTENSION) {
372304
+ for (const operationType of definition3.operationTypes ?? []) {
372305
+ const owner = operationTypes.get(operationType.operation);
372306
+ if (owner == null) {
372307
+ operationTypes.set(operationType.operation, { operationType, filePath: source2.filePath });
372308
+ } else if (owner.operationType.type.name.value !== operationType.type.name.value) {
372309
+ conflicts2.push({
372310
+ typeName: "schema",
372311
+ memberName: operationType.operation,
372312
+ kept: owner.filePath,
372313
+ dropped: source2.filePath
372314
+ });
372315
+ }
372316
+ }
372317
+ continue;
372318
+ }
372319
+ if (isTypeExtension(definition3)) {
372320
+ mergeTypeDefinition({
372321
+ incoming: typeExtensionToDefinition(definition3),
372322
+ isExtension: true,
372323
+ filePath: source2.filePath,
372324
+ types: types4,
372325
+ conflicts: conflicts2,
372326
+ inaccessible
372327
+ });
372328
+ continue;
372329
+ }
372330
+ if (isTypeDefinition(definition3)) {
372331
+ mergeTypeDefinition({
372332
+ incoming: definition3,
372333
+ isExtension: false,
372334
+ filePath: source2.filePath,
372335
+ types: types4,
372336
+ conflicts: conflicts2,
372337
+ inaccessible
372338
+ });
372339
+ continue;
372340
+ }
372341
+ if (definition3.kind === Kind.OPERATION_DEFINITION || definition3.kind === Kind.FRAGMENT_DEFINITION) {
372342
+ continue;
372343
+ }
372344
+ otherDefinitions.push(definition3);
372345
+ }
372346
+ }
372347
+ if (inaccessible.seen) {
372348
+ const queryRootName = queryRootTypeName(operationTypes, types4);
372349
+ pruneInaccessibleTypes(types4, inaccessible.types);
372350
+ pruneUnsatisfiedInterfaces(types4);
372351
+ if (queryRootName != null && !types4.has(queryRootName)) {
372352
+ throw new Error(`Every field on the GraphQL query root "${queryRootName}" returns a type marked @inaccessible (${[...inaccessible.types].sort().join(", ")}), so the merged schema has no reachable operations. Remove @inaccessible from at least one reachable type, or exclude these files from the docs.`);
372353
+ }
372354
+ }
372355
+ const definitions7 = [
372356
+ ...[...directiveDefinitions.values()].map((entry) => entry.definition),
372357
+ ...otherDefinitions,
372358
+ ...[...types4.values()].map((type7) => type7.definition)
372359
+ ];
372360
+ const rootOperationTypes = [...operationTypes.values()].map((entry) => entry.operationType).filter((operationType) => types4.has(operationType.type.name.value));
372361
+ if (rootOperationTypes.length > 0) {
372362
+ definitions7.push({ kind: Kind.SCHEMA_DEFINITION, operationTypes: rootOperationTypes });
372363
+ }
372364
+ return { document: { kind: Kind.DOCUMENT, definitions: definitions7 }, conflicts: conflicts2 };
372365
+ }
372366
+ function queryRootTypeName(operationTypes, types4) {
372367
+ const declared = operationTypes.get("query")?.operationType.type.name.value;
372368
+ if (declared != null) {
372369
+ return types4.has(declared) ? declared : void 0;
372370
+ }
372371
+ return types4.has("Query") ? "Query" : void 0;
372372
+ }
372373
+ function parseSource(source2) {
372374
+ try {
372375
+ return parse9(source2.sdl);
372376
+ } catch (error50) {
372377
+ throw new Error(`${source2.filePath}: ${error50 instanceof Error ? error50.message : String(error50)}`);
372378
+ }
372379
+ }
372380
+ function isTypeDefinition(definition3) {
372381
+ return definition3.kind === Kind.SCALAR_TYPE_DEFINITION || definition3.kind === Kind.OBJECT_TYPE_DEFINITION || definition3.kind === Kind.INTERFACE_TYPE_DEFINITION || definition3.kind === Kind.UNION_TYPE_DEFINITION || definition3.kind === Kind.ENUM_TYPE_DEFINITION || definition3.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION;
372382
+ }
372383
+ function isTypeExtension(definition3) {
372384
+ return definition3.kind === Kind.SCALAR_TYPE_EXTENSION || definition3.kind === Kind.OBJECT_TYPE_EXTENSION || definition3.kind === Kind.INTERFACE_TYPE_EXTENSION || definition3.kind === Kind.UNION_TYPE_EXTENSION || definition3.kind === Kind.ENUM_TYPE_EXTENSION || definition3.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION;
372385
+ }
372386
+ function typeExtensionToDefinition(extension4) {
372387
+ switch (extension4.kind) {
372388
+ case Kind.SCALAR_TYPE_EXTENSION:
372389
+ return { ...extension4, kind: Kind.SCALAR_TYPE_DEFINITION, description: void 0 };
372390
+ case Kind.OBJECT_TYPE_EXTENSION:
372391
+ return { ...extension4, kind: Kind.OBJECT_TYPE_DEFINITION, description: void 0 };
372392
+ case Kind.INTERFACE_TYPE_EXTENSION:
372393
+ return { ...extension4, kind: Kind.INTERFACE_TYPE_DEFINITION, description: void 0 };
372394
+ case Kind.UNION_TYPE_EXTENSION:
372395
+ return { ...extension4, kind: Kind.UNION_TYPE_DEFINITION, description: void 0 };
372396
+ case Kind.ENUM_TYPE_EXTENSION:
372397
+ return { ...extension4, kind: Kind.ENUM_TYPE_DEFINITION, description: void 0 };
372398
+ case Kind.INPUT_OBJECT_TYPE_EXTENSION:
372399
+ return { ...extension4, kind: Kind.INPUT_OBJECT_TYPE_DEFINITION, description: void 0 };
372400
+ }
372401
+ }
372402
+ function stripFederationDirectives(directives) {
372403
+ if (directives == null) {
372404
+ return void 0;
372405
+ }
372406
+ return directives.filter((directive) => !FEDERATION_DIRECTIVES.has(directive.name.value));
372407
+ }
372408
+ function isInaccessible(node4) {
372409
+ return node4.directives?.some((directive) => directive.name.value === INACCESSIBLE_DIRECTIVE) ?? false;
372410
+ }
372411
+ function cleanArguments(args, inaccessible) {
372412
+ return args?.filter(keepAccessible(inaccessible)).map((argument) => ({
372413
+ ...argument,
372414
+ directives: stripFederationDirectives(argument.directives)
372415
+ }));
372416
+ }
372417
+ function keepAccessible(inaccessible) {
372418
+ return (node4) => {
372419
+ if (!isInaccessible(node4)) {
372420
+ return true;
372421
+ }
372422
+ inaccessible.seen = true;
372423
+ return false;
372424
+ };
372425
+ }
372426
+ function cleanTypeDefinition(definition3, inaccessible) {
372427
+ const directives = stripFederationDirectives(definition3.directives);
372428
+ if (isInaccessible(definition3)) {
372429
+ inaccessible.seen = true;
372430
+ inaccessible.types.add(definition3.name.value);
372431
+ }
372432
+ const keep = keepAccessible(inaccessible);
372433
+ switch (definition3.kind) {
372434
+ case Kind.OBJECT_TYPE_DEFINITION:
372435
+ case Kind.INTERFACE_TYPE_DEFINITION:
372436
+ return {
372437
+ ...definition3,
372438
+ directives,
372439
+ fields: definition3.fields?.filter(keep).map((field5) => ({
372440
+ ...field5,
372441
+ directives: stripFederationDirectives(field5.directives),
372442
+ arguments: cleanArguments(field5.arguments, inaccessible)
372443
+ }))
372444
+ };
372445
+ case Kind.INPUT_OBJECT_TYPE_DEFINITION:
372446
+ return {
372447
+ ...definition3,
372448
+ directives,
372449
+ fields: definition3.fields?.filter(keep).map((field5) => ({
372450
+ ...field5,
372451
+ directives: stripFederationDirectives(field5.directives)
372452
+ }))
372453
+ };
372454
+ case Kind.ENUM_TYPE_DEFINITION:
372455
+ return {
372456
+ ...definition3,
372457
+ directives,
372458
+ values: definition3.values?.filter(keep).map((value2) => ({
372459
+ ...value2,
372460
+ directives: stripFederationDirectives(value2.directives)
372461
+ }))
372462
+ };
372463
+ case Kind.SCALAR_TYPE_DEFINITION:
372464
+ case Kind.UNION_TYPE_DEFINITION:
372465
+ return { ...definition3, directives };
372466
+ }
372467
+ }
372468
+ function namedTypeName(type7) {
372469
+ switch (type7.kind) {
372470
+ case Kind.NAMED_TYPE:
372471
+ return type7.name.value;
372472
+ case Kind.LIST_TYPE:
372473
+ case Kind.NON_NULL_TYPE:
372474
+ return namedTypeName(type7.type);
372475
+ }
372476
+ }
372477
+ function pruneInaccessibleTypes(types4, inaccessibleTypes) {
372478
+ const removed = /* @__PURE__ */ new Set();
372479
+ for (const typeName of inaccessibleTypes) {
372480
+ if (types4.delete(typeName)) {
372481
+ removed.add(typeName);
372482
+ }
372483
+ }
372484
+ let changed = true;
372485
+ while (changed) {
372486
+ changed = false;
372487
+ for (const [typeName, type7] of types4) {
372488
+ const pruned = pruneReferences(type7.definition, removed);
372489
+ if (pruned == null) {
372490
+ types4.delete(typeName);
372491
+ removed.add(typeName);
372492
+ changed = true;
372493
+ continue;
372494
+ }
372495
+ if (pruned !== type7.definition) {
372496
+ type7.definition = pruned;
372497
+ changed = true;
372498
+ }
372499
+ }
372500
+ }
372501
+ }
372502
+ function fieldNamesOf(definition3) {
372503
+ if (definition3.kind !== Kind.OBJECT_TYPE_DEFINITION && definition3.kind !== Kind.INTERFACE_TYPE_DEFINITION) {
372504
+ return /* @__PURE__ */ new Set();
372505
+ }
372506
+ return new Set((definition3.fields ?? []).map((field5) => field5.name.value));
372507
+ }
372508
+ function pruneUnsatisfiedInterfaces(types4) {
372509
+ for (const type7 of types4.values()) {
372510
+ const definition3 = type7.definition;
372511
+ if (definition3.kind !== Kind.OBJECT_TYPE_DEFINITION && definition3.kind !== Kind.INTERFACE_TYPE_DEFINITION) {
372512
+ continue;
372513
+ }
372514
+ const declared = definition3.interfaces ?? [];
372515
+ const ownFields = fieldNamesOf(definition3);
372516
+ const interfaces = declared.filter((node4) => {
372517
+ const implemented = types4.get(node4.name.value);
372518
+ if (implemented == null) {
372519
+ return false;
372520
+ }
372521
+ return [...fieldNamesOf(implemented.definition)].every((fieldName) => ownFields.has(fieldName));
372522
+ });
372523
+ if (interfaces.length !== declared.length) {
372524
+ type7.definition = { ...definition3, interfaces };
372525
+ }
372526
+ }
372527
+ }
372528
+ function pruneReferences(definition3, removed) {
372529
+ switch (definition3.kind) {
372530
+ case Kind.OBJECT_TYPE_DEFINITION:
372531
+ case Kind.INTERFACE_TYPE_DEFINITION: {
372532
+ const fields = (definition3.fields ?? []).filter((field5) => !removed.has(namedTypeName(field5.type)) && !(field5.arguments ?? []).some((argument) => removed.has(namedTypeName(argument.type))));
372533
+ if (fields.length === 0) {
372534
+ return null;
372535
+ }
372536
+ const interfaces = (definition3.interfaces ?? []).filter((node4) => !removed.has(node4.name.value));
372537
+ if (fields.length === definition3.fields?.length && interfaces.length === (definition3.interfaces ?? []).length) {
372538
+ return definition3;
372539
+ }
372540
+ return { ...definition3, fields, interfaces };
372541
+ }
372542
+ case Kind.INPUT_OBJECT_TYPE_DEFINITION: {
372543
+ const fields = (definition3.fields ?? []).filter((field5) => !removed.has(namedTypeName(field5.type)));
372544
+ if (fields.length === 0) {
372545
+ return null;
372546
+ }
372547
+ return fields.length === definition3.fields?.length ? definition3 : { ...definition3, fields };
372548
+ }
372549
+ case Kind.UNION_TYPE_DEFINITION: {
372550
+ const members = (definition3.types ?? []).filter((node4) => !removed.has(node4.name.value));
372551
+ if (members.length === 0) {
372552
+ return null;
372553
+ }
372554
+ return members.length === definition3.types?.length ? definition3 : { ...definition3, types: members };
372555
+ }
372556
+ case Kind.ENUM_TYPE_DEFINITION:
372557
+ return definition3.values?.length === 0 ? null : definition3;
372558
+ case Kind.SCALAR_TYPE_DEFINITION:
372559
+ return definition3;
372560
+ }
372561
+ }
372562
+ function mergeTypeDefinition({ incoming, isExtension, filePath, types: types4, conflicts: conflicts2, inaccessible }) {
372563
+ const name2 = incoming.name.value;
372564
+ const cleaned = cleanTypeDefinition(incoming, inaccessible);
372565
+ const existing = types4.get(name2);
372566
+ if (existing == null) {
372567
+ types4.set(name2, initMergedType(cleaned, filePath, isExtension));
372568
+ return;
372569
+ }
372570
+ if (existing.definition.kind !== cleaned.kind) {
372571
+ conflicts2.push({
372572
+ typeName: name2,
372573
+ memberName: "<declaration>",
372574
+ kept: existing.filePath,
372575
+ dropped: filePath
372576
+ });
372577
+ return;
372578
+ }
372579
+ if (existing.fromExtension && !isExtension) {
372580
+ const promoted = initMergedType(cleaned, filePath, false);
372581
+ promoted.definition = mergeMembers(promoted, existing.definition, existing.filePath, conflicts2);
372582
+ types4.set(name2, promoted);
372583
+ return;
372584
+ }
372585
+ existing.definition = mergeMembers(existing, cleaned, filePath, conflicts2);
372586
+ }
372587
+ function initMergedType(definition3, filePath, fromExtension) {
372588
+ const members = /* @__PURE__ */ new Map();
372589
+ for (const member of getMembers(definition3)) {
372590
+ members.set(member.name.value, { filePath, signature: memberSignature(member) });
372591
+ }
372592
+ return { definition: definition3, filePath, members, fromExtension };
372593
+ }
372594
+ function getMembers(definition3) {
372595
+ switch (definition3.kind) {
372596
+ case Kind.OBJECT_TYPE_DEFINITION:
372597
+ case Kind.INTERFACE_TYPE_DEFINITION:
372598
+ case Kind.INPUT_OBJECT_TYPE_DEFINITION:
372599
+ return definition3.fields ?? [];
372600
+ case Kind.ENUM_TYPE_DEFINITION:
372601
+ return definition3.values ?? [];
372602
+ case Kind.UNION_TYPE_DEFINITION:
372603
+ return definition3.types ?? [];
372604
+ case Kind.SCALAR_TYPE_DEFINITION:
372605
+ return [];
372606
+ }
372607
+ }
372608
+ function memberSignature(member) {
372609
+ if (member.kind === Kind.FIELD_DEFINITION) {
372610
+ const args = (member.arguments ?? []).map((argument) => `${argument.name.value}:${print(argument.type)}`);
372611
+ return `${print(member.type)}(${args.join(",")})`;
372612
+ }
372613
+ if (member.kind === Kind.INPUT_VALUE_DEFINITION) {
372614
+ return print(member.type);
372615
+ }
372616
+ return member.name.value;
372617
+ }
372618
+ function mergeMembers(existing, incoming, filePath, conflicts2) {
372619
+ const base4 = existing.definition;
372620
+ const description = base4.description ?? incoming.description;
372621
+ const typeName = base4.name.value;
372622
+ const dedupe = (current3, additional) => {
372623
+ const merged = [...current3 ?? []];
372624
+ for (const member of additional ?? []) {
372625
+ const memberName = member.name.value;
372626
+ const signature = memberSignature(member);
372627
+ const owner = existing.members.get(memberName);
372628
+ if (owner != null) {
372629
+ if (owner.signature !== signature) {
372630
+ conflicts2.push({ typeName, memberName, kept: owner.filePath, dropped: filePath });
372631
+ }
372632
+ continue;
372633
+ }
372634
+ existing.members.set(memberName, { filePath, signature });
372635
+ merged.push(member);
372636
+ }
372637
+ return merged;
372638
+ };
372639
+ if (base4.kind === Kind.OBJECT_TYPE_DEFINITION && incoming.kind === Kind.OBJECT_TYPE_DEFINITION) {
372640
+ return {
372641
+ ...base4,
372642
+ description,
372643
+ interfaces: dedupeNamedTypes(base4.interfaces, incoming.interfaces),
372644
+ fields: dedupe(base4.fields, incoming.fields)
372645
+ };
372646
+ }
372647
+ if (base4.kind === Kind.INTERFACE_TYPE_DEFINITION && incoming.kind === Kind.INTERFACE_TYPE_DEFINITION) {
372648
+ return {
372649
+ ...base4,
372650
+ description,
372651
+ interfaces: dedupeNamedTypes(base4.interfaces, incoming.interfaces),
372652
+ fields: dedupe(base4.fields, incoming.fields)
372653
+ };
372654
+ }
372655
+ if (base4.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION && incoming.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION) {
372656
+ return { ...base4, description, fields: dedupe(base4.fields, incoming.fields) };
372657
+ }
372658
+ if (base4.kind === Kind.ENUM_TYPE_DEFINITION && incoming.kind === Kind.ENUM_TYPE_DEFINITION) {
372659
+ return { ...base4, description, values: dedupe(base4.values, incoming.values) };
372660
+ }
372661
+ if (base4.kind === Kind.UNION_TYPE_DEFINITION && incoming.kind === Kind.UNION_TYPE_DEFINITION) {
372662
+ return { ...base4, description, types: dedupeNamedTypes(base4.types, incoming.types) };
372663
+ }
372664
+ return { ...base4, description };
372665
+ }
372666
+ function dedupeNamedTypes(current3, additional) {
372667
+ const seen = new Set((current3 ?? []).map((type7) => type7.name.value));
372668
+ const merged = [...current3 ?? []];
372669
+ for (const type7 of additional ?? []) {
372670
+ if (!seen.has(type7.name.value)) {
372671
+ seen.add(type7.name.value);
372672
+ merged.push(type7);
372673
+ }
372674
+ }
372675
+ return merged;
372676
+ }
372677
+ var INACCESSIBLE_DIRECTIVE, FEDERATION_DIRECTIVES;
372678
+ var init_mergeGraphQlDocuments = __esm({
372679
+ "../api-importers/graphql/lib/mergeGraphQlDocuments.js"() {
372680
+ "use strict";
372681
+ init_graphql();
372682
+ INACCESSIBLE_DIRECTIVE = "inaccessible";
372683
+ FEDERATION_DIRECTIVES = /* @__PURE__ */ new Set([
372684
+ "link",
372685
+ "key",
372686
+ "external",
372687
+ "requires",
372688
+ "provides",
372689
+ "shareable",
372690
+ "inaccessible",
372691
+ "override",
372692
+ "extends",
372693
+ "composeDirective",
372694
+ "interfaceObject",
372695
+ "tag",
372696
+ "authenticated",
372697
+ "requiresScopes",
372698
+ "policy",
372699
+ // federation v2.8
372700
+ "context",
372701
+ "fromContext",
372702
+ // federation v2.9 (demand control)
372703
+ "cost",
372704
+ "listSize"
372705
+ ]);
372706
+ }
372707
+ });
372708
+
371769
372709
  // ../api-importers/graphql/lib/GraphQLConverter.js
371770
372710
  var import_promises39, GraphQLConverter;
371771
372711
  var init_GraphQLConverter = __esm({
@@ -371774,17 +372714,18 @@ var init_GraphQLConverter = __esm({
371774
372714
  init_js();
371775
372715
  import_promises39 = require("fs/promises");
371776
372716
  init_graphql();
372717
+ init_mergeGraphQlDocuments();
371777
372718
  GraphQLConverter = class {
371778
372719
  schema;
371779
372720
  context;
371780
- filePath;
372721
+ filePaths;
371781
372722
  namespace;
371782
372723
  processingTypes = /* @__PURE__ */ new Set();
371783
372724
  types = {};
371784
372725
  examplesByOperation = /* @__PURE__ */ new Map();
371785
372726
  constructor({ context: context3, filePath, namespace, examples }) {
371786
372727
  this.context = context3;
371787
- this.filePath = filePath;
372728
+ this.filePaths = Array.isArray(filePath) ? filePath : [filePath];
371788
372729
  this.namespace = namespace;
371789
372730
  if (examples != null) {
371790
372731
  for (const entry of examples) {
@@ -371795,15 +372736,32 @@ var init_GraphQLConverter = __esm({
371795
372736
  variables: ex.variables ?? void 0,
371796
372737
  response: ex.response ?? void 0
371797
372738
  }));
371798
- if (entry.operationType != null) {
371799
- const key2 = `${entry.operationType.toLowerCase()}:${entry.operation}`;
371800
- this.examplesByOperation.set(key2, mapped);
371801
- } else {
371802
- this.examplesByOperation.set(entry.operation, mapped);
372739
+ const key2 = entry.operationType != null ? `${entry.operationType.toLowerCase()}:${entry.operation}` : entry.operation;
372740
+ if (this.examplesByOperation.has(key2)) {
372741
+ this.context.logger.warn(`Multiple GraphQL examples provided for "${key2}". Keeping the first and ignoring the rest.`);
372742
+ continue;
371803
372743
  }
372744
+ this.examplesByOperation.set(key2, mapped);
371804
372745
  }
371805
372746
  }
371806
372747
  }
372748
+ // `@deprecated` is a standard, consumer-facing directive (unlike the federation directives
372749
+ // dropped during merging), so it is carried through as availability metadata.
372750
+ availabilityOf(node4) {
372751
+ return node4.deprecationReason != null ? "Deprecated" : void 0;
372752
+ }
372753
+ // The deprecation reason has nowhere to live in the FDR shape other than the description,
372754
+ // and it is the part consumers act on ("use X instead").
372755
+ describeWithDeprecation(node4) {
372756
+ const description = node4.description ?? void 0;
372757
+ if (node4.deprecationReason == null || node4.deprecationReason === DEFAULT_DEPRECATION_REASON) {
372758
+ return description;
372759
+ }
372760
+ const deprecation = `**Deprecated:** ${node4.deprecationReason}`;
372761
+ return description != null ? `${description}
372762
+
372763
+ ${deprecation}` : deprecation;
372764
+ }
371807
372765
  isBuiltInScalar(typeName) {
371808
372766
  return ["String", "Int", "Float", "Boolean", "ID"].includes(typeName);
371809
372767
  }
@@ -371836,9 +372794,42 @@ var init_GraphQLConverter = __esm({
371836
372794
  }
371837
372795
  return fields.every((f3) => f3.args.length > 0);
371838
372796
  }
372797
+ /**
372798
+ * Builds the merged document, reporting SDL problems instead of silently accepting them.
372799
+ *
372800
+ * `assumeValidSDL` is the fallback rather than the default: merged subgraphs can still carry
372801
+ * constructs that only compose at runtime (e.g. a directive whose definition lives in the
372802
+ * supergraph), and failing the docs build on those would make federation unusable.
372803
+ */
372804
+ buildSchema(document4) {
372805
+ try {
372806
+ const schema = buildASTSchema(document4);
372807
+ for (const error50 of validateSchema2(schema)) {
372808
+ this.context.logger.warn(`Invalid GraphQL schema: ${error50.message}`);
372809
+ }
372810
+ return schema;
372811
+ } catch (validationError) {
372812
+ let schema;
372813
+ try {
372814
+ schema = buildASTSchema(document4, { assumeValidSDL: true });
372815
+ } catch {
372816
+ throw validationError;
372817
+ }
372818
+ this.context.logger.warn(`Invalid GraphQL schema: ${validationError instanceof Error ? validationError.message : String(validationError)} Continuing without SDL validation.`);
372819
+ return schema;
372820
+ }
372821
+ }
371839
372822
  async convert() {
371840
- const sdlContent = await (0, import_promises39.readFile)(this.filePath, "utf-8");
371841
- this.schema = buildSchema(sdlContent);
372823
+ const sources = await Promise.all(this.filePaths.map(async (filePath) => ({
372824
+ filePath,
372825
+ sdl: await (0, import_promises39.readFile)(filePath, "utf-8")
372826
+ })));
372827
+ const { document: document4, conflicts: conflicts2 } = mergeGraphQlDocuments(sources);
372828
+ for (const conflict of conflicts2) {
372829
+ const member = `${conflict.typeName}.${conflict.memberName}`;
372830
+ this.context.logger.warn(conflict.kept === conflict.dropped ? `GraphQL schema conflict: ${member} is declared more than once in ${conflict.kept} with differing shapes. Keeping the first declaration.` : `GraphQL schema conflict: ${member} is defined in both ${conflict.kept} and ${conflict.dropped}. Keeping the definition from ${conflict.kept}.`);
372831
+ }
372832
+ this.schema = this.buildSchema(document4);
371842
372833
  this.collectTypeDefinitions();
371843
372834
  const pendingOperations = [];
371844
372835
  const queryType = this.schema.getQueryType();
@@ -372032,8 +373023,8 @@ var init_GraphQLConverter = __esm({
372032
373023
  operationType,
372033
373024
  name: name2,
372034
373025
  displayName: void 0,
372035
- description: field5.description ?? void 0,
372036
- availability: void 0,
373026
+ description: this.describeWithDeprecation(field5),
373027
+ availability: this.availabilityOf(field5),
372037
373028
  fieldPath: fieldPath != null && fieldPath.length > 0 ? fieldPath : void 0,
372038
373029
  arguments: args.length > 0 ? args : void 0,
372039
373030
  returnType: this.convertOutputType(field5.type),
@@ -372044,8 +373035,8 @@ var init_GraphQLConverter = __esm({
372044
373035
  convertArgument(arg) {
372045
373036
  return {
372046
373037
  name: arg.name,
372047
- description: arg.description ?? void 0,
372048
- availability: void 0,
373038
+ description: this.describeWithDeprecation(arg),
373039
+ availability: this.availabilityOf(arg),
372049
373040
  type: this.convertInputType(arg.type),
372050
373041
  defaultValue: arg.defaultValue
372051
373042
  };
@@ -372215,8 +373206,8 @@ var init_GraphQLConverter = __esm({
372215
373206
  type: "enum",
372216
373207
  values: values2.map((value2) => ({
372217
373208
  value: value2.name,
372218
- description: value2.description ?? void 0,
372219
- availability: void 0
373209
+ description: this.describeWithDeprecation(value2),
373210
+ availability: this.availabilityOf(value2)
372220
373211
  })),
372221
373212
  default: void 0
372222
373213
  };
@@ -372226,8 +373217,8 @@ var init_GraphQLConverter = __esm({
372226
373217
  const properties7 = Object.entries(fields).map(([fieldName, field5]) => ({
372227
373218
  key: FdrAPI_exports.PropertyKey(fieldName),
372228
373219
  valueType: this.convertOutputType(field5.type),
372229
- description: field5.description ?? void 0,
372230
- availability: void 0,
373220
+ description: this.describeWithDeprecation(field5),
373221
+ availability: this.availabilityOf(field5),
372231
373222
  propertyAccess: void 0,
372232
373223
  arguments: field5.args.length > 0 ? field5.args.map((arg) => this.convertArgument(arg)) : void 0
372233
373224
  }));
@@ -372274,8 +373265,8 @@ var init_GraphQLConverter = __esm({
372274
373265
  const properties7 = Object.entries(fields).map(([fieldName, field5]) => ({
372275
373266
  key: FdrAPI_exports.PropertyKey(fieldName),
372276
373267
  valueType: this.convertOutputType(field5.type),
372277
- description: field5.description ?? void 0,
372278
- availability: void 0,
373268
+ description: this.describeWithDeprecation(field5),
373269
+ availability: this.availabilityOf(field5),
372279
373270
  propertyAccess: void 0,
372280
373271
  arguments: field5.args.length > 0 ? field5.args.map((arg) => this.convertArgument(arg)) : void 0
372281
373272
  }));
@@ -372291,8 +373282,8 @@ var init_GraphQLConverter = __esm({
372291
373282
  const properties7 = Object.entries(fields).map(([fieldName, field5]) => ({
372292
373283
  key: FdrAPI_exports.PropertyKey(fieldName),
372293
373284
  valueType: this.convertInputType(field5.type),
372294
- description: field5.description ?? void 0,
372295
- availability: void 0,
373285
+ description: this.describeWithDeprecation(field5),
373286
+ availability: this.availabilityOf(field5),
372296
373287
  propertyAccess: void 0
372297
373288
  }));
372298
373289
  return {
@@ -372679,20 +373670,21 @@ var init_OSSWorkspace = __esm({
372679
373670
  async processGraphQLSpecs(context3) {
372680
373671
  const { GraphQLConverter: GraphQLConverter2 } = await Promise.resolve().then(() => (init_lib34(), lib_exports9));
372681
373672
  const graphqlSpecs = this.allSpecs.filter((spec) => spec.type === "graphql");
372682
- for (const spec of graphqlSpecs) {
373673
+ for (const [, specs] of groupGraphQLSpecsByNamespace(graphqlSpecs)) {
373674
+ const filePaths = specs.map((spec) => spec.absoluteFilepath);
372683
373675
  try {
372684
- const examples = await loadGraphQlExamples(spec.absoluteFilepathToExamples, context3);
373676
+ const examples = (await Promise.all(specs.map((spec) => loadGraphQlExamples(spec.absoluteFilepathToExamples, context3)))).filter(isNonNullish).flat();
372685
373677
  const converter = new GraphQLConverter2({
372686
373678
  context: context3,
372687
- filePath: spec.absoluteFilepath,
372688
- namespace: spec.namespace,
373679
+ filePath: filePaths,
373680
+ namespace: specs[0]?.namespace,
372689
373681
  examples
372690
373682
  });
372691
373683
  const result = await converter.convert();
372692
373684
  Object.assign(this.graphqlOperations, result.graphqlOperations);
372693
373685
  Object.assign(this.graphqlTypes, result.types);
372694
373686
  } catch (error50) {
372695
- context3.logger.error(`Failed to process GraphQL spec ${spec.absoluteFilepath}:`, extractErrorMessage(error50));
373687
+ context3.logger.error(`Failed to process GraphQL spec(s) ${filePaths.join(", ")}:`, extractErrorMessage(error50));
372696
373688
  }
372697
373689
  }
372698
373690
  }
@@ -472765,6 +473757,7 @@ var import_dayjs3, import_utc3, import_fs26, import_promises80, import_gray_matt
472765
473757
  var init_DocsDefinitionResolver = __esm({
472766
473758
  "../docs-resolver/lib/DocsDefinitionResolver.js"() {
472767
473759
  "use strict";
473760
+ init_lib17();
472768
473761
  init_lib36();
472769
473762
  init_lib20();
472770
473763
  init_lib4();
@@ -474187,25 +475180,27 @@ https://buildwithfern.com/learn/docs/getting-started/project-structure#api-defin
474187
475180
  return { operations: graphqlOperations, types: graphqlTypes, namespacesByOperationId };
474188
475181
  }
474189
475182
  const graphqlSpecs = workspace.allSpecs.filter((spec) => spec.type === "graphql");
474190
- for (const spec of graphqlSpecs) {
475183
+ for (const [, specs] of groupGraphQLSpecsByNamespace(graphqlSpecs)) {
475184
+ const filePaths = specs.map((spec) => spec.absoluteFilepath);
475185
+ const namespace = specs[0]?.namespace;
474191
475186
  try {
474192
- const examples = await this.loadGraphQlExamples(spec.absoluteFilepathToExamples);
475187
+ const examples = (await Promise.all(specs.map((spec) => this.loadGraphQlExamples(spec.absoluteFilepathToExamples)))).filter(isNonNullish).flat();
474193
475188
  const converter = new GraphQLConverter({
474194
475189
  context: this.taskContext,
474195
- filePath: spec.absoluteFilepath,
474196
- namespace: spec.namespace,
475190
+ filePath: filePaths,
475191
+ namespace,
474197
475192
  examples
474198
475193
  });
474199
475194
  const graphqlResult = await converter.convert();
474200
475195
  Object.assign(graphqlOperations, graphqlResult.graphqlOperations);
474201
475196
  Object.assign(graphqlTypes, graphqlResult.types);
474202
- if (spec.namespace) {
475197
+ if (namespace) {
474203
475198
  for (const operationId of Object.keys(graphqlResult.graphqlOperations)) {
474204
- namespacesByOperationId.set(FdrAPI_exports.GraphQlOperationId(operationId), spec.namespace);
475199
+ namespacesByOperationId.set(FdrAPI_exports.GraphQlOperationId(operationId), namespace);
474205
475200
  }
474206
475201
  }
474207
475202
  } catch (error50) {
474208
- this.taskContext.logger.error(`Failed to process GraphQL spec ${spec.absoluteFilepath}:`, String(error50));
475203
+ this.taskContext.logger.error(`Failed to process GraphQL spec(s) ${filePaths.join(", ")}:`, extractErrorMessage(error50));
474209
475204
  }
474210
475205
  }
474211
475206
  return { operations: graphqlOperations, types: graphqlTypes, namespacesByOperationId };
@@ -703479,7 +704474,7 @@ var AccessTokenPosthogManager = class {
703479
704474
  properties: {
703480
704475
  ...event,
703481
704476
  ...event.properties,
703482
- version: "5.104.0",
704477
+ version: "5.105.0",
703483
704478
  usingAccessToken: true,
703484
704479
  ...getRunIdProperties()
703485
704480
  }
@@ -703545,7 +704540,7 @@ var UserPosthogManager = class {
703545
704540
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
703546
704541
  event: "CLI",
703547
704542
  properties: {
703548
- version: "5.104.0",
704543
+ version: "5.105.0",
703549
704544
  ...event,
703550
704545
  ...event.properties,
703551
704546
  usingAccessToken: false,
@@ -884928,7 +885923,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
884928
885923
  var LOGS_FOLDER_NAME = "logs";
884929
885924
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
884930
885925
  function getCliSource() {
884931
- const version7 = "5.104.0";
885926
+ const version7 = "5.105.0";
884932
885927
  return `cli@${version7}`;
884933
885928
  }
884934
885929
  var DebugLogger = class {
@@ -911014,7 +912009,7 @@ var LegacyDocsPublisher = class {
911014
912009
  previewId,
911015
912010
  disableTemplates: void 0,
911016
912011
  skipUpload,
911017
- cliVersion: "5.104.0",
912012
+ cliVersion: "5.105.0",
911018
912013
  loginCommand: "fern auth login"
911019
912014
  });
911020
912015
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -951683,6 +952678,7 @@ var RUST_KEYWORDS = /* @__PURE__ */ new Set([
951683
952678
  "virtual",
951684
952679
  "yield"
951685
952680
  ]);
952681
+ var RUST_NON_RAW_KEYWORDS = /* @__PURE__ */ new Set(["crate", "self", "Self", "super"]);
951686
952682
  var RUST_RESERVED_TYPES = /* @__PURE__ */ new Set([
951687
952683
  "Box",
951688
952684
  "Option",
@@ -952102,6 +953098,9 @@ function escapeRustKeyword(name2) {
952102
953098
  if (/^[0-9]/.test(name2)) {
952103
953099
  return `_${name2}`;
952104
953100
  }
953101
+ if (RUST_NON_RAW_KEYWORDS.has(name2)) {
953102
+ return `${name2}_`;
953103
+ }
952105
953104
  return RUST_KEYWORDS.has(name2) ? `r#${name2}` : name2;
952106
953105
  }
952107
953106
  function escapeRustReservedType(name2) {
@@ -978385,7 +979384,7 @@ function getAutomationContextFromEnv() {
978385
979384
  config_branch: process.env.FERN_CONFIG_BRANCH,
978386
979385
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
978387
979386
  trigger: process.env.GITHUB_EVENT_NAME,
978388
- cli_version: "5.104.0"
979387
+ cli_version: "5.105.0"
978389
979388
  };
978390
979389
  }
978391
979390
  function isAutomationMode() {
@@ -979217,7 +980216,7 @@ var CliContext = class _CliContext {
979217
980216
  if (false) {
979218
980217
  this.logger.error("CLI_VERSION is not defined");
979219
980218
  }
979220
- return "5.104.0";
980219
+ return "5.105.0";
979221
980220
  }
979222
980221
  getCliName() {
979223
980222
  if (false) {