@squidcloud/backend 1.0.479 → 1.0.482
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.
|
@@ -57,6 +57,37 @@ export declare function secureAiQuery(integrationId?: IntegrationId): ActionMeth
|
|
|
57
57
|
* @category Decorator
|
|
58
58
|
*/
|
|
59
59
|
export declare function secureCollection<T extends DatabaseActionType>(collectionName: CollectionName, type: T, integrationId?: IntegrationId): ActionMethodDecorator<SecureDatabaseAction<T>>;
|
|
60
|
+
/**
|
|
61
|
+
* Class decorator that declares reads from a collection as intentionally public.
|
|
62
|
+
*
|
|
63
|
+
* Public reads bypass security-rule evaluation entirely: Core serves them without calling backend
|
|
64
|
+
* code, so any client can read the collection, including unauthenticated ones. Use it only for data
|
|
65
|
+
* that is safe to expose to everyone; prefer a `@secureCollection` read rule when access must depend
|
|
66
|
+
* on the caller.
|
|
67
|
+
*
|
|
68
|
+
* Only reads can be made public. Writes always go through their security rules, so a public-read
|
|
69
|
+
* collection can still restrict `insert`/`update`/`delete`/`write` with `@secureCollection`.
|
|
70
|
+
*
|
|
71
|
+
* Secure wins on conflict: if a `@secureCollection` or `@secureDatabase` read (or `all`) rule also
|
|
72
|
+
* applies to the same collection, that rule takes precedence at runtime and the public declaration
|
|
73
|
+
* is ignored.
|
|
74
|
+
*
|
|
75
|
+
* @param collectionName The name of the public collection.
|
|
76
|
+
* @param type The public action type. Only `read` is supported.
|
|
77
|
+
* @param integrationId The ID of the integration containing the collection. Defaults to the built-in database.
|
|
78
|
+
* @category Database
|
|
79
|
+
* @category Decorator
|
|
80
|
+
* @example
|
|
81
|
+
* // Anyone can read the `articles` collection, but only authors can write to it.
|
|
82
|
+
* @publicCollection('articles', 'read')
|
|
83
|
+
* export class ArticleService extends SquidService {
|
|
84
|
+
* @secureCollection('articles', 'write')
|
|
85
|
+
* async secureArticlesWrite(context: MutationContext): Promise<boolean> {
|
|
86
|
+
* return this.isAuthenticated();
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
*/
|
|
90
|
+
export declare function publicCollection(collectionName: CollectionName, type: 'read', integrationId?: IntegrationId): ClassDecorator;
|
|
60
91
|
/**
|
|
61
92
|
* The decorator allows protects storage buckets so only authorized users can access it.
|
|
62
93
|
* @category Storage
|
|
@@ -2,6 +2,12 @@ import { AiStatusMessage, AuthWithApiKey, AuthWithBearer, ClientId, RunContext,
|
|
|
2
2
|
import { SquidFile } from '../../internal-common/src/public-types-backend/bundle-api.public-types';
|
|
3
3
|
import { TenantModuleId } from '../../internal-common/src/public-types-backend/bundle-data.public-types';
|
|
4
4
|
import { WorkspaceClient } from './workspace-client';
|
|
5
|
+
/** The content of a webhook or OpenAPI protocol response: body, status code, and headers, all optional. */
|
|
6
|
+
interface ProtocolResponseContent {
|
|
7
|
+
body?: unknown;
|
|
8
|
+
statusCode?: number;
|
|
9
|
+
headers?: Record<string, unknown>;
|
|
10
|
+
}
|
|
5
11
|
/**
|
|
6
12
|
* A base class for all the different types of Squid backend services. This class serves as a container
|
|
7
13
|
* for the various methods implemented in the backend in order to customize the Squid backend for an application.
|
|
@@ -94,11 +100,7 @@ export declare class SquidService {
|
|
|
94
100
|
* @param content The response content including optional body, status code, and headers.
|
|
95
101
|
* @throws An object marked as a webhook response.
|
|
96
102
|
*/
|
|
97
|
-
throwWebhookResponse(content:
|
|
98
|
-
body: unknown;
|
|
99
|
-
statusCode: number;
|
|
100
|
-
headers: Record<string, unknown>;
|
|
101
|
-
}>): never;
|
|
103
|
+
throwWebhookResponse(content: ProtocolResponseContent): never;
|
|
102
104
|
/**
|
|
103
105
|
* Constructs a response for an OpenAPI operation. This function is typically used within an OpenAPI handler.
|
|
104
106
|
*
|
|
@@ -115,11 +117,7 @@ export declare class SquidService {
|
|
|
115
117
|
* @param content The response content including optional body, status code, and headers.
|
|
116
118
|
* @throws An object marked as an OpenAPI response.
|
|
117
119
|
*/
|
|
118
|
-
throwOpenApiResponse(content:
|
|
119
|
-
body: unknown;
|
|
120
|
-
statusCode: number;
|
|
121
|
-
headers: Record<string, unknown>;
|
|
122
|
-
}>): never;
|
|
120
|
+
throwOpenApiResponse(content: ProtocolResponseContent): never;
|
|
123
121
|
/**
|
|
124
122
|
* Converts a file to a SquidFile object. This function is useful when you want to return a file using OpenAPI (tsoa
|
|
125
123
|
* decorators).
|
|
@@ -152,3 +150,4 @@ export declare function getSquid(): Squid;
|
|
|
152
150
|
* main {@link getSquid} instance.
|
|
153
151
|
*/
|
|
154
152
|
export declare function getPassiveSquid(): Squid;
|
|
153
|
+
export {};
|