@squidcloud/backend 1.0.110 → 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,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
+ }