Skip to content

Commit 30b8dc8

Browse files
committed
fix: tool name tweaks
1 parent 37d9024 commit 30b8dc8

File tree

7 files changed

+35
-18
lines changed

7 files changed

+35
-18
lines changed

src/lib/tools/email-layouts.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { KnockTool } from "../knock-tool.js";
99
type SerializedEmailLayout = {
1010
key: string;
1111
name: string;
12+
htmlContent: string;
13+
textContent: string;
1214
};
1315

1416
function serializeEmailLayoutResponse(
@@ -17,6 +19,8 @@ function serializeEmailLayoutResponse(
1719
return {
1820
key: emailLayout.key,
1921
name: emailLayout.name,
22+
htmlContent: emailLayout.html_layout,
23+
textContent: emailLayout.text_layout,
2024
};
2125
}
2226

@@ -46,7 +50,7 @@ const listEmailLayouts = KnockTool({
4650
});
4751

4852
const createOrUpdateEmailLayout = KnockTool({
49-
method: "create_or_update_email_layout",
53+
method: "upsert_email_layout",
5054
name: "Create or update email layout",
5155
description: `Create or update a new email layout within the environment given. Use this tool when you need to define shared pieces of content across multiple email templates, like a header/footer. The email layout will be used to render the email template.
5256

src/lib/tools/message-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const listMessageTypes = KnockTool({
4848
});
4949

5050
const createOrUpdateMessageType = KnockTool({
51-
method: "create_or_update_message_type",
51+
method: "upsert_message_type",
5252
name: "Create or update message type",
5353
description: `
5454
Create or update a message type. A message type is a schema that defines fields available to an editor within Knock. Message types always have at least one variant, that MUST be named "default". Use this tool when you need to create a new message type, or update an existing message type.

src/lib/tools/objects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const getObject = KnockTool({
4848
});
4949

5050
const createOrUpdateObject = KnockTool({
51-
method: "create_or_update_object",
51+
method: "upsert_object",
5252
name: "Create or update object",
5353
description: `Create or update an object in a specific collection. Objects are used to model custom collections in Knock that are NOT users or tenants. If the object does not exist, it will be created. If the object exists, it will be updated with the provided properties. The update will always perform an upsert operation, so you do not need to provide the full properties each time.
5454

src/lib/tools/tenants.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ const listTenants = KnockTool({
4949
},
5050
});
5151

52-
const setTenant = KnockTool({
53-
method: "set_tenant",
54-
name: "Set tenant",
52+
const createOrUpdateTenant = KnockTool({
53+
method: "upsert_tenant",
54+
name: "Create or update tenant",
5555
description: `
5656
Creates or updates a tenant using the properties provided. Tenants in Knock are used to model organizations, teams, and other groups of users. They are a special type of object.
5757
@@ -83,10 +83,10 @@ const setTenant = KnockTool({
8383
export const tenants = {
8484
getTenant,
8585
listTenants,
86-
setTenant,
86+
createOrUpdateTenant,
8787
};
8888

8989
export const permissions = {
9090
read: ["getTenant", "listTenants"],
91-
manage: ["setTenant"],
91+
manage: ["createOrUpdateTenant"],
9292
};

src/lib/tools/users.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const getUser = KnockTool({
4040
});
4141

4242
const createOrUpdateUser = KnockTool({
43-
method: "create_or_update_user",
43+
method: "upsert_user",
4444
name: "Create or update user",
4545
description: `
4646
Creates a new user if they don't exist, or updates the user object for the given userId, including email, name, phone number, and any custom properties.

src/lib/tools/workflow-steps.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ const contentBlockSchema = z.union([
137137
]);
138138

139139
const createOrUpdateEmailStepInWorkflow = KnockTool({
140-
method: "create_or_update_email_step_in_workflow",
140+
method: "upsert_workflow_email_step",
141141
name: "Create or update email step in workflow",
142142
description: `
143143
Creates or updates an email step in a workflow. Use this tool when you're asked to create an email notification and you need to specify the content of the email.
@@ -302,7 +302,7 @@ const createOrUpdateEmailStepInWorkflow = KnockTool({
302302
});
303303

304304
const createOrUpdateSmsStepInWorkflow = KnockTool({
305-
method: "create_or_update_sms_step_in_workflow",
305+
method: "upsert_workflow_sms_step",
306306
name: "Create or update sms step in workflow",
307307
description: `
308308
Creates an SMS step in a workflow. Use this tool when you're asked to create an SMS notification and you need to specify the content of the SMS.
@@ -355,7 +355,7 @@ const createOrUpdateSmsStepInWorkflow = KnockTool({
355355
});
356356

357357
const createOrUpdatePushStepInWorkflow = KnockTool({
358-
method: "create_or_update_push_step_in_workflow",
358+
method: "upsert_workflow_push_step",
359359
name: "Create or update push step in workflow",
360360
description: `
361361
Creates a push step in a workflow. Use this tool when you're asked to create a push notification and you need to specify the content of the push notification.
@@ -415,7 +415,7 @@ const createOrUpdatePushStepInWorkflow = KnockTool({
415415

416416
// TODO: Add support for action buttons, not just the action URL
417417
const createOrUpdateInAppFeedStepInWorkflow = KnockTool({
418-
method: "create_or_update_in_app_feed_step_in_workflow",
418+
method: "upsert_workflow_in_app_step",
419419
name: "Create or update in app feed step in workflow",
420420
description: `
421421
Creates an in app feed step in a workflow. Use this tool when you're asked to create an in app feed notification and you need to specify the content of the in app feed notification.
@@ -476,7 +476,7 @@ const createOrUpdateInAppFeedStepInWorkflow = KnockTool({
476476
});
477477

478478
const createOrUpdateChatStepInWorkflow = KnockTool({
479-
method: "create_or_update_chat_step_in_workflow",
479+
method: "upsert_workflow_chat_step",
480480
name: "Create or update chat step in workflow",
481481
description: `
482482
Creates a chat step in a workflow. Use this tool when you're asked to create a chat, Slack, Discord, or Microsoft Teams notification and you need to specify the content of the chat notification.
@@ -530,7 +530,7 @@ const createOrUpdateChatStepInWorkflow = KnockTool({
530530
});
531531

532532
const createOrUpdateDelayStepInWorkflow = KnockTool({
533-
method: "create_or_update_delay_step_in_workflow",
533+
method: "upsert_workflow_delay_step",
534534
name: "Create or update delay step in workflow",
535535
description: `
536536
Creates a delay step in a workflow. Use this tool when you're asked to add a delay to the workflow that pauses, or waits for a period of time before continuing.
@@ -598,7 +598,7 @@ const createOrUpdateDelayStepInWorkflow = KnockTool({
598598
});
599599

600600
const createOrUpdateBatchStepInWorkflow = KnockTool({
601-
method: "create_or_update_batch_step_in_workflow",
601+
method: "upsert_workflow_batch_step",
602602
name: "Create or update batch step in workflow",
603603
description: `
604604
Creates a batch step in a workflow. Use this tool when you're asked to create a batch step or asked to add digesting behavior to a workflow. The batch step collects multiple workflow triggers for a single recipient over a period of time and then flushes the content to the next step.

src/lib/tools/workflows.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Workflow } from "@knocklabs/mgmt/resources/index.js";
1+
import { Workflow, WorkflowStep } from "@knocklabs/mgmt/resources/index.js";
22
import { z } from "zod";
33

44
import { KnockTool } from "../knock-tool.js";
@@ -28,6 +28,19 @@ export function serializeWorkflowResponse(
2828
};
2929
}
3030

31+
export function serializeFullWorkflowResponse(
32+
workflow: Workflow
33+
): SerializedWorkflow & { steps: WorkflowStep[] } {
34+
return {
35+
key: workflow.key,
36+
name: workflow.name,
37+
description: workflow.description,
38+
categories: workflow.categories,
39+
schema: workflow.trigger_data_json_schema,
40+
steps: workflow.steps,
41+
};
42+
}
43+
3144
const listWorkflows = KnockTool({
3245
method: "list_workflows",
3346
name: "List workflows",
@@ -80,7 +93,7 @@ const getWorkflow = KnockTool({
8093
environment: params.environment ?? config.environment ?? "development",
8194
});
8295

83-
return serializeWorkflowResponse(workflow);
96+
return serializeFullWorkflowResponse(workflow);
8497
},
8598
});
8699

0 commit comments

Comments
 (0)