Skip to content

Commit 4d5d1d4

Browse files
viambotgithub-actions[bot]
authored andcommitted
[WORKFLOW] AI update based on proto changes from commit 28f2f05
1 parent 5c29f20 commit 4d5d1d4

File tree

7 files changed

+169
-7
lines changed

7 files changed

+169
-7
lines changed

src/app/app-client.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ describe('AppClient tests', () => {
6969
secrets: [sharedSecret],
7070
secret: 'secret',
7171
fqdn: 'fqdn',
72+
isMainPart: false,
73+
dnsName: 'dns.name.example.com',
7274
});
7375

7476
const logEntry = new LogEntry({

src/app/billing-client.spec.ts

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,23 @@ import {
77
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
88
import { BillingService } from '../gen/app/v1/billing_connect';
99
import {
10+
CreateInvoiceAndChargeImmediatelyRequest,
11+
CreateInvoiceAndChargeImmediatelyResponse,
12+
GetAvailableBillingTiersRequest,
13+
GetAvailableBillingTiersResponse,
14+
GetCurrentMonthUsageRequest,
15+
GetCurrentMonthUsageResponse,
16+
GetInvoicePdfRequest,
1017
GetInvoicePdfResponse,
18+
GetInvoicesSummaryRequest,
1119
GetInvoicesSummaryResponse,
20+
GetOrgBillingInformationRequest,
1221
PaymentMethodType,
1322
ResourceUsageCosts,
1423
ResourceUsageCostsBySource,
24+
SendPaymentRequiredEmailRequest,
1525
SourceType,
26+
UpdateOrganizationBillingTierRequest,
1627
UsageCost,
1728
UsageCostType,
1829
} from '../gen/app/v1/billing_pb';
@@ -162,4 +173,48 @@ describe('BillingClient tests', () => {
162173
const array = new Uint8Array([1, 2, 3, 4]);
163174
await expect(promise).resolves.toStrictEqual(array);
164175
});
165-
});
176+
177+
describe('createInvoiceAndChargeImmediately tests', () => {
178+
let capReq: CreateInvoiceAndChargeImmediatelyRequest;
179+
beforeEach(() => {
180+
mockTransport = createRouterTransport(({ service }) => {
181+
service(BillingService, {
182+
createInvoiceAndChargeImmediately: (req) => {
183+
capReq = req;
184+
return new CreateInvoiceAndChargeImmediatelyResponse();
185+
},
186+
});
187+
});
188+
});
189+
190+
it('creates and charges invoice immediately', async () => {
191+
const expectedRequest = new CreateInvoiceAndChargeImmediatelyRequest({
192+
orgIdToCharge: 'orgIdToCharge',
193+
amount: 100.00,
194+
description: 'test description',
195+
orgIdForBranding: 'orgIdForBranding',
196+
});
197+
198+
await subject().createInvoiceAndChargeImmediately(
199+
'orgIdToCharge',
200+
100.00,
201+
'test description',
202+
'orgIdForBranding'
203+
);
204+
expect(capReq).toStrictEqual(expectedRequest);
205+
});
206+
207+
it('creates and charges invoice immediately with optional fields omitted', async () => {
208+
const expectedRequest = new CreateInvoiceAndChargeImmediatelyRequest({
209+
orgIdToCharge: 'orgIdToCharge',
210+
amount: 100.00,
211+
});
212+
213+
await subject().createInvoiceAndChargeImmediately(
214+
'orgIdToCharge',
215+
100.00
216+
);
217+
expect(capReq).toStrictEqual(expectedRequest);
218+
});
219+
});
220+
});

