@formspec/build 0.1.0-alpha.42 → 0.1.0-alpha.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1594,7 +1594,7 @@ function generateCustomType(type, ctx) {
1594
1594
  }
1595
1595
  return registration.toJsonSchema(type.payload, ctx.vendorPrefix);
1596
1596
  }
1597
- var JSON_SCHEMA_STRUCTURAL_KEYWORDS = /* @__PURE__ */ new Set([
1597
+ var VOCABULARY_MODE_BLOCKED_KEYWORDS = /* @__PURE__ */ new Set([
1598
1598
  "$schema",
1599
1599
  "$ref",
1600
1600
  "$defs",
@@ -1665,7 +1665,7 @@ function applyCustomConstraint(schema, constraint, ctx) {
1665
1665
  if (registration.emitsVocabularyKeywords) {
1666
1666
  const target = schema;
1667
1667
  for (const [key, value] of Object.entries(extensionSchema)) {
1668
- if (JSON_SCHEMA_STRUCTURAL_KEYWORDS.has(key)) {
1668
+ if (VOCABULARY_MODE_BLOCKED_KEYWORDS.has(key)) {
1669
1669
  throw new Error(
1670
1670
  `Custom constraint "${constraint.constraintId}" with emitsVocabularyKeywords must not overwrite standard JSON Schema keyword "${key}"`
1671
1671
  );
@@ -2209,48 +2209,8 @@ var ts2 = __toESM(require("typescript"), 1);
2209
2209
  // src/analyzer/tsdoc-parser.ts
2210
2210
  var ts = __toESM(require("typescript"), 1);
2211
2211
  var import_internal2 = require("@formspec/analysis/internal");
2212
- var import_tsdoc = require("@microsoft/tsdoc");
2213
2212
  var import_internals4 = require("@formspec/core/internals");
2214
2213
  var import_internals5 = require("@formspec/core/internals");
2215
- var TAGS_REQUIRING_RAW_TEXT = /* @__PURE__ */ new Set(["pattern", "enumOptions", "defaultValue"]);
2216
- function createFormSpecTSDocConfig(extensionTagNames = []) {
2217
- const config = new import_tsdoc.TSDocConfiguration();
2218
- for (const tagName of Object.keys(import_internals4.BUILTIN_CONSTRAINT_DEFINITIONS)) {
2219
- config.addTagDefinition(
2220
- new import_tsdoc.TSDocTagDefinition({
2221
- tagName: "@" + tagName,
2222
- syntaxKind: import_tsdoc.TSDocTagSyntaxKind.BlockTag,
2223
- allowMultiple: true
2224
- })
2225
- );
2226
- }
2227
- for (const tagName of ["apiName", "displayName", "format", "placeholder"]) {
2228
- config.addTagDefinition(
2229
- new import_tsdoc.TSDocTagDefinition({
2230
- tagName: "@" + tagName,
2231
- syntaxKind: import_tsdoc.TSDocTagSyntaxKind.BlockTag,
2232
- allowMultiple: true
2233
- })
2234
- );
2235
- }
2236
- for (const tagName of extensionTagNames) {
2237
- config.addTagDefinition(
2238
- new import_tsdoc.TSDocTagDefinition({
2239
- tagName: "@" + tagName,
2240
- syntaxKind: import_tsdoc.TSDocTagSyntaxKind.BlockTag,
2241
- allowMultiple: true
2242
- })
2243
- );
2244
- }
2245
- return config;
2246
- }
2247
- function sharedCommentSyntaxOptions(options, offset) {
2248
- const extensions = options?.extensionRegistry?.extensions;
2249
- return {
2250
- ...offset !== void 0 ? { offset } : {},
2251
- ...extensions !== void 0 ? { extensions } : {}
2252
- };
2253
- }
2254
2214
  function sharedTagValueOptions(options) {
2255
2215
  return {
2256
2216
  ...options?.extensionRegistry !== void 0 ? { registry: options.extensionRegistry } : {},
@@ -2350,6 +2310,30 @@ function pushUniqueCompilerDiagnostics(target, additions) {
2350
2310
  target.push(diagnostic);
2351
2311
  }
2352
2312
  }
2313
+ function processConstraintTag(tagName, text, parsedTag, provenance, node, sourceFile, supportingDeclarations, options, constraints, diagnostics) {
2314
+ const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
2315
+ node,
2316
+ sourceFile,
2317
+ tagName,
2318
+ parsedTag,
2319
+ provenance,
2320
+ supportingDeclarations,
2321
+ options
2322
+ );
2323
+ if (compilerDiagnostics.length > 0) {
2324
+ pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
2325
+ return;
2326
+ }
2327
+ const constraintNode = (0, import_internal2.parseConstraintTagValue)(
2328
+ tagName,
2329
+ text,
2330
+ provenance,
2331
+ sharedTagValueOptions(options)
2332
+ );
2333
+ if (constraintNode) {
2334
+ constraints.push(constraintNode);
2335
+ }
2336
+ }
2353
2337
  function renderSyntheticArgumentExpression(valueKind, argumentText) {
2354
2338
  const trimmed = argumentText.trim();
2355
2339
  if (trimmed === "") {
@@ -2635,10 +2619,9 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2635
2619
  )
2636
2620
  ];
2637
2621
  }
2638
- var parserCache = /* @__PURE__ */ new Map();
2639
2622
  var parseResultCache = /* @__PURE__ */ new Map();
2640
- function getParser(options) {
2641
- const extensionTagNames = [
2623
+ function getExtensionTagNames(options) {
2624
+ return [
2642
2625
  ...options?.extensionRegistry?.extensions.flatMap(
2643
2626
  (extension) => (extension.constraintTags ?? []).map((tag) => (0, import_internal2.normalizeFormSpecTagName)(tag.tagName))
2644
2627
  ) ?? [],
@@ -2646,14 +2629,6 @@ function getParser(options) {
2646
2629
  (extension) => (extension.metadataSlots ?? []).map((slot) => (0, import_internal2.normalizeFormSpecTagName)(slot.tagName))
2647
2630
  ) ?? []
2648
2631
  ].sort();
2649
- const cacheKey = extensionTagNames.join("|");
2650
- const existing = parserCache.get(cacheKey);
2651
- if (existing) {
2652
- return existing;
2653
- }
2654
- const parser = new import_tsdoc.TSDocParser(createFormSpecTSDocConfig(extensionTagNames));
2655
- parserCache.set(cacheKey, parser);
2656
- return parser;
2657
2632
  }
2658
2633
  function getExtensionRegistryCacheKey(registry) {
2659
2634
  if (registry === void 0) {
@@ -2704,13 +2679,13 @@ function parseTSDocTags(node, file = "", options) {
2704
2679
  let placeholder;
2705
2680
  let displayNameProvenance;
2706
2681
  let placeholderProvenance;
2707
- const rawTextTags = [];
2708
2682
  const sourceFile = node.getSourceFile();
2709
2683
  const sourceText = sourceFile.getFullText();
2710
2684
  const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
2711
2685
  const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
2712
2686
  const commentRanges = ts.getLeadingCommentRanges(sourceText, node.getFullStart());
2713
2687
  const rawTextFallbacks = collectRawTextFallbacks(node, file);
2688
+ const extensionTagNames = getExtensionTagNames(options);
2714
2689
  if (commentRanges) {
2715
2690
  for (const range of commentRanges) {
2716
2691
  if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) {
@@ -2720,38 +2695,18 @@ function parseTSDocTags(node, file = "", options) {
2720
2695
  if (!commentText.startsWith("/**")) {
2721
2696
  continue;
2722
2697
  }
2723
- const parser = getParser(options);
2724
- const parserContext = parser.parseRange(
2725
- import_tsdoc.TextRange.fromStringRange(sourceText, range.pos, range.end)
2726
- );
2727
- const docComment = parserContext.docComment;
2728
- const parsedComment = (0, import_internal2.parseCommentBlock)(
2729
- commentText,
2730
- sharedCommentSyntaxOptions(options, range.pos)
2731
- );
2732
- let parsedTagCursor = 0;
2733
- const nextParsedTag = (normalizedTagName) => {
2734
- while (parsedTagCursor < parsedComment.tags.length) {
2735
- const candidate = parsedComment.tags[parsedTagCursor];
2736
- parsedTagCursor += 1;
2737
- if (candidate?.normalizedTagName === normalizedTagName) {
2738
- return candidate;
2739
- }
2740
- }
2741
- return null;
2742
- };
2743
- for (const parsedTag of parsedComment.tags) {
2744
- if (TAGS_REQUIRING_RAW_TEXT.has(parsedTag.normalizedTagName)) {
2745
- rawTextTags.push({ tag: parsedTag, commentText, commentOffset: range.pos });
2746
- }
2747
- }
2748
- for (const block of docComment.customBlocks) {
2749
- const tagName = (0, import_internals4.normalizeConstraintTagName)(block.blockTag.tagName.substring(1));
2750
- const parsedTag = nextParsedTag(tagName);
2698
+ const extensions = options?.extensionRegistry?.extensions;
2699
+ const unified = (0, import_internal2.parseUnifiedComment)(commentText, {
2700
+ offset: range.pos,
2701
+ extensionTagNames,
2702
+ ...extensions !== void 0 ? { extensions } : {}
2703
+ });
2704
+ for (const tag of unified.tags) {
2705
+ const tagName = tag.normalizedTagName;
2751
2706
  if (tagName === "displayName" || tagName === "format" || tagName === "placeholder") {
2752
- const text2 = getBestBlockPayloadText(parsedTag, commentText, range.pos, block);
2707
+ const text2 = tag.resolvedPayloadText;
2753
2708
  if (text2 === "") continue;
2754
- const provenance2 = parsedTag !== null ? provenanceForParsedTag(parsedTag, sourceFile, file) : provenanceForComment(range, sourceFile, file, tagName);
2709
+ const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
2755
2710
  switch (tagName) {
2756
2711
  case "displayName":
2757
2712
  if (!isMemberTargetDisplayName(text2) && displayName === void 0) {
@@ -2776,64 +2731,69 @@ function parseTSDocTags(node, file = "", options) {
2776
2731
  }
2777
2732
  continue;
2778
2733
  }
2779
- if (TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
2780
- const text = getBestBlockPayloadText(parsedTag, commentText, range.pos, block);
2781
- const expectedType = (0, import_internals4.isBuiltinConstraintName)(tagName) ? import_internals4.BUILTIN_CONSTRAINT_DEFINITIONS[tagName] : void 0;
2782
- if (text === "" && expectedType !== "boolean") continue;
2783
- const provenance = parsedTag !== null ? provenanceForParsedTag(parsedTag, sourceFile, file) : provenanceForComment(range, sourceFile, file, tagName);
2784
- const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
2785
- node,
2786
- sourceFile,
2787
- tagName,
2788
- parsedTag,
2789
- provenance,
2790
- supportingDeclarations,
2791
- options
2792
- );
2793
- if (compilerDiagnostics.length > 0) {
2794
- pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
2734
+ if (import_internal2.TAGS_REQUIRING_RAW_TEXT.has(tagName)) {
2735
+ const fallback = rawTextFallbacks.get(tagName)?.shift();
2736
+ const text2 = (0, import_internal2.choosePreferredPayloadText)(tag.resolvedPayloadText, fallback?.text ?? "");
2737
+ if (text2 === "") continue;
2738
+ const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
2739
+ if (tagName === "defaultValue") {
2740
+ annotations.push((0, import_internal2.parseDefaultValueTagValue)(text2, provenance2));
2741
+ continue;
2742
+ }
2743
+ processConstraintTag(
2744
+ tagName,
2745
+ text2,
2746
+ tag,
2747
+ provenance2,
2748
+ node,
2749
+ sourceFile,
2750
+ supportingDeclarations,
2751
+ options,
2752
+ constraints,
2753
+ diagnostics
2754
+ );
2795
2755
  continue;
2796
2756
  }
2797
- const constraintNode = (0, import_internal2.parseConstraintTagValue)(
2757
+ const text = tag.resolvedPayloadText;
2758
+ const expectedType = (0, import_internals4.isBuiltinConstraintName)(tagName) ? import_internals4.BUILTIN_CONSTRAINT_DEFINITIONS[tagName] : void 0;
2759
+ if (text === "" && expectedType !== "boolean") continue;
2760
+ const provenance = provenanceForParsedTag(tag, sourceFile, file);
2761
+ processConstraintTag(
2798
2762
  tagName,
2799
2763
  text,
2764
+ tag,
2800
2765
  provenance,
2801
- sharedTagValueOptions(options)
2766
+ node,
2767
+ sourceFile,
2768
+ supportingDeclarations,
2769
+ options,
2770
+ constraints,
2771
+ diagnostics
2802
2772
  );
2803
- if (constraintNode) {
2804
- constraints.push(constraintNode);
2805
- }
2806
2773
  }
2807
- if (docComment.deprecatedBlock !== void 0) {
2808
- const message = extractBlockText(docComment.deprecatedBlock).trim();
2774
+ if (unified.isDeprecated) {
2809
2775
  annotations.push({
2810
2776
  kind: "annotation",
2811
2777
  annotationKind: "deprecated",
2812
- ...message !== "" && { message },
2778
+ ...unified.deprecationMessage !== "" && { message: unified.deprecationMessage },
2813
2779
  provenance: provenanceForComment(range, sourceFile, file, "deprecated")
2814
2780
  });
2815
2781
  }
2816
- {
2817
- const summary = extractPlainText(docComment.summarySection).trim();
2818
- if (summary !== "") {
2819
- annotations.push({
2820
- kind: "annotation",
2821
- annotationKind: "description",
2822
- value: summary,
2823
- provenance: provenanceForComment(range, sourceFile, file, "summary")
2824
- });
2825
- }
2782
+ if (unified.summaryText !== "") {
2783
+ annotations.push({
2784
+ kind: "annotation",
2785
+ annotationKind: "description",
2786
+ value: unified.summaryText,
2787
+ provenance: provenanceForComment(range, sourceFile, file, "summary")
2788
+ });
2826
2789
  }
2827
- if (docComment.remarksBlock !== void 0) {
2828
- const remarksText = extractBlockText(docComment.remarksBlock).trim();
2829
- if (remarksText !== "") {
2830
- annotations.push({
2831
- kind: "annotation",
2832
- annotationKind: "remarks",
2833
- value: remarksText,
2834
- provenance: provenanceForComment(range, sourceFile, file, "remarks")
2835
- });
2836
- }
2790
+ if (unified.remarksText !== "") {
2791
+ annotations.push({
2792
+ kind: "annotation",
2793
+ annotationKind: "remarks",
2794
+ value: unified.remarksText,
2795
+ provenance: provenanceForComment(range, sourceFile, file, "remarks")
2796
+ });
2837
2797
  }
2838
2798
  }
2839
2799
  }
@@ -2853,77 +2813,27 @@ function parseTSDocTags(node, file = "", options) {
2853
2813
  provenance: placeholderProvenance
2854
2814
  });
2855
2815
  }
2856
- if (rawTextTags.length > 0) {
2857
- for (const rawTextTag of rawTextTags) {
2858
- const fallbackQueue = rawTextFallbacks.get(rawTextTag.tag.normalizedTagName);
2859
- const fallback = fallbackQueue?.shift();
2860
- const text = choosePreferredPayloadText(
2861
- getSharedPayloadText(rawTextTag.tag, rawTextTag.commentText, rawTextTag.commentOffset),
2862
- fallback?.text ?? ""
2863
- );
2864
- if (text === "") continue;
2865
- const provenance = provenanceForParsedTag(rawTextTag.tag, sourceFile, file);
2866
- if (rawTextTag.tag.normalizedTagName === "defaultValue") {
2867
- const defaultValueNode = (0, import_internal2.parseDefaultValueTagValue)(text, provenance);
2868
- annotations.push(defaultValueNode);
2869
- continue;
2870
- }
2871
- const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
2872
- node,
2873
- sourceFile,
2874
- rawTextTag.tag.normalizedTagName,
2875
- rawTextTag.tag,
2876
- provenance,
2877
- supportingDeclarations,
2878
- options
2879
- );
2880
- if (compilerDiagnostics.length > 0) {
2881
- pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
2882
- continue;
2883
- }
2884
- const constraintNode = (0, import_internal2.parseConstraintTagValue)(
2885
- rawTextTag.tag.normalizedTagName,
2886
- text,
2887
- provenance,
2888
- sharedTagValueOptions(options)
2889
- );
2890
- if (constraintNode) {
2891
- constraints.push(constraintNode);
2892
- }
2893
- }
2894
- }
2895
2816
  for (const [tagName, fallbacks] of rawTextFallbacks) {
2896
2817
  for (const fallback of fallbacks) {
2897
2818
  const text = fallback.text.trim();
2898
2819
  if (text === "") continue;
2899
2820
  const provenance = fallback.provenance;
2900
2821
  if (tagName === "defaultValue") {
2901
- const defaultValueNode = (0, import_internal2.parseDefaultValueTagValue)(text, provenance);
2902
- annotations.push(defaultValueNode);
2822
+ annotations.push((0, import_internal2.parseDefaultValueTagValue)(text, provenance));
2903
2823
  continue;
2904
2824
  }
2905
- const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
2906
- node,
2907
- sourceFile,
2825
+ processConstraintTag(
2908
2826
  tagName,
2827
+ text,
2909
2828
  null,
2910
2829
  provenance,
2830
+ node,
2831
+ sourceFile,
2911
2832
  supportingDeclarations,
2912
- options
2913
- );
2914
- if (compilerDiagnostics.length > 0) {
2915
- pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
2916
- continue;
2917
- }
2918
- const constraintNode = (0, import_internal2.parseConstraintTagValue)(
2919
- tagName,
2920
- text,
2921
- provenance,
2922
- sharedTagValueOptions(options)
2833
+ options,
2834
+ constraints,
2835
+ diagnostics
2923
2836
  );
2924
- if (constraintNode) {
2925
- constraints.push(constraintNode);
2926
- }
2927
2837
  }
2928
2838
  }
2929
2839
  const result = { constraints, annotations, diagnostics };
@@ -2941,8 +2851,8 @@ function extractDisplayNameMetadata(node) {
2941
2851
  if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) continue;
2942
2852
  const commentText = sourceText.substring(range.pos, range.end);
2943
2853
  if (!commentText.startsWith("/**")) continue;
2944
- const parsed = (0, import_internal2.parseCommentBlock)(commentText);
2945
- for (const tag of parsed.tags) {
2854
+ const unified = (0, import_internal2.parseUnifiedComment)(commentText);
2855
+ for (const tag of unified.tags) {
2946
2856
  if (tag.normalizedTagName !== "displayName") {
2947
2857
  continue;
2948
2858
  }
@@ -2961,56 +2871,11 @@ function extractDisplayNameMetadata(node) {
2961
2871
  memberDisplayNames
2962
2872
  };
2963
2873
  }
2964
- function extractBlockText(block) {
2965
- return extractPlainText(block.content);
2966
- }
2967
- function extractPlainText(node) {
2968
- let result = "";
2969
- if (node instanceof import_tsdoc.DocExcerpt) {
2970
- return node.content.toString();
2971
- }
2972
- if (node instanceof import_tsdoc.DocPlainText) {
2973
- return node.text;
2974
- }
2975
- if (node instanceof import_tsdoc.DocSoftBreak) {
2976
- return " ";
2977
- }
2978
- if (typeof node.getChildNodes === "function") {
2979
- for (const child of node.getChildNodes()) {
2980
- result += extractPlainText(child);
2981
- }
2982
- }
2983
- return result;
2984
- }
2985
- function choosePreferredPayloadText(primary, fallback) {
2986
- const preferred = primary.trim();
2987
- const alternate = fallback.trim();
2988
- if (preferred === "") return alternate;
2989
- if (alternate === "") return preferred;
2990
- if (alternate.includes("\n")) return alternate;
2991
- if (alternate.length > preferred.length && alternate.startsWith(preferred)) {
2992
- return alternate;
2993
- }
2994
- return preferred;
2995
- }
2996
- function getSharedPayloadText(tag, commentText, commentOffset) {
2997
- if (tag.payloadSpan === null) {
2998
- return "";
2999
- }
3000
- return (0, import_internal2.sliceCommentSpan)(commentText, tag.payloadSpan, {
3001
- offset: commentOffset
3002
- }).trim();
3003
- }
3004
- function getBestBlockPayloadText(tag, commentText, commentOffset, block) {
3005
- const sharedText = tag === null ? "" : getSharedPayloadText(tag, commentText, commentOffset);
3006
- const blockText = extractBlockText(block).replace(/\s+/g, " ").trim();
3007
- return choosePreferredPayloadText(sharedText, blockText);
3008
- }
3009
2874
  function collectRawTextFallbacks(node, file) {
3010
2875
  const fallbacks = /* @__PURE__ */ new Map();
3011
2876
  for (const tag of ts.getJSDocTags(node)) {
3012
2877
  const tagName = (0, import_internals4.normalizeConstraintTagName)(tag.tagName.text);
3013
- if (!TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
2878
+ if (!import_internal2.TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
3014
2879
  const commentText = getTagCommentText(tag)?.trim() ?? "";
3015
2880
  if (commentText === "") continue;
3016
2881
  const entries = fallbacks.get(tagName) ?? [];
@@ -3119,6 +2984,31 @@ function isObjectType(type) {
3119
2984
  function isIntersectionType(type) {
3120
2985
  return !!(type.flags & ts3.TypeFlags.Intersection);
3121
2986
  }
2987
+ function isIntegerBrandedType(type) {
2988
+ if (!type.isIntersection()) {
2989
+ return false;
2990
+ }
2991
+ const hasNumberBase = type.types.some(
2992
+ (member) => !!(member.flags & ts3.TypeFlags.Number)
2993
+ );
2994
+ if (!hasNumberBase) {
2995
+ return false;
2996
+ }
2997
+ return type.getProperties().some((prop) => {
2998
+ const declaration = prop.valueDeclaration ?? prop.declarations?.[0];
2999
+ if (declaration === void 0) {
3000
+ return false;
3001
+ }
3002
+ if (!ts3.isPropertySignature(declaration) && !ts3.isPropertyDeclaration(declaration)) {
3003
+ return false;
3004
+ }
3005
+ const name = declaration.name;
3006
+ if (!ts3.isComputedPropertyName(name)) {
3007
+ return false;
3008
+ }
3009
+ return ts3.isIdentifier(name.expression) && name.expression.text === "__integerBrand";
3010
+ });
3011
+ }
3122
3012
  function isResolvableObjectLikeAliasTypeNode(typeNode) {
3123
3013
  if (ts3.isParenthesizedTypeNode(typeNode)) {
3124
3014
  return isResolvableObjectLikeAliasTypeNode(typeNode.type);
@@ -4244,6 +4134,9 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
4244
4134
  if (primitiveAlias) {
4245
4135
  return primitiveAlias;
4246
4136
  }
4137
+ if (isIntegerBrandedType(type)) {
4138
+ return { kind: "primitive", primitiveKind: "integer" };
4139
+ }
4247
4140
  if (type.flags & ts3.TypeFlags.String) {
4248
4141
  return { kind: "primitive", primitiveKind: "string" };
4249
4142
  }
@@ -4346,7 +4239,7 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
4346
4239
  return { kind: "primitive", primitiveKind: "string" };
4347
4240
  }
4348
4241
  function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4349
- if (!(type.flags & (ts3.TypeFlags.String | ts3.TypeFlags.Number | ts3.TypeFlags.BigInt | ts3.TypeFlags.BigIntLiteral | ts3.TypeFlags.Boolean | ts3.TypeFlags.Null))) {
4242
+ if (!(type.flags & (ts3.TypeFlags.String | ts3.TypeFlags.Number | ts3.TypeFlags.BigInt | ts3.TypeFlags.BigIntLiteral | ts3.TypeFlags.Boolean | ts3.TypeFlags.Null)) && !isIntegerBrandedType(type)) {
4350
4243
  return null;
4351
4244
  }
4352
4245
  const aliasDecl = type.aliasSymbol?.declarations?.find(ts3.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
@@ -4432,6 +4325,9 @@ function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiti
4432
4325
  visitedAliases
4433
4326
  );
4434
4327
  }
4328
+ if (isIntegerBrandedType(type)) {
4329
+ return { kind: "primitive", primitiveKind: "integer" };
4330
+ }
4435
4331
  if (type.flags & ts3.TypeFlags.String) {
4436
4332
  return { kind: "primitive", primitiveKind: "string" };
4437
4333
  }
@@ -4655,7 +4551,7 @@ function typeNodeContainsReference(type, targetName) {
4655
4551
  }
4656
4552
  }
4657
4553
  function shouldEmitResolvedObjectProperty(property, declaration) {
4658
- if (property.name.startsWith("__@")) {
4554
+ if (property.name.startsWith("__")) {
4659
4555
  return false;
4660
4556
  }
4661
4557
  if (declaration !== void 0 && "name" in declaration && declaration.name !== void 0) {
@@ -5646,7 +5542,9 @@ function generateSchemasFromClass(options) {
5646
5542
  classDecl,
5647
5543
  ctx.checker,
5648
5544
  options.filePath,
5545
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5649
5546
  options.extensionRegistry,
5547
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5650
5548
  options.metadata,
5651
5549
  options.discriminator
5652
5550
  );
@@ -5654,9 +5552,13 @@ function generateSchemasFromClass(options) {
5654
5552
  analysis,
5655
5553
  { file: options.filePath },
5656
5554
  {
5555
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5657
5556
  extensionRegistry: options.extensionRegistry,
5557
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5658
5558
  metadata: options.metadata,
5559
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5659
5560
  enumSerialization: options.enumSerialization,
5561
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5660
5562
  vendorPrefix: options.vendorPrefix
5661
5563
  }
5662
5564
  );
@@ -5703,7 +5605,12 @@ function generateSchemasDetailedInternal(options) {
5703
5605
  diagnostics: [createProgramContextFailureDiagnostic(options.filePath, error)]
5704
5606
  };
5705
5607
  }
5706
- return generateSchemasFromDetailedProgramContext(ctx, options.filePath, options.typeName, options);
5608
+ return generateSchemasFromDetailedProgramContext(
5609
+ ctx,
5610
+ options.filePath,
5611
+ options.typeName,
5612
+ options
5613
+ );
5707
5614
  }
5708
5615
  function generateSchemasFromProgramDetailed(options) {
5709
5616
  return generateSchemasFromProgram({
@@ -5721,7 +5628,12 @@ function generateSchemasFromProgramDetailedInternal(options) {
5721
5628
  diagnostics: [createProgramContextFailureDiagnostic(options.filePath, error)]
5722
5629
  };
5723
5630
  }
5724
- return generateSchemasFromDetailedProgramContext(ctx, options.filePath, options.typeName, options);
5631
+ return generateSchemasFromDetailedProgramContext(
5632
+ ctx,
5633
+ options.filePath,
5634
+ options.typeName,
5635
+ options
5636
+ );
5725
5637
  }
5726
5638
  function generateSchemasBatch(options) {
5727
5639
  const contextCache = /* @__PURE__ */ new Map();
@@ -5765,13 +5677,27 @@ function generateSchemasBatchFromProgram(options) {
5765
5677
  );
5766
5678
  });
5767
5679
  }
5680
+ function resolveOptions(options) {
5681
+ const configRegistry = options.config?.extensions !== void 0 ? createExtensionRegistry(options.config.extensions) : void 0;
5682
+ return {
5683
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5684
+ extensionRegistry: options.extensionRegistry ?? configRegistry,
5685
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5686
+ vendorPrefix: options.vendorPrefix ?? options.config?.vendorPrefix,
5687
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5688
+ enumSerialization: options.enumSerialization ?? options.config?.enumSerialization,
5689
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5690
+ metadata: options.metadata ?? options.config?.metadata
5691
+ };
5692
+ }
5768
5693
  function generateSchemasFromDetailedProgramContext(ctx, filePath, typeName, options) {
5694
+ const resolved = resolveOptions(options);
5769
5695
  const analysisResult = analyzeNamedTypeToIRFromProgramContextDetailed(
5770
5696
  ctx,
5771
5697
  filePath,
5772
5698
  typeName,
5773
- options.extensionRegistry,
5774
- options.metadata,
5699
+ resolved.extensionRegistry,
5700
+ resolved.metadata,
5775
5701
  options.discriminator
5776
5702
  );
5777
5703
  if (!analysisResult.ok) {
@@ -5784,10 +5710,10 @@ function generateSchemasFromDetailedProgramContext(ctx, filePath, typeName, opti
5784
5710
  analysisResult.analysis,
5785
5711
  { file: filePath },
5786
5712
  {
5787
- extensionRegistry: options.extensionRegistry,
5788
- metadata: options.metadata,
5789
- enumSerialization: options.enumSerialization,
5790
- vendorPrefix: options.vendorPrefix
5713
+ extensionRegistry: resolved.extensionRegistry,
5714
+ metadata: resolved.metadata,
5715
+ enumSerialization: resolved.enumSerialization,
5716
+ vendorPrefix: resolved.vendorPrefix
5791
5717
  }
5792
5718
  );
5793
5719
  }
@@ -5924,6 +5850,7 @@ function omitApiName(metadata) {
5924
5850
  }
5925
5851
  function enforceRequiredMetadata(metadata, declarationKind, logicalName, options) {
5926
5852
  const declarationPolicy = getDeclarationMetadataPolicy(
5853
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5927
5854
  normalizeMetadataPolicy(options.metadata),
5928
5855
  declarationKind
5929
5856
  );
@@ -5998,6 +5925,7 @@ function toStandaloneJsonSchema(root, typeRegistry, options) {
5998
5925
  provenance: syntheticField.provenance
5999
5926
  },
6000
5927
  {
5928
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6001
5929
  policy: normalizeMetadataPolicy(options?.metadata),
6002
5930
  surface: "tsdoc",
6003
5931
  rootLogicalName: root.name
@@ -6006,8 +5934,11 @@ function toStandaloneJsonSchema(root, typeRegistry, options) {
6006
5934
  const schema = generateJsonSchemaFromIR(
6007
5935
  ir,
6008
5936
  {
5937
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6009
5938
  extensionRegistry: options?.extensionRegistry,
5939
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6010
5940
  enumSerialization: options?.enumSerialization,
5941
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6011
5942
  vendorPrefix: options?.vendorPrefix
6012
5943
  }
6013
5944
  );
@@ -6033,9 +5964,13 @@ function generateSchemasFromAnalysis(analysis, filePath, options) {
6033
5964
  analysis,
6034
5965
  { file: filePath },
6035
5966
  {
5967
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6036
5968
  extensionRegistry: options?.extensionRegistry,
5969
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6037
5970
  enumSerialization: options?.enumSerialization,
5971
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6038
5972
  metadata: options?.metadata,
5973
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6039
5974
  vendorPrefix: options?.vendorPrefix
6040
5975
  }
6041
5976
  ),
@@ -6060,7 +5995,9 @@ function generateSchemasFromResolvedType(options, skipNamedDeclaration = false,
6060
5995
  typeRegistry,
6061
5996
  /* @__PURE__ */ new Set(),
6062
5997
  options.sourceNode,
5998
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6063
5999
  createAnalyzerMetadataPolicy(options.metadata, options.discriminator),
6000
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6064
6001
  options.extensionRegistry,
6065
6002
  diagnostics
6066
6003
  );
@@ -6109,7 +6046,9 @@ function generateSchemasFromDeclaration(options) {
6109
6046
  options.declaration,
6110
6047
  options.context.checker,
6111
6048
  filePath,
6049
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6112
6050
  options.extensionRegistry,
6051
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6113
6052
  options.metadata,
6114
6053
  options.discriminator
6115
6054
  ),
@@ -6123,7 +6062,9 @@ function generateSchemasFromDeclaration(options) {
6123
6062
  options.declaration,
6124
6063
  options.context.checker,
6125
6064
  filePath,
6065
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6126
6066
  options.extensionRegistry,
6067
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6127
6068
  options.metadata,
6128
6069
  options.discriminator
6129
6070
  ),
@@ -6136,7 +6077,9 @@ function generateSchemasFromDeclaration(options) {
6136
6077
  options.declaration,
6137
6078
  options.context.checker,
6138
6079
  filePath,
6080
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6139
6081
  options.extensionRegistry,
6082
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6140
6083
  options.metadata,
6141
6084
  options.discriminator
6142
6085
  );
@@ -6147,7 +6090,9 @@ function generateSchemasFromDeclaration(options) {
6147
6090
  options.declaration,
6148
6091
  options.context.checker,
6149
6092
  filePath,
6093
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6150
6094
  options.extensionRegistry,
6095
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6151
6096
  options.metadata
6152
6097
  );
6153
6098
  if (aliasRootInfo.diagnostics.length > 0) {
@@ -6202,7 +6147,9 @@ function resolveDeclarationMetadata(options) {
6202
6147
  const analysis = (0, import_internal5.analyzeMetadataForNodeWithChecker)({
6203
6148
  checker: options.context.checker,
6204
6149
  node: options.declaration,
6150
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6205
6151
  metadata: options.metadata,
6152
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6206
6153
  extensions: options.extensionRegistry?.extensions,
6207
6154
  buildContext: options.context
6208
6155
  });
@@ -6239,7 +6186,9 @@ function buildMixedAuthoringSchemas(options) {
6239
6186
  const analysis = analyzeNamedTypeToIR(
6240
6187
  filePath,
6241
6188
  typeName,
6189
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6242
6190
  schemaOptions.extensionRegistry,
6191
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6243
6192
  schemaOptions.metadata,
6244
6193
  schemaOptions.discriminator
6245
6194
  );
@@ -6247,6 +6196,7 @@ function buildMixedAuthoringSchemas(options) {
6247
6196
  const ir = canonicalizeTSDoc(
6248
6197
  composedAnalysis,
6249
6198
  { file: filePath },
6199
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6250
6200
  schemaOptions.metadata !== void 0 ? { metadata: schemaOptions.metadata } : void 0
6251
6201
  );
6252
6202
  return {