@powersync/common 0.0.0-dev-20260504100448 → 0.0.0-dev-20260630141119
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/lib/attachments/AttachmentContext.d.ts +9 -8
- package/lib/attachments/AttachmentContext.js +8 -3
- package/lib/attachments/AttachmentContext.js.map +1 -1
- package/lib/attachments/AttachmentErrorHandler.d.ts +6 -6
- package/lib/attachments/AttachmentQueue.d.ts +85 -36
- package/lib/attachments/AttachmentQueue.js +19 -21
- package/lib/attachments/AttachmentQueue.js.map +1 -1
- package/lib/attachments/AttachmentService.d.ts +3 -3
- package/lib/attachments/AttachmentService.js +4 -3
- package/lib/attachments/AttachmentService.js.map +1 -1
- package/lib/attachments/LocalStorageAdapter.d.ts +14 -8
- package/lib/attachments/LocalStorageAdapter.js +3 -0
- package/lib/attachments/LocalStorageAdapter.js.map +1 -1
- package/lib/attachments/RemoteStorageAdapter.d.ts +4 -4
- package/lib/attachments/Schema.d.ts +14 -6
- package/lib/attachments/Schema.js +8 -3
- package/lib/attachments/Schema.js.map +1 -1
- package/lib/attachments/SyncingService.d.ts +2 -2
- package/lib/attachments/SyncingService.js +8 -3
- package/lib/attachments/SyncingService.js.map +1 -1
- package/lib/attachments/WatchedAttachmentItem.d.ts +3 -1
- package/lib/client/{AbstractPowerSyncDatabase.d.ts → CommonPowerSyncDatabase.d.ts} +112 -238
- package/lib/client/CommonPowerSyncDatabase.js +2 -0
- package/lib/client/CommonPowerSyncDatabase.js.map +1 -0
- package/lib/client/Query.d.ts +9 -0
- package/lib/client/SQLOpenFactory.d.ts +44 -10
- package/lib/client/SQLOpenFactory.js +1 -19
- package/lib/client/SQLOpenFactory.js.map +1 -1
- package/lib/client/compilableQueryWatch.d.ts +8 -2
- package/lib/client/compilableQueryWatch.js +4 -2
- package/lib/client/compilableQueryWatch.js.map +1 -1
- package/lib/client/connection/PowerSyncBackendConnector.d.ts +6 -3
- package/lib/client/connection/PowerSyncCredentials.d.ts +3 -0
- package/lib/client/runOnSchemaChange.d.ts +5 -2
- package/lib/client/runOnSchemaChange.js +3 -0
- package/lib/client/runOnSchemaChange.js.map +1 -1
- package/lib/client/sync/bucket/CrudBatch.d.ts +2 -0
- package/lib/client/sync/bucket/CrudBatch.js +2 -0
- package/lib/client/sync/bucket/CrudBatch.js.map +1 -1
- package/lib/client/sync/bucket/CrudEntry.d.ts +9 -31
- package/lib/client/sync/bucket/CrudEntry.js +2 -97
- package/lib/client/sync/bucket/CrudEntry.js.map +1 -1
- package/lib/client/sync/bucket/CrudTransaction.d.ts +3 -0
- package/lib/client/sync/bucket/CrudTransaction.js +3 -0
- package/lib/client/sync/bucket/CrudTransaction.js.map +1 -1
- package/lib/client/sync/options.d.ts +65 -0
- package/lib/client/sync/options.js +25 -0
- package/lib/client/sync/options.js.map +1 -0
- package/lib/client/sync/stream/JsonValue.d.ts +3 -0
- package/lib/client/sync/sync-streams.d.ts +23 -8
- package/lib/client/triggers/TriggerManager.d.ts +28 -56
- package/lib/client/triggers/TriggerManager.js +2 -1
- package/lib/client/triggers/TriggerManager.js.map +1 -1
- package/lib/client/triggers/sanitizeSQL.d.ts +4 -0
- package/lib/client/triggers/sanitizeSQL.js +4 -0
- package/lib/client/triggers/sanitizeSQL.js.map +1 -1
- package/lib/client/watched/GetAllQuery.d.ts +7 -3
- package/lib/client/watched/GetAllQuery.js +3 -1
- package/lib/client/watched/GetAllQuery.js.map +1 -1
- package/lib/client/watched/WatchedQuery.d.ts +20 -6
- package/lib/client/watched/WatchedQuery.js +3 -5
- package/lib/client/watched/WatchedQuery.js.map +1 -1
- package/lib/client/watched/processors/DifferentialQueryProcessor.d.ts +15 -45
- package/lib/client/watched/processors/DifferentialQueryProcessor.js +1 -172
- package/lib/client/watched/processors/DifferentialQueryProcessor.js.map +1 -1
- package/lib/client/watched/processors/OnChangeQueryProcessor.d.ts +4 -22
- package/lib/client/watched/processors/OnChangeQueryProcessor.js +1 -82
- package/lib/client/watched/processors/OnChangeQueryProcessor.js.map +1 -1
- package/lib/client/watched/processors/comparators.d.ts +8 -0
- package/lib/client/watched/processors/comparators.js +4 -0
- package/lib/client/watched/processors/comparators.js.map +1 -1
- package/lib/db/DBAdapter.d.ts +90 -113
- package/lib/db/DBAdapter.js +70 -89
- package/lib/db/DBAdapter.js.map +1 -1
- package/lib/db/QueryResult.d.ts +104 -0
- package/lib/db/QueryResult.js +96 -0
- package/lib/db/QueryResult.js.map +1 -0
- package/lib/db/crud/SyncProgress.d.ts +7 -14
- package/lib/db/crud/SyncProgress.js +1 -60
- package/lib/db/crud/SyncProgress.js.map +1 -1
- package/lib/db/crud/SyncStatus.d.ts +54 -91
- package/lib/db/crud/SyncStatus.js +1 -245
- package/lib/db/crud/SyncStatus.js.map +1 -1
- package/lib/db/crud/UploadQueueStatus.d.ts +3 -0
- package/lib/db/crud/UploadQueueStatus.js +3 -0
- package/lib/db/crud/UploadQueueStatus.js.map +1 -1
- package/lib/db/schema/Column.d.ts +22 -1
- package/lib/db/schema/Column.js +10 -4
- package/lib/db/schema/Column.js.map +1 -1
- package/lib/db/schema/Index.d.ts +8 -3
- package/lib/db/schema/Index.js +4 -1
- package/lib/db/schema/Index.js.map +1 -1
- package/lib/db/schema/IndexedColumn.d.ts +8 -3
- package/lib/db/schema/IndexedColumn.js +4 -1
- package/lib/db/schema/IndexedColumn.js.map +1 -1
- package/lib/db/schema/RawTable.d.ts +7 -1
- package/lib/db/schema/Schema.d.ts +10 -29
- package/lib/db/schema/Schema.js +3 -1
- package/lib/db/schema/Schema.js.map +1 -1
- package/lib/db/schema/Table.d.ts +69 -91
- package/lib/db/schema/Table.js +88 -87
- package/lib/db/schema/Table.js.map +1 -1
- package/lib/index.d.ts +6 -22
- package/lib/index.js +5 -22
- package/lib/index.js.map +1 -1
- package/lib/types/types.d.ts +6 -0
- package/lib/utils/BaseObserver.d.ts +12 -0
- package/lib/utils/BaseObserver.js +3 -0
- package/lib/utils/BaseObserver.js.map +1 -1
- package/lib/utils/Logger.d.ts +60 -22
- package/lib/utils/Logger.js +38 -30
- package/lib/utils/Logger.js.map +1 -1
- package/lib/utils/MetaBaseObserver.d.ts +11 -11
- package/lib/utils/MetaBaseObserver.js +1 -50
- package/lib/utils/MetaBaseObserver.js.map +1 -1
- package/lib/utils/mutex.d.ts +3 -45
- package/lib/utils/mutex.js +1 -153
- package/lib/utils/mutex.js.map +1 -1
- package/package.json +9 -46
- package/src/attachments/AttachmentContext.ts +15 -13
- package/src/attachments/AttachmentErrorHandler.ts +6 -6
- package/src/attachments/AttachmentQueue.ts +99 -42
- package/src/attachments/AttachmentService.ts +7 -6
- package/src/attachments/LocalStorageAdapter.ts +14 -8
- package/src/attachments/README.md +2 -0
- package/src/attachments/RemoteStorageAdapter.ts +4 -4
- package/src/attachments/Schema.ts +14 -6
- package/src/attachments/SyncingService.ts +10 -6
- package/src/attachments/WatchedAttachmentItem.ts +3 -1
- package/src/client/CommonPowerSyncDatabase.ts +540 -0
- package/src/client/Query.ts +9 -0
- package/src/client/SQLOpenFactory.ts +47 -19
- package/src/client/compilableQueryWatch.ts +9 -4
- package/src/client/connection/PowerSyncBackendConnector.ts +6 -3
- package/src/client/connection/PowerSyncCredentials.ts +3 -0
- package/src/client/runOnSchemaChange.ts +5 -2
- package/src/client/sync/bucket/CrudBatch.ts +2 -0
- package/src/client/sync/bucket/CrudEntry.ts +10 -101
- package/src/client/sync/bucket/CrudTransaction.ts +3 -0
- package/src/client/sync/options.ts +77 -0
- package/src/client/sync/stream/JsonValue.ts +3 -0
- package/src/client/sync/sync-streams.ts +23 -10
- package/src/client/triggers/TriggerManager.ts +29 -59
- package/src/client/triggers/sanitizeSQL.ts +5 -0
- package/src/client/watched/GetAllQuery.ts +8 -4
- package/src/client/watched/WatchedQuery.ts +20 -11
- package/src/client/watched/processors/DifferentialQueryProcessor.ts +19 -219
- package/src/client/watched/processors/OnChangeQueryProcessor.ts +4 -109
- package/src/client/watched/processors/comparators.ts +8 -0
- package/src/db/DBAdapter.ts +160 -175
- package/src/db/QueryResult.ts +195 -0
- package/src/db/crud/SyncProgress.ts +8 -43
- package/src/db/crud/SyncStatus.ts +66 -216
- package/src/db/crud/UploadQueueStatus.ts +3 -0
- package/src/db/schema/Column.ts +22 -5
- package/src/db/schema/Index.ts +9 -3
- package/src/db/schema/IndexedColumn.ts +9 -3
- package/src/db/schema/RawTable.ts +7 -1
- package/src/db/schema/Schema.ts +12 -7
- package/src/db/schema/Table.ts +130 -180
- package/src/index.ts +6 -22
- package/src/types/types.ts +6 -0
- package/src/utils/BaseObserver.ts +12 -0
- package/src/utils/Logger.ts +86 -31
- package/src/utils/MetaBaseObserver.ts +14 -60
- package/src/utils/mutex.ts +4 -189
- package/dist/bundle.cjs +0 -14136
- package/dist/bundle.cjs.map +0 -1
- package/dist/bundle.mjs +0 -14056
- package/dist/bundle.mjs.map +0 -1
- package/dist/bundle.node.cjs +0 -11613
- package/dist/bundle.node.cjs.map +0 -1
- package/dist/bundle.node.mjs +0 -11533
- package/dist/bundle.node.mjs.map +0 -1
- package/dist/index.d.cts +0 -4052
- package/legacy/sync_protocol.d.ts +0 -103
- package/lib/client/AbstractPowerSyncDatabase.js +0 -987
- package/lib/client/AbstractPowerSyncDatabase.js.map +0 -1
- package/lib/client/AbstractPowerSyncOpenFactory.d.ts +0 -22
- package/lib/client/AbstractPowerSyncOpenFactory.js +0 -25
- package/lib/client/AbstractPowerSyncOpenFactory.js.map +0 -1
- package/lib/client/ConnectionManager.d.ts +0 -112
- package/lib/client/ConnectionManager.js +0 -294
- package/lib/client/ConnectionManager.js.map +0 -1
- package/lib/client/CustomQuery.d.ts +0 -22
- package/lib/client/CustomQuery.js +0 -43
- package/lib/client/CustomQuery.js.map +0 -1
- package/lib/client/constants.d.ts +0 -1
- package/lib/client/constants.js +0 -2
- package/lib/client/constants.js.map +0 -1
- package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +0 -40
- package/lib/client/sync/bucket/BucketStorageAdapter.js +0 -19
- package/lib/client/sync/bucket/BucketStorageAdapter.js.map +0 -1
- package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +0 -34
- package/lib/client/sync/bucket/SqliteBucketStorage.js +0 -162
- package/lib/client/sync/bucket/SqliteBucketStorage.js.map +0 -1
- package/lib/client/sync/stream/AbstractRemote.d.ts +0 -151
- package/lib/client/sync/stream/AbstractRemote.js +0 -473
- package/lib/client/sync/stream/AbstractRemote.js.map +0 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +0 -218
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +0 -663
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +0 -1
- package/lib/client/sync/stream/WebsocketClientTransport.d.ts +0 -15
- package/lib/client/sync/stream/WebsocketClientTransport.js +0 -61
- package/lib/client/sync/stream/WebsocketClientTransport.js.map +0 -1
- package/lib/client/sync/stream/core-instruction.d.ts +0 -71
- package/lib/client/sync/stream/core-instruction.js +0 -27
- package/lib/client/sync/stream/core-instruction.js.map +0 -1
- package/lib/client/triggers/MemoryTriggerClaimManager.d.ts +0 -6
- package/lib/client/triggers/MemoryTriggerClaimManager.js +0 -21
- package/lib/client/triggers/MemoryTriggerClaimManager.js.map +0 -1
- package/lib/client/triggers/TriggerManagerImpl.d.ts +0 -39
- package/lib/client/triggers/TriggerManagerImpl.js +0 -405
- package/lib/client/triggers/TriggerManagerImpl.js.map +0 -1
- package/lib/client/watched/processors/AbstractQueryProcessor.d.ts +0 -68
- package/lib/client/watched/processors/AbstractQueryProcessor.js +0 -151
- package/lib/client/watched/processors/AbstractQueryProcessor.js.map +0 -1
- package/lib/db/ConnectionClosedError.d.ts +0 -10
- package/lib/db/ConnectionClosedError.js +0 -21
- package/lib/db/ConnectionClosedError.js.map +0 -1
- package/lib/db/schema/TableV2.d.ts +0 -9
- package/lib/db/schema/TableV2.js +0 -9
- package/lib/db/schema/TableV2.js.map +0 -1
- package/lib/utils/AbortOperation.d.ts +0 -9
- package/lib/utils/AbortOperation.js +0 -19
- package/lib/utils/AbortOperation.js.map +0 -1
- package/lib/utils/ControlledExecutor.d.ts +0 -25
- package/lib/utils/ControlledExecutor.js +0 -51
- package/lib/utils/ControlledExecutor.js.map +0 -1
- package/lib/utils/async.d.ts +0 -14
- package/lib/utils/async.js +0 -46
- package/lib/utils/async.js.map +0 -1
- package/lib/utils/parseQuery.d.ts +0 -6
- package/lib/utils/parseQuery.js +0 -17
- package/lib/utils/parseQuery.js.map +0 -1
- package/lib/utils/queue.d.ts +0 -16
- package/lib/utils/queue.js +0 -42
- package/lib/utils/queue.js.map +0 -1
- package/lib/utils/stream_transform.d.ts +0 -39
- package/lib/utils/stream_transform.js +0 -206
- package/lib/utils/stream_transform.js.map +0 -1
- package/src/client/AbstractPowerSyncDatabase.ts +0 -1362
- package/src/client/AbstractPowerSyncOpenFactory.ts +0 -39
- package/src/client/ConnectionManager.ts +0 -402
- package/src/client/CustomQuery.ts +0 -56
- package/src/client/constants.ts +0 -1
- package/src/client/sync/bucket/BucketStorageAdapter.ts +0 -49
- package/src/client/sync/bucket/SqliteBucketStorage.ts +0 -199
- package/src/client/sync/stream/AbstractRemote.ts +0 -602
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +0 -905
- package/src/client/sync/stream/WebsocketClientTransport.ts +0 -80
- package/src/client/sync/stream/core-instruction.ts +0 -98
- package/src/client/triggers/MemoryTriggerClaimManager.ts +0 -25
- package/src/client/triggers/TriggerManagerImpl.ts +0 -496
- package/src/client/watched/processors/AbstractQueryProcessor.ts +0 -226
- package/src/db/ConnectionClosedError.ts +0 -23
- package/src/db/schema/TableV2.ts +0 -9
- package/src/utils/AbortOperation.ts +0 -17
- package/src/utils/ControlledExecutor.ts +0 -72
- package/src/utils/async.ts +0 -50
- package/src/utils/parseQuery.ts +0 -25
- package/src/utils/queue.ts +0 -48
- package/src/utils/stream_transform.ts +0 -252
|
@@ -1,473 +0,0 @@
|
|
|
1
|
-
import Logger from 'js-logger';
|
|
2
|
-
import { RSocketConnector } from 'rsocket-core';
|
|
3
|
-
import PACKAGE from '../../../../package.json' with { type: 'json' };
|
|
4
|
-
import { AbortOperation } from '../../../utils/AbortOperation.js';
|
|
5
|
-
import { WebsocketClientTransport } from './WebsocketClientTransport.js';
|
|
6
|
-
import { doneResult, extractBsonObjects, extractJsonLines } from '../../../utils/stream_transform.js';
|
|
7
|
-
import { EventIterator } from 'event-iterator';
|
|
8
|
-
const POWERSYNC_TRAILING_SLASH_MATCH = /\/+$/;
|
|
9
|
-
const POWERSYNC_JS_VERSION = PACKAGE.version;
|
|
10
|
-
const SYNC_QUEUE_REQUEST_HIGH_WATER = 10;
|
|
11
|
-
const SYNC_QUEUE_REQUEST_LOW_WATER = 5;
|
|
12
|
-
// Keep alive message is sent every period
|
|
13
|
-
const KEEP_ALIVE_MS = 20_000;
|
|
14
|
-
// One message of any type must be received in this period.
|
|
15
|
-
const SOCKET_TIMEOUT_MS = 30_000;
|
|
16
|
-
// One keepalive message must be received in this period.
|
|
17
|
-
// If there is a backlog of messages (for example on slow connections), keepalive messages could be delayed
|
|
18
|
-
// significantly. Therefore this is longer than the socket timeout.
|
|
19
|
-
const KEEP_ALIVE_LIFETIME_MS = 90_000;
|
|
20
|
-
export const DEFAULT_REMOTE_LOGGER = Logger.get('PowerSyncRemote');
|
|
21
|
-
export var FetchStrategy;
|
|
22
|
-
(function (FetchStrategy) {
|
|
23
|
-
/**
|
|
24
|
-
* Queues multiple sync events before processing, reducing round-trips.
|
|
25
|
-
* This comes at the cost of more processing overhead, which may cause ACK timeouts on older/weaker devices for big enough datasets.
|
|
26
|
-
*/
|
|
27
|
-
FetchStrategy["Buffered"] = "buffered";
|
|
28
|
-
/**
|
|
29
|
-
* Processes each sync event immediately before requesting the next.
|
|
30
|
-
* This reduces processing overhead and improves real-time responsiveness.
|
|
31
|
-
*/
|
|
32
|
-
FetchStrategy["Sequential"] = "sequential";
|
|
33
|
-
})(FetchStrategy || (FetchStrategy = {}));
|
|
34
|
-
/**
|
|
35
|
-
* Class wrapper for providing a fetch implementation.
|
|
36
|
-
* The class wrapper is used to distinguish the fetchImplementation
|
|
37
|
-
* option in [AbstractRemoteOptions] from the general fetch method
|
|
38
|
-
* which is typeof "function"
|
|
39
|
-
*/
|
|
40
|
-
export class FetchImplementationProvider {
|
|
41
|
-
getFetch() {
|
|
42
|
-
throw new Error('Unspecified fetch implementation');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export const DEFAULT_REMOTE_OPTIONS = {
|
|
46
|
-
socketUrlTransformer: (url) => url.replace(/^https?:\/\//, function (match) {
|
|
47
|
-
return match === 'https://' ? 'wss://' : 'ws://';
|
|
48
|
-
}),
|
|
49
|
-
fetchImplementation: new FetchImplementationProvider(),
|
|
50
|
-
fetchOptions: {}
|
|
51
|
-
};
|
|
52
|
-
export class AbstractRemote {
|
|
53
|
-
connector;
|
|
54
|
-
logger;
|
|
55
|
-
credentials = null;
|
|
56
|
-
options;
|
|
57
|
-
constructor(connector, logger = DEFAULT_REMOTE_LOGGER, options) {
|
|
58
|
-
this.connector = connector;
|
|
59
|
-
this.logger = logger;
|
|
60
|
-
this.options = {
|
|
61
|
-
...DEFAULT_REMOTE_OPTIONS,
|
|
62
|
-
...(options ?? {})
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* @returns a fetch implementation (function)
|
|
67
|
-
* which can be called to perform fetch requests
|
|
68
|
-
*/
|
|
69
|
-
get fetch() {
|
|
70
|
-
const { fetchImplementation } = this.options;
|
|
71
|
-
return fetchImplementation instanceof FetchImplementationProvider
|
|
72
|
-
? fetchImplementation.getFetch()
|
|
73
|
-
: fetchImplementation;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Get credentials currently cached, or fetch new credentials if none are
|
|
77
|
-
* available.
|
|
78
|
-
*
|
|
79
|
-
* These credentials may have expired already.
|
|
80
|
-
*/
|
|
81
|
-
async getCredentials() {
|
|
82
|
-
if (this.credentials) {
|
|
83
|
-
return this.credentials;
|
|
84
|
-
}
|
|
85
|
-
return this.prefetchCredentials();
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Fetch a new set of credentials and cache it.
|
|
89
|
-
*
|
|
90
|
-
* Until this call succeeds, `getCredentials` will still return the
|
|
91
|
-
* old credentials.
|
|
92
|
-
*
|
|
93
|
-
* This may be called before the current credentials have expired.
|
|
94
|
-
*/
|
|
95
|
-
async prefetchCredentials() {
|
|
96
|
-
this.credentials = await this.fetchCredentials();
|
|
97
|
-
return this.credentials;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Get credentials for PowerSync.
|
|
101
|
-
*
|
|
102
|
-
* This should always fetch a fresh set of credentials - don't use cached
|
|
103
|
-
* values.
|
|
104
|
-
*/
|
|
105
|
-
async fetchCredentials() {
|
|
106
|
-
const credentials = await this.connector.fetchCredentials();
|
|
107
|
-
if (credentials?.endpoint.match(POWERSYNC_TRAILING_SLASH_MATCH)) {
|
|
108
|
-
throw new Error(`A trailing forward slash "/" was found in the fetchCredentials endpoint: "${credentials.endpoint}". Remove the trailing forward slash "/" to fix this error.`);
|
|
109
|
-
}
|
|
110
|
-
return credentials;
|
|
111
|
-
}
|
|
112
|
-
/***
|
|
113
|
-
* Immediately invalidate credentials.
|
|
114
|
-
*
|
|
115
|
-
* This may be called when the current credentials have expired.
|
|
116
|
-
*/
|
|
117
|
-
invalidateCredentials() {
|
|
118
|
-
this.credentials = null;
|
|
119
|
-
this.connector.invalidateCredentials?.();
|
|
120
|
-
}
|
|
121
|
-
getUserAgent() {
|
|
122
|
-
return `powersync-js/${POWERSYNC_JS_VERSION}`;
|
|
123
|
-
}
|
|
124
|
-
async buildRequest(path) {
|
|
125
|
-
const credentials = await this.getCredentials();
|
|
126
|
-
if (credentials != null && (credentials.endpoint == null || credentials.endpoint == '')) {
|
|
127
|
-
throw new Error('PowerSync endpoint not configured');
|
|
128
|
-
}
|
|
129
|
-
else if (credentials?.token == null || credentials?.token == '') {
|
|
130
|
-
const error = new Error(`Not signed in`);
|
|
131
|
-
error.status = 401;
|
|
132
|
-
throw error;
|
|
133
|
-
}
|
|
134
|
-
const userAgent = this.getUserAgent();
|
|
135
|
-
return {
|
|
136
|
-
url: credentials.endpoint + path,
|
|
137
|
-
headers: {
|
|
138
|
-
'content-type': 'application/json',
|
|
139
|
-
Authorization: `Token ${credentials.token}`,
|
|
140
|
-
'x-user-agent': userAgent
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
async post(path, data, headers = {}) {
|
|
145
|
-
const request = await this.buildRequest(path);
|
|
146
|
-
const res = await this.fetch(request.url, {
|
|
147
|
-
method: 'POST',
|
|
148
|
-
headers: {
|
|
149
|
-
...headers,
|
|
150
|
-
...request.headers
|
|
151
|
-
},
|
|
152
|
-
body: JSON.stringify(data)
|
|
153
|
-
});
|
|
154
|
-
if (res.status === 401) {
|
|
155
|
-
this.invalidateCredentials();
|
|
156
|
-
}
|
|
157
|
-
if (!res.ok) {
|
|
158
|
-
throw new Error(`Received ${res.status} - ${res.statusText} when posting to ${path}: ${await res.text()}}`);
|
|
159
|
-
}
|
|
160
|
-
return res.json();
|
|
161
|
-
}
|
|
162
|
-
async get(path, headers) {
|
|
163
|
-
const request = await this.buildRequest(path);
|
|
164
|
-
const res = await this.fetch(request.url, {
|
|
165
|
-
method: 'GET',
|
|
166
|
-
headers: {
|
|
167
|
-
...headers,
|
|
168
|
-
...request.headers
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
if (res.status === 401) {
|
|
172
|
-
this.invalidateCredentials();
|
|
173
|
-
}
|
|
174
|
-
if (!res.ok) {
|
|
175
|
-
throw new Error(`Received ${res.status} - ${res.statusText} when getting from ${path}: ${await res.text()}}`);
|
|
176
|
-
}
|
|
177
|
-
return res.json();
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* @returns A text decoder decoding UTF-8. This is a method to allow patching it for Hermes which doesn't support the
|
|
181
|
-
* builtin, without forcing us to bundle a polyfill with `@powersync/common`.
|
|
182
|
-
*/
|
|
183
|
-
createTextDecoder() {
|
|
184
|
-
return new TextDecoder();
|
|
185
|
-
}
|
|
186
|
-
createSocket(url) {
|
|
187
|
-
return new WebSocket(url);
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Returns a data stream of sync line data, fetched via RSocket-over-WebSocket.
|
|
191
|
-
*
|
|
192
|
-
* The only mechanism to abort the returned stream is to use the abort signal in {@link SocketSyncStreamOptions}.
|
|
193
|
-
*/
|
|
194
|
-
async socketStreamRaw(options) {
|
|
195
|
-
const { path, fetchStrategy = FetchStrategy.Buffered } = options;
|
|
196
|
-
const mimeType = 'application/json';
|
|
197
|
-
function toBuffer(js) {
|
|
198
|
-
return Buffer.from(JSON.stringify(js));
|
|
199
|
-
}
|
|
200
|
-
const syncQueueRequestSize = fetchStrategy == FetchStrategy.Buffered ? 10 : 1;
|
|
201
|
-
const request = await this.buildRequest(path);
|
|
202
|
-
const url = this.options.socketUrlTransformer(request.url);
|
|
203
|
-
// Add the user agent in the setup payload - we can't set custom
|
|
204
|
-
// headers with websockets on web. The browser userAgent is however added
|
|
205
|
-
// automatically as a header.
|
|
206
|
-
const userAgent = this.getUserAgent();
|
|
207
|
-
// While we're connecting (a process that can't be aborted in RSocket), the WebSocket instance to close if we wanted
|
|
208
|
-
// to abort the connection.
|
|
209
|
-
let pendingSocket = null;
|
|
210
|
-
let keepAliveTimeout;
|
|
211
|
-
let rsocket = null;
|
|
212
|
-
let queue = null;
|
|
213
|
-
let didClose = false;
|
|
214
|
-
const abortRequest = () => {
|
|
215
|
-
if (didClose) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
didClose = true;
|
|
219
|
-
clearTimeout(keepAliveTimeout);
|
|
220
|
-
if (pendingSocket) {
|
|
221
|
-
pendingSocket.close();
|
|
222
|
-
}
|
|
223
|
-
if (rsocket) {
|
|
224
|
-
rsocket.close();
|
|
225
|
-
}
|
|
226
|
-
if (queue) {
|
|
227
|
-
queue.stop();
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
// Handle upstream abort
|
|
231
|
-
if (options.abortSignal.aborted) {
|
|
232
|
-
throw new AbortOperation('Connection request aborted');
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
options.abortSignal.addEventListener('abort', abortRequest);
|
|
236
|
-
}
|
|
237
|
-
const resetTimeout = () => {
|
|
238
|
-
clearTimeout(keepAliveTimeout);
|
|
239
|
-
keepAliveTimeout = setTimeout(() => {
|
|
240
|
-
this.logger.error(`No data received on WebSocket in ${SOCKET_TIMEOUT_MS}ms, closing connection.`);
|
|
241
|
-
abortRequest();
|
|
242
|
-
}, SOCKET_TIMEOUT_MS);
|
|
243
|
-
};
|
|
244
|
-
resetTimeout();
|
|
245
|
-
const connector = new RSocketConnector({
|
|
246
|
-
transport: new WebsocketClientTransport({
|
|
247
|
-
url,
|
|
248
|
-
wsCreator: (url) => {
|
|
249
|
-
const socket = (pendingSocket = this.createSocket(url));
|
|
250
|
-
socket.addEventListener('message', () => {
|
|
251
|
-
resetTimeout();
|
|
252
|
-
});
|
|
253
|
-
return socket;
|
|
254
|
-
}
|
|
255
|
-
}),
|
|
256
|
-
setup: {
|
|
257
|
-
keepAlive: KEEP_ALIVE_MS,
|
|
258
|
-
lifetime: KEEP_ALIVE_LIFETIME_MS,
|
|
259
|
-
dataMimeType: mimeType,
|
|
260
|
-
metadataMimeType: mimeType,
|
|
261
|
-
payload: {
|
|
262
|
-
data: null,
|
|
263
|
-
metadata: toBuffer({
|
|
264
|
-
token: request.headers.Authorization,
|
|
265
|
-
user_agent: userAgent
|
|
266
|
-
})
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
try {
|
|
271
|
-
rsocket = await connector.connect();
|
|
272
|
-
// The connection is established, we no longer need to monitor the initial timeout
|
|
273
|
-
pendingSocket = null;
|
|
274
|
-
}
|
|
275
|
-
catch (ex) {
|
|
276
|
-
this.logger.error(`Failed to connect WebSocket`, ex);
|
|
277
|
-
abortRequest();
|
|
278
|
-
throw ex;
|
|
279
|
-
}
|
|
280
|
-
resetTimeout();
|
|
281
|
-
// Helps to prevent double close scenarios
|
|
282
|
-
rsocket.onClose(() => (rsocket = null));
|
|
283
|
-
return await new Promise((resolve, reject) => {
|
|
284
|
-
let connectionEstablished = false;
|
|
285
|
-
let pendingEventsCount = syncQueueRequestSize;
|
|
286
|
-
let paused = false;
|
|
287
|
-
let res = null;
|
|
288
|
-
function requestMore() {
|
|
289
|
-
const delta = syncQueueRequestSize - pendingEventsCount;
|
|
290
|
-
if (!paused && delta > 0) {
|
|
291
|
-
res?.request(delta);
|
|
292
|
-
pendingEventsCount = syncQueueRequestSize;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
const events = new EventIterator((q) => {
|
|
296
|
-
queue = q;
|
|
297
|
-
q.on('highWater', () => (paused = true));
|
|
298
|
-
q.on('lowWater', () => {
|
|
299
|
-
paused = false;
|
|
300
|
-
requestMore();
|
|
301
|
-
});
|
|
302
|
-
}, { highWaterMark: SYNC_QUEUE_REQUEST_HIGH_WATER, lowWaterMark: SYNC_QUEUE_REQUEST_LOW_WATER })[Symbol.asyncIterator]();
|
|
303
|
-
res = rsocket.requestStream({
|
|
304
|
-
data: toBuffer(options.data),
|
|
305
|
-
metadata: toBuffer({
|
|
306
|
-
path
|
|
307
|
-
})
|
|
308
|
-
}, syncQueueRequestSize, // The initial N amount
|
|
309
|
-
{
|
|
310
|
-
onError: (e) => {
|
|
311
|
-
if (e.message.includes('PSYNC_')) {
|
|
312
|
-
if (e.message.includes('PSYNC_S21')) {
|
|
313
|
-
this.invalidateCredentials();
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
// Possible that connection is with an older service, always invalidate to be safe
|
|
318
|
-
if (e.message !== 'Closed. ') {
|
|
319
|
-
this.invalidateCredentials();
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
// Don't log closed as an error
|
|
323
|
-
if (e.message !== 'Closed. ') {
|
|
324
|
-
this.logger.error(e);
|
|
325
|
-
}
|
|
326
|
-
// RSocket will close the RSocket stream automatically
|
|
327
|
-
// Close the downstream stream as well - this will close the RSocket connection and WebSocket
|
|
328
|
-
abortRequest();
|
|
329
|
-
// Handles cases where the connection failed e.g. auth error or connection error
|
|
330
|
-
if (!connectionEstablished) {
|
|
331
|
-
reject(e);
|
|
332
|
-
}
|
|
333
|
-
},
|
|
334
|
-
onNext: (payload) => {
|
|
335
|
-
// The connection is active
|
|
336
|
-
if (!connectionEstablished) {
|
|
337
|
-
connectionEstablished = true;
|
|
338
|
-
resolve(events);
|
|
339
|
-
}
|
|
340
|
-
const { data } = payload;
|
|
341
|
-
if (data) {
|
|
342
|
-
queue.push(data);
|
|
343
|
-
}
|
|
344
|
-
// Less events are now pending
|
|
345
|
-
pendingEventsCount--;
|
|
346
|
-
// Request another event (unless the downstream consumer is paused).
|
|
347
|
-
requestMore();
|
|
348
|
-
},
|
|
349
|
-
onComplete: () => {
|
|
350
|
-
abortRequest(); // this will also emit a done event
|
|
351
|
-
},
|
|
352
|
-
onExtension: () => { }
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* @returns Whether the HTTP implementation on this platform can receive streamed binary responses. This is true on
|
|
358
|
-
* all platforms except React Native (who would have guessed...), where we must not request BSON responses.
|
|
359
|
-
*
|
|
360
|
-
* @see https://github.com/react-native-community/fetch?tab=readme-ov-file#motivation
|
|
361
|
-
*/
|
|
362
|
-
get supportsStreamingBinaryResponses() {
|
|
363
|
-
return true;
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Posts a `/sync/stream` request, asserts that it completes successfully and returns the streaming response as an
|
|
367
|
-
* async iterator of byte blobs.
|
|
368
|
-
*
|
|
369
|
-
* To cancel the async iterator, use the abort signal from {@link SyncStreamOptions} passed to this method.
|
|
370
|
-
*/
|
|
371
|
-
async fetchStreamRaw(options) {
|
|
372
|
-
const { data, path, headers, abortSignal } = options;
|
|
373
|
-
const request = await this.buildRequest(path);
|
|
374
|
-
/**
|
|
375
|
-
* This abort controller will abort pending fetch requests.
|
|
376
|
-
* If the request has resolved, it will be used to close the readable stream.
|
|
377
|
-
* Which will cancel the network request.
|
|
378
|
-
*
|
|
379
|
-
* This nested controller is required since:
|
|
380
|
-
* Aborting the active fetch request while it is being consumed seems to throw
|
|
381
|
-
* an unhandled exception on the window level.
|
|
382
|
-
*/
|
|
383
|
-
if (abortSignal.aborted) {
|
|
384
|
-
throw new AbortOperation('Abort request received before making fetchStreamRaw request');
|
|
385
|
-
}
|
|
386
|
-
const controller = new AbortController();
|
|
387
|
-
let reader = null;
|
|
388
|
-
abortSignal.addEventListener('abort', () => {
|
|
389
|
-
const reason = abortSignal.reason ??
|
|
390
|
-
new AbortOperation('Cancelling network request before it resolves. Abort signal has been received.');
|
|
391
|
-
if (reader == null) {
|
|
392
|
-
// Only abort via the abort controller if the request has not resolved yet
|
|
393
|
-
controller.abort(reason);
|
|
394
|
-
}
|
|
395
|
-
else {
|
|
396
|
-
reader.cancel(reason).catch(() => {
|
|
397
|
-
// Cancelling the reader might rethrow an exception we would have handled by throwing in next(). So we can
|
|
398
|
-
// ignore it here.
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
let res;
|
|
403
|
-
let responseIsBson = false;
|
|
404
|
-
try {
|
|
405
|
-
const ndJson = 'application/x-ndjson';
|
|
406
|
-
const bson = 'application/vnd.powersync.bson-stream';
|
|
407
|
-
res = await this.fetch(request.url, {
|
|
408
|
-
method: 'POST',
|
|
409
|
-
headers: {
|
|
410
|
-
...headers,
|
|
411
|
-
...request.headers,
|
|
412
|
-
accept: this.supportsStreamingBinaryResponses ? `${bson};q=0.9,${ndJson};q=0.8` : ndJson
|
|
413
|
-
},
|
|
414
|
-
body: JSON.stringify(data),
|
|
415
|
-
signal: controller.signal,
|
|
416
|
-
cache: 'no-store',
|
|
417
|
-
...(this.options.fetchOptions ?? {}),
|
|
418
|
-
...options.fetchOptions
|
|
419
|
-
});
|
|
420
|
-
if (!res.ok || !res.body) {
|
|
421
|
-
const text = await res.text();
|
|
422
|
-
this.logger.error(`Could not POST streaming to ${path} - ${res.status} - ${res.statusText}: ${text}`);
|
|
423
|
-
const error = new Error(`HTTP ${res.statusText}: ${text}`);
|
|
424
|
-
error.status = res.status;
|
|
425
|
-
throw error;
|
|
426
|
-
}
|
|
427
|
-
const contentType = res.headers.get('content-type');
|
|
428
|
-
responseIsBson = contentType == bson;
|
|
429
|
-
}
|
|
430
|
-
catch (ex) {
|
|
431
|
-
if (ex.name == 'AbortError') {
|
|
432
|
-
throw new AbortOperation(`Pending fetch request to ${request.url} has been aborted.`);
|
|
433
|
-
}
|
|
434
|
-
throw ex;
|
|
435
|
-
}
|
|
436
|
-
reader = res.body.getReader();
|
|
437
|
-
const stream = {
|
|
438
|
-
next: async () => {
|
|
439
|
-
if (controller.signal.aborted) {
|
|
440
|
-
return doneResult;
|
|
441
|
-
}
|
|
442
|
-
try {
|
|
443
|
-
return await reader.read();
|
|
444
|
-
}
|
|
445
|
-
catch (ex) {
|
|
446
|
-
if (controller.signal.aborted) {
|
|
447
|
-
// .read() completes with an error if we cancel the reader, which we do to disconnect. So this is just
|
|
448
|
-
// things working as intended, we can return a done event and consider the exception handled.
|
|
449
|
-
return doneResult;
|
|
450
|
-
}
|
|
451
|
-
throw ex;
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
return { isBson: responseIsBson, stream };
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* Posts a `/sync/stream` request.
|
|
459
|
-
*
|
|
460
|
-
* Depending on the `Content-Type` of the response, this returns strings for sync lines or encoded BSON documents as
|
|
461
|
-
* {@link Uint8Array}s.
|
|
462
|
-
*/
|
|
463
|
-
async fetchStream(options) {
|
|
464
|
-
const { isBson, stream } = await this.fetchStreamRaw(options);
|
|
465
|
-
if (isBson) {
|
|
466
|
-
return extractBsonObjects(stream);
|
|
467
|
-
}
|
|
468
|
-
else {
|
|
469
|
-
return extractJsonLines(stream, this.createTextDecoder());
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
//# sourceMappingURL=AbstractRemote.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractRemote.js","sourceRoot":"","sources":["../../../../src/client/sync/stream/AbstractRemote.ts"],"names":[],"mappings":"AACA,OAAO,MAAmB,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAwB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,OAAO,MAAM,0BAA0B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAElE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAEjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAQ/C,MAAM,8BAA8B,GAAG,MAAM,CAAC;AAC9C,MAAM,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;AAE7C,MAAM,6BAA6B,GAAG,EAAE,CAAC;AACzC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAEvC,0CAA0C;AAC1C,MAAM,aAAa,GAAG,MAAM,CAAC;AAE7B,2DAA2D;AAC3D,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC,yDAAyD;AACzD,2GAA2G;AAC3G,mEAAmE;AACnE,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAEtC,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAUnE,MAAM,CAAN,IAAY,aAYX;AAZD,WAAY,aAAa;IACvB;;;OAGG;IACH,sCAA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