Skip to content

Paka.Exports

Paka / Exports

Import

typescript
import { Paka } from '@wollybeard/kit'
typescript
import * as Paka from '@wollybeard/kit/paka'

Namespaces

Constants

[C] ExportLevel

typescript
Enums<{ readonly value: 'value'; readonly type: 'type' }>

Export level distinguishes between runtime values and type-only exports.

[C] ValueExportType

typescript
Enums<
  {
    readonly function: 'function'
    readonly const: 'const'
    readonly class: 'class'
    readonly namespace: 'namespace'
  }
>

Value export types

  • exports that exist at runtime.

[C] TypeExportType

typescript
Enums<
  {
    readonly interface: 'interface'
    readonly 'type-alias': 'type-alias'
    readonly enum: 'enum'
    readonly union: 'union'
    readonly intersection: 'intersection'
  }
>

Type export types

  • exports that only exist in TypeScript's type system.

[C] BuilderMethodCategory

typescript
Enums<
  {
    readonly chainable: 'chainable'
    readonly terminal: 'terminal'
    readonly transform: 'transform'
  }
>

Builder method classification based on return type.

  • chainable
  • Returns the same builder type (for method chaining)
  • terminal
  • Returns void (ends the builder chain)
  • transform
  • Returns a different builder type (transforms to another builder)

[C] SignatureModel

typescript
Union<
  [
    typeof FunctionSignatureModel,
    typeof BuilderSignatureModel,
    typeof ClassSignatureModel,
    typeof TypeSignatureModel,
    typeof ValueSignatureModel,
  ]
>

Signature model

  • tagged union of all signature types.

Discriminated by _tag field:

  • FunctionSignatureModel
  • Functions with structured overloads
  • BuilderSignatureModel
  • Builder pattern APIs with chainable/terminal methods
  • ClassSignatureModel
  • Classes with constructor, properties, methods
  • TypeSignatureModel
  • Types, interfaces, type aliases (text)
  • ValueSignatureModel
  • Const values (type as text)

[C] Module

typescript
Schema<Module, ModuleEncoded, never>

Module schema

  • uses suspend for circular reference with ValueExport.

NOTE: The as any assertions are required here due to circular dependency:

  • Module contains Export[] (through exports field)
  • ValueExport (part of Export union) contains optional Module (through module field)

Effect Schema's S.suspend handles this at runtime, but TypeScript needs help with the circular type reference. The interface definitions above ensure type safety for consumers.

[C] Export

typescript
Union<[typeof ValueExport, typeof TypeExport]>

Export is a tagged union of value and type exports.

[C] Entrypoint

typescript
Union<[typeof DrillableNamespaceEntrypoint, typeof SimpleEntrypoint]>

Entrypoint union

  • all patterns.

[C] InterfaceModel

typescript
typeof Package

The complete interface model output.

Classes

[Class] Example

typescript
class {
}

Code example extracted from JSDoc

[Class] SourceLocation

typescript
class {
}

Source location for "View source" links.

[Class] TypeParameter

typescript
class {
}

Type parameter for generic functions/classes. Captures type parameter name, constraint, and default value.

Examples:

typescript
// <T extends string = 'default'>
{ name: 'T', constraint: 'string', default: "'default'" }

[Class] Parameter

typescript
class {
}

Function/method parameter. Captures parameter name, type, modifiers, and JSDoc description.

Examples:

typescript
import { 
Paka
} from '@wollybeard/kit/paka' // ---cut---
// (items: T[], fn?: (item: T) => U, ...rest: unknown[]) ;[ {
name
: 'items',
type
: 'T[]',
optional
: false,
rest
: false,
description
: 'Array of items to process',
}, {
name
: 'fn',
type
: '(item: T) => U',
optional
: true,
rest
: false,
description
: 'Transform function',
}, {
name
: 'rest',
type
: 'unknown[]',
optional
: false,
rest
: true },
]

[Class] FunctionSignature

typescript
class {
}

Single function signature (one overload). Captures type parameters, parameters, return type, and JSDoc documentation.

