@electric-sql/client 1.2.0 → 1.2.1
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/dist/cjs/index.cjs +4 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +34 -3
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.d.ts +34 -3
- package/dist/index.legacy-esm.js +4 -1
- package/dist/index.legacy-esm.js.map +1 -1
- package/dist/index.mjs +4 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/client.ts +7 -1
- package/src/types.ts +33 -2
package/dist/index.d.ts
CHANGED
|
@@ -20,9 +20,31 @@ type NormalizedPgSnapshot = {
|
|
|
20
20
|
xip_list: bigint[];
|
|
21
21
|
};
|
|
22
22
|
interface Header {
|
|
23
|
-
[key: Exclude<string, `operation` | `control`>]: Value;
|
|
23
|
+
[key: Exclude<string, `operation` | `control` | `event`>]: Value;
|
|
24
24
|
}
|
|
25
25
|
type Operation = `insert` | `update` | `delete`;
|
|
26
|
+
/**
|
|
27
|
+
* A tag is a string identifying a reason for this row to be part of the shape.
|
|
28
|
+
*
|
|
29
|
+
* Tags can be composite, but they are always sent as a single string. Compound tags
|
|
30
|
+
* are separated by `|`. It's up to the client to split the tag into its components
|
|
31
|
+
* in order to react to move-outs correctly. Tag parts are guaranteed to not contain an
|
|
32
|
+
* unescaped `|` character (escaped as `\\|`) or be a literal `*`.
|
|
33
|
+
*
|
|
34
|
+
* Composite tag width is guaranteed to be fixed for a given shape.
|
|
35
|
+
*/
|
|
36
|
+
type MoveTag = string;
|
|
37
|
+
/**
|
|
38
|
+
* A move-out pattern is a position and a value. The position is the index of the column
|
|
39
|
+
* that is being moved out. The value is the value of the column that is being moved out.
|
|
40
|
+
*
|
|
41
|
+
* Tag width and value order is fixed for a given shape, so the client can determine
|
|
42
|
+
* which tags match this pattern.
|
|
43
|
+
*/
|
|
44
|
+
type MoveOutPattern = {
|
|
45
|
+
pos: number;
|
|
46
|
+
value: string;
|
|
47
|
+
};
|
|
26
48
|
type ControlMessage = {
|
|
27
49
|
headers: (Header & {
|
|
28
50
|
control: `up-to-date` | `must-refetch`;
|
|
@@ -31,6 +53,12 @@ type ControlMessage = {
|
|
|
31
53
|
control: `snapshot-end`;
|
|
32
54
|
} & PostgresSnapshot);
|
|
33
55
|
};
|
|
56
|
+
type EventMessage = {
|
|
57
|
+
headers: Header & {
|
|
58
|
+
event: `move-out`;
|
|
59
|
+
patterns: MoveOutPattern[];
|
|
60
|
+
};
|
|
61
|
+
};
|
|
34
62
|
type ChangeMessage<T extends Row<unknown> = Row> = {
|
|
35
63
|
key: string;
|
|
36
64
|
value: T;
|
|
@@ -38,9 +66,12 @@ type ChangeMessage<T extends Row<unknown> = Row> = {
|
|
|
38
66
|
headers: Header & {
|
|
39
67
|
operation: Operation;
|
|
40
68
|
txids?: number[];
|
|
69
|
+
/** Tags will always be present for changes if the shape has a subquery in its where clause, and are omitted otherwise.*/
|
|
70
|
+
tags?: MoveTag[];
|
|
71
|
+
removed_tags?: MoveTag[];
|
|
41
72
|
};
|
|
42
73
|
};
|
|
43
|
-
type Message<T extends Row<unknown> = Row> = ControlMessage | ChangeMessage<T>;
|
|
74
|
+
type Message<T extends Row<unknown> = Row> = ControlMessage | EventMessage | ChangeMessage<T>;
|
|
44
75
|
/**
|
|
45
76
|
* Common properties for all columns.
|
|
46
77
|
* `dims` is the number of dimensions of the column. Only provided if the column is an array.
|
|
@@ -808,4 +839,4 @@ declare function isControlMessage<T extends Row<unknown> = Row>(message: Message
|
|
|
808
839
|
*/
|
|
809
840
|
declare function isVisibleInSnapshot(txid: number | bigint | `${bigint}`, snapshot: PostgresSnapshot | NormalizedPgSnapshot): boolean;
|
|
810
841
|
|
|
811
|
-
export { BackoffDefaults, type BackoffOptions, type BitColumn, type BpcharColumn, type ChangeMessage, type ColumnInfo, type ColumnMapper, type CommonColumnProps, type ControlMessage, ELECTRIC_PROTOCOL_QUERY_PARAMS, type ExternalHeadersRecord, type ExternalParamsRecord, FetchError, type GetExtensions, type IntervalColumn, type IntervalColumnWithPrecision, type LogMode, type MaybePromise, type Message, type NormalizedPgSnapshot, type NumericColumn, type Offset, type Operation, type PostgresParams, type PostgresSnapshot, type RegularColumn, type Row, type Schema, Shape, type ShapeChangedCallback, type ShapeData, ShapeStream, type ShapeStreamInterface, type ShapeStreamOptions, type SnapshotMetadata, type SubsetParams, type TimeColumn, type TypedMessages, type Value, type VarcharColumn, camelToSnake, createColumnMapper, isChangeMessage, isControlMessage, isVisibleInSnapshot, resolveValue, snakeCamelMapper, snakeToCamel };
|
|
842
|
+
export { BackoffDefaults, type BackoffOptions, type BitColumn, type BpcharColumn, type ChangeMessage, type ColumnInfo, type ColumnMapper, type CommonColumnProps, type ControlMessage, ELECTRIC_PROTOCOL_QUERY_PARAMS, type EventMessage, type ExternalHeadersRecord, type ExternalParamsRecord, FetchError, type GetExtensions, type IntervalColumn, type IntervalColumnWithPrecision, type LogMode, type MaybePromise, type Message, type MoveOutPattern, type MoveTag, type NormalizedPgSnapshot, type NumericColumn, type Offset, type Operation, type PostgresParams, type PostgresSnapshot, type RegularColumn, type Row, type Schema, Shape, type ShapeChangedCallback, type ShapeData, ShapeStream, type ShapeStreamInterface, type ShapeStreamOptions, type SnapshotMetadata, type SubsetParams, type TimeColumn, type TypedMessages, type Value, type VarcharColumn, camelToSnake, createColumnMapper, isChangeMessage, isControlMessage, isVisibleInSnapshot, resolveValue, snakeCamelMapper, snakeToCamel };
|
package/dist/index.legacy-esm.js
CHANGED
|
@@ -1607,10 +1607,13 @@ requestShapeSSE_fn = async function(opts) {
|
|
|
1607
1607
|
const { fetchUrl, requestAbortController, headers } = opts;
|
|
1608
1608
|
const fetch2 = __privateGet(this, _sseFetchClient);
|
|
1609
1609
|
__privateSet(this, _lastSseConnectionStartTime, Date.now());
|
|
1610
|
+
const sseHeaders = __spreadProps(__spreadValues({}, headers), {
|
|
1611
|
+
Accept: `text/event-stream`
|
|
1612
|
+
});
|
|
1610
1613
|
try {
|
|
1611
1614
|
let buffer = [];
|
|
1612
1615
|
await fetchEventSource(fetchUrl.toString(), {
|
|
1613
|
-
headers,
|
|
1616
|
+
headers: sseHeaders,
|
|
1614
1617
|
fetch: fetch2,
|
|
1615
1618
|
onopen: async (response) => {
|
|
1616
1619
|
__privateSet(this, _connected, true);
|