@squidcloud/google-drive-client 1.0.146-beta

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.
@@ -0,0 +1,137 @@
1
+ import { AiContextMetadata } from '@squidcloud/client';
2
+ export { AiContextMetadata };
3
+ /**
4
+ * The type of document in personal storage.
5
+ * @category GoogleDrive
6
+ */
7
+ export type PsDocumentType = 'file' | 'folder';
8
+ /**
9
+ * Document data from Google Drive.
10
+ * @category GoogleDrive
11
+ */
12
+ export interface PsDocumentData {
13
+ /** The unique identifier of the document. */
14
+ id: string;
15
+ /** The name of the document. */
16
+ name: string;
17
+ /** The type of the document (file or folder). */
18
+ type: PsDocumentType;
19
+ /** The MIME type of the document. */
20
+ mimeType: string;
21
+ /** The last modified date of the document. */
22
+ modifiedDate: Date;
23
+ }
24
+ /**
25
+ * Represents a document that has been indexed for AI processing.
26
+ * @category GoogleDrive
27
+ */
28
+ export interface PsIndexedDocument {
29
+ /** The unique identifier of the document. */
30
+ id: string;
31
+ /** The name of the document. */
32
+ name: string;
33
+ /** The type of the document (file or folder). */
34
+ type: PsDocumentType;
35
+ /** Metadata associated with the document. */
36
+ metadata: AiContextMetadata;
37
+ /** The ID of the parent folder, if the document was indexed as part of a folder. */
38
+ folderDocumentId?: string;
39
+ }
40
+ /**
41
+ * Error information for a document that failed to index.
42
+ * @category GoogleDrive
43
+ */
44
+ export interface PsIndexDocumentError {
45
+ /** The unique identifier of the document. */
46
+ documentId: string;
47
+ /** The name of the document. */
48
+ name: string;
49
+ /** The error message describing why indexing failed. */
50
+ errorMessage: string;
51
+ }
52
+ /**
53
+ * Error information for a document that failed to unindex.
54
+ * @category GoogleDrive
55
+ */
56
+ export interface PsUnindexDocumentError {
57
+ /** The unique identifier of the document. */
58
+ documentId: string;
59
+ /** The name of the document. */
60
+ name: string;
61
+ /** The error message describing why unindexing failed. */
62
+ errorMessage: string;
63
+ }
64
+ /**
65
+ * Request to index a document or folder for AI processing.
66
+ * @category GoogleDrive
67
+ */
68
+ export interface PsIndexDocumentOrFolderRequest {
69
+ /** The ID of the integration in the Squid console. */
70
+ integrationId: string;
71
+ /** User-specific identifier to retrieve the correct OAuth tokens. */
72
+ identifier: string;
73
+ /** The ID of the document or folder to index. */
74
+ documentOrFolderId: string;
75
+ /** Optional metadata to associate with the indexed document(s). */
76
+ metadata?: AiContextMetadata;
77
+ }
78
+ /**
79
+ * Response from indexing a document or folder.
80
+ * @category GoogleDrive
81
+ */
82
+ export interface PsIndexDocumentOrFolderResponse {
83
+ /** Array of errors for documents that failed to index. Empty if all succeeded. */
84
+ errors: Array<PsIndexDocumentError>;
85
+ }
86
+ /**
87
+ * Request to list indexed documents.
88
+ * @category GoogleDrive
89
+ */
90
+ export interface PsListIndexedDocumentsRequest {
91
+ /** The ID of the integration in the Squid console. */
92
+ integrationId: string;
93
+ /** User-specific identifier to retrieve the correct OAuth tokens. */
94
+ identifier: string;
95
+ /** Optional filter for document type (file or folder). */
96
+ type?: PsDocumentType;
97
+ }
98
+ /**
99
+ * Response containing list of indexed documents.
100
+ * @category GoogleDrive
101
+ */
102
+ export interface PsListIndexedDocumentsResponse {
103
+ /** Array of indexed documents. */
104
+ documents: Array<PsIndexedDocument>;
105
+ }
106
+ /**
107
+ * Request to unindex a document or folder.
108
+ * @category GoogleDrive
109
+ */
110
+ export interface PsUnindexDocumentOrFolderRequest {
111
+ /** The ID of the integration in the Squid console. */
112
+ integrationId: string;
113
+ /** User-specific identifier to retrieve the correct OAuth tokens. */
114
+ identifier: string;
115
+ /** The ID of the document or folder to unindex. */
116
+ documentOrFolderId: string;
117
+ }
118
+ /**
119
+ * Response from unindexing a document or folder.
120
+ * @category GoogleDrive
121
+ */
122
+ export interface PsUnindexDocumentOrFolderResponse {
123
+ /** Array of errors for documents that failed to unindex. Empty if all succeeded. */
124
+ errors: Array<PsUnindexDocumentError>;
125
+ }
126
+ /**
127
+ * Request to extract data from a document.
128
+ * @category GoogleDrive
129
+ */
130
+ export interface PsExtractDataFromDocumentRequest {
131
+ /** The ID of the integration in the Squid console. */
132
+ integrationId: string;
133
+ /** User-specific identifier to retrieve the correct OAuth tokens. */
134
+ identifier: string;
135
+ /** The ID of the document to extract data from. */
136
+ documentId: string;
137
+ }
@@ -0,0 +1,60 @@
1
+ import { ExtractDataFromDocumentResponse, GetAccessTokenResponse, Squid } from '@squidcloud/client';
2
+ import { AiContextMetadata, PsExtractDataFromDocumentRequest, PsIndexDocumentError, PsIndexDocumentOrFolderRequest, PsIndexDocumentOrFolderResponse, PsIndexedDocument, PsListIndexedDocumentsRequest, PsListIndexedDocumentsResponse, PsUnindexDocumentError, PsUnindexDocumentOrFolderRequest, PsUnindexDocumentOrFolderResponse } from '../../common/src/google-drive-types';
3
+ /**
4
+ * OAuth2 scopes required for Google Drive integration.
5
+ * Use these scopes when requesting the OAuth2 auth code from Google.
6
+ */
7
+ export declare const GOOGLE_DRIVE_SCOPES: readonly ["openid", "email", "https://www.googleapis.com/auth/drive.readonly", "https://www.googleapis.com/auth/drive.metadata.readonly"];
8
+ export { AiContextMetadata, PsExtractDataFromDocumentRequest, PsIndexDocumentError, PsIndexDocumentOrFolderRequest, PsIndexDocumentOrFolderResponse, PsIndexedDocument, PsListIndexedDocumentsRequest, PsListIndexedDocumentsResponse, PsUnindexDocumentError, PsUnindexDocumentOrFolderRequest, PsUnindexDocumentOrFolderResponse, };
9
+ /**
10
+ * Client for Google Drive personal storage integration.
11
+ * Provides convenient methods to interact with Google Drive via Squid's personal storage APIs.
12
+ */
13
+ export declare class GoogleDriveClient {
14
+ private readonly squid;
15
+ private readonly integrationId;
16
+ constructor(squid: Squid, integrationId: string);
17
+ /**
18
+ * Save an OAuth authorization code after the user completes the OAuth flow.
19
+ *
20
+ * @param authCode - The authorization code from Google
21
+ * @param identifier - User-specific identifier
22
+ * @returns Access token and expiration time
23
+ */
24
+ saveAuthCode(authCode: string, identifier: string): Promise<GetAccessTokenResponse>;
25
+ /**
26
+ * List all indexed documents for an identifier.
27
+ *
28
+ * @param identifier - User-specific identifier
29
+ * @param type - Optional filter by type ('file' or 'folder')
30
+ * @returns Array of indexed documents
31
+ */
32
+ listIndexedDocuments(identifier: string, type?: 'file' | 'folder'): Promise<Array<PsIndexedDocument>>;
33
+ /**
34
+ * Index a document or folder for AI context.
35
+ * If it is a folder, all files within it are indexed recursively.
36
+ *
37
+ * @param documentOrFolderId - Google Drive document or folder ID
38
+ * @param identifier - User-specific identifier
39
+ * @param metadata - Optional metadata to attach
40
+ * @returns Array of errors for documents that failed to index. Empty if all succeeded.
41
+ */
42
+ indexDocumentOrFolder(documentOrFolderId: string, identifier: string, metadata?: AiContextMetadata): Promise<Array<PsIndexDocumentError>>;
43
+ /**
44
+ * Remove a document or folder from the index (and AI context).
45
+ * If a folder is provided, all files within it will be unindexed.
46
+ *
47
+ * @param documentOrFolderId - Google Drive document or folder ID
48
+ * @param identifier - User-specific identifier
49
+ * @returns Array of errors for documents that failed to unindex. Empty if all succeeded.
50
+ */
51
+ unindexDocumentOrFolder(documentOrFolderId: string, identifier: string): Promise<Array<PsUnindexDocumentError>>;
52
+ /**
53
+ * Extract data from a document (download file content).
54
+ *
55
+ * @param documentId - Google Drive document ID
56
+ * @param identifier - User-specific identifier
57
+ * @returns Extracted document data with pages
58
+ */
59
+ extractDataFromDocument(documentId: string, identifier: string): Promise<ExtractDataFromDocumentResponse>;
60
+ }
@@ -0,0 +1 @@
1
+ export * from './google-drive-client';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var e={d:(t,i)=>{for(var o in i)e.o(i,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:i[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{GOOGLE_DRIVE_SCOPES:()=>i,GoogleDriveClient:()=>o});const i=["openid","email","https://www.googleapis.com/auth/drive.readonly","https://www.googleapis.com/auth/drive.metadata.readonly"];class o{constructor(e,t){this.squid=e,this.integrationId=t}async saveAuthCode(e,t){return await this.squid.externalAuth(this.integrationId).saveAuthCode(e,t)}async listIndexedDocuments(e,t){const i={integrationId:this.integrationId,identifier:e,type:t};return(await this.squid.executeFunction("getGoogleDriveIndexedDocuments",i)).documents}async indexDocumentOrFolder(e,t,i){const o={integrationId:this.integrationId,identifier:t,documentOrFolderId:e,metadata:i};return(await this.squid.executeFunction("indexGoogleDriveDocumentOrFolder",o)).errors}async unindexDocumentOrFolder(e,t){const i={integrationId:this.integrationId,identifier:t,documentOrFolderId:e};return(await this.squid.executeFunction("unindexGoogleDriveDocumentOrFolder",i)).errors}async extractDataFromDocument(e,t){const i={integrationId:this.integrationId,identifier:t,documentId:e};return await this.squid.executeFunction("extractGoogleDriveDocument",i)}}var n=exports;for(var r in t)n[r]=t[r];t.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@squidcloud/google-drive-client",
3
+ "version": "1.0.146-beta",
4
+ "description": "Squid Google Drive Client",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "prebuild": "del-cli dist",
9
+ "build": "webpack --mode=production",
10
+ "lint": "eslint",
11
+ "publish:public": "npm run build && npm publish --access public"
12
+ },
13
+ "files": [
14
+ "dist/**/*"
15
+ ],
16
+ "keywords": [],
17
+ "author": "",
18
+ "license": "ISC",
19
+ "dependencies": {
20
+ "assertic": "^1.3.0",
21
+ "lodash": "^4.17.21",
22
+ "@squidcloud/client": "^1.0.146-beta"
23
+ },
24
+ "engines": {
25
+ "node": ">=20.0.0"
26
+ }
27
+ }