@relayfile/sdk 0.7.9 → 0.7.11
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/README.md +7 -1
- package/dist/client.d.ts +26 -1
- package/dist/client.js +921 -2
- package/dist/index.d.ts +2 -2
- package/dist/setup.d.ts +57 -0
- package/dist/setup.js +107 -0
- package/dist/types.d.ts +100 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -81,7 +81,11 @@ import { RelayFileClient } from "@relayfile/sdk";
|
|
|
81
81
|
|
|
82
82
|
const client = new RelayFileClient({
|
|
83
83
|
baseUrl: "https://api.relayfile.com",
|
|
84
|
-
token: process.env.RELAYFILE_TOKEN ?? ""
|
|
84
|
+
token: process.env.RELAYFILE_TOKEN ?? "",
|
|
85
|
+
changeLog: {
|
|
86
|
+
retentionMs: 7 * 24 * 60 * 60 * 1000,
|
|
87
|
+
maxEntries: 10_000
|
|
88
|
+
}
|
|
85
89
|
});
|
|
86
90
|
|
|
87
91
|
const workspaceId = "workspace_123";
|
|
@@ -108,6 +112,8 @@ await client.writeFile({
|
|
|
108
112
|
|
|
109
113
|
Use a relayfile JWT whose claims include `workspace_id`, `agent_name`, and `aud: ["relayfile"]`. The SDK adds `X-Correlation-Id` automatically for API calls.
|
|
110
114
|
|
|
115
|
+
The optional `changeLog` block configures the SDK's local per-workspace retained-change mirror used by `subscribe()`, `open({ replayOnStart })`, and `getResourceAtEvent(eventId)`. Durable retention still lives on the Relayfile backend.
|
|
116
|
+
|
|
111
117
|
## Full Docs
|
|
112
118
|
|
|
113
119
|
Full documentation is available in the [relayfile docs](https://github.com/AgentWorkforce/relayfile/tree/main/docs).
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AdminIngressStatusResponse, type AdminSyncStatusResponse, type BulkWriteInput, type BulkWriteResponse, type BackendStatusResponse, type AckResponse, type CommitForkInput, type CommitForkResponse, type CreateForkInput, type DeleteFileInput, type DeadLetterItem, type DeadLetterFeedResponse, type DiscardForkInput, type EventFeedResponse, type ExportJsonResponse, type ExportOptions, type FileQueryResponse, type FileReadResponse, type FilesystemEvent, type GetEventsOptions, type GetAdminIngressStatusOptions, type GetAdminSyncStatusOptions, type GetOperationsOptions, type GetSyncDeadLettersOptions, type GetSyncIngressStatusOptions, type GetSyncStatusOptions, type ListTreeOptions, type OperationFeedResponse, type OperationStatusResponse, type QueuedResponse, type ReadFileInput, type QueryFilesOptions, type SyncIngressStatusResponse, type SyncStatusResponse, type TreeResponse, type WriteFileInput, type WriteQueuedResponse, type IngestWebhookInput, type WritebackItem, type AckWritebackInput, type AckWritebackResponse } from "./types.js";
|
|
1
|
+
import { type AdminIngressStatusResponse, type AdminSyncStatusResponse, type BulkWriteInput, type BulkWriteResponse, type BackendStatusResponse, type AckResponse, type CommitForkInput, type CommitForkResponse, type CreateForkInput, type DeleteFileInput, type DeadLetterItem, type DeadLetterFeedResponse, type DiscardForkInput, type EventFeedResponse, type ExportJsonResponse, type ExportOptions, type FileQueryResponse, type FileReadResponse, type FilesystemEvent, type GetEventsOptions, type GetAdminIngressStatusOptions, type GetAdminSyncStatusOptions, type GetOperationsOptions, type GetSyncDeadLettersOptions, type GetSyncIngressStatusOptions, type GetSyncStatusOptions, type ListTreeOptions, type OperationFeedResponse, type OperationStatusResponse, type QueuedResponse, type ResourceAtEventResult, type ReadFileInput, type QueryFilesOptions, type Subscription, type SyncIngressStatusResponse, type SyncStatusResponse, type TreeResponse, type WriteFileInput, type WriteQueuedResponse, type IngestWebhookInput, type WritebackItem, type AckWritebackInput, type AckWritebackResponse, type ChangeEvent, type ChangeLogQueryResult, type ChangeStreamConnection, type ChangeStreamConnectionOptions, type SubscribeOptions } from "./types.js";
|
|
2
2
|
import type { ForkHandle } from "@relayfile/core";
|
|
3
3
|
/**
|
|
4
4
|
* Bearer token or token factory used for Relayfile API requests.
|
|
@@ -13,6 +13,18 @@ export interface RelayFileRetryOptions {
|
|
|
13
13
|
maxDelayMs?: number;
|
|
14
14
|
jitterRatio?: number;
|
|
15
15
|
}
|
|
16
|
+
export interface RelayFileChangeLogOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Local retained-change cache TTL in milliseconds.
|
|
19
|
+
*
|
|
20
|
+
* This mirrors the backend retention window opportunistically for delivered
|
|
21
|
+
* or replayed events; durable change-log retention remains a server-side
|
|
22
|
+
* responsibility.
|
|
23
|
+
*/
|
|
24
|
+
retentionMs?: number;
|
|
25
|
+
/** Maximum number of retained change entries to keep per workspace locally. */
|
|
26
|
+
maxEntries?: number;
|
|
27
|
+
}
|
|
16
28
|
/** Default base URL for the hosted Relayfile API */
|
|
17
29
|
export declare const DEFAULT_RELAYFILE_BASE_URL = "https://api.relayfile.dev";
|
|
18
30
|
export interface RelayFileClientOptions {
|
|
@@ -28,6 +40,7 @@ export interface RelayFileClientOptions {
|
|
|
28
40
|
fetchImpl?: typeof fetch;
|
|
29
41
|
userAgent?: string;
|
|
30
42
|
retry?: RelayFileRetryOptions;
|
|
43
|
+
changeLog?: RelayFileChangeLogOptions;
|
|
31
44
|
}
|
|
32
45
|
type WebSocketEventName = "event" | "error" | "open" | "close";
|
|
33
46
|
type WebSocketHandlerMap = {
|
|
@@ -44,6 +57,10 @@ export interface ConnectWebSocketOptions {
|
|
|
44
57
|
token?: string;
|
|
45
58
|
onEvent?: (event: FilesystemEvent) => void;
|
|
46
59
|
}
|
|
60
|
+
interface ProactiveRequestContext {
|
|
61
|
+
workspaceId: string;
|
|
62
|
+
token?: string;
|
|
63
|
+
}
|
|
47
64
|
export declare class RelayFileClient {
|
|
48
65
|
private readonly baseUrl;
|
|
49
66
|
private readonly tokenProvider;
|
|
@@ -82,6 +99,11 @@ export declare class RelayFileClient {
|
|
|
82
99
|
discardFork(input: DiscardForkInput): Promise<void>;
|
|
83
100
|
commitFork(input: CommitForkInput): Promise<CommitForkResponse>;
|
|
84
101
|
getEvents(workspaceId: string, options?: GetEventsOptions): Promise<EventFeedResponse>;
|
|
102
|
+
subscribe(globs: string[], onChange: (event: ChangeEvent) => void, options?: SubscribeOptions): Subscription;
|
|
103
|
+
open(options: ChangeStreamConnectionOptions): ChangeStreamConnection;
|
|
104
|
+
getResourceAtEvent(eventId: string, context?: ProactiveRequestContext): Promise<ResourceAtEventResult>;
|
|
105
|
+
listChangesSince(isoTimestamp: string, context?: ProactiveRequestContext): Promise<ChangeLogQueryResult>;
|
|
106
|
+
listLastNChanges(limit: number, context?: ProactiveRequestContext): Promise<ChangeLogQueryResult>;
|
|
85
107
|
exportWorkspace(options: ExportOptions): Promise<ExportJsonResponse | Blob>;
|
|
86
108
|
connectWebSocket(workspaceId: string, options?: ConnectWebSocketOptions): WebSocketConnection;
|
|
87
109
|
getOp(workspaceId: string, opId: string, correlationId?: string, signal?: AbortSignal): Promise<OperationStatusResponse>;
|
|
@@ -102,6 +124,9 @@ export declare class RelayFileClient {
|
|
|
102
124
|
ingestWebhook(input: IngestWebhookInput): Promise<QueuedResponse>;
|
|
103
125
|
listPendingWritebacks(workspaceId: string, correlationId?: string, signal?: AbortSignal): Promise<WritebackItem[]>;
|
|
104
126
|
ackWriteback(input: AckWritebackInput): Promise<AckWritebackResponse>;
|
|
127
|
+
private cacheWireChangeEvent;
|
|
128
|
+
private primeReplayCache;
|
|
129
|
+
private resolveWorkspaceId;
|
|
105
130
|
private request;
|
|
106
131
|
private performRequest;
|
|
107
132
|
private shouldRetryStatus;
|