@powersync/common 0.0.0-dev-20260414110516 → 0.0.0-dev-20260504100448
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/bundle.cjs +33 -665
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +34 -654
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +33 -665
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +34 -654
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +22 -369
- package/legacy/sync_protocol.d.ts +103 -0
- package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +1 -63
- package/lib/client/sync/bucket/BucketStorageAdapter.js.map +1 -1
- package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +1 -28
- package/lib/client/sync/bucket/SqliteBucketStorage.js +0 -162
- package/lib/client/sync/bucket/SqliteBucketStorage.js.map +1 -1
- package/lib/client/sync/stream/AbstractRemote.d.ts +2 -12
- package/lib/client/sync/stream/AbstractRemote.js +3 -13
- package/lib/client/sync/stream/AbstractRemote.js.map +1 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +12 -35
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +29 -337
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -1
- package/lib/client/sync/stream/JsonValue.d.ts +7 -0
- package/lib/client/sync/stream/JsonValue.js +2 -0
- package/lib/client/sync/stream/JsonValue.js.map +1 -0
- package/lib/client/sync/stream/core-instruction.d.ts +1 -2
- package/lib/client/sync/stream/core-instruction.js.map +1 -1
- package/lib/db/crud/SyncStatus.d.ts +0 -4
- package/lib/db/crud/SyncStatus.js +0 -4
- package/lib/db/crud/SyncStatus.js.map +1 -1
- package/lib/db/schema/RawTable.d.ts +0 -5
- package/lib/db/schema/Schema.d.ts +0 -2
- package/lib/db/schema/Schema.js +0 -2
- package/lib/db/schema/Schema.js.map +1 -1
- package/lib/index.d.ts +1 -5
- package/lib/index.js +1 -5
- package/lib/index.js.map +1 -1
- package/package.json +7 -4
- package/src/client/sync/bucket/BucketStorageAdapter.ts +1 -70
- package/src/client/sync/bucket/SqliteBucketStorage.ts +1 -197
- package/src/client/sync/stream/AbstractRemote.ts +5 -27
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +41 -407
- package/src/client/sync/stream/JsonValue.ts +8 -0
- package/src/client/sync/stream/core-instruction.ts +1 -2
- package/src/db/crud/SyncStatus.ts +0 -4
- package/src/db/schema/RawTable.ts +0 -5
- package/src/db/schema/Schema.ts +0 -2
- package/src/index.ts +1 -5
- package/lib/client/sync/bucket/OpType.d.ts +0 -16
- package/lib/client/sync/bucket/OpType.js +0 -23
- package/lib/client/sync/bucket/OpType.js.map +0 -1
- package/lib/client/sync/bucket/OplogEntry.d.ts +0 -23
- package/lib/client/sync/bucket/OplogEntry.js +0 -36
- package/lib/client/sync/bucket/OplogEntry.js.map +0 -1
- package/lib/client/sync/bucket/SyncDataBatch.d.ts +0 -6
- package/lib/client/sync/bucket/SyncDataBatch.js +0 -12
- package/lib/client/sync/bucket/SyncDataBatch.js.map +0 -1
- package/lib/client/sync/bucket/SyncDataBucket.d.ts +0 -40
- package/lib/client/sync/bucket/SyncDataBucket.js +0 -40
- package/lib/client/sync/bucket/SyncDataBucket.js.map +0 -1
- package/lib/client/sync/stream/streaming-sync-types.d.ts +0 -143
- package/lib/client/sync/stream/streaming-sync-types.js +0 -26
- package/lib/client/sync/stream/streaming-sync-types.js.map +0 -1
- package/src/client/sync/bucket/OpType.ts +0 -23
- package/src/client/sync/bucket/OplogEntry.ts +0 -50
- package/src/client/sync/bucket/SyncDataBatch.ts +0 -11
- package/src/client/sync/bucket/SyncDataBucket.ts +0 -49
- package/src/client/sync/stream/streaming-sync-types.ts +0 -210
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Logger, { ILogger, ILogLevel } from 'js-logger';
|
|
2
2
|
export { GlobalLogger, ILogHandler, ILogLevel, ILogger, ILoggerOpts } from 'js-logger';
|
|
3
|
-
import { BSON } from 'bson';
|
|
4
3
|
import { fetch } from 'cross-fetch';
|
|
5
4
|
|
|
6
5
|
interface Disposable {
|
|
@@ -310,139 +309,6 @@ declare class CrudBatch {
|
|
|
310
309
|
complete: (writeCheckpoint?: string) => Promise<void>);
|
|
311
310
|
}
|
|
312
311
|
|
|
313
|
-
declare enum OpTypeEnum {
|
|
314
|
-
CLEAR = 1,
|
|
315
|
-
MOVE = 2,
|
|
316
|
-
PUT = 3,
|
|
317
|
-
REMOVE = 4
|
|
318
|
-
}
|
|
319
|
-
type OpTypeJSON = string;
|
|
320
|
-
/**
|
|
321
|
-
* Used internally for sync buckets.
|
|
322
|
-
*/
|
|
323
|
-
declare class OpType {
|
|
324
|
-
value: OpTypeEnum;
|
|
325
|
-
static fromJSON(jsonValue: OpTypeJSON): OpType;
|
|
326
|
-
constructor(value: OpTypeEnum);
|
|
327
|
-
toJSON(): string;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
interface OplogEntryJSON {
|
|
331
|
-
checksum: number;
|
|
332
|
-
data?: string;
|
|
333
|
-
object_id?: string;
|
|
334
|
-
object_type?: string;
|
|
335
|
-
op_id: string;
|
|
336
|
-
op: OpTypeJSON;
|
|
337
|
-
subkey?: string;
|
|
338
|
-
}
|
|
339
|
-
declare class OplogEntry {
|
|
340
|
-
op_id: OpId;
|
|
341
|
-
op: OpType;
|
|
342
|
-
checksum: number;
|
|
343
|
-
subkey?: string | undefined;
|
|
344
|
-
object_type?: string | undefined;
|
|
345
|
-
object_id?: string | undefined;
|
|
346
|
-
data?: string | undefined;
|
|
347
|
-
static fromRow(row: OplogEntryJSON): OplogEntry;
|
|
348
|
-
constructor(op_id: OpId, op: OpType, checksum: number, subkey?: string | undefined, object_type?: string | undefined, object_id?: string | undefined, data?: string | undefined);
|
|
349
|
-
toJSON(fixedKeyEncoding?: boolean): OplogEntryJSON;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
type SyncDataBucketJSON = {
|
|
353
|
-
bucket: string;
|
|
354
|
-
has_more?: boolean;
|
|
355
|
-
after?: string;
|
|
356
|
-
next_after?: string;
|
|
357
|
-
data: OplogEntryJSON[];
|
|
358
|
-
};
|
|
359
|
-
declare class SyncDataBucket {
|
|
360
|
-
bucket: string;
|
|
361
|
-
data: OplogEntry[];
|
|
362
|
-
/**
|
|
363
|
-
* True if the response does not contain all the data for this bucket, and another request must be made.
|
|
364
|
-
*/
|
|
365
|
-
has_more: boolean;
|
|
366
|
-
/**
|
|
367
|
-
* The `after` specified in the request.
|
|
368
|
-
*/
|
|
369
|
-
after?: OpId | undefined;
|
|
370
|
-
/**
|
|
371
|
-
* Use this for the next request.
|
|
372
|
-
*/
|
|
373
|
-
next_after?: OpId | undefined;
|
|
374
|
-
static fromRow(row: SyncDataBucketJSON): SyncDataBucket;
|
|
375
|
-
constructor(bucket: string, data: OplogEntry[],
|
|
376
|
-
/**
|
|
377
|
-
* True if the response does not contain all the data for this bucket, and another request must be made.
|
|
378
|
-
*/
|
|
379
|
-
has_more: boolean,
|
|
380
|
-
/**
|
|
381
|
-
* The `after` specified in the request.
|
|
382
|
-
*/
|
|
383
|
-
after?: OpId | undefined,
|
|
384
|
-
/**
|
|
385
|
-
* Use this for the next request.
|
|
386
|
-
*/
|
|
387
|
-
next_after?: OpId | undefined);
|
|
388
|
-
toJSON(fixedKeyEncoding?: boolean): SyncDataBucketJSON;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
declare class SyncDataBatch {
|
|
392
|
-
buckets: SyncDataBucket[];
|
|
393
|
-
static fromJSON(json: any): SyncDataBatch;
|
|
394
|
-
constructor(buckets: SyncDataBucket[]);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
interface BucketDescription {
|
|
398
|
-
name: string;
|
|
399
|
-
priority: number;
|
|
400
|
-
}
|
|
401
|
-
interface Checkpoint {
|
|
402
|
-
last_op_id: OpId;
|
|
403
|
-
buckets: BucketChecksum[];
|
|
404
|
-
write_checkpoint?: string;
|
|
405
|
-
streams?: any[];
|
|
406
|
-
}
|
|
407
|
-
interface BucketState {
|
|
408
|
-
bucket: string;
|
|
409
|
-
op_id: string;
|
|
410
|
-
}
|
|
411
|
-
interface ChecksumCache {
|
|
412
|
-
checksums: Map<string, {
|
|
413
|
-
checksum: BucketChecksum;
|
|
414
|
-
last_op_id: OpId;
|
|
415
|
-
}>;
|
|
416
|
-
lastOpId: OpId;
|
|
417
|
-
}
|
|
418
|
-
interface SyncLocalDatabaseResult {
|
|
419
|
-
ready: boolean;
|
|
420
|
-
checkpointValid: boolean;
|
|
421
|
-
checkpointFailures?: string[];
|
|
422
|
-
}
|
|
423
|
-
type SavedProgress = {
|
|
424
|
-
atLast: number;
|
|
425
|
-
sinceLast: number;
|
|
426
|
-
};
|
|
427
|
-
type BucketOperationProgress = Record<string, SavedProgress>;
|
|
428
|
-
interface BucketChecksum {
|
|
429
|
-
bucket: string;
|
|
430
|
-
priority?: number;
|
|
431
|
-
/**
|
|
432
|
-
* 32-bit unsigned hash.
|
|
433
|
-
*/
|
|
434
|
-
checksum: number;
|
|
435
|
-
/**
|
|
436
|
-
* Count of operations - informational only.
|
|
437
|
-
*/
|
|
438
|
-
count?: number;
|
|
439
|
-
/**
|
|
440
|
-
* The JavaScript client does not use this field, which is why it's defined to be `any`. We rely on the structure of
|
|
441
|
-
* this interface to pass custom `BucketChecksum`s to the Rust client in unit tests, which so all fields need to be
|
|
442
|
-
* present.
|
|
443
|
-
*/
|
|
444
|
-
subscriptions?: any;
|
|
445
|
-
}
|
|
446
312
|
declare enum PSInternalTable {
|
|
447
313
|
DATA = "ps_data",
|
|
448
314
|
CRUD = "ps_crud",
|
|
@@ -464,23 +330,11 @@ interface BucketStorageListener extends BaseListener {
|
|
|
464
330
|
}
|
|
465
331
|
interface BucketStorageAdapter extends BaseObserverInterface<BucketStorageListener>, Disposable {
|
|
466
332
|
init(): Promise<void>;
|
|
467
|
-
saveSyncData(batch: SyncDataBatch, fixedKeyFormat?: boolean): Promise<void>;
|
|
468
|
-
removeBuckets(buckets: string[]): Promise<void>;
|
|
469
|
-
setTargetCheckpoint(checkpoint: Checkpoint): Promise<void>;
|
|
470
|
-
startSession(): void;
|
|
471
|
-
getBucketStates(): Promise<BucketState[]>;
|
|
472
|
-
getBucketOperationProgress(): Promise<BucketOperationProgress>;
|
|
473
333
|
hasMigratedSubkeys(): Promise<boolean>;
|
|
474
334
|
migrateToFixedSubkeys(): Promise<void>;
|
|
475
|
-
syncLocalDatabase(checkpoint: Checkpoint, priority?: number): Promise<{
|
|
476
|
-
checkpointValid: boolean;
|
|
477
|
-
ready: boolean;
|
|
478
|
-
failures?: any[];
|
|
479
|
-
}>;
|
|
480
335
|
nextCrudItem(): Promise<CrudEntry | undefined>;
|
|
481
336
|
hasCrud(): Promise<boolean>;
|
|
482
337
|
getCrudBatch(limit?: number): Promise<CrudBatch | null>;
|
|
483
|
-
hasCompletedSync(): Promise<boolean>;
|
|
484
338
|
updateLocalTarget(cb: () => Promise<string>): Promise<boolean>;
|
|
485
339
|
getMaxOpId(): string;
|
|
486
340
|
/**
|
|
@@ -499,146 +353,6 @@ interface PowerSyncCredentials {
|
|
|
499
353
|
expiresAt?: Date;
|
|
500
354
|
}
|
|
501
355
|
|
|
502
|
-
/**
|
|
503
|
-
* For sync2.json
|
|
504
|
-
*/
|
|
505
|
-
interface ContinueCheckpointRequest {
|
|
506
|
-
/**
|
|
507
|
-
* Existing bucket states. Only these buckets are synchronized.
|
|
508
|
-
*/
|
|
509
|
-
buckets: BucketRequest[];
|
|
510
|
-
checkpoint_token: string;
|
|
511
|
-
limit?: number;
|
|
512
|
-
}
|
|
513
|
-
interface SyncNewCheckpointRequest {
|
|
514
|
-
/**
|
|
515
|
-
* Existing bucket states. Used if include_data is specified.
|
|
516
|
-
*/
|
|
517
|
-
buckets?: BucketRequest[];
|
|
518
|
-
request_checkpoint: {
|
|
519
|
-
/**
|
|
520
|
-
* Whether or not to include an initial data request.
|
|
521
|
-
*/
|
|
522
|
-
include_data: boolean;
|
|
523
|
-
/**
|
|
524
|
-
* Whether or not to compute a checksum.
|
|
525
|
-
*/
|
|
526
|
-
include_checksum: boolean;
|
|
527
|
-
};
|
|
528
|
-
limit?: number;
|
|
529
|
-
}
|
|
530
|
-
type SyncRequest = ContinueCheckpointRequest | SyncNewCheckpointRequest;
|
|
531
|
-
interface SyncResponse {
|
|
532
|
-
/**
|
|
533
|
-
* Data for the buckets returned. May not have an an entry for each bucket in the request.
|
|
534
|
-
*/
|
|
535
|
-
data?: SyncDataBucketJSON[];
|
|
536
|
-
/**
|
|
537
|
-
* True if the response limit has been reached, and another request must be made.
|
|
538
|
-
*/
|
|
539
|
-
has_more: boolean;
|
|
540
|
-
checkpoint_token?: string;
|
|
541
|
-
checkpoint?: Checkpoint;
|
|
542
|
-
}
|
|
543
|
-
type JSONValue = string | number | boolean | null | undefined | JSONObject | JSONArray;
|
|
544
|
-
interface JSONObject {
|
|
545
|
-
[key: string]: JSONValue;
|
|
546
|
-
}
|
|
547
|
-
type JSONArray = JSONValue[];
|
|
548
|
-
type StreamingSyncRequestParameterType = JSONValue;
|
|
549
|
-
interface StreamingSyncRequest {
|
|
550
|
-
/**
|
|
551
|
-
* Existing bucket states.
|
|
552
|
-
*/
|
|
553
|
-
buckets?: BucketRequest[];
|
|
554
|
-
/**
|
|
555
|
-
* If specified, limit the response to only include these buckets.
|
|
556
|
-
*/
|
|
557
|
-
only?: string[];
|
|
558
|
-
/**
|
|
559
|
-
* Whether or not to compute a checksum for each checkpoint
|
|
560
|
-
*/
|
|
561
|
-
include_checksum: boolean;
|
|
562
|
-
/**
|
|
563
|
-
* Changes the response to stringified data in each OplogEntry
|
|
564
|
-
*/
|
|
565
|
-
raw_data: boolean;
|
|
566
|
-
/**
|
|
567
|
-
* Client parameters to be passed to the sync rules.
|
|
568
|
-
*/
|
|
569
|
-
parameters?: Record<string, StreamingSyncRequestParameterType>;
|
|
570
|
-
/**
|
|
571
|
-
* Application metadata to be included in service logs.
|
|
572
|
-
*/
|
|
573
|
-
app_metadata?: Record<string, string>;
|
|
574
|
-
client_id?: string;
|
|
575
|
-
}
|
|
576
|
-
interface StreamingSyncCheckpoint {
|
|
577
|
-
checkpoint: Checkpoint;
|
|
578
|
-
}
|
|
579
|
-
interface StreamingSyncCheckpointDiff {
|
|
580
|
-
checkpoint_diff: {
|
|
581
|
-
last_op_id: OpId;
|
|
582
|
-
updated_buckets: BucketChecksum[];
|
|
583
|
-
removed_buckets: string[];
|
|
584
|
-
write_checkpoint?: string;
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
interface StreamingSyncDataJSON {
|
|
588
|
-
data: SyncDataBucketJSON;
|
|
589
|
-
}
|
|
590
|
-
interface StreamingSyncCheckpointComplete {
|
|
591
|
-
checkpoint_complete: {
|
|
592
|
-
last_op_id: OpId;
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
interface StreamingSyncCheckpointPartiallyComplete {
|
|
596
|
-
partial_checkpoint_complete: {
|
|
597
|
-
priority: number;
|
|
598
|
-
last_op_id: OpId;
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
interface StreamingSyncKeepalive {
|
|
602
|
-
/** If specified, token expires in this many seconds. */
|
|
603
|
-
token_expires_in: number;
|
|
604
|
-
}
|
|
605
|
-
type StreamingSyncLine = StreamingSyncDataJSON | StreamingSyncCheckpoint | StreamingSyncCheckpointDiff | StreamingSyncCheckpointComplete | StreamingSyncCheckpointPartiallyComplete | StreamingSyncKeepalive;
|
|
606
|
-
type CrudUploadNotification = {
|
|
607
|
-
crud_upload_completed: null;
|
|
608
|
-
};
|
|
609
|
-
type StreamingSyncLineOrCrudUploadComplete = StreamingSyncLine | CrudUploadNotification;
|
|
610
|
-
interface BucketRequest {
|
|
611
|
-
name: string;
|
|
612
|
-
/**
|
|
613
|
-
* Base-10 number. Sync all data from this bucket with op_id > after.
|
|
614
|
-
*/
|
|
615
|
-
after: OpId;
|
|
616
|
-
}
|
|
617
|
-
declare function isStreamingSyncData(line: StreamingSyncLine): line is StreamingSyncDataJSON;
|
|
618
|
-
declare function isStreamingKeepalive(line: StreamingSyncLine): line is StreamingSyncKeepalive;
|
|
619
|
-
declare function isStreamingSyncCheckpoint(line: StreamingSyncLine): line is StreamingSyncCheckpoint;
|
|
620
|
-
declare function isStreamingSyncCheckpointComplete(line: StreamingSyncLine): line is StreamingSyncCheckpointComplete;
|
|
621
|
-
declare function isStreamingSyncCheckpointPartiallyComplete(line: StreamingSyncLine): line is StreamingSyncCheckpointPartiallyComplete;
|
|
622
|
-
declare function isStreamingSyncCheckpointDiff(line: StreamingSyncLine): line is StreamingSyncCheckpointDiff;
|
|
623
|
-
declare function isContinueCheckpointRequest(request: SyncRequest): request is ContinueCheckpointRequest;
|
|
624
|
-
declare function isSyncNewCheckpointRequest(request: SyncRequest): request is SyncNewCheckpointRequest;
|
|
625
|
-
/**
|
|
626
|
-
* For crud.json
|
|
627
|
-
*/
|
|
628
|
-
interface CrudRequest {
|
|
629
|
-
data: CrudEntry[];
|
|
630
|
-
}
|
|
631
|
-
interface CrudResponse {
|
|
632
|
-
/**
|
|
633
|
-
* A sync response with a checkpoint >= this checkpoint would contain all the changes in this request.
|
|
634
|
-
*
|
|
635
|
-
* Any earlier checkpoint may or may not contain these changes.
|
|
636
|
-
*
|
|
637
|
-
* May be empty when the request contains no ops.
|
|
638
|
-
*/
|
|
639
|
-
checkpoint?: OpId;
|
|
640
|
-
}
|
|
641
|
-
|
|
642
356
|
/**
|
|
643
357
|
* An async iterator that can't be cancelled.
|
|
644
358
|
*
|
|
@@ -649,7 +363,6 @@ interface CrudResponse {
|
|
|
649
363
|
*/
|
|
650
364
|
type SimpleAsyncIterator<T> = Pick<AsyncIterator<T>, 'next'>;
|
|
651
365
|
|
|
652
|
-
type BSONImplementation = typeof BSON;
|
|
653
366
|
type RemoteConnector = {
|
|
654
367
|
fetchCredentials: () => Promise<PowerSyncCredentials | null>;
|
|
655
368
|
invalidateCredentials?: () => void;
|
|
@@ -657,7 +370,7 @@ type RemoteConnector = {
|
|
|
657
370
|
declare const DEFAULT_REMOTE_LOGGER: Logger.ILogger;
|
|
658
371
|
type SyncStreamOptions = {
|
|
659
372
|
path: string;
|
|
660
|
-
data:
|
|
373
|
+
data: unknown;
|
|
661
374
|
headers?: Record<string, string>;
|
|
662
375
|
abortSignal: AbortSignal;
|
|
663
376
|
fetchOptions?: Request;
|
|
@@ -760,10 +473,6 @@ declare abstract class AbstractRemote {
|
|
|
760
473
|
}>;
|
|
761
474
|
post(path: string, data: any, headers?: Record<string, string>): Promise<any>;
|
|
762
475
|
get(path: string, headers?: Record<string, string>): Promise<any>;
|
|
763
|
-
/**
|
|
764
|
-
* Provides a BSON implementation. The import nature of this varies depending on the platform
|
|
765
|
-
*/
|
|
766
|
-
abstract getBSON(): Promise<BSONImplementation>;
|
|
767
476
|
/**
|
|
768
477
|
* @returns A text decoder decoding UTF-8. This is a method to allow patching it for Hermes which doesn't support the
|
|
769
478
|
* builtin, without forcing us to bundle a polyfill with `@powersync/common`.
|
|
@@ -774,11 +483,8 @@ declare abstract class AbstractRemote {
|
|
|
774
483
|
* Returns a data stream of sync line data, fetched via RSocket-over-WebSocket.
|
|
775
484
|
*
|
|
776
485
|
* The only mechanism to abort the returned stream is to use the abort signal in {@link SocketSyncStreamOptions}.
|
|
777
|
-
*
|
|
778
|
-
* @param bson A BSON encoder and decoder. When set, the data stream will be requested with a BSON payload
|
|
779
|
-
* (required for compatibility with older sync services).
|
|
780
486
|
*/
|
|
781
|
-
socketStreamRaw(options: SocketSyncStreamOptions
|
|
487
|
+
socketStreamRaw(options: SocketSyncStreamOptions): Promise<SimpleAsyncIterator<Uint8Array>>;
|
|
782
488
|
/**
|
|
783
489
|
* @returns Whether the HTTP implementation on this platform can receive streamed binary responses. This is true on
|
|
784
490
|
* all platforms except React Native (who would have guessed...), where we must not request BSON responses.
|
|
@@ -805,6 +511,13 @@ declare abstract class AbstractRemote {
|
|
|
805
511
|
fetchStream(options: SyncStreamOptions): Promise<SimpleAsyncIterator<Uint8Array | string>>;
|
|
806
512
|
}
|
|
807
513
|
|
|
514
|
+
type JSONValue = string | number | boolean | null | undefined | JSONObject | JSONArray;
|
|
515
|
+
interface JSONObject {
|
|
516
|
+
[key: string]: JSONValue;
|
|
517
|
+
}
|
|
518
|
+
type JSONArray = JSONValue[];
|
|
519
|
+
type StreamingSyncRequestParameterType = JSONValue;
|
|
520
|
+
|
|
808
521
|
declare enum LockType {
|
|
809
522
|
CRUD = "crud",
|
|
810
523
|
SYNC = "sync"
|
|
@@ -814,35 +527,21 @@ declare enum SyncStreamConnectionMethod {
|
|
|
814
527
|
WEB_SOCKET = "web-socket"
|
|
815
528
|
}
|
|
816
529
|
declare enum SyncClientImplementation {
|
|
817
|
-
/**
|
|
818
|
-
* Decodes and handles sync lines received from the sync service in JavaScript.
|
|
819
|
-
*
|
|
820
|
-
* This is the default option.
|
|
821
|
-
*
|
|
822
|
-
* @deprecated We recommend the {@link RUST} client implementation for all apps. If you have issues with
|
|
823
|
-
* the Rust client, please file an issue or reach out to us. The JavaScript client will be removed in a future
|
|
824
|
-
* version of the PowerSync SDK.
|
|
825
|
-
*/
|
|
826
|
-
JAVASCRIPT = "js",
|
|
827
530
|
/**
|
|
828
531
|
* This implementation offloads the sync line decoding and handling into the PowerSync
|
|
829
532
|
* core extension.
|
|
830
533
|
*
|
|
831
|
-
* This
|
|
832
|
-
* recommended client implementation for all apps.
|
|
534
|
+
* This is the only option, as an older JavaScript client implementation has been removed from the SDK.
|
|
833
535
|
*
|
|
834
536
|
* ## Compatibility warning
|
|
835
537
|
*
|
|
836
538
|
* The Rust sync client stores sync data in a format that is slightly different than the one used
|
|
837
|
-
* by the old
|
|
838
|
-
*
|
|
839
|
-
* Further, the {@link JAVASCRIPT} client in recent versions of the PowerSync JS SDK (starting from
|
|
840
|
-
* the version introducing {@link RUST} as an option) also supports the new format, so you can switch
|
|
841
|
-
* back to {@link JAVASCRIPT} later.
|
|
539
|
+
* by the old JavaScript client. When adopting the {@link RUST} client on existing databases, the PowerSync SDK will
|
|
540
|
+
* migrate the format automatically.
|
|
842
541
|
*
|
|
843
|
-
*
|
|
844
|
-
*
|
|
845
|
-
*
|
|
542
|
+
* SDK versions supporting both the JavaScript and the Rust client support both formats with the JavaScript client
|
|
543
|
+
* implementaiton. However, downgrading to an SDK version that only supports the JavaScript client would not be
|
|
544
|
+
* possible anymore. Problematic SDK versions have been released before 2025-06-09.
|
|
846
545
|
*/
|
|
847
546
|
RUST = "rust"
|
|
848
547
|
}
|
|
@@ -895,11 +594,7 @@ interface BaseConnectionOptions {
|
|
|
895
594
|
*/
|
|
896
595
|
appMetadata?: Record<string, string>;
|
|
897
596
|
/**
|
|
898
|
-
*
|
|
899
|
-
* service, or whether this work should be offloaded to the PowerSync core extension.
|
|
900
|
-
*
|
|
901
|
-
* This defaults to the JavaScript implementation ({@link SyncClientImplementation.JAVASCRIPT})
|
|
902
|
-
* since the ({@link SyncClientImplementation.RUST}) implementation is experimental at the moment.
|
|
597
|
+
* @deprecated The Rust sync client is used unconditionally, so this option can't be configured.
|
|
903
598
|
*/
|
|
904
599
|
clientImplementation?: SyncClientImplementation;
|
|
905
600
|
/**
|
|
@@ -956,15 +651,14 @@ interface StreamingSyncImplementation extends BaseObserverInterface<StreamingSyn
|
|
|
956
651
|
*/
|
|
957
652
|
disconnect(): Promise<void>;
|
|
958
653
|
getWriteCheckpoint: () => Promise<string>;
|
|
959
|
-
hasCompletedSync: () => Promise<boolean>;
|
|
960
654
|
isConnected: boolean;
|
|
961
|
-
lastSyncedAt?: Date;
|
|
962
655
|
syncStatus: SyncStatus;
|
|
963
656
|
triggerCrudUpload: () => void;
|
|
964
657
|
waitForReady(): Promise<void>;
|
|
965
658
|
waitForStatus(status: SyncStatusOptions): Promise<void>;
|
|
966
659
|
waitUntilStatusMatches(predicate: (status: SyncStatus) => boolean): Promise<void>;
|
|
967
660
|
updateSubscriptions(subscriptions: SubscribedStream[]): void;
|
|
661
|
+
markConnectionMayHaveChanged(): void;
|
|
968
662
|
}
|
|
969
663
|
declare const DEFAULT_CRUD_UPLOAD_THROTTLE_MS = 1000;
|
|
970
664
|
declare const DEFAULT_RETRY_DELAY_MS = 5000;
|
|
@@ -979,14 +673,14 @@ type SubscribedStream = {
|
|
|
979
673
|
params: Record<string, any> | null;
|
|
980
674
|
};
|
|
981
675
|
declare abstract class AbstractStreamingSyncImplementation extends BaseObserver<StreamingSyncImplementationListener> implements StreamingSyncImplementation {
|
|
982
|
-
protected _lastSyncedAt: Date | null;
|
|
983
676
|
protected options: AbstractStreamingSyncImplementationOptions;
|
|
984
677
|
protected abortController: AbortController | null;
|
|
985
|
-
protected uploadAbortController: AbortController |
|
|
678
|
+
protected uploadAbortController: AbortController | undefined;
|
|
986
679
|
protected crudUpdateListener?: () => void;
|
|
987
680
|
protected streamingSyncPromise?: Promise<void>;
|
|
988
681
|
protected logger: ILogger;
|
|
989
682
|
private activeStreams;
|
|
683
|
+
private connectionMayHaveChanged;
|
|
990
684
|
private isUploadingCrud;
|
|
991
685
|
private notifyCompletedUploads?;
|
|
992
686
|
private handleActiveStreamsChange?;
|
|
@@ -1000,7 +694,6 @@ declare abstract class AbstractStreamingSyncImplementation extends BaseObserver<
|
|
|
1000
694
|
get isConnected(): boolean;
|
|
1001
695
|
dispose(): Promise<void>;
|
|
1002
696
|
abstract obtainLock<T>(lockOptions: LockOptions<T>): Promise<T>;
|
|
1003
|
-
hasCompletedSync(): Promise<boolean>;
|
|
1004
697
|
getWriteCheckpoint(): Promise<string>;
|
|
1005
698
|
protected _uploadAllCrud(): Promise<void>;
|
|
1006
699
|
connect(options?: PowerSyncConnectionOptions): Promise<void>;
|
|
@@ -1009,7 +702,7 @@ declare abstract class AbstractStreamingSyncImplementation extends BaseObserver<
|
|
|
1009
702
|
* @deprecated use [connect instead]
|
|
1010
703
|
*/
|
|
1011
704
|
streamingSync(signal?: AbortSignal, options?: PowerSyncConnectionOptions): Promise<void>;
|
|
1012
|
-
|
|
705
|
+
markConnectionMayHaveChanged(): void;
|
|
1013
706
|
/**
|
|
1014
707
|
* Older versions of the JS SDK used to encode subkeys as JSON in {@link OplogEntry.toJSON}.
|
|
1015
708
|
* Because subkeys are always strings, this leads to quotes being added around them in `ps_oplog`.
|
|
@@ -1028,10 +721,7 @@ declare abstract class AbstractStreamingSyncImplementation extends BaseObserver<
|
|
|
1028
721
|
private requireKeyFormat;
|
|
1029
722
|
protected streamingSyncIteration(signal: AbortSignal, options?: PowerSyncConnectionOptions): Promise<RustIterationResult | null>;
|
|
1030
723
|
private receiveSyncLines;
|
|
1031
|
-
private legacyStreamingSyncIteration;
|
|
1032
724
|
private rustSyncIteration;
|
|
1033
|
-
private updateSyncStatusForStartingCheckpoint;
|
|
1034
|
-
private applyCheckpoint;
|
|
1035
725
|
protected updateSyncStatus(options: SyncStatusOptions): void;
|
|
1036
726
|
private delayRetry;
|
|
1037
727
|
updateSubscriptions(subscriptions: SubscribedStream[]): void;
|
|
@@ -1331,14 +1021,10 @@ declare class SyncStatus {
|
|
|
1331
1021
|
*
|
|
1332
1022
|
* This returns null when the database is currently being opened and we don't have reliable information about all
|
|
1333
1023
|
* included streams yet.
|
|
1334
|
-
*
|
|
1335
|
-
* @experimental Sync streams are currently in alpha.
|
|
1336
1024
|
*/
|
|
1337
1025
|
get syncStreams(): SyncStreamStatus[] | undefined;
|
|
1338
1026
|
/**
|
|
1339
1027
|
* If the `stream` appears in {@link syncStreams}, returns the current status for that stream.
|
|
1340
|
-
*
|
|
1341
|
-
* @experimental Sync streams are currently in alpha.
|
|
1342
1028
|
*/
|
|
1343
1029
|
forStream(stream: SyncStreamDescription): SyncStreamStatus | undefined;
|
|
1344
1030
|
/**
|
|
@@ -1683,11 +1369,6 @@ declare class Table<Columns extends ColumnsType = ColumnsType> {
|
|
|
1683
1369
|
* To collect local writes to raw tables with PowerSync, custom triggers are required. See
|
|
1684
1370
|
* {@link https://docs.powersync.com/usage/use-case-examples/raw-tables the documentation} for details and an example on
|
|
1685
1371
|
* using raw tables.
|
|
1686
|
-
*
|
|
1687
|
-
* Note that raw tables are only supported when using the new `SyncClientImplementation.rust` sync client.
|
|
1688
|
-
*
|
|
1689
|
-
* @experimental Please note that this feature is experimental at the moment, and not covered by PowerSync semver or
|
|
1690
|
-
* stability guarantees.
|
|
1691
1372
|
*/
|
|
1692
1373
|
type RawTableType = RawTableTypeWithStatements | InferredRawTableType;
|
|
1693
1374
|
interface RawTableTypeWithStatements {
|
|
@@ -1787,10 +1468,8 @@ declare class Schema<S extends SchemaType = SchemaType> {
|
|
|
1787
1468
|
* developer instead of automatically by PowerSync.
|
|
1788
1469
|
* Since raw tables are not backed by JSON, running complex queries on them may be more efficient. Further, they allow
|
|
1789
1470
|
* using client-side table and column constraints.
|
|
1790
|
-
* Note that raw tables are only supported when using the new `SyncClientImplementation.rust` sync client.
|
|
1791
1471
|
*
|
|
1792
1472
|
* @param tables An object of (table name, raw table definition) entries.
|
|
1793
|
-
* @experimental Note that the raw tables API is still experimental and may change in the future.
|
|
1794
1473
|
*/
|
|
1795
1474
|
withRawTables(tables: Record<string, RawTableType>): void;
|
|
1796
1475
|
validate(): void;
|
|
@@ -4220,7 +3899,6 @@ declare class SqliteBucketStorage extends BaseObserver<BucketStorageListener> im
|
|
|
4220
3899
|
private db;
|
|
4221
3900
|
private logger;
|
|
4222
3901
|
tableNames: Set<string>;
|
|
4223
|
-
private _hasCompletedSync;
|
|
4224
3902
|
private updateListener;
|
|
4225
3903
|
private _clientId?;
|
|
4226
3904
|
constructor(db: DBAdapter, logger?: ILogger);
|
|
@@ -4229,27 +3907,6 @@ declare class SqliteBucketStorage extends BaseObserver<BucketStorageListener> im
|
|
|
4229
3907
|
_getClientId(): Promise<string>;
|
|
4230
3908
|
getClientId(): Promise<string>;
|
|
4231
3909
|
getMaxOpId(): string;
|
|
4232
|
-
/**
|
|
4233
|
-
* Reset any caches.
|
|
4234
|
-
*/
|
|
4235
|
-
startSession(): void;
|
|
4236
|
-
getBucketStates(): Promise<BucketState[]>;
|
|
4237
|
-
getBucketOperationProgress(): Promise<BucketOperationProgress>;
|
|
4238
|
-
saveSyncData(batch: SyncDataBatch, fixedKeyFormat?: boolean): Promise<void>;
|
|
4239
|
-
removeBuckets(buckets: string[]): Promise<void>;
|
|
4240
|
-
/**
|
|
4241
|
-
* Mark a bucket for deletion.
|
|
4242
|
-
*/
|
|
4243
|
-
private deleteBucket;
|
|
4244
|
-
hasCompletedSync(): Promise<boolean>;
|
|
4245
|
-
syncLocalDatabase(checkpoint: Checkpoint, priority?: number): Promise<SyncLocalDatabaseResult>;
|
|
4246
|
-
/**
|
|
4247
|
-
* Atomically update the local state to the current checkpoint.
|
|
4248
|
-
*
|
|
4249
|
-
* This includes creating new tables, dropping old tables, and copying data over from the oplog.
|
|
4250
|
-
*/
|
|
4251
|
-
private updateObjectsFromBuckets;
|
|
4252
|
-
validateChecksums(checkpoint: Checkpoint, priority: number | undefined): Promise<SyncLocalDatabaseResult>;
|
|
4253
3910
|
updateLocalTarget(cb: () => Promise<string>): Promise<boolean>;
|
|
4254
3911
|
nextCrudItem(): Promise<CrudEntry | undefined>;
|
|
4255
3912
|
hasCrud(): Promise<boolean>;
|
|
@@ -4261,10 +3918,6 @@ declare class SqliteBucketStorage extends BaseObserver<BucketStorageListener> im
|
|
|
4261
3918
|
writeTransaction<T>(callback: (tx: Transaction) => Promise<T>, options?: {
|
|
4262
3919
|
timeoutMs: number;
|
|
4263
3920
|
}): Promise<T>;
|
|
4264
|
-
/**
|
|
4265
|
-
* Set a target checkpoint.
|
|
4266
|
-
*/
|
|
4267
|
-
setTargetCheckpoint(checkpoint: Checkpoint): Promise<void>;
|
|
4268
3921
|
control(op: PowerSyncControlCommand, payload: string | Uint8Array | ArrayBuffer | null): Promise<string>;
|
|
4269
3922
|
hasMigratedSubkeys(): Promise<boolean>;
|
|
4270
3923
|
migrateToFixedSubkeys(): Promise<void>;
|
|
@@ -4395,5 +4048,5 @@ interface ParsedQuery {
|
|
|
4395
4048
|
}
|
|
4396
4049
|
declare const parseQuery: <T>(query: string | CompilableQuery<T>, parameters: any[]) => ParsedQuery;
|
|
4397
4050
|
|
|
4398
|
-
export { ATTACHMENT_TABLE, AbortOperation, AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, AbstractQueryProcessor, AbstractRemote, AbstractStreamingSyncImplementation, ArrayComparator, AttachmentContext, AttachmentQueue, AttachmentService, AttachmentState, AttachmentTable, BaseObserver, Column, ColumnType, ConnectionClosedError, ConnectionManager, ControlledExecutor, CrudBatch, CrudEntry, CrudTransaction, DBAdapterDefaultMixin, DBGetUtilsDefaultMixin, DEFAULT_CRUD_BATCH_LIMIT, DEFAULT_CRUD_UPLOAD_THROTTLE_MS, DEFAULT_INDEX_COLUMN_OPTIONS, DEFAULT_INDEX_OPTIONS, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_POWERSYNC_CLOSE_OPTIONS, DEFAULT_POWERSYNC_DB_OPTIONS, DEFAULT_REMOTE_LOGGER, DEFAULT_REMOTE_OPTIONS, DEFAULT_RETRY_DELAY_MS, DEFAULT_ROW_COMPARATOR, DEFAULT_STREAMING_SYNC_OPTIONS, DEFAULT_STREAM_CONNECTION_OPTIONS, DEFAULT_SYNC_CLIENT_IMPLEMENTATION, DEFAULT_TABLE_OPTIONS, DEFAULT_WATCH_QUERY_OPTIONS, DEFAULT_WATCH_THROTTLE_MS, DiffTriggerOperation, DifferentialQueryProcessor, EMPTY_DIFFERENTIAL, EncodingType, FalsyComparator, FetchImplementationProvider, FetchStrategy, GetAllQuery, Index, IndexedColumn, InvalidSQLCharacters, LockType, LogLevel, MAX_AMOUNT_OF_COLUMNS, MAX_OP_ID, MEMORY_TRIGGER_CLAIM_MANAGER, Mutex, OnChangeQueryProcessor,
|
|
4399
|
-
export type { AbstractQueryProcessorOptions, AbstractRemoteOptions, AbstractStreamingSyncImplementationOptions, AdditionalConnectionOptions, ArrayComparatorOptions, ArrayQueryDefinition, AttachmentData, AttachmentErrorHandler, AttachmentRecord, AttachmentTableOptions,
|
|
4051
|
+
export { ATTACHMENT_TABLE, AbortOperation, AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, AbstractQueryProcessor, AbstractRemote, AbstractStreamingSyncImplementation, ArrayComparator, AttachmentContext, AttachmentQueue, AttachmentService, AttachmentState, AttachmentTable, BaseObserver, Column, ColumnType, ConnectionClosedError, ConnectionManager, ControlledExecutor, CrudBatch, CrudEntry, CrudTransaction, DBAdapterDefaultMixin, DBGetUtilsDefaultMixin, DEFAULT_CRUD_BATCH_LIMIT, DEFAULT_CRUD_UPLOAD_THROTTLE_MS, DEFAULT_INDEX_COLUMN_OPTIONS, DEFAULT_INDEX_OPTIONS, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_POWERSYNC_CLOSE_OPTIONS, DEFAULT_POWERSYNC_DB_OPTIONS, DEFAULT_REMOTE_LOGGER, DEFAULT_REMOTE_OPTIONS, DEFAULT_RETRY_DELAY_MS, DEFAULT_ROW_COMPARATOR, DEFAULT_STREAMING_SYNC_OPTIONS, DEFAULT_STREAM_CONNECTION_OPTIONS, DEFAULT_SYNC_CLIENT_IMPLEMENTATION, DEFAULT_TABLE_OPTIONS, DEFAULT_WATCH_QUERY_OPTIONS, DEFAULT_WATCH_THROTTLE_MS, DiffTriggerOperation, DifferentialQueryProcessor, EMPTY_DIFFERENTIAL, EncodingType, FalsyComparator, FetchImplementationProvider, FetchStrategy, GetAllQuery, Index, IndexedColumn, InvalidSQLCharacters, LockType, LogLevel, MAX_AMOUNT_OF_COLUMNS, MAX_OP_ID, MEMORY_TRIGGER_CLAIM_MANAGER, Mutex, OnChangeQueryProcessor, PSInternalTable, PowerSyncControlCommand, RowUpdateType, Schema, Semaphore, SqliteBucketStorage, SyncClientImplementation, SyncProgress, SyncStatus, SyncStreamConnectionMethod, SyncingService, Table, TableV2, TriggerManagerImpl, UpdateType, UploadQueueStats, WatchedQueryListenerEvent, attachmentFromSql, column, compilableQueryWatch, createBaseLogger, createLogger, extractTableUpdates, isBatchedUpdateNotification, isDBAdapter, isPowerSyncDatabaseOptionsWithSettings, isSQLOpenFactory, isSQLOpenOptions, parseQuery, runOnSchemaChange, sanitizeSQL, sanitizeUUID, timeoutSignal };
|
|
4052
|
+
export type { AbstractQueryProcessorOptions, AbstractRemoteOptions, AbstractStreamingSyncImplementationOptions, AdditionalConnectionOptions, ArrayComparatorOptions, ArrayQueryDefinition, AttachmentData, AttachmentErrorHandler, AttachmentRecord, AttachmentTableOptions, BaseColumnType, BaseConnectionOptions, BaseListener, BaseObserverInterface, BasePowerSyncDatabaseOptions, BaseTriggerDiffRecord, BatchedUpdateNotification, BucketStorageAdapter, BucketStorageListener, ColumnOptions, ColumnsType, CompilableQuery, CompilableQueryWatchHandler, CompiledQuery, ConnectionManagerListener, ConnectionManagerOptions, ConnectionManagerSyncImplementationResult, ConnectionPool, ControlledExecutorOptions, CreateDiffTriggerOptions, CreateLoggerOptions, CreateSyncImplementationOptions, DBAdapter, DBAdapterListener, DBGetUtils, DBLockOptions, DifferentialQueryProcessorOptions, DifferentialWatchedQuery, DifferentialWatchedQueryComparator, DifferentialWatchedQueryListener, DifferentialWatchedQueryOptions, DifferentialWatchedQuerySettings, DisconnectAndClearOptions, Disposable, ExtractColumnValueType, ExtractedTriggerDiffRecord, FetchImplementation, GetAllQueryOptions, IndexColumnOptions, IndexOptions, IndexShorthand, InternalConnectionOptions, InternalSubscriptionAdapter, LinkQueryOptions, LocalStorageAdapter, LockContext, LockOptions, MutableWatchedQueryState, OnChangeQueryProcessorOptions, OpId, ParsedQuery, PendingStatement, PendingStatementParameter, PowerSyncBackendConnector, PowerSyncCloseOptions, PowerSyncConnectionOptions, PowerSyncCredentials, PowerSyncDBListener, PowerSyncDatabaseOptions, PowerSyncDatabaseOptionsWithDBAdapter, PowerSyncDatabaseOptionsWithOpenFactory, PowerSyncDatabaseOptionsWithSettings, PowerSyncOpenFactoryOptions, ProgressWithOperations, Query, QueryParam, QueryResult, RawTableType, RemoteConnector, RemoteStorageAdapter, RequiredAdditionalConnectionOptions, RequiredPowerSyncConnectionOptions, RowType, SQLOnChangeOptions, SQLOpenFactory, SQLOpenOptions, SQLWatchOptions, SchemaTableType, SimpleAsyncIterator, SocketSyncStreamOptions, SqlExecutor, StandardWatchedQuery, StandardWatchedQueryOptions, StreamingSyncImplementation, StreamingSyncImplementationListener, StreamingSyncRequestParameterType, SubscribedStream, SyncDataFlowStatus, SyncPriorityStatus, SyncStatusOptions, SyncStream, SyncStreamDescription, SyncStreamOptions, SyncStreamStatus, SyncStreamSubscribeOptions, SyncStreamSubscription, SyncSubscriptionDescription, TableOptions, TableOrRawTableOptions, TableUpdateOperation, TableV2Options, TrackDiffOptions, TrackPreviousOptions, Transaction, TriggerClaimManager, TriggerCreationHooks, TriggerDiffDeleteRecord, TriggerDiffHandlerContext, TriggerDiffInsertRecord, TriggerDiffRecord, TriggerDiffUpdateRecord, TriggerManager, TriggerManagerConfig, TriggerRemoveCallback, TriggerRemoveCallbackOptions, UnlockFn, UpdateNotification, WatchCompatibleQuery, WatchExecuteOptions, WatchHandler, WatchOnChangeEvent, WatchOnChangeHandler, WatchedAttachmentItem, WatchedQuery, WatchedQueryComparator, WatchedQueryDifferential, WatchedQueryListener, WatchedQueryOptions, WatchedQueryRowDifferential, WatchedQuerySettings, WatchedQueryState, WithDiffOptions };
|