-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.ts
47 lines (41 loc) · 1.2 KB
/
mod.ts
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
import type { TransformerArgs } from '@skmtc/skmtc/schematic-types'
import { Endpoint } from './src/Endpoint.ts'
import { QueryContainer } from './src/Container.ts'
import { withDescription } from '@skmtc/skmtc/typescript'
const transform = ({ context, transformerSettings }: TransformerArgs) => {
const operations = context.schemaModel.operations
.map(operation => {
const settings = transformerSettings.getOperationSettings({
path: operation.path,
method: operation.method
})
return {
operation,
settings
}
})
.filter(({ settings }) => settings.isSelected())
.map(({ operation, settings }, index) => {
console.log(
`${index}. `.padEnd(5),
operation.method.toUpperCase().padEnd(8),
operation.path
)
return withDescription(
Endpoint.create({ context, operation, settings }),
operation.description
)
})
const rtkContainer = QueryContainer.create({
context,
transformerSettings,
operations
})
context.register({
content: rtkContainer,
destinationPath: transformerSettings.getExportPath({
appendFileName: true
})
})
}
export default transform