@abloatai/ablo 0.7.0 → 0.9.0
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/CHANGELOG.md +72 -1
- package/README.md +80 -66
- package/dist/BaseSyncedStore.d.ts +73 -0
- package/dist/BaseSyncedStore.js +179 -5
- package/dist/Model.d.ts +42 -0
- package/dist/Model.js +103 -44
- package/dist/SyncEngineContext.d.ts +2 -1
- package/dist/SyncEngineContext.js +5 -3
- package/dist/agent/session.js +6 -5
- package/dist/ai-sdk/coordination-context.js +4 -0
- package/dist/ai-sdk/index.d.ts +56 -47
- package/dist/ai-sdk/index.js +56 -47
- package/dist/ai-sdk/intent-broadcast.d.ts +5 -0
- package/dist/ai-sdk/intent-broadcast.js +11 -4
- package/dist/ai-sdk/wrap.d.ts +14 -11
- package/dist/ai-sdk/wrap.js +11 -13
- package/dist/auth/credentialSource.d.ts +34 -0
- package/dist/auth/credentialSource.js +63 -0
- package/dist/auth/index.d.ts +2 -22
- package/dist/auth/index.js +26 -36
- package/dist/auth/schemas.d.ts +35 -0
- package/dist/auth/schemas.js +53 -0
- package/dist/client/Ablo.d.ts +259 -33
- package/dist/client/Ablo.js +276 -73
- package/dist/client/ApiClient.d.ts +52 -4
- package/dist/client/ApiClient.js +236 -66
- package/dist/client/auth.d.ts +21 -2
- package/dist/client/auth.js +77 -5
- package/dist/client/createInternalComponents.d.ts +2 -0
- package/dist/client/createInternalComponents.js +8 -1
- package/dist/client/createModelProxy.d.ts +187 -79
- package/dist/client/createModelProxy.js +203 -68
- package/dist/client/httpClient.d.ts +71 -0
- package/dist/client/httpClient.js +69 -0
- package/dist/client/identity.d.ts +2 -6
- package/dist/client/identity.js +63 -11
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +1 -0
- package/dist/client/registerDataSource.d.ts +19 -0
- package/dist/client/registerDataSource.js +59 -0
- package/dist/client/validateAbloOptions.d.ts +2 -1
- package/dist/client/validateAbloOptions.js +8 -7
- package/dist/core/DatabaseManager.js +30 -2
- package/dist/core/openIDBWithTimeout.d.ts +36 -0
- package/dist/core/openIDBWithTimeout.js +88 -1
- package/dist/errorCodes.d.ts +92 -1
- package/dist/errorCodes.js +139 -7
- package/dist/errors.d.ts +54 -3
- package/dist/errors.js +192 -44
- package/dist/index.d.ts +23 -10
- package/dist/index.js +21 -8
- package/dist/keys/index.d.ts +76 -0
- package/dist/keys/index.js +171 -0
- package/dist/mutators/UndoManager.d.ts +86 -50
- package/dist/mutators/UndoManager.js +129 -22
- package/dist/mutators/inverseOp.d.ts +129 -0
- package/dist/mutators/inverseOp.js +74 -0
- package/dist/mutators/readerActions.d.ts +1 -1
- package/dist/mutators/undoApply.d.ts +42 -0
- package/dist/mutators/undoApply.js +143 -0
- package/dist/query/client.d.ts +10 -9
- package/dist/query/client.js +22 -14
- package/dist/react/AbloProvider.d.ts +23 -101
- package/dist/react/AbloProvider.js +61 -103
- package/dist/react/ClientSideSuspense.d.ts +1 -1
- package/dist/react/DefaultFallback.d.ts +1 -1
- package/dist/react/SyncGroupProvider.d.ts +1 -1
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +3 -2
- package/dist/react/useAblo.d.ts +4 -4
- package/dist/react/useAblo.js +10 -5
- package/dist/react/useCurrentUserId.d.ts +1 -1
- package/dist/react/useCurrentUserId.js +1 -1
- package/dist/react/useMutators.js +19 -12
- package/dist/react/useReactive.js +16 -3
- package/dist/schema/ddl.d.ts +26 -3
- package/dist/schema/ddl.js +152 -4
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.js +12 -0
- package/dist/schema/model.d.ts +11 -0
- package/dist/schema/model.js +2 -0
- package/dist/schema/openapi.d.ts +28 -0
- package/dist/schema/openapi.js +118 -0
- package/dist/schema/plane.d.ts +23 -0
- package/dist/schema/plane.js +19 -0
- package/dist/schema/relation.d.ts +20 -0
- package/dist/schema/serialize.d.ts +7 -3
- package/dist/schema/serialize.js +6 -2
- package/dist/schema/sync-delta-row.d.ts +157 -0
- package/dist/schema/sync-delta-row.js +102 -0
- package/dist/schema/sync-delta-wire.d.ts +180 -0
- package/dist/schema/sync-delta-wire.js +102 -0
- package/dist/server/adapter.d.ts +156 -0
- package/dist/server/adapter.js +19 -0
- package/dist/server/commit.d.ts +82 -0
- package/dist/server/commit.js +1 -0
- package/dist/server/index.d.ts +14 -0
- package/dist/server/index.js +1 -0
- package/dist/server/next.d.ts +51 -0
- package/dist/server/next.js +47 -0
- package/dist/server/read-config.d.ts +60 -0
- package/dist/server/read-config.js +8 -0
- package/dist/server/storage-mode.d.ts +17 -0
- package/dist/server/storage-mode.js +12 -0
- package/dist/source/adapter.d.ts +59 -0
- package/dist/source/adapter.js +19 -0
- package/dist/source/adapters/drizzle.d.ts +34 -0
- package/dist/source/adapters/drizzle.js +147 -0
- package/dist/source/adapters/memory.d.ts +12 -0
- package/dist/source/adapters/memory.js +114 -0
- package/dist/source/adapters/prisma.d.ts +57 -0
- package/dist/source/adapters/prisma.js +199 -0
- package/dist/source/conformance.d.ts +32 -0
- package/dist/source/conformance.js +134 -0
- package/dist/source/contract.d.ts +143 -0
- package/dist/source/contract.js +98 -0
- package/dist/source/index.d.ts +61 -10
- package/dist/source/index.js +98 -0
- package/dist/source/next.d.ts +33 -0
- package/dist/source/next.js +26 -0
- package/dist/sync/BootstrapHelper.d.ts +10 -0
- package/dist/sync/BootstrapHelper.js +56 -42
- package/dist/sync/ConnectionManager.d.ts +57 -1
- package/dist/sync/ConnectionManager.js +186 -11
- package/dist/sync/HydrationCoordinator.d.ts +93 -17
- package/dist/sync/HydrationCoordinator.js +241 -41
- package/dist/sync/NetworkProbe.d.ts +60 -18
- package/dist/sync/NetworkProbe.js +121 -23
- package/dist/sync/SyncWebSocket.d.ts +45 -70
- package/dist/sync/SyncWebSocket.js +113 -89
- package/dist/sync/createIntentStream.js +10 -1
- package/dist/sync/participants.js +5 -2
- package/dist/transactions/TransactionQueue.js +13 -1
- package/dist/types/streams.d.ts +9 -0
- package/dist/utils/mobx-setup.js +1 -0
- package/dist/webhooks/events.d.ts +38 -0
- package/dist/webhooks/events.js +40 -0
- package/dist/webhooks/index.d.ts +10 -0
- package/dist/webhooks/index.js +10 -0
- package/dist/wire/errorEnvelope.d.ts +34 -0
- package/dist/wire/errorEnvelope.js +86 -0
- package/dist/wire/frames.d.ts +119 -0
- package/dist/wire/frames.js +1 -0
- package/dist/wire/index.d.ts +24 -0
- package/dist/wire/index.js +21 -0
- package/dist/wire/listEnvelope.d.ts +45 -0
- package/dist/wire/listEnvelope.js +17 -0
- package/docs/api-keys.md +5 -5
- package/docs/api.md +125 -65
- package/docs/audit.md +16 -9
- package/docs/cli.md +57 -47
- package/docs/client-behavior.md +54 -40
- package/docs/coordination.md +66 -80
- package/docs/data-sources.md +56 -34
- package/docs/examples/agent-human.md +74 -28
- package/docs/examples/ai-sdk-tool.md +29 -22
- package/docs/examples/existing-python-backend.md +41 -26
- package/docs/examples/nextjs.md +32 -17
- package/docs/examples/scoped-agent.md +43 -28
- package/docs/examples/server-agent.md +40 -15
- package/docs/guarantees.md +38 -27
- package/docs/identity.md +65 -59
- package/docs/index.md +30 -19
- package/docs/integration-guide.md +78 -78
- package/docs/interaction-model.md +43 -35
- package/docs/mcp/claude-code.md +11 -19
- package/docs/mcp/cursor.md +7 -25
- package/docs/mcp/windsurf.md +7 -20
- package/docs/mcp.md +103 -26
- package/docs/quickstart.md +63 -61
- package/docs/react.md +24 -16
- package/docs/roadmap.md +13 -13
- package/docs/schema-contract.md +111 -0
- package/docs/the-loop.md +21 -0
- package/examples/README.md +8 -4
- package/examples/data-source/README.md +10 -7
- package/examples/data-source/customer-server.ts +27 -25
- package/examples/data-source/run.ts +4 -3
- package/examples/quickstart.ts +1 -1
- package/llms.txt +55 -21
- package/package.json +48 -3
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
* testable in isolation and the constructor doesn't carry it.
|
|
8
8
|
*
|
|
9
9
|
* Each schema model gets one `ModelOperations<T, CreateInput>` —
|
|
10
|
-
* exposes `retrieve
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* `
|
|
10
|
+
* exposes the async server reads `retrieve` / `list`, the synchronous
|
|
11
|
+
* local-graph snapshots `get` / `getAll` / `getCount`, the writes
|
|
12
|
+
* `create` / `update` / `delete`, the coordination namespace `claim`
|
|
13
|
+
* (`claim({ id })` plus `claim.state` / `claim.queue` / `claim.release` /
|
|
14
|
+
* `claim.reorder`), and `onChange`. The factory returns a plain object; the
|
|
15
|
+
* client assembles the `ablo.<model>` lookup table from these.
|
|
14
16
|
*/
|
|
15
17
|
import type { MutationOptions } from '../interfaces/index.js';
|
|
16
18
|
import type { ModelRegistry } from '../ModelRegistry.js';
|
|
@@ -19,7 +21,7 @@ import type { SyncClient } from '../SyncClient.js';
|
|
|
19
21
|
import type { HydrationCoordinator } from '../sync/HydrationCoordinator.js';
|
|
20
22
|
import type { LoadWhere } from '../query/types.js';
|
|
21
23
|
import { ModelScope } from '../types/index.js';
|
|
22
|
-
import type { Duration, Intent, IntentWaitOptions, Snapshot } from '../types/streams.js';
|
|
24
|
+
import type { Duration, Intent, IntentWaitOptions, Snapshot, TargetRange } from '../types/streams.js';
|
|
23
25
|
export interface ModelClientMeta {
|
|
24
26
|
readonly key: string;
|
|
25
27
|
readonly typename: string;
|
|
@@ -48,7 +50,7 @@ export interface ModelLoadOptions<T> {
|
|
|
48
50
|
* - tuple form: `[['name', 'ILIKE', '%Goldman%']]` for operators
|
|
49
51
|
*
|
|
50
52
|
* See `LoadWhere<T>` in `query/types.ts`. For OR semantics, run two
|
|
51
|
-
* `
|
|
53
|
+
* `list()` calls and union — the wire protocol is AND-only.
|
|
52
54
|
*/
|
|
53
55
|
where?: LoadWhere<T>;
|
|
54
56
|
orderBy?: {
|
|
@@ -68,6 +70,9 @@ export interface ModelLoadOptions<T> {
|
|
|
68
70
|
*/
|
|
69
71
|
expand?: readonly string[];
|
|
70
72
|
}
|
|
73
|
+
/** Options for the single-row async server read `retrieve({ id })`. A subset of
|
|
74
|
+
* {@link ModelLoadOptions} — `where`/`limit`/`orderBy` are fixed by the id. */
|
|
75
|
+
export type ModelRetrieveOptions = Pick<ModelLoadOptions<unknown>, 'type' | 'expand'>;
|
|
71
76
|
export interface IntentLeaseHandle {
|
|
72
77
|
readonly id: string;
|
|
73
78
|
release(): Promise<void>;
|
|
@@ -79,6 +84,9 @@ export interface ModelCollaboration<T> {
|
|
|
79
84
|
model: string;
|
|
80
85
|
id: string;
|
|
81
86
|
field?: string;
|
|
87
|
+
path?: string;
|
|
88
|
+
range?: TargetRange;
|
|
89
|
+
meta?: Record<string, unknown>;
|
|
82
90
|
};
|
|
83
91
|
action: string;
|
|
84
92
|
ttl?: Duration;
|
|
@@ -134,12 +142,19 @@ export interface ModelCollaboration<T> {
|
|
|
134
142
|
*/
|
|
135
143
|
readonly selfParticipantId: string;
|
|
136
144
|
}
|
|
137
|
-
|
|
138
|
-
export interface ClaimOptions {
|
|
145
|
+
export interface ClaimTargetOptions<T = Record<string, unknown>> {
|
|
139
146
|
/** Phase shown to observers while held. Defaults to `'editing'`. */
|
|
140
147
|
action?: string;
|
|
148
|
+
/** Peer-visible explanation of the work being performed. */
|
|
149
|
+
description?: string;
|
|
141
150
|
/** Field-level target, for fine-grained claimed-state badges. */
|
|
142
151
|
field?: string;
|
|
152
|
+
/** Optional path for document/file-like targets. */
|
|
153
|
+
path?: string;
|
|
154
|
+
/** Optional range for document/file-like targets. */
|
|
155
|
+
range?: TargetRange;
|
|
156
|
+
/** App-defined structured metadata. */
|
|
157
|
+
meta?: Record<string, unknown>;
|
|
143
158
|
/** Crash-cleanup TTL — the claim auto-releases if the holder dies. */
|
|
144
159
|
ttl?: Duration;
|
|
145
160
|
/**
|
|
@@ -159,106 +174,199 @@ export interface ClaimOptions {
|
|
|
159
174
|
*/
|
|
160
175
|
maxQueueDepth?: number;
|
|
161
176
|
}
|
|
177
|
+
/** Options for `claim({ id, ... })`. */
|
|
178
|
+
export interface ClaimParams<T = Record<string, unknown>> extends ClaimTargetOptions<T> {
|
|
179
|
+
readonly id: string;
|
|
180
|
+
}
|
|
181
|
+
export interface ClaimLookupParams<T = Record<string, unknown>> {
|
|
182
|
+
readonly id: string;
|
|
183
|
+
readonly field?: string;
|
|
184
|
+
}
|
|
185
|
+
export interface ClaimReorderParams<T = Record<string, unknown>> extends ClaimLookupParams<T> {
|
|
186
|
+
readonly order: readonly Intent[];
|
|
187
|
+
}
|
|
162
188
|
/**
|
|
163
|
-
* A
|
|
189
|
+
* A claim handle: the held entity data plus an explicit release hook, so
|
|
164
190
|
*
|
|
165
191
|
* ```ts
|
|
166
|
-
* await ablo.weatherReports.claim(
|
|
167
|
-
*
|
|
192
|
+
* const claim = await ablo.weatherReports.claim({
|
|
193
|
+
* id: 'report_stockholm',
|
|
194
|
+
* action: 'forecasting',
|
|
195
|
+
* description: 'Fetching current weather before writing the forecast.',
|
|
168
196
|
* });
|
|
197
|
+
* try {
|
|
198
|
+
* await ablo.weatherReports.update({
|
|
199
|
+
* id: claim.target.id,
|
|
200
|
+
* data: { status: 'ready' },
|
|
201
|
+
* claim,
|
|
202
|
+
* });
|
|
203
|
+
* } finally {
|
|
204
|
+
* await claim.release();
|
|
205
|
+
* }
|
|
169
206
|
* ```
|
|
170
207
|
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
208
|
+
* `data` is a snapshot taken after the lease is held. Write through the flat
|
|
209
|
+
* `ablo.<model>.update({ id, data, claim })` verb — the handle carries the
|
|
210
|
+
* lease id and snapshot watermark for attribution + stale protection.
|
|
174
211
|
*/
|
|
175
|
-
export
|
|
212
|
+
export interface ClaimHandle<T = Record<string, unknown>> extends AsyncDisposable {
|
|
213
|
+
readonly object: 'claim';
|
|
214
|
+
readonly claimId: string;
|
|
215
|
+
readonly target: {
|
|
216
|
+
readonly model: string;
|
|
217
|
+
readonly id: string;
|
|
218
|
+
readonly field?: string;
|
|
219
|
+
readonly path?: string;
|
|
220
|
+
readonly range?: TargetRange;
|
|
221
|
+
readonly meta?: Record<string, unknown>;
|
|
222
|
+
};
|
|
223
|
+
readonly action: string;
|
|
224
|
+
readonly description?: string;
|
|
225
|
+
readonly data: T;
|
|
226
|
+
release(): Promise<void>;
|
|
227
|
+
revoke(): void;
|
|
228
|
+
}
|
|
229
|
+
export type ClaimOptions<T = Record<string, unknown>> = ClaimTargetOptions<T>;
|
|
230
|
+
/**
|
|
231
|
+
* The coordination surface for a model, exposed as a callable namespace.
|
|
232
|
+
*
|
|
233
|
+
* Most callers do not need this namespace directly. Put `claim: { ... }` on a
|
|
234
|
+
* write and the SDK acquires/releases around that one mutation:
|
|
235
|
+
*
|
|
236
|
+
* ```ts
|
|
237
|
+
* await ablo.tasks.update({
|
|
238
|
+
* id,
|
|
239
|
+
* data: { title },
|
|
240
|
+
* claim: {
|
|
241
|
+
* field: 'title',
|
|
242
|
+
* action: 'renaming',
|
|
243
|
+
* description: 'Renaming the task to match the project brief.',
|
|
244
|
+
* },
|
|
245
|
+
* });
|
|
246
|
+
* ```
|
|
247
|
+
*
|
|
248
|
+
* Use `claim({ id, ... })` when a tool spans multiple writes and needs one
|
|
249
|
+
* handle. `state`, `queue`, and `reorder` are coordination reads/scheduler
|
|
250
|
+
* controls for UI and operators.
|
|
251
|
+
*/
|
|
252
|
+
export interface ClaimApi<T> {
|
|
253
|
+
/** Take a claim and get an explicit held-work handle back. */
|
|
254
|
+
(params: ClaimParams<T>): Promise<ClaimHandle<T>>;
|
|
255
|
+
/**
|
|
256
|
+
* Current holder for a row, or `null` when free. Use this for UI badges and
|
|
257
|
+
* preflight checks, not for the normal write path.
|
|
258
|
+
*/
|
|
259
|
+
state(params: ClaimLookupParams<T>): Intent | null;
|
|
260
|
+
/**
|
|
261
|
+
* FIFO wait line behind the current holder. Advanced: useful for operator
|
|
262
|
+
* UIs and schedulers.
|
|
263
|
+
*/
|
|
264
|
+
queue(params: ClaimLookupParams<T>): {
|
|
265
|
+
readonly object: 'list';
|
|
266
|
+
readonly data: readonly Intent[];
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Re-rank the wait line. Advanced and permission-gated.
|
|
270
|
+
*/
|
|
271
|
+
reorder(params: ClaimReorderParams<T>): void;
|
|
272
|
+
/** Release a manual claim handle early. Single-write claims auto-release. */
|
|
273
|
+
release(params: ClaimLookupParams<T> | ClaimHandle<T>): Promise<void>;
|
|
274
|
+
}
|
|
275
|
+
export interface ModelRetrieveParams extends ModelRetrieveOptions {
|
|
276
|
+
readonly id: string;
|
|
277
|
+
}
|
|
278
|
+
export interface ModelCreateParams<T, CreateInput> extends MutationOptions {
|
|
279
|
+
readonly data: CreateInput;
|
|
280
|
+
readonly id?: string | null;
|
|
281
|
+
readonly claim?: ClaimHandle<T> | ClaimTargetOptions<T> | null;
|
|
282
|
+
}
|
|
283
|
+
export interface ModelUpdateParams<T> extends MutationOptions {
|
|
284
|
+
readonly id: string;
|
|
285
|
+
readonly data: Partial<T>;
|
|
286
|
+
readonly claim?: ClaimHandle<T> | ClaimTargetOptions<T> | null;
|
|
287
|
+
}
|
|
288
|
+
export interface ModelDeleteParams<T> extends MutationOptions {
|
|
289
|
+
readonly id: string;
|
|
290
|
+
readonly claim?: ClaimHandle<T> | ClaimTargetOptions<T> | null;
|
|
291
|
+
}
|
|
176
292
|
export interface ModelOperations<T, CreateInput> {
|
|
177
293
|
/**
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
294
|
+
* Read a single entity by id from the **server** — async. Resolves through
|
|
295
|
+
* the 3-tier lookup (local pool → IndexedDB → network `POST /sync/query`)
|
|
296
|
+
* and lands the row in the local graph. Resolves to `undefined` when no
|
|
297
|
+
* such row exists.
|
|
298
|
+
*
|
|
299
|
+
* This is the default "get me this entity" read and the one hosted /
|
|
300
|
+
* stateless callers want, since their local graph starts empty. For a
|
|
301
|
+
* synchronous read of an already-warm graph (a React selector) use
|
|
302
|
+
* `get(id)`.
|
|
181
303
|
*
|
|
182
|
-
* Mirrors `stripe.customers.retrieve(id)
|
|
304
|
+
* Mirrors `stripe.customers.retrieve({ id })` — network-backed.
|
|
183
305
|
*/
|
|
184
|
-
retrieve(
|
|
306
|
+
retrieve(params: ModelRetrieveParams): Promise<T | undefined>;
|
|
185
307
|
/**
|
|
186
|
-
* List entities matching a filter from the
|
|
187
|
-
*
|
|
308
|
+
* List entities matching a filter from the **server** — async. Same 3-tier
|
|
309
|
+
* lookup + graph hydration as `retrieve`; single-flight deduped. Returns the
|
|
310
|
+
* matched rows.
|
|
188
311
|
*
|
|
189
|
-
* Mirrors `stripe.customers.list({...})
|
|
312
|
+
* Mirrors `stripe.customers.list({...})` — network-backed. For a synchronous
|
|
313
|
+
* read of the local graph use `getAll(...)`.
|
|
314
|
+
*/
|
|
315
|
+
list(options?: ModelLoadOptions<T>): Promise<T[]>;
|
|
316
|
+
/**
|
|
317
|
+
* Synchronous snapshot of a single entity from the **local graph** — no
|
|
318
|
+
* network. Returns `undefined` when the row isn't resident (cold hosted
|
|
319
|
+
* client, or a `lazy` model not yet loaded). Pairs with reactive selectors:
|
|
320
|
+
* `useAblo((ablo) => ablo.<model>.get(id))`.
|
|
321
|
+
*/
|
|
322
|
+
get(id: string): T | undefined;
|
|
323
|
+
/**
|
|
324
|
+
* Synchronous snapshot of a filtered collection from the **local graph** —
|
|
325
|
+
* no network round-trip. Empty until `retrieve`/`list`/bootstrap has warmed
|
|
326
|
+
* the graph.
|
|
190
327
|
*/
|
|
191
|
-
|
|
192
|
-
/** Count entities
|
|
193
|
-
|
|
328
|
+
getAll(options?: ModelListOptions<T>): T[];
|
|
329
|
+
/** Count entities in the **local graph** (synchronous, no network). */
|
|
330
|
+
getCount(options?: ModelCountOptions<T>): number;
|
|
194
331
|
/**
|
|
195
332
|
* Create a new entity — **optimistic, offline-first**. Resolves once
|
|
196
333
|
* the mutation is queued locally, not when the server confirms.
|
|
197
334
|
* Server rejection rolls back automatically; watch `sync.syncStatus`.
|
|
198
335
|
*/
|
|
199
|
-
create(
|
|
336
|
+
create(params: ModelCreateParams<T, CreateInput>): Promise<T>;
|
|
200
337
|
/** Update an entity by id — optimistic, offline-first (see `create`). */
|
|
201
|
-
update(
|
|
338
|
+
update(params: ModelUpdateParams<T>): Promise<T>;
|
|
202
339
|
/** Delete an entity by id — optimistic, offline-first (see `create`). */
|
|
203
|
-
delete(
|
|
340
|
+
delete(params: ModelDeleteParams<T>): Promise<void>;
|
|
204
341
|
/**
|
|
205
|
-
* Claim a row so other writers wait or are rejected until you're done
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
* form is also available for wider lexical scopes.
|
|
342
|
+
* Claim a row so other writers wait or are rejected until you're done, and
|
|
343
|
+
* inspect or manage that coordination through the same namespace. Call it to
|
|
344
|
+
* take a claim handle; reach for its members to observe and steer the wait line:
|
|
209
345
|
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* });
|
|
215
|
-
* ```
|
|
216
|
-
*/
|
|
217
|
-
claim(id: string, options?: ClaimOptions): Promise<ClaimedRow<T>>;
|
|
218
|
-
claim<R>(id: string, work: (row: ClaimedRow<T>) => Promise<R> | R, options?: ClaimOptions): Promise<R>;
|
|
219
|
-
/**
|
|
220
|
-
* Read who's coordinating on a row — the current holder (who, phase,
|
|
221
|
-
* until when), or `null` when free. Synchronous and reactive; for
|
|
222
|
-
* observers/UI. Never blocks.
|
|
223
|
-
*/
|
|
224
|
-
claimState(id: string): Intent | null;
|
|
225
|
-
/**
|
|
226
|
-
* The wait queue on a row — who's lined up behind the holder and what each
|
|
227
|
-
* intends. Reactive snapshot (synced from the server, like `activity`);
|
|
228
|
-
* returns a Stripe-style list envelope, FIFO order, empty when no one waits.
|
|
346
|
+
* - `claim.state({ id })` — who holds the row now, or `null` when free
|
|
347
|
+
* - `claim.queue({ id })` — who's lined up behind the holder
|
|
348
|
+
* - `claim.release({ id })` — drop a claim early (usually implicit on scope exit)
|
|
349
|
+
* - `claim.reorder({ id, order })` — re-rank the wait line
|
|
229
350
|
*
|
|
230
351
|
* ```ts
|
|
231
|
-
* const
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
* `intent.reorder` capability), so it's fire-and-forget — the new order
|
|
244
|
-
* arrives reactively through `queue(id)`.
|
|
352
|
+
* const claim = await ablo.weatherReports.claim({
|
|
353
|
+
* id: 'report_stockholm',
|
|
354
|
+
* action: 'forecasting',
|
|
355
|
+
* description: 'Fetching fresh weather before updating the report.',
|
|
356
|
+
* });
|
|
357
|
+
* const weather = await getWeather(claim.data.location);
|
|
358
|
+
* await ablo.weatherReports.update({
|
|
359
|
+
* id: claim.target.id,
|
|
360
|
+
* data: { forecast: weather },
|
|
361
|
+
* claim,
|
|
362
|
+
* });
|
|
363
|
+
* await claim.release();
|
|
245
364
|
*
|
|
246
|
-
*
|
|
247
|
-
* const { data } = ablo.decks.queue('deck_1');
|
|
248
|
-
* ablo.decks.reorder('deck_1', [data[2], data[0], data[1]]); // promote #2
|
|
365
|
+
* const holder = ablo.weatherReports.claim.state({ id: 'report_stockholm' });
|
|
249
366
|
* ```
|
|
250
367
|
*/
|
|
251
|
-
|
|
252
|
-
/** Release a claim you hold early. Usually implicit (scope exit). */
|
|
253
|
-
release(id: string): Promise<void>;
|
|
368
|
+
claim: ClaimApi<T>;
|
|
254
369
|
/** Listen for changes (callback called on every change). */
|
|
255
370
|
onChange(callback: (entities: T[]) => void, options?: ModelListOptions<T>): () => void;
|
|
256
|
-
/**
|
|
257
|
-
* Load matching rows into the local graph if they are not already
|
|
258
|
-
* present. Single-flight: concurrent calls with the same args share
|
|
259
|
-
* one in-flight request. Default `type: 'complete'` waits for the
|
|
260
|
-
* server; `type: 'unknown'` returns local + refreshes async.
|
|
261
|
-
*/
|
|
262
|
-
load(options?: ModelLoadOptions<T>): Promise<T[]>;
|
|
263
371
|
}
|
|
264
372
|
export declare function createModelProxy<T, C>(schemaKey: string, registeredModelName: string, objectPool: ObjectPool, syncClient: SyncClient, registry: ModelRegistry, hydration: HydrationCoordinator, collaboration?: ModelCollaboration<T>): ModelOperations<T, C>;
|