src/app/billing-client.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from '@connectrpc/connect';
66
import { BillingService } from '../gen/app/v1/billing_connect';
77
import type { GetCurrentMonthUsageResponse as PBGetCurrentMonthUsageResponse } from '../gen/app/v1/billing_pb';
8+
import { CreateInvoiceAndChargeImmediatelyRequest, CreateInvoiceAndChargeImmediatelyResponse, GetAvailableBillingTiersRequest, GetAvailableBillingTiersResponse, GetInvoicePdfRequest, GetInvoicePdfResponse, GetInvoicesSummaryRequest, GetInvoicesSummaryResponse, GetOrgBillingInformationRequest, GetOrgBillingInformationResponse, SendPaymentRequiredEmailRequest, SendPaymentRequiredEmailResponse, UpdateOrganizationBillingTierRequest, UpdateOrganizationBillingTierResponse } from '../gen/app/v1/billing_pb';
89

910
export type GetCurrentMonthUsageResponse =
1011
Partial<PBGetCurrentMonthUsageResponse> & {
@@ -119,6 +120,39 @@ export class BillingClient {
119120
}
120121
return concatArrayU8(chunks);
121122
}
123+
124+
/**
125+
* Directly create a flat fee invoice for an organization and charge on the spot
126+
*
127+
* @example
128+
*
129+
* ```ts
130+
* await billing.createInvoiceAndChargeImmediately(
131+
* '<organization-id-to-charge>',
132+
* 100.00,
133+
* 'One-time charge for services',
134+
* '<organization-id-for-branding>'
135+
* );
136+
* ```
137+
*
138+
* @param orgIdToCharge The ID of the organization to charge.
139+
* @param amount The amount to charge.
140+
* @param description Optional description for the invoice.
141+
* @param orgIdForBranding Optional organization ID for branding the invoice.
142+
*/
143+
async createInvoiceAndChargeImmediately(
144+
orgIdToCharge: string,
145+
amount: number,
146+
description?: string,
147+
orgIdForBranding?: string
148+
): Promise<void> {
149+
await this.client.createInvoiceAndChargeImmediately({
150+
orgIdToCharge,
151+
amount,
152+
description,
153+
orgIdForBranding,
154+
});
155+
}
122156
}
123157

124158
const concatArrayU8 = (arrays: Uint8Array[]) => {

src/app/data-client.spec.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ import {
6464
ListDatasetsByIDsResponse,
6565
ListDatasetsByOrganizationIDRequest,
6666
ListDatasetsByOrganizationIDResponse,
67+
MergeDatasetsRequest,
68+
MergeDatasetsResponse,
6769
RenameDatasetRequest,
6870
RenameDatasetResponse,
6971
} from '../gen/app/dataset/v1/dataset_pb';
@@ -408,7 +410,11 @@ describe('DataClient tests', () => {
408410
capReq = req;
409411
if (!once) {
410412
once = true;
411-
return binDataResponse;
413+
const response = new BinaryDataByFilterResponse();
414+
response.deletedCount = req.includeInternalData
415+
? BigInt(20)
416+
: BigInt(10);
417+
return response;
412418
}
413419
return new BinaryDataByFilterResponse();
414420
},
@@ -1335,6 +1341,38 @@ describe('DatasetClient tests', () => {
13351341
expect(set2?.created).toEqual(dataset2.timeCreated?.toDate());
13361342
});
13371343
});
1344+
1345+
describe('mergeDatasets tests', () => {
1346+
let capReq: MergeDatasetsRequest;
1347+
beforeEach(() => {
1348+
mockTransport = createRouterTransport(({ service }) => {
1349+
service(DatasetService, {
1350+
mergeDatasets: (req) => {
1351+
capReq = req;
1352+
return new MergeDatasetsResponse({
1353+
datasetId: 'newDatasetId',
1354+
});
1355+
},
1356+
});
1357+
});
1358+
});
1359+
1360+
it('merges datasets', async () => {
1361+
const expectedRequest = new MergeDatasetsRequest({
1362+
datasetIds: ['id1', 'id2'],
1363+
name: 'newName',
1364+
organizationId: 'orgId',
1365+
});
1366+
1367+
const promise = await subject().mergeDatasets(
1368+
['id1', 'id2'],
1369+
'newName',
1370+
'orgId'
1371+
);
1372+
expect(capReq).toStrictEqual(expectedRequest);
1373+
expect(promise).toEqual('newDatasetId');
1374+
});
1375+
});
13381376
});
13391377

