@formspec/build 0.1.0-alpha.36 → 0.1.0-alpha.38

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.
@@ -106,6 +106,8 @@ export declare function generateSchemasFromParameter(options: GenerateSchemasFro
106
106
  /**
107
107
  * Generates schemas for a method or function return type.
108
108
  *
109
+ * Awaited `Promise<T>`-style return types are unwrapped before generation.
110
+ *
109
111
  * @public
110
112
  */
111
113
  export declare function generateSchemasFromReturnType(options: GenerateSchemasFromReturnTypeOptions): DiscoveredTypeSchemas;
@@ -1 +1 @@
1
- {"version":3,"file":"discovered-schema.d.ts","sourceRoot":"","sources":["../../src/generators/discovered-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAQjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAU7D,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAK/F;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACpC,iDAAiD;IACjD,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;CACpC;AAED;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAC/B,EAAE,CAAC,gBAAgB,GACnB,EAAE,CAAC,oBAAoB,GACvB,EAAE,CAAC,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,MAAM,WAAW,qCAAsC,SAAQ,6BAA6B;IAC1F,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,wCAAwC;IACxC,QAAQ,CAAC,WAAW,EAAE,uBAAuB,CAAC;CAC/C;AAED;;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Q,CAAC,SAAS,EAAE,EAAE,CAAC,oBAAoB,CAAC;CAC7C;AAED;;;;GAIG;AACH,MAAM,WAAW,oCAAqC,SAAQ,6BAA6B;IACzF,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,gFAAgF;IAChF,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,oBAAoB,CAAC;CAC/C;AAwSD;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,qCAAqC,GAC7C,qBAAqB,CA+EvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,8BAA8B,GACtC,qBAAqB,CAEvB;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,mCAAmC,GAC3C,qBAAqB,CAOvB;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,oCAAoC,GAC5C,qBAAqB,CAyBvB"}
package/dist/index.cjs CHANGED
@@ -2166,6 +2166,16 @@ function buildSupportingDeclarations(sourceFile, extensionTypeNames) {
2166
2166
  return true;
2167
2167
  }).map((statement) => statement.getText(sourceFile));
2168
2168
  }
