@squidcloud/client 1.0.414 → 1.0.416

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.
@@ -15,6 +15,11 @@ export declare const AI_PROVIDER_TYPES: readonly ["anthropic", "flux", "gemini",
15
15
  * chat/search/transcribe etc...).
16
16
  */
17
17
  export type AiProviderType = (typeof AI_PROVIDER_TYPES)[number];
18
+ /**
19
+ * Type of AI provider that supports file upload operations.
20
+ * Only a subset of AI providers support file management features.
21
+ */
22
+ export type AiFileProviderType = Extract<AiProviderType, 'openai' | 'gemini' | 'anthropic'>;
18
23
  /**
19
24
  * @category AI
20
25
  */
@@ -138,6 +138,8 @@ export type AiContextMetadataFilter = AiContextMetadataFieldFilter | AiContextMe
138
138
  export interface AiKnowledgeBaseContext {
139
139
  /** The unique identifier of the context entry. */
140
140
  id: string;
141
+ /** The application id of the context entry */
142
+ appId: AppId;
141
143
  /** The knowledge base id of the context entry */
142
144
  knowledgeBaseId: AiKnowledgeBaseId;
143
145
  /** The date and time the context was created. */
@@ -0,0 +1,39 @@
1
+ import { IntegrationId } from '../communication.public-types';
2
+ /**
3
+ * Configuration for identifying a user's external auth connection.
4
+ * @category ExternalAuth
5
+ */
6
+ export interface ExternalAuthConfig {
7
+ /** The integration ID (e.g., 'google-calendar', 'microsoft-teams'). */
8
+ integrationId: IntegrationId;
9
+ /** User-specific identifier to distinguish between different users' tokens. */
10
+ identifier: string;
11
+ }
12
+ /**
13
+ * Request to save an authorization code and exchange it for tokens.
14
+ * @category ExternalAuth
15
+ */
16
+ export interface SaveAuthCodeRequest {
17
+ /** The authorization code from the auth provider. */
18
+ authCode: string;
19
+ /** Configuration identifying the user and integration. */
20
+ externalAuthConfig: ExternalAuthConfig;
21
+ }
22
+ /**
23
+ * Request to get a valid access token for an integration.
24
+ * @category ExternalAuth
25
+ */
26
+ export interface GetAccessTokenRequest {
27
+ /** Configuration identifying the user and integration. */
28
+ externalAuthConfig: ExternalAuthConfig;
29
+ }
30
+ /**
31
+ * Response containing a valid access token and expiration time.
32
+ * @category ExternalAuth
33
+ */
34
+ export interface GetAccessTokenResponse {
35
+ /** Valid access token for making API calls. */
36
+ accessToken: string;
37
+ /** When the access token expires. */
38
+ expirationTime: Date;
39
+ }
@@ -3,10 +3,11 @@ import { AiAgentClientOptions } from './agent/ai-agent-client';
3
3
  import { AiAgentReference } from './agent/ai-agent-client-reference';
4
4
  import { AiAssistantClient } from './ai-assistant-client';
5
5
  import { AiAudioClient } from './ai-audio-client';
6
+ import { AiFilesClient } from './ai-files-client';
6
7
  import { AiImageClient } from './ai-image-client';
7
8
  import { AiKnowledgeBaseReference } from './ai-knowledge-base/ai-knowledge-base-client-reference';
8
9
  import { AiMatchMakingClient } from './ai-matchmaking-client';
9
- import { AiAgent, AiAgentId, AiKnowledgeBase, AiKnowledgeBaseId, AiProviderType, ApplicationAiSettings, IntegrationId, SecretKey } from './public-types';
10
+ import { AiAgent, AiAgentId, AiFileProviderType, AiKnowledgeBase, AiKnowledgeBaseId, AiProviderType, ApplicationAiSettings, IntegrationId, SecretKey } from './public-types';
10
11
  /**
11
12
  * AiClient class serves as a facade for interacting with different AI services.
12
13
  * It provides simplified access to AI chatbot and assistant functionalities
@@ -56,6 +57,19 @@ export declare class AiClient {
56
57
  * @deprecated - Use `knowledgebase('kbId').searchContextsWith*()` instead.
57
58
  */
58
59
  matchMaking(): AiMatchMakingClient;
60
+ /**
61
+ * Creates a client to manage files for a specific AI provider.
62
+ *
63
+ * @param provider - The AI provider (openai, gemini, or anthropic).
64
+ * @returns An AiFilesClient bound to the specified provider.
65
+ * @example
66
+ * ```typescript
67
+ * const openaiFiles = squid.ai().files('openai');
68
+ * const fileId = await openaiFiles.uploadFile({ file });
69
+ * await openaiFiles.deleteFile(fileId);
70
+ * ```
71
+ */
72
+ files(provider: AiFileProviderType): AiFilesClient;
59
73
  /**
60
74
  * Executes an AI query using a specific DB integration, sending a prompt to the AI and returning its response.
61
75
  * This function allows for direct interaction with the AI's capabilities by sending text prompts and receiving
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Options for uploading a file to an AI provider.
3
+ * @category AI
4
+ */
5
+ export interface UploadAiFileOptions {
6
+ /** The file to upload. */
7
+ file: File;
8
+ /** Optional expiration time in seconds for automatic cleanup. */
9
+ expirationInSeconds?: number;
10
+ }
11
+ /**
12
+ * AiFilesClient provides methods for managing files with a specific AI provider.
13
+ * The provider is bound when the client is created via `squid.ai().files(provider)`.
14
+ * @category AI
15
+ */
16
+ export declare class AiFilesClient {
17
+ private readonly provider;
18
+ private readonly rpcManager;
19
+ /**
20
+ * Uploads a file to the AI provider for use with AI features like code interpreter.
21
+ *
22
+ * @param options - Options for uploading the file.
23
+ * @returns A Promise that resolves to the file ID assigned by the provider.
24
+ */
25
+ uploadFile(options: UploadAiFileOptions): Promise<string>;
26
+ /**
27
+ * Deletes a file from the AI provider's storage.
28
+ *
29
+ * @param fileId - The ID of the file to delete.
30
+ * @returns A Promise that resolves to true if the file was deleted, false if it didn't exist.
31
+ */
32
+ deleteFile(fileId: string): Promise<boolean>;
33
+ }
@@ -20,4 +20,8 @@ export interface DistributedLock {
20
20
  * @returns An observable that emits when the lock is released.
21
21
  */
22
22
  observeRelease(): Observable<void>;
23
+ /** The resource identifier (mutex name) that was locked. */
24
+ get resourceId(): string;
25
+ /** Unique lock instance ID within the system. */
26
+ get lockId(): string;
23
27
  }
@@ -0,0 +1,36 @@
1
+ import { GetAccessTokenResponse } from '../../internal-common/src/public-types/external-auth/external-auth.public-types';
2
+ /**
3
+ * Client for managing authentication tokens for external integrations.
4
+ *
5
+ * Provides methods for saving and retrieving auth tokens for external services.
6
+ * @category ExternalAuth
7
+ */
8
+ export declare class ExternalAuthClient {
9
+ private readonly integrationId;
10
+ private readonly rpcManager;
11
+ /**
12
+ * Takes an auth token, potentially exchanges the auth token with an external api depending on the external auth,
13
+ * and stores the result in Squid's secure storage.
14
+ *
15
+ * This function requires Squid to be initialized with an API key
16
+ *
17
+ * @param authCode - The authorization code obtained from the auth provider's callback.
18
+ * @param identifier - A user-specific identifier (usually a user ID) to associate with the tokens.
19
+ * This allows multiple users to connect their own accounts to the same integration.
20
+ * @returns A promise that resolves with the access token and its expiration time.
21
+ */
22
+ saveAuthCode(authCode: string, identifier: string): Promise<GetAccessTokenResponse>;
23
+ /**
24
+ * Retrieves a valid access token for the integration.
25
+ * Automatically refreshes the token if it has expired or is about to expire.
26
+ *
27
+ * This function requires Squid to be initialized with an API key
28
+ *
29
+ * @param identifier - The user-specific identifier that was used when saving the auth code.
30
+ * @returns A promise that resolves with a valid access token and its expiration time.
31
+ *
32
+ * @throws Error if no tokens are found for the given integration and identifier.
33
+ * The user must first complete the auth flow by calling `saveAuthCode()`.
34
+ */
35
+ getAccessToken(identifier: string): Promise<GetAccessTokenResponse>;
36
+ }
@@ -5,6 +5,7 @@ export * from './agent/ai-agent-client.types';
5
5
  export * from './ai-assistant-client';
6
6
  export * from './ai-audio-client';
7
7
  export * from './ai-client';
8
+ export * from './ai-files-client';
8
9
  export * from './ai-image-client';
9
10
  export * from './ai-knowledge-base/ai-knowledge-base-client';
10
11
  export * from './ai-knowledge-base/ai-knowledge-base-client-reference';
@@ -26,6 +27,7 @@ export * from './document-reference';
26
27
  export * from './document-reference.factory';
27
28
  export * from './document-store';
28
29
  export * from './execute-function-options';
30
+ export * from './external-auth-client';
29
31
  export * from './extraction-client';
30
32
  export * from './file-args-transformer';
31
33
  export * from './file-utils';
@@ -12,6 +12,7 @@ export * from '../../internal-common/src/public-types/code-executor.public-types
12
12
  export * from '../../internal-common/src/public-types/communication.public-types';
13
13
  export * from '../../internal-common/src/public-types/context.public-types';
14
14
  export * from '../../internal-common/src/public-types/document.public-types';
15
+ export * from '../../internal-common/src/public-types/external-auth/external-auth.public-types';
15
16
  export * from '../../internal-common/src/public-types/extraction.public-types';
16
17
  export * from '../../internal-common/src/public-types/http-status.public-types';
17
18
  export * from '../../internal-common/src/public-types/integration.public-types';
@@ -5,6 +5,7 @@ import { CollectionReference } from './collection-reference';
5
5
  import { ConnectionDetails } from './connection-details';
6
6
  import { DistributedLock } from './distributed-lock.manager';
7
7
  import { ExecuteFunctionOptions } from './execute-function-options';
8
+ import { ExternalAuthClient } from './external-auth-client';
8
9
  import { ExtractionClient } from './extraction-client';
9
10
  import { JobClient } from './job-client';
10
11
  import { NotificationClient } from './notification-client';
@@ -330,6 +331,15 @@ export declare class Squid {
330
331
  * @param integrationId The storage integration ID to use.
331
332
  */
332
333
  personalStorage(integrationId: IntegrationId): PersonalStorageClient;
334
+ /**
335
+ * Returns a client for managing external oauth tokens for integrations.
336
+ * Use this to save authorization codes and retrieve access tokens.
337
+ * Squid automatically handles token refresh when tokens expire.
338
+ *
339
+ * @param integrationId The integration ID
340
+ * @returns An ExternalAuthClient instance for the specified integration
341
+ */
342
+ externalAuth(integrationId: IntegrationId): ExternalAuthClient;
333
343
  /**
334
344
  * Returns a client for working with structured data extraction tools.
335
345
  */
@@ -2,4 +2,4 @@
2
2
  * The current version of the SquidCloud client package.
3
3
  * @category Platform
4
4
  */
5
- export declare const SQUIDCLOUD_CLIENT_PACKAGE_VERSION = "1.0.414";
5
+ export declare const SQUIDCLOUD_CLIENT_PACKAGE_VERSION = "1.0.416";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.414",
3
+ "version": "1.0.416",
4
4
  "description": "A typescript implementation of the Squid client",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",