Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/services/flows/__tests__/__snapshots__/web-inputs.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`flows.webInputs get 1`] = `
{
"headers": {
"accept": "*/*",
"accept-encoding": "gzip,deflate",
"connection": "close",
"host": "flows.globus.org",
"user-agent": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)",
},
"method": "GET",
"url": "https://flows.globus.org/web_inputs/web-input-id",
}
`;

exports[`flows.webInputs getAll 1`] = `
{
"headers": {
"accept": "*/*",
"accept-encoding": "gzip,deflate",
"connection": "close",
"host": "flows.globus.org",
"user-agent": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)",
},
"method": "GET",
"url": "https://flows.globus.org/web_inputs",
}
`;

exports[`flows.webInputs respond 1`] = `
{
"headers": {
"accept": "*/*",
"accept-encoding": "gzip,deflate",
"connection": "close",
"content-length": "15",
"content-type": "application/json",
"host": "flows.globus.org",
"user-agent": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)",
},
"method": "POST",
"url": "https://flows.globus.org/web_inputs/web-input-id/response",
}
`;
45 changes: 45 additions & 0 deletions src/services/flows/__tests__/web-inputs.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { mirror } from '../../../__mocks__/handlers';
import { webInputs } from '..';

const WEB_INPUT_ID = 'web-input-id';

describe('flows.webInputs', () => {
test('get', async () => {
const {
req: { url, method, headers },
} = await mirror(await webInputs.get(WEB_INPUT_ID));
expect({
url,
method,
headers,
}).toMatchSnapshot();
});

test('getAll', async () => {
const {
req: { url, method, headers },
} = await mirror(await webInputs.getAll());
expect({
url,
method,
headers,
}).toMatchSnapshot();
});

test('respond', async () => {
const {
req: { url, method, headers },
} = await mirror(
await webInputs.respond(WEB_INPUT_ID, {
body: {
response: { value: 'response' },
},
}),
);
expect({
url,
method,
headers,
}).toMatchSnapshot();
});
});
4 changes: 4 additions & 0 deletions src/services/flows/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ export const SCOPES = {
RUN: 'https://auth.globus.org/scopes/eec9b274-0c81-4334-bdc2-54e90e689b9a/run',
RUN_STATUS: 'https://auth.globus.org/scopes/eec9b274-0c81-4334-bdc2-54e90e689b9a/run_status',
RUN_MANAGE: 'https://auth.globus.org/scopes/eec9b274-0c81-4334-bdc2-54e90e689b9a/run_manage',
WEB_INPUT_VIEW:
'https://auth.globus.org/scopes/eec9b274-0c81-4334-bdc2-54e90e689b9a/web_input_view',
WEB_INPUT_RESPOND:
'https://auth.globus.org/scopes/eec9b274-0c81-4334-bdc2-54e90e689b9a/web_input_respond',
};
1 change: 1 addition & 0 deletions src/services/flows/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export const CONFIG = FLOWS;

export * as flows from './service/flows.js';
export * as runs from './service/runs.js';
export * as webInputs from './service/web-inputs.js';
144 changes: 144 additions & 0 deletions src/services/flows/service/web-inputs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import { ID, SCOPES } from '../config.js';
import { HTTP_METHODS, serviceRequest } from '../../shared.js';
import { createServiceMethodFactory } from '../../factory.js';
import { RESOURCE_SERVERS } from '../../auth/config.js';

import type { OpenAPI } from '../index.js';
import type {
JSONFetchResponse,
ServiceMethod,
ServiceMethodDynamicSegments,
} from '../../types.js';

export const get = function (
web_input_id: string,
options?,
sdkOptions?,
): Promise<
JSONFetchResponse<
OpenAPI.paths['/web_inputs/{web_input_id}']['get']['responses']['200']['content']['application/json']
>
> {
return serviceRequest(
{
service: ID,
scope: SCOPES.WEB_INPUT_VIEW,
path: `/web_inputs/${web_input_id}`,
},
options,
sdkOptions,
);
} satisfies ServiceMethodDynamicSegments<
string,
{
query?: OpenAPI.paths['/web_inputs/{web_input_id}']['get']['parameters']['query'];
},
JSONFetchResponse<
OpenAPI.paths['/web_inputs/{web_input_id}']['get']['responses']['200']['content']['application/json']
>
>;

/**
* @see https://flows.globus.org/redoc#tag/Web-Inputs/paths/~1web_inputs/get
*/
export const getAll = function (
options?,
sdkOptions?,
): Promise<
JSONFetchResponse<
OpenAPI.paths['/web_inputs']['get']['responses']['200']['content']['application/json']
>
> {
return serviceRequest(
{
service: ID,
scope: SCOPES.WEB_INPUT_VIEW,
path: `/web_inputs`,
},
options,
sdkOptions,
);
} satisfies ServiceMethod<{
query?: OpenAPI.paths['/web_inputs']['get']['parameters']['query'];
}>;

/**
* @see https://flows.globus.org/redoc#tag/Web-Inputs/paths/~1web_inputs~1%7Bweb_input_id%7D~1response/post
*/
export const respond = function (
web_input_id: string,
options?,
sdkOptions?,
): Promise<
JSONFetchResponse<
OpenAPI.paths['/web_inputs/{web_input_id}/response']['post']['responses']['200']['content']['application/json']
>
> {
return serviceRequest(
{
service: ID,
scope: SCOPES.WEB_INPUT_RESPOND,
path: `/web_inputs/${web_input_id}/response`,
method: HTTP_METHODS.POST,
},
options,
sdkOptions,
);
} satisfies ServiceMethodDynamicSegments<
string,
{
body: OpenAPI.paths['/web_inputs/{web_input_id}/response']['post']['requestBody']['content']['application/json'];
},
JSONFetchResponse<
OpenAPI.paths['/web_inputs/{web_input_id}/response']['post']['responses']['200']['content']['application/json']
>
>;

/**
* @private
*/
export const next = {
get: createServiceMethodFactory({
service: ID,
resource_server: RESOURCE_SERVERS.FLOWS,
path: `/web_inputs/{web_input_id}`,
}).generate<
{
request?: {
query?: OpenAPI.paths['/web_inputs/{web_input_id}']['get']['parameters']['query'];
};
},
JSONFetchResponse<
OpenAPI.paths['/web_inputs/{web_input_id}']['get']['responses']['200']['content']['application/json']
>
>(),
getAll: createServiceMethodFactory({
service: ID,
resource_server: RESOURCE_SERVERS.FLOWS,
path: `/web_inputs`,
}).generate<
{
request?: {
query?: OpenAPI.paths['/web_inputs']['get']['parameters']['query'];
};
},
JSONFetchResponse<
OpenAPI.paths['/web_inputs']['get']['responses']['200']['content']['application/json']
>
>(),
respond: createServiceMethodFactory({
service: ID,
resource_server: RESOURCE_SERVERS.FLOWS,
path: `/web_inputs/{web_input_id}/response`,
}).generate<
{
request?: {
query?: OpenAPI.paths['/web_inputs/{web_input_id}/response']['post']['parameters']['query'];
data?: OpenAPI.paths['/web_inputs/{web_input_id}/response']['post']['requestBody']['content']['application/json'];
};
},
JSONFetchResponse<
OpenAPI.paths['/web_inputs/{web_input_id}/response']['post']['responses']['200']['content']['application/json']
>
>(),
};
Loading