@abloatai/ablo 0.20.0 → 0.20.2
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 +12 -0
- package/dist/client/Ablo.d.ts +3 -3
- package/dist/client/createModelProxy.d.ts +6 -6
- package/dist/index.d.ts +1 -1
- package/dist/types/streams.d.ts +10 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.20.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Extend the `HeldClaim` return type to the HTTP transport. 0.20.1 fixed `await using` on the WebSocket client's `claim()` but missed the stateless HTTP client (`HttpClaimApi`) used by server-side agents, which still returned the looser `Claim<T>`. Both transports' `claim()` now return `HeldClaim<T>`, so `await using held = await ablo.<model>.claim(...)` typechecks regardless of transport.
|
|
8
|
+
|
|
9
|
+
## 0.20.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Fix `await using held = await ablo.<model>.claim(...)` failing to typecheck. `claim()` now returns a `HeldClaim<T>` — a `Claim<T>` with `data`, `release`, `revoke`, and the async disposer made `Required` (they're optional on the base `Claim<T>`, which also models observed peer claims that lack them). A held claim is therefore assignable to `AsyncDisposable`, so the `await using` auto-release pattern compiles. Observed claim surfaces still return the looser `Claim<T>`. `HeldClaim` is exported.
|
|
14
|
+
|
|
3
15
|
## 0.20.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/client/Ablo.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ import type { SyncWebSocket } from '../sync/SyncWebSocket.js';
|
|
|
29
29
|
import type { SyncGroupInput } from '../schema/roles.js';
|
|
30
30
|
import { type SyncStatus } from '../BaseSyncedStore.js';
|
|
31
31
|
import type { ClaimStream, ClaimWaitOptions, PresenceStream, Snapshot } from '../types/streams.js';
|
|
32
|
-
import type { Claim, Duration } from '../types/streams.js';
|
|
32
|
+
import type { Claim, HeldClaim, Duration } from '../types/streams.js';
|
|
33
33
|
import { type AbloApi, type AbloApiClientOptions, type AbloApiClaims } from './ApiClient.js';
|
|
34
34
|
import { type AbloHttpClient, type AbloHttpClientOptions } from './httpClient.js';
|
|
35
35
|
/**
|
|
@@ -404,7 +404,7 @@ export interface InternalAbloOptions<S extends SchemaRecord = SchemaRecord> {
|
|
|
404
404
|
* `create({ data })` / `update({ id, data })` / `delete({ id })` — writes
|
|
405
405
|
* `claim({ id })` — durable claim handle for coordinated writes
|
|
406
406
|
*/
|
|
407
|
-
export type { LocalCountOptions, LocalReadOptions, ModelListScope, ServerReadOptions, ModelRetrieveParams, ModelCreateParams, ModelUpdateParams, ModelDeleteParams, ClaimOptions, ClaimParams, ClaimLookupParams, ClaimReorderParams, Claim, ModelOperations, } from './createModelProxy.js';
|
|
407
|
+
export type { LocalCountOptions, LocalReadOptions, ModelListScope, ServerReadOptions, ModelRetrieveParams, ModelCreateParams, ModelUpdateParams, ModelDeleteParams, ClaimOptions, ClaimParams, ClaimLookupParams, ClaimReorderParams, Claim, HeldClaim, ModelOperations, } from './createModelProxy.js';
|
|
408
408
|
import type { ModelOperations, ClaimOptions, ClaimParams, ClaimReadApi, AwaitedClaimMethod, ServerReadOptions } from './createModelProxy.js';
|
|
409
409
|
export type ModelOperationAction = 'create' | 'update' | 'delete' | 'archive' | 'unarchive';
|
|
410
410
|
export type CommitWait = 'queued' | 'confirmed';
|
|
@@ -544,7 +544,7 @@ export interface ModelMutationOptions extends ClaimedOptions {
|
|
|
544
544
|
* wrapper that statelessness forces. `claim({ id })` is identical (already async
|
|
545
545
|
* on both); `state`/`queue`/`reorder`/`release` are the awaited form.
|
|
546
546
|
*/
|
|
547
|
-
export type HttpClaimApi<T = Record<string, unknown>> = ((params: ClaimParams<T>) => Promise<
|
|
547
|
+
export type HttpClaimApi<T = Record<string, unknown>> = ((params: ClaimParams<T>) => Promise<HeldClaim<T>>) & {
|
|
548
548
|
[K in keyof ClaimReadApi<T>]: AwaitedClaimMethod<ClaimReadApi<T>[K]>;
|
|
549
549
|
};
|
|
550
550
|
export interface ModelClient<T = Record<string, unknown>> {
|
|
@@ -22,7 +22,7 @@ import type { HydrationCoordinator } from '../sync/HydrationCoordinator.js';
|
|
|
22
22
|
import type { JoinedParticipant } from '../sync/participants.js';
|
|
23
23
|
import type { LoadWhere } from '../query/types.js';
|
|
24
24
|
import { ModelScope } from '../types/index.js';
|
|
25
|
-
import type { Duration, Claim, ClaimWaitOptions, Snapshot, TargetRange } from '../types/streams.js';
|
|
25
|
+
import type { Duration, Claim, HeldClaim, ClaimWaitOptions, Snapshot, TargetRange } from '../types/streams.js';
|
|
26
26
|
export interface ModelClientMeta {
|
|
27
27
|
readonly key: string;
|
|
28
28
|
readonly typename: string;
|
|
@@ -258,7 +258,7 @@ export interface ClaimReorderParams<T = Record<string, unknown>> extends ClaimLo
|
|
|
258
258
|
* `ablo.<model>.update({ id, data, claim })` verb — the handle carries the
|
|
259
259
|
* lease id and snapshot watermark for attribution + stale protection.
|
|
260
260
|
*/
|
|
261
|
-
export type { Claim };
|
|
261
|
+
export type { Claim, HeldClaim };
|
|
262
262
|
export type ClaimOptions<T = Record<string, unknown>> = ClaimTargetOptions<T>;
|
|
263
263
|
/**
|
|
264
264
|
* The coordination surface for a model, exposed as a callable namespace.
|
|
@@ -323,11 +323,11 @@ export type AwaitedClaimMethod<F> = F extends (...args: infer A) => infer R ? R
|
|
|
323
323
|
export interface ClaimApi<T> extends ClaimReadApi<T> {
|
|
324
324
|
/**
|
|
325
325
|
* Take a claim and get an explicit held-work handle back. Returns a
|
|
326
|
-
* {@link
|
|
327
|
-
*
|
|
328
|
-
* `handle.data` directly without a guard.
|
|
326
|
+
* {@link HeldClaim} — `data`, `release`, `revoke`, and the async disposer are
|
|
327
|
+
* guaranteed present (this door always re-reads the row under the lease), so
|
|
328
|
+
* callers use `handle.data` directly and `await using` works without a guard.
|
|
329
329
|
*/
|
|
330
|
-
(params: ClaimParams<T>): Promise<
|
|
330
|
+
(params: ClaimParams<T>): Promise<HeldClaim<T>>;
|
|
331
331
|
}
|
|
332
332
|
export interface ModelRetrieveParams extends ServerRetrieveOptions {
|
|
333
333
|
readonly id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export type { MutationExecutor } from './interfaces/index.js';
|
|
|
52
52
|
export type { HttpClaimApi, InternalAbloOptions } from './client/Ablo.js';
|
|
53
53
|
export { type AbloHttpClientOptions, type AbloHttpClient, type HttpModelClient, } from './client/httpClient.js';
|
|
54
54
|
export { ABLO_DEFAULT_BASE_URL, ABLO_HOSTED_API_DOMAIN, ABLO_HOSTED_HTTP_BASE_URL, normalizeAbloHostedBaseUrl, } from './client/auth.js';
|
|
55
|
-
export type { AbloOptions, LocalCountOptions, LocalReadOptions, ModelListScope, ServerReadOptions, ModelRetrieveParams, ModelCreateParams, ModelUpdateParams, ModelDeleteParams, ClaimOptions, ClaimParams, ClaimLookupParams, ClaimReorderParams, Claim, ModelOperations, } from './client/Ablo.js';
|
|
55
|
+
export type { AbloOptions, LocalCountOptions, LocalReadOptions, ModelListScope, ServerReadOptions, ModelRetrieveParams, ModelCreateParams, ModelUpdateParams, ModelDeleteParams, ClaimOptions, ClaimParams, ClaimLookupParams, ClaimReorderParams, Claim, HeldClaim, ModelOperations, } from './client/Ablo.js';
|
|
56
56
|
export type { AbloPersistence } from './client/persistence.js';
|
|
57
57
|
import { Ablo } from './client/Ablo.js';
|
|
58
58
|
export default Ablo;
|
package/dist/types/streams.d.ts
CHANGED
|
@@ -517,3 +517,13 @@ export interface Claim<T = Record<string, unknown>> {
|
|
|
517
517
|
/** Auto-release on `await using` scope exit. Present only on a held claim. */
|
|
518
518
|
[Symbol.asyncDispose]?(): PromiseLike<void>;
|
|
519
519
|
}
|
|
520
|
+
/**
|
|
521
|
+
* A claim you HOLD — the resolved value of `ablo.<model>.claim(...)`. Same
|
|
522
|
+
* composition pattern as {@link PresenceTarget}: a `Claim<T>` with the
|
|
523
|
+
* lease-control members made `Required` (they're optional on the base because it
|
|
524
|
+
* also models observed peer claims, which lack them). Narrowing the return type
|
|
525
|
+
* is what makes `await using held = await ablo.x.claim(...)` typecheck —
|
|
526
|
+
* `Claim<T>`'s optional `[Symbol.asyncDispose]` is not assignable to
|
|
527
|
+
* `AsyncDisposable`.
|
|
528
|
+
*/
|
|
529
|
+
export type HeldClaim<T = Record<string, unknown>> = Claim<T> & Required<Pick<Claim<T>, 'data' | 'release' | 'revoke' | typeof Symbol.asyncDispose>>;
|