@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.
Files changed (32) hide show
  1. package/dist/backend/src/actions.d.ts +480 -193
  2. package/dist/backend/src/index.d.ts +7 -3
  3. package/dist/backend/src/llm-service.d.ts +13 -0
  4. package/dist/backend/src/metadata.d.ts +1 -273
  5. package/dist/backend/src/metadata.spec.d.ts +1 -0
  6. package/dist/backend/src/project.d.ts +12 -7
  7. package/dist/backend/src/public-types.d.ts +15 -0
  8. package/dist/backend/src/squid.service.d.ts +143 -0
  9. package/dist/backend/src/utils.d.ts +3 -0
  10. package/dist/cjs/index.js +2 -0
  11. package/dist/cjs/index.js.LICENSE.txt +8 -0
  12. package/dist/esm/index.js +2 -0
  13. package/dist/esm/index.js.LICENSE.txt +8 -0
  14. package/dist/internal-common/src/public-types-backend/ai-agent.public-context.d.ts +71 -0
  15. package/dist/internal-common/src/public-types-backend/api-call.public-context.d.ts +30 -0
  16. package/dist/internal-common/src/public-types-backend/application.public-types.d.ts +94 -0
  17. package/dist/internal-common/src/public-types-backend/bundle-api.public-types.d.ts +178 -0
  18. package/dist/internal-common/src/public-types-backend/bundle-data.public-types.d.ts +46 -0
  19. package/dist/internal-common/src/public-types-backend/distributed-lock.public-context.d.ts +4 -0
  20. package/dist/internal-common/src/public-types-backend/graphql.public-context.d.ts +7 -0
  21. package/dist/internal-common/src/public-types-backend/llm.public-types.d.ts +10 -0
  22. package/dist/internal-common/src/public-types-backend/mcp.public-types.d.ts +31 -0
  23. package/dist/internal-common/src/public-types-backend/metric.public-context.d.ts +12 -0
  24. package/dist/internal-common/src/public-types-backend/mutation.public-context.d.ts +148 -0
  25. package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +72 -0
  26. package/dist/internal-common/src/public-types-backend/query.public-context.d.ts +177 -0
  27. package/dist/internal-common/src/public-types-backend/storage.public-types.d.ts +15 -0
  28. package/dist/internal-common/src/public-types-backend/topic.public-context.d.ts +17 -0
  29. package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -0
  30. package/package.json +28 -9
  31. package/dist/backend/src/service.d.ts +0 -83
  32. package/dist/index.js +0 -2