2169
+ function pushUniqueCompilerDiagnostics(target, additions) {
2170
+ for (const diagnostic of additions) {
2171
+ if ((diagnostic.code === "UNSUPPORTED_CUSTOM_TYPE_OVERRIDE" || diagnostic.code === "SYNTHETIC_SETUP_FAILURE") && target.some(
2172
+ (existing) => existing.code === diagnostic.code && existing.message === diagnostic.message
2173
+ )) {
2174
+ continue;
2175
+ }
2176
+ target.push(diagnostic);
2177
+ }
2178
+ }
2169
2179
  function renderSyntheticArgumentExpression(valueKind, argumentText) {
2170
2180
  const trimmed = argumentText.trim();
2171
2181
  if (trimmed === "") {
@@ -2432,6 +2442,16 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2432
2442
  if (result.diagnostics.length === 0) {
2433
2443
  return [];
2434
2444
  }
2445
+ const setupDiagnostic = result.diagnostics.find((diagnostic) => diagnostic.kind !== "typescript");
2446
+ if (setupDiagnostic !== void 0) {
2447
+ return [
2448
+ makeDiagnostic(
2449
+ setupDiagnostic.kind === "unsupported-custom-type-override" ? "UNSUPPORTED_CUSTOM_TYPE_OVERRIDE" : "SYNTHETIC_SETUP_FAILURE",
2450
+ setupDiagnostic.message,
2451
+ provenance
2452
+ )
2453
+ ];
2454
+ }
2435
2455
  const expectedLabel = definition.valueKind === null ? "compatible argument" : capabilityLabel(definition.valueKind);
2436
2456
  return [
2437
2457
  makeDiagnostic(
@@ -2597,7 +2617,7 @@ function parseTSDocTags(node, file = "", options) {
2597
2617
  options
2598
2618
  );
2599
2619
  if (compilerDiagnostics.length > 0) {
2600
- diagnostics.push(...compilerDiagnostics);
2620
+ pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
2601
2621
  continue;
2602
2622
  }
2603
2623
  const constraintNode = (0, import_internal2.parseConstraintTagValue)(
@@ -2684,7 +2704,7 @@ function parseTSDocTags(node, file = "", options) {
2684
2704
  options
2685
2705
  );
2686
2706
  if (compilerDiagnostics.length > 0) {
2687
- diagnostics.push(...compilerDiagnostics);
2707
+ pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
2688
2708
  continue;
2689
2709
  }
2690
2710
  const constraintNode = (0, import_internal2.parseConstraintTagValue)(
@@ -2718,7 +2738,7 @@ function parseTSDocTags(node, file = "", options) {
2718
2738
  options
2719
2739
  );
2720
2740
  if (compilerDiagnostics.length > 0) {
2721
- diagnostics.push(...compilerDiagnostics);
2741
+ pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
2722
2742
  continue;
2723
2743
  }
2724
2744
  const constraintNode = (0, import_internal2.parseConstraintTagValue)(
@@ -2925,6 +2945,21 @@ function isObjectType(type) {
2925
2945
  function isIntersectionType(type) {
2926
2946
  return !!(type.flags & ts3.TypeFlags.Intersection);
2927
2947
  }
2948
+ function isResolvableObjectLikeAliasTypeNode(typeNode) {
2949
+ if (ts3.isParenthesizedTypeNode(typeNode)) {
2950
+ return isResolvableObjectLikeAliasTypeNode(typeNode.type);
2951
+ }
2952
+ if (ts3.isTypeLiteralNode(typeNode) || ts3.isTypeReferenceNode(typeNode)) {
2953
+ return true;
2954
+ }
2955
+ return ts3.isIntersectionTypeNode(typeNode) && typeNode.types.length > 0 && typeNode.types.every((member) => isResolvableObjectLikeAliasTypeNode(member));
2956
+ }
2957
+ function isSemanticallyPlainObjectLikeType(type, checker) {
2958
+ if (isIntersectionType(type)) {
2959
+ return type.types.length > 0 && type.types.every((member) => isSemanticallyPlainObjectLikeType(member, checker));
2960
+ }
2961
+ return isObjectType(type) && checker.getSignaturesOfType(type, ts3.SignatureKind.Call).length === 0 && checker.getSignaturesOfType(type, ts3.SignatureKind.Construct).length === 0 && !checker.isArrayType(type) && !checker.isTupleType(type);
2962
+ }
2928
2963
  function isTypeReference(type) {
2929
2964
  return !!(type.flags & ts3.TypeFlags.Object) && !!(type.objectFlags & ts3.ObjectFlags.Reference);
2930
2965
  }
@@ -3182,6 +3217,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3182
3217
  const kindDesc = ts3.SyntaxKind[typeAlias.type.kind] ?? "unknown";
3183
3218
  return {
3184
3219
  ok: false,
3220
+ kind: "not-object-like",
3185
3221
  error: `Type alias "${typeAlias.name.text}" at line ${String(line + 1)} is not an object-like type alias (found ${kindDesc})`
3186
3222
  };
3187
3223
  }
@@ -3196,6 +3232,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3196
3232
  const { line } = sourceFile.getLineAndCharacterOfPosition(typeAlias.getStart());
3197
3233
  return {
3198
3234
  ok: false,
3235
+ kind: "duplicate-properties",
3199
3236
  error: `Type alias "${name}" at line ${String(line + 1)} contains duplicate property names across object-like members: ${duplicatePropertyNames.join(", ")}`
3200
3237
  };
3201
3238
  }
@@ -3892,10 +3929,10 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
3892
3929
  return [...duplicates].sort();
3893
3930
  }
3894
3931
  function getAnalyzableObjectLikePropertyName(name) {
3895
- if (!ts3.isIdentifier(name)) {
3896
- return null;
3932
+ if (ts3.isIdentifier(name) || ts3.isStringLiteral(name) || ts3.isNumericLiteral(name)) {
3933
+ return name.text;
3897
3934
  }
3898
- return name.text;
3935
+ return null;
3899
3936
  }
3900
3937
  function applyEnumMemberDisplayNames(type, annotations) {
3901
3938
  if (!annotations.some(
@@ -4105,6 +4142,19 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
4105
4142
  diagnostics
4106
4143
  );
4107
4144
  }
4145
+ if (resolvedSourceTypeNode !== void 0 && isResolvableObjectLikeAliasTypeNode(resolvedSourceTypeNode) && isSemanticallyPlainObjectLikeType(type, checker)) {
4146
+ return resolveObjectType(
4147
+ type,
4148
+ checker,
4149
+ file,
4150
+ typeRegistry,
4151
+ visiting,
4152
+ sourceNode,
4153
+ metadataPolicy,
4154
+ extensionRegistry,
4155
+ diagnostics
4156
+ );
4157
+ }
4108
4158
  }
4109
4159
  if (isObjectType(type)) {
4110
4160
  return resolveObjectType(
@@ -5012,6 +5062,95 @@ function findInterfaceByName(sourceFile, interfaceName) {
5012
5062
  function findTypeAliasByName(sourceFile, aliasName) {
5013
5063
  return findNodeByName(sourceFile, aliasName, ts4.isTypeAliasDeclaration, (n) => n.name.text);
5014
5064
  }
5065
+ function getResolvedObjectRootType(rootType, typeRegistry) {
5066
+ if (rootType.kind === "object") {
5067
+ return rootType;
5068
+ }
5069
+ if (rootType.kind !== "reference") {
5070
+ return null;
5071
+ }
5072
+ const definition = typeRegistry[rootType.name];
5073
+ return definition?.type.kind === "object" ? definition.type : null;
5074
+ }
5075
+ function createResolvedObjectAliasAnalysis(name, rootType, typeRegistry, rootInfo, diagnostics) {
5076
+ const resolvedRootType = getResolvedObjectRootType(rootType, typeRegistry);
5077
+ if (resolvedRootType === null) {
5078
+ return null;
5079
+ }
5080
+ const fields = resolvedRootType.properties.map((property) => ({
5081
+ kind: "field",
5082
+ name: property.name,
5083
+ ...property.metadata !== void 0 && { metadata: property.metadata },
5084
+ type: property.type,
5085
+ required: !property.optional,
5086
+ constraints: property.constraints,
5087
+ annotations: property.annotations,
5088
+ provenance: property.provenance
5089
+ }));
5090
+ return {
5091
+ name,
5092
+ ...rootInfo.metadata !== void 0 && { metadata: rootInfo.metadata },
5093
+ fields,
5094
+ fieldLayouts: fields.map(() => ({})),
5095
+ typeRegistry,
5096
+ ...rootInfo.annotations.length > 0 && { annotations: [...rootInfo.annotations] },
5097
+ ...diagnostics.length > 0 && { diagnostics: [...diagnostics] },
5098
+ instanceMethods: [],
5099
+ staticMethods: []
5100
+ };
5101
+ }
5102
+ function containsTypeReferenceInObjectLikeAlias(typeNode) {
5103
+ if (ts4.isParenthesizedTypeNode(typeNode)) {
5104
+ return containsTypeReferenceInObjectLikeAlias(typeNode.type);
5105
+ }
5106
+ if (ts4.isTypeReferenceNode(typeNode)) {
5107
+ return true;
5108
+ }
5109
+ return ts4.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
5110
+ }
5111
+ function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
5112
+ if (ts4.isParenthesizedTypeNode(typeNode)) {
5113
+ return collectFallbackAliasMemberPropertyNames(typeNode.type, checker);
5114
+ }
5115
+ if (ts4.isTypeLiteralNode(typeNode)) {
5116
+ const propertyNames = [];
5117
+ for (const member of typeNode.members) {
5118
+ if (!ts4.isPropertySignature(member)) {
5119
+ continue;
5120
+ }
5121
+ const propertyName = getAnalyzableObjectLikePropertyName(member.name);
5122
+ if (propertyName !== null) {
5123
+ propertyNames.push(propertyName);
5124
+ }
5125
+ }
5126
+ return propertyNames;
5127
+ }
5128
+ if (ts4.isTypeReferenceNode(typeNode)) {
5129
+ return checker.getTypeFromTypeNode(typeNode).getProperties().map((property) => property.getName());
5130
+ }
5131
+ return null;
5132
+ }
5133
+ function findFallbackAliasDuplicatePropertyNames(typeNode, checker) {
5134
+ if (!ts4.isIntersectionTypeNode(typeNode)) {
5135
+ return [];
5136
+ }
5137
+ const seen = /* @__PURE__ */ new Set();
5138
+ const duplicates = /* @__PURE__ */ new Set();
5139
+ for (const member of typeNode.types) {
5140
+ const propertyNames = collectFallbackAliasMemberPropertyNames(member, checker);
5141
+ if (propertyNames === null) {
5142
+ continue;
5143
+ }
5144
+ for (const propertyName of propertyNames) {
5145
+ if (seen.has(propertyName)) {
5146
+ duplicates.add(propertyName);
5147
+ } else {
5148
+ seen.add(propertyName);
5149
+ }
5150
+ }
5151
+ }
5152
+ return [...duplicates].sort();
5153
+ }
5015
5154
  function analyzeNamedTypeToIR(filePath, typeName, extensionRegistry, metadataPolicy, discriminatorOptions) {
5016
5155
  const ctx = createProgramContext(filePath);
5017
5156
  return analyzeNamedTypeToIRFromProgramContext(
@@ -5060,6 +5199,51 @@ function analyzeNamedTypeToIRFromProgramContext(ctx, filePath, typeName, extensi
5060
5199
  if (result.ok) {
5061
5200
  return result.analysis;
5062
5201
  }
5202
+ const fallbackEligible = result.kind === "not-object-like" && isResolvableObjectLikeAliasTypeNode(typeAlias.type) && containsTypeReferenceInObjectLikeAlias(typeAlias.type);
5203
+ if (!fallbackEligible) {
5204
+ throw new Error(result.error);
5205
+ }
5206
+ const duplicatePropertyNames = findFallbackAliasDuplicatePropertyNames(
5207
+ typeAlias.type,
5208
+ ctx.checker
5209
+ );
5210
+ if (duplicatePropertyNames.length > 0) {
5211
+ const sourceFile = typeAlias.getSourceFile();
5212
+ const { line } = sourceFile.getLineAndCharacterOfPosition(typeAlias.getStart());
5213
+ throw new Error(
5214
+ `Type alias "${typeAlias.name.text}" at line ${String(line + 1)} contains duplicate property names across object-like members: ${duplicatePropertyNames.join(", ")}`
5215
+ );
5216
+ }
5217
+ const rootInfo = analyzeDeclarationRootInfo(
5218
+ typeAlias,
5219
+ ctx.checker,
5220
+ analysisFilePath,
5221
+ extensionRegistry,
5222
+ metadataPolicy
5223
+ );
5224
+ const diagnostics = [...rootInfo.diagnostics];
5225
+ const typeRegistry = {};
5226
+ const rootType = resolveTypeNode(
5227
+ ctx.checker.getTypeAtLocation(typeAlias),
5228
+ ctx.checker,
5229
+ analysisFilePath,
5230
+ typeRegistry,
5231
+ /* @__PURE__ */ new Set(),
5232
+ typeAlias,
5233
+ createAnalyzerMetadataPolicy(metadataPolicy, discriminatorOptions),
5234
+ extensionRegistry,
5235
+ diagnostics
5236
+ );
5237
+ const fallbackAnalysis = createResolvedObjectAliasAnalysis(
5238
+ typeAlias.name.text,
5239
+ rootType,
5240
+ typeRegistry,
5241
+ rootInfo,
5242
+ diagnostics
5243
+ );
5244
+ if (fallbackAnalysis !== null) {
5245
+ return fallbackAnalysis;
5246
+ }
5063
5247
  throw new Error(result.error);
5064
5248
  }
5065
5249
  throw new Error(
@@ -5563,15 +5747,36 @@ function generateSchemasFromParameter(options) {
5563
5747
  }
5564
5748
  function generateSchemasFromReturnType(options) {
5565
5749
  const signature = options.context.checker.getSignatureFromDeclaration(options.declaration);
5566
- const type = signature !== void 0 ? options.context.checker.getReturnTypeOfSignature(signature) : options.context.checker.getTypeAtLocation(options.declaration);
5750
+ const returnType = signature !== void 0 ? options.context.checker.getReturnTypeOfSignature(signature) : options.context.checker.getTypeAtLocation(options.declaration);
5751
+ const type = unwrapPromiseType(options.context.checker, returnType);
5752
+ const sourceNode = type !== returnType ? unwrapPromiseTypeNode(options.declaration.type) ?? options.declaration.type ?? options.declaration : options.declaration.type ?? options.declaration;
5567
5753
  const fallbackName = options.declaration.name !== void 0 && ts7.isIdentifier(options.declaration.name) ? `${options.declaration.name.text}ReturnType` : "ReturnType";
5568
5754
  return generateSchemasFromResolvedType({
5569
5755
  ...options,
5570
5756
  type,
5571
- sourceNode: options.declaration.type ?? options.declaration,
5757
+ sourceNode,
5572
5758
  name: fallbackName
5573
5759
  });
5574
5760
  }
5761
+ function unwrapPromiseType(checker, type) {
5762
+ if (!("getAwaitedType" in checker) || typeof checker.getAwaitedType !== "function") {
5763
+ return type;
5764
+ }
5765
+ return checker.getAwaitedType(type) ?? type;
5766
+ }
5767
+ function unwrapPromiseTypeNode(typeNode) {
5768
+ if (typeNode === void 0) {
5769
+ return void 0;
5770
+ }
5771
+ if (ts7.isParenthesizedTypeNode(typeNode)) {
5772
+ const unwrapped = unwrapPromiseTypeNode(typeNode.type);
5773
+ return unwrapped ?? typeNode;
5774
+ }
5775
+ return isPromiseTypeReferenceNode(typeNode) ? typeNode.typeArguments[0] : typeNode;
5776
+ }
5777
+ function isPromiseTypeReferenceNode(typeNode) {
5778
+ return ts7.isTypeReferenceNode(typeNode) && ts7.isIdentifier(typeNode.typeName) && typeNode.typeName.text === "Promise" && typeNode.typeArguments !== void 0 && typeNode.typeArguments.length > 0;
5779
+ }
5575
5780
 
5576
5781
  // src/generators/mixed-authoring.ts
5577
5782
  function buildMixedAuthoringSchemas(options) {