Skip to content

Commit

Permalink
升级keq并重新构建sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Val-istar-Guo committed Aug 13, 2024
1 parent d8461f8 commit 124ec9c
Show file tree
Hide file tree
Showing 35 changed files with 1,215 additions and 237 deletions.
2 changes: 1 addition & 1 deletion app/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"get-stream": "^9.0.1",
"into-stream": "^8.0.1",
"json-schema-typed": "^7.0.3",
"keq": "^2.7.1",
"keq": "^2.7.3",
"keq-debug": "^2.0.5",
"keq-headers": "^2.0.4",
"mime": "^4.0.3",
Expand Down
90 changes: 45 additions & 45 deletions app/backend/pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions app/compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"handlebars": "^4.7.8",
"into-stream": "^8.0.1",
"json-schema-typed": "^7.0.3",
"keq": "^2.7.1",
"keq": "^2.7.3",
"keq-debug": "^2.0.5",
"keq-headers": "^2.0.4",
"mime": "^4.0.3",
Expand Down Expand Up @@ -82,7 +82,7 @@
"@typescript-eslint/parser": "^7.13.1",
"eslint": "^8.57.0",
"jest": "29.7.0",
"keq-cli": "^4.5.7",
"keq-cli": "^4.6.4",
"source-map-support": "^0.5.21",
"supertest": "^7.0.0",
"ts-jest": "29.1.5",
Expand Down
363 changes: 310 additions & 53 deletions app/compiler/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/compiler/src/api/backend/components/schemas/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface Plugin {
/**
* 编译器状态
*/
"status": "disabled" | "enabled"
"status": "disabled" | "enabled" | "breakdown"
/**
* 编译器地址
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface PluginMetadata {
*/
"apiVersion": string
/**
* Compiler 选项
* Plugin 选项
*/
"options"?: (PluginOptionDefinition)[]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export interface UpdatePluginDTO {
/**
* 编译器状态
*/
"status"?: "disabled" | "enabled"
"status"?: "disabled" | "enabled" | "breakdown"
"options"?: (UpdatePluginOptionDTO)[]
}
17 changes: 17 additions & 0 deletions app/compiler/src/api/backend/create_plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Keq } from 'keq'
import { request } from 'keq'
import type { RequestParameters, ResponseMap, Operation } from "./types/create_plugin"



export function createPlugin<STATUS extends keyof ResponseMap>(arg?: RequestParameters): Keq<ResponseMap[STATUS], Operation<STATUS>> {
const req = request.post<ResponseMap[STATUS]>("/api/plugin")
.option('module', {
name: "backend",
pathname: "/api/plugin",
})

if (arg && "url" in arg) req.send({ "url": arg["url"] })

return req as unknown as Keq<ResponseMap[STATUS], Operation<STATUS>>
}
17 changes: 17 additions & 0 deletions app/compiler/src/api/backend/delete_plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Keq } from 'keq'
import { request } from 'keq'
import type { RequestParameters, ResponseMap, Operation } from "./types/delete_plugin"



export function deletePlugin<STATUS extends keyof ResponseMap>(arg?: RequestParameters): Keq<ResponseMap[STATUS], Operation<STATUS>> {
const req = request.delete<ResponseMap[STATUS]>("/api/plugin/:pluginId")
.option('module', {
name: "backend",
pathname: "/api/plugin/:pluginId",
})

if (arg && "pluginId" in arg) req.params("pluginId", String(arg["pluginId"]))

return req as unknown as Keq<ResponseMap[STATUS], Operation<STATUS>>
}
10 changes: 5 additions & 5 deletions app/compiler/src/api/backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export * from "./query_sheet_versions"
export * from "./query_sheet_version"
export * from "./query_sdks"
export * from "./query_sdk"
export * from "./query_compilers"
export * from "./create_compiler"
export * from "./query_compiler"
export * from "./update_compiler"
export * from "./delete_compiler"
export * from "./query_plugins"
export * from "./create_plugin"
export * from "./query_plugin"
export * from "./update_plugin"
export * from "./delete_plugin"
17 changes: 17 additions & 0 deletions app/compiler/src/api/backend/query_plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Keq } from 'keq'
import { request } from 'keq'
import type { RequestParameters, ResponseMap, Operation } from "./types/query_plugin"



