js-bao-wss-client 2.0.5 → 2.0.7
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 +1 -1
- package/dist/JsBaoClient.d.ts +154 -61
- package/dist/JsBaoClient.d.ts.map +1 -1
- package/dist/JsBaoClient.js +94 -11
- package/dist/JsBaoClient.js.map +1 -1
- package/dist/api/cacheFacade.d.ts +6 -6
- package/dist/api/cacheFacade.d.ts.map +1 -1
- package/dist/api/cacheFacade.js.map +1 -1
- package/dist/api/collectionTypeConfigsApi.d.ts +23 -0
- package/dist/api/collectionTypeConfigsApi.d.ts.map +1 -1
- package/dist/api/collectionTypeConfigsApi.js.map +1 -1
- package/dist/api/collectionsApi.d.ts +15 -0
- package/dist/api/collectionsApi.d.ts.map +1 -1
- package/dist/api/collectionsApi.js.map +1 -1
- package/dist/api/cronTriggersApi.d.ts +19 -6
- package/dist/api/cronTriggersApi.d.ts.map +1 -1
- package/dist/api/cronTriggersApi.js.map +1 -1
- package/dist/api/databaseTypeConfigsApi.d.ts +110 -5
- package/dist/api/databaseTypeConfigsApi.d.ts.map +1 -1
- package/dist/api/databaseTypeConfigsApi.js.map +1 -1
- package/dist/api/databasesApi.d.ts +114 -76
- package/dist/api/databasesApi.d.ts.map +1 -1
- package/dist/api/databasesApi.js +24 -2
- package/dist/api/databasesApi.js.map +1 -1
- package/dist/api/documentsApi.d.ts +70 -9
- package/dist/api/documentsApi.d.ts.map +1 -1
- package/dist/api/documentsApi.js +53 -0
- package/dist/api/documentsApi.js.map +1 -1
- package/dist/api/geminiApi.d.ts +9 -9
- package/dist/api/geminiApi.d.ts.map +1 -1
- package/dist/api/geminiApi.js.map +1 -1
- package/dist/api/invitationsApi.d.ts +15 -3
- package/dist/api/invitationsApi.d.ts.map +1 -1
- package/dist/api/invitationsApi.js +15 -3
- package/dist/api/invitationsApi.js.map +1 -1
- package/dist/api/llmApi.d.ts +8 -8
- package/dist/api/llmApi.d.ts.map +1 -1
- package/dist/api/llmApi.js.map +1 -1
- package/dist/api/notificationsApi.d.ts +2 -2
- package/dist/api/operationDefinition.d.ts +279 -0
- package/dist/api/operationDefinition.d.ts.map +1 -0
- package/dist/api/operationDefinition.js +47 -0
- package/dist/api/operationDefinition.js.map +1 -0
- package/dist/api/resourceMetadataApi.d.ts +34 -15
- package/dist/api/resourceMetadataApi.d.ts.map +1 -1
- package/dist/api/resourceMetadataApi.js.map +1 -1
- package/dist/api/ruleSetsApi.d.ts +57 -11
- package/dist/api/ruleSetsApi.d.ts.map +1 -1
- package/dist/api/ruleSetsApi.js.map +1 -1
- package/dist/browser.umd.js +318 -37
- package/dist/browser.umd.js.map +1 -1
- package/dist/internal/blobManager.d.ts +5 -5
- package/dist/internal/blobManager.d.ts.map +1 -1
- package/dist/internal/blobManager.js.map +1 -1
- package/dist/internal/documentManager.d.ts +1 -0
- package/dist/internal/documentManager.d.ts.map +1 -1
- package/dist/internal/documentManager.js.map +1 -1
- package/dist/internal/httpClient.d.ts +58 -1
- package/dist/internal/httpClient.d.ts.map +1 -1
- package/dist/internal/httpClient.js +132 -21
- package/dist/internal/httpClient.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3532,7 +3532,7 @@ For contributors and developers working on this package:
|
|
|
3532
3532
|
|
|
3533
3533
|
### Testing Locally
|
|
3534
3534
|
|
|
3535
|
-
See [LOCAL_TESTING.md](
|
|
3535
|
+
See [LOCAL_TESTING.md](https://github.com/Primitive-Labs/js-bao-wss-client/blob/main/LOCAL_TESTING.md) for a comprehensive guide on testing your changes locally using `npm pack`.
|
|
3536
3536
|
|
|
3537
3537
|
**Quick test:**
|
|
3538
3538
|
|
package/dist/JsBaoClient.d.ts
CHANGED
|
@@ -33,17 +33,17 @@ export { JsBaoError, isJsBaoError, JsBaoApiError, isJsBaoApiError, JsBaoNetworkE
|
|
|
33
33
|
export type { JsBaoErrorCode } from "./errors";
|
|
34
34
|
export { AuthError, AUTH_CODES } from "./internal/authController";
|
|
35
35
|
export type { AuthCode } from "./internal/authController";
|
|
36
|
-
export type { DocumentInfo, DocumentPermissionEntry, DocumentInvitation, DocumentInvitationResponse, DocumentAccessResult, DocumentGroupPermissionEntry, DocumentAliasInfo, DocumentAliasScope, PermissionUpdateResult, DirectPermissionGrant, DeferredPermissionGrant, PendingInvitationEntry, PendingGroupInvitationEntry, } from "./api/documentsApi";
|
|
36
|
+
export type { DocumentInfo, DocumentPermissionEntry, DocumentInvitation, DocumentInvitationResponse, DocumentAccessResult, DocumentGroupPermissionEntry, DocumentAliasInfo, DocumentAliasScope, PermissionUpdateResult, DirectPermissionGrant, DeferredPermissionGrant, PendingInvitationEntry, PendingGroupInvitationEntry, LinkAccessResult, } from "./api/documentsApi";
|
|
37
37
|
export type { UserProfile, SharedDocument, SharedDocumentListResult, SharedDocumentsOptions, OwnedDocumentsOptions, } from "./api/meApi";
|
|
38
38
|
export type { SessionInfo } from "./api/sessionApi";
|
|
39
39
|
export type { BasicUserInfo, BatchUserProfile } from "./api/usersApi";
|
|
40
|
-
export type { DatabaseInfo, DatabasePermissionEntry, DatabaseGroupPermissionEntry, GrantDatabaseGroupPermissionParams, DatabaseOwnershipTransferResult, DatabaseOperationInfo, AddManagerParams, GrantPermissionParams, CsvImportOptions, CsvImportProgress, CsvImportResult, DatabaseChangeEvent, DatabaseChangePayload, DatabaseSubscribeOptions, ListDatabasesOptions, } from "./api/databasesApi";
|
|
40
|
+
export type { DatabaseInfo, DatabasePermissionEntry, DatabaseGroupPermissionEntry, GrantDatabaseGroupPermissionParams, DatabaseOwnershipTransferResult, DatabaseOperationInfo, AddManagerParams, GrantPermissionParams, CsvImportOptions, CsvImportProgress, CsvImportResult, CelContextResult, ExecuteOperationOptions, DatabaseChangeEvent, DatabaseChangePayload, DatabaseSubscribeOptions, ListDatabasesOptions, OperationType, OperationFilter, QueryDefinition, MutationOperation, MutationDefinition, CountDefinition, AggregateOperation, AggregateDefinition, PipelineStep, PipelineDefinition, ApplyToQuerySource, ApplyToQueryAction, ApplyToQueryDefinition, OperationDefinition, CreateOperationParams, UpdateOperationParams, } from "./api/databasesApi";
|
|
41
41
|
export type { GroupInfo, GroupMemberInfo, GroupMembershipInfo, GroupDocumentInfo, GroupDatabaseInfo, ListUserMembershipsOptions, PaginatedResult, DirectGroupAdd, DeferredGroupAdd, GroupAddMemberResult, } from "./api/groupsApi";
|
|
42
42
|
export type { CollectionInfo, CollectionDocumentInfo, CollectionGroupPermissionInfo, CollectionMemberInfo, CollectionAccessInfo, DocumentCollectionInfo, AddCollectionMemberParams, DirectCollectionAdd, DeferredCollectionAdd, CollectionAddMemberResult, PendingCollectionInvitationEntry, } from "./api/collectionsApi";
|
|
43
|
-
export type { RuleSetInfo, RuleSetSchema, RuleSetTestResult, RuleSetDebugResult, TraceEntry, TriggerDefInfo, ModelRulesInfo, } from "./api/ruleSetsApi";
|
|
43
|
+
export type { RuleSetInfo, RuleSetSchema, RuleSetTestResult, RuleSetDebugResult, TraceEntry, TriggerDefInfo, ModelRulesInfo, PathDeclaration, RuleLoads, RuleExpression, CategoryRules, } from "./api/ruleSetsApi";
|
|
44
44
|
export type { GroupTypeConfigInfo } from "./api/groupTypeConfigsApi";
|
|
45
45
|
export type { CollectionTypeConfigInfo, CreateCollectionTypeConfigParams, UpdateCollectionTypeConfigParams, } from "./api/collectionTypeConfigsApi";
|
|
46
|
-
export type { DatabaseTypeConfigInfo, CreateDatabaseTypeConfigParams, UpdateDatabaseTypeConfigParams, } from "./api/databaseTypeConfigsApi";
|
|
46
|
+
export type { DatabaseTypeConfigInfo, CreateDatabaseTypeConfigParams, UpdateDatabaseTypeConfigParams, DeclaredMetadataManifest, DeclaredManifestPath, DeclaredManifestPathFrom, DeclaredManifestPathRootFrom, } from "./api/databaseTypeConfigsApi";
|
|
47
47
|
export type { AppInvitationInfo, InvitationQuota, CreateInvitationParams, InvitationListResult, DeferredGrant, DeferredDocumentGrant, DeferredGroupGrant, DeferredGrantListResult, DeferredGrantRevokeResult, AcceptInviteResult, } from "./api/invitationsApi";
|
|
48
48
|
export type { DoDb, DOClientEngine, ModelIdentifier, ModelFieldInfo, SaveOptions } from "js-bao/client";
|
|
49
49
|
export type { DiscoveredSchema, DiscoveredModel, DiscoveredField, DiscoveredConstraint, DiscoveredRelationship } from "js-bao";
|
|
@@ -97,15 +97,15 @@ export interface AnalyticsAutoEventsOptions {
|
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
export type { GeminiRole, GeminiContentPart, GeminiMessage, GeminiPromptOptions, GeminiGenerateOptions, GeminiGenerateResult, GeminiModelSummary, GeminiStructuredOutput, GeminiGenerateRawOptions, } from "./api/geminiApi";
|
|
100
|
-
export interface IntegrationCallRequest {
|
|
100
|
+
export interface IntegrationCallRequest<TReq = unknown> {
|
|
101
101
|
integrationKey: string;
|
|
102
102
|
method?: string;
|
|
103
103
|
path?: string;
|
|
104
104
|
query?: Record<string, any>;
|
|
105
105
|
headers?: Record<string, string>;
|
|
106
|
-
body?:
|
|
106
|
+
body?: TReq;
|
|
107
107
|
}
|
|
108
|
-
export interface IntegrationCallResponse<T =
|
|
108
|
+
export interface IntegrationCallResponse<T = unknown> {
|
|
109
109
|
status: number;
|
|
110
110
|
headers: Record<string, string>;
|
|
111
111
|
body: T;
|
|
@@ -114,7 +114,16 @@ export interface IntegrationCallResponse<T = any> {
|
|
|
114
114
|
errorCode?: string;
|
|
115
115
|
}
|
|
116
116
|
export interface IntegrationsAPI {
|
|
117
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Call an integration's proxy endpoint.
|
|
119
|
+
*
|
|
120
|
+
* The optional generics are additive (issue #1542). `TRes` types the response
|
|
121
|
+
* body and is **first** to preserve the meaning of existing single-arg
|
|
122
|
+
* `call<MyResponse>()` call sites; `TReq` types the request `body`. Both
|
|
123
|
+
* default to `unknown` (issue #1540 typing hygiene), so untyped callers must
|
|
124
|
+
* narrow before reading arbitrary properties.
|
|
125
|
+
*/
|
|
126
|
+
call<TRes = unknown, TReq = unknown>(request: IntegrationCallRequest<TReq>): Promise<IntegrationCallResponse<TRes>>;
|
|
118
127
|
}
|
|
119
128
|
export interface WorkflowsAPI {
|
|
120
129
|
/**
|
|
@@ -160,7 +169,7 @@ export interface WorkflowsAPI {
|
|
|
160
169
|
* are unaffected. The generated per-workflow `<key>(client)` factory supplies
|
|
161
170
|
* it from the workflow's `outputSchema`.
|
|
162
171
|
*/
|
|
163
|
-
getStatus<O =
|
|
172
|
+
getStatus<O = unknown>(options: GetWorkflowStatusOptions): Promise<WorkflowStatusResult<O>>;
|
|
164
173
|
/**
|
|
165
174
|
* Wait for an async workflow run to reach a terminal state, then resolve
|
|
166
175
|
* `{ status, output?, error? }` (#1443).
|
|
@@ -188,10 +197,10 @@ export interface WorkflowsAPI {
|
|
|
188
197
|
*
|
|
189
198
|
* The optional generic `O` types the result envelope's `output` (issue #1512)
|
|
190
199
|
* — a terminated run can still carry partial output. Additive, defaults to
|
|
191
|
-
* `any`.
|
|
192
|
-
*
|
|
200
|
+
* `any`. The generated per-workflow factory emits a `terminate` member that
|
|
201
|
+
* binds this generic to the workflow's `<Key>Output` (issue #1543).
|
|
193
202
|
*/
|
|
194
|
-
terminate<O =
|
|
203
|
+
terminate<O = unknown>(options: TerminateWorkflowOptions): Promise<WorkflowStatusResult<O>>;
|
|
195
204
|
/** List workflow runs for the current user */
|
|
196
205
|
listRuns(options?: ListWorkflowRunsOptions): Promise<ListWorkflowRunsResult>;
|
|
197
206
|
/** List step runs for a specific workflow run. The run must have been started by the current user. */
|
|
@@ -202,28 +211,48 @@ export interface WorkflowsAPI {
|
|
|
202
211
|
confirmApply(options: ConfirmApplyOptions): Promise<ConfirmApplyResult>;
|
|
203
212
|
/** Release a claimed workflow apply so another client can retry. Called automatically on apply handler failure. */
|
|
204
213
|
releaseApply(options: ReleaseApplyOptions): Promise<ReleaseApplyResult>;
|
|
205
|
-
/**
|
|
214
|
+
/**
|
|
215
|
+
* Fetch pending workflow applies for a document.
|
|
216
|
+
*
|
|
217
|
+
* Returns a concrete `PendingApply[]` (issue #1542) instead of the former
|
|
218
|
+
* `any[]`. The server element carries no `output`, so there is no output
|
|
219
|
+
* generic here — the apply output is typed on `define`/`onApply<O>`, where it
|
|
220
|
+
* is actually delivered.
|
|
221
|
+
*/
|
|
206
222
|
getPendingApplies(options: {
|
|
207
223
|
contextDocId: string;
|
|
208
|
-
}): Promise<
|
|
209
|
-
/**
|
|
210
|
-
|
|
224
|
+
}): Promise<PendingApply[]>;
|
|
225
|
+
/**
|
|
226
|
+
* Define a workflow with its apply handler. Call once at app initialization
|
|
227
|
+
* so any client can handle apply.
|
|
228
|
+
*
|
|
229
|
+
* The optional generic `O` types the apply handler's `output` (issue #1542).
|
|
230
|
+
* It is additive and defaults to today's untyped `any`, so existing callers
|
|
231
|
+
* are unaffected.
|
|
232
|
+
*/
|
|
233
|
+
define<O = unknown>(workflowKey: string, options: WorkflowDefineOptions<O>): void;
|
|
211
234
|
}
|
|
212
235
|
export interface PromptsAPI {
|
|
213
|
-
/**
|
|
214
|
-
|
|
236
|
+
/**
|
|
237
|
+
* Execute a prompt by key and return the result.
|
|
238
|
+
*
|
|
239
|
+
* The optional generics are additive (issue #1542). `V` types the
|
|
240
|
+
* `variables` bag and `R` types `rawResponse`. Both default to today's
|
|
241
|
+
* untyped shapes, so existing callers are unaffected.
|
|
242
|
+
*/
|
|
243
|
+
execute<V extends object = Record<string, unknown>, R = unknown>(promptKey: string, options: ExecutePromptOptions<V>): Promise<ExecutePromptResult<R>>;
|
|
215
244
|
}
|
|
216
245
|
/** Options for executing a prompt */
|
|
217
|
-
export interface ExecutePromptOptions {
|
|
246
|
+
export interface ExecutePromptOptions<V extends object = Record<string, unknown>> {
|
|
218
247
|
/** Variables to pass to the prompt template */
|
|
219
|
-
variables:
|
|
248
|
+
variables: V;
|
|
220
249
|
/** Override the model specified in the prompt config */
|
|
221
250
|
modelOverride?: string;
|
|
222
251
|
/** Specific config ID to use (defaults to activeConfigId) */
|
|
223
252
|
configId?: string;
|
|
224
253
|
}
|
|
225
254
|
/** Result from executing a prompt */
|
|
226
|
-
export interface ExecutePromptResult {
|
|
255
|
+
export interface ExecutePromptResult<R = unknown> {
|
|
227
256
|
success: boolean;
|
|
228
257
|
output: string;
|
|
229
258
|
error?: string;
|
|
@@ -233,7 +262,7 @@ export interface ExecutePromptResult {
|
|
|
233
262
|
outputTokens?: number;
|
|
234
263
|
totalTokens?: number;
|
|
235
264
|
};
|
|
236
|
-
rawResponse:
|
|
265
|
+
rawResponse: R;
|
|
237
266
|
configId: string;
|
|
238
267
|
}
|
|
239
268
|
export interface JsBaoClientOptions {
|
|
@@ -345,18 +374,18 @@ interface DocumentClosedEvent {
|
|
|
345
374
|
}
|
|
346
375
|
export interface DocumentMetadataChangedEvent {
|
|
347
376
|
documentId: string;
|
|
348
|
-
metadata:
|
|
377
|
+
metadata: LocalMetadataEntry | null;
|
|
349
378
|
changedFields?: string[];
|
|
350
379
|
action?: "created" | "updated" | "evicted" | "deleted";
|
|
351
380
|
source?: "local" | "server" | "idb";
|
|
352
381
|
}
|
|
353
382
|
export interface MeUpdatedEvent {
|
|
354
|
-
value:
|
|
383
|
+
value: unknown;
|
|
355
384
|
updatedAt?: string;
|
|
356
385
|
source?: "server" | "cache" | string;
|
|
357
386
|
}
|
|
358
387
|
export interface MeUpdateFailedEvent {
|
|
359
|
-
error:
|
|
388
|
+
error: unknown;
|
|
360
389
|
}
|
|
361
390
|
export interface PermissionEvent {
|
|
362
391
|
documentId: string;
|
|
@@ -527,12 +556,12 @@ export interface WorkflowStatusEvent {
|
|
|
527
556
|
runKey: string;
|
|
528
557
|
runId: string;
|
|
529
558
|
status: "completed" | "failed" | "terminated";
|
|
530
|
-
output?:
|
|
559
|
+
output?: unknown;
|
|
531
560
|
error?: string;
|
|
532
561
|
contextDocId?: string;
|
|
533
562
|
needsApply?: boolean;
|
|
534
563
|
startedByUserId?: string;
|
|
535
|
-
meta?: Record<string,
|
|
564
|
+
meta?: Record<string, unknown>;
|
|
536
565
|
}
|
|
537
566
|
export interface WorkflowStartedEvent {
|
|
538
567
|
type: "workflowStarted";
|
|
@@ -542,7 +571,7 @@ export interface WorkflowStartedEvent {
|
|
|
542
571
|
runId: string;
|
|
543
572
|
instanceId: string;
|
|
544
573
|
contextDocId?: string;
|
|
545
|
-
meta?: Record<string,
|
|
574
|
+
meta?: Record<string, unknown>;
|
|
546
575
|
}
|
|
547
576
|
/** Options for synchronously running a workflow via `workflows.runSync` (#728). */
|
|
548
577
|
export interface RunSyncWorkflowOptions {
|
|
@@ -555,7 +584,7 @@ export interface RunSyncWorkflowOptions {
|
|
|
555
584
|
/** Document ID to associate the run with. Defaults to the user's root document. */
|
|
556
585
|
contextDocId?: string;
|
|
557
586
|
/** User-defined metadata attached to the run (max 1KB). Returned in listRuns and runSync envelope. */
|
|
558
|
-
meta?: Record<string,
|
|
587
|
+
meta?: Record<string, unknown>;
|
|
559
588
|
/**
|
|
560
589
|
* Hard wall-clock ceiling in milliseconds. Defaults to 5000. Capped
|
|
561
590
|
* server-side to 30000 (Workers CPU budget). When exceeded, the run
|
|
@@ -579,14 +608,20 @@ export interface RunSyncWorkflowResult<O = any> {
|
|
|
579
608
|
runId: string;
|
|
580
609
|
runKey: string;
|
|
581
610
|
/**
|
|
582
|
-
*
|
|
611
|
+
* Status from the run.
|
|
583
612
|
* - "completed" — workflow finished without error
|
|
584
613
|
* - "failed" — engine raised an error (see `error`)
|
|
585
614
|
* - "terminated" — caller-side AbortSignal fired mid-execution
|
|
586
615
|
* - "timeout" — server-side timeout ceiling tripped
|
|
587
616
|
* - "apply_pending" — workflow needs the client-side apply step
|
|
617
|
+
*
|
|
618
|
+
* On an idempotency hit or write-race loss (`existing: true`), runSync
|
|
619
|
+
* echoes the matched run's raw persisted `WorkflowRun.status`, which can
|
|
620
|
+
* still be transient — `"queued"`, `"running"`, or `"apply_claimed"` — so
|
|
621
|
+
* this is `WorkflowRunStatus` (the model's full set) plus the runSync-only
|
|
622
|
+
* `"timeout"` value.
|
|
588
623
|
*/
|
|
589
|
-
status:
|
|
624
|
+
status: WorkflowRunStatus | "timeout";
|
|
590
625
|
/** Final output of the workflow, when `status === "completed"`. */
|
|
591
626
|
output?: O;
|
|
592
627
|
/** Error message when `status === "failed"`. */
|
|
@@ -607,7 +642,7 @@ export interface StartWorkflowOptions {
|
|
|
607
642
|
/** Document ID to associate the run with */
|
|
608
643
|
contextDocId?: string;
|
|
609
644
|
/** User-defined metadata attached to the run (max 1KB). Returned in listRuns and getStatus. */
|
|
610
|
-
meta?: Record<string,
|
|
645
|
+
meta?: Record<string, unknown>;
|
|
611
646
|
/** If true, terminates any existing run with the same runKey and starts a new one */
|
|
612
647
|
forceRerun?: boolean;
|
|
613
648
|
}
|
|
@@ -616,7 +651,7 @@ export interface StartWorkflowResult {
|
|
|
616
651
|
runId: string;
|
|
617
652
|
runKey: string;
|
|
618
653
|
instanceId: string;
|
|
619
|
-
status:
|
|
654
|
+
status: WorkflowRunStatus;
|
|
620
655
|
/** True if this runKey already existed and the existing run was returned */
|
|
621
656
|
existing?: boolean;
|
|
622
657
|
}
|
|
@@ -672,7 +707,7 @@ export interface WorkflowRun {
|
|
|
672
707
|
* present in run responses (the server sends `errorMessage || null`). */
|
|
673
708
|
errorMessage?: string | null;
|
|
674
709
|
/** User-defined metadata (max 1KB) */
|
|
675
|
-
meta?: Record<string,
|
|
710
|
+
meta?: Record<string, unknown>;
|
|
676
711
|
}
|
|
677
712
|
/** Result from listing workflow runs */
|
|
678
713
|
export interface ListWorkflowRunsResult {
|
|
@@ -694,17 +729,17 @@ export interface WorkflowStepRunRecord {
|
|
|
694
729
|
/** completed | failed | skipped */
|
|
695
730
|
status: string;
|
|
696
731
|
/** Rendered step config (after template evaluation) */
|
|
697
|
-
config?:
|
|
732
|
+
config?: unknown;
|
|
698
733
|
/** Original step config before template rendering (for transform steps) */
|
|
699
|
-
rawConfig?:
|
|
734
|
+
rawConfig?: unknown;
|
|
700
735
|
/** Resolved input to the step */
|
|
701
|
-
input?:
|
|
736
|
+
input?: unknown;
|
|
702
737
|
/** Output from the step */
|
|
703
|
-
output?:
|
|
738
|
+
output?: unknown;
|
|
704
739
|
/** Error message if the step failed */
|
|
705
740
|
error?: string | null;
|
|
706
741
|
/** Structured error details (stack trace, cause chain) if the step failed */
|
|
707
|
-
errorDetails?:
|
|
742
|
+
errorDetails?: unknown;
|
|
708
743
|
startedAt?: string;
|
|
709
744
|
endedAt?: string;
|
|
710
745
|
durationMs?: number;
|
|
@@ -713,9 +748,9 @@ export interface WorkflowStepRunRecord {
|
|
|
713
748
|
totalTokens?: number;
|
|
714
749
|
retryCount?: number;
|
|
715
750
|
/** Snapshot of input and previous step outputs at the time this step ran */
|
|
716
|
-
context?:
|
|
751
|
+
context?: unknown;
|
|
717
752
|
/** Template warnings captured during step execution */
|
|
718
|
-
templateWarnings?:
|
|
753
|
+
templateWarnings?: unknown;
|
|
719
754
|
}
|
|
720
755
|
/** Result from listing step runs for a workflow run */
|
|
721
756
|
export interface ListWorkflowStepRunsResult {
|
|
@@ -793,20 +828,61 @@ export interface ReleaseApplyResult {
|
|
|
793
828
|
released: boolean;
|
|
794
829
|
reason?: string;
|
|
795
830
|
}
|
|
796
|
-
/**
|
|
797
|
-
|
|
831
|
+
/**
|
|
832
|
+
* Callback for applying a workflow result to a document. `O` types the
|
|
833
|
+
* workflow's `output` (issue #1542); it is additive and defaults to today's
|
|
834
|
+
* untyped `any`.
|
|
835
|
+
*/
|
|
836
|
+
type WorkflowApplyHandler<O = unknown> = (result: {
|
|
798
837
|
workflowKey: string;
|
|
799
838
|
runKey: string;
|
|
800
839
|
runId: string;
|
|
801
840
|
contextDocId?: string;
|
|
802
|
-
output:
|
|
841
|
+
output: O;
|
|
803
842
|
startedByUserId?: string;
|
|
804
843
|
meta?: Record<string, any>;
|
|
805
844
|
}) => void | Promise<void>;
|
|
845
|
+
/**
|
|
846
|
+
* One pending (or reclaimable) workflow apply, as returned by
|
|
847
|
+
* `workflows.getPendingApplies`. Concrete shape (issue #1542) mirroring the
|
|
848
|
+
* server element — it carries no `output`, so there is no output generic here.
|
|
849
|
+
*/
|
|
850
|
+
export interface PendingApply {
|
|
851
|
+
runId: string;
|
|
852
|
+
runKey: string;
|
|
853
|
+
workflowKey: string;
|
|
854
|
+
workflowId: string;
|
|
855
|
+
instanceId: string;
|
|
856
|
+
contextDocId: string;
|
|
857
|
+
/** "apply_pending", or "apply_claimed" for a run whose apply lease expired. */
|
|
858
|
+
status: string;
|
|
859
|
+
startedByUserId: string;
|
|
860
|
+
/**
|
|
861
|
+
* ISO timestamp the apply was claimed, or null once claimed and released.
|
|
862
|
+
* Absent (the key is omitted) for a run that has never been claimed, so this
|
|
863
|
+
* property is optional.
|
|
864
|
+
*/
|
|
865
|
+
claimedAt?: string | null;
|
|
866
|
+
/**
|
|
867
|
+
* Connection id that holds/held the apply claim, or null. Absent for a run
|
|
868
|
+
* that has never been claimed, so this property is optional.
|
|
869
|
+
*/
|
|
870
|
+
claimedBy?: string | null;
|
|
871
|
+
/** Apply-lease timeout in milliseconds. */
|
|
872
|
+
applyLeaseTimeoutMs: number;
|
|
873
|
+
/**
|
|
874
|
+
* Parsed workflow run metadata, or `null` when none was set. Typed as
|
|
875
|
+
* `unknown` because the server accepts and round-trips any JSON value here:
|
|
876
|
+
* `normalizeMeta` stores whatever was passed (object, array, string, number,
|
|
877
|
+
* boolean) and `parseMeta` returns that same shape. Narrow before use — do
|
|
878
|
+
* not assume an object.
|
|
879
|
+
*/
|
|
880
|
+
meta: unknown;
|
|
881
|
+
}
|
|
806
882
|
/** Options for defining a workflow via `workflows.define()` */
|
|
807
|
-
export interface WorkflowDefineOptions {
|
|
883
|
+
export interface WorkflowDefineOptions<O = unknown> {
|
|
808
884
|
/** Handler to apply workflow results to the document. Called automatically when this workflow completes with needsApply. */
|
|
809
|
-
onApply: WorkflowApplyHandler
|
|
885
|
+
onApply: WorkflowApplyHandler<O>;
|
|
810
886
|
}
|
|
811
887
|
/** Options for {@link JsBaoClient.waitForUserId}. */
|
|
812
888
|
export interface WaitForUserIdOptions {
|
|
@@ -904,11 +980,11 @@ export interface EvictAllLocalOptions {
|
|
|
904
980
|
}
|
|
905
981
|
export interface JsBaoEvents {
|
|
906
982
|
error: {
|
|
907
|
-
error:
|
|
983
|
+
error: unknown;
|
|
908
984
|
};
|
|
909
985
|
status: StatusChangedEvent;
|
|
910
986
|
networkMode: NetworkModeEvent;
|
|
911
|
-
auth:
|
|
987
|
+
auth: unknown;
|
|
912
988
|
"auth-success": {
|
|
913
989
|
token: string;
|
|
914
990
|
previousToken: string | null;
|
|
@@ -928,9 +1004,9 @@ export interface JsBaoEvents {
|
|
|
928
1004
|
"offlineAuth:renewed": OfflineAuthRenewedEvent;
|
|
929
1005
|
"offlineAuth:revoked": {};
|
|
930
1006
|
"offlineAuth:expiringSoon": OfflineAuthExpiringSoonEvent;
|
|
931
|
-
connection:
|
|
932
|
-
"connection-error":
|
|
933
|
-
"connection-close":
|
|
1007
|
+
connection: unknown;
|
|
1008
|
+
"connection-error": unknown;
|
|
1009
|
+
"connection-close": unknown;
|
|
934
1010
|
documentLoaded: DocumentLoadedEvent;
|
|
935
1011
|
documentClosed: DocumentClosedEvent;
|
|
936
1012
|
documentOpened: DocumentEvent;
|
|
@@ -953,8 +1029,8 @@ export interface JsBaoEvents {
|
|
|
953
1029
|
syncPerf: {
|
|
954
1030
|
type: "syncPerf";
|
|
955
1031
|
documentId: string;
|
|
956
|
-
timings: Record<string,
|
|
957
|
-
clientTimings?: Record<string,
|
|
1032
|
+
timings: Record<string, unknown>;
|
|
1033
|
+
clientTimings?: Record<string, unknown>;
|
|
958
1034
|
};
|
|
959
1035
|
"schema-discovered": SchemaDiscoveredEvent;
|
|
960
1036
|
}
|
|
@@ -965,7 +1041,7 @@ export interface SchemaDiscoveredEvent {
|
|
|
965
1041
|
}
|
|
966
1042
|
export interface AnalyticsClient {
|
|
967
1043
|
logEvent(event: AnalyticsEventInput): void;
|
|
968
|
-
logSnapshot(context?: Record<string,
|
|
1044
|
+
logSnapshot(context?: Record<string, unknown>): void;
|
|
969
1045
|
flush(): void;
|
|
970
1046
|
setPlanOverride(plan: string | null | undefined): void;
|
|
971
1047
|
setAppVersionOverride(version: string | null | undefined): void;
|
|
@@ -1373,6 +1449,23 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1373
1449
|
private claimWorkflowApply;
|
|
1374
1450
|
private releaseWorkflowApply;
|
|
1375
1451
|
private confirmWorkflowApply;
|
|
1452
|
+
/**
|
|
1453
|
+
* Whether a thrown confirm-apply error is worth retrying. Network failures
|
|
1454
|
+
* (unreachable server, refused connection, DNS failure, or an aborted
|
|
1455
|
+
* timeout — all surfaced as `JsBaoNetworkError`) and HTTP 5xx are transient,
|
|
1456
|
+
* so retrying the idempotent confirm may still succeed. Any other HTTP status
|
|
1457
|
+
* (4xx) is a definitive rejection and is not retried.
|
|
1458
|
+
*/
|
|
1459
|
+
private isRetryableConfirmError;
|
|
1460
|
+
/**
|
|
1461
|
+
* Retry the confirm POST on transient failures, bounded by both an attempt
|
|
1462
|
+
* count and a time budget that stays within the server's apply lease. Only
|
|
1463
|
+
* the confirm POST is retried here — the caller runs the user's onApply
|
|
1464
|
+
* handler exactly once, before invoking this, so retries never re-run it.
|
|
1465
|
+
* A `confirmed: false` result (a genuine claim loss) is returned normally,
|
|
1466
|
+
* not retried; the caller releases the claim in that case.
|
|
1467
|
+
*/
|
|
1468
|
+
private confirmWorkflowApplyWithRetry;
|
|
1376
1469
|
private getWorkflowPendingApplies;
|
|
1377
1470
|
private defineWorkflow;
|
|
1378
1471
|
private handleWorkflowApply;
|
|
@@ -1489,7 +1582,7 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1489
1582
|
* @param documentId - The document to set awareness for
|
|
1490
1583
|
* @param state - Arbitrary awareness data (cursor, selection, user info) to broadcast to collaborators
|
|
1491
1584
|
* @group Awareness */
|
|
1492
|
-
setAwareness(documentId: string, state:
|
|
1585
|
+
setAwareness<S = unknown>(documentId: string, state: S): void;
|
|
1493
1586
|
private getIndexedDbNames;
|
|
1494
1587
|
private doesIndexedDbExist;
|
|
1495
1588
|
/** Check if a document has IndexedDB persistence.
|
|
@@ -1597,11 +1690,11 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1597
1690
|
* Note: the server's wire field is named `metadata`; the local cache key is
|
|
1598
1691
|
* `docMetadata` to avoid colliding with the cache envelope's `metadata` key.
|
|
1599
1692
|
* @group Documents */
|
|
1600
|
-
updateLocalMetadata(documentId: string, updates: {
|
|
1693
|
+
updateLocalMetadata<M = unknown>(documentId: string, updates: {
|
|
1601
1694
|
title?: string;
|
|
1602
1695
|
tags?: string[];
|
|
1603
1696
|
thumbnailBlobId?: string | null;
|
|
1604
|
-
docMetadata?:
|
|
1697
|
+
docMetadata?: M | null;
|
|
1605
1698
|
}): Promise<void>;
|
|
1606
1699
|
private _updateSynced;
|
|
1607
1700
|
/** Open a document for real-time collaboration and sync.
|
|
@@ -1811,15 +1904,15 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1811
1904
|
* @param documentId - The document to set awareness for
|
|
1812
1905
|
* @param state - Arbitrary awareness data (cursor, selection, user info) to broadcast to collaborators
|
|
1813
1906
|
* @group Awareness */
|
|
1814
|
-
setLocalAwarenessState(documentId: string, state:
|
|
1907
|
+
setLocalAwarenessState<S = unknown>(documentId: string, state: S): void;
|
|
1815
1908
|
/** Get the local user's current awareness state for a document.
|
|
1816
1909
|
* @param documentId - The document to get local awareness for
|
|
1817
1910
|
* @group Awareness */
|
|
1818
|
-
getLocalAwarenessState(documentId: string):
|
|
1911
|
+
getLocalAwarenessState<S = unknown>(documentId: string): S | null;
|
|
1819
1912
|
/** Get all users' awareness states for a document.
|
|
1820
1913
|
* @param documentId - The document to get awareness states for
|
|
1821
1914
|
* @group Awareness */
|
|
1822
|
-
getAwarenessStates(documentId: string): Map<string,
|
|
1915
|
+
getAwarenessStates<S = unknown>(documentId: string): Map<string, S>;
|
|
1823
1916
|
/** Remove awareness states for specific clients and broadcast the removal to the server.
|
|
1824
1917
|
* @param documentId - The document to remove awareness from
|
|
1825
1918
|
* @param clientIds - Array of client IDs whose awareness states should be removed
|
|
@@ -2153,7 +2246,7 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
2153
2246
|
* @param options - Document creation options
|
|
2154
2247
|
* @group Documents */
|
|
2155
2248
|
createDocument(options: CreateDocumentOptions): Promise<{
|
|
2156
|
-
metadata:
|
|
2249
|
+
metadata: LocalMetadataEntry;
|
|
2157
2250
|
}>;
|
|
2158
2251
|
/** Retry committing a pending offline-created document to the server.
|
|
2159
2252
|
* @param documentId - The pending document to retry committing
|