Changing how types are generated from the open api spec a bit.
This commit is contained in:
parent
2436bc2e32
commit
2603024792
|
@ -25,7 +25,7 @@
|
|||
"generate:proxy:preprod": "node scripts/proxy/generateProxyConfig preprod",
|
||||
"generate:proxy:prod": "node scripts/proxy/generateProxyConfig prod",
|
||||
"format": "prettier --config ../../.prettierrc.json 'src/**/*.ts' --write",
|
||||
"specs": "node specs/generate.js && openapi-typescript specs/openapi.yaml --output src/api/controllers/public/types/openapi.ts",
|
||||
"specs": "node specs/generate.js && openapi-typescript specs/openapi.yaml --output src/definitions/openapi.ts",
|
||||
"lint": "eslint --fix src/",
|
||||
"lint:fix": "yarn run format && yarn run lint",
|
||||
"initialise": "node scripts/initialise.js",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Application, ApplicationOutput } from "../types/components"
|
||||
import { Application, ApplicationOutput } from "./types"
|
||||
|
||||
function application(body: any): Application {
|
||||
let app = body?.application ? body.application : body
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Query, ExecuteQueryOutput } from "../types/components"
|
||||
import { Query, ExecuteQueryOutput } from "./types"
|
||||
|
||||
function query(body: any): Query {
|
||||
return {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Row, RowSearch, RowOutput } from "../types/components"
|
||||
import { Row, RowSearch, RowOutput } from "./types"
|
||||
|
||||
function row(body: any): Row {
|
||||
delete body._rev
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Table, TableOutput } from "../types/components"
|
||||
import { Table, TableOutput } from "./types"
|
||||
|
||||
function table(body: any): Table {
|
||||
return {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { components } from "./openapi"
|
||||
import { components } from "../../../../definitions/openapi"
|
||||
|
||||
export type Query = components["schemas"]["query"]
|
||||
export type ExecuteQueryOutput = components["schemas"]["executeQueryOutput"]
|
|
@ -1,4 +1,4 @@
|
|||
import { User, UserOutput } from "../types/components"
|
||||
import { User, UserOutput } from "./types"
|
||||
|
||||
function user(body: any): User {
|
||||
return {
|
||||
|
|
|
@ -9,12 +9,12 @@ enum Resources {
|
|||
SEARCH = "search",
|
||||
}
|
||||
|
||||
function isSearch(ctx: any) {
|
||||
return ctx.url.endsWith(Resources.SEARCH)
|
||||
function isArrayResponse(ctx: any) {
|
||||
return ctx.url.endsWith(Resources.SEARCH) || Array.isArray(ctx.body)
|
||||
}
|
||||
|
||||
function processApplications(ctx: any) {
|
||||
if (isSearch(ctx)) {
|
||||
if (isArrayResponse(ctx)) {
|
||||
return mapping.mapApplications(ctx)
|
||||
} else {
|
||||
return mapping.mapApplication(ctx)
|
||||
|
@ -22,7 +22,7 @@ function processApplications(ctx: any) {
|
|||
}
|
||||
|
||||
function processTables(ctx: any) {
|
||||
if (isSearch(ctx)) {
|
||||
if (isArrayResponse(ctx)) {
|
||||
return mapping.mapTables(ctx)
|
||||
} else {
|
||||
return mapping.mapTable(ctx)
|
||||
|
@ -30,7 +30,7 @@ function processTables(ctx: any) {
|
|||
}
|
||||
|
||||
function processRows(ctx: any) {
|
||||
if (isSearch(ctx)) {
|
||||
if (isArrayResponse(ctx)) {
|
||||
return mapping.mapRowSearch(ctx)
|
||||
} else {
|
||||
return mapping.mapRow(ctx)
|
||||
|
@ -38,7 +38,7 @@ function processRows(ctx: any) {
|
|||
}
|
||||
|
||||
function processUsers(ctx: any) {
|
||||
if (isSearch(ctx)) {
|
||||
if (isArrayResponse(ctx)) {
|
||||
return mapping.mapUsers(ctx)
|
||||
} else {
|
||||
return mapping.mapUser(ctx)
|
||||
|
@ -46,7 +46,7 @@ function processUsers(ctx: any) {
|
|||
}
|
||||
|
||||
function processQueries(ctx: any) {
|
||||
if (isSearch(ctx)) {
|
||||
if (isArrayResponse(ctx)) {
|
||||
return mapping.mapQueries(ctx)
|
||||
} else {
|
||||
return mapping.mapQueryExecution(ctx)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue