@squidcloud/client 1.0.466 → 1.0.468

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 (49) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/esm/index.js +1 -1
  3. package/dist/internal-common/src/metric-name.d.ts +14 -0
  4. package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +5 -1
  5. package/dist/internal-common/src/public-types/ai-common.public-types.d.ts +4 -4
  6. package/dist/internal-common/src/public-types/ai-function.public-types.d.ts +12 -2
  7. package/dist/internal-common/src/public-types/ai-knowledge-base.public-types.d.ts +44 -0
  8. package/dist/internal-common/src/public-types/api.public-types.d.ts +10 -2
  9. package/dist/internal-common/src/public-types/job.public-types.d.ts +28 -0
  10. package/dist/internal-common/src/public-types/schema.public-types.d.ts +12 -0
  11. package/dist/internal-common/src/public-types-backend/api-call.public-context.d.ts +30 -0
  12. package/dist/internal-common/src/public-types-backend/mutation.public-context.d.ts +148 -0
  13. package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +72 -0
  14. package/dist/internal-common/src/public-types-backend/query.public-context.d.ts +190 -0
  15. package/dist/internal-common/src/types/ai-agent.types.d.ts +240 -0
  16. package/dist/internal-common/src/types/ai-knowledge-base.types.d.ts +202 -0
  17. package/dist/internal-common/src/types/ai-matchmaking.types.d.ts +59 -0
  18. package/dist/internal-common/src/types/backend-function.types.d.ts +1 -0
  19. package/dist/internal-common/src/types/communication.types.d.ts +1 -0
  20. package/dist/internal-common/src/types/document.types.d.ts +1 -0
  21. package/dist/internal-common/src/types/file.types.d.ts +6 -0
  22. package/dist/internal-common/src/types/headers.types.d.ts +17 -0
  23. package/dist/internal-common/src/types/management-api-key.types.d.ts +92 -0
  24. package/dist/internal-common/src/types/mutation.types.d.ts +1 -0
  25. package/dist/internal-common/src/types/notification.types.d.ts +5 -0
  26. package/dist/internal-common/src/types/observability.types.d.ts +135 -0
  27. package/dist/internal-common/src/types/query.types.d.ts +15 -0
  28. package/dist/internal-common/src/types/secret.types.d.ts +7 -0
  29. package/dist/internal-common/src/types/socket.types.d.ts +1 -0
  30. package/dist/internal-common/src/types/stage.d.ts +9 -0
  31. package/dist/internal-common/src/types/time-units.d.ts +1 -0
  32. package/dist/internal-common/src/types/url-shortener.types.d.ts +45 -0
  33. package/dist/internal-common/src/utils/array.d.ts +7 -0
  34. package/dist/internal-common/src/utils/e2e-test-utils.d.ts +2 -0
  35. package/dist/internal-common/src/utils/file-utils.d.ts +2 -0
  36. package/dist/internal-common/src/utils/global.utils.d.ts +1 -0
  37. package/dist/internal-common/src/utils/http.d.ts +5 -0
  38. package/dist/internal-common/src/utils/lock.manager.d.ts +14 -0
  39. package/dist/internal-common/src/utils/metric-utils.d.ts +4 -0
  40. package/dist/internal-common/src/utils/metrics.types.d.ts +7 -0
  41. package/dist/internal-common/src/utils/object.d.ts +86 -0
  42. package/dist/internal-common/src/utils/serialization.d.ts +18 -0
  43. package/dist/internal-common/src/utils/squid.constants.d.ts +6 -0
  44. package/dist/internal-common/src/utils/trace-id-generator.d.ts +1 -0
  45. package/dist/internal-common/src/utils/validation.d.ts +19 -0
  46. package/dist/internal-common/src/websocket.impl.d.ts +26 -0
  47. package/dist/typescript-client/src/job-client.d.ts +16 -0
  48. package/dist/typescript-client/src/version.d.ts +1 -1
  49. package/package.json +3 -4
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Names of the Squid metrics.
3
+ *
4
+ * This list and its Kotlin counterpart (MetricName.kt) may diverge:
5
+ * each side declares only the metrics that its own backend emits.
6
+ * However, metrics emitted by both backends MUST use identical names on both sides —
7
+ * otherwise dashboards and metric queries that mix data from both sources will break.
8
+ *
9
+ * See MetricName.kt for documentation on each value.
10
+ */
11
+ 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_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", "squid_acquireLock_count", "squid_acquireLock_time", "squid_releaseLock_count", "squid_releaseLock_time"];
12
+ export type MetricName = (typeof ALL_SQUID_METRIC_NAMES)[number];
13
+ /** Common prefix for all Squid metrics. */
14
+ export declare const SQUID_METRIC_NAME_PREFIX = "squid_";
@@ -351,7 +351,11 @@ export type AiAgentMemoryMode = 'none' | 'read-only' | 'read-write';
351
351
  */
352
352
  export interface AiAgentMemoryOptions {
353
353
  /**
354
- * The memory mode for an AI agent
354
+ * The memory mode for an AI agent.
355
+ *
356
+ * Note: Squid persists chat history in its own store only for models whose provider does NOT manage memory
357
+ * itself. For provider-managed-memory models (e.g. Claude Code, which keeps its own CLI session), this mode
358
+ * still controls whether the conversation resumes, but Squid never reads or writes its own history DB.
355
359
  */
356
360
  memoryMode: AiAgentMemoryMode;
357
361
  /**
@@ -24,12 +24,12 @@ export type AiFileProviderType = Extract<AiProviderType, 'openai' | 'gemini' | '
24
24
  * Public OpenAI chat model names (active models only).
25
25
  * @category AI
26
26
  */
27
- export declare const OPENAI_CHAT_MODEL_NAMES: readonly ["gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano"];
27
+ export declare const OPENAI_CHAT_MODEL_NAMES: readonly ["gpt-5.4-mini", "gpt-5.4-nano", "gpt-5.5", "gpt-5.5-pro"];
28
28
  /**
29
29
  * Public Gemini chat model names (active models only).
30
30
  * @category AI
31
31
  */
32
- export declare const GEMINI_CHAT_MODEL_NAMES: readonly ["gemini-3.1-pro", "gemini-3.5-flash"];
32
+ export declare const GEMINI_CHAT_MODEL_NAMES: readonly ["gemini-3.1-pro", "gemini-3.5-flash", "gemini-3.1-flash-lite"];
33
33
  /**
34
34
  * Public Grok chat model names (active models only).
35
35
  * @category AI
@@ -39,12 +39,12 @@ export declare const GROK_CHAT_MODEL_NAMES: readonly ["grok-4", "grok-4-1-fast-r
39
39
  * Public Anthropic chat model names (active models only).
40
40
  * @category AI
41
41
  */
42
- export declare const ANTHROPIC_CHAT_MODEL_NAMES: readonly ["claude-haiku-4-5-20251001", "claude-opus-4-7", "claude-sonnet-4-6"];
42
+ export declare const ANTHROPIC_CHAT_MODEL_NAMES: readonly ["claude-haiku-4-5-20251001", "claude-opus-4-8", "claude-sonnet-4-6"];
43
43
  /**
44
44
  * The supported AI model names.
45
45
  * @category AI
46
46
  */
47
- export declare const VENDOR_AI_CHAT_MODEL_NAMES: readonly ["gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano", "claude-haiku-4-5-20251001", "claude-opus-4-7", "claude-sonnet-4-6", "gemini-3.1-pro", "gemini-3.5-flash", "grok-4", "grok-4-1-fast-reasoning", "grok-4-1-fast-non-reasoning"];
47
+ export declare const VENDOR_AI_CHAT_MODEL_NAMES: readonly ["gpt-5.4-mini", "gpt-5.4-nano", "gpt-5.5", "gpt-5.5-pro", "claude-haiku-4-5-20251001", "claude-opus-4-8", "claude-sonnet-4-6", "gemini-3.1-pro", "gemini-3.5-flash", "gemini-3.1-flash-lite", "grok-4", "grok-4-1-fast-reasoning", "grok-4-1-fast-non-reasoning"];
48
48
  /** Checks if the given model name is a global AI chat model name. */
49
49
  export declare function isVendorAiChatModelName(modelName: unknown): modelName is VendorAiChatModelName;
50
50
  /**
@@ -37,8 +37,18 @@ export interface AiFunctionAttributes {
37
37
  export interface AiFunctionMetadata {
38
38
  /** The fully qualified name of the function (serviceName:functionName). */
39
39
  serviceFunction: ServiceFunctionName;
40
- /** Description of what the function does. */
41
- description: string;
40
+ /**
41
+ * Description of what the function does. Optional when {@link promptId} is set,
42
+ * in which case the description is resolved server-side from the prompt
43
+ * registry at the point the LLM tool definition is built.
44
+ */
45
+ description?: string;
46
+ /**
47
+ * Opaque id of a registered prompt that supplies this function's description.
48
+ * Stored verbatim (the public SDK never resolves it — that would ship the
49
+ * internal prompt registry to customers); resolution happens server-side.
50
+ */
51
+ promptId?: string;
42
52
  /** Parameters that the function accepts. */
43
53
  params: Array<AiFunctionParam>;
44
54
  /** Additional attributes for the function. */
@@ -137,6 +137,33 @@ export interface AiKnowledgeBaseChatOptions {
137
137
  chunkLimit?: number;
138
138
  /** Which chat model to use when asking the question */
139
139
  chatModel?: AiChatModelSelection;
140
+ /**
141
+ * Selects how the underlying vector store generates candidates:
142
+ * - `'hybrid'` (default): fuses dense vector and keyword candidates when the backend supports it
143
+ * (Mongo Atlas uses `$rankFusion`; backends without native fusion fall back to dense-only with
144
+ * the legacy app-side keyword fallback).
145
+ * - `'vector'`: dense-only — skips native fusion even on backends that support it.
146
+ *
147
+ * Intended to let A/B evaluations compare dense-only vs hybrid retrieval on the same backend.
148
+ */
149
+ searchMode?: 'vector' | 'hybrid';
150
+ /**
151
+ * Per-pipeline weights for native hybrid fusion (Mongo `$rankFusion.combination.weights`). Only
152
+ * applies when `searchMode` is `'hybrid'` on a backend with native fusion; ignored otherwise.
153
+ * Each value must be a finite non-negative number; an omitted key defaults to `1` (the MongoDB
154
+ * default). Useful for A/B evaluating dense-vs-keyword weighting on the same backend.
155
+ */
156
+ hybridWeights?: AiHybridSearchWeights;
157
+ }
158
+ /**
159
+ * Per-pipeline weights for native hybrid fusion. Sub-keys mirror the `$rankFusion` pipeline names.
160
+ * @category AI
161
+ */
162
+ export interface AiHybridSearchWeights {
163
+ /** Weight for the dense vector sub-pipeline. Defaults to `1`. */
164
+ vector?: number;
165
+ /** Weight for the BM25 keyword sub-pipeline. Defaults to `1`. */
166
+ keyword?: number;
140
167
  }
141
168
  /**
142
169
  * @category AI
@@ -305,6 +332,23 @@ export interface AiKnowledgeBaseSearchOptions {
305
332
  chunkLimit?: number;
306
333
  /** Which chat model to use when asking the question */
307
334
  chatModel?: AiChatModelSelection;
335
+ /**
336
+ * Selects how the underlying vector store generates candidates:
337
+ * - `'hybrid'` (default): fuses dense vector and keyword candidates when the backend supports it
338
+ * (Mongo Atlas uses `$rankFusion`; backends without native fusion fall back to dense-only with
339
+ * the legacy app-side keyword fallback).
340
+ * - `'vector'`: dense-only — skips native fusion even on backends that support it.
341
+ *
342
+ * Intended to let A/B evaluations compare dense-only vs hybrid retrieval on the same backend.
343
+ */
344
+ searchMode?: 'vector' | 'hybrid';
345
+ /**
346
+ * Per-pipeline weights for native hybrid fusion (Mongo `$rankFusion.combination.weights`). Only
347
+ * applies when `searchMode` is `'hybrid'` on a backend with native fusion; ignored otherwise.
348
+ * Each value must be a finite non-negative number; an omitted key defaults to `1` (the MongoDB
349
+ * default). Useful for A/B evaluating dense-vs-keyword weighting on the same backend.
350
+ */
351
+ hybridWeights?: AiHybridSearchWeights;
308
352
  }
