@fedify/vocab-tools 2.0.36-dev.2647 → 2.0.36-dev.2729

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/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab-tools",
3
- "version": "2.0.36-dev.2647+2864b09d",
3
+ "version": "2.0.36-dev.2729+88a727c8",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts"
package/dist/mod.cjs CHANGED
@@ -8,7 +8,7 @@ let yaml = require("yaml");
8
8
  let es_toolkit = require("es-toolkit");
9
9
  //#region deno.json
10
10
  var name = "@fedify/vocab-tools";
11
- var version = "2.0.36-dev.2647+2864b09d";
11
+ var version = "2.0.36-dev.2729+88a727c8";
12
12
  //#endregion
13
13
  //#region src/type.ts
14
14
  const HEURISTICS_CONTEXTS = [
@@ -320,6 +320,7 @@ const scalarTypes = {
320
320
  },
321
321
  "fedify:publicKey": {
322
322
  name: "CryptoKey",
323
+ inputName: "CryptoKeyLike",
323
324
  typeGuard(v) {
324
325
  return `
325
326
  // @ts-ignore: CryptoKey exists in the global scope.
@@ -342,6 +343,7 @@ const scalarTypes = {
342
343
  },
343
344
  "fedify:multibaseKey": {
344
345
  name: "CryptoKey",
346
+ inputName: "CryptoKeyLike",
345
347
  typeGuard(v) {
346
348
  return `
347
349
  // @ts-ignore: CryptoKey exists in the global scope.
@@ -413,15 +415,36 @@ const scalarTypes = {
413
415
  }
414
416
  }
415
417
  };
416
- function getTypeName(typeUri, types) {
418
+ /**
419
+ * Gets the TypeScript type name for a type URI.
420
+ * @param typeUri The type URI to resolve.
421
+ * @param types The vocabulary types in scope.
422
+ * @param forInput Whether to return the type accepted as input by
423
+ * constructors and `clone()`, which can be wider than the type
424
+ * those APIs return.
425
+ * @returns The TypeScript type name.
426
+ */
427
+ function getTypeName(typeUri, types, forInput = false) {
417
428
  if (typeUri in types) return types[typeUri].name;
418
- if (typeUri in scalarTypes) return scalarTypes[typeUri].name;
429
+ if (typeUri in scalarTypes) {
430
+ const scalar = scalarTypes[typeUri];
431
+ return forInput ? scalar.inputName ?? scalar.name : scalar.name;
432
+ }
419
433
  throw new Error(`Unknown type: ${typeUri}`);
420
434
  }
421
- function getTypeNames(typeUris, types, parentheses = false) {
435
+ /**
436
+ * Gets the TypeScript type names for a list of type URIs.
437
+ * @param typeUris The type URIs to resolve.
438
+ * @param types The vocabulary types in scope.
439
+ * @param parentheses Whether to wrap a union in parentheses.
440
+ * @param forInput Whether to return the types accepted as input by
441
+ * constructors and `clone()`.
442
+ * @returns The TypeScript type expression.
443
+ */
444
+ function getTypeNames(typeUris, types, parentheses = false, forInput = false) {
422
445
  if (typeUris.length < 1) return "never";
423
- else if (typeUris.length === 1) return getTypeName(typeUris[0], types);
424
- let typeNames = typeUris.map((typeUri) => getTypeName(typeUri, types));
446
+ else if (typeUris.length === 1) return getTypeName(typeUris[0], types, forInput);
447
+ let typeNames = typeUris.map((typeUri) => getTypeName(typeUri, types, forInput));
425
448
  typeNames = typeNames.filter((t, i) => typeNames.indexOf(t) === i);
426
449
  const t = typeNames.join(" | ");
427
450
  return parentheses && typeNames.length > 1 ? `(${t})` : t;
@@ -1060,14 +1083,21 @@ async function* generateDecoder(typeUri, types) {
1060
1083
  }
1061
1084
  //#endregion
1062
1085
  //#region src/constructor.ts
1086
+ /**
1087
+ * Generates the TypeScript type of a property in the `values` object that the
1088
+ * constructor and `clone()` accept.
1089
+ * @param property The property to generate the type for.
1090
+ * @param types The vocabulary types in scope.
1091
+ * @returns The generated type expression.
1092
+ */
1063
1093
  function generateParameterType(property, types) {
1064
1094
  const range = property.range;
1065
1095
  const scalar = areAllScalarTypes(range, types);
1066
1096
  const code = [];
1067
- if (hasSingularAccessor(property)) if (scalar) code.push(`${property.singularName}?: ${getTypeNames(range, types)} | null;`);
1068
- else code.push(`${property.singularName}?: ${getTypeNames(range, types)} | URL | null;`);
1069
- if (isNonFunctionalProperty(property)) if (scalar) code.push(`${property.pluralName}?: (${getTypeNames(range, types, true)})[];`);
1070
- else code.push(`${property.pluralName}?: (${getTypeNames(range, types)} | URL)[];`);
1097
+ if (hasSingularAccessor(property)) if (scalar) code.push(`${property.singularName}?: ${getTypeNames(range, types, false, true)} | null;`);
1098
+ else code.push(`${property.singularName}?: ${getTypeNames(range, types, false, true)} | URL | null;`);
1099
+ if (isNonFunctionalProperty(property)) if (scalar) code.push(`${property.pluralName}?: (${getTypeNames(range, types, true, true)})[];`);
1100
+ else code.push(`${property.pluralName}?: (${getTypeNames(range, types, false, true)} | URL)[];`);
1071
1101
  return code.join("\n");
1072
1102
  }
1073
1103
  async function* generateParametersType(typeUri, types, parentheses = true, excludeProperties = []) {
@@ -1910,6 +1940,7 @@ async function* generateClasses(types) {
1910
1940
  yield `import { type Span, SpanStatusCode, type TracerProvider, trace }
1911
1941
  from "@opentelemetry/api";\n`;
1912
1942
  yield `import {
1943
+ type CryptoKeyLike,
1913
1944
  decodeMultibase,
1914
1945
  type DocumentLoader,
1915
1946
  encodeMultibase,
package/dist/mod.js CHANGED
@@ -7,7 +7,7 @@ import { parse } from "yaml";
7
7
  import { pascalCase } from "es-toolkit";
8
8
  //#region deno.json
9
9
  var name = "@fedify/vocab-tools";
10
- var version = "2.0.36-dev.2647+2864b09d";
10
+ var version = "2.0.36-dev.2729+88a727c8";
11
11
  //#endregion
12
12
  //#region src/type.ts
13
13
  const HEURISTICS_CONTEXTS = [
@@ -319,6 +319,7 @@ const scalarTypes = {
319
319
  },
320
320
  "fedify:publicKey": {
321
321
  name: "CryptoKey",
322
+ inputName: "CryptoKeyLike",
322
323
  typeGuard(v) {
323
324
  return `
324
325
  // @ts-ignore: CryptoKey exists in the global scope.
@@ -341,6 +342,7 @@ const scalarTypes = {
341
342
  },
342
343
  "fedify:multibaseKey": {
343
344
  name: "CryptoKey",
345
+ inputName: "CryptoKeyLike",
344
346
  typeGuard(v) {
345
347
  return `
346
348
  // @ts-ignore: CryptoKey exists in the global scope.
@@ -412,15 +414,36 @@ const scalarTypes = {
412
414
  }
413
415
  }
414
416
  };
415
- function getTypeName(typeUri, types) {
417
+ /**
418
+ * Gets the TypeScript type name for a type URI.
419
+ * @param typeUri The type URI to resolve.
420
+ * @param types The vocabulary types in scope.
421
+ * @param forInput Whether to return the type accepted as input by
422
+ * constructors and `clone()`, which can be wider than the type
423
+ * those APIs return.
424
+ * @returns The TypeScript type name.
425
+ */
426
+ function getTypeName(typeUri, types, forInput = false) {
416
427
  if (typeUri in types) return types[typeUri].name;
417
- if (typeUri in scalarTypes) return scalarTypes[typeUri].name;
428
+ if (typeUri in scalarTypes) {
429
+ const scalar = scalarTypes[typeUri];
430
+ return forInput ? scalar.inputName ?? scalar.name : scalar.name;
431
+ }
418
432
  throw new Error(`Unknown type: ${typeUri}`);
419
433
  }
420
- function getTypeNames(typeUris, types, parentheses = false) {
434
+ /**
435
+ * Gets the TypeScript type names for a list of type URIs.
436
+ * @param typeUris The type URIs to resolve.
437
+ * @param types The vocabulary types in scope.
438
+ * @param parentheses Whether to wrap a union in parentheses.
439
+ * @param forInput Whether to return the types accepted as input by
440
+ * constructors and `clone()`.
441
+ * @returns The TypeScript type expression.
442
+ */
443
+ function getTypeNames(typeUris, types, parentheses = false, forInput = false) {
421
444
  if (typeUris.length < 1) return "never";
422
- else if (typeUris.length === 1) return getTypeName(typeUris[0], types);
423
- let typeNames = typeUris.map((typeUri) => getTypeName(typeUri, types));
445
+ else if (typeUris.length === 1) return getTypeName(typeUris[0], types, forInput);
446
+ let typeNames = typeUris.map((typeUri) => getTypeName(typeUri, types, forInput));
424
447
  typeNames = typeNames.filter((t, i) => typeNames.indexOf(t) === i);
425
448
  const t = typeNames.join(" | ");
426
449
  return parentheses && typeNames.length > 1 ? `(${t})` : t;
@@ -1059,14 +1082,21 @@ async function* generateDecoder(typeUri, types) {
1059
1082
  }
1060
1083
  //#endregion
1061
1084
  //#region src/constructor.ts
1085
+ /**
1086
+ * Generates the TypeScript type of a property in the `values` object that the
1087
+ * constructor and `clone()` accept.
1088
+ * @param property The property to generate the type for.
1089
+ * @param types The vocabulary types in scope.
1090
+ * @returns The generated type expression.
1091
+ */
1062
1092
  function generateParameterType(property, types) {
1063
1093
  const range = property.range;
1064
1094
  const scalar = areAllScalarTypes(range, types);
1065
1095
  const code = [];
1066
- if (hasSingularAccessor(property)) if (scalar) code.push(`${property.singularName}?: ${getTypeNames(range, types)} | null;`);
1067
- else code.push(`${property.singularName}?: ${getTypeNames(range, types)} | URL | null;`);
1068
- if (isNonFunctionalProperty(property)) if (scalar) code.push(`${property.pluralName}?: (${getTypeNames(range, types, true)})[];`);
1069
- else code.push(`${property.pluralName}?: (${getTypeNames(range, types)} | URL)[];`);
1096
+ if (hasSingularAccessor(property)) if (scalar) code.push(`${property.singularName}?: ${getTypeNames(range, types, false, true)} | null;`);
1097
+ else code.push(`${property.singularName}?: ${getTypeNames(range, types, false, true)} | URL | null;`);
1098
+ if (isNonFunctionalProperty(property)) if (scalar) code.push(`${property.pluralName}?: (${getTypeNames(range, types, true, true)})[];`);
1099
+ else code.push(`${property.pluralName}?: (${getTypeNames(range, types, false, true)} | URL)[];`);
1070
1100
  return code.join("\n");
1071
1101
  }
1072
1102
  async function* generateParametersType(typeUri, types, parentheses = true, excludeProperties = []) {
@@ -1909,6 +1939,7 @@ async function* generateClasses(types) {
1909
1939
  yield `import { type Span, SpanStatusCode, type TracerProvider, trace }
1910
1940
  from "@opentelemetry/api";\n`;
1911
1941
  yield `import {
1942
+ type CryptoKeyLike,
1912
1943
  decodeMultibase,
1913
1944
  type DocumentLoader,
1914
1945
  encodeMultibase,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab-tools",
3
- "version": "2.0.36-dev.2647+2864b09d",
3
+ "version": "2.0.36-dev.2729+88a727c8",
4
4
  "description": "Code generator for Activity Vocabulary APIs",
5
5
  "homepage": "https://fedify.dev/",
6
6
  "repository": {
@@ -7,6 +7,7 @@ import { getLogger } from \\"@logtape/logtape\\";
7
7
  import { type Span, SpanStatusCode, type TracerProvider, trace }
8
8
  from \\"@opentelemetry/api\\";
9
9
  import {
10
+ type CryptoKeyLike,
10
11
  decodeMultibase,
11
12
  type DocumentLoader,
12
13
  encodeMultibase,
@@ -19115,7 +19116,7 @@ export class CryptographicKey {
19115
19116
  values:
19116
19117
  {
19117
19118
  id?: URL | null;
19118
- owner?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKey | null;}
19119
+ owner?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKeyLike | null;}
19119
19120
  ,
19120
19121
  options: {
19121
19122
  documentLoader?: DocumentLoader,
@@ -19181,7 +19182,7 @@ owner?: Application | Group | Organization | Person | Service | URL | null;publi
19181
19182
  values:
19182
19183
  {
19183
19184
  id?: URL | null;
19184
- owner?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKey | null;}
19185
+ owner?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKeyLike | null;}
19185
19186
 
19186
19187
  = {},
19187
19188
  options: {
@@ -20036,7 +20037,7 @@ export class Multikey {
20036
20037
  values:
20037
20038
  {
20038
20039
  id?: URL | null;
20039
- controller?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKey | null;}
20040
+ controller?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKeyLike | null;}
20040
20041
  ,
20041
20042
  options: {
20042
20043
  documentLoader?: DocumentLoader,
@@ -20102,7 +20103,7 @@ controller?: Application | Group | Organization | Person | Service | URL | null;
20102
20103
  values:
20103
20104
  {
20104
20105
  id?: URL | null;
20105
- controller?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKey | null;}
20106
+ controller?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKeyLike | null;}
20106
20107
 
20107
20108
  = {},
20108
20109
  options: {
@@ -5,6 +5,7 @@ import { getLogger } from \\"@logtape/logtape\\";
5
5
  import { type Span, SpanStatusCode, type TracerProvider, trace }
6
6
  from \\"@opentelemetry/api\\";
7
7
  import {
8
+ type CryptoKeyLike,
8
9
  decodeMultibase,
9
10
  type DocumentLoader,
10
11
  encodeMultibase,
@@ -19113,7 +19114,7 @@ export class CryptographicKey {
19113
19114
  values:
19114
19115
  {
19115
19116
  id?: URL | null;
19116
- owner?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKey | null;}
19117
+ owner?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKeyLike | null;}
19117
19118
  ,
19118
19119
  options: {
19119
19120
  documentLoader?: DocumentLoader,
@@ -19179,7 +19180,7 @@ owner?: Application | Group | Organization | Person | Service | URL | null;publi
19179
19180
  values:
19180
19181
  {
19181
19182
  id?: URL | null;
19182
- owner?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKey | null;}
19183
+ owner?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKeyLike | null;}
19183
19184
 
19184
19185
  = {},
19185
19186
  options: {
@@ -20034,7 +20035,7 @@ export class Multikey {
20034
20035
  values:
20035
20036
  {
20036
20037
  id?: URL | null;
20037
- controller?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKey | null;}
20038
+ controller?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKeyLike | null;}
20038
20039
  ,
20039
20040
  options: {
20040
20041
  documentLoader?: DocumentLoader,
@@ -20100,7 +20101,7 @@ controller?: Application | Group | Organization | Person | Service | URL | null;
20100
20101
  values:
20101
20102
  {
20102
20103
  id?: URL | null;
20103
- controller?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKey | null;}
20104
+ controller?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKeyLike | null;}
20104
20105
 
20105
20106
  = {},
20106
20107
  options: {
@@ -7,6 +7,7 @@ import { getLogger } from "@logtape/logtape";
7
7
  import { type Span, SpanStatusCode, type TracerProvider, trace }
8
8
  from "@opentelemetry/api";
9
9
  import {
10
+ type CryptoKeyLike,
10
11
  decodeMultibase,
11
12
  type DocumentLoader,
12
13
  encodeMultibase,
@@ -19115,7 +19116,7 @@ export class CryptographicKey {
19115
19116
  values:
19116
19117
  {
19117
19118
  id?: URL | null;
19118
- owner?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKey | null;}
19119
+ owner?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKeyLike | null;}
19119
19120
  ,
19120
19121
  options: {
19121
19122
  documentLoader?: DocumentLoader,
@@ -19181,7 +19182,7 @@ owner?: Application | Group | Organization | Person | Service | URL | null;publi
19181
19182
  values:
19182
19183
  {
19183
19184
  id?: URL | null;
19184
- owner?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKey | null;}
19185
+ owner?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKeyLike | null;}
19185
19186
 
19186
19187
  = {},
19187
19188
  options: {
@@ -20036,7 +20037,7 @@ export class Multikey {
20036
20037
  values:
20037
20038
  {
20038
20039
  id?: URL | null;
20039
- controller?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKey | null;}
20040
+ controller?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKeyLike | null;}
20040
20041
  ,
20041
20042
  options: {
20042
20043
  documentLoader?: DocumentLoader,
@@ -20102,7 +20103,7 @@ controller?: Application | Group | Organization | Person | Service | URL | null;
20102
20103
  values:
20103
20104
  {
20104
20105
  id?: URL | null;
20105
- controller?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKey | null;}
20106
+ controller?: Application | Group | Organization | Person | Service | URL | null;publicKey?: CryptoKeyLike | null;}
20106
20107
 
20107
20108
  = {},
20108
20109
  options: {
package/src/class.ts CHANGED
@@ -143,6 +143,7 @@ export async function* generateClasses(
143
143
  yield `import { type Span, SpanStatusCode, type TracerProvider, trace }
144
144
  from "@opentelemetry/api";\n`;
145
145
  yield `import {
146
+ type CryptoKeyLike,
146
147
  decodeMultibase,
147
148
  type DocumentLoader,
148
149
  encodeMultibase,
@@ -8,6 +8,13 @@ import {
8
8
  getTypeNames,
9
9
  } from "./type.ts";
10
10
 
11
+ /**
12
+ * Generates the TypeScript type of a property in the `values` object that the
13
+ * constructor and `clone()` accept.
14
+ * @param property The property to generate the type for.
15
+ * @param types The vocabulary types in scope.
16
+ * @returns The generated type expression.
17
+ */
11
18
  function generateParameterType(
12
19
  property: PropertySchema,
13
20
  types: Record<string, TypeSchema>,
@@ -18,12 +25,14 @@ function generateParameterType(
18
25
  if (hasSingularAccessor(property)) {
19
26
  if (scalar) {
20
27
  code.push(
21
- `${property.singularName}?: ${getTypeNames(range, types)} | null;`,
28
+ `${property.singularName}?: ${
29
+ getTypeNames(range, types, false, true)
30
+ } | null;`,
22
31
  );
23
32
  } else {
24
33
  code.push(
25
34
  `${property.singularName}?: ${
26
- getTypeNames(range, types)
35
+ getTypeNames(range, types, false, true)
27
36
  } | URL | null;`,
28
37
  );
29
38
  }
@@ -31,11 +40,15 @@ function generateParameterType(
31
40
  if (isNonFunctionalProperty(property)) {
32
41
  if (scalar) {
33
42
  code.push(
34
- `${property.pluralName}?: (${getTypeNames(range, types, true)})[];`,
43
+ `${property.pluralName}?: (${
44
+ getTypeNames(range, types, true, true)
45
+ })[];`,
35
46
  );
36
47
  } else {
37
48
  code.push(
38
- `${property.pluralName}?: (${getTypeNames(range, types)} | URL)[];`,
49
+ `${property.pluralName}?: (${
50
+ getTypeNames(range, types, false, true)
51
+ } | URL)[];`,
39
52
  );
40
53
  }
41
54
  }
package/src/type.ts CHANGED
@@ -17,6 +17,11 @@ const ACTIVITY_TYPE_URI = "https://www.w3.org/ns/activitystreams#Activity";
17
17
 
18
18
  interface ScalarType {
19
19
  name: string;
20
+ /**
21
+ * The type name to use for values accepted by constructors and `clone()`,
22
+ * when it is wider than {@link name}. Defaults to {@link name}.
23
+ */
24
+ inputName?: string;
20
25
  typeGuard(variable: string): string;
21
26
  encoder(variable: string): string;
22
27
  compactEncoder?: (variable: string) => string;
@@ -333,6 +338,7 @@ const scalarTypes: Record<string, ScalarType> = {
333
338
  },
334
339
  "fedify:publicKey": {
335
340
  name: "CryptoKey",
341
+ inputName: "CryptoKeyLike",
336
342
  typeGuard(v) {
337
343
  return `
338
344
  // @ts-ignore: CryptoKey exists in the global scope.
@@ -355,6 +361,7 @@ const scalarTypes: Record<string, ScalarType> = {
355
361
  },
356
362
  "fedify:multibaseKey": {
357
363
  name: "CryptoKey",
364
+ inputName: "CryptoKeyLike",
358
365
  typeGuard(v) {
359
366
  return `
360
367
  // @ts-ignore: CryptoKey exists in the global scope.
@@ -431,23 +438,50 @@ const scalarTypes: Record<string, ScalarType> = {
431
438
  },
432
439
  };
433
440
 
441
+ /**
442
+ * Gets the TypeScript type name for a type URI.
443
+ * @param typeUri The type URI to resolve.
444
+ * @param types The vocabulary types in scope.
445
+ * @param forInput Whether to return the type accepted as input by
446
+ * constructors and `clone()`, which can be wider than the type
447
+ * those APIs return.
448
+ * @returns The TypeScript type name.
449
+ */
434
450
  export function getTypeName(
435
451
  typeUri: string,
436
452
  types: Record<string, TypeSchema>,
453
+ forInput = false,
437
454
  ): string {
438
455
  if (typeUri in types) return types[typeUri].name;
439
- if (typeUri in scalarTypes) return scalarTypes[typeUri].name;
456
+ if (typeUri in scalarTypes) {
457
+ const scalar = scalarTypes[typeUri];
458
+ return forInput ? scalar.inputName ?? scalar.name : scalar.name;
459
+ }
440
460
  throw new Error(`Unknown type: ${typeUri}`);
441
461
  }
442
462
 
463
+ /**
464
+ * Gets the TypeScript type names for a list of type URIs.
465
+ * @param typeUris The type URIs to resolve.
466
+ * @param types The vocabulary types in scope.
467
+ * @param parentheses Whether to wrap a union in parentheses.
468
+ * @param forInput Whether to return the types accepted as input by
469
+ * constructors and `clone()`.
470
+ * @returns The TypeScript type expression.
471
+ */
443
472
  export function getTypeNames(
444
473
  typeUris: string[],
445
474
  types: Record<string, TypeSchema>,
446
475
  parentheses = false,
476
+ forInput = false,
447
477
  ): string {
448
478
  if (typeUris.length < 1) return "never";
449
- else if (typeUris.length === 1) return getTypeName(typeUris[0], types);
450
- let typeNames = typeUris.map((typeUri) => getTypeName(typeUri, types));
479
+ else if (typeUris.length === 1) {
480
+ return getTypeName(typeUris[0], types, forInput);
481
+ }
482
+ let typeNames = typeUris.map((typeUri) =>
483
+ getTypeName(typeUri, types, forInput)
484
+ );
451
485
  typeNames = typeNames.filter((t, i) => typeNames.indexOf(t) === i);
452
486
  const t = typeNames.join(" | ");
453
487
  return parentheses && typeNames.length > 1 ? `(${t})` : t;