@squidcloud/backend 1.0.481 → 1.0.483
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.
- package/dist/backend/src/actions.d.ts +45 -1
- package/dist/backend/src/public-types.d.ts +1 -0
- package/dist/backend/src/workspace-client.d.ts +22 -6
- package/dist/cjs/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/internal-common/src/public-types-backend/bundle-api.public-types.d.ts +5 -0
- package/dist/internal-common/src/public-types-backend/langgraph.public-context.d.ts +16 -0
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AiFunctionId, ApiEndpointId, CollectionName, IntegrationId, IntegrationType, TopicName } from '@squidcloud/client';
|
|
2
2
|
import { JSONSchema } from 'json-schema-typed';
|
|
3
|
-
import { ActionMethodDecorator, AiFunctionAction, ClientConnectionStateChangeAction, EventHandlerAction, ExecutableAction, LimiterConfig, LimitsAction, LlmAskAction, McpAuthorizerAction, McpToolAction, QueueMessageAction, SchedulerAction, SecureAiAgentAction, SecureAiQueryAction, SecureApiAction, SecureDatabaseAction, SecureDistributedLockAction, SecureGraphQLAction, SecureMetricAction, SecureNativeQueryAction, SecureStorageAction, SecureTopicAction, TriggerAction, WebhookAction } from '../../internal-common/src/public-types-backend/bundle-api.public-types';
|
|
3
|
+
import { ActionMethodDecorator, AiFunctionAction, ClientConnectionStateChangeAction, EventHandlerAction, ExecutableAction, LimiterConfig, LimitsAction, LlmAskAction, McpAuthorizerAction, McpToolAction, QueueMessageAction, SchedulerAction, SecureAiAgentAction, SecureAiQueryAction, SecureApiAction, SecureDatabaseAction, SecureDistributedLockAction, SecureGraphQLAction, SecureLangGraphAction, SecureMetricAction, SecureNativeQueryAction, SecureStorageAction, SecureTopicAction, TriggerAction, WebhookAction } from '../../internal-common/src/public-types-backend/bundle-api.public-types';
|
|
4
4
|
import { AiFunctionAttributes, AiFunctionParam, DatabaseActionType, MetricActionType, StorageActionType, TopicActionType } from '../../internal-common/src/public-types-backend/bundle-data.public-types';
|
|
5
5
|
import { AiFunctionsConfiguratorRequest, AiFunctionsConfiguratorResponse, CronExpression, CronExpressionString, LlmServiceOptions, McpServerOptions, MutationType, SchedulerId, TriggerId, WebhookId } from './public-types';
|
|
6
6
|
/**
|
|
@@ -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
|
|
@@ -423,6 +454,19 @@ export declare function secureDistributedLock(mutex?: string): ActionMethodDecor
|
|
|
423
454
|
@category Decorator
|
|
424
455
|
*/
|
|
425
456
|
export declare function secureAiAgent(agentId?: string): ActionMethodDecorator<SecureAiAgentAction>;
|
|
457
|
+
/**
|
|
458
|
+
* A decorator that can be used to secure a LangGraph invocation.
|
|
459
|
+
*
|
|
460
|
+
* The function should return a boolean or a `Promise` of a boolean indicating
|
|
461
|
+
* whether the invocation is allowed. It takes a {@link SecureLangGraphContext}
|
|
462
|
+
* parameter containing the `operation` (`'invoke' | 'resume' | 'getState' | 'deleteThread'`),
|
|
463
|
+
* `graphId`, `threadId`, `input`, and `resumePayload` of the request.
|
|
464
|
+
*
|
|
465
|
+
* @param graphId The ID of the graph to secure - if not provided, this will apply to all graphs.
|
|
466
|
+
* @category AI
|
|
467
|
+
* @category Decorator
|
|
468
|
+
*/
|
|
469
|
+
export declare function secureLangGraph(graphId?: string): ActionMethodDecorator<SecureLangGraphAction>;
|
|
426
470
|
/**
|
|
427
471
|
* A decorator that can be used to rate/quota limit a function. In its simplest form, the decorator
|
|
428
472
|
* can take the query rate that is allowed for the given function and/or how many total calls are
|
|
@@ -5,6 +5,7 @@ export * from '../../internal-common/src/public-types-backend/bundle-api.public-
|
|
|
5
5
|
export * from '../../internal-common/src/public-types-backend/bundle-data.public-types';
|
|
6
6
|
export * from '../../internal-common/src/public-types-backend/distributed-lock.public-context';
|
|
7
7
|
export * from '../../internal-common/src/public-types-backend/graphql.public-context';
|
|
8
|
+
export * from '../../internal-common/src/public-types-backend/langgraph.public-context';
|
|
8
9
|
export * from '../../internal-common/src/public-types-backend/llm.public-types';
|
|
9
10
|
export * from '../../internal-common/src/public-types-backend/mcp.public-types';
|
|
10
11
|
export * from '../../internal-common/src/public-types-backend/metric.public-context';
|
|
@@ -5,6 +5,23 @@ export interface WorkspaceMetadata {
|
|
|
5
5
|
/** Absolute path of the workspace directory on this pod's local disk. */
|
|
6
6
|
path: string;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Options for {@link WorkspaceClient.create}.
|
|
10
|
+
*
|
|
11
|
+
* Note the durability contract of the directory itself, which is separate from the GC TTL below: only
|
|
12
|
+
* {@link WorkspaceClient.push} makes local changes durable. The pod-local copy is evicted after 6 hours
|
|
13
|
+
* without a `create`, `push`, or agent run, so a long-running job that writes files and pushes them more
|
|
14
|
+
* than 6 hours later loses whatever it had not pushed — unlike an expired *tracked* workspace, whose
|
|
15
|
+
* final push revives it. Push periodically for work that spans hours.
|
|
16
|
+
*/
|
|
17
|
+
export interface WorkspaceCreateOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Idle TTL in seconds (bounds: see workspace.utils): the workspace is reclaimed by GC after this long
|
|
20
|
+
* without use; every use pushes the deadline forward. Persisted last-write-wins; when absent, the
|
|
21
|
+
* workspace keeps its stored TTL (or the default — one day — for a new one).
|
|
22
|
+
*/
|
|
23
|
+
idleTtlSeconds?: number;
|
|
24
|
+
}
|
|
8
25
|
/**
|
|
9
26
|
* Returns whether the shared workspace server is configured on this pod. Callers that want to degrade
|
|
10
27
|
* gracefully (treat a shared workspace as best-effort/ephemeral rather than fail) should check this
|
|
@@ -37,13 +54,14 @@ export declare class WorkspaceClient {
|
|
|
37
54
|
* new workspace id when none is given. Safe to call repeatedly: pulls from the workspace server only
|
|
38
55
|
* when there is something to pull, and is a no-op for a brand-new, never-pushed workspace.
|
|
39
56
|
*/
|
|
40
|
-
create(id?: string): Promise<WorkspaceMetadata>;
|
|
57
|
+
create(id?: string, options?: WorkspaceCreateOptions): Promise<WorkspaceMetadata>;
|
|
41
58
|
/** Syncs the current state of the workspace directory to the workspace server as the new authoritative state. */
|
|
42
59
|
push(id: string): Promise<WorkspaceMetadata>;
|
|
43
60
|
/**
|
|
44
|
-
* Deletes the workspace
|
|
45
|
-
*
|
|
46
|
-
*
|
|
61
|
+
* Deletes the workspace everywhere it canonically exists: its directory on the workspace server and its
|
|
62
|
+
* GC tracking record (both via core), plus every copy on this pod — the live directory, its marker, and
|
|
63
|
+
* any tree an interrupted eviction left in quarantine. Copies left on other pod replicas by an earlier
|
|
64
|
+
* `create` are reclaimed by their own pod's cache eviction, not by this call.
|
|
47
65
|
*/
|
|
48
66
|
delete(id: string): Promise<void>;
|
|
49
67
|
private buildMetadata;
|
|
@@ -55,8 +73,6 @@ export declare class WorkspaceClient {
|
|
|
55
73
|
private pull;
|
|
56
74
|
/** Pushes `dir` to the workspace server as the new authoritative state. */
|
|
57
75
|
private pushDir;
|
|
58
|
-
/** Mirrors an empty local directory onto the server to clear its content. */
|
|
59
|
-
private rsyncEmptyTo;
|
|
60
76
|
/**
|
|
61
77
|
* Runs rsync against the workspace server for `workspaceId`, fetching a fresh, short-lived certificate
|
|
62
78
|
* scoped to that workspace first and cleaning it up afterwards. The certificate (not the key) is what
|