@squidcloud/client 1.0.131 → 1.0.133

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 CHANGED
@@ -26802,7 +26802,7 @@ const AiAssistantMutateRequestSchema = {
26802
26802
  properties: {
26803
26803
  modelName: {
26804
26804
  type: 'string',
26805
- enum: ['gpt-3.5-turbo', 'gpt-4', 'claude-2'],
26805
+ enum: ['gpt-3.5-turbo', 'gpt-4', 'claude-2', 'gpt-4-1106-preview'],
26806
26806
  },
26807
26807
  strictContext: {
26808
26808
  type: 'boolean',
@@ -26856,7 +26856,7 @@ const AiAssistantMutateRequestSchema = {
26856
26856
  properties: {
26857
26857
  modelName: {
26858
26858
  type: 'string',
26859
- enum: ['gpt-3.5-turbo', 'gpt-4', 'claude-2'],
26859
+ enum: ['gpt-3.5-turbo', 'gpt-4', 'claude-2', 'gpt-4-1106-preview'],
26860
26860
  },
26861
26861
  strictContext: {
26862
26862
  type: 'boolean',
@@ -26955,6 +26955,9 @@ const AiModelData = {
26955
26955
  'claude-2': {
26956
26956
  tokens: 100000,
26957
26957
  },
26958
+ 'gpt-4-1106-preview': {
26959
+ tokens: 8192,
26960
+ },
26958
26961
  };
26959
26962
 
26960
26963
  ;// CONCATENATED MODULE: ../common/src/integrations/observability.types.ts
@@ -30692,6 +30695,7 @@ function createWebSocketWrapper(url, opts = {}) {
30692
30695
 
30693
30696
 
30694
30697
 
30698
+
30695
30699
 
30696
30700
 
30697
30701
 
@@ -49213,10 +49217,6 @@ class RpcManager {
49213
49217
  for (const [key, value] of Object.entries(headers)) {
49214
49218
  this.setStaticHeader(key, value);
49215
49219
  }
49216
- const apiKey = this.authManager.getApiKey();
49217
- if (apiKey) {
49218
- this.setStaticHeader('Authorization', `ApiKey ${apiKey}`);
49219
- }
49220
49220
  this.clientIdService.observeClientId().subscribe(clientId => {
49221
49221
  if (clientId) {
49222
49222
  this.setStaticHeader('x-squid-clientid', clientId);
@@ -49228,6 +49228,7 @@ class RpcManager {
49228
49228
  destructManager.onDestruct(async () => {
49229
49229
  await this.awaitAllSettled();
49230
49230
  });
49231
+ const apiKey = this.authManager.getApiKey();
49231
49232
  const rateLimiterMultiplier = apiKey ? 5 : 1;
49232
49233
  this.rateLimiters = {
49233
49234
  default: new RateLimiter(60 * rateLimiterMultiplier, 5),
@@ -49236,6 +49237,10 @@ class RpcManager {
49236
49237
  };
49237
49238
  }
49238
49239
  async getAuthHeaders() {
49240
+ const apiKey = this.authManager.getApiKey();
49241
+ if (apiKey) {
49242
+ return { Authorization: `ApiKey ${apiKey}` };
49243
+ }
49239
49244
  const { token, integrationId } = await this.authManager.getAuthData();
49240
49245
  if (!token)
49241
49246
  return {};
@@ -49835,6 +49840,30 @@ class Squid {
49835
49840
  this.executeNativeRelationalQuery = (integrationId, query, params = {}) => {
49836
49841
  return this.nativeQueryManager.executeNativeQuery(integrationId, { type: 'relational', query, params });
49837
49842
  };
49843
+ /**
49844
+ * Executes a native MongoDB aggregation pipeline with the given parameters and returns a promise with the result.
49845
+ *
49846
+ * Native queries allow you to execute raw MongoDB queries directly against the database.
49847
+ * This can be particularly useful when you need to perform complex operations or aggregations that are not
49848
+ * easily accomplished with standard query methods or other high-level abstractions provided by the database driver or ORM.
49849
+ *
49850
+ * @param {IntegrationId} integrationId - The id of the integration that the query is associated with.
49851
+ * @param {string} collectionName - The name of the MongoDB collection to run the aggregation pipeline against.
49852
+ * @param {Array<Record<string, any>>} [aggregationPipeline=[]] - The array of aggregation stages to be executed.
49853
+ * Each stage in the pipeline is an object specifying the operation to be performed.
49854
+ * @returns {Promise<Array<T>>} A promise that resolves with an array of documents resulting from the aggregation pipeline.
49855
+ * Each document in the array is of the generic type T, which can be specified when calling the function.
49856
+ * @template T - The type of the documents that are expected to be returned by the aggregation pipeline. If not specified,
49857
+ * any type is assumed by default.
49858
+ * @type {Promise<Array<SquidDocument>>}
49859
+ */
49860
+ this.executeNativeMongoQuery = (integrationId, collectionName, aggregationPipeline = []) => {
49861
+ return this.nativeQueryManager.executeNativeQuery(integrationId, {
49862
+ type: 'mongo',
49863
+ collectionName,
49864
+ aggregationPipeline,
49865
+ });
49866
+ };
49838
49867
  /**
49839
49868
  * Invokes the given HTTP API (defined by the integration ID and the endpoint ID) with the given request parameters
49840
49869
  * and returns a promise with the response. The structure of the request and the response is defined in the
@@ -1,5 +1,5 @@
1
1
  /** The supported AI model names. */
2
- export type AiModelName = 'gpt-3.5-turbo' | 'gpt-4' | 'claude-2';
2
+ export type AiModelName = 'gpt-3.5-turbo' | 'gpt-4' | 'claude-2' | 'gpt-4-1106-preview';
3
3
  export type AiAssistantContextType = 'text' | 'url' | 'file';
4
4
  export interface AiAssistantTextContext {
5
5
  type: 'text';
@@ -26,6 +26,7 @@ export * from './named-query.context';
26
26
  export * from './named-query.schemas';
27
27
  export * from './named-query.types';
28
28
  export * from './native-query.context';
29
+ export * from './native-query.types';
29
30
  export * from './query';
30
31
  export * from './query.types';
31
32
  export * from './regions';
@@ -118,7 +118,7 @@ export type ObservabilityIntegrationType = (typeof ObservabilityIntegrationTypes
118
118
  export type ObservabilityIntegrationConfig = IntegrationConfigTypes[ObservabilityIntegrationType];
119
119
  export type AuthIntegrationType = (typeof AuthIntegrationTypes)[number];
120
120
  export type AuthIntegrationConfig = IntegrationConfigTypes[AuthIntegrationType];
121
- export declare function isDataIntegrationType(type: IntegrationType): type is DatabaseIntegrationType;
121
+ export declare function isDataIntegrationType(type: unknown): type is DatabaseIntegrationType;
122
122
  export declare function isDataIntegration(integration: any): integration is BaseDatabaseIntegrationConfig;
123
123
  export declare function isAuthIntegrationType(type: IntegrationType): type is AuthIntegrationType;
124
124
  export declare function isAuthIntegration(integration: any): integration is AuthIntegrationConfig;
@@ -0,0 +1,16 @@
1
+ export type NativeQueryRequestType = 'relational' | 'mongo';
2
+ interface BaseNativeQueryRequest {
3
+ type: NativeQueryRequestType;
4
+ }
5
+ export interface RelationalNativeQueryRequest extends BaseNativeQueryRequest {
6
+ type: 'relational';
7
+ query: string;
8
+ params: Record<string, any>;
9
+ }
10
+ export interface MongoNativeQueryRequest extends BaseNativeQueryRequest {
11
+ type: 'mongo';
12
+ collectionName: string;
13
+ aggregationPipeline: Array<any | undefined>;
14
+ }
15
+ export type NativeQueryRequest = RelationalNativeQueryRequest | MongoNativeQueryRequest;
16
+ export {};
@@ -5,5 +5,6 @@ export interface ExecuteAiQueryRequest {
5
5
  }
6
6
  export interface ExecuteAiQueryResponse {
7
7
  answer: string;
8
+ explanation?: string;
8
9
  executedQuery?: string;
9
10
  }
@@ -1,18 +1,7 @@
1
- import { IntegrationId } from '@squidcloud/common';
1
+ import { IntegrationId, NativeQueryRequest } from '@squidcloud/common';
2
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
3
  export declare class NativeQueryManager {
14
4
  private readonly rpcManager;
15
5
  constructor(rpcManager: RpcManager);
16
6
  executeNativeQuery<T>(integrationId: IntegrationId, request: NativeQueryRequest): Promise<T>;
17
7
  }
18
- export {};
@@ -193,6 +193,24 @@ export declare class Squid {
193
193
  * @type {Promise<Array<SquidDocument>>}
194
194
  */
195
195
  executeNativeRelationalQuery: <T = any>(integrationId: IntegrationId, query: string, params?: Record<string, any>) => Promise<T[]>;
196
+ /**
197
+ * Executes a native MongoDB aggregation pipeline with the given parameters and returns a promise with the result.
198
+ *
199
+ * Native queries allow you to execute raw MongoDB queries directly against the database.
200
+ * This can be particularly useful when you need to perform complex operations or aggregations that are not
201
+ * easily accomplished with standard query methods or other high-level abstractions provided by the database driver or ORM.
202
+ *
203
+ * @param {IntegrationId} integrationId - The id of the integration that the query is associated with.
204
+ * @param {string} collectionName - The name of the MongoDB collection to run the aggregation pipeline against.
205
+ * @param {Array<Record<string, any>>} [aggregationPipeline=[]] - The array of aggregation stages to be executed.
206
+ * Each stage in the pipeline is an object specifying the operation to be performed.
207
+ * @returns {Promise<Array<T>>} A promise that resolves with an array of documents resulting from the aggregation pipeline.
208
+ * Each document in the array is of the generic type T, which can be specified when calling the function.
209
+ * @template T - The type of the documents that are expected to be returned by the aggregation pipeline. If not specified,
210
+ * any type is assumed by default.
211
+ * @type {Promise<Array<SquidDocument>>}
212
+ */
213
+ executeNativeMongoQuery: <T = any>(integrationId: IntegrationId, collectionName: string, aggregationPipeline?: Array<Record<string, any>>) => Promise<T[]>;
196
214
  /**
197
215
  * Invokes the given HTTP API (defined by the integration ID and the endpoint ID) with the given request parameters
198
216
  * and returns a promise with the response. The structure of the request and the response is defined in the
@@ -233,6 +251,30 @@ export declare class Squid {
233
251
  * @returns An AI Assistant client.
234
252
  */
235
253
  assistant: (integrationId: IntegrationId) => AiAssistantClient;
254
+ /**
255
+ * Executes an AI query using a specific DB integration, sending a prompt to the AI and returning its response.
256
+ * This function allows for direct interaction with the AI's capabilities by sending text prompts and receiving
257
+ * the AI's responses, which can be used for various applications such as automating tasks, generating content,
258
+ * or obtaining information.
259
+ *
260
+ * @param integrationId The identifier for the DB integration which is used to direct the query to the
261
+ * appropriate DB.
262
+ * @param prompt The text prompt to send to the AI. This should be formulated in a way that the AI can
263
+ * understand and respond to, taking into account the nature of the task or the information
264
+ * sought.
265
+ * @returns A promise that resolves to an `ExecuteAiQueryResponse`. This response includes the AI's
266
+ * reply to the provided prompt, along with any other relevant information that is part of
267
+ * the AI's response. The promise can be awaited to handle the response asynchronously.
268
+ *
269
+ * @example
270
+ * ```
271
+ * const response = await ai().executeAiQuery(myDbIntegrationId, "How many transactions ran yesterday?");
272
+ * console.log(response);
273
+ * ```
274
+ *
275
+ * For more details on the usage and capabilities of the AI Assistant, refer to the documentation provided at
276
+ * {@link https://docs.squid.cloud/docs/ai}.
277
+ */
236
278
  executeAiQuery: (integrationId: IntegrationId, prompt: string) => Promise<ExecuteAiQueryResponse>;
237
279
  };
238
280
  get secrets(): SecretClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.131",
3
+ "version": "1.0.133",
4
4
  "description": "A typescript implementation of the Squid client",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/typescript-client/src/index.d.ts",
@@ -49,11 +49,7 @@
49
49
  "assertic": "^1.0.0",
50
50
  "copy-webpack-plugin": "^11.0.0",
51
51
  "cpx": "^1.5.0",
52
- "eslint": "8.22.0",
53
- "eslint-config-prettier": "^8.3.0",
54
- "eslint-plugin-prettier": "^4.0.0",
55
52
  "generate-package-json-webpack-plugin": "^2.6.0",
56
- "prettier": "^2.8.0",
57
53
  "tsconfig-paths-webpack-plugin": "^4.0.0",
58
54
  "tscpaths": "^0.0.9",
59
55
  "webpack": "^5.75.0",