@powersync/service-module-postgres-storage 0.0.0-dev-20260602073133 → 0.0.0-dev-20260909133214

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.
Files changed (133) hide show
  1. package/CHANGELOG.md +179 -6
  2. package/dist/migrations/scripts/1782950400000-checkpoint-requested-at.d.ts +3 -0
  3. package/dist/migrations/scripts/1782950400000-checkpoint-requested-at.js +42 -0
  4. package/dist/migrations/scripts/1782950400000-checkpoint-requested-at.js.map +1 -0
  5. package/dist/migrations/scripts/1784900000000-source-metadata.d.ts +3 -0
  6. package/dist/migrations/scripts/1784900000000-source-metadata.js +22 -0
  7. package/dist/migrations/scripts/1784900000000-source-metadata.js.map +1 -0
  8. package/dist/migrations/scripts/1788000000000-sync-config-version-label.d.ts +3 -0
  9. package/dist/migrations/scripts/1788000000000-sync-config-version-label.js +12 -0
  10. package/dist/migrations/scripts/1788000000000-sync-config-version-label.js.map +1 -0
  11. package/dist/{@types/storage → storage}/PostgresBucketStorageFactory.d.ts +14 -12
  12. package/dist/storage/PostgresBucketStorageFactory.js +73 -62
  13. package/dist/storage/PostgresBucketStorageFactory.js.map +1 -1
  14. package/dist/{@types/storage → storage}/PostgresCompactor.d.ts +3 -1
  15. package/dist/storage/PostgresCompactor.js +21 -1
  16. package/dist/storage/PostgresCompactor.js.map +1 -1
  17. package/dist/storage/PostgresReportStorage.js.map +1 -1
  18. package/dist/storage/PostgresStorageProvider.js +3 -1
  19. package/dist/storage/PostgresStorageProvider.js.map +1 -1
  20. package/dist/{@types/storage → storage}/PostgresSyncRulesStorage.d.ts +39 -13
  21. package/dist/storage/PostgresSyncRulesStorage.js +266 -181
  22. package/dist/storage/PostgresSyncRulesStorage.js.map +1 -1
  23. package/dist/{@types/storage → storage}/batch/PostgresBucketBatch.d.ts +10 -26
  24. package/dist/storage/batch/PostgresBucketBatch.js +290 -286
  25. package/dist/storage/batch/PostgresBucketBatch.js.map +1 -1
  26. package/dist/{@types/storage → storage}/checkpoints/PostgresWriteCheckpointAPI.d.ts +2 -2
  27. package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js +163 -26
  28. package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js.map +1 -1
  29. package/dist/{@types/storage → storage}/current-data-store.d.ts +8 -2
  30. package/dist/storage/current-data-store.js +66 -11
  31. package/dist/storage/current-data-store.js.map +1 -1
  32. package/dist/{@types/storage → storage}/storage-index.d.ts +1 -0
  33. package/dist/storage/storage-index.js +1 -0
  34. package/dist/storage/storage-index.js.map +1 -1
  35. package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.d.ts +17 -0
  36. package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.js +94 -0
  37. package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.js.map +1 -0
  38. package/dist/{@types/types → types}/models/ActiveCheckpoint.d.ts +2 -2
  39. package/dist/types/models/ActiveCheckpoint.js +3 -2
  40. package/dist/types/models/ActiveCheckpoint.js.map +1 -1
  41. package/dist/{@types/types → types}/models/ActiveCheckpointNotification.d.ts +2 -2
  42. package/dist/types/models/BucketData.d.ts +22 -0
  43. package/dist/types/models/BucketData.js +7 -6
  44. package/dist/types/models/BucketData.js.map +1 -1
  45. package/dist/{@types/types → types}/models/CurrentData.d.ts +1 -1
  46. package/dist/types/models/CurrentData.js +2 -1
  47. package/dist/types/models/CurrentData.js.map +1 -1
  48. package/dist/{@types/types → types}/models/SdkReporting.d.ts +3 -3
  49. package/dist/types/models/SdkReporting.js +3 -5
  50. package/dist/types/models/SdkReporting.js.map +1 -1
  51. package/dist/{@types/types → types}/models/SourceTable.d.ts +13 -8
  52. package/dist/types/models/SourceTable.js +11 -6
  53. package/dist/types/models/SourceTable.js.map +1 -1
  54. package/dist/{@types/types → types}/models/SyncRules.d.ts +11 -10
  55. package/dist/types/models/SyncRules.js +12 -11
  56. package/dist/types/models/SyncRules.js.map +1 -1
  57. package/dist/{@types/types → types}/models/WriteCheckpoint.d.ts +2 -0
  58. package/dist/types/models/WriteCheckpoint.js +6 -2
  59. package/dist/types/models/WriteCheckpoint.js.map +1 -1
  60. package/dist/{@types/types → types}/types.d.ts +2 -0
  61. package/dist/utils/checkpoints.d.ts +9 -0
  62. package/dist/utils/checkpoints.js +26 -0
  63. package/dist/utils/checkpoints.js.map +1 -0
  64. package/dist/utils/test-utils.js +2 -2
  65. package/dist/utils/test-utils.js.map +1 -1
  66. package/package.json +10 -22
  67. package/src/migrations/scripts/1782950400000-checkpoint-requested-at.ts +51 -0
  68. package/src/migrations/scripts/1784900000000-source-metadata.ts +31 -0
  69. package/src/migrations/scripts/1788000000000-sync-config-version-label.ts +18 -0
  70. package/src/storage/PostgresBucketStorageFactory.ts +82 -65
  71. package/src/storage/PostgresCompactor.ts +25 -1
  72. package/src/storage/PostgresReportStorage.ts +1 -2
  73. package/src/storage/PostgresStorageProvider.ts +3 -1
  74. package/src/storage/PostgresSyncRulesStorage.ts +295 -196
  75. package/src/storage/batch/PostgresBucketBatch.ts +321 -310
  76. package/src/storage/checkpoints/PostgresWriteCheckpointAPI.ts +176 -26
  77. package/src/storage/current-data-store.ts +66 -11
  78. package/src/storage/storage-index.ts +1 -0
  79. package/src/storage/sync-rules/PostgresPersistedSyncConfigContent.ts +105 -0
  80. package/src/types/models/ActiveCheckpoint.ts +3 -2
  81. package/src/types/models/BucketData.ts +7 -6
  82. package/src/types/models/CurrentData.ts +2 -1
  83. package/src/types/models/SdkReporting.ts +4 -4
  84. package/src/types/models/SourceTable.ts +12 -6
  85. package/src/types/models/SyncRules.ts +12 -11
  86. package/src/types/models/WriteCheckpoint.ts +6 -2
  87. package/src/utils/checkpoints.ts +31 -0
  88. package/src/utils/test-utils.ts +2 -2
  89. package/test/src/__snapshots__/storage_sync.test.ts.snap +44 -1621
  90. package/test/src/checkpoint_notifications.test.ts +528 -0
  91. package/test/src/migrations.test.ts +1 -1
  92. package/test/src/storage.test.ts +235 -11
  93. package/test/src/storage_compacting.test.ts +17 -9
  94. package/test/src/storage_sync.test.ts +55 -8
  95. package/test/src/util.ts +1 -1
  96. package/test/tsconfig.json +1 -3
  97. package/tsconfig.json +1 -4
  98. package/tsconfig.tsbuildinfo +1 -0
  99. package/dist/.tsbuildinfo +0 -1
  100. package/dist/@types/storage/sync-rules/PostgresPersistedSyncRulesContent.d.ts +0 -9
  101. package/dist/@types/types/models/BucketData.d.ts +0 -22
  102. package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js +0 -49
  103. package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js.map +0 -1
  104. package/src/storage/sync-rules/PostgresPersistedSyncRulesContent.ts +0 -54
  105. /package/dist/{@types/index.d.ts → index.d.ts} +0 -0
  106. /package/dist/{@types/migrations → migrations}/PostgresMigrationAgent.d.ts +0 -0
  107. /package/dist/{@types/migrations → migrations}/PostgresMigrationStore.d.ts +0 -0
  108. /package/dist/{@types/migrations → migrations}/migration-utils.d.ts +0 -0
  109. /package/dist/{@types/migrations → migrations}/scripts/1684951997326-init.d.ts +0 -0
  110. /package/dist/{@types/migrations → migrations}/scripts/1749024804042-snapshot-progress.d.ts +0 -0
  111. /package/dist/{@types/migrations → migrations}/scripts/1756282360128-connection-reporting.d.ts +0 -0
  112. /package/dist/{@types/migrations → migrations}/scripts/1771232439485-storage-version.d.ts +0 -0
  113. /package/dist/{@types/migrations → migrations}/scripts/1771424826685-current-data-pending-deletes.d.ts +0 -0
  114. /package/dist/{@types/migrations → migrations}/scripts/1771491856000-sync-plan.d.ts +0 -0
  115. /package/dist/{@types/module → module}/PostgresStorageModule.d.ts +0 -0
  116. /package/dist/{@types/storage → storage}/PostgresReportStorage.d.ts +0 -0
  117. /package/dist/{@types/storage → storage}/PostgresStorageProvider.d.ts +0 -0
  118. /package/dist/{@types/storage → storage}/batch/OperationBatch.d.ts +0 -0
  119. /package/dist/{@types/storage → storage}/batch/PostgresPersistedBatch.d.ts +0 -0
  120. /package/dist/{@types/storage → storage}/table-id.d.ts +0 -0
  121. /package/dist/{@types/types → types}/codecs.d.ts +0 -0
  122. /package/dist/{@types/types → types}/models/BucketParameters.d.ts +0 -0
  123. /package/dist/{@types/types → types}/models/Instance.d.ts +0 -0
  124. /package/dist/{@types/types → types}/models/Migration.d.ts +0 -0
  125. /package/dist/{@types/types → types}/models/json.d.ts +0 -0
  126. /package/dist/{@types/types → types}/models/models-index.d.ts +0 -0
  127. /package/dist/{@types/utils → utils}/application-name.d.ts +0 -0
  128. /package/dist/{@types/utils → utils}/bson.d.ts +0 -0
  129. /package/dist/{@types/utils → utils}/bucket-data.d.ts +0 -0
  130. /package/dist/{@types/utils → utils}/db.d.ts +0 -0
  131. /package/dist/{@types/utils → utils}/test-utils.d.ts +0 -0
  132. /package/dist/{@types/utils → utils}/ts-codec.d.ts +0 -0
  133. /package/dist/{@types/utils → utils}/utils-index.d.ts +0 -0
