Skip to content

Commit 01e0331

Browse files
viambotgithub-actions[bot]
authored andcommitted
[WORKFLOW] AI update based on proto changes from commit 4676591
1 parent 369de2e commit 01e0331

File tree

4 files changed

+149
-4
lines changed

4 files changed

+149
-4
lines changed

src/app/data-client.spec.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import {
2525
ConfigureDatabaseUserResponse,
2626
CreateIndexRequest,
2727
CreateIndexResponse,
28+
CreateBinaryDataSignedURLRequest,
29+
CreateBinaryDataSignedURLResponse,
2830
DataRequest,
2931
DeleteBinaryDataByFilterRequest,
3032
DeleteBinaryDataByFilterResponse,
@@ -1229,6 +1231,52 @@ describe('DataClient tests', () => {
12291231
});
12301232
});
12311233

1234+
describe('createBinaryDataSignedURL tests', () => {
1235+
const binaryDataId = 'testBinaryDataId';
1236+
const signedUrl = 'https://example.com/signed-url';
1237+
const expiresAt = new Date(2025, 0, 1, 12, 0, 0); // Jan 1, 2025 12:00:00
1238+
const expirationMinutes = 60;
1239+
1240+
let capReq: CreateBinaryDataSignedURLRequest;
1241+
beforeEach(() => {
1242+
mockTransport = createRouterTransport(({ service }) => {
1243+
service(DataService, {
1244+
createBinaryDataSignedURL: (req) => {
1245+
capReq = req;
1246+
return new CreateBinaryDataSignedURLResponse({
1247+
signedUrl,
1248+
expiresAt: Timestamp.fromDate(expiresAt),
1249+
});
1250+
},
1251+
});
1252+
});
1253+
});
1254+
1255+
it('creates a binary data signed URL with default expiration', async () => {
1256+
const expectedRequest = new CreateBinaryDataSignedURLRequest({
1257+
binaryDataId,
1258+
});
1259+
1260+
const result = await subject().createBinaryDataSignedURL(binaryDataId);
1261+
expect(capReq).toStrictEqual(expectedRequest);
1262+
expect(result).toEqual({ signedUrl, expiresAt });
1263+
});
1264+
1265+
it('creates a binary data signed URL with specified expiration', async () => {
1266+
const expectedRequest = new CreateBinaryDataSignedURLRequest({
1267+
binaryDataId,
1268+
expirationMinutes,
1269+
});
1270+
1271+
const result = await subject().createBinaryDataSignedURL(
1272+
binaryDataId,
1273+
expirationMinutes
1274+
);
1275+
expect(capReq).toStrictEqual(expectedRequest);
1276+
expect(result).toEqual({ signedUrl, expiresAt });
1277+
});
1278+
});
1279+
12321280
describe('createFilter tests', () => {
12331281
it('create empty filter', () => {
12341282
const testFilter = DataClient.createFilter({});
@@ -2037,4 +2085,4 @@ describe('fileUpload tests', () => {
20372085

20382086
expect(receivedData).toStrictEqual(data);
20392087
});
2040-
});
2088+
});

src/app/data-client.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import {
1818
TabularDataSource,
1919
TabularDataSourceType,
2020
TagsFilter,
21+
CreateBinaryDataSignedURLRequest,
22+
CreateBinaryDataSignedURLResponse,
2123
} from '../gen/app/data/v1/data_pb';
2224
import { DataPipelinesService } from '../gen/app/datapipelines/v1/data_pipelines_connect';
2325
import {
@@ -1737,6 +1739,43 @@ export class DataClient {
17371739
pipelineName,
17381740
});
17391741
}
1742+
1743+
/**
1744+
* CreateBinaryDataSignedURL creates a temporary public URL for a binary data file.
1745+
*
1746+
* @example
1747+
*
1748+
* ```ts
1749+
* const { signedUrl, expiresAt } = await dataClient.createBinaryDataSignedURL(
1750+
* 'ccb74b53-1235-4328-a4b9-91dff1915a50/x5vur1fmps/YAEzj5I1kTwtYsDdf4a7ctaJpGgKRHmnM9bJNVyblk52UpqmrnMVTITaBKZctKEh',
1751+
* 60 // Expiration in minutes
1752+
* );
1753+
* console.log('Signed URL:', signedUrl);
1754+
* console.log('Expires At:', expiresAt);
1755+
* ```
1756+
*
1757+
* For more information, see [Data
1758+
* API](https://docs.viam.com/dev/reference/apis/data-client/#createbinarydatasignedurl).
1759+
*
1760+
* @param binaryDataId The binary data ID of the file to create a signed URL for.
1761+
* @param expirationMinutes Optional expiration time in minutes. Defaults to 15 minutes if not specified.
1762+
* Maximum allowed is 10080 minutes (7 days).
1763+
* @returns An object containing the signed URL and its expiration time.
1764+
*/
1765+
async createBinaryDataSignedURL(
1766+
binaryDataId: string,
1767+
expirationMinutes?: number
1768+
): Promise<{ signedUrl: string; expiresAt: Date }> {
1769+
const req = new CreateBinaryDataSignedURLRequest({
1770+
binaryDataId,
1771+
expirationMinutes,
1772+
});
1773+
const resp = await this.dataClient.createBinaryDataSignedURL(req);
1774+
return {
1775+
signedUrl: resp.signedUrl,
1776+
expiresAt: resp.expiresAt!.toDate(), // eslint-disable-line @typescript-eslint/no-non-null-assertion
1777+
};
1778+
}
17401779
}
17411780

