@abloatai/ablo 0.27.0 → 0.29.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 +59 -3
- package/README.md +1 -1
- package/dist/BaseSyncedStore.js +8 -9
- package/dist/Database.d.ts +14 -1
- package/dist/Database.js +228 -28
- package/dist/Model.d.ts +17 -0
- package/dist/Model.js +32 -1
- package/dist/SyncClient.d.ts +10 -6
- package/dist/SyncClient.js +390 -75
- package/dist/adapters/inMemoryStorage.d.ts +1 -0
- package/dist/adapters/inMemoryStorage.js +29 -13
- package/dist/ai-sdk/coordinatedTool.d.ts +15 -2
- package/dist/auth/schemas.d.ts +6 -0
- package/dist/auth/schemas.js +7 -0
- package/dist/cli.cjs +821 -402
- package/dist/client/Ablo.d.ts +53 -24
- package/dist/client/Ablo.js +12 -199
- package/dist/client/claimHeartbeatLoop.d.ts +1 -1
- package/dist/client/claimHeartbeatLoop.js +1 -1
- package/dist/client/createInternalComponents.d.ts +4 -0
- package/dist/client/createInternalComponents.js +3 -1
- package/dist/client/durableWrites.d.ts +21 -0
- package/dist/client/durableWrites.js +46 -0
- package/dist/client/httpClient.d.ts +21 -45
- package/dist/client/httpClient.js +104 -26
- package/dist/client/httpTransport.d.ts +8 -0
- package/dist/client/{ApiClient.js → httpTransport.js} +361 -308
- package/dist/client/modelRegistration.js +11 -0
- package/dist/client/options.d.ts +54 -7
- package/dist/client/options.js +3 -2
- package/dist/client/resourceTypes.d.ts +9 -85
- package/dist/client/resourceTypes.js +1 -1
- package/dist/client/sessionMint.d.ts +5 -6
- package/dist/client/sessionMint.js +4 -5
- package/dist/client/validateAbloOptions.js +3 -3
- package/dist/client/wsMutationExecutor.d.ts +3 -2
- package/dist/client/wsMutationExecutor.js +3 -2
- package/dist/coordination/schema.d.ts +30 -0
- package/dist/coordination/schema.js +14 -0
- package/dist/core/StoreManager.d.ts +2 -0
- package/dist/core/StoreManager.js +12 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/errorCodes.js +6 -2
- package/dist/errors.d.ts +4 -40
- package/dist/errors.js +5 -5
- package/dist/index.d.ts +20 -8
- package/dist/index.js +9 -5
- package/dist/interfaces/index.d.ts +5 -2
- package/dist/mutators/UndoManager.d.ts +2 -0
- package/dist/mutators/UndoManager.js +32 -0
- package/dist/mutators/defineMutators.d.ts +18 -0
- package/dist/mutators/defineMutators.js +4 -8
- package/dist/react/index.d.ts +1 -1
- package/dist/react/useAblo.d.ts +6 -4
- package/dist/react/useAblo.js +25 -3
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.js +1 -1
- package/dist/schema/schema.d.ts +31 -1
- package/dist/schema/select.d.ts +15 -0
- package/dist/schema/select.js +27 -3
- package/dist/source/connector.d.ts +3 -3
- package/dist/source/factory.d.ts +4 -6
- package/dist/source/factory.js +4 -7
- package/dist/source/index.d.ts +4 -4
- package/dist/source/index.js +2 -2
- package/dist/source/signing.d.ts +0 -3
- package/dist/source/types.d.ts +0 -26
- package/dist/stores/ObjectStore.d.ts +14 -1
- package/dist/stores/ObjectStore.js +33 -10
- package/dist/stores/ObjectStoreContract.d.ts +2 -0
- package/dist/surface.d.ts +1 -1
- package/dist/surface.js +3 -0
- package/dist/sync/BootstrapFetcher.d.ts +10 -0
- package/dist/sync/BootstrapFetcher.js +27 -4
- package/dist/sync/SyncWebSocket.d.ts +2 -1
- package/dist/sync/createClaimStream.d.ts +11 -2
- package/dist/sync/createClaimStream.js +4 -3
- package/dist/sync/persistedPrefix.d.ts +12 -0
- package/dist/sync/persistedPrefix.js +22 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +1 -0
- package/dist/testing/mocks/FakeDatabase.d.ts +18 -0
- package/dist/testing/mocks/FakeDatabase.js +10 -0
- package/dist/testing/mocks/MockWebSocket.d.ts +2 -1
- package/dist/transactions/TransactionQueue.d.ts +66 -8
- package/dist/transactions/TransactionQueue.js +607 -89
- package/dist/transactions/commitEnvelope.d.ts +132 -0
- package/dist/transactions/commitEnvelope.js +139 -0
- package/dist/transactions/commitOutboxStore.d.ts +32 -0
- package/dist/transactions/commitOutboxStore.js +26 -0
- package/dist/transactions/commitPayload.d.ts +15 -0
- package/dist/transactions/commitPayload.js +6 -0
- package/dist/transactions/durableWriteStore.d.ts +123 -0
- package/dist/transactions/durableWriteStore.js +30 -0
- package/dist/transactions/httpCommitEnvelope.d.ts +44 -0
- package/dist/transactions/httpCommitEnvelope.js +181 -0
- package/dist/transactions/idempotencyKey.d.ts +10 -0
- package/dist/transactions/idempotencyKey.js +9 -0
- package/dist/transactions/replayValidation.d.ts +83 -0
- package/dist/transactions/replayValidation.js +46 -1
- package/dist/types/global.d.ts +10 -29
- package/dist/types/global.js +4 -7
- package/dist/types/streams.d.ts +2 -28
- package/dist/wire/bootstrapReason.d.ts +9 -0
- package/dist/wire/bootstrapReason.js +8 -0
- package/dist/wire/frames.d.ts +6 -21
- package/dist/wire/frames.js +4 -4
- package/dist/wire/index.d.ts +6 -3
- package/dist/wire/index.js +3 -2
- package/dist/wire/protocolVersion.d.ts +30 -17
- package/dist/wire/protocolVersion.js +34 -18
- package/docs/agents.md +8 -3
- package/docs/api.md +16 -14
- package/docs/client-behavior.md +6 -3
- package/docs/coordination.md +4 -5
- package/docs/data-sources.md +5 -8
- package/docs/guarantees.md +21 -0
- package/docs/integration-guide.md +1 -0
- package/docs/mcp.md +1 -1
- package/docs/migration.md +21 -1
- package/docs/quickstart.md +11 -0
- package/docs/react.md +0 -46
- package/examples/README.md +6 -5
- package/llms.txt +15 -15
- package/package.json +3 -3
- package/dist/client/ApiClient.d.ts +0 -177
package/dist/index.d.ts
CHANGED
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* type Entry = Ablo.Peer;
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* `Ablo({ schema, apiKey })` returns typed model clients.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* `Ablo({ schema, apiKey })` returns typed model clients. Server-side agents,
|
|
18
|
+
* MCP route handlers, and workers select `transport: 'http'`; both transports
|
|
19
|
+
* keep the same `ablo.<model>` application surface.
|
|
20
20
|
*
|
|
21
21
|
* The whole package reaches you through one name: `Ablo` is at once a factory
|
|
22
22
|
* function, a type, and a namespace. You call model clients with dot access on
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
*
|
|
46
46
|
* A handful of exports are for advanced use and are marked "Advanced" at their
|
|
47
47
|
* declaration below, each with the one situation it is for:
|
|
48
|
-
* • `dataSource`
|
|
48
|
+
* • `dataSource` — when your own database stays canonical.
|
|
49
49
|
* • `defaultPolicy` — when you customize conflict resolution.
|
|
50
50
|
* • `defineMutators` / `createTransaction` — when you write custom mutators.
|
|
51
51
|
* If you don't recognize one of these, you don't need it.
|
|
@@ -54,18 +54,30 @@ export { Ablo } from './client/Ablo.js';
|
|
|
54
54
|
export type { MutationExecutor } from './interfaces/index.js';
|
|
55
55
|
export type { ModelUpdater, ContentionOptions } from './client/functionalUpdate.js';
|
|
56
56
|
export { DEFAULT_CONTENTION_RETRIES } from './client/functionalUpdate.js';
|
|
57
|
-
export type {
|
|
57
|
+
export type { AbloReads } from './client/Ablo.js';
|
|
58
58
|
export { type AbloHttpClientOptions, type AbloHttpClient, type HttpModelClient, } from './client/httpClient.js';
|
|
59
59
|
export { ABLO_DEFAULT_BASE_URL, ABLO_HOSTED_API_DOMAIN, ABLO_HOSTED_HTTP_BASE_URL, normalizeAbloHostedBaseUrl, } from './client/auth.js';
|
|
60
|
-
export type { AbloOptions, LocalCountOptions, LocalReadOptions, ModelListScope, ServerReadOptions, ModelRetrieveParams, ModelCreateParams, ModelUpdateParams, ModelDeleteParams,
|
|
60
|
+
export type { AbloOptions, LocalCountOptions, LocalReadOptions, ModelListScope, ServerReadOptions, ModelRetrieveParams, ModelCreateParams, ModelUpdateParams, ModelDeleteParams, } from './client/Ablo.js';
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Use `Ablo.Claim.Held`. This compatibility export remains until
|
|
63
|
+
* the next major release because it was explicitly documented in 0.20.1.
|
|
64
|
+
*/
|
|
65
|
+
export type { HeldClaim } from './client/Ablo.js';
|
|
61
66
|
export type { AbloPersistence } from './client/persistence.js';
|
|
67
|
+
export { durableWritesConfigSchema, durableWriteStoreSchema, pendingWriteSchema, } from './transactions/durableWriteStore.js';
|
|
68
|
+
export type { DurableWritesConfig, DurableWriteStore, PendingWrite, } from './transactions/durableWriteStore.js';
|
|
69
|
+
export type { CommitOutboxRecord, CommitOutboxStore, } from './transactions/commitOutboxStore.js';
|
|
70
|
+
export { durableCommitEnvelopeSchema, } from './transactions/commitEnvelope.js';
|
|
71
|
+
export type { CommitOutboxScope, DurableCommitEnvelope, } from './transactions/commitEnvelope.js';
|
|
72
|
+
export { durableHttpCommitEnvelopeSchema, } from './transactions/httpCommitEnvelope.js';
|
|
73
|
+
export type { DurableHttpCommitEnvelope, } from './transactions/httpCommitEnvelope.js';
|
|
62
74
|
import { Ablo } from './client/Ablo.js';
|
|
63
75
|
export default Ablo;
|
|
64
|
-
export { dataSource,
|
|
76
|
+
export { dataSource, sourceEventForOperation, signAbloSourceRequest, verifyAbloSourceRequest, } from './source/index.js';
|
|
65
77
|
export { createSourceConnector, type SourceConnector, type SourceConnectorOptions, type ConnectorStatus, } from './source/connector.js';
|
|
66
78
|
export { defaultPolicy, capabilityPreemptPolicy, interpretConflictAxis } from './policy/index.js';
|
|
67
79
|
export { SyncSessionError, AbloError, AbloAuthenticationError, AbloPermissionError, AbloRateLimitError, AbloIdempotencyError, AbloConnectionError, AbloValidationError, AbloNotFoundError, AbloServerError, AbloStaleContextError, AbloClaimedError, AbloContentionError, CapabilityError, translateHttpError, hasWireCode, errorFromWire, toAbloError, ERROR_CODES, ERROR_CONTRACT_VERSION, errorCodeSpec, isRetryableCode, classifyRecovery, recoveryClassSchema, RECOVERY_CLASSES, } from './errors.js';
|
|
68
|
-
export type {
|
|
80
|
+
export type { RequiredCapability } from './errors.js';
|
|
69
81
|
export type { ErrorCode, WireErrorCode, ErrorCategory, ErrorCodeSpec, RecoveryClass } from './errors.js';
|
|
70
82
|
export { errorEnvelope, statusForType } from './wire/errorEnvelope.js';
|
|
71
83
|
export type { ErrorEnvelope } from './wire/errorEnvelope.js';
|
package/dist/index.js
CHANGED
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* type Entry = Ablo.Peer;
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* `Ablo({ schema, apiKey })` returns typed model clients.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* `Ablo({ schema, apiKey })` returns typed model clients. Server-side agents,
|
|
18
|
+
* MCP route handlers, and workers select `transport: 'http'`; both transports
|
|
19
|
+
* keep the same `ablo.<model>` application surface.
|
|
20
20
|
*
|
|
21
21
|
* The whole package reaches you through one name: `Ablo` is at once a factory
|
|
22
22
|
* function, a type, and a namespace. You call model clients with dot access on
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
*
|
|
46
46
|
* A handful of exports are for advanced use and are marked "Advanced" at their
|
|
47
47
|
* declaration below, each with the one situation it is for:
|
|
48
|
-
* • `dataSource`
|
|
48
|
+
* • `dataSource` — when your own database stays canonical.
|
|
49
49
|
* • `defaultPolicy` — when you customize conflict resolution.
|
|
50
50
|
* • `defineMutators` / `createTransaction` — when you write custom mutators.
|
|
51
51
|
* If you don't recognize one of these, you don't need it.
|
|
@@ -63,6 +63,10 @@ export { DEFAULT_CONTENTION_RETRIES } from './client/functionalUpdate.js';
|
|
|
63
63
|
// `AbloHttpClient` type, which is the return type of that call.
|
|
64
64
|
export {} from './client/httpClient.js';
|
|
65
65
|
export { ABLO_DEFAULT_BASE_URL, ABLO_HOSTED_API_DOMAIN, ABLO_HOSTED_HTTP_BASE_URL, normalizeAbloHostedBaseUrl, } from './client/auth.js';
|
|
66
|
+
export { durableWritesConfigSchema, durableWriteStoreSchema, pendingWriteSchema, } from './transactions/durableWriteStore.js';
|
|
67
|
+
/* eslint-enable @typescript-eslint/no-deprecated */
|
|
68
|
+
export { durableCommitEnvelopeSchema, } from './transactions/commitEnvelope.js';
|
|
69
|
+
export { durableHttpCommitEnvelopeSchema, } from './transactions/httpCommitEnvelope.js';
|
|
66
70
|
// Participant types live under `Ablo.Participant.*` —
|
|
67
71
|
// `Ablo.Participant.Joined`, `Ablo.Participant.Manager`,
|
|
68
72
|
// `Ablo.Participant.JoinOptions`, etc. Same dot-access shape as
|
|
@@ -74,7 +78,7 @@ export default Ablo;
|
|
|
74
78
|
// database. The default is Ablo-managed storage; reach for this only when you
|
|
75
79
|
// have deliberately chosen to keep your database canonical. The matching types
|
|
76
80
|
// live under `Ablo.Source.*` (`Ablo.Source.Operation`, `Ablo.Source.Commit.Params`).
|
|
77
|
-
export { dataSource,
|
|
81
|
+
export { dataSource, sourceEventForOperation, signAbloSourceRequest, verifyAbloSourceRequest, } from './source/index.js';
|
|
78
82
|
// Serves the Data Source `commit`, `load`, and `list` operations over an
|
|
79
83
|
// outbound WebSocket, so a database with no public inbound URL (running on a
|
|
80
84
|
// developer's machine or inside a locked-down network) can still be reached by
|
|
@@ -200,8 +200,8 @@ export interface CommitResult {
|
|
|
200
200
|
* - `idempotencyKey` — when set, the server caches the response for 24 hours and
|
|
201
201
|
* returns the cached result on any retry using the same key. When omitted, the
|
|
202
202
|
* SDK generates a fresh UUID per mutation, so every call is retry-safe by
|
|
203
|
-
* default.
|
|
204
|
-
* write
|
|
203
|
+
* default. `null` is retained for source compatibility and is treated like
|
|
204
|
+
* omission; write retries never opt out of request identity.
|
|
205
205
|
* - `label` — a human-readable tag recorded with the mutation for debugging, such
|
|
206
206
|
* as "nightly cleanup" or "user click".
|
|
207
207
|
*/
|
|
@@ -230,6 +230,9 @@ export interface MutationOptions {
|
|
|
230
230
|
* checks that none of them moved since their `readAt` and applies the entry's
|
|
231
231
|
* `onStale` behavior to the whole batch. This is distinct from the per-operation
|
|
232
232
|
* `readAt`, which guards only the row being written.
|
|
233
|
+
*
|
|
234
|
+
* See `packages/sync-engine/docs/concurrency-convention.md` (§3 the two
|
|
235
|
+
* footprints, §4 the read-set) for the governing convention.
|
|
233
236
|
*/
|
|
234
237
|
reads?: ReadDependency[] | null;
|
|
235
238
|
}
|
|
@@ -250,6 +250,8 @@ export declare class UndoManager<S extends Schema> {
|
|
|
250
250
|
private readonly store;
|
|
251
251
|
private readonly organizationId;
|
|
252
252
|
private readonly scopes;
|
|
253
|
+
/** The options each scope was constructed with, for the mismatch warning below. */
|
|
254
|
+
private readonly creationOptions;
|
|
253
255
|
constructor(schema: S, store: SyncStoreContract, organizationId: string);
|
|
254
256
|
getScope(name: string, options?: UndoScopeOptions): UndoScope<S>;
|
|
255
257
|
clearAll(): void;
|
|
@@ -569,6 +569,8 @@ export class UndoManager {
|
|
|
569
569
|
store;
|
|
570
570
|
organizationId;
|
|
571
571
|
scopes = new Map();
|
|
572
|
+
/** The options each scope was constructed with, for the mismatch warning below. */
|
|
573
|
+
creationOptions = new Map();
|
|
572
574
|
constructor(schema, store, organizationId) {
|
|
573
575
|
this.schema = schema;
|
|
574
576
|
this.store = store;
|
|
@@ -579,6 +581,36 @@ export class UndoManager {
|
|
|
579
581
|
if (!scope) {
|
|
580
582
|
scope = new UndoScope(this.schema, this.store, this.organizationId, options);
|
|
581
583
|
this.scopes.set(name, scope);
|
|
584
|
+
this.creationOptions.set(name, options);
|
|
585
|
+
return scope;
|
|
586
|
+
}
|
|
587
|
+
// A scope keeps the options it was created with; later calls cannot change
|
|
588
|
+
// them. Requesting the shared scope with no options is the normal pattern
|
|
589
|
+
// and stays silent — but passing options that conflict with the creation
|
|
590
|
+
// values means one caller believes it configured a scope that another
|
|
591
|
+
// caller already configured differently, which is how a surface silently
|
|
592
|
+
// ends up with, say, no stream recording. Surface that instead of letting
|
|
593
|
+
// it pass.
|
|
594
|
+
if (options) {
|
|
595
|
+
const created = this.creationOptions.get(name);
|
|
596
|
+
const conflicts = [];
|
|
597
|
+
if (options.recordFromStream !== undefined &&
|
|
598
|
+
options.recordFromStream !== (created?.recordFromStream ?? false)) {
|
|
599
|
+
conflicts.push('recordFromStream');
|
|
600
|
+
}
|
|
601
|
+
if (options.maxHistory !== undefined && options.maxHistory !== (created?.maxHistory ?? 100)) {
|
|
602
|
+
conflicts.push('maxHistory');
|
|
603
|
+
}
|
|
604
|
+
if (options.conflictPolicy !== undefined &&
|
|
605
|
+
options.conflictPolicy !== (created?.conflictPolicy ?? DEFAULT_UNDO_CONFLICT_POLICY)) {
|
|
606
|
+
conflicts.push('conflictPolicy');
|
|
607
|
+
}
|
|
608
|
+
if (conflicts.length > 0) {
|
|
609
|
+
getContext().logger.warn(`The undo scope "${name}" already exists with different options — ` +
|
|
610
|
+
`${conflicts.join(', ')} cannot be changed after creation and the requested ` +
|
|
611
|
+
`values are ignored. Create the scope with its full options before any ` +
|
|
612
|
+
`caller requests it without them, or use a differently named scope.`);
|
|
613
|
+
}
|
|
582
614
|
}
|
|
583
615
|
return scope;
|
|
584
616
|
}
|
|
@@ -13,6 +13,14 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { Schema } from '../schema/schema.js';
|
|
15
15
|
import type { Transaction } from './Transaction.js';
|
|
16
|
+
import type { ResolveSchema } from '../types/global.js';
|
|
17
|
+
/**
|
|
18
|
+
* `ResolveSchema` narrowed to satisfy the `Schema` bound — mirrors
|
|
19
|
+
* {@link Ablo.RegisteredSchema}. When nothing is registered, `ResolveSchema`
|
|
20
|
+
* is a loose `{ models }` shape that doesn't extend `Schema`, so we fall back
|
|
21
|
+
* to `Schema` to keep the mutator tree typed rather than collapsing.
|
|
22
|
+
*/
|
|
23
|
+
type RegisteredSchema = ResolveSchema extends Schema ? ResolveSchema : Schema;
|
|
16
24
|
/**
|
|
17
25
|
* The signature of a single custom mutator. The engine supplies `tx`; you control
|
|
18
26
|
* `args`, in whatever shape you like, and the resolved return value. `TArgs` and
|
|
@@ -40,3 +48,13 @@ export type MutatorDefs<S extends Schema> = {
|
|
|
40
48
|
* work here; the function exists purely as a place for type inference to anchor.
|
|
41
49
|
*/
|
|
42
50
|
export declare function defineMutators<S extends Schema, const M extends MutatorDefs<S>>(_schema: S, mutators: M): M;
|
|
51
|
+
/**
|
|
52
|
+
* Register-anchored overload: omit the schema value and the tree is typed
|
|
53
|
+
* against `ResolveSchema` (this app's registered schema). Shared product code
|
|
54
|
+
* used across apps that bind different schemas should use this form — it moves
|
|
55
|
+
* with each app's `Register` instead of pinning one concrete schema, so the
|
|
56
|
+
* mutator tree stays assignable at every consumer (which reads the same
|
|
57
|
+
* `Register`). See docs/plans/per-product-schema-projections.md.
|
|
58
|
+
*/
|
|
59
|
+
export declare function defineMutators<const M extends MutatorDefs<RegisteredSchema>>(mutators: M): M;
|
|
60
|
+
export {};
|
|
@@ -11,12 +11,8 @@
|
|
|
11
11
|
* `typeof mutators` carries every mutator's precise `args` and result types
|
|
12
12
|
* through to wherever they are invoked.
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* work here; the function exists purely as a place for type inference to anchor.
|
|
19
|
-
*/
|
|
20
|
-
export function defineMutators(_schema, mutators) {
|
|
21
|
-
return mutators;
|
|
14
|
+
export function defineMutators(schemaOrMutators, maybeMutators) {
|
|
15
|
+
// The schema argument is a type anchor only — never read at runtime. With one
|
|
16
|
+
// argument the mutator tree is in the first slot; with two it's in the second.
|
|
17
|
+
return (maybeMutators ?? schemaOrMutators);
|
|
22
18
|
}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
* useAblo((ablo) => ablo.<model>.claim.state(...)) — reactive coordination reads
|
|
44
44
|
* useWatch({ scope }) — join a scope to get its peers and claims
|
|
45
45
|
*/
|
|
46
|
-
export type { DefaultSyncShape, ResolveSchema,
|
|
46
|
+
export type { DefaultSyncShape, ResolveSchema, ResolveUserMeta, ResolveModelKey, } from '../types/global.js';
|
|
47
47
|
export { AbloProvider, useWatch, usePeers, useSync, useSyncStore, type AbloProviderProps, type ParticipantScope, type ParticipantStatus, type UseWatchOptions, type UseWatchReturn, type MeshParticipantStatus, } from './AbloProvider.js';
|
|
48
48
|
export { ClientSideSuspense, type ClientSideSuspenseProps, } from './ClientSideSuspense.js';
|
|
49
49
|
export { DefaultFallback } from './DefaultFallback.js';
|
package/dist/react/useAblo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Ablo, ModelClaim } from '../client/Ablo.js';
|
|
1
|
+
import type { Ablo, AbloReads, ModelClaim } from '../client/Ablo.js';
|
|
2
2
|
import type { ModelOperations } from '../client/createModelProxy.js';
|
|
3
3
|
import type { SchemaRecord } from '../schema/schema.js';
|
|
4
4
|
import type { ResolveSchema } from '../types/global.js';
|
|
@@ -11,8 +11,8 @@ import type { ResolveSchema } from '../types/global.js';
|
|
|
11
11
|
type DefaultModels = ResolveSchema extends {
|
|
12
12
|
models: infer M;
|
|
13
13
|
} ? M extends SchemaRecord ? M : SchemaRecord : SchemaRecord;
|
|
14
|
-
type ModelClientSelector<R extends SchemaRecord, T, C> = (ablo:
|
|
15
|
-
type AbloSelector<R extends SchemaRecord, T> = (ablo:
|
|
14
|
+
type ModelClientSelector<R extends SchemaRecord, T, C> = (ablo: AbloReads<R>) => ModelOperations<T, C>;
|
|
15
|
+
type AbloSelector<R extends SchemaRecord, T> = (ablo: AbloReads<R>) => T;
|
|
16
16
|
export interface UseAbloModelOptions<T> {
|
|
17
17
|
/**
|
|
18
18
|
* An initial row, usually from a server component or a route loader. The hook
|
|
@@ -48,7 +48,9 @@ export type UseAbloHydratedModelResult<T> = Omit<UseAbloModelResult<T>, 'data'>
|
|
|
48
48
|
* if (!ablo) return <Loading />;
|
|
49
49
|
* const doc = await ablo.documents.retrieve({ id }); // async server read
|
|
50
50
|
*
|
|
51
|
-
* // Reactive selector (a synchronous local snapshot)
|
|
51
|
+
* // Reactive selector (a synchronous local snapshot). The selector's reads
|
|
52
|
+
* // are typed as snapshot rows — data fields + computeds, no relation
|
|
53
|
+
* // accessors — matching what the hook actually returns:
|
|
52
54
|
* const doc = useAblo((ablo) => ablo.documents.get(id)) ?? serverDoc;
|
|
53
55
|
* const active = useAblo((ablo) => ablo.documents.claim.state({ id }));
|
|
54
56
|
*
|
package/dist/react/useAblo.js
CHANGED
|
@@ -5,6 +5,24 @@ import { getModelClientMeta } from '../client/createModelProxy.js';
|
|
|
5
5
|
import { Model } from '../Model.js';
|
|
6
6
|
import { useReactive } from './useReactive.js';
|
|
7
7
|
const EMPTY_CLAIMS = Object.freeze([]);
|
|
8
|
+
/**
|
|
9
|
+
* Restore the caller's schema generics on the context-held engine. React
|
|
10
|
+
* context erases generics (see `AbloInternalContextValue.engine`), so this is
|
|
11
|
+
* the one deliberate rebind point: the runtime value is the fully typed
|
|
12
|
+
* client, and `R` is the compile-time view the calling hook declared.
|
|
13
|
+
*/
|
|
14
|
+
function rebindEngine(engine) {
|
|
15
|
+
return engine;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The same rebind viewed through the reactive-read surface — the identical
|
|
19
|
+
* runtime object, with model reads typed as snapshot rows, because everything
|
|
20
|
+
* a selector returns is converted through `snapshotValue` before the hook
|
|
21
|
+
* hands it back.
|
|
22
|
+
*/
|
|
23
|
+
function reactiveReads(engine) {
|
|
24
|
+
return rebindEngine(engine);
|
|
25
|
+
}
|
|
8
26
|
function readModelResult(engine, modelClient, id, initial) {
|
|
9
27
|
if (!modelClient || id === undefined) {
|
|
10
28
|
return { data: initial, claims: EMPTY_CLAIMS, claimed: false };
|
|
@@ -43,7 +61,7 @@ export function useAblo(modelOrSelect, id, options) {
|
|
|
43
61
|
const isSelectorOnly = typeof modelOrSelect === 'function' && id === undefined;
|
|
44
62
|
const modelClient = typeof modelOrSelect === 'function' && id !== undefined
|
|
45
63
|
? engine
|
|
46
|
-
? modelOrSelect(engine)
|
|
64
|
+
? modelOrSelect(reactiveReads(engine))
|
|
47
65
|
: undefined
|
|
48
66
|
: typeof modelOrSelect === 'function'
|
|
49
67
|
? undefined
|
|
@@ -66,7 +84,11 @@ export function useAblo(modelOrSelect, id, options) {
|
|
|
66
84
|
if (!engine || !isSelectorOnly || typeof modelOrSelect !== 'function') {
|
|
67
85
|
return undefined;
|
|
68
86
|
}
|
|
69
|
-
return
|
|
87
|
+
// The selector runs against the real engine — reads inside it return the
|
|
88
|
+
// pool's model instances. `snapshotValue` then converts the RESULT to
|
|
89
|
+
// plain snapshot rows, which is what the selector's `AbloReads`
|
|
90
|
+
// parameter type already promised.
|
|
91
|
+
return snapshotValue(modelOrSelect(reactiveReads(engine)));
|
|
70
92
|
});
|
|
71
93
|
const modelResult = useReactive(() => {
|
|
72
94
|
void claimVersion;
|
|
@@ -76,5 +98,5 @@ export function useAblo(modelOrSelect, id, options) {
|
|
|
76
98
|
return selected;
|
|
77
99
|
if (modelOrSelect)
|
|
78
100
|
return modelResult;
|
|
79
|
-
return engine;
|
|
101
|
+
return engine === null ? null : rebindEngine(engine);
|
|
80
102
|
}
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -30,9 +30,9 @@ export { syncDeltaActionSchema, wireDeltaDataSchema, participantRefSchema, syncD
|
|
|
30
30
|
export { model, scopeKindOf, type ModelDef, type ModelOptions, type LoadStrategy, type PersistOptions, type RelationRecord, type GrantsRef, type ConflictAxis, } from './model.js';
|
|
31
31
|
export { coordination, humansOverwrite, humansReject, humansNotify, agentsOverwrite, agentsReject, agentsNotify, systemOverwrite, systemReject, systemNotify, type ConflictRule, } from './coordination.js';
|
|
32
32
|
export { mutable, readOnly, type SugarOptions } from './sugar.js';
|
|
33
|
-
export { defineSchema, composeIdentitySyncGroups, type Schema, type SchemaRecord, type Model, type InferModel, type InferCreate, type InferModelNames, type BaseModelFields, type InsertValue, type UpsertValue, type UpdateValue, type DeleteId, type DefineSchemaOptions, type Casing, type CasingConvention, type CasingFn, composeEntitySyncGroups, intersectRequestedWithAllowed, type IdentityRole, type IdentityContext, type IdentityRoleSource, type EntityRole, type EntityContext, type EntityRoleSource, type RoleSource, type RoleContext, type SyncGroup, type SyncGroupInput, identityRole, entityRole, extractIdentityIds, extractEntityIds, syncGroup, syncGroupSchema, syncGroupInputSchema, isSyncGroupInput, identityRoleSchema, entityRoleSchema, roleSchema, roleSourceSchema, scopeSchema, grantsRefSchema, groupsInputSchema, type GroupsInput, } from './schema.js';
|
|
33
|
+
export { defineSchema, composeIdentitySyncGroups, type Schema, type SchemaRecord, type Model, type Row, type InferModel, type InferCreate, type InferRow, type InferModelNames, type BaseModelFields, type InsertValue, type UpsertValue, type UpdateValue, type DeleteId, type DefineSchemaOptions, type Casing, type CasingConvention, type CasingFn, composeEntitySyncGroups, intersectRequestedWithAllowed, type IdentityRole, type IdentityContext, type IdentityRoleSource, type EntityRole, type EntityContext, type EntityRoleSource, type RoleSource, type RoleContext, type SyncGroup, type SyncGroupInput, identityRole, entityRole, extractIdentityIds, extractEntityIds, syncGroup, syncGroupSchema, syncGroupInputSchema, isSyncGroupInput, identityRoleSchema, entityRoleSchema, roleSchema, roleSourceSchema, scopeSchema, grantsRefSchema, groupsInputSchema, type GroupsInput, } from './schema.js';
|
|
34
34
|
export { serializeSchema, parseSchema, toSchemaJSON, fromSchemaJSON, schemaHash, type SchemaJSON, type ModelJSON, type RelationJSON, } from './serialize.js';
|
|
35
|
-
export { selectModels } from './select.js';
|
|
35
|
+
export { selectModels, omitModels } from './select.js';
|
|
36
36
|
export { generateProvisionPlan, generateMigrationPlan, appSchemaName, camelToSnake, snakeToCamel, q, sqlType, type ProvisionPlan, type MigrationPlan, } from './ddl.js';
|
|
37
37
|
export { PG_LOCK_NOT_AVAILABLE, resolveDdlLockTimeout, resolveDdlMaxLockAttempts, ddlLockRetryBackoffMs, type DdlLockEnv, } from './ddlLock.js';
|
|
38
38
|
export { diffSchema, classifyMigration, classifyCast, isAutoApplicable, isBlockerResolved, unresolvedBlockers, type BackfillValue, type MigrationStep, type FieldChanges, type FieldColumnChange, type FieldTypeChange, type NullabilityChange, type EnumValuesChange, type IndexChange, type CastSafety, type FieldType, type RenameHints, type MigrationSignal, type MigrationClassification, type WarningCode, type BlockerCode, } from './diff.js';
|
package/dist/schema/index.js
CHANGED
|
@@ -57,7 +57,7 @@ export { defineSchema, composeIdentitySyncGroups, composeEntitySyncGroups, inter
|
|
|
57
57
|
// Schema ⇄ JSON — serialize a schema for transport and rebuild it on the far side.
|
|
58
58
|
export { serializeSchema, parseSchema, toSchemaJSON, fromSchemaJSON, schemaHash, } from './serialize.js';
|
|
59
59
|
// Schema projection — derive an app's subset from one canonical schema.
|
|
60
|
-
export { selectModels } from './select.js';
|
|
60
|
+
export { selectModels, omitModels } from './select.js';
|
|
61
61
|
// Schema → Postgres DDL — shared by the host implementation and the command-line tools.
|
|
62
62
|
export { generateProvisionPlan, generateMigrationPlan, appSchemaName, camelToSnake, snakeToCamel, q, sqlType, } from './ddl.js';
|
|
63
63
|
// Safe-DDL locking knobs (lock_timeout plus a bounded retry on lock contention),
|
package/dist/schema/schema.d.ts
CHANGED
|
@@ -162,8 +162,38 @@ Omit<z.infer<z.ZodObject<Shape>>, keyof BaseModelFields> & BaseModelFields & Bas
|
|
|
162
162
|
* to `slide.layers` would have no effect at runtime.
|
|
163
163
|
*/
|
|
164
164
|
export type InferRelations<S extends Schema, R extends RelationRecord> = string extends keyof R ? unknown : {
|
|
165
|
-
readonly [K in keyof R]: R[K] extends RelationDef<infer Type, infer Target
|
|
165
|
+
readonly [K in keyof R]: R[K] extends RelationDef<infer Type, infer Target> ? Target extends keyof S['models'] ? Type extends 'hasMany' ? InferModel<S, Target>[] : Type extends 'hasOne' | 'belongsTo' ? InferModel<S, Target> | undefined : never : never : never;
|
|
166
166
|
};
|
|
167
|
+
/**
|
|
168
|
+
* The row shape a reactive read returns: the model's data fields, base fields,
|
|
169
|
+
* and schema computed getters — WITHOUT relation accessors and WITHOUT model
|
|
170
|
+
* methods. Derived from the model definition, exactly like {@link InferModel},
|
|
171
|
+
* mirroring what `toReactiveSnapshot()` produces at runtime.
|
|
172
|
+
*
|
|
173
|
+
* Relations (`hasMany` / `belongsTo`) are store-backed getters that exist only
|
|
174
|
+
* on the pool's model instances, so a reactive row honestly omits them —
|
|
175
|
+
* reading `row.layers` is a compile error instead of a silent `undefined`.
|
|
176
|
+
* Compose relations through a selector or hook instead.
|
|
177
|
+
*
|
|
178
|
+
* The same pairing other data layers converged on: Zero's data-only `Row<...>`
|
|
179
|
+
* with relations added per-query, Prisma's scalar-only model types with
|
|
180
|
+
* `GetPayload<{ include }>`, mobx-state-tree's `Instance<T>` / `SnapshotOut<T>`.
|
|
181
|
+
*/
|
|
182
|
+
export type InferRow<S extends Schema, ModelName extends keyof S['models']> = S['models'][ModelName] extends ModelDef<infer Shape, RelationRecord, infer C> ? // Same reserved-field guard as InferModel — see the comment there.
|
|
183
|
+
Omit<z.infer<z.ZodObject<Shape>>, keyof BaseModelFields> & BaseModelFields & InferComputed<C> : never;
|
|
184
|
+
/**
|
|
185
|
+
* The reactive-row companion to {@link Model}. Once your project's
|
|
186
|
+
* `ablo/register.ts` registers the schema, a single argument is all it takes:
|
|
187
|
+
*
|
|
188
|
+
* ```ts
|
|
189
|
+
* type SlideRow = Row<'slides'>; // data fields + computeds, no relations
|
|
190
|
+
* type Slide = Model<'slides'>; // the pool's model instance
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* Without that registration, or for a second schema, pass the schema
|
|
194
|
+
* explicitly: `Row<typeof schema, 'slides'>`.
|
|
195
|
+
*/
|
|
196
|
+
export type Row<A, B = never> = [B] extends [never] ? A extends keyof RegisteredSchema['models'] ? InferRow<RegisteredSchema, A> : never : A extends Schema ? InferRow<A, B extends keyof A['models'] ? B : never> : never;
|
|
167
197
|
/**
|
|
168
198
|
* Infer the return types of computed getters.
|
|
169
199
|
* Maps each computed function's return type into a readonly property.
|
package/dist/schema/select.d.ts
CHANGED
|
@@ -23,3 +23,18 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import type { Schema, SchemaRecord } from './schema.js';
|
|
25
25
|
export declare function selectModels<S extends SchemaRecord, K extends keyof S & string>(schema: Schema<S>, keys: readonly K[]): Schema<Pick<S, K>>;
|
|
26
|
+
/**
|
|
27
|
+
* `omitModels` is `selectModels` from the other side: keep every model EXCEPT
|
|
28
|
+
* the named ones. Use it when an app is the general case and another product
|
|
29
|
+
* owns the omitted models — e.g. the product suite shell drops the standalone
|
|
30
|
+
* Mail store, which `@ablo/mail-schema` selects for the mail app:
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* export const schema = omitModels(full, ['mailMailboxes', 'mailThreads']);
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Same validation as `selectModels`: relations into the omitted set are
|
|
37
|
+
* dropped, and a dropped `parent` edge throws — so a model whose scope routes
|
|
38
|
+
* through an omitted parent cannot be silently kept.
|
|
39
|
+
*/
|
|
40
|
+
export declare function omitModels<S extends SchemaRecord, K extends keyof S & string>(schema: Schema<S>, keys: readonly K[]): Schema<Omit<S, K>>;
|
package/dist/schema/select.js
CHANGED
|
@@ -29,7 +29,7 @@ export function selectModels(schema, keys) {
|
|
|
29
29
|
for (const key of keys) {
|
|
30
30
|
const def = schema.models[key];
|
|
31
31
|
if (!def) {
|
|
32
|
-
throw new AbloValidationError(`selectModels: "${
|
|
32
|
+
throw new AbloValidationError(`selectModels: "${key}" is not a model in the source schema`, { code: 'invalid_schema', param: key });
|
|
33
33
|
}
|
|
34
34
|
// Prune relations whose target isn't in the selected set. A pruned
|
|
35
35
|
// `parent` edge is a routing error, not a silent drop.
|
|
@@ -40,8 +40,8 @@ export function selectModels(schema, keys) {
|
|
|
40
40
|
continue;
|
|
41
41
|
}
|
|
42
42
|
if (rel.options?.parent) {
|
|
43
|
-
throw new AbloValidationError(`selectModels: model "${
|
|
44
|
-
`which is not in the selected set. Include "${rel.target}" so scope inheritance still routes.`, { code: 'invalid_schema', param: `${
|
|
43
|
+
throw new AbloValidationError(`selectModels: model "${key}" has a parent relation "${relName}" → "${rel.target}", ` +
|
|
44
|
+
`which is not in the selected set. Include "${rel.target}" so scope inheritance still routes.`, { code: 'invalid_schema', param: `${key}.${relName}` });
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
models[key] = { ...def, relations };
|
|
@@ -53,3 +53,27 @@ export function selectModels(schema, keys) {
|
|
|
53
53
|
identityRoles: schema.identityRoles,
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* `omitModels` is `selectModels` from the other side: keep every model EXCEPT
|
|
58
|
+
* the named ones. Use it when an app is the general case and another product
|
|
59
|
+
* owns the omitted models — e.g. the product suite shell drops the standalone
|
|
60
|
+
* Mail store, which `@ablo/mail-schema` selects for the mail app:
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* export const schema = omitModels(full, ['mailMailboxes', 'mailThreads']);
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* Same validation as `selectModels`: relations into the omitted set are
|
|
67
|
+
* dropped, and a dropped `parent` edge throws — so a model whose scope routes
|
|
68
|
+
* through an omitted parent cannot be silently kept.
|
|
69
|
+
*/
|
|
70
|
+
export function omitModels(schema, keys) {
|
|
71
|
+
const drop = new Set(keys);
|
|
72
|
+
for (const key of keys) {
|
|
73
|
+
if (!schema.models[key]) {
|
|
74
|
+
throw new AbloValidationError(`omitModels: "${key}" is not a model in the source schema`, { code: 'invalid_schema', param: key });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const kept = Object.keys(schema.models).filter((k) => !drop.has(k));
|
|
78
|
+
return selectModels(schema, kept);
|
|
79
|
+
}
|
|
@@ -62,9 +62,9 @@ export interface SourceConnectorOptions {
|
|
|
62
62
|
*/
|
|
63
63
|
readonly apiKey: string;
|
|
64
64
|
/**
|
|
65
|
-
* The Data Source handler to serve, as returned by `dataSource(options)
|
|
66
|
-
*
|
|
67
|
-
*
|
|
65
|
+
* The Data Source handler to serve, as returned by `dataSource(options)`.
|
|
66
|
+
* The connector feeds it each request and relays the response back untouched;
|
|
67
|
+
* it never inspects or alters either one.
|
|
68
68
|
*/
|
|
69
69
|
readonly handler: (request: Request) => Promise<Response>;
|
|
70
70
|
/** The Ablo base URL to dial. Defaults to `https://api.abloatai.com`. */
|
package/dist/source/factory.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Builds the
|
|
3
|
-
*
|
|
2
|
+
* Builds the request handler returned by `dataSource()`. Given your options —
|
|
3
|
+
* the schema, the API key, and either
|
|
4
4
|
* per-model handlers or an ORM adapter — the handler verifies each signed request,
|
|
5
5
|
* enforces the per-key scopes, and routes the four wire operations (`load`,
|
|
6
6
|
* `list`, `commit`, and `events`) to whichever handlers you configured.
|
|
@@ -13,7 +13,7 @@ type SourceModels<S extends SchemaRecord, TAuth> = Partial<{
|
|
|
13
13
|
readonly id: string;
|
|
14
14
|
} & Record<string, unknown>, InferCreate<Schema<S>, K>, TAuth>;
|
|
15
15
|
}>;
|
|
16
|
-
export type
|
|
16
|
+
export type DataSourceOptions<S extends SchemaRecord, TAuth = unknown> = {
|
|
17
17
|
readonly schema: Schema<S>;
|
|
18
18
|
/**
|
|
19
19
|
* Your Ablo project credential. Ablo signs each Data Source call with the same
|
|
@@ -66,7 +66,7 @@ export type AbloSourceOptions<S extends SchemaRecord, TAuth = unknown> = {
|
|
|
66
66
|
readonly events?: SourceEventsHandler<TAuth>;
|
|
67
67
|
/**
|
|
68
68
|
* Groups per-model handlers under a `models` key. The spread form below is
|
|
69
|
-
* usually shorter — `
|
|
69
|
+
* usually shorter — `dataSource({ schema, files: { load, list, commit } })` —
|
|
70
70
|
* but this explicit form is available when you prefer it.
|
|
71
71
|
*/
|
|
72
72
|
readonly models?: SourceModels<S, TAuth>;
|
|
@@ -88,7 +88,5 @@ export type AbloSourceOptions<S extends SchemaRecord, TAuth = unknown> = {
|
|
|
88
88
|
* canonical rows in your database: Ablo calls a narrow, signed endpoint you
|
|
89
89
|
* control rather than holding your database credentials.
|
|
90
90
|
*/
|
|
91
|
-
export declare function abloSource<const S extends SchemaRecord, TAuth = unknown>(options: AbloSourceOptions<S, TAuth>): (request: Request) => Promise<Response>;
|
|
92
|
-
export type DataSourceOptions<S extends SchemaRecord, TAuth = unknown> = AbloSourceOptions<S, TAuth>;
|
|
93
91
|
export declare function dataSource<const S extends SchemaRecord, TAuth = unknown>(options: DataSourceOptions<S, TAuth>): (request: Request) => Promise<Response>;
|
|
94
92
|
export {};
|
package/dist/source/factory.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Builds the
|
|
3
|
-
*
|
|
2
|
+
* Builds the request handler returned by `dataSource()`. Given your options —
|
|
3
|
+
* the schema, the API key, and either
|
|
4
4
|
* per-model handlers or an ORM adapter — the handler verifies each signed request,
|
|
5
5
|
* enforces the per-key scopes, and routes the four wire operations (`load`,
|
|
6
6
|
* `list`, `commit`, and `events`) to whichever handlers you configured.
|
|
@@ -131,8 +131,8 @@ function sameModel(operations) {
|
|
|
131
131
|
* canonical rows in your database: Ablo calls a narrow, signed endpoint you
|
|
132
132
|
* control rather than holding your database credentials.
|
|
133
133
|
*/
|
|
134
|
-
export function
|
|
135
|
-
return async function
|
|
134
|
+
export function dataSource(options) {
|
|
135
|
+
return async function handleDataSource(request) {
|
|
136
136
|
if (request.method !== 'POST') {
|
|
137
137
|
return json({ error: 'method_not_allowed' }, 405);
|
|
138
138
|
}
|
|
@@ -263,6 +263,3 @@ export function abloSource(options) {
|
|
|
263
263
|
return json({ error: 'unknown_source_request' }, 400);
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
|
-
export function dataSource(options) {
|
|
267
|
-
return abloSource(options);
|
|
268
|
-
}
|
package/dist/source/index.d.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
*
|
|
5
5
|
* - `types.ts` — the shared wire and handler types, plus `sourceEventForOperation`
|
|
6
6
|
* - `signing.ts` — request signing and verification
|
|
7
|
-
* - `factory.ts` — the `
|
|
7
|
+
* - `factory.ts` — the `dataSource()` endpoint factory
|
|
8
8
|
*
|
|
9
9
|
* Import from here; the sibling modules import one another directly.
|
|
10
10
|
*/
|
|
11
|
-
export { sourceEventForOperation, type SourcePrimitive, type SourceWhere, type SourceListQuery, type SourceListPage, type SourceListResult, type SourceRequestContext, type SourceOperation, type SourceDelta, type SourceEvent, type SourceEventForOperationOptions, type SourceCommitResult, type SourceCommitParams, type SourceScope, type SourceEventsResult, type SourceEventsHandler, type SourceAuthorizeContext, type SourceHandlerContext, type SourceModelHandlers, type SourceCommitHandler, type SourceApiKey, type SourceLoadRequest, type SourceListRequest, type SourceCommitRequest, type SourceEventsRequest, type SourceRequest, type SourceResponse,
|
|
12
|
-
export { ABLO_SOURCE_HEADERS, SourceSignatureError, signAbloSourceRequest, verifyAbloSourceRequest, type SourceSignatureOptions, type SourceSignatureVerificationOptions, type SourceSignatureVerificationResult,
|
|
13
|
-
export {
|
|
11
|
+
export { sourceEventForOperation, type SourcePrimitive, type SourceWhere, type SourceListQuery, type SourceListPage, type SourceListResult, type SourceRequestContext, type SourceOperation, type SourceDelta, type SourceEvent, type SourceEventForOperationOptions, type SourceCommitResult, type SourceCommitParams, type SourceScope, type SourceEventsResult, type SourceEventsHandler, type SourceAuthorizeContext, type SourceHandlerContext, type SourceModelHandlers, type SourceCommitHandler, type SourceApiKey, type SourceLoadRequest, type SourceListRequest, type SourceCommitRequest, type SourceEventsRequest, type SourceRequest, type SourceResponse, } from './types.js';
|
|
12
|
+
export { ABLO_SOURCE_HEADERS, SourceSignatureError, signAbloSourceRequest, verifyAbloSourceRequest, type SourceSignatureOptions, type SourceSignatureVerificationOptions, type SourceSignatureVerificationResult, } from './signing.js';
|
|
13
|
+
export { dataSource, type DataSourceOptions, } from './factory.js';
|
|
14
14
|
export { createPushQueue, InMemoryPushQueueStorage, STANDARD_WEBHOOKS_RETRY_SCHEDULE, type PushQueue, type PushQueueItem, type PushQueueOptions, type PushQueueStorage, } from './pushQueue.js';
|
|
15
15
|
export { createSourceConnector, DEFAULT_RECONNECT_SCHEDULE, type SourceConnector, type SourceConnectorOptions, type ConnectorWebSocket, type ConnectorWebSocketFactory, type ConnectorStatus, } from './connector.js';
|
|
16
16
|
export { SOURCE_CONNECTOR_PROTOCOL_VERSION, SOURCE_CONNECTOR_WS_PATH, WS_SOURCE_SUBPROTOCOL, sourceConnectorSubprotocols, encodeFrame, decodeFrame, ConnectorProtocolError, connectorFrameSchema, type ConnectorFrame, type RegisterFrame, type ReadyFrame, type RequestFrame, type ResponseFrame, type ErrorFrame, } from './connectorProtocol.js';
|
package/dist/source/index.js
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
*
|
|
5
5
|
* - `types.ts` — the shared wire and handler types, plus `sourceEventForOperation`
|
|
6
6
|
* - `signing.ts` — request signing and verification
|
|
7
|
-
* - `factory.ts` — the `
|
|
7
|
+
* - `factory.ts` — the `dataSource()` endpoint factory
|
|
8
8
|
*
|
|
9
9
|
* Import from here; the sibling modules import one another directly.
|
|
10
10
|
*/
|
|
11
11
|
export { sourceEventForOperation, } from './types.js';
|
|
12
12
|
export { ABLO_SOURCE_HEADERS, SourceSignatureError, signAbloSourceRequest, verifyAbloSourceRequest, } from './signing.js';
|
|
13
|
-
export {
|
|
13
|
+
export { dataSource, } from './factory.js';
|
|
14
14
|
export { createPushQueue, InMemoryPushQueueStorage, STANDARD_WEBHOOKS_RETRY_SCHEDULE, } from './pushQueue.js';
|
|
15
15
|
// The reverse-channel connector — an outbound transport for the load, list, and
|
|
16
16
|
// commit leg, and the dial-out counterpart to `createPushQueue`. It lets you serve
|
package/dist/source/signing.d.ts
CHANGED
|
@@ -83,6 +83,3 @@ export declare function signAbloSourceRequest(options: SourceSignatureOptions):
|
|
|
83
83
|
* id and signing time. This is the counterpart to {@link signAbloSourceRequest}.
|
|
84
84
|
*/
|
|
85
85
|
export declare function verifyAbloSourceRequest(options: SourceSignatureVerificationOptions): Promise<SourceSignatureVerificationResult>;
|
|
86
|
-
export type DataSourceSignatureOptions = SourceSignatureOptions;
|
|
87
|
-
export type DataSourceSignatureVerificationOptions = SourceSignatureVerificationOptions;
|
|
88
|
-
export type DataSourceSignatureVerificationResult = SourceSignatureVerificationResult;
|
package/dist/source/types.d.ts
CHANGED
|
@@ -323,29 +323,3 @@ export type SourceResponse<Row = Record<string, unknown>> = {
|
|
|
323
323
|
readonly rows?: readonly Row[];
|
|
324
324
|
readonly deltas?: readonly SourceDelta[];
|
|
325
325
|
};
|
|
326
|
-
export type DataSourcePrimitive = SourcePrimitive;
|
|
327
|
-
export type DataSourceWhere = SourceWhere;
|
|
328
|
-
export type DataSourceListQuery = SourceListQuery;
|
|
329
|
-
export type DataSourceListPage<Row> = SourceListPage<Row>;
|
|
330
|
-
export type DataSourceListResult<Row> = SourceListResult<Row>;
|
|
331
|
-
export type DataSourceRequestContext = SourceRequestContext;
|
|
332
|
-
export type DataSourceOperation = SourceOperation;
|
|
333
|
-
export type DataSourceDelta = SourceDelta;
|
|
334
|
-
export type DataSourceEvent = SourceEvent;
|
|
335
|
-
export type DataSourceEventForOperationOptions = SourceEventForOperationOptions;
|
|
336
|
-
export type DataSourceCommitResult<Row = Record<string, unknown>> = SourceCommitResult<Row>;
|
|
337
|
-
export type DataSourceCommitParams<TAuth = unknown> = SourceCommitParams<TAuth>;
|
|
338
|
-
export type DataSourceScope = SourceScope;
|
|
339
|
-
export type DataSourceEventsResult = SourceEventsResult;
|
|
340
|
-
export type DataSourceEventsHandler<TAuth = unknown> = SourceEventsHandler<TAuth>;
|
|
341
|
-
export type DataSourceAuthorizeContext = SourceAuthorizeContext;
|
|
342
|
-
export type DataSourceHandlerContext<TAuth = unknown> = SourceHandlerContext<TAuth>;
|
|
343
|
-
export type DataSourceModelHandlers<Row, CreateInput, TAuth = unknown> = SourceModelHandlers<Row, CreateInput, TAuth>;
|
|
344
|
-
export type DataSourceCommitHandler<TAuth = unknown> = SourceCommitHandler<TAuth>;
|
|
345
|
-
export type DataSourceApiKey = SourceApiKey;
|
|
346
|
-
export type DataSourceLoadRequest = SourceLoadRequest;
|
|
347
|
-
export type DataSourceListRequest = SourceListRequest;
|
|
348
|
-
export type DataSourceCommitRequest = SourceCommitRequest;
|
|
349
|
-
export type DataSourceEventsRequest = SourceEventsRequest;
|
|
350
|
-
export type DataSourceRequest = SourceRequest;
|
|
351
|
-
export type DataSourceResponse<Row = Record<string, unknown>> = SourceResponse<Row>;
|