@composio/core 0.11.0 → 0.13.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/BaseProvider-BBnsv9kS.d.mts +29425 -0
- package/dist/{BaseProvider-CVbQxTNa.d.cts → BaseProvider-Brb3o86-.d.mts} +91 -44
- package/dist/CustomTool-D9qwyMrv.mjs +468 -0
- package/dist/{CustomTool-C-IUByoU.d.cts → CustomTool-Dmi6ti3I.d.mts} +2 -4
- package/dist/{CustomTool-CChQSp44.d.mts → CustomTool-DrJpOhY2.d.mts} +2 -4
- package/dist/{FileModifierErrors-C7z16Dfi.mjs → FileModifierErrors-3fSwIWoa.mjs} +35 -36
- package/dist/{Telemetry-DQax33Gh.mjs → Telemetry-DhGI_J4G.mjs} +15 -15
- package/dist/{composio-pcA13w87.d.cts → composio-DHIKRdeG.d.mts} +641 -380
- package/dist/{composio-BlASKqjQ.d.mts → composio-vMwhASRc.d.mts} +1390 -1129
- package/dist/{customTool.types-QtkAZQma.d.cts → customTool.types-CKH2R2ia.d.mts} +487 -189
- package/dist/{customTool.types-DLIORcYN.d.mts → customTool.types-DXin7Cfc.d.mts} +924 -626
- package/dist/docs/error-consistency.md +97 -0
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +306 -0
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +205 -0
- package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +488 -0
- package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +94 -0
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +67 -0
- package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +304 -0
- package/dist/docs/reference/sdk-reference/typescript/meta.json +17 -0
- package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +107 -0
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +163 -0
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +229 -0
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +131 -0
- package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +169 -0
- package/dist/docs/reference/sdk-reference/typescript/tools.mdx +453 -0
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +434 -0
- package/dist/{CustomTool-D5s-aADw.mjs → errors-DSIlYfl5.mjs} +72 -459
- package/dist/experimental/index.d.mts +2 -3
- package/dist/experimental/index.mjs +1 -3
- package/dist/{fileUtils.node-Dq7ebZPC.mjs → fileUtils.node-BiO1JQsJ.mjs} +26 -25
- package/dist/index.d.mts +1708 -2400
- package/dist/index.mjs +2632 -2006
- package/dist/jsonSchema-CFKdONpP.mjs +251 -0
- package/dist/models/Files.node.d.mts +1 -2
- package/dist/models/Files.node.mjs +3 -4
- package/dist/models/Files.workerd.d.mts +0 -1
- package/dist/platform/node.d.mts +1 -2
- package/dist/platform/workerd.d.mts +1 -2
- package/dist/{chunk-CWQeghP5.mjs → rolldown-runtime-w6R9maHv.mjs} +3 -5
- package/dist/{types-J2KCXP8R.d.mts → types-D4Id3wXA.d.mts} +2 -3
- package/dist/{types-DRG5qLxI.d.cts → types-qTbYYBJw.d.mts} +2 -3
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.mjs +3 -0
- package/dist/utils/json-schema.d.mts +2 -0
- package/dist/utils/json-schema.mjs +3 -0
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +44 -24
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/docs/error-consistency.md +97 -0
- package/package.json +40 -88
- package/src/composio.ts +509 -0
- package/src/errors/AuthConfigErrors.ts +23 -0
- package/src/errors/ComposioError.ts +408 -0
- package/src/errors/ConnectedAccountsErrors.ts +158 -0
- package/src/errors/ConnectionRequestErrors.ts +32 -0
- package/src/errors/FileModifierErrors.ts +100 -0
- package/src/errors/PusherErrors.ts +28 -0
- package/src/errors/RemoteFileErrors.ts +62 -0
- package/src/errors/SDKErrors.ts +92 -0
- package/src/errors/ToolErrors.ts +244 -0
- package/src/errors/ToolkitErrors.ts +39 -0
- package/src/errors/TriggerErrors.ts +120 -0
- package/src/errors/ValidationErrors.ts +99 -0
- package/src/errors/index.ts +41 -0
- package/src/experimental/index.ts +28 -0
- package/src/index.ts +64 -0
- package/src/lib/toolRouterConstants.ts +1 -0
- package/src/lib/toolRouterParams.ts +306 -0
- package/src/models/AuthConfigs.ts +398 -0
- package/src/models/AuthScheme.ts +206 -0
- package/src/models/ConnectedAccounts.ts +735 -0
- package/src/models/ConnectionRequest.ts +150 -0
- package/src/models/CustomTool.ts +676 -0
- package/src/models/Experimental.ts +202 -0
- package/src/models/Files.node.ts +93 -0
- package/src/models/Files.workerd.ts +49 -0
- package/src/models/MCP.ts +478 -0
- package/src/models/RemoteFile.ts +172 -0
- package/src/models/SessionContext.ts +147 -0
- package/src/models/Sessions.ts +21 -0
- package/src/models/ToolRouter.ts +391 -0
- package/src/models/ToolRouterSession.ts +827 -0
- package/src/models/ToolRouterSessionFileMount.ts +389 -0
- package/src/models/Toolkits.ts +412 -0
- package/src/models/Tools.ts +1260 -0
- package/src/models/Triggers.ts +1381 -0
- package/src/models/customToolExecution.ts +118 -0
- package/src/models/inlineCustomToolsPayload.ts +17 -0
- package/src/models/proxyParamsTransform.ts +26 -0
- package/src/provider/BaseProvider.ts +138 -0
- package/src/provider/ComposioProvider.ts +29 -0
- package/src/provider/OpenAIProvider.ts +547 -0
- package/src/services/internal/InternalService.ts +50 -0
- package/src/services/internal/InternalService.types.ts +14 -0
- package/src/services/pusher/Pusher.ts +230 -0
- package/src/services/telemetry/TelemetryService.ts +48 -0
- package/src/services/telemetry/TelemetryService.types.ts +67 -0
- package/src/telemetry/BatchProcessor.ts +77 -0
- package/src/telemetry/README.md +123 -0
- package/src/telemetry/Telemetry.ts +356 -0
- package/src/types/ToolRouterSessionFilesMount.types.ts +96 -0
- package/src/types/authConfigs.types.ts +174 -0
- package/src/types/composio.types.ts +1 -0
- package/src/types/connectedAccountAuthStates.types.ts +852 -0
- package/src/types/connectedAccounts.types.ts +395 -0
- package/src/types/connectionRequest.types.ts +16 -0
- package/src/types/customTool.types.ts +261 -0
- package/{dist/files.types-lo4zZd87.d.cts → src/types/files.types.ts} +3 -5
- package/src/types/mcp.experimental.types.ts +163 -0
- package/src/types/mcp.types.ts +362 -0
- package/src/types/modifiers.types.ts +663 -0
- package/src/types/org.types.ts +0 -0
- package/src/types/provider.types.ts +41 -0
- package/src/types/pusher.types.ts +18 -0
- package/src/types/requestOptions.types.ts +62 -0
- package/src/types/telemetry.types.ts +89 -0
- package/src/types/tool.types.ts +408 -0
- package/src/types/toolRouter.types.ts +761 -0
- package/src/types/toolkit.types.ts +130 -0
- package/src/types/triggers.types.ts +401 -0
- package/src/types/webhookEvents.types.ts +219 -0
- package/src/utils/buffer.ts +30 -0
- package/src/utils/cancellation.ts +22 -0
- package/src/utils/config-defaults/ConfigDefaults.node.ts +7 -0
- package/src/utils/config-defaults/ConfigDefaults.workerd.ts +10 -0
- package/src/utils/config-defaults/index.ts +1 -0
- package/src/utils/config-defaults/types.ts +14 -0
- package/src/utils/constants.ts +22 -0
- package/src/utils/crypto.ts +34 -0
- package/src/utils/env.ts +34 -0
- package/src/utils/fileDirs.ts +81 -0
- package/src/utils/fileUtils.node.ts +458 -0
- package/src/utils/json-schema.ts +1 -0
- package/src/utils/jsonSchema.ts +355 -0
- package/src/utils/logger.ts +99 -0
- package/src/utils/mime.ts +75 -0
- package/src/utils/modifiers/FileToolModifier.node.ts +477 -0
- package/src/utils/modifiers/FileToolModifier.utils.neutral.ts +132 -0
- package/src/utils/modifiers/FileToolModifier.workerd.ts +51 -0
- package/src/utils/pagination.ts +73 -0
- package/src/utils/pusher.ts +286 -0
- package/src/utils/schemaPropertyKeys.ts +433 -0
- package/src/utils/sdk.ts +110 -0
- package/src/utils/sensitiveFileUploadPaths.node.ts +105 -0
- package/src/utils/session.ts +114 -0
- package/src/utils/toolArguments.ts +73 -0
- package/src/utils/toolkitVersion.ts +26 -0
- package/src/utils/transform.ts +42 -0
- package/src/utils/transformers/authConfigs.ts +107 -0
- package/src/utils/transformers/connectedAccounts.ts +119 -0
- package/src/utils/transformers/mcp.ts +164 -0
- package/src/utils/transformers/toolRouterResponseTransform.ts +160 -0
- package/src/utils/transformers/toolkits.ts +100 -0
- package/src/utils/transformers/triggers.ts +118 -0
- package/src/utils/uploadDirAllowlist.node.ts +178 -0
- package/src/utils/uuid.ts +7 -0
- package/src/utils/version.ts +58 -0
- package/src/utils/zodSchema.ts +90 -0
- package/dist/BaseProvider-BvHvJLXc.d.mts +0 -29378
- package/dist/CustomTool-D3-NreIm.cjs +0 -1341
- package/dist/FileModifierErrors-BYJBHiay.cjs +0 -554
- package/dist/FileToolModifier.utils.neutral-DSBQs9-i.cjs +0 -96
- package/dist/Telemetry-BQ_pl5AK.cjs +0 -360
- package/dist/buffer-BjWptbNH.cjs +0 -63
- package/dist/chunk-CQwRTUmo.cjs +0 -53
- package/dist/experimental/index.cjs +0 -5
- package/dist/experimental/index.d.cts +0 -3
- package/dist/fileUtils.node-DtnSRMWa.cjs +0 -462
- package/dist/index.cjs +0 -8523
- package/dist/index.d.cts +0 -6065
- package/dist/models/Files.node.cjs +0 -55
- package/dist/models/Files.node.d.cts +0 -56
- package/dist/models/Files.workerd.cjs +0 -29
- package/dist/models/Files.workerd.d.cts +0 -13
- package/dist/platform/node.cjs +0 -55
- package/dist/platform/node.d.cts +0 -11
- package/dist/platform/workerd.cjs +0 -42
- package/dist/platform/workerd.d.cts +0 -12
- package/dist/types-pDNm1lYs.d.cts +0 -69
- package/dist/utils/config-defaults/ConfigDefaults.node.cjs +0 -10
- package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +0 -7
- package/dist/utils/config-defaults/ConfigDefaults.workerd.cjs +0 -10
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +0 -7
- package/dist/utils/modifiers/FileToolModifier.node.cjs +0 -224
- package/dist/utils/modifiers/FileToolModifier.node.d.cts +0 -22
- package/dist/utils/modifiers/FileToolModifier.workerd.cjs +0 -27
- package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +0 -20
- /package/dist/{FileToolModifier.utils.neutral-BpSceNK8.mjs → FileToolModifier.utils.neutral-B5rT711M.mjs} +0 -0
- /package/dist/{buffer-yOtEsT4J.mjs → buffer-PcbMMsgm.mjs} +0 -0
- /package/dist/{files.types-BXDWA_zS.d.mts → files.types-DeMC_mAW.d.mts} +0 -0
- /package/dist/{types-HpJQ8K9l.d.mts → types-DdoCRzLj.d.mts} +0 -0
|
@@ -1,554 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CQwRTUmo.cjs');
|
|
2
|
-
let _composio_client = require("@composio/client");
|
|
3
|
-
let zod_v3 = require("zod/v3");
|
|
4
|
-
let chalk = require("chalk");
|
|
5
|
-
chalk = require_chunk.__toESM(chalk);
|
|
6
|
-
|
|
7
|
-
//#region src/utils/env.ts
|
|
8
|
-
const getEnvVariable = (name, defaultValue = void 0) => {
|
|
9
|
-
try {
|
|
10
|
-
return process.env[name] || defaultValue;
|
|
11
|
-
} catch (_e) {
|
|
12
|
-
return defaultValue;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Method to return all the envs based on a specific prefix
|
|
17
|
-
* @param prefix
|
|
18
|
-
* @example
|
|
19
|
-
* COMPOSIO_TOOLKIT_VERSION_GITHUB=20250902_00
|
|
20
|
-
* COMPOSIO_TOOLKIT_VERSION_SLACK=20250902_00
|
|
21
|
-
* COMPOSIO_TOOLKIT_VERSION_GMAIL=latest
|
|
22
|
-
* @returns {Record<string, unknown>}
|
|
23
|
-
* @returns
|
|
24
|
-
*/
|
|
25
|
-
const getEnvsWithPrefix = (prefix) => {
|
|
26
|
-
try {
|
|
27
|
-
if (process && process.env) return Object.fromEntries(Object.entries(process.env).filter(([key]) => key.startsWith(prefix)));
|
|
28
|
-
else return {};
|
|
29
|
-
} catch (error) {
|
|
30
|
-
return {};
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/utils/constants.ts
|
|
36
|
-
var constants_exports = /* @__PURE__ */ require_chunk.__exportAll({
|
|
37
|
-
CLIENT_PUSHER_KEY: () => CLIENT_PUSHER_KEY,
|
|
38
|
-
COMPOSIO_DIR: () => COMPOSIO_DIR,
|
|
39
|
-
COMPOSIO_LOG_LEVEL: () => COMPOSIO_LOG_LEVEL,
|
|
40
|
-
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
41
|
-
DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID: () => DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID,
|
|
42
|
-
DEFAULT_WEB_URL: () => DEFAULT_WEB_URL,
|
|
43
|
-
IS_DEVELOPMENT_OR_CI: () => IS_DEVELOPMENT_OR_CI,
|
|
44
|
-
TELEMETRY_URL: () => TELEMETRY_URL,
|
|
45
|
-
TEMP_FILES_DIRECTORY_NAME: () => TEMP_FILES_DIRECTORY_NAME,
|
|
46
|
-
USER_DATA_FILE_NAME: () => USER_DATA_FILE_NAME
|
|
47
|
-
});
|
|
48
|
-
const COMPOSIO_DIR = ".composio";
|
|
49
|
-
const USER_DATA_FILE_NAME = "user_data.json";
|
|
50
|
-
const TEMP_FILES_DIRECTORY_NAME = "files";
|
|
51
|
-
const DEFAULT_BASE_URL = "https://backend.composio.dev";
|
|
52
|
-
const DEFAULT_WEB_URL = "https://dashboard.composio.dev/";
|
|
53
|
-
const TELEMETRY_URL = "https://app.composio.dev";
|
|
54
|
-
const CLIENT_PUSHER_KEY = getEnvVariable("CLIENT_PUSHER_KEY") || "ff9f18c208855d77a152";
|
|
55
|
-
const COMPOSIO_LOG_LEVEL = getEnvVariable("COMPOSIO_LOG_LEVEL");
|
|
56
|
-
const IS_DEVELOPMENT_OR_CI = getEnvVariable("DEVELOPMENT") || getEnvVariable("CI") || false;
|
|
57
|
-
const DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID = "files";
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/utils/logger.ts
|
|
61
|
-
const LOG_LEVELS = {
|
|
62
|
-
silent: -1,
|
|
63
|
-
error: 0,
|
|
64
|
-
warn: 1,
|
|
65
|
-
info: 2,
|
|
66
|
-
debug: 3
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Get the current log level from environment variables.
|
|
70
|
-
* Defaults to 'info' if not set or invalid.
|
|
71
|
-
* @returns {LogLevel} The current log level
|
|
72
|
-
*/
|
|
73
|
-
const getLogLevel = () => {
|
|
74
|
-
const envLevel = (COMPOSIO_LOG_LEVEL ?? "info")?.toLowerCase();
|
|
75
|
-
return envLevel && envLevel in LOG_LEVELS ? envLevel : "info";
|
|
76
|
-
};
|
|
77
|
-
var Logger = class {
|
|
78
|
-
level;
|
|
79
|
-
includeTimestamp;
|
|
80
|
-
console;
|
|
81
|
-
constructor(options = {}) {
|
|
82
|
-
this.level = options.level ?? getLogLevel();
|
|
83
|
-
this.includeTimestamp = options.includeTimestamp ?? true;
|
|
84
|
-
this.console = console;
|
|
85
|
-
}
|
|
86
|
-
formatMessage(args) {
|
|
87
|
-
const formattedArgs = args.map((arg, index) => {
|
|
88
|
-
if (typeof arg === "object") return JSON.stringify(arg);
|
|
89
|
-
else {
|
|
90
|
-
if (index === 0) if (args.length > 1) return chalk.default.yellow(`${arg}`);
|
|
91
|
-
else return String(arg);
|
|
92
|
-
return String(arg);
|
|
93
|
-
}
|
|
94
|
-
}).join("\n");
|
|
95
|
-
if (!this.includeTimestamp) return formattedArgs;
|
|
96
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
97
|
-
return `${chalk.default.gray(timestamp)} - ${formattedArgs}`;
|
|
98
|
-
}
|
|
99
|
-
shouldLog(level) {
|
|
100
|
-
return LOG_LEVELS[level] <= LOG_LEVELS[this.level];
|
|
101
|
-
}
|
|
102
|
-
error(...args) {
|
|
103
|
-
if (this.shouldLog("error")) this.console.error(this.formatMessage(args));
|
|
104
|
-
}
|
|
105
|
-
warn(...args) {
|
|
106
|
-
if (this.shouldLog("warn")) this.console.warn(this.formatMessage(args));
|
|
107
|
-
}
|
|
108
|
-
info(...args) {
|
|
109
|
-
if (this.shouldLog("info")) this.console.info(this.formatMessage(args));
|
|
110
|
-
}
|
|
111
|
-
debug(...args) {
|
|
112
|
-
if (this.shouldLog("debug")) this.console.debug(this.formatMessage(args));
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
const logger = new Logger();
|
|
116
|
-
var logger_default = logger;
|
|
117
|
-
|
|
118
|
-
//#endregion
|
|
119
|
-
//#region src/errors/ComposioError.ts
|
|
120
|
-
/**
|
|
121
|
-
* @fileoverview Error class for Composio.
|
|
122
|
-
*
|
|
123
|
-
* This error class is used to create custom errors for Composio.
|
|
124
|
-
* It extends the built-in Error class and adds additional properties for code, status code, cause, meta, and possible fixes.
|
|
125
|
-
*
|
|
126
|
-
* @author Musthaq Ahamad <musthaq@composio.dev>
|
|
127
|
-
* @module errors/ComposioError
|
|
128
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error}
|
|
129
|
-
*/
|
|
130
|
-
/**
|
|
131
|
-
* Base error class for all Composio errors
|
|
132
|
-
*/
|
|
133
|
-
var ComposioError = class ComposioError extends Error {
|
|
134
|
-
/** @readonly Error name */
|
|
135
|
-
name = "ComposioError";
|
|
136
|
-
code;
|
|
137
|
-
possibleFixes;
|
|
138
|
-
errorId;
|
|
139
|
-
/**
|
|
140
|
-
* Creates a new ComposioError
|
|
141
|
-
* @param message Error message
|
|
142
|
-
* @param options Additional error options
|
|
143
|
-
*/
|
|
144
|
-
constructor(message, options = {}) {
|
|
145
|
-
super(message);
|
|
146
|
-
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
147
|
-
const statusCode = options.statusCode || (options.cause instanceof _composio_client.BadRequestError ? options.cause.status : void 0);
|
|
148
|
-
this.code = `TS-SDK::${options.code}`;
|
|
149
|
-
this.possibleFixes = options.possibleFixes;
|
|
150
|
-
this.definePropertyIfExists("statusCode", statusCode);
|
|
151
|
-
this.definePropertyIfExists("cause", options.cause);
|
|
152
|
-
const combinedStack = options.cause instanceof Error ? ComposioError.combineStackTraces(options.cause.stack, this.stack) : options.stack ?? this.stack;
|
|
153
|
-
this.definePropertyIfExists("stack", combinedStack);
|
|
154
|
-
if (options.meta && Object.keys(options.meta).length > 0) this.definePropertyIfExists("meta", options.meta);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Helper method to define a property only if it has a value
|
|
158
|
-
* @param propertyName Name of the property to define
|
|
159
|
-
* @param value Value to assign to the property
|
|
160
|
-
* @private
|
|
161
|
-
*/
|
|
162
|
-
definePropertyIfExists(propertyName, value) {
|
|
163
|
-
if (value !== void 0) Object.defineProperty(this, propertyName, {
|
|
164
|
-
value,
|
|
165
|
-
enumerable: true,
|
|
166
|
-
writable: false,
|
|
167
|
-
configurable: true
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Helper method to combine stack traces when wrapping errors
|
|
172
|
-
* This ensures the full call chain is preserved
|
|
173
|
-
* @param originalStack The stack of the error being wrapped
|
|
174
|
-
* @param currentStack The stack of the wrapper error
|
|
175
|
-
* @returns Combined stack trace
|
|
176
|
-
* @private
|
|
177
|
-
*/
|
|
178
|
-
static combineStackTraces(originalStack, currentStack) {
|
|
179
|
-
if (!originalStack) return currentStack;
|
|
180
|
-
if (!currentStack) return originalStack;
|
|
181
|
-
const currentHeader = currentStack.split("\n")[0];
|
|
182
|
-
const originalStackBody = originalStack.split("\n").slice(1).join("\n");
|
|
183
|
-
return `${currentHeader}\n${currentStack.split("\n").slice(1).join("\n")}\n\nCaused by:\n${originalStackBody}`;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Extract and normalize error data for formatting
|
|
187
|
-
* @param includeStack Whether to include stack trace information
|
|
188
|
-
* @returns Structured error data for formatting
|
|
189
|
-
* @private
|
|
190
|
-
*/
|
|
191
|
-
getErrorData(includeStack = false) {
|
|
192
|
-
const data = {
|
|
193
|
-
name: this.name,
|
|
194
|
-
message: this.message
|
|
195
|
-
};
|
|
196
|
-
const { cause, code, stack, statusCode, meta, possibleFixes } = this;
|
|
197
|
-
if (cause !== void 0) {
|
|
198
|
-
const rawCause = cause;
|
|
199
|
-
data.cause = rawCause instanceof Error ? rawCause.message : String(rawCause);
|
|
200
|
-
}
|
|
201
|
-
if (code) data.code = code;
|
|
202
|
-
if (statusCode !== void 0) data.statusCode = statusCode;
|
|
203
|
-
if (meta) data.meta = meta;
|
|
204
|
-
if (possibleFixes) data.possibleFixes = possibleFixes;
|
|
205
|
-
if (includeStack && stack) if (stack.includes("Caused by:")) {
|
|
206
|
-
const [currentStack, causeStack] = stack.split("Caused by:");
|
|
207
|
-
data.stack = [
|
|
208
|
-
...currentStack.split("\n").slice(1),
|
|
209
|
-
"Caused by:",
|
|
210
|
-
...causeStack.split("\n")
|
|
211
|
-
];
|
|
212
|
-
} else data.stack = stack.split("\n").slice(1);
|
|
213
|
-
return data;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Prints a user-friendly, colorful representation of the error to the logger
|
|
217
|
-
* @param includeStack Whether to include the stack trace in the output (default: false)
|
|
218
|
-
*/
|
|
219
|
-
prettyPrint(includeStack = false) {
|
|
220
|
-
const data = this.getErrorData(includeStack);
|
|
221
|
-
let output = "\n" + chalk.default.bgRed.white.bold(" ERROR ") + " " + chalk.default.white.bold(data.message) + "\n";
|
|
222
|
-
if (data.code) output += chalk.default.yellow(`Error Code: ${data.code}`) + "\n";
|
|
223
|
-
if (data.statusCode !== void 0) output += chalk.default.yellow(`Status: ${data.statusCode}`) + "\n";
|
|
224
|
-
if (data.cause) {
|
|
225
|
-
output += chalk.default.gray("Reason:") + "\n";
|
|
226
|
-
output += " " + chalk.default.white(data.cause) + "\n";
|
|
227
|
-
}
|
|
228
|
-
if (data.meta) {
|
|
229
|
-
output += chalk.default.gray("Additional Information:") + "\n";
|
|
230
|
-
output += " " + chalk.default.white(JSON.stringify(data.meta, null, 2).replace(/\n/g, "\n ")) + "\n";
|
|
231
|
-
}
|
|
232
|
-
if (data.possibleFixes?.length) {
|
|
233
|
-
output += "\n" + chalk.default.cyan.bold("Try the following:") + "\n";
|
|
234
|
-
const fixes = data.possibleFixes?.map((fix, index) => ` ${index + 1}. ` + chalk.default.white(fix));
|
|
235
|
-
output += fixes?.join("\n") + "\n";
|
|
236
|
-
}
|
|
237
|
-
if (data.stack?.length) {
|
|
238
|
-
output += "\n" + chalk.default.gray("Stack Trace:") + "\n";
|
|
239
|
-
output += chalk.default.gray(data.stack.join("\n")) + "\n";
|
|
240
|
-
}
|
|
241
|
-
output += "\n";
|
|
242
|
-
logger_default.error(output);
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Static factory method to create and pretty print an error in one step
|
|
246
|
-
* @param message Error message
|
|
247
|
-
* @param options Error options
|
|
248
|
-
* @param includeStack Whether to include the stack trace in the output
|
|
249
|
-
* @returns The created error instance
|
|
250
|
-
*/
|
|
251
|
-
static createAndPrint(message, options = {}, includeStack = false) {
|
|
252
|
-
const error = new ComposioError(message, options);
|
|
253
|
-
error.prettyPrint(includeStack);
|
|
254
|
-
return error;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Utility function to handle errors in a consistent way
|
|
258
|
-
* This properly displays the error without throwing
|
|
259
|
-
* @param error The error to handle
|
|
260
|
-
* @param options Options for error handling
|
|
261
|
-
*/
|
|
262
|
-
static handle(error, options = {}) {
|
|
263
|
-
const { includeStack = false, exitProcess = false } = options;
|
|
264
|
-
if (error instanceof ComposioError) error.prettyPrint(includeStack);
|
|
265
|
-
else if (error instanceof zod_v3.ZodError) this.handleZodError(error, includeStack);
|
|
266
|
-
else if (error instanceof Error) this.handleStandardError(error, includeStack);
|
|
267
|
-
else this.handleUnknownError(error);
|
|
268
|
-
if (exitProcess) this.throwError(error);
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Utility function to handle errors and then throw them
|
|
272
|
-
* This properly displays the error and then throws it, allowing callers to catch it.
|
|
273
|
-
* Use this for fatal errors that should stop execution.
|
|
274
|
-
* @param error The error to handle and throw
|
|
275
|
-
* @param includeStack Whether to include the stack trace in the output
|
|
276
|
-
* @throws ComposioError - Always throws after displaying the error
|
|
277
|
-
*/
|
|
278
|
-
static handleAndThrow(error, includeStack = false) {
|
|
279
|
-
this.handle(error, { includeStack });
|
|
280
|
-
this.throwError(error);
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Helper method to throw an error as a ComposioError
|
|
284
|
-
* @param error The error to throw
|
|
285
|
-
* @private
|
|
286
|
-
*/
|
|
287
|
-
static throwError(error) {
|
|
288
|
-
if (error instanceof ComposioError) throw error;
|
|
289
|
-
else if (error instanceof Error) throw new ComposioError(error.message, { cause: error });
|
|
290
|
-
else throw new ComposioError(String(error));
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Helper method to handle Zod validation errors
|
|
294
|
-
* @param error The Zod error to handle
|
|
295
|
-
* @param includeStack Whether to include the stack trace
|
|
296
|
-
* @private
|
|
297
|
-
*/
|
|
298
|
-
static handleZodError(error, includeStack) {
|
|
299
|
-
logger_default.error("\n" + chalk.default.bgRed.white.bold(" ERROR ") + " " + chalk.default.white.bold(error.message));
|
|
300
|
-
logger_default.error(chalk.default.gray("Invalid parameters:"));
|
|
301
|
-
error.errors.forEach((err) => {
|
|
302
|
-
logger_default.error(chalk.default.yellow(err.path.join(".")) + " " + chalk.default.white(err.message));
|
|
303
|
-
});
|
|
304
|
-
logger_default.error(chalk.default.gray("Expected parameters:"));
|
|
305
|
-
error.errors.forEach((err) => {
|
|
306
|
-
logger_default.error(chalk.default.yellow(err.path.join(".")) + " " + chalk.default.white(err.message));
|
|
307
|
-
});
|
|
308
|
-
if (includeStack) {
|
|
309
|
-
logger_default.error("\n" + chalk.default.gray("Validation Errors:"));
|
|
310
|
-
error.errors.forEach((err) => {
|
|
311
|
-
const path = err.path.join(".");
|
|
312
|
-
logger_default.error(chalk.default.gray(" • ") + chalk.default.yellow(path ? `${path}: ` : "") + chalk.default.white(err.message));
|
|
313
|
-
});
|
|
314
|
-
if (error.stack) {
|
|
315
|
-
logger_default.error("\n" + chalk.default.gray("Stack Trace:"));
|
|
316
|
-
const stackLines = error.stack.split("\n").slice(1);
|
|
317
|
-
logger_default.error(chalk.default.gray(stackLines.join("\n")));
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
logger_default.error("");
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Helper method to handle standard Error objects
|
|
324
|
-
* @param error The standard error to handle
|
|
325
|
-
* @param includeStack Whether to include the stack trace
|
|
326
|
-
* @private
|
|
327
|
-
*/
|
|
328
|
-
static handleStandardError(error, includeStack) {
|
|
329
|
-
logger_default.error("\n" + chalk.default.bgRed.white.bold(" ERROR ") + " " + chalk.default.white.bold(error.message));
|
|
330
|
-
if (includeStack && error.stack) {
|
|
331
|
-
logger_default.error("\n" + chalk.default.gray("Stack Trace:"));
|
|
332
|
-
const stackLines = error.stack.split("\n").slice(1);
|
|
333
|
-
logger_default.error(chalk.default.gray(stackLines.join("\n")));
|
|
334
|
-
}
|
|
335
|
-
logger_default.error("");
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Helper method to handle unknown error types
|
|
339
|
-
* @param error The unknown error value
|
|
340
|
-
* @private
|
|
341
|
-
*/
|
|
342
|
-
static handleUnknownError(error) {
|
|
343
|
-
logger_default.error("\n" + chalk.default.bgRed.white.bold(" ERROR ") + " " + chalk.default.white.bold("Unknown error occurred"));
|
|
344
|
-
if (error !== null && error !== void 0) {
|
|
345
|
-
logger_default.error(chalk.default.gray("Error details:"));
|
|
346
|
-
logger_default.error(" " + chalk.default.white(String(error)));
|
|
347
|
-
}
|
|
348
|
-
logger_default.error("");
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
//#endregion
|
|
353
|
-
//#region src/errors/FileModifierErrors.ts
|
|
354
|
-
const FileModifierErrorCodes = {
|
|
355
|
-
FILE_UPLOAD_FAILED: "FILE_UPLOAD_FAILED",
|
|
356
|
-
SENSITIVE_FILE_PATH_BLOCKED: "SENSITIVE_FILE_PATH_BLOCKED",
|
|
357
|
-
FILE_UPLOAD_ABORTED: "FILE_UPLOAD_ABORTED",
|
|
358
|
-
FILE_UPLOAD_PATH_NOT_ALLOWED: "FILE_UPLOAD_PATH_NOT_ALLOWED",
|
|
359
|
-
FILE_NOT_FOUND: "FILE_NOT_FOUND"
|
|
360
|
-
};
|
|
361
|
-
var ComposioFileUploadError = class extends ComposioError {
|
|
362
|
-
constructor(message = "Failed to upload file", options = {}) {
|
|
363
|
-
super(message, {
|
|
364
|
-
...options,
|
|
365
|
-
code: options.code ?? FileModifierErrorCodes.FILE_UPLOAD_FAILED,
|
|
366
|
-
possibleFixes: options.possibleFixes || ["Check if the file exists in the location provided"]
|
|
367
|
-
});
|
|
368
|
-
this.name = "ComposioFileUploadError";
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
/**
|
|
372
|
-
* Thrown when a local file path is refused before upload (sensitive directory or
|
|
373
|
-
* credential-like file name). Subclass of {@link ComposioFileUploadError} so existing
|
|
374
|
-
* `instanceof ComposioFileUploadError` handlers still apply.
|
|
375
|
-
*/
|
|
376
|
-
var ComposioSensitiveFilePathBlockedError = class extends ComposioFileUploadError {
|
|
377
|
-
constructor(message, options = {}) {
|
|
378
|
-
super(message, {
|
|
379
|
-
...options,
|
|
380
|
-
code: FileModifierErrorCodes.SENSITIVE_FILE_PATH_BLOCKED,
|
|
381
|
-
possibleFixes: options.possibleFixes ?? [
|
|
382
|
-
"Use a file outside ~/.ssh, ~/.aws, and other credential locations",
|
|
383
|
-
"Set sensitiveFileUploadProtection: false only if you understand the risk",
|
|
384
|
-
"Add path segments to block with fileUploadPathDenySegments"
|
|
385
|
-
]
|
|
386
|
-
});
|
|
387
|
-
this.name = "ComposioSensitiveFilePathBlockedError";
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
/**
|
|
391
|
-
* Thrown when a `beforeFileUpload` hook returns `false`.
|
|
392
|
-
*/
|
|
393
|
-
var ComposioFileUploadAbortedError = class extends ComposioFileUploadError {
|
|
394
|
-
constructor(message, options = {}) {
|
|
395
|
-
super(message, {
|
|
396
|
-
...options,
|
|
397
|
-
code: FileModifierErrorCodes.FILE_UPLOAD_ABORTED,
|
|
398
|
-
possibleFixes: options.possibleFixes ?? ["Change beforeFileUpload to return a file path to upload, or allow the upload to proceed"]
|
|
399
|
-
});
|
|
400
|
-
this.name = "ComposioFileUploadAbortedError";
|
|
401
|
-
}
|
|
402
|
-
};
|
|
403
|
-
/**
|
|
404
|
-
* Thrown when automatic file upload during tool execution is attempted from a path
|
|
405
|
-
* that is outside the configured {@link ComposioConfig.fileUploadDirs} allowlist.
|
|
406
|
-
*
|
|
407
|
-
* This only fires for auto-upload (enabled via
|
|
408
|
-
* `dangerouslyAllowAutoUploadDownloadFiles: true`). Manual `composio.files.upload()`
|
|
409
|
-
* calls are never subject to this check.
|
|
410
|
-
*/
|
|
411
|
-
var ComposioFileUploadPathNotAllowedError = class extends ComposioFileUploadError {
|
|
412
|
-
constructor(message, options = {}) {
|
|
413
|
-
super(message, {
|
|
414
|
-
...options,
|
|
415
|
-
code: FileModifierErrorCodes.FILE_UPLOAD_PATH_NOT_ALLOWED,
|
|
416
|
-
possibleFixes: options.possibleFixes ?? [
|
|
417
|
-
"Move the file under one of the directories in `fileUploadDirs`",
|
|
418
|
-
"Stage the file under the default upload dir (`~/.composio/temp`)",
|
|
419
|
-
"Add the containing directory to `fileUploadDirs` when constructing Composio",
|
|
420
|
-
"Pass the file by URL or as a File/Blob object instead of a filesystem path"
|
|
421
|
-
]
|
|
422
|
-
});
|
|
423
|
-
this.name = "ComposioFileUploadPathNotAllowedError";
|
|
424
|
-
}
|
|
425
|
-
};
|
|
426
|
-
/**
|
|
427
|
-
* Thrown when a local file path passed for upload does not exist on disk.
|
|
428
|
-
* Provides extra debugging context (resolved absolute path, cwd, allowlist state)
|
|
429
|
-
* to help the caller distinguish between "typo" and "not-allowlisted" failures.
|
|
430
|
-
*/
|
|
431
|
-
var ComposioFileNotFoundError = class extends ComposioFileUploadError {
|
|
432
|
-
constructor(message, options = {}) {
|
|
433
|
-
super(message, {
|
|
434
|
-
...options,
|
|
435
|
-
code: FileModifierErrorCodes.FILE_NOT_FOUND,
|
|
436
|
-
possibleFixes: options.possibleFixes ?? [
|
|
437
|
-
"Double-check the path for typos",
|
|
438
|
-
"Remember relative paths are resolved against process.cwd() at upload time",
|
|
439
|
-
"Verify the file exists and the process has read permission"
|
|
440
|
-
]
|
|
441
|
-
});
|
|
442
|
-
this.name = "ComposioFileNotFoundError";
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
//#endregion
|
|
447
|
-
Object.defineProperty(exports, 'COMPOSIO_DIR', {
|
|
448
|
-
enumerable: true,
|
|
449
|
-
get: function () {
|
|
450
|
-
return COMPOSIO_DIR;
|
|
451
|
-
}
|
|
452
|
-
});
|
|
453
|
-
Object.defineProperty(exports, 'COMPOSIO_LOG_LEVEL', {
|
|
454
|
-
enumerable: true,
|
|
455
|
-
get: function () {
|
|
456
|
-
return COMPOSIO_LOG_LEVEL;
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
|
-
Object.defineProperty(exports, 'ComposioError', {
|
|
460
|
-
enumerable: true,
|
|
461
|
-
get: function () {
|
|
462
|
-
return ComposioError;
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
Object.defineProperty(exports, 'ComposioFileNotFoundError', {
|
|
466
|
-
enumerable: true,
|
|
467
|
-
get: function () {
|
|
468
|
-
return ComposioFileNotFoundError;
|
|
469
|
-
}
|
|
470
|
-
});
|
|
471
|
-
Object.defineProperty(exports, 'ComposioFileUploadAbortedError', {
|
|
472
|
-
enumerable: true,
|
|
473
|
-
get: function () {
|
|
474
|
-
return ComposioFileUploadAbortedError;
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
Object.defineProperty(exports, 'ComposioFileUploadError', {
|
|
478
|
-
enumerable: true,
|
|
479
|
-
get: function () {
|
|
480
|
-
return ComposioFileUploadError;
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
Object.defineProperty(exports, 'ComposioFileUploadPathNotAllowedError', {
|
|
484
|
-
enumerable: true,
|
|
485
|
-
get: function () {
|
|
486
|
-
return ComposioFileUploadPathNotAllowedError;
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
Object.defineProperty(exports, 'ComposioSensitiveFilePathBlockedError', {
|
|
490
|
-
enumerable: true,
|
|
491
|
-
get: function () {
|
|
492
|
-
return ComposioSensitiveFilePathBlockedError;
|
|
493
|
-
}
|
|
494
|
-
});
|
|
495
|
-
Object.defineProperty(exports, 'DEFAULT_BASE_URL', {
|
|
496
|
-
enumerable: true,
|
|
497
|
-
get: function () {
|
|
498
|
-
return DEFAULT_BASE_URL;
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
Object.defineProperty(exports, 'DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID', {
|
|
502
|
-
enumerable: true,
|
|
503
|
-
get: function () {
|
|
504
|
-
return DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID;
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
Object.defineProperty(exports, 'FileModifierErrorCodes', {
|
|
508
|
-
enumerable: true,
|
|
509
|
-
get: function () {
|
|
510
|
-
return FileModifierErrorCodes;
|
|
511
|
-
}
|
|
512
|
-
});
|
|
513
|
-
Object.defineProperty(exports, 'IS_DEVELOPMENT_OR_CI', {
|
|
514
|
-
enumerable: true,
|
|
515
|
-
get: function () {
|
|
516
|
-
return IS_DEVELOPMENT_OR_CI;
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
Object.defineProperty(exports, 'TEMP_FILES_DIRECTORY_NAME', {
|
|
520
|
-
enumerable: true,
|
|
521
|
-
get: function () {
|
|
522
|
-
return TEMP_FILES_DIRECTORY_NAME;
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
Object.defineProperty(exports, 'USER_DATA_FILE_NAME', {
|
|
526
|
-
enumerable: true,
|
|
527
|
-
get: function () {
|
|
528
|
-
return USER_DATA_FILE_NAME;
|
|
529
|
-
}
|
|
530
|
-
});
|
|
531
|
-
Object.defineProperty(exports, 'constants_exports', {
|
|
532
|
-
enumerable: true,
|
|
533
|
-
get: function () {
|
|
534
|
-
return constants_exports;
|
|
535
|
-
}
|
|
536
|
-
});
|
|
537
|
-
Object.defineProperty(exports, 'getEnvVariable', {
|
|
538
|
-
enumerable: true,
|
|
539
|
-
get: function () {
|
|
540
|
-
return getEnvVariable;
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
Object.defineProperty(exports, 'getEnvsWithPrefix', {
|
|
544
|
-
enumerable: true,
|
|
545
|
-
get: function () {
|
|
546
|
-
return getEnvsWithPrefix;
|
|
547
|
-
}
|
|
548
|
-
});
|
|
549
|
-
Object.defineProperty(exports, 'logger_default', {
|
|
550
|
-
enumerable: true,
|
|
551
|
-
get: function () {
|
|
552
|
-
return logger_default;
|
|
553
|
-
}
|
|
554
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/utils/modifiers/FileToolModifier.utils.neutral.ts
|
|
3
|
-
function isPlainObject(val) {
|
|
4
|
-
return typeof val === "object" && val !== null && !Array.isArray(val);
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Transforms a single JSON schema property, recursively handling nested properties,
|
|
8
|
-
* anyOf, oneOf, and allOf.
|
|
9
|
-
*/
|
|
10
|
-
const transformSchema = (property) => {
|
|
11
|
-
if (property.file_uploadable) return {
|
|
12
|
-
title: property.title,
|
|
13
|
-
description: property.description,
|
|
14
|
-
format: "path",
|
|
15
|
-
type: "string",
|
|
16
|
-
file_uploadable: true
|
|
17
|
-
};
|
|
18
|
-
const newProperty = { ...property };
|
|
19
|
-
if (property.type === "object" && property.properties) newProperty.properties = transformProperties(property.properties);
|
|
20
|
-
if (property.anyOf) newProperty.anyOf = property.anyOf.map(transformSchema);
|
|
21
|
-
if (property.oneOf) newProperty.oneOf = property.oneOf.map(transformSchema);
|
|
22
|
-
if (property.allOf) newProperty.allOf = property.allOf.map(transformSchema);
|
|
23
|
-
if (property.items) if (Array.isArray(property.items)) newProperty.items = property.items.map(transformSchema);
|
|
24
|
-
else newProperty.items = transformSchema(property.items);
|
|
25
|
-
return newProperty;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Transforms the properties of the tool schema to include the file upload URL.
|
|
29
|
-
*
|
|
30
|
-
* Attaches the format: 'path' to the properties that are file uploadable for agents.
|
|
31
|
-
*
|
|
32
|
-
* @param properties - The properties of the tool schema.
|
|
33
|
-
* @returns The transformed properties.
|
|
34
|
-
*/
|
|
35
|
-
const transformProperties = (properties) => {
|
|
36
|
-
const newProperties = {};
|
|
37
|
-
for (const [key, property] of Object.entries(properties)) newProperties[key] = transformSchema(property);
|
|
38
|
-
return newProperties;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Recursively checks if a schema (or any of its variants) contains a specific file property.
|
|
42
|
-
*/
|
|
43
|
-
const schemaHasFileProperty = (schema, property) => {
|
|
44
|
-
if (!schema) return false;
|
|
45
|
-
if (schema[property]) return true;
|
|
46
|
-
if (schema.properties) {
|
|
47
|
-
for (const prop of Object.values(schema.properties)) if (schemaHasFileProperty(prop, property)) return true;
|
|
48
|
-
}
|
|
49
|
-
if (schema.anyOf) {
|
|
50
|
-
for (const variant of schema.anyOf) if (schemaHasFileProperty(variant, property)) return true;
|
|
51
|
-
}
|
|
52
|
-
if (schema.oneOf) {
|
|
53
|
-
for (const variant of schema.oneOf) if (schemaHasFileProperty(variant, property)) return true;
|
|
54
|
-
}
|
|
55
|
-
if (schema.allOf) {
|
|
56
|
-
for (const variant of schema.allOf) if (schemaHasFileProperty(variant, property)) return true;
|
|
57
|
-
}
|
|
58
|
-
if (schema.items) {
|
|
59
|
-
if (Array.isArray(schema.items)) {
|
|
60
|
-
for (const item of schema.items) if (schemaHasFileProperty(item, property)) return true;
|
|
61
|
-
} else if (schemaHasFileProperty(schema.items, property)) return true;
|
|
62
|
-
}
|
|
63
|
-
return false;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Recursively checks if a schema (or any of its variants) contains file_uploadable properties.
|
|
67
|
-
*/
|
|
68
|
-
const schemaHasFileUploadable = (schema) => {
|
|
69
|
-
return schemaHasFileProperty(schema, "file_uploadable");
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
//#endregion
|
|
73
|
-
Object.defineProperty(exports, 'isPlainObject', {
|
|
74
|
-
enumerable: true,
|
|
75
|
-
get: function () {
|
|
76
|
-
return isPlainObject;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
Object.defineProperty(exports, 'schemaHasFileProperty', {
|
|
80
|
-
enumerable: true,
|
|
81
|
-
get: function () {
|
|
82
|
-
return schemaHasFileProperty;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
Object.defineProperty(exports, 'schemaHasFileUploadable', {
|
|
86
|
-
enumerable: true,
|
|
87
|
-
get: function () {
|
|
88
|
-
return schemaHasFileUploadable;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
Object.defineProperty(exports, 'transformProperties', {
|
|
92
|
-
enumerable: true,
|
|
93
|
-
get: function () {
|
|
94
|
-
return transformProperties;
|
|
95
|
-
}
|
|
96
|
-
});
|