@@ -0,0 +1,94 @@
1
+ import * as lib_postgres from '@powersync/lib-service-postgres';
2
+ import { ErrorCode, ServiceError } from '@powersync/lib-services-framework';
3
+ import { storage } from '@powersync/service-core';
4
+ import { models } from '../../types/types.js';
5
+ export class PostgresPersistedSyncConfigContent extends storage.PersistedSyncConfigContent {
6
+ db;
7
+ constructor(db, row) {
8
+ super({
9
+ replicationStreamId: Number(row.id),
10
+ sync_rules_content: row.content,
11
+ compiled_plan: row.sync_plan,
12
+ replicationStreamName: row.slot_name,
13
+ storageVersion: row.storage_version ?? storage.LEGACY_STORAGE_VERSION,
14
+ syncConfigState: row.state,
15
+ version_label: row.version_label ?? undefined
16
+ });
17
+ this.db = db;
18
+ }
19
+ async getSyncConfigStatus() {
20
+ const row = await this.db.sql `
21
+ SELECT
22
+ *
23
+ FROM
24
+ sync_rules
25
+ WHERE
26
+ id = ${{ value: this.replicationStreamId, type: 'int4' }}
27
+ `
28
+ .decoded(models.SyncRules)
29
+ .first();
30
+ return row == null ? null : syncConfigStatusFromRow(row);
31
+ }
32
+ }
33
+ function syncConfigStatusFromRow(row) {
34
+ return {
35
+ id: String(row.id),
36
+ replicationStreamId: Number(row.id),
37
+ state: row.state,
38
+ snapshot_done: row.snapshot_done,
39
+ last_checkpoint_lsn: row.last_checkpoint_lsn,
40
+ last_fatal_error: row.last_fatal_error,
41
+ last_keepalive_ts: row.last_keepalive_ts ? new Date(row.last_keepalive_ts) : null,
42
+ last_checkpoint_ts: row.last_checkpoint_ts ? new Date(row.last_checkpoint_ts) : null
43
+ };
44
+ }
45
+ export class PostgresPersistedReplicationStream extends storage.PersistedReplicationStream {
46
+ db;
47
+ row;
48
+ current_lock = null;
49
+ syncConfigContent;
50
+ constructor(db, row) {
51
+ super({
52
+ replicationStreamId: Number(row.id),
53
+ replicationStreamName: row.slot_name,
54
+ state: row.state,
55
+ storageVersion: row.storage_version ?? storage.LEGACY_STORAGE_VERSION
56
+ });
57
+ this.db = db;
58
+ this.row = row;
59
+ if (this.storageVersion >= storage.STORAGE_VERSION_4) {
60
+ throw new ServiceError(ErrorCode.PSYNC_S1005, `Unsupported storage version ${this.storageVersion} for PostgreSQL storage`);
61
+ }
62
+ this.syncConfigContent = [new PostgresPersistedSyncConfigContent(this.db, this.row)];
63
+ }
64
+ parsed(options) {
65
+ return this.syncConfigContent[0].parsed(options);
66
+ }
67
+ async lock() {
68
+ const manager = new lib_postgres.PostgresLockManager({
69
+ db: this.db,
70
+ name: `sync_rules_${this.replicationStreamId}_${this.replicationStreamName}`
71
+ });
72
+ const lockHandle = await manager.acquire();
73
+ if (!lockHandle) {
74
+ throw new ServiceError(ErrorCode.PSYNC_S1003, `Replication stream is locked by another process, standing by.`);
75
+ }
76
+ const interval = setInterval(async () => {
77
+ try {
78
+ await lockHandle.refresh();
79
+ }
80
+ catch (e) {
81
+ this.logger.error('Failed to refresh lock', e);
82
+ clearInterval(interval);
83
+ }
84
+ }, 30_130);
85
+ return (this.current_lock = {
86
+ sync_rules_id: this.replicationStreamId,
87
+ release: async () => {
88
+ clearInterval(interval);
89
+ return lockHandle.release();
90
+ }
91
+ });
92
+ }
93
+ }
94
+ //# sourceMappingURL=PostgresPersistedSyncConfigContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PostgresPersistedSyncConfigContent.js","sourceRoot":"","sources":["../../../src/storage/sync-rules/PostgresPersistedSyncConfigContent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,OAAO,kCAAmC,SAAQ,OAAO,CAAC,0BAA0B;IAE9E;IADV,YACU,EAA+B,EACvC,GAA4B;QAE5B,KAAK,CAAC;YACJ,mBAAmB,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,kBAAkB,EAAE,GAAG,CAAC,OAAO;YAC/B,aAAa,EAAE,GAAG,CAAC,SAAS;YAC5B,qBAAqB,EAAE,GAAG,CAAC,SAAS;YACpC,cAAc,EAAE,GAAG,CAAC,eAAe,IAAI,OAAO,CAAC,sBAAsB;YACrE,eAAe,EAAE,GAAG,CAAC,KAA8B;YACnD,aAAa,EAAE,GAAG,CAAC,aAAa,IAAI,SAAS;SAC9C,CAAC,CAAC;QAXK,OAAE,GAAF,EAAE,CAA6B;IAYzC,CAAC;IAED,KAAK,CAAC,mBAAmB;QACvB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,GAAG,CAAA;;;;;;eAMlB,EAAE,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,EAAE,MAAM,EAAE;KAC3D;aACE,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC;aACzB,KAAK,EAAE,CAAC;QAEX,OAAO,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC;IAC3D,CAAC;C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 'ts-codec';
5
5
  */
