@squidcloud/client 1.0.470 → 1.0.471

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 (45) 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-knowledge-base.public-types.d.ts +15 -43
  5. package/dist/internal-common/src/public-types/extraction.public-types.d.ts +33 -0
  6. package/dist/internal-common/src/public-types/metadata-filter.public-types.d.ts +85 -0
  7. package/dist/internal-common/src/public-types/metric.public-types.d.ts +23 -3
  8. package/dist/internal-common/src/public-types-backend/api-call.public-context.d.ts +30 -0
  9. package/dist/internal-common/src/public-types-backend/mutation.public-context.d.ts +148 -0
  10. package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +72 -0
  11. package/dist/internal-common/src/public-types-backend/query.public-context.d.ts +190 -0
  12. package/dist/internal-common/src/types/ai-agent.types.d.ts +240 -0
  13. package/dist/internal-common/src/types/ai-knowledge-base.types.d.ts +202 -0
  14. package/dist/internal-common/src/types/ai-matchmaking.types.d.ts +59 -0
  15. package/dist/internal-common/src/types/backend-function.types.d.ts +1 -0
  16. package/dist/internal-common/src/types/communication.types.d.ts +1 -0
  17. package/dist/internal-common/src/types/document.types.d.ts +1 -0
  18. package/dist/internal-common/src/types/file.types.d.ts +6 -0
  19. package/dist/internal-common/src/types/headers.types.d.ts +17 -0
  20. package/dist/internal-common/src/types/management-api-key.types.d.ts +92 -0
  21. package/dist/internal-common/src/types/mutation.types.d.ts +1 -0
  22. package/dist/internal-common/src/types/notification.types.d.ts +5 -0
  23. package/dist/internal-common/src/types/observability.types.d.ts +142 -0
  24. package/dist/internal-common/src/types/query.types.d.ts +15 -0
  25. package/dist/internal-common/src/types/secret.types.d.ts +7 -0
  26. package/dist/internal-common/src/types/socket.types.d.ts +1 -0
  27. package/dist/internal-common/src/types/stage.d.ts +9 -0
  28. package/dist/internal-common/src/types/time-units.d.ts +1 -0
  29. package/dist/internal-common/src/types/url-shortener.types.d.ts +45 -0
  30. package/dist/internal-common/src/utils/array.d.ts +7 -0
  31. package/dist/internal-common/src/utils/e2e-test-utils.d.ts +2 -0
  32. package/dist/internal-common/src/utils/file-utils.d.ts +2 -0
  33. package/dist/internal-common/src/utils/global.utils.d.ts +1 -0
  34. package/dist/internal-common/src/utils/http.d.ts +11 -0
  35. package/dist/internal-common/src/utils/lock.manager.d.ts +14 -0
  36. package/dist/internal-common/src/utils/metric-utils.d.ts +4 -0
  37. package/dist/internal-common/src/utils/metrics.types.d.ts +7 -0
  38. package/dist/internal-common/src/utils/object.d.ts +86 -0
  39. package/dist/internal-common/src/utils/serialization.d.ts +18 -0
  40. package/dist/internal-common/src/utils/squid.constants.d.ts +6 -0
  41. package/dist/internal-common/src/utils/trace-id-generator.d.ts +1 -0
  42. package/dist/internal-common/src/utils/validation.d.ts +19 -0
  43. package/dist/internal-common/src/websocket.impl.d.ts +26 -0
  44. package/dist/typescript-client/src/version.d.ts +1 -1
  45. package/package.json +1 -1
@@ -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_aiChatbotChatReasoningTokens_count", "squid_aiChatbotChatCacheReadInputTokens_count", "squid_aiChatbotChatCacheWriteInputTokens_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_";
@@ -2,6 +2,7 @@ import { AgentContextRequest, AiChatModelSelection, UpsertContextStatusError } f
2
2
  import { AiEmbeddingsModelSelection, AiRerankProvider } from './ai-common.public-types';
3
3
  import { AiContextId, AiKnowledgeBaseId, AppId } from './communication.public-types';
4
4
  import { DocumentExtractionMethod } from './extraction.public-types';
5
+ import { MetadataAndFilter, MetadataFieldFilter, MetadataFilter, MetadataOrFilter, MetadataSimpleFilter, MetadataValue, MetadataValueArray } from './metadata-filter.public-types';
5
6
  /**
6
7
  * The set of supported vector store backends for a knowledge base. The authoritative backend for a
7
8
  * given KB is persisted on its record; reads/writes route through the matching vector provider.
@@ -57,67 +58,37 @@ export interface AiKnowledgeBaseMetadataField {
57
58
  export type AiContextMetadata = Record<string, AiContextMetadataValue>;
58
59
  /**
59
60
  * @category AI
61
+ * @deprecated Use {@link MetadataValue} from `metadata-filter.public-types` instead.
60
62
  */
61
- export type AiContextMetadataValue = number | string | boolean | undefined;
63
+ export type AiContextMetadataValue = MetadataValue;
62
64
  /**
63
65
  * @category AI
66
+ * @deprecated Use {@link MetadataValueArray} from `metadata-filter.public-types` instead.
64
67
  */
65
- export type AiContextMetadataValueArray = AiContextMetadataValue[];
66
- interface AiContextMetadataEqFilter {
67
- $eq: AiContextMetadataValue;
68
- }
69
- interface AiContextMetadataNeFilter {
70
- $ne: AiContextMetadataValue;
71
- }
72
- interface AiContextMetadataGtFilter {
73
- $gt: number;
74
- }
75
- interface AiContextMetadataGteFilter {
76
- $gte: number;
77
- }
78
- interface AiContextMetadataLtFilter {
79
- $lt: number;
80
- }
81
- interface AiContextMetadataLteFilter {
82
- $lte: number;
83
- }
84
- interface AiContextMetadataInFilter {
85
- $in: AiContextMetadataValueArray;
86
- }
87
- interface AiContextMetadataNinFilter {
88
- $nin: AiContextMetadataValueArray;
89
- }
90
- interface AiContextMetadataExistsFilter {
91
- $exists: boolean;
92
- }
68
+ export type AiContextMetadataValueArray = MetadataValueArray;
93
69
  /**
94
70
  * @category AI
71
+ * @deprecated Use {@link MetadataSimpleFilter} from `metadata-filter.public-types` instead.
95
72
  */
96
- export type AiContextMetadataSimpleFilter = AiContextMetadataEqFilter | AiContextMetadataNeFilter | AiContextMetadataGtFilter | AiContextMetadataGteFilter | AiContextMetadataLtFilter | AiContextMetadataLteFilter | AiContextMetadataInFilter | AiContextMetadataNinFilter | AiContextMetadataExistsFilter;
73
+ export type AiContextMetadataSimpleFilter = MetadataSimpleFilter;
97
74
  /**
98
75
  * A filter for AI context metadata based on field-specific conditions or values.
99
76
  * @category AI
77
+ * @deprecated Use {@link MetadataFieldFilter} from `metadata-filter.public-types` instead.
100
78
  */
101
- export interface AiContextMetadataFieldFilter {
102
- /** A record where keys are field names and values are either simple filters or direct metadata values. */
103
- [field: string]: AiContextMetadataSimpleFilter | AiContextMetadataValue;
104
- }
79
+ export type AiContextMetadataFieldFilter = MetadataFieldFilter;
105
80
  /**
106
81
  * A filter combining multiple AI context metadata filters with a logical AND operation.
107
82
  * @category AI
83
+ * @deprecated Use {@link MetadataAndFilter} from `metadata-filter.public-types` instead.
108
84
  */
109
- export interface AiContextMetadataAndFilter {
110
- /** An array of filters that must all be true for the condition to pass. */
111
- $and: AiContextMetadataFilter[];
112
- }
85
+ export type AiContextMetadataAndFilter = MetadataAndFilter;
113
86
  /**
114
87
  * A filter combining multiple AI context metadata filters with a logical OR operation.
115
88
  * @category AI
89
+ * @deprecated Use {@link MetadataOrFilter} from `metadata-filter.public-types` instead.
116
90
  */
117
- export interface AiContextMetadataOrFilter {
118
- /** An array of filters where at least one must be true for the condition to pass. */
119
- $or: AiContextMetadataFilter[];
120
- }
91
+ export type AiContextMetadataOrFilter = MetadataOrFilter;
121
92
  /**
122
93
  * The options for the AI knowledgebase search method.
123
94
  * @category AI
@@ -167,8 +138,9 @@ export interface AiHybridSearchWeights {
167
138
  }
168
139
  /**
169
140
  * @category AI
141
+ * @deprecated Use {@link MetadataFilter} from `metadata-filter.public-types` instead.
170
142
  */
