@openpkg-ts/sdk 0.45.0 → 0.47.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.
- package/dist/index.d.ts +187 -98
- package/dist/index.js +783 -82
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -17,8 +17,6 @@ interface ExtractOptions {
|
|
|
17
17
|
maxExternalTypeDepth?: number;
|
|
18
18
|
resolveExternalTypes?: boolean;
|
|
19
19
|
schemaExtraction?: "static" | "hybrid";
|
|
20
|
-
/** Target JSON Schema dialect for runtime schema extraction */
|
|
21
|
-
schemaTarget?: "draft-2020-12" | "draft-07" | "openapi-3.0";
|
|
22
20
|
/** Include $schema URL in output */
|
|
23
21
|
includeSchema?: boolean;
|
|
24
22
|
/** Only extract these exports (supports * wildcards) */
|
|
@@ -36,10 +34,20 @@ interface ExtractOptions {
|
|
|
36
34
|
/** Max properties to serialize per object type (default: 500) */
|
|
37
35
|
maxProperties?: number;
|
|
38
36
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
37
|
+
* Controls how types from outside the entry package are handled.
|
|
38
|
+
*
|
|
39
|
+
* By default, ambient/global types (lib.dom, bun-types) and non-workspace
|
|
40
|
+
* `node_modules` packages register as **opaque external stubs** — a `types[]`
|
|
41
|
+
* entry with `external: true` and an `x-ts-type` name, so `$ref`s stay
|
|
42
|
+
* resolvable without inlining a foreign package's full (and
|
|
43
|
+
* environment-dependent) member surface. Referenced-but-not-exported types
|
|
44
|
+
* from the entry package and workspace siblings always expand fully.
|
|
45
|
+
*
|
|
46
|
+
* - `true` → fully expand every referenced package (restores pre-stub
|
|
47
|
+
* behavior; output becomes environment-dependent for global types)
|
|
48
|
+
* - `string[]` → fully expand the listed packages (plus workspace siblings)
|
|
49
|
+
* - `false` → disable the reachability-expansion pass entirely
|
|
50
|
+
* - default → workspace siblings only; everything else stubbed
|
|
43
51
|
*/
|
|
44
52
|
followExternal?: boolean | string[];
|
|
45
53
|
/** Callback when properties are truncated */
|
|
@@ -1157,6 +1165,7 @@ declare function listExports(options: ListExportsOptions): Promise<ListExportsRe
|
|
|
1157
1165
|
* ```
|
|
1158
1166
|
*/
|
|
1159
1167
|
declare const extractSpec: (options: ExtractOptions) => Promise<ExtractResult>;
|
|
1168
|
+
import { assertSpec, getAvailableVersions, getValidationErrors, LATEST_VERSION, SchemaVersion, SpecError, validateSpec } from "@openpkg-ts/spec";
|
|
1160
1169
|
import { SpecType as SpecType4 } from "@openpkg-ts/spec";
|
|
1161
1170
|
import ts2 from "typescript";
|
|
1162
1171
|
import ts from "typescript";
|
|
@@ -1182,6 +1191,12 @@ interface SerializerContext {
|
|
|
1182
1191
|
maxProperties: number;
|
|
1183
1192
|
/** Callback when properties are truncated */
|
|
1184
1193
|
onTruncation?: (typeName: string, actual: number, limit: number) => void;
|
|
1194
|
+
/**
|
|
1195
|
+
* Location gate for structural expansion of referenced types. When set and
|
|
1196
|
+
* it rejects a symbol, the registry records an opaque external stub instead
|
|
1197
|
+
* of the full member surface. Unset → expand everything (unit-test contexts).
|
|
1198
|
+
*/
|
|
1199
|
+
shouldExpandExternal?: (symbol: ts.Symbol) => boolean;
|
|
1185
1200
|
}
|
|
1186
1201
|
declare class TypeRegistry {
|
|
1187
1202
|
private types;
|
|
@@ -1620,24 +1635,165 @@ declare const arktypeAdapter: SchemaAdapter;
|
|
|
1620
1635
|
declare const typeboxAdapter: SchemaAdapter;
|
|
1621
1636
|
declare const valibotAdapter: SchemaAdapter;
|
|
1622
1637
|
declare const zodAdapter: SchemaAdapter;
|
|
1623
|
-
import { SpecExport as SpecExport9 } from "@openpkg-ts/spec";
|
|
1638
|
+
import { OpenPkg as OpenPkg12, SpecExport as SpecExport9, SpecType as SpecType6 } from "@openpkg-ts/spec";
|
|
1639
|
+
interface AsStandardSchemaOptions {
|
|
1640
|
+
keepExtensions?: boolean;
|
|
1641
|
+
}
|
|
1642
|
+
/**
|
|
1643
|
+
* Wrap an export, type, or named subject as a StandardJSONSchemaV1 producer.
|
|
1644
|
+
* A string subject is resolved against the spec (exports first, then types).
|
|
1645
|
+
*/
|
|
1646
|
+
declare function asStandardSchema(subject: SpecExport9 | SpecType6 | string, spec: OpenPkg12, options?: AsStandardSchemaOptions): StandardJSONSchemaV1;
|
|
1647
|
+
import { SpecSchema as SpecSchema2 } from "@openpkg-ts/spec";
|
|
1648
|
+
/** Object-shaped SpecSchema (excludes the string shorthand) — spreadable. */
|
|
1649
|
+
type BuiltinSchema = Extract<SpecSchema2, object>;
|
|
1650
|
+
/**
|
|
1651
|
+
* Structural JSON Schema approximations for JS/TS built-in types.
|
|
1652
|
+
* Used when serializing references to lib types (which are never registered
|
|
1653
|
+
* in a spec's types[]) and by adapters mapping refs for external consumers.
|
|
1654
|
+
*/
|
|
1655
|
+
declare const BUILTIN_TYPE_SCHEMAS: Record<string, BuiltinSchema>;
|
|
1656
|
+
import { OpenPkg as OpenPkg13, SpecExport as SpecExport11, SpecType as SpecType8 } from "@openpkg-ts/spec";
|
|
1657
|
+
import { SpecExport as SpecExport10, SpecMember as SpecMember3, SpecSchema as SpecSchema3, SpecType as SpecType7 } from "@openpkg-ts/spec";
|
|
1658
|
+
/**
|
|
1659
|
+
* Options for schema normalization
|
|
1660
|
+
*/
|
|
1661
|
+
interface NormalizeOptions {
|
|
1662
|
+
/** Include $schema field in output */
|
|
1663
|
+
includeSchemaField?: boolean;
|
|
1664
|
+
}
|
|
1665
|
+
/**
|
|
1666
|
+
* JSON Schema 2020-12 compatible output type.
|
|
1667
|
+
* Uses Record<string, unknown> for flexibility since JSON Schema is highly polymorphic.
|
|
1668
|
+
*/
|
|
1669
|
+
type JSONSchema = Record<string, unknown>;
|
|
1670
|
+
/**
|
|
1671
|
+
* Normalize a SpecSchema to JSON Schema 2020-12.
|
|
1672
|
+
*
|
|
1673
|
+
* @param schema - The SpecSchema to normalize
|
|
1674
|
+
* @param options - Normalization options
|
|
1675
|
+
* @returns JSON Schema 2020-12 compatible schema
|
|
1676
|
+
*/
|
|
1677
|
+
declare function normalizeSchema(schema: SpecSchema3, options?: NormalizeOptions): JSONSchema;
|
|
1678
|
+
declare function normalizeExport(exp: SpecExport10, options?: NormalizeOptions): SpecExport10;
|
|
1679
|
+
/**
|
|
1680
|
+
* Normalize a SpecType, normalizing its schema and nested schemas.
|
|
1681
|
+
*
|
|
1682
|
+
* For interfaces and classes, this function will:
|
|
1683
|
+
* 1. Normalize any existing schema
|
|
1684
|
+
* 2. Normalize member schemas
|
|
1685
|
+
* 3. Generate a JSON Schema from members if members exist (populates `schema` field)
|
|
1686
|
+
*/
|
|
1687
|
+
declare function normalizeType(type: SpecType7, options?: NormalizeOptions): SpecType7;
|
|
1688
|
+
/**
|
|
1689
|
+
* Convert a members array to JSON Schema properties format.
|
|
1690
|
+
*
|
|
1691
|
+
* This function transforms the SpecMember[] array representation used by
|
|
1692
|
+
* interfaces/classes into a JSON Schema 2020-12 object schema with properties,
|
|
1693
|
+
* required array, and additionalProperties.
|
|
1694
|
+
*
|
|
1695
|
+
* Member Kind Mappings:
|
|
1696
|
+
* | Member Kind | JSON Schema Output |
|
|
1697
|
+
* |--------------------|-------------------------------------------------------|
|
|
1698
|
+
* | property | Direct schema in properties |
|
|
1699
|
+
* | method | { "x-ts-function": true, "x-ts-signatures": [...] } |
|
|
1700
|
+
* | getter | Schema in properties (read-only via extension) |
|
|
1701
|
+
* | setter | Schema in properties (write-only via extension) |
|
|
1702
|
+
* | index | additionalProperties schema |
|
|
1703
|
+
*
|
|
1704
|
+
* @param members - The members array from an interface/class
|
|
1705
|
+
* @param options - Normalization options
|
|
1706
|
+
* @returns JSON Schema object with properties, required, and additionalProperties
|
|
1707
|
+
*/
|
|
1708
|
+
declare function normalizeMembers(members: SpecMember3[], options?: NormalizeOptions): JSONSchema;
|
|
1709
|
+
interface ToJsonSchemaOptions {
|
|
1710
|
+
/** Root the document at a single or type (by name). Default: whole-spec $defs catalogue. */
|
|
1711
|
+
root?: string;
|
|
1712
|
+
/** Keep x-ts-* keys (default false). */
|
|
1713
|
+
keepExtensions?: boolean;
|
|
1714
|
+
/** Include the $schema field (default true). */
|
|
1715
|
+
includeSchemaField?: boolean;
|
|
1716
|
+
}
|
|
1717
|
+
interface JsonSchemaDocument extends Record<string, unknown> {
|
|
1718
|
+
$schema?: string;
|
|
1719
|
+
$defs?: Record<string, JSONSchema>;
|
|
1720
|
+
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Root a JSON Schema document at a single or type, bundling only its
|
|
1723
|
+
* transitively-referenced types into `$defs`.
|
|
1724
|
+
*/
|
|
1725
|
+
declare function exportToJsonSchema(subject: SpecExport11 | SpecType8, spec: OpenPkg13, options?: Omit<ToJsonSchemaOptions, "root">): JsonSchemaDocument;
|
|
1726
|
+
/**
|
|
1727
|
+
* Lift a whole spec (or, with `root`, a single named export/type) into a
|
|
1728
|
+
* standalone JSON Schema 2020-12 document.
|
|
1729
|
+
*/
|
|
1730
|
+
declare function toJsonSchema(spec: OpenPkg13, options?: ToJsonSchemaOptions): JsonSchemaDocument;
|
|
1731
|
+
import { OpenPkg as OpenPkg14, SpecSchema as SpecSchema4 } from "@openpkg-ts/spec";
|
|
1732
|
+
/** Strip TypeScript-specific extension keywords from a schema tree (deep). */
|
|
1733
|
+
declare function stripTsExtensions(schema: JSONSchema): JSONSchema;
|
|
1734
|
+
interface BundleOptions {
|
|
1735
|
+
/** Keep x-ts-* extension keys (default false — stripped). */
|
|
1736
|
+
keepExtensions?: boolean;
|
|
1737
|
+
/** Names to treat as unresolvable generics (export/type type parameters). */
|
|
1738
|
+
typeParameterNames?: readonly string[];
|
|
1739
|
+
/** Dangling-ref strategy (default 'permissive': replace with {} + warning). */
|
|
1740
|
+
onUnresolved?: "permissive" | "error";
|
|
1741
|
+
}
|
|
1742
|
+
interface BundleResult {
|
|
1743
|
+
/** Root schema, refs rewritten to #/$defs/<key>. */
|
|
1744
|
+
schema: JSONSchema;
|
|
1745
|
+
/** Transitively collected + rewritten type definitions. */
|
|
1746
|
+
defs: Record<string, JSONSchema>;
|
|
1747
|
+
/** Dangling refs, name collisions, pruned nodes. */
|
|
1748
|
+
warnings: string[];
|
|
1749
|
+
}
|
|
1750
|
+
/**
|
|
1751
|
+
* Bundle a spec schema into a self-contained JSON Schema fragment.
|
|
1752
|
+
*
|
|
1753
|
+
* Every `#/types/Name` ref becomes either an inlined builtin schema, an
|
|
1754
|
+
* `x-ts-type` marker (type parameters), or a `#/$defs/<key>` ref whose target
|
|
1755
|
+
* is collected (transitively, cycle-safe) into `defs`.
|
|
1756
|
+
*/
|
|
1757
|
+
declare function bundleRefs(root: SpecSchema4, spec: OpenPkg14, options?: BundleOptions): BundleResult;
|
|
1758
|
+
import { OpenPkg as OpenPkg15, SpecExport as SpecExport12 } from "@openpkg-ts/spec";
|
|
1759
|
+
type ToolSchemaProvider = "openai-strict" | "anthropic";
|
|
1760
|
+
interface ToToolSchemaOptions {
|
|
1761
|
+
provider: ToolSchemaProvider;
|
|
1762
|
+
/** Overload to use (default 0). */
|
|
1763
|
+
signatureIndex?: number;
|
|
1764
|
+
}
|
|
1765
|
+
interface ToolSchemaResult {
|
|
1766
|
+
/** Export name — the tool name. */
|
|
1767
|
+
name: string;
|
|
1768
|
+
description?: string;
|
|
1769
|
+
/** { type:'object', properties, required, [additionalProperties], [$defs] } */
|
|
1770
|
+
parameters: JSONSchema;
|
|
1771
|
+
/** Pruned props, lowered unions, dangling refs. */
|
|
1772
|
+
warnings: string[];
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* Build an AI tool-use parameter schema for a function export.
|
|
1776
|
+
* Throws for non-function exports (class/variable support is out of scope in v1).
|
|
1777
|
+
*/
|
|
1778
|
+
declare function toToolSchema(exp: SpecExport12, spec: OpenPkg15, options: ToToolSchemaOptions): ToolSchemaResult;
|
|
1779
|
+
import { SpecExport as SpecExport13 } from "@openpkg-ts/spec";
|
|
1624
1780
|
import ts8 from "typescript";
|
|
1625
|
-
declare function serializeClass(node: ts8.ClassDeclaration, ctx: SerializerContext):
|
|
1626
|
-
import { SpecExport as
|
|
1781
|
+
declare function serializeClass(node: ts8.ClassDeclaration, ctx: SerializerContext): SpecExport13 | null;
|
|
1782
|
+
import { SpecExport as SpecExport14 } from "@openpkg-ts/spec";
|
|
1627
1783
|
import ts9 from "typescript";
|
|
1628
|
-
declare function serializeEnum(node: ts9.EnumDeclaration, ctx: SerializerContext):
|
|
1629
|
-
import { SpecExport as
|
|
1784
|
+
declare function serializeEnum(node: ts9.EnumDeclaration, ctx: SerializerContext): SpecExport14 | null;
|
|
1785
|
+
import { SpecExport as SpecExport15 } from "@openpkg-ts/spec";
|
|
1630
1786
|
import ts10 from "typescript";
|
|
1631
|
-
declare function serializeFunctionExport(node: ts10.FunctionDeclaration | ts10.ArrowFunction | ts10.FunctionExpression, ctx: SerializerContext, nameOverride?: string):
|
|
1632
|
-
import { SpecExport as
|
|
1787
|
+
declare function serializeFunctionExport(node: ts10.FunctionDeclaration | ts10.ArrowFunction | ts10.FunctionExpression, ctx: SerializerContext, nameOverride?: string): SpecExport15 | null;
|
|
1788
|
+
import { SpecExport as SpecExport16 } from "@openpkg-ts/spec";
|
|
1633
1789
|
import ts11 from "typescript";
|
|
1634
|
-
declare function serializeInterface(node: ts11.InterfaceDeclaration, ctx: SerializerContext):
|
|
1635
|
-
import { SpecExport as
|
|
1790
|
+
declare function serializeInterface(node: ts11.InterfaceDeclaration, ctx: SerializerContext): SpecExport16 | null;
|
|
1791
|
+
import { SpecExport as SpecExport17 } from "@openpkg-ts/spec";
|
|
1636
1792
|
import ts12 from "typescript";
|
|
1637
|
-
declare function serializeTypeAlias(node: ts12.TypeAliasDeclaration, ctx: SerializerContext):
|
|
1638
|
-
import { SpecExport as
|
|
1793
|
+
declare function serializeTypeAlias(node: ts12.TypeAliasDeclaration, ctx: SerializerContext): SpecExport17 | null;
|
|
1794
|
+
import { SpecExport as SpecExport18 } from "@openpkg-ts/spec";
|
|
1639
1795
|
import ts13 from "typescript";
|
|
1640
|
-
declare function serializeVariable(node: ts13.VariableDeclaration, statement: ts13.VariableStatement, ctx: SerializerContext):
|
|
1796
|
+
declare function serializeVariable(node: ts13.VariableDeclaration, statement: ts13.VariableStatement, ctx: SerializerContext): SpecExport18 | null;
|
|
1641
1797
|
import { SpecSignatureParameter } from "@openpkg-ts/spec";
|
|
1642
1798
|
import ts14 from "typescript";
|
|
1643
1799
|
declare function extractParameters(signature: ts14.Signature, ctx: SerializerContext): SpecSignatureParameter[];
|
|
@@ -1646,14 +1802,9 @@ declare function extractParameters(signature: ts14.Signature, ctx: SerializerCon
|
|
|
1646
1802
|
* Uses ctx.registeredTypes to prevent re-processing already-registered types.
|
|
1647
1803
|
*/
|
|
1648
1804
|
declare function registerReferencedTypes(type: ts14.Type, ctx: SerializerContext, depth?: number): void;
|
|
1649
|
-
import { SpecSchema as
|
|
1805
|
+
import { SpecSchema as SpecSchema5 } from "@openpkg-ts/spec";
|
|
1650
1806
|
import ts15 from "typescript";
|
|
1651
1807
|
/**
|
|
1652
|
-
* Built-in type schemas with JSON Schema format hints.
|
|
1653
|
-
* Used for types that have specific serialization formats.
|
|
1654
|
-
*/
|
|
1655
|
-
declare const BUILTIN_TYPE_SCHEMAS: Record<string, SpecSchema2>;
|
|
1656
|
-
/**
|
|
1657
1808
|
* Remove `import("<abs path>").` qualifiers from checker-rendered type text.
|
|
1658
1809
|
* Machine-specific paths must never appear in a published spec.
|
|
1659
1810
|
*/
|
|
@@ -1680,7 +1831,7 @@ declare function isReadonlyPropertySymbol(prop: ts15.Symbol): boolean;
|
|
|
1680
1831
|
* - `x-ts-method`: declaration form marker for method-syntax members
|
|
1681
1832
|
* (SymbolFlags.Method survives on true methods, is stripped by mapping).
|
|
1682
1833
|
*/
|
|
1683
|
-
declare function decoratePropertySchema(schema:
|
|
1834
|
+
declare function decoratePropertySchema(schema: SpecSchema5, prop: ts15.Symbol, propType: ts15.Type, checker: ts15.TypeChecker): SpecSchema5;
|
|
1684
1835
|
/**
|
|
1685
1836
|
* Alias-level x-ts-type is emitted when the alias RHS is a renderable
|
|
1686
1837
|
* expression (array, instantiation, union, intersection, function, keyof, …).
|
|
@@ -1722,117 +1873,55 @@ declare function isAnonymous(type: ts15.Type): boolean;
|
|
|
1722
1873
|
* Ensure schema is non-empty — fallback to x-ts-type string representation if empty.
|
|
1723
1874
|
* Never emit {} as a schema; always include meaningful type info.
|
|
1724
1875
|
*/
|
|
1725
|
-
declare function ensureNonEmptySchema(schema:
|
|
1876
|
+
declare function ensureNonEmptySchema(schema: SpecSchema5, type: ts15.Type, checker: ts15.TypeChecker): SpecSchema5;
|
|
1726
1877
|
/**
|
|
1727
1878
|
* Build a structured SpecSchema from a TypeScript type.
|
|
1728
1879
|
* Uses $ref for named types and typeArguments for generics.
|
|
1729
1880
|
* Guarantees non-empty schema output via ensureNonEmptySchema wrapper.
|
|
1730
1881
|
*/
|
|
1731
|
-
declare function buildSchema(type: ts15.Type, checker: ts15.TypeChecker, ctx?: SerializerContext):
|
|
1882
|
+
declare function buildSchema(type: ts15.Type, checker: ts15.TypeChecker, ctx?: SerializerContext): SpecSchema5;
|
|
1732
1883
|
/**
|
|
1733
1884
|
* Build schema for function types
|
|
1734
1885
|
*/
|
|
1735
|
-
declare function buildFunctionSchema(callSignatures: readonly ts15.Signature[], checker: ts15.TypeChecker, ctx: SerializerContext | undefined):
|
|
1886
|
+
declare function buildFunctionSchema(callSignatures: readonly ts15.Signature[], checker: ts15.TypeChecker, ctx: SerializerContext | undefined): SpecSchema5;
|
|
1736
1887
|
/**
|
|
1737
1888
|
* Build schema for object types with properties
|
|
1738
1889
|
*/
|
|
1739
|
-
declare function buildObjectSchema(properties: ts15.Symbol[], checker: ts15.TypeChecker, ctx: SerializerContext | undefined, originalType?: ts15.Type):
|
|
1890
|
+
declare function buildObjectSchema(properties: ts15.Symbol[], checker: ts15.TypeChecker, ctx: SerializerContext | undefined, originalType?: ts15.Type): SpecSchema5;
|
|
1740
1891
|
/**
|
|
1741
1892
|
* Check if a schema is a pure $ref (only has $ref property)
|
|
1742
1893
|
*/
|
|
1743
|
-
declare function isPureRefSchema(schema:
|
|
1894
|
+
declare function isPureRefSchema(schema: SpecSchema5): schema is {
|
|
1744
1895
|
$ref: string;
|
|
1745
1896
|
};
|
|
1746
1897
|
/**
|
|
1747
1898
|
* Add description to a schema, handling $ref properly.
|
|
1748
1899
|
* For pure $ref schemas, wraps in allOf to preserve the reference.
|
|
1749
1900
|
*/
|
|
1750
|
-
declare function withDescription2(schema:
|
|
1901
|
+
declare function withDescription2(schema: SpecSchema5, description: string): SpecSchema5;
|
|
1751
1902
|
/**
|
|
1752
1903
|
* Mark a schema as deprecated, handling $ref properly.
|
|
1753
1904
|
* For pure $ref schemas, wraps in allOf to preserve the reference.
|
|
1754
1905
|
*/
|
|
1755
|
-
declare function withDeprecated(schema:
|
|
1906
|
+
declare function withDeprecated(schema: SpecSchema5, reason?: string): SpecSchema5;
|
|
1756
1907
|
/**
|
|
1757
1908
|
* Check if a schema represents the 'any' type
|
|
1758
1909
|
*/
|
|
1759
|
-
declare function schemaIsAny(schema:
|
|
1910
|
+
declare function schemaIsAny(schema: SpecSchema5): boolean;
|
|
1760
1911
|
/**
|
|
1761
1912
|
* Deep equality comparison for schemas
|
|
1762
1913
|
*/
|
|
1763
|
-
declare function schemasAreEqual(left:
|
|
1914
|
+
declare function schemasAreEqual(left: SpecSchema5, right: SpecSchema5): boolean;
|
|
1764
1915
|
/**
|
|
1765
1916
|
* Remove duplicate schemas from an array while preserving order.
|
|
1766
1917
|
*/
|
|
1767
|
-
declare function deduplicateSchemas(schemas:
|
|
1918
|
+
declare function deduplicateSchemas(schemas: SpecSchema5[]): SpecSchema5[];
|
|
1768
1919
|
/**
|
|
1769
1920
|
* Find a discriminator property in a union of object types (tagged union pattern).
|
|
1770
1921
|
* A valid discriminator has a unique literal value in each union member.
|
|
1771
1922
|
*/
|
|
1772
1923
|
declare function findDiscriminatorProperty(unionTypes: ts15.Type[], checker: ts15.TypeChecker): string | undefined;
|
|
1773
|
-
import { SpecExport as SpecExport15, SpecMember as SpecMember3, SpecSchema as SpecSchema3, SpecType as SpecType6 } from "@openpkg-ts/spec";
|
|
1774
|
-
/**
|
|
1775
|
-
* Options for schema normalization
|
|
1776
|
-
*/
|
|
1777
|
-
interface NormalizeOptions {
|
|
1778
|
-
/** Include $schema field in output */
|
|
1779
|
-
includeSchemaField?: boolean;
|
|
1780
|
-
/** Target JSON Schema dialect (default: 'draft-2020-12') */
|
|
1781
|
-
dialect?: "draft-2020-12" | "draft-07";
|
|
1782
|
-
}
|
|
1783
|
-
/**
|
|
1784
|
-
* JSON Schema 2020-12 compatible output type.
|
|
1785
|
-
* Uses Record<string, unknown> for flexibility since JSON Schema is highly polymorphic.
|
|
1786
|
-
*/
|
|
1787
|
-
type JSONSchema = Record<string, unknown>;
|
|
1788
|
-
/**
|
|
1789
|
-
* Normalize a SpecSchema to JSON Schema 2020-12.
|
|
1790
|
-
*
|
|
1791
|
-
* @param schema - The SpecSchema to normalize
|
|
1792
|
-
* @param options - Normalization options
|
|
1793
|
-
* @returns JSON Schema 2020-12 compatible schema
|
|
1794
|
-
*/
|
|
1795
|
-
declare function normalizeSchema(schema: SpecSchema3, options?: NormalizeOptions): JSONSchema;
|
|
1796
|
-
/**
|
|
1797
|
-
* Normalize a SpecExport, normalizing its schema and nested schemas.
|
|
1798
|
-
*
|
|
1799
|
-
* For interfaces and classes, this function will:
|
|
1800
|
-
* 1. Normalize any existing schema
|
|
1801
|
-
* 2. Normalize member schemas
|
|
1802
|
-
* 3. Generate a JSON Schema from members if members exist (populates `schema` field)
|
|
1803
|
-
*/
|
|
1804
|
-
declare function normalizeExport(exp: SpecExport15, options?: NormalizeOptions): SpecExport15;
|
|
1805
|
-
/**
|
|
1806
|
-
* Normalize a SpecType, normalizing its schema and nested schemas.
|
|
1807
|
-
*
|
|
1808
|
-
* For interfaces and classes, this function will:
|
|
1809
|
-
* 1. Normalize any existing schema
|
|
1810
|
-
* 2. Normalize member schemas
|
|
1811
|
-
* 3. Generate a JSON Schema from members if members exist (populates `schema` field)
|
|
1812
|
-
*/
|
|
1813
|
-
declare function normalizeType(type: SpecType6, options?: NormalizeOptions): SpecType6;
|
|
1814
|
-
/**
|
|
1815
|
-
* Convert a members array to JSON Schema properties format.
|
|
1816
|
-
*
|
|
1817
|
-
* This function transforms the SpecMember[] array representation used by
|
|
1818
|
-
* interfaces/classes into a JSON Schema 2020-12 object schema with properties,
|
|
1819
|
-
* required array, and additionalProperties.
|
|
1820
|
-
*
|
|
1821
|
-
* Member Kind Mappings:
|
|
1822
|
-
* | Member Kind | JSON Schema Output |
|
|
1823
|
-
* |--------------------|-------------------------------------------------------|
|
|
1824
|
-
* | property | Direct schema in properties |
|
|
1825
|
-
* | method | { "x-ts-function": true, "x-ts-signatures": [...] } |
|
|
1826
|
-
* | getter | Schema in properties (read-only via extension) |
|
|
1827
|
-
* | setter | Schema in properties (write-only via extension) |
|
|
1828
|
-
* | index | additionalProperties schema |
|
|
1829
|
-
*
|
|
1830
|
-
* @param members - The members array from an interface/class
|
|
1831
|
-
* @param options - Normalization options
|
|
1832
|
-
* @returns JSON Schema object with properties, required, and additionalProperties
|
|
1833
|
-
*/
|
|
1834
|
-
declare function normalizeMembers(members: SpecMember3[], options?: NormalizeOptions): JSONSchema;
|
|
1835
1924
|
import ts16 from "typescript";
|
|
1836
1925
|
declare function isExported(node: ts16.Node): boolean;
|
|
1837
1926
|
declare function getNodeName(node: ts16.Node): string | undefined;
|
|
1838
|
-
export { zodAdapter, withDescription2 as withDescription, withDeprecated, valibotAdapter, typeboxAdapter, toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toPagefindRecords2 as toPagefindRecords, toNavigation2 as toNavigation, toMarkdown2 as toMarkdown, toJSONString, toJSON2 as toJSON, toHTML2 as toHTML, toFumadocsMetaJSON, toDocusaurusSidebarJS, toAlgoliaRecords2 as toAlgoliaRecords, stripUndefinedFromType, sortByName, shouldEmitAliasTypeText, serializeVariable, serializeTypeAlias, serializeInterface, serializeFunctionExport, serializeEnum, serializeClass, scrubImportQualifiers, schemasAreEqual, schemaIsAny, resolveTypeRef, resolveExportTarget, resolveCompiledPath, renderTypeText, registerReferencedTypes, registerAdapter, recommendSemverBump, query, normalizeType, normalizeSchema, normalizeMembers, normalizeExport, mergeConfig, loadSpec, loadConfig, listExports, isTypeReference, isTypeOnlyExport, isSymbolDeprecated, isStandardJSONSchema, isSchemaType, isReadonlyPropertySymbol, isPureRefSchema, isProperty, isPrimitiveName, isMethod, isExported, isBuiltinSymbol, isBuiltinGeneric, isAnonymous, hasDeprecatedTag, groupByVisibility, getTypeOrigin, getSourceLocation, getProperties, getParamDescription, getNonNullableType, getNodeName, getMethods, getMemberBadges, getJSDocComment, getExportKind, getExport2 as getExport, getDeprecationMessage, toMarkdown2 as generateDocs, formatTypeParameters, formatSchema, formatReturnType, formatParameters, formatMappedType, formatConditionalType, formatBadges, findMissingParamDocs, findDiscriminatorProperty, findAdapter, filterSpec, extractTypeParameters, extractStandardSchemasFromTs, extractStandardSchemasFromProject, extractStandardSchemas, extractSpec, extractSchemaType, extractParameters, extract, exportToMarkdown, ensureNonEmptySchema, diffSpec2 as diffSpecs, diffSpec, detectTsRuntime, deduplicateSchemas, decoratePropertySchema, createProgram, createDocs, categorizeBreakingChanges, calculateNextVersion, buildSignatureString, buildSchema, buildObjectSchema, buildFunctionSchema, arktypeAdapter, analyzeSpec, TypeRegistry, TypeReference2 as TypeReference, TsRuntime, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, StandardJSONSchemaTarget, StandardJSONSchemaOptions, SpecMappedType, SpecDiff, SpecDiagnostics, SpecConditionalType, SkippedExportDetail, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SerializerContext, SemverRecommendation, SemverBump, SearchRecord, SearchOptions, SearchIndex, SchemaExtractionResult, SchemaAdapter, STRING_PROTOTYPE_METHODS, QueryBuilder, ProjectExtractionOutput, ProjectExtractionInfo, ProgramResult, ProgramOptions, PagefindRecord, PRIMITIVES, OpenpkgConfig, NormalizeOptions, NavOptions, NavItem, NavGroup, NavFormat, NUMBER_PROTOTYPE_METHODS, MemberChangeInfo, MarkdownOptions, LoadOptions, ListExportsResult, ListExportsOptions, 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, DiagnosticItem, Diagnostic, CategorizedBreaking, CacheManagerOptions, CacheManager, CONFIG_FILENAME, BreakingSeverity, BUILTIN_TYPE_SCHEMAS, AlgoliaRecord, ARRAY_PROTOTYPE_METHODS };
|
|
1927
|
+
export { zodAdapter, withDescription2 as withDescription, withDeprecated, validateSpec, valibotAdapter, typeboxAdapter, 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, resolveExportTarget, resolveCompiledPath, renderTypeText, registerReferencedTypes, registerAdapter, recommendSemverBump, query, normalizeType, normalizeSchema, normalizeMembers, normalizeExport, mergeConfig, loadSpec, loadConfig, listExports, isTypeReference, isTypeOnlyExport, isSymbolDeprecated, isStandardJSONSchema, isSchemaType, isReadonlyPropertySymbol, isPureRefSchema, isProperty, isPrimitiveName, isMethod, isExported, isBuiltinSymbol, isBuiltinGeneric, isAnonymous, hasDeprecatedTag, groupByVisibility, getValidationErrors, getTypeOrigin, getSourceLocation, getProperties, getParamDescription, getNonNullableType, getNodeName, getMethods, getMemberBadges, getJSDocComment, getExportKind, getExport2 as getExport, getDeprecationMessage, getAvailableVersions, toMarkdown2 as generateDocs, formatTypeParameters, formatSchema, formatReturnType, formatParameters, formatMappedType, formatConditionalType, formatBadges, findMissingParamDocs, findDiscriminatorProperty, findAdapter, filterSpec, extractTypeParameters, extractStandardSchemasFromTs, extractStandardSchemasFromProject, extractStandardSchemas, extractSpec, extractSchemaType, extractParameters, extract, exportToMarkdown, exportToJsonSchema, ensureNonEmptySchema, diffSpec2 as diffSpecs, diffSpec, detectTsRuntime, deduplicateSchemas, decoratePropertySchema, createProgram, createDocs, categorizeBreakingChanges, calculateNextVersion, bundleRefs, buildSignatureString, buildSchema, buildObjectSchema, buildFunctionSchema, assertSpec, asStandardSchema, arktypeAdapter, analyzeSpec, TypeRegistry, TypeReference2 as TypeReference, TsRuntime, ToolSchemaResult, ToolSchemaProvider, ToToolSchemaOptions, ToJsonSchemaOptions, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, StandardJSONSchemaTarget, StandardJSONSchemaOptions, SpecMappedType, SpecError, SpecDiff, SpecDiagnostics, SpecConditionalType, SkippedExportDetail, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SerializerContext, SemverRecommendation, SemverBump, SearchRecord, SearchOptions, SearchIndex, SchemaVersion, SchemaExtractionResult, SchemaAdapter, STRING_PROTOTYPE_METHODS, QueryBuilder, ProjectExtractionOutput, ProjectExtractionInfo, ProgramResult, ProgramOptions, PagefindRecord, 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, DiagnosticItem, Diagnostic, CategorizedBreaking, CacheManagerOptions, CacheManager, CONFIG_FILENAME, BundleResult, BundleOptions, BuiltinSchema, BreakingSeverity, BUILTIN_TYPE_SCHEMAS, AsStandardSchemaOptions, AlgoliaRecord, ARRAY_PROTOTYPE_METHODS };
|