actions/action_codegen.ts view source
(origin_path: string): string Creates a file banner comment.
origin_path
stringreturns
string 5 declarations
actions/action_codegen.ts view source
(origin_path: string): string Creates a file banner comment.
origin_pathstringstring actions/action_codegen.ts view source
(spec: { method: string; initiator: "frontend" | "backend" | "both"; side_effects: true | null; input: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; output: ZodType<unknown, unknown, $ZodTypeInternals<...>>; description: string; kind: "request_response"; auth: "public" | ... 2 more ... | { ...; }; async: true; } | { ...; } | { ...; }, executor: "frontend" | "backend", imports: ImportBuilder): string Generates the phase handlers for an action spec using the unified ActionEvent type with the new phase/step type parameters.
spec{ method: string; initiator: "frontend" | "backend" | "both"; side_effects: true | null; input: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; output: ZodType<unknown, unknown, $ZodTypeInternals<...>>; description: string; kind: "request_response"; auth: "public" | ... 2 more ... | { ...; }; async: ...executor"frontend" | "backend"importsstring actions/action_codegen.ts view source
(spec: { method: string; initiator: "frontend" | "backend" | "both"; side_effects: true | null; input: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; output: ZodType<unknown, unknown, $ZodTypeInternals<...>>; description: string; kind: "request_response"; auth: "public" | ... 2 more ... | { ...; }; async: true; } | { ...; } | { ...; }, executor: "frontend" | "backend"): ("send_request" | ... 7 more ... | "execute")[] Determines which phases an executor can handle based on the action spec.
spec{ method: string; initiator: "frontend" | "backend" | "both"; side_effects: true | null; input: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; output: ZodType<unknown, unknown, $ZodTypeInternals<...>>; description: string; kind: "request_response"; auth: "public" | ... 2 more ... | { ...; }; async: ...executor"frontend" | "backend"("send_request" | "receive_request" | "send_response" | "receive_response" | "send_error" | "receive_error" | "send" | "receive" | "execute")[] actions/action_codegen.ts view source
(spec: { method: string; initiator: "frontend" | "backend" | "both"; side_effects: true | null; input: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; output: ZodType<unknown, unknown, $ZodTypeInternals<...>>; description: string; kind: "request_response"; auth: "public" | ... 2 more ... | { ...; }; async: true; } | { ...; } | { ...; }, phase: "send_request" | ... 7 more ... | "execute", imports: ImportBuilder, path_prefix: string): string Gets the handler return type for a specific phase and spec. Also adds necessary imports to the ImportBuilder.
spec{ method: string; initiator: "frontend" | "backend" | "both"; side_effects: true | null; input: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; output: ZodType<unknown, unknown, $ZodTypeInternals<...>>; description: string; kind: "request_response"; auth: "public" | ... 2 more ... | { ...; }; async: ...phase"send_request" | "receive_request" | "send_response" | "receive_response" | "send_error" | "receive_error" | "send" | "receive" | "execute"importspath_prefixstringstring actions/action_codegen.ts view source
Manages imports for generated code, building them on demand.
Automatically optimizes type-only imports to use import type syntax.
Why this matters:
- import type statements are completely removed during compilation
- Mixed imports like import { type A, B } cannot be safely removed
- This ensures optimal tree-shaking and smaller bundle sizes
const imports = new ImportBuilder();
imports.add_types('./types.js', 'Foo', 'Bar');
imports.add('./utils.js', 'helper');
imports.add_type('./utils.js', 'HelperOptions');
imports.add('./action_specs.js', '* as specs');
// Generates:
// import type {Foo, Bar} from './types.js';
// import {helper, type HelperOptions} from './utils.js';
// import * as specs from './action_specs.js';importstype Map<string, Map<string, ImportItem>>
addAdd a value import to be included in the generated code.
type (from: string, what: string): this
fromthe module to import from
stringwhatwhat to import (value)
stringthisadd_typeAdd a type import to be included in the generated code.
type (from: string, what: string): this
fromthe module to import from
stringwhatwhat to import (type)
stringthisadd_manyAdd multiple value imports from the same module.
type (from: string, ...items: string[]): this
fromstringitemsstring[]thisadd_typesAdd multiple type imports from the same module.
type (from: string, ...items: string[]): this
fromstringitemsstring[]thisbuildGenerate the import statements.
If all imports from a module are types, uses import type syntax.
type (): string
stringhas_importsCheck if the builder has any imports.
type (): boolean
booleanpreviewPreview what imports will be generated (useful for debugging).
type (): string[]
string[]array of import statement strings
clearClear all imports.
type (): this
this