171
- export type AiContextMetadataFilter = AiContextMetadataFieldFilter | AiContextMetadataAndFilter | AiContextMetadataOrFilter;
143
+ export type AiContextMetadataFilter = MetadataFilter;
172
144
  /**
173
145
  * Represents an AI knowledge base's context entry with metadata and content.
174
146
  * @category AI
@@ -35,6 +35,15 @@ export interface ExtractDataFromDocumentOptions {
35
35
  * the content. Only consulted by extractors that handle text input.
36
36
  */
37
37
  textFormat?: 'auto' | 'markdown' | 'html' | 'plain';
38
+ /**
39
+ * Whether to read document-level properties (title/author/dates) from the source container and
40
+ * return them as `documentMetadata`. Off by default: container parsing has a real per-file cost
41
+ * (zip/PDF re-parse), so callers opt in only when the owning knowledge base declares metadata fields.
42
+ *
43
+ * Honored only by file-based extraction (which owns the original buffer for every format);
44
+ * URL-based extraction ignores it and never returns `documentMetadata`.
45
+ */
46
+ collectDocumentMetadata?: boolean;
38
47
  }
39
48
  /**
40
49
  * Request payload for extracting data from a document via URL.
@@ -108,6 +117,11 @@ export interface ExtractDataFromDocumentResponse {
108
117
  * Path to the original file in cloud storage, if applicable.
109
118
  */
110
119
  longTermStoragePath?: string;
120
+ /**
121
+ * Document-level metadata extracted from the source container (best-effort). Present only when the
122
+ * extractor was able to read it.
123
+ */
124
+ documentMetadata?: DocumentMetadata;
111
125
  }
112
126
  /**
113
127
  * Create PDF request type.
@@ -186,3 +200,22 @@ export interface CreatePdfResponse {
186
200
  /** The generated filename. */
187
201
  fileName?: string;
188
202
  }