Used within FunctionSignatureModel to support multiple overloads.

Examples:

typescript
{
  typeParameters: [{ 
name
: 'T',
constraint
: 'string' }],
parameters: [{
name
: 'value',
type
: 'T',
description
: 'Input value' }],
returnType: 'T', returnDoc: 'The processed value', throws: ['Error if value is invalid'] }

[Class] FunctionSignatureModel

typescript
class {
}

Function signature model supporting multiple overloads.

Structured representation of function signatures with full parameter, type parameter, and return type information.

Examples:

typescript
// function parse(input: string): Config
// function parse(input: Buffer): Config
{
  _tag: 'FunctionSignatureModel',
    overloads: [
      { 
typeParameters
: [],
parameters
: [{
name
: 'input',
type
: 'string', ... }],
returnType
: 'Config' },
{
typeParameters
: [],
parameters
: [{
name
: 'input',
type
: 'Buffer', ... }],
returnType
: 'Config' }
] }

[Class] BuilderMethod

typescript
class {
}

Builder method on a builder interface.

Captures method name, overloads, and classification based on return type. Methods are classified during extraction by analyzing their return types.

Examples:

typescript
// inputType<I>(): TestBuilder<State & { input: I }>
{
  name: 'inputType',
    overloads: [...],
      category: 'chainable',
        transformsTo: 
undefined
} // test(): void { name: 'test', overloads: [...], category: 'terminal', transformsTo:
undefined
} // layer<R>(layer: any): OtherBuilder<State, R> { name: 'layer', overloads: [...], category: 'transform', transformsTo: 'OtherBuilder' }

[Class] BuilderSignatureModel

typescript
class {
}

Builder signature model for fluent/builder pattern APIs.

Builder patterns are detected when a function is marked with @builder JSDoc tag. The extractor automatically crawls the returned builder type interface and classifies methods based on their return types:

  • Chainable: Returns the same builder type (enables method chaining)
  • Terminal: Returns void (ends the builder chain)
  • Transform: Returns a different builder type (transforms to another builder)

Examples:

Extracted as:

typescript
{
  _tag: 'BuilderSignatureModel',
    typeName: 'TestBuilder',
      entryPoint: FunctionSignature { ... },
  chainableMethods: [
    { 
name
: 'inputType',
category
: 'chainable', ... },
{
name
: 'cases',
category
: 'chainable', ... }
], terminalMethods: [ {
name
: 'test',
category
: 'terminal',
overloads
: [...2 overloads] }
], transformMethods: [ {
name
: 'layer',
category
: 'transform',
transformsTo
: 'OtherBuilder', ... }
] }

[Class] TypeSignatureModel

typescript
class {
}

Type signature model (interfaces, type aliases, etc).

For now, these are kept as plain text since parsing TypeScript type definitions into structured form is complex with diminishing returns.

Future: Could be expanded to structured form (properties, methods, etc).

[Class] ValueSignatureModel

typescript
class {
}

Value signature model (simple const values, primitives).

Used for exports that are simple constant values (not functions/classes). Stores the inferred type as text.

Examples:

typescript
// export const PI = 3.14159
{ _tag: 'ValueSignatureModel', type: 'number' }

[Class] ClassProperty

typescript
class {
}

Class property. Captures property name, type, modifiers, and JSDoc description.

Examples:

typescript
import { 
Paka
} from '@wollybeard/kit/paka' // ---cut---
// class User { // readonly id: string // name?: string // static count: number // } ;[ {
name
: 'id',
type
: 'string',
optional
: false,
readonly
: true,
static
: false,
}, {
name
: 'name',
type
: 'string',
optional
: true,
readonly
: false,
static
: false,
}, {
name
: 'count',
type
: 'number',
optional
: false,
readonly
: false,
static
: true,
}, ]

[Class] ClassMethod

typescript
class {
}

Class method. Captures method name, overloads, and modifiers.

Examples:

typescript
// class User {
//   getName(): string
//   static create(name: string): User
// }
[
  { 
name
: 'getName',
overloads
: [...],
static
: false },
{
name
: 'create',
overloads
: [...],
static
: true }
]