13401378
describe('DataSyncClient tests', () => {

src/app/data-client.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
TabularDataSourceType,
1818
} from '../gen/app/data/v1/data_pb';
1919
import { DatasetService } from '../gen/app/dataset/v1/dataset_connect';
20-
import type { Dataset as PBDataset } from '../gen/app/dataset/v1/dataset_pb';
20+
import type { Dataset as PBDataset, MergeDatasetsRequest, MergeDatasetsResponse } from '../gen/app/dataset/v1/dataset_pb';
2121
import { DataSyncService } from '../gen/app/datasync/v1/data_sync_connect';
2222
import { DataPipelinesService } from '../gen/app/datapipelines/v1/data_pipelines_connect';
2323
import {
@@ -1086,6 +1086,37 @@ export class DataClient {
10861086
});
10871087
}
10881088

1089+
/**
1090+
* MergeDatasets merges multiple datasets into a new dataset.
1091+
*
1092+
* @example
1093+
*
1094+
* ```ts
1095+
* const newDatasetId = await dataClient.mergeDatasets(
1096+
* ['dataset-id-1', 'dataset-id-2'],
1097+
* 'merged-dataset-name',
1098+
* 'organization-id'
1099+
* );
1100+
* ```
1101+
*
1102+
* @param datasetIds The IDs of the datasets to merge.
1103+
* @param name The name of the new merged dataset.
1104+
* @param organizationId The ID of the organization that owns the datasets.
1105+
* @returns The dataset ID of the newly created merged dataset.
1106+
*/
1107+
async mergeDatasets(
1108+
datasetIds: string[],
1109+
name: string,
1110+
organizationId: string
1111+
): Promise<string> {
1112+
const resp = await this.datasetClient.mergeDatasets({
1113+
datasetIds,
1114+
name,
1115+
organizationId,
1116+
});
1117+
return resp.datasetId;
1118+
}
1119+
10891120
/**
10901121
* Uploads the content and metadata for tabular data.
10911122
*
@@ -1568,4 +1599,4 @@ export class ListDataPipelineRunsPage {
15681599
}
15691600

15701601
export { type BinaryID, type Order } from '../gen/app/data/v1/data_pb';
1571-
export { type UploadMetadata } from '../gen/app/datasync/v1/data_sync_pb';
1602+
export { type UploadMetadata } from '../gen/app/datasync/v1/data_sync_pb';

src/components/camera/camera.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export interface Camera extends Resource {
6262
* @param mimeType - A specific MIME type to request. This is not necessarily
6363
* the same type that will be returned.
6464
*/
65-
getImage: (mimeType?: MimeType, extra?: Struct) => Promise<Uint8Array>;
65+
getImage: (mimeType?: MimeType, filterSourceNames?: string[], extra?: Struct) => Promise<Uint8Array>;
6666

6767
/**
6868
* Render a frame from a camera to an HTTP response.
@@ -112,4 +112,4 @@ export interface Camera extends Resource {
112112
* API](https://docs.viam.com/dev/reference/apis/components/camera/#getproperties).
113113
*/
114114
getProperties: () => Promise<Properties>;
115-
}
115+
}

src/components/camera/client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ export class CameraClient implements Camera {
4444

4545
async getImage(
4646
mimeType: MimeType = '',
47+
filterSourceNames: string[] = [],
4748
extra = {},
4849
callOptions = this.callOptions
4950
) {
5051
const request = new GetImageRequest({
5152
name: this.name,
5253
mimeType,
54+
filterSourceNames,
5355
extra: Struct.fromJson(extra),
5456
});
5557

@@ -111,4 +113,4 @@ export class CameraClient implements Camera {
111113
callOptions
112114
);
113115
}
114-
}
116+
}

0 commit comments

Comments
 (0)