@squidcloud/client 1.0.492 → 1.0.493
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-connection.public-types.d.ts +34 -0
- package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +33 -2
- package/dist/internal-common/src/public-types/ai-common.public-types.d.ts +29 -0
- package/dist/internal-common/src/public-types/ai-knowledge-base.public-types.d.ts +284 -29
- package/dist/internal-common/src/public-types/ai-voice.public-types.d.ts +200 -0
- package/dist/internal-common/src/public-types/connector.public-types.d.ts +1 -1
- package/dist/internal-common/src/public-types/integration.public-types.d.ts +1 -1
- 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 +514 -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 +52 -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 +223 -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 +24 -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 +21 -0
- package/dist/internal-common/src/websocket.impl.d.ts +26 -0
- package/dist/typescript-client/src/ai-client.d.ts +13 -1
- package/dist/typescript-client/src/ai-knowledge-base/ai-knowledge-base-client-reference.d.ts +4 -2
- package/dist/typescript-client/src/ai-voice-client.d.ts +42 -0
- package/dist/typescript-client/src/ai-web-voice-call.d.ts +62 -0
- package/dist/typescript-client/src/index.d.ts +2 -0
- package/dist/typescript-client/src/public-types.d.ts +2 -0
- package/dist/typescript-client/src/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { AllAiAgentChatOptions } from './ai-agent.public-types';
|
|
2
|
+
import type { AiAgentId, IntegrationId } from './communication.public-types';
|
|
3
|
+
/**
|
|
4
|
+
* Providers that put a Squid agent on a phone call. `twilio` relays the call to Squid over a WebSocket
|
|
5
|
+
* Squid serves; `openai` is an OpenAI Realtime call Squid answers itself, see
|
|
6
|
+
* {@link AnswerOpenAiVoiceCallRequest}.
|
|
7
|
+
* @category AI
|
|
8
|
+
*/
|
|
9
|
+
export declare const AI_VOICE_RELAY_PROVIDERS: readonly ["twilio", "openai"];
|
|
10
|
+
/**
|
|
11
|
+
* A provider of {@link AI_VOICE_RELAY_PROVIDERS}.
|
|
12
|
+
* @category AI
|
|
13
|
+
*/
|
|
14
|
+
export type AiVoiceRelayProvider = (typeof AI_VOICE_RELAY_PROVIDERS)[number];
|
|
15
|
+
/**
|
|
16
|
+
* How a call opens. `phrase` speaks the greeting as soon as the call is answered; `agent` has the agent
|
|
17
|
+
* compose its opening line on a first turn before the caller speaks, so it can look the caller up and greet a
|
|
18
|
+
* known caller by name, with the greeting as what it says when there is nothing to personalize.
|
|
19
|
+
* @category AI
|
|
20
|
+
*/
|
|
21
|
+
export declare const AI_VOICE_GREETING_MODES: readonly ["phrase", "agent"];
|
|
22
|
+
/**
|
|
23
|
+
* A mode of {@link AI_VOICE_GREETING_MODES}.
|
|
24
|
+
* @category AI
|
|
25
|
+
*/
|
|
26
|
+
export type AiVoiceGreetingMode = (typeof AI_VOICE_GREETING_MODES)[number];
|
|
27
|
+
/**
|
|
28
|
+
* Request to open a voice session: a phone call the provider relays to a Squid agent in real time.
|
|
29
|
+
* The response carries the relay URL the provider must connect to.
|
|
30
|
+
* @category AI
|
|
31
|
+
*/
|
|
32
|
+
export interface CreateAiVoiceSessionRequest {
|
|
33
|
+
/** The agent that answers the call. */
|
|
34
|
+
agentId: AiAgentId;
|
|
35
|
+
/** The telephony provider that relays the call. */
|
|
36
|
+
provider: AiVoiceRelayProvider;
|
|
37
|
+
/** The provider's id of the call (a Twilio CallSid), when known before the provider connects. */
|
|
38
|
+
externalCallId?: string;
|
|
39
|
+
/** Chat options applied to every turn of the call: instructions, connected integrations, agent context. */
|
|
40
|
+
chatOptions?: AllAiAgentChatOptions;
|
|
41
|
+
/** Free-form data echoed on every session event, for the caller's own bookkeeping. */
|
|
42
|
+
metadata?: Record<string, unknown>;
|
|
43
|
+
/** `agent` has the agent open the call once the provider connects; otherwise the provider speaks its own greeting. */
|
|
44
|
+
greetingMode?: AiVoiceGreetingMode;
|
|
45
|
+
/** What the agent says in `agent` mode when there is nothing to personalize. */
|
|
46
|
+
greeting?: string;
|
|
47
|
+
/** How long the relay token stays valid before the provider connects, in seconds. Defaults to 5 minutes. */
|
|
48
|
+
connectTimeoutSeconds?: number;
|
|
49
|
+
/** Public base URL of the application when it differs from the default, such as a tunnel in local development. */
|
|
50
|
+
relayBaseUrl?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The opened voice session.
|
|
54
|
+
* @category AI
|
|
55
|
+
*/
|
|
56
|
+
export interface CreateAiVoiceSessionResponse {
|
|
57
|
+
/** Unique id of the session. */
|
|
58
|
+
sessionId: string;
|
|
59
|
+
/** One-time relay token; already embedded in `relayUrl`. */
|
|
60
|
+
token: string;
|
|
61
|
+
/** Absolute `wss://` URL the telephony provider connects to for this call. */
|
|
62
|
+
relayUrl: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Request to answer a phone call that reached an OpenAI project's SIP endpoint. Squid accepts the call with
|
|
66
|
+
* the given instructions, and for the call's life runs the agent whenever the realtime model asks it
|
|
67
|
+
* something and hangs up when the model ends the call. Requires the application API key.
|
|
68
|
+
* @category AI
|
|
69
|
+
*/
|
|
70
|
+
export interface AnswerOpenAiVoiceCallRequest {
|
|
71
|
+
/** The agent the realtime model asks for knowledge and actions. */
|
|
72
|
+
agentId: AiAgentId;
|
|
73
|
+
/** The call id from OpenAI's `realtime.call.incoming` webhook. */
|
|
74
|
+
callId: string;
|
|
75
|
+
/** The `openai_voice` integration whose API key answers the call. */
|
|
76
|
+
integrationId: IntegrationId;
|
|
77
|
+
/** Realtime model that talks on the call; defaults to the integration's default model. */
|
|
78
|
+
model?: string;
|
|
79
|
+
/** Voice of the realtime model; defaults to the integration's default voice. */
|
|
80
|
+
voice?: string;
|
|
81
|
+
/** Instructions of the realtime model. */
|
|
82
|
+
instructions: string;
|
|
83
|
+
/** Spoken as soon as the call is answered; without it the model waits for the caller to speak first. */
|
|
84
|
+
greeting?: string;
|
|
85
|
+
/** `agent` has the agent compose the opening line, with `greeting` as its fallback; `phrase` (the default) speaks `greeting` as is. */
|
|
86
|
+
greetingMode?: AiVoiceGreetingMode;
|
|
87
|
+
/** The telephony provider's id of the call (a Twilio CallSid), echoed on every session event. */
|
|
88
|
+
externalCallId?: string;
|
|
89
|
+
/** Chat options applied to every turn the agent runs for the call: instructions, agent context. */
|
|
90
|
+
chatOptions?: AllAiAgentChatOptions;
|
|
91
|
+
/** Free-form data echoed on every session event, for the caller's own bookkeeping. */
|
|
92
|
+
metadata?: Record<string, unknown>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The answered OpenAI call.
|
|
96
|
+
* @category AI
|
|
97
|
+
*/
|
|
98
|
+
export interface AnswerOpenAiVoiceCallResponse {
|
|
99
|
+
/** Unique id of the voice session that runs the call. */
|
|
100
|
+
sessionId: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* How a voice call handles languages: `single` keeps the whole call in its language, `selected` lets the
|
|
104
|
+
* caller switch between it and the chosen ones, `any` follows the caller into any language.
|
|
105
|
+
* @category AI
|
|
106
|
+
*/
|
|
107
|
+
export type AiVoiceLanguageMode = 'single' | 'selected' | 'any';
|
|
108
|
+
/**
|
|
109
|
+
* Request to start a voice call with an agent from a browser. The browser produces a WebRTC offer, Squid
|
|
110
|
+
* creates the call on the OpenAI Realtime API and returns the answer; from then on the browser talks to
|
|
111
|
+
* OpenAI directly while Squid runs the agent behind the call. Every setting defaults to what the agent's
|
|
112
|
+
* phone line uses (its Twilio ability with the OpenAI engine), then to the application's OpenAI Voice
|
|
113
|
+
* integration. Open to application users under the agent's security rules, and to the API key.
|
|
114
|
+
* @category AI
|
|
115
|
+
*/
|
|
116
|
+
export interface StartOpenAiWebVoiceCallRequest {
|
|
117
|
+
/** The agent the realtime model asks for knowledge and actions. */
|
|
118
|
+
agentId: AiAgentId;
|
|
119
|
+
/** The browser's WebRTC offer, as SDP. */
|
|
120
|
+
sdp: string;
|
|
121
|
+
/** The `openai_voice` integration to use; needed only when the agent has no phone line and the app has several. */
|
|
122
|
+
integrationId?: IntegrationId;
|
|
123
|
+
/** Realtime model that talks on the call. */
|
|
124
|
+
model?: string;
|
|
125
|
+
/** Voice of the realtime model. */
|
|
126
|
+
voice?: string;
|
|
127
|
+
/** Language the call starts in, as an ISO code or BCP-47 tag. */
|
|
128
|
+
language?: string;
|
|
129
|
+
/** Whether the caller may switch language mid-call. */
|
|
130
|
+
languageMode?: AiVoiceLanguageMode;
|
|
131
|
+
/** The languages the caller may switch to in `selected` mode. */
|
|
132
|
+
additionalLanguages?: Array<string>;
|
|
133
|
+
/** Spoken as soon as the call starts; without any greeting the model waits for the caller. */
|
|
134
|
+
greeting?: string;
|
|
135
|
+
/** `agent` has the agent compose the opening line, with `greeting` as its fallback; defaults to the phone line's mode. */
|
|
136
|
+
greetingMode?: AiVoiceGreetingMode;
|
|
137
|
+
/** What this call is for, added to the realtime model's instructions. */
|
|
138
|
+
instructions?: string;
|
|
139
|
+
/** Chat options applied to every turn the agent runs for the call: instructions, agent context. */
|
|
140
|
+
chatOptions?: AllAiAgentChatOptions;
|
|
141
|
+
/** Free-form data echoed on every session event, for the caller's own bookkeeping. */
|
|
142
|
+
metadata?: Record<string, unknown>;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The started browser call.
|
|
146
|
+
* @category AI
|
|
147
|
+
*/
|
|
148
|
+
export interface StartOpenAiWebVoiceCallResponse {
|
|
149
|
+
/** Unique id of the voice session that runs the call. */
|
|
150
|
+
sessionId: string;
|
|
151
|
+
/** Id of the call at OpenAI. */
|
|
152
|
+
callId: string;
|
|
153
|
+
/** OpenAI's WebRTC answer, as SDP, for the browser's remote description. */
|
|
154
|
+
sdp: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Event type emitted on the application event bus for every voice session milestone. Subscribe with
|
|
158
|
+
* `@eventHandler(AI_VOICE_SESSION_EVENT_TYPE)`; the payload is an {@link AiVoiceSessionEvent}.
|
|
159
|
+
* @category AI
|
|
160
|
+
*/
|
|
161
|
+
export declare const AI_VOICE_SESSION_EVENT_TYPE = "ai-voice-session-event";
|
|
162
|
+
/**
|
|
163
|
+
* Milestones of a voice session.
|
|
164
|
+
* @category AI
|
|
165
|
+
*/
|
|
166
|
+
export type AiVoiceSessionEventKind = 'started' | 'turn' | 'ended';
|
|
167
|
+
/**
|
|
168
|
+
* One spoken turn of a voice session.
|
|
169
|
+
* @category AI
|
|
170
|
+
*/
|
|
171
|
+
export interface AiVoiceSessionTurn {
|
|
172
|
+
/** Who spoke. */
|
|
173
|
+
role: 'user' | 'agent';
|
|
174
|
+
/** What was said, as transcribed (user) or generated (agent). */
|
|
175
|
+
text: string;
|
|
176
|
+
/** When the turn completed, as an ISO timestamp. */
|
|
177
|
+
at: string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Payload of an {@link AI_VOICE_SESSION_EVENT_TYPE} event.
|
|
181
|
+
* @category AI
|
|
182
|
+
*/
|
|
183
|
+
export interface AiVoiceSessionEvent {
|
|
184
|
+
/** Which milestone this event reports. */
|
|
185
|
+
kind: AiVoiceSessionEventKind;
|
|
186
|
+
/** The session the event belongs to. */
|
|
187
|
+
sessionId: string;
|
|
188
|
+
/** The provider of the call. */
|
|
189
|
+
provider: AiVoiceRelayProvider;
|
|
190
|
+
/** The agent answering the call. */
|
|
191
|
+
agentId: AiAgentId;
|
|
192
|
+
/** The provider's id of the call, when known. */
|
|
193
|
+
externalCallId?: string;
|
|
194
|
+
/** The metadata given when the session was created. */
|
|
195
|
+
metadata?: Record<string, unknown>;
|
|
196
|
+
/** The completed turn; set only for `turn` events. */
|
|
197
|
+
turn?: AiVoiceSessionTurn;
|
|
198
|
+
/** Why the session ended; set only for `ended` events. */
|
|
199
|
+
endReason?: string;
|
|
200
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 'CONNECTOR_PACKAGES_TO_EXCLUDE_FROM_AUTO_SYNC' in ConnectorsService (console-backend).
|
|
5
5
|
* @category Platform
|
|
6
6
|
*/
|
|
7
|
-
export declare const CONNECTOR_IDS: readonly ["bitbucket", "confluence", "cotomi", "essentials", "freshdesk", "generic_site_ingester", "github", "google_calendar", "google_drive", "hubspot", "sharepoint", "jira", "jira_jsm", "linear", "mail", "onedrive", "outlook", "salesforce", "servicenow_csm", "slack", "teams", "ticketmind_companion", "zendesk"];
|
|
7
|
+
export declare const CONNECTOR_IDS: readonly ["bitbucket", "confluence", "connect_companion", "cotomi", "elevenlabs", "openai_voice", "essentials", "freshdesk", "generic_site_ingester", "github", "google_calendar", "google_drive", "hubspot", "sharepoint", "jira", "jira_jsm", "linear", "mail", "onedrive", "outlook", "salesforce", "servicenow_csm", "slack", "teams", "ticketmind_companion", "twilio", "zendesk"];
|
|
8
8
|
/**
|
|
9
9
|
* Unique connector package name.
|
|
10
10
|
* @category Platform
|
|
@@ -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", "bedrock", "azure_blob", "azure_cosmosdb", "azure_postgresql", "azure_sql", "bigquery", "bitbucket", "built_in_azure_blob", "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", "azure-entra-external-id", "azure-entra-id", "dynamodb", "elasticsearch", "firebase_auth", "firestore", "gcs", "generic_site_ingester", "github", "google_calendar", "google_docs", "google_drive", "graphql", "hubspot", "jira", "jira_jsm", "jwt_hmac", "jwt_rsa", "kafka", "keycloak", "linear", "mariadb", "monday", "mongo", "mssql", "databricks", "mysql", "newrelic", "okta", "onedrive", "outlook", "oracledb", "pinecone", "postgres", "redis", "s3", "salesforce", "sap_hana", "sentry", "snowflake", "spanner", "xata", "zendesk", "servicenow_csm", "freshdesk", "mail", "slack", "mcp", "a2a", "legend", "teams", "openai_compatible", "openai_compatible_embedding", "sharepoint", "vertex"];
|
|
3
|
+
export declare const INTEGRATION_TYPES: readonly ["active_directory", "ai_agents", "ai_chatbot", "algolia", "alloydb", "api", "auth0", "bedrock", "azure_blob", "azure_cosmosdb", "azure_postgresql", "azure_sql", "bigquery", "bitbucket", "built_in_azure_blob", "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", "azure-entra-external-id", "azure-entra-id", "dynamodb", "elasticsearch", "firebase_auth", "firestore", "gcs", "generic_site_ingester", "github", "google_calendar", "google_docs", "google_drive", "graphql", "hubspot", "jira", "jira_jsm", "jwt_hmac", "jwt_rsa", "kafka", "keycloak", "linear", "mariadb", "monday", "mongo", "mssql", "databricks", "mysql", "newrelic", "okta", "onedrive", "outlook", "oracledb", "pinecone", "postgres", "redis", "s3", "salesforce", "sap_hana", "sentry", "snowflake", "spanner", "xata", "zendesk", "servicenow_csm", "freshdesk", "mail", "slack", "twilio", "elevenlabs", "openai_voice", "mcp", "a2a", "legend", "teams", "openai_compatible", "openai_compatible_embedding", "sharepoint", "vertex"];
|
|
4
4
|
/**
|
|
5
5
|
* @category Database
|
|
6
6
|
*/
|
|
@@ -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;
|