@openpkg-ts/sdk 0.54.8 → 0.54.10
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.d.ts +39 -5
- package/dist/index.js +710 -450
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1202,6 +1202,12 @@ import { assertSpec, getAvailableVersions, getValidationErrors, LATEST_VERSION,
|
|
|
1202
1202
|
import { SpecType as SpecType4 } from "@openpkg-ts/spec";
|
|
1203
1203
|
import ts2 from "typescript";
|
|
1204
1204
|
import ts from "typescript";
|
|
1205
|
+
interface ExpansionBudget {
|
|
1206
|
+
/** Export name, or `type <id>` for a registered type. */
|
|
1207
|
+
owner: string;
|
|
1208
|
+
ops: number;
|
|
1209
|
+
exceeded: boolean;
|
|
1210
|
+
}
|
|
1205
1211
|
interface SerializerContext {
|
|
1206
1212
|
typeChecker: ts.TypeChecker;
|
|
1207
1213
|
program: ts.Program;
|
|
@@ -1214,6 +1220,8 @@ interface SerializerContext {
|
|
|
1214
1220
|
visitedTypes: Set<ts.Type>;
|
|
1215
1221
|
/** Permanent "already processed" set for registerReferencedTypes */
|
|
1216
1222
|
registeredTypes: Set<ts.Type>;
|
|
1223
|
+
/** Generic union/intersection alias being built at its own declaration: decomposed once, referenced everywhere else. */
|
|
1224
|
+
aliasBody?: ts.Type;
|
|
1217
1225
|
/** Flag to indicate we're processing tuple elements - skip Array prototype methods */
|
|
1218
1226
|
inTupleElement?: boolean;
|
|
1219
1227
|
/** Include private/protected class members (default: false) */
|
|
@@ -1242,12 +1250,22 @@ interface SerializerContext {
|
|
|
1242
1250
|
idOwner: Map<string, string>;
|
|
1243
1251
|
/** Workspace package name → dir, used to package-scope colliding type ids. */
|
|
1244
1252
|
workspacePackages: ReadonlyMap<string, string>;
|
|
1245
|
-
/**
|
|
1253
|
+
/**
|
|
1254
|
+
* Schema-build steps of the or registered type being built. Each gets
|
|
1255
|
+
* its own budget, so what one spends never changes what another emits: the
|
|
1256
|
+
* same comes out the same in a full run and under `only`.
|
|
1257
|
+
*/
|
|
1258
|
+
budget: ExpansionBudget;
|
|
1259
|
+
/** Cap on one budget's steps; past this, that owner's deep parts emit x-ts-type text. */
|
|
1260
|
+
maxBudgetOps: number;
|
|
1261
|
+
/** Structural schema-build steps taken this extract, all budgets together. */
|
|
1246
1262
|
schemaOps: number;
|
|
1247
|
-
/**
|
|
1263
|
+
/** Safety ceiling on schemaOps against runaway expansion; past this, everything emits text. */
|
|
1248
1264
|
maxSchemaOps: number;
|
|
1249
|
-
/** True once
|
|
1265
|
+
/** True once any schema degraded to text (a budget ran out, or a type defers expansion). */
|
|
1250
1266
|
budgetExceeded: boolean;
|
|
1267
|
+
/** Owners whose budget ran out, in the order they did. */
|
|
1268
|
+
exhaustedBudgets: string[];
|
|
1251
1269
|
}
|
|
1252
1270
|
declare class TypeRegistry {
|
|
1253
1271
|
private types;
|
|
@@ -1845,8 +1863,9 @@ import { SpecExport as SpecExport14 } from "@openpkg-ts/spec";
|
|
|
1845
1863
|
import ts11 from "typescript";
|
|
1846
1864
|
/**
|
|
1847
1865
|
* @param declaredType - Written annotation of the variable holding `node`; when callable it supplies the signatures.
|
|
1866
|
+
* @param jsdocNode - Statement carrying the docs when that is not `node` (`() => {}`).
|
|
1848
1867
|
*/
|
|
1849
|
-
declare function serializeFunctionExport(node: ts11.FunctionDeclaration | ts11.ArrowFunction | ts11.FunctionExpression, ctx: SerializerContext, nameOverride?: string, declaredType?: ts11.TypeNode): SpecExport14 | null;
|
|
1868
|
+
declare function serializeFunctionExport(node: ts11.FunctionDeclaration | ts11.ArrowFunction | ts11.FunctionExpression, ctx: SerializerContext, nameOverride?: string, declaredType?: ts11.TypeNode, jsdocNode?: ts11.Node): SpecExport14 | null;
|
|
1850
1869
|
import { SpecExport as SpecExport15 } from "@openpkg-ts/spec";
|
|
1851
1870
|
import ts12 from "typescript";
|
|
1852
1871
|
declare function serializeInterface(node: ts12.InterfaceDeclaration, ctx: SerializerContext): SpecExport15 | null;
|
|
@@ -1904,6 +1923,16 @@ declare function typeNodeOfSignature(sig: ts16.Signature): ts16.TypeNode | undef
|
|
|
1904
1923
|
*/
|
|
1905
1924
|
declare function buildSchemaFromTypeNode(node: ts16.TypeNode, checker: ts16.TypeChecker, ctx?: SerializerContext): SpecSchema5;
|
|
1906
1925
|
/**
|
|
1926
|
+
* Schema arms for the bases of a class or interface the checker cannot see
|
|
1927
|
+
* into (`any`: an unresolved import, an alias over a missing global). Such a
|
|
1928
|
+
* base contributes members nobody can list, so the own shape must not read as
|
|
1929
|
+
* closed: callers emit `allOf: [own shape, ...arms]`, the form an alias
|
|
1930
|
+
* intersection with the same arm (`{...} & Config`) already takes.
|
|
1931
|
+
*/
|
|
1932
|
+
declare function openHeritageArms(declarations: readonly ts16.Declaration[], checker: ts16.TypeChecker, ctx?: SerializerContext): SpecSchema5[];
|
|
1933
|
+
/** `allOf` of a shape and the open heritage arms; the shape alone when there are none. */
|
|
1934
|
+
declare function withOpenHeritage(schema: SpecSchema5, arms: readonly SpecSchema5[]): SpecSchema5;
|
|
1935
|
+
/**
|
|
1907
1936
|
* Strip `undefined` from a union type when optionality is already expressed
|
|
1908
1937
|
* elsewhere (`required: false`, `flags.optional`). Used for both schema shape
|
|
1909
1938
|
* and x-ts-type text so neither re-encodes optionality as `| undefined`.
|
|
@@ -1980,6 +2009,11 @@ declare function ensureNonEmptySchema(schema: SpecSchema5, type: ts16.Type, chec
|
|
|
1980
2009
|
*/
|
|
1981
2010
|
declare function buildSchema(type: ts16.Type, checker: ts16.TypeChecker, ctx?: SerializerContext, typeNode?: ts16.TypeNode): SpecSchema5;
|
|
1982
2011
|
/**
|
|
2012
|
+
* Schema of a named type at its own declaration. A generic union/intersection
|
|
2013
|
+
* alias is decomposed here and nowhere else; every use of it is a `$ref`.
|
|
2014
|
+
*/
|
|
2015
|
+
declare function buildAliasBodySchema(type: ts16.Type, checker: ts16.TypeChecker, ctx: SerializerContext): SpecSchema5;
|
|
2016
|
+
/**
|
|
1983
2017
|
* Build schema for function types
|
|
1984
2018
|
*/
|
|
1985
2019
|
declare function buildFunctionSchema(callSignatures: readonly ts16.Signature[], checker: ts16.TypeChecker, ctx: SerializerContext | undefined): SpecSchema5;
|
|
@@ -2023,4 +2057,4 @@ declare function findDiscriminatorProperty(unionTypes: ts16.Type[], checker: ts1
|
|
|
2023
2057
|
import ts17 from "typescript";
|
|
2024
2058
|
declare function isExported(node: ts17.Node): boolean;
|
|
2025
2059
|
declare function getNodeName(node: ts17.Node): string | undefined;
|
|
2026
|
-
export { zodAdapter, writtenTypeText, withDescription2 as withDescription, withDeprecated, validateSpec, valibotAdapter, typeboxAdapter, typeNodeOfSignature, typeNodeDefersExpansion, toToolSchema, toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toPagefindRecords2 as toPagefindRecords, toNavigation2 as toNavigation, toMarkdown2 as toMarkdown, toJsonSchema, toJSONString, toJSON2 as toJSON, toHTML2 as toHTML, toFumadocsMetaJSON, toDocusaurusSidebarJS, toAlgoliaRecords2 as toAlgoliaRecords, stripUndefinedFromType, stripTsExtensions, sortByName, shouldEmitAliasTypeText, serializeVariable, serializeTypeAlias, serializeInterface, serializeFunctionExport, serializeEnum, serializeClass, scrubImportQualifiers, schemasAreEqual, schemaIsAny, resolveTypeRef, resolveTarget, resolveExportTarget, resolveCompiledPath, resolveAliasSymbol, renderTypeText, registerReferencedTypes, registerAdapter, recommendSemverBump, query, pickEntry, parseGithubRepo, normalizeType, normalizeSchema, normalizeMembers, normalizeExport, mergeConfig, loadSpec, loadConfig, listExports, isTypeReference, isTypeOnlyExport, isSymbolDeprecated, isStandardJSONSchema, isSchemaType, isRemoteInput, isReadonlyPropertySymbol, isPureRefSchema, isProperty, isPrimitiveName, isPathLikeInput, isMethod, isExported, isEntryFilePath, isDeferredMappedOrConditional, isBuiltinSymbol, isBuiltinGeneric, isAnonymous, groupByVisibility, getValidationErrors, getTypeOrigin, getSourceLocation, getProperties, getParamDescription, getNonNullableType, getNodeName, getMethods, getMemberBadges, getJSDocComment, getExportKind, getExport2 as getExport, getAvailableVersions, toMarkdown2 as generateDocs, formatTypeParameters, formatSchema, formatReturnType, formatParameters, formatMappedType, formatConditionalType, formatBadges, findWorkspaceRoot, findDiscriminatorProperty, findAdapter, filterSpec, extractTypeParameters, extractStandardSchemasFromTs, extractStandardSchemasFromProject, extractStandardSchemas, extractSpec, extractSchemaType, extractParameters, extract, exportToMarkdown, exportToJsonSchema, ensureNonEmptySchema, diffSpec2 as diffSpecs, diffSpec, detectTsRuntime, deduplicateSchemas, decoratePropertySchema, declaredTypeNode, createProgram, createDocs, cloneRemote, categorizeBreakingChanges, catalogPackages, calculateNextVersion, bundleRefs, buildSignatureString, buildSchemaFromTypeNode, buildSchema, buildObjectSchema, buildFunctionSchema, assertSpec, asStandardSchema, arktypeAdapter, TypeRegistry, TypeReference2 as TypeReference, TsRuntime, ToolSchemaResult, ToolSchemaProvider, ToToolSchemaOptions, ToJsonSchemaOptions, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, StandardJSONSchemaTarget, StandardJSONSchemaOptions, SpecMappedType, SpecError, SpecDiff, SpecConditionalType, SkippedExportDetail, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SerializerContext, SemverRecommendation, SemverBump, SearchRecord, SearchOptions, SearchIndex, SchemaVersion, SchemaExtractionResult, SchemaAdapter, STRING_PROTOTYPE_METHODS, ResolveTargetResult, ResolveTargetOptions, ResolveOk, ResolveNeedsBuild, ResolveExplicit, ResolveEmpty, ResolveAmbiguous, QueryBuilder, ProjectExtractionOutput, ProjectExtractionInfo, ProgramResult, ProgramOptions, PagefindRecord, PackageRecord, PRIMITIVES, OpenpkgConfig, NormalizeOptions, NavOptions, NavItem, NavGroup, NavFormat, NUMBER_PROTOTYPE_METHODS, MemberChangeInfo, MarkdownOptions, LoadOptions, ListExportsResult, ListExportsOptions, LATEST_VERSION, JsonSchemaDocument, JSONSchema, JSONOptions, HTMLOptions, GroupBy, GetExportResult, GetExportOptions, GenericNav, FumadocsMetaItem, FumadocsMeta, FormatSchemaOptions, ForgottenExport, FilterResult, FilterCriteria, ExtractionWarningCode, ExtractionWarning, ExtractStandardSchemasOptions, ExtractResult, ExtractOptions, ExtractFromProjectOptions, ExternalsConfig, ExportVerification, ExportTracker, ExportMarkdownOptions, ExportItem, DocusaurusSidebarItem, DocusaurusSidebar, DocsInstance, Diagnostic, CloneFn, CategorizedBreaking, CacheManagerOptions, CacheManager, CONFIG_FILENAME, BundleResult, BundleOptions, BuiltinSchema, BreakingSeverity, BUILTIN_TYPE_SCHEMAS, AsStandardSchemaOptions, AlgoliaRecord, ARRAY_PROTOTYPE_METHODS };
|
|
2060
|
+
export { zodAdapter, writtenTypeText, withOpenHeritage, withDescription2 as withDescription, withDeprecated, validateSpec, valibotAdapter, typeboxAdapter, typeNodeOfSignature, typeNodeDefersExpansion, toToolSchema, toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toPagefindRecords2 as toPagefindRecords, toNavigation2 as toNavigation, toMarkdown2 as toMarkdown, toJsonSchema, toJSONString, toJSON2 as toJSON, toHTML2 as toHTML, toFumadocsMetaJSON, toDocusaurusSidebarJS, toAlgoliaRecords2 as toAlgoliaRecords, stripUndefinedFromType, stripTsExtensions, sortByName, shouldEmitAliasTypeText, serializeVariable, serializeTypeAlias, serializeInterface, serializeFunctionExport, serializeEnum, serializeClass, scrubImportQualifiers, schemasAreEqual, schemaIsAny, resolveTypeRef, resolveTarget, resolveExportTarget, resolveCompiledPath, resolveAliasSymbol, renderTypeText, registerReferencedTypes, registerAdapter, recommendSemverBump, query, pickEntry, parseGithubRepo, openHeritageArms, normalizeType, normalizeSchema, normalizeMembers, normalizeExport, mergeConfig, loadSpec, loadConfig, listExports, isTypeReference, isTypeOnlyExport, isSymbolDeprecated, isStandardJSONSchema, isSchemaType, isRemoteInput, isReadonlyPropertySymbol, isPureRefSchema, isProperty, isPrimitiveName, isPathLikeInput, isMethod, isExported, isEntryFilePath, isDeferredMappedOrConditional, isBuiltinSymbol, isBuiltinGeneric, isAnonymous, groupByVisibility, getValidationErrors, getTypeOrigin, getSourceLocation, getProperties, getParamDescription, getNonNullableType, getNodeName, getMethods, getMemberBadges, getJSDocComment, getExportKind, getExport2 as getExport, getAvailableVersions, toMarkdown2 as generateDocs, formatTypeParameters, formatSchema, formatReturnType, formatParameters, formatMappedType, formatConditionalType, formatBadges, findWorkspaceRoot, findDiscriminatorProperty, findAdapter, filterSpec, extractTypeParameters, extractStandardSchemasFromTs, extractStandardSchemasFromProject, extractStandardSchemas, extractSpec, extractSchemaType, extractParameters, extract, exportToMarkdown, exportToJsonSchema, ensureNonEmptySchema, diffSpec2 as diffSpecs, diffSpec, detectTsRuntime, deduplicateSchemas, decoratePropertySchema, declaredTypeNode, createProgram, createDocs, cloneRemote, categorizeBreakingChanges, catalogPackages, calculateNextVersion, bundleRefs, buildSignatureString, buildSchemaFromTypeNode, buildSchema, buildObjectSchema, buildFunctionSchema, buildAliasBodySchema, assertSpec, asStandardSchema, arktypeAdapter, TypeRegistry, TypeReference2 as TypeReference, TsRuntime, ToolSchemaResult, ToolSchemaProvider, ToToolSchemaOptions, ToJsonSchemaOptions, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, StandardJSONSchemaTarget, StandardJSONSchemaOptions, SpecMappedType, SpecError, SpecDiff, SpecConditionalType, SkippedExportDetail, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SerializerContext, SemverRecommendation, SemverBump, SearchRecord, SearchOptions, SearchIndex, SchemaVersion, SchemaExtractionResult, SchemaAdapter, STRING_PROTOTYPE_METHODS, ResolveTargetResult, ResolveTargetOptions, ResolveOk, ResolveNeedsBuild, ResolveExplicit, ResolveEmpty, ResolveAmbiguous, QueryBuilder, ProjectExtractionOutput, ProjectExtractionInfo, ProgramResult, ProgramOptions, PagefindRecord, PackageRecord, PRIMITIVES, OpenpkgConfig, NormalizeOptions, NavOptions, NavItem, NavGroup, NavFormat, NUMBER_PROTOTYPE_METHODS, MemberChangeInfo, MarkdownOptions, LoadOptions, ListExportsResult, ListExportsOptions, LATEST_VERSION, JsonSchemaDocument, JSONSchema, JSONOptions, HTMLOptions, GroupBy, GetExportResult, GetExportOptions, GenericNav, FumadocsMetaItem, FumadocsMeta, FormatSchemaOptions, ForgottenExport, FilterResult, FilterCriteria, ExtractionWarningCode, ExtractionWarning, ExtractStandardSchemasOptions, ExtractResult, ExtractOptions, ExtractFromProjectOptions, ExternalsConfig, ExportVerification, ExportTracker, ExportMarkdownOptions, ExportItem, DocusaurusSidebarItem, DocusaurusSidebar, DocsInstance, Diagnostic, CloneFn, CategorizedBreaking, CacheManagerOptions, CacheManager, CONFIG_FILENAME, BundleResult, BundleOptions, BuiltinSchema, BreakingSeverity, BUILTIN_TYPE_SCHEMAS, AsStandardSchemaOptions, AlgoliaRecord, ARRAY_PROTOTYPE_METHODS };
|