@squidcloud/client 1.0.412 → 1.0.414

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.
Files changed (48) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/esm/index.js +1 -1
  3. package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +20 -18
  4. package/dist/internal-common/src/public-types/ai-common.public-types.d.ts +8 -0
  5. package/dist/internal-common/src/public-types/integration.public-types.d.ts +2 -2
  6. package/dist/typescript-client/src/agent/ai-agent-client-reference.d.ts +19 -6
  7. package/dist/typescript-client/src/agent/ai-agent-client.d.ts +12 -1
  8. package/dist/typescript-client/src/ai-client.d.ts +2 -1
  9. package/dist/typescript-client/src/distributed-lock.manager.d.ts +6 -2
  10. package/dist/typescript-client/src/squid.d.ts +2 -0
  11. package/dist/typescript-client/src/version.d.ts +1 -1
  12. package/package.json +1 -1
  13. package/dist/internal-common/src/metric-name.d.ts +0 -9
  14. package/dist/internal-common/src/public-types-backend/api-call.public-context.d.ts +0 -30
  15. package/dist/internal-common/src/public-types-backend/mutation.public-context.d.ts +0 -148
  16. package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +0 -72
  17. package/dist/internal-common/src/public-types-backend/query.public-context.d.ts +0 -177
  18. package/dist/internal-common/src/types/ai-agent.types.d.ts +0 -168
  19. package/dist/internal-common/src/types/ai-assistant.types.d.ts +0 -1
  20. package/dist/internal-common/src/types/ai-knowledge-base.types.d.ts +0 -202
  21. package/dist/internal-common/src/types/ai-matchmaking.types.d.ts +0 -59
  22. package/dist/internal-common/src/types/backend-function.types.d.ts +0 -1
  23. package/dist/internal-common/src/types/communication.types.d.ts +0 -1
  24. package/dist/internal-common/src/types/document.types.d.ts +0 -1
  25. package/dist/internal-common/src/types/file.types.d.ts +0 -6
  26. package/dist/internal-common/src/types/headers.types.d.ts +0 -17
  27. package/dist/internal-common/src/types/mutation.types.d.ts +0 -1
  28. package/dist/internal-common/src/types/notification.types.d.ts +0 -5
  29. package/dist/internal-common/src/types/observability.types.d.ts +0 -78
  30. package/dist/internal-common/src/types/query.types.d.ts +0 -13
  31. package/dist/internal-common/src/types/secret.types.d.ts +0 -2
  32. package/dist/internal-common/src/types/socket.types.d.ts +0 -1
  33. package/dist/internal-common/src/types/stage.d.ts +0 -9
  34. package/dist/internal-common/src/types/time-units.d.ts +0 -1
  35. package/dist/internal-common/src/types/url-shortener.types.d.ts +0 -41
  36. package/dist/internal-common/src/utils/array.d.ts +0 -7
  37. package/dist/internal-common/src/utils/e2e-test-utils.d.ts +0 -2
  38. package/dist/internal-common/src/utils/global.utils.d.ts +0 -1
  39. package/dist/internal-common/src/utils/http.d.ts +0 -5
  40. package/dist/internal-common/src/utils/lock.manager.d.ts +0 -14
  41. package/dist/internal-common/src/utils/metric-utils.d.ts +0 -4
  42. package/dist/internal-common/src/utils/metrics.types.d.ts +0 -7
  43. package/dist/internal-common/src/utils/object.d.ts +0 -58
  44. package/dist/internal-common/src/utils/serialization.d.ts +0 -17
  45. package/dist/internal-common/src/utils/squid.constants.d.ts +0 -1
  46. package/dist/internal-common/src/utils/trace-id-generator.d.ts +0 -1
  47. package/dist/internal-common/src/utils/validation.d.ts +0 -19
  48. package/dist/internal-common/src/websocket.impl.d.ts +0 -26
@@ -269,6 +269,22 @@ export interface AiAgentMemoryOptions {
269
269
  */
270
270
  expirationMinutes?: number;
271
271
  }