309
353
  /**
310
354
  * A single chunk of data returned from an AI search operation.
@@ -63,10 +63,18 @@ export interface GraphQLConnectionOptions {
63
63
  }
64
64
  /** A mapping of field names to their corresponding injection field definitions. */
65
65
  export type ApiInjectionSchema = Record<FieldName, ApiInjectionField>;
66
- /** Options for discovering APIs via an OpenAPI specification. */
66
+ /**
67
+ * Options for discovering APIs via an OpenAPI specification. Supply either a URL
68
+ * to fetch the document from, or the raw document content directly.
69
+ */
67
70
  export interface OpenApiDiscoveryOptions {
68
71
  /** The URL of the OpenAPI specification document. */
69
- openApiSpecUrl: string;
72
+ openApiSpecUrl?: string;
73
+ /**
74
+ * The raw OpenAPI specification document (JSON or YAML), used to discover the
75
+ * schema directly when the spec is provided as content rather than a URL.
76
+ */
77
+ openApiSpecContent?: string;
70
78
  }
71
79
  /** Represents the structure of an API endpoint, including its path, method, schemas, and metadata. */
72
80
  export interface ApiEndpoint {
@@ -22,6 +22,34 @@ export interface SubscribeToJobRequest {
22
22
  /** The unique identifier of the job to subscribe to */
23
23
  jobId: JobId;
24
24
  }
25
+ /**
26
+ * Represents a request to start a client-owned job.
27
+ * The caller generates the jobId; the client that starts the job owns it and must resolve it.
28
+ */
29
+ export interface StartJobRequest {
30
+ /** The unique identifier of the job to start. */
31
+ jobId: JobId;
32
+ }
33
+ /**
34
+ * Represents a request to resolve a client-owned job with its result or error.
35
+ */
36
+ export interface ResolveJobRequest {
37
+ /** The unique identifier of the job to resolve. */
38
+ jobId: JobId;
39
+ /** The terminal status to set on the job. */
40
+ status: 'completed' | 'failed';
41
+ /** The job result, present when status is 'completed'. */
42
+ result?: unknown;
43
+ /** The error message, present when status is 'failed'. */
44
+ error?: string;
45
+ }
46
+ /**
47
+ * Represents a keep-alive request signalling that the client still owns the listed active jobs.
48
+ */
49
+ export interface KeepAliveRequest {
50
+ /** The identifiers of the jobs the client is keeping alive. */
51
+ jobIds: Array<JobId>;
52
+ }
25
53
  /**
26
54
  * Represents an asynchronous job
27
55
  */
@@ -47,9 +47,21 @@ export type TopLevelPropertySchema = PropertySchema & {
47
47
  */
48
48
  hidden?: boolean;
49
49
  };
50
+ /**
51
+ * Milestoning kind on a Legend/PURE class. Drives `.all()` arity and the date
52
+ * arguments required when navigating to the class's properties:
53
+ * - `business-temporal` → `.all(businessDate)`, `$x.prop(businessDate)`
54
+ * - `processing-temporal` → `.all(processingDate)`, `$x.prop(processingDate)`
55
+ * - `bitemporal` → `.all(processingDate, businessDate)`, `$x.prop(processingDate, businessDate)`
56
+ * Legend integrations populate this when discovering the schema so downstream consumers
57
+ * (AI query generation, validation) know whether dates are required.
58
+ */
59
+ export type MilestoningKind = 'business-temporal' | 'processing-temporal' | 'bitemporal';
50
60
  /** Schema for a full collection, allowing partial property definitions with extended metadata. */
51
61
  export type CollectionSchema = Omit<ConvertDeep<JSONSchema>, 'properties'> & {
52
62
  properties?: Record<string, TopLevelPropertySchema>;
63
+ /** Legend/PURE only: milestoning stereotype on the class, if any. */
64
+ milestoning?: MilestoningKind;
53
65
  };
54
66
  /**
55
67
  * API-boundary view of {@link CollectionSchema} for use in OpenAPI-exposed
@@ -0,0 +1,30 @@
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
+ }
@@ -0,0 +1,148 @@
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 {};
@@ -0,0 +1,72 @@
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 {};