Skip to content

Commit e1f3569

Browse files
authored
Migrate SDK to connect-es (#368)
1 parent b3c06b8 commit e1f3569

File tree

147 files changed

+9541
-11881
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+9541
-11881
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test-watch: $(node_modules) build-buf
3131
lint: $(node_modules) build-buf
3232
npm run lint
3333
npm run typecheck
34-
npm run check
34+
npm run check -- --ignore=@bufbuild/protobuf
3535

3636
.PHONY: format
3737
format: $(node_modules)

buf.gen.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
version: v1
2+
managed:
3+
enabled: true
24
plugins:
3-
- name: js
5+
- plugin: buf.build/connectrpc/es:v1.5.0
46
out: src/gen
5-
opt:
6-
- import_style=commonjs
7-
- name: grpc-web
7+
- plugin: buf.build/bufbuild/es:v1.10.0
88
out: src/gen
9-
opt:
10-
- import_style=commonjs
11-
- mode=grpcwebtext
12-
- name: ts
13-
out: src/gen
14-
opt:
15-
- service=grpc-web

doc/dependency_decisions.yml

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,13 @@
2727
:license_links: https://github.com/bufbuild/buf/blob/main/LICENSE
2828
:versions: []
2929
:when: 2023-05-01 18:09:18.081521457 Z
30-
- - :license
31-
- '@improbable-eng/grpc-web'
32-
- Apache 2.0
33-
- :who:
34-
:why: 'TODO(RSDK-583): why is license finder unable to detect this license automatically?'
35-
:license_links: https://www.npmjs.com/package/@improbable-eng/grpc-web
36-
:versions: []
37-
:when: 2023-05-01 18:11:37.804857463 Z
38-
- - :license
39-
- '@improbable-eng/grpc-web-fake-transport'
40-
- Apache 2.0
41-
- :who:
42-
:why: 'TODO(RSDK-583): why is license finder unable to detect this license automatically?'
43-
:license_links: https://www.npmjs.com/package/@improbable-eng/grpc-web-fake-transport
44-
:versions: []
45-
:when: 2023-05-01 18:11:37.804857463 Z
30+
- - :approve
31+
- "@bufbuild/protobuf"
32+
- :who:
33+
:why:
34+
:versions:
35+
- 1.10.0
36+
:when: 2024-09-30 14:52:13.805002459 Z
4637
- - :license
4738
- '@typescript-eslint/parser'
4839
- BSD-2-Clause
@@ -89,14 +80,6 @@
8980
:license_links: https://github.com/viamrobotics/js-config/blob/main/LICENSE
9081
:versions: []
9182
:when: 2023-12-28 23:30:28.297289000 Z
92-
- - :license
93-
- protoc-gen-js
94-
- MIT
95-
- :who:
96-
:why: 'TODO(RSDK-583): why is license finder unable to detect this license automatically?'
97-
:license_links: https://github.com/yinzara/protoc-gen-js/blob/master/LICENSE
98-
:versions: []
99-
:when: 2023-05-12 14:28:29.173104997 Z
10083
- - :permit
10184
- ISC
10285
- :who:

examples/connect-app-teleop-react/package-lock.json

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

examples/connect-app-teleop-react/src/client.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ import {
55
createViamClient,
66
type AccessToken,
77
type Credential,
8+
type Credentials,
89
type RobotClient,
910
type ViamClient,
1011
} from '@viamrobotics/sdk';
1112

12-
const isAccessToken = (x: Credential | AccessToken): x is AccessToken => {
13-
return x.type === 'access-token';
14-
};
15-
1613
/**
1714
* Given a set of credentials, get a robot client.
1815
*
@@ -25,8 +22,7 @@ export const getRobotClient = async (
2522
): Promise<RobotClient> => {
2623
return createRobotClient({
2724
host: hostname,
28-
credential: credentials,
29-
authEntity: isAccessToken(credentials) ? '' : credentials.authEntity,
25+
credentials,
3026
signalingAddress: 'https://app.viam.com:443',
3127
iceServers: [{ urls: 'stun:global.stun.twilio.com:3478' }],
3228
});
@@ -39,10 +35,10 @@ export const getRobotClient = async (
3935
* @returns A viam client
4036
*/
4137
export const getViamClient = async (
42-
credentials: AccessToken | Credential
38+
credentials: Credentials
4339
): Promise<ViamClient> => {
4440
return createViamClient({
45-
credential: credentials,
41+
credentials,
4642
});
4743
};
4844

examples/connect-app-teleop-react/src/components/locations-list.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { useEffect, useState } from 'react';
33

44
export interface LocationsListProps {
55
appClient: AppClient;
6-
organization: appApi.Organization.AsObject
7-
onLocationSelected: (location: appApi.Location.AsObject) => unknown;
6+
organization: appApi.Organization
7+
onLocationSelected: (location: appApi.Location) => unknown;
88
}
99

1010
export const LocationsList = ({ appClient, organization, onLocationSelected }: LocationsListProps): JSX.Element => {
1111

12-
const [locations, setLocations] = useState<appApi.Location.AsObject[]>([]);
12+
const [locations, setLocations] = useState<appApi.Location[]>([]);
1313
useEffect(() => {
1414
async function getLocations() {
1515
const locations = await appClient.listLocations(organization.id);

examples/connect-app-teleop-react/src/components/machine-part-control.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { appApi, type AccessToken, type Credential } from '@viamrobotics/sdk';
1+
import { appApi, type Credentials } from '@viamrobotics/sdk';
22
import { useMotionControls } from '../motion';
33
import { useRobotClientStore, useStream } from '../state';
44
import { MotionArrows } from './motion-arrows';
55
import { VideoStream } from './video-stream';
66

77
export interface MachinePartControlProps {
8-
credentials: Credential | AccessToken;
9-
machinePart: appApi.RobotPart.AsObject;
8+
credentials: Credentials;
9+
machinePart: appApi.RobotPart;
1010
}
1111

1212
export const MachinePartControl = ({ credentials, machinePart }: MachinePartControlProps): JSX.Element => {

examples/connect-app-teleop-react/src/components/machine-parts-list.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { useEffect, useState } from 'react';
33

44
export interface MachinesPartsListProps {
55
appClient: AppClient;
6-
machine: appApi.Robot.AsObject;
7-
onMachinePartSelected: (machine: appApi.RobotPart.AsObject) => unknown;
6+
machine: appApi.Robot;
7+
onMachinePartSelected: (machine: appApi.RobotPart) => unknown;
88
}
99

1010
export const MachinePartsList = ({ appClient, machine, onMachinePartSelected }: MachinesPartsListProps): JSX.Element => {
11-
const [machineParts, setMachineParts] = useState<appApi.RobotPart.AsObject[]>([]);
11+
const [machineParts, setMachineParts] = useState<appApi.RobotPart[]>([]);
1212
useEffect(() => {
1313
async function getMachineParts() {
1414
const machineParts = await appClient.getRobotParts(machine.id);

examples/connect-app-teleop-react/src/components/machines-list.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { useEffect, useState } from 'react';
33

44
export interface MachinesListProps {
55
appClient: AppClient;
6-
location: appApi.Location.AsObject;
7-
onMachineSelected: (machine: appApi.Robot.AsObject) => unknown;
6+
location: appApi.Location;
7+
onMachineSelected: (machine: appApi.Robot) => unknown;
88
}
99

1010
export const MachinesList = ({ appClient, location, onMachineSelected }: MachinesListProps): JSX.Element => {
11-
const [machines, setMachines] = useState<appApi.Robot.AsObject[]>([]);
11+
const [machines, setMachines] = useState<appApi.Robot[]>([]);
1212
useEffect(() => {
1313
async function getMachines() {
1414
const machines = await appClient.listRobots(location.id);

examples/connect-app-teleop-react/src/components/orgs-list.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { useEffect, useState } from 'react';
33

44
export interface OrganizationsListProps {
55
appClient: AppClient;
6-
onOrganizationSelected: (organization: appApi.Organization.AsObject) => unknown;
6+
onOrganizationSelected: (organization: appApi.Organization) => unknown;
77
}
88

99
export const OrganizationsList = ({ appClient, onOrganizationSelected }: OrganizationsListProps): JSX.Element => {
1010

11-
const [organizations, setOrganizations] = useState<appApi.Organization.AsObject[]>([]);
11+
const [organizations, setOrganizations] = useState<appApi.Organization[]>([]);
1212
useEffect(() => {
1313
async function getLocations() {
1414
const organizations = await appClient.listOrganizations();

0 commit comments

Comments
 (0)