@powersync/service-module-postgres-storage 0.1.0 → 0.1.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 +29 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/types/types.d.ts +4 -2
- package/dist/migrations/migration-utils.js +2 -1
- package/dist/migrations/migration-utils.js.map +1 -1
- package/dist/storage/PostgresCompactor.js +2 -2
- package/dist/storage/PostgresCompactor.js.map +1 -1
- package/dist/storage/PostgresSyncRulesStorage.js +205 -205
- package/dist/storage/PostgresSyncRulesStorage.js.map +1 -1
- package/dist/storage/batch/PostgresBucketBatch.js +4 -4
- package/dist/storage/batch/PostgresBucketBatch.js.map +1 -1
- package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js +2 -2
- package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js.map +1 -1
- package/dist/types/codecs.js +3 -2
- package/dist/types/codecs.js.map +1 -1
- package/package.json +8 -8
- package/src/migrations/migration-utils.ts +2 -1
- package/src/storage/PostgresCompactor.ts +4 -2
- package/src/storage/PostgresSyncRulesStorage.ts +666 -666
- package/src/storage/batch/PostgresBucketBatch.ts +13 -4
- package/src/storage/sync-rules/PostgresPersistedSyncRulesContent.ts +5 -2
- package/src/types/codecs.ts +3 -2
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import * as lib_postgres from '@powersync/lib-service-postgres';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
container,
|
|
4
|
+
DisposableObserver,
|
|
5
|
+
ErrorCode,
|
|
6
|
+
errors,
|
|
7
|
+
logger,
|
|
8
|
+
ReplicationAssertionError,
|
|
9
|
+
ServiceAssertionError,
|
|
10
|
+
ServiceError
|
|
11
|
+
} from '@powersync/lib-services-framework';
|
|
3
12
|
import { storage, utils } from '@powersync/service-core';
|
|
4
13
|
import * as sync_rules from '@powersync/service-sync-rules';
|
|
5
14
|
import * as timers from 'timers/promises';
|
|
@@ -258,7 +267,7 @@ export class PostgresBucketBatch
|
|
|
258
267
|
this.batch = resumeBatch;
|
|
259
268
|
|
|
260
269
|
if (lastOp == null) {
|
|
261
|
-
throw new
|
|
270
|
+
throw new ServiceAssertionError('Unexpected last_op == null');
|
|
262
271
|
}
|
|
263
272
|
|
|
264
273
|
this.persisted_op = lastOp;
|
|
@@ -631,7 +640,7 @@ export class PostgresBucketBatch
|
|
|
631
640
|
return null;
|
|
632
641
|
}
|
|
633
642
|
} else {
|
|
634
|
-
throw new
|
|
643
|
+
throw new ReplicationAssertionError(`${record.tag} not supported with skipExistingRows: true`);
|
|
635
644
|
}
|
|
636
645
|
}
|
|
637
646
|
|
|
@@ -680,7 +689,7 @@ export class PostgresBucketBatch
|
|
|
680
689
|
try {
|
|
681
690
|
afterData = storage.serializeBson(after);
|
|
682
691
|
if (afterData!.byteLength > MAX_ROW_SIZE) {
|
|
683
|
-
throw new
|
|
692
|
+
throw new ServiceError(ErrorCode.PSYNC_S1002, `Row too large: ${afterData?.byteLength}`);
|
|
684
693
|
}
|
|
685
694
|
} catch (e) {
|
|
686
695
|
// Replace with empty values, equivalent to TOAST values
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as lib_postgres from '@powersync/lib-service-postgres';
|
|
2
|
-
import { logger } from '@powersync/lib-services-framework';
|
|
2
|
+
import { ErrorCode, logger, ServiceError } from '@powersync/lib-services-framework';
|
|
3
3
|
import { storage } from '@powersync/service-core';
|
|
4
4
|
import { SqlSyncRules } from '@powersync/service-sync-rules';
|
|
5
5
|
|
|
@@ -44,7 +44,10 @@ export class PostgresPersistedSyncRulesContent implements storage.PersistedSyncR
|
|
|
44
44
|
});
|
|
45
45
|
const lockHandle = await manager.acquire();
|
|
46
46
|
if (!lockHandle) {
|
|
47
|
-
throw new
|
|
47
|
+
throw new ServiceError(
|
|
48
|
+
ErrorCode.PSYNC_S1003,
|
|
49
|
+
`Sync rules: ${this.id} have been locked by another process for replication.`
|
|
50
|
+
);
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
const interval = setInterval(async () => {
|
package/src/types/codecs.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReplicationAssertionError } from '@powersync/lib-services-framework';
|
|
1
2
|
import * as t from 'ts-codec';
|
|
2
3
|
|
|
3
4
|
export const BIGINT_MAX = BigInt('9223372036854775807');
|
|
@@ -98,7 +99,7 @@ export const hexBuffer = t.codec(
|
|
|
98
99
|
return Buffer.from(encoded);
|
|
99
100
|
}
|
|
100
101
|
if (typeof encoded !== 'string') {
|
|
101
|
-
throw new
|
|
102
|
+
throw new ReplicationAssertionError(`Expected either a Buffer instance or hex encoded buffer string`);
|
|
102
103
|
}
|
|
103
104
|
return Buffer.from(encoded, 'hex');
|
|
104
105
|
}
|
|
@@ -116,7 +117,7 @@ export const pgwire_number = t.codec(
|
|
|
116
117
|
return encoded;
|
|
117
118
|
}
|
|
118
119
|
if (typeof encoded !== 'bigint') {
|
|
119
|
-
throw new
|
|
120
|
+
throw new ReplicationAssertionError(`Expected either number or bigint for value`);
|
|
120
121
|
}
|
|
121
122
|
if (encoded > BigInt(Number.MAX_SAFE_INTEGER) || encoded < BigInt(Number.MIN_SAFE_INTEGER)) {
|
|
122
123
|
throw new RangeError('BigInt value is out of safe integer range for conversion to Number.');
|