17421781
export class ListDataPipelineRunsPage {
@@ -1793,5 +1832,7 @@ export {
17931832
type BinaryID,
17941833
type IndexableCollection,
17951834
type Order,
1835+
CreateBinaryDataSignedURLRequest,
1836+
CreateBinaryDataSignedURLResponse,
17961837
} from '../gen/app/data/v1/data_pb';
17971838
export { type UploadMetadata } from '../gen/app/datasync/v1/data_sync_pb';

src/components/gantry/client.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { RobotClient } from '../../robot';
1313
import type { Options } from '../../types';
1414
import { doCommandFromClient } from '../../utils';
1515
import type { Gantry } from './gantry';
16-
import { GetGeometriesRequest } from '../../gen/common/v1/common_pb';
16+
import { GetGeometriesRequest, GetKinematicsRequest, GetKinematicsResponse, KinematicParamType } from '../../gen/common/v1/common_pb';
1717

1818
/**
1919
* A gRPC-web client for the Gantry component.
@@ -42,6 +42,32 @@ export class GantryClient implements Gantry {
4242
return response.geometries;
4343
}
4444

45+
async getKinematics(extra = {}, callOptions = this.callOptions) {
46+
const request = new GetKinematicsRequest({
47+
name: this.name,
48+
extra: Struct.fromJson(extra),
49+
});
50+
51+
this.options.requestLogger?.(request);
52+
53+
const resp = await this.client.getKinematics(request, callOptions);
54+
const { kinematicsData } = resp;
55+
if (!kinematicsData) {
56+
throw new Error('No kinematics data');
57+
}
58+
return {
59+
name: this.name,
60+
kinematic_param_type: KinematicParamType[
61+
kinematicsData.kinematicParamType
62+
].replace('KINEMATIC_PARAM_TYPE_', '') as
63+
| 'SVA'
64+
| 'URDF'
65+
| 'UNSPECIFIED',
66+
joints: kinematicsData.joints,
67+
links: kinematicsData.links,
68+
};
69+
}
70+
4571
async getPosition(extra = {}, callOptions = this.callOptions) {
4672
const request = new GetPositionRequest({
4773
name: this.name,
@@ -130,4 +156,4 @@ export class GantryClient implements Gantry {
130156
callOptions
131157
);
132158
}
133-
}
159+
}

src/components/gantry/gantry.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { Struct } from '@bufbuild/protobuf';
22
import type { Resource } from '../../types';
33
import type { Geometry } from '../../gen/common/v1/common_pb';
4+
import type { Frame } from '../../gen/app/v1/robot_pb';
5+
import type { Vector3 } from '../../types';
46

57
/** Represents a physical gantry that exists in three-dimensional space. */
68
export interface Gantry extends Resource {
@@ -21,6 +23,34 @@ export interface Gantry extends Resource {
2123
*/
2224
getGeometries: (extra?: Struct) => Promise<Geometry[]>;
2325

26+
/**
27+
* Get the kinematics information associated with the gantry.
28+
*
29+
* @example
30+
*
31+
* ```ts
32+
* const gantry = new VIAM.GantryClient(machine, 'my_gantry');
33+
* const kinematics = await gantry.getKinematics();
34+
* console.log(kinematics);
35+
* ```
36+
*
37+
* For more information, see [Gantry
38+
* API](https://docs.viam.com/dev/reference/apis/components/gantry/#getkinematics).
39+
*/
40+
getKinematics: (extra?: Struct) => Promise<{
41+
name: string;
42+
kinematic_param_type: 'SVA' | 'URDF' | 'UNSPECIFIED';
43+
joints: {
44+
id: string;
45+
type: string;
46+
parent: string;
47+
axis: Vector3;
48+
max: number;
49+
min: number;
50+
}[];
51+
links: Frame[];
52+
}>;
53+
2454
/**
2555
* Move each axis of the gantry to the positionsMm at the speeds in
2656
* speedsMmPerSec.
@@ -144,4 +174,4 @@ export interface Gantry extends Resource {
144174
* API](https://docs.viam.com/dev/reference/apis/components/gantry/#ismoving).
145175
*/
146176
isMoving: () => Promise<boolean>;
147-
}
177+
}

0 commit comments

Comments
 (0)