export function queryPlugin<STATUS extends keyof ResponseMap>(arg?: RequestParameters): Keq<ResponseMap[STATUS], Operation<STATUS>> {
const req = request.get<ResponseMap[STATUS]>("/api/plugin/:pluginId")
.option('module', {
name: "backend",
pathname: "/api/plugin/:pluginId",
})

if (arg && "pluginId" in arg) req.params("pluginId", String(arg["pluginId"]))

return req as unknown as Keq<ResponseMap[STATUS], Operation<STATUS>>
}
20 changes: 20 additions & 0 deletions app/compiler/src/api/backend/query_plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Keq } from 'keq'
import { request } from 'keq'
import type { RequestParameters, ResponseMap, Operation } from "./types/query_plugins"



export function queryPlugins<STATUS extends keyof ResponseMap>(arg?: RequestParameters): Keq<ResponseMap[STATUS], Operation<STATUS>> {
const req = request.get<ResponseMap[STATUS]>("/api/plugin")
.option('module', {
name: "backend",
pathname: "/api/plugin",
})

const queryWrap = (value: any) => typeof value === 'boolean' ? String(value) : value

if (arg && "limit" in arg) req.query("limit", queryWrap(arg["limit"]))
if (arg && "offset" in arg) req.query("offset", queryWrap(arg["offset"]))

return req as unknown as Keq<ResponseMap[STATUS], Operation<STATUS>>
}
31 changes: 31 additions & 0 deletions app/compiler/src/api/backend/types/create_plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { KeqOperation } from 'keq'
import type { Plugin } from "../components/schemas/plugin"
import type { CreatePluginDTO } from "../components/schemas/create_plugin_dto"


export interface ResponseMap {
"201": Plugin
}


export type QueryParameters = {
}

export type RouteParameters = {
}

export type HeaderParameters = {
}

export type BodyParameters =(CreatePluginDTO)

export type RequestParameters = QueryParameters & RouteParameters & HeaderParameters & BodyParameters


export interface Operation<STATUS extends keyof ResponseMap> extends KeqOperation {
requestParams: RouteParameters
requestQuery: QueryParameters
requestHeaders: HeaderParameters
requestBody: BodyParameters
responseBody: ResponseMap[STATUS]
}
30 changes: 30 additions & 0 deletions app/compiler/src/api/backend/types/delete_plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { KeqOperation } from 'keq'
import type { Plugin } from "../components/schemas/plugin"


export interface ResponseMap {
"200": Plugin
}


export type QueryParameters = {
}

export type RouteParameters = {
"pluginId": string
}

export type HeaderParameters = {
}

export type BodyParameters ={}
export type RequestParameters = QueryParameters & RouteParameters & HeaderParameters & BodyParameters


