@composio/core 0.4.0 → 0.5.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/{chunk-SfbczIpV.mjs → chunk-0j-ceAHr.mjs} +3 -4
- package/dist/chunk-CQwRTUmo.cjs +53 -0
- package/dist/fileUtils-CJjp8sBn.cjs +931 -0
- package/dist/fileUtils-XEoNI39Q.mjs +852 -0
- package/dist/files.types-B7P5A1Z5.d.mts +17 -0
- package/dist/files.types-D-RzIOHq.d.cts +17 -0
- package/dist/index.cjs +363 -1069
- package/dist/index.d.cts +656 -384
- package/dist/index.d.mts +655 -384
- package/dist/index.mjs +251 -920
- package/dist/models/Files.node.cjs +38 -0
- package/dist/models/Files.node.d.cts +41 -0
- package/dist/models/Files.node.d.mts +41 -0
- package/dist/models/Files.node.mjs +39 -0
- package/dist/models/Files.workerd.cjs +29 -0
- package/dist/models/Files.workerd.d.cts +13 -0
- package/dist/models/Files.workerd.d.mts +13 -0
- package/dist/models/Files.workerd.mjs +28 -0
- package/dist/platform/node.cjs +46 -0
- package/dist/platform/node.d.cts +11 -0
- package/dist/platform/node.d.mts +11 -0
- package/dist/platform/node.mjs +42 -0
- package/dist/platform/workerd.cjs +36 -0
- package/dist/platform/workerd.d.cts +12 -0
- package/dist/platform/workerd.d.mts +12 -0
- package/dist/platform/workerd.mjs +35 -0
- package/dist/types-BaUqjuX3.d.mts +56 -0
- package/dist/types-BrsW5suw.d.cts +56 -0
- package/generated/index.d.ts +6 -0
- package/generated/index.js +18 -0
- package/package.json +74 -14
- package/src/platform/index.ts +2 -0
- package/src/platform/node.ts +51 -0
- package/src/platform/types.ts +60 -0
- package/src/platform/workerd.ts +57 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const require_fileUtils = require('../fileUtils-CJjp8sBn.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/models/Files.node.ts
|
|
4
|
+
var Files = class {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
require_fileUtils.telemetry.instrument(this, "Files");
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Upload a file to S3 and return the file data.
|
|
11
|
+
* @param filePath - The path to the file to upload or a URL of the file to upload.
|
|
12
|
+
* @param toolSlug - The slug of the tool that is uploading the file.
|
|
13
|
+
* @param toolkitSlug - The slug of the toolkit that is uploading the file.
|
|
14
|
+
* @returns The file data.
|
|
15
|
+
*/
|
|
16
|
+
async upload({ file, toolSlug, toolkitSlug }) {
|
|
17
|
+
return await require_fileUtils.getFileDataAfterUploadingToS3(file, {
|
|
18
|
+
toolSlug,
|
|
19
|
+
toolkitSlug,
|
|
20
|
+
client: this.client
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Download a file from S3 and return the file data.
|
|
25
|
+
* @param s3key - The S3 key of the file to download.
|
|
26
|
+
* @returns The file data.
|
|
27
|
+
*/
|
|
28
|
+
async download({ toolSlug, s3Url, mimeType }) {
|
|
29
|
+
return await require_fileUtils.downloadFileFromS3({
|
|
30
|
+
toolSlug,
|
|
31
|
+
s3Url,
|
|
32
|
+
mimeType
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.Files = Files;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { n as FileUploadData, t as FileDownloadData } from "../files.types-D-RzIOHq.cjs";
|
|
2
|
+
import ComposioClient from "@composio/client";
|
|
3
|
+
|
|
4
|
+
//#region src/models/Files.node.d.ts
|
|
5
|
+
|
|
6
|
+
declare class Files {
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor(client: ComposioClient);
|
|
9
|
+
/**
|
|
10
|
+
* Upload a file to S3 and return the file data.
|
|
11
|
+
* @param filePath - The path to the file to upload or a URL of the file to upload.
|
|
12
|
+
* @param toolSlug - The slug of the tool that is uploading the file.
|
|
13
|
+
* @param toolkitSlug - The slug of the toolkit that is uploading the file.
|
|
14
|
+
* @returns The file data.
|
|
15
|
+
*/
|
|
16
|
+
upload({
|
|
17
|
+
file,
|
|
18
|
+
toolSlug,
|
|
19
|
+
toolkitSlug
|
|
20
|
+
}: {
|
|
21
|
+
file: File | string;
|
|
22
|
+
toolSlug: string;
|
|
23
|
+
toolkitSlug: string;
|
|
24
|
+
}): Promise<FileUploadData>;
|
|
25
|
+
/**
|
|
26
|
+
* Download a file from S3 and return the file data.
|
|
27
|
+
* @param s3key - The S3 key of the file to download.
|
|
28
|
+
* @returns The file data.
|
|
29
|
+
*/
|
|
30
|
+
download({
|
|
31
|
+
toolSlug,
|
|
32
|
+
s3Url,
|
|
33
|
+
mimeType
|
|
34
|
+
}: {
|
|
35
|
+
s3Url: string;
|
|
36
|
+
toolSlug: string;
|
|
37
|
+
mimeType: string;
|
|
38
|
+
}): Promise<FileDownloadData>;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { Files };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { n as FileUploadData, t as FileDownloadData } from "../files.types-B7P5A1Z5.mjs";
|
|
2
|
+
import ComposioClient from "@composio/client";
|
|
3
|
+
|
|
4
|
+
//#region src/models/Files.node.d.ts
|
|
5
|
+
|
|
6
|
+
declare class Files {
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor(client: ComposioClient);
|
|
9
|
+
/**
|
|
10
|
+
* Upload a file to S3 and return the file data.
|
|
11
|
+
* @param filePath - The path to the file to upload or a URL of the file to upload.
|
|
12
|
+
* @param toolSlug - The slug of the tool that is uploading the file.
|
|
13
|
+
* @param toolkitSlug - The slug of the toolkit that is uploading the file.
|
|
14
|
+
* @returns The file data.
|
|
15
|
+
*/
|
|
16
|
+
upload({
|
|
17
|
+
file,
|
|
18
|
+
toolSlug,
|
|
19
|
+
toolkitSlug
|
|
20
|
+
}: {
|
|
21
|
+
file: File | string;
|
|
22
|
+
toolSlug: string;
|
|
23
|
+
toolkitSlug: string;
|
|
24
|
+
}): Promise<FileUploadData>;
|
|
25
|
+
/**
|
|
26
|
+
* Download a file from S3 and return the file data.
|
|
27
|
+
* @param s3key - The S3 key of the file to download.
|
|
28
|
+
* @returns The file data.
|
|
29
|
+
*/
|
|
30
|
+
download({
|
|
31
|
+
toolSlug,
|
|
32
|
+
s3Url,
|
|
33
|
+
mimeType
|
|
34
|
+
}: {
|
|
35
|
+
s3Url: string;
|
|
36
|
+
toolSlug: string;
|
|
37
|
+
mimeType: string;
|
|
38
|
+
}): Promise<FileDownloadData>;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { Files };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import "../chunk-0j-ceAHr.mjs";
|
|
2
|
+
import { n as getFileDataAfterUploadingToS3, r as telemetry, t as downloadFileFromS3 } from "../fileUtils-XEoNI39Q.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/models/Files.node.ts
|
|
5
|
+
var Files = class {
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
telemetry.instrument(this, "Files");
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Upload a file to S3 and return the file data.
|
|
12
|
+
* @param filePath - The path to the file to upload or a URL of the file to upload.
|
|
13
|
+
* @param toolSlug - The slug of the tool that is uploading the file.
|
|
14
|
+
* @param toolkitSlug - The slug of the toolkit that is uploading the file.
|
|
15
|
+
* @returns The file data.
|
|
16
|
+
*/
|
|
17
|
+
async upload({ file, toolSlug, toolkitSlug }) {
|
|
18
|
+
return await getFileDataAfterUploadingToS3(file, {
|
|
19
|
+
toolSlug,
|
|
20
|
+
toolkitSlug,
|
|
21
|
+
client: this.client
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Download a file from S3 and return the file data.
|
|
26
|
+
* @param s3key - The S3 key of the file to download.
|
|
27
|
+
* @returns The file data.
|
|
28
|
+
*/
|
|
29
|
+
async download({ toolSlug, s3Url, mimeType }) {
|
|
30
|
+
return await downloadFileFromS3({
|
|
31
|
+
toolSlug,
|
|
32
|
+
s3Url,
|
|
33
|
+
mimeType
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { Files };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/models/Files.workerd.ts
|
|
3
|
+
const UNSUPPORTED_MESSAGE = "File operations (upload/download) are not supported in Cloudflare Workers or Edge runtimes. These operations require Node.js-specific APIs (Buffer, crypto, file system) that are not available in this environment. Please use a Node.js runtime for file operations.";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a Proxy that throws a user-friendly error when any method is accessed.
|
|
6
|
+
* This ensures that users get a clear error message when attempting to use
|
|
7
|
+
* file operations in unsupported environments.
|
|
8
|
+
*/
|
|
9
|
+
const createUnsupportedFilesProxy = () => {
|
|
10
|
+
return new Proxy({}, { get(_target, prop) {
|
|
11
|
+
if (prop === Symbol.toStringTag) return "Files";
|
|
12
|
+
if (prop === "constructor") return Files;
|
|
13
|
+
return () => {
|
|
14
|
+
throw new Error(UNSUPPORTED_MESSAGE);
|
|
15
|
+
};
|
|
16
|
+
} });
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Files class for Cloudflare Workers / Edge runtimes.
|
|
20
|
+
* All methods throw an error indicating that file operations are not supported.
|
|
21
|
+
*/
|
|
22
|
+
var Files = class {
|
|
23
|
+
constructor(_client) {
|
|
24
|
+
return createUnsupportedFilesProxy();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.Files = Files;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import ComposioClient from "@composio/client";
|
|
2
|
+
|
|
3
|
+
//#region src/models/Files.workerd.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Files class for Cloudflare Workers / Edge runtimes.
|
|
7
|
+
* All methods throw an error indicating that file operations are not supported.
|
|
8
|
+
*/
|
|
9
|
+
declare class Files {
|
|
10
|
+
constructor(_client: ComposioClient);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Files };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import ComposioClient from "@composio/client";
|
|
2
|
+
|
|
3
|
+
//#region src/models/Files.workerd.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Files class for Cloudflare Workers / Edge runtimes.
|
|
7
|
+
* All methods throw an error indicating that file operations are not supported.
|
|
8
|
+
*/
|
|
9
|
+
declare class Files {
|
|
10
|
+
constructor(_client: ComposioClient);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Files };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/models/Files.workerd.ts
|
|
2
|
+
const UNSUPPORTED_MESSAGE = "File operations (upload/download) are not supported in Cloudflare Workers or Edge runtimes. These operations require Node.js-specific APIs (Buffer, crypto, file system) that are not available in this environment. Please use a Node.js runtime for file operations.";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Proxy that throws a user-friendly error when any method is accessed.
|
|
5
|
+
* This ensures that users get a clear error message when attempting to use
|
|
6
|
+
* file operations in unsupported environments.
|
|
7
|
+
*/
|
|
8
|
+
const createUnsupportedFilesProxy = () => {
|
|
9
|
+
return new Proxy({}, { get(_target, prop) {
|
|
10
|
+
if (prop === Symbol.toStringTag) return "Files";
|
|
11
|
+
if (prop === "constructor") return Files;
|
|
12
|
+
return () => {
|
|
13
|
+
throw new Error(UNSUPPORTED_MESSAGE);
|
|
14
|
+
};
|
|
15
|
+
} });
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Files class for Cloudflare Workers / Edge runtimes.
|
|
19
|
+
* All methods throw an error indicating that file operations are not supported.
|
|
20
|
+
*/
|
|
21
|
+
var Files = class {
|
|
22
|
+
constructor(_client) {
|
|
23
|
+
return createUnsupportedFilesProxy();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Files };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const require_chunk = require('../chunk-CQwRTUmo.cjs');
|
|
2
|
+
let node_fs = require("node:fs");
|
|
3
|
+
node_fs = require_chunk.__toESM(node_fs);
|
|
4
|
+
let node_os = require("node:os");
|
|
5
|
+
node_os = require_chunk.__toESM(node_os);
|
|
6
|
+
let node_path = require("node:path");
|
|
7
|
+
node_path = require_chunk.__toESM(node_path);
|
|
8
|
+
|
|
9
|
+
//#region src/platform/node.ts
|
|
10
|
+
/**
|
|
11
|
+
* Node.js platform implementation.
|
|
12
|
+
* Provides full file system and OS operations using Node.js built-in modules.
|
|
13
|
+
*/
|
|
14
|
+
const platform = {
|
|
15
|
+
supportsFileSystem: true,
|
|
16
|
+
homedir() {
|
|
17
|
+
try {
|
|
18
|
+
return node_os.homedir();
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
joinPath(...paths) {
|
|
24
|
+
return node_path.join(...paths);
|
|
25
|
+
},
|
|
26
|
+
basename(filePath) {
|
|
27
|
+
return node_path.basename(filePath);
|
|
28
|
+
},
|
|
29
|
+
existsSync(filePath) {
|
|
30
|
+
return node_fs.existsSync(filePath);
|
|
31
|
+
},
|
|
32
|
+
mkdirSync(dirPath) {
|
|
33
|
+
node_fs.mkdirSync(dirPath, { recursive: true });
|
|
34
|
+
},
|
|
35
|
+
readFileSync(filePath, encoding) {
|
|
36
|
+
if (encoding) return node_fs.readFileSync(filePath, encoding);
|
|
37
|
+
return node_fs.readFileSync(filePath);
|
|
38
|
+
},
|
|
39
|
+
writeFileSync(filePath, content, encoding) {
|
|
40
|
+
if (encoding && typeof content === "string") node_fs.writeFileSync(filePath, content, encoding);
|
|
41
|
+
else node_fs.writeFileSync(filePath, content);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
exports.platform = platform;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { t as Platform } from "../types-BrsW5suw.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/platform/node.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Node.js platform implementation.
|
|
7
|
+
* Provides full file system and OS operations using Node.js built-in modules.
|
|
8
|
+
*/
|
|
9
|
+
declare const platform: Platform;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { platform };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { t as Platform } from "../types-BaUqjuX3.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/platform/node.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Node.js platform implementation.
|
|
7
|
+
* Provides full file system and OS operations using Node.js built-in modules.
|
|
8
|
+
*/
|
|
9
|
+
declare const platform: Platform;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { platform };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as os from "node:os";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/platform/node.ts
|
|
6
|
+
/**
|
|
7
|
+
* Node.js platform implementation.
|
|
8
|
+
* Provides full file system and OS operations using Node.js built-in modules.
|
|
9
|
+
*/
|
|
10
|
+
const platform = {
|
|
11
|
+
supportsFileSystem: true,
|
|
12
|
+
homedir() {
|
|
13
|
+
try {
|
|
14
|
+
return os.homedir();
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
joinPath(...paths) {
|
|
20
|
+
return path.join(...paths);
|
|
21
|
+
},
|
|
22
|
+
basename(filePath) {
|
|
23
|
+
return path.basename(filePath);
|
|
24
|
+
},
|
|
25
|
+
existsSync(filePath) {
|
|
26
|
+
return fs.existsSync(filePath);
|
|
27
|
+
},
|
|
28
|
+
mkdirSync(dirPath) {
|
|
29
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
30
|
+
},
|
|
31
|
+
readFileSync(filePath, encoding) {
|
|
32
|
+
if (encoding) return fs.readFileSync(filePath, encoding);
|
|
33
|
+
return fs.readFileSync(filePath);
|
|
34
|
+
},
|
|
35
|
+
writeFileSync(filePath, content, encoding) {
|
|
36
|
+
if (encoding && typeof content === "string") fs.writeFileSync(filePath, content, encoding);
|
|
37
|
+
else fs.writeFileSync(filePath, content);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { platform };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/platform/workerd.ts
|
|
3
|
+
/**
|
|
4
|
+
* Cloudflare Workers / Edge runtime platform implementation.
|
|
5
|
+
* Provides stub implementations for file system operations that are unavailable in edge runtimes.
|
|
6
|
+
* All file system operations gracefully return null/empty values or throw descriptive errors.
|
|
7
|
+
*/
|
|
8
|
+
const platform = {
|
|
9
|
+
supportsFileSystem: false,
|
|
10
|
+
homedir() {
|
|
11
|
+
return null;
|
|
12
|
+
},
|
|
13
|
+
joinPath(...paths) {
|
|
14
|
+
return paths.map((segment, index) => {
|
|
15
|
+
if (index === 0) return segment.replace(/\/+$/, "");
|
|
16
|
+
return segment.replace(/^\/+|\/+$/g, "");
|
|
17
|
+
}).filter(Boolean).join("/");
|
|
18
|
+
},
|
|
19
|
+
basename(filePath) {
|
|
20
|
+
const segments = filePath.replace(/\/+$/, "").split("/");
|
|
21
|
+
return segments[segments.length - 1] || "";
|
|
22
|
+
},
|
|
23
|
+
existsSync(_filePath) {
|
|
24
|
+
return false;
|
|
25
|
+
},
|
|
26
|
+
mkdirSync(_dirPath) {},
|
|
27
|
+
readFileSync(_filePath, _encoding) {
|
|
28
|
+
throw new Error("File system operations are not supported in this runtime environment (Cloudflare Workers/Edge). Use environment variables or external storage services instead.");
|
|
29
|
+
},
|
|
30
|
+
writeFileSync(_filePath, _content, _encoding) {
|
|
31
|
+
throw new Error("File system operations are not supported in this runtime environment (Cloudflare Workers/Edge). Use environment variables or external storage services instead.");
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.platform = platform;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { t as Platform } from "../types-BrsW5suw.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/platform/workerd.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Cloudflare Workers / Edge runtime platform implementation.
|
|
7
|
+
* Provides stub implementations for file system operations that are unavailable in edge runtimes.
|
|
8
|
+
* All file system operations gracefully return null/empty values or throw descriptive errors.
|
|
9
|
+
*/
|
|
10
|
+
declare const platform: Platform;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { platform };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { t as Platform } from "../types-BaUqjuX3.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/platform/workerd.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Cloudflare Workers / Edge runtime platform implementation.
|
|
7
|
+
* Provides stub implementations for file system operations that are unavailable in edge runtimes.
|
|
8
|
+
* All file system operations gracefully return null/empty values or throw descriptive errors.
|
|
9
|
+
*/
|
|
10
|
+
declare const platform: Platform;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { platform };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/platform/workerd.ts
|
|
2
|
+
/**
|
|
3
|
+
* Cloudflare Workers / Edge runtime platform implementation.
|
|
4
|
+
* Provides stub implementations for file system operations that are unavailable in edge runtimes.
|
|
5
|
+
* All file system operations gracefully return null/empty values or throw descriptive errors.
|
|
6
|
+
*/
|
|
7
|
+
const platform = {
|
|
8
|
+
supportsFileSystem: false,
|
|
9
|
+
homedir() {
|
|
10
|
+
return null;
|
|
11
|
+
},
|
|
12
|
+
joinPath(...paths) {
|
|
13
|
+
return paths.map((segment, index) => {
|
|
14
|
+
if (index === 0) return segment.replace(/\/+$/, "");
|
|
15
|
+
return segment.replace(/^\/+|\/+$/g, "");
|
|
16
|
+
}).filter(Boolean).join("/");
|
|
17
|
+
},
|
|
18
|
+
basename(filePath) {
|
|
19
|
+
const segments = filePath.replace(/\/+$/, "").split("/");
|
|
20
|
+
return segments[segments.length - 1] || "";
|
|
21
|
+
},
|
|
22
|
+
existsSync(_filePath) {
|
|
23
|
+
return false;
|
|
24
|
+
},
|
|
25
|
+
mkdirSync(_dirPath) {},
|
|
26
|
+
readFileSync(_filePath, _encoding) {
|
|
27
|
+
throw new Error("File system operations are not supported in this runtime environment (Cloudflare Workers/Edge). Use environment variables or external storage services instead.");
|
|
28
|
+
},
|
|
29
|
+
writeFileSync(_filePath, _content, _encoding) {
|
|
30
|
+
throw new Error("File system operations are not supported in this runtime environment (Cloudflare Workers/Edge). Use environment variables or external storage services instead.");
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { platform };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//#region src/platform/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Platform abstraction for file system and OS operations.
|
|
4
|
+
* This interface allows different implementations for Node.js and edge runtimes (e.g., Cloudflare Workers).
|
|
5
|
+
*/
|
|
6
|
+
interface Platform {
|
|
7
|
+
/**
|
|
8
|
+
* Returns the user's home directory path.
|
|
9
|
+
* @returns The home directory path, or null if unavailable (e.g., in edge runtimes).
|
|
10
|
+
*/
|
|
11
|
+
homedir(): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Joins path segments into a single path.
|
|
14
|
+
* @param paths - Path segments to join.
|
|
15
|
+
* @returns The joined path.
|
|
16
|
+
*/
|
|
17
|
+
joinPath(...paths: string[]): string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the last portion of a path (the filename).
|
|
20
|
+
* @param filePath - The path to extract the basename from.
|
|
21
|
+
* @returns The basename of the path.
|
|
22
|
+
*/
|
|
23
|
+
basename(filePath: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a file or directory exists at the given path.
|
|
26
|
+
* @param filePath - The path to check.
|
|
27
|
+
* @returns True if the path exists, false otherwise.
|
|
28
|
+
*/
|
|
29
|
+
existsSync(filePath: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a directory at the given path, including parent directories if needed.
|
|
32
|
+
* @param dirPath - The directory path to create.
|
|
33
|
+
*/
|
|
34
|
+
mkdirSync(dirPath: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Reads a file synchronously and returns its contents.
|
|
37
|
+
* @param filePath - The path to the file.
|
|
38
|
+
* @param encoding - Optional encoding (e.g., 'utf8'). If not provided, returns a Buffer.
|
|
39
|
+
* @returns The file contents as a string (if encoding provided) or Buffer.
|
|
40
|
+
*/
|
|
41
|
+
readFileSync(filePath: string, encoding?: BufferEncoding): string | Buffer;
|
|
42
|
+
/**
|
|
43
|
+
* Writes content to a file synchronously.
|
|
44
|
+
* @param filePath - The path to the file.
|
|
45
|
+
* @param content - The content to write (string or Buffer).
|
|
46
|
+
* @param encoding - Optional encoding for string content.
|
|
47
|
+
*/
|
|
48
|
+
writeFileSync(filePath: string, content: string | Buffer, encoding?: BufferEncoding): void;
|
|
49
|
+
/**
|
|
50
|
+
* Indicates whether this platform supports file system operations.
|
|
51
|
+
* Edge runtimes like Cloudflare Workers return false.
|
|
52
|
+
*/
|
|
53
|
+
readonly supportsFileSystem: boolean;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { Platform as t };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//#region src/platform/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Platform abstraction for file system and OS operations.
|
|
4
|
+
* This interface allows different implementations for Node.js and edge runtimes (e.g., Cloudflare Workers).
|
|
5
|
+
*/
|
|
6
|
+
interface Platform {
|
|
7
|
+
/**
|
|
8
|
+
* Returns the user's home directory path.
|
|
9
|
+
* @returns The home directory path, or null if unavailable (e.g., in edge runtimes).
|
|
10
|
+
*/
|
|
11
|
+
homedir(): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Joins path segments into a single path.
|
|
14
|
+
* @param paths - Path segments to join.
|
|
15
|
+
* @returns The joined path.
|
|
16
|
+
*/
|
|
17
|
+
joinPath(...paths: string[]): string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the last portion of a path (the filename).
|
|
20
|
+
* @param filePath - The path to extract the basename from.
|
|
21
|
+
* @returns The basename of the path.
|
|
22
|
+
*/
|
|
23
|
+
basename(filePath: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a file or directory exists at the given path.
|
|
26
|
+
* @param filePath - The path to check.
|
|
27
|
+
* @returns True if the path exists, false otherwise.
|
|
28
|
+
*/
|
|
29
|
+
existsSync(filePath: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a directory at the given path, including parent directories if needed.
|
|
32
|
+
* @param dirPath - The directory path to create.
|
|
33
|
+
*/
|
|
34
|
+
mkdirSync(dirPath: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Reads a file synchronously and returns its contents.
|
|
37
|
+
* @param filePath - The path to the file.
|
|
38
|
+
* @param encoding - Optional encoding (e.g., 'utf8'). If not provided, returns a Buffer.
|
|
39
|
+
* @returns The file contents as a string (if encoding provided) or Buffer.
|
|
40
|
+
*/
|
|
41
|
+
readFileSync(filePath: string, encoding?: BufferEncoding): string | Buffer;
|
|
42
|
+
/**
|
|
43
|
+
* Writes content to a file synchronously.
|
|
44
|
+
* @param filePath - The path to the file.
|
|
45
|
+
* @param content - The content to write (string or Buffer).
|
|
46
|
+
* @param encoding - Optional encoding for string content.
|
|
47
|
+
*/
|
|
48
|
+
writeFileSync(filePath: string, content: string | Buffer, encoding?: BufferEncoding): void;
|
|
49
|
+
/**
|
|
50
|
+
* Indicates whether this platform supports file system operations.
|
|
51
|
+
* Edge runtimes like Cloudflare Workers return false.
|
|
52
|
+
*/
|
|
53
|
+
readonly supportsFileSystem: boolean;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { Platform as t };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stub file for @composio/core/generated exports.
|
|
3
|
+
* Run `composio ts generate` to generate the actual toolkit types.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const ERROR_MESSAGE = `
|
|
7
|
+
@composio/core/generated has not been initialized.
|
|
8
|
+
Please run \`composio ts generate\` in your project to generate the toolkit types.
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export const Toolkits = new Proxy(
|
|
12
|
+
{},
|
|
13
|
+
{
|
|
14
|
+
get(_, prop) {
|
|
15
|
+
throw new Error(ERROR_MESSAGE);
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
);
|