feat: steps system infra
This commit is contained in:
40
packages/hoppscotch-app/helpers/import-export/steps.ts
Normal file
40
packages/hoppscotch-app/helpers/import-export/steps.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Defines which type of content a Step returns.
|
||||
* Add an entry here when you define a step
|
||||
*/
|
||||
export type StepReturnTypes = {
|
||||
FILE_OR_URL_IMPORT: string // String content of the file/url
|
||||
TARGET_MY_COLLECTION: number // folderPath
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines what the data structure of a step
|
||||
*/
|
||||
export type Step<T extends keyof StepReturnTypes> = {
|
||||
name: T
|
||||
caption?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* The return output value of an individual step
|
||||
*/
|
||||
export type StepReturnType<T> = T extends Step<infer U>
|
||||
? StepReturnTypes[U]
|
||||
: never
|
||||
|
||||
/**
|
||||
* Defines the value of the output list generated by a step
|
||||
*/
|
||||
export type StepsOutputList<T> = {
|
||||
[K in keyof T]: StepReturnType<T[K]>
|
||||
}
|
||||
|
||||
/** Use this function to define a step */
|
||||
export const step = <T extends keyof StepReturnTypes>(
|
||||
stepName: T,
|
||||
caption?: string
|
||||
) =>
|
||||
<Step<T>>{
|
||||
name: stepName,
|
||||
caption,
|
||||
}
|
||||
Reference in New Issue
Block a user