Skip to content

Commit 96760b9

Browse files
committed
feat(proto): add protocol to HostBody
1 parent fd8abaa commit 96760b9

16 files changed

Lines changed: 171 additions & 88 deletions

gen/openapi/user/v1/user_service.swagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@
234234
"USER_STATUS_WAIT_EMAIL_CHECK"
235235
],
236236
"default": "USER_STATUS_UNSPECIFIED",
237-
"title": "- USER_STATUS_DISABLED: 封禁\n - USER_STATUS_NORMAL: 正常\n - USER_STATUS_WAIT_EMAIL_CHECK: 等待验证邮箱"
237+
"description": "- USER_STATUS_DISABLED: 封禁\n - USER_STATUS_NORMAL: 正常\n - USER_STATUS_WAIT_EMAIL_CHECK: 等待验证邮箱"
238238
}
239239
}
240240
}

gen/proto/fetch.pb.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,23 @@ export function replacer(key: any, value: any): any {
117117
return value;
118118
}
119119

120+
function dateReviver(key, value) {
121+
// check if value match ISO 8601 date format
122+
if (typeof value === "string" && /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(.\d+)?(Z)?$/.test(value)) {
123+
return new Date(value);
124+
}
125+
return value;
126+
}
127+
120128
export function fetchReq<I, O>(path: string, init?: InitReq): Promise<O> {
121129
const {pathPrefix, ...req} = init || {}
122130

123131
const url = pathPrefix ? `${pathPrefix}${path}` : path
124132

125-
return fetch(url, req).then(r => r.json().then((body: O) => {
126-
if (!r.ok) { throw body; }
127-
return body;
128-
})) as Promise<O>
133+
return fetch(url, req).then(async r=> {
134+
if (!r.ok){throw await r.json()}
135+
return JSON.parse(await r.text(), dateReviver);
136+
}) as Promise<O>
129137
}
130138

131139
// NotifyStreamEntityArrival is a callback that will be called on streaming entity arrival
@@ -301,6 +309,8 @@ function flattenRequestPayload<T extends RequestPayload>(
301309
objectToMerge = flattenRequestPayload(value as RequestPayload, newPath);
302310
} else if (isNonZeroValuePrimitive || isNonEmptyPrimitiveArray) {
303311
objectToMerge = { [newPath]: value };
312+
} else if (value instanceof Date){
313+
objectToMerge = { [newPath]: value.toISOString() };
304314
}
305315

306316
return { ...acc, ...objectToMerge };

gen/proto/sync/v1/config_body.pb.go

Lines changed: 89 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/proto/sync/v1/config_body.pb.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66

77
import * as SyncV1Audit from "./audit.pb"
88
import * as SyncV1Port_forward from "./port_forward.pb"
9+
10+
export enum HostProtocol {
11+
HOST_PROTOCOL_UNSPECIFIED = "HOST_PROTOCOL_UNSPECIFIED",
12+
HOST_PROTOCOL_SSH = "HOST_PROTOCOL_SSH",
13+
HOST_PROTOCOL_TELNET = "HOST_PROTOCOL_TELNET",
14+
}
15+
916
export type SshKeyBody = {
1017
label?: string
1118
privateKey?: string
@@ -37,6 +44,7 @@ export type HostBody = {
3744
identityId?: string
3845
proxyHostIds?: string[]
3946
forwardAgent?: boolean
47+
protocol?: HostProtocol
4048
}
4149

4250
export type PortForwardBody = {

gen/proto/sync/v1/host.pb.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
* This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
55
*/
66

7-
import * as GoogleProtobufTimestamp from "../../google/protobuf/timestamp.pb"
87
export type Host = {
98
id?: string
10-
createdAt?: GoogleProtobufTimestamp.Timestamp
11-
updatedAt?: GoogleProtobufTimestamp.Timestamp
12-
deletedAt?: GoogleProtobufTimestamp.Timestamp
9+
createdAt?: Date
10+
updatedAt?: Date
11+
deletedAt?: Date
1312
clientId?: string
1413
label?: string
1514
tags?: string[]

gen/proto/sync/v1/keychain.pb.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
* This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
55
*/
66

7-
import * as GoogleProtobufTimestamp from "../../google/protobuf/timestamp.pb"
87
export type SshKey = {
98
id?: string
10-
createdAt?: GoogleProtobufTimestamp.Timestamp
11-
updatedAt?: GoogleProtobufTimestamp.Timestamp
12-
deletedAt?: GoogleProtobufTimestamp.Timestamp
9+
createdAt?: Date
10+
updatedAt?: Date
11+
deletedAt?: Date
1312
clientId?: string
1413
label?: string
1514
privateKey?: string
@@ -19,9 +18,9 @@ export type SshKey = {
1918

2019
export type Identity = {
2120
id?: string
22-
createdAt?: GoogleProtobufTimestamp.Timestamp
23-
updatedAt?: GoogleProtobufTimestamp.Timestamp
24-
deletedAt?: GoogleProtobufTimestamp.Timestamp
21+
createdAt?: Date
22+
updatedAt?: Date
23+
deletedAt?: Date
2524
clientId?: string
2625
label?: string
2726
username?: string

gen/proto/sync/v1/known_hosts.pb.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
* This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
55
*/
66

7-
import * as GoogleProtobufTimestamp from "../../google/protobuf/timestamp.pb"
87
export type KnownHost = {
98
id?: string
10-
createdAt?: GoogleProtobufTimestamp.Timestamp
11-
updatedAt?: GoogleProtobufTimestamp.Timestamp
12-
deletedAt?: GoogleProtobufTimestamp.Timestamp
9+
createdAt?: Date
10+
updatedAt?: Date
11+
deletedAt?: Date
1312
clientId?: string
1413
address?: string
1514
publicKey?: string

gen/proto/sync/v1/port_forward.pb.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
55
*/
66

7-
import * as GoogleProtobufTimestamp from "../../google/protobuf/timestamp.pb"
87

98
export enum PortForwardType {
109
PORT_FORWARD_TYPE_UNSPECIFIED = "PORT_FORWARD_TYPE_UNSPECIFIED",
@@ -15,9 +14,9 @@ export enum PortForwardType {
1514

1615
export type PortForward = {
1716
id?: string
18-
createdAt?: GoogleProtobufTimestamp.Timestamp
19-
updatedAt?: GoogleProtobufTimestamp.Timestamp
20-
deletedAt?: GoogleProtobufTimestamp.Timestamp
17+
createdAt?: Date
18+
updatedAt?: Date
19+
deletedAt?: Date
2120
clientId?: string
2221
label?: string
2322
type?: PortForwardType

gen/proto/sync/v1/sync_service.pb.gw.go

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)