@@ -1,193 +1,480 @@
1
- import { ActionMethodDecorator, AiChatbotActionType, AiFunctionAction, AiFunctionParam, ApiEndpointId, ClientConnectionStateChangeAction, CollectionName, CronExpression, CronExpressionString, DatabaseActionType, ExecutableAction, IntegrationId, QueryName, SchedulerAction, SchedulerId, SecureAiChatbotAction, SecureApiAction, SecureDatabaseAction, SecureDistributedLockAction, SecureGraphQLAction, SecureNamedQueryAction, SecureNativeQueryAction, TriggerAction, TriggerId, WebhookAction, WebhookId } from '@squidcloud/common';
2
- /**
3
- * Decorator that marks a function for securing a database.
4
- * The decorator takes a type of action and an optional integration ID.
5
- * If no integration ID is provided, the `built_in_db` integration is used.
6
- *
7
- * The function should return a boolean or a `Promise` of a boolean indicating
8
- * whether the action is allowed.
9
- * In addition, depending on the action, the function can take a context object
10
- * as a parameter. The context object contains information about the action.
11
- *
12
- * To read more about securing a database, see the
13
- * {@link https://docs.squid.cloud/docs/development-tools/backend/security-rules/secure-data-access#securedatabase documentation}.
14
- * @param type The type af action to secure.
15
- * @param integrationId The ID of the integration to secure.
16
- */
17
- export declare function secureDatabase<T extends DatabaseActionType>(type: T, integrationId?: IntegrationId): ActionMethodDecorator<SecureDatabaseAction<T>>;
18
- /**
19
- * Decorator that marks a function for securing a collection inside a database.
20
- * The decorator takes the collection, type of action, and an optional integration ID.
21
- * If no integration ID is provided, the `built_in_db` integration is used.
22
- *
23
- * The function should return a boolean or a `Promise` of a boolean indicating
24
- * whether the action is allowed.
25
- * In addition, depending on the action, the function can take a context object
26
- * as a parameter. The context object contains information about the action.
27
- *
28
- * To read more about securing a collection rules, see the
29
- * {@link https://docs.squid.cloud/docs/development-tools/backend/security-rules/secure-data-access#securecollection documentation}.
30
- * @param collectionName The name of the collection to secure.
31
- * @param type The type af action to secure.
32
- * @param integrationId The ID of the integration to secure.
33
- */
34
- export declare function secureCollection<T extends DatabaseActionType>(collectionName: CollectionName, type: T, integrationId?: IntegrationId): ActionMethodDecorator<SecureDatabaseAction<T>>;
35
- /**
36
- * Decorator that marks a function for securing an API or an endpoint inside an API.
37
- * The decorator takes the API integration ID, and an optional endpoint ID.
38
- * If no endpoint ID is provided, the function will secure the whole API.
39
- *
40
- * The function should return a boolean or a `Promise` of a boolean indicating
41
- * whether the action is allowed.
42
- * The function takes a context object as a parameter. The context object contains information about the action.
43
- *
44
- * To read more about securing an API, see the
45
- * {@link https://docs.squid.cloud/docs/development-tools/backend/security-rules/secure-api documentation}.
46
- * @param integrationId The ID of the integration to secure.
47
- * @param endpointId The ID of the endpoint to secure.
48
- */
49
- export declare function secureApi(integrationId: IntegrationId, endpointId?: ApiEndpointId): ActionMethodDecorator<SecureApiAction>;
50
- /**
51
- * Decorator that marks a function for securing a GraphQL integration.
52
- *
53
- * The function should return a boolean or a `Promise` of a boolean indicating
54
- * whether the action is allowed.
55
- * The function takes a context object as a parameter. The context object contains information about the action.
56
- *
57
- * To read more about securing a GraphQL integration, see the
58
- * {@link https://docs.squid.cloud/docs/development-tools/backend/security-rules/secure-graphql documentation}.
59
- * @param integrationId
60
- */
61
- export declare function secureGraphQL(integrationId: IntegrationId): ActionMethodDecorator<SecureGraphQLAction>;
62
- /**
63
- * Decorator that marks a function for exposing it as an executable.
64
- * The function can accept any parameter that can be serialized to JSON and return any parameter that can be serialzied
65
- * to JSON.
66
- *
67
- * Once the function is exposed, it can be called from the Squid Cloud SDK using the `executeFunction` method.
68
- * To read more about exposing an executable, see the
69
- * {@link https://docs.squid.cloud/docs/development-tools/backend/executables documentation}.
70
- */
71
- export declare function executable(): ActionMethodDecorator<ExecutableAction>;
72
- /**
73
- * Decorator that marks a function for exposing it to the AI assistant.
74
- * The function accepts a JSON object as described in the description of the function in the annotation.
75
- *
76
- * TODO - add docs
77
- * To read more about exposing an executable, see the
78
- * {@link https://docs.squid.cloud/docs/development-tools/backend/executables documentation}.
79
- */
80
- export declare function aiFunction<ParamType extends Record<string, any> = any>(description: string, params: Array<AiFunctionParam>): ActionMethodDecorator<AiFunctionAction<ParamType>>;
81
- /**
82
- * Decorator that marks a function as a trigger to a change in a collection. The function will be called each time a
83
- * change is made to the collection.
84
- * The function accepts a context object as a parameter. The context object contains information about the change.
85
- *
86
- * To read more about triggers, see the
87
- * {@link https://docs.squid.cloud/docs/development-tools/backend/triggers documentation}.
88
- *
89
- * @param ID The ID of the trigger. Should be unique.
90
- * @param collectionName The name of the collection to trigger on.
91
- * @param integrationId The ID of the integration to trigger on. If not provided, the `built_in_db` integration is
92
- * used.
93
- */
94
- export declare function trigger(id: TriggerId, collectionName: CollectionName, integrationId?: IntegrationId): ActionMethodDecorator<TriggerAction>;
95
- /**
96
- * Decorator that marks a function as a scheduler. The function will be called according to the provided cron
97
- * expression.
98
- *
99
- * To read more about schedulers, see the
100
- * {@link https://docs.squid.cloud/docs/development-tools/backend/schedulers documentation}.
101
- *
102
- * @param ID The ID of the scheduler. Should be unique.
103
- * @param cronExpression The cron expression to schedule the function on.
104
- * @param exclusive Whether the scheduler should be exclusive. If set to true, the scheduler will not trigger if the
105
- * previous scheduler is still running.
106
- */
107
- export declare function scheduler(id: SchedulerId, cronExpression: CronExpression | CronExpressionString, exclusive?: boolean): ActionMethodDecorator<SchedulerAction>;
108
- /**
109
- * Decorator that marks a function as a webhook. The function will be called when a webhook is triggered.
110
- * Once the webhook is created, it will be exposed as a URL with the provided webhook ID with this format:
111
- * `https://<your app Id>.<app region>.squid.cloud/webhooks/<webhook-id>`.
112
- *
113
- * The function accepts a context object as a parameter. The context object contains information about the webhook.
114
- * The function can return any value that can be serialized to JSON or a `WebhookResponse` object that can be created
115
- * using:
116
- * `this.createWebhookResponse(<params>)`.
117
- *
118
- * To read more about webhooks, see the
119
- * {@link https://docs.squid.cloud/docs/development-tools/backend/webhooks documentation}.
120
- * @param ID The ID of the webhook. Should be unique.
121
- */
122
- export declare function webhook(id: WebhookId): ActionMethodDecorator<WebhookAction>;
123
- /**
124
- * A decorator that can be applied on a static string property of a class to mark it as a named query.
125
- * The string can be any valid SQL in the given integration and can accept named parameters
126
- *
127
- * A named query can be invoked from the SDK using the `executeNamedQuery` method.
128
- *
129
- * To read more about named queries, see the
130
- * {@link https://docs.squid.cloud/docs/development-tools/backend/named-queries documentation}.
131
- *
132
- * @param integrationId The database integration ID (Note that the `built_in_db` does not support named queries)
133
- * @param name The name of the query that will be used to call it from the SDK.
134
- */
135
- export declare function namedQuery(integrationId: string, name: string): any;
136
- /**
137
- * A decorator that can be used to secure a named query. Named queries are secured by default and can be invoked only
138
- * if the decorated function allows it.
139
- * The function returns a boolean or a `Promise` of a boolean that indicates whether the query can be executed or not.
140
- *
141
- * The function accepts a context object as a parameter. The context object contains information about the query.
142
- *
143
- * To read more about securing a Named Query, see the
144
- * {@link https://docs.squid.cloud/docs/development-tools/backend/security-rules/secure-data-access#securenamedquery documentation}.
145
- *
146
- * @param integrationId The database integration ID.
147
- * @param queryName The name of the query.
148
- */
149
- export declare function secureNamedQuery(integrationId: IntegrationId, queryName: QueryName): ActionMethodDecorator<SecureNamedQueryAction>;
150
- /**
151
- * A decorator that can be used to secure a native query. Native queries are not secured by default and must be
152
- * explicitly secured using this decorator. The decorated function must return a boolean or a `Promise` of a boolean
153
- * that indicates whether the query can be executed or not.
154
- *
155
- * The function accepts a context object as a parameter. The context object contains information about the query.
156
- *
157
- * To read more about securing a Native Query, see the
158
- * {@link https://docs.squid.cloud/docs/development-tools/backend/security-rules/secure-data-access#securenativequery documentation}.
159
- *
160
- * @param integrationId The database integration ID.
161
- * @returns A decorator function that can be used to secure a native query.
162
- */
163
- export declare function secureNativeQuery(integrationId: IntegrationId): ActionMethodDecorator<SecureNativeQueryAction>;
164
- /**
165
- * A decorator that can be used to secure a distributed lock. Distributed locks are secured by default and can be
166
- * invoked only if the decorated function allows it. The function returns a boolean or a `Promise` of a boolean that
167
- * indicates whether the lock can be acquired or not.
168
- *
169
- * The function accepts a context object as a parameter. The context object contains information about the mutex and
170
- * the request.
171
- *
172
- * @param mutex The mutex to lock on. If none provided, the rule will apply for all mutexes.
173
- */
174
- export declare function secureDistributedLock(mutex?: string): ActionMethodDecorator<SecureDistributedLockAction>;
175
- /**
176
- * A decorator that can be used to secure an AI chatbot. The decorator takes the AI Chatbot
177
- * integration ID, the action type (`chat` or `mutate`), and an optional profile ID. If no profile ID
178
- * is provided, the function will secure all requests to the integration (for the given action type).
179
- *
180
- * The function should return a boolean or a `Promise` of a boolean indicating
181
- * whether the action is allowed.
182
- * The function takes a context object as a parameter. The context object contains information about the action.
183
- *
184
- * To read more about named queries, see the
185
- * {@link https://docs.squid.cloud/docs/development-tools/backend/security-rules/secure-ai-chatbot documentation}.
186
- *
187
- @param integrationId The ID of the integration to secure.
188
- @param type The type af action to secure.
189
- @param profileId The ID of the profile to secure.
190
- */
191
- export declare function secureAiChatbot<T extends AiChatbotActionType>(integrationId: IntegrationId, type: T, profileId?: string): ActionMethodDecorator<SecureAiChatbotAction<T>>;
192
- /** Decorator that marks a function for handling a client connection state change */
193
- export declare function clientConnectionStateHandler(): ActionMethodDecorator<ClientConnectionStateChangeAction>;
1
+ import { AiFunctionId, ApiEndpointId, CollectionName, IntegrationId, IntegrationType, TopicName } from '@squidcloud/client';
2
+ import { JSONSchema } from 'json-schema-typed';
3
+ import { ActionMethodDecorator, AiFunctionAction, ClientConnectionStateChangeAction, ExecutableAction, LimiterConfig, LimitsAction, LlmAskAction, McpAuthorizerAction, McpToolAction, SchedulerAction, SecureAiAgentAction, SecureAiQueryAction, SecureApiAction, SecureDatabaseAction, SecureDistributedLockAction, SecureGraphQLAction, SecureMetricAction, SecureNativeQueryAction, SecureStorageAction, SecureTopicAction, TriggerAction, WebhookAction } from '../../internal-common/src/public-types-backend/bundle-api.public-types';
4
+ import { AiFunctionAttributes, AiFunctionParam, DatabaseActionType, MetricActionType, StorageActionType, TopicActionType } from '../../internal-common/src/public-types-backend/bundle-data.public-types';
5
+ import { AiFunctionsConfiguratorRequest, AiFunctionsConfiguratorResponse, CronExpression, CronExpressionString, LlmServiceOptions, McpServerOptions, MutationType, SchedulerId, TriggerId, WebhookId } from './public-types';
6
+ /**
7
+ * Decorator that marks a function for securing a database.
8
+ * The decorator takes a type of action and an optional integration ID.
9
+ * If no integration ID is provided, the `built_in_db` integration is used.
10
+ *
11
+ * The function should return a boolean or a `Promise` of a boolean indicating
12
+ * whether the action is allowed.
13
+ * In addition, depending on the action, the function can take a context object
14
+ * as a parameter. The context object contains information about the action.
15
+ *
16
+ * To read more about securing a database, see the
17
+ * {@link https://docs.getsquid.ai/docs/security/security-rules/secure-data-access#securedatabase documentation}.
18
+ * @param type The type of action to secure.
19
+ * @param integrationId The ID of the integration to secure.
20
+ * @category Database
21
+ * @category Decorator
22
+ */
23
+ export declare function secureDatabase<T extends DatabaseActionType>(type: T, integrationId?: IntegrationId): ActionMethodDecorator<SecureDatabaseAction<T>>;
24
+ /**
25
+ * Decorator that marks a function for securing a database for querying it with AI (`executeAiQuery`).
26
+ *
27
+ * The decorator takes an optional integration ID.
28
+ * If no integration ID is provided, the `built_in_db` integration is used.
29
+ *
30
+ * The function should return a boolean or a `Promise` of a boolean indicating
31
+ * whether the action is allowed.
32
+ * In addition, the function takes a context object as a parameter.
33
+ * The context object contains information about the action.
34
+ *
35
+ * @param integrationId The ID of the integration to secure.
36
+ * @category Database
37
+ * @category Decorator
38
+ * @category AI
39
+ */
40
+ export declare function secureAiQuery(integrationId?: IntegrationId): ActionMethodDecorator<SecureAiQueryAction>;
41
+ /**
42
+ * Decorator that marks a function for securing a collection inside a database.
43
+ * The decorator takes the collection, type of action, and an optional integration ID.
44
+ * If no integration ID is provided, the `built_in_db` integration is used.
45
+ *
46
+ * The function should return a boolean or a `Promise` of a boolean indicating
47
+ * whether the action is allowed.
48
+ * In addition, depending on the action, the function can take a context object
49
+ * as a parameter. The context object contains information about the action.
50
+ *
51
+ * To read more about securing a collection rules, see the
52
+ * {@link https://docs.getsquid.ai/docs/security/security-rules/secure-data-access#securecollection documentation}.
53
+ * @param collectionName The name of the collection to secure.
54
+ * @param type The type of action to secure.
55
+ * @param integrationId The ID of the integration to secure.
56
+ * @category Database
57
+ * @category Decorator
58
+ */
59
+ export declare function secureCollection<T extends DatabaseActionType>(collectionName: CollectionName, type: T, integrationId?: IntegrationId): ActionMethodDecorator<SecureDatabaseAction<T>>;
60
+ /**
61
+ * The decorator allows protects storage buckets so only authorized users can access it.
62
+ * @category Storage
63
+ * @category Decorator
64
+ */
65
+ export declare function secureStorage<T extends StorageActionType>(type: T, integrationId?: IntegrationId): ActionMethodDecorator<SecureStorageAction<T>>;
66
+ /**
67
+ * Decorator that marks a function for securing a topic in a message queue.
68
+ * The decorator takes the topic name, type of action, and an optional integration ID.
69
+ * If no integration ID is provided, the `built_in_queue` integration is used.
70
+ *
71
+ * The function should return a boolean or a `Promise` of a boolean indicating
72
+ * whether the action is allowed.
73
+ *
74
+ * To read more about securing a topic, see the
75
+ * {@link https://docs.getsquid.ai/docs/security/security-rules/secure-data-access documentation}.
76
+ * @param topicName The name of the topic to secure.
77
+ * @param type The type of action to secure.
78
+ * @param integrationId The ID of the integration to secure.
79
+ * @category Queue
80
+ * @category Decorator
81
+ */
82
+ export declare function secureTopic<T extends TopicActionType>(topicName: TopicName, type: T, integrationId?: IntegrationId): ActionMethodDecorator<SecureTopicAction<T>>;
83
+ /**
84
+ * Decorator that marks a function for securing a metric.
85
+ * The decorator takes the metric name prefix and type of action.
86
+ *
87
+ * The function should return a boolean or a `Promise` of a boolean indicating
88
+ * whether the action is allowed.
89
+ * @category Decorator
90
+ */
91
+ export declare function secureMetric<T extends MetricActionType>(options: SecureMetricOptions<T>): ActionMethodDecorator<SecureMetricAction<T>>;
92
+ /**
93
+ * Options for '@secureMetrics' decorator.
94
+ * @category Platform
95
+ */
96
+ export interface SecureMetricOptions<T extends MetricActionType> {
97
+ /** The name prefix of the metric to secure. */
98
+ metricNamePrefix?: string;
99
+ /** The type of action to secure. */
100
+ type: T;
101
+ }
102
+ /**
103
+ * Decorator that marks a function for securing an API or an endpoint inside an API.
104
+ * The decorator takes the API integration ID, and an optional endpoint ID.
105
+ * If no endpoint ID is provided, the function will secure the whole API.
106
+ *
107
+ * The function should return a boolean or a `Promise` of a boolean indicating
108
+ * whether the action is allowed.
109
+ * The function takes a context object as a parameter. The context object contains information about the action.
110
+ *
111
+ * To read more about securing an API, see the
112
+ * {@link https://docs.getsquid.ai/docs/security/security-rules/secure-api documentation}.
113
+ * @param integrationId The ID of the integration to secure.
114
+ * @param endpointId The ID of the endpoint to secure.
115
+ * @category Decorator
116
+ */
117
+ export declare function secureApi(integrationId: IntegrationId, endpointId?: ApiEndpointId): ActionMethodDecorator<SecureApiAction>;
118
+ /**
119
+ * Decorator that marks a function for securing a GraphQL integration.
120
+ *
121
+ * The function should return a boolean or a `Promise` of a boolean indicating
122
+ * whether the action is allowed.
123
+ * The function takes a context object as a parameter. The context object contains information about the action.
124
+ *
125
+ * To read more about securing a GraphQL integration, see the
126
+ * {@link https://docs.getsquid.ai/docs/security/security-rules/secure-graphql/ documentation}.
127
+ * @param integrationId
128
+ * @category Decorator
129
+ */
130
+ export declare function secureGraphQL(integrationId: IntegrationId): ActionMethodDecorator<SecureGraphQLAction>;
131
+ /**
132
+ * Decorator marking a function as executable, making it accessible via the Squid SDK.
133
+ *
134
+ * Functions decorated with `@executable`:
135
+ * - May accept and return parameters serializable to JSON.
136
+ * - Automatically handle files or arrays of files from the client, receiving them as SquidFile objects.
137
+ *
138
+ * Once exposed, the decorated function can be executed using Squid's `executeFunction` method.
139
+ *
140
+ * For detailed guidance on executable functions, see:
141
+ * {@link https://docs.getsquid.ai/docs/sdk/backend-sdk/executables documentation}
142
+ * @category Decorator
143
+ */
144
+ export declare function executable(): ActionMethodDecorator<ExecutableAction>;
145
+ /**
146
+ * Options for the `@aiFunction` annotation.
147
+ * @category AI
148
+ */
149
+ export interface AiFunctionMetadataOptions {
150
+ /**
151
+ * Unique AI function ID. If not set, the function name (excluding the class name) is used as the default ID.
152
+ * If not provided the ID of the function is constructed as 'ClassName:FunctionName'.
153
+ */
154
+ id?: AiFunctionId;
155
+ /** Describes the capabilities of the function. This is used by the AI agent to determine when to call it. */
156
+ description: string;
157
+ /** Parameters for the AI function. These parameters are passed to the function by the calling agent. */
158
+ params: Array<AiFunctionParam>;
159
+ /** Additional optional attributes for the function. Example: related integrations. */
160
+ attributes?: AiFunctionAttributes;
161
+ /**
162
+ * The categories this function is associated with.
163
+ *
164
+ * Can be many or none. If no categories are specified, then the function is lumped into a default category.
165
+ *
166
+ * The Studio will group the functions into the categories for easier discovery.
167
+ *
168
+ * If multiple categories are given, the function will appear once in each category section in the Studio.
169
+ */
170
+ categories?: string[];
171
+ /** Mark the function as internal-only. Hides the function from appearing in the Studio. */
172
+ internal?: boolean;
173
+ }
174
+ /**
175
+ * Options for the `@mcpTool` annotation.
176
+ * @category AI
177
+ */
178
+ export interface McpToolMetadataOptions {
179
+ /** Describes the capabilities of the function. This is used by the AI agent to determine when to call it. */
180
+ description: string;
181
+ /** Parameters for the MCP Tool. */
182
+ inputSchema: JSONSchema;
183
+ /** (Optional) The tool output schema. */
184
+ outputSchema?: JSONSchema;
185
+ }
186
+ /**
187
+ * Decorator that marks a function for exposing it to the AI assistant.
188
+ * The function accepts a JSON object as described in the description of the function in the annotation.
189
+ *
190
+ * To read more about exposing an executable, see the
191
+ * {@link https://docs.getsquid.ai/docs/sdk/backend-sdk/ai/ai-functions documentation}.
192
+ * @category AI
193
+ * @category Decorator
194
+ */
195
+ export declare function aiFunction<ParamType extends Record<string, any> = any>(description: string, params: Array<AiFunctionParam>, attributes?: AiFunctionAttributes, categories?: Array<string>, internal?: boolean): ActionMethodDecorator<AiFunctionAction<ParamType>>;
196
+ /**
197
+ * Decorator that marks a function for exposing it to the AI assistant.
198
+ * The function accepts a JSON object as described in the description of the function in the annotation.
199
+ *
200
+ * To read more about exposing an executable, see the
201
+ * {@link https://docs.getsquid.ai/docs/sdk/backend-sdk/ai/ai-functions documentation}.
202
+ * @category AI
203
+ * @category Decorator
204
+ */
205
+ export declare function aiFunction<ParamType extends Record<string, any> = any>(options: AiFunctionMetadataOptions): ActionMethodDecorator<AiFunctionAction<ParamType>>;
206
+ /**
207
+ * Options for the `@aiFunctionsConfigurator` annotation.
208
+ * @category AI
209
+ */
210
+ export interface AiFunctionsConfiguratorMetadataOptions {
211
+ /**
212
+ * Unique AI function configurator ID.
213
+ * If not set, the function name (excluding the class name) is used as the default ID.
214
+ * If not provided the ID of the function is constructed as 'ClassName:FunctionName'.
215
+ */
216
+ id?: AiFunctionId;
217
+ /**
218
+ * Integration types this configurator should be called for to compute effective AI function overrides.
219
+ */
220
+ integrationTypes: Array<IntegrationType>;
221
+ }
222
+ /**
223
+ * A type defining an AI functions configurator action.
224
+ * @category AI
225
+ */
226
+ export type AiFunctionsConfiguratorAction = (req: AiFunctionsConfiguratorRequest) => AiFunctionsConfiguratorResponse;
227
+ /**
228
+ * Decorator that marks a function as a configurator for AI functions used for connected integrations.
229
+ * The configurator function accepts connected integration options and returns AI functions overrides.
230
+ * The configurator function is called only for connected integrations with non-default connection options.
231
+ * @category AI
232
+ * @category Decorator
233
+ */
234
+ export declare function aiFunctionsConfigurator(options: AiFunctionsConfiguratorMetadataOptions): ActionMethodDecorator<AiFunctionsConfiguratorAction>;
235
+ /**
236
+ * Options for the `@trigger` annotation.
237
+ * @category Platform
238
+ */
239
+ export interface TriggerOptions {
240
+ /**
241
+ * The ID of the trigger. Should be unique.
242
+ * If not used `ClassName.FunctionName` is used as an ID.
243
+ */
244
+ id?: string;
245
+ /** Name of the collection to trigger on. */
246
+ collection: string;
247
+ /** The ID of the integration to trigger on. If not provided, the `built_in_db` integration is used. */
248
+ integrationId?: string;
249
+ /**
250
+ * Types of mutations processed by the function annotated as `@trigger`.
251
+ * If not defined the function is called for all kinds of mutations.
252
+ */
253
+ mutationTypes?: Array<MutationType>;
254
+ }
255
+ /**
256
+ * Decorator that marks a function as a trigger to a change in a collection. The function will be called each time a
257
+ * change is made to the collection.
258
+ * The function accepts a context object as a parameter. The context object contains information about the change.
259
+ *
260
+ * To read more about triggers, see the
261
+ * {@link https://docs.getsquid.ai/docs/sdk/backend-sdk/triggers documentation}.
262
+ *
263
+ * @param id The ID of the trigger. Should be unique.
264
+ * @param collectionName The name of the collection to trigger on.
265
+ * @param integrationId The ID of the integration to trigger on. If not provided, the `built_in_db` integration is
266
+ * used.
267
+ * @category Decorator
268
+ */
269
+ export declare function trigger(id: TriggerId, collectionName: CollectionName, integrationId?: IntegrationId): ActionMethodDecorator<TriggerAction>;
270
+ /**
271
+ * Decorator that marks a function as a trigger to a change in a collection. The function will be called each time a
272
+ * change is made to the collection.
273
+ * The function accepts a context object as a parameter. The context object contains information about the change.
274
+ *
275
+ * To read more about triggers, see the
276
+ * {@link https://docs.getsquid.ai/docs/sdk/backend-sdk/triggers documentation}.
277
+ * @category Decorator
278
+ */
279
+ export declare function trigger(options: TriggerOptions): ActionMethodDecorator<TriggerAction>;
280
+ /**
281
+ * Options for the `@scheduler` annotation.
282
+ * @category Platform
283
+ */
284
+ export interface SchedulerOptions {
285
+ /** The cron expression (in UTC) to schedule the function on. */
286
+ cron: CronExpression | CronExpressionString;
287
+ /**
288
+ * The ID of the scheduler. Must be unique.
289
+ * If not provided the ID of the scheduler is constructed as 'ClassName:FunctionName'.
290
+ */
291
+ id?: SchedulerId;
292
+ /**
293
+ * Whether the scheduler should be exclusive.
294
+ * If set to true, the scheduler will not trigger if the previous scheduler is still running.
295
+ * Default: true.
296
+ */
297
+ exclusive?: boolean;
298
+ }
299
+ /**
300
+ * Decorator that marks a function as a scheduler. The function will be called according to the provided cron
301
+ * expression.
302
+ *
303
+ * To read more about schedulers, see the
304
+ * {@link https://docs.getsquid.ai/docs/sdk/backend-sdk/schedulers documentation}.
305
+ *
306
+ * @param id The ID of the scheduler. Should be unique.
307
+ * @param cronExpression The cron expression (in UTC) to schedule the function on.
308
+ * @param exclusive Whether the scheduler should be exclusive. If set to true, the scheduler will not trigger if the
309
+ * previous scheduler is still running. Default: true.
310
+ * @category Decorator
311
+ */
312
+ export declare function scheduler(id: SchedulerId, cronExpression: CronExpression | CronExpressionString, exclusive?: boolean): ActionMethodDecorator<SchedulerAction>;
313
+ /**
314
+ * Decorator that marks a function as a scheduler.
315
+ * The function will be called according to the provided cron expression.
316
+ *
317
+ * To read more about schedulers, see the
318
+ * {@link https://docs.getsquid.ai/docs/sdk/backend-sdk/schedulers documentation}.
319
+ * @category Decorator
320
+ */
321
+ export declare function scheduler(options: SchedulerOptions): ActionMethodDecorator<SchedulerAction>;
322
+ /**
323
+ * Decorator that marks a function as a webhook. The function will be called when a webhook is triggered.
324
+ * Once the webhook is created, it will be exposed as a URL with the provided webhook ID with this format:
325
+ * `https://<your app ID>.<app region>.squid.cloud/webhooks/<webhook-id>`.
326
+ *
327
+ * The function accepts a context object as a parameter. The context object contains information about the webhook.
328
+ * The function can return any value that can be serialized to JSON or a `WebhookResponse` object that can be created
329
+ * using:
330
+ * `this.createWebhookResponse(<params>)`.
331
+ *
332
+ * To read more about webhooks, see the
333
+ * {@link https://docs.getsquid.ai/docs/sdk/backend-sdk/webhooks documentation}.
334
+ * @param id The ID of the webhook. Should be unique.
335
+ * @category Decorator
336
+ */
337
+ export declare function webhook(id: WebhookId): ActionMethodDecorator<WebhookAction>;
338
+ /**
339
+ * A decorator that can be used to secure a native query. Native queries are not secured by default and must be
340
+ * explicitly secured using this decorator. The decorated function must return a boolean or a `Promise` of a boolean
341
+ * that indicates whether the query can be executed or not.
342
+ *
343
+ * The function accepts a context object as a parameter. The context object contains information about the query.
344
+ *
345
+ * To read more about securing a Native Query, see the
346
+ * {@link https://docs.getsquid.ai/docs/security/security-rules/secure-data-access#securing-native-queries
347
+ * documentation}.
348
+ *
349
+ * @param integrationId The database integration ID.
350
+ * @returns A decorator function that can be used to secure a native query.
351
+ * @category Database
352
+ * @category Decorator
353
+ */
354
+ export declare function secureNativeQuery(integrationId: IntegrationId): ActionMethodDecorator<SecureNativeQueryAction>;
355
+ /**
356
+ * A decorator that can be used to secure a distributed lock. Distributed locks are secured by default and can be
357
+ * invoked only if the decorated function allows it. The function returns a boolean or a `Promise` of a boolean that
358
+ * indicates whether the lock can be acquired or not.
359
+ *
360
+ * The function accepts a context object as a parameter. The context object contains information about the mutex and
361
+ * the request.
362
+ *
363
+ * @param mutex The mutex to lock on. If none provided, the rule will apply for all mutexes.
364
+ * @category Decorator
365
+ */
366
+ export declare function secureDistributedLock(mutex?: string): ActionMethodDecorator<SecureDistributedLockAction>;
367
+ /**
368
+ * A decorator that can be used to secure an AI agent.
369
+ *
370
+ * The function should return a boolean or a `Promise` of a boolean indicating
371
+ * whether the action is allowed.
372
+ * The function takes a context object as a parameter. The context object contains information about the action.
373
+ *
374
+ * To read more about securing an AI agent, see the
375
+ * {@link https://docs.getsquid.ai/docs/security/security-rules/secure-ai-agents documentation}.
376
+ *
377
+ @param agentId The ID of the agent to secure - if not provided, this will apply to all agents.
378
+ @category AI
379
+ @category Decorator
380
+ */
381
+ export declare function secureAiAgent(agentId?: string): ActionMethodDecorator<SecureAiAgentAction>;
382
+ /**
383
+ * A decorator that can be used to rate/quota limit a function. In its simplest form, the decorator
384
+ * can take the query rate that is allowed for the given function and/or how many total calls are
385
+ * permitted and will enforce those limits.
386
+ *
387
+ * It will either execute the function or return an Error if the rate/quota limits are exceeded.
388
+ *
389
+ * Rate Limit behavior:
390
+ * - The rate limit unit is QPS (Queries Per Second).
391
+ * - Bursts of up to 3x the given rate are permitted.
392
+ * - The consumption bucket refills gradually.
393
+ *
394
+ * Quota Limit behavior:
395
+ * - Has a `renewPeriod` field that defaults to "monthly".
396
+ * - The "monthly" period is defined as 30 days.
397
+ * - The "quarterly" period is defined as 90 days.
398
+ * - Renews occur at the top of the hour (##:00 for HH:mm).
399
+ * - No carry-over of unused quota from one period to the next.
400
+ * - Changes to the limit value for a specific limit combo (function & scope & renewPeriod) will
401
+ * reset the active count. For example, if a user has made 10 calls and the limit is changed from
402
+ * 20 to 15, the user will be able to make 15 more calls (not 5).
403
+ *
404
+ * Limits can be defined with more specifics and multiple limits can be
405
+ * defined for a single function.
406
+ *
407
+ * Examples:
408
+ * - Basic definition using defaults:
409
+ * ```
410
+ * @limits({ rateLimit: 5 }) // Only rate limit.
411
+ * @limits({ quotaLimit: 20 }) // Only quota limit.
412
+ * @limits({ rateLimit: 5, quotaLimit: 20 }) // Both rate and quota.
413
+ * ```
414
+ * Defaults to "global" scope and "monthly" renewPeriod.
415
+ * - As objects defining scope and renewPeriod:
416
+ * ```
417
+ * @limits({
418
+ * rateLimit: {
419
+ * value: 5,
420
+ * scope: 'global'
421
+ * },
422
+ * quotaLimit: {
423
+ * value: 20,
424
+ * scope: 'global',
425
+ * renewPeriod: 'monthly'
426
+ * }
427
+ * })
428
+ * ```
429
+ * - As arrays of objects defining scope and renewPeriod
430
+ * ```
431
+ * @limits({
432
+ * rateLimit: [
433
+ * { value: 5, scope: 'global' },
434
+ * { value: 2, scope: 'user' }
435
+ * ],
436
+ * quotaLimit: [
437
+ * { value: 20, scope: 'global', renewPeriod: 'monthly' },
438
+ * { value: 5000, scope: 'ip', renewPeriod: 'annually' }
439
+ * ]
440
+ * })
441
+ * ```
442
+ *
443
+ * All matching limits are consumed for each call. For example, an "IP" scoped limit will be
444
+ * consumed in addition to a "global" scoped limit.
445
+ *
446
+ * @param options LimiterConfig object specifying what kind of limits are desired.
447
+ * @category Decorator
448
+ */
449
+ export declare function limits(options: LimiterConfig): ActionMethodDecorator<LimitsAction>;
450
+ /**
451
+ * Decorator‐factory that takes service options and returns a ClassDecorator.
452
+ * @category Decorator
453
+ */
454
+ export declare function llmService(opts: LlmServiceOptions): ClassDecorator;
455
+ /**
456
+ * A decorator to mark a function to call to ask an LLM for a response.
457
+ * @category Decorator
458
+ */
459
+ export declare function llmAsk(): ActionMethodDecorator<LlmAskAction>;
460
+ /**
461
+ * Decorator that marks a class as an MCP server.
462
+ * @category Decorator
463
+ */
464
+ export declare function mcpServer(opts: McpServerOptions): ClassDecorator;
465
+ /**
466
+ * A decorator to mark a function as a tool that can be used by the MCP .
467
+ * @param options Options for the MCP tool.
468
+ * @category Decorator
469
+ */
470
+ export declare function mcpTool(options: McpToolMetadataOptions): ActionMethodDecorator<McpToolAction>;
471
+ /**
472
+ * A decorator to mark a function as authorized request handler for the MCP.
473
+ * @category Decorator
474
+ */
475
+ export declare function mcpAuthorizer(): ActionMethodDecorator<McpAuthorizerAction>;
476
+ /**
477
+ * Decorator that marks a function for handling a client connection state change.
478
+ * @category Platform
479
+ */
480
+ export declare function clientConnectionStateHandler(): ActionMethodDecorator<ClientConnectionStateChangeAction>;