@knocklabs/agent-toolkit 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/ai-sdk/index.js +22 -1085
  2. package/dist/ai-sdk/index.js.map +1 -1
  3. package/dist/ai-sdk/tool-converter.js +3 -10
  4. package/dist/ai-sdk/tool-converter.js.map +1 -1
  5. package/dist/chunk-2CNJ4XX6.js +33 -0
  6. package/dist/chunk-2CNJ4XX6.js.map +1 -0
  7. package/dist/chunk-3LZK6RH6.js +29 -0
  8. package/dist/chunk-3LZK6RH6.js.map +1 -0
  9. package/dist/chunk-4VR65G5W.js +66 -0
  10. package/dist/chunk-4VR65G5W.js.map +1 -0
  11. package/dist/chunk-6H3BXH2Y.js +15 -0
  12. package/dist/chunk-6H3BXH2Y.js.map +1 -0
  13. package/dist/chunk-BY4KQPUO.js +39 -0
  14. package/dist/chunk-BY4KQPUO.js.map +1 -0
  15. package/dist/chunk-DSRTYV37.js +39 -0
  16. package/dist/chunk-DSRTYV37.js.map +1 -0
  17. package/dist/chunk-JTYQTWCX.js +75 -0
  18. package/dist/chunk-JTYQTWCX.js.map +1 -0
  19. package/dist/chunk-NZB2TMJW.js +92 -0
  20. package/dist/chunk-NZB2TMJW.js.map +1 -0
  21. package/dist/chunk-O6DWF42E.js +31 -0
  22. package/dist/chunk-O6DWF42E.js.map +1 -0
  23. package/dist/chunk-OD5VHBGN.js +32 -0
  24. package/dist/chunk-OD5VHBGN.js.map +1 -0
  25. package/dist/chunk-PDMA6RIB.js +19 -0
  26. package/dist/chunk-PDMA6RIB.js.map +1 -0
  27. package/dist/chunk-RYMJEH6P.js +140 -0
  28. package/dist/chunk-RYMJEH6P.js.map +1 -0
  29. package/dist/chunk-THLK376Y.js +191 -0
  30. package/dist/chunk-THLK376Y.js.map +1 -0
  31. package/dist/chunk-TLHETJRF.js +75 -0
  32. package/dist/chunk-TLHETJRF.js.map +1 -0
  33. package/dist/chunk-TOBLV65T.js +30 -0
  34. package/dist/chunk-TOBLV65T.js.map +1 -0
  35. package/dist/chunk-VJFA3ZVW.js +210 -0
  36. package/dist/chunk-VJFA3ZVW.js.map +1 -0
  37. package/dist/chunk-WB4XCCUS.js +19 -0
  38. package/dist/chunk-WB4XCCUS.js.map +1 -0
  39. package/dist/chunk-XRQWR3LY.js +184 -0
  40. package/dist/chunk-XRQWR3LY.js.map +1 -0
  41. package/dist/chunk-XUYE3AGB.js +27 -0
  42. package/dist/chunk-XUYE3AGB.js.map +1 -0
  43. package/dist/lib/knock-client.js +3 -24
  44. package/dist/lib/knock-client.js.map +1 -1
  45. package/dist/lib/knock-tool.js +3 -25
  46. package/dist/lib/knock-tool.js.map +1 -1
  47. package/dist/lib/tools/channels.js +5 -49
  48. package/dist/lib/tools/channels.js.map +1 -1
  49. package/dist/lib/tools/commits.js +5 -93
  50. package/dist/lib/tools/commits.js.map +1 -1
  51. package/dist/lib/tools/email-layouts.js +5 -55
  52. package/dist/lib/tools/email-layouts.js.map +1 -1
  53. package/dist/lib/tools/environments.js +5 -47
  54. package/dist/lib/tools/environments.js.map +1 -1
  55. package/dist/lib/tools/index.js +17 -1016
  56. package/dist/lib/tools/index.js.map +1 -1
  57. package/dist/lib/tools/message-types.js +5 -209
  58. package/dist/lib/tools/message-types.js.map +1 -1
  59. package/dist/lib/tools/messages.js +5 -50
  60. package/dist/lib/tools/messages.js.map +1 -1
  61. package/dist/lib/tools/objects.js +5 -158
  62. package/dist/lib/tools/objects.js.map +1 -1
  63. package/dist/lib/tools/partials.js +5 -55
  64. package/dist/lib/tools/partials.js.map +1 -1
  65. package/dist/lib/tools/tenants.js +5 -93
  66. package/dist/lib/tools/tenants.js.map +1 -1
  67. package/dist/lib/tools/users.js +5 -228
  68. package/dist/lib/tools/users.js.map +1 -1
  69. package/dist/lib/tools/workflows.js +5 -202
  70. package/dist/lib/tools/workflows.js.map +1 -1
  71. package/dist/lib/utils.js +18 -1071
  72. package/dist/lib/utils.js.map +1 -1
  73. package/dist/modelcontextprotocol/adapter.js +3 -22
  74. package/dist/modelcontextprotocol/adapter.js.map +1 -1
  75. package/dist/modelcontextprotocol/index.js +17 -976
  76. package/dist/modelcontextprotocol/index.js.map +1 -1
  77. package/dist/modelcontextprotocol/local-server.js +25 -1041
  78. package/dist/modelcontextprotocol/local-server.js.map +1 -1
  79. package/dist/openai/index.js +22 -1089
  80. package/dist/openai/index.js.map +1 -1
  81. package/dist/openai/tool-converter.js +3 -14
  82. package/dist/openai/tool-converter.js.map +1 -1
  83. package/package.json +3 -3
