11import { z } from 'zod'
22import type { Steps } from '../alphalib/types/template.ts'
33import { optionalStepsSchema } from '../alphalib/types/template.ts'
4- import type { BillResponse , ListedTemplate , TemplateResponse } from '../apiTypes.ts'
5- import type { AssemblyStatus , Transloadit } from '../Transloadit.ts'
6- import type { IOutputCtl } from './OutputCtl.ts'
7-
8- // Re-export transloadit types for CLI use
9-
10-
11-
124
135// Zod schemas for runtime validation
146const APIErrorSchema = z . object ( {
@@ -54,98 +46,6 @@ export interface TemplateFile {
5446 data : TemplateFileData
5547}
5648
57- // Template list item (from API)
58- interface TemplateListItem {
59- id : string
60- modified : string
61- name ?: string
62- }
63-
64- // CLI Invocation types
65- interface BaseInvocation {
66- error ?: boolean
67- message ?: string
68- mode : string
69- action ?: string
70- logLevel ?: number
71- jsonMode ?: boolean
72- }
73-
74- interface AssemblyInvocation extends BaseInvocation {
75- mode : 'assemblies'
76- action ?: 'create' | 'get' | 'list' | 'delete' | 'replay'
77- inputs : string [ ]
78- output ?: string
79- recursive ?: boolean
80- watch ?: boolean
81- del ?: boolean
82- reprocessStale ?: boolean
83- steps ?: string
84- template ?: string
85- fields ?: Record < string , string >
86- assemblies ?: string [ ]
87- before ?: string
88- after ?: string
89- keywords ?: string [ ]
90- notify_url ?: string
91- reparse ?: boolean
92- }
93-
94- interface TemplateInvocation extends BaseInvocation {
95- mode : 'templates'
96- action ?: 'create' | 'get' | 'list' | 'delete' | 'modify' | 'sync'
97- templates ?: string [ ]
98- template ?: string
99- name ?: string
100- file ?: string
101- files ?: string [ ]
102- before ?: string
103- after ?: string
104- order ?: 'asc' | 'desc'
105- sort ?: string
106- fields ?: string [ ]
107- recursive ?: boolean
108- }
109-
110- interface BillInvocation extends BaseInvocation {
111- mode : 'bills'
112- action ?: 'get'
113- months : string [ ]
114- }
115-
116- interface NotificationInvocation extends BaseInvocation {
117- mode : 'assembly-notifications'
118- action ?: 'list' | 'replay'
119- assemblies ?: string [ ]
120- notify_url ?: string
121- type ?: string
122- assembly_id ?: string
123- pagesize ?: number
124- }
125-
126- interface HelpInvocation extends BaseInvocation {
127- mode : 'help' | 'version' | 'register'
128- }
129-
130- type Invocation =
131- | AssemblyInvocation
132- | TemplateInvocation
133- | BillInvocation
134- | NotificationInvocation
135- | HelpInvocation
136-
137- // Command handler type
138- type CommandHandler < T extends BaseInvocation = BaseInvocation > = (
139- output : IOutputCtl ,
140- client : Transloadit | undefined ,
141- invocation : T ,
142- ) => void | Promise < void >
143-
144- // Type guard for Error
145- function isError ( value : unknown ) : value is Error {
146- return value instanceof Error
147- }
148-
14949// Helper to ensure error is Error type
15050export function ensureError ( value : unknown ) : Error {
15151 if ( value instanceof Error ) {
@@ -168,16 +68,3 @@ export function isTransloaditAPIError(value: unknown): value is TransloaditAPIEr
16868export function isErrnoException ( value : unknown ) : value is NodeJS . ErrnoException {
16969 return value instanceof Error && 'code' in value
17070}
171-
172- // Safe array access helper
173- function safeGet < T > ( arr : T [ ] , index : number ) : T | undefined {
174- return arr [ index ]
175- }
176-
177- // Assert defined helper
178- function assertDefined < T > ( value : T | undefined | null , message : string ) : T {
179- if ( value === undefined || value === null ) {
180- throw new Error ( message )
181- }
182- return value
183- }
0 commit comments