@composio/core 0.27.0 → 0.28.0
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.
- package/dist/{CustomTool-CqPoLUD6.d.mts → CustomTool-DyypijT6.d.mts} +2 -2
- package/dist/{Telemetry-41JkqpZ7.mjs → Telemetry-D2PJwXKx.mjs} +1 -1
- package/dist/{composio-BUa10iB3.d.mts → composio-CwHMpKXb.d.mts} +704 -26
- package/dist/{customTool.types-gX421uPT.d.mts → customTool.types-DoItUHkO.d.mts} +11 -10
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +3 -3
- package/dist/experimental/index.d.mts +2 -2
- package/dist/{fileUtils.node-DNLhLg0W.mjs → fileUtils.node-ILI1IjnZ.mjs} +4 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2107 -1977
- package/dist/models/Files.node.mjs +2 -2
- package/dist/sensitiveFileUploadPaths-BaEORC7-.mjs +588 -0
- package/dist/{types-DXxfzBX3.d.mts → types-DWZWePfZ.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/package.json +7 -6
- package/src/lib/toolRouterParams.ts +28 -33
- package/src/lib/toolRouterSessionDelete.ts +1 -10
- package/src/models/ConnectedAccounts.ts +1 -1
- package/src/models/CustomTool.ts +1 -1
- package/src/models/CustomToolkits.ts +114 -8
- package/src/models/Experimental.ts +1 -1
- package/src/models/MCP.ts +1 -2
- package/src/models/SessionConfigs.ts +11 -3
- package/src/models/SessionContext.ts +4 -4
- package/src/models/ToolRouter.ts +2 -3
- package/src/models/ToolRouterSession.ts +17 -16
- package/src/models/Tools.ts +3 -3
- package/src/models/Triggers.ts +12 -5
- package/src/models/inlineCustomToolsPayload.ts +3 -3
- package/src/models/proxyParamsTransform.ts +1 -1
- package/src/types/customTool.types.ts +13 -5
- package/src/types/customToolkits.types.ts +89 -9
- package/src/types/sessionConfigs.types.ts +21 -7
- package/src/types/toolRouter.types.ts +14 -7
- package/src/types/triggers.types.ts +14 -0
- package/src/utils/fileUtils.node.ts +5 -2
- package/src/utils/mime.ts +347 -1
- package/src/utils/transformers/connectedAccounts.ts +2 -7
- package/src/utils/transformers/customToolkits.ts +78 -9
- package/src/utils/transformers/sessionConfigs.ts +3 -3
- package/src/utils/transformers/toolRouterResponseTransform.ts +23 -75
- package/src/utils/transformers/toolkits.ts +7 -13
- package/src/utils/transformers/triggers.ts +28 -18
- package/dist/sensitiveFileUploadPaths-BlLp-Yo2.mjs +0 -189
package/src/models/Triggers.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import ComposioClient, { APIError } from '@composio/client';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type TriggerInstanceUpsertParams as ClientTriggerInstanceUpsertParams,
|
|
5
|
-
} from '@composio/client/resources/index';
|
|
2
|
+
import type { TriggerInstanceUpsertParams as ClientTriggerInstanceUpsertParams } from '@composio/client/resources/trigger-instances';
|
|
3
|
+
import { TriggersTypeRetrieveEnumResponse } from '@composio/client/resources/triggers-types';
|
|
6
4
|
import {
|
|
7
5
|
TriggerInstanceUpsertResponse,
|
|
8
6
|
TriggerInstanceUpsertParamsSchema,
|
|
@@ -238,10 +236,14 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
|
|
|
238
236
|
* Create a new trigger instance for a user
|
|
239
237
|
* If the connected account id is not provided, the first connected account for the user and toolkit will be used
|
|
240
238
|
*
|
|
239
|
+
* For a trigger that supports both webhook and polling, `body.type` picks one; omit it to let Composio choose.
|
|
240
|
+
* `body.pollingInterval` sets the minutes between polls and wins over `triggerConfig.interval`.
|
|
241
|
+
*
|
|
241
242
|
* @param {string} userId - The user id of the trigger instance
|
|
242
243
|
* @param {string} slug - The slug of the trigger instance
|
|
243
244
|
* @param {TriggerInstanceUpsertParams} body - The parameters to create the trigger instance
|
|
244
|
-
* @returns {Promise<TriggerInstanceUpsertResponse>} The
|
|
245
|
+
* @returns {Promise<TriggerInstanceUpsertResponse>} The trigger instance, with the type it uses, why it polls
|
|
246
|
+
* when it fell back from a webhook, and its polling interval
|
|
245
247
|
*/
|
|
246
248
|
async create(
|
|
247
249
|
userId: string,
|
|
@@ -288,6 +290,8 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
|
|
|
288
290
|
const upsertParams: ClientTriggerInstanceUpsertParams = {
|
|
289
291
|
connected_account_id: parsedBody.data.connectedAccountId,
|
|
290
292
|
trigger_config: parsedBody.data.triggerConfig,
|
|
293
|
+
type: parsedBody.data.type,
|
|
294
|
+
polling_interval: parsedBody.data.pollingInterval,
|
|
291
295
|
toolkit_versions: this.toolkitVersions,
|
|
292
296
|
user_id: userId,
|
|
293
297
|
};
|
|
@@ -298,6 +302,9 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
|
|
|
298
302
|
|
|
299
303
|
return {
|
|
300
304
|
triggerId: result.trigger_id,
|
|
305
|
+
type: result.type,
|
|
306
|
+
fallbackReason: result.fallback_reason,
|
|
307
|
+
pollingInterval: result.polling_interval,
|
|
301
308
|
};
|
|
302
309
|
}
|
|
303
310
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
SessionExecuteParams,
|
|
3
3
|
SessionSearchParams,
|
|
4
|
-
} from '@composio/client/resources/tool-router/session
|
|
4
|
+
} from '@composio/client/resources/tool-router/session';
|
|
5
5
|
import type { InlineCustomToolsWirePayload } from '../types/customTool.types';
|
|
6
6
|
|
|
7
7
|
type InlineCustomToolsExperimental =
|
|
8
|
-
| SessionExecuteParams
|
|
9
|
-
| SessionSearchParams
|
|
8
|
+
| NonNullable<SessionExecuteParams['experimental']>
|
|
9
|
+
| NonNullable<SessionSearchParams['experimental']>;
|
|
10
10
|
|
|
11
11
|
export function inlineCustomToolsExperimental<TExperimental extends InlineCustomToolsExperimental>(
|
|
12
12
|
payload?: InlineCustomToolsWirePayload
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* to the official @composio/client proxy execute params.
|
|
4
4
|
*/
|
|
5
5
|
import type { SessionProxyExecuteParams } from '../types/toolRouter.types';
|
|
6
|
-
import type { SessionProxyExecuteParams as ClientProxyExecuteParams } from '@composio/client/resources/tool-router/session
|
|
6
|
+
import type { SessionProxyExecuteParams as ClientProxyExecuteParams } from '@composio/client/resources/tool-router/session';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Transform SDK session proxy params to the official client request format.
|
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
import type {
|
|
9
9
|
SessionCreateParams,
|
|
10
10
|
SessionCreateResponse,
|
|
11
|
-
} from '@composio/client/resources/tool-router/session
|
|
11
|
+
} from '@composio/client/resources/tool-router/session';
|
|
12
12
|
|
|
13
13
|
export type AnyZodSchema = z.ZodType | z4.ZodType;
|
|
14
14
|
export type InferZodSchema<T extends AnyZodSchema> = T extends z.ZodType
|
|
@@ -142,7 +142,9 @@ export interface CustomTool {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/** Serialized tool definition sent to backend for search indexing. Uses official client type. */
|
|
145
|
-
export type CustomToolDefinition =
|
|
145
|
+
export type CustomToolDefinition = NonNullable<
|
|
146
|
+
NonNullable<SessionCreateParams['experimental']>['custom_tools']
|
|
147
|
+
>[number];
|
|
146
148
|
|
|
147
149
|
export type CustomToolWireDefinition = CustomToolDefinition;
|
|
148
150
|
|
|
@@ -188,7 +190,9 @@ export interface CustomToolkit {
|
|
|
188
190
|
}
|
|
189
191
|
|
|
190
192
|
/** Serialized toolkit definition sent to backend. Uses official client type. */
|
|
191
|
-
export type CustomToolkitDefinition =
|
|
193
|
+
export type CustomToolkitDefinition = NonNullable<
|
|
194
|
+
NonNullable<NonNullable<SessionCreateParams['experimental']>['custom_toolkits']>[number]
|
|
195
|
+
>;
|
|
192
196
|
|
|
193
197
|
export type CustomToolkitWireDefinition = CustomToolkitDefinition;
|
|
194
198
|
|
|
@@ -255,7 +259,11 @@ export interface RegisteredCustomToolkit {
|
|
|
255
259
|
// ────────────────────────────────────────────────────────────────
|
|
256
260
|
|
|
257
261
|
/** Custom tool as returned in the session create response (has prefixed slug + original_slug). */
|
|
258
|
-
export type CustomToolResponse =
|
|
262
|
+
export type CustomToolResponse = NonNullable<
|
|
263
|
+
NonNullable<SessionCreateResponse['experimental']>['custom_tools']
|
|
264
|
+
>[number];
|
|
259
265
|
|
|
260
266
|
/** Custom toolkit as returned in the session create response (has prefixed slugs + original_slugs). */
|
|
261
|
-
export type CustomToolkitResponse =
|
|
267
|
+
export type CustomToolkitResponse = NonNullable<
|
|
268
|
+
NonNullable<NonNullable<SessionCreateResponse['experimental']>['custom_toolkits']>[number]
|
|
269
|
+
>;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod/v3';
|
|
2
2
|
|
|
3
|
+
const CustomToolkitApiKeyFieldSchema = z.object({
|
|
4
|
+
displayName: z.string().min(1).max(100).optional(),
|
|
5
|
+
description: z.string().min(1).max(500).optional(),
|
|
6
|
+
});
|
|
7
|
+
export type CustomToolkitApiKeyField = z.infer<typeof CustomToolkitApiKeyFieldSchema>;
|
|
8
|
+
|
|
3
9
|
/**
|
|
4
10
|
* How end users authenticate to a custom toolkit.
|
|
5
11
|
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
@@ -15,10 +21,14 @@ export const CustomToolkitAuthSchemeSchema = z.discriminatedUnion('mode', [
|
|
|
15
21
|
*/
|
|
16
22
|
headers: z.record(z.string(), z.string()),
|
|
17
23
|
/** End-user copy for the API key input on the connect page. */
|
|
18
|
-
apiKeyField:
|
|
24
|
+
apiKeyField: CustomToolkitApiKeyFieldSchema.optional(),
|
|
25
|
+
/** Additional connect-page input used by `{{generic_id}}` in headers. */
|
|
26
|
+
additionalFields: z
|
|
19
27
|
.object({
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
genericId: z.object({
|
|
29
|
+
displayName: z.string().min(1).max(100),
|
|
30
|
+
description: z.string().min(1).max(500).optional(),
|
|
31
|
+
}),
|
|
22
32
|
})
|
|
23
33
|
.optional(),
|
|
24
34
|
}),
|
|
@@ -33,9 +43,84 @@ export const CustomToolkitAuthSchemeSchema = z.discriminatedUnion('mode', [
|
|
|
33
43
|
]);
|
|
34
44
|
export type CustomToolkitAuthScheme = z.infer<typeof CustomToolkitAuthSchemeSchema>;
|
|
35
45
|
|
|
46
|
+
const CustomToolkitLogoFileSchema = z.object({
|
|
47
|
+
content: z.string().min(1),
|
|
48
|
+
mimeType: z.enum(['image/png', 'image/jpeg']),
|
|
49
|
+
});
|
|
50
|
+
export type CustomToolkitLogoFile = z.infer<typeof CustomToolkitLogoFileSchema>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Params for `composio.experimental.customToolkits.create()`.
|
|
54
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
55
|
+
*/
|
|
56
|
+
export const CustomToolkitCreateParamsSchema = z.object({
|
|
57
|
+
/** Human-readable toolkit name. */
|
|
58
|
+
name: z.string().min(1).max(200),
|
|
59
|
+
/** The MCP server URL. Must use https. */
|
|
60
|
+
appUrl: z.string().url(),
|
|
61
|
+
/** Square PNG or JPEG logo (256-1024px, max 3MB), base64-encoded. Defaults to the MCP logo. */
|
|
62
|
+
logoFile: CustomToolkitLogoFileSchema.optional(),
|
|
63
|
+
/** At least one scheme. Cannot be changed after create. */
|
|
64
|
+
authSchemes: z.array(CustomToolkitAuthSchemeSchema).min(1),
|
|
65
|
+
/**
|
|
66
|
+
* `'all'` to share the toolkit with every user in the project, or a user ID
|
|
67
|
+
* to make it private to that user. Cannot be changed after create.
|
|
68
|
+
*/
|
|
69
|
+
userId: z.string().min(1),
|
|
70
|
+
/** Where to send the user after they connect. Used only for `connectLink`. */
|
|
71
|
+
callbackUrl: z.string().url().optional(),
|
|
72
|
+
});
|
|
73
|
+
export type CustomToolkitCreateParams = z.infer<typeof CustomToolkitCreateParamsSchema>;
|
|
74
|
+
|
|
75
|
+
export const CustomToolkitCreateResponseSchema = z.object({
|
|
76
|
+
/** Slug of the created toolkit. Store it to update, sync or delete the toolkit later. */
|
|
77
|
+
slug: z.string(),
|
|
78
|
+
/**
|
|
79
|
+
* Hosted connect page for a private toolkit's user. `null` for shared or
|
|
80
|
+
* no-auth toolkits, or if the link could not be created.
|
|
81
|
+
*/
|
|
82
|
+
connectLink: z
|
|
83
|
+
.object({
|
|
84
|
+
redirectUrl: z.string(),
|
|
85
|
+
expiresAt: z.string(),
|
|
86
|
+
connectedAccountId: z.string(),
|
|
87
|
+
})
|
|
88
|
+
.nullable(),
|
|
89
|
+
});
|
|
90
|
+
export type CustomToolkitCreateResponse = z.infer<typeof CustomToolkitCreateResponseSchema>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Params for `composio.experimental.customToolkits.update()`.
|
|
94
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
95
|
+
*/
|
|
96
|
+
export const CustomToolkitUpdateParamsSchema = z
|
|
97
|
+
.object({
|
|
98
|
+
name: z.string().min(1).max(200).optional(),
|
|
99
|
+
logoFile: CustomToolkitLogoFileSchema.optional(),
|
|
100
|
+
/** End-user copy for the API key input on the connect page. API_KEY toolkits only. */
|
|
101
|
+
apiKeyField: CustomToolkitApiKeyFieldSchema.optional(),
|
|
102
|
+
/**
|
|
103
|
+
* The user the toolkit is private to. Required to update a private toolkit
|
|
104
|
+
* when the project has 2FA enabled.
|
|
105
|
+
*/
|
|
106
|
+
userId: z.string().min(1).optional(),
|
|
107
|
+
})
|
|
108
|
+
.refine(
|
|
109
|
+
params => [params.name, params.logoFile, params.apiKeyField].some(value => value !== undefined),
|
|
110
|
+
{ message: 'Provide at least one of name, logoFile, apiKeyField' }
|
|
111
|
+
);
|
|
112
|
+
export type CustomToolkitUpdateParams = z.infer<typeof CustomToolkitUpdateParamsSchema>;
|
|
113
|
+
|
|
114
|
+
export const CustomToolkitUpdateResponseSchema = z.object({
|
|
115
|
+
success: z.literal(true),
|
|
116
|
+
});
|
|
117
|
+
export type CustomToolkitUpdateResponse = z.infer<typeof CustomToolkitUpdateResponseSchema>;
|
|
118
|
+
|
|
36
119
|
/**
|
|
37
120
|
* Params for `composio.experimental.customToolkits.upsert()`.
|
|
38
121
|
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
122
|
+
*
|
|
123
|
+
* @deprecated Use `CustomToolkitCreateParams` with `create()`.
|
|
39
124
|
*/
|
|
40
125
|
export const CustomToolkitUpsertParamsSchema = z.object({
|
|
41
126
|
/**
|
|
@@ -53,12 +138,7 @@ export const CustomToolkitUpsertParamsSchema = z.object({
|
|
|
53
138
|
/** The app URL. For an MCP app, the MCP server URL. */
|
|
54
139
|
appUrl: z.string().url(),
|
|
55
140
|
/** Square PNG or JPEG logo (256-1024px, max 3MB), base64-encoded. Defaults to the Composio logo. */
|
|
56
|
-
logoFile:
|
|
57
|
-
.object({
|
|
58
|
-
content: z.string().min(1),
|
|
59
|
-
mimeType: z.enum(['image/png', 'image/jpeg']),
|
|
60
|
-
})
|
|
61
|
-
.optional(),
|
|
141
|
+
logoFile: CustomToolkitLogoFileSchema.optional(),
|
|
62
142
|
/** At least one scheme. The schemes cannot change once the toolkit exists. */
|
|
63
143
|
authSchemes: z.array(CustomToolkitAuthSchemeSchema).min(1),
|
|
64
144
|
}),
|
|
@@ -6,7 +6,10 @@ import { ToolRouterTagsParamSchema } from './toolRouter.types';
|
|
|
6
6
|
* active configs only, 20 per page, at most 100.
|
|
7
7
|
*/
|
|
8
8
|
export const SessionConfigListParamsSchema = z.object({
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated The Composio API no longer accepts this field. It is ignored
|
|
11
|
+
* and `list()` logs a warning when it is set; filter `items` by name instead.
|
|
12
|
+
*/
|
|
10
13
|
search: z.string().optional(),
|
|
11
14
|
/** `true` returns only archived configs. Omitted returns active configs. */
|
|
12
15
|
archived: z.boolean().optional(),
|
|
@@ -43,25 +46,36 @@ export type SessionConfigListResponse = z.infer<typeof SessionConfigListResponse
|
|
|
43
46
|
const SessionConfigTagPolicySchema = z.object({
|
|
44
47
|
enable: z.array(ToolRouterTagsParamSchema.element).optional(),
|
|
45
48
|
disable: z.array(ToolRouterTagsParamSchema.element).optional(),
|
|
49
|
+
/** Tags whose tools need the user's approval before they run. */
|
|
50
|
+
require_approval: z.array(ToolRouterTagsParamSchema.element).optional(),
|
|
46
51
|
});
|
|
47
52
|
|
|
53
|
+
/** What in a policy entry needs the user's approval before it runs. */
|
|
54
|
+
const requireApproval = { require_approval: z.array(z.string()).optional() };
|
|
55
|
+
const ApprovalOnlyPolicySchema = z.object({ require_approval: z.array(z.string()) });
|
|
56
|
+
|
|
48
57
|
/**
|
|
49
58
|
* The access policy stored in a saved Session config, in the backend's
|
|
50
|
-
* `enable`/`disable` shape. Toolkit slug keys and tag names
|
|
51
|
-
* as the backend sends them.
|
|
59
|
+
* `enable`/`disable`/`require_approval` shape. Toolkit slug keys and tag names
|
|
60
|
+
* are kept exactly as the backend sends them.
|
|
52
61
|
*/
|
|
53
62
|
export const SessionConfigPolicySchema = z.object({
|
|
54
63
|
toolkits: z
|
|
55
|
-
.union([
|
|
64
|
+
.union([
|
|
65
|
+
z.object({ enable: z.array(z.string()), ...requireApproval }),
|
|
66
|
+
z.object({ disable: z.array(z.string()), ...requireApproval }),
|
|
67
|
+
ApprovalOnlyPolicySchema,
|
|
68
|
+
])
|
|
56
69
|
.optional(),
|
|
57
70
|
/** Per-toolkit tool policy, keyed by toolkit slug. */
|
|
58
71
|
tools: z
|
|
59
72
|
.record(
|
|
60
73
|
z.string(),
|
|
61
74
|
z.union([
|
|
62
|
-
z.object({ enable: z.array(z.string()) }),
|
|
63
|
-
z.object({ disable: z.array(z.string()) }),
|
|
64
|
-
z.object({ tags: SessionConfigTagPolicySchema }),
|
|
75
|
+
z.object({ enable: z.array(z.string()), ...requireApproval }),
|
|
76
|
+
z.object({ disable: z.array(z.string()), ...requireApproval }),
|
|
77
|
+
z.object({ tags: SessionConfigTagPolicySchema, ...requireApproval }),
|
|
78
|
+
ApprovalOnlyPolicySchema,
|
|
65
79
|
])
|
|
66
80
|
)
|
|
67
81
|
.optional(),
|
|
@@ -5,12 +5,13 @@ import { ConnectionRequest } from './connectionRequest.types';
|
|
|
5
5
|
import type { ComposioRequestOptions } from './requestOptions.types';
|
|
6
6
|
import type { ToolRouterSessionFilesMount } from '../models/ToolRouterSessionFileMount';
|
|
7
7
|
import { ConnectedAccountExperimentalSchema } from './connectedAccounts.types';
|
|
8
|
+
import type { ConnectedAccountExperimental } from './connectedAccounts.types';
|
|
8
9
|
import type {
|
|
9
10
|
SessionConfigHistoryResponse,
|
|
10
11
|
SessionCreateResponse,
|
|
11
12
|
SessionExecuteMetaParams,
|
|
12
13
|
SessionExecuteParams,
|
|
13
|
-
} from '@composio/client/resources/tool-router/session
|
|
14
|
+
} from '@composio/client/resources/tool-router/session';
|
|
14
15
|
import type {
|
|
15
16
|
CustomTool,
|
|
16
17
|
CustomToolkit,
|
|
@@ -715,7 +716,7 @@ export type ToolRouterToolsFn<
|
|
|
715
716
|
|
|
716
717
|
export type ToolRouterAuthorizeFn = (
|
|
717
718
|
toolkit: string,
|
|
718
|
-
options?: { callbackUrl?: string; alias?: string }
|
|
719
|
+
options?: { callbackUrl?: string; alias?: string; experimental?: ConnectedAccountExperimental }
|
|
719
720
|
) => Promise<ConnectionRequest>;
|
|
720
721
|
|
|
721
722
|
export const ToolRouterToolkitsOptionsSchema = z.object({
|
|
@@ -1011,11 +1012,15 @@ export type ToolRouterSessionExecuteMetaFn = (
|
|
|
1011
1012
|
requestOptions?: ComposioRequestOptions
|
|
1012
1013
|
) => Promise<ToolRouterSessionExecuteResponse>;
|
|
1013
1014
|
|
|
1014
|
-
export type ToolRouterSessionPreloadConfig =
|
|
1015
|
+
export type ToolRouterSessionPreloadConfig = NonNullable<
|
|
1016
|
+
SessionCreateResponse['config']
|
|
1017
|
+
>['preload'];
|
|
1015
1018
|
|
|
1016
|
-
export type ToolRouterSessionWorkbenchConfig =
|
|
1019
|
+
export type ToolRouterSessionWorkbenchConfig = NonNullable<
|
|
1020
|
+
NonNullable<SessionCreateResponse['config']>['workbench']
|
|
1021
|
+
>;
|
|
1017
1022
|
|
|
1018
|
-
export type ToolRouterSessionWarning = SessionCreateResponse
|
|
1023
|
+
export type ToolRouterSessionWarning = NonNullable<SessionCreateResponse['warnings']>[number];
|
|
1019
1024
|
|
|
1020
1025
|
/**
|
|
1021
1026
|
* Server-side session configuration as returned by the API: toolkit/tool
|
|
@@ -1023,7 +1028,7 @@ export type ToolRouterSessionWarning = SessionCreateResponse.Warning;
|
|
|
1023
1028
|
* preload, sandbox (`workbench`), search, execute, proxy execute and Instant
|
|
1024
1029
|
* settings.
|
|
1025
1030
|
*/
|
|
1026
|
-
export type ToolRouterSessionConfig = SessionCreateResponse
|
|
1031
|
+
export type ToolRouterSessionConfig = NonNullable<SessionCreateResponse['config']>;
|
|
1027
1032
|
|
|
1028
1033
|
export interface ToolRouterSessionMetadata {
|
|
1029
1034
|
/** Present on every session built from an API response; the constructor synthesises a minimal config when absent. */
|
|
@@ -1351,7 +1356,9 @@ export type ToolRouterSessionListConfigHistoryOptions = z.infer<
|
|
|
1351
1356
|
* The session configuration at one version, as stored by the API. This is
|
|
1352
1357
|
* the wire shape (snake_case), with the Instant policy under `instant`.
|
|
1353
1358
|
*/
|
|
1354
|
-
export type ToolRouterSessionConfigHistoryConfig =
|
|
1359
|
+
export type ToolRouterSessionConfigHistoryConfig = NonNullable<
|
|
1360
|
+
SessionConfigHistoryResponse['items'][number]['config']
|
|
1361
|
+
>;
|
|
1355
1362
|
|
|
1356
1363
|
export type ToolRouterSessionConfigHistoryItem = {
|
|
1357
1364
|
/** The config version this entry represents. */
|
|
@@ -30,6 +30,9 @@ export const TriggerInstanceListActiveParamsSchema = z.object({
|
|
|
30
30
|
|
|
31
31
|
export type TriggerInstanceListActiveParams = z.infer<typeof TriggerInstanceListActiveParamsSchema>;
|
|
32
32
|
|
|
33
|
+
export const TriggerInstanceTypeSchema = z.enum(['webhook', 'poll']);
|
|
34
|
+
export type TriggerInstanceType = z.infer<typeof TriggerInstanceTypeSchema>;
|
|
35
|
+
|
|
33
36
|
export const TriggerInstanceListActiveResponseItemSchema = z.object({
|
|
34
37
|
id: z.string(),
|
|
35
38
|
connectedAccountId: z.string(),
|
|
@@ -40,6 +43,9 @@ export const TriggerInstanceListActiveResponseItemSchema = z.object({
|
|
|
40
43
|
updatedAt: z.string(),
|
|
41
44
|
triggerData: z.string().optional(),
|
|
42
45
|
uuid: z.string().optional(),
|
|
46
|
+
type: TriggerInstanceTypeSchema,
|
|
47
|
+
fallbackReason: z.string().nullable(),
|
|
48
|
+
pollingInterval: z.number().nullable(),
|
|
43
49
|
});
|
|
44
50
|
|
|
45
51
|
export const TriggerInstanceListActiveResponseSchema = z.object({
|
|
@@ -58,12 +64,17 @@ export type TriggerInstanceListActiveResponseItem = z.infer<
|
|
|
58
64
|
export const TriggerInstanceUpsertParamsSchema = z.object({
|
|
59
65
|
connectedAccountId: z.string().optional(),
|
|
60
66
|
triggerConfig: z.record(z.unknown()).optional(),
|
|
67
|
+
type: TriggerInstanceTypeSchema.optional(),
|
|
68
|
+
pollingInterval: z.number().int().positive().optional(),
|
|
61
69
|
});
|
|
62
70
|
|
|
63
71
|
export type TriggerInstanceUpsertParams = z.infer<typeof TriggerInstanceUpsertParamsSchema>;
|
|
64
72
|
|
|
65
73
|
export const TriggerInstanceUpsertResponseSchema = z.object({
|
|
66
74
|
triggerId: z.string(),
|
|
75
|
+
type: TriggerInstanceTypeSchema,
|
|
76
|
+
fallbackReason: z.string().nullable(),
|
|
77
|
+
pollingInterval: z.number().nullable(),
|
|
67
78
|
});
|
|
68
79
|
|
|
69
80
|
export type TriggerInstanceUpsertResponse = z.infer<typeof TriggerInstanceUpsertResponseSchema>;
|
|
@@ -162,6 +173,9 @@ export const TriggerTypeSchema = z.object({
|
|
|
162
173
|
payload: z.record(z.unknown()),
|
|
163
174
|
config: z.record(z.unknown()),
|
|
164
175
|
version: z.string().optional(),
|
|
176
|
+
type: TriggerInstanceTypeSchema,
|
|
177
|
+
types: z.array(TriggerInstanceTypeSchema),
|
|
178
|
+
requiresWebhookEndpointSetup: z.boolean().optional(),
|
|
165
179
|
});
|
|
166
180
|
|
|
167
181
|
export type TriggerType = z.infer<typeof TriggerTypeSchema>;
|
|
@@ -11,6 +11,7 @@ import { assertSafeFileUploadPath } from './sensitiveFileUploadPaths';
|
|
|
11
11
|
import { assertPathInsideUploadDirs } from './uploadDirAllowlist.node';
|
|
12
12
|
import { ssrfSafeFetch } from './ssrfGuard.node';
|
|
13
13
|
import { readResponseBodyWithLimit } from './readResponseBody';
|
|
14
|
+
import { getMimeTypeFromFileName } from './mime';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Options for {@link getFileDataAfterUploadingToS3} (S3 presigned upload from local path, URL, or File).
|
|
@@ -66,6 +67,7 @@ const getExtensionFromMimeType = (mimeType: string): string => {
|
|
|
66
67
|
'text/plain': 'txt',
|
|
67
68
|
'text/html': 'html',
|
|
68
69
|
'text/css': 'css',
|
|
70
|
+
'text/csv': 'csv',
|
|
69
71
|
'text/javascript': 'js',
|
|
70
72
|
'application/json': 'json',
|
|
71
73
|
'application/xml': 'xml',
|
|
@@ -102,7 +104,8 @@ const getExtensionFromMimeType = (mimeType: string): string => {
|
|
|
102
104
|
const cleanMimeType = mimeType.split(';')[0].toLowerCase().trim();
|
|
103
105
|
|
|
104
106
|
// Try exact match first
|
|
105
|
-
|
|
107
|
+
// An own property only: `constructor` or `__proto__` must not reach Object.prototype.
|
|
108
|
+
if (Object.hasOwn(mimeToExt, cleanMimeType)) {
|
|
106
109
|
return mimeToExt[cleanMimeType];
|
|
107
110
|
}
|
|
108
111
|
|
|
@@ -160,7 +163,7 @@ const readFileContent = async (
|
|
|
160
163
|
content instanceof Uint8Array
|
|
161
164
|
? uint8ArrayToBase64(content)
|
|
162
165
|
: uint8ArrayToBase64(new TextEncoder().encode(content)),
|
|
163
|
-
mimeType:
|
|
166
|
+
mimeType: getMimeTypeFromFileName(filePath),
|
|
164
167
|
};
|
|
165
168
|
} catch (error) {
|
|
166
169
|
throw new Error(`Error reading file at ${filePath}: ${error}`);
|