@thomasfosterau/legation 0.0.0 → 0.1.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 +2054 -0
- package/LICENSE +21 -0
- package/README.md +349 -1
- package/dist/MemoryBackend-BziXwfcs.d.ts +4884 -0
- package/dist/MemoryBackend-BziXwfcs.d.ts.map +1 -0
- package/dist/MemoryBackend-DxP8t4ge.js +9477 -0
- package/dist/MemoryBackend-DxP8t4ge.js.map +1 -0
- package/dist/index-CPPfp0F4.d.ts +399 -0
- package/dist/index-CPPfp0F4.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/internal-CxXRlFK9.d.ts +2362 -0
- package/dist/internal-CxXRlFK9.d.ts.map +1 -0
- package/dist/internal-JyoQMlfK.js +3758 -0
- package/dist/internal-JyoQMlfK.js.map +1 -0
- package/dist/internal.d.ts +3 -0
- package/dist/internal.js +3 -0
- package/dist/rolldown-runtime-D8jQpDG7.js +12 -0
- package/dist/sql/index.d.ts +294 -0
- package/dist/sql/index.d.ts.map +1 -0
- package/dist/sql/index.js +969 -0
- package/dist/sql/index.js.map +1 -0
- package/dist/src-FWXpu_vP.js +1082 -0
- package/dist/src-FWXpu_vP.js.map +1 -0
- package/package.json +61 -3
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Ct as Subset_d_exports, E as Coverage_d_exports, Et as CollectionIndex_d_exports, K as RowChange_d_exports, N as ClientEngine_d_exports, Y as MutationState_d_exports, _ as MirrorChannel_d_exports, ft as Protocol_d_exports, i as SyncServer_d_exports, j as Related_d_exports, l as Cvr_d_exports, s as InvalidationBus_d_exports, w as ClientView_d_exports } from "./MemoryBackend-BziXwfcs.js";
|
|
2
|
+
import { A as AtomicKeyValue_d_exports, C as Subscriptions_d_exports, D as Introspection_d_exports, E as OrderedTree_d_exports, M as RpcTransport_d_exports, N as UnknownMutator_d_exports, O as Paced_d_exports, P as Hash_d_exports, S as Derive_d_exports, T as LiveView_d_exports, _ as MirrorProtocol_d_exports, a as BusBrokers_d_exports, b as LiveQuery_d_exports, c as FanoutTopics_d_exports, d as HttpCache_d_exports, f as FilterCorpus_d_exports, g as EngineHost_d_exports, h as Mirror_d_exports, i as HintSource_d_exports, j as SpecExport_d_exports, k as Undo_d_exports, l as PushPoke_d_exports, m as BackendContract_d_exports, n as SyncRoom_d_exports, o as FanoutBus_d_exports, p as RejectionMemory_d_exports, s as FanoutBroker_d_exports, t as Telemetry_d_exports, u as InvalidationSink_d_exports, v as PromiseFacade_d_exports, w as Incremental_d_exports, x as FractionalIndex_d_exports, y as EngineAtoms_d_exports } from "./internal-CxXRlFK9.js";
|
|
3
|
+
export { AtomicKeyValue_d_exports as AtomicKeyValue, BackendContract_d_exports as BackendContract, BusBrokers_d_exports as BusBrokers, ClientEngine_d_exports as ClientEngine, ClientView_d_exports as ClientView, CollectionIndex_d_exports as CollectionIndex, Coverage_d_exports as Coverage, Cvr_d_exports as Cvr, Derive_d_exports as Derive, EngineAtoms_d_exports as EngineAtoms, EngineHost_d_exports as EngineHost, FanoutBroker_d_exports as FanoutBroker, FanoutBus_d_exports as FanoutBus, FanoutTopics_d_exports as FanoutTopics, FilterCorpus_d_exports as FilterCorpus, FractionalIndex_d_exports as FractionalIndex, Hash_d_exports as Hash, HintSource_d_exports as HintSource, HttpCache_d_exports as HttpCache, Incremental_d_exports as Incremental, Introspection_d_exports as Introspection, InvalidationBus_d_exports as InvalidationBus, InvalidationSink_d_exports as InvalidationSink, LiveQuery_d_exports as LiveQuery, LiveView_d_exports as LiveView, Mirror_d_exports as Mirror, MirrorChannel_d_exports as MirrorChannel, MirrorProtocol_d_exports as MirrorProtocol, MutationState_d_exports as MutationState, OrderedTree_d_exports as OrderedTree, Paced_d_exports as Paced, PromiseFacade_d_exports as PromiseFacade, Protocol_d_exports as Protocol, PushPoke_d_exports as PushPoke, RejectionMemory_d_exports as RejectionMemory, Related_d_exports as Related, RowChange_d_exports as RowChange, RpcTransport_d_exports as RpcTransport, SpecExport_d_exports as SpecExport, Subscriptions_d_exports as Subscriptions, Subset_d_exports as Subset, SyncRoom_d_exports as SyncRoom, SyncServer_d_exports as SyncServer, Telemetry_d_exports as Telemetry, Undo_d_exports as Undo, UnknownMutator_d_exports as UnknownMutator };
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { A as Subscriptions_exports, E as Mirror_exports, H as MirrorProtocol_exports, Jt as Related_exports, N as Coverage_exports, O as ClientView_exports, Ot as Protocol_exports, Pt as AtomicKeyValue_exports, Q as ClientEngine_exports, Qt as Subset_exports, Y as RpcTransport_exports, c as InvalidationBus_exports, ct as MutationState_exports, f as Cvr_exports, gt as Hash_exports, ht as FractionalIndex_exports, i as SyncServer_exports, lt as LiveView_exports, mt as OrderedTree_exports, ot as Telemetry_exports, rn as CollectionIndex_exports, st as RowChange_exports, v as UnknownMutator_exports, x as RejectionMemory_exports } from "./MemoryBackend-DxP8t4ge.js";
|
|
2
|
+
import { S as SpecExport_exports, _ as Derive_exports, a as FanoutBus_exports, b as Paced_exports, c as PushPoke_exports, d as FilterCorpus_exports, f as EngineHost_exports, g as LiveQuery_exports, h as EngineAtoms_exports, i as BusBrokers_exports, l as InvalidationSink_exports, m as PromiseFacade_exports, n as SyncRoom_exports, o as FanoutBroker_exports, p as MirrorChannel_exports, r as HintSource_exports, s as FanoutTopics_exports, t as HttpCache_exports, u as BackendContract_exports, v as Incremental_exports, x as Undo_exports, y as Introspection_exports } from "./internal-JyoQMlfK.js";
|
|
3
|
+
export { AtomicKeyValue_exports as AtomicKeyValue, BackendContract_exports as BackendContract, BusBrokers_exports as BusBrokers, ClientEngine_exports as ClientEngine, ClientView_exports as ClientView, CollectionIndex_exports as CollectionIndex, Coverage_exports as Coverage, Cvr_exports as Cvr, Derive_exports as Derive, EngineAtoms_exports as EngineAtoms, EngineHost_exports as EngineHost, FanoutBroker_exports as FanoutBroker, FanoutBus_exports as FanoutBus, FanoutTopics_exports as FanoutTopics, FilterCorpus_exports as FilterCorpus, FractionalIndex_exports as FractionalIndex, Hash_exports as Hash, HintSource_exports as HintSource, HttpCache_exports as HttpCache, Incremental_exports as Incremental, Introspection_exports as Introspection, InvalidationBus_exports as InvalidationBus, InvalidationSink_exports as InvalidationSink, LiveQuery_exports as LiveQuery, LiveView_exports as LiveView, Mirror_exports as Mirror, MirrorChannel_exports as MirrorChannel, MirrorProtocol_exports as MirrorProtocol, MutationState_exports as MutationState, OrderedTree_exports as OrderedTree, Paced_exports as Paced, PromiseFacade_exports as PromiseFacade, Protocol_exports as Protocol, PushPoke_exports as PushPoke, RejectionMemory_exports as RejectionMemory, Related_exports as Related, RowChange_exports as RowChange, RpcTransport_exports as RpcTransport, SpecExport_exports as SpecExport, Subscriptions_exports as Subscriptions, Subset_exports as Subset, SyncRoom_exports as SyncRoom, SyncServer_exports as SyncServer, Telemetry_exports as Telemetry, Undo_exports as Undo, UnknownMutator_exports as UnknownMutator };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
export { __exportAll as t };
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { It as MutationRejected, Mt as BackendError, Ot as LiteralKind, X as AnyMutator, gt as AnyCollection, kt as Predicate, lt as ChangeHint, st as Backend, ut as SyncContext } from "../MemoryBackend-BziXwfcs.js";
|
|
2
|
+
import "../index-CPPfp0F4.js";
|
|
3
|
+
import { r as HintSource } from "../internal-CxXRlFK9.js";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Duration from "effect/Duration";
|
|
7
|
+
import { SqlClient } from "effect/sql/SqlClient";
|
|
8
|
+
declare namespace Sql_d_exports {
|
|
9
|
+
export { CompileOptions, Dialect, Kinds, SqlFragment, UnionRows, compileSelect, compileWhere, postgres, sqlite };
|
|
10
|
+
}
|
|
11
|
+
/** A SQL fragment plus its ordered bind parameters. */
|
|
12
|
+
interface SqlFragment {
|
|
13
|
+
readonly text: string;
|
|
14
|
+
readonly params: ReadonlyArray<unknown>;
|
|
15
|
+
}
|
|
16
|
+
/** Placeholder, identifier-quoting, collation and boolean rules for a SQL dialect. */
|
|
17
|
+
interface Dialect {
|
|
18
|
+
/** Bind placeholder for the 1-based parameter index. */
|
|
19
|
+
readonly placeholder: (index: number) => string;
|
|
20
|
+
/** Quote a column/table identifier. */
|
|
21
|
+
readonly quote: (identifier: string) => string;
|
|
22
|
+
/** The code-point collation name, emitted as `COLLATE <name>` after a declared-text operand. */
|
|
23
|
+
readonly textCollation: string;
|
|
24
|
+
/** How a boolean literal binds (Postgres has booleans; SQLite stores `0`/`1`). */
|
|
25
|
+
readonly boolean: (value: boolean) => unknown;
|
|
26
|
+
/** The larger of two SQL expressions: `MAX` on SQLite, `GREATEST` on PostgreSQL. */
|
|
27
|
+
readonly greatest: (left: string, right: string) => string;
|
|
28
|
+
/**
|
|
29
|
+
* The statement that makes the transaction it runs in SERIALIZABLE, run first
|
|
30
|
+
* in each `applyMutations` transaction (#353). It must be the transaction's first
|
|
31
|
+
* statement in a top-level transaction: a nested one refuses it, and the batch
|
|
32
|
+
* then fails. Absent on a dialect whose writers already serialise (SQLite takes
|
|
33
|
+
* its write lock with `BEGIN IMMEDIATE`); a hand-written dialect without it gets
|
|
34
|
+
* no isolation statement, so its executor must provide the isolation itself.
|
|
35
|
+
*/
|
|
36
|
+
readonly serializable?: string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* How each arm of `SqlBackend.evaluateMany`'s one `UNION ALL` statement
|
|
39
|
+
* carries its row (#505), since mappings' columns differ per collection.
|
|
40
|
+
* Absent on a hand-written dialect, `evaluateMany` is too, and a pull
|
|
41
|
+
* evaluates its subsets one statement each. See {@link UnionRows}.
|
|
42
|
+
*/
|
|
43
|
+
readonly unionRows?: UnionRows | undefined;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* How a `UNION ALL` arm carries a row whose columns differ from the other
|
|
47
|
+
* arms' (`Dialect.unionRows`, #505):
|
|
48
|
+
*
|
|
49
|
+
* - `Columns`: the relation's own columns by position, padded with `NULL` to
|
|
50
|
+
* the widest arm. Only for a database whose `UNION ALL` columns take any
|
|
51
|
+
* type per row (SQLite): each value then reaches the driver as `SELECT *`
|
|
52
|
+
* would give it. `columnsOf` lists a relation's columns, one row per column
|
|
53
|
+
* with its name in a `name` column.
|
|
54
|
+
* - `Json`: one column of JSON text, `rowJson(alias)` for the row aliased
|
|
55
|
+
* `alias` (PostgreSQL's `row_to_json`). JSON carries text, booleans, `NULL`
|
|
56
|
+
* and numbers that fit a double as the driver does; other column types reach
|
|
57
|
+
* the backend as JSON gives them.
|
|
58
|
+
*/
|
|
59
|
+
type UnionRows = {
|
|
60
|
+
readonly _tag: "Columns";
|
|
61
|
+
readonly columnsOf: (relation: string) => SqlFragment;
|
|
62
|
+
} | {
|
|
63
|
+
readonly _tag: "Json";
|
|
64
|
+
readonly rowJson: (alias: string) => string;
|
|
65
|
+
};
|
|
66
|
+
/** Field → literal kind, for the collation clause and typed binds. */
|
|
67
|
+
type Kinds = Readonly<Record<string, LiteralKind>>;
|
|
68
|
+
/** Options shared by {@link compileWhere} and {@link compileSelect}. */
|
|
69
|
+
interface CompileOptions {
|
|
70
|
+
/** Declared literal kinds of the predicate's own fields (see the module doc). */
|
|
71
|
+
readonly kinds?: Kinds | undefined;
|
|
72
|
+
/** Declared kinds of other collections' fields, keyed by collection, for the inner `where` of an `Exists`. */
|
|
73
|
+
readonly foreignKinds?: Readonly<Record<string, Kinds>> | undefined;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* SQLite: `?` placeholders, `COLLATE BINARY`, booleans as `0`/`1`, a `UNION
|
|
77
|
+
* ALL` arm's row as its own columns by position (`pragma_table_info`).
|
|
78
|
+
*/
|
|
79
|
+
declare const sqlite: Dialect;
|
|
80
|
+
/**
|
|
81
|
+
* PostgreSQL: `$1`, `$2`, … placeholders, `COLLATE "C"`, native booleans,
|
|
82
|
+
* SERIALIZABLE transactions, a `UNION ALL` arm's row as JSON (`row_to_json`).
|
|
83
|
+
*/
|
|
84
|
+
declare const postgres: Dialect;
|
|
85
|
+
/**
|
|
86
|
+
* Compile a predicate into a `WHERE`-ready fragment for a dialect. Pass
|
|
87
|
+
* `options.kinds` (field → literal kind) so declared-text fields get their
|
|
88
|
+
* collation clause and literals bind by the declared kind; without a
|
|
89
|
+
* declaration nothing collates and a literal binds as its JS type (see the
|
|
90
|
+
* module doc).
|
|
91
|
+
*/
|
|
92
|
+
declare const compileWhere: (predicate: Predicate, dialect?: Dialect, options?: CompileOptions) => SqlFragment;
|
|
93
|
+
/**
|
|
94
|
+
* Compile a `SELECT * FROM <table> WHERE <predicate>` for a subset. The
|
|
95
|
+
* `WHERE` is exact (see the module doc). Order, limit and cursor are not
|
|
96
|
+
* pushed down: this statement may later grow an `ORDER BY … LIMIT` for
|
|
97
|
+
* backends that want it, but today the backend's `Subset.apply` finalises
|
|
98
|
+
* them locally, so this stays a single, safe statement.
|
|
99
|
+
*/
|
|
100
|
+
declare const compileSelect: (options: {
|
|
101
|
+
readonly table: string;
|
|
102
|
+
readonly where: Predicate;
|
|
103
|
+
readonly dialect?: Dialect;
|
|
104
|
+
} & CompileOptions) => SqlFragment;
|
|
105
|
+
declare namespace SqlBackend_d_exports {
|
|
106
|
+
export { InexactJsonNumber, SqlBackendConfig, SqlExecutor, SqlHandler, SqlRow, TableMapping, fromCollection, make$2 as make, versionOf };
|
|
107
|
+
}
|
|
108
|
+
/** A row as returned by the driver: a column → value record. */
|
|
109
|
+
type SqlRow = Record<string, unknown>;
|
|
110
|
+
/**
|
|
111
|
+
* The minimal database surface the backend needs.
|
|
112
|
+
*
|
|
113
|
+
* **Isolation (guarantee 1, #353):** `transaction` must run its effect as one
|
|
114
|
+
* database transaction whose reads a concurrent transaction cannot change under
|
|
115
|
+
* them before it commits, so a handler never writes from a stale read. That is
|
|
116
|
+
* SERIALIZABLE isolation, or an equivalent check, and the reference executors
|
|
117
|
+
* meet it: SQLite serialises writers (`BEGIN IMMEDIATE`), and the PostgreSQL
|
|
118
|
+
* dialect's `serializable` statement sets SERIALIZABLE on each transaction. On
|
|
119
|
+
* PostgreSQL that transaction must be top-level, not a nested one run as a
|
|
120
|
+
* savepoint: the statement is refused there, and `applyMutations` fails with a
|
|
121
|
+
* `BackendError`. An executor whose database cannot do this does not conform. A
|
|
122
|
+
* serialization failure (PostgreSQL SQLSTATE 40001 or 40P01) must surface as a
|
|
123
|
+
* `BackendError`, so the client retries the batch; the D1 executor does not meet
|
|
124
|
+
* the requirement (`transactional: false`, #342).
|
|
125
|
+
*/
|
|
126
|
+
interface SqlExecutor {
|
|
127
|
+
/** Run a query and return its rows. */
|
|
128
|
+
readonly query: (fragment: SqlFragment) => Effect.Effect<ReadonlyArray<SqlRow>, BackendError>;
|
|
129
|
+
/** Run a statement for its effect (insert/update/delete). */
|
|
130
|
+
readonly run: (fragment: SqlFragment) => Effect.Effect<void, BackendError>;
|
|
131
|
+
/**
|
|
132
|
+
* Run an effect inside a transaction (atomic commit / rollback on error). On
|
|
133
|
+
* PostgreSQL it must open a top-level transaction, not a savepoint nested in
|
|
134
|
+
* another one, so SERIALIZABLE can be set first (see the `dialect` option of
|
|
135
|
+
* `SqlBackendConfig`).
|
|
136
|
+
*/
|
|
137
|
+
readonly transaction: <A, R>(effect: Effect.Effect<A, BackendError, R>) => Effect.Effect<A, BackendError, R>;
|
|
138
|
+
/**
|
|
139
|
+
* Whether `transaction` commits and rolls back atomically; defaults to `true`.
|
|
140
|
+
*
|
|
141
|
+
* Set `false` on an executor without transactions (D1). `applyMutations` then
|
|
142
|
+
* bumps each id after its handler instead of claiming it first, because a
|
|
143
|
+
* claim committed on its own would be skipped by a retry after a crash.
|
|
144
|
+
*/
|
|
145
|
+
readonly transactional?: boolean | undefined;
|
|
146
|
+
}
|
|
147
|
+
/** How a collection maps onto a table. */
|
|
148
|
+
interface TableMapping {
|
|
149
|
+
/** The write target: what mutator handlers address. Also the read default. */
|
|
150
|
+
readonly table: string;
|
|
151
|
+
/**
|
|
152
|
+
* The relation reads evaluate against, when it differs from `table`
|
|
153
|
+
* (issue #204) — typically a view joining a root version table to a leaf
|
|
154
|
+
* at its current version. Read-only: `SqlBackend` never writes rows
|
|
155
|
+
* itself, only the mutation-id ledger, so nothing here needs `table` to be
|
|
156
|
+
* writable. Defaults to `table`.
|
|
157
|
+
*/
|
|
158
|
+
readonly readRelation?: string;
|
|
159
|
+
/** Primary-key column. Defaults to `"id"`. */
|
|
160
|
+
readonly idColumn?: string;
|
|
161
|
+
/** Column holding the row version; if absent, a content hash is used. */
|
|
162
|
+
readonly versionColumn?: string;
|
|
163
|
+
/**
|
|
164
|
+
* Declared literal kinds of the filterable columns (field → kind), passed
|
|
165
|
+
* to the `Sql` compiler: a column declared `text` gets the code-point
|
|
166
|
+
* collation clause (the clause needs the declaration; a string literal
|
|
167
|
+
* alone never collates), `instant` columns do not, literals bind by the
|
|
168
|
+
* declared kind, and `boolean` columns bind and decode as the dialect
|
|
169
|
+
* stores them (`0`/`1` on SQLite). A column without a kind compiles to a
|
|
170
|
+
* plain comparison with the literal bound as its JS type (see `Sql`). See
|
|
171
|
+
* {@link fromCollection} to derive this instead of writing it by hand.
|
|
172
|
+
*/
|
|
173
|
+
readonly kinds?: Kinds;
|
|
174
|
+
/**
|
|
175
|
+
* A row matching this predicate is a tombstone, not a live row (issue
|
|
176
|
+
* #204): `evaluate` drops it from the entries it returns, so it is simply
|
|
177
|
+
* absent from the next CVR view and diffs as a delete, the same as a row
|
|
178
|
+
* that vanished from the relation outright. Expressed in the engine's own
|
|
179
|
+
* `Predicate` vocabulary (evaluated with `Predicate.test`) rather than a
|
|
180
|
+
* bespoke shape, so it composes with everything else that already
|
|
181
|
+
* understands a `Predicate` (the `Sql` compiler, the differential
|
|
182
|
+
* harness). Typically an `IsNull`/`eq` test on a soft-delete column
|
|
183
|
+
* (`Predicate.isNotNull("deletedAt")`'s negation, an `action` enum check).
|
|
184
|
+
*/
|
|
185
|
+
readonly tombstone?: Predicate;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Derive a `TableMapping` from a `Collection`: column kinds come from its
|
|
189
|
+
* declared filterable set (`Collection.filterDeclarationOf`, #154) instead of
|
|
190
|
+
* being restated by hand — the common case. `table`, and optionally
|
|
191
|
+
* `readRelation` / `idColumn` / `versionColumn` / `tombstone`, are still
|
|
192
|
+
* given explicitly; the hand-written record shape (this function's return
|
|
193
|
+
* type) remains the override path for a mapping derivation can't cover.
|
|
194
|
+
*/
|
|
195
|
+
declare const fromCollection: (collection: AnyCollection, options: {
|
|
196
|
+
readonly table: string;
|
|
197
|
+
readonly readRelation?: string;
|
|
198
|
+
readonly idColumn?: string;
|
|
199
|
+
readonly versionColumn?: string;
|
|
200
|
+
readonly tombstone?: Predicate;
|
|
201
|
+
}) => TableMapping;
|
|
202
|
+
/**
|
|
203
|
+
* An app-authored write, running its own SQL inside the push transaction. Fail
|
|
204
|
+
* with `BackendError` for a transient error (aborts the whole push) or
|
|
205
|
+
* `MutationRejected` for a permanent one (this mutation's writes are rolled back
|
|
206
|
+
* to a savepoint, its id still bumped, the batch continues).
|
|
207
|
+
*/
|
|
208
|
+
type SqlHandler = (args: unknown, tx: SqlExecutor, context: SyncContext) => Effect.Effect<ReadonlyArray<ChangeHint>, BackendError | MutationRejected>;
|
|
209
|
+
/** Configuration for {@link make}. */
|
|
210
|
+
interface SqlBackendConfig {
|
|
211
|
+
readonly executor: SqlExecutor;
|
|
212
|
+
readonly tables: Readonly<Record<string, TableMapping>>;
|
|
213
|
+
/** Mutator definitions, for decoding/validating pushed args. */
|
|
214
|
+
readonly mutators: ReadonlyMap<string, AnyMutator>;
|
|
215
|
+
readonly handlers: Readonly<Record<string, SqlHandler>>;
|
|
216
|
+
/**
|
|
217
|
+
* The SQL dialect. Defaults to SQLite (`Sql.sqlite`). A PostgreSQL app must pass
|
|
218
|
+
* `Sql.postgres`: that sets SERIALIZABLE on each transaction, and omitting it runs
|
|
219
|
+
* the batches at READ COMMITTED with no error. A hand-written dialect without a
|
|
220
|
+
* `serializable` statement gets no isolation statement, so its executor must
|
|
221
|
+
* provide the isolation itself (see {@link SqlExecutor}).
|
|
222
|
+
*/
|
|
223
|
+
readonly dialect?: Dialect | undefined;
|
|
224
|
+
/**
|
|
225
|
+
* Per-client mutation-id ledger table. Defaults to `"sync_mutations"`. It must
|
|
226
|
+
* have the `rejections` column that #366 added: an older table fails the push
|
|
227
|
+
* with a `BackendError` naming the migration (see the sql README).
|
|
228
|
+
*/
|
|
229
|
+
readonly mutationsTable?: string;
|
|
230
|
+
}
|
|
231
|
+
declare const InexactJsonNumber_base: Schema.Class<InexactJsonNumber, Schema.TaggedStruct<"InexactJsonNumber", {
|
|
232
|
+
readonly message: Schema.String;
|
|
233
|
+
/** The collection whose read relation holds the column. */
|
|
234
|
+
readonly collection: Schema.String;
|
|
235
|
+
/** The read relation's column the number sits in (top-level key of the row's JSON). */
|
|
236
|
+
readonly column: Schema.String;
|
|
237
|
+
}>, import("effect/Cause").YieldableError & {
|
|
238
|
+
readonly brand: unique symbol;
|
|
239
|
+
}>;
|
|
240
|
+
/**
|
|
241
|
+
* Why a pull fell back from its batched statement to one `evaluate` per
|
|
242
|
+
* subset: a number in a JSON row (PostgreSQL's `row_to_json`) that JSON
|
|
243
|
+
* cannot carry exactly (#505). `JSON.parse` reads every JSON number as a
|
|
244
|
+
* double, so one with more significant digits than a double holds (a `bigint`
|
|
245
|
+
* past ±(2^53 − 1), a `numeric` of high precision, such a number inside a
|
|
246
|
+
* `json` / `jsonb` column) would read back as a different value than the
|
|
247
|
+
* database holds, and an integer past ±(2^53 − 1) is read by the driver as
|
|
248
|
+
* text, not a number. `evaluateMany` then answers the pull with `evaluate`
|
|
249
|
+
* per subset, whose values are the driver's, and logs this once per
|
|
250
|
+
* collection and column at `Warning` level, as the log's cause: declare the
|
|
251
|
+
* column `integer`, `double precision` or `text` in the read relation (a view
|
|
252
|
+
* can cast it) so the pull stays one statement.
|
|
253
|
+
*
|
|
254
|
+
* Logged, never raised: the pull still succeeds.
|
|
255
|
+
*/
|
|
256
|
+
declare class InexactJsonNumber extends InexactJsonNumber_base {}
|
|
257
|
+
/** Content-hash fallback version when no version column is mapped. */
|
|
258
|
+
declare const versionOf: (value: unknown) => string;
|
|
259
|
+
/**
|
|
260
|
+
* A {@link Backend.Backend} over a {@link SqlExecutor}: subset evaluation, row fetch and the
|
|
261
|
+
* transactional, idempotent mutation-id ledger.
|
|
262
|
+
*/
|
|
263
|
+
declare const make$2: (config: SqlBackendConfig) => Backend;
|
|
264
|
+
declare namespace PollingHintSource_d_exports {
|
|
265
|
+
export { PollingHintSourceConfig, make$1 as make };
|
|
266
|
+
}
|
|
267
|
+
/** Configuration for {@link make}. */
|
|
268
|
+
interface PollingHintSourceConfig {
|
|
269
|
+
readonly executor: SqlExecutor;
|
|
270
|
+
/** Collection → table mapping (the `SqlBackend` mapping, reused). */
|
|
271
|
+
readonly tables: Readonly<Record<string, TableMapping>>;
|
|
272
|
+
/** Poll cadence — the bounded staleness of an out-of-band write. */
|
|
273
|
+
readonly interval: Duration.Input;
|
|
274
|
+
/** Collections to poll. Defaults to every key of `tables`. */
|
|
275
|
+
readonly collections?: ReadonlyArray<string>;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* A `HintSource` that polls each mapped table for a cheap change detector and publishes a hint
|
|
279
|
+
* when a collection changes out of band.
|
|
280
|
+
*/
|
|
281
|
+
declare const make$1: (config: PollingHintSourceConfig) => HintSource;
|
|
282
|
+
declare namespace PgExecutor_d_exports {
|
|
283
|
+
export { make };
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* The executor over `sql`: unprepared statements, and a real transaction per `transaction` call.
|
|
287
|
+
*
|
|
288
|
+
* A failed statement or transaction fails as a `BackendError` that carries the driver's `SqlError`
|
|
289
|
+
* as its `cause` (a serialization refusal included), with the statement text, never its parameters,
|
|
290
|
+
* in the message.
|
|
291
|
+
*/
|
|
292
|
+
declare const make: (sql: SqlClient) => SqlExecutor;
|
|
293
|
+
export { PgExecutor_d_exports as PgExecutor, PollingHintSource_d_exports as PollingHintSource, Sql_d_exports as Sql, SqlBackend_d_exports as SqlBackend };
|
|
294
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["Predicate.LiteralKind","Predicate.Predicate","Sql.SqlFragment","Sql.Kinds","Predicate.Predicate","Collection.AnyCollection","Backend.SyncContext","Backend.ChangeHint","Mutator.AnyMutator","Sql.Dialect","make","Backend.Backend","SqlBackend.SqlExecutor","SqlBackend.TableMapping","make","HintSource.HintSource","SqlBackend.SqlExecutor"],"sources":["../../src/sql/Sql.ts","../../src/sql/SqlBackend.ts","../../src/sql/PollingHintSource.ts","../../src/sql/PgExecutor.ts"],"mappings":";;;;;;;;;;;UAuEiB;WACN;WACA,QAAQ;;;UAIF;;WAEN,cAAc;;WAEd,QAAQ;;WAER;;WAEA,UAAU;;WAEV,WAAW,cAAc;;;;;;;;;WASzB;;;;;;;WAOA,YAAY;;;;;;;;;;;;;;;;KAiBX;WAEG;WACA,YAAY,qBAAqB;;WAGjC;WACA,UAAU;;;KAIb,QAAQ,SAAS,eAAeA;;UAG3B;;WAEN,QAAQ;;WAER,eAAe,SAAS,eAAe;;;;;;cASrC,QAAQ;;;;;cAmBR,UAAU;;;;;;;;cAqJV,eACX,WAAWC,WACX,UAAS,SACT,UAAS,mBACR;;;;;;;;cAkBU,gBACX;WACW;WACA,OAAOA;WACP,UAAU;IACjB,mBACH;;;;;KCzJS,SAAS;;;;;;;;;;;;;;;;;UAkBJ;;WAEN,QAAQ,UAAUC,gBAAoB,OAAO,OAAO,cAAc,SAAS;;WAE3E,MAAM,UAAUA,gBAAoB,OAAO,aAAa;;;;;;;WAOxD,cAAc,GAAG,GACxB,QAAQ,OAAO,OAAO,GAAG,cAAc,OACpC,OAAO,OAAO,GAAG,cAAc;;;;;;;;WAQ3B;;;UAIM;;WAEN;;;;;;;;WAQA;;WAEA;;WAEA;;;;;;;;;;;WAWA,QAAQC;;;;;;;;;;;;WAYR,YAAYC;;;;;;;;;;cAWV,iBACX,YAAYC,eACZ;WACW;WACA;WACA;WACA;WACA,YAAYD;MAEtB;;;;;;;KAcS,cACV,eACA,IAAI,aACJ,SAASE,gBACN,OAAO,OAAO,cAAcC,aAAqB,eAAe;;UAGpD;WACN,UAAU;WACV,QAAQ,SAAS,eAAe;;WAEhC,UAAU,oBAAoBC;WAC9B,UAAU,SAAS,eAAe;;;;;;;;WAQlC,UAAUC;;;;;;WAMV;;;;;;;;;WA8CS;;;;;;;;;;;;;;;;;;cAFP,0BAA0B;;cAgF1B,YAAS;;;;;cAYTC,SAAQ,QAAQ,qBAAmBC;;;;;UC5a/B;WACN,UAAUC;;WAEV,QAAQ,SAAS,eAAeC;;WAEhC,UAAU,SAAS;;WAEnB,cAAc;;;;;;cAgCZC,SAAQ,QAAQ,4BAA0BC;;;;;;;;;;;cCtB1C,OAAQ,KAAK,cAAYC"}
|