@squidcloud/client 1.0.486 → 1.0.488
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 +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/internal-common/src/ai/system-openai-compatible.d.ts +35 -0
- package/dist/internal-common/src/metric-name.d.ts +14 -0
- package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +57 -2
- package/dist/internal-common/src/public-types/ai-knowledge-base.public-types.d.ts +26 -8
- package/dist/internal-common/src/public-types-backend/api-call.public-context.d.ts +30 -0
- package/dist/internal-common/src/public-types-backend/mutation.public-context.d.ts +161 -0
- package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +75 -0
- package/dist/internal-common/src/public-types-backend/query.public-context.d.ts +193 -0
- package/dist/internal-common/src/types/ai-agent.types.d.ts +302 -0
- package/dist/internal-common/src/types/ai-knowledge-base.types.d.ts +306 -0
- package/dist/internal-common/src/types/ai-matchmaking.types.d.ts +19 -0
- package/dist/internal-common/src/types/backend-function.types.d.ts +1 -0
- package/dist/internal-common/src/types/communication.types.d.ts +1 -0
- package/dist/internal-common/src/types/document.types.d.ts +1 -0
- package/dist/internal-common/src/types/file.types.d.ts +6 -0
- package/dist/internal-common/src/types/headers.types.d.ts +41 -0
- package/dist/internal-common/src/types/management-api-key.types.d.ts +92 -0
- package/dist/internal-common/src/types/mutation.types.d.ts +1 -0
- package/dist/internal-common/src/types/notification.types.d.ts +19 -0
- package/dist/internal-common/src/types/observability.types.d.ts +168 -0
- package/dist/internal-common/src/types/query.types.d.ts +15 -0
- package/dist/internal-common/src/types/secret.types.d.ts +7 -0
- package/dist/internal-common/src/types/socket.types.d.ts +1 -0
- package/dist/internal-common/src/types/stage.d.ts +9 -0
- package/dist/internal-common/src/types/time-units.d.ts +1 -0
- package/dist/internal-common/src/types/url-shortener.types.d.ts +45 -0
- package/dist/internal-common/src/utils/array.d.ts +7 -0
- package/dist/internal-common/src/utils/e2e-test-utils.d.ts +2 -0
- package/dist/internal-common/src/utils/file-utils.d.ts +2 -0
- package/dist/internal-common/src/utils/global.utils.d.ts +1 -0
- package/dist/internal-common/src/utils/http.d.ts +10 -0
- package/dist/internal-common/src/utils/lock.manager.d.ts +14 -0
- package/dist/internal-common/src/utils/metric-utils.d.ts +4 -0
- package/dist/internal-common/src/utils/metrics.types.d.ts +7 -0
- package/dist/internal-common/src/utils/object.d.ts +86 -0
- package/dist/internal-common/src/utils/serialization.d.ts +24 -0
- package/dist/internal-common/src/utils/squid.constants.d.ts +6 -0
- package/dist/internal-common/src/utils/trace-id-generator.d.ts +1 -0
- package/dist/internal-common/src/utils/validation.d.ts +19 -0
- package/dist/internal-common/src/websocket.impl.d.ts +26 -0
- package/dist/typescript-client/src/agent/ai-agent-client-reference.d.ts +7 -1
- package/dist/typescript-client/src/ai-knowledge-base/ai-knowledge-base-client-reference.d.ts +6 -6
- package/dist/typescript-client/src/ai-status-updates.d.ts +1 -0
- package/dist/typescript-client/src/index.d.ts +1 -0
- package/dist/typescript-client/src/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System-level OpenAI-compatible backends ("slots") for Squid's own internal AI calls.
|
|
3
|
+
*
|
|
4
|
+
* Generic plumbing for pointing an internal model at ANY OpenAI-compatible HTTP endpoint —
|
|
5
|
+
* primarily Squid's own self-hosted models, but any OpenAI-compatible backend works. The
|
|
6
|
+
* non-secret part of a slot (base URL, optional headers/extra body) is hardcoded here on purpose
|
|
7
|
+
* (changing a backend is a reviewed code change); only the API key lives in Vault under
|
|
8
|
+
* `SystemSecrets['openai-compatible'][slotName].apiKey`.
|
|
9
|
+
*
|
|
10
|
+
* NOT the customer-facing `openai_compatible` Integration (per-app, console-configured). Models
|
|
11
|
+
* served through these slots are declared in `AI_CHAT_MODEL_REGISTRY` with
|
|
12
|
+
* `providerType: 'openai-compatible'` + `openAiCompatibleSlot`, and resolve only with
|
|
13
|
+
* `keyType: 'system'` (see `AiProviderFactory.getChatProviderForModel`) — never customer-reachable.
|
|
14
|
+
*
|
|
15
|
+
* No slots are defined yet (foundation only). To wire one up:
|
|
16
|
+
* 1. add a slot below, e.g. `'my-model': { baseUrl: 'https://llm.internal.squid/v1' }`;
|
|
17
|
+
* 2. seed its key in `SystemSecrets['openai-compatible']['my-model'].apiKey`;
|
|
18
|
+
* 3. add a model entry in ai-model.registry.ts pointing `openAiCompatibleSlot: 'my-model'`.
|
|
19
|
+
*/
|
|
20
|
+
/** Non-secret configuration of one system OpenAI-compatible backend. */
|
|
21
|
+
export interface SystemOpenAiCompatibleSlotConfig {
|
|
22
|
+
/** Base URL of the OpenAI-compatible API, e.g. a self-hosted 'https://llm.internal.squid/v1'. */
|
|
23
|
+
baseUrl: string;
|
|
24
|
+
/** Extra HTTP headers sent with every request. */
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
/** Extra JSON body fields merged into every request — reserved wire fields are dropped by the provider. */
|
|
27
|
+
extraBody?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
/** Name of a system OpenAI-compatible slot (a key of `SYSTEM_OPENAI_COMPATIBLE_SLOTS`). */
|
|
30
|
+
export type SystemOpenAiCompatibleSlotName = string;
|
|
31
|
+
/**
|
|
32
|
+
* Registered system OpenAI-compatible slots, keyed by name. Empty by design — add a self-hosted
|
|
33
|
+
* (or any other) OpenAI-compatible backend here; see the module doc above.
|
|
34
|
+
*/
|
|
35
|
+
export declare const SYSTEM_OPENAI_COMPATIBLE_SLOTS: Record<SystemOpenAiCompatibleSlotName, SystemOpenAiCompatibleSlotConfig>;
|
|
@@ -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_aiChatbotChatCostUsd_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_sourceCodeAnalysis_count", "squid_sourceCodeAnalysis_time", "squid_sourceCodeWorkspaceBytes_value", "squid_sourceCodeInputTokens_count", "squid_sourceCodeOutputTokens_count", "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_apiControllerCall_count", "squid_apiControllerCall_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_queueMessageHandler_count", "squid_queueMessageHandler_time", "squid_registerQuery_count", "squid_registerQuery_time", "squid_rerankChunks_count", "squid_rerankChunks_time", "squid_schedulerJob_count", "squid_schedulerJob_time", "squid_eventHandler_count", "squid_eventHandler_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_";
|
|
@@ -505,6 +505,11 @@ export interface BaseAiChatOptions {
|
|
|
505
505
|
temperature?: number;
|
|
506
506
|
/** Preset instruction options that can be toggled on */
|
|
507
507
|
guardrails?: GuardrailsOptions;
|
|
508
|
+
/**
|
|
509
|
+
* Refuses prompts that carry PII before they reach the model. Read from the stored agent only —
|
|
510
|
+
* a value passed with a chat request is ignored, so a caller cannot switch off its own screening.
|
|
511
|
+
*/
|
|
512
|
+
pii?: AiPiiOptions;
|
|
508
513
|
/** The LLM model to use. Can be a vendor model name (string) or an integration-based model (object). */
|
|
509
514
|
model?: AiChatModelSelection;
|
|
510
515
|
/** Which provider's reranker to use for reranking the context. Defaults to 'cohere'. */
|
|
@@ -1077,6 +1082,56 @@ export type GuardrailsOptions = {
|
|
|
1077
1082
|
/** A custom guardrail instruction, if specified. */
|
|
1078
1083
|
custom?: string;
|
|
1079
1084
|
};
|
|
1085
|
+
/**
|
|
1086
|
+
* PII kinds a prompt can be screened for. Each one is judged in context by the screening model, so
|
|
1087
|
+
* a value is classified by what the prompt says it is rather than by which format it happens to fit.
|
|
1088
|
+
* @category AI
|
|
1089
|
+
*/
|
|
1090
|
+
export type AiPiiEntityType = 'email' | 'phoneNumber' | 'creditCard' | 'ssn' | 'iban' | 'passport';
|
|
1091
|
+
/** Entity kinds screened when {@link AiPiiOptions.entities} is omitted. */
|
|
1092
|
+
export declare const DEFAULT_PII_ENTITY_TYPES: ReadonlyArray<AiPiiEntityType>;
|
|
1093
|
+
/** Model that screens prompts unless overridden. Small and fast: it runs on every prompt. */
|
|
1094
|
+
export declare const DEFAULT_PII_CLASSIFIER_MODEL = "gpt-5.6-luna";
|
|
1095
|
+
/**
|
|
1096
|
+
* Rejects a prompt before it reaches the agent's model when it carries PII, so the prompt is never
|
|
1097
|
+
* sent to the model provider, never answered, and never written to chat memory.
|
|
1098
|
+
*
|
|
1099
|
+
* Screening is one {@link classifierModel} call per prompt, covering {@link entities} and
|
|
1100
|
+
* {@link customRules} together. Because a model does the reading rather than a pattern, a value is
|
|
1101
|
+
* judged by what the prompt says it is, and app-specific identifiers can be described in plain
|
|
1102
|
+
* language instead of expressed as a format.
|
|
1103
|
+
*
|
|
1104
|
+
* This is the inverse of {@link GuardrailsOptions.disablePii}, which asks the agent's own model not
|
|
1105
|
+
* to *emit* PII in its answer.
|
|
1106
|
+
* @category AI
|
|
1107
|
+
*/
|
|
1108
|
+
export type AiPiiOptions = {
|
|
1109
|
+
/** `reject` refuses a prompt carrying PII; `off` (default) disables screening entirely. */
|
|
1110
|
+
onDetect: 'off' | 'reject';
|
|
1111
|
+
/** Entity kinds to screen for. Defaults to {@link DEFAULT_PII_ENTITY_TYPES}. */
|
|
1112
|
+
entities?: Array<AiPiiEntityType>;
|
|
1113
|
+
/** App-specific PII in plain language, e.g. `'internal case numbers like CASE-12345'`. */
|
|
1114
|
+
customRules?: Array<string>;
|
|
1115
|
+
/** Model performing the screening. Defaults to {@link DEFAULT_PII_CLASSIFIER_MODEL}. */
|
|
1116
|
+
classifierModel?: AiChatModelSelection;
|
|
1117
|
+
/** Literal values that never count as PII, e.g. a shared support address. */
|
|
1118
|
+
allowList?: Array<string>;
|
|
1119
|
+
};
|
|
1120
|
+
/**
|
|
1121
|
+
* Outcome of screening one prompt. On a detection the prompt is replaced by {@link redactedPrompt}
|
|
1122
|
+
* everywhere it would otherwise be stored, so the audit trail records that a request was refused
|
|
1123
|
+
* and why without restating the values that caused it.
|
|
1124
|
+
* @category AI
|
|
1125
|
+
*/
|
|
1126
|
+
export type AiPiiScanResult = {
|
|
1127
|
+
detected: false;
|
|
1128
|
+
} | {
|
|
1129
|
+
detected: true;
|
|
1130
|
+
/** Entity kinds and custom-rule names that matched. Never the matched values. */
|
|
1131
|
+
matchedTypes: Array<string>;
|
|
1132
|
+
/** The prompt with every match replaced by a `[REDACTED:<type>]` placeholder. */
|
|
1133
|
+
redactedPrompt: string;
|
|
1134
|
+
};
|
|
1080
1135
|
/**
|
|
1081
1136
|
* Response structure for transcribing audio and asking an AI agent a question.
|
|
1082
1137
|
* @category AI
|
|
@@ -1146,8 +1201,8 @@ export type AiSessionContext = {
|
|
|
1146
1201
|
/** The ID of the job associated with the session. */
|
|
1147
1202
|
jobId: JobId;
|
|
1148
1203
|
/**
|
|
1149
|
-
* The conversation this call belongs to, as the caller named it (`memoryOptions.memoryId
|
|
1150
|
-
*
|
|
1204
|
+
* The conversation this call belongs to, as the caller named it (`memoryOptions.memoryId`).
|
|
1205
|
+
* Stable across the turns of one chat and different for two chats, including
|
|
1151
1206
|
* two chats of the same client, which `clientId` is not: a client id belongs to a connection, and
|
|
1152
1207
|
* one connection can carry several conversations. Not the id chat history is keyed by — that one
|
|
1153
1208
|
* falls back to `clientId` — so do not read it as one. Absent for callers that named no conversation
|
|
@@ -161,8 +161,9 @@ export interface AiKnowledgeBaseGraphSearchOptions {
|
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
163
|
* Per-knowledge-base GraphRAG configuration. Opt-in and mutable (unlike `embeddingModel`/`vectorDbType`);
|
|
164
|
-
* only honored for `vectorDbType:'mongoAtlas'` KBs. Enabling it on a KB that already has content
|
|
165
|
-
* graph
|
|
164
|
+
* only honored for `vectorDbType:'mongoAtlas'` KBs. Enabling it on a KB that already has content backfills
|
|
165
|
+
* the graph automatically (a debounced structural build runs once the KB goes quiet); the `rebuildGraph`
|
|
166
|
+
* endpoint remains available for an immediate or full rebuild.
|
|
166
167
|
* @category AI
|
|
167
168
|
*/
|
|
168
169
|
export interface AiKnowledgeBaseGraphConfig {
|
|
@@ -172,6 +173,12 @@ export interface AiKnowledgeBaseGraphConfig {
|
|
|
172
173
|
extractionModel?: AiChatModelSelection;
|
|
173
174
|
/** Optional domain taxonomy hint (entity types) injected into the extraction prompt. */
|
|
174
175
|
entityTypes?: string[];
|
|
176
|
+
/**
|
|
177
|
+
* Quiet window (milliseconds) after the last graph activity before the sweep auto-builds the
|
|
178
|
+
* structure. Must be a positive integer. Defaults to the server's window (5 minutes); the sweep
|
|
179
|
+
* cadence (1 minute) bounds how promptly an elapsed window is picked up.
|
|
180
|
+
*/
|
|
181
|
+
autoBuildDebounceMs?: number;
|
|
175
182
|
/** Concept-layer (facet taxonomy) configuration. Omitted ⇒ `facets: 'auto'`. */
|
|
176
183
|
concepts?: AiKnowledgeBaseGraphConceptsConfig;
|
|
177
184
|
}
|
|
@@ -1085,6 +1092,13 @@ export interface GetKnowledgeBaseGraphStatusResponse {
|
|
|
1085
1092
|
* {@link ingestUsage}.
|
|
1086
1093
|
*/
|
|
1087
1094
|
combinedIngestUsage?: KnowledgeBaseGraphUsage;
|
|
1095
|
+
/** When a structural/full rebuild last completed successfully (epoch millis), when one ever has. */
|
|
1096
|
+
lastStructureBuildAt?: number;
|
|
1097
|
+
/**
|
|
1098
|
+
* When the debounced auto-build sweep will pick the KB up (epoch millis), present while an auto-build
|
|
1099
|
+
* is pending. Recomputed per poll — it moves forward while ingest activity continues.
|
|
1100
|
+
*/
|
|
1101
|
+
nextAutoBuildAt?: number;
|
|
1088
1102
|
}
|
|
1089
1103
|
/** The most recent graph backfill/rebuild job of a knowledge base. @category AI */
|
|
1090
1104
|
export interface KnowledgeBaseGraphBuildJob {
|
|
@@ -1092,6 +1106,8 @@ export interface KnowledgeBaseGraphBuildJob {
|
|
|
1092
1106
|
status: 'in_progress' | 'completed' | 'failed';
|
|
1093
1107
|
/** Failure message, present when `status` is `'failed'`. */
|
|
1094
1108
|
error?: string;
|
|
1109
|
+
/** When the job was enqueued (epoch millis). */
|
|
1110
|
+
startedAt?: number;
|
|
1095
1111
|
}
|
|
1096
1112
|
/**
|
|
1097
1113
|
* Aggregated LLM token usage (and best-effort cost) of graph work on a KB. Token counts are the
|
|
@@ -1172,13 +1188,15 @@ export interface KnowledgeBaseGraphFacetValueStatus {
|
|
|
1172
1188
|
/**
|
|
1173
1189
|
* How much of the knowledge base's graph a rebuild recomputes.
|
|
1174
1190
|
*
|
|
1191
|
+
* - `'structural'` (default) — keeps the already-extracted entity graph (LLM extraction runs only for
|
|
1192
|
+
* contexts that were never graph-indexed, e.g. after an interrupted ingest) and recomputes the
|
|
1193
|
+
* derived structure on top of it: entity resolution, lexical mentions, topics and facets. Typically
|
|
1194
|
+
* a small fraction of a full rebuild's cost — the right choice for folding freshly ingested
|
|
1195
|
+
* documents into topics/facets.
|
|
1175
1196
|
* - `'full'` — wipes the graph and re-extracts entities/relationships from every chunk with an LLM,
|
|
1176
1197
|
* then rebuilds the concept layer. The expensive deep-clean: re-extraction dominates its cost.
|
|
1177
|
-
*
|
|
1178
|
-
*
|
|
1179
|
-
* structure on top of it: entity resolution, lexical mentions, topics and facets. Typically a small
|
|
1180
|
-
* fraction of a full rebuild's cost — the right choice for folding freshly ingested documents into
|
|
1181
|
-
* topics/facets.
|
|
1198
|
+
* Only needed when the extraction itself must be redone, e.g. after changing `entityTypes` or
|
|
1199
|
+
* `extractionModel`.
|
|
1182
1200
|
* @category AI
|
|
1183
1201
|
*/
|
|
1184
1202
|
export type KnowledgeBaseGraphRebuildMode = 'full' | 'structural';
|
|
@@ -1189,7 +1207,7 @@ export type KnowledgeBaseGraphRebuildMode = 'full' | 'structural';
|
|
|
1189
1207
|
export interface RebuildKnowledgeBaseGraphRequest {
|
|
1190
1208
|
/** The id of the AiKnowledgeBase. */
|
|
1191
1209
|
knowledgeBaseId: AiKnowledgeBaseId;
|
|
1192
|
-
/** What to recompute (see {@link KnowledgeBaseGraphRebuildMode}). Default `'
|
|
1210
|
+
/** What to recompute (see {@link KnowledgeBaseGraphRebuildMode}). Default `'structural'`. */
|
|
1193
1211
|
mode?: KnowledgeBaseGraphRebuildMode;
|
|
1194
1212
|
}
|
|
1195
1213
|
/**
|
|
@@ -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,161 @@
|
|
|
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
|
+
/**
|
|
13
|
+
* Base fields shared by all document mutations.
|
|
14
|
+
* @category Database
|
|
15
|
+
*/
|
|
16
|
+
export interface BaseMutation {
|
|
17
|
+
/** The type of the mutation. */
|
|
18
|
+
type: MutationType;
|
|
19
|
+
/** The identity of the mutated document. */
|
|
20
|
+
squidDocIdObj: SquidDocIdObj;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A mutation on a document.
|
|
24
|
+
* @category Database
|
|
25
|
+
*/
|
|
26
|
+
export type Mutation<T = any> = UpdateMutation<T> | InsertMutation<T> | DeleteMutation;
|
|
27
|
+
/**
|
|
28
|
+
* Represents a delete mutation on a document.
|
|
29
|
+
* @category Database
|
|
30
|
+
*/
|
|
31
|
+
export interface DeleteMutation extends BaseMutation {
|
|
32
|
+
/** Specifies that the mutation is a deletion. */
|
|
33
|
+
type: 'delete';
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Represents an update mutation on a document.
|
|
37
|
+
* @category Database
|
|
38
|
+
*/
|
|
39
|
+
export interface UpdateMutation<T = any> extends BaseMutation {
|
|
40
|
+
/** Specifies that the mutation is an update. */
|
|
41
|
+
type: 'update';
|
|
42
|
+
/** The updated properties */
|
|
43
|
+
properties: {
|
|
44
|
+
[key in keyof T & string]?: Array<PropertyMutation<T[key]>>;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Represents an insert mutation on a document.
|
|
49
|
+
* @category Database
|
|
50
|
+
*/
|
|
51
|
+
export interface InsertMutation<T = any> extends BaseMutation {
|
|
52
|
+
/** Specifies that the mutation is an insertion. */
|
|
53
|
+
type: 'insert';
|
|
54
|
+
/** The inserted document */
|
|
55
|
+
properties: T;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A representation of a single property update.
|
|
59
|
+
* @category Database
|
|
60
|
+
*/
|
|
61
|
+
export type PropertyMutation<Value = any> = ApplyNumericFnPropertyMutation | ApplyStringFnPropertyMutation | ValueUpdatePropertyMutation<Value> | RemovePropertyMutation;
|
|
62
|
+
/**
|
|
63
|
+
* A value update property mutation.
|
|
64
|
+
* @category Database
|
|
65
|
+
*/
|
|
66
|
+
export interface ValueUpdatePropertyMutation<Value = any> {
|
|
67
|
+
/** Specifies that the mutation updates a value. */
|
|
68
|
+
type: 'update';
|
|
69
|
+
/** New value to be set. */
|
|
70
|
+
value: Value;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Applying a numeric function to a property.
|
|
74
|
+
* @category Database
|
|
75
|
+
*/
|
|
76
|
+
export interface ApplyNumericFnPropertyMutation {
|
|
77
|
+
/** Specifies that the mutation applies a numeric function. */
|
|
78
|
+
type: 'applyNumericFn';
|
|
79
|
+
/** Numeric function to apply. */
|
|
80
|
+
fn: 'increment';
|
|
81
|
+
/** Value to use in the numeric function. */
|
|
82
|
+
value: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A property update that removes a property from a document.
|
|
86
|
+
* @category Database
|
|
87
|
+
*/
|
|
88
|
+
export interface RemovePropertyMutation {
|
|
89
|
+
/** Specifies that the mutation removes a property. */
|
|
90
|
+
type: 'removeProperty';
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A property mutation that appends a value to the existing string.
|
|
94
|
+
* @category Database
|
|
95
|
+
*/
|
|
96
|
+
export interface ApplyExtendString {
|
|
97
|
+
/** Specifies that the mutation applies a string function. */
|
|
98
|
+
type: 'applyStringFn';
|
|
99
|
+
/** String function to extend the existing string. */
|
|
100
|
+
fn: 'extendString';
|
|
101
|
+
/** String value to append. */
|
|
102
|
+
value: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* A property mutation that trims the existing string.
|
|
106
|
+
* @category Database
|
|
107
|
+
*/
|
|
108
|
+
export interface ApplyTrimString {
|
|
109
|
+
/** Specifies that the mutation applies a string function. */
|
|
110
|
+
type: 'applyStringFn';
|
|
111
|
+
/** String function to trim the existing string. */
|
|
112
|
+
fn: 'trim';
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* A property mutation that modifies a string.
|
|
116
|
+
* @category Database
|
|
117
|
+
*/
|
|
118
|
+
export type ApplyStringFnPropertyMutation = ApplyExtendString | ApplyTrimString;
|
|
119
|
+
/**
|
|
120
|
+
* The before and after documents of a document change.
|
|
121
|
+
* @category Database
|
|
122
|
+
*/
|
|
123
|
+
export interface BeforeAndAfterDocs<T = SquidDocument> {
|
|
124
|
+
/** Document state before the mutation. */
|
|
125
|
+
before: T | undefined;
|
|
126
|
+
/** Document state after the mutation. */
|
|
127
|
+
after: T | undefined;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The mutation context that will be provided to the security function.
|
|
131
|
+
* @category Database
|
|
132
|
+
*/
|
|
133
|
+
export declare class MutationContext<T = any> {
|
|
134
|
+
readonly mutation: Mutation<T>;
|
|
135
|
+
readonly beforeAndAfterDocs: BeforeAndAfterDocs<T>;
|
|
136
|
+
readonly serverTimeStamp: Date;
|
|
137
|
+
/**
|
|
138
|
+
* Returns the state of the document before the mutation was applied.
|
|
139
|
+
*/
|
|
140
|
+
get before(): T | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Returns the state of the document after the mutation was applied.
|
|
143
|
+
*/
|
|
144
|
+
get after(): T | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Returns the type of the mutation (insert, update, or delete).
|
|
147
|
+
*/
|
|
148
|
+
getMutationType(): MutationType;
|
|
149
|
+
/** Returns true if the mutation affects the provided path. */
|
|
150
|
+
affectsPath(path: Paths<T>): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Find all affected paths starting from a root path.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* doc before - { a: { b: 1, c: 2 }, d: 3 }
|
|
156
|
+
* doc after - { a: { b: 1, c: 3 }, d: 4 }
|
|
157
|
+
* doc.affectedPaths('a') // ['a.c']
|
|
158
|
+
*/
|
|
159
|
+
affectedPaths(startingRoot?: Paths<T> | string): Array<Paths<T>>;
|
|
160
|
+
private checkPath;
|
|
161
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* Base fields shared by all native query contexts.
|
|
9
|
+
* @category Database
|
|
10
|
+
*/
|
|
11
|
+
export interface BaseNativeQueryContext {
|
|
12
|
+
/** Type of the native query request. */
|
|
13
|
+
type: NativeQueryRequestType;
|
|
14
|
+
/** Identifier for the integration. */
|
|
15
|
+
integrationId: IntegrationId;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Context for executing a relational database query.
|
|
19
|
+
* @category Database
|
|
20
|
+
*/
|
|
21
|
+
export interface RelationalNativeQueryContext extends BaseNativeQueryContext {
|
|
22
|
+
/** Specifies that the query is for a relational database. */
|
|
23
|
+
type: 'relational';
|
|
24
|
+
/** SQL query string to be executed. */
|
|
25
|
+
query: string;
|
|
26
|
+
/** Parameters to be used in the query. */
|
|
27
|
+
params: Record<string, any>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Context for executing a MongoDB query.
|
|
31
|
+
* @category Database
|
|
32
|
+
*/
|
|
33
|
+
export interface MongoNativeQueryContext extends BaseNativeQueryContext {
|
|
34
|
+
/** Specifies that the query is for a Mongo database. */
|
|
35
|
+
type: 'mongo';
|
|
36
|
+
/** Name of the MongoDB collection to query. */
|
|
37
|
+
collectionName: string;
|
|
38
|
+
/** Array of aggregation pipeline stages. */
|
|
39
|
+
aggregationPipeline: Array<any | undefined>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Context for executing an Elasticsearch query.
|
|
43
|
+
* @category Database
|
|
44
|
+
*/
|
|
45
|
+
export interface ElasticsearchNativeQueryContext {
|
|
46
|
+
/** Specifies that the query is for an Elasticsearch database. */
|
|
47
|
+
type: 'elasticsearch';
|
|
48
|
+
/** Elasticsearch index to query. */
|
|
49
|
+
index: string;
|
|
50
|
+
/** Elasticsearch query string. */
|
|
51
|
+
endpoint?: string;
|
|
52
|
+
/** HTTP method to use for the request. */
|
|
53
|
+
method?: 'GET' | 'POST';
|
|
54
|
+
/** Body of the request. */
|
|
55
|
+
body: Record<string, any>;
|
|
56
|
+
/** Headers to include in the request. */
|
|
57
|
+
integrationId: IntegrationId;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Context for executing a pure database query.
|
|
61
|
+
* @category Database
|
|
62
|
+
*/
|
|
63
|
+
export interface PureNativeQueryContext extends BaseNativeQueryContext {
|
|
64
|
+
/** Specifies that the query is for a relational database. */
|
|
65
|
+
type: 'pure';
|
|
66
|
+
/** SQL query string to be executed. */
|
|
67
|
+
query: string;
|
|
68
|
+
/** Parameters to be used in the query. */
|
|
69
|
+
params: Record<string, any>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Union type representing either a relational or MongoDB native query context.
|
|
73
|
+
* @category Database
|
|
74
|
+
*/
|
|
75
|
+
export type NativeQueryContext = RelationalNativeQueryContext | MongoNativeQueryContext | ElasticsearchNativeQueryContext | PureNativeQueryContext;
|