All files apiTypes.ts

0% Statements 0/0
0% Branches 1/1
0% Functions 1/1
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166                                                                                                                                                                                                                                                                                                                                           
import { AssemblyInstructions, AssemblyInstructionsInput } from './alphalib/types/template'
 
export interface OptionalAuthParams {
  auth?: { key?: string; expires?: string }
}
 
// todo make zod schemas for these types in the backend for these too (in alphalib?)
// currently the types are not entirely correct, and probably lacking some props
 
export interface BaseResponse {
  // todo are these always there? maybe sometimes missing or null
  ok: string // todo should we type the different possible `ok` responses?
  message: string
}
 
export interface PaginationList<T> {
  items: T[]
}
 
export interface PaginationListWithCount<T> extends PaginationList<T> {
  count: number
}
 
// `auth` is not required in the JS API because it can be specified in the constructor,
// and it will then be auto-added before the request
export type CreateAssemblyParams = Omit<AssemblyInstructionsInput, 'auth'> & OptionalAuthParams
 
export type ListAssembliesParams = OptionalAuthParams & {
  page?: number
  pagesize?: number
  type?: 'all' | 'uploading' | 'executing' | 'canceled' | 'completed' | 'failed' | 'request_aborted'
  fromdate?: string
  todate?: string
  keywords?: string[]
}
 
// todo this is outdated and possibly wrong
/** See https://transloadit.com/docs/api/assemblies-assembly-id-get/ */
export interface ListedAssembly {
  id: string
  parent_id?: string | null
  account_id: string
  template_id?: string | null
  instance: string
  notify_url?: string | null
  redirect_url?: string | null
  files: string // json stringified
  warning_count: number
  execution_duration: number
  execution_start: string
  ok?: string | null
  error?: string | null
  created: string
}
 
export type ReplayAssemblyParams = Pick<
  CreateAssemblyParams,
  'auth' | 'template_id' | 'notify_url' | 'fields'
> & {
  reparse_template?: number
}
 
export interface ReplayAssemblyResponse extends BaseResponse {
  success: boolean
  assembly_id: string
  assembly_url: string
  assembly_ssl_url: string
  notify_url?: string
}
 
export type ReplayAssemblyNotificationParams = OptionalAuthParams & {
  notify_url?: string
  wait?: boolean
}
 
export interface ReplayAssemblyNotificationResponse {
  ok: string
  success: boolean
  notification_id: string
}
 
export type TemplateContent = Pick<
  CreateAssemblyParams,
  'allow_steps_override' | 'steps' | 'auth' | 'notify_url'
>
 
export type ResponseTemplateContent = Pick<
  AssemblyInstructions,
  'allow_steps_override' | 'steps' | 'auth' | 'notify_url'
>
 
export type CreateTemplateParams = OptionalAuthParams & {
  name: string
  template: TemplateContent
  require_signature_auth?: number
}
 
export type EditTemplateParams = OptionalAuthParams & {
  name?: string
  template?: TemplateContent
  require_signature_auth?: number
}
 
export type ListTemplatesParams = OptionalAuthParams & {
  page?: number
  pagesize?: number
  sort?: 'id' | 'name' | 'created' | 'modified'
  order?: 'desc' | 'asc'
  fromdate?: string
  todate?: string
  keywords?: string[]
}
 
interface TemplateResponseBase {
  id: string
  name: string
  content: ResponseTemplateContent
  require_signature_auth: number
}
 
export interface ListedTemplate extends TemplateResponseBase {
  encryption_version: number
  last_used?: string
  created: string
  modified: string
}
 
export interface TemplateResponse extends TemplateResponseBase, BaseResponse {}
 
// todo type this according to api2 valid values for better dx?
export type TemplateCredentialContent = Record<string, string>
 
export type CreateTemplateCredentialParams = OptionalAuthParams & {
  name: string
  type: string
  content: TemplateCredentialContent
}
 
export type ListTemplateCredentialsParams = OptionalAuthParams & {
  page?: number
  sort?: string
  order: 'asc' | 'desc'
}
 
// todo
export interface TemplateCredential {
  id: string
  name: string
  type: string
  content: TemplateCredentialContent
  account_id?: string
  created?: string
  modified?: string
  stringified?: string
}
 
export interface TemplateCredentialResponse extends BaseResponse {
  credential: TemplateCredential
}
 
export interface TemplateCredentialsResponse extends BaseResponse {
  credentials: TemplateCredential[]
}
 
export type BillResponse = any // todo