203
+ /**
204
+ * Document-level properties read from the source container during extraction. Every field is optional
205
+ * and best-effort: when a container does not expose a property (or parsing fails) the field is simply
206
+ * absent. Consumed by schema-driven metadata extraction as the deterministic source for matching
207
+ * knowledge-base `metadataFields` before falling back to LLM extraction.
208
+ * @category AI
209
+ */
210
+ export interface DocumentMetadata {
211
+ /** Document title (e.g. OOXML `dc:title`, PDF `/Title`, front-matter `title`, `<title>`). */
212
+ docTitle?: string;
213
+ /** Document author (e.g. OOXML `dc:creator`, PDF `/Author`, front-matter / `<meta author>`). */
214
+ docAuthor?: string;
215
+ /** Creation timestamp, ISO 8601. */
216
+ docCreatedAt?: string;
217
+ /** Last-modified timestamp, ISO 8601. */
218
+ docModifiedAt?: string;
219
+ /** Source document type: `pdf` | `docx` | `pptx` | `xlsx` | `md` | `html` | `txt`. */
220
+ docType?: string;
221
+ }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Generic metadata filter types used across the platform.
3
+ *
4
+ * These types define a MongoDB-style filter syntax for filtering records by metadata
5
+ * fields. They support field-level operators (`$eq`, `$ne`, `$gt`, `$gte`, `$lt`,
6
+ * `$lte`, `$in`, `$nin`, `$exists`) and boolean combinators (`$and`, `$or`).
7
+ *
8
+ * Originally created for AI knowledge base context filtering, these types are now
9
+ * shared across metrics tag filtering, matchmaking, and other subsystems.
10
+ */
11
+ /** Primitive metadata value. */
12
+ export type MetadataValue = number | string | boolean | undefined;
13
+ /** Array of metadata values (used by `$in` / `$nin`). */
14
+ export type MetadataValueArray = MetadataValue[];
15
+ interface MetadataEqFilter {
16
+ $eq: MetadataValue;
17
+ }
18
+ interface MetadataNeFilter {
19
+ $ne: MetadataValue;
20
+ }
21
+ interface MetadataGtFilter {
22
+ $gt: number;
23
+ }
24
+ interface MetadataGteFilter {
25
+ $gte: number;
26
+ }
27
+ interface MetadataLtFilter {
28
+ $lt: number;
29
+ }
30
+ interface MetadataLteFilter {
31
+ $lte: number;
32
+ }
33
+ interface MetadataInFilter {
34
+ $in: MetadataValueArray;
35
+ }
36
+ interface MetadataNinFilter {
37
+ $nin: MetadataValueArray;
38
+ }
39
+ interface MetadataExistsFilter {
40
+ $exists: boolean;
41
+ }
42
+ /** A single-field operator: one of `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`, `$in`, `$nin`, `$exists`. */
43
+ export type MetadataSimpleFilter = MetadataEqFilter | MetadataNeFilter | MetadataGtFilter | MetadataGteFilter | MetadataLtFilter | MetadataLteFilter | MetadataInFilter | MetadataNinFilter | MetadataExistsFilter;
44
+ /**
45
+ * A filter for metadata based on field-specific conditions or direct values.
46
+ * @category Metadata
47
+ */
48
+ export interface MetadataFieldFilter {
49
+ /** A record where keys are field names and values are either operator objects or direct scalar values. */
50
+ [field: string]: MetadataSimpleFilter | MetadataValue;
51
+ }
52
+ /**
53
+ * A filter combining multiple metadata filters with a logical AND operation.
54
+ * @category Metadata
55
+ */
56
+ export interface MetadataAndFilter {
57
+ /** An array of filters that must all be true for the condition to pass. */
58
+ $and: MetadataFilter[];
59
+ }
60
+ /**
61
+ * A filter combining multiple metadata filters with a logical OR operation.
62
+ * @category Metadata
63
+ */
64
+ export interface MetadataOrFilter {
65
+ /** An array of filters where at least one must be true for the condition to pass. */
66
+ $or: MetadataFilter[];
67
+ }
68
+ /**
69
+ * A composable metadata filter supporting field operators and boolean combinators.
70
+ *
71
+ * @example Simple equality
72
+ * ```ts
73
+ * { status: 'active' }
74
+ * ```
75
+ * @example Operators
76
+ * ```ts
77
+ * { age: { $gte: 18 }, role: { $in: ['admin', 'editor'] } }
78
+ * ```
79
+ * @example Boolean combinators
80
+ * ```ts
81
+ * { $or: [{ status: 'active' }, { role: { $ne: 'guest' } }] }
82
+ * ```
83
+ */
84
+ export type MetadataFilter = MetadataFieldFilter | MetadataAndFilter | MetadataOrFilter;
85
+ export {};
@@ -1,3 +1,11 @@
1
+ import { MetadataFilter } from './metadata-filter.public-types';
2
+ /**
3
+ * Tag filter for metric queries. Accepts either a simple key-value record (backward compatible)
4
+ * or the full {@link MetadataFilter} tree with `$eq`, `$ne`, `$in`, `$nin`, `$exists`,
5
+ * `$gt`, `$gte`, `$lt`, `$lte`, `$and`, `$or`.
6
+ * @category Metrics
7
+ */
8
+ export type MetricTagFilter = Record<string, string> | MetadataFilter;
1
9
  /**
2
10
  * Name of metrics publicly provided by the system.
3
11
  * - Metrics suffixed by '_time' are 'gauge' metrics.
@@ -49,10 +57,22 @@ export interface QueryMetricsRequestCommon {
49
57
  */
50
58
  fillValue?: number | null;
51
59
  /**
52
- * Tag filters.
53
- * TODO: add operations to exclude tags: !=, !contains...
60
+ * Tag filters. Supports two formats:
61
+ * - Simple: `Record<string, string>` — each key-value pair is an exact equality match.
62
+ * - Advanced: `AiContextMetadataFilter` — the same filter syntax used by AI knowledge base
63
+ * metadata, supporting `$eq`, `$ne`, `$in`, `$nin`, `$exists`, `$and`, `$or`, and
64
+ * comparison operators (`$gt`, `$gte`, `$lt`, `$lte` — numeric comparisons on string tags).
65
+ *
66
+ * @example Simple format
67
+ * ```ts
68
+ * tagFilter: { aiModel: 'claude-sonnet-4-5-20250514', isError: '0' }
69
+ * ```
70
+ * @example Advanced format
71
+ * ```ts
72
+ * tagFilter: { $or: [{ aiModel: { $in: ['claude-sonnet-4-5-20250514', 'gpt-4o'] } }, { isError: { $ne: '0' } }] }
73
+ * ```
54
74
  */
55
- tagFilter?: Record<string, string>;
75
+ tagFilter?: MetricTagFilter;
56
76
  /**
57
77
  * A mapping of known tag values that must be present in the response groups.
58
78
  *
@@ -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 {};