@squidcloud/client 1.0.482 → 1.0.484
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-integrations.public-types.d.ts +7 -0
- package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +31 -1
- package/dist/internal-common/src/public-types/ai-common.public-types.d.ts +4 -4
- package/dist/internal-common/src/public-types/ai-function.public-types.d.ts +36 -0
- package/dist/internal-common/src/public-types/ai-knowledge-base.public-types.d.ts +153 -2
- package/dist/internal-common/src/public-types/ai-query.public-types.d.ts +6 -0
- package/dist/internal-common/src/public-types/connector.public-types.d.ts +1 -1
- package/dist/internal-common/src/public-types/extraction.public-types.d.ts +125 -2
- package/dist/internal-common/src/public-types/integration.public-types.d.ts +1 -1
- package/dist/internal-common/src/public-types/langgraph.public-types.d.ts +40 -0
- package/dist/internal-common/src/public-types/source-code.public-types.d.ts +191 -0
- package/dist/internal-common/src/public-types/web.public-types.d.ts +5 -0
- 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 +249 -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 +5 -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/ai-knowledge-base/ai-knowledge-base-client-reference.d.ts +9 -1
- package/dist/typescript-client/src/distributed-lock.manager.d.ts +3 -2
- package/dist/typescript-client/src/index.d.ts +1 -0
- package/dist/typescript-client/src/integration-client.d.ts +5 -1
- package/dist/typescript-client/src/langgraph-client.d.ts +62 -0
- package/dist/typescript-client/src/public-types.d.ts +2 -0
- package/dist/typescript-client/src/squid.d.ts +6 -0
- package/dist/typescript-client/src/version.d.ts +1 -1
- package/dist/typescript-client/src/web-client.d.ts +9 -1
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for starting a new LangGraph run.
|
|
3
|
+
* @category AI
|
|
4
|
+
*/
|
|
5
|
+
export interface InvokeLangGraphOptions {
|
|
6
|
+
/** If provided, the run executes against this thread. If omitted, a new thread is created. */
|
|
7
|
+
threadId?: string;
|
|
8
|
+
/** Initial state for the run. */
|
|
9
|
+
input?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Successful result of a LangGraph invocation.
|
|
13
|
+
* @category AI
|
|
14
|
+
*/
|
|
15
|
+
export interface InvokeLangGraphSuccessResult {
|
|
16
|
+
/** Always `true` on success. */
|
|
17
|
+
ok: true;
|
|
18
|
+
/** Thread the run executed against. */
|
|
19
|
+
threadId: string;
|
|
20
|
+
/** `completed` when the graph finished, `interrupted` when awaiting a resume. */
|
|
21
|
+
status: 'completed' | 'interrupted';
|
|
22
|
+
/** Final (or paused) state values. */
|
|
23
|
+
state: Record<string, unknown> | null;
|
|
24
|
+
/** Next nodes to execute. Empty when `status` is `completed`. */
|
|
25
|
+
next: string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Successful result of a getState call.
|
|
29
|
+
* @category AI
|
|
30
|
+
*/
|
|
31
|
+
export interface GetLangGraphStateSuccessResult {
|
|
32
|
+
/** Always `true` on success. */
|
|
33
|
+
ok: true;
|
|
34
|
+
/** Thread the state belongs to. */
|
|
35
|
+
threadId: string;
|
|
36
|
+
/** Current state values. */
|
|
37
|
+
state: Record<string, unknown> | null;
|
|
38
|
+
/** Next nodes to execute. Empty if the graph has completed. */
|
|
39
|
+
next: string[];
|
|
40
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { IntegrationInfo } from './integration.public-types';
|
|
2
|
+
/** Identifies the source-code analysis AI function. */
|
|
3
|
+
export declare const SOURCE_CODE_ANALYZE_FUNCTION_ID = "analyzeCode";
|
|
4
|
+
/** Limits the number of repositories selected for analysis. */
|
|
5
|
+
export declare const SOURCE_CODE_MAX_REPOSITORIES = 20;
|
|
6
|
+
/** Limits each supplemental instruction field supplied to source-code analysis. */
|
|
7
|
+
export declare const SOURCE_CODE_MAX_SUPPLEMENTAL_INSTRUCTIONS_LENGTH = 20000;
|
|
8
|
+
/** Lists CLI providers available for source-code analysis. */
|
|
9
|
+
export declare const SOURCE_CODE_ANALYZER_MODELS: readonly ["claude-code", "codex"];
|
|
10
|
+
/** Identifies a CLI provider available for source-code analysis. */
|
|
11
|
+
export type SourceCodeAnalyzerModel = (typeof SOURCE_CODE_ANALYZER_MODELS)[number];
|
|
12
|
+
/** Lists supported source-control providers. */
|
|
13
|
+
export declare const SOURCE_CONTROL_PROVIDERS: readonly ["github", "bitbucket"];
|
|
14
|
+
/** Identifies a supported source-control provider. */
|
|
15
|
+
export type SourceControlProvider = (typeof SOURCE_CONTROL_PROVIDERS)[number];
|
|
16
|
+
/** Lists integration types that provide source repositories. */
|
|
17
|
+
export declare const SOURCE_CODE_INTEGRATION_TYPES: readonly ["github", "bitbucket"];
|
|
18
|
+
/** Identifies an integration type that provides source repositories. */
|
|
19
|
+
export type SourceCodeIntegrationType = (typeof SOURCE_CODE_INTEGRATION_TYPES)[number];
|
|
20
|
+
/** Configures source-code analysis for an AI agent integration. */
|
|
21
|
+
export interface AiAgentSourceCodeIntegrationOptions {
|
|
22
|
+
/** Enables repository-backed code analysis. */
|
|
23
|
+
codeAnalysisEnabled: boolean;
|
|
24
|
+
/** Selects the CLI provider used for code analysis. */
|
|
25
|
+
analyzerModel?: SourceCodeAnalyzerModel;
|
|
26
|
+
/** Provides supplemental code-analysis instructions. */
|
|
27
|
+
analyzerInstructions?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Stores the immutable GitHub identity and access metadata for a selected repository. */
|
|
30
|
+
export interface GitHubRepositoryConfiguration {
|
|
31
|
+
/** Stores GitHub's numeric repository identifier. */
|
|
32
|
+
id: number;
|
|
33
|
+
/** Stores the owner/repository name. */
|
|
34
|
+
fullName: string;
|
|
35
|
+
/** Stores the credential-free HTTPS clone URL. */
|
|
36
|
+
cloneUrl: string;
|
|
37
|
+
/** Stores the credential-free HTTPS web URL. */
|
|
38
|
+
htmlUrl: string;
|
|
39
|
+
/** Stores the default branch name. */
|
|
40
|
+
defaultBranch: string;
|
|
41
|
+
}
|
|
42
|
+
/** Stores the immutable Bitbucket identity and access metadata for a selected repository. */
|
|
43
|
+
export interface BitbucketRepositoryConfiguration {
|
|
44
|
+
/** Stores Bitbucket's immutable repository UUID. */
|
|
45
|
+
uuid: string;
|
|
46
|
+
/** Stores the workspace/repository name. */
|
|
47
|
+
fullName: string;
|
|
48
|
+
/** Stores the credential-free HTTPS clone URL. */
|
|
49
|
+
cloneUrl: string;
|
|
50
|
+
/** Stores the credential-free HTTPS web URL. */
|
|
51
|
+
webUrl: string;
|
|
52
|
+
/** Stores the default branch name. */
|
|
53
|
+
defaultBranch: string;
|
|
54
|
+
}
|
|
55
|
+
/** Represents the repository-selection portion of a GitHub integration configuration. */
|
|
56
|
+
interface GitHubRepositorySelectionConfiguration {
|
|
57
|
+
/** Stores the legacy owner/repository selection. */
|
|
58
|
+
repository?: string;
|
|
59
|
+
/** Stores canonical selected repository metadata. */
|
|
60
|
+
repositories?: GitHubRepositoryConfiguration[];
|
|
61
|
+
/** Stores the selected default owner/repository name. */
|
|
62
|
+
defaultRepository?: string;
|
|
63
|
+
}
|
|
64
|
+
/** Represents the repository-selection portion of a Bitbucket integration configuration. */
|
|
65
|
+
interface BitbucketRepositorySelectionConfiguration {
|
|
66
|
+
/** Stores the configured Bitbucket workspace slug. */
|
|
67
|
+
workspace: string;
|
|
68
|
+
/** Stores canonical selected repository metadata. */
|
|
69
|
+
repositories: BitbucketRepositoryConfiguration[];
|
|
70
|
+
/** Stores the selected default workspace/repository name. */
|
|
71
|
+
defaultRepository: string;
|
|
72
|
+
}
|
|
73
|
+
/** Describes a source repository that can be prepared for analysis. */
|
|
74
|
+
export interface SourceRepository {
|
|
75
|
+
/** Identifies the source-control provider. */
|
|
76
|
+
provider: SourceControlProvider;
|
|
77
|
+
/** Stores the provider's immutable repository identifier. */
|
|
78
|
+
providerRepositoryId: string;
|
|
79
|
+
/** Stores the owner/repository name. */
|
|
80
|
+
fullName: string;
|
|
81
|
+
/** Stores the credential-free clone URL. */
|
|
82
|
+
cloneUrl: string;
|
|
83
|
+
/** Stores the repository web URL. */
|
|
84
|
+
webUrl: string;
|
|
85
|
+
/** Stores the repository's default branch. */
|
|
86
|
+
defaultBranch: string;
|
|
87
|
+
}
|
|
88
|
+
/** Requests analysis of selected source-code repositories. */
|
|
89
|
+
export interface AnalyzeCodeRequest {
|
|
90
|
+
/** Contains the question to answer. */
|
|
91
|
+
question: string;
|
|
92
|
+
/** Narrows repository selection. */
|
|
93
|
+
repositoryHints?: string;
|
|
94
|
+
/** Narrows analysis to a captured reference. */
|
|
95
|
+
refHint?: string;
|
|
96
|
+
/** Supplies customer context for the answer. */
|
|
97
|
+
customerContext?: string;
|
|
98
|
+
}
|
|
99
|
+
/** Marks an inclusive range of lines in a repository path. */
|
|
100
|
+
export interface SourceCodeLineRange {
|
|
101
|
+
/** Stores the first included line number. */
|
|
102
|
+
start: number;
|
|
103
|
+
/** Stores the last included line number. */
|
|
104
|
+
end: number;
|
|
105
|
+
}
|
|
106
|
+
/** Identifies a path supporting a source-code finding. */
|
|
107
|
+
export interface SourceCodePathEvidence {
|
|
108
|
+
/** Stores the path relative to the repository root. */
|
|
109
|
+
path: string;
|
|
110
|
+
/** Marks the supporting line range when available. */
|
|
111
|
+
lines?: SourceCodeLineRange;
|
|
112
|
+
}
|
|
113
|
+
/** Identifies the captured repository reference behind a finding. */
|
|
114
|
+
export interface SourceCodeRef {
|
|
115
|
+
/** Identifies the reference kind. */
|
|
116
|
+
type: 'branch' | 'tag' | 'commit';
|
|
117
|
+
/** Stores the captured reference name. */
|
|
118
|
+
name: string;
|
|
119
|
+
}
|
|
120
|
+
/** Records repository evidence supporting a source-code answer. */
|
|
121
|
+
export interface SourceCodeRepositoryEvidence {
|
|
122
|
+
/** Stores the owner/repository name. */
|
|
123
|
+
repository: string;
|
|
124
|
+
/** Identifies the inspected captured reference. */
|
|
125
|
+
ref: SourceCodeRef;
|
|
126
|
+
/** Stores the immutable commit SHA. */
|
|
127
|
+
commitSha: string;
|
|
128
|
+
/** Lists paths supporting the finding. */
|
|
129
|
+
paths: SourceCodePathEvidence[];
|
|
130
|
+
/** Stores the snapshot fetch time. */
|
|
131
|
+
fetchedAt: string;
|
|
132
|
+
/** Marks evidence from a stale snapshot. */
|
|
133
|
+
stale: boolean;
|
|
134
|
+
}
|
|
135
|
+
/** Returns a source-code analysis answer and its evidence. */
|
|
136
|
+
export interface AnalyzeCodeResult {
|
|
137
|
+
/** Contains the concise answer. */
|
|
138
|
+
answer: string;
|
|
139
|
+
/** Lists repository evidence supporting the answer. */
|
|
140
|
+
repositories: SourceCodeRepositoryEvidence[];
|
|
141
|
+
/** Stores the latest snapshot fetch time. */
|
|
142
|
+
fetchTimestamp: string;
|
|
143
|
+
/** Marks whether any source snapshot is stale. */
|
|
144
|
+
stale: boolean;
|
|
145
|
+
/** Lists warnings encountered during analysis. */
|
|
146
|
+
warnings: string[];
|
|
147
|
+
/** Warns when a prepared workspace cannot persist. */
|
|
148
|
+
workspacePersistenceWarning?: string;
|
|
149
|
+
}
|
|
150
|
+
/** Requests discovery from an existing or draft source-code integration. */
|
|
151
|
+
export type DiscoverSourceRepositoriesRequest = {
|
|
152
|
+
/** Identifies the source-code integration type. */
|
|
153
|
+
integrationType: SourceCodeIntegrationType;
|
|
154
|
+
/** Identifies the persisted integration. */
|
|
155
|
+
integrationId: string;
|
|
156
|
+
/** Prevents draft and persisted integration inputs from mixing. */
|
|
157
|
+
draftIntegration?: never;
|
|
158
|
+
} | {
|
|
159
|
+
/** Identifies the source-code integration type. */
|
|
160
|
+
integrationType: SourceCodeIntegrationType;
|
|
161
|
+
/** Prevents draft and persisted integration inputs from mixing. */
|
|
162
|
+
integrationId?: never;
|
|
163
|
+
/** Supplies an integration that has not been persisted. */
|
|
164
|
+
draftIntegration: IntegrationInfo;
|
|
165
|
+
};
|
|
166
|
+
/** Returns repositories discovered from a source-code integration. */
|
|
167
|
+
export interface DiscoverSourceRepositoriesResponse {
|
|
168
|
+
/** Lists repositories available for selection. */
|
|
169
|
+
repositories: SourceRepository[];
|
|
170
|
+
}
|
|
171
|
+
/** Represents a normalized GitHub repository selection. */
|
|
172
|
+
export interface NormalizedGitHubRepositorySelection {
|
|
173
|
+
/** Stores the accepted legacy selection when canonical metadata is absent. */
|
|
174
|
+
legacyRepository?: string;
|
|
175
|
+
/** Lists validated canonical repository metadata. */
|
|
176
|
+
repositories: GitHubRepositoryConfiguration[];
|
|
177
|
+
/** Stores the validated default owner/repository name. */
|
|
178
|
+
defaultRepository: string;
|
|
179
|
+
}
|
|
180
|
+
/** Represents a normalized Bitbucket repository selection. */
|
|
181
|
+
export interface NormalizedBitbucketRepositorySelection {
|
|
182
|
+
/** Lists validated canonical repository metadata. */
|
|
183
|
+
repositories: BitbucketRepositoryConfiguration[];
|
|
184
|
+
/** Stores the validated default workspace/repository name. */
|
|
185
|
+
defaultRepository: string;
|
|
186
|
+
}
|
|
187
|
+
/** Normalizes selected GitHub repositories for persistence and connector use. */
|
|
188
|
+
export declare function normalizeGitHubRepositorySelection(configuration: GitHubRepositorySelectionConfiguration): NormalizedGitHubRepositorySelection;
|
|
189
|
+
/** Normalizes selected Bitbucket repositories for persistence and connector use. */
|
|
190
|
+
export declare function normalizeBitbucketRepositorySelection(configuration: BitbucketRepositorySelectionConfiguration): NormalizedBitbucketRepositorySelection;
|
|
191
|
+
export {};
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
export interface WebAiSearchRequest {
|
|
5
5
|
/** The search query. */
|
|
6
6
|
query: string;
|
|
7
|
+
/**
|
|
8
|
+
* When provided, restricts the web search to these domains (subdomains are included).
|
|
9
|
+
* Cited URLs in the response are guaranteed to belong to one of the listed domains.
|
|
10
|
+
*/
|
|
11
|
+
allowedDomains?: Array<string>;
|
|
7
12
|
}
|
|
8
13
|
/**
|
|
9
14
|
* Represents a cited URL in the search response.
|
|
@@ -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;
|