@squidcloud/client 1.0.483 → 1.0.485
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 +79 -3
- package/dist/internal-common/src/public-types/ai-common.public-types.d.ts +9 -0
- 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 +141 -2
- 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 +9 -2
- package/dist/internal-common/src/public-types/integration.public-types.d.ts +7 -1
- package/dist/internal-common/src/public-types/source-code.public-types.d.ts +196 -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 +253 -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 +12 -1
- 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/integration-client.d.ts +5 -1
- package/dist/typescript-client/src/public-types.d.ts +1 -0
- package/dist/typescript-client/src/version.d.ts +1 -1
- package/package.json +1 -3
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { CanonicalReasoningEffort } from './ai-agent.public-types';
|
|
2
|
+
import type { IntegrationInfo } from './integration.public-types';
|
|
3
|
+
/** Identifies the source-code analysis AI function. */
|
|
4
|
+
export declare const SOURCE_CODE_ANALYZE_FUNCTION_ID = "analyzeCode";
|
|
5
|
+
/** Limits the number of repositories selected for analysis. */
|
|
6
|
+
export declare const SOURCE_CODE_MAX_REPOSITORIES = 20;
|
|
7
|
+
/** Limits each supplemental instruction field supplied to source-code analysis. */
|
|
8
|
+
export declare const SOURCE_CODE_MAX_SUPPLEMENTAL_INSTRUCTIONS_LENGTH = 20000;
|
|
9
|
+
/** Lists CLI providers available for source-code analysis. */
|
|
10
|
+
export declare const SOURCE_CODE_ANALYZER_MODELS: readonly ["claude-code", "codex"];
|
|
11
|
+
/** Identifies a CLI provider available for source-code analysis. */
|
|
12
|
+
export type SourceCodeAnalyzerModel = (typeof SOURCE_CODE_ANALYZER_MODELS)[number];
|
|
13
|
+
/** Lists supported source-control providers. */
|
|
14
|
+
export declare const SOURCE_CONTROL_PROVIDERS: readonly ["github", "bitbucket"];
|
|
15
|
+
/** Identifies a supported source-control provider. */
|
|
16
|
+
export type SourceControlProvider = (typeof SOURCE_CONTROL_PROVIDERS)[number];
|
|
17
|
+
/** Lists integration types that provide source repositories. */
|
|
18
|
+
export declare const SOURCE_CODE_INTEGRATION_TYPES: readonly ["github", "bitbucket"];
|
|
19
|
+
/** Identifies an integration type that provides source repositories. */
|
|
20
|
+
export type SourceCodeIntegrationType = (typeof SOURCE_CODE_INTEGRATION_TYPES)[number];
|
|
21
|
+
/** Configures source-code analysis for an AI agent integration. */
|
|
22
|
+
export interface AiAgentSourceCodeIntegrationOptions {
|
|
23
|
+
/** Enables repository-backed code analysis. */
|
|
24
|
+
codeAnalysisEnabled: boolean;
|
|
25
|
+
/** Selects the CLI provider used for code analysis. */
|
|
26
|
+
analyzerModel?: SourceCodeAnalyzerModel;
|
|
27
|
+
/** Selects a concrete model from the analyzer provider's CLI registry. */
|
|
28
|
+
analyzerModelId?: string;
|
|
29
|
+
/** Selects the reasoning effort used by the analyzer CLI. */
|
|
30
|
+
analyzerReasoningEffort?: CanonicalReasoningEffort;
|
|
31
|
+
/** Provides supplemental code-analysis instructions. */
|
|
32
|
+
analyzerInstructions?: string;
|
|
33
|
+
}
|
|
34
|
+
/** Stores the immutable GitHub identity and access metadata for a selected repository. */
|
|
35
|
+
export interface GitHubRepositoryConfiguration {
|
|
36
|
+
/** Stores GitHub's numeric repository identifier. */
|
|
37
|
+
id: number;
|
|
38
|
+
/** Stores the owner/repository name. */
|
|
39
|
+
fullName: string;
|
|
40
|
+
/** Stores the credential-free HTTPS clone URL. */
|
|
41
|
+
cloneUrl: string;
|
|
42
|
+
/** Stores the credential-free HTTPS web URL. */
|
|
43
|
+
htmlUrl: string;
|
|
44
|
+
/** Stores the default branch name. */
|
|
45
|
+
defaultBranch: string;
|
|
46
|
+
}
|
|
47
|
+
/** Stores the immutable Bitbucket identity and access metadata for a selected repository. */
|
|
48
|
+
export interface BitbucketRepositoryConfiguration {
|
|
49
|
+
/** Stores Bitbucket's immutable repository UUID. */
|
|
50
|
+
uuid: string;
|
|
51
|
+
/** Stores the workspace/repository name. */
|
|
52
|
+
fullName: string;
|
|
53
|
+
/** Stores the credential-free HTTPS clone URL. */
|
|
54
|
+
cloneUrl: string;
|
|
55
|
+
/** Stores the credential-free HTTPS web URL. */
|
|
56
|
+
webUrl: string;
|
|
57
|
+
/** Stores the default branch name. */
|
|
58
|
+
defaultBranch: string;
|
|
59
|
+
}
|
|
60
|
+
/** Represents the repository-selection portion of a GitHub integration configuration. */
|
|
61
|
+
interface GitHubRepositorySelectionConfiguration {
|
|
62
|
+
/** Stores the legacy owner/repository selection. */
|
|
63
|
+
repository?: string;
|
|
64
|
+
/** Stores canonical selected repository metadata. */
|
|
65
|
+
repositories?: GitHubRepositoryConfiguration[];
|
|
66
|
+
/** Stores the selected default owner/repository name. */
|
|
67
|
+
defaultRepository?: string;
|
|
68
|
+
}
|
|
69
|
+
/** Represents the repository-selection portion of a Bitbucket integration configuration. */
|
|
70
|
+
interface BitbucketRepositorySelectionConfiguration {
|
|
71
|
+
/** Stores the configured Bitbucket workspace slug. */
|
|
72
|
+
workspace: string;
|
|
73
|
+
/** Stores canonical selected repository metadata. */
|
|
74
|
+
repositories: BitbucketRepositoryConfiguration[];
|
|
75
|
+
/** Stores the selected default workspace/repository name. */
|
|
76
|
+
defaultRepository: string;
|
|
77
|
+
}
|
|
78
|
+
/** Describes a source repository that can be prepared for analysis. */
|
|
79
|
+
export interface SourceRepository {
|
|
80
|
+
/** Identifies the source-control provider. */
|
|
81
|
+
provider: SourceControlProvider;
|
|
82
|
+
/** Stores the provider's immutable repository identifier. */
|
|
83
|
+
providerRepositoryId: string;
|
|
84
|
+
/** Stores the owner/repository name. */
|
|
85
|
+
fullName: string;
|
|
86
|
+
/** Stores the credential-free clone URL. */
|
|
87
|
+
cloneUrl: string;
|
|
88
|
+
/** Stores the repository web URL. */
|
|
89
|
+
webUrl: string;
|
|
90
|
+
/** Stores the repository's default branch. */
|
|
91
|
+
defaultBranch: string;
|
|
92
|
+
}
|
|
93
|
+
/** Requests analysis of selected source-code repositories. */
|
|
94
|
+
export interface AnalyzeCodeRequest {
|
|
95
|
+
/** Contains the question to answer. */
|
|
96
|
+
question: string;
|
|
97
|
+
/** Narrows repository selection. */
|
|
98
|
+
repositoryHints?: string;
|
|
99
|
+
/** Narrows analysis to a captured reference. */
|
|
100
|
+
refHint?: string;
|
|
101
|
+
/** Supplies customer context for the answer. */
|
|
102
|
+
customerContext?: string;
|
|
103
|
+
}
|
|
104
|
+
/** Marks an inclusive range of lines in a repository path. */
|
|
105
|
+
export interface SourceCodeLineRange {
|
|
106
|
+
/** Stores the first included line number. */
|
|
107
|
+
start: number;
|
|
108
|
+
/** Stores the last included line number. */
|
|
109
|
+
end: number;
|
|
110
|
+
}
|
|
111
|
+
/** Identifies a path supporting a source-code finding. */
|
|
112
|
+
export interface SourceCodePathEvidence {
|
|
113
|
+
/** Stores the path relative to the repository root. */
|
|
114
|
+
path: string;
|
|
115
|
+
/** Marks the supporting line range when available. */
|
|
116
|
+
lines?: SourceCodeLineRange;
|
|
117
|
+
}
|
|
118
|
+
/** Identifies the captured repository reference behind a finding. */
|
|
119
|
+
export interface SourceCodeRef {
|
|
120
|
+
/** Identifies the reference kind. */
|
|
121
|
+
type: 'branch' | 'tag' | 'commit';
|
|
122
|
+
/** Stores the captured reference name. */
|
|
123
|
+
name: string;
|
|
124
|
+
}
|
|
125
|
+
/** Records repository evidence supporting a source-code answer. */
|
|
126
|
+
export interface SourceCodeRepositoryEvidence {
|
|
127
|
+
/** Stores the owner/repository name. */
|
|
128
|
+
repository: string;
|
|
129
|
+
/** Identifies the inspected captured reference. */
|
|
130
|
+
ref: SourceCodeRef;
|
|
131
|
+
/** Stores the immutable commit SHA. */
|
|
132
|
+
commitSha: string;
|
|
133
|
+
/** Lists paths supporting the finding. */
|
|
134
|
+
paths: SourceCodePathEvidence[];
|
|
135
|
+
/** Stores the snapshot fetch time. */
|
|
136
|
+
fetchedAt: string;
|
|
137
|
+
/** Marks evidence from a stale snapshot. */
|
|
138
|
+
stale: boolean;
|
|
139
|
+
}
|
|
140
|
+
/** Returns a source-code analysis answer and its evidence. */
|
|
141
|
+
export interface AnalyzeCodeResult {
|
|
142
|
+
/** Contains the concise answer. */
|
|
143
|
+
answer: string;
|
|
144
|
+
/** Lists repository evidence supporting the answer. */
|
|
145
|
+
repositories: SourceCodeRepositoryEvidence[];
|
|
146
|
+
/** Stores the latest snapshot fetch time. */
|
|
147
|
+
fetchTimestamp: string;
|
|
148
|
+
/** Marks whether any source snapshot is stale. */
|
|
149
|
+
stale: boolean;
|
|
150
|
+
/** Lists warnings encountered during analysis. */
|
|
151
|
+
warnings: string[];
|
|
152
|
+
/** Warns when a prepared workspace cannot persist. */
|
|
153
|
+
workspacePersistenceWarning?: string;
|
|
154
|
+
}
|
|
155
|
+
/** Requests discovery from an existing or draft source-code integration. */
|
|
156
|
+
export type DiscoverSourceRepositoriesRequest = {
|
|
157
|
+
/** Identifies the source-code integration type. */
|
|
158
|
+
integrationType: SourceCodeIntegrationType;
|
|
159
|
+
/** Identifies the persisted integration. */
|
|
160
|
+
integrationId: string;
|
|
161
|
+
/** Prevents draft and persisted integration inputs from mixing. */
|
|
162
|
+
draftIntegration?: never;
|
|
163
|
+
} | {
|
|
164
|
+
/** Identifies the source-code integration type. */
|
|
165
|
+
integrationType: SourceCodeIntegrationType;
|
|
166
|
+
/** Prevents draft and persisted integration inputs from mixing. */
|
|
167
|
+
integrationId?: never;
|
|
168
|
+
/** Supplies an integration that has not been persisted. */
|
|
169
|
+
draftIntegration: IntegrationInfo;
|
|
170
|
+
};
|
|
171
|
+
/** Returns repositories discovered from a source-code integration. */
|
|
172
|
+
export interface DiscoverSourceRepositoriesResponse {
|
|
173
|
+
/** Lists repositories available for selection. */
|
|
174
|
+
repositories: SourceRepository[];
|
|
175
|
+
}
|
|
176
|
+
/** Represents a normalized GitHub repository selection. */
|
|
177
|
+
export interface NormalizedGitHubRepositorySelection {
|
|
178
|
+
/** Stores the accepted legacy selection when canonical metadata is absent. */
|
|
179
|
+
legacyRepository?: string;
|
|
180
|
+
/** Lists validated canonical repository metadata. */
|
|
181
|
+
repositories: GitHubRepositoryConfiguration[];
|
|
182
|
+
/** Stores the validated default owner/repository name. */
|
|
183
|
+
defaultRepository: string;
|
|
184
|
+
}
|
|
185
|
+
/** Represents a normalized Bitbucket repository selection. */
|
|
186
|
+
export interface NormalizedBitbucketRepositorySelection {
|
|
187
|
+
/** Lists validated canonical repository metadata. */
|
|
188
|
+
repositories: BitbucketRepositoryConfiguration[];
|
|
189
|
+
/** Stores the validated default workspace/repository name. */
|
|
190
|
+
defaultRepository: string;
|
|
191
|
+
}
|
|
192
|
+
/** Normalizes selected GitHub repositories for persistence and connector use. */
|
|
193
|
+
export declare function normalizeGitHubRepositorySelection(configuration: GitHubRepositorySelectionConfiguration): NormalizedGitHubRepositorySelection;
|
|
194
|
+
/** Normalizes selected Bitbucket repositories for persistence and connector use. */
|
|
195
|
+
export declare function normalizeBitbucketRepositorySelection(configuration: BitbucketRepositorySelectionConfiguration): NormalizedBitbucketRepositorySelection;
|
|
196
|
+
export {};
|
|
@@ -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;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { AiQueryOptions } from '../public-types/ai-query.public-types';
|
|
2
|
+
import { IntegrationId } from '../public-types/communication.public-types';
|
|
3
|
+
import { CollectionName, DocumentData, FieldName } from '../public-types/document.public-types';
|
|
4
|
+
import { FieldSort, Operator, Query, SimpleCondition } from '../public-types/query.public-types';
|
|
5
|
+
import { DeepRecord, FieldOf, PartialBy, Paths } from '../public-types/typescript.public-types';
|
|
6
|
+
/**
|
|
7
|
+
* The information provided to the secureAiQuery function about the AI query being executed.
|
|
8
|
+
* @category AI
|
|
9
|
+
*/
|
|
10
|
+
export interface AiQueryContext {
|
|
11
|
+
/** The prompt provided for the AI query. */
|
|
12
|
+
prompt: string;
|
|
13
|
+
/** The options used for executing the AI query. */
|
|
14
|
+
options: AiQueryOptions;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Represents the Squid query context.
|
|
18
|
+
* Passed to methods that require query details, such as those annotated with the `@secureCollection` annotation.
|
|
19
|
+
* @category Database
|
|
20
|
+
*/
|
|
21
|
+
export declare class QueryContext<T extends DocumentData = any> {
|
|
22
|
+
readonly query: Query<T>;
|
|
23
|
+
/**
|
|
24
|
+
* The ID of the integration being queried.
|
|
25
|
+
*/
|
|
26
|
+
get integrationId(): IntegrationId;
|
|
27
|
+
/**
|
|
28
|
+
* The name of the collection being queried.
|
|
29
|
+
*/
|
|
30
|
+
get collectionName(): CollectionName;
|
|
31
|
+
/**
|
|
32
|
+
* The query limit if one exists, -1 otherwise.
|
|
33
|
+
*/
|
|
34
|
+
get limit(): number;
|
|
35
|
+
/**
|
|
36
|
+
* The fields to project (include) in query results, or undefined if all fields should be returned.
|
|
37
|
+
*/
|
|
38
|
+
get projectFields(): Array<FieldName> | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Verifies that the query's sort order aligns with the provided field sorts. The fields specified in the `sorts`
|
|
41
|
+
* parameter must appear in the exact order at the beginning of the query's sort sequence. The query can include
|
|
42
|
+
* additional fields in its sort order, but only after the specified sorts.
|
|
43
|
+
*
|
|
44
|
+
* @param sorts An array of field sorts.
|
|
45
|
+
* @returns Whether the query's sorts matches the provided field sorts.
|
|
46
|
+
*/
|
|
47
|
+
sortedBy(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Verifies that the query's sort order exactly matches the provided field sorts. The fields specified in the
|
|
50
|
+
* `sorts` parameter must appear in the exact order in the query's sort sequence. No additional sorts may be present
|
|
51
|
+
* in the query.
|
|
52
|
+
*
|
|
53
|
+
* @param sorts An array of field sorts.
|
|
54
|
+
* @returns Whether the query's sorts exactly match the provided field sorts.
|
|
55
|
+
*/
|
|
56
|
+
sortedByExact(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
|
|
59
|
+
* to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
|
|
60
|
+
* additional conditions, as these only narrow the result set.
|
|
61
|
+
*
|
|
62
|
+
* @param fieldName The name of the field for the condition.
|
|
63
|
+
* @param operator The operator of the condition.
|
|
64
|
+
* @param value The value of the condition.
|
|
65
|
+
* @returns Whether the query is a subquery of the parent condition.
|
|
66
|
+
*/
|
|
67
|
+
isSubqueryOf<F extends Paths<T>, O extends AllOperators>(fieldName: F, operator: O, value: GenericValue<T, F, O> | null): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
|
|
70
|
+
* to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
|
|
71
|
+
* additional conditions, as these only narrow the result set.
|
|
72
|
+
*
|
|
73
|
+
* @param condition The condition to validate.
|
|
74
|
+
* @returns Whether the query is a subquery of the parent condition.
|
|
75
|
+
*/
|
|
76
|
+
isSubqueryOfCondition(condition: GeneralCondition<T>): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Verifies that the query is a subquery of the specified conditions. A subquery is defined as a query that evaluates
|
|
79
|
+
* to a subset of the results that would be obtained by applying the parent conditions. The subquery may also include
|
|
80
|
+
* additional conditions, as these only narrow the result set.
|
|
81
|
+
*
|
|
82
|
+
* @param conditions The conditions to validate.
|
|
83
|
+
* @returns Whether the query includes subquery of the parent conditions.
|
|
84
|
+
*/
|
|
85
|
+
isSubqueryOfConditions(conditions: GeneralConditions<T>): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Verifies that the query is a subquery of the specified query. A subquery is defined as a query that evaluates
|
|
88
|
+
* to a subset of the results that obtained for the parent query, including sorts and limits.
|
|
89
|
+
*
|
|
90
|
+
* @param query The query to validate.
|
|
91
|
+
* @returns Whether the query is a subquery of the parent query.
|
|
92
|
+
*/
|
|
93
|
+
isSubqueryOfQuery(query: Query<T>): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Checks if this query's projectFields are a subset of the parent query's projectFields.
|
|
96
|
+
* A query can only be a child of another if the parent provides all fields the child needs.
|
|
97
|
+
*
|
|
98
|
+
* @param childFields - The projectFields of this query (the potential child)
|
|
99
|
+
* @param parentFields - The projectFields of the candidate parent query
|
|
100
|
+
* @returns Whether the child's fields are available from the parent
|
|
101
|
+
*/
|
|
102
|
+
private isProjectFieldsSubset;
|
|
103
|
+
/**
|
|
104
|
+
* Returns all conditions that apply to any of the specified field names. This method
|
|
105
|
+
* provides a convenient way to retrieve all conditions that involve a specific set of fields.
|
|
106
|
+
*
|
|
107
|
+
* @param fieldNames The field names for which to retrieve conditions.
|
|
108
|
+
* @returns An array of conditions that involve any of the specified field names.
|
|
109
|
+
*/
|
|
110
|
+
getConditionsFor<K extends Paths<T>>(...fieldNames: Array<K>): ContextConditions<T, K>;
|
|
111
|
+
/**
|
|
112
|
+
* Returns all conditions that apply to the specified field name. This method provides
|
|
113
|
+
* a convenient way to retrieve all conditions that involve a specific field.
|
|
114
|
+
*
|
|
115
|
+
* @param fieldName The field name for which to retrieve conditions.
|
|
116
|
+
* @returns An array of conditions that involve the specified field name.
|
|
117
|
+
*/
|
|
118
|
+
getConditionsForField<K extends Paths<T>>(fieldName: K): ContextConditions<T>;
|
|
119
|
+
/**
|
|
120
|
+
* Returns true if the given document can be a result of the query.
|
|
121
|
+
* The method does not account for limit and sort order.
|
|
122
|
+
*/
|
|
123
|
+
documentMatchesQuery(doc: DocumentData): boolean;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* A list of context conditions.
|
|
127
|
+
* @category Database
|
|
128
|
+
*/
|
|
129
|
+
export type ContextConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<ContextCondition<Doc, F>>;
|
|
130
|
+
/**
|
|
131
|
+
* A Context condition - a condition that replaces multiple '==' or '!=' conditions with 'in' and 'not in'.
|
|
132
|
+
* @category Database
|
|
133
|
+
*/
|
|
134
|
+
export type ContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = InContextCondition<Doc, F> | NotInContextCondition<Doc, F> | OtherContextCondition<Doc, F>;
|
|
135
|
+
/**
|
|
136
|
+
* A condition using the 'in' operator to match values within a set.
|
|
137
|
+
* @category Database
|
|
138
|
+
*/
|
|
139
|
+
export interface InContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'in'> {
|
|
140
|
+
/** Specifies the 'in' operator to check if a value exists within an array. */
|
|
141
|
+
operator: 'in';
|
|
142
|
+
/** An array of values to match against the field. */
|
|
143
|
+
value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A condition using the 'not in' operator to exclude values within a set.
|
|
147
|
+
* @category Database
|
|
148
|
+
*/
|
|
149
|
+
export interface NotInContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'not in'> {
|
|
150
|
+
/** Specifies the 'not in' operator to check if a value does not exist within an array. */
|
|
151
|
+
operator: 'not in';
|
|
152
|
+
/** An array of values to exclude from the field. */
|
|
153
|
+
value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* A condition using operators other than 'in' or 'not in' for field comparisons.
|
|
157
|
+
* @category Database
|
|
158
|
+
*/
|
|
159
|
+
export interface OtherContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, Exclude<ContextOperator, 'in' | 'not in'>> {
|
|
160
|
+
/** The operator to use for the comparison, excluding 'in' and 'not in'. */
|
|
161
|
+
operator: Exclude<ContextOperator, 'in' | 'not in'>;
|
|
162
|
+
/** The value to compare against the field. */
|
|
163
|
+
value: FieldOf<DeepRecord<Doc>, Paths<Doc>> | any;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* A condition that includes all operators, including 'in' and 'not in', for general use.
|
|
167
|
+
* @category Database
|
|
168
|
+
*/
|
|
169
|
+
export interface GeneralCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, AllOperators> {
|
|
170
|
+
/** The operator to apply to the condition, including all possible operators. */
|
|
171
|
+
operator: AllOperators;
|
|
172
|
+
/** The value to use in the condition comparison. */
|
|
173
|
+
value: any;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* A list of general conditions.
|
|
177
|
+
* @category Database
|
|
178
|
+
*/
|
|
179
|
+
export type GeneralConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<GeneralCondition<Doc, F>>;
|
|
180
|
+
/**
|
|
181
|
+
* @category Database
|
|
182
|
+
*/
|
|
183
|
+
export type ContextOperator = Exclude<Operator, '==' | '!='> | 'in' | 'not in';
|
|
184
|
+
/**
|
|
185
|
+
* Set of operators supported by query context conditions, including list membership.
|
|
186
|
+
* @category Database
|
|
187
|
+
*/
|
|
188
|
+
export type AllOperators = Operator | 'in' | 'not in';
|
|
189
|
+
/**
|
|
190
|
+
* A generic value that can exist in a query.
|
|
191
|
+
* @category Database
|
|
192
|
+
*/
|
|
193
|
+
export type GenericValue<Doc = any, F extends Paths<Doc> = Paths<Doc>, O extends AllOperators = any> = O extends 'in' ? Array<DeepRecord<Doc>[F]> | null : O extends 'not in' ? Array<DeepRecord<Doc>[F]> | null : DeepRecord<Doc>[F] | null;
|