Skip to content

Commit f001164

Browse files
authored
fix(Transfer, Typescript): transfer.endpointSearch return type (#664)
[sc-45590]
1 parent e510249 commit f001164

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/services/transfer/__tests__/endpoint-search.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { endpointSearch } from '..';
2-
3-
import type { MirroredRequest } from '../../../__mocks__/handlers';
2+
import { mirror } from '../../../__mocks__/handlers';
43

54
test('endpointSearch', async () => {
65
const result = await endpointSearch({
@@ -14,7 +13,7 @@ test('endpointSearch', async () => {
1413
});
1514
const {
1615
req: { url, method, headers },
17-
} = (await result.json()) as MirroredRequest;
16+
} = await mirror(result);
1817
expect({
1918
url,
2019
method,

src/services/transfer/service/endpoint-search.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { serviceRequest } from '../../shared.js';
22
import { ID, SCOPES } from '../config.js';
33

4-
import type { ServiceMethod } from '../../../services/types.js';
5-
import type { QueryParameters } from '../types.js';
6-
import type { EntityType } from './endpoint.js';
7-
4+
import type { JSONFetchResponse, ServiceMethod } from '../../../services/types.js';
5+
import type { PaginatedResponse, QueryParameters } from '../types.js';
6+
import type { EntityType, EndpointListDocument } from './endpoint.js';
87
/**
98
* @see https://docs.globus.org/api/transfer/endpoint_search/#search_scope
109
*/
@@ -34,11 +33,19 @@ export type EndpointSearchQuery = QueryParameters<
3433
'Offset'
3534
>;
3635

36+
export type EndpointSearchResult = PaginatedResponse<
37+
'Offset',
38+
Omit<EndpointListDocument, 'length'>
39+
>;
40+
3741
/**
3842
* Get a list of endpoints matching the search filters in a given search scope.
3943
* @see https://docs.globus.org/api/transfer/endpoint_search/#endpoint_search
4044
*/
41-
export const endpointSearch = function (options?, sdkOptions?) {
45+
export const endpointSearch = function (
46+
options?,
47+
sdkOptions?,
48+
): Promise<JSONFetchResponse<EndpointSearchResult>> {
4249
const serviceRequestOptions = {
4350
...options,
4451
query: options?.query,
@@ -52,8 +59,11 @@ export const endpointSearch = function (options?, sdkOptions?) {
5259
serviceRequestOptions,
5360
sdkOptions,
5461
);
55-
} satisfies ServiceMethod<{
56-
query?: EndpointSearchQuery;
57-
}>;
62+
} satisfies ServiceMethod<
63+
{
64+
query?: EndpointSearchQuery;
65+
},
66+
JSONFetchResponse<EndpointSearchResult>
67+
>;
5868

5969
export default endpointSearch;

0 commit comments

Comments
 (0)