@credal/actions 0.2.89 → 0.2.90
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/actions/autogen/templates.js +2 -2
- package/dist/actions/autogen/types.d.ts +3 -3
- package/dist/actions/autogen/types.js +2 -4
- package/dist/actions/providers/google-oauth/getDriveFileContentById.js +5 -4
- package/dist/actions/providers/google-oauth/searchDriveByKeywordsAndGetFileContent.js +2 -2
- package/dist/actions/providers/google-oauth/searchDriveByQueryAndGetFileContent.js +2 -2
- package/package.json +1 -1
|
@@ -6839,7 +6839,7 @@ export const googleOauthSearchDriveByKeywordsAndGetFileContentDefinition = {
|
|
|
6839
6839
|
properties: {
|
|
6840
6840
|
searchQuery: {
|
|
6841
6841
|
type: "string",
|
|
6842
|
-
description: "The query to
|
|
6842
|
+
description: "The query input to Google Drive search",
|
|
6843
6843
|
},
|
|
6844
6844
|
limit: {
|
|
6845
6845
|
type: "number",
|
|
@@ -6987,7 +6987,7 @@ export const googleOauthGetDriveFileContentByIdDefinition = {
|
|
|
6987
6987
|
scopes: ["drive.readonly"],
|
|
6988
6988
|
parameters: {
|
|
6989
6989
|
type: "object",
|
|
6990
|
-
required: ["fileId"
|
|
6990
|
+
required: ["fileId"],
|
|
6991
6991
|
properties: {
|
|
6992
6992
|
fileId: {
|
|
6993
6993
|
type: "string",
|
|
@@ -4195,17 +4195,17 @@ export type googleOauthSearchDriveByQueryAndGetFileContentOutputType = z.infer<t
|
|
|
4195
4195
|
export type googleOauthSearchDriveByQueryAndGetFileContentFunction = ActionFunction<googleOauthSearchDriveByQueryAndGetFileContentParamsType, AuthParamsType, googleOauthSearchDriveByQueryAndGetFileContentOutputType>;
|
|
4196
4196
|
export declare const googleOauthGetDriveFileContentByIdParamsSchema: z.ZodObject<{
|
|
4197
4197
|
fileId: z.ZodString;
|
|
4198
|
-
limit: z.ZodNumber
|
|
4198
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
4199
4199
|
timeoutLimit: z.ZodOptional<z.ZodNumber>;
|
|
4200
4200
|
fileSizeLimit: z.ZodOptional<z.ZodNumber>;
|
|
4201
4201
|
}, "strip", z.ZodTypeAny, {
|
|
4202
|
-
limit: number;
|
|
4203
4202
|
fileId: string;
|
|
4203
|
+
limit?: number | undefined;
|
|
4204
4204
|
fileSizeLimit?: number | undefined;
|
|
4205
4205
|
timeoutLimit?: number | undefined;
|
|
4206
4206
|
}, {
|
|
4207
|
-
limit: number;
|
|
4208
4207
|
fileId: string;
|
|
4208
|
+
limit?: number | undefined;
|
|
4209
4209
|
fileSizeLimit?: number | undefined;
|
|
4210
4210
|
timeoutLimit?: number | undefined;
|
|
4211
4211
|
}>;
|
|
@@ -2588,9 +2588,7 @@ export const googleOauthSearchDriveByQueryOutputSchema = z.object({
|
|
|
2588
2588
|
error: z.string().describe("Error message if search failed").optional(),
|
|
2589
2589
|
});
|
|
2590
2590
|
export const googleOauthSearchDriveByKeywordsAndGetFileContentParamsSchema = z.object({
|
|
2591
|
-
searchQuery: z
|
|
2592
|
-
.string()
|
|
2593
|
-
.describe("The query to search for in file contents, eg 'compliance policy' or 'data encryption'. The more relevant words the better."),
|
|
2591
|
+
searchQuery: z.string().describe("The query input to Google Drive search"),
|
|
2594
2592
|
limit: z.number().describe("The maximum number of files to return").optional(),
|
|
2595
2593
|
fileSizeLimit: z.number().describe("The maximum length of a file in characters").optional(),
|
|
2596
2594
|
searchDriveByDrive: z.boolean().describe("Search drive by drive or run a general search"),
|
|
@@ -2639,7 +2637,7 @@ export const googleOauthSearchDriveByQueryAndGetFileContentOutputSchema = z.obje
|
|
|
2639
2637
|
});
|
|
2640
2638
|
export const googleOauthGetDriveFileContentByIdParamsSchema = z.object({
|
|
2641
2639
|
fileId: z.string().describe("The ID of the file to get content from"),
|
|
2642
|
-
limit: z.number().describe("The character limit for the file content"),
|
|
2640
|
+
limit: z.number().describe("The character limit for the file content").optional(),
|
|
2643
2641
|
timeoutLimit: z
|
|
2644
2642
|
.number()
|
|
2645
2643
|
.describe("The timeout limit for the file content retrieval (default of 15 seconds)")
|
|
@@ -19,7 +19,7 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
19
19
|
}
|
|
20
20
|
const BASE_URL = "https://www.googleapis.com/drive/v3/files/";
|
|
21
21
|
const headers = { Authorization: `Bearer ${authParams.authToken}` };
|
|
22
|
-
const { limit } = params;
|
|
22
|
+
const { limit: charLimit, fileId } = params;
|
|
23
23
|
const timeoutLimit = params.timeoutLimit !== undefined && params.timeoutLimit > 0 ? params.timeoutLimit * 1000 : 15000;
|
|
24
24
|
const axiosClient = createAxiosClientWithTimeout(timeoutLimit);
|
|
25
25
|
// helper to fetch drive metadata with fields we need (incl. shortcut details)
|
|
@@ -33,7 +33,7 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
33
33
|
});
|
|
34
34
|
try {
|
|
35
35
|
// 1) metadata (possibly a shortcut)
|
|
36
|
-
let meta = yield fetchMeta(
|
|
36
|
+
let meta = yield fetchMeta(fileId);
|
|
37
37
|
// 2) resolve shortcut transparently (re-point to target id + mime)
|
|
38
38
|
if (meta.mimeType === "application/vnd.google-apps.shortcut" && ((_b = meta.shortcutDetails) === null || _b === void 0 ? void 0 : _b.targetId)) {
|
|
39
39
|
meta = yield fetchMeta(meta.shortcutDetails.targetId);
|
|
@@ -111,8 +111,9 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
111
111
|
.replace(/\r?\n+/g, " ")
|
|
112
112
|
.replace(/ +/g, " ");
|
|
113
113
|
const originalLength = content.length;
|
|
114
|
-
if (
|
|
115
|
-
|
|
114
|
+
if (charLimit && content.length > charLimit) {
|
|
115
|
+
// TODO in the future do this around the most valuable snippet of the doc?
|
|
116
|
+
content = content.slice(0, charLimit);
|
|
116
117
|
}
|
|
117
118
|
return { success: true, content, fileName, fileLength: originalLength };
|
|
118
119
|
}
|
|
@@ -15,7 +15,7 @@ const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], v
|
|
|
15
15
|
if (!authParams.authToken) {
|
|
16
16
|
return { success: false, error: MISSING_AUTH_TOKEN, files: [] };
|
|
17
17
|
}
|
|
18
|
-
const { searchQuery, limit, searchDriveByDrive, orderByQuery, fileSizeLimit } = params;
|
|
18
|
+
const { searchQuery, limit, searchDriveByDrive, orderByQuery, fileSizeLimit: maxChars } = params;
|
|
19
19
|
// First, perform the search
|
|
20
20
|
const query = searchQuery
|
|
21
21
|
.split(" ")
|
|
@@ -35,7 +35,7 @@ const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], v
|
|
|
35
35
|
const contentPromises = files.map((file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
36
|
try {
|
|
37
37
|
const contentResult = yield getDriveFileContentById({
|
|
38
|
-
params: { fileId: file.id, limit:
|
|
38
|
+
params: { fileId: file.id, limit: maxChars },
|
|
39
39
|
authParams,
|
|
40
40
|
});
|
|
41
41
|
return {
|
|
@@ -15,7 +15,7 @@ const searchDriveByQueryAndGetFileContent = (_a) => __awaiter(void 0, [_a], void
|
|
|
15
15
|
if (!authParams.authToken) {
|
|
16
16
|
return { success: false, error: MISSING_AUTH_TOKEN, files: [] };
|
|
17
17
|
}
|
|
18
|
-
const { query, limit, searchDriveByDrive, orderByQuery, fileSizeLimit } = params;
|
|
18
|
+
const { query, limit, searchDriveByDrive, orderByQuery, fileSizeLimit: maxChars } = params;
|
|
19
19
|
// First, perform the search
|
|
20
20
|
const searchResult = yield searchDriveByQuery({
|
|
21
21
|
params: { query, limit, searchDriveByDrive, orderByQuery },
|
|
@@ -30,7 +30,7 @@ const searchDriveByQueryAndGetFileContent = (_a) => __awaiter(void 0, [_a], void
|
|
|
30
30
|
const contentPromises = files.map((file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
31
|
try {
|
|
32
32
|
const contentResult = yield getDriveFileContentById({
|
|
33
|
-
params: { fileId: file.id, limit:
|
|
33
|
+
params: { fileId: file.id, limit: maxChars },
|
|
34
34
|
authParams,
|
|
35
35
|
});
|
|
36
36
|
return {
|