@tanstack/electric-db-collection 0.1.29 → 0.1.31
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/electric.cjs +191 -41
- package/dist/cjs/electric.cjs.map +1 -1
- package/dist/cjs/electric.d.cts +116 -7
- package/dist/cjs/errors.cjs +16 -29
- package/dist/cjs/errors.cjs.map +1 -1
- package/dist/cjs/errors.d.cts +7 -10
- package/dist/cjs/index.cjs +2 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/electric.d.ts +116 -7
- package/dist/esm/electric.js +188 -43
- package/dist/esm/electric.js.map +1 -1
- package/dist/esm/errors.d.ts +7 -10
- package/dist/esm/errors.js +16 -29
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.js +3 -4
- package/package.json +2 -2
- package/src/electric.ts +391 -74
- package/src/errors.ts +14 -27
package/src/errors.ts
CHANGED
|
@@ -2,49 +2,36 @@ import { TanStackDBError } from "@tanstack/db"
|
|
|
2
2
|
|
|
3
3
|
// Electric DB Collection Errors
|
|
4
4
|
export class ElectricDBCollectionError extends TanStackDBError {
|
|
5
|
-
constructor(message: string) {
|
|
6
|
-
super(message)
|
|
5
|
+
constructor(message: string, collectionId?: string) {
|
|
6
|
+
super(`${collectionId ? `[${collectionId}] ` : ``}${message}`)
|
|
7
7
|
this.name = `ElectricDBCollectionError`
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export class ExpectedNumberInAwaitTxIdError extends ElectricDBCollectionError {
|
|
12
|
-
constructor(txIdType: string) {
|
|
13
|
-
super(`Expected number in awaitTxId, received ${txIdType}
|
|
12
|
+
constructor(txIdType: string, collectionId?: string) {
|
|
13
|
+
super(`Expected number in awaitTxId, received ${txIdType}`, collectionId)
|
|
14
14
|
this.name = `ExpectedNumberInAwaitTxIdError`
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export class TimeoutWaitingForTxIdError extends ElectricDBCollectionError {
|
|
19
|
-
constructor(txId: number) {
|
|
20
|
-
super(`Timeout waiting for txId: ${txId}
|
|
19
|
+
constructor(txId: number, collectionId?: string) {
|
|
20
|
+
super(`Timeout waiting for txId: ${txId}`, collectionId)
|
|
21
21
|
this.name = `TimeoutWaitingForTxIdError`
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export class
|
|
26
|
-
constructor() {
|
|
27
|
-
super(
|
|
28
|
-
|
|
29
|
-
)
|
|
30
|
-
this.name = `ElectricInsertHandlerMustReturnTxIdError`
|
|
25
|
+
export class TimeoutWaitingForMatchError extends ElectricDBCollectionError {
|
|
26
|
+
constructor(collectionId?: string) {
|
|
27
|
+
super(`Timeout waiting for custom match function`, collectionId)
|
|
28
|
+
this.name = `TimeoutWaitingForMatchError`
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
export class
|
|
35
|
-
constructor() {
|
|
36
|
-
super(
|
|
37
|
-
|
|
38
|
-
)
|
|
39
|
-
this.name = `ElectricUpdateHandlerMustReturnTxIdError`
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export class ElectricDeleteHandlerMustReturnTxIdError extends ElectricDBCollectionError {
|
|
44
|
-
constructor() {
|
|
45
|
-
super(
|
|
46
|
-
`Electric collection onDelete handler must return a txid or array of txids`
|
|
47
|
-
)
|
|
48
|
-
this.name = `ElectricDeleteHandlerMustReturnTxIdError`
|
|
32
|
+
export class StreamAbortedError extends ElectricDBCollectionError {
|
|
33
|
+
constructor(collectionId?: string) {
|
|
34
|
+
super(`Stream aborted`, collectionId)
|
|
35
|
+
this.name = `StreamAbortedError`
|
|
49
36
|
}
|
|
50
37
|
}
|