export interface Operation<STATUS extends keyof ResponseMap> extends KeqOperation {
requestParams: RouteParameters
requestQuery: QueryParameters
requestHeaders: HeaderParameters
requestBody: BodyParameters
responseBody: ResponseMap[STATUS]
}
4 changes: 2 additions & 2 deletions app/compiler/src/api/backend/types/query_api_files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export interface ResponseMap {
export type QueryParameters = {
"sheetId": string
"version"?: string
"limit"?: string
"offset"?: string
"limit"?: number
"offset"?: number
}

export type RouteParameters = {
Expand Down
4 changes: 2 additions & 2 deletions app/compiler/src/api/backend/types/query_applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export interface ResponseMap {
export type QueryParameters = {
"title"?: string
"code"?: string
"limit"?: string
"offset"?: string
"limit"?: number
"offset"?: number
}

export type RouteParameters = {
Expand Down
30 changes: 30 additions & 0 deletions app/compiler/src/api/backend/types/query_plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { KeqOperation } from 'keq'
import type { Plugin } from "../components/schemas/plugin"


export interface ResponseMap {
"200": Plugin
}


export type QueryParameters = {
}

export type RouteParameters = {
"pluginId": string
}

export type HeaderParameters = {
}

export type BodyParameters ={}
export type RequestParameters = QueryParameters & RouteParameters & HeaderParameters & BodyParameters


export interface Operation<STATUS extends keyof ResponseMap> extends KeqOperation {
requestParams: RouteParameters
requestQuery: QueryParameters
requestHeaders: HeaderParameters
requestBody: BodyParameters
responseBody: ResponseMap[STATUS]
}
31 changes: 31 additions & 0 deletions app/compiler/src/api/backend/types/query_plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { KeqOperation } from 'keq'
import type { ResponseOfQueryPluginsDTO } from "../components/schemas/response_of_query_plugins_dto"


export interface ResponseMap {
"200": ResponseOfQueryPluginsDTO
}


export type QueryParameters = {
"limit"?: number
"offset"?: number
}

export type RouteParameters = {
}

export type HeaderParameters = {
}

export type BodyParameters ={}
export type RequestParameters = QueryParameters & RouteParameters & HeaderParameters & BodyParameters


export interface Operation<STATUS extends keyof ResponseMap> extends KeqOperation {
requestParams: RouteParameters
requestQuery: QueryParameters
requestHeaders: HeaderParameters
requestBody: BodyParameters
responseBody: ResponseMap[STATUS]
}
4 changes: 2 additions & 2 deletions app/compiler/src/api/backend/types/query_sdks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export interface ResponseMap {
export type QueryParameters = {
"sheetId"?: string
"version"?: string
"limit"?: string
"offset"?: string
"limit"?: number
"offset"?: number
}

export type RouteParameters = {
Expand Down
4 changes: 2 additions & 2 deletions app/compiler/src/api/backend/types/query_sheet_versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export interface ResponseMap {

export type QueryParameters = {
"sheetId": string
"limit"?: string
"offset"?: string
"limit"?: number
"offset"?: number
}

export type RouteParameters = {
Expand Down
4 changes: 2 additions & 2 deletions app/compiler/src/api/backend/types/query_sheets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export type QueryParameters = {
"title"?: string
"type"?: string
"applicationId"?: string
"limit"?: string
"offset"?: string
"limit"?: number
"offset"?: number
}

export type RouteParameters = {
Expand Down
32 changes: 32 additions & 0 deletions app/compiler/src/api/backend/types/update_plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { KeqOperation } from 'keq'
import type { Plugin } from "../components/schemas/plugin"
import type { UpdatePluginDTO } from "../components/schemas/update_plugin_dto"


export interface ResponseMap {
"200": Plugin
}


export type QueryParameters = {
}

export type RouteParameters = {
"pluginId": string
}

export type HeaderParameters = {
}

export type BodyParameters =(UpdatePluginDTO)

export type RequestParameters = QueryParameters & RouteParameters & HeaderParameters & BodyParameters


export interface Operation<STATUS extends keyof ResponseMap> extends KeqOperation {
requestParams: RouteParameters
requestQuery: QueryParameters
requestHeaders: HeaderParameters
requestBody: BodyParameters
responseBody: ResponseMap[STATUS]
}
19 changes: 19 additions & 0 deletions app/compiler/src/api/backend/update_plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Keq } from 'keq'
import { request } from 'keq'
import type { RequestParameters, ResponseMap, Operation } from "./types/update_plugin"



export function updatePlugin<STATUS extends keyof ResponseMap>(arg?: RequestParameters): Keq<ResponseMap[STATUS], Operation<STATUS>> {
const req = request.put<ResponseMap[STATUS]>("/api/plugin/:pluginId")
.option('module', {
name: "backend",
pathname: "/api/plugin/:pluginId",
})

if (arg && "pluginId" in arg) req.params("pluginId", String(arg["pluginId"]))
if (arg && "status" in arg) req.send({ "status": arg["status"] })
if (arg && "options" in arg) req.send({ "options": arg["options"] })

return req as unknown as Keq<ResponseMap[STATUS], Operation<STATUS>>
}
4 changes: 2 additions & 2 deletions app/frontend/api/backend/types/query_api_files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export interface ResponseMap {
export type QueryParameters = {
"sheetId": string
"version"?: string
"limit"?: string
"offset"?: string
"limit"?: number
"offset"?: number
}

export type RouteParameters = {
Expand Down
4 changes: 2 additions & 2 deletions app/frontend/api/backend/types/query_applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export interface ResponseMap {
export type QueryParameters = {
"title"?: string
"code"?: string
"limit"?: string
"offset"?: string
"limit"?: number
"offset"?: number
}

export type RouteParameters = {
Expand Down
Loading

0 comments on commit 124ec9c

Please sign in to comment.