41 lines
861 B
TypeScript
41 lines
861 B
TypeScript
/**
|
|
* 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,
|
|
}
|