@squidcloud/backend 1.0.111 → 1.0.112

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,170 +1,170 @@
1
- import { ActionMethodDecorator, AiAssistantActionType, ApiEndpointId, ClientConnectionStateChangeAction, 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
- * {@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 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
78
- * {@link https://docs.squid.cloud/docs/development-tools/backend/triggers documentation}.
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
83
- * used.
84
- */
85
- export declare function trigger(id: TriggerId, collectionName: CollectionName, integrationId?: IntegrationId): ActionMethodDecorator<TriggerAction>;
86
- /**
87
- * Decorator that marks a function as a scheduler. The function will be called according to the provided cron
88
- * expression.
89
- *
90
- * To read more about schedulers, see the
91
- * {@link https://docs.squid.cloud/docs/development-tools/backend/schedulers documentation}.
92
- *
93
- * @param ID The ID of the scheduler. Should be unique.
94
- * @param cronExpression The cron expression to schedule the function on.
95
- * @param exclusive Whether the scheduler should be exclusive. If set to true, the scheduler will not trigger if the
96
- * previous scheduler is still running.
97
- */
98
- export declare function scheduler(id: SchedulerId, cronExpression: CronExpression | CronExpressionString, exclusive?: boolean): ActionMethodDecorator<SchedulerAction>;
99
- /**
100
- * Decorator that marks a function as a webhook. The function will be called when a webhook is triggered.
101
- * Once the webhook is created, it will be exposed as a URL with the provided webhook ID with this format:
102
- * `https://<your app Id>.<app region>.squid.cloud/webhooks/<webhook-id>`.
103
- *
104
- * The function accepts a context object as a parameter. The context object contains information about the webhook.
105
- * The function can return any value that can be serialized to JSON or a `WebhookResponse` object that can be created
106
- * using:
107
- * `this.createWebhookResponse(<params>)`.
108
- *
109
- * To read more about webhooks, see the
110
- * {@link https://docs.squid.cloud/docs/development-tools/backend/webhooks documentation}.
111
- * @param ID The ID of the webhook. Should be unique.
112
- */
113
- export declare function webhook(id: WebhookId): ActionMethodDecorator<WebhookAction>;
114
- /**
115
- * A decorator that can be applied on a static string property of a class to mark it as a named query.
116
- * The string can be any valid SQL in the given integration and can accept named parameters
117
- *
118
- * A named query can be invoked from the SDK using the `executeNamedQuery` method.
119
- *
120
- * To read more about named queries, see the
121
- * {@link https://docs.squid.cloud/docs/development-tools/backend/named-queries documentation}.
122
- *
123
- * @param integrationId The database integration ID (Note that the `built_in_db` does not support named queries)
124
- * @param name The name of the query that will be used to call it from the SDK.
125
- */
126
- export declare function namedQuery(integrationId: string, name: string): any;
127
- /**
128
- * A decorator that can be used to secure a named query. Named queries are secured by default and can be invoked only
129
- * if the decorated function allows it.
130
- * The function returns a boolean or a `Promise` of a boolean that indicates whether the query can be executed or not.
131
- *
132
- * The function accepts a context object as a parameter. The context object contains information about the query.
133
- *
134
- * To read more about securing a GraphQL integration, see the
135
- * {@link https://docs.squid.cloud/docs/development-tools/backend/security-rules/secure-data-access#securenamedquery documentation}.
136
- *
137
- * @param integrationId The database integration ID.
138
- * @param queryName The name of the query.
139
- */
140
- export declare function secureNamedQuery(integrationId: IntegrationId, queryName: QueryName): ActionMethodDecorator<SecureNamedQueryAction>;
141
- /**
142
- * A decorator that can be used to secure a distributed lock. Distributed locks are secured by default and can be
143
- * invoked only if the decorated function allows it. The function returns a boolean or a `Promise` of a boolean that
144
- * indicates whether the lock can be acquired or not.
145
- *
146
- * The function accepts a context object as a parameter. The context object contains information about the mutex and
147
- * the request.
148
- *
149
- * @param mutex The mutex to lock on. If none provided, the rule will apply for all mutexes.
150
- */
151
- export declare function secureDistributedLock(mutex?: string): ActionMethodDecorator<SecureDistributedLockAction>;
152
- /**
153
- * A decorator that can be used to secure an AI Assistant. The decorator takes the AI Assistant
154
- * integration ID, the action type (`chat` or `mutate`), and an optional profile ID. If no profile ID
155
- * is provided, the function will secure all requests to the integration (for the given action type).
156
- *
157
- * The function should return a boolean or a `Promise` of a boolean indicating
158
- * whether the action is allowed.
159
- * The function takes a context object as a parameter. The context object contains information about the action.
160
- *
161
- * To read more about named queries, see the
162
- * {@link https://docs.squid.cloud/docs/development-tools/backend/security-rules/secure-ai-assistant documentation}.
163
- *
164
- @param integrationId The ID of the integration to secure.
165
- @param type The type af action to secure.
166
- @param profileId The ID of the profile to secure.
167
- */
168
- export declare function secureAiAssistant<T extends AiAssistantActionType>(integrationId: IntegrationId, type: T, profileId?: string): ActionMethodDecorator<SecureAiAssistantAction<T>>;
169
- /** Decorator that marks a function for handling a client connection state change */
170
- export declare function clientConnectionStateHandler(): ActionMethodDecorator<ClientConnectionStateChangeAction>;
1
+ import { ActionMethodDecorator, AiAssistantActionType, ApiEndpointId, ClientConnectionStateChangeAction, 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
+ * {@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 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
78
+ * {@link https://docs.squid.cloud/docs/development-tools/backend/triggers documentation}.
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
83
+ * used.
84
+ */
85
+ export declare function trigger(id: TriggerId, collectionName: CollectionName, integrationId?: IntegrationId): ActionMethodDecorator<TriggerAction>;
86
+ /**
87
+ * Decorator that marks a function as a scheduler. The function will be called according to the provided cron
88
+ * expression.
89
+ *
90
+ * To read more about schedulers, see the
91
+ * {@link https://docs.squid.cloud/docs/development-tools/backend/schedulers documentation}.
92
+ *
93
+ * @param ID The ID of the scheduler. Should be unique.
94
+ * @param cronExpression The cron expression to schedule the function on.
95
+ * @param exclusive Whether the scheduler should be exclusive. If set to true, the scheduler will not trigger if the
96
+ * previous scheduler is still running.
97
+ */
98
+ export declare function scheduler(id: SchedulerId, cronExpression: CronExpression | CronExpressionString, exclusive?: boolean): ActionMethodDecorator<SchedulerAction>;
99
+ /**
100
+ * Decorator that marks a function as a webhook. The function will be called when a webhook is triggered.
101
+ * Once the webhook is created, it will be exposed as a URL with the provided webhook ID with this format:
102
+ * `https://<your app Id>.<app region>.squid.cloud/webhooks/<webhook-id>`.
103
+ *
104
+ * The function accepts a context object as a parameter. The context object contains information about the webhook.
105
+ * The function can return any value that can be serialized to JSON or a `WebhookResponse` object that can be created
106
+ * using:
107
+ * `this.createWebhookResponse(<params>)`.
108
+ *
109
+ * To read more about webhooks, see the
110
+ * {@link https://docs.squid.cloud/docs/development-tools/backend/webhooks documentation}.
111
+ * @param ID The ID of the webhook. Should be unique.
112
+ */
113
+ export declare function webhook(id: WebhookId): ActionMethodDecorator<WebhookAction>;
114
+ /**
115
+ * A decorator that can be applied on a static string property of a class to mark it as a named query.
116
+ * The string can be any valid SQL in the given integration and can accept named parameters
117
+ *
118
+ * A named query can be invoked from the SDK using the `executeNamedQuery` method.
119
+ *
120
+ * To read more about named queries, see the
121
+ * {@link https://docs.squid.cloud/docs/development-tools/backend/named-queries documentation}.
122
+ *
123
+ * @param integrationId The database integration ID (Note that the `built_in_db` does not support named queries)
124
+ * @param name The name of the query that will be used to call it from the SDK.
125
+ */
126
+ export declare function namedQuery(integrationId: string, name: string): any;
127
+ /**
128
+ * A decorator that can be used to secure a named query. Named queries are secured by default and can be invoked only
129
+ * if the decorated function allows it.
130
+ * The function returns a boolean or a `Promise` of a boolean that indicates whether the query can be executed or not.
131
+ *
132
+ * The function accepts a context object as a parameter. The context object contains information about the query.
133
+ *
134
+ * To read more about securing a GraphQL integration, see the
135
+ * {@link https://docs.squid.cloud/docs/development-tools/backend/security-rules/secure-data-access#securenamedquery documentation}.
136
+ *
137
+ * @param integrationId The database integration ID.
138
+ * @param queryName The name of the query.
139
+ */
140
+ export declare function secureNamedQuery(integrationId: IntegrationId, queryName: QueryName): ActionMethodDecorator<SecureNamedQueryAction>;
141
+ /**
142
+ * A decorator that can be used to secure a distributed lock. Distributed locks are secured by default and can be
143
+ * invoked only if the decorated function allows it. The function returns a boolean or a `Promise` of a boolean that
144
+ * indicates whether the lock can be acquired or not.
145
+ *
146
+ * The function accepts a context object as a parameter. The context object contains information about the mutex and
147
+ * the request.
148
+ *
149
+ * @param mutex The mutex to lock on. If none provided, the rule will apply for all mutexes.
150
+ */
151
+ export declare function secureDistributedLock(mutex?: string): ActionMethodDecorator<SecureDistributedLockAction>;
152
+ /**
153
+ * A decorator that can be used to secure an AI Assistant. The decorator takes the AI Assistant
154
+ * integration ID, the action type (`chat` or `mutate`), and an optional profile ID. If no profile ID
155
+ * is provided, the function will secure all requests to the integration (for the given action type).
156
+ *
157
+ * The function should return a boolean or a `Promise` of a boolean indicating
158
+ * whether the action is allowed.
159
+ * The function takes a context object as a parameter. The context object contains information about the action.
160
+ *
161
+ * To read more about named queries, see the
162
+ * {@link https://docs.squid.cloud/docs/development-tools/backend/security-rules/secure-ai-assistant documentation}.
163
+ *
164
+ @param integrationId The ID of the integration to secure.
165
+ @param type The type af action to secure.
166
+ @param profileId The ID of the profile to secure.
167
+ */
168
+ export declare function secureAiAssistant<T extends AiAssistantActionType>(integrationId: IntegrationId, type: T, profileId?: string): ActionMethodDecorator<SecureAiAssistantAction<T>>;
169
+ /** Decorator that marks a function for handling a client connection state change */
170
+ 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';
@@ -1,256 +1,256 @@
1
- import { AiAssistantActionType, ApiEndpointId, ApplicationBundleData, CollectionName, DatabaseActionType, IntegrationId, QueryName, SchedulerId, ServiceFunctionName, TriggerId, WebhookId } from '@squidcloud/common';
2
- declare class Meta {
3
- data: ApplicationBundleData;
4
- /**
5
- * @secureDatabase("read", "ExampleIntegration")
6
- *
7
- * Applying the decorator above to the myMethod method on the MyService
8
- * class will generate the following metadata:
9
- *
10
- * data: {
11
- * databases: {
12
- * ExampleIntegration: {
13
- * security: {
14
- * read: ['MyService:myMethod']
15
- * }
16
- * }
17
- * }
18
- * }
19
- */
20
- secureDatabase(type: DatabaseActionType, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
21
- /**
22
- * @secureCollection("ExampleCollection", "read", "ExampleIntegration")
23
- *
24
- * Applying the decorator above to the myMethod method on the MyService
25
- * class will generate the following metadata:
26
- *
27
- * data: {
28
- * databases: {
29
- * ExampleIntegration: {
30
- * collections: {
31
- * ExampleCollection: {
32
- * security: {
33
- * read: ['MyService:myMethod']
34
- * }
35
- * }
36
- * }
37
- * }
38
- * }
39
- * }
40
- */
41
- secureCollection(collectionName: CollectionName, type: DatabaseActionType, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
42
- /**
43
- * @secureApi("ExampleIntegration", "myEndpoint")
44
- *
45
- * Applying the decorator above to the myMethod method on the MyService
46
- * class will generate the following metadata:
47
- *
48
- * data: {
49
- * apis: {
50
- * ExampleIntegration: {
51
- * myEndpoint: {
52
- * security: ['MyService:myMethod']
53
- * }
54
- * }
55
- * }
56
- * }
57
- */
58
- secureApi(integrationId: IntegrationId, endpointId: ApiEndpointId | undefined, serviceFunction: ServiceFunctionName): void;
59
- /**
60
- * @secureGraphQL("ExampleIntegration")
61
- *
62
- * Applying the decorator above to the myMethod method on the MyService
63
- * class will generate the following metadata:
64
- *
65
- * data: {
66
- * graphql: {
67
- * ExampleIntegration: {
68
- * security: ['MyService:myMethod']
69
- * }
70
- * }
71
- * }
72
- */
73
- secureGraphQL(integrationId: IntegrationId, serviceFunction: ServiceFunctionName): void;
74
- /**
75
- * @transformDatabase(""read", "ExampleIntegration")
76
- *
77
- * Applying the decorator above to the myMethod method on the MyService
78
- * class will generate the following metadata:
79
- *
80
- * data: {
81
- * databases: {
82
- * ExampleIntegration: {
83
- * transform: {
84
- * read: {
85
- * type: "read"
86
- * functionName: "MyService:myMethod"
87
- * }
88
- * }
89
- * }
90
- * }
91
- * }
92
- */
93
- transformDatabase(type: DatabaseActionType, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
94
- /**
95
- * @transformCollection("ExampleCollection", "read", "ExampleIntegration")
96
- *
97
- * Applying the decorator above to the myMethod method on the MyService
98
- * class will generate the following metadata:
99
- *
100
- * data: {
101
- * databases: {
102
- * ExampleIntegration: {
103
- * collections: {
104
- * ExampleCollection: {
105
- * transform: {
106
- * read: {
107
- * type: "read"
108
- * functionName: "MyService:myMethod"
109
- * }
110
- * }
111
- * }
112
- * }
113
- * }
114
- * }
115
- * }
116
- */
117
- transformCollection(collectionName: CollectionName, type: DatabaseActionType, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
118
- /**
119
- * @executable()
120
- *
121
- * Applying the decorator above to the myMethod method on the MyService
122
- * class will generate the following metadata:
123
- *
124
- * data: {
125
- * executables: {
126
- * myExecutable: {
127
- * serviceName: "MyService:myMethod",
128
- * }
129
- * }
130
- * }
131
- */
132
- executable(serviceFunction: ServiceFunctionName): void;
133
- /**
134
- * @trigger("my-trigger", "ExampleCollection", "ExampleIntegration")
135
- *
136
- * Applying the decorator above to the myMethod method on the MyService
137
- * class will generate the following metadata:
138
- *
139
- * data: {
140
- * triggers: {
141
- * "my-trigger": {
142
- * integrationId: "ExampleIntegration"
143
- * collectionName: "ExampleCollection"
144
- * functionName: "MyService:myMethod",
145
- * }
146
- * }
147
- * }
148
- */
149
- trigger(id: TriggerId, collectionName: CollectionName, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
150
- /**
151
- * @scheduler("my-scheduler", "CronExpression", true)
152
- *
153
- * Applying the decorator above to the myMethod method on the MyService
154
- * class will generate the following metadata:
155
- *
156
- * data: {
157
- * schedulers: {
158
- * "my-scheduler", {
159
- * cronExpression: "CronExpression"
160
- * functionName: "MyService:myMethod",
161
- * }
162
- * }
163
- * }
164
- */
165
- scheduler(id: SchedulerId, cronExpression: string, serviceFunction: ServiceFunctionName, exclusive: boolean): void;
166
- /**
167
- * @webhook("my-webhook")
168
- *
169
- * Applying the decorator above to the myMethod method on the MyService
170
- * class will generate the following metadata:
171
- *
172
- * data: {
173
- * webhooks: {
174
- * "my-webhook", {
175
- * functionName: "MyService:myMethod",
176
- * }
177
- * }
178
- * }
179
- */
180
- webhook(id: WebhookId, serviceFunction: ServiceFunctionName): void;
181
- /**
182
- * @namedQuery('exampleIntegration', 'my-query')
183
- * static myQuery = "select * from my-table where id = ${id}";
184
- *
185
- * Applying the decorator above to the myQuery static string in MyService
186
- * class will generate the following metadata:
187
- *
188
- *
189
- *
190
- * data: {
191
- * namedQueries: {
192
- * "exampleIntegration", {
193
- * my-query: {
194
- * queryString: "select * from my-table where id = $id"
195
- * }
196
- * }
197
- * }
198
- * }
199
- */
200
- namedQuery(integrationId: IntegrationId, name: QueryName, queryString: string): void;
201
- /**
202
- * @secureNamedQuery("exampleIntegration", "queryName")
203
- *
204
- * Applying the decorator above to the myMethod method on the MyService
205
- * class will generate the following metadata:
206
- *
207
- * data: {
208
- * namedQueries: {
209
- * exampleIntegration: {
210
- * queryName: {
211
- * security: MyService:myMethod
212
- * }
213
- * }
214
- * }
215
- * }
216
- */
217
- secureNamedQuery(integrationId: IntegrationId, name: QueryName, serviceFunction: ServiceFunctionName): void;
218
- /**
219
- * @secureDistributedLock("mutex", true)
220
- *
221
- * Applying the decorator above to the myMethod method on the MyService
222
- * class will generate the following metadata:
223
- *
224
- * data: {
225
- * distributedLocks: {
226
- * security: [MyService:myMethod]
227
- * }
228
- * }
229
- */
230
- secureDistributedLock(mutex: string | undefined, serviceFunction: ServiceFunctionName): void;
231
- /**
232
- * @secureAiAssistant(ExampleIntegration, "chat", myProfile)
233
- *
234
- * Applying the decorator above to the myMethod method on the MyService
235
- * class will generate the following metadata:
236
- *
237
- * data: {
238
- * aiAssistants: {
239
- * ExampleIntegration: {
240
- * myProfile: {
241
- * security: {
242
- * chat: ['MyService:myMethod']
243
- * }
244
- * }
245
- * }
246
- * }
247
- * }
248
- */
249
- secureAiAssistant(type: AiAssistantActionType, integrationId: IntegrationId, profileId: string | undefined, serviceFunction: ServiceFunctionName): void;
250
- clientConnectionChangeHandler(serviceFunction: ServiceFunctionName): void;
251
- }
252
- /**
253
- * @internal
254
- */
255
- export declare const metadata: Meta;
256
- export {};
1
+ import { AiAssistantActionType, ApiEndpointId, ApplicationBundleData, CollectionName, DatabaseActionType, IntegrationId, QueryName, SchedulerId, ServiceFunctionName, TriggerId, WebhookId } from '@squidcloud/common';
2
+ declare class Meta {
3
+ data: ApplicationBundleData;
4
+ /**
5
+ * @secureDatabase("read", "ExampleIntegration")
6
+ *
7
+ * Applying the decorator above to the myMethod method on the MyService
8
+ * class will generate the following metadata:
9
+ *
10
+ * data: {
11
+ * databases: {
12
+ * ExampleIntegration: {
13
+ * security: {
14
+ * read: ['MyService:myMethod']
15
+ * }
16
+ * }
17
+ * }
18
+ * }
19
+ */
20
+ secureDatabase(type: DatabaseActionType, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
21
+ /**
22
+ * @secureCollection("ExampleCollection", "read", "ExampleIntegration")
23
+ *
24
+ * Applying the decorator above to the myMethod method on the MyService
25
+ * class will generate the following metadata:
26
+ *
27
+ * data: {
28
+ * databases: {
29
+ * ExampleIntegration: {
30
+ * collections: {
31
+ * ExampleCollection: {
32
+ * security: {
33
+ * read: ['MyService:myMethod']
34
+ * }
35
+ * }
36
+ * }
37
+ * }
38
+ * }
39
+ * }
40
+ */
41
+ secureCollection(collectionName: CollectionName, type: DatabaseActionType, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
42
+ /**
43
+ * @secureApi("ExampleIntegration", "myEndpoint")
44
+ *
45
+ * Applying the decorator above to the myMethod method on the MyService
46
+ * class will generate the following metadata:
47
+ *
48
+ * data: {
49
+ * apis: {
50
+ * ExampleIntegration: {
51
+ * myEndpoint: {
52
+ * security: ['MyService:myMethod']
53
+ * }
54
+ * }
55
+ * }
56
+ * }
57
+ */
58
+ secureApi(integrationId: IntegrationId, endpointId: ApiEndpointId | undefined, serviceFunction: ServiceFunctionName): void;
59
+ /**
60
+ * @secureGraphQL("ExampleIntegration")
61
+ *
62
+ * Applying the decorator above to the myMethod method on the MyService
63
+ * class will generate the following metadata:
64
+ *
65
+ * data: {
66
+ * graphql: {
67
+ * ExampleIntegration: {
68
+ * security: ['MyService:myMethod']
69
+ * }
70
+ * }
71
+ * }
72
+ */
73
+ secureGraphQL(integrationId: IntegrationId, serviceFunction: ServiceFunctionName): void;
74
+ /**
75
+ * @transformDatabase(""read", "ExampleIntegration")
76
+ *
77
+ * Applying the decorator above to the myMethod method on the MyService
78
+ * class will generate the following metadata:
79
+ *
80
+ * data: {
81
+ * databases: {
82
+ * ExampleIntegration: {
83
+ * transform: {
84
+ * read: {
85
+ * type: "read"
86
+ * functionName: "MyService:myMethod"
87
+ * }
88
+ * }
89
+ * }
90
+ * }
91
+ * }
92
+ */
93
+ transformDatabase(type: DatabaseActionType, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
94
+ /**
95
+ * @transformCollection("ExampleCollection", "read", "ExampleIntegration")
96
+ *
97
+ * Applying the decorator above to the myMethod method on the MyService
98
+ * class will generate the following metadata:
99
+ *
100
+ * data: {
101
+ * databases: {
102
+ * ExampleIntegration: {
103
+ * collections: {
104
+ * ExampleCollection: {
105
+ * transform: {
106
+ * read: {
107
+ * type: "read"
108
+ * functionName: "MyService:myMethod"
109
+ * }
110
+ * }
111
+ * }
112
+ * }
113
+ * }
114
+ * }
115
+ * }
116
+ */
117
+ transformCollection(collectionName: CollectionName, type: DatabaseActionType, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
118
+ /**
119
+ * @executable()
120
+ *
121
+ * Applying the decorator above to the myMethod method on the MyService
122
+ * class will generate the following metadata:
123
+ *
124
+ * data: {
125
+ * executables: {
126
+ * myExecutable: {
127
+ * serviceName: "MyService:myMethod",
128
+ * }
129
+ * }
130
+ * }
131
+ */
132
+ executable(serviceFunction: ServiceFunctionName): void;
133
+ /**
134
+ * @trigger("my-trigger", "ExampleCollection", "ExampleIntegration")
135
+ *
136
+ * Applying the decorator above to the myMethod method on the MyService
137
+ * class will generate the following metadata:
138
+ *
139
+ * data: {
140
+ * triggers: {
141
+ * "my-trigger": {
142
+ * integrationId: "ExampleIntegration"
143
+ * collectionName: "ExampleCollection"
144
+ * functionName: "MyService:myMethod",
145
+ * }
146
+ * }
147
+ * }
148
+ */
149
+ trigger(id: TriggerId, collectionName: CollectionName, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
150
+ /**
151
+ * @scheduler("my-scheduler", "CronExpression", true)
152
+ *
153
+ * Applying the decorator above to the myMethod method on the MyService
154
+ * class will generate the following metadata:
155
+ *
156
+ * data: {
157
+ * schedulers: {
158
+ * "my-scheduler", {
159
+ * cronExpression: "CronExpression"
160
+ * functionName: "MyService:myMethod",
161
+ * }
162
+ * }
163
+ * }
164
+ */
165
+ scheduler(id: SchedulerId, cronExpression: string, serviceFunction: ServiceFunctionName, exclusive: boolean): void;
166
+ /**
167
+ * @webhook("my-webhook")
168
+ *
169
+ * Applying the decorator above to the myMethod method on the MyService
170
+ * class will generate the following metadata:
171
+ *
172
+ * data: {
173
+ * webhooks: {
174
+ * "my-webhook", {
175
+ * functionName: "MyService:myMethod",
176
+ * }
177
+ * }
178
+ * }
179
+ */
180
+ webhook(id: WebhookId, serviceFunction: ServiceFunctionName): void;
181
+ /**
182
+ * @namedQuery('exampleIntegration', 'my-query')
183
+ * static myQuery = "select * from my-table where id = ${id}";
184
+ *
185
+ * Applying the decorator above to the myQuery static string in MyService
186
+ * class will generate the following metadata:
187
+ *
188
+ *
189
+ *
190
+ * data: {
191
+ * namedQueries: {
192
+ * "exampleIntegration", {
193
+ * my-query: {
194
+ * queryString: "select * from my-table where id = $id"
195
+ * }
196
+ * }
197
+ * }
198
+ * }
199
+ */
200
+ namedQuery(integrationId: IntegrationId, name: QueryName, queryString: string): void;
201
+ /**
202
+ * @secureNamedQuery("exampleIntegration", "queryName")
203
+ *
204
+ * Applying the decorator above to the myMethod method on the MyService
205
+ * class will generate the following metadata:
206
+ *
207
+ * data: {
208
+ * namedQueries: {
209
+ * exampleIntegration: {
210
+ * queryName: {
211
+ * security: MyService:myMethod
212
+ * }
213
+ * }
214
+ * }
215
+ * }
216
+ */
217
+ secureNamedQuery(integrationId: IntegrationId, name: QueryName, serviceFunction: ServiceFunctionName): void;
218
+ /**
219
+ * @secureDistributedLock("mutex", true)
220
+ *
221
+ * Applying the decorator above to the myMethod method on the MyService
222
+ * class will generate the following metadata:
223
+ *
224
+ * data: {
225
+ * distributedLocks: {
226
+ * security: [MyService:myMethod]
227
+ * }
228
+ * }
229
+ */
230
+ secureDistributedLock(mutex: string | undefined, serviceFunction: ServiceFunctionName): void;
231
+ /**
232
+ * @secureAiAssistant(ExampleIntegration, "chat", myProfile)
233
+ *
234
+ * Applying the decorator above to the myMethod method on the MyService
235
+ * class will generate the following metadata:
236
+ *
237
+ * data: {
238
+ * aiAssistants: {
239
+ * ExampleIntegration: {
240
+ * myProfile: {
241
+ * security: {
242
+ * chat: ['MyService:myMethod']
243
+ * }
244
+ * }
245
+ * }
246
+ * }
247
+ * }
248
+ */
249
+ secureAiAssistant(type: AiAssistantActionType, integrationId: IntegrationId, profileId: string | undefined, serviceFunction: ServiceFunctionName): void;
250
+ clientConnectionChangeHandler(serviceFunction: ServiceFunctionName): void;
251
+ }
252
+ /**
253
+ * @internal
254
+ */
255
+ export declare const metadata: Meta;
256
+ export {};
@@ -1,7 +1,7 @@
1
- /**
2
- * The SquidProject class is the entry point for the Squid backend project.
3
- */
4
- export declare class SquidProject {
5
- private metadata;
6
- private cleanup;
7
- }
1
+ /**
2
+ * The SquidProject class is the entry point for the Squid backend project.
3
+ */
4
+ export declare class SquidProject {
5
+ private metadata;
6
+ private cleanup;
7
+ }
@@ -1,83 +1,83 @@
1
- import { Squid } from '@squidcloud/client';
2
- import { AuthWithApiKey, AuthWithBearer, Logger, RunContext, SecretKey, SecretValue, ServiceConfig, SupportedSquidRegion, WebhookResponse } from '@squidcloud/common';
3
- /**
4
- * A base class for all the different types of Squid backend services. This class serves as a container
5
- * for the various methods implemented in the backend in order to customize the Squid backend for an application.
6
- */
7
- export declare class SquidService {
8
- /** The list of your application's secrets as defined in the Squid Cloud Console. */
9
- readonly secrets: Record<SecretKey, SecretValue>;
10
- /**
11
- * A logger instance for your application. If you connected one of the observability integrations, the logger will be
12
- * reported to the observability service.
13
- */
14
- readonly logger: Logger;
15
- private readonly backendApiKey;
16
- /**
17
- * The context object for the current request. This object contains information about the current request, such as
18
- * the current user, the IP address, the user agent used, the request headers, and more.
19
- */
20
- readonly context: RunContext;
21
- private readonly codeDir;
22
- /**
23
- * Your application's region. When developing locally, the region will be set to `local`.
24
- */
25
- readonly region: SupportedSquidRegion;
26
- private readonly auth;
27
- private readonly config;
28
- /**
29
- * @internal
30
- */
31
- constructor(config: ServiceConfig);
32
- /**
33
- * Returns the API key used by the backend for your application.
34
- */
35
- getApiKey(): string;
36
- /**
37
- * Returns the Squid client instance for your application.
38
- *
39
- * @returns the Squid client instance for your application.
40
- */
41
- get squid(): Squid;
42
- /**
43
- * Returns the assets directory for your application.
44
- * To read more about the assets directory, see the [Squid
45
- * documentation](https://docs.squid.cloud/docs/development-tools/backend/project-structure#assets-directory).
46
- *
47
- * @returns the assets directory for your application.
48
- */
49
- get assetsDirectory(): string;
50
- /**
51
- * Returns the auth object for the current request or undefined if unauthenticated or if using an API key.
52
- *
53
- * @returns The auth object for the current request or undefined if unauthenticated or if using an API key.
54
- */
55
- getUserAuth(): AuthWithBearer | undefined;
56
- /**
57
- * Returns the auth object for the current request or undefined if unauthenticated or if using a user token.
58
- *
59
- * @returns The auth object for the current request or undefined if unauthenticated or if using a user token.
60
- */
61
- getApiKeyAuth(): AuthWithApiKey | undefined;
62
- /**
63
- * Returns true if the current request is authenticated (using a user token or an API key).
64
- *
65
- * @returns true if the current request is authenticated (using a user token or an API key).
66
- */
67
- isAuthenticated(): boolean;
68
- /**
69
- * Asserts that the current request is authenticated (using a user token or an API key).
70
- * @throws UNAUTHORIZED if the current request is not authenticated.
71
- */
72
- assertIsAuthenticated(): void;
73
- /**
74
- * A helper method to create a webhook response. This method should be used inside a webhook handler (function
75
- * decorated with @webhook).
76
- *
77
- * @param body The body of the response.
78
- * @param statusCode The status code of the response.
79
- * @param headers The headers of the response.
80
- * @returns The webhook response.
81
- */
82
- createWebhookResponse(body?: any, statusCode?: number, headers?: Record<string, any>): WebhookResponse;
83
- }
1
+ import { Squid } from '@squidcloud/client';
2
+ import { AuthWithApiKey, AuthWithBearer, Logger, RunContext, SecretKey, SecretValue, ServiceConfig, SupportedSquidRegion, WebhookResponse } from '@squidcloud/common';
3
+ /**
4
+ * A base class for all the different types of Squid backend services. This class serves as a container
5
+ * for the various methods implemented in the backend in order to customize the Squid backend for an application.
6
+ */
7
+ export declare class SquidService {
8
+ /** The list of your application's secrets as defined in the Squid Cloud Console. */
9
+ readonly secrets: Record<SecretKey, SecretValue>;
10
+ /**
11
+ * A logger instance for your application. If you connected one of the observability integrations, the logger will be
12
+ * reported to the observability service.
13
+ */
14
+ readonly logger: Logger;
15
+ private readonly backendApiKey;
16
+ /**
17
+ * The context object for the current request. This object contains information about the current request, such as
18
+ * the current user, the IP address, the user agent used, the request headers, and more.
19
+ */
20
+ readonly context: RunContext;
21
+ private readonly codeDir;
22
+ /**
23
+ * Your application's region. When developing locally, the region will be set to `local`.
24
+ */
25
+ readonly region: SupportedSquidRegion;
26
+ private readonly auth;
27
+ private readonly config;
28
+ /**
29
+ * @internal
30
+ */
31
+ constructor(config: ServiceConfig);
32
+ /**
33
+ * Returns the API key used by the backend for your application.
34
+ */
35
+ getApiKey(): string;
36
+ /**
37
+ * Returns the Squid client instance for your application.
38
+ *
39
+ * @returns the Squid client instance for your application.
40
+ */
41
+ get squid(): Squid;
42
+ /**
43
+ * Returns the assets directory for your application.
44
+ * To read more about the assets directory, see the [Squid
45
+ * documentation](https://docs.squid.cloud/docs/development-tools/backend/project-structure#assets-directory).
46
+ *
47
+ * @returns the assets directory for your application.
48
+ */
49
+ get assetsDirectory(): string;
50
+ /**
51
+ * Returns the auth object for the current request or undefined if unauthenticated or if using an API key.
52
+ *
53
+ * @returns The auth object for the current request or undefined if unauthenticated or if using an API key.
54
+ */
55
+ getUserAuth(): AuthWithBearer | undefined;
56
+ /**
57
+ * Returns the auth object for the current request or undefined if unauthenticated or if using a user token.
58
+ *
59
+ * @returns The auth object for the current request or undefined if unauthenticated or if using a user token.
60
+ */
61
+ getApiKeyAuth(): AuthWithApiKey | undefined;
62
+ /**
63
+ * Returns true if the current request is authenticated (using a user token or an API key).
64
+ *
65
+ * @returns true if the current request is authenticated (using a user token or an API key).
66
+ */
67
+ isAuthenticated(): boolean;
68
+ /**
69
+ * Asserts that the current request is authenticated (using a user token or an API key).
70
+ * @throws UNAUTHORIZED if the current request is not authenticated.
71
+ */
72
+ assertIsAuthenticated(): void;
73
+ /**
74
+ * A helper method to create a webhook response. This method should be used inside a webhook handler (function
75
+ * decorated with @webhook).
76
+ *
77
+ * @param body The body of the response.
78
+ * @param statusCode The status code of the response.
79
+ * @param headers The headers of the response.
80
+ * @returns The webhook response.
81
+ */
82
+ createWebhookResponse(body?: any, statusCode?: number, headers?: Record<string, any>): WebhookResponse;
83
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/backend",
3
- "version": "1.0.111",
3
+ "version": "1.0.112",
4
4
  "description": "Squid Cloud's backend SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/backend/src/index.d.ts",