@@ -0,0 +1,92 @@
1
+ import {
2
+ messageTypes,
3
+ permissions as permissions6
4
+ } from "./chunk-THLK376Y.js";
5
+ import {
6
+ messages,
7
+ permissions as permissions5
8
+ } from "./chunk-OD5VHBGN.js";
9
+ import {
10
+ objects,
11
+ permissions as permissions7
12
+ } from "./chunk-RYMJEH6P.js";
13
+ import {
14
+ partials,
15
+ permissions as permissions8
16
+ } from "./chunk-BY4KQPUO.js";
17
+ import {
18
+ permissions as permissions9,
19
+ tenants
20
+ } from "./chunk-JTYQTWCX.js";
21
+ import {
22
+ permissions as permissions10,
23
+ users
24
+ } from "./chunk-VJFA3ZVW.js";
25
+ import {
26
+ permissions as permissions11,
27
+ workflows
28
+ } from "./chunk-XRQWR3LY.js";
29
+ import {
30
+ channels,
31
+ permissions
32
+ } from "./chunk-2CNJ4XX6.js";
33
+ import {
34
+ commits,
35
+ permissions as permissions2
36
+ } from "./chunk-TLHETJRF.js";
37
+ import {
38
+ emailLayouts,
39
+ permissions as permissions3
40
+ } from "./chunk-DSRTYV37.js";
41
+ import {
42
+ environments,
43
+ permissions as permissions4
44
+ } from "./chunk-O6DWF42E.js";
45
+
46
+ // src/lib/tools/index.ts
47
+ var tools = {
48
+ channels,
49
+ commits,
50
+ emailLayouts,
51
+ environments,
52
+ messages,
53
+ messageTypes,
54
+ objects,
55
+ partials,
56
+ tenants,
57
+ users,
58
+ workflows
59
+ };
60
+ var allTools = {
61
+ ...channels,
62
+ ...commits,
63
+ ...emailLayouts,
64
+ ...environments,
65
+ ...messageTypes,
66
+ ...messages,
67
+ ...objects,
68
+ ...partials,
69
+ ...tenants,
70
+ ...users,
71
+ ...workflows
72
+ };
73
+ var toolPermissions = {
74
+ channels: permissions,
75
+ commits: permissions2,
76
+ emailLayouts: permissions3,
77
+ environments: permissions4,
78
+ messages: permissions5,
79
+ messageTypes: permissions6,
80
+ objects: permissions7,
81
+ partials: permissions8,
82
+ tenants: permissions9,
83
+ users: permissions10,
84
+ workflows: permissions11
85
+ };
86
+
87
+ export {
88
+ tools,
89
+ allTools,
90
+ toolPermissions
91
+ };
92
+ //# sourceMappingURL=chunk-NZB2TMJW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/tools/index.ts"],"sourcesContent":["import { channels, permissions as channelsPermissions } from \"./channels.js\";\nimport { commits, permissions as commitsPermissions } from \"./commits.js\";\nimport {\n emailLayouts,\n permissions as emailLayoutsPermissions,\n} from \"./email-layouts.js\";\nimport {\n environments,\n permissions as environmentsPermissions,\n} from \"./environments.js\";\nimport { messages, permissions as messagesPermissions } from \"./messages.js\";\nimport {\n messageTypes,\n permissions as messageTypesPermissions,\n} from \"./message-types.js\";\nimport { objects, permissions as objectsPermissions } from \"./objects.js\";\nimport { partials, permissions as partialsPermissions } from \"./partials.js\";\nimport { tenants, permissions as tenantsPermissions } from \"./tenants.js\";\nimport { users, permissions as usersPermissions } from \"./users.js\";\nimport { workflows, permissions as workflowsPermissions } from \"./workflows.js\";\n\nexport const tools = {\n channels,\n commits,\n emailLayouts,\n environments,\n messages,\n messageTypes,\n objects,\n partials,\n tenants,\n users,\n workflows,\n};\n\nexport const allTools = {\n ...channels,\n ...commits,\n ...emailLayouts,\n ...environments,\n ...messageTypes,\n ...messages,\n ...objects,\n ...partials,\n ...tenants,\n ...users,\n ...workflows,\n};\n\nexport const toolPermissions = {\n channels: channelsPermissions,\n commits: commitsPermissions,\n emailLayouts: emailLayoutsPermissions,\n environments: environmentsPermissions,\n messages: messagesPermissions,\n messageTypes: messageTypesPermissions,\n objects: objectsPermissions,\n partials: partialsPermissions,\n tenants: tenantsPermissions,\n users: usersPermissions,\n workflows: workflowsPermissions,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBO,IAAM,QAAQ;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,WAAW;AAAA,EACtB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEO,IAAM,kBAAkB;AAAA,EAC7B,UAAU;AAAA,EACV,SAASA;AAAA,EACT,cAAcA;AAAA,EACd,cAAcA;AAAA,EACd,UAAUA;AAAA,EACV,cAAcA;AAAA,EACd,SAASA;AAAA,EACT,UAAUA;AAAA,EACV,SAASA;AAAA,EACT,OAAOA;AAAA,EACP,WAAWA;AACb;","names":["permissions"]}
@@ -0,0 +1,31 @@
1
+ import {
2
+ KnockTool
3
+ } from "./chunk-TOBLV65T.js";
4
+
5
+ // src/lib/tools/environments.ts
6
+ var listEnvironments = KnockTool({
7
+ method: "list_environments",
8
+ name: "List environments",
9
+ description: `
10
+ Lists all environments available, returning the slug, name, and the order of each environment. Use this tool when you need to see what environments are available to deploy to.
11
+ `,
12
+ execute: (knockClient) => async (params) => {
13
+ const allEnvironments = [];
14
+ for await (const environment of knockClient.environments.list()) {
15
+ allEnvironments.push(environment);
16
+ }
17
+ return allEnvironments;
18
+ }
19
+ });
20
+ var environments = {
21
+ listEnvironments
22
+ };
23
+ var permissions = {
24
+ read: ["listEnvironments"]
25
+ };
26
+
27
+ export {
28
+ environments,
29
+ permissions
30
+ };
31
+ //# sourceMappingURL=chunk-O6DWF42E.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/tools/environments.ts"],"sourcesContent":["import { Environment } from \"@knocklabs/mgmt/resources/environments.js\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listEnvironments = KnockTool({\n method: \"list_environments\",\n name: \"List environments\",\n description: `\n Lists all environments available, returning the slug, name, and the order of each environment. Use this tool when you need to see what environments are available to deploy to.\n `,\n execute: (knockClient) => async (params) => {\n const allEnvironments: Environment[] = [];\n for await (const environment of knockClient.environments.list()) {\n allEnvironments.push(environment);\n }\n return allEnvironments;\n },\n});\n\nexport const environments = {\n listEnvironments,\n};\n\nexport const permissions = {\n read: [\"listEnvironments\"],\n};\n"],"mappings":";;;;;AAGA,IAAM,mBAAmB,UAAU;AAAA,EACjC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA,EAGb,SAAS,CAAC,gBAAgB,OAAO,WAAW;AAC1C,UAAM,kBAAiC,CAAC;AACxC,qBAAiB,eAAe,YAAY,aAAa,KAAK,GAAG;AAC/D,sBAAgB,KAAK,WAAW;AAAA,IAClC;AACA,WAAO;AAAA,EACT;AACF,CAAC;AAEM,IAAM,eAAe;AAAA,EAC1B;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,MAAM,CAAC,kBAAkB;AAC3B;","names":[]}
@@ -0,0 +1,32 @@
1
+ import {
2
+ KnockTool
3
+ } from "./chunk-TOBLV65T.js";
4
+
5
+ // src/lib/tools/messages.ts
6
+ import { z } from "zod";
7
+ var getMessageContent = KnockTool({
8
+ method: "get_message_content",
9
+ name: "Get message content",
10
+ description: `
11
+ Retrieves the complete contents of a single message, specified by the messageId. The message contents includes the rendered template that was sent to the recipient. Use this tool when you want to surface information about the emails, SMS, and push notifications that were sent to a user.
12
+ `,
13
+ parameters: z.object({
14
+ messageId: z.string().describe("(string): The messageId of the message to retrieve.")
15
+ }),
16
+ execute: (knockClient) => async (params) => {
17
+ const publicClient = await knockClient.publicApi();
18
+ return await publicClient.messages.getContent(params.messageId);
19
+ }
20
+ });
21
+ var messages = {
22
+ getMessageContent
23
+ };
24
+ var permissions = {
25
+ read: ["getMessageContent"]
26
+ };
27
+
28
+ export {
29
+ messages,
30
+ permissions
31
+ };
32
+ //# sourceMappingURL=chunk-OD5VHBGN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/tools/messages.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst getMessageContent = KnockTool({\n method: \"get_message_content\",\n name: \"Get message content\",\n description: `\n Retrieves the complete contents of a single message, specified by the messageId. The message contents includes the rendered template that was sent to the recipient. Use this tool when you want to surface information about the emails, SMS, and push notifications that were sent to a user.\n `,\n parameters: z.object({\n messageId: z\n .string()\n .describe(\"(string): The messageId of the message to retrieve.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.messages.getContent(params.messageId);\n },\n});\n\nexport const messages = {\n getMessageContent,\n};\n\nexport const permissions = {\n read: [\"getMessageContent\"],\n};\n"],"mappings":";;;;;AAAA,SAAS,SAAS;AAGlB,IAAM,oBAAoB,UAAU;AAAA,EAClC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA,EAGb,YAAY,EAAE,OAAO;AAAA,IACnB,WAAW,EACR,OAAO,EACP,SAAS,qDAAqD;AAAA,EACnE,CAAC;AAAA,EACD,SAAS,CAAC,gBAAgB,OAAO,WAAW;AAC1C,UAAM,eAAe,MAAM,YAAY,UAAU;AACjD,WAAO,MAAM,aAAa,SAAS,WAAW,OAAO,SAAS;AAAA,EAChE;AACF,CAAC;AAEM,IAAM,WAAW;AAAA,EACtB;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,MAAM,CAAC,mBAAmB;AAC5B;","names":[]}
@@ -0,0 +1,19 @@
1
+ import {
2
+ allTools
3
+ } from "./chunk-NZB2TMJW.js";
4
+ import {
5
+ KnockMcpServer
6
+ } from "./chunk-XUYE3AGB.js";
7
+
8
+ // src/modelcontextprotocol/index.ts
9
+ var createKnockMcpServer = async (params) => {
10
+ const { tools, knockClient, config } = params;
11
+ return Promise.resolve(
12
+ new KnockMcpServer(knockClient, config, tools || Object.values(allTools))
13
+ );
14
+ };
15
+
16
+ export {
17
+ createKnockMcpServer
18
+ };
19
+ //# sourceMappingURL=chunk-PDMA6RIB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/modelcontextprotocol/index.ts"],"sourcesContent":["import type { KnockTool } from \"../lib/knock-tool.js\";\nimport { allTools } from \"../lib/tools/index.js\";\nimport { KnockMcpServer } from \"./adapter.js\";\nimport { Config } from \"../types.js\";\nimport { KnockClient } from \"../lib/knock-client.js\";\n\ntype CreateKnockMcpServerParams = {\n /**\n * Array of Knock tools to enable in the server.\n */\n tools?: KnockTool[];\n\n /**\n * A Knock client to use for the server.\n */\n knockClient: KnockClient;\n\n /**\n * The config to use for the server.\n */\n config: Config;\n};\n\n/**\n * Creates a Knock MCP Server with the given parameters.\n */\nexport const createKnockMcpServer = async (\n params: CreateKnockMcpServerParams\n): Promise<KnockMcpServer> => {\n const { tools, knockClient, config } = params;\n\n return Promise.resolve(\n new KnockMcpServer(knockClient, config, tools || Object.values(allTools))\n );\n};\n"],"mappings":";;;;;;;;AA0BO,IAAM,uBAAuB,OAClC,WAC4B;AAC5B,QAAM,EAAE,OAAO,aAAa,OAAO,IAAI;AAEvC,SAAO,QAAQ;AAAA,IACb,IAAI,eAAe,aAAa,QAAQ,SAAS,OAAO,OAAO,QAAQ,CAAC;AAAA,EAC1E;AACF;","names":[]}
@@ -0,0 +1,140 @@
1
+ import {
2
+ KnockTool
3
+ } from "./chunk-TOBLV65T.js";
4
+
5
+ // src/lib/tools/objects.ts
6
+ import { z } from "zod";
7
+ var listObjects = KnockTool({
8
+ method: "list_objects",
9
+ name: "List objects",
10
+ description: "List all objects in a single collection. Objects are used to model custom collections in Knock that are NOT users or tenants. Use this tool when you need to return a paginated list of objects in a single collection.",
11
+ parameters: z.object({
12
+ collection: z.string().describe("(string): The collection to list objects from.")
13
+ }),
14
+ execute: (knockClient, config) => async (params) => {
15
+ const publicClient = await knockClient.publicApi();
16
+ return await publicClient.objects.list(params.collection);
17
+ }
18
+ });
19
+ var getObject = KnockTool({
20
+ method: "get_object",
21
+ name: "Get object",
22
+ description: "Get an object wihin a collection. Returns information about the object including any custom properties. Use this tool when you need to retrieve an object to understand it's properties.",
23
+ parameters: z.object({
24
+ collection: z.string().describe("(string): The collection to get the object from."),
25
+ objectId: z.string().describe("(string): The ID of the object to get.")
26
+ }),
27
+ execute: (knockClient, config) => async (params) => {
28
+ const publicClient = await knockClient.publicApi();
29
+ return await publicClient.objects.get(params.collection, params.objectId);
30
+ }
31
+ });
32
+ var createOrUpdateObject = KnockTool({
33
+ method: "create_or_update_object",
34
+ name: "Create or update object",
35
+ 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.
36
+
37
+ Use this tool when you need to create a new object, or update an existing custom-object. Custom objects can be used to subscribe users' to as lists, and also send non-user facing notifications to.`,
38
+ parameters: z.object({
39
+ collection: z.string().describe("(string): The collection to create or update the object in."),
40
+ objectId: z.string().describe("(string): The ID of the object to create or update."),
41
+ properties: z.record(z.string(), z.any()).describe("(object): The properties to set on the object.")
42
+ }),
43
+ execute: (knockClient, config) => async (params) => {
44
+ const publicClient = await knockClient.publicApi();
45
+ return await publicClient.objects.set(
46
+ params.collection,
47
+ params.objectId,
48
+ params.properties
49
+ );
50
+ }
51
+ });
52
+ var deleteObject = KnockTool({
53
+ method: "delete_object",
54
+ name: "Delete object",
55
+ description: `Delete an object from a specific collection. Use this tool when you need to remove an object from the system.`,
56
+ parameters: z.object({
57
+ collection: z.string().describe("(string): The collection to delete the object from."),
58
+ objectId: z.string().describe("(string): The ID of the object to delete.")
59
+ }),
60
+ execute: (knockClient, config) => async (params) => {
61
+ const publicClient = await knockClient.publicApi();
62
+ await publicClient.objects.delete(params.collection, params.objectId);
63
+ return { success: true };
64
+ }
65
+ });
66
+ var subscribeUsersToObject = KnockTool({
67
+ method: "subscribe_users_to_object",
68
+ name: "Subscribe users to object",
69
+ description: `
70
+ Subscribe a list of users to an object in a specific collection. We use this to model lists of users, for pub-sub use cases.
71
+
72
+ Use this tool when you need to subscribe one or more users to an object where you will then trigger workflows for those lists of users to send notifications to.
73
+
74
+ Before using this tool, you should create the object in the collection using the createOrUpdateObject tool.
75
+ `,
76
+ parameters: z.object({
77
+ collection: z.string().describe("(string): The collection to subscribe the user to."),
78
+ objectId: z.string().describe("(string): The ID of the object to subscribe the user to."),
79
+ userIds: z.array(z.string()).describe(
80
+ "(array): The IDs of the users to subscribe to the object. If not provided, the current user will be subscribed."
81
+ )
82
+ }),
83
+ execute: (knockClient, config) => async (params) => {
84
+ const publicClient = await knockClient.publicApi();
85
+ return await publicClient.objects.addSubscriptions(
86
+ params.collection,
87
+ params.objectId,
88
+ {
89
+ recipients: params.userIds ?? [config.userId]
90
+ }
91
+ );
92
+ }
93
+ });
94
+ var unsubscribeUsersFromObject = KnockTool({
95
+ method: "unsubscribe_users_from_object",
96
+ name: "Unsubscribe users from object",
97
+ description: `Unsubscribe a list of users from an object in a specific collection. We use this to model lists of users, for pub-sub use cases.
98
+
99
+ Use this tool when you need to unsubscribe one or more users from an object where you will then trigger workflows for those lists of users to send notifications to.`,
100
+ parameters: z.object({
101
+ collection: z.string().describe("(string): The collection to unsubscribe the user from."),
102
+ objectId: z.string().describe("(string): The ID of the object to unsubscribe the user from."),
103
+ userIds: z.array(z.string()).describe(
104
+ "(array): The IDs of the users to unsubscribe from the object."
105
+ )
106
+ }),
107
+ execute: (knockClient, config) => async (params) => {
108
+ const publicClient = await knockClient.publicApi();
109
+ return await publicClient.objects.deleteSubscriptions(
110
+ params.collection,
111
+ params.objectId,
112
+ {
113
+ recipients: params.userIds ?? [config.userId]
114
+ }
115
+ );
116
+ }
117
+ });
118
+ var objects = {
119
+ listObjects,
120
+ getObject,
121
+ createOrUpdateObject,
122
+ deleteObject,
123
+ subscribeUsersToObject,
124
+ unsubscribeUsersFromObject
125
+ };
126
+ var permissions = {
127
+ read: ["listObjects", "getObject"],
128
+ manage: [
129
+ "createOrUpdateObject",
130
+ "deleteObject",
131
+ "subscribeUsersToObject",
132
+ "unsubscribeUsersFromObject"
133
+ ]
134
+ };
135
+
136
+ export {
137
+ objects,
138
+ permissions
139
+ };
140
+ //# sourceMappingURL=chunk-RYMJEH6P.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/tools/objects.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listObjects = KnockTool({\n method: \"list_objects\",\n name: \"List objects\",\n description:\n \"List all objects in a single collection. Objects are used to model custom collections in Knock that are NOT users or tenants. Use this tool when you need to return a paginated list of objects in a single collection.\",\n parameters: z.object({\n collection: z\n .string()\n .describe(\"(string): The collection to list objects from.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.objects.list(params.collection);\n },\n});\n\nconst getObject = KnockTool({\n method: \"get_object\",\n name: \"Get object\",\n description:\n \"Get an object wihin a collection. Returns information about the object including any custom properties. Use this tool when you need to retrieve an object to understand it's properties.\",\n parameters: z.object({\n collection: z\n .string()\n .describe(\"(string): The collection to get the object from.\"),\n objectId: z.string().describe(\"(string): The ID of the object to get.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.objects.get(params.collection, params.objectId);\n },\n});\n\nconst createOrUpdateObject = KnockTool({\n method: \"create_or_update_object\",\n name: \"Create or update object\",\n 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.\n \n Use this tool when you need to create a new object, or update an existing custom-object. Custom objects can be used to subscribe users' to as lists, and also send non-user facing notifications to.`,\n parameters: z.object({\n collection: z\n .string()\n .describe(\"(string): The collection to create or update the object in.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to create or update.\"),\n properties: z\n .record(z.string(), z.any())\n .describe(\"(object): The properties to set on the object.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.objects.set(\n params.collection,\n params.objectId,\n params.properties\n );\n },\n});\n\nconst deleteObject = KnockTool({\n method: \"delete_object\",\n name: \"Delete object\",\n description: `Delete an object from a specific collection. Use this tool when you need to remove an object from the system.`,\n parameters: z.object({\n collection: z\n .string()\n .describe(\"(string): The collection to delete the object from.\"),\n objectId: z.string().describe(\"(string): The ID of the object to delete.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n await publicClient.objects.delete(params.collection, params.objectId);\n return { success: true };\n },\n});\n\nconst subscribeUsersToObject = KnockTool({\n method: \"subscribe_users_to_object\",\n name: \"Subscribe users to object\",\n description: `\n Subscribe a list of users to an object in a specific collection. We use this to model lists of users, for pub-sub use cases.\n \n Use this tool when you need to subscribe one or more users to an object where you will then trigger workflows for those lists of users to send notifications to.\n\n Before using this tool, you should create the object in the collection using the createOrUpdateObject tool.\n `,\n parameters: z.object({\n collection: z\n .string()\n .describe(\"(string): The collection to subscribe the user to.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to subscribe the user to.\"),\n userIds: z\n .array(z.string())\n .describe(\n \"(array): The IDs of the users to subscribe to the object. If not provided, the current user will be subscribed.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.objects.addSubscriptions(\n params.collection,\n params.objectId,\n {\n recipients: params.userIds ?? [config.userId],\n }\n );\n },\n});\n\nconst unsubscribeUsersFromObject = KnockTool({\n method: \"unsubscribe_users_from_object\",\n name: \"Unsubscribe users from object\",\n description: `Unsubscribe a list of users from an object in a specific collection. We use this to model lists of users, for pub-sub use cases.\n \n Use this tool when you need to unsubscribe one or more users from an object where you will then trigger workflows for those lists of users to send notifications to.`,\n parameters: z.object({\n collection: z\n .string()\n .describe(\"(string): The collection to unsubscribe the user from.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to unsubscribe the user from.\"),\n userIds: z\n .array(z.string())\n .describe(\n \"(array): The IDs of the users to unsubscribe from the object.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.objects.deleteSubscriptions(\n params.collection,\n params.objectId,\n {\n recipients: params.userIds ?? [config.userId],\n }\n );\n },\n});\n\nexport const objects = {\n listObjects,\n getObject,\n createOrUpdateObject,\n deleteObject,\n subscribeUsersToObject,\n unsubscribeUsersFromObject,\n};\n\nexport const permissions = {\n read: [\"listObjects\", \"getObject\"],\n manage: [\n \"createOrUpdateObject\",\n \"deleteObject\",\n \"subscribeUsersToObject\",\n \"unsubscribeUsersFromObject\",\n ],\n};\n"],"mappings":";;;;;AAAA,SAAS,SAAS;AAGlB,IAAM,cAAc,UAAU;AAAA,EAC5B,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aACE;AAAA,EACF,YAAY,EAAE,OAAO;AAAA,IACnB,YAAY,EACT,OAAO,EACP,SAAS,gDAAgD;AAAA,EAC9D,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,UAAM,eAAe,MAAM,YAAY,UAAU;AACjD,WAAO,MAAM,aAAa,QAAQ,KAAK,OAAO,UAAU;AAAA,EAC1D;AACF,CAAC;AAED,IAAM,YAAY,UAAU;AAAA,EAC1B,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aACE;AAAA,EACF,YAAY,EAAE,OAAO;AAAA,IACnB,YAAY,EACT,OAAO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B,MAAM,CAAC,eAAe,WAAW;AAAA,EACjC,QAAQ;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,191 @@
1
+ import {
2
+ KnockTool
3
+ } from "./chunk-TOBLV65T.js";
4
+
5
+ // src/lib/tools/message-types.ts
6
+ import { z } from "zod";
7
+ var listMessageTypes = KnockTool({
8
+ method: "list_message_types",
9
+ name: "List message types",
10
+ description: "List all message types available for the environment. Each message type returns the schema, which includes information about the variants and the fields available per-variant. Use this tool when you need to understand the different message types that are available for the environment for use in Guides.",
11
+ parameters: z.object({
12
+ environment: z.string().describe(
13
+ "(string): The environment to list message types for. Defaults to `development`."
14
+ )
15
+ }),
16
+ execute: (knockClient, config) => async (params) => {
17
+ const allMessageTypes = [];
18
+ for await (const messageType of knockClient.messageTypes.list({
19
+ environment: params.environment ?? config.environment ?? "development"
20
+ })) {
21
+ allMessageTypes.push(messageType);
22
+ }
23
+ return allMessageTypes;
24
+ }
25
+ });
26
+ var createOrUpdateMessageType = KnockTool({
27
+ method: "create_or_update_message_type",
28
+ name: "Create or update message type",
29
+ description: `
30
+ 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".
31
+
32
+ Use this tool when you need to create a new message type, or update an existing message type. You must pass the FULL message type to this tool if you're going to update an existing message type.
33
+
34
+ The preview is a string of HTML that will be rendered in the Knock UI as a representation of the message type. It is shared across all variants. It supports liquid, where the field name is available as a variable, so a field named "text" will be rendered as {{ text }}.
35
+
36
+ <example>
37
+ <description>
38
+ Create a new message type for a banner component that has a text and an action URL.
39
+ </description>
40
+ <input>
41
+ {
42
+ "messageTypeKey": "banner",
43
+ "name": "Banner",
44
+ "description": "A banner component that has a text and an action URL.",
45
+ "preview": "<div>{{ text }}</div>",
46
+ "variants": [
47
+ {
48
+ "key": "default",
49
+ "name": "Default",
50
+ "fields": [
51
+ {
52
+ "key": "text",
53
+ "type": "text",
54
+ "label": "Text",
55
+ "settings": {
56
+ "max_length": 100,
57
+ },
58
+ },
59
+ {
60
+ "key": "action_url",
61
+ "type": "text",
62
+ "label": "Action URL",
63
+ "settings": {
64
+ "placeholder": "https://example.com",
65
+ },
66
+ }
67
+ ]
68
+ }
69
+ ]
70
+ }
71
+ </input>
72
+ </example>
73
+ <example>
74
+ <description>
75
+ Create a message type for a card component that has an icon type, title, body, and a single action button.
76
+ </description>
77
+ <input>
78
+ {
79
+ "messageTypeKey": "card",
80
+ "name": "Card",
81
+ "description": "A single-action card component.",
82
+ "preview": "
83
+ <div>
84
+ <h2>{{ title }}</h2>
85
+ <p>{{ body }}</p>
86
+ <button>Action</button>
87
+ </div>
88
+ ",
89
+ "variants": [
90
+ {
91
+ "key": "default",
92
+ "name": "Default",
93
+ "fields": [
94
+ {
95
+ "key": "icon_type",
96
+ "type": "select",
97
+ "label": "Icon type",
98
+ "settings": {
99
+ "options": [
100
+ {
101
+ "value": "warning",
102
+ "label": "Warning",
103
+ },
104
+ {
105
+ "value": "success",
106
+ "label": "Success",
107
+ },
108
+ {
109
+ "value": "info",
110
+ "label": "Info",
111
+ },
112
+ {
113
+ "value": "error",
114
+ "label": "Error",
115
+ },
116
+ ]
117
+ },
118
+ },
119
+ {
120
+ "key": "title",
121
+ "type": "text",
122
+ "label": "Title",
123
+ },
124
+ {
125
+ "key": "description",
126
+ "type": "markdown",
127
+ "label": "Description",
128
+ },
129
+ {
130
+ "key": "action_button",
131
+ "type": "button",
132
+ "label": "Action button",
133
+ },
134
+ ]
135
+ }
136
+ ]
137
+ }
138
+ </input>
139
+ </example>
140
+ `,
141
+ parameters: z.object({
142
+ messageTypeKey: z.string().describe("(string): The key of the message type to create or update."),
143
+ name: z.string().describe("(string): The name of the message type."),
144
+ description: z.string().optional().describe("(string): The description of the message type."),
145
+ preview: z.string().optional().describe(
146
+ "(string): The preview of the variant. This is a string of HTML that will be rendered in the preview of the message type. There is a single preview shared by all variants."
147
+ ),
148
+ variants: z.array(
149
+ z.object({
150
+ key: z.string().describe("(string): The key of the variant."),
151
+ name: z.string().describe("(string): The name of the variant."),
152
+ description: z.string().optional().describe("(string): The description of the variant."),
153
+ fields: z.array(
154
+ z.object({
155
+ key: z.string().describe("(string): The key of the field."),
156
+ type: z.string().describe(
157
+ "(string): The type of the field. One of `text`, `textarea`, `button`, `markdown`, `select`, `multi_select`."
158
+ ),
159
+ label: z.string().describe("(string): The label of the field."),
160
+ settings: z.object({}).describe("(object): The settings of the field.")
161
+ })
162
+ ).describe("(array): The fields of the variant.")
163
+ })
164
+ ).describe("(array): The variants of the message type.")
165
+ }),
166
+ execute: (knockClient, config) => async (params) => {
167
+ return await knockClient.messageTypes.upsert(params.messageTypeKey, {
168
+ message_type: {
169
+ name: params.name,
170
+ variants: params.variants,
171
+ description: params.description ?? "",
172
+ preview: params.preview ?? "<div></div>"
173
+ },
174
+ environment: params.environment ?? config.environment ?? "development"
175
+ });
176
+ }
177
+ });
178
+ var messageTypes = {
179
+ listMessageTypes,
180
+ createOrUpdateMessageType
181
+ };
182
+ var permissions = {
183
+ read: ["listMessageTypes"],
184
+ manage: ["createOrUpdateMessageType"]
185
+ };
186
+
187
+ export {
188
+ messageTypes,
189
+ permissions
190
+ };
191
+ //# sourceMappingURL=chunk-THLK376Y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/tools/message-types.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\nimport { MessageType } from \"@knocklabs/mgmt/resources/message-types.js\";\n\nconst listMessageTypes = KnockTool({\n method: \"list_message_types\",\n name: \"List message types\",\n description:\n \"List all message types available for the environment. Each message type returns the schema, which includes information about the variants and the fields available per-variant. Use this tool when you need to understand the different message types that are available for the environment for use in Guides.\",\n parameters: z.object({\n environment: z\n .string()\n .describe(\n \"(string): The environment to list message types for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allMessageTypes: MessageType[] = [];\n for await (const messageType of knockClient.messageTypes.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allMessageTypes.push(messageType);\n }\n return allMessageTypes;\n },\n});\n\nconst createOrUpdateMessageType = KnockTool({\n method: \"create_or_update_message_type\",\n name: \"Create or update message type\",\n description: `\n 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\".\n \n Use this tool when you need to create a new message type, or update an existing message type. You must pass the FULL message type to this tool if you're going to update an existing message type.\n\n The preview is a string of HTML that will be rendered in the Knock UI as a representation of the message type. It is shared across all variants. It supports liquid, where the field name is available as a variable, so a field named \"text\" will be rendered as {{ text }}.\n\n <example>\n <description>\n Create a new message type for a banner component that has a text and an action URL.\n </description>\n <input>\n {\n \"messageTypeKey\": \"banner\",\n \"name\": \"Banner\",\n \"description\": \"A banner component that has a text and an action URL.\",\n \"preview\": \"<div>{{ text }}</div>\",\n \"variants\": [\n {\n \"key\": \"default\",\n \"name\": \"Default\",\n \"fields\": [\n {\n \"key\": \"text\",\n \"type\": \"text\",\n \"label\": \"Text\",\n \"settings\": {\n \"max_length\": 100,\n },\n },\n {\n \"key\": \"action_url\",\n \"type\": \"text\",\n \"label\": \"Action URL\",\n \"settings\": {\n \"placeholder\": \"https://example.com\",\n },\n }\n ]\n }\n ]\n }\n </input>\n </example>\n <example>\n <description>\n Create a message type for a card component that has an icon type, title, body, and a single action button.\n </description>\n <input>\n {\n \"messageTypeKey\": \"card\",\n \"name\": \"Card\",\n \"description\": \"A single-action card component.\",\n \"preview\": \"\n <div>\n <h2>{{ title }}</h2>\n <p>{{ body }}</p>\n <button>Action</button>\n </div>\n \",\n \"variants\": [\n {\n \"key\": \"default\",\n \"name\": \"Default\",\n \"fields\": [\n {\n \"key\": \"icon_type\",\n \"type\": \"select\",\n \"label\": \"Icon type\",\n \"settings\": {\n \"options\": [\n {\n \"value\": \"warning\",\n \"label\": \"Warning\",\n },\n {\n \"value\": \"success\",\n \"label\": \"Success\",\n },\n {\n \"value\": \"info\",\n \"label\": \"Info\",\n },\n {\n \"value\": \"error\",\n \"label\": \"Error\",\n },\n ]\n },\n },\n {\n \"key\": \"title\",\n \"type\": \"text\",\n \"label\": \"Title\",\n },\n {\n \"key\": \"description\",\n \"type\": \"markdown\",\n \"label\": \"Description\",\n },\n {\n \"key\": \"action_button\",\n \"type\": \"button\",\n \"label\": \"Action button\",\n },\n ]\n }\n ]\n }\n </input>\n </example>\n `,\n parameters: z.object({\n messageTypeKey: z\n .string()\n .describe(\"(string): The key of the message type to create or update.\"),\n name: z.string().describe(\"(string): The name of the message type.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the message type.\"),\n preview: z\n .string()\n .optional()\n .describe(\n \"(string): The preview of the variant. This is a string of HTML that will be rendered in the preview of the message type. There is a single preview shared by all variants.\"\n ),\n variants: z\n .array(\n z.object({\n key: z.string().describe(\"(string): The key of the variant.\"),\n name: z.string().describe(\"(string): The name of the variant.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the variant.\"),\n fields: z\n .array(\n z.object({\n key: z.string().describe(\"(string): The key of the field.\"),\n type: z\n .string()\n .describe(\n \"(string): The type of the field. One of `text`, `textarea`, `button`, `markdown`, `select`, `multi_select`.\"\n ),\n label: z.string().describe(\"(string): The label of the field.\"),\n settings: z\n .object({})\n .describe(\"(object): The settings of the field.\"),\n })\n )\n .describe(\"(array): The fields of the variant.\"),\n })\n )\n .describe(\"(array): The variants of the message type.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.messageTypes.upsert(params.messageTypeKey, {\n message_type: {\n name: params.name,\n variants: params.variants,\n description: params.description ?? \"\",\n preview: params.preview ?? \"<div></div>\",\n },\n environment: params.environment ?? config.environment ?? \"development\",\n });\n },\n});\n\nexport const messageTypes = {\n listMessageTypes,\n createOrUpdateMessageType,\n};\n\nexport const permissions = {\n read: [\"listMessageTypes\"],\n manage: [\"createOrUpdateMessageType\"],\n};\n"],"mappings":";;;;;AAAA,SAAS,SAAS;AAIlB,IAAM,m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names":[]}
@@ -0,0 +1,75 @@
1
+ import {
2
+ KnockTool
3
+ } from "./chunk-TOBLV65T.js";
4
+
5
+ // src/lib/tools/commits.ts
6
+ import { z } from "zod";
7
+ var listCommits = KnockTool({
8
+ method: "list_commits",
9
+ name: "List commits",
10
+ description: `
11
+ Returns all commits available in the environment. Use this tool when you are asked to see what changes are available to be deployed.
12
+ `,
13
+ parameters: z.object({
14
+ environment: z.string().describe(
15
+ "(string): The environment to list commits for. Defaults to `development`."
16
+ ),
17
+ promoted: z.boolean().describe(
18
+ "(boolean): Whether to only return promoted commits. Defaults to `false`."
19
+ )
20
+ }),
21
+ execute: (knockClient, config) => async (params) => {
22
+ return await knockClient.commits.list({
23
+ environment: params.environment ?? config.environment ?? "development",
24
+ promoted: params.promoted ?? false
25
+ });
26
+ }
27
+ });
28
+ var commitAllChanges = KnockTool({
29
+ method: "commit_all_changes",
30
+ name: "Commit all changes",
31
+ description: `
32
+ Commit all pending changes to the current environment. Use this tool when you are asked to save all changes to the current environment. This can only be used in the development environment.
33
+ `,
34
+ parameters: z.object({
35
+ message: z.string().describe("(string): The message to include in the commit.")
36
+ }),
37
+ execute: (knockClient, config) => async (params) => {
38
+ return await knockClient.commits.commitAll({
39
+ environment: config.environment ?? "development",
40
+ commit_message: params.message
41
+ });
42
+ }
43
+ });
44
+ var promoteAllCommits = KnockTool({
45
+ method: "promote_all_commits",
46
+ name: "Promote all commits",
47
+ description: `
48
+ Promote all commits to the next environment. Use this tool when you are asked to deploy all changes.
49
+
50
+ When not specified, the \`toEnvironment\` will default to the environment that comes after the environment specified in the config.
51
+ `,
52
+ parameters: z.object({
53
+ toEnvironment: z.string().describe("(string): The environment to promote all commits to.")
54
+ }),
55
+ execute: (knockClient, config) => async (params) => {
56
+ return await knockClient.put("/v1/commits/promote", {
57
+ body: { to_environment: params.toEnvironment }
58
+ });
59
+ }
60
+ });
61
+ var commits = {
62
+ listCommits,
63
+ commitAllChanges,
64
+ promoteAllCommits
65
+ };
66
+ var permissions = {
67
+ read: ["listCommits"],
68
+ manage: ["commitAllChanges", "promoteAllCommits"]
69
+ };
70
+
71
+ export {
72
+ commits,
73
+ permissions
74
+ };
75
+ //# sourceMappingURL=chunk-TLHETJRF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/tools/commits.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listCommits = KnockTool({\n method: \"list_commits\",\n name: \"List commits\",\n description: `\n Returns all commits available in the environment. Use this tool when you are asked to see what changes are available to be deployed.\n `,\n parameters: z.object({\n environment: z\n .string()\n .describe(\n \"(string): The environment to list commits for. Defaults to `development`.\"\n ),\n promoted: z\n .boolean()\n .describe(\n \"(boolean): Whether to only return promoted commits. Defaults to `false`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.commits.list({\n environment: params.environment ?? config.environment ?? \"development\",\n promoted: params.promoted ?? false,\n });\n },\n});\n\nconst commitAllChanges = KnockTool({\n method: \"commit_all_changes\",\n name: \"Commit all changes\",\n description: `\n Commit all pending changes to the current environment. Use this tool when you are asked to save all changes to the current environment. This can only be used in the development environment.\n `,\n parameters: z.object({\n message: z\n .string()\n .describe(\"(string): The message to include in the commit.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.commits.commitAll({\n environment: config.environment ?? \"development\",\n commit_message: params.message,\n });\n },\n});\n\nconst promoteAllCommits = KnockTool({\n method: \"promote_all_commits\",\n name: \"Promote all commits\",\n description: `\n Promote all commits to the next environment. Use this tool when you are asked to deploy all changes. \n\n When not specified, the \\`toEnvironment\\` will default to the environment that comes after the environment specified in the config.\n `,\n parameters: z.object({\n toEnvironment: z\n .string()\n .describe(\"(string): The environment to promote all commits to.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.put(\"/v1/commits/promote\", {\n body: { to_environment: params.toEnvironment },\n });\n },\n});\n\nexport const commits = {\n listCommits,\n commitAllChanges,\n promoteAllCommits,\n};\n\nexport const permissions = {\n read: [\"listCommits\"],\n manage: [\"commitAllChanges\", \"promoteAllCommits\"],\n};\n"],"mappings":";;;;;AAAA,SAAS,SAAS;AAGlB,IAAM,cAAc,UAAU;AAAA,EAC5B,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA,EAGb,YAAY,EAAE,OAAO;AAAA,IACnB,aAAa,EACV,OAAO,EACP;AAAA,MACC;AAAA,IACF;AAAA,IACF,UAAU,EACP,QAAQ,EACR;AAAA,MACC;AAAA,IACF;AAAA,EACJ,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,WAAO,MAAM,YAAY,QAAQ,KAAK;AAAA,MACpC,aAAa,OAAO,eAAe,OAAO,eAAe;AAAA,MACzD,UAAU,OAAO,YAAY;AAAA,IAC/B,CAAC;AAAA,EACH;AACF,CAAC;AAED,IAAM,mBAAmB,UAAU;AAAA,EACjC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA,EAGb,YAAY,EAAE,OAAO;AAAA,IACnB,SAAS,EACN,OAAO,EACP,SAAS,iDAAiD;AAAA,EAC/D,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,WAAO,MAAM,YAAY,QAAQ,UAAU;AAAA,MACzC,aAAa,OAAO,eAAe;AAAA,MACnC,gBAAgB,OAAO;AAAA,IACzB,CAAC;AAAA,EACH;AACF,CAAC;AAED,IAAM,oBAAoB,UAAU;AAAA,EAClC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA,EAKb,YAAY,EAAE,OAAO;AAAA,IACnB,eAAe,EACZ,OAAO,EACP,SAAS,sDAAsD;AAAA,EACpE,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,WAAO,MAAM,YAAY,IAAI,uBAAuB;AAAA,MAClD,MAAM,EAAE,gB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