@squidcloud/client 1.0.128 → 1.0.130
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/cjs/index.js +474 -227
- package/dist/common/src/bundle-api.types.d.ts +3 -0
- package/dist/common/src/index.d.ts +1 -0
- package/dist/common/src/integrations/database.types.d.ts +28 -2
- package/dist/common/src/integrations/index.d.ts +4 -2
- package/dist/common/src/native-query.context.d.ts +7 -0
- package/dist/typescript-client/src/ai.types.d.ts +9 -0
- package/dist/typescript-client/src/auth.manager.d.ts +27 -13
- package/dist/typescript-client/src/named-query.manager.d.ts +1 -2
- package/dist/typescript-client/src/native-query-manager.d.ts +18 -0
- package/dist/typescript-client/src/rpc.manager.d.ts +1 -1
- package/dist/typescript-client/src/socket.manager.d.ts +9 -1
- package/dist/typescript-client/src/squid.d.ts +42 -6
- package/package.json +1 -1
|
@@ -10,9 +10,11 @@ import { DistributedLockContext } from './distributed-lock.context';
|
|
|
10
10
|
import { AiAssistantChatContext, AiAssistantMutationContext } from './ai-assistant.context';
|
|
11
11
|
import { ClientId } from './communication.types';
|
|
12
12
|
import { ClientConnectionState } from './socket.types';
|
|
13
|
+
import { NativeQueryContext } from './native-query.context';
|
|
13
14
|
export type SecureDatabaseAction<T extends DatabaseActionType> = T extends 'all' ? () => boolean | Promise<boolean> : T extends 'read' ? ((context: QueryContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>) : ((context: MutationContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
|
|
14
15
|
export type SecureApiAction = ((context: ApiCallContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
|
|
15
16
|
export type SecureNamedQueryAction = ((context: NamedQueryContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
|
|
17
|
+
export type SecureNativeQueryAction = ((context: NativeQueryContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
|
|
16
18
|
export type SecureDistributedLockAction = ((context: DistributedLockContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
|
|
17
19
|
export type SecureGraphQLAction = ((context: GraphqlContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
|
|
18
20
|
export type SecureAiAssistantAction<T extends AiAssistantActionType> = T extends 'all' ? () => boolean | Promise<boolean> : T extends 'chat' ? ((context: AiAssistantChatContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>) : ((context: AiAssistantMutationContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
|
|
@@ -31,6 +33,7 @@ export type WebhookAction = ((request: WebhookRequest) => any) | (() => any);
|
|
|
31
33
|
/** The context provided to a webhook function. */
|
|
32
34
|
export interface WebhookRequest {
|
|
33
35
|
body: any;
|
|
36
|
+
rawBody?: string;
|
|
34
37
|
queryParams: Record<string, string>;
|
|
35
38
|
headers: Record<string, string>;
|
|
36
39
|
httpMethod: 'post' | 'get' | 'put' | 'delete';
|
|
@@ -25,6 +25,7 @@ export * from './mutation.types';
|
|
|
25
25
|
export * from './named-query.context';
|
|
26
26
|
export * from './named-query.schemas';
|
|
27
27
|
export * from './named-query.types';
|
|
28
|
+
export * from './native-query.context';
|
|
28
29
|
export * from './query';
|
|
29
30
|
export * from './query.types';
|
|
30
31
|
export * from './regions';
|
|
@@ -23,6 +23,9 @@ export interface MongoConnectionOptions {
|
|
|
23
23
|
export interface MySqlConnectionSecretOptions {
|
|
24
24
|
password: string;
|
|
25
25
|
}
|
|
26
|
+
export interface BigQueryConnectionSecretOptions {
|
|
27
|
+
privateKey: string;
|
|
28
|
+
}
|
|
26
29
|
export interface OracleConnectionSecretOptions {
|
|
27
30
|
password: string;
|
|
28
31
|
}
|
|
@@ -44,6 +47,12 @@ export interface MySqlConnectionOptions {
|
|
|
44
47
|
connectionLimit?: number;
|
|
45
48
|
sslEnabled?: boolean;
|
|
46
49
|
}
|
|
50
|
+
export interface BigQueryConnectionOptions {
|
|
51
|
+
secrets: BigQueryConnectionSecretOptions;
|
|
52
|
+
projectId: string;
|
|
53
|
+
datasetId: string;
|
|
54
|
+
email: string;
|
|
55
|
+
}
|
|
47
56
|
export interface OracleConnectionOptions {
|
|
48
57
|
secrets: OracleConnectionSecretOptions;
|
|
49
58
|
host: string;
|
|
@@ -99,6 +108,9 @@ export interface BaseDatabaseIntegrationConfig extends BaseIntegrationConfig {
|
|
|
99
108
|
export interface MySqlIntegrationConfiguration {
|
|
100
109
|
connectionOptions: MySqlConnectionOptions;
|
|
101
110
|
}
|
|
111
|
+
export interface BigQueryIntegrationConfiguration {
|
|
112
|
+
connectionOptions: BigQueryConnectionOptions;
|
|
113
|
+
}
|
|
102
114
|
export interface OracleIntegrationConfiguration {
|
|
103
115
|
connectionOptions: OracleConnectionOptions;
|
|
104
116
|
}
|
|
@@ -121,6 +133,10 @@ export interface MySqlIntegrationConfig extends BaseDatabaseIntegrationConfig {
|
|
|
121
133
|
type: IntegrationType.mysql;
|
|
122
134
|
configuration: MySqlIntegrationConfiguration;
|
|
123
135
|
}
|
|
136
|
+
export interface BigQueryIntegrationConfig extends BaseDatabaseIntegrationConfig {
|
|
137
|
+
type: IntegrationType.bigquery;
|
|
138
|
+
configuration: BigQueryIntegrationConfiguration;
|
|
139
|
+
}
|
|
124
140
|
export interface OracleIntegrationConfig extends BaseDatabaseIntegrationConfig {
|
|
125
141
|
type: IntegrationType.oracledb;
|
|
126
142
|
configuration: OracleIntegrationConfiguration;
|
|
@@ -168,6 +184,12 @@ interface TestMysqlDataConnectionRequest {
|
|
|
168
184
|
connectionOptions: MySqlConnectionOptions;
|
|
169
185
|
};
|
|
170
186
|
}
|
|
187
|
+
interface TestBigQueryDataConnectionRequest {
|
|
188
|
+
type: IntegrationType.bigquery;
|
|
189
|
+
configuration: {
|
|
190
|
+
connectionOptions: BigQueryConnectionOptions;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
171
193
|
interface TestOracleDataConnectionRequest {
|
|
172
194
|
type: IntegrationType.oracledb;
|
|
173
195
|
configuration: {
|
|
@@ -198,7 +220,7 @@ interface TestCockroachDataConnectionRequest {
|
|
|
198
220
|
connectionOptions: PostgresConnectionOptions;
|
|
199
221
|
};
|
|
200
222
|
}
|
|
201
|
-
export type TestDataConnectionRequest = TestMongoDataConnectionRequest | TestMysqlDataConnectionRequest | TestOracleDataConnectionRequest | TestMssqlDataConnectionRequest | TestCockroachDataConnectionRequest | TestPostgresDataConnectionRequest | TestSnowflakeDataConnectionRequest;
|
|
223
|
+
export type TestDataConnectionRequest = TestMongoDataConnectionRequest | TestMysqlDataConnectionRequest | TestBigQueryDataConnectionRequest | TestOracleDataConnectionRequest | TestMssqlDataConnectionRequest | TestCockroachDataConnectionRequest | TestPostgresDataConnectionRequest | TestSnowflakeDataConnectionRequest;
|
|
202
224
|
export interface CollectionReadiness {
|
|
203
225
|
hasPermissions: boolean;
|
|
204
226
|
grantPermissionsCommands: string[];
|
|
@@ -220,6 +242,10 @@ interface DiscoverMysqlDataConnectionSchemaRequest {
|
|
|
220
242
|
integrationType: IntegrationType.mysql;
|
|
221
243
|
connectionOptions: MySqlConnectionOptions;
|
|
222
244
|
}
|
|
245
|
+
interface DiscoverBigQueryDataConnectionSchemaRequest {
|
|
246
|
+
integrationType: IntegrationType.bigquery;
|
|
247
|
+
connectionOptions: BigQueryConnectionOptions;
|
|
248
|
+
}
|
|
223
249
|
interface DiscoverOracleDataConnectionSchemaRequest {
|
|
224
250
|
integrationType: IntegrationType.oracledb;
|
|
225
251
|
connectionOptions: OracleConnectionOptions;
|
|
@@ -244,5 +270,5 @@ export interface TestDataConnectionResponse {
|
|
|
244
270
|
success: boolean;
|
|
245
271
|
errorMessage?: string;
|
|
246
272
|
}
|
|
247
|
-
export type DiscoverDataConnectionSchemaRequest = DiscoverMongoDataConnectionSchemaRequest | DiscoverInternalDataConnectionSchemaRequest | DiscoverMysqlDataConnectionSchemaRequest | DiscoverOracleDataConnectionSchemaRequest | DiscoverMssqlDataConnectionSchemaRequest | DiscoverCockroachDataConnectionSchemaRequest | DiscoverPostgresDataConnectionSchemaRequest | DiscoverSnowflakeDataConnectionSchemaRequest;
|
|
273
|
+
export type DiscoverDataConnectionSchemaRequest = DiscoverMongoDataConnectionSchemaRequest | DiscoverInternalDataConnectionSchemaRequest | DiscoverMysqlDataConnectionSchemaRequest | DiscoverBigQueryDataConnectionSchemaRequest | DiscoverOracleDataConnectionSchemaRequest | DiscoverMssqlDataConnectionSchemaRequest | DiscoverCockroachDataConnectionSchemaRequest | DiscoverPostgresDataConnectionSchemaRequest | DiscoverSnowflakeDataConnectionSchemaRequest;
|
|
248
274
|
export {};
|
|
@@ -7,7 +7,7 @@ import { IntegrationId } from '../communication.types';
|
|
|
7
7
|
import { AiAssistantIntegrationConfig } from './ai_assistant.types';
|
|
8
8
|
import { GraphQLIntegrationConfig, HttpApiIntegrationConfig, IntegrationApiSchema, IntegrationGraphQLSchema, TestGraphQLDataConnectionRequest } from './api.types';
|
|
9
9
|
import { Auth0IntegrationConfig, CognitoIntegrationConfig, JwtHmacIntegrationConfig, JwtRsaIntegrationConfig, OktaIntegrationConfig } from './auth.types';
|
|
10
|
-
import { BaseDatabaseIntegrationConfig, CockroachIntegrationConfig, IntegrationDataSchema, InternalIntegrationConfig, MongoIntegrationConfig, MssqlIntegrationConfig, MySqlIntegrationConfig, OracleIntegrationConfig, PinotIntegrationConfig, PostgresIntegrationConfig, SnowflakeIntegrationConfig, TestDataConnectionRequest } from './database.types';
|
|
10
|
+
import { BaseDatabaseIntegrationConfig, BigQueryIntegrationConfig, CockroachIntegrationConfig, IntegrationDataSchema, InternalIntegrationConfig, MongoIntegrationConfig, MssqlIntegrationConfig, MySqlIntegrationConfig, OracleIntegrationConfig, PinotIntegrationConfig, PostgresIntegrationConfig, SnowflakeIntegrationConfig, TestDataConnectionRequest } from './database.types';
|
|
11
11
|
import { DatadogIntegrationConfig, NewRelicIntegrationConfig } from './observability.types';
|
|
12
12
|
export declare enum IntegrationCategory {
|
|
13
13
|
'database' = "database",
|
|
@@ -70,6 +70,7 @@ export interface IntegrationConfigTypes {
|
|
|
70
70
|
[IntegrationType.built_in_db]: InternalIntegrationConfig;
|
|
71
71
|
[IntegrationType.mongo]: MongoIntegrationConfig;
|
|
72
72
|
[IntegrationType.mysql]: MySqlIntegrationConfig;
|
|
73
|
+
[IntegrationType.bigquery]: BigQueryIntegrationConfig;
|
|
73
74
|
[IntegrationType.oracledb]: OracleIntegrationConfig;
|
|
74
75
|
[IntegrationType.pinot]: PinotIntegrationConfig;
|
|
75
76
|
[IntegrationType.mssql]: MssqlIntegrationConfig;
|
|
@@ -92,6 +93,7 @@ export interface IntegrationSchemaTypes {
|
|
|
92
93
|
[IntegrationType.mongo]: IntegrationDataSchema;
|
|
93
94
|
[IntegrationType.mysql]: IntegrationDataSchema;
|
|
94
95
|
[IntegrationType.oracledb]: IntegrationDataSchema;
|
|
96
|
+
[IntegrationType.bigquery]: IntegrationDataSchema;
|
|
95
97
|
[IntegrationType.pinot]: IntegrationDataSchema;
|
|
96
98
|
[IntegrationType.mssql]: IntegrationDataSchema;
|
|
97
99
|
[IntegrationType.postgres]: IntegrationDataSchema;
|
|
@@ -104,7 +106,7 @@ export type IntegrationTypeWithConfig = keyof IntegrationConfigTypes;
|
|
|
104
106
|
export type IntegrationSchemaKeys = keyof IntegrationSchemaTypes;
|
|
105
107
|
export type IntegrationConfig = IntegrationConfigTypes[IntegrationTypeWithConfig];
|
|
106
108
|
export type IntegrationSchema = IntegrationSchemaTypes[IntegrationSchemaKeys];
|
|
107
|
-
export declare const DatabaseIntegrationTypes: readonly [IntegrationType.built_in_db, IntegrationType.mongo, IntegrationType.mysql, IntegrationType.mssql, IntegrationType.postgres, IntegrationType.cockroach, IntegrationType.snowflake, IntegrationType.oracledb, IntegrationType.pinot];
|
|
109
|
+
export declare const DatabaseIntegrationTypes: readonly [IntegrationType.built_in_db, IntegrationType.mongo, IntegrationType.mysql, IntegrationType.bigquery, IntegrationType.mssql, IntegrationType.postgres, IntegrationType.cockroach, IntegrationType.snowflake, IntegrationType.oracledb, IntegrationType.pinot];
|
|
108
110
|
export type DatabaseIntegrationType = (typeof DatabaseIntegrationTypes)[number];
|
|
109
111
|
export type DatabaseIntegrationConfig = IntegrationConfigTypes[DatabaseIntegrationType];
|
|
110
112
|
export declare const ApiIntegrationTypes: readonly [IntegrationType.api, IntegrationType.graphql];
|
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
import { ApiKey, AuthToken, IntegrationId } from '@squidcloud/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { AuthTokenProvider } from './squid';
|
|
4
|
+
export interface AuthData {
|
|
5
5
|
token: string | undefined;
|
|
6
6
|
integrationId?: IntegrationId;
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
8
|
export declare class AuthManager {
|
|
9
|
-
private readonly destructManager;
|
|
10
9
|
private readonly apiKey;
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
private authDataProvider;
|
|
11
|
+
constructor(apiKey: ApiKey | undefined, authTokenProvider?: AuthTokenProvider);
|
|
12
|
+
/**
|
|
13
|
+
* Last used ID or Access token. Used for compatibility with the old Squid code
|
|
14
|
+
* and will be removed when `getAuthToken(): AuthToken | undefined {` is removed.
|
|
15
|
+
*/
|
|
16
|
+
private lastUsedJwtTokenForDeprecatedCode;
|
|
17
|
+
private lastUsedIntegrationIdForDeprecatedCode;
|
|
18
|
+
/**
|
|
19
|
+
* Sets a new ID token or an ID token provider.
|
|
20
|
+
* Deprecated. Pass the provider via constructor parameters.
|
|
21
|
+
*/
|
|
22
|
+
setAuthIdToken(tokenArg: string | undefined | Promise<string | undefined> | Observable<string | undefined> | AuthTokenProvider, integrationId?: IntegrationId): void;
|
|
23
|
+
private setAuthTokenProvider;
|
|
24
|
+
getAuthData(): Promise<AuthData>;
|
|
25
|
+
/**
|
|
26
|
+
* Returns an observable over AuthData.
|
|
27
|
+
* Deprecated: the method will be removed soon. Use getAuthData().
|
|
28
|
+
*/
|
|
18
29
|
observeAuthIdToken(): Observable<AuthData>;
|
|
19
|
-
waitForReadyState(): Promise<void>;
|
|
20
30
|
getApiKey(): ApiKey | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the last used Auth token.
|
|
33
|
+
* Deprecated. Use: `getToken()` instead.
|
|
34
|
+
*/
|
|
21
35
|
getAuthToken(): AuthToken | undefined;
|
|
36
|
+
getToken(): Promise<AuthToken | undefined>;
|
|
22
37
|
}
|
|
23
|
-
export {};
|
|
@@ -4,9 +4,8 @@ import { RpcManager } from './rpc.manager';
|
|
|
4
4
|
import { SocketManager } from './socket.manager';
|
|
5
5
|
export declare class NamedQueryManager {
|
|
6
6
|
private readonly rpcManager;
|
|
7
|
-
private readonly socketManager;
|
|
8
7
|
private readonly ongoingNamedQueryExecutions;
|
|
9
8
|
constructor(rpcManager: RpcManager, socketManager: SocketManager);
|
|
10
|
-
executeNamedQueryAndSubscribe<T>(integrationId: IntegrationId, queryName: QueryName, params: Record<string, any>): Observable<T
|
|
9
|
+
executeNamedQueryAndSubscribe<T>(integrationId: IntegrationId, queryName: QueryName, params: Record<string, any>): Observable<Array<T>>;
|
|
11
10
|
private handleNamedQueryResponse;
|
|
12
11
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IntegrationId } from '@squidcloud/common';
|
|
2
|
+
import { RpcManager } from './rpc.manager';
|
|
3
|
+
export type NativeQueryRequestType = 'relational';
|
|
4
|
+
interface BaseNativeQueryRequest {
|
|
5
|
+
type: NativeQueryRequestType;
|
|
6
|
+
}
|
|
7
|
+
export interface RelationalNativeQueryRequest extends BaseNativeQueryRequest {
|
|
8
|
+
type: 'relational';
|
|
9
|
+
query: string;
|
|
10
|
+
params: Record<string, any>;
|
|
11
|
+
}
|
|
12
|
+
export type NativeQueryRequest = RelationalNativeQueryRequest;
|
|
13
|
+
export declare class NativeQueryManager {
|
|
14
|
+
private readonly rpcManager;
|
|
15
|
+
constructor(rpcManager: RpcManager);
|
|
16
|
+
executeNativeQuery<T>(integrationId: IntegrationId, request: NativeQueryRequest): Promise<T>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -11,11 +11,11 @@ export declare class RpcManager {
|
|
|
11
11
|
private readonly onGoingRpcCounter;
|
|
12
12
|
private readonly rateLimiters;
|
|
13
13
|
constructor(region: SupportedSquidRegion, appId: string, destructManager: DestructManager, headers: Record<string, string> | undefined, authManager: AuthManager, clientIdService: ClientIdService);
|
|
14
|
+
private getAuthHeaders;
|
|
14
15
|
awaitAllSettled(): Promise<void>;
|
|
15
16
|
setStaticHeader(key: string, value: string): void;
|
|
16
17
|
deleteStaticHeader(key: string): void;
|
|
17
18
|
getStaticHeaders(): Record<string, string>;
|
|
18
|
-
private ready;
|
|
19
19
|
post<T>(path: string, message: any, files?: File[]): Promise<T>;
|
|
20
20
|
private parseResponse;
|
|
21
21
|
private getRateLimiterBucket;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MessageFromClient, MessageToClient, SupportedSquidRegion } from '@squidcloud/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { DestructManager } from './destruct.manager';
|
|
4
3
|
import { AuthManager } from './auth.manager';
|
|
5
4
|
import { ClientIdService } from './client-id.service';
|
|
5
|
+
import { DestructManager } from './destruct.manager';
|
|
6
6
|
export declare class SocketManager {
|
|
7
7
|
private readonly clientIdService;
|
|
8
8
|
private readonly region;
|
|
@@ -16,6 +16,7 @@ export declare class SocketManager {
|
|
|
16
16
|
private readonly seenMessageIds;
|
|
17
17
|
private socket;
|
|
18
18
|
private destructSubject;
|
|
19
|
+
private lastTick;
|
|
19
20
|
/**
|
|
20
21
|
* On a client disconnecting, we wait for a bit to see if the client reconnects,
|
|
21
22
|
* if no reconnect happens within the timeout, we consider the client to be too old.
|
|
@@ -23,11 +24,18 @@ export declare class SocketManager {
|
|
|
23
24
|
* Note: we make this a function so that we can easily override it in tests.
|
|
24
25
|
*/
|
|
25
26
|
private clientTooOldThreshold;
|
|
27
|
+
private tickInterval;
|
|
26
28
|
constructor(clientIdService: ClientIdService, region: SupportedSquidRegion, appId: string, messageNotificationWrapper: (fn: () => any) => any, destructManager: DestructManager, authManager: AuthManager);
|
|
29
|
+
refreshClient(): void;
|
|
30
|
+
tick(): void;
|
|
27
31
|
observeNotifications<T extends MessageToClient>(): Observable<T>;
|
|
28
32
|
observeConnectionReady(): Observable<boolean>;
|
|
29
33
|
sendMessage(message: MessageFromClient): void;
|
|
34
|
+
private sendMessageAsync;
|
|
35
|
+
/** Sends 'kill' message ignoring 'connectionReady' observable. */
|
|
36
|
+
private sendKillMessage;
|
|
30
37
|
private connect;
|
|
38
|
+
disconnect(): void;
|
|
31
39
|
private onConnectionReady;
|
|
32
40
|
private onMessage;
|
|
33
41
|
private setupMessageAcknowledgments;
|
|
@@ -7,6 +7,7 @@ import { DistributedLock } from './distributed-lock.manager';
|
|
|
7
7
|
import { GraphQLClient } from './graphql-client';
|
|
8
8
|
import { SecretClient } from './secret.client';
|
|
9
9
|
import { TransactionId } from './types';
|
|
10
|
+
import { ExecuteAiQueryResponse } from './ai.types';
|
|
10
11
|
/** The different options that can be used to initialize a Squid instance. */
|
|
11
12
|
export interface SquidOptions {
|
|
12
13
|
/**
|
|
@@ -25,6 +26,17 @@ export interface SquidOptions {
|
|
|
25
26
|
* The API key can be found in the Squid Cloud Console.
|
|
26
27
|
*/
|
|
27
28
|
apiKey?: ApiKey;
|
|
29
|
+
/**
|
|
30
|
+
* Access token provider for the application.
|
|
31
|
+
* Used for managing the process of verifying the identity and authorization
|
|
32
|
+
* of users who attempt to access this application.
|
|
33
|
+
*
|
|
34
|
+
* When the authTokenProvider is set, the Squid service will fetch a token
|
|
35
|
+
* and include it with every request to the Squid backend.
|
|
36
|
+
*
|
|
37
|
+
* On the backend, Squid will validate the access token and extract the user details.
|
|
38
|
+
*/
|
|
39
|
+
authTokenProvider?: AuthTokenProvider;
|
|
28
40
|
/**
|
|
29
41
|
* The region that the application is running in. This is used to determine the URL of the Squid Cloud API.
|
|
30
42
|
*/
|
|
@@ -43,6 +55,11 @@ export interface SquidOptions {
|
|
|
43
55
|
*/
|
|
44
56
|
apiServerUrlOverrideMapping?: Record<IntegrationId, string>;
|
|
45
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* A function to retrieve a new and updated Access Token.
|
|
60
|
+
* Called by Squid every time a Squid client makes requests to the Squid backend.
|
|
61
|
+
*/
|
|
62
|
+
export type AuthTokenProvider = (integrationId?: string) => Promise<string | undefined>;
|
|
46
63
|
/**
|
|
47
64
|
* The main entry point to the Squid Client SDK.
|
|
48
65
|
*
|
|
@@ -63,6 +80,7 @@ export declare class Squid {
|
|
|
63
80
|
private readonly collectionReferenceFactory;
|
|
64
81
|
private readonly backendFunctionManager;
|
|
65
82
|
private readonly namedQueryManager;
|
|
83
|
+
private readonly nativeQueryManager;
|
|
66
84
|
private readonly apiManager;
|
|
67
85
|
private readonly graphqlClientFactory;
|
|
68
86
|
private readonly destructManager;
|
|
@@ -96,15 +114,18 @@ export declare class Squid {
|
|
|
96
114
|
*/
|
|
97
115
|
static getInstances(): Array<Squid>;
|
|
98
116
|
/**
|
|
99
|
-
* Sets the
|
|
100
|
-
* to the security rules.
|
|
117
|
+
* Sets the authorization access token (OAuth2.0) that will be sent to the server and will be used for providing the
|
|
118
|
+
* `auth` object to the security rules.
|
|
101
119
|
*
|
|
102
|
-
* @
|
|
103
|
-
*
|
|
120
|
+
* @deprecated: pass `AuthTokenProvider` in the constructor of the class.
|
|
121
|
+
*
|
|
122
|
+
* @param accessToken The OAuth2.0 access token or a promise that resolves with the access token.
|
|
123
|
+
* When undefined, no authorization information is sent.
|
|
124
|
+
* The Observable variant of the parameter is deprecated and will be removed soon.
|
|
104
125
|
* @param integrationId The id of the integration.
|
|
105
126
|
* @returns void
|
|
106
127
|
*/
|
|
107
|
-
setAuthIdToken: (
|
|
128
|
+
setAuthIdToken: (accessToken: string | undefined | Promise<string | undefined> | Observable<string | undefined> | AuthTokenProvider, integrationId?: IntegrationId) => void;
|
|
108
129
|
/**
|
|
109
130
|
* Returns a reference to the collection in the provided integration.
|
|
110
131
|
*
|
|
@@ -156,7 +177,21 @@ export declare class Squid {
|
|
|
156
177
|
* @returns A promise that resolves with the result of the named query.
|
|
157
178
|
* @typeParam T The type of the result of the named query.
|
|
158
179
|
*/
|
|
159
|
-
executeNamedQuery: <T = any>(integrationId: IntegrationId, queryName: QueryName, params: Record<string, any>) => Promise<T>;
|
|
180
|
+
executeNamedQuery: <T = any>(integrationId: IntegrationId, queryName: QueryName, params: Record<string, any>) => Promise<T[]>;
|
|
181
|
+
/**
|
|
182
|
+
* Executes a native relational query with the given parameters and returns a promise with the result.
|
|
183
|
+
*
|
|
184
|
+
* Native queries allow you to execute raw SQL or other database-specific queries directly against the database.
|
|
185
|
+
* This can be useful when you need to perform operations that are not easily accomplished with named queries or
|
|
186
|
+
* other high-level abstractions.
|
|
187
|
+
*
|
|
188
|
+
* @param integrationId The id of the integration that the query is associated with.
|
|
189
|
+
* @param query The raw SQL or other database-specific query to execute.
|
|
190
|
+
* @param params (Optional) The parameters to pass to the query. Defaults to an empty object.
|
|
191
|
+
* @returns A promise that resolves with the result of the query.
|
|
192
|
+
* @type {Promise<Array<SquidDocument>>}
|
|
193
|
+
*/
|
|
194
|
+
executeNativeRelationalQuery: <T = any>(integrationId: IntegrationId, query: string, params?: Record<string, any>) => Promise<T[]>;
|
|
160
195
|
/**
|
|
161
196
|
* Invokes the given HTTP API (defined by the integration ID and the endpoint ID) with the given request parameters
|
|
162
197
|
* and returns a promise with the response. The structure of the request and the response is defined in the
|
|
@@ -197,6 +232,7 @@ export declare class Squid {
|
|
|
197
232
|
* @returns An AI Assistant client.
|
|
198
233
|
*/
|
|
199
234
|
assistant: (integrationId: IntegrationId) => AiAssistantClient;
|
|
235
|
+
executeAiQuery: (integrationId: IntegrationId, prompt: string) => Promise<ExecuteAiQueryResponse>;
|
|
200
236
|
};
|
|
201
237
|
get secrets(): SecretClient;
|
|
202
238
|
/**
|