6
6
  export declare const ActiveCheckpoint: t.ObjectCodec<{
7
7
  id: t.Codec<number, number, "pg_number", t.CodecProps>;
8
- last_checkpoint: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<bigint, string | number, string, t.CodecProps>>;
9
- last_checkpoint_lsn: t.Union<t.Codec<null, null, string, t.CodecProps>, t.IdentityCodec<t.CodecType.String>>;
8
+ last_checkpoint: t.Codec<bigint | null, string | number | null>;
9
+ last_checkpoint_lsn: t.Codec<string | null, string | null>;
10
10
  }>;
11
11
  export type ActiveCheckpoint = t.Encoded<typeof ActiveCheckpoint>;
12
12
  export type ActiveCheckpointDecoded = t.Decoded<typeof ActiveCheckpoint>;
@@ -1,3 +1,4 @@
1
+ import { orNull } from '@powersync/service-types';
1
2
  import * as t from 'ts-codec';
2
3
  import { bigint, pgwire_number } from '../codecs.js';
3
4
  /**
@@ -6,7 +7,7 @@ import { bigint, pgwire_number } from '../codecs.js';
6
7
  */
7
8
  export const ActiveCheckpoint = t.object({
8
9
  id: pgwire_number,
9
- last_checkpoint: t.Null.or(bigint),
10
- last_checkpoint_lsn: t.Null.or(t.string)
10
+ last_checkpoint: orNull(bigint),
11
+ last_checkpoint_lsn: orNull(t.string)
11
12
  });
