Skip to content

Commit

Permalink
types(rest-client/addons): refactor types and their exports
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor Didenko authored and nd0ut committed Nov 15, 2023
1 parent 67a01dc commit 9aaec7a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 35 deletions.
13 changes: 11 additions & 2 deletions packages/rest-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@ export {
AddonParams,
AddonUcClamavVirusScanParams,
AddonAwsRekognitionDetectLabelsParams,
AddonAwsRekognitionModerationLabelsParams,
AddonRemoveBgParams
} from './types/AddonParams'
export {
AddonData,
AwsLabel,
AppData,
ClamavVirusScan,
AwsRekognitionDetectLabelParent,
AwsRekognitionDetectLabelInstance,
AwsRekognitionDetectLabel,
AwsRekognitionDetectLabels,
RemoveBg
AwsRekognitionDetectModerationLabels,
AwsRekognitionDetectModerationLabel,
RemoveBg,
TechFieldsAppData
} from './types/AppData'
export { BatchResponse, BatchResponseStatus } from './types/BatchResponse'
export { ConversionStatus } from './types/ConversionStatus'
Expand All @@ -30,7 +36,10 @@ export { WebhookEvent } from './types/WebhookEvent'
export { StoreValue } from '@uploadcare/api-client-utils'
export { Paginatable } from './types/Paginatable'
export { Md5Function } from './lib/md5/Md5Function'
export { ConversionOptions } from './types/ConversionOptions'
export {
ConversionOptions,
BaseConversionOption
} from './types/ConversionOptions'
export { ConversionResponse } from './types/ConversionResponse'
export { ConversionStatusOptions } from './types/ConversionStatusOptions'
export { ConversionStatusResponse } from './types/ConversionStatusResponse'
Expand Down
57 changes: 25 additions & 32 deletions packages/rest-client/src/types/AppData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export type TechFieldsAppData = {
datetime_updated: string
}

export type ClamavVirusScan = {
data: {
infected: boolean
infected_with: string
}
} & TechFieldsAppData
export type AddonData<T> = TechFieldsAppData & { data: T }

export type ClamavVirusScan = AddonData<{
infected: boolean
infected_with: string
}>

export type AwsRekognitionDetectLabelParent = {
Name: string
Expand All @@ -27,41 +27,34 @@ export type AwsRekognitionDetectLabelInstance = {
}
}

export type AwsRekognitionDetectLabel = {
Confidence: number
Name: string
export type AwsLabel<T> = T & { Confidence: number; Name: string }

export type AwsRekognitionDetectLabel = AwsLabel<{
Parents: AwsRekognitionDetectLabelParent[]
Instances: AwsRekognitionDetectLabelInstance[]
}
}>

export type AwsRekognitionDetectLabels = {
data: {
LabelModelVersion: string
Labels: AwsRekognitionDetectLabel[]
}
} & TechFieldsAppData
export type AwsRekognitionDetectLabels = AddonData<{
LabelModelVersion: string
Labels: AwsRekognitionDetectLabel[]
}>

export type AwsRekognitionDetectModerationLabel = Pick<
AwsRekognitionDetectLabel,
'Confidence' | 'Name'
> & { ParentName: string }
export type AwsRekognitionDetectModerationLabel = AwsLabel<{
ParentName: string
}>

export type AwsRekognitionDetectModerationLabels = {
data: {
ModerationModelVersion: string
ModerationLabels: AwsRekognitionDetectModerationLabel[]
}
} & TechFieldsAppData
export type AwsRekognitionDetectModerationLabels = AddonData<{
ModerationModelVersion: string
ModerationLabels: AwsRekognitionDetectModerationLabel[]
}>

export type RemoveBg = {
data: {
foreground_type: string
}
} & TechFieldsAppData
export type RemoveBg = AddonData<{
foreground_type: string
}>

export type AppData = {
[AddonName.UC_CLAMAV_VIRUS_SCAN]?: ClamavVirusScan
[AddonName.AWS_REKOGNITION_DETECT_LABELS]?: AwsRekognitionDetectLabels
[AddonName.AWS_REKOGNITION_DETECT_MODERATION_LABELS]: AwsRekognitionDetectModerationLabels
[AddonName.AWS_REKOGNITION_DETECT_MODERATION_LABELS]?: AwsRekognitionDetectModerationLabels
[AddonName.REMOVE_BG]?: RemoveBg
}
2 changes: 1 addition & 1 deletion packages/rest-client/src/types/ConversionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ConversionType } from './ConversionType'
import { StoreValue } from '@uploadcare/api-client-utils'
import { ValueOf } from './ValueOf'

type BaseConversionOption<T> = {
export type BaseConversionOption<T> = {
type: T
paths: string[]
store?: StoreValue
Expand Down

0 comments on commit 9aaec7a

Please sign in to comment.