Skip to content
Open
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@makehq/sdk",
"version": "1.6.0",
"version": "1.6.1",
"description": "Make TypeScript SDK",
"license": "MIT",
"author": "Make",
Expand Down
21 changes: 12 additions & 9 deletions src/endpoints/credential-requests.tools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Make } from '../make.js';
import type { MakeTool } from '../tools.js';
import type { CredentialSelection } from './credential-requests.js';

export const tools: MakeTool[] = [
{
Expand Down Expand Up @@ -198,7 +199,15 @@ export const tools: MakeTool[] = [
type: 'array',
description:
'Array of module IDs to request from the user, for example: ["WatchDirectMessages", "WatchFiles"]. ' +
'Use ["*"] to select all modules for the given application.',
'Use ["*"] to select all modules for the given application. At least one of appModules or appEndpoints must be specified (both may be provided together).',
minItems: 1,
items: { type: 'string' },
},
appEndpoints: {
type: 'array',
description:
'Array of Endpoint Names that the credential will be used to access, for example: ["GetUser", "ListFiles"]. ' +
'Use ["*"] to select all endpoints for the given application. At least one of appModules or appEndpoints must be specified (both may be provided together).',
minItems: 1,
items: { type: 'string' },
},
Expand All @@ -217,7 +226,7 @@ export const tools: MakeTool[] = [
description: 'Description for this credential to be displayed in the Request view.',
},
},
required: ['appName', 'appModules'],
required: ['appName'],
},
},
},
Expand All @@ -236,13 +245,7 @@ export const tools: MakeTool[] = [
name?: string;
description?: string;
teamId: number;
credentials: {
appName: string;
appModules: string[];
appVersion?: number;
nameOverride?: string;
description?: string;
}[];
credentials: CredentialSelection[];
},
) => {
return await make.credentialRequests.createAction(args);
Expand Down
27 changes: 21 additions & 6 deletions src/endpoints/credential-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,9 @@ export type CreateCredentialRequestBody = {
provider: Record<string, JSONValue>;
};

/**
* Represents an app/module selection to derive credentials from.
*/
export type CredentialSelection = {
type CredentialSelectionBase = {
/** Name of the application to request credentials for */
appName: string;
/** Array of module IDs to include. Use ["*"] to select all modules with credentials. */
appModules: string[];
/** Version of the application. Defaults to the latest available version if not provided. */
appVersion?: number;
/** Optional name override for the credential when created in the platform */
Expand All @@ -126,6 +121,26 @@ export type CredentialSelection = {
description?: string;
};

/**
* Represents an app/module selection to derive credentials from.
* At least one of `appModules` or `appEndpoints` must be specified (both may be provided together).
*/
export type CredentialSelection = CredentialSelectionBase &
(
| {
/** Array of module IDs to include. Use ["*"] to select all modules with credentials. */
appModules: string[];
/** Array of Endpoint Names that the credential will be used to access. Use ["*"] to select all endpoints. */
appEndpoints?: string[];
}
| {
/** Array of module IDs to include. Use ["*"] to select all modules with credentials. */
appModules?: string[];
/** Array of Endpoint Names that the credential will be used to access. Use ["*"] to select all endpoints. */
appEndpoints: string[];
}
);

/**
* Body for creating a credential action
*/
Expand Down
18 changes: 18 additions & 0 deletions test/credential-requests.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,24 @@ describe('Integration: CredentialRequests', () => {
expect(requests.some(r => r.id === actionRequestId)).toBe(false);
});

it('Should create a credential action using appEndpoints', async () => {
const action = await make.credentialRequests.createAction({
teamId: MAKE_TEAM,
credentials: [
{
appName: 'http',
appEndpoints: ['*'],
appVersion: 3,
},
],
});
expect(action.request.id).toBeDefined();
expect(action.publicUri).toBeDefined();
expect(action.request.teamId).toBe(MAKE_TEAM);

await make.credentialRequests.delete(action.request.id);
});

it('Should create a credential action with name and description', async () => {
const action = await make.credentialRequests.createAction({
teamId: MAKE_TEAM,
Expand Down
34 changes: 34 additions & 0 deletions test/credential-requests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,40 @@ describe('Endpoints: CredentialRequests', () => {
});
});

it('Should create a credential action with appEndpoints', async () => {
const body = {
teamId: 123,
credentials: [
{
appName: 'http',
appEndpoints: ['GetUser', 'ListFiles'],
appVersion: 3,
},
],
};

mockFetch('POST https://make.local/api/v2/credential-requests/actions/create', createActionMock, req => {
expect(req.body).toStrictEqual(body);
expect(req.headers.get('content-type')).toBe('application/json');
});

const result = await make.credentialRequests.createAction({
teamId: 123,
credentials: [
{
appName: 'http',
appEndpoints: ['GetUser', 'ListFiles'],
appVersion: 3,
},
],
});

expect(result).toStrictEqual({
request: createActionMock.request,
publicUri: createActionMock.publicUri,
});
});

it('Should create a credential request by connection/key types', async () => {
const body = {
teamId: 123,
Expand Down