12
13
  //# sourceMappingURL=ActiveCheckpoint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActiveCheckpoint.js","sourceRoot":"","sources":["../../../src/types/models/ActiveCheckpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,EAAE,EAAE,aAAa;IACjB,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;IAClC,mBAAmB,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;CACzC,CAAC,CAAC"}
1
+ {"version":3,"file":"ActiveCheckpoint.js","sourceRoot":"","sources":["../../../src/types/models/ActiveCheckpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,EAAE,EAAE,aAAa;IACjB,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC;IAC/B,mBAAmB,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;CACtC,CAAC,CAAC"}
@@ -2,8 +2,8 @@ import * as t from 'ts-codec';
2
2
  export declare const ActiveCheckpointPayload: t.ObjectCodec<{
3
3
  active_checkpoint: t.ObjectCodec<{
4
4
  id: t.Codec<number, number, "pg_number", t.CodecProps>;
5
- last_checkpoint: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<bigint, string | number, string, t.CodecProps>>;
6
- last_checkpoint_lsn: t.Union<t.Codec<null, null, string, t.CodecProps>, t.IdentityCodec<t.CodecType.String>>;
5
+ last_checkpoint: t.Codec<bigint | null, string | number | null>;
6
+ last_checkpoint_lsn: t.Codec<string | null, string | null>;
7
7
  }>;
8
8
  }>;
9
9
  export type ActiveCheckpointPayload = t.Encoded<typeof ActiveCheckpointPayload>;
@@ -0,0 +1,22 @@
1
+ import * as t from 'ts-codec';
2
+ export declare enum OpType {
3
+ PUT = "PUT",
4
+ REMOVE = "REMOVE",
5
+ MOVE = "MOVE",
6
+ CLEAR = "CLEAR"
7
+ }
8
+ export declare const BucketData: t.ObjectCodec<{
9
+ group_id: t.Codec<number, number, "pg_number", t.CodecProps>;
10
+ bucket_name: t.IdentityCodec<t.CodecType.String>;
11
+ op_id: t.Codec<bigint, string | number, string, t.CodecProps>;
12
+ op: t.EnumCodec<typeof OpType>;
13
+ source_table: t.Codec<string | null, string | null>;
14
+ source_key: t.Codec<Buffer<ArrayBuffer> | null, string | null>;
15
+ table_name: t.Codec<string | null, string | null>;
16
+ row_id: t.Codec<string | null, string | null>;
17
+ checksum: t.Codec<bigint, string | number, string, t.CodecProps>;
18
+ data: t.Codec<string | null, string | null>;
19
+ target_op: t.Codec<bigint | null, string | number | null>;
20
+ }>;
21
+ export type BucketData = t.Encoded<typeof BucketData>;
22
+ export type BucketDataDecoded = t.Decoded<typeof BucketData>;
@@ -1,3 +1,4 @@
1
+ import { orNull } from '@powersync/service-types';
1
2
  import * as t from 'ts-codec';
2
3
  import { bigint, hexBuffer, pgwire_number } from '../codecs.js';
3
4
  export var OpType;
@@ -12,12 +13,12 @@ export const BucketData = t.object({
12
13
  bucket_name: t.string,
13
14
  op_id: bigint,
14
15
  op: t.Enum(OpType),
15
- source_table: t.Null.or(t.string),
16
- source_key: t.Null.or(hexBuffer),
17
- table_name: t.string.or(t.Null),
18
- row_id: t.string.or(t.Null),
16
+ source_table: orNull(t.string),
17
+ source_key: orNull(hexBuffer),
18
+ table_name: orNull(t.string),
19
+ row_id: orNull(t.string),
19
20
  checksum: bigint,
20
- data: t.Null.or(t.string),
21
- target_op: t.Null.or(bigint)
21
+ data: orNull(t.string),
22
+ target_op: orNull(bigint)
22
23
  });
23
24
  //# sourceMappingURL=BucketData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BucketData.js","sourceRoot":"","sources":["../../../src/types/models/BucketData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEhE,MAAM,CAAN,IAAY,MAKX;AALD,WAAY,MAAM;IAChB,qBAAW,CAAA;IACX,2BAAiB,CAAA;IACjB,uBAAa,CAAA;IACb,yBA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Aa;IACvB,WAAW,EAAE,CAAC,CAAC,MAAM;IACrB,KAAK,EAAE,MAAM;IACb,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC,SAAS,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC;CAC1B,CAAC,CAAC"}
@@ -29,7 +29,7 @@ export declare const V3CurrentData: t.ObjectCodec<{
29
29
  lookups: t.ArrayCodec<t.Codec<Buffer<ArrayBuffer>, string, "hexBuffer", t.CodecProps>>;
30
30
  source_key: t.Codec<Buffer<ArrayBuffer>, string, "hexBuffer", t.CodecProps>;
31
31
  source_table: t.IdentityCodec<t.CodecType.String>;
32
- pending_delete: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<bigint, string | number, string, t.CodecProps>>;
32
+ pending_delete: t.Codec<bigint | null, string | number | null>;
33
33
  }>;
34
34
  export type V1CurrentData = t.Encoded<typeof V1CurrentData>;
35
35
  export type V1CurrentDataDecoded = t.Decoded<typeof V1CurrentData>;
@@ -1,3 +1,4 @@
1
+ import { orNull } from '@powersync/service-types';
1
2
  import * as t from 'ts-codec';
2
3
  import { bigint, hexBuffer, jsonb, pgwire_number } from '../codecs.js';
3
4
  export const CurrentBucket = t.object({
@@ -20,6 +21,6 @@ export const V3CurrentData = t.object({
20
21
  lookups: t.array(hexBuffer),
21
22
  source_key: hexBuffer,
22
23
  source_table: t.string,
23
- pending_delete: t.Null.or(bigint)
24
+ pending_delete: orNull(bigint)
24
25
  });
25
26
  //# sourceMappingURL=CurrentData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CurrentData.js","sourceRoot":"","sources":["../../../src/types/models/CurrentData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,MAAM;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM;IACf,EAAE,EAAE,CAAC,CAAC,MAAM;CACb,CAAC,CAAC;AAKH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACtC,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,aAAa;IACvB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IAC3B,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,CAAC,CAAC,MAAM;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACtC,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,aAAa;IACvB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IAC3B,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,CAAC,CAAC,MAAM;IACtB,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;CAClC,CAAC,CAAC"}
1
+ {"version":3,"file":"CurrentData.js","sourceRoot":"","sources":["../../../src/types/models/CurrentData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,MAAM;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM;IACf,EAAE,EAAE,CAAC,CAAC,MAAM;CACb,CAAC,CAAC;AAKH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACtC,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,aAAa;IACvB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IAC3B,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,CAAC,CAAC,MAAM;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACtC,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,aAAa;IACvB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IAC3B,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,CAAC,CAAC,MAAM;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC;CAC/B,CAAC,CAAC"}
@@ -7,15 +7,15 @@ export declare const Sdks: t.ObjectCodec<{
7
7
  export type Sdks = t.Encoded<typeof Sdks>;
8
8
  export declare const SdkReporting: t.ObjectCodec<{
9
9
  users: t.Codec<bigint, string | number, string, t.CodecProps>;
10
- sdks: t.Union<t.Codec<{
10
+ sdks: t.OptionalCodec<t.Codec<{
11
11
  data: {
12
12
  sdk: string;
13
13
  clients: number;
14
14
  users: number;
15
15
  }[];
16
- } | undefined, {
16
+ } | null, {
17
17
  data: string;
18
- } | undefined, string, t.CodecProps>, t.Codec<null, null, t.CodecType.Null, t.CodecProps>>;
18
+ } | null, string, t.CodecProps>>;
19
19
  }>;
20
20
  export type SdkReporting = t.Encoded<typeof SdkReporting>;
21
21
  export type SdkReportingDecoded = t.Decoded<typeof SdkReporting>;
@@ -1,3 +1,4 @@
1
+ import { orNull } from '@powersync/service-types';
1
2
  import * as t from 'ts-codec';
2
3
  import { bigint, jsonb } from '../codecs.js';
3
4
  export const Sdks = t.object({
@@ -7,11 +8,8 @@ export const Sdks = t.object({
7
8
  });
8
9
  export const SdkReporting = t.object({
9
10
  users: bigint,
10
- sdks: t
11
- .object({
11
+ sdks: orNull(t.object({
12
12
  data: jsonb(t.array(Sdks))
13
- })
14
- .optional()
15
- .or(t.Null)
13
+ })).optional()
16
14
  });
17
15
  //# sourceMappingURL=SdkReporting.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SdkReporting.js","sourceRoot":"","sources":["../../../src/types/models/SdkReporting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,GAAG,EAAE,CAAC,CAAC,MAAM;IACb,OAAO,EAAE,CAAC,CAAC,MAAM;IACjB,KAAK,EAAE,CAAC,CAAC,MAAM;CAChB,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,CAAC;SACJ,MAAM,CAAC;QACN,IAAI,EAAE,KAAK,CAAS,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KACnC,CAAC;SACD,QAAQ,EAAE;SACV,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;CACd,CAAC,CAAC"}
1
+ {"version":3,"file":"SdkReporting.js","sourceRoot":"","sources":["../../../src/types/models/SdkReporting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,GAAG,EAAE,CAAC,CAAC,MAAM;IACb,OAAO,EAAE,CAAC,CAAC,MAAM;IACjB,KAAK,EAAE,CAAC,CAAC,MAAM;CAChB,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,MAAM,CACV,CAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,KAAK,CAAS,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KACnC,CAAC,CACH,CAAC,QAAQ,EAAE;CACb,CAAC,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { JsonValue } from '@powersync/service-core';
1
2
  import * as t from 'ts-codec';
2
3
  export type StoredRelationId = {
3
4
  object_id: string | number | undefined;
@@ -11,24 +12,28 @@ export declare const ColumnDescriptor: t.ObjectCodec<{
11
12
  /**
12
13
  * Some data sources have a type id that can be used to identify the type of the column
13
14
  */
14
- typeId: t.OptionalCodec<t.Codec<number, number, string, t.CodecProps>>;
15
+ type_oid: t.OptionalCodec<t.Codec<number, number, string, t.CodecProps>>;
15
16
  }>;
16
17
  export declare const SourceTable: t.ObjectCodec<{
17
18
  id: t.IdentityCodec<t.CodecType.String>;
18
19
  group_id: t.Codec<number, number, "pg_number", t.CodecProps>;
19
20
  connection_id: t.Codec<bigint, string | number, string, t.CodecProps>;
20
- relation_id: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<StoredRelationId, string, string, t.CodecProps>>;
21
+ relation_id: t.Codec<StoredRelationId | null, string | null>;
21
22
  schema_name: t.IdentityCodec<t.CodecType.String>;
22
23
  table_name: t.IdentityCodec<t.CodecType.String>;
23
- replica_id_columns: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<{
24
+ replica_id_columns: t.Codec<{
24
25
  name: string;
25
26
  type?: string | undefined;
26
- typeId?: number | undefined;
27
- }[], string, string, t.CodecProps>>;
27
+ type_oid?: number | undefined;
28
+ }[] | null, string | null>;
28
29
  snapshot_done: t.IdentityCodec<t.CodecType.Boolean>;
29
- snapshot_total_estimated_count: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<bigint, string | number, string, t.CodecProps>>;
30
- snapshot_replicated_count: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<bigint, string | number, string, t.CodecProps>>;
31
- snapshot_last_key: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<Buffer<ArrayBuffer>, string, "hexBuffer", t.CodecProps>>;
30
+ snapshot_total_estimated_count: t.Codec<bigint | null, string | number | null>;
31
+ snapshot_replicated_count: t.Codec<bigint | null, string | number | null>;
32
+ snapshot_last_key: t.Codec<Buffer<ArrayBuffer> | null, string | null>;
33
+ /**
34
+ * Source-specific metadata. Null for legacy records.
35
+ */
36
+ source_metadata: t.Codec<JsonValue, string | null>;
32
37
  }>;
33
38
  export type SourceTable = t.Encoded<typeof SourceTable>;
34
39
  export type SourceTableDecoded = t.Decoded<typeof SourceTable>;
@@ -1,3 +1,4 @@
1
+ import { orNull } from '@powersync/service-types';
1
2
  import * as t from 'ts-codec';
2
3
  import { bigint, hexBuffer, jsonb, jsonb_raw, pgwire_number } from '../codecs.js';
3
4
  export const ColumnDescriptor = t.object({
@@ -9,19 +10,23 @@ export const ColumnDescriptor = t.object({
9
10
  /**
10
11
  * Some data sources have a type id that can be used to identify the type of the column
11
12
  */
12
- typeId: t.number.optional()
13
+ type_oid: t.number.optional()
13
14
  });
14
15
  export const SourceTable = t.object({
15
16
  id: t.string,
16
17
  group_id: pgwire_number,
17
18
  connection_id: bigint,
18
- relation_id: t.Null.or(jsonb_raw()),
19
+ relation_id: orNull(jsonb_raw()),
19
20
  schema_name: t.string,
20
21
  table_name: t.string,
21
- replica_id_columns: t.Null.or(jsonb(t.array(ColumnDescriptor))),
22
+ replica_id_columns: orNull(jsonb(t.array(ColumnDescriptor))),
22
23
  snapshot_done: t.boolean,
23
- snapshot_total_estimated_count: t.Null.or(bigint),
24
- snapshot_replicated_count: t.Null.or(bigint),
25
- snapshot_last_key: t.Null.or(hexBuffer)
24
+ snapshot_total_estimated_count: orNull(bigint),
25
+ snapshot_replicated_count: orNull(bigint),
26
+ snapshot_last_key: orNull(hexBuffer),
27
+ /**
28
+ * Source-specific metadata. Null for legacy records.
29
+ */
30
+ source_metadata: orNull(jsonb_raw())
26
31
  });
27
32
  //# sourceMappingURL=SourceTable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SourceTable.js","sourceRoot":"","sources":["../../../src/types/models/SourceTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAMlF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,MAAM;IACd;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;IACzB;;OAEG;IACH,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,EAAE,EAAE,CAAC,CAAC,MAAM;IACZ,QAAQ,EAAE,aAAa;IACvB,aAAa,EAAE,MAAM;IACrB,WAAW,EAAE,CAAC,CA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AAE,CAAC,CAAC,MAAM;IACrB,UAAU,EAAE,CAAC,CAAC,MAAM;IACpB,kBAAkB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC5D,aAAa,EAAE,CAAC,CAAC,OAAO;IACxB,8BAA8B,EAAE,MAAM,CAAC,MAAM,CAAC;IAC9C,yBAAyB,EAAE,MAAM,CAAC,MAAM,CAAC;IACzC,iBAAiB,EAAE,MAAM,CAAC,SAAS,CAAC;IACpC;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC,SAAS,EAAa,CAAC;CAChD,CAAC,CAAC"}
@@ -12,42 +12,43 @@ export declare const SyncRules: t.ObjectCodec<{
12
12
  /**
13
13
  * May be set if snapshot_done = false, if the replication stream requires it.
14
14
  */
15
- snapshot_lsn: t.Union<t.Codec<null, null, string, t.CodecProps>, t.IdentityCodec<t.CodecType.String>>;
15
+ snapshot_lsn: t.Codec<string | null, string | null>;
16
16
  /**
17
17
  * The last consistent checkpoint.
18
18
  *
19
19
  * There may be higher OpIds used in the database if we're in the middle of replicating a large transaction.
20
20
  */
21
- last_checkpoint: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<bigint, string | number, string, t.CodecProps>>;
21
+ last_checkpoint: t.Codec<bigint | null, string | number | null>;
22
22
  /**
23
23
  * The LSN associated with the last consistent checkpoint.
24
24
  */
25
- last_checkpoint_lsn: t.Union<t.Codec<null, null, string, t.CodecProps>, t.IdentityCodec<t.CodecType.String>>;
25
+ last_checkpoint_lsn: t.Codec<string | null, string | null>;
26
26
  /**
27
27
  * If set, no new checkpoints may be created < this value.
28
28
  */
29
- no_checkpoint_before: t.Union<t.Codec<null, null, string, t.CodecProps>, t.IdentityCodec<t.CodecType.String>>;
29
+ no_checkpoint_before: t.Codec<string | null, string | null>;
30
30
  slot_name: t.IdentityCodec<t.CodecType.String>;
31
31
  /**
32
32
  * Last time we persisted a checkpoint.
33
33
  *
34
34
  * This may be old if no data is incoming.
35
35
  */
36
- last_checkpoint_ts: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<Date, string | import("@powersync/service-sync-rules").DateTimeValue, string, t.CodecProps>>;
36
+ last_checkpoint_ts: t.Codec<Date | null, string | import("@powersync/service-sync-rules").DateTimeValue | null>;
37
37
  /**
38
38
  * Last time we persisted a checkpoint or keepalive.
39
39
  *
40
40
  * This should stay fairly current while replicating.
41
41
  */
42
- last_keepalive_ts: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<Date, string | import("@powersync/service-sync-rules").DateTimeValue, string, t.CodecProps>>;
42
+ last_keepalive_ts: t.Codec<Date | null, string | import("@powersync/service-sync-rules").DateTimeValue | null>;
43
43
  /**
44
44
  * If an error is stopping replication, it will be stored here.
45
45
  */
46
- last_fatal_error: t.Union<t.Codec<null, null, string, t.CodecProps>, t.IdentityCodec<t.CodecType.String>>;
47
- keepalive_op: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<bigint, string | number, string, t.CodecProps>>;
46
+ last_fatal_error: t.Codec<string | null, string | null>;
47
+ keepalive_op: t.Codec<bigint | null, string | number | null>;
48
48
  storage_version: t.OptionalCodec<t.Codec<number | null, number | null, string, t.CodecProps>>;
49
+ version_label: t.OptionalCodec<t.Codec<string | null, string | null, string, t.CodecProps>>;
49
50
  content: t.IdentityCodec<t.CodecType.String>;
50
- sync_plan: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<{
51
+ sync_plan: t.Codec<{
51
52
  plan: any;
52
53
  compatibility: {
53
54
  edition: number;
@@ -64,7 +65,7 @@ export declare const SyncRules: t.ObjectCodec<{
64
65
  } | undefined;
65
66
  ts?: string | undefined;
66
67
  }[] | undefined;
67
- }, import("@powersync/service-jsonbig").JsonContainer>>;
68
+ } | null, import("@powersync/service-jsonbig").JsonContainer | null>;
68
69
  }>;
69
70
  export type SyncRules = t.Encoded<typeof SyncRules>;
70
71
  export type SyncRulesDecoded = t.Decoded<typeof SyncRules>;
@@ -1,5 +1,5 @@
1
1
  import { framework, storage } from '@powersync/service-core';
2
- import { ReplicationError } from '@powersync/service-types';
2
+ import { orNull, ReplicationError } from '@powersync/service-types';
3
3
  import * as t from 'ts-codec';
4
4
  import { bigint, pgwire_number } from '../codecs.js';
5
5
  import { jsonContainerObject } from './json.js';
@@ -15,42 +15,43 @@ export const SyncRules = t.object({
15
15
  /**
16
16
  * May be set if snapshot_done = false, if the replication stream requires it.
17
17
  */
18
- snapshot_lsn: t.Null.or(t.string),
18
+ snapshot_lsn: orNull(t.string),
19
19
  /**
20
20
  * The last consistent checkpoint.
21
21
  *
22
22
  * There may be higher OpIds used in the database if we're in the middle of replicating a large transaction.
23
23
  */
24
- last_checkpoint: t.Null.or(bigint),
24
+ last_checkpoint: orNull(bigint),
25
25
  /**
26
26
  * The LSN associated with the last consistent checkpoint.
27
27
  */
28
- last_checkpoint_lsn: t.Null.or(t.string),
28
+ last_checkpoint_lsn: orNull(t.string),
29
29
  /**
30
30
  * If set, no new checkpoints may be created < this value.
31
31
  */
32
- no_checkpoint_before: t.Null.or(t.string),
32
+ no_checkpoint_before: orNull(t.string),
33
33
  slot_name: t.string,
34
34
  /**
35
35
  * Last time we persisted a checkpoint.
36
36
  *
37
37
  * This may be old if no data is incoming.
38
38
  */
39
- last_checkpoint_ts: t.Null.or(framework.codecs.date),
39
+ last_checkpoint_ts: orNull(framework.codecs.date),
40
40
  /**
41
41
  * Last time we persisted a checkpoint or keepalive.
42
42
  *
43
43
  * This should stay fairly current while replicating.
44
44
  */
45
- last_keepalive_ts: t.Null.or(framework.codecs.date),
45
+ last_keepalive_ts: orNull(framework.codecs.date),
46
46
  /**
47
47
  * If an error is stopping replication, it will be stored here.
48
48
  */
49
- last_fatal_error: t.Null.or(t.string),
50
- keepalive_op: t.Null.or(bigint),
51
- storage_version: t.Null.or(pgwire_number).optional(),
49
+ last_fatal_error: orNull(t.string),
50
+ keepalive_op: orNull(bigint),
51
+ storage_version: orNull(pgwire_number).optional(),
52
+ version_label: orNull(t.string).optional(),
52
53
  content: t.string,
53
- sync_plan: t.Null.or(jsonContainerObject(t.object({
54
+ sync_plan: orNull(jsonContainerObject(t.object({
54
55
  plan: t.any,
55
56
  compatibility: t.object({
56
57
  edition: t.number,
@@ -1 +1 @@
1
- {"version":3,"file":"SyncRules.js","sourceRoot":"","sources":["../../../src/types/models/SyncRules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,EAAE,EAAE,aAAa;IACjB,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;IACpC;;;;OAIG;IACH,aAAa,EAAE,CAAC,CAAC,OAAO;IACxB;;OAEG;IACH,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IACjC;;;;OAIG;IACH,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;IAClC;;OAEG;IACH,mBAAmB,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IACxC;;OAEG;IACH,oBAAoB,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IACzC,SAAS,EAAE,CAAC,CAAC,MAAM;IACnB;;;;OAIG;IACH,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;IACpD;;;;O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CAAC,CAAC,CAAC,OAAO,CAAC;YAC9B,qBAAqB,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;SAC3C,CAAC;QACF,gBAAgB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE;KAC7C,CAAC,CACH,CACF;CACF,CAAC,CAAC"}
@@ -3,6 +3,7 @@ export declare const WriteCheckpoint: t.ObjectCodec<{
3
3
  user_id: t.IdentityCodec<t.CodecType.String>;
4
4
  lsns: t.Codec<Record<string, string>, string, string, t.CodecProps>;
5
5
  write_checkpoint: t.Codec<bigint, string | number, string, t.CodecProps>;
6
+ checkpoint_requested_at: t.Codec<Date | null, string | import("@powersync/service-sync-rules").DateTimeValue | null>;
6
7
  }>;
7
8
  export type WriteCheckpoint = t.Encoded<typeof WriteCheckpoint>;
8
9
  export type WriteCheckpointDecoded = t.Decoded<typeof WriteCheckpoint>;
@@ -10,6 +11,7 @@ export declare const CustomWriteCheckpoint: t.ObjectCodec<{
10
11
  user_id: t.IdentityCodec<t.CodecType.String>;
11
12
  write_checkpoint: t.Codec<bigint, string | number, string, t.CodecProps>;
12
13
  sync_rules_id: t.Codec<bigint, string | number, string, t.CodecProps>;
14
+ checkpoint_requested_at: t.Codec<Date | null, string | import("@powersync/service-sync-rules").DateTimeValue | null>;
13
15
  }>;
14
16
  export type CustomWriteCheckpoint = t.Encoded<typeof CustomWriteCheckpoint>;
15
17
  export type CustomWriteCheckpointDecoded = t.Decoded<typeof CustomWriteCheckpoint>;
@@ -1,13 +1,17 @@
1
+ import { framework } from '@powersync/service-core';
2
+ import { orNull } from '@powersync/service-types';
1
3
  import * as t from 'ts-codec';
2
4
  import { bigint, jsonb } from '../codecs.js';
3
5
  export const WriteCheckpoint = t.object({
4
6
  user_id: t.string,
5
7
  lsns: jsonb(t.record(t.string)),
6
- write_checkpoint: bigint
8
+ write_checkpoint: bigint,
9
+ checkpoint_requested_at: orNull(framework.codecs.date)
7
10
  });
8
11
  export const CustomWriteCheckpoint = t.object({
9
12
  user_id: t.string,
10
13
  write_checkpoint: bigint,
11
- sync_rules_id: bigint
14
+ sync_rules_id: bigint,
15
+ checkpoint_requested_at: orNull(framework.codecs.date)
12
16
  });
13
17
  //# sourceMappingURL=WriteCheckpoint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WriteCheckpoint.js","sourceRoot":"","sources":["../../../src/types/models/WriteCheckpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,OAAO,EAAE,CAAC,CAAC,MAAM;IACjB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC/B,gBAAgB,EAAE,MAAM;CACzB,CAAC,CAAC;AAKH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC,MAAM;IACjB,gBAAgB,EAAE,MAAM;IACxB,aAAa,EAAE,MAAM;CACtB,CAAC,CAAC"}
1
+ {"version":3,"file":"WriteCheckpoint.js","sourceRoot":"","sources":["../../../src/types/models/WriteCheckpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,OAAO,EAAE,CAAC,CAAC,MAAM;IACjB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC/B,gBAAgB,EAAE,MAAM;IACxB,uBAAuB,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;CACvD,CAAC,CAAC;AAKH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC,MAAM;IACjB,gBAAgB,EAAE,MAAM;IACxB,aAAa,EAAE,MAAM;IACrB,uBAAuB,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;CACvD,CAAC,CAAC"}
@@ -32,6 +32,7 @@ export type OperationBatchLimits = t.Encoded<typeof OperationBatchLimits>;
32
32
  export declare const PostgresStorageConfig: t.Intersection<t.Codec<{
33
33
  type: string;
34
34
  max_pool_size?: number | undefined;
35
+ default_storage_version?: number | undefined;
35
36
  } & {
36
37
  type: "postgresql";
37
38
  id?: string | undefined;
@@ -54,6 +55,7 @@ export declare const PostgresStorageConfig: t.Intersection<t.Codec<{
54
55
  }, {
55
56
  type: string;
56
57
  max_pool_size?: number | undefined;
58
+ default_storage_version?: number | undefined;
57
59
  } & {
58
60
  type: "postgresql";
59
61
  id?: string | undefined;
@@ -0,0 +1,9 @@
1
+ import * as lib_postgres from '@powersync/lib-service-postgres';
2
+ import { models } from '../types/types.js';
3
+ /**
4
+ * Gets the latest active checkpoint document.
5
+ * This is mainly exported for mocking in tests.
6
+ */
7
+ export declare function getActiveCheckpointDocument({ db }: {
8
+ db: lib_postgres.DatabaseClient;
9
+ }): Promise<models.ActiveCheckpointDecoded | null>;
@@ -0,0 +1,26 @@
1
+ import { storage } from '@powersync/service-core';
2
+ import { models } from '../types/types.js';
3
+ /**
4
+ * Gets the latest active checkpoint document.
5
+ * This is mainly exported for mocking in tests.
6
+ */
7
+ export async function getActiveCheckpointDocument({ db }) {
8
+ return db.sql `
9
+ SELECT
10
+ id,
11
+ last_checkpoint,
12
+ last_checkpoint_lsn
13
+ FROM
14
+ sync_rules
15
+ WHERE
16
+ state = ${{ value: storage.SyncRuleState.ACTIVE, type: 'varchar' }}
17
+ OR state = ${{ value: storage.SyncRuleState.ERRORED, type: 'varchar' }}
18
+ ORDER BY
19
+ id DESC
20
+ LIMIT
21
+ 1
22
+ `
23
+ .decoded(models.ActiveCheckpoint)
24
+ .first();
25
+ }
26
+ //# sourceMappingURL=checkpoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkpoints.js","sourceRoot":"","sources":["../../src/utils/checkpoints.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,EAChD,EAAE,EAGH;IACC,OAAO,EAAE,CAAC,GAAG,CAAA;;;;;;;;gBAQC,EAAE,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;mBACrD,EAAE,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;;;;;GAKzE;SACE,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC;SAChC,KAAK,EAAE,CAAC;AACb,CAAC"}
@@ -54,7 +54,7 @@ export function postgresTestSetup(factoryOptions) {
54
54
  await runMigrations({ down: false, up: true });
55
55
  await using storageFactory = new PostgresBucketStorageFactory({
56
56
  config: TEST_CONNECTION_OPTIONS,
57
- slot_name_prefix: 'test_'
57
+ replicationStreamNamePrefix: 'test_'
58
58
  });
59
59
  await truncateTables(storageFactory.db);
60
60
  };
@@ -81,7 +81,7 @@ export function postgresTestSetup(factoryOptions) {
81
81
  }
82
82
  return new PostgresBucketStorageFactory({
83
83
  config: TEST_CONNECTION_OPTIONS,
84
- slot_name_prefix: 'test_'
84
+ replicationStreamNamePrefix: 'test_'
85
85
  });
86
86
  }
87
87
  catch (ex) {