@contello/client 3.4.0 → 3.5.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.
@@ -4,7 +4,7 @@ import { glob } from "node:fs/promises";
4
4
  import { dirname, relative, resolve } from "node:path";
5
5
  import { Kind, NoFragmentCyclesRule, NoUnusedFragmentsRule, Source, buildClientSchema, doTypesOverlap, getIntrospectionQuery, getLocation, isCompositeType, isEnumType, isInputObjectType, isInterfaceType, isListType, isNonNullType, isObjectType, isRequiredArgument, isScalarType, isUnionType, parse, print, specifiedRules, typeFromAST, validate, visit } from "graphql";
6
6
  import { pathToFileURL } from "node:url";
7
- //#region src/generate/config.ts
7
+ // src/generate/config.ts
8
8
  const CONFIG_NAMES = [
9
9
  "contello.config.ts",
10
10
  "contello.config.js",
@@ -32,8 +32,7 @@ async function loadConfig(cwd) {
32
32
  }
33
33
  throw new Error(`no config file found (tried: ${CONFIG_NAMES.join(", ")})`);
34
34
  }
35
- //#endregion
36
- //#region src/generate/documents.ts
35
+ // src/generate/documents.ts
37
36
  const SUPPRESSED_RULE_NAMES = /* @__PURE__ */ new Set([NoFragmentCyclesRule.name, NoUnusedFragmentsRule.name]);
38
37
  const VALIDATION_RULES = specifiedRules.filter((rule) => !SUPPRESSED_RULE_NAMES.has(rule.name));
39
38
  function collectFragments(documents) {
@@ -133,8 +132,7 @@ function fragmentBundleExpression(fragment, allFragments) {
133
132
  function generateFragmentSchemas(fragments) {
134
133
  return fragments.values().toArray().toSorted((a, b) => a.name.value.localeCompare(b.name.value)).map((fragment) => `const ${fragment.name.value}FragmentSchema = \`${print(fragment)}\`;`).join("\n");
135
134
  }
136
- //#endregion
137
- //#region src/generate/introspect.ts
135
+ // src/generate/introspect.ts
138
136
  async function introspectSchema(url, project, token) {
139
137
  const endpoint = `${url}/graphql/projects/${project}`;
140
138
  const response = await fetch(endpoint, {
@@ -151,8 +149,7 @@ async function introspectSchema(url, project, token) {
151
149
  if (!json.data) throw new Error(`introspection returned no data (${endpoint})`);
152
150
  return buildClientSchema(json.data);
153
151
  }
154
- //#endregion
155
- //#region src/generate/scalar-types.ts
152
+ // src/generate/scalar-types.ts
156
153
  const SCALAR_MAP = {
157
154
  String: "string",
158
155
  Int: "number",
@@ -168,8 +165,7 @@ const DEFAULT_CUSTOM_SCALAR = "unknown";
168
165
  function resolveScalarType(name) {
169
166
  return SCALAR_MAP[name] ?? "unknown";
170
167
  }
171
- //#endregion
172
- //#region src/generate/utils.ts
168
+ // src/generate/utils.ts
173
169
  /** standard sorting stub */
174
170
  function compareCodeUnits(a, b) {
175
171
  if (a < b) return -1;
@@ -193,8 +189,7 @@ function isContelloModel(schema, typeName) {
193
189
  }
194
190
  return false;
195
191
  }
196
- //#endregion
197
- //#region src/generate/operation-types.ts
192
+ // src/generate/operation-types.ts
198
193
  function unwrapType(type) {
199
194
  let isList = false;
200
195
  let isNonNull = false;
@@ -371,8 +366,7 @@ function generateOperationTypes(schema, operations, fragments) {
371
366
  }
372
367
  return lines.join("\n");
373
368
  }
374
- //#endregion
375
- //#region src/generate/operations.ts
369
+ // src/generate/operations.ts
376
370
  /** Emits `export type Operations = { ... }`. */
377
371
  function generateOperationsType(operations) {
378
372
  const lines = ["export type Operations = {"];
@@ -399,8 +393,7 @@ function generateOperationsConst(operations) {
399
393
  lines.push("};");
400
394
  return lines.join("\n");
401
395
  }
402
- //#endregion
403
- //#region src/generate/schema-types.ts
396
+ // src/generate/schema-types.ts
404
397
  function typeToTs(type, nonNull = false) {
405
398
  let current = type;
406
399
  let isNonNullWrapped = nonNull;
@@ -511,8 +504,7 @@ function extractEntityModels(schema) {
511
504
  }
512
505
  return map;
513
506
  }
514
- //#endregion
515
- //#region src/built-in-mutations.ts
507
+ // src/built-in-mutations.ts
516
508
  /**
517
509
  * Write bindings for the built-in sources. Unlike entity mutations these are not derived — their
518
510
  * field and argument names are fixed parts of every Contello schema — but the generator still
@@ -576,8 +568,7 @@ const BUILT_IN_MUTATIONS = {
576
568
  }
577
569
  }
578
570
  };
579
- //#endregion
580
- //#region src/generate/sources.ts
571
+ // src/generate/sources.ts
581
572
  /** Built-in (non-entity) types that are source-able through dedicated Subscription fields. */
582
573
  const BUILT_IN_SOURCES = [
583
574
  {
@@ -888,8 +879,7 @@ function mutationEntries(mutations) {
888
879
  return binding ? [[kind, binding]] : [];
889
880
  });
890
881
  }
891
- //#endregion
892
- //#region src/generate/transform-components.ts
882
+ // src/generate/transform-components.ts
893
883
  const FLAT_PREFIX = "_flat_";
894
884
  const FLAT_COMPONENT_TYPE = "ContelloFlatComponent";
895
885
  const COMPONENT_UNION = "ContelloComponent";
@@ -1067,8 +1057,7 @@ function transformFragment(schema, fragment, fragments) {
1067
1057
  selectionSet
1068
1058
  };
1069
1059
  }
1070
- //#endregion
1071
- //#region src/generate/transform-scalars.ts
1060
+ // src/generate/transform-scalars.ts
1072
1061
  const SCALAR_PREFIX = {
1073
1062
  LocalDateTime: "_ldt_",
1074
1063
  LocalDate: "_ld_"
@@ -1182,8 +1171,7 @@ function transformScalarFragment(schema, fragment) {
1182
1171
  selectionSet: transformed
1183
1172
  };
1184
1173
  }
1185
- //#endregion
1186
- //#region src/generate/index.ts
1174
+ // src/generate/index.ts
1187
1175
  const ctrlSeq = "\x1B[";
1188
1176
  const styled = (s, pre, post) => `${ctrlSeq}${pre}${s}${ctrlSeq}${post}`;
1189
1177
  const dim = (s) => styled(s, "2m", "22m");
@@ -1324,7 +1312,6 @@ async function run() {
1324
1312
  console.log("");
1325
1313
  }
1326
1314
  }
1327
- //#endregion
1328
1315
  export { run };
1329
1316
 
1330
- //# sourceMappingURL=generate-CwfbsOys.js.map
1317
+ //# sourceMappingURL=generate-IysMI3VF.js.map