[Class] ClassSignatureModel

typescript
class {
}

Class signature model with structured class information.

Structured representation of class with constructor, properties, and methods.

Examples:

typescript
// export class User {
//   readonly id: string
//   name: string
//   constructor(id: string, name: string) { ... }
//   getName(): string { return this.name }
//   static create(name: string): User { return new User(crypto.randomUUID(), name) }
// }
{
  _tag: 'ClassSignatureModel',
    ctor: { typeParameters: [], parameters: [...], returnType: 'User' },
  properties: [
    { 
name
: 'id',
type
: 'string',
readonly
: true, ... },
{
name
: 'name',
type
: 'string',
readonly
: false, ... }
], methods: [ {
name
: 'getName',
overloads
: [...],
static
: false },
{
name
: 'create',
overloads
: [...],
static
: true }
] }

[Class] ValueExport

typescript
class {
}

Value export

  • represents a runtime export. Namespace exports include a nested module.

[Class] TypeExport

typescript
class {
}

Type export

  • represents a type-only export.

[Class] DrillableNamespaceEntrypoint

typescript
class {
}

Drillable Namespace Pattern entrypoint.

This pattern is detected ONLY for the main entrypoint ('.') when ALL conditions are met:

  1. The main entrypoint source file contains a namespace export: export * as Name from './path' 2. The namespace name (PascalCase, e.g., A) converts to kebab-case (e.g., a) 3. A subpath export exists in package.json with that kebab name (e.g., ./a) 4. The file that the namespace export points to 5. AND the file that the subpath export points to 6. Must resolve to the SAME source file

When detected, this enables two import forms:

  • import { Name } from 'package'
  • imports the namespace from main entrypoint
  • import * as Name from 'package/kebab-name'
  • imports the barrel directly

Examples:

Both the namespace export and the subpath export resolve to src/a.ts → Drillable!

typescript
// package.json
{
  "exports": {
    ".": "./build/index.js",
      "./a": "./build/a.js"
  }
}

// src/index.ts (main entrypoint)
export * as 
A
from './a.js'
// src/a.ts (barrel implementation) export const
foo
= () => { }

Non-drillable case - different files

typescript
// package.json
{
  "exports": {
    ".": "./build/index.js",
      "./a": "./build/a.js"
  }
}

// src/index.ts
export * as 
A
from './z.js' // ← Points to z.js, not a.js
// Namespace points to src/z.ts, subpath points to src/a.ts → NOT drillable (different files)

[Class] SimpleEntrypoint

typescript
class {
}

Simple entrypoint without special import pattern.

[Class] PackageMetadata

typescript
class {
}

Package metadata.

[Class] Package

typescript
class {
}

Package represents the complete extracted documentation model.

Types

[T] ExportLevel

typescript
type ExportLevel = typeof ExportLevel.Type

[T] ValueExportType

typescript
type ValueExportType = typeof ValueExportType.Type

[T] TypeExportType

typescript
type TypeExportType = typeof TypeExportType.Type

[T] BuilderMethodCategory

typescript
type BuilderMethodCategory = typeof BuilderMethodCategory.Type

[T] SignatureModel

typescript
type SignatureModel = S.Schema.Type<typeof SignatureModel>

[I] Module

typescript
interface Module {
  readonly location: typeof FsLoc.RelFile.Type
  readonly description: string
  readonly descriptionSource?: 'jsdoc' | 'md-file'
  readonly category?: string
  readonly exports: ReadonlyArray<Export>
}

Module type definition.

[I] ModuleEncoded

typescript
interface ModuleEncoded extends Module {}

Module encoded type (same as Module since no transformations).

[T] Export

typescript
type Export = S.Schema.Type<typeof Export>

[T] Entrypoint

typescript
type Entrypoint = S.Schema.Type<typeof Entrypoint>

[T] InterfaceModel

typescript
type InterfaceModel = S.Schema.Type<typeof InterfaceModel>