@squidcloud/backend 1.0.72 → 1.0.74

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,145 +1,144 @@
1
- import { ActionMethodDecorator, AiAssistantActionType, ApiEndpointId, CollectionName, CronExpression, CronExpressionString, DatabaseActionType, ExecutableAction, IntegrationId, QueryName, SchedulerAction, SchedulerId, SecureAiAssistantAction, SecureApiAction, SecureDatabaseAction, SecureDistributedLockAction, SecureGraphQLAction, SecureNamedQueryAction, TransformDatabaseAction, 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
- * [documentation]{@link https://docs.squid.cloud/docs/backend/security-rules/secure-data-access#securedatabase}.
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
- * [documentation]{@link https://docs.squid.cloud/docs/backend/security-rules/secure-data-access#securecollection}.
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
- * [documentation]{@link https://docs.squid.cloud/docs/backend/security-rules/secure-api}.
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<T extends SecureApiAction>(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
- * [documentation]{@link https://docs.squid.cloud/docs/backend/security-rules/secure-graphql}.
59
- * @param integrationId
60
- */
61
- export declare function secureGraphQL<T extends SecureGraphQLAction>(integrationId: IntegrationId): ActionMethodDecorator<SecureGraphQLAction>;
62
- export declare function transformCollection<T extends DatabaseActionType>(collectionName: CollectionName, type: T, integrationId?: IntegrationId): ActionMethodDecorator<TransformDatabaseAction<T>>;
63
- /**
64
- * Decorator that marks a function for exposing it as an executable.
65
- * The function can accept any parameter that can be serialized to JSON and return any parameter that can be serialzied
66
- * to JSON.
67
- *
68
- * Once the function is exposed, it can be called from the Squid Cloud SDK using the `executeFunction` method.
69
- * To read more about exposing an executable, see the
70
- * [documentation]{@link https://docs.squid.cloud/docs/backend/executables}.
71
- */
72
- export declare function executable(): ActionMethodDecorator<ExecutableAction>;
73
- /**
74
- * Decorator that marks a function as a trigger to a change in a collection. The function will be called each time a
75
- * change is made to the collection.
76
- * The function accepts a context object as a parameter. The context object contains information about the change.
77
- *
78
- * To read more about triggers, see the [documentation]{@link https://docs.squid.cloud/docs/backend/triggers}.
79
- *
80
- * @param id The id of the trigger. Should be unique.
81
- * @param collectionName The name of the collection to trigger on.
82
- * @param integrationId The id of the integration to trigger on. If not provided, the `built_in_db` integration is used.
83
- */
84
- export declare function trigger(id: TriggerId, collectionName: CollectionName, integrationId?: IntegrationId): ActionMethodDecorator<TriggerAction>;
85
- /**
86
- * Decorator that marks a function as a scheduler. The function will be called according to the provided cron
87
- * expression.
88
- *
89
- * To read more about schedulers, see the [documentation]{@link https://docs.squid.cloud/docs/backend/schedulers}.
90
- *
91
- * @param id The id of the scheduler. Should be unique.
92
- * @param cronExpression The cron expression to schedule the function on.
93
- * @param exclusive Whether the scheduler should be exclusive. If set to true, the scheduler will not trigger if the
94
- * previous scheduler is still running.
95
- */
96
- export declare function scheduler(id: SchedulerId, cronExpression: CronExpression | CronExpressionString, exclusive?: boolean): ActionMethodDecorator<SchedulerAction>;
97
- /**
98
- * Decorator that marks a function as a webhook. The function will be called when a webhook is triggered.
99
- * Once the webhook is created, it will be exposed as a URL with the provided webhook id with this format:
100
- * `https://<your app Id>.<app region>.squid.cloud/webhooks/<webhook-id>`.
101
- *
102
- * The function accepts a context object as a parameter. The context object contains information about the webhook.
103
- * The function can return any value that can be serialized to JSON or a `WebhookResponse` object that can be created
104
- * using:
105
- * `this.createWebhookResponse(<params>)`.
106
- *
107
- * To read more about webhooks, see the [documentation]{@link https://docs.squid.cloud/docs/backend/webhooks}.
108
- * @param id The id of the webhook. Should be unique.
109
- */
110
- export declare function webhook(id: WebhookId): ActionMethodDecorator<WebhookAction>;
111
- /**
112
- * A decorator that can be applied on a static string property of a class to mark it as a named query.
113
- * The string can be any valid SQL in the given integration and can accept named parameters
114
- *
115
- * A named query can be invoked from the SDK using the `executeNamedQuery` method.
116
- *
117
- * To read more about named queries, see the [documentation]{@link https://docs.squid.cloud/docs/backend/named-queries}.
118
- *
119
- * @param integrationId The database integration id (Note that the `built_in_db` does not support named queries)
120
- * @param name The name of the query that will be used to call it from the SDK.
121
- */
122
- export declare function namedQuery(integrationId: string, name: string): any;
123
- /**
124
- * A decorator that can be used to secure a named query. Named queries are secured by default and can be invoked only
125
- * if the decorated function allows it.
126
- * The function returns a boolean or a `Promise` of a boolean 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
- * @param integrationId The database integration id.
131
- * @param queryName The name of the query.
132
- */
133
- export declare function secureNamedQuery<T extends SecureNamedQueryAction>(integrationId: IntegrationId, queryName: QueryName): ActionMethodDecorator<SecureNamedQueryAction>;
134
- /**
135
- * A decorator that can be used to secure a distributed lock. Distributed locks are secured by default and can be
136
- * invoked only if the decorated function allows it. The function returns a boolean or a `Promise` of a boolean that
137
- * indicates whether the lock can be acquired or not.
138
- *
139
- * The function accepts a context object as a parameter. The context object contains information about the mutex and
140
- * the request.
141
- *
142
- * @param mutex The mutex to lock on. If none provided, the rule will apply for all mutexes.
143
- */
144
- export declare function secureDistributedLock<T extends SecureDistributedLockAction>(mutex?: string): ActionMethodDecorator<SecureDistributedLockAction>;
145
- export declare function secureAiAssistant<T extends AiAssistantActionType>(integrationId: IntegrationId, type: T, profileId?: string): ActionMethodDecorator<SecureAiAssistantAction<T>>;
1
+ import { ActionMethodDecorator, AiAssistantActionType, ApiEndpointId, CollectionName, CronExpression, CronExpressionString, DatabaseActionType, ExecutableAction, IntegrationId, QueryName, SchedulerAction, SchedulerId, SecureAiAssistantAction, SecureApiAction, SecureDatabaseAction, SecureDistributedLockAction, SecureGraphQLAction, SecureNamedQueryAction, 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
+ * [documentation]{@link https://docs.squid.cloud/docs/backend/security-rules/secure-data-access#securedatabase}.
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
+ * [documentation]{@link https://docs.squid.cloud/docs/backend/security-rules/secure-data-access#securecollection}.
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
+ * [documentation]{@link https://docs.squid.cloud/docs/backend/security-rules/secure-api}.
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<T extends SecureApiAction>(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
+ * [documentation]{@link https://docs.squid.cloud/docs/backend/security-rules/secure-graphql}.
59
+ * @param integrationId
60
+ */
61
+ export declare function secureGraphQL<T extends SecureGraphQLAction>(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
+ * [documentation]{@link https://docs.squid.cloud/docs/backend/executables}.
70
+ */
71
+ export declare function executable(): ActionMethodDecorator<ExecutableAction>;
72
+ /**
73
+ * Decorator that marks a function as a trigger to a change in a collection. The function will be called each time a
74
+ * change is made to the collection.
75
+ * The function accepts a context object as a parameter. The context object contains information about the change.
76
+ *
77
+ * To read more about triggers, see the [documentation]{@link https://docs.squid.cloud/docs/backend/triggers}.
78
+ *
79
+ * @param id The id of the trigger. Should be unique.
80
+ * @param collectionName The name of the collection to trigger on.
81
+ * @param integrationId The id of the integration to trigger on. If not provided, the `built_in_db` integration is used.
82
+ */
83
+ export declare function trigger(id: TriggerId, collectionName: CollectionName, integrationId?: IntegrationId): ActionMethodDecorator<TriggerAction>;
84
+ /**
85
+ * Decorator that marks a function as a scheduler. The function will be called according to the provided cron
86
+ * expression.
87
+ *
88
+ * To read more about schedulers, see the [documentation]{@link https://docs.squid.cloud/docs/backend/schedulers}.
89
+ *
90
+ * @param id The id of the scheduler. Should be unique.
91
+ * @param cronExpression The cron expression to schedule the function on.
92
+ * @param exclusive Whether the scheduler should be exclusive. If set to true, the scheduler will not trigger if the
93
+ * previous scheduler is still running.
94
+ */
95
+ export declare function scheduler(id: SchedulerId, cronExpression: CronExpression | CronExpressionString, exclusive?: boolean): ActionMethodDecorator<SchedulerAction>;
96
+ /**
97
+ * Decorator that marks a function as a webhook. The function will be called when a webhook is triggered.
98
+ * Once the webhook is created, it will be exposed as a URL with the provided webhook id with this format:
99
+ * `https://<your app Id>.<app region>.squid.cloud/webhooks/<webhook-id>`.
100
+ *
101
+ * The function accepts a context object as a parameter. The context object contains information about the webhook.
102
+ * The function can return any value that can be serialized to JSON or a `WebhookResponse` object that can be created
103
+ * using:
104
+ * `this.createWebhookResponse(<params>)`.
105
+ *
106
+ * To read more about webhooks, see the [documentation]{@link https://docs.squid.cloud/docs/backend/webhooks}.
107
+ * @param id The id of the webhook. Should be unique.
108
+ */
109
+ export declare function webhook(id: WebhookId): ActionMethodDecorator<WebhookAction>;
110
+ /**
111
+ * A decorator that can be applied on a static string property of a class to mark it as a named query.
112
+ * The string can be any valid SQL in the given integration and can accept named parameters
113
+ *
114
+ * A named query can be invoked from the SDK using the `executeNamedQuery` method.
115
+ *
116
+ * To read more about named queries, see the [documentation]{@link https://docs.squid.cloud/docs/backend/named-queries}.
117
+ *
118
+ * @param integrationId The database integration id (Note that the `built_in_db` does not support named queries)
119
+ * @param name The name of the query that will be used to call it from the SDK.
120
+ */
121
+ export declare function namedQuery(integrationId: string, name: string): any;
122
+ /**
123
+ * A decorator that can be used to secure a named query. Named queries are secured by default and can be invoked only
124
+ * if the decorated function allows it.
125
+ * The function returns a boolean or a `Promise` of a boolean that indicates whether the query can be executed or not.
126
+ *
127
+ * The function accepts a context object as a parameter. The context object contains information about the query.
128
+ *
129
+ * @param integrationId The database integration id.
130
+ * @param queryName The name of the query.
131
+ */
132
+ export declare function secureNamedQuery<T extends SecureNamedQueryAction>(integrationId: IntegrationId, queryName: QueryName): ActionMethodDecorator<SecureNamedQueryAction>;
133
+ /**
134
+ * A decorator that can be used to secure a distributed lock. Distributed locks are secured by default and can be
135
+ * invoked only if the decorated function allows it. The function returns a boolean or a `Promise` of a boolean that
136
+ * indicates whether the lock can be acquired or not.
137
+ *
138
+ * The function accepts a context object as a parameter. The context object contains information about the mutex and
139
+ * the request.
140
+ *
141
+ * @param mutex The mutex to lock on. If none provided, the rule will apply for all mutexes.
142
+ */
143
+ export declare function secureDistributedLock<T extends SecureDistributedLockAction>(mutex?: string): ActionMethodDecorator<SecureDistributedLockAction>;
144
+ export declare function secureAiAssistant<T extends AiAssistantActionType>(integrationId: IntegrationId, type: T, profileId?: string): ActionMethodDecorator<SecureAiAssistantAction<T>>;
@@ -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';