@squidcloud/backend 1.0.145 → 1.0.146-beta
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/backend/src/actions.d.ts +480 -193
- package/dist/backend/src/index.d.ts +7 -3
- package/dist/backend/src/llm-service.d.ts +13 -0
- package/dist/backend/src/metadata.d.ts +1 -273
- package/dist/backend/src/metadata.spec.d.ts +1 -0
- package/dist/backend/src/project.d.ts +12 -7
- package/dist/backend/src/public-types.d.ts +15 -0
- package/dist/backend/src/squid.service.d.ts +143 -0
- package/dist/backend/src/utils.d.ts +3 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.LICENSE.txt +8 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.LICENSE.txt +8 -0
- package/dist/internal-common/src/public-types-backend/ai-agent.public-context.d.ts +71 -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/application.public-types.d.ts +94 -0
- package/dist/internal-common/src/public-types-backend/bundle-api.public-types.d.ts +178 -0
- package/dist/internal-common/src/public-types-backend/bundle-data.public-types.d.ts +46 -0
- package/dist/internal-common/src/public-types-backend/distributed-lock.public-context.d.ts +4 -0
- package/dist/internal-common/src/public-types-backend/graphql.public-context.d.ts +7 -0
- package/dist/internal-common/src/public-types-backend/llm.public-types.d.ts +10 -0
- package/dist/internal-common/src/public-types-backend/mcp.public-types.d.ts +31 -0
- package/dist/internal-common/src/public-types-backend/metric.public-context.d.ts +12 -0
- package/dist/internal-common/src/public-types-backend/mutation.public-context.d.ts +148 -0
- package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +72 -0
- package/dist/internal-common/src/public-types-backend/query.public-context.d.ts +177 -0
- package/dist/internal-common/src/public-types-backend/storage.public-types.d.ts +15 -0
- package/dist/internal-common/src/public-types-backend/topic.public-context.d.ts +17 -0
- package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -0
- package/package.json +28 -9
- package/dist/backend/src/service.d.ts +0 -83
- package/dist/index.js +0 -2
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { IntegrationId } from '@squidcloud/client';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the type of native query request, either relational, elastic or MongoDB.
|
|
4
|
+
* @category Database
|
|
5
|
+
*/
|
|
6
|
+
export type NativeQueryRequestType = 'relational' | 'mongo' | 'elasticsearch' | 'pure';
|
|
7
|
+
interface BaseNativeQueryContext {
|
|
8
|
+
/** Type of the native query request. */
|
|
9
|
+
type: NativeQueryRequestType;
|
|
10
|
+
/** Identifier for the integration. */
|
|
11
|
+
integrationId: IntegrationId;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Context for executing a relational database query.
|
|
15
|
+
* @category Database
|
|
16
|
+
*/
|
|
17
|
+
export interface RelationalNativeQueryContext extends BaseNativeQueryContext {
|
|
18
|
+
/** Specifies that the query is for a relational database. */
|
|
19
|
+
type: 'relational';
|
|
20
|
+
/** SQL query string to be executed. */
|
|
21
|
+
query: string;
|
|
22
|
+
/** Parameters to be used in the query. */
|
|
23
|
+
params: Record<string, any>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Context for executing a MongoDB query.
|
|
27
|
+
* @category Database
|
|
28
|
+
*/
|
|
29
|
+
export interface MongoNativeQueryContext extends BaseNativeQueryContext {
|
|
30
|
+
/** Specifies that the query is for a Mongo database. */
|
|
31
|
+
type: 'mongo';
|
|
32
|
+
/** Name of the MongoDB collection to query. */
|
|
33
|
+
collectionName: string;
|
|
34
|
+
/** Array of aggregation pipeline stages. */
|
|
35
|
+
aggregationPipeline: Array<any | undefined>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Context for executing an Elasticsearch query.
|
|
39
|
+
* @category Database
|
|
40
|
+
*/
|
|
41
|
+
export interface ElasticsearchNativeQueryContext {
|
|
42
|
+
/** Specifies that the query is for an Elasticsearch database. */
|
|
43
|
+
type: 'elasticsearch';
|
|
44
|
+
/** Elasticsearch index to query. */
|
|
45
|
+
index: string;
|
|
46
|
+
/** Elasticsearch query string. */
|
|
47
|
+
endpoint?: string;
|
|
48
|
+
/** HTTP method to use for the request. */
|
|
49
|
+
method?: 'GET' | 'POST';
|
|
50
|
+
/** Body of the request. */
|
|
51
|
+
body: Record<string, any>;
|
|
52
|
+
/** Headers to include in the request. */
|
|
53
|
+
integrationId: IntegrationId;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Context for executing a pure database query.
|
|
57
|
+
* @category Database
|
|
58
|
+
*/
|
|
59
|
+
export interface PureNativeQueryContext extends BaseNativeQueryContext {
|
|
60
|
+
/** Specifies that the query is for a relational database. */
|
|
61
|
+
type: 'pure';
|
|
62
|
+
/** SQL query string to be executed. */
|
|
63
|
+
query: string;
|
|
64
|
+
/** Parameters to be used in the query. */
|
|
65
|
+
params: Record<string, any>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Union type representing either a relational or MongoDB native query context.
|
|
69
|
+
* @category Database
|
|
70
|
+
*/
|
|
71
|
+
export type NativeQueryContext = RelationalNativeQueryContext | MongoNativeQueryContext | ElasticsearchNativeQueryContext | PureNativeQueryContext;
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { AiQueryOptions } from '@squidcloud/client';
|
|
2
|
+
import { IntegrationId } from '@squidcloud/client';
|
|
3
|
+
import { CollectionName, DocumentData } from '@squidcloud/client';
|
|
4
|
+
import { FieldSort, Operator, Query, SimpleCondition } from '@squidcloud/client';
|
|
5
|
+
import { DeepRecord, FieldOf, PartialBy, Paths } from '@squidcloud/client';
|
|
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
|
+
* Verifies that the query's sort order aligns with the provided field sorts. The fields specified in the `sorts`
|
|
37
|
+
* parameter must appear in the exact order at the beginning of the query's sort sequence. The query can include
|
|
38
|
+
* additional fields in its sort order, but only after the specified sorts.
|
|
39
|
+
*
|
|
40
|
+
* @param sorts An array of field sorts.
|
|
41
|
+
* @returns Whether the query's sorts matches the provided field sorts.
|
|
42
|
+
*/
|
|
43
|
+
sortedBy(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Verifies that the query's sort order exactly matches the provided field sorts. The fields specified in the
|
|
46
|
+
* `sorts` parameter must appear in the exact order in the query's sort sequence. No additional sorts may be present
|
|
47
|
+
* in the query.
|
|
48
|
+
*
|
|
49
|
+
* @param sorts An array of field sorts.
|
|
50
|
+
* @returns Whether the query's sorts exactly match the provided field sorts.
|
|
51
|
+
*/
|
|
52
|
+
sortedByExact(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
|
|
55
|
+
* to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
|
|
56
|
+
* additional conditions, as these only narrow the result set.
|
|
57
|
+
*
|
|
58
|
+
* @param fieldName The name of the field for the condition.
|
|
59
|
+
* @param operator The operator of the condition.
|
|
60
|
+
* @param value The value of the condition.
|
|
61
|
+
* @returns Whether the query is a subquery of the parent condition.
|
|
62
|
+
*/
|
|
63
|
+
isSubqueryOf<F extends Paths<T>, O extends AllOperators>(fieldName: F, operator: O, value: GenericValue<T, F, O> | null): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
|
|
66
|
+
* to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
|
|
67
|
+
* additional conditions, as these only narrow the result set.
|
|
68
|
+
*
|
|
69
|
+
* @param condition The condition to validate.
|
|
70
|
+
* @returns Whether the query is a subquery of the parent condition.
|
|
71
|
+
*/
|
|
72
|
+
isSubqueryOfCondition(condition: GeneralCondition<T>): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Verifies that the query is a subquery of the specified conditions. A subquery is defined as a query that evaluates
|
|
75
|
+
* to a subset of the results that would be obtained by applying the parent conditions. The subquery may also include
|
|
76
|
+
* additional conditions, as these only narrow the result set.
|
|
77
|
+
*
|
|
78
|
+
* @param conditions The conditions to validate.
|
|
79
|
+
* @returns Whether the query includes subquery of the parent conditions.
|
|
80
|
+
*/
|
|
81
|
+
isSubqueryOfConditions(conditions: GeneralConditions<T>): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Verifies that the query is a subquery of the specified query. A subquery is defined as a query that evaluates
|
|
84
|
+
* to a subset of the results that obtained for the parent query, including sorts and limits.
|
|
85
|
+
*
|
|
86
|
+
* @param query The query to validate.
|
|
87
|
+
* @returns Whether the query is a subquery of the parent query.
|
|
88
|
+
*/
|
|
89
|
+
isSubqueryOfQuery(query: Query<T>): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Returns all conditions that apply to any of the specified field names. This method
|
|
92
|
+
* provides a convenient way to retrieve all conditions that involve a specific set of fields.
|
|
93
|
+
*
|
|
94
|
+
* @param fieldNames The field names for which to retrieve conditions.
|
|
95
|
+
* @returns An array of conditions that involve any of the specified field names.
|
|
96
|
+
*/
|
|
97
|
+
getConditionsFor<K extends Paths<T>>(...fieldNames: Array<K>): ContextConditions<T, K>;
|
|
98
|
+
/**
|
|
99
|
+
* Returns all conditions that apply to the specified field name. This method provides
|
|
100
|
+
* a convenient way to retrieve all conditions that involve a specific field.
|
|
101
|
+
*
|
|
102
|
+
* @param fieldName The field name for which to retrieve conditions.
|
|
103
|
+
* @returns An array of conditions that involve the specified field name.
|
|
104
|
+
*/
|
|
105
|
+
getConditionsForField<K extends Paths<T>>(fieldName: K): ContextConditions<T>;
|
|
106
|
+
/**
|
|
107
|
+
* Returns true if the given document can be a result of the query.
|
|
108
|
+
* The method does not account for limit and sort order.
|
|
109
|
+
*/
|
|
110
|
+
documentMatchesQuery(doc: DocumentData): boolean;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A list of context conditions.
|
|
114
|
+
* @category Database
|
|
115
|
+
*/
|
|
116
|
+
export type ContextConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<ContextCondition<Doc, F>>;
|
|
117
|
+
/**
|
|
118
|
+
* A Context condition - a condition that replaces multiple '==' or '!=' conditions with 'in' and 'not in'.
|
|
119
|
+
* @category Database
|
|
120
|
+
*/
|
|
121
|
+
export type ContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = InContextCondition<Doc, F> | NotInContextCondition<Doc, F> | OtherContextCondition<Doc, F>;
|
|
122
|
+
/**
|
|
123
|
+
* A condition using the 'in' operator to match values within a set.
|
|
124
|
+
* @category Database
|
|
125
|
+
*/
|
|
126
|
+
export interface InContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'in'> {
|
|
127
|
+
/** Specifies the 'in' operator to check if a value exists within an array. */
|
|
128
|
+
operator: 'in';
|
|
129
|
+
/** An array of values to match against the field. */
|
|
130
|
+
value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* A condition using the 'not in' operator to exclude values within a set.
|
|
134
|
+
* @category Database
|
|
135
|
+
*/
|
|
136
|
+
export interface NotInContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'not in'> {
|
|
137
|
+
/** Specifies the 'not in' operator to check if a value does not exist within an array. */
|
|
138
|
+
operator: 'not in';
|
|
139
|
+
/** An array of values to exclude from the field. */
|
|
140
|
+
value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* A condition using operators other than 'in' or 'not in' for field comparisons.
|
|
144
|
+
* @category Database
|
|
145
|
+
*/
|
|
146
|
+
export interface OtherContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, Exclude<ContextOperator, 'in' | 'not in'>> {
|
|
147
|
+
/** The operator to use for the comparison, excluding 'in' and 'not in'. */
|
|
148
|
+
operator: Exclude<ContextOperator, 'in' | 'not in'>;
|
|
149
|
+
/** The value to compare against the field. */
|
|
150
|
+
value: FieldOf<DeepRecord<Doc>, Paths<Doc>> | any;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* A condition that includes all operators, including 'in' and 'not in', for general use.
|
|
154
|
+
* @category Database
|
|
155
|
+
*/
|
|
156
|
+
export interface GeneralCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, AllOperators> {
|
|
157
|
+
/** The operator to apply to the condition, including all possible operators. */
|
|
158
|
+
operator: AllOperators;
|
|
159
|
+
/** The value to use in the condition comparison. */
|
|
160
|
+
value: any;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* A list of general conditions.
|
|
164
|
+
* @category Database
|
|
165
|
+
*/
|
|
166
|
+
export type GeneralConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<GeneralCondition<Doc, F>>;
|
|
167
|
+
/**
|
|
168
|
+
* @category Database
|
|
169
|
+
*/
|
|
170
|
+
export type ContextOperator = Exclude<Operator, '==' | '!='> | 'in' | 'not in';
|
|
171
|
+
type AllOperators = Operator | 'in' | 'not in';
|
|
172
|
+
/**
|
|
173
|
+
* A generic value that can exist in a query.
|
|
174
|
+
* @category Database
|
|
175
|
+
*/
|
|
176
|
+
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;
|
|
177
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IntegrationId } from '@squidcloud/client';
|
|
2
|
+
import { StorageActionType } from './bundle-data.public-types';
|
|
3
|
+
/** Supported types of storage operations. */
|
|
4
|
+
export type StorageFunctionality = 'fileUpload' | 'getFileMetadata' | 'getDownloadUrl' | 'deleteFiles' | 'listDirectoryContents';
|
|
5
|
+
/** Context for performing a storage-related operation. */
|
|
6
|
+
export interface StorageContext {
|
|
7
|
+
/** Identifier of the integration performing the storage action. */
|
|
8
|
+
integrationId: IntegrationId;
|
|
9
|
+
/** List of paths within the storage bucket relevant to the action. */
|
|
10
|
+
pathsInBucket: Array<string>;
|
|
11
|
+
/** Type of action being performed on the storage. */
|
|
12
|
+
action: StorageActionType;
|
|
13
|
+
/** Specific storage functionality being used. */
|
|
14
|
+
functionality: StorageFunctionality;
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IntegrationId } from '@squidcloud/client';
|
|
2
|
+
/** Context used when reading from a topic. */
|
|
3
|
+
export interface TopicReadContext {
|
|
4
|
+
/** Identifier of the integration the topic belongs to. */
|
|
5
|
+
integrationId: IntegrationId;
|
|
6
|
+
/** Name of the topic being read. */
|
|
7
|
+
topicName: string;
|
|
8
|
+
}
|
|
9
|
+
/** Context used when writing to a topic. */
|
|
10
|
+
export interface TopicWriteContext<T> {
|
|
11
|
+
/** Identifier of the integration the topic belongs to. */
|
|
12
|
+
integrationId: IntegrationId;
|
|
13
|
+
/** Name of the topic being written to. */
|
|
14
|
+
topicName: string;
|
|
15
|
+
/** Messages to write to the topic. */
|
|
16
|
+
messages: Array<T>;
|
|
17
|
+
}
|