import ts, { ArrowFunction, Bundle, ClassDeclaration, ClassExpression, CompilerHost, CompilerOptions, ConstructorDeclaration, CustomTransformer, CustomTransformerFactory, Declaration, EntityName, ExportDeclaration, Expression, ExpressionWithTypeArguments, FunctionDeclaration, FunctionExpression, Identifier, ImportDeclaration, JSDocImportTag, MethodDeclaration, ModuleDeclaration, ModuleExportName, Node, NodeArray, NodeFactory, ParseConfigHost, PropertyAccessExpression, QualifiedName, ResolvedModule, ScriptKind, SourceFile, Statement, StringLiteral, Symbol as Symbol$1, SymbolTable, TransformationContext, TypeAliasDeclaration, TypeChecker, TypeParameterDeclaration, TypeReferenceNode } from "typescript"; import { ReflectionOp } from "@deepkit/type-spec"; import { TypeAnnotation } from "@deepkit/core"; //#region ../../../node_modules/.pnpm/@deepkit+type-compiler@1.0.19_patch_hash=bd438188cbc12e606ed4d519c25ab921a833fbc2d92357_7b895da70230968802896bd8f1cfd4e0/node_modules/@deepkit/type-compiler/dist/cjs/src/ts-types.d.ts /** * Contains @internal properties that are not yet in the public API of TS. */ interface SourceFile$1 extends SourceFile { /** * If two source files are for the same version of the same package, one will redirect to the other. * (See `createRedirectSourceFile` in program.ts.) * The redirect will have this set. The redirected-to source file will be in `redirectTargetsMap`. */ redirectInfo?: any; scriptKind?: ScriptKind; externalModuleIndicator?: Node; commonJsModuleIndicator?: Node; jsGlobalAugmentations?: SymbolTable; symbol?: Symbol$1; } //#endregion //#region ../../../node_modules/.pnpm/@deepkit+type-compiler@1.0.19_patch_hash=bd438188cbc12e606ed4d519c25ab921a833fbc2d92357_7b895da70230968802896bd8f1cfd4e0/node_modules/@deepkit/type-compiler/dist/cjs/src/reflection-ast.d.ts type PackExpression = Expression | string | number | boolean | bigint; type JSDocTagValue = string | boolean; declare class NodeConverter { protected f: NodeFactory; constructor(f: NodeFactory); toExpression(node?: T): Expression; } //#endregion //#region ../../../node_modules/.pnpm/@deepkit+type-compiler@1.0.19_patch_hash=bd438188cbc12e606ed4d519c25ab921a833fbc2d92357_7b895da70230968802896bd8f1cfd4e0/node_modules/@deepkit/type-compiler/dist/cjs/src/resolver.d.ts /** * A utility to resolve a module path and its declaration. * * It automatically reads a SourceFile, binds and caches it. */ declare class Resolver { compilerOptions: CompilerOptions; host: CompilerHost; protected sourceFiles: { [fileName: string]: SourceFile; }; constructor(compilerOptions: CompilerOptions, host: CompilerHost, sourceFiles: { [fileName: string]: SourceFile; }); resolve(from: SourceFile, importOrExportNode: ExportDeclaration | ImportDeclaration | JSDocImportTag): SourceFile | undefined; protected resolveImpl(modulePath: StringLiteral, sourceFile: SourceFile): ResolvedModule | undefined; /** * Tries to resolve the .ts/d.ts file path for a given module path. * Scans relative paths. Looks into package.json "types" and "exports" (with new 4.7 support) * * @param sourceFile the SourceFile of the file that contains the import. modulePath is relative to that. * @param modulePath the x in 'from x'. */ resolveSourceFile(sourceFile: SourceFile, modulePath: StringLiteral): SourceFile | undefined; } //#endregion //#region ../../../node_modules/.pnpm/@deepkit+type-compiler@1.0.19_patch_hash=bd438188cbc12e606ed4d519c25ab921a833fbc2d92357_7b895da70230968802896bd8f1cfd4e0/node_modules/@deepkit/type-compiler/dist/cjs/src/config.d.ts /** * Default means reflection is enabled for this file. * Never means the whole reflection is disabled for this file. * Explicit means that reflection is per default disabled for this file, but each symbol/type * in it is allowed to enable it using jsdoc `@reflection`. */ declare const reflectionModes: readonly ["default", "explicit", "never"]; type Mode = (typeof reflectionModes)[number]; interface ReflectionConfig { /** * Allows to exclude type definitions/TS files from being included in the type compilation step. * When a global .d.ts is matched, their types won't be embedded (useful to exclude DOM for example) */ exclude?: string[]; /** * Either a boolean indication general reflection mode, * or a list of globs to match against. */ reflection?: string[] | Mode; } interface ResolvedConfig extends ReflectionConfig { path: string; compilerOptions: ts.CompilerOptions; mergeStrategy: 'merge' | 'replace'; } interface MatchResult { tsConfigPath: string; mode: (typeof reflectionModes)[number]; } type Matcher = (path: string) => MatchResult; type ConfigResolver = { match: Matcher; config: ResolvedConfig; }; type ReflectionConfigCache = { [path: string]: ConfigResolver; }; //#endregion //#region ../../../node_modules/.pnpm/@deepkit+type-compiler@1.0.19_patch_hash=bd438188cbc12e606ed4d519c25ab921a833fbc2d92357_7b895da70230968802896bd8f1cfd4e0/node_modules/@deepkit/type-compiler/dist/cjs/src/compiler.d.ts declare function encodeOps(ops: ReflectionOp[]): string; declare const packSizeByte: number; /** * It can't be more ops than this given number */ declare const packSize: number; declare function debugPackStruct(sourceFile: SourceFile$1, forType: Node, pack: { ops: ReflectionOp[]; stack: PackExpression[]; }): void; interface Frame { variables: { name: string; index: number; }[]; opIndex: number; conditional?: true; previous?: Frame; } type StackEntry = Expression | string | number | boolean; declare class CompilerProgram { forNode: Node; sourceFile?: SourceFile$1; protected ops: ReflectionOp[]; protected stack: StackEntry[]; protected mainOffset: number; protected stackPosition: number; protected frame: Frame; protected activeCoRoutines: { ops: ReflectionOp[]; }[]; protected coRoutines: { ops: ReflectionOp[]; }[]; constructor(forNode: Node, sourceFile?: SourceFile$1); buildPackStruct(): { ops: ReflectionOp[]; stack: StackEntry[]; }; isEmpty(): boolean; pushConditionalFrame(): void; pushStack(item: StackEntry): number; pushCoRoutine(): void; popCoRoutine(): number; pushOp(...ops: ReflectionOp[]): void; pushOpAtFrame(frame: Frame, ...ops: ReflectionOp[]): void; /** * Returns the index of the `entry` in the stack, if already exists. If not, add it, and return that new index. */ findOrAddStackEntry(entry: any): number; /** * To make room for a stack entry expected on the stack as input for example. */ increaseStackPosition(): number; protected resolveFunctionParameters: Map; resolveFunctionParametersIncrease(fn: Node): void; resolveFunctionParametersDecrease(fn: Node): void; isResolveFunctionParameters(fn: Node): boolean; /** * * Each pushFrame() call needs a popFrame() call. */ pushFrame(implicit?: boolean): Frame; findConditionalFrame(): Frame; /** * Remove stack without doing it as OP in the processor. Some other command calls popFrame() already, which makes popFrameImplicit() an implicit popFrame. * e.g. union, class, etc. all call popFrame(). the current CompilerProgram needs to be aware of that, which this function is for. */ popFrameImplicit(): void; moveFrame(): void; pushVariable(name: string, frame?: Frame): number; pushTemplateParameter(name: string, withDefault?: boolean): number; findVariable(name: string, frame?: Frame): { frameOffset: number; stackIndex: number; }; } declare class Cache { resolver: ReflectionConfigCache; sourceFiles: { [fileName: string]: SourceFile$1; }; globalSourceFiles?: SourceFile$1[]; /** * Signals the cache to check if it needs to be cleared. */ tick(): void; } /** * Read the TypeScript AST and generate pack struct (instructions + pre-defined stack). * * This transformer extracts type and add the encoded (so its small and low overhead) at classes and functions as property. * * Deepkit/type can then extract and decode them on-demand. */ declare class ReflectionTransformer implements CustomTransformer { protected context: TransformationContext; protected cache: Cache; sourceFile: SourceFile$1; protected f: NodeFactory; protected embedAssignType: boolean; /** * Types added to this map will get a type program directly under it. * This is for types used in the very same file. */ protected compileDeclarations: Map; /** * Types added to this map will get a type program at the top root level of the program. * This is for imported types, which need to be inlined into the current file, as we do not emit type imports (TS will omit them). */ protected embedDeclarations: Map; /** * When a node was embedded or compiled (from the maps above), we store it here to know to not add it again. */ protected compiledDeclarations: Set; protected addImports: { importDeclaration: ImportDeclaration | JSDocImportTag; identifier: Identifier; }[]; protected additionalImports: Map; protected nodeConverter: NodeConverter; protected typeChecker?: TypeChecker; protected resolver: Resolver; protected host: CompilerHost; protected overriddenHost: boolean; protected overriddenConfigResolver?: ConfigResolver; protected compilerOptions: CompilerOptions; /** * When a deep call expression was found a script-wide variable is necessary * as temporary storage. */ protected tempResultIdentifier?: Identifier; protected parseConfigHost: ParseConfigHost; protected intrinsicMetaDeclaration: TypeAliasDeclaration; constructor(context: TransformationContext, cache?: Cache); forHost(host: CompilerHost): this; withReflection(config: ReflectionConfig): this; transformBundle(node: Bundle): Bundle; getTempResultIdentifier(): Identifier; protected getConfigResolver(sourceFile: { fileName: string; }): ConfigResolver; protected getReflectionConfig(sourceFile: { fileName: string; }): MatchResult; protected isWithReflection(sourceFile: SourceFile$1 | undefined, node: Node & { __deepkitConfig?: ReflectionConfig; }): boolean; transformSourceFile(sourceFile: SourceFile$1): SourceFile$1; attachAdditionalStatements(statements: NodeArray | Statement[]): Statement[]; protected getModuleType(): 'cjs' | 'esm'; protected getArrowFunctionΩPropertyAccessIdentifier(node: ArrowFunction): Identifier | undefined; protected injectResetΩ(node: T): T; protected createProgramVarFromNode(node: Node, name: EntityName, sourceFile?: SourceFile$1): Statement[]; protected extractPackStructOfExpression(node: Expression, program: CompilerProgram): void; protected extractPackStructOfType(node: Node | Declaration | ClassDeclaration | ClassExpression, program: CompilerProgram): void; protected knownClasses: { [name: string]: ReflectionOp; }; protected getGlobalLibs(): SourceFile$1[]; /** * This is a custom resolver based on populated `locals` from the binder. It uses a custom resolution algorithm since * we have no access to the binder/TypeChecker directly and instantiating a TypeChecker per file/transformer is incredible slow. */ protected resolveDeclaration(typeName: EntityName): { declaration: Node; importDeclaration?: ImportDeclaration | JSDocImportTag; typeOnly?: boolean; } | void; protected getDeclarationVariableName(typeName: EntityName): Identifier; /** * The semantic of isExcluded is different from checking if the fileName is part * of reflection config option. isExcluded checks if the file should be excluded * via the exclude option. mainly used to exclude globals and external libraries. */ protected isExcluded(fileName: string): boolean; protected extractPackStructOfTypeReference(type: TypeReferenceNode | ExpressionWithTypeArguments, program: CompilerProgram): void; /** * Returns the class declaration, function/arrow declaration, or block where type was used. */ protected getTypeUser(type: Node): Node; /** * With this function we want to check if `type` is used in the signature itself from the parent of `declaration`. * If so, we do not try to infer the type from runtime values. * * Examples where we do not infer from runtime, `type` being `T` and `declaration` being `` (return false): * * ```typescript * class User { * config: T; * } * * class User { * constructor(public config: T) {} * } * * function do(item: T): void {} * function do(item: T): T {} * ``` * * Examples where we infer from runtime (return true): * * ```typescript * function do(item: T) { * return typeOf; //<-- because of that * } * * function do(item: T) { * class A { * config: T; //<-- because of that * } * return A; * } * * function do(item: T) { * class A { * doIt() { * class B { * config: T; //<-- because of that * } * return B; * } * } * return A; * } * * function do(item: T) { * class A { * doIt(): T { //<-- because of that * } * } * return A; * } * ``` */ protected needsToBeInferred(declaration: TypeParameterDeclaration, type: TypeReferenceNode | ExpressionWithTypeArguments): boolean; protected resolveTypeOnlyImport(entityName: EntityName, program: CompilerProgram): void; protected resolveTypeName(typeName: string, program: CompilerProgram): void; protected resolveTypeParameter(declaration: TypeParameterDeclaration, type: TypeReferenceNode | ExpressionWithTypeArguments, program: CompilerProgram): void; protected createAccessorForEntityName(e: QualifiedName): PropertyAccessExpression; protected findDeclarationInFile(sourceFile: SourceFile$1 | ModuleDeclaration, declarationName: string): Declaration | undefined; protected resolveImportSpecifier(_declarationName: string | ModuleExportName, importOrExport: ExportDeclaration | ImportDeclaration | JSDocImportTag, sourceFile: SourceFile$1): Declaration | undefined; protected followExport(declarationName: string, statement: ExportDeclaration, sourceFile: SourceFile$1): Declaration | undefined; protected getTypeOfType(type: Node | Declaration): Expression | undefined; protected packOpsAndStack(program: CompilerProgram): ts.Expression; /** * Note: We have to duplicate the expressions as it can be that incoming expression are from another file and contain wrong pos/end properties, * so the code generation is then broken when we simply reuse them. Wrong code like ``User.__type = [.toEqual({`` is then generated. * This function is probably not complete, but we add new copies when required. */ protected valueToExpression(value: undefined | PackExpression | PackExpression[]): Expression; /** * A class is decorated with type information by adding a static variable. * * class Model { * static __types = pack(ReflectionOp.string); //<-- encoded type information * title: string; * } */ protected decorateClass(sourceFile: SourceFile$1, node: ClassDeclaration | ClassExpression): Node; /** * const fn = function() {} * * => const fn = __assignType(function() {}, [34]) */ protected decorateFunctionExpression(expression: FunctionExpression): ts.FunctionExpression | ts.CallExpression; /** * function name() {} * * => function name() {}; name.__type = 34; */ protected decorateFunctionDeclaration(declaration: FunctionDeclaration): ts.ExportAssignment | ts.FunctionDeclaration | ts.Statement[]; /** * const fn = () => {} * => const fn = __assignType(() => {}, [34]) */ protected decorateArrowFunction(expression: ArrowFunction): ts.ArrowFunction | ts.CallExpression; /** * Object.assign(fn, {__type: []}) is much slower than a custom implementation like * * assignType(fn, []) * * where we embed assignType() at the beginning of the type. */ protected wrapWithAssignType(fn: Expression, type: Expression): ts.CallExpression; /** * Emit `{ __meta?: never & [name, value] }` — the runtime shape of `TypeAnnotation`. * Consumed later via `typeAnnotation.getForName(type, name)`. */ protected emitTypeAnnotation(program: CompilerProgram, name: string, value: JSDocTagValue): void; protected collectJSDocAnnotations(node: Node | undefined): { description?: string; annotations: { name: string; value: JSDocTagValue; }[]; }; /** * Run `emitType()` then intersect the result with TypeAnnotations derived from JSDoc/TSDoc. * Also sets `ReflectionOp.description` when a description string is available (back-compat). * * @returns The resolved description string, if any. */ protected withJSDocTypeAnnotations(program: CompilerProgram, node: Node | undefined, emitType: () => void, options?: { applyDescriptionOp?: boolean; }): string | undefined; /** * Checks if reflection was disabled/enabled in file via JSDoc attribute for a particular * Node, e.g `@reflection no`. If nothing is found, "reflection" config option needs to be used. */ protected getExplicitReflectionMode(sourceFile: SourceFile$1 | undefined, node: Node): boolean | undefined; } declare class DeclarationTransformer extends ReflectionTransformer { protected addExports: { identifier: string; }[]; transformSourceFile(sourceFile: SourceFile$1): SourceFile$1; } declare const transformer: CustomTransformerFactory; declare const declarationTransformer: CustomTransformerFactory; //#endregion //#region ../../../node_modules/.pnpm/@deepkit+type-compiler@1.0.19_patch_hash=bd438188cbc12e606ed4d519c25ab921a833fbc2d92357_7b895da70230968802896bd8f1cfd4e0/node_modules/@deepkit/type-compiler/dist/cjs/src/loader.d.ts declare class DeepkitLoader { protected options: CompilerOptions; protected host: ts.CompilerHost; protected program: ts.Program; protected printer: ts.Printer; protected cache: Cache; protected knownFiles: { [path: string]: string; }; protected sourceFiles: { [path: string]: SourceFile; }; constructor(); transform(source: string, path: string): string; } //#endregion //#region src/deepkit.d.ts /** * Schema metadata options mirroring JSON Schema metadata keywords. * * @see https://deepkit.io/en/documentation/runtime-types/types#custom-type-annotations */ interface SchemaMetaOptions { id?: string; title?: string; description?: string; docs?: string; alias?: string[]; tags?: string[]; deprecated?: boolean; hidden?: boolean; ignore?: boolean; internal?: boolean; runtime?: boolean; examples?: (unknown | { name?: string; description?: string; value: unknown; })[]; readOnly?: boolean; writeOnly?: boolean; contentEncoding?: string; contentMediaType?: string; contentSchema?: string; } /** * Combined schema metadata annotation. * * @example * ```ts * type Username = string & SchemaMeta<{ title: "Username"; deprecated: true }>; * ``` */ type SchemaMeta = TypeAnnotation<"schemaMeta", T>; /** * Unique schema / property identifier. * * @example * ```ts * type UserId = string & Id<"user">; * ``` */ type Id = TypeAnnotation<"id", T>; /** * Human-readable title. * * @example * ```ts * type Name = string & Title<"Display name">; * ``` */ type Title = TypeAnnotation<"title", T>; /** * Human-readable description. * * @example * ```ts * type Bio = string & Description<"Short biography">; * ``` */ type Description = TypeAnnotation<"description", T>; /** * External documentation URL. * * @example * ```ts * type Token = string & Docs<"https://example.com/docs/token">; * ``` */ type Docs = TypeAnnotation<"docs", T>; /** * Alternate names for the field. * * @example * ```ts * type Email = string & Alias<["mail", "e-mail"]>; * ``` */ type Alias = TypeAnnotation<"alias", T>; /** * Categorization tags / groups. * * @example * ```ts * type Password = string & Tags<["credentials", "secret"]>; * ``` */ type Tags = TypeAnnotation<"tags", T>; /** * Marks the field as deprecated. * * @example * ```ts * type LegacyId = string & Deprecated; * ``` */ type Deprecated = TypeAnnotation<"deprecated">; /** * Hides the field from documentation / UI surfaces. * * @example * ```ts * type Secret = string & Hidden; * ``` */ type Hidden = TypeAnnotation<"hidden">; /** * Ignores the field during schema processing. * * @example * ```ts * type Scratch = string & Ignore; * ``` */ type Ignore = TypeAnnotation<"ignore">; /** * Marks the field as internal. * * @example * ```ts * type InternalId = string & Internal; * ``` */ type Internal = TypeAnnotation<"internal">; /** * Marks the field as populated only at runtime. * * @example * ```ts * type Computed = string & Runtime; * ``` */ type Runtime = TypeAnnotation<"runtime">; /** * Example value shape for documentation. */ type SchemaExample = unknown | { name?: string; description?: string; value: unknown; }; /** * Example values for documentation. * * @example * ```ts * type Status = string & Examples<[{ value: "active" }, { name: "Off", value: "inactive" }]>; * ``` */ type Examples = TypeAnnotation<"examples", T>; /** * Marks the field as read-only. * * @example * ```ts * type CreatedAt = string & ReadOnly; * ``` */ type ReadOnly = TypeAnnotation<"readOnly">; /** * Marks the field as write-only. * * @example * ```ts * type Password = string & WriteOnly; * ``` */ type WriteOnly = TypeAnnotation<"writeOnly">; /** * Content encoding (e.g. `base64`). * * @example * ```ts * type Blob = string & ContentEncoding<"base64">; * ``` */ type ContentEncoding = TypeAnnotation<"contentEncoding", T>; /** * Content media type (e.g. `application/json`). * * @example * ```ts * type Payload = string & ContentMediaType<"application/json">; * ``` */ type ContentMediaType = TypeAnnotation<"contentMediaType", T>; /** * Content schema reference. * * @example * ```ts * type Body = string & ContentSchema<"https://example.com/schemas/body.json">; * ``` */ type ContentSchema = TypeAnnotation<"contentSchema", T>; //#endregion export { Alias, Cache, ContentEncoding, ContentMediaType, ContentSchema, DeclarationTransformer, DeepkitLoader, Deprecated, Description, Docs, Examples, Hidden, Id, Ignore, Internal, ReadOnly, ReflectionTransformer, Runtime, SchemaExample, SchemaMeta, SchemaMetaOptions, Tags, Title, WriteOnly, debugPackStruct, declarationTransformer, encodeOps, packSize, packSizeByte, transformer }; //# sourceMappingURL=deepkit.d.mts.map