272
+ /**
273
+ * Model specification for integration-based LLM providers like Ollama.
274
+ * @category AI
275
+ */
276
+ export interface IntegrationModelSpec {
277
+ /** The integration ID that provides the LLM */
278
+ integrationId: IntegrationId;
279
+ /** The model name within that integration */
280
+ model: string;
281
+ }
282
+ /**
283
+ * Type for specifying which LLM model to use.
284
+ * Can be either a vendor model name (string) or an integration-based model (object).
285
+ * @category AI
286
+ */
287
+ export type AiChatModelSelection = AiChatModelName | IntegrationModelSpec;
272
288
  /**
273
289
  * The base AI agent chat options, should not be used directly.
274
290
  * @category AI
@@ -329,8 +345,8 @@ export interface BaseAiChatOptions {
329
345
  temperature?: number;
330
346
  /** Preset instruction options that can be toggled on */
331
347
  guardrails?: GuardrailsOptions;
332
- /** The LLM model to use. */
333
- model?: AiChatModelName;
348
+ /** The LLM model to use. Can be a vendor model name (string) or an integration-based model (object). */
349
+ model?: AiChatModelSelection;
334
350
  /** Which provider's reranker to use for reranking the context. Defaults to 'cohere'. */
335
351
  rerankProvider?: AiRerankProvider;
336
352
  /**
@@ -441,6 +457,8 @@ export interface AiAgent<T extends AiChatModelName | undefined = undefined> {
441
457
  options: AiChatOptions<T>;
442
458
  /** The embedding model name used by the agent. */
443
459
  embeddingModelName: AiEmbeddingsModelName;
460
+ /** Optional api key used specifically for operations on this agent */
461
+ apiKey?: string;
444
462
  }
445
463
  /**
446
464
  * @category AI
@@ -496,22 +514,6 @@ export interface AiChatMessage {
496
514
  export declare const AI_STATUS_MESSAGE_PARENT_MESSAGE_ID_TAG = "parent";
497
515
  /** The tag contains a response of the AI tool call. */
498
516
  export declare const AI_STATUS_MESSAGE_RESULT_TAG = "result";
499
- /**
500
- * The options for the AI agent search method.
501
- * @category AI
502
- */
503
- export interface AiSearchOptions {
504
- /** The prompt to search for */
505
- prompt: string;
506
- /** DEPRECATED: A set of filters that will limit the context the AI can access. */
507
- contextMetadataFilter?: AiContextMetadataFilter;
508
- /** A set of filters that will limit the context the AI can access. */
509
- contextMetadataFilterForKnowledgeBase?: Record<AiKnowledgeBaseId, AiContextMetadataFilter>;
510
- /** The maximum number of results to return */
511
- limit?: number;
512
- /** Which provider's reranker to use for reranking the context. Defaults to 'cohere'. */
513
- rerankProvider?: AiRerankProvider;
514
- }
515
517
  /**
516
518
  * A single chunk of data returned from an AI search operation.
517
519
  * @category AI
@@ -170,3 +170,11 @@ export type StableDiffusionModelName = (typeof STABLE_DIFFUSION_MODEL_NAMES)[num
170
170
  * @category AI
171
171
  */
172
172
  export type FluxModelName = (typeof FLUX_MODEL_NAMES)[number];
173
+ /**
174
+ * Type guard to check if a model selection is integration-based.
175
+ * @category AI
176
+ */
177
+ export declare function isIntegrationModelSpec(model: unknown): model is {
178
+ integrationId: string;
179
+ model: string;
180
+ };
@@ -1,6 +1,6 @@
1
1
  import { IntegrationId } from './communication.public-types';
2
2
  /** List of all integration types supported by Squid. */
