@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
@@ -0,0 +1,71 @@
1
+ import { AiConnectedIntegrationMetadata, AiSessionContext, AllAiAgentChatOptions } from '@squidcloud/client';
2
+ import { AiFunctionId } from '@squidcloud/client';
3
+ import { AiAgentId, IntegrationId } from '@squidcloud/client';
4
+ import { IntegrationType } from '@squidcloud/client';
5
+ /**
6
+ * Context object passed as a second parameter to every AI function call,
7
+ * providing both agent-specific and function-specific context.
8
+ * @category AI
9
+ */
10
+ export interface AiFunctionCallContext<FunctionContextType = unknown, AgentContextType = unknown> {
11
+ /** Unique identifier for the AI agent making the call. */
12
+ agentId: AiAgentId;
13
+ /**
14
+ * Persistent context of the AI agent that calls the function.
15
+ * Same for all AI functions used by this agent.
16
+ */
17
+ agentContext: AgentContextType;
18
+ /**
19
+ * Context specific to each individual AI function call.
20
+ * Can contain parameters or data unique to the current function invocation
21
+ * or current function connection to the AI agent.
22
+ */
23
+ functionContext: FunctionContextType;
24
+ /** The session associated with this AI function call. */
25
+ sessionContext: AiSessionContext;
26
+ }
27
+ /** AiFunctionContext for the connected integration function. Contains predefined integration data. */
28
+ export interface AiFunctionCallContextWithIntegration<AiConnectedIntegrationOptionsType = unknown, FunctionContextType = unknown, AgentContextType = unknown> extends AiFunctionCallContext<FunctionContextType, AgentContextType>, AiConnectedIntegrationMetadata<AiConnectedIntegrationOptionsType> {
29
+ }
30
+ /**
31
+ * Provides context to the security rules of an AI Agent for each new user prompt.
32
+ * Refer to the `@secureAiAgent` annotation for more details.
33
+ * @category AI
34
+ */
35
+ export declare class SecureAiAgentContext {
36
+ readonly prompt?: string;
37
+ readonly agentId: AiAgentId;
38
+ readonly options?: AllAiAgentChatOptions;
39
+ }
40
+ /**
41
+ * A type defining an AI functions configurator request.
42
+ * @category AI
43
+ */
44
+ export interface AiFunctionsConfiguratorRequest {
45
+ /** ID of the connected integration to configure. */
46
+ integrationId: IntegrationId;
47
+ /** Type of the integration to configure. */
48
+ integrationType: IntegrationType;
49
+ /** Current connected integration metadata with custom options. */
50
+ metadata: AiConnectedIntegrationMetadata;
51
+ }
52
+ /**
53
+ * Result of the configurator function call:
54
+ * details how to override the set of AI functions available in the bundle.
55
+ */
56
+ export interface AiFunctionsConfiguratorResponse {
57
+ /**
58
+ * Map of overridden functions.
59
+ * If a function is not mentioned in the map - there is no override.
60
+ */
61
+ functionOverrides: Record<AiFunctionId, AiFunctionOverrideDetails>;
62
+ }
63
+ /** An override for a single AI function. */
64
+ export interface AiFunctionOverrideDetails {
65
+ /** Overridden AI function ID. */
66
+ id: AiFunctionId;
67
+ /** If set to true, the function won't be available for the connector agent. */
68
+ isExcluded?: boolean;
69
+ /** Set of parameters to fill with a predefined values. */
70
+ predefinedParameters: Record<string, unknown>;
71
+ }
@@ -0,0 +1,30 @@
1
+ import { ApiOptions } from '@squidcloud/client';
2
+ import { ApiEndpointId, HttpMethod } from '@squidcloud/client';
3
+ import { IntegrationId } from '@squidcloud/client';
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,94 @@
1
+ /** A type alias for a string that represents a webhook. */
2
+ export type WebhookId = string;
3
+ /** A type alias for a string that represents a trigger ID. */
4
+ export type TriggerId = string;
5
+ /** A type alias for a string that represents a scheduler ID. */
6
+ export type SchedulerId = string;
7
+ /** The supported cron expression string. */
8
+ export type CronExpressionString = `${string} ${string} ${string} ${string} ${string}` | `${string} ${string} ${string} ${string}`;
9
+ /** A set of predefined cron expressions. */
10
+ export declare enum CronExpression {
11
+ EVERY_SECOND = "* * * * * *",
12
+ EVERY_5_SECONDS = "*/5 * * * * *",
13
+ EVERY_10_SECONDS = "*/10 * * * * *",
14
+ EVERY_30_SECONDS = "*/30 * * * * *",
15
+ EVERY_MINUTE = "*/1 * * * *",
16
+ EVERY_5_MINUTES = "0 */5 * * * *",
17
+ EVERY_10_MINUTES = "0 */10 * * * *",
18
+ EVERY_30_MINUTES = "0 */30 * * * *",
19
+ EVERY_HOUR = "0 0-23/1 * * *",
20
+ EVERY_2_HOURS = "0 0-23/2 * * *",
21
+ EVERY_3_HOURS = "0 0-23/3 * * *",
22
+ EVERY_4_HOURS = "0 0-23/4 * * *",
23
+ EVERY_5_HOURS = "0 0-23/5 * * *",
24
+ EVERY_6_HOURS = "0 0-23/6 * * *",
25
+ EVERY_7_HOURS = "0 0-23/7 * * *",
26
+ EVERY_8_HOURS = "0 0-23/8 * * *",
27
+ EVERY_9_HOURS = "0 0-23/9 * * *",
28
+ EVERY_10_HOURS = "0 0-23/10 * * *",
29
+ EVERY_11_HOURS = "0 0-23/11 * * *",
30
+ EVERY_12_HOURS = "0 0-23/12 * * *",
31
+ EVERY_DAY_AT_1AM = "0 01 * * *",
32
+ EVERY_DAY_AT_2AM = "0 02 * * *",
33
+ EVERY_DAY_AT_3AM = "0 03 * * *",
34
+ EVERY_DAY_AT_4AM = "0 04 * * *",
35
+ EVERY_DAY_AT_5AM = "0 05 * * *",
36
+ EVERY_DAY_AT_6AM = "0 06 * * *",
37
+ EVERY_DAY_AT_7AM = "0 07 * * *",
38
+ EVERY_DAY_AT_8AM = "0 08 * * *",
39
+ EVERY_DAY_AT_9AM = "0 09 * * *",
40
+ EVERY_DAY_AT_10AM = "0 10 * * *",
41
+ EVERY_DAY_AT_11AM = "0 11 * * *",
42
+ EVERY_DAY_AT_NOON = "0 12 * * *",
43
+ EVERY_DAY_AT_1PM = "0 13 * * *",
44
+ EVERY_DAY_AT_2PM = "0 14 * * *",
45
+ EVERY_DAY_AT_3PM = "0 15 * * *",
46
+ EVERY_DAY_AT_4PM = "0 16 * * *",
47
+ EVERY_DAY_AT_5PM = "0 17 * * *",
48
+ EVERY_DAY_AT_6PM = "0 18 * * *",
49
+ EVERY_DAY_AT_7PM = "0 19 * * *",
50
+ EVERY_DAY_AT_8PM = "0 20 * * *",
51
+ EVERY_DAY_AT_9PM = "0 21 * * *",
52
+ EVERY_DAY_AT_10PM = "0 22 * * *",
53
+ EVERY_DAY_AT_11PM = "0 23 * * *",
54
+ EVERY_DAY_AT_MIDNIGHT = "0 0 * * *",
55
+ EVERY_WEEK = "0 0 * * 7",
56
+ EVERY_WEEKDAY = "0 0 * * 1-5",
57
+ EVERY_WEEKEND = "0 0 * * 6,7",
58
+ EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT = "0 0 1 * *",
59
+ EVERY_1ST_DAY_OF_MONTH_AT_NOON = "0 12 1 * *",
60
+ EVERY_2ND_HOUR = "0 */2 * * *",
61
+ EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM = "0 1-23/2 * * *",
62
+ EVERY_2ND_MONTH = "0 0 1 */2 *",
63
+ EVERY_QUARTER = "0 0 1 */3 *",
64
+ EVERY_6_MONTHS = "0 0 1 */6 *",
65
+ EVERY_YEAR = "0 0 1 1 *",
66
+ EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM = "0 */30 9-17 * * *",
67
+ EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM = "0 */30 9-18 * * *",
68
+ EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM = "0 */30 10-19 * * *",
69
+ MONDAY_TO_FRIDAY_AT_1AM = "0 0 01 * * 1-5",
70
+ MONDAY_TO_FRIDAY_AT_2AM = "0 0 02 * * 1-5",
71
+ MONDAY_TO_FRIDAY_AT_3AM = "0 0 03 * * 1-5",
72
+ MONDAY_TO_FRIDAY_AT_4AM = "0 0 04 * * 1-5",
73
+ MONDAY_TO_FRIDAY_AT_5AM = "0 0 05 * * 1-5",
74
+ MONDAY_TO_FRIDAY_AT_6AM = "0 0 06 * * 1-5",
75
+ MONDAY_TO_FRIDAY_AT_7AM = "0 0 07 * * 1-5",
76
+ MONDAY_TO_FRIDAY_AT_8AM = "0 0 08 * * 1-5",
77
+ MONDAY_TO_FRIDAY_AT_9AM = "0 0 09 * * 1-5",
78
+ MONDAY_TO_FRIDAY_AT_09_30AM = "0 30 09 * * 1-5",
79
+ MONDAY_TO_FRIDAY_AT_10AM = "0 0 10 * * 1-5",
80
+ MONDAY_TO_FRIDAY_AT_11AM = "0 0 11 * * 1-5",
81
+ MONDAY_TO_FRIDAY_AT_11_30AM = "0 30 11 * * 1-5",
82
+ MONDAY_TO_FRIDAY_AT_12PM = "0 0 12 * * 1-5",
83
+ MONDAY_TO_FRIDAY_AT_1PM = "0 0 13 * * 1-5",
84
+ MONDAY_TO_FRIDAY_AT_2PM = "0 0 14 * * 1-5",
85
+ MONDAY_TO_FRIDAY_AT_3PM = "0 0 15 * * 1-5",
86
+ MONDAY_TO_FRIDAY_AT_4PM = "0 0 16 * * 1-5",
87
+ MONDAY_TO_FRIDAY_AT_5PM = "0 0 17 * * 1-5",
88
+ MONDAY_TO_FRIDAY_AT_6PM = "0 0 18 * * 1-5",
89
+ MONDAY_TO_FRIDAY_AT_7PM = "0 0 19 * * 1-5",
90
+ MONDAY_TO_FRIDAY_AT_8PM = "0 0 20 * * 1-5",
91
+ MONDAY_TO_FRIDAY_AT_9PM = "0 0 21 * * 1-5",
92
+ MONDAY_TO_FRIDAY_AT_10PM = "0 0 22 * * 1-5",
93
+ MONDAY_TO_FRIDAY_AT_11PM = "0 0 23 * * 1-5"
94
+ }
@@ -0,0 +1,178 @@
1
+ import { UserAiAskResponse, UserAiChatOptions } from '@squidcloud/client';
2
+ import { ClientId, IntegrationId } from '@squidcloud/client';
3
+ import { CollectionName, DocIdOrDocIdObj, DocumentData } from '@squidcloud/client';
4
+ import { ClientConnectionState } from '@squidcloud/client';
5
+ import { AiFunctionCallContextWithIntegration, SecureAiAgentContext } from './ai-agent.public-context';
6
+ import { ApiCallContext } from './api-call.public-context';
7
+ import { DatabaseActionType, MetricActionType, StorageActionType, TopicActionType } from './bundle-data.public-types';
8
+ import { DistributedLockContext } from './distributed-lock.public-context';
9
+ import { GraphqlContext } from './graphql.public-context';
10
+ import { McpAuthorizationRequest } from './mcp.public-types';
11
+ import { SecureMetricContext } from './metric.public-context';
12
+ import { MutationContext, MutationType } from './mutation.public-context';
13
+ import { NativeQueryContext } from './native-query.public-context';
14
+ import { AiQueryContext, QueryContext } from './query.public-context';
15
+ import { StorageContext } from './storage.public-types';
16
+ import { TopicReadContext, TopicWriteContext } from './topic.public-context';
17
+ /**
18
+ * @category Database
19
+ */
20
+ export type SecureDatabaseAction<T extends DatabaseActionType> = T extends 'all' ? () => boolean | Promise<boolean> : T extends 'read' ? ((context: QueryContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>) : ((context: MutationContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
21
+ /**
22
+ * @category Database
23
+ * @category AI
24
+ */
25
+ export type SecureAiQueryAction = ((context: AiQueryContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
26
+ /**
27
+ * @category Storage
28
+ */
29
+ export type SecureStorageAction<T extends StorageActionType> = T extends 'all' ? () => boolean | Promise<boolean> : (context: StorageContext) => boolean | Promise<boolean>;
30
+ /**
31
+ * @category Queue
32
+ */
33
+ export type SecureTopicAction<T extends TopicActionType> = T extends 'all' ? () => boolean | Promise<boolean> : T extends 'read' ? ((context: TopicReadContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>) : ((context: TopicWriteContext<T>) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
34
+ /** A function that determines access to a metric based on the action type T. */
35
+ export type SecureMetricAction<T extends MetricActionType> = T extends 'all' ? ((context: SecureMetricContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>) : T extends 'write' ? ((context: SecureMetricContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>) : never;
36
+ /** A function that determines access to an API call, optionally using the call context. */
37
+ export type SecureApiAction = ((context: ApiCallContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
38
+ /** A function that determines access to a native query, optionally using the query context. */
39
+ export type SecureNativeQueryAction = ((context: NativeQueryContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
40
+ /** A function that determines access to a distributed lock, optionally using the lock context. */
41
+ export type SecureDistributedLockAction = ((context: DistributedLockContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
42
+ /** A function that determines access to a GraphQL operation, optionally using the GraphQL context. */
43
+ export type SecureGraphQLAction = ((context: GraphqlContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
44
+ /**
45
+ * @category AI
46
+ */
47
+ export type SecureAiAgentAction = ((context: SecureAiAgentContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
48
+ /** A type defining a function that handles changes in client connection state. */
49
+ export type ClientConnectionStateChangeAction = (clientId: ClientId, clientConnectionState: ClientConnectionState) => Promise<void> | void;
50
+ /** A type representing a generic executable function with variable arguments. */
51
+ export type ExecutableAction = (...args: any[]) => any;
52
+ /**
53
+ * A type defining an AI function action with parameters and context.
54
+ * The context object may be AiFunctionCallContext (for functions with no integration type) or
55
+ * AiFunctionCallContextWithIntegration.
56
+ * @category AI
57
+ */
58
+ export type AiFunctionAction<T extends Record<string, any> = any> = (params: T, context: AiFunctionCallContextWithIntegration<any, any, any>) => any;
59
+ /**
60
+ * A type defining an MCP tool with parameters.
61
+ * @category AI
62
+ */
63
+ export type McpToolAction<T extends Record<string, any> = any> = (params: T) => any;
64
+ /**
65
+ * A type defining an MCP authorizer action that can authorize requests.
66
+ * @category AI
67
+ */
68
+ export type McpAuthorizerAction = ((request: McpAuthorizationRequest) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
69
+ /** A type defining a trigger function that responds to document changes. */
70
+ export type TriggerAction = ((request: TriggerRequest) => void | Promise<void>) | (() => void | Promise<void>);
71
+ /** The context provided to a trigger function. */
72
+ export interface TriggerRequest<T extends DocumentData = any> {
73
+ /** The ID of the integration associated with the trigger. */
74
+ integrationId: IntegrationId;
75
+ /** The name of the collection affected by the trigger. */
76
+ collectionName: CollectionName;
77
+ /** The document ID or object representing the affected document. */
78
+ docId: DocIdOrDocIdObj;
79
+ /** The type of mutation that triggered the action. */
80
+ mutationType: MutationType;
81
+ /** The document state before the mutation, if available. */
82
+ docBefore?: T;
83
+ /** The document state after the mutation, if available. */
84
+ docAfter?: T;
85
+ }
86
+ /** A type defining a scheduled task action. */
87
+ export type SchedulerAction = () => void | Promise<void>;
88
+ /** Defines a function with rate or quota limits. */
89
+ export type LimitsAction = (...args: any[]) => any | Promise<any>;
90
+ /** Specifies the scope of a limiter, such as per IP, user, or global. */
91
+ export type LimiterScope = 'ip' | 'user' | 'global';
92
+ /** Specifies the renewal period for a quota limit. */
93
+ export type QuotaRenewPeriod = 'hourly' | 'daily' | 'weekly' | 'monthly' | 'quarterly' | 'annually';
94
+ /** Options for rate limiting. */
95
+ export interface RateLimitOptions {
96
+ /** Number of executions permitted per second, allowing bursts up to 3x this limit. */
97
+ value: number;
98
+ /** Specifies the scope of the rate limit, such as per user, IP, or global. */
99
+ scope?: LimiterScope;
100
+ }
101
+ /** Options for quota limiting. */
102
+ export interface QuotaLimitOptions {
103
+ /** Total number of executions allowed, reset upon backend redeployment. */
104
+ value: number;
105
+ /** Specifies the scope of the quota limit, such as per user, IP, or global. */
106
+ scope?: LimiterScope;
107
+ /** Defines the period after which the quota resets. */
108
+ renewPeriod?: QuotaRenewPeriod;
109
+ }
110
+ /**
111
+ * Options for rate and quota limiting backend functions.
112
+ *
113
+ * This mirrors the type in Kotlin. It is not the type the developer defines in their code, which is LimiterConfig.
114
+ */
115
+ export interface LimiterOptions {
116
+ /** Array of rate limit configurations, allowing different limits at different scopes. */
117
+ rateLimit?: RateLimitOptions[];
118
+ /** Array of quota limit configurations, allowing different limits at different scopes. */
119
+ quotaLimit?: QuotaLimitOptions[];
120
+ }
121
+ /** A configuration type for defining rate and quota limits in a flexible format. */
122
+ export type LimiterConfig = {
123
+ /** The rate limit, specified as a number, a single RateLimitOptions object, or an array of RateLimitOptions. */
124
+ rateLimit?: number | RateLimitOptions | Array<RateLimitOptions>;
125
+ /** The quota limit, specified as a number, a single QuotaLimitOptions object, or an array of QuotaLimitOptions. */
126
+ quotaLimit?: number | QuotaLimitOptions | Array<QuotaLimitOptions>;
127
+ };
128
+ /** A type defining a webhook function that processes incoming requests, with or without request context. */
129
+ export type WebhookAction = ((request: WebhookRequest) => any) | (() => any);
130
+ /** The context provided to a webhook function. */
131
+ export interface WebhookRequest<T = any> {
132
+ /** The parsed body of the webhook request. */
133
+ body: T;
134
+ /** The unparsed body of the webhook request as a string, if available. */
135
+ rawBody?: string;
136
+ /** A record of query parameters included in the webhook request. */
137
+ queryParams: Record<string, string>;
138
+ /** A record of HTTP headers included in the webhook request. */
139
+ headers: Record<string, string>;
140
+ /** The HTTP method used for the webhook request. */
141
+ httpMethod: 'post' | 'get' | 'put' | 'delete';
142
+ /** An array of files uploaded with the webhook request, if any. */
143
+ files?: Array<SquidFile>;
144
+ }
145
+ /** An interface representing the response structure returned by a webhook function. */
146
+ export interface WebhookResponse {
147
+ /** A record of HTTP headers to include in the webhook response. */
148
+ headers: Record<string, any>;
149
+ /** The body content of the webhook response. */
150
+ body: any;
151
+ /** The HTTP status code for the webhook response. */
152
+ statusCode: number;
153
+ /** A flag indicating this is a webhook response object. */
154
+ __isWebhookResponse__: true;
155
+ }
156
+ /** An interface representing a file in some Squid operations. */
157
+ export interface SquidFile {
158
+ /** The binary data of the file. */
159
+ data: Uint8Array;
160
+ /** The name of the form field containing the file. */
161
+ fieldName: string;
162
+ /** The MIME type of the uploaded file. */
163
+ mimetype: string;
164
+ /** The original filename as provided by the uploader. */
165
+ originalName: string;
166
+ /** The size of the file in bytes. */
167
+ size: number;
168
+ /** The encoding of the file, if specified. */
169
+ encoding?: string;
170
+ /** An indicator that this is a Squid file. */
171
+ __isSquidFile__: true;
172
+ }
173
+ /** Defines a function for asking an LLM model a prompt. */
174
+ export type LlmAskAction = (prompt: string, options: UserAiChatOptions) => Promise<UserAiAskResponse>;
175
+ /**
176
+ * Base type for all decorators used in backend projects.
177
+ */
178
+ export type ActionMethodDecorator<U> = <T extends U>(target: Object, propertyName: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
@@ -0,0 +1,46 @@
1
+ import { AiFileUrl } from '@squidcloud/client';
2
+ import { IntegrationType } from '@squidcloud/client';
3
+ /** The different types of actions that can be performed on a database. */
4
+ export type DatabaseActionType = 'read' | 'write' | 'update' | 'insert' | 'delete' | 'all';
5
+ /** The different types of actions that can be performed for storage. */
6
+ export type StorageActionType = 'read' | 'write' | 'update' | 'insert' | 'delete' | 'all';
7
+ /** The different types of actions that can be performed on a topic. */
8
+ export type TopicActionType = 'read' | 'write' | 'all';
9
+ /** The different type of actions for metrics. */
10
+ export type MetricActionType = 'write' | 'all';
11
+ /** Represents the possible data types for an AI function parameter. */
12
+ export type AiFunctionParamType = 'string' | 'number' | 'boolean' | 'date' | 'files';
13
+ /** Defines the structure of a parameter for an AI function. */
14
+ export interface AiFunctionParam {
15
+ /** Name of the parameter. */
16
+ name: string;
17
+ /** Description of the parameter's purpose. */
18
+ description: string;
19
+ /** Data type of the parameter. */
20
+ type: AiFunctionParamType;
21
+ /** Indicates if the parameter is mandatory. */
22
+ required: boolean;
23
+ /** List of possible values for the parameter, if applicable. */
24
+ enum?: Array<Omit<AiFunctionParamType, 'date'>>;
25
+ }
26
+ /** Represents an AI function response that also includes files. */
27
+ export interface AiFunctionResponseWithFiles {
28
+ /** Indicates that this is an AI function response with files. */
29
+ __isAiFunctionResponseWithFiles: true;
30
+ /** The response from the AI function. */
31
+ response: any;
32
+ /** Optional list of files associated with the response. */
33
+ files: Array<AiFileUrl>;
34
+ }
35
+ /** Additional optional readonly metadata for AI function. */
36
+ export interface AiFunctionAttributes {
37
+ /**
38
+ * Type of integration this function is used for.
39
+ * Functions with defined 'integrationType' require 'integrationId' to be passed as part of the function context.
40
+ */
41
+ integrationType?: Array<IntegrationType>;
42
+ }
43
+ /** ID of the tenant module: either user code (see USER_CODE_MODULE_ID) or a connector ID. */
44
+ export type TenantModuleId = string;
45
+ /** Type for the user code module loaded by worker/local-backend code. */
46
+ export declare const USER_CODE_MODULE_ID: TenantModuleId;
@@ -0,0 +1,4 @@
1
+ /** The context provided to a secure distributed lock function. */
2
+ export declare class DistributedLockContext {
3
+ readonly mutex: string;
4
+ }
@@ -0,0 +1,7 @@
1
+ /** The context provided to a secure GraphQL function. */
2
+ export declare class GraphqlContext {
3
+ readonly isGraphiQL: boolean;
4
+ readonly query: string | undefined;
5
+ readonly variables: string | Record<string, any> | undefined;
6
+ readonly operationName: string | undefined;
7
+ }
@@ -0,0 +1,10 @@
1
+ import { LlmModelMetadata, UserAiChatModelName } from '@squidcloud/client';
2
+ /**
3
+ * Options for the `@llmService` decorator.
4
+ */
5
+ export interface LlmServiceOptions {
6
+ /**
7
+ * Map of model names to their metadata.
8
+ */
9
+ models: Record<UserAiChatModelName, LlmModelMetadata>;
10
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Options for the `@mcpServer` decorator.
3
+ */
4
+ export interface McpServerOptions {
5
+ /** Unique ID for this MCP server that will also be used in the MCP url. */
6
+ id: string;
7
+ /**
8
+ * The MCP description.
9
+ */
10
+ description: string;
11
+ /** The MCP name - it will be exposed in the MCP manifest. */
12
+ name: string;
13
+ /**
14
+ * The version of the MCP server.
15
+ * This will be exposed in the MCP manifest.
16
+ */
17
+ version: string;
18
+ }
19
+ /**
20
+ * Represents a request to authorize an MCP request.
21
+ *
22
+ * @category MCP
23
+ */
24
+ export interface McpAuthorizationRequest {
25
+ /** The parsed body of the webhook request. */
26
+ body: any;
27
+ /** A record of query parameters included in the webhook request. */
28
+ queryParams: Record<string, string>;
29
+ /** A record of HTTP headers included in the webhook request. */
30
+ headers: Record<string, string>;
31
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * A context passed to functions annotated with the '@secureMetric' decorator.
3
+ * @category Platform
4
+ */
5
+ export interface SecureMetricContext {
6
+ /** Name of the metric to check. */
7
+ name: string;
8
+ /** Key-value pairs for tagging the metric. */
9
+ tags: Record<string, string>;
10
+ /** Numeric value of the metric. */
11
+ value: number;
12
+ }
@@ -0,0 +1,148 @@
1
+ import { SquidDocIdObj, SquidDocument } from '@squidcloud/client';
2
+ import { Paths } from '@squidcloud/client';
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
+ interface BaseMutation {
13
+ type: MutationType;
14
+ squidDocIdObj: SquidDocIdObj;
15
+ }
16
+ /**
17
+ * A mutation on a document.
18
+ * @category Database
19
+ */
20
+ export type Mutation<T = any> = UpdateMutation<T> | InsertMutation<T> | DeleteMutation;
21
+ /**
22
+ * Represents a delete mutation on a document.
23
+ * @category Database
24
+ */
25
+ export interface DeleteMutation extends BaseMutation {
26
+ /** Specifies that the mutation is a deletion. */
27
+ type: 'delete';
28
+ }
29
+ /**
30
+ * Represents an update mutation on a document.
31
+ * @category Database
32
+ */
33
+ export interface UpdateMutation<T = any> extends BaseMutation {
34
+ /** Specifies that the mutation is an update. */
35
+ type: 'update';
36
+ /** The updated properties */
37
+ properties: {
38
+ [key in keyof T & string]?: Array<PropertyMutation<T[key]>>;
39
+ };
40
+ }
41
+ /**
42
+ * Represents an insert mutation on a document.
43
+ * @category Database
44
+ */
45
+ export interface InsertMutation<T = any> extends BaseMutation {
46
+ /** Specifies that the mutation is an insertion. */
47
+ type: 'insert';
48
+ /** The inserted document */
49
+ properties: T;
50
+ }
51
+ /**
52
+ * A representation of a single property update.
53
+ * @category Database
54
+ */
55
+ export type PropertyMutation<Value = any> = ApplyNumericFnPropertyMutation | ApplyStringFnPropertyMutation | ValueUpdatePropertyMutation<Value> | RemovePropertyMutation;
56
+ /**
57
+ * A value update property mutation.
58
+ * @category Database
59
+ */
60
+ export interface ValueUpdatePropertyMutation<Value = any> {
61
+ /** Specifies that the mutation updates a value. */
62
+ type: 'update';
63
+ /** New value to be set. */
64
+ value: Value;
65
+ }
66
+ /**
67
+ * Applying a numeric function to a property.
68
+ * @category Database
69
+ */
70
+ export interface ApplyNumericFnPropertyMutation {
71
+ /** Specifies that the mutation applies a numeric function. */
72
+ type: 'applyNumericFn';
73
+ /** Numeric function to apply. */
74
+ fn: 'increment';
75
+ /** Value to use in the numeric function. */
76
+ value: number;
77
+ }
78
+ /**
79
+ * A property update that removes a property from a document.
80
+ * @category Database
81
+ */
82
+ export interface RemovePropertyMutation {
83
+ /** Specifies that the mutation removes a property. */
84
+ type: 'removeProperty';
85
+ }
86
+ interface ApplyExtendString {
87
+ /** Specifies that the mutation applies a string function. */
88
+ type: 'applyStringFn';
89
+ /** String function to extend the existing string. */
90
+ fn: 'extendString';
91
+ /** String value to append. */
92
+ value: string;
93
+ }
94
+ interface ApplyTrimString {
95
+ /** Specifies that the mutation applies a string function. */
96
+ type: 'applyStringFn';
97
+ /** String function to trim the existing string. */
98
+ fn: 'trim';
99
+ }
100
+ /**
101
+ * A property mutation that modifies a string.
102
+ * @category Database
103
+ */
104
+ export type ApplyStringFnPropertyMutation = ApplyExtendString | ApplyTrimString;
105
+ /**
106
+ * The before and after documents of a document change.
107
+ * @category Database
108
+ */
109
+ export interface BeforeAndAfterDocs<T = SquidDocument> {
110
+ /** Document state before the mutation. */
111
+ before: T | undefined;
112
+ /** Document state after the mutation. */
113
+ after: T | undefined;
114
+ }
115
+ /**
116
+ * The mutation context that will be provided to the security function.
117
+ * @category Database
118
+ */
119
+ export declare class MutationContext<T = any> {
120
+ readonly mutation: Mutation<T>;
121
+ readonly beforeAndAfterDocs: BeforeAndAfterDocs<T>;
122
+ readonly serverTimeStamp: Date;
123
+ /**
124
+ * Returns the state of the document before the mutation was applied.
125
+ */
126
+ get before(): T | undefined;
127
+ /**
128
+ * Returns the state of the document after the mutation was applied.
129
+ */
130
+ get after(): T | undefined;
131
+ /**
132
+ * Returns the type of the mutation (insert, update, or delete).
133
+ */
134
+ getMutationType(): MutationType;
135
+ /** Returns true if the mutation affects the provided path. */
136
+ affectsPath(path: Paths<T>): boolean;
137
+ /**
138
+ * Find all affected paths starting from a root path.
139
+ *
140
+ * @example
141
+ * doc before - { a: { b: 1, c: 2 }, d: 3 }
142
+ * doc after - { a: { b: 1, c: 3 }, d: 4 }
143
+ * doc.affectedPaths('a') // ['a.c']
144
+ */
145
+ affectedPaths(startingRoot?: Paths<T> | string): Array<Paths<T>>;
146
+ private checkPath;
147
+ }
148
+ export {};