@squidcloud/backend 1.0.147 → 1.0.149

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.
@@ -1,193 +1,166 @@
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 { ActionMethodDecorator, AiChatbotActionType, AiFunctionAction, AiFunctionParam, ApiEndpointId, ClientConnectionStateChangeAction, CollectionName, CronExpression, CronExpressionString, DatabaseActionType, ExecutableAction, IntegrationId, SchedulerAction, SchedulerId, SecureAiChatbotAction, SecureApiAction, SecureDatabaseAction, SecureDistributedLockAction, SecureGraphQLAction, 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 used to secure a native query. Native queries are not secured by default and must be
125
+ * explicitly secured using this decorator. The decorated function must return a boolean or a `Promise` of a boolean
126
+ * that indicates whether the query can be executed or not.
127
+ *
128
+ * The function accepts a context object as a parameter. The context object contains information about the query.
129
+ *
130
+ * To read more about securing a Native Query, see the
131
+ * {@link https://docs.squid.cloud/docs/development-tools/backend/security-rules/secure-data-access#securenativequery documentation}.
132
+ *
133
+ * @param integrationId The database integration ID.
134
+ * @returns A decorator function that can be used to secure a native query.
135
+ */
136
+ export declare function secureNativeQuery(integrationId: IntegrationId): ActionMethodDecorator<SecureNativeQueryAction>;
137
+ /**
138
+ * A decorator that can be used to secure a distributed lock. Distributed locks are secured by default and can be
139
+ * invoked only if the decorated function allows it. The function returns a boolean or a `Promise` of a boolean that
140
+ * indicates whether the lock can be acquired or not.
141
+ *
142
+ * The function accepts a context object as a parameter. The context object contains information about the mutex and
143
+ * the request.
144
+ *
145
+ * @param mutex The mutex to lock on. If none provided, the rule will apply for all mutexes.
146
+ */
147
+ export declare function secureDistributedLock(mutex?: string): ActionMethodDecorator<SecureDistributedLockAction>;
148
+ /**
149
+ * A decorator that can be used to secure an AI chatbot. The decorator takes the AI Chatbot
150
+ * integration ID, the action type (`chat` or `mutate`), and an optional profile ID. If no profile ID
151
+ * is provided, the function will secure all requests to the integration (for the given action type).
152
+ *
153
+ * The function should return a boolean or a `Promise` of a boolean indicating
154
+ * whether the action is allowed.
155
+ * The function takes a context object as a parameter. The context object contains information about the action.
156
+ *
157
+ * To read more about named queries, see the
158
+ * {@link https://docs.squid.cloud/docs/development-tools/backend/security-rules/secure-ai-chatbot documentation}.
159
+ *
160
+ @param integrationId The ID of the integration to secure.
161
+ @param type The type af action to secure.
162
+ @param profileId The ID of the profile to secure.
163
+ */
164
+ export declare function secureAiChatbot<T extends AiChatbotActionType>(integrationId: IntegrationId, type: T, profileId?: string): ActionMethodDecorator<SecureAiChatbotAction<T>>;
165
+ /** Decorator that marks a function for handling a client connection state change */
166
+ export declare function clientConnectionStateHandler(): ActionMethodDecorator<ClientConnectionStateChangeAction>;
@@ -1,3 +1,3 @@
1
- export * from './actions';
2
- export * from './project';
3
- export * from './service';
1
+ export * from './actions';
2
+ export * from './project';
3
+ export * from './service';