@powersync/common 0.0.0-dev-20250922105207 → 0.0.0-dev-20250922105508
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 +4 -4
- package/dist/bundle.mjs +5 -5
- package/dist/index.d.cts +1047 -838
- package/lib/client/AbstractPowerSyncDatabase.d.ts +16 -4
- package/lib/client/AbstractPowerSyncDatabase.js +36 -26
- package/lib/client/ConnectionManager.d.ts +26 -2
- package/lib/client/ConnectionManager.js +114 -2
- package/lib/client/SQLOpenFactory.d.ts +0 -2
- package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +9 -1
- package/lib/client/sync/bucket/BucketStorageAdapter.js +1 -0
- package/lib/client/sync/stream/AbstractRemote.js +3 -0
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +24 -3
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +54 -39
- package/lib/client/sync/stream/core-instruction.d.ts +20 -1
- package/lib/client/sync/stream/core-instruction.js +26 -1
- package/lib/client/sync/sync-streams.d.ts +98 -0
- package/lib/client/sync/sync-streams.js +1 -0
- package/lib/client/triggers/TriggerManager.d.ts +1 -1
- package/lib/client/watched/WatchedQuery.d.ts +2 -0
- package/lib/client/watched/WatchedQuery.js +1 -0
- package/lib/client/watched/processors/AbstractQueryProcessor.d.ts +2 -1
- package/lib/client/watched/processors/AbstractQueryProcessor.js +30 -15
- package/lib/client/watched/processors/DifferentialQueryProcessor.js +7 -1
- package/lib/client/watched/processors/OnChangeQueryProcessor.js +7 -1
- package/lib/db/crud/SyncStatus.d.ts +37 -1
- package/lib/db/crud/SyncStatus.js +61 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -357,6 +357,7 @@ interface Checkpoint {
|
|
|
357
357
|
last_op_id: OpId;
|
|
358
358
|
buckets: BucketChecksum[];
|
|
359
359
|
write_checkpoint?: string;
|
|
360
|
+
streams?: any[];
|
|
360
361
|
}
|
|
361
362
|
interface BucketState {
|
|
362
363
|
bucket: string;
|
|
@@ -390,6 +391,12 @@ interface BucketChecksum {
|
|
|
390
391
|
* Count of operations - informational only.
|
|
391
392
|
*/
|
|
392
393
|
count?: number;
|
|
394
|
+
/**
|
|
395
|
+
* The JavaScript client does not use this field, which is why it's defined to be `any`. We rely on the structure of
|
|
396
|
+
* this interface to pass custom `BucketChecksum`s to the Rust client in unit tests, which so all fields need to be
|
|
397
|
+
* present.
|
|
398
|
+
*/
|
|
399
|
+
subscriptions?: any;
|
|
393
400
|
}
|
|
394
401
|
declare enum PSInternalTable {
|
|
395
402
|
DATA = "ps_data",
|
|
@@ -404,7 +411,8 @@ declare enum PowerSyncControlCommand {
|
|
|
404
411
|
STOP = "stop",
|
|
405
412
|
START = "start",
|
|
406
413
|
NOTIFY_TOKEN_REFRESHED = "refreshed_token",
|
|
407
|
-
NOTIFY_CRUD_UPLOAD_COMPLETED = "completed_upload"
|
|
414
|
+
NOTIFY_CRUD_UPLOAD_COMPLETED = "completed_upload",
|
|
415
|
+
UPDATE_SUBSCRIPTIONS = "update_subscriptions"
|
|
408
416
|
}
|
|
409
417
|
interface BucketStorageListener extends BaseListener {
|
|
410
418
|
crudUpdate: () => void;
|
|
@@ -576,6 +584,20 @@ interface CrudResponse {
|
|
|
576
584
|
checkpoint?: OpId;
|
|
577
585
|
}
|
|
578
586
|
|
|
587
|
+
interface CoreStreamSubscription {
|
|
588
|
+
progress: {
|
|
589
|
+
total: number;
|
|
590
|
+
downloaded: number;
|
|
591
|
+
};
|
|
592
|
+
name: string;
|
|
593
|
+
parameters: any;
|
|
594
|
+
priority: number | null;
|
|
595
|
+
active: boolean;
|
|
596
|
+
is_default: boolean;
|
|
597
|
+
has_explicit_subscription: boolean;
|
|
598
|
+
expires_at: number | null;
|
|
599
|
+
last_synced_at: number | null;
|
|
600
|
+
}
|
|
579
601
|
interface BucketProgress {
|
|
580
602
|
priority: number;
|
|
581
603
|
at_last: number;
|
|
@@ -583,1020 +605,1172 @@ interface BucketProgress {
|
|
|
583
605
|
target_count: number;
|
|
584
606
|
}
|
|
585
607
|
|
|
586
|
-
|
|
587
|
-
|
|
608
|
+
type DataStreamOptions<ParsedData, SourceData> = {
|
|
609
|
+
mapLine?: (line: SourceData) => ParsedData;
|
|
610
|
+
/**
|
|
611
|
+
* Close the stream if any consumer throws an error
|
|
612
|
+
*/
|
|
613
|
+
closeOnError?: boolean;
|
|
614
|
+
pressure?: {
|
|
615
|
+
highWaterMark?: number;
|
|
616
|
+
lowWaterMark?: number;
|
|
617
|
+
};
|
|
618
|
+
logger?: ILogger;
|
|
619
|
+
};
|
|
620
|
+
type DataStreamCallback<Data extends any = any> = (data: Data) => Promise<void>;
|
|
621
|
+
interface DataStreamListener<Data extends any = any> extends BaseListener {
|
|
622
|
+
data: (data: Data) => Promise<void>;
|
|
623
|
+
closed: () => void;
|
|
624
|
+
error: (error: Error) => void;
|
|
625
|
+
highWater: () => Promise<void>;
|
|
626
|
+
lowWater: () => Promise<void>;
|
|
627
|
+
}
|
|
628
|
+
declare const DEFAULT_PRESSURE_LIMITS: {
|
|
629
|
+
highWater: number;
|
|
630
|
+
lowWater: number;
|
|
631
|
+
};
|
|
588
632
|
/**
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
* {@link SyncStatus#downloadProgress}.
|
|
633
|
+
* A very basic implementation of a data stream with backpressure support which does not use
|
|
634
|
+
* native JS streams or async iterators.
|
|
635
|
+
* This is handy for environments such as React Native which need polyfills for the above.
|
|
593
636
|
*/
|
|
594
|
-
|
|
637
|
+
declare class DataStream<ParsedData, SourceData = any> extends BaseObserver<DataStreamListener<ParsedData>> {
|
|
638
|
+
protected options?: DataStreamOptions<ParsedData, SourceData> | undefined;
|
|
639
|
+
dataQueue: SourceData[];
|
|
640
|
+
protected isClosed: boolean;
|
|
641
|
+
protected processingPromise: Promise<void> | null;
|
|
642
|
+
protected notifyDataAdded: (() => void) | null;
|
|
643
|
+
protected logger: ILogger;
|
|
644
|
+
protected mapLine: (line: SourceData) => ParsedData;
|
|
645
|
+
constructor(options?: DataStreamOptions<ParsedData, SourceData> | undefined);
|
|
646
|
+
get highWatermark(): number;
|
|
647
|
+
get lowWatermark(): number;
|
|
648
|
+
get closed(): boolean;
|
|
649
|
+
close(): Promise<void>;
|
|
595
650
|
/**
|
|
596
|
-
*
|
|
597
|
-
* to complete.
|
|
651
|
+
* Enqueues data for the consumers to read
|
|
598
652
|
*/
|
|
599
|
-
|
|
653
|
+
enqueueData(data: SourceData): void;
|
|
600
654
|
/**
|
|
601
|
-
*
|
|
655
|
+
* Reads data once from the data stream
|
|
656
|
+
* @returns a Data payload or Null if the stream closed.
|
|
602
657
|
*/
|
|
603
|
-
|
|
658
|
+
read(): Promise<ParsedData | null>;
|
|
604
659
|
/**
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
* This will be a number between `0.0` and `1.0` (inclusive).
|
|
608
|
-
*
|
|
609
|
-
* When this number reaches `1.0`, all changes have been received from the sync service.
|
|
610
|
-
* Actually applying these changes happens before the `downloadProgress` field is cleared from
|
|
611
|
-
* {@link SyncStatus}, so progress can stay at `1.0` for a short while before completing.
|
|
660
|
+
* Executes a callback for each data item in the stream
|
|
612
661
|
*/
|
|
613
|
-
|
|
662
|
+
forEach(callback: DataStreamCallback<ParsedData>): () => void;
|
|
663
|
+
protected processQueue(): Promise<void> | undefined;
|
|
664
|
+
protected hasDataReader(): boolean;
|
|
665
|
+
protected _processQueue(): Promise<void>;
|
|
666
|
+
protected iterateAsyncErrored(cb: (l: Partial<DataStreamListener<ParsedData>>) => Promise<void>): Promise<void>;
|
|
614
667
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
declare
|
|
636
|
-
protected internal: InternalProgressInformation;
|
|
637
|
-
totalOperations: number;
|
|
638
|
-
downloadedOperations: number;
|
|
639
|
-
downloadedFraction: number;
|
|
640
|
-
constructor(internal: InternalProgressInformation);
|
|
668
|
+
|
|
669
|
+
interface PowerSyncCredentials {
|
|
670
|
+
endpoint: string;
|
|
671
|
+
token: string;
|
|
672
|
+
expiresAt?: Date;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
type BSONImplementation = typeof BSON;
|
|
676
|
+
type RemoteConnector = {
|
|
677
|
+
fetchCredentials: () => Promise<PowerSyncCredentials | null>;
|
|
678
|
+
invalidateCredentials?: () => void;
|
|
679
|
+
};
|
|
680
|
+
declare const DEFAULT_REMOTE_LOGGER: Logger.ILogger;
|
|
681
|
+
type SyncStreamOptions = {
|
|
682
|
+
path: string;
|
|
683
|
+
data: StreamingSyncRequest;
|
|
684
|
+
headers?: Record<string, string>;
|
|
685
|
+
abortSignal?: AbortSignal;
|
|
686
|
+
fetchOptions?: Request;
|
|
687
|
+
};
|
|
688
|
+
declare enum FetchStrategy {
|
|
641
689
|
/**
|
|
642
|
-
*
|
|
643
|
-
*
|
|
644
|
-
* The returned {@link ProgressWithOperations} tracks the target amount of operations that need
|
|
645
|
-
* to be downloaded in total and how many of them have already been received.
|
|
690
|
+
* Queues multiple sync events before processing, reducing round-trips.
|
|
691
|
+
* This comes at the cost of more processing overhead, which may cause ACK timeouts on older/weaker devices for big enough datasets.
|
|
646
692
|
*/
|
|
647
|
-
|
|
693
|
+
Buffered = "buffered",
|
|
694
|
+
/**
|
|
695
|
+
* Processes each sync event immediately before requesting the next.
|
|
696
|
+
* This reduces processing overhead and improves real-time responsiveness.
|
|
697
|
+
*/
|
|
698
|
+
Sequential = "sequential"
|
|
648
699
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
700
|
+
type SocketSyncStreamOptions = SyncStreamOptions & {
|
|
701
|
+
fetchStrategy: FetchStrategy;
|
|
702
|
+
};
|
|
703
|
+
type FetchImplementation = typeof fetch;
|
|
704
|
+
/**
|
|
705
|
+
* Class wrapper for providing a fetch implementation.
|
|
706
|
+
* The class wrapper is used to distinguish the fetchImplementation
|
|
707
|
+
* option in [AbstractRemoteOptions] from the general fetch method
|
|
708
|
+
* which is typeof "function"
|
|
709
|
+
*/
|
|
710
|
+
declare class FetchImplementationProvider {
|
|
711
|
+
getFetch(): FetchImplementation;
|
|
712
|
+
}
|
|
713
|
+
type AbstractRemoteOptions = {
|
|
653
714
|
/**
|
|
654
|
-
*
|
|
655
|
-
*
|
|
656
|
-
*
|
|
715
|
+
* Transforms the PowerSync base URL which might contain
|
|
716
|
+
* `http(s)://` to the corresponding WebSocket variant
|
|
717
|
+
* e.g. `ws(s)://`
|
|
657
718
|
*/
|
|
658
|
-
|
|
719
|
+
socketUrlTransformer: (url: string) => string;
|
|
659
720
|
/**
|
|
660
|
-
*
|
|
661
|
-
*
|
|
721
|
+
* Optionally provide the fetch implementation to use.
|
|
722
|
+
* Note that this usually needs to be bound to the global scope.
|
|
723
|
+
* Binding should be done before passing here.
|
|
662
724
|
*/
|
|
663
|
-
|
|
725
|
+
fetchImplementation: FetchImplementation | FetchImplementationProvider;
|
|
664
726
|
/**
|
|
665
|
-
*
|
|
727
|
+
* Optional options to pass directly to all `fetch` calls.
|
|
666
728
|
*
|
|
667
|
-
*
|
|
729
|
+
* This can include fields such as `dispatcher` (e.g. for proxy support),
|
|
730
|
+
* `cache`, or any other fetch-compatible options.
|
|
668
731
|
*/
|
|
669
|
-
|
|
670
|
-
}>;
|
|
671
|
-
interface SyncPriorityStatus {
|
|
672
|
-
priority: number;
|
|
673
|
-
lastSyncedAt?: Date;
|
|
674
|
-
hasSynced?: boolean;
|
|
675
|
-
}
|
|
676
|
-
type SyncStatusOptions = {
|
|
677
|
-
connected?: boolean;
|
|
678
|
-
connecting?: boolean;
|
|
679
|
-
dataFlow?: SyncDataFlowStatus;
|
|
680
|
-
lastSyncedAt?: Date;
|
|
681
|
-
hasSynced?: boolean;
|
|
682
|
-
priorityStatusEntries?: SyncPriorityStatus[];
|
|
732
|
+
fetchOptions?: {};
|
|
683
733
|
};
|
|
684
|
-
declare
|
|
685
|
-
|
|
686
|
-
|
|
734
|
+
declare const DEFAULT_REMOTE_OPTIONS: AbstractRemoteOptions;
|
|
735
|
+
declare abstract class AbstractRemote {
|
|
736
|
+
protected connector: RemoteConnector;
|
|
737
|
+
protected logger: ILogger;
|
|
738
|
+
protected credentials: PowerSyncCredentials | null;
|
|
739
|
+
protected options: AbstractRemoteOptions;
|
|
740
|
+
constructor(connector: RemoteConnector, logger?: ILogger, options?: Partial<AbstractRemoteOptions>);
|
|
687
741
|
/**
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
* @returns {boolean} True if connected, false otherwise. Defaults to false if not specified.
|
|
742
|
+
* @returns a fetch implementation (function)
|
|
743
|
+
* which can be called to perform fetch requests
|
|
691
744
|
*/
|
|
692
|
-
get
|
|
745
|
+
get fetch(): FetchImplementation;
|
|
693
746
|
/**
|
|
694
|
-
*
|
|
747
|
+
* Get credentials currently cached, or fetch new credentials if none are
|
|
748
|
+
* available.
|
|
695
749
|
*
|
|
696
|
-
*
|
|
750
|
+
* These credentials may have expired already.
|
|
697
751
|
*/
|
|
698
|
-
|
|
752
|
+
getCredentials(): Promise<PowerSyncCredentials | null>;
|
|
699
753
|
/**
|
|
700
|
-
*
|
|
701
|
-
* This timestamp is reset to null after a restart of the PowerSync service.
|
|
754
|
+
* Fetch a new set of credentials and cache it.
|
|
702
755
|
*
|
|
703
|
-
*
|
|
756
|
+
* Until this call succeeds, `getCredentials` will still return the
|
|
757
|
+
* old credentials.
|
|
758
|
+
*
|
|
759
|
+
* This may be called before the current credentials have expired.
|
|
704
760
|
*/
|
|
705
|
-
|
|
761
|
+
prefetchCredentials(): Promise<PowerSyncCredentials | null>;
|
|
706
762
|
/**
|
|
707
|
-
*
|
|
763
|
+
* Get credentials for PowerSync.
|
|
708
764
|
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
765
|
+
* This should always fetch a fresh set of credentials - don't use cached
|
|
766
|
+
* values.
|
|
711
767
|
*/
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
*
|
|
768
|
+
fetchCredentials(): Promise<PowerSyncCredentials | null>;
|
|
769
|
+
/***
|
|
770
|
+
* Immediately invalidate credentials.
|
|
715
771
|
*
|
|
716
|
-
*
|
|
717
|
-
* - downloading: True if actively downloading changes (only when connected is also true)
|
|
718
|
-
* - uploading: True if actively uploading changes
|
|
719
|
-
* Defaults to {downloading: false, uploading: false} if not specified.
|
|
772
|
+
* This may be called when the current credentials have expired.
|
|
720
773
|
*/
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
/**
|
|
731
|
-
* Error during uploading.
|
|
732
|
-
* Cleared on the next successful upload.
|
|
733
|
-
*/
|
|
734
|
-
uploadError?: Error;
|
|
735
|
-
/**
|
|
736
|
-
* Internal information about how far we are downloading operations in buckets.
|
|
737
|
-
*
|
|
738
|
-
* Please use the {@link SyncStatus#downloadProgress} property to track sync progress.
|
|
739
|
-
*/
|
|
740
|
-
downloadProgress: InternalProgressInformation | null;
|
|
774
|
+
invalidateCredentials(): void;
|
|
775
|
+
getUserAgent(): string;
|
|
776
|
+
protected buildRequest(path: string): Promise<{
|
|
777
|
+
url: string;
|
|
778
|
+
headers: {
|
|
779
|
+
'content-type': string;
|
|
780
|
+
Authorization: string;
|
|
781
|
+
'x-user-agent': string;
|
|
782
|
+
};
|
|
741
783
|
}>;
|
|
784
|
+
post(path: string, data: any, headers?: Record<string, string>): Promise<any>;
|
|
785
|
+
get(path: string, headers?: Record<string, string>): Promise<any>;
|
|
742
786
|
/**
|
|
743
|
-
* Provides
|
|
787
|
+
* Provides a BSON implementation. The import nature of this varies depending on the platform
|
|
788
|
+
*/
|
|
789
|
+
abstract getBSON(): Promise<BSONImplementation>;
|
|
790
|
+
protected createSocket(url: string): WebSocket;
|
|
791
|
+
/**
|
|
792
|
+
* Returns a data stream of sync line data.
|
|
744
793
|
*
|
|
745
|
-
* @
|
|
746
|
-
*
|
|
794
|
+
* @param map Maps received payload frames to the typed event value.
|
|
795
|
+
* @param bson A BSON encoder and decoder. When set, the data stream will be requested with a BSON payload
|
|
796
|
+
* (required for compatibility with older sync services).
|
|
747
797
|
*/
|
|
748
|
-
|
|
798
|
+
socketStreamRaw<T>(options: SocketSyncStreamOptions, map: (buffer: Uint8Array) => T, bson?: typeof BSON): Promise<DataStream<T>>;
|
|
749
799
|
/**
|
|
750
|
-
*
|
|
751
|
-
|
|
800
|
+
* Connects to the sync/stream http endpoint, mapping and emitting each received string line.
|
|
801
|
+
*/
|
|
802
|
+
postStreamRaw<T>(options: SyncStreamOptions, mapLine: (line: string) => T): Promise<DataStream<T>>;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
declare enum LockType {
|
|
806
|
+
CRUD = "crud",
|
|
807
|
+
SYNC = "sync"
|
|
808
|
+
}
|
|
809
|
+
declare enum SyncStreamConnectionMethod {
|
|
810
|
+
HTTP = "http",
|
|
811
|
+
WEB_SOCKET = "web-socket"
|
|
812
|
+
}
|
|
813
|
+
declare enum SyncClientImplementation {
|
|
814
|
+
/**
|
|
815
|
+
* Decodes and handles sync lines received from the sync service in JavaScript.
|
|
752
816
|
*
|
|
753
|
-
* This
|
|
817
|
+
* This is the default option.
|
|
818
|
+
*
|
|
819
|
+
* @deprecated Don't use {@link SyncClientImplementation.JAVASCRIPT} directly. Instead, use
|
|
820
|
+
* {@link DEFAULT_SYNC_CLIENT_IMPLEMENTATION} or omit the option. The explicit choice to use
|
|
821
|
+
* the JavaScript-based sync implementation will be removed from a future version of the SDK.
|
|
754
822
|
*/
|
|
755
|
-
|
|
823
|
+
JAVASCRIPT = "js",
|
|
756
824
|
/**
|
|
757
|
-
*
|
|
758
|
-
*
|
|
825
|
+
* This implementation offloads the sync line decoding and handling into the PowerSync
|
|
826
|
+
* core extension.
|
|
759
827
|
*
|
|
760
|
-
*
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
* syncing.
|
|
828
|
+
* @experimental
|
|
829
|
+
* While this implementation is more performant than {@link SyncClientImplementation.JAVASCRIPT},
|
|
830
|
+
* it has seen less real-world testing and is marked as __experimental__ at the moment.
|
|
764
831
|
*
|
|
765
|
-
*
|
|
766
|
-
* status information available. This is because when PowerSync makes data for a given priority available,
|
|
767
|
-
* all buckets in higher-priorities are guaranteed to be consistent with that checkpoint.
|
|
832
|
+
* ## Compatibility warning
|
|
768
833
|
*
|
|
769
|
-
*
|
|
770
|
-
*
|
|
834
|
+
* The Rust sync client stores sync data in a format that is slightly different than the one used
|
|
835
|
+
* by the old {@link JAVASCRIPT} implementation. When adopting the {@link RUST} client on existing
|
|
836
|
+
* databases, the PowerSync SDK will migrate the format automatically.
|
|
837
|
+
* Further, the {@link JAVASCRIPT} client in recent versions of the PowerSync JS SDK (starting from
|
|
838
|
+
* the version introducing {@link RUST} as an option) also supports the new format, so you can switch
|
|
839
|
+
* back to {@link JAVASCRIPT} later.
|
|
771
840
|
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
841
|
+
* __However__: Upgrading the SDK version, then adopting {@link RUST} as a sync client and later
|
|
842
|
+
* downgrading the SDK to an older version (necessarily using the JavaScript-based implementation then)
|
|
843
|
+
* can lead to sync issues.
|
|
774
844
|
*/
|
|
775
|
-
|
|
845
|
+
RUST = "rust"
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* The default {@link SyncClientImplementation} to use.
|
|
849
|
+
*
|
|
850
|
+
* Please use this field instead of {@link SyncClientImplementation.JAVASCRIPT} directly. A future version
|
|
851
|
+
* of the PowerSync SDK will enable {@link SyncClientImplementation.RUST} by default and remove the JavaScript
|
|
852
|
+
* option.
|
|
853
|
+
*/
|
|
854
|
+
declare const DEFAULT_SYNC_CLIENT_IMPLEMENTATION = SyncClientImplementation.JAVASCRIPT;
|
|
855
|
+
/**
|
|
856
|
+
* Abstract Lock to be implemented by various JS environments
|
|
857
|
+
*/
|
|
858
|
+
interface LockOptions<T> {
|
|
859
|
+
callback: () => Promise<T>;
|
|
860
|
+
type: LockType;
|
|
861
|
+
signal?: AbortSignal;
|
|
862
|
+
}
|
|
863
|
+
interface AbstractStreamingSyncImplementationOptions extends RequiredAdditionalConnectionOptions {
|
|
864
|
+
adapter: BucketStorageAdapter;
|
|
865
|
+
subscriptions: SubscribedStream[];
|
|
866
|
+
uploadCrud: () => Promise<void>;
|
|
776
867
|
/**
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
* @param {SyncStatus} status The SyncStatus instance to compare against
|
|
781
|
-
* @returns {boolean} True if the instances are considered equal, false otherwise
|
|
868
|
+
* An identifier for which PowerSync DB this sync implementation is
|
|
869
|
+
* linked to. Most commonly DB name, but not restricted to DB name.
|
|
782
870
|
*/
|
|
783
|
-
|
|
871
|
+
identifier?: string;
|
|
872
|
+
logger?: ILogger;
|
|
873
|
+
remote: AbstractRemote;
|
|
874
|
+
}
|
|
875
|
+
interface StreamingSyncImplementationListener extends BaseListener {
|
|
784
876
|
/**
|
|
785
|
-
*
|
|
786
|
-
*
|
|
787
|
-
*
|
|
788
|
-
* @returns {string} A string representation of the sync status
|
|
877
|
+
* Triggered whenever a status update has been attempted to be made or
|
|
878
|
+
* refreshed.
|
|
789
879
|
*/
|
|
790
|
-
|
|
880
|
+
statusUpdated?: ((statusUpdate: SyncStatusOptions) => void) | undefined;
|
|
791
881
|
/**
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
* @returns {SyncStatusOptions} A plain object representation of the sync status
|
|
882
|
+
* Triggers whenever the status' members have changed in value
|
|
795
883
|
*/
|
|
796
|
-
|
|
797
|
-
private static comparePriorities;
|
|
884
|
+
statusChanged?: ((status: SyncStatus) => void) | undefined;
|
|
798
885
|
}
|
|
799
|
-
|
|
800
|
-
|
|
886
|
+
/**
|
|
887
|
+
* Configurable options to be used when connecting to the PowerSync
|
|
888
|
+
* backend instance.
|
|
889
|
+
*/
|
|
890
|
+
type PowerSyncConnectionOptions = Omit<InternalConnectionOptions, 'serializedSchema'>;
|
|
891
|
+
interface InternalConnectionOptions extends BaseConnectionOptions, AdditionalConnectionOptions {
|
|
892
|
+
}
|
|
893
|
+
/** @internal */
|
|
894
|
+
interface BaseConnectionOptions {
|
|
801
895
|
/**
|
|
802
|
-
*
|
|
896
|
+
* Whether to use a JavaScript implementation to handle received sync lines from the sync
|
|
897
|
+
* service, or whether this work should be offloaded to the PowerSync core extension.
|
|
898
|
+
*
|
|
899
|
+
* This defaults to the JavaScript implementation ({@link SyncClientImplementation.JAVASCRIPT})
|
|
900
|
+
* since the ({@link SyncClientImplementation.RUST}) implementation is experimental at the moment.
|
|
803
901
|
*/
|
|
804
|
-
|
|
902
|
+
clientImplementation?: SyncClientImplementation;
|
|
805
903
|
/**
|
|
806
|
-
*
|
|
904
|
+
* The connection method to use when streaming updates from
|
|
905
|
+
* the PowerSync backend instance.
|
|
906
|
+
* Defaults to a HTTP streaming connection.
|
|
807
907
|
*/
|
|
808
|
-
|
|
809
|
-
constructor(
|
|
908
|
+
connectionMethod?: SyncStreamConnectionMethod;
|
|
810
909
|
/**
|
|
811
|
-
*
|
|
910
|
+
* The fetch strategy to use when streaming updates from the PowerSync backend instance.
|
|
812
911
|
*/
|
|
813
|
-
|
|
912
|
+
fetchStrategy?: FetchStrategy;
|
|
814
913
|
/**
|
|
815
|
-
*
|
|
914
|
+
* These parameters are passed to the sync rules, and will be available under the`user_parameters` object.
|
|
816
915
|
*/
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
916
|
+
params?: Record<string, StreamingSyncRequestParameterType>;
|
|
917
|
+
/**
|
|
918
|
+
* Whether to include streams that have `auto_subscribe: true` in their definition.
|
|
919
|
+
*
|
|
920
|
+
* This defaults to `true`.
|
|
921
|
+
*/
|
|
922
|
+
includeDefaultStreams?: boolean;
|
|
923
|
+
/**
|
|
924
|
+
* The serialized schema - mainly used to forward information about raw tables to the sync client.
|
|
925
|
+
*/
|
|
926
|
+
serializedSchema?: any;
|
|
825
927
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
928
|
+
/** @internal */
|
|
929
|
+
interface AdditionalConnectionOptions {
|
|
930
|
+
/**
|
|
931
|
+
* Delay for retrying sync streaming operations
|
|
932
|
+
* from the PowerSync backend after an error occurs.
|
|
933
|
+
*/
|
|
934
|
+
retryDelayMs?: number;
|
|
935
|
+
/**
|
|
936
|
+
* Backend Connector CRUD operations are throttled
|
|
937
|
+
* to occur at most every `crudUploadThrottleMs`
|
|
938
|
+
* milliseconds.
|
|
939
|
+
*/
|
|
940
|
+
crudUploadThrottleMs?: number;
|
|
829
941
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
type ColumnsType = Record<string, BaseColumnType<any>>;
|
|
834
|
-
type ExtractColumnValueType<T extends BaseColumnType<any>> = T extends BaseColumnType<infer R> ? R : unknown;
|
|
835
|
-
declare const MAX_AMOUNT_OF_COLUMNS = 1999;
|
|
836
|
-
declare const column: {
|
|
837
|
-
text: BaseColumnType<string | null>;
|
|
838
|
-
integer: BaseColumnType<number | null>;
|
|
839
|
-
real: BaseColumnType<number | null>;
|
|
840
|
-
};
|
|
841
|
-
declare class Column {
|
|
842
|
-
protected options: ColumnOptions;
|
|
843
|
-
constructor(options: ColumnOptions);
|
|
844
|
-
get name(): string;
|
|
845
|
-
get type(): ColumnType | undefined;
|
|
846
|
-
toJSON(): {
|
|
847
|
-
name: string;
|
|
848
|
-
type: ColumnType | undefined;
|
|
849
|
-
};
|
|
942
|
+
/** @internal */
|
|
943
|
+
interface RequiredAdditionalConnectionOptions extends Required<AdditionalConnectionOptions> {
|
|
944
|
+
subscriptions: SubscribedStream[];
|
|
850
945
|
}
|
|
851
|
-
|
|
852
|
-
/**
|
|
853
|
-
* A pending variant of a {@link RawTable} that doesn't have a name (because it would be inferred when creating the
|
|
854
|
-
* schema).
|
|
855
|
-
*/
|
|
856
|
-
type RawTableType = {
|
|
946
|
+
interface StreamingSyncImplementation extends BaseObserverInterface<StreamingSyncImplementationListener>, Disposable {
|
|
857
947
|
/**
|
|
858
|
-
*
|
|
948
|
+
* Connects to the sync service
|
|
859
949
|
*/
|
|
860
|
-
|
|
950
|
+
connect(options?: InternalConnectionOptions): Promise<void>;
|
|
861
951
|
/**
|
|
862
|
-
*
|
|
952
|
+
* Disconnects from the sync services.
|
|
953
|
+
* @throws if not connected or if abort is not controlled internally
|
|
863
954
|
*/
|
|
864
|
-
|
|
955
|
+
disconnect(): Promise<void>;
|
|
956
|
+
getWriteCheckpoint: () => Promise<string>;
|
|
957
|
+
hasCompletedSync: () => Promise<boolean>;
|
|
958
|
+
isConnected: boolean;
|
|
959
|
+
lastSyncedAt?: Date;
|
|
960
|
+
syncStatus: SyncStatus;
|
|
961
|
+
triggerCrudUpload: () => void;
|
|
962
|
+
waitForReady(): Promise<void>;
|
|
963
|
+
waitForStatus(status: SyncStatusOptions): Promise<void>;
|
|
964
|
+
waitUntilStatusMatches(predicate: (status: SyncStatus) => boolean): Promise<void>;
|
|
965
|
+
updateSubscriptions(subscriptions: SubscribedStream[]): void;
|
|
966
|
+
}
|
|
967
|
+
declare const DEFAULT_CRUD_UPLOAD_THROTTLE_MS = 1000;
|
|
968
|
+
declare const DEFAULT_RETRY_DELAY_MS = 5000;
|
|
969
|
+
declare const DEFAULT_STREAMING_SYNC_OPTIONS: {
|
|
970
|
+
retryDelayMs: number;
|
|
971
|
+
crudUploadThrottleMs: number;
|
|
865
972
|
};
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
*
|
|
872
|
-
* For insert and replace operations, the values of columns in the table are available as parameters through
|
|
873
|
-
* `{Column: 'name'}`.
|
|
874
|
-
*/
|
|
875
|
-
type PendingStatementParameter = 'Id' | {
|
|
876
|
-
Column: string;
|
|
973
|
+
type RequiredPowerSyncConnectionOptions = Required<BaseConnectionOptions>;
|
|
974
|
+
declare const DEFAULT_STREAM_CONNECTION_OPTIONS: RequiredPowerSyncConnectionOptions;
|
|
975
|
+
type SubscribedStream = {
|
|
976
|
+
name: string;
|
|
977
|
+
params: Record<string, any> | null;
|
|
877
978
|
};
|
|
979
|
+
declare abstract class AbstractStreamingSyncImplementation extends BaseObserver<StreamingSyncImplementationListener> implements StreamingSyncImplementation {
|
|
980
|
+
protected _lastSyncedAt: Date | null;
|
|
981
|
+
protected options: AbstractStreamingSyncImplementationOptions;
|
|
982
|
+
protected abortController: AbortController | null;
|
|
983
|
+
protected uploadAbortController: AbortController | null;
|
|
984
|
+
protected crudUpdateListener?: () => void;
|
|
985
|
+
protected streamingSyncPromise?: Promise<void>;
|
|
986
|
+
protected logger: ILogger;
|
|
987
|
+
private activeStreams;
|
|
988
|
+
private isUploadingCrud;
|
|
989
|
+
private notifyCompletedUploads?;
|
|
990
|
+
private handleActiveStreamsChange?;
|
|
991
|
+
syncStatus: SyncStatus;
|
|
992
|
+
triggerCrudUpload: () => void;
|
|
993
|
+
constructor(options: AbstractStreamingSyncImplementationOptions);
|
|
994
|
+
waitForReady(): Promise<void>;
|
|
995
|
+
waitForStatus(status: SyncStatusOptions): Promise<void>;
|
|
996
|
+
waitUntilStatusMatches(predicate: (status: SyncStatus) => boolean): Promise<void>;
|
|
997
|
+
get lastSyncedAt(): Date | undefined;
|
|
998
|
+
get isConnected(): boolean;
|
|
999
|
+
dispose(): Promise<void>;
|
|
1000
|
+
abstract obtainLock<T>(lockOptions: LockOptions<T>): Promise<T>;
|
|
1001
|
+
hasCompletedSync(): Promise<boolean>;
|
|
1002
|
+
getWriteCheckpoint(): Promise<string>;
|
|
1003
|
+
protected _uploadAllCrud(): Promise<void>;
|
|
1004
|
+
connect(options?: PowerSyncConnectionOptions): Promise<void>;
|
|
1005
|
+
disconnect(): Promise<void>;
|
|
1006
|
+
/**
|
|
1007
|
+
* @deprecated use [connect instead]
|
|
1008
|
+
*/
|
|
1009
|
+
streamingSync(signal?: AbortSignal, options?: PowerSyncConnectionOptions): Promise<void>;
|
|
1010
|
+
private collectLocalBucketState;
|
|
1011
|
+
/**
|
|
1012
|
+
* Older versions of the JS SDK used to encode subkeys as JSON in {@link OplogEntry.toJSON}.
|
|
1013
|
+
* Because subkeys are always strings, this leads to quotes being added around them in `ps_oplog`.
|
|
1014
|
+
* While this is not a problem as long as it's done consistently, it causes issues when a database
|
|
1015
|
+
* created by the JS SDK is used with other SDKs, or (more likely) when the new Rust sync client
|
|
1016
|
+
* is enabled.
|
|
1017
|
+
*
|
|
1018
|
+
* So, we add a migration from the old key format (with quotes) to the new one (no quotes). The
|
|
1019
|
+
* migration is only triggered when necessary (for now). The function returns whether the new format
|
|
1020
|
+
* should be used, so that the JS SDK is able to write to updated databases.
|
|
1021
|
+
*
|
|
1022
|
+
* @param requireFixedKeyFormat Whether we require the new format or also support the old one.
|
|
1023
|
+
* The Rust client requires the new subkey format.
|
|
1024
|
+
* @returns Whether the database is now using the new, fixed subkey format.
|
|
1025
|
+
*/
|
|
1026
|
+
private requireKeyFormat;
|
|
1027
|
+
protected streamingSyncIteration(signal: AbortSignal, options?: PowerSyncConnectionOptions): Promise<RustIterationResult | null>;
|
|
1028
|
+
private legacyStreamingSyncIteration;
|
|
1029
|
+
private rustSyncIteration;
|
|
1030
|
+
private updateSyncStatusForStartingCheckpoint;
|
|
1031
|
+
private applyCheckpoint;
|
|
1032
|
+
protected updateSyncStatus(options: SyncStatusOptions): void;
|
|
1033
|
+
private delayRetry;
|
|
1034
|
+
updateSubscriptions(subscriptions: SubscribedStream[]): void;
|
|
1035
|
+
}
|
|
1036
|
+
interface RustIterationResult {
|
|
1037
|
+
immediateRestart: boolean;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
/** @internal */
|
|
1041
|
+
type InternalProgressInformation = Record<string, BucketProgress>;
|
|
878
1042
|
/**
|
|
879
|
-
*
|
|
1043
|
+
* Information about a progressing download made by the PowerSync SDK.
|
|
1044
|
+
*
|
|
1045
|
+
* To obtain these values, use {@link SyncProgress}, available through
|
|
1046
|
+
* {@link SyncStatus#downloadProgress}.
|
|
880
1047
|
*/
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
1048
|
+
interface ProgressWithOperations {
|
|
1049
|
+
/**
|
|
1050
|
+
* The total amount of operations to download for the current sync iteration
|
|
1051
|
+
* to complete.
|
|
1052
|
+
*/
|
|
1053
|
+
totalOperations: number;
|
|
1054
|
+
/**
|
|
1055
|
+
* The amount of operations that have already been downloaded.
|
|
1056
|
+
*/
|
|
1057
|
+
downloadedOperations: number;
|
|
1058
|
+
/**
|
|
1059
|
+
* Relative progress, as {@link downloadedOperations} of {@link totalOperations}.
|
|
1060
|
+
*
|
|
1061
|
+
* This will be a number between `0.0` and `1.0` (inclusive).
|
|
1062
|
+
*
|
|
1063
|
+
* When this number reaches `1.0`, all changes have been received from the sync service.
|
|
1064
|
+
* Actually applying these changes happens before the `downloadProgress` field is cleared from
|
|
1065
|
+
* {@link SyncStatus}, so progress can stay at `1.0` for a short while before completing.
|
|
1066
|
+
*/
|
|
1067
|
+
downloadedFraction: number;
|
|
1068
|
+
}
|
|
885
1069
|
/**
|
|
886
|
-
*
|
|
1070
|
+
* Provides realtime progress on how PowerSync is downloading rows.
|
|
887
1071
|
*
|
|
888
|
-
*
|
|
889
|
-
*
|
|
1072
|
+
* The progress until the next complete sync is available through the fields on {@link ProgressWithOperations},
|
|
1073
|
+
* which this class implements.
|
|
1074
|
+
* Additionally, the {@link SyncProgress.untilPriority} method can be used to otbain progress towards
|
|
1075
|
+
* a specific priority (instead of the progress for the entire download).
|
|
890
1076
|
*
|
|
891
|
-
*
|
|
892
|
-
*
|
|
893
|
-
* using raw tables.
|
|
1077
|
+
* The reported progress always reflects the status towards the end of a sync iteration (after
|
|
1078
|
+
* which a consistent snapshot of all buckets is available locally).
|
|
894
1079
|
*
|
|
895
|
-
*
|
|
1080
|
+
* In rare cases (in particular, when a [compacting](https://docs.powersync.com/usage/lifecycle-maintenance/compacting-buckets)
|
|
1081
|
+
* operation takes place between syncs), it's possible for the returned numbers to be slightly
|
|
1082
|
+
* inaccurate. For this reason, {@link SyncProgress} should be seen as an approximation of progress.
|
|
1083
|
+
* The information returned is good enough to build progress bars, but not exact enough to track
|
|
1084
|
+
* individual download counts.
|
|
896
1085
|
*
|
|
897
|
-
*
|
|
898
|
-
*
|
|
1086
|
+
* Also note that data is downloaded in bulk, which means that individual counters are unlikely
|
|
1087
|
+
* to be updated one-by-one.
|
|
899
1088
|
*/
|
|
900
|
-
declare class
|
|
1089
|
+
declare class SyncProgress implements ProgressWithOperations {
|
|
1090
|
+
protected internal: InternalProgressInformation;
|
|
1091
|
+
totalOperations: number;
|
|
1092
|
+
downloadedOperations: number;
|
|
1093
|
+
downloadedFraction: number;
|
|
1094
|
+
constructor(internal: InternalProgressInformation);
|
|
901
1095
|
/**
|
|
902
|
-
*
|
|
1096
|
+
* Returns download progress towards all data up until the specified priority being received.
|
|
903
1097
|
*
|
|
904
|
-
*
|
|
905
|
-
*
|
|
906
|
-
* appears in the source / backend database) are to be handled specially.
|
|
1098
|
+
* The returned {@link ProgressWithOperations} tracks the target amount of operations that need
|
|
1099
|
+
* to be downloaded in total and how many of them have already been received.
|
|
907
1100
|
*/
|
|
908
|
-
|
|
909
|
-
put: PendingStatement;
|
|
910
|
-
delete: PendingStatement;
|
|
911
|
-
constructor(name: string, type: RawTableType);
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
interface IndexColumnOptions {
|
|
915
|
-
name: string;
|
|
916
|
-
ascending?: boolean;
|
|
917
|
-
}
|
|
918
|
-
declare const DEFAULT_INDEX_COLUMN_OPTIONS: Partial<IndexColumnOptions>;
|
|
919
|
-
declare class IndexedColumn {
|
|
920
|
-
protected options: IndexColumnOptions;
|
|
921
|
-
static createAscending(column: string): IndexedColumn;
|
|
922
|
-
constructor(options: IndexColumnOptions);
|
|
923
|
-
get name(): string;
|
|
924
|
-
get ascending(): boolean | undefined;
|
|
925
|
-
toJSON(table: Table): {
|
|
926
|
-
name: string;
|
|
927
|
-
ascending: boolean | undefined;
|
|
928
|
-
type: ColumnType;
|
|
929
|
-
};
|
|
1101
|
+
untilPriority(priority: number): ProgressWithOperations;
|
|
930
1102
|
}
|
|
931
1103
|
|
|
932
|
-
|
|
1104
|
+
/**
|
|
1105
|
+
* A description of a sync stream, consisting of its {@link name} and the {@link parameters} used when subscribing.
|
|
1106
|
+
*/
|
|
1107
|
+
interface SyncStreamDescription {
|
|
1108
|
+
/**
|
|
1109
|
+
* The name of the stream as it appears in the stream definition for the PowerSync service.
|
|
1110
|
+
*/
|
|
933
1111
|
name: string;
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
constructor(options: IndexOptions);
|
|
941
|
-
get name(): string;
|
|
942
|
-
get columns(): IndexedColumn[];
|
|
943
|
-
toJSON(table: Table): {
|
|
944
|
-
name: string;
|
|
945
|
-
columns: {
|
|
946
|
-
name: string;
|
|
947
|
-
ascending: boolean | undefined;
|
|
948
|
-
type: ColumnType;
|
|
949
|
-
}[];
|
|
950
|
-
};
|
|
1112
|
+
/**
|
|
1113
|
+
* The parameters used to subscribe to the stream, if any.
|
|
1114
|
+
*
|
|
1115
|
+
* The same stream can be subscribed to multiple times with different parameters.
|
|
1116
|
+
*/
|
|
1117
|
+
parameters: Record<string, any> | null;
|
|
951
1118
|
}
|
|
952
|
-
|
|
953
1119
|
/**
|
|
954
|
-
|
|
955
|
-
@deprecated You should use {@link Table} instead as it now allows TableV2 syntax.
|
|
956
|
-
This will be removed in the next major release.
|
|
957
|
-
*/
|
|
958
|
-
declare class TableV2<Columns extends ColumnsType = ColumnsType> extends Table<Columns> {
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
interface SharedTableOptions {
|
|
962
|
-
localOnly?: boolean;
|
|
963
|
-
insertOnly?: boolean;
|
|
964
|
-
viewName?: string;
|
|
965
|
-
trackPrevious?: boolean | TrackPreviousOptions;
|
|
966
|
-
trackMetadata?: boolean;
|
|
967
|
-
ignoreEmptyUpdates?: boolean;
|
|
968
|
-
}
|
|
969
|
-
/** Whether to include previous column values when PowerSync tracks local changes.
|
|
1120
|
+
* Information about a subscribed sync stream.
|
|
970
1121
|
*
|
|
971
|
-
*
|
|
972
|
-
* why it can be enabled on per-table or per-columm basis.
|
|
1122
|
+
* This includes the {@link SyncStreamDescription}, along with information about the current sync status.
|
|
973
1123
|
*/
|
|
974
|
-
interface
|
|
975
|
-
|
|
976
|
-
columns?: string[];
|
|
977
|
-
/** When enabled, only include values that have actually been changed by an update. */
|
|
978
|
-
onlyWhenChanged?: boolean;
|
|
979
|
-
}
|
|
980
|
-
interface TableOptions extends SharedTableOptions {
|
|
1124
|
+
interface SyncSubscriptionDescription extends SyncStreamDescription {
|
|
1125
|
+
active: boolean;
|
|
981
1126
|
/**
|
|
982
|
-
*
|
|
1127
|
+
* Whether this stream subscription is included by default, regardless of whether the stream has explicitly been
|
|
1128
|
+
* subscribed to or not.
|
|
1129
|
+
*
|
|
1130
|
+
* It's possible for both {@link isDefault} and {@link hasExplicitSubscription} to be true at the same time - this
|
|
1131
|
+
* happens when a default stream was subscribed explicitly.
|
|
983
1132
|
*/
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1133
|
+
isDefault: boolean;
|
|
1134
|
+
/**
|
|
1135
|
+
* Whether this stream has been subscribed to explicitly.
|
|
1136
|
+
*
|
|
1137
|
+
* It's possible for both {@link isDefault} and {@link hasExplicitSubscription} to be true at the same time - this
|
|
1138
|
+
* happens when a default stream was subscribed explicitly.
|
|
1139
|
+
*/
|
|
1140
|
+
hasExplicitSubscription: boolean;
|
|
1141
|
+
/**
|
|
1142
|
+
* For sync streams that have a time-to-live, the current time at which the stream would expire if not subscribed to
|
|
1143
|
+
* again.
|
|
1144
|
+
*/
|
|
1145
|
+
expiresAt: Date | null;
|
|
1146
|
+
/**
|
|
1147
|
+
* Whether this stream subscription has been synced at least once.
|
|
1148
|
+
*/
|
|
1149
|
+
hasSynced: boolean;
|
|
1150
|
+
/**
|
|
1151
|
+
* If {@link hasSynced} is true, the last time data from this stream has been synced.
|
|
1152
|
+
*/
|
|
1153
|
+
lastSyncedAt: Date | null;
|
|
996
1154
|
}
|
|
997
|
-
|
|
998
|
-
indexes: never[];
|
|
999
|
-
insertOnly: boolean;
|
|
1000
|
-
localOnly: boolean;
|
|
1001
|
-
trackPrevious: boolean;
|
|
1002
|
-
trackMetadata: boolean;
|
|
1003
|
-
ignoreEmptyUpdates: boolean;
|
|
1004
|
-
};
|
|
1005
|
-
declare const InvalidSQLCharacters: RegExp;
|
|
1006
|
-
declare class Table<Columns extends ColumnsType = ColumnsType> {
|
|
1007
|
-
protected options: TableOptions;
|
|
1008
|
-
protected _mappedColumns: Columns;
|
|
1009
|
-
static createLocalOnly(options: TableOptions): Table<ColumnsType>;
|
|
1010
|
-
static createInsertOnly(options: TableOptions): Table<ColumnsType>;
|
|
1155
|
+
interface SyncStreamSubscribeOptions {
|
|
1011
1156
|
/**
|
|
1012
|
-
*
|
|
1013
|
-
* @deprecated This was only only included for TableV2 and is no longer necessary.
|
|
1014
|
-
* Prefer to use new Table() directly.
|
|
1157
|
+
* A "time to live" for this stream subscription, in seconds.
|
|
1015
1158
|
*
|
|
1016
|
-
*
|
|
1159
|
+
* The TTL control when a stream gets evicted after not having an active {@link SyncStreamSubscription} object
|
|
1160
|
+
* attached to it.
|
|
1017
1161
|
*/
|
|
1018
|
-
|
|
1162
|
+
ttl?: number;
|
|
1019
1163
|
/**
|
|
1020
|
-
*
|
|
1164
|
+
* A priority to assign to this subscription. This overrides the default priority that may have been set on streams.
|
|
1021
1165
|
*
|
|
1022
|
-
*
|
|
1023
|
-
|
|
1024
|
-
|
|
1166
|
+
* For details on priorities, see [priotized sync](https://docs.powersync.com/usage/use-case-examples/prioritized-sync).
|
|
1167
|
+
*/
|
|
1168
|
+
priority?: 0 | 1 | 2 | 3;
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* A handle to a {@link SyncStreamDescription} that allows subscribing to the stream.
|
|
1172
|
+
*
|
|
1173
|
+
* To obtain an instance of {@link SyncStream}, call {@link AbstractPowerSyncDatabase.syncStream}.
|
|
1174
|
+
*/
|
|
1175
|
+
interface SyncStream extends SyncStreamDescription {
|
|
1176
|
+
/**
|
|
1177
|
+
* Adds a subscription to this stream, requesting it to be included when connecting to the sync service.
|
|
1025
1178
|
*
|
|
1026
|
-
* @
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1029
|
-
*
|
|
1030
|
-
* @example
|
|
1031
|
-
* ```javascript
|
|
1032
|
-
* // New Constructor
|
|
1033
|
-
* const table = new Table(
|
|
1034
|
-
* {
|
|
1035
|
-
* name: column.text,
|
|
1036
|
-
* age: column.integer
|
|
1037
|
-
* },
|
|
1038
|
-
* { indexes: { nameIndex: ['name'] } }
|
|
1039
|
-
* );
|
|
1040
|
-
*```
|
|
1041
|
-
*
|
|
1042
|
-
*
|
|
1043
|
-
* @example
|
|
1044
|
-
* ```javascript
|
|
1045
|
-
* // Deprecated Constructor
|
|
1046
|
-
* const table = new Table({
|
|
1047
|
-
* name: 'users',
|
|
1048
|
-
* columns: [
|
|
1049
|
-
* new Column({ name: 'name', type: ColumnType.TEXT }),
|
|
1050
|
-
* new Column({ name: 'age', type: ColumnType.INTEGER })
|
|
1051
|
-
* ]
|
|
1052
|
-
* });
|
|
1053
|
-
*```
|
|
1179
|
+
* You should keep a reference to the returned {@link SyncStreamSubscription} object along as you need data for that
|
|
1180
|
+
* stream. As soon as {@link SyncStreamSubscription.unsubscribe} is called for all subscriptions on this stream
|
|
1181
|
+
* (including subscriptions created on other tabs), the {@link SyncStreamSubscribeOptions.ttl} starts ticking and will
|
|
1182
|
+
* eventually evict the stream (unless {@link subscribe} is called again).
|
|
1054
1183
|
*/
|
|
1055
|
-
|
|
1184
|
+
subscribe(options?: SyncStreamSubscribeOptions): Promise<SyncStreamSubscription>;
|
|
1056
1185
|
/**
|
|
1057
|
-
*
|
|
1058
|
-
* Use the new constructor shown below instead as this does not show types.
|
|
1059
|
-
* @example
|
|
1060
|
-
* <caption>Use this instead</caption>
|
|
1061
|
-
* ```javascript
|
|
1062
|
-
* const table = new Table(
|
|
1063
|
-
* {
|
|
1064
|
-
* name: column.text,
|
|
1065
|
-
* age: column.integer
|
|
1066
|
-
* },
|
|
1067
|
-
* { indexes: { nameIndex: ['name'] } }
|
|
1068
|
-
* );
|
|
1069
|
-
*```
|
|
1070
|
-
*/
|
|
1071
|
-
constructor(options: TableOptions);
|
|
1072
|
-
copyWithName(name: string): Table;
|
|
1073
|
-
private isTableV1;
|
|
1074
|
-
private initTableV1;
|
|
1075
|
-
private initTableV2;
|
|
1076
|
-
private applyDefaultOptions;
|
|
1077
|
-
get name(): string;
|
|
1078
|
-
get viewNameOverride(): string | undefined;
|
|
1079
|
-
get viewName(): string;
|
|
1080
|
-
get columns(): Column[];
|
|
1081
|
-
get columnMap(): Columns;
|
|
1082
|
-
get indexes(): Index[];
|
|
1083
|
-
get localOnly(): boolean;
|
|
1084
|
-
get insertOnly(): boolean;
|
|
1085
|
-
get trackPrevious(): boolean | TrackPreviousOptions;
|
|
1086
|
-
get trackMetadata(): boolean;
|
|
1087
|
-
get ignoreEmptyUpdates(): boolean;
|
|
1088
|
-
get internalName(): string;
|
|
1089
|
-
get validName(): boolean;
|
|
1090
|
-
validate(): void;
|
|
1091
|
-
toJSON(): {
|
|
1092
|
-
name: string;
|
|
1093
|
-
view_name: string;
|
|
1094
|
-
local_only: boolean;
|
|
1095
|
-
insert_only: boolean;
|
|
1096
|
-
include_old: any;
|
|
1097
|
-
include_old_only_when_changed: boolean;
|
|
1098
|
-
include_metadata: boolean;
|
|
1099
|
-
ignore_empty_update: boolean;
|
|
1100
|
-
columns: {
|
|
1101
|
-
name: string;
|
|
1102
|
-
type: ColumnType | undefined;
|
|
1103
|
-
}[];
|
|
1104
|
-
indexes: {
|
|
1105
|
-
name: string;
|
|
1106
|
-
columns: {
|
|
1107
|
-
name: string;
|
|
1108
|
-
ascending: boolean | undefined;
|
|
1109
|
-
type: ColumnType;
|
|
1110
|
-
}[];
|
|
1111
|
-
}[];
|
|
1112
|
-
};
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
type SchemaType = Record<string, Table<any>>;
|
|
1116
|
-
type SchemaTableType<S extends SchemaType> = {
|
|
1117
|
-
[K in keyof S]: RowType<S[K]>;
|
|
1118
|
-
};
|
|
1119
|
-
/**
|
|
1120
|
-
* A schema is a collection of tables. It is used to define the structure of a database.
|
|
1121
|
-
*/
|
|
1122
|
-
declare class Schema<S extends SchemaType = SchemaType> {
|
|
1123
|
-
readonly types: SchemaTableType<S>;
|
|
1124
|
-
readonly props: S;
|
|
1125
|
-
readonly tables: Table[];
|
|
1126
|
-
readonly rawTables: RawTable[];
|
|
1127
|
-
constructor(tables: Table[] | S);
|
|
1128
|
-
/**
|
|
1129
|
-
* Adds raw tables to this schema. Raw tables are identified by their name, but entirely managed by the application
|
|
1130
|
-
* developer instead of automatically by PowerSync.
|
|
1131
|
-
* Since raw tables are not backed by JSON, running complex queries on them may be more efficient. Further, they allow
|
|
1132
|
-
* using client-side table and column constraints.
|
|
1133
|
-
* Note that raw tables are only supported when using the new `SyncClientImplementation.rust` sync client.
|
|
1186
|
+
* Clears all subscriptions attached to this stream and resets the TTL for the stream.
|
|
1134
1187
|
*
|
|
1135
|
-
*
|
|
1136
|
-
* @experimental Note that the raw tables API is still experimental and may change in the future.
|
|
1188
|
+
* This is a potentially dangerous operations, as it interferes with other stream subscriptions.
|
|
1137
1189
|
*/
|
|
1138
|
-
|
|
1139
|
-
validate(): void;
|
|
1140
|
-
toJSON(): {
|
|
1141
|
-
tables: {
|
|
1142
|
-
name: string;
|
|
1143
|
-
view_name: string;
|
|
1144
|
-
local_only: boolean;
|
|
1145
|
-
insert_only: boolean;
|
|
1146
|
-
include_old: any;
|
|
1147
|
-
include_old_only_when_changed: boolean;
|
|
1148
|
-
include_metadata: boolean;
|
|
1149
|
-
ignore_empty_update: boolean;
|
|
1150
|
-
columns: {
|
|
1151
|
-
name: string;
|
|
1152
|
-
type: ColumnType | undefined;
|
|
1153
|
-
}[];
|
|
1154
|
-
indexes: {
|
|
1155
|
-
name: string;
|
|
1156
|
-
columns: {
|
|
1157
|
-
name: string;
|
|
1158
|
-
ascending: boolean | undefined;
|
|
1159
|
-
type: ColumnType;
|
|
1160
|
-
}[];
|
|
1161
|
-
}[];
|
|
1162
|
-
}[];
|
|
1163
|
-
raw_tables: RawTable[];
|
|
1164
|
-
};
|
|
1165
|
-
private convertToClassicTables;
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
interface PowerSyncCredentials {
|
|
1169
|
-
endpoint: string;
|
|
1170
|
-
token: string;
|
|
1171
|
-
expiresAt?: Date;
|
|
1190
|
+
unsubscribeAll(): Promise<void>;
|
|
1172
1191
|
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
* which is used to authenticate against the PowerSync service.
|
|
1177
|
-
*
|
|
1178
|
-
* This should always fetch a fresh set of credentials - don't use cached
|
|
1179
|
-
* values.
|
|
1180
|
-
*
|
|
1181
|
-
* Return null if the user is not signed in. Throw an error if credentials
|
|
1182
|
-
* cannot be fetched due to a network error or other temporary error.
|
|
1183
|
-
*
|
|
1184
|
-
* This token is kept for the duration of a sync connection.
|
|
1185
|
-
*/
|
|
1186
|
-
fetchCredentials: () => Promise<PowerSyncCredentials | null>;
|
|
1187
|
-
/** Upload local changes to the app backend.
|
|
1188
|
-
*
|
|
1189
|
-
* Use {@link AbstractPowerSyncDatabase.getCrudBatch} to get a batch of changes to upload.
|
|
1190
|
-
*
|
|
1191
|
-
* Any thrown errors will result in a retry after the configured wait period (default: 5 seconds).
|
|
1192
|
+
interface SyncStreamSubscription extends SyncStreamDescription {
|
|
1193
|
+
/**
|
|
1194
|
+
* A promise that resolves once data from in this sync stream has been synced and applied.
|
|
1192
1195
|
*/
|
|
1193
|
-
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
type DataStreamOptions<ParsedData, SourceData> = {
|
|
1197
|
-
mapLine?: (line: SourceData) => ParsedData;
|
|
1196
|
+
waitForFirstSync(abort?: AbortSignal): Promise<void>;
|
|
1198
1197
|
/**
|
|
1199
|
-
*
|
|
1198
|
+
* Removes this stream subscription.
|
|
1200
1199
|
*/
|
|
1201
|
-
|
|
1202
|
-
pressure?: {
|
|
1203
|
-
highWaterMark?: number;
|
|
1204
|
-
lowWaterMark?: number;
|
|
1205
|
-
};
|
|
1206
|
-
logger?: ILogger;
|
|
1207
|
-
};
|
|
1208
|
-
type DataStreamCallback<Data extends any = any> = (data: Data) => Promise<void>;
|
|
1209
|
-
interface DataStreamListener<Data extends any = any> extends BaseListener {
|
|
1210
|
-
data: (data: Data) => Promise<void>;
|
|
1211
|
-
closed: () => void;
|
|
1212
|
-
error: (error: Error) => void;
|
|
1213
|
-
highWater: () => Promise<void>;
|
|
1214
|
-
lowWater: () => Promise<void>;
|
|
1200
|
+
unsubscribe(): void;
|
|
1215
1201
|
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
/**
|
|
1221
|
-
* A very basic implementation of a data stream with backpressure support which does not use
|
|
1222
|
-
* native JS streams or async iterators.
|
|
1223
|
-
* This is handy for environments such as React Native which need polyfills for the above.
|
|
1224
|
-
*/
|
|
1225
|
-
declare class DataStream<ParsedData, SourceData = any> extends BaseObserver<DataStreamListener<ParsedData>> {
|
|
1226
|
-
protected options?: DataStreamOptions<ParsedData, SourceData> | undefined;
|
|
1227
|
-
dataQueue: SourceData[];
|
|
1228
|
-
protected isClosed: boolean;
|
|
1229
|
-
protected processingPromise: Promise<void> | null;
|
|
1230
|
-
protected notifyDataAdded: (() => void) | null;
|
|
1231
|
-
protected logger: ILogger;
|
|
1232
|
-
protected mapLine: (line: SourceData) => ParsedData;
|
|
1233
|
-
constructor(options?: DataStreamOptions<ParsedData, SourceData> | undefined);
|
|
1234
|
-
get highWatermark(): number;
|
|
1235
|
-
get lowWatermark(): number;
|
|
1236
|
-
get closed(): boolean;
|
|
1237
|
-
close(): Promise<void>;
|
|
1202
|
+
|
|
1203
|
+
type SyncDataFlowStatus = Partial<{
|
|
1204
|
+
downloading: boolean;
|
|
1205
|
+
uploading: boolean;
|
|
1238
1206
|
/**
|
|
1239
|
-
*
|
|
1207
|
+
* Error during downloading (including connecting).
|
|
1208
|
+
*
|
|
1209
|
+
* Cleared on the next successful data download.
|
|
1240
1210
|
*/
|
|
1241
|
-
|
|
1211
|
+
downloadError?: Error;
|
|
1242
1212
|
/**
|
|
1243
|
-
*
|
|
1244
|
-
*
|
|
1213
|
+
* Error during uploading.
|
|
1214
|
+
* Cleared on the next successful upload.
|
|
1245
1215
|
*/
|
|
1246
|
-
|
|
1216
|
+
uploadError?: Error;
|
|
1247
1217
|
/**
|
|
1248
|
-
*
|
|
1218
|
+
* Internal information about how far we are downloading operations in buckets.
|
|
1219
|
+
*
|
|
1220
|
+
* Please use the {@link SyncStatus#downloadProgress} property to track sync progress.
|
|
1249
1221
|
*/
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1222
|
+
downloadProgress: InternalProgressInformation | null;
|
|
1223
|
+
internalStreamSubscriptions: CoreStreamSubscription[] | null;
|
|
1224
|
+
}>;
|
|
1225
|
+
interface SyncPriorityStatus {
|
|
1226
|
+
priority: number;
|
|
1227
|
+
lastSyncedAt?: Date;
|
|
1228
|
+
hasSynced?: boolean;
|
|
1255
1229
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
path: string;
|
|
1265
|
-
data: StreamingSyncRequest;
|
|
1266
|
-
headers?: Record<string, string>;
|
|
1267
|
-
abortSignal?: AbortSignal;
|
|
1268
|
-
fetchOptions?: Request;
|
|
1230
|
+
type SyncStatusOptions = {
|
|
1231
|
+
connected?: boolean;
|
|
1232
|
+
connecting?: boolean;
|
|
1233
|
+
dataFlow?: SyncDataFlowStatus;
|
|
1234
|
+
lastSyncedAt?: Date;
|
|
1235
|
+
hasSynced?: boolean;
|
|
1236
|
+
priorityStatusEntries?: SyncPriorityStatus[];
|
|
1237
|
+
clientImplementation?: SyncClientImplementation;
|
|
1269
1238
|
};
|
|
1270
|
-
declare
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
* This comes at the cost of more processing overhead, which may cause ACK timeouts on older/weaker devices for big enough datasets.
|
|
1274
|
-
*/
|
|
1275
|
-
Buffered = "buffered",
|
|
1239
|
+
declare class SyncStatus {
|
|
1240
|
+
protected options: SyncStatusOptions;
|
|
1241
|
+
constructor(options: SyncStatusOptions);
|
|
1276
1242
|
/**
|
|
1277
|
-
*
|
|
1278
|
-
*
|
|
1243
|
+
* Returns the used sync client implementation (either the one implemented in JavaScript or the newer Rust-based
|
|
1244
|
+
* implementation).
|
|
1245
|
+
*
|
|
1246
|
+
* This information is only available after a connection has been requested.
|
|
1279
1247
|
*/
|
|
1280
|
-
|
|
1281
|
-
}
|
|
1282
|
-
type SocketSyncStreamOptions = SyncStreamOptions & {
|
|
1283
|
-
fetchStrategy: FetchStrategy;
|
|
1284
|
-
};
|
|
1285
|
-
type FetchImplementation = typeof fetch;
|
|
1286
|
-
/**
|
|
1287
|
-
* Class wrapper for providing a fetch implementation.
|
|
1288
|
-
* The class wrapper is used to distinguish the fetchImplementation
|
|
1289
|
-
* option in [AbstractRemoteOptions] from the general fetch method
|
|
1290
|
-
* which is typeof "function"
|
|
1291
|
-
*/
|
|
1292
|
-
declare class FetchImplementationProvider {
|
|
1293
|
-
getFetch(): FetchImplementation;
|
|
1294
|
-
}
|
|
1295
|
-
type AbstractRemoteOptions = {
|
|
1248
|
+
get clientImplementation(): SyncClientImplementation | undefined;
|
|
1296
1249
|
/**
|
|
1297
|
-
*
|
|
1298
|
-
*
|
|
1299
|
-
*
|
|
1250
|
+
* Indicates if the client is currently connected to the PowerSync service.
|
|
1251
|
+
*
|
|
1252
|
+
* @returns {boolean} True if connected, false otherwise. Defaults to false if not specified.
|
|
1300
1253
|
*/
|
|
1301
|
-
|
|
1254
|
+
get connected(): boolean;
|
|
1302
1255
|
/**
|
|
1303
|
-
*
|
|
1304
|
-
*
|
|
1305
|
-
*
|
|
1256
|
+
* Indicates if the client is in the process of establishing a connection to the PowerSync service.
|
|
1257
|
+
*
|
|
1258
|
+
* @returns {boolean} True if connecting, false otherwise. Defaults to false if not specified.
|
|
1306
1259
|
*/
|
|
1307
|
-
|
|
1260
|
+
get connecting(): boolean;
|
|
1308
1261
|
/**
|
|
1309
|
-
*
|
|
1262
|
+
* Time that a last sync has fully completed, if any.
|
|
1263
|
+
* This timestamp is reset to null after a restart of the PowerSync service.
|
|
1310
1264
|
*
|
|
1311
|
-
*
|
|
1312
|
-
* `cache`, or any other fetch-compatible options.
|
|
1265
|
+
* @returns {Date | undefined} The timestamp of the last successful sync, or undefined if no sync has completed.
|
|
1313
1266
|
*/
|
|
1314
|
-
|
|
1315
|
-
};
|
|
1316
|
-
declare const DEFAULT_REMOTE_OPTIONS: AbstractRemoteOptions;
|
|
1317
|
-
declare abstract class AbstractRemote {
|
|
1318
|
-
protected connector: RemoteConnector;
|
|
1319
|
-
protected logger: ILogger;
|
|
1320
|
-
protected credentials: PowerSyncCredentials | null;
|
|
1321
|
-
protected options: AbstractRemoteOptions;
|
|
1322
|
-
constructor(connector: RemoteConnector, logger?: ILogger, options?: Partial<AbstractRemoteOptions>);
|
|
1267
|
+
get lastSyncedAt(): Date | undefined;
|
|
1323
1268
|
/**
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1269
|
+
* Indicates whether there has been at least one full sync completed since initialization.
|
|
1270
|
+
*
|
|
1271
|
+
* @returns {boolean | undefined} True if at least one sync has completed, false if no sync has completed,
|
|
1272
|
+
* or undefined when the state is still being loaded from the database.
|
|
1326
1273
|
*/
|
|
1327
|
-
get
|
|
1274
|
+
get hasSynced(): boolean | undefined;
|
|
1328
1275
|
/**
|
|
1329
|
-
*
|
|
1330
|
-
* available.
|
|
1276
|
+
* Provides the current data flow status regarding uploads and downloads.
|
|
1331
1277
|
*
|
|
1332
|
-
*
|
|
1278
|
+
* @returns {SyncDataFlowStatus} An object containing:
|
|
1279
|
+
* - downloading: True if actively downloading changes (only when connected is also true)
|
|
1280
|
+
* - uploading: True if actively uploading changes
|
|
1281
|
+
* Defaults to {downloading: false, uploading: false} if not specified.
|
|
1333
1282
|
*/
|
|
1334
|
-
|
|
1283
|
+
get dataFlowStatus(): Partial<{
|
|
1284
|
+
downloading: boolean;
|
|
1285
|
+
uploading: boolean;
|
|
1286
|
+
/**
|
|
1287
|
+
* Error during downloading (including connecting).
|
|
1288
|
+
*
|
|
1289
|
+
* Cleared on the next successful data download.
|
|
1290
|
+
*/
|
|
1291
|
+
downloadError?: Error;
|
|
1292
|
+
/**
|
|
1293
|
+
* Error during uploading.
|
|
1294
|
+
* Cleared on the next successful upload.
|
|
1295
|
+
*/
|
|
1296
|
+
uploadError?: Error;
|
|
1297
|
+
/**
|
|
1298
|
+
* Internal information about how far we are downloading operations in buckets.
|
|
1299
|
+
*
|
|
1300
|
+
* Please use the {@link SyncStatus#downloadProgress} property to track sync progress.
|
|
1301
|
+
*/
|
|
1302
|
+
downloadProgress: InternalProgressInformation | null;
|
|
1303
|
+
internalStreamSubscriptions: CoreStreamSubscription[] | null;
|
|
1304
|
+
}>;
|
|
1335
1305
|
/**
|
|
1336
|
-
*
|
|
1306
|
+
* All sync streams currently being tracked in teh database.
|
|
1337
1307
|
*
|
|
1338
|
-
*
|
|
1339
|
-
*
|
|
1308
|
+
* This returns null when the database is currently being opened and we don't have reliable information about all
|
|
1309
|
+
* included streams yet.
|
|
1340
1310
|
*
|
|
1341
|
-
*
|
|
1311
|
+
* @experimental Sync streams are currently in alpha.
|
|
1342
1312
|
*/
|
|
1343
|
-
|
|
1313
|
+
get syncStreams(): SyncStreamStatus[] | undefined;
|
|
1344
1314
|
/**
|
|
1345
|
-
*
|
|
1315
|
+
* If the `stream` appears in {@link syncStreams}, returns the current status for that stream.
|
|
1346
1316
|
*
|
|
1347
|
-
*
|
|
1348
|
-
* values.
|
|
1317
|
+
* @experimental Sync streams are currently in alpha.
|
|
1349
1318
|
*/
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
*
|
|
1319
|
+
forStream(stream: SyncStreamDescription): SyncStreamStatus | undefined;
|
|
1320
|
+
/**
|
|
1321
|
+
* Provides sync status information for all bucket priorities, sorted by priority (highest first).
|
|
1353
1322
|
*
|
|
1354
|
-
*
|
|
1323
|
+
* @returns {SyncPriorityStatus[]} An array of status entries for different sync priority levels,
|
|
1324
|
+
* sorted with highest priorities (lower numbers) first.
|
|
1355
1325
|
*/
|
|
1356
|
-
|
|
1357
|
-
getUserAgent(): string;
|
|
1358
|
-
protected buildRequest(path: string): Promise<{
|
|
1359
|
-
url: string;
|
|
1360
|
-
headers: {
|
|
1361
|
-
'content-type': string;
|
|
1362
|
-
Authorization: string;
|
|
1363
|
-
'x-user-agent': string;
|
|
1364
|
-
};
|
|
1365
|
-
}>;
|
|
1366
|
-
post(path: string, data: any, headers?: Record<string, string>): Promise<any>;
|
|
1367
|
-
get(path: string, headers?: Record<string, string>): Promise<any>;
|
|
1326
|
+
get priorityStatusEntries(): SyncPriorityStatus[];
|
|
1368
1327
|
/**
|
|
1369
|
-
*
|
|
1328
|
+
* A realtime progress report on how many operations have been downloaded and
|
|
1329
|
+
* how many are necessary in total to complete the next sync iteration.
|
|
1330
|
+
*
|
|
1331
|
+
* This field is only set when {@link SyncDataFlowStatus#downloading} is also true.
|
|
1370
1332
|
*/
|
|
1371
|
-
|
|
1372
|
-
protected createSocket(url: string): WebSocket;
|
|
1333
|
+
get downloadProgress(): SyncProgress | null;
|
|
1373
1334
|
/**
|
|
1374
|
-
*
|
|
1335
|
+
* Reports the sync status (a pair of {@link SyncStatus#hasSynced} and {@link SyncStatus#lastSyncedAt} fields)
|
|
1336
|
+
* for a specific bucket priority level.
|
|
1375
1337
|
*
|
|
1376
|
-
*
|
|
1377
|
-
*
|
|
1378
|
-
*
|
|
1338
|
+
* When buckets with different priorities are declared, PowerSync may choose to synchronize higher-priority
|
|
1339
|
+
* buckets first. When a consistent view over all buckets for all priorities up until the given priority is
|
|
1340
|
+
* reached, PowerSync makes data from those buckets available before lower-priority buckets have finished
|
|
1341
|
+
* syncing.
|
|
1342
|
+
*
|
|
1343
|
+
* This method returns the status for the requested priority or the next higher priority level that has
|
|
1344
|
+
* status information available. This is because when PowerSync makes data for a given priority available,
|
|
1345
|
+
* all buckets in higher-priorities are guaranteed to be consistent with that checkpoint.
|
|
1346
|
+
*
|
|
1347
|
+
* For example, if PowerSync just finished synchronizing buckets in priority level 3, calling this method
|
|
1348
|
+
* with a priority of 1 may return information for priority level 3.
|
|
1349
|
+
*
|
|
1350
|
+
* @param {number} priority The bucket priority for which the status should be reported
|
|
1351
|
+
* @returns {SyncPriorityStatus} Status information for the requested priority level or the next higher level with available status
|
|
1379
1352
|
*/
|
|
1380
|
-
|
|
1353
|
+
statusForPriority(priority: number): SyncPriorityStatus;
|
|
1381
1354
|
/**
|
|
1382
|
-
*
|
|
1355
|
+
* Compares this SyncStatus instance with another to determine if they are equal.
|
|
1356
|
+
* Equality is determined by comparing the serialized JSON representation of both instances.
|
|
1357
|
+
*
|
|
1358
|
+
* @param {SyncStatus} status The SyncStatus instance to compare against
|
|
1359
|
+
* @returns {boolean} True if the instances are considered equal, false otherwise
|
|
1383
1360
|
*/
|
|
1384
|
-
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
declare enum LockType {
|
|
1388
|
-
CRUD = "crud",
|
|
1389
|
-
SYNC = "sync"
|
|
1390
|
-
}
|
|
1391
|
-
declare enum SyncStreamConnectionMethod {
|
|
1392
|
-
HTTP = "http",
|
|
1393
|
-
WEB_SOCKET = "web-socket"
|
|
1394
|
-
}
|
|
1395
|
-
declare enum SyncClientImplementation {
|
|
1361
|
+
isEqual(status: SyncStatus): boolean;
|
|
1396
1362
|
/**
|
|
1397
|
-
*
|
|
1398
|
-
*
|
|
1399
|
-
* This is the default option.
|
|
1363
|
+
* Creates a human-readable string representation of the current sync status.
|
|
1364
|
+
* Includes information about connection state, sync completion, and data flow.
|
|
1400
1365
|
*
|
|
1401
|
-
* @
|
|
1402
|
-
* {@link DEFAULT_SYNC_CLIENT_IMPLEMENTATION} or omit the option. The explicit choice to use
|
|
1403
|
-
* the JavaScript-based sync implementation will be removed from a future version of the SDK.
|
|
1366
|
+
* @returns {string} A string representation of the sync status
|
|
1404
1367
|
*/
|
|
1405
|
-
|
|
1368
|
+
getMessage(): string;
|
|
1406
1369
|
/**
|
|
1407
|
-
*
|
|
1408
|
-
* core extension.
|
|
1409
|
-
*
|
|
1410
|
-
* @experimental
|
|
1411
|
-
* While this implementation is more performant than {@link SyncClientImplementation.JAVASCRIPT},
|
|
1412
|
-
* it has seen less real-world testing and is marked as __experimental__ at the moment.
|
|
1413
|
-
*
|
|
1414
|
-
* ## Compatibility warning
|
|
1415
|
-
*
|
|
1416
|
-
* The Rust sync client stores sync data in a format that is slightly different than the one used
|
|
1417
|
-
* by the old {@link JAVASCRIPT} implementation. When adopting the {@link RUST} client on existing
|
|
1418
|
-
* databases, the PowerSync SDK will migrate the format automatically.
|
|
1419
|
-
* Further, the {@link JAVASCRIPT} client in recent versions of the PowerSync JS SDK (starting from
|
|
1420
|
-
* the version introducing {@link RUST} as an option) also supports the new format, so you can switch
|
|
1421
|
-
* back to {@link JAVASCRIPT} later.
|
|
1370
|
+
* Serializes the SyncStatus instance to a plain object.
|
|
1422
1371
|
*
|
|
1423
|
-
*
|
|
1424
|
-
* downgrading the SDK to an older version (necessarily using the JavaScript-based implementation then)
|
|
1425
|
-
* can lead to sync issues.
|
|
1372
|
+
* @returns {SyncStatusOptions} A plain object representation of the sync status
|
|
1426
1373
|
*/
|
|
1427
|
-
|
|
1374
|
+
toJSON(): SyncStatusOptions;
|
|
1375
|
+
private static comparePriorities;
|
|
1428
1376
|
}
|
|
1429
1377
|
/**
|
|
1430
|
-
*
|
|
1431
|
-
*
|
|
1432
|
-
* Please use this field instead of {@link SyncClientImplementation.JAVASCRIPT} directly. A future version
|
|
1433
|
-
* of the PowerSync SDK will enable {@link SyncClientImplementation.RUST} by default and remove the JavaScript
|
|
1434
|
-
* option.
|
|
1435
|
-
*/
|
|
1436
|
-
declare const DEFAULT_SYNC_CLIENT_IMPLEMENTATION = SyncClientImplementation.JAVASCRIPT;
|
|
1437
|
-
/**
|
|
1438
|
-
* Abstract Lock to be implemented by various JS environments
|
|
1378
|
+
* Information about a sync stream subscription.
|
|
1439
1379
|
*/
|
|
1440
|
-
interface
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1380
|
+
interface SyncStreamStatus {
|
|
1381
|
+
progress: ProgressWithOperations | null;
|
|
1382
|
+
subscription: SyncSubscriptionDescription;
|
|
1383
|
+
priority: number | null;
|
|
1444
1384
|
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
uploadCrud: () => Promise<void>;
|
|
1385
|
+
|
|
1386
|
+
declare class UploadQueueStats {
|
|
1448
1387
|
/**
|
|
1449
|
-
*
|
|
1450
|
-
* linked to. Most commonly DB name, but not restricted to DB name.
|
|
1388
|
+
* Number of records in the upload queue.
|
|
1451
1389
|
*/
|
|
1452
|
-
|
|
1453
|
-
logger?: ILogger;
|
|
1454
|
-
remote: AbstractRemote;
|
|
1455
|
-
}
|
|
1456
|
-
interface StreamingSyncImplementationListener extends BaseListener {
|
|
1390
|
+
count: number;
|
|
1457
1391
|
/**
|
|
1458
|
-
*
|
|
1459
|
-
* refreshed.
|
|
1392
|
+
* Size of the upload queue in bytes.
|
|
1460
1393
|
*/
|
|
1461
|
-
|
|
1394
|
+
size: number | null;
|
|
1395
|
+
constructor(
|
|
1462
1396
|
/**
|
|
1463
|
-
*
|
|
1397
|
+
* Number of records in the upload queue.
|
|
1464
1398
|
*/
|
|
1465
|
-
|
|
1399
|
+
count: number,
|
|
1400
|
+
/**
|
|
1401
|
+
* Size of the upload queue in bytes.
|
|
1402
|
+
*/
|
|
1403
|
+
size?: number | null);
|
|
1404
|
+
toString(): string;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
declare enum ColumnType {
|
|
1408
|
+
TEXT = "TEXT",
|
|
1409
|
+
INTEGER = "INTEGER",
|
|
1410
|
+
REAL = "REAL"
|
|
1411
|
+
}
|
|
1412
|
+
interface ColumnOptions {
|
|
1413
|
+
name: string;
|
|
1414
|
+
type?: ColumnType;
|
|
1415
|
+
}
|
|
1416
|
+
type BaseColumnType<T extends number | string | null> = {
|
|
1417
|
+
type: ColumnType;
|
|
1418
|
+
};
|
|
1419
|
+
type ColumnsType = Record<string, BaseColumnType<any>>;
|
|
1420
|
+
type ExtractColumnValueType<T extends BaseColumnType<any>> = T extends BaseColumnType<infer R> ? R : unknown;
|
|
1421
|
+
declare const MAX_AMOUNT_OF_COLUMNS = 1999;
|
|
1422
|
+
declare const column: {
|
|
1423
|
+
text: BaseColumnType<string | null>;
|
|
1424
|
+
integer: BaseColumnType<number | null>;
|
|
1425
|
+
real: BaseColumnType<number | null>;
|
|
1426
|
+
};
|
|
1427
|
+
declare class Column {
|
|
1428
|
+
protected options: ColumnOptions;
|
|
1429
|
+
constructor(options: ColumnOptions);
|
|
1430
|
+
get name(): string;
|
|
1431
|
+
get type(): ColumnType | undefined;
|
|
1432
|
+
toJSON(): {
|
|
1433
|
+
name: string;
|
|
1434
|
+
type: ColumnType | undefined;
|
|
1435
|
+
};
|
|
1466
1436
|
}
|
|
1437
|
+
|
|
1467
1438
|
/**
|
|
1468
|
-
*
|
|
1469
|
-
*
|
|
1439
|
+
* A pending variant of a {@link RawTable} that doesn't have a name (because it would be inferred when creating the
|
|
1440
|
+
* schema).
|
|
1470
1441
|
*/
|
|
1471
|
-
type
|
|
1472
|
-
interface InternalConnectionOptions extends BaseConnectionOptions, AdditionalConnectionOptions {
|
|
1473
|
-
}
|
|
1474
|
-
/** @internal */
|
|
1475
|
-
interface BaseConnectionOptions {
|
|
1476
|
-
/**
|
|
1477
|
-
* Whether to use a JavaScript implementation to handle received sync lines from the sync
|
|
1478
|
-
* service, or whether this work should be offloaded to the PowerSync core extension.
|
|
1479
|
-
*
|
|
1480
|
-
* This defaults to the JavaScript implementation ({@link SyncClientImplementation.JAVASCRIPT})
|
|
1481
|
-
* since the ({@link SyncClientImplementation.RUST}) implementation is experimental at the moment.
|
|
1482
|
-
*/
|
|
1483
|
-
clientImplementation?: SyncClientImplementation;
|
|
1484
|
-
/**
|
|
1485
|
-
* The connection method to use when streaming updates from
|
|
1486
|
-
* the PowerSync backend instance.
|
|
1487
|
-
* Defaults to a HTTP streaming connection.
|
|
1488
|
-
*/
|
|
1489
|
-
connectionMethod?: SyncStreamConnectionMethod;
|
|
1442
|
+
type RawTableType = {
|
|
1490
1443
|
/**
|
|
1491
|
-
* The
|
|
1444
|
+
* The statement to run when PowerSync detects that a row needs to be inserted or updated.
|
|
1492
1445
|
*/
|
|
1493
|
-
|
|
1446
|
+
put: PendingStatement;
|
|
1494
1447
|
/**
|
|
1495
|
-
*
|
|
1448
|
+
* The statement to run when PowerSync detects that a row needs to be deleted.
|
|
1496
1449
|
*/
|
|
1497
|
-
|
|
1450
|
+
delete: PendingStatement;
|
|
1451
|
+
};
|
|
1452
|
+
/**
|
|
1453
|
+
* A parameter to use as part of {@link PendingStatement}.
|
|
1454
|
+
*
|
|
1455
|
+
* For delete statements, only the `"Id"` value is supported - the sync client will replace it with the id of the row to
|
|
1456
|
+
* be synced.
|
|
1457
|
+
*
|
|
1458
|
+
* For insert and replace operations, the values of columns in the table are available as parameters through
|
|
1459
|
+
* `{Column: 'name'}`.
|
|
1460
|
+
*/
|
|
1461
|
+
type PendingStatementParameter = 'Id' | {
|
|
1462
|
+
Column: string;
|
|
1463
|
+
};
|
|
1464
|
+
/**
|
|
1465
|
+
* A statement that the PowerSync client should use to insert or delete data into a table managed by the user.
|
|
1466
|
+
*/
|
|
1467
|
+
type PendingStatement = {
|
|
1468
|
+
sql: string;
|
|
1469
|
+
params: PendingStatementParameter[];
|
|
1470
|
+
};
|
|
1471
|
+
/**
|
|
1472
|
+
* Instructs PowerSync to sync data into a "raw" table.
|
|
1473
|
+
*
|
|
1474
|
+
* Since raw tables are not backed by JSON, running complex queries on them may be more efficient. Further, they allow
|
|
1475
|
+
* using client-side table and column constraints.
|
|
1476
|
+
*
|
|
1477
|
+
* To collect local writes to raw tables with PowerSync, custom triggers are required. See
|
|
1478
|
+
* {@link https://docs.powersync.com/usage/use-case-examples/raw-tables the documentation} for details and an example on
|
|
1479
|
+
* using raw tables.
|
|
1480
|
+
*
|
|
1481
|
+
* Note that raw tables are only supported when using the new `SyncClientImplementation.rust` sync client.
|
|
1482
|
+
*
|
|
1483
|
+
* @experimental Please note that this feature is experimental at the moment, and not covered by PowerSync semver or
|
|
1484
|
+
* stability guarantees.
|
|
1485
|
+
*/
|
|
1486
|
+
declare class RawTable implements RawTableType {
|
|
1498
1487
|
/**
|
|
1499
|
-
* The
|
|
1488
|
+
* The name of the table.
|
|
1489
|
+
*
|
|
1490
|
+
* This does not have to match the actual table name in the schema - {@link put} and {@link delete} are free to use
|
|
1491
|
+
* another table. Instead, this name is used by the sync client to recognize that operations on this table (as it
|
|
1492
|
+
* appears in the source / backend database) are to be handled specially.
|
|
1500
1493
|
*/
|
|
1501
|
-
|
|
1494
|
+
name: string;
|
|
1495
|
+
put: PendingStatement;
|
|
1496
|
+
delete: PendingStatement;
|
|
1497
|
+
constructor(name: string, type: RawTableType);
|
|
1502
1498
|
}
|
|
1503
|
-
|
|
1504
|
-
interface
|
|
1499
|
+
|
|
1500
|
+
interface IndexColumnOptions {
|
|
1501
|
+
name: string;
|
|
1502
|
+
ascending?: boolean;
|
|
1503
|
+
}
|
|
1504
|
+
declare const DEFAULT_INDEX_COLUMN_OPTIONS: Partial<IndexColumnOptions>;
|
|
1505
|
+
declare class IndexedColumn {
|
|
1506
|
+
protected options: IndexColumnOptions;
|
|
1507
|
+
static createAscending(column: string): IndexedColumn;
|
|
1508
|
+
constructor(options: IndexColumnOptions);
|
|
1509
|
+
get name(): string;
|
|
1510
|
+
get ascending(): boolean | undefined;
|
|
1511
|
+
toJSON(table: Table): {
|
|
1512
|
+
name: string;
|
|
1513
|
+
ascending: boolean | undefined;
|
|
1514
|
+
type: ColumnType;
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
interface IndexOptions {
|
|
1519
|
+
name: string;
|
|
1520
|
+
columns?: IndexedColumn[];
|
|
1521
|
+
}
|
|
1522
|
+
declare const DEFAULT_INDEX_OPTIONS: Partial<IndexOptions>;
|
|
1523
|
+
declare class Index {
|
|
1524
|
+
protected options: IndexOptions;
|
|
1525
|
+
static createAscending(options: IndexOptions, columnNames: string[]): Index;
|
|
1526
|
+
constructor(options: IndexOptions);
|
|
1527
|
+
get name(): string;
|
|
1528
|
+
get columns(): IndexedColumn[];
|
|
1529
|
+
toJSON(table: Table): {
|
|
1530
|
+
name: string;
|
|
1531
|
+
columns: {
|
|
1532
|
+
name: string;
|
|
1533
|
+
ascending: boolean | undefined;
|
|
1534
|
+
type: ColumnType;
|
|
1535
|
+
}[];
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
/**
|
|
1540
|
+
Generate a new table from the columns and indexes
|
|
1541
|
+
@deprecated You should use {@link Table} instead as it now allows TableV2 syntax.
|
|
1542
|
+
This will be removed in the next major release.
|
|
1543
|
+
*/
|
|
1544
|
+
declare class TableV2<Columns extends ColumnsType = ColumnsType> extends Table<Columns> {
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
interface SharedTableOptions {
|
|
1548
|
+
localOnly?: boolean;
|
|
1549
|
+
insertOnly?: boolean;
|
|
1550
|
+
viewName?: string;
|
|
1551
|
+
trackPrevious?: boolean | TrackPreviousOptions;
|
|
1552
|
+
trackMetadata?: boolean;
|
|
1553
|
+
ignoreEmptyUpdates?: boolean;
|
|
1554
|
+
}
|
|
1555
|
+
/** Whether to include previous column values when PowerSync tracks local changes.
|
|
1556
|
+
*
|
|
1557
|
+
* Including old values may be helpful for some backend connector implementations, which is
|
|
1558
|
+
* why it can be enabled on per-table or per-columm basis.
|
|
1559
|
+
*/
|
|
1560
|
+
interface TrackPreviousOptions {
|
|
1561
|
+
/** When defined, a list of column names for which old values should be tracked. */
|
|
1562
|
+
columns?: string[];
|
|
1563
|
+
/** When enabled, only include values that have actually been changed by an update. */
|
|
1564
|
+
onlyWhenChanged?: boolean;
|
|
1565
|
+
}
|
|
1566
|
+
interface TableOptions extends SharedTableOptions {
|
|
1505
1567
|
/**
|
|
1506
|
-
*
|
|
1507
|
-
* from the PowerSync backend after an error occurs.
|
|
1568
|
+
* The synced table name, matching sync rules
|
|
1508
1569
|
*/
|
|
1509
|
-
|
|
1570
|
+
name: string;
|
|
1571
|
+
columns: Column[];
|
|
1572
|
+
indexes?: Index[];
|
|
1573
|
+
}
|
|
1574
|
+
type RowType<T extends TableV2<any>> = {
|
|
1575
|
+
[K in keyof T['columnMap']]: ExtractColumnValueType<T['columnMap'][K]>;
|
|
1576
|
+
} & {
|
|
1577
|
+
id: string;
|
|
1578
|
+
};
|
|
1579
|
+
type IndexShorthand = Record<string, string[]>;
|
|
1580
|
+
interface TableV2Options extends SharedTableOptions {
|
|
1581
|
+
indexes?: IndexShorthand;
|
|
1582
|
+
}
|
|
1583
|
+
declare const DEFAULT_TABLE_OPTIONS: {
|
|
1584
|
+
indexes: never[];
|
|
1585
|
+
insertOnly: boolean;
|
|
1586
|
+
localOnly: boolean;
|
|
1587
|
+
trackPrevious: boolean;
|
|
1588
|
+
trackMetadata: boolean;
|
|
1589
|
+
ignoreEmptyUpdates: boolean;
|
|
1590
|
+
};
|
|
1591
|
+
declare const InvalidSQLCharacters: RegExp;
|
|
1592
|
+
declare class Table<Columns extends ColumnsType = ColumnsType> {
|
|
1593
|
+
protected options: TableOptions;
|
|
1594
|
+
protected _mappedColumns: Columns;
|
|
1595
|
+
static createLocalOnly(options: TableOptions): Table<ColumnsType>;
|
|
1596
|
+
static createInsertOnly(options: TableOptions): Table<ColumnsType>;
|
|
1510
1597
|
/**
|
|
1511
|
-
*
|
|
1512
|
-
*
|
|
1513
|
-
*
|
|
1598
|
+
* Create a table.
|
|
1599
|
+
* @deprecated This was only only included for TableV2 and is no longer necessary.
|
|
1600
|
+
* Prefer to use new Table() directly.
|
|
1601
|
+
*
|
|
1602
|
+
* TODO remove in the next major release.
|
|
1514
1603
|
*/
|
|
1515
|
-
|
|
1516
|
-
}
|
|
1517
|
-
/** @internal */
|
|
1518
|
-
type RequiredAdditionalConnectionOptions = Required<AdditionalConnectionOptions>;
|
|
1519
|
-
interface StreamingSyncImplementation extends BaseObserverInterface<StreamingSyncImplementationListener>, Disposable {
|
|
1604
|
+
static createTable(name: string, table: Table): Table<ColumnsType>;
|
|
1520
1605
|
/**
|
|
1521
|
-
*
|
|
1606
|
+
* Creates a new Table instance.
|
|
1607
|
+
*
|
|
1608
|
+
* This constructor supports two different versions:
|
|
1609
|
+
* 1. New constructor: Using a Columns object and an optional TableV2Options object
|
|
1610
|
+
* 2. Deprecated constructor: Using a TableOptions object (will be removed in the next major release)
|
|
1611
|
+
*
|
|
1612
|
+
* @constructor
|
|
1613
|
+
* @param {Columns | TableOptions} optionsOrColumns - Either a Columns object (for V2 syntax) or a TableOptions object (for V1 syntax)
|
|
1614
|
+
* @param {TableV2Options} [v2Options] - Optional configuration options for V2 syntax
|
|
1615
|
+
*
|
|
1616
|
+
* @example
|
|
1617
|
+
* ```javascript
|
|
1618
|
+
* // New Constructor
|
|
1619
|
+
* const table = new Table(
|
|
1620
|
+
* {
|
|
1621
|
+
* name: column.text,
|
|
1622
|
+
* age: column.integer
|
|
1623
|
+
* },
|
|
1624
|
+
* { indexes: { nameIndex: ['name'] } }
|
|
1625
|
+
* );
|
|
1626
|
+
*```
|
|
1627
|
+
*
|
|
1628
|
+
*
|
|
1629
|
+
* @example
|
|
1630
|
+
* ```javascript
|
|
1631
|
+
* // Deprecated Constructor
|
|
1632
|
+
* const table = new Table({
|
|
1633
|
+
* name: 'users',
|
|
1634
|
+
* columns: [
|
|
1635
|
+
* new Column({ name: 'name', type: ColumnType.TEXT }),
|
|
1636
|
+
* new Column({ name: 'age', type: ColumnType.INTEGER })
|
|
1637
|
+
* ]
|
|
1638
|
+
* });
|
|
1639
|
+
*```
|
|
1522
1640
|
*/
|
|
1523
|
-
|
|
1641
|
+
constructor(columns: Columns, options?: TableV2Options);
|
|
1524
1642
|
/**
|
|
1525
|
-
*
|
|
1526
|
-
*
|
|
1643
|
+
* @deprecated This constructor will be removed in the next major release.
|
|
1644
|
+
* Use the new constructor shown below instead as this does not show types.
|
|
1645
|
+
* @example
|
|
1646
|
+
* <caption>Use this instead</caption>
|
|
1647
|
+
* ```javascript
|
|
1648
|
+
* const table = new Table(
|
|
1649
|
+
* {
|
|
1650
|
+
* name: column.text,
|
|
1651
|
+
* age: column.integer
|
|
1652
|
+
* },
|
|
1653
|
+
* { indexes: { nameIndex: ['name'] } }
|
|
1654
|
+
* );
|
|
1655
|
+
*```
|
|
1527
1656
|
*/
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1657
|
+
constructor(options: TableOptions);
|
|
1658
|
+
copyWithName(name: string): Table;
|
|
1659
|
+
private isTableV1;
|
|
1660
|
+
private initTableV1;
|
|
1661
|
+
private initTableV2;
|
|
1662
|
+
private applyDefaultOptions;
|
|
1663
|
+
get name(): string;
|
|
1664
|
+
get viewNameOverride(): string | undefined;
|
|
1665
|
+
get viewName(): string;
|
|
1666
|
+
get columns(): Column[];
|
|
1667
|
+
get columnMap(): Columns;
|
|
1668
|
+
get indexes(): Index[];
|
|
1669
|
+
get localOnly(): boolean;
|
|
1670
|
+
get insertOnly(): boolean;
|
|
1671
|
+
get trackPrevious(): boolean | TrackPreviousOptions;
|
|
1672
|
+
get trackMetadata(): boolean;
|
|
1673
|
+
get ignoreEmptyUpdates(): boolean;
|
|
1674
|
+
get internalName(): string;
|
|
1675
|
+
get validName(): boolean;
|
|
1676
|
+
validate(): void;
|
|
1677
|
+
toJSON(): {
|
|
1678
|
+
name: string;
|
|
1679
|
+
view_name: string;
|
|
1680
|
+
local_only: boolean;
|
|
1681
|
+
insert_only: boolean;
|
|
1682
|
+
include_old: any;
|
|
1683
|
+
include_old_only_when_changed: boolean;
|
|
1684
|
+
include_metadata: boolean;
|
|
1685
|
+
ignore_empty_update: boolean;
|
|
1686
|
+
columns: {
|
|
1687
|
+
name: string;
|
|
1688
|
+
type: ColumnType | undefined;
|
|
1689
|
+
}[];
|
|
1690
|
+
indexes: {
|
|
1691
|
+
name: string;
|
|
1692
|
+
columns: {
|
|
1693
|
+
name: string;
|
|
1694
|
+
ascending: boolean | undefined;
|
|
1695
|
+
type: ColumnType;
|
|
1696
|
+
}[];
|
|
1697
|
+
}[];
|
|
1698
|
+
};
|
|
1538
1699
|
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
crudUploadThrottleMs: number;
|
|
1700
|
+
|
|
1701
|
+
type SchemaType = Record<string, Table<any>>;
|
|
1702
|
+
type SchemaTableType<S extends SchemaType> = {
|
|
1703
|
+
[K in keyof S]: RowType<S[K]>;
|
|
1544
1704
|
};
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
protected logger: ILogger;
|
|
1555
|
-
private isUploadingCrud;
|
|
1556
|
-
private notifyCompletedUploads?;
|
|
1557
|
-
syncStatus: SyncStatus;
|
|
1558
|
-
triggerCrudUpload: () => void;
|
|
1559
|
-
constructor(options: AbstractStreamingSyncImplementationOptions);
|
|
1560
|
-
waitForReady(): Promise<void>;
|
|
1561
|
-
waitForStatus(status: SyncStatusOptions): Promise<void>;
|
|
1562
|
-
waitUntilStatusMatches(predicate: (status: SyncStatus) => boolean): Promise<void>;
|
|
1563
|
-
get lastSyncedAt(): Date | undefined;
|
|
1564
|
-
get isConnected(): boolean;
|
|
1565
|
-
dispose(): Promise<void>;
|
|
1566
|
-
abstract obtainLock<T>(lockOptions: LockOptions<T>): Promise<T>;
|
|
1567
|
-
hasCompletedSync(): Promise<boolean>;
|
|
1568
|
-
getWriteCheckpoint(): Promise<string>;
|
|
1569
|
-
protected _uploadAllCrud(): Promise<void>;
|
|
1570
|
-
connect(options?: PowerSyncConnectionOptions): Promise<void>;
|
|
1571
|
-
disconnect(): Promise<void>;
|
|
1705
|
+
/**
|
|
1706
|
+
* A schema is a collection of tables. It is used to define the structure of a database.
|
|
1707
|
+
*/
|
|
1708
|
+
declare class Schema<S extends SchemaType = SchemaType> {
|
|
1709
|
+
readonly types: SchemaTableType<S>;
|
|
1710
|
+
readonly props: S;
|
|
1711
|
+
readonly tables: Table[];
|
|
1712
|
+
readonly rawTables: RawTable[];
|
|
1713
|
+
constructor(tables: Table[] | S);
|
|
1572
1714
|
/**
|
|
1573
|
-
*
|
|
1715
|
+
* Adds raw tables to this schema. Raw tables are identified by their name, but entirely managed by the application
|
|
1716
|
+
* developer instead of automatically by PowerSync.
|
|
1717
|
+
* Since raw tables are not backed by JSON, running complex queries on them may be more efficient. Further, they allow
|
|
1718
|
+
* using client-side table and column constraints.
|
|
1719
|
+
* Note that raw tables are only supported when using the new `SyncClientImplementation.rust` sync client.
|
|
1720
|
+
*
|
|
1721
|
+
* @param tables An object of (table name, raw table definition) entries.
|
|
1722
|
+
* @experimental Note that the raw tables API is still experimental and may change in the future.
|
|
1574
1723
|
*/
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1724
|
+
withRawTables(tables: Record<string, RawTableType>): void;
|
|
1725
|
+
validate(): void;
|
|
1726
|
+
toJSON(): {
|
|
1727
|
+
tables: {
|
|
1728
|
+
name: string;
|
|
1729
|
+
view_name: string;
|
|
1730
|
+
local_only: boolean;
|
|
1731
|
+
insert_only: boolean;
|
|
1732
|
+
include_old: any;
|
|
1733
|
+
include_old_only_when_changed: boolean;
|
|
1734
|
+
include_metadata: boolean;
|
|
1735
|
+
ignore_empty_update: boolean;
|
|
1736
|
+
columns: {
|
|
1737
|
+
name: string;
|
|
1738
|
+
type: ColumnType | undefined;
|
|
1739
|
+
}[];
|
|
1740
|
+
indexes: {
|
|
1741
|
+
name: string;
|
|
1742
|
+
columns: {
|
|
1743
|
+
name: string;
|
|
1744
|
+
ascending: boolean | undefined;
|
|
1745
|
+
type: ColumnType;
|
|
1746
|
+
}[];
|
|
1747
|
+
}[];
|
|
1748
|
+
}[];
|
|
1749
|
+
raw_tables: RawTable[];
|
|
1750
|
+
};
|
|
1751
|
+
private convertToClassicTables;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
interface PowerSyncBackendConnector {
|
|
1755
|
+
/** Allows the PowerSync client to retrieve an authentication token from your backend
|
|
1756
|
+
* which is used to authenticate against the PowerSync service.
|
|
1583
1757
|
*
|
|
1584
|
-
*
|
|
1585
|
-
*
|
|
1586
|
-
* should be used, so that the JS SDK is able to write to updated databases.
|
|
1758
|
+
* This should always fetch a fresh set of credentials - don't use cached
|
|
1759
|
+
* values.
|
|
1587
1760
|
*
|
|
1588
|
-
*
|
|
1589
|
-
*
|
|
1590
|
-
*
|
|
1761
|
+
* Return null if the user is not signed in. Throw an error if credentials
|
|
1762
|
+
* cannot be fetched due to a network error or other temporary error.
|
|
1763
|
+
*
|
|
1764
|
+
* This token is kept for the duration of a sync connection.
|
|
1591
1765
|
*/
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1766
|
+
fetchCredentials: () => Promise<PowerSyncCredentials | null>;
|
|
1767
|
+
/** Upload local changes to the app backend.
|
|
1768
|
+
*
|
|
1769
|
+
* Use {@link AbstractPowerSyncDatabase.getCrudBatch} to get a batch of changes to upload.
|
|
1770
|
+
*
|
|
1771
|
+
* Any thrown errors will result in a retry after the configured wait period (default: 5 seconds).
|
|
1772
|
+
*/
|
|
1773
|
+
uploadData: (database: AbstractPowerSyncDatabase) => Promise<void>;
|
|
1600
1774
|
}
|
|
1601
1775
|
|
|
1602
1776
|
/**
|
|
@@ -1610,11 +1784,24 @@ interface ConnectionManagerSyncImplementationResult {
|
|
|
1610
1784
|
*/
|
|
1611
1785
|
onDispose: () => Promise<void> | void;
|
|
1612
1786
|
}
|
|
1787
|
+
/**
|
|
1788
|
+
* The subset of {@link AbstractStreamingSyncImplementationOptions} managed by the connection manager.
|
|
1789
|
+
*
|
|
1790
|
+
* @internal
|
|
1791
|
+
*/
|
|
1792
|
+
interface CreateSyncImplementationOptions extends AdditionalConnectionOptions {
|
|
1793
|
+
subscriptions: SubscribedStream[];
|
|
1794
|
+
}
|
|
1795
|
+
interface InternalSubscriptionAdapter {
|
|
1796
|
+
firstStatusMatching(predicate: (status: SyncStatus) => any, abort?: AbortSignal): Promise<void>;
|
|
1797
|
+
resolveOfflineSyncStatus(): Promise<void>;
|
|
1798
|
+
rustSubscriptionsCommand(payload: any): Promise<void>;
|
|
1799
|
+
}
|
|
1613
1800
|
/**
|
|
1614
1801
|
* @internal
|
|
1615
1802
|
*/
|
|
1616
1803
|
interface ConnectionManagerOptions {
|
|
1617
|
-
createSyncImplementation(connector: PowerSyncBackendConnector, options:
|
|
1804
|
+
createSyncImplementation(connector: PowerSyncBackendConnector, options: CreateSyncImplementationOptions): Promise<ConnectionManagerSyncImplementationResult>;
|
|
1618
1805
|
logger: ILogger;
|
|
1619
1806
|
}
|
|
1620
1807
|
type StoredConnectionOptions = {
|
|
@@ -1660,6 +1847,12 @@ declare class ConnectionManager extends BaseObserver<ConnectionManagerListener>
|
|
|
1660
1847
|
* is disposed.
|
|
1661
1848
|
*/
|
|
1662
1849
|
protected syncDisposer: (() => Promise<void> | void) | null;
|
|
1850
|
+
/**
|
|
1851
|
+
* Subscriptions managed in this connection manager.
|
|
1852
|
+
*
|
|
1853
|
+
* On the web, these local subscriptions are merged across tabs by a shared worker.
|
|
1854
|
+
*/
|
|
1855
|
+
private locallyActiveSubscriptions;
|
|
1663
1856
|
constructor(options: ConnectionManagerOptions);
|
|
1664
1857
|
get logger(): ILogger;
|
|
1665
1858
|
close(): Promise<void>;
|
|
@@ -1673,6 +1866,9 @@ declare class ConnectionManager extends BaseObserver<ConnectionManagerListener>
|
|
|
1673
1866
|
disconnect(): Promise<void>;
|
|
1674
1867
|
protected disconnectInternal(): Promise<void>;
|
|
1675
1868
|
protected performDisconnect(): Promise<void>;
|
|
1869
|
+
stream(adapter: InternalSubscriptionAdapter, name: string, parameters: Record<string, any> | null): SyncStream;
|
|
1870
|
+
private get activeStreams();
|
|
1871
|
+
private subscriptionsMayHaveChanged;
|
|
1676
1872
|
}
|
|
1677
1873
|
|
|
1678
1874
|
/**
|
|
@@ -1807,12 +2003,14 @@ declare enum WatchedQueryListenerEvent {
|
|
|
1807
2003
|
ON_DATA = "onData",
|
|
1808
2004
|
ON_ERROR = "onError",
|
|
1809
2005
|
ON_STATE_CHANGE = "onStateChange",
|
|
2006
|
+
SETTINGS_WILL_UPDATE = "settingsWillUpdate",
|
|
1810
2007
|
CLOSED = "closed"
|
|
1811
2008
|
}
|
|
1812
2009
|
interface WatchedQueryListener<Data> extends BaseListener {
|
|
1813
2010
|
[WatchedQueryListenerEvent.ON_DATA]?: (data: Data) => void | Promise<void>;
|
|
1814
2011
|
[WatchedQueryListenerEvent.ON_ERROR]?: (error: Error) => void | Promise<void>;
|
|
1815
2012
|
[WatchedQueryListenerEvent.ON_STATE_CHANGE]?: (state: WatchedQueryState<Data>) => void | Promise<void>;
|
|
2013
|
+
[WatchedQueryListenerEvent.SETTINGS_WILL_UPDATE]?: () => void;
|
|
1816
2014
|
[WatchedQueryListenerEvent.CLOSED]?: () => void | Promise<void>;
|
|
1817
2015
|
}
|
|
1818
2016
|
declare const DEFAULT_WATCH_THROTTLE_MS = 30;
|
|
@@ -1878,6 +2076,7 @@ declare abstract class AbstractQueryProcessor<Data = unknown[], Settings extends
|
|
|
1878
2076
|
constructor(options: AbstractQueryProcessorOptions<Data, Settings>);
|
|
1879
2077
|
protected constructInitialState(): WatchedQueryState<Data>;
|
|
1880
2078
|
protected get reportFetching(): boolean;
|
|
2079
|
+
protected updateSettingsInternal(settings: Settings, signal: AbortSignal): Promise<void>;
|
|
1881
2080
|
/**
|
|
1882
2081
|
* Updates the underlying query.
|
|
1883
2082
|
*/
|
|
@@ -1891,7 +2090,7 @@ declare abstract class AbstractQueryProcessor<Data = unknown[], Settings extends
|
|
|
1891
2090
|
/**
|
|
1892
2091
|
* Configures base DB listeners and links the query to listeners.
|
|
1893
2092
|
*/
|
|
1894
|
-
protected init(): Promise<void>;
|
|
2093
|
+
protected init(signal: AbortSignal): Promise<void>;
|
|
1895
2094
|
close(): Promise<void>;
|
|
1896
2095
|
/**
|
|
1897
2096
|
* Runs a callback and reports errors to the error listeners.
|
|
@@ -2169,7 +2368,6 @@ interface SQLOpenOptions {
|
|
|
2169
2368
|
* debugMode: process.env.NODE_ENV !== 'production'
|
|
2170
2369
|
*/
|
|
2171
2370
|
debugMode?: boolean;
|
|
2172
|
-
logger?: ILogger;
|
|
2173
2371
|
}
|
|
2174
2372
|
interface SQLOpenFactory {
|
|
2175
2373
|
/**
|
|
@@ -2542,7 +2740,7 @@ interface TriggerManager {
|
|
|
2542
2740
|
* },
|
|
2543
2741
|
* onChange: async (context) => {
|
|
2544
2742
|
* // Fetches the todo records that were inserted during this diff
|
|
2545
|
-
* const newTodos = await context.
|
|
2743
|
+
* const newTodos = await context.withDiff<Database['todos']>(`
|
|
2546
2744
|
* SELECT
|
|
2547
2745
|
* todos.*
|
|
2548
2746
|
* FROM
|
|
@@ -2693,6 +2891,7 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
|
|
|
2693
2891
|
protected bucketStorageAdapter: BucketStorageAdapter;
|
|
2694
2892
|
protected _isReadyPromise: Promise<void>;
|
|
2695
2893
|
protected connectionManager: ConnectionManager;
|
|
2894
|
+
private subscriptions;
|
|
2696
2895
|
get syncStreamImplementation(): StreamingSyncImplementation | null;
|
|
2697
2896
|
protected _schema: Schema;
|
|
2698
2897
|
private _database;
|
|
@@ -2728,7 +2927,7 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
|
|
|
2728
2927
|
* Opens the DBAdapter given open options using a default open factory
|
|
2729
2928
|
*/
|
|
2730
2929
|
protected abstract openDBAdapter(options: PowerSyncDatabaseOptionsWithSettings): DBAdapter;
|
|
2731
|
-
protected abstract generateSyncStreamImplementation(connector: PowerSyncBackendConnector, options: RequiredAdditionalConnectionOptions): StreamingSyncImplementation;
|
|
2930
|
+
protected abstract generateSyncStreamImplementation(connector: PowerSyncBackendConnector, options: CreateSyncImplementationOptions & RequiredAdditionalConnectionOptions): StreamingSyncImplementation;
|
|
2732
2931
|
protected abstract generateBucketStorageAdapter(): BucketStorageAdapter;
|
|
2733
2932
|
/**
|
|
2734
2933
|
* @returns A promise which will resolve once initialization is completed.
|
|
@@ -2747,6 +2946,7 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
|
|
|
2747
2946
|
signal?: AbortSignal;
|
|
2748
2947
|
priority?: number;
|
|
2749
2948
|
}): Promise<void>;
|
|
2949
|
+
private waitForStatus;
|
|
2750
2950
|
/**
|
|
2751
2951
|
* Allows for extended implementations to execute custom initialization
|
|
2752
2952
|
* logic as part of the total init process
|
|
@@ -2758,7 +2958,7 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
|
|
|
2758
2958
|
*/
|
|
2759
2959
|
protected initialize(): Promise<void>;
|
|
2760
2960
|
private _loadVersion;
|
|
2761
|
-
protected
|
|
2961
|
+
protected resolveOfflineSyncStatus(): Promise<void>;
|
|
2762
2962
|
/**
|
|
2763
2963
|
* Replace the schema with a new version. This is for advanced use cases - typically the schema should just be specified once in the constructor.
|
|
2764
2964
|
*
|
|
@@ -2770,7 +2970,7 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
|
|
|
2770
2970
|
* While initializing is automatic, this helps to catch and report initialization errors.
|
|
2771
2971
|
*/
|
|
2772
2972
|
init(): Promise<void>;
|
|
2773
|
-
resolvedConnectionOptions(options
|
|
2973
|
+
protected resolvedConnectionOptions(options: CreateSyncImplementationOptions): CreateSyncImplementationOptions & RequiredAdditionalConnectionOptions;
|
|
2774
2974
|
/**
|
|
2775
2975
|
* @deprecated Use {@link AbstractPowerSyncDatabase#close} instead.
|
|
2776
2976
|
* Clears all listeners registered by {@link AbstractPowerSyncDatabase#registerListener}.
|
|
@@ -2800,6 +3000,15 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
|
|
|
2800
3000
|
* To preserve data in local-only tables, set clearLocal to false.
|
|
2801
3001
|
*/
|
|
2802
3002
|
disconnectAndClear(options?: DisconnectAndClearOptions): Promise<void>;
|
|
3003
|
+
/**
|
|
3004
|
+
* Create a sync stream to query its status or to subscribe to it.
|
|
3005
|
+
*
|
|
3006
|
+
* @param name The name of the stream to subscribe to.
|
|
3007
|
+
* @param params Optional parameters for the stream subscription.
|
|
3008
|
+
* @returns A {@link SyncStream} instance that can be subscribed to.
|
|
3009
|
+
* @experimental Sync streams are currently in alpha.
|
|
3010
|
+
*/
|
|
3011
|
+
syncStream(name: string, params?: Record<string, any>): SyncStream;
|
|
2803
3012
|
/**
|
|
2804
3013
|
* Close the database, releasing resources.
|
|
2805
3014
|
*
|
|
@@ -3366,4 +3575,4 @@ interface ParsedQuery {
|
|
|
3366
3575
|
declare const parseQuery: <T>(query: string | CompilableQuery<T>, parameters: any[]) => ParsedQuery;
|
|
3367
3576
|
|
|
3368
3577
|
export { AbortOperation, AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, AbstractQueryProcessor, AbstractRemote, AbstractStreamingSyncImplementation, ArrayComparator, BaseObserver, Column, ColumnType, ConnectionManager, ControlledExecutor, CrudBatch, CrudEntry, CrudTransaction, 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_PRESSURE_LIMITS, 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, DataStream, DiffTriggerOperation, DifferentialQueryProcessor, EMPTY_DIFFERENTIAL, FalsyComparator, FetchImplementationProvider, FetchStrategy, GetAllQuery, Index, IndexedColumn, InvalidSQLCharacters, LockType, LogLevel, MAX_AMOUNT_OF_COLUMNS, MAX_OP_ID, OnChangeQueryProcessor, OpType, OpTypeEnum, OplogEntry, PSInternalTable, PowerSyncControlCommand, RowUpdateType, Schema, SqliteBucketStorage, SyncClientImplementation, SyncDataBatch, SyncDataBucket, SyncProgress, SyncStatus, SyncStreamConnectionMethod, Table, TableV2, UpdateType, UploadQueueStats, WatchedQueryListenerEvent, column, compilableQueryWatch, createBaseLogger, createLogger, extractTableUpdates, isBatchedUpdateNotification, isContinueCheckpointRequest, isDBAdapter, isPowerSyncDatabaseOptionsWithSettings, isSQLOpenFactory, isSQLOpenOptions, isStreamingKeepalive, isStreamingSyncCheckpoint, isStreamingSyncCheckpointComplete, isStreamingSyncCheckpointDiff, isStreamingSyncCheckpointPartiallyComplete, isStreamingSyncData, isSyncNewCheckpointRequest, parseQuery, runOnSchemaChange, sanitizeSQL, sanitizeUUID };
|
|
3369
|
-
export type { AbstractQueryProcessorOptions, AbstractRemoteOptions, AbstractStreamingSyncImplementationOptions, AdditionalConnectionOptions, ArrayComparatorOptions, ArrayQueryDefinition, BSONImplementation, BaseColumnType, BaseConnectionOptions, BaseListener, BaseObserverInterface, BasePowerSyncDatabaseOptions, BaseTriggerDiffRecord, BatchedUpdateNotification, BucketChecksum, BucketDescription, BucketOperationProgress, BucketRequest, BucketState, BucketStorageAdapter, BucketStorageListener, Checkpoint, ChecksumCache, ColumnOptions, ColumnsType, CompilableQuery, CompilableQueryWatchHandler, CompiledQuery, ConnectionManagerListener, ConnectionManagerOptions, ConnectionManagerSyncImplementationResult, ContinueCheckpointRequest, ControlledExecutorOptions, CreateDiffTriggerOptions, CreateLoggerOptions, CrudRequest, CrudResponse, CrudUploadNotification, DBAdapter, DBAdapterListener, DBGetUtils, DBLockOptions, DataStreamCallback, DataStreamListener, DataStreamOptions, DifferentialQueryProcessorOptions, DifferentialWatchedQuery, DifferentialWatchedQueryComparator, DifferentialWatchedQueryListener, DifferentialWatchedQueryOptions, DifferentialWatchedQuerySettings, DisconnectAndClearOptions, Disposable, ExtractColumnValueType, ExtractedTriggerDiffRecord, FetchImplementation, GetAllQueryOptions, IndexColumnOptions, IndexOptions, IndexShorthand, InternalConnectionOptions, LinkQueryOptions, LockContext, LockOptions, MutableWatchedQueryState, OnChangeQueryProcessorOptions, OpId, OpTypeJSON, OplogEntryJSON, ParsedQuery, PowerSyncBackendConnector, PowerSyncCloseOptions, PowerSyncConnectionOptions, PowerSyncCredentials, PowerSyncDBListener, PowerSyncDatabaseOptions, PowerSyncDatabaseOptionsWithDBAdapter, PowerSyncDatabaseOptionsWithOpenFactory, PowerSyncDatabaseOptionsWithSettings, PowerSyncOpenFactoryOptions, ProgressWithOperations, Query, QueryParam, QueryResult, RemoteConnector, RequiredAdditionalConnectionOptions, RequiredPowerSyncConnectionOptions, RowType, SQLOnChangeOptions, SQLOpenFactory, SQLOpenOptions, SQLWatchOptions, SavedProgress, SchemaTableType, SocketSyncStreamOptions, StandardWatchedQuery, StandardWatchedQueryOptions, StreamingSyncCheckpoint, StreamingSyncCheckpointComplete, StreamingSyncCheckpointDiff, StreamingSyncCheckpointPartiallyComplete, StreamingSyncDataJSON, StreamingSyncImplementation, StreamingSyncImplementationListener, StreamingSyncKeepalive, StreamingSyncLine, StreamingSyncLineOrCrudUploadComplete, StreamingSyncRequest, StreamingSyncRequestParameterType, SyncDataBucketJSON, SyncDataFlowStatus, SyncLocalDatabaseResult, SyncNewCheckpointRequest, SyncPriorityStatus, SyncRequest, SyncResponse, SyncStatusOptions, SyncStreamOptions, TableOptions, TableUpdateOperation, TableV2Options, TrackDiffOptions, TrackPreviousOptions, Transaction, TriggerCreationHooks, TriggerDiffDeleteRecord, TriggerDiffHandlerContext, TriggerDiffInsertRecord, TriggerDiffRecord, TriggerDiffUpdateRecord, TriggerManager, TriggerRemoveCallback, UpdateNotification, WatchCompatibleQuery, WatchExecuteOptions, WatchHandler, WatchOnChangeEvent, WatchOnChangeHandler, WatchedQuery, WatchedQueryComparator, WatchedQueryDifferential, WatchedQueryListener, WatchedQueryOptions, WatchedQueryRowDifferential, WatchedQuerySettings, WatchedQueryState };
|
|
3578
|
+
export type { AbstractQueryProcessorOptions, AbstractRemoteOptions, AbstractStreamingSyncImplementationOptions, AdditionalConnectionOptions, ArrayComparatorOptions, ArrayQueryDefinition, BSONImplementation, BaseColumnType, BaseConnectionOptions, BaseListener, BaseObserverInterface, BasePowerSyncDatabaseOptions, BaseTriggerDiffRecord, BatchedUpdateNotification, BucketChecksum, BucketDescription, BucketOperationProgress, BucketRequest, BucketState, BucketStorageAdapter, BucketStorageListener, Checkpoint, ChecksumCache, ColumnOptions, ColumnsType, CompilableQuery, CompilableQueryWatchHandler, CompiledQuery, ConnectionManagerListener, ConnectionManagerOptions, ConnectionManagerSyncImplementationResult, ContinueCheckpointRequest, ControlledExecutorOptions, CreateDiffTriggerOptions, CreateLoggerOptions, CreateSyncImplementationOptions, CrudRequest, CrudResponse, CrudUploadNotification, DBAdapter, DBAdapterListener, DBGetUtils, DBLockOptions, DataStreamCallback, DataStreamListener, DataStreamOptions, DifferentialQueryProcessorOptions, DifferentialWatchedQuery, DifferentialWatchedQueryComparator, DifferentialWatchedQueryListener, DifferentialWatchedQueryOptions, DifferentialWatchedQuerySettings, DisconnectAndClearOptions, Disposable, ExtractColumnValueType, ExtractedTriggerDiffRecord, FetchImplementation, GetAllQueryOptions, IndexColumnOptions, IndexOptions, IndexShorthand, InternalConnectionOptions, InternalSubscriptionAdapter, LinkQueryOptions, LockContext, LockOptions, MutableWatchedQueryState, OnChangeQueryProcessorOptions, OpId, OpTypeJSON, OplogEntryJSON, ParsedQuery, PowerSyncBackendConnector, PowerSyncCloseOptions, PowerSyncConnectionOptions, PowerSyncCredentials, PowerSyncDBListener, PowerSyncDatabaseOptions, PowerSyncDatabaseOptionsWithDBAdapter, PowerSyncDatabaseOptionsWithOpenFactory, PowerSyncDatabaseOptionsWithSettings, PowerSyncOpenFactoryOptions, ProgressWithOperations, Query, QueryParam, QueryResult, RemoteConnector, RequiredAdditionalConnectionOptions, RequiredPowerSyncConnectionOptions, RowType, SQLOnChangeOptions, SQLOpenFactory, SQLOpenOptions, SQLWatchOptions, SavedProgress, SchemaTableType, SocketSyncStreamOptions, StandardWatchedQuery, StandardWatchedQueryOptions, StreamingSyncCheckpoint, StreamingSyncCheckpointComplete, StreamingSyncCheckpointDiff, StreamingSyncCheckpointPartiallyComplete, StreamingSyncDataJSON, StreamingSyncImplementation, StreamingSyncImplementationListener, StreamingSyncKeepalive, StreamingSyncLine, StreamingSyncLineOrCrudUploadComplete, StreamingSyncRequest, StreamingSyncRequestParameterType, SubscribedStream, SyncDataBucketJSON, SyncDataFlowStatus, SyncLocalDatabaseResult, SyncNewCheckpointRequest, SyncPriorityStatus, SyncRequest, SyncResponse, SyncStatusOptions, SyncStream, SyncStreamDescription, SyncStreamOptions, SyncStreamStatus, SyncStreamSubscribeOptions, SyncStreamSubscription, SyncSubscriptionDescription, TableOptions, TableUpdateOperation, TableV2Options, TrackDiffOptions, TrackPreviousOptions, Transaction, TriggerCreationHooks, TriggerDiffDeleteRecord, TriggerDiffHandlerContext, TriggerDiffInsertRecord, TriggerDiffRecord, TriggerDiffUpdateRecord, TriggerManager, TriggerRemoveCallback, UpdateNotification, WatchCompatibleQuery, WatchExecuteOptions, WatchHandler, WatchOnChangeEvent, WatchOnChangeHandler, WatchedQuery, WatchedQueryComparator, WatchedQueryDifferential, WatchedQueryListener, WatchedQueryOptions, WatchedQueryRowDifferential, WatchedQuerySettings, WatchedQueryState };
|