Skip to content

Commit 40c9015

Browse files
committed
Clean up CLI types for knip and lint
1 parent 8c346b7 commit 40c9015

File tree

5 files changed

+3
-125
lines changed

5 files changed

+3
-125
lines changed

knip.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ import type { KnipConfig } from 'knip'
33
// Note: `yarn check` runs knip with --fix --allow-remove-files. This is safe because
44
// lint:ts and tests run immediately after - they'll fail if knip removes something needed.
55
const config: KnipConfig = {
6-
entry: [
7-
'src/Transloadit.ts',
8-
'src/cli.ts',
9-
'test/**/*.{ts,tsx,js,jsx}',
10-
'vitest.config.ts',
11-
],
6+
entry: ['src/Transloadit.ts', 'src/cli.ts', 'test/**/*.{ts,tsx,js,jsx}', 'vitest.config.ts'],
127
project: ['{src,test}/**/*.{ts,tsx,js,jsx}'],
138
ignore: [
149
'dist/**',

src/cli/commands/notifications.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { AuthenticatedCommand } from './BaseCommand.ts'
77

88
// --- Types and business logic ---
99

10-
export interface NotificationsReplayOptions {
10+
interface NotificationsReplayOptions {
1111
notify_url?: string
1212
assemblies: string[]
1313
}

src/cli/commands/templates.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ interface TemplateDeleteOptions {
3737
templates: string[]
3838
}
3939

40-
export interface TemplateListOptions {
40+
interface TemplateListOptions {
4141
before?: string
4242
after?: string
4343
order?: 'asc' | 'desc'

src/cli/helpers.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import fs from 'node:fs'
22
import type { Readable } from 'node:stream'
3-
import type { APIError } from './types.ts'
43
import { isAPIError } from './types.ts'
54

65
export function getEnvCredentials(): { authKey: string; authSecret: string } | null {
@@ -35,9 +34,6 @@ export function formatAPIError(err: unknown): string {
3534
return String(err)
3635
}
3736

38-
// Re-export APIError type for convenience
39-
40-
4137
export function zip<A, B>(listA: A[], listB: B[]): [A, B][]
4238
export function zip<T>(...lists: T[][]): T[][]
4339
export function zip<T>(...lists: T[][]): T[][] {

src/cli/types.ts

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
import { z } from 'zod'
22
import type { Steps } from '../alphalib/types/template.ts'
33
import { 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
146
const 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
15050
export function ensureError(value: unknown): Error {
15151
if (value instanceof Error) {
@@ -168,16 +68,3 @@ export function isTransloaditAPIError(value: unknown): value is TransloaditAPIEr
16868
export 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

Comments
 (0)