Skip to content

Commit 605e6b5

Browse files
committed
feat(sync): add snippet team config payload
This adds the snippet config kind and payload schema so snippets can round-trip through TeamConfig sync records.
1 parent d1270a8 commit 605e6b5

15 files changed

Lines changed: 152 additions & 54 deletions

gen/openapi/sync/v1/sync_service.swagger.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@
312312
"TEAM_CONFIG_KIND_IDENTITY",
313313
"TEAM_CONFIG_KIND_KNOWN_HOST",
314314
"TEAM_CONFIG_KIND_HOST",
315-
"TEAM_CONFIG_KIND_PORT_FORWARD"
315+
"TEAM_CONFIG_KIND_PORT_FORWARD",
316+
"TEAM_CONFIG_KIND_SNIPPET"
316317
],
317318
"default": "TEAM_CONFIG_KIND_UNSPECIFIED"
318319
},

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: 80 additions & 5 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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,11 @@ export type PortForwardBody = {
4545
targetPort?: number
4646
chainHostIds?: string[]
4747
autoStart?: boolean
48+
}
49+
50+
export type SnippetBody = {
51+
name?: string
52+
script?: string
53+
package?: string[]
54+
sortOrder?: string
4855
}

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.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
*/
66

77
import * as fm from "../../fetch.pb"
8-
import * as GoogleProtobufTimestamp from "../../google/protobuf/timestamp.pb"
98
import * as TeamV1Team from "../../team/v1/team.pb"
109
import * as UserV1Key_wallet from "../../user/v1/key_wallet.pb"
1110
import * as SyncV1Team_config from "./team_config.pb"
1211
export type SyncConfigRequest = {
13-
after?: GoogleProtobufTimestamp.Timestamp
12+
after?: Date
1413
teamId?: string
1514
}
1615

1716
export type SyncConfigResponse = {
18-
serverTime?: GoogleProtobufTimestamp.Timestamp
17+
serverTime?: Date
1918
records?: SyncV1Team_config.TeamConfigRecord[]
2019
}
2120

@@ -25,25 +24,25 @@ export type UpdateConfigRequest = {
2524
}
2625

2726
export type UpdateConfigResponse = {
28-
serverTime?: GoogleProtobufTimestamp.Timestamp
27+
serverTime?: Date
2928
record?: SyncV1Team_config.TeamConfigRecord
3029
}
3130

3231
export type SyncTeamRequest = {
33-
after?: GoogleProtobufTimestamp.Timestamp
32+
after?: Date
3433
}
3534

3635
export type SyncTeamResponse = {
37-
serverTime?: GoogleProtobufTimestamp.Timestamp
36+
serverTime?: Date
3837
teams?: TeamV1Team.Team[]
3938
}
4039

4140
export type SyncUserKeyWalletRequest = {
42-
after?: GoogleProtobufTimestamp.Timestamp
41+
after?: Date
4342
}
4443

4544
export type SyncUserKeyWalletResponse = {
46-
serverTime?: GoogleProtobufTimestamp.Timestamp
45+
serverTime?: Date
4746
publicKey?: string
4847
encryptedPrivateKey?: string
4948
userKeyWalletSet?: UserV1Key_wallet.UserKeyWallet[]
@@ -59,7 +58,7 @@ export type UpdateUserKeyWalletResponse = {
5958
publicKey?: string
6059
encryptedPrivateKey?: string
6160
userKeyWalletSet?: UserV1Key_wallet.UserKeyWallet[]
62-
serverTime?: GoogleProtobufTimestamp.Timestamp
61+
serverTime?: Date
6362
}
6463

6564
export class SyncService {

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

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

0 commit comments

Comments
 (0)