3
- export declare const INTEGRATION_TYPES: readonly ["active_directory", "ai_agents", "ai_chatbot", "algolia", "alloydb", "api", "auth0", "azure_cosmosdb", "azure_postgresql", "azure_sql", "bigquery", "built_in_db", "built_in_gcs", "built_in_queue", "built_in_s3", "cassandra", "clickhouse", "cloudsql", "cockroach", "cognito", "connected_knowledgebases", "confluence", "confluent", "datadog", "db2", "descope", "documentdb", "dynamodb", "elasticsearch", "firebase_auth", "firestore", "gcs", "google_calendar", "google_docs", "google_drive", "graphql", "hubspot", "jira", "jwt_hmac", "jwt_rsa", "kafka", "linear", "mariadb", "monday", "mongo", "mssql", "databricks", "mysql", "newrelic", "okta", "onedrive", "oracledb", "pinecone", "postgres", "redis", "s3", "salesforce_crm", "sap_hana", "sentry", "servicenow", "snowflake", "spanner", "xata", "zendesk", "mail", "slack", "mcp", "a2a", "legend"];
3
+ export declare const INTEGRATION_TYPES: readonly ["active_directory", "ai_agents", "ai_chatbot", "algolia", "alloydb", "api", "auth0", "azure_cosmosdb", "azure_postgresql", "azure_sql", "bigquery", "built_in_db", "built_in_gcs", "built_in_queue", "built_in_s3", "cassandra", "clickhouse", "cloudsql", "cockroach", "cognito", "connected_knowledgebases", "confluence", "confluent", "datadog", "db2", "descope", "documentdb", "dynamodb", "elasticsearch", "firebase_auth", "firestore", "gcs", "google_calendar", "google_docs", "google_drive", "graphql", "hubspot", "jira", "jwt_hmac", "jwt_rsa", "kafka", "keycloak", "linear", "mariadb", "monday", "mongo", "mssql", "databricks", "mysql", "newrelic", "okta", "onedrive", "oracledb", "pinecone", "postgres", "redis", "s3", "salesforce_crm", "sap_hana", "sentry", "servicenow", "snowflake", "spanner", "xata", "zendesk", "mail", "slack", "mcp", "a2a", "legend", "ollama"];
4
4
  /**
5
5
  * @category Database
6
6
  */
@@ -8,7 +8,7 @@ export declare const DATA_INTEGRATION_TYPES: readonly ["bigquery", "built_in_db"
8
8
  /**
9
9
  * @category Auth
10
10
  */
11
- export declare const AUTH_INTEGRATION_TYPES: readonly ["auth0", "jwt_rsa", "jwt_hmac", "cognito", "okta", "descope", "firebase_auth"];
11
+ export declare const AUTH_INTEGRATION_TYPES: readonly ["auth0", "jwt_rsa", "jwt_hmac", "cognito", "okta", "keycloak", "descope", "firebase_auth"];
12
12
  /** Supported integration types for GraphQL-based services. */
13
13
  export declare const GRAPHQL_INTEGRATION_TYPES: readonly ["graphql", "linear"];
14
14
  /** Supported integration types for HTTP-based services. */
@@ -1,5 +1,5 @@
1
1
  import { Observable } from 'rxjs';
2
- import { AiAgent, AiChatMessage, AiConnectedAgentMetadata, AiSearchOptions, AiSearchResultChunk, AiStatusMessage, AiTranscribeAndAskResponse, AllAiAgentChatOptions, GuardrailsOptions, UpsertAgentRequest } from '../../../internal-common/src/public-types/ai-agent.public-types';
2
+ import { AiAgent, AiChatMessage, AiChatModelSelection, AiConnectedAgentMetadata, AiStatusMessage, AiTranscribeAndAskResponse, AllAiAgentChatOptions, GuardrailsOptions, UpsertAgentRequest } from '../../../internal-common/src/public-types/ai-agent.public-types';
3
3
  import { AiChatModelName } from '../../../internal-common/src/public-types/ai-common.public-types';
4
4
  import { JobId } from '../../../internal-common/src/public-types/job.public-types';
5
5
  import { Paths } from '../../../internal-common/src/public-types/typescript.public-types';
@@ -18,6 +18,7 @@ export type UpsertAgentRequestParams = Omit<UpsertAgentRequest, 'id'>;
18
18
  */
19
19
  export declare class AiAgentReference {
20
20
  private readonly agentId;
21
+ private readonly agentApiKey;
21
22
  private readonly ongoingChatSequences;
22
23
  private readonly rpcManager;
23
24
  private readonly socketManager;
@@ -42,7 +43,7 @@ export declare class AiAgentReference {
42
43
  /**
43
44
  * Changes the AI model used by the agent.
44
45
  */
45
- updateModel(model: AiChatModelName): Promise<void>;
46
+ updateModel(model: AiChatModelSelection): Promise<void>;
46
47
  /**
47
48
  * Updates the list of agents connected to this agent.
48
49
  */
@@ -59,6 +60,18 @@ export declare class AiAgentReference {
59
60
  * Deletes the custom guardrails for the agent.
60
61
  */
61
62
  deleteCustomGuardrail(): Promise<void>;
63
+ /**
64
+ * Regenerates the api key for the agent.
65
+ * Will throw an error if the agent does not exist.
66
+ *
67
+ * @returns the new api key
68
+ */
69
+ regenerateApiKey(): Promise<string>;
70
+ /**
71
+ * Fetches the default api key for the agent
72
+ * @returns the api key if one exists
73
+ */
74
+ getApiKey(): Promise<string | undefined>;
62
75
  /**
63
76
  * Sends a prompt to the agent and receives streamed text responses.
64
77
  * @param prompt The text prompt to send to the agent.
@@ -77,10 +90,6 @@ export declare class AiAgentReference {
77
90
  * knows it can look up the job’s status.
78
91
  */
79
92
  transcribeAndChat(fileToTranscribe: File, options?: AiChatOptionsWithoutVoice, jobId?: JobId): Promise<TranscribeAndChatResponse>;
80
- /**
81
- * Performs a semantic search using the agent's knowledge base.
82
- */
83
- search(options: AiSearchOptions): Promise<Array<AiSearchResultChunk>>;
84
93
  /**
85
94
  * Sends a prompt and returns a full string response.
86
95
  * @param prompt The text prompt to send to the agent.
@@ -165,4 +174,8 @@ export declare class AiAgentReference {
165
174
  private replaceFileTags;
166
175
  private askInternal;
167
176
  private chatInternal;
177
+ /**
178
+ * Calls rpcManager post but with the agent api key if one was given during construction
179
+ */
180
+ private post;
168
181
  }
@@ -1,5 +1,16 @@
1
1
  import { AiAgent, AiAgentId } from '../public-types';
2
2
  import { AiAgentReference } from './ai-agent-client-reference';
3
+ /**
4
+ * Allows the user to provide custom options to the agent client
5
+ *
6
+ * @category AI
7
+ */
8
+ export type AiAgentClientOptions = {
9
+ /**
10
+ * Allows providing an agent API key that can be used instead of the app API key
11
+ */
12
+ apiKey?: string;
13
+ };
3
14
  /**
4
15
  * AiAgentClient manages AI agent interactions, including listing agents,
5
16
  * handling real-time chat responses, and processing AI status updates
@@ -16,7 +27,7 @@ export declare class AiAgentClient {
16
27
  * Retrieves an instance of AiAgentReference for a specific agent ID.
17
28
  * This reference provides methods for interacting with the agent.
18
29
  */
19
- agent(id: AiAgentId): AiAgentReference;
30
+ agent(id: AiAgentId, options?: AiAgentClientOptions | undefined): AiAgentReference;
20
31
  /**
21
32
  * Lists all agents available in the system.
22
33
  * @returns A promise that resolves to an array of AiAgent instances.
@@ -1,4 +1,5 @@
1
1
  import { AiQueryOptions, AiQueryResponse, ExecuteAiApiResponse } from '../../internal-common/src/public-types/ai-query.public-types';
2
+ import { AiAgentClientOptions } from './agent/ai-agent-client';
2
3
  import { AiAgentReference } from './agent/ai-agent-client-reference';
3
4
  import { AiAssistantClient } from './ai-assistant-client';
4
5
  import { AiAudioClient } from './ai-audio-client';
@@ -24,7 +25,7 @@ export declare class AiClient {
24
25
  * Returns a reference to the specified AI agent.
25
26
  * If no ID is provided, the built-in agent is used by default.
26
27
  */
27
- agent(agentId?: AiAgentId): AiAgentReference;
28
+ agent(agentId?: AiAgentId, options?: AiAgentClientOptions | undefined): AiAgentReference;
28
29
  /**
29
30
  * Returns a reference to the specified AI knowledge base.
30
31
  */
@@ -4,8 +4,12 @@ import { Observable } from 'rxjs';
4
4
  * @category Platform
5
5
  */
6
6
  export interface DistributedLock {
7
- /** Releases the lock. */
8
- release(): void;
7
+ /**
8
+ * Releases the lock by sending a release message to the server.
9
+ * The release process runs asynchronously. Use `observeRelease()` to be notified when the release completes.
10
+ * @returns A promise that resolves when the release message is sent, or undefined for backward compatibility.
11
+ */
12
+ release(): Promise<void> | void;
9
13
  /**
10
14
  * Whether the lock has been released.
11
15
  * @returns True if the lock has been released.
@@ -363,6 +363,8 @@ export declare class Squid {
363
363
  * @returns A promise that resolves when the destruct process is complete.
364
364
  */
365
365
  destruct(): Promise<void>;
366
+ /** Set to true if the client was destructured. */
367
+ get isDestructed(): boolean;
366
368
  /** Provides information about the connection to the Squid Server. */
367
369
  connectionDetails(): ConnectionDetails;
368
370
  /** Returns the notification client for handling (publishing and receiving) custom messages. */
@@ -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.412";
5
+ export declare const SQUIDCLOUD_CLIENT_PACKAGE_VERSION = "1.0.414";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.412",
3
+ "version": "1.0.414",
4
4
  "description": "A typescript implementation of the Squid client",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,9 +0,0 @@
1
- /**
2
- * Names of the Squid metrics.
3
- * Should be in sync with MetricName.kt.
4
- * See MetricName.kt for documentation on each value.
5
- */
6
- export declare const ALL_SQUID_METRIC_NAMES: readonly ["squid_functionExecution_count", "squid_functionExecution_time", "squid_aiChatbotContext_size", "squid_aiChatbotChatInputTokens_count", "squid_aiChatbotChatOutputTokens_count", "squid_aiChatbotChatOutcome_count", "squid_aiImageGeneration_count", "squid_aiImageGeneration_time", "squid_aiRemoveBackground_count", "squid_aiRemoveBackground_time", "squid_aiAudioTranscribe_count", "squid_aiAudioTranscribe_time", "squid_aiAudioCreateSpeech_count", "squid_aiAudioCreateSpeech_time", "squid_aiIntegrationData_count", "squid_aiIntegrationData_time", "squid_aiIntegrationApi_count", "squid_aiIntegrationApi_time", "squid_apiControllerCall_count", "squid_apiControllerCall_time", "squid_aiContextUpsert_count", "squid_aiContextDelete_count", "squid_codeInitialization_count", "squid_codeInitialization_time", "squid_deleteApiKey_count", "squid_deleteApiKey_time", "squid_deleteSecret_count", "squid_deleteSecret_time", "squid_discoverGraphQLConnectionSchema_count", "squid_discoverGraphQLConnectionSchema_time", "squid_discoverOpenApiSchema_count", "squid_discoverOpenApiSchema_time", "squid_discoverOpenApiSchemaFromFile_count", "squid_discoverOpenApiSchemaFromFile_time", "squid_executeBackendFunction_count", "squid_executeBackendFunction_time", "squid_getAiChatbotProfiles_count", "squid_getAiChatbotProfiles_time", "squid_getAllApiKeys_count", "squid_getAllApiKeys_time", "squid_getAllSecrets_count", "squid_getAllSecrets_time", "squid_getAppApiKey_count", "squid_getAppApiKey_time", "squid_getSecret_count", "squid_getSecret_time", "squid_graphql_count", "squid_graphql_time", "squid_graphqlQuery_count", "squid_graphqlQuery_time", "squid_integrationCount_value", "squid_acquireLock_count", "squid_releaseLock_count", "squid_mutate_count", "squid_mutate_time", "squid_metricQuery_count", "squid_metricQuery_time", "squid_metricReport_count", "squid_metricReport_time", "squid_nativeQuery_count", "squid_nativeQuery_time", "squid_openapi_count", "squid_openapi_time", "squid_produceTopicMessage_count", "squid_produceTopicMessage_time", "squid_query_count", "squid_query_time", "squid_registerQuery_count", "squid_registerQuery_time", "squid_rerankChunks_count", "squid_rerankChunks_time", "squid_schedulerJob_count", "squid_schedulerJob_time", "squid_schema_size", "squid_secrets_entries", "squid_storageDeleteFiles_count", "squid_storageDeleteFiles_time", "squid_storageGetDownloadUrl_count", "squid_storageGetDownloadUrl_time", "squid_storageGetFileMetadata_count", "squid_storageGetFileMetadata_time", "squid_storageListDirectoryContents_count", "squid_storageListDirectoryContents_time", "squid_storageUploadFile_count", "squid_storageUploadFile_time", "squid_subscribeToTopic_count", "squid_subscribeToTopic_time", "squid_testGraphQLConnection_count", "squid_testGraphQLConnection_time", "squid_testAgentProtocolConnection_count", "squid_testAgentProtocolConnection_time", "squid_trigger_count", "squid_trigger_time", "squid_upsertApiKey_count", "squid_upsertApiKey_time", "squid_upsertSecret_count", "squid_upsertSecret_time", "squid_vectorChunks_count", "squid_vectorChunks_time", "squid_webhook_count", "squid_webhook_time"];
7
- export type MetricName = (typeof ALL_SQUID_METRIC_NAMES)[number];
8
- /** Common prefix for all Squid metrics. */
9
- export declare const SQUID_METRIC_NAME_PREFIX = "squid_";
@@ -1,30 +0,0 @@
1
- import { ApiOptions } from '../public-types/api-client.public-types';
2
- import { ApiEndpointId, HttpMethod } from '../public-types/api.public-types';
3
- import { IntegrationId } from '../public-types/communication.public-types';
4
- /** The headers of an API call. */
5
- export type ApiHeaders = Record<string, string | number | boolean>;
6
- /** The context of an API call. */
7
- export declare class ApiCallContext {
8
- readonly integrationId: IntegrationId;
9
- readonly endpointId: ApiEndpointId;
10
- readonly url: string;
11
- readonly method: HttpMethod;
12
- readonly body: unknown;
13
- readonly options: ApiOptions;
14
- }
15
- /**
16
- * Represents a request to call an API through a specified integration and endpoint.
17
- * Includes optional method override and additional request options.
18
- */
19
- export interface CallApiRequest<BodyType = any> {
20
- /** The identifier of the integration through which the API is called. */
21
- integrationId: IntegrationId;
22
- /** Target API endpoint to invoke. */
23
- endpointId: ApiEndpointId;
24
- /** Optional request payload. */
25
- body?: BodyType;
26
- /** Optional HTTP method override. Default is POST. */
27
- overrideMethod?: HttpMethod;
28
- /** Additional request options. */
29
- options: ApiOptions;
30
- }
@@ -1,148 +0,0 @@
1
- import { SquidDocIdObj, SquidDocument } from '../public-types/document.public-types';
2
- import { Paths } from '../public-types/typescript.public-types';
3
- /**
4
- * The mutation type.
5
- * @category Database
6
- */
7
- export declare const MUTATION_TYPES: readonly ["insert", "update", "delete"];
8
- /**
9
- * @category Database
10
- */
11
- export type MutationType = (typeof MUTATION_TYPES)[number];
12
- interface BaseMutation {
13
- type: MutationType;
14
- squidDocIdObj: SquidDocIdObj;
15
- }
16
- /**
17
- * A mutation on a document.
18
- * @category Database
19
- */
20
- export type Mutation<T = any> = UpdateMutation<T> | InsertMutation<T> | DeleteMutation;
21
- /**
22
- * Represents a delete mutation on a document.
23
- * @category Database
24
- */
25
- export interface DeleteMutation extends BaseMutation {
26
- /** Specifies that the mutation is a deletion. */
27
- type: 'delete';
28
- }
29
- /**
30
- * Represents an update mutation on a document.
31
- * @category Database
32
- */
33
- export interface UpdateMutation<T = any> extends BaseMutation {
34
- /** Specifies that the mutation is an update. */
35
- type: 'update';
36
- /** The updated properties */
37
- properties: {
38
- [key in keyof T & string]?: Array<PropertyMutation<T[key]>>;
39
- };
40
- }
41
- /**
42
- * Represents an insert mutation on a document.
43
- * @category Database
44
- */
45
- export interface InsertMutation<T = any> extends BaseMutation {
46
- /** Specifies that the mutation is an insertion. */
47
- type: 'insert';
48
- /** The inserted document */
49
- properties: T;
50
- }
51
- /**
52
- * A representation of a single property update.
53
- * @category Database
54
- */
55
- export type PropertyMutation<Value = any> = ApplyNumericFnPropertyMutation | ApplyStringFnPropertyMutation | ValueUpdatePropertyMutation<Value> | RemovePropertyMutation;
56
- /**
57
- * A value update property mutation.
58
- * @category Database
59
- */
60
- export interface ValueUpdatePropertyMutation<Value = any> {
61
- /** Specifies that the mutation updates a value. */
62
- type: 'update';
63
- /** New value to be set. */
64
- value: Value;
65
- }
66
- /**
67
- * Applying a numeric function to a property.
68
- * @category Database
69
- */
70
- export interface ApplyNumericFnPropertyMutation {
71
- /** Specifies that the mutation applies a numeric function. */
72
- type: 'applyNumericFn';
73
- /** Numeric function to apply. */
74
- fn: 'increment';
75
- /** Value to use in the numeric function. */
76
- value: number;
77
- }
78
- /**
79
- * A property update that removes a property from a document.
80
- * @category Database
81
- */
82
- export interface RemovePropertyMutation {
83
- /** Specifies that the mutation removes a property. */
84
- type: 'removeProperty';
85
- }
86
- interface ApplyExtendString {
87
- /** Specifies that the mutation applies a string function. */
88
- type: 'applyStringFn';
89
- /** String function to extend the existing string. */
90
- fn: 'extendString';
91
- /** String value to append. */
92
- value: string;
93
- }
94
- interface ApplyTrimString {
95
- /** Specifies that the mutation applies a string function. */
96
- type: 'applyStringFn';
97
- /** String function to trim the existing string. */
98
- fn: 'trim';
99
- }
100
- /**
101
- * A property mutation that modifies a string.
102
- * @category Database
103
- */
104
- export type ApplyStringFnPropertyMutation = ApplyExtendString | ApplyTrimString;
105
- /**
106
- * The before and after documents of a document change.
107
- * @category Database
108
- */
109
- export interface BeforeAndAfterDocs<T = SquidDocument> {
110
- /** Document state before the mutation. */
111
- before: T | undefined;
112
- /** Document state after the mutation. */
113
- after: T | undefined;
114
- }
115
- /**
116
- * The mutation context that will be provided to the security function.
117
- * @category Database
118
- */
119
- export declare class MutationContext<T = any> {
120
- readonly mutation: Mutation<T>;
121
- readonly beforeAndAfterDocs: BeforeAndAfterDocs<T>;
122
- readonly serverTimeStamp: Date;
123
- /**
124
- * Returns the state of the document before the mutation was applied.
125
- */
126
- get before(): T | undefined;
127
- /**
128
- * Returns the state of the document after the mutation was applied.
129
- */
130
- get after(): T | undefined;
131
- /**
132
- * Returns the type of the mutation (insert, update, or delete).
133
- */
134
- getMutationType(): MutationType;
135
- /** Returns true if the mutation affects the provided path. */
136
- affectsPath(path: Paths<T>): boolean;
137
- /**
138
- * Find all affected paths starting from a root path.
139
- *
140
- * @example
141
- * doc before - { a: { b: 1, c: 2 }, d: 3 }
142
- * doc after - { a: { b: 1, c: 3 }, d: 4 }
143
- * doc.affectedPaths('a') // ['a.c']
144
- */
145
- affectedPaths(startingRoot?: Paths<T> | string): Array<Paths<T>>;
146
- private checkPath;
147
- }
148
- export {};
@@ -1,72 +0,0 @@
1
- import { IntegrationId } from '../public-types/communication.public-types';
2
- /**
3
- * Represents the type of native query request, either relational, elastic or MongoDB.
4
- * @category Database
5
- */
6
- export type NativeQueryRequestType = 'relational' | 'mongo' | 'elasticsearch' | 'pure';
7
- interface BaseNativeQueryContext {
8
- /** Type of the native query request. */
9
- type: NativeQueryRequestType;
10
- /** Identifier for the integration. */
11
- integrationId: IntegrationId;
12
- }
13
- /**
14
- * Context for executing a relational database query.
15
- * @category Database
16
- */
17
- export interface RelationalNativeQueryContext extends BaseNativeQueryContext {
18
- /** Specifies that the query is for a relational database. */
19
- type: 'relational';
20
- /** SQL query string to be executed. */
21
- query: string;
22
- /** Parameters to be used in the query. */
23
- params: Record<string, any>;
24
- }
25
- /**
26
- * Context for executing a MongoDB query.
27
- * @category Database
28
- */
29
- export interface MongoNativeQueryContext extends BaseNativeQueryContext {
30
- /** Specifies that the query is for a Mongo database. */
31
- type: 'mongo';
32
- /** Name of the MongoDB collection to query. */
33
- collectionName: string;
34
- /** Array of aggregation pipeline stages. */
35
- aggregationPipeline: Array<any | undefined>;
36
- }
37
- /**
38
- * Context for executing an Elasticsearch query.
39
- * @category Database
40
- */
41
- export interface ElasticsearchNativeQueryContext {
42
- /** Specifies that the query is for an Elasticsearch database. */
43
- type: 'elasticsearch';
44
- /** Elasticsearch index to query. */
45
- index: string;
46
- /** Elasticsearch query string. */
47
- endpoint?: string;
48
- /** HTTP method to use for the request. */
49
- method?: 'GET' | 'POST';
50
- /** Body of the request. */
51
- body: Record<string, any>;
52
- /** Headers to include in the request. */
53
- integrationId: IntegrationId;
54
- }
55
- /**
56
- * Context for executing a pure database query.
57
- * @category Database
58
- */
59
- export interface PureNativeQueryContext extends BaseNativeQueryContext {
60
- /** Specifies that the query is for a relational database. */
61
- type: 'pure';
62
- /** SQL query string to be executed. */
63
- query: string;
64
- /** Parameters to be used in the query. */
65
- params: Record<string, any>;
66
- }
67
- /**
68
- * Union type representing either a relational or MongoDB native query context.
69
- * @category Database
70
- */
71
- export type NativeQueryContext = RelationalNativeQueryContext | MongoNativeQueryContext | ElasticsearchNativeQueryContext | PureNativeQueryContext;
72
- export {};