@powersync/common 1.39.0 → 1.41.0

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/index.d.cts CHANGED
@@ -1748,7 +1748,6 @@ declare class Schema<S extends SchemaType = SchemaType> {
1748
1748
  }[];
1749
1749
  raw_tables: RawTable[];
1750
1750
  };
1751
- private convertToClassicTables;
1752
1751
  }
1753
1752
 
1754
1753
  interface PowerSyncBackendConnector {
@@ -1854,6 +1853,8 @@ declare class ConnectionManager extends BaseObserver<ConnectionManagerListener>
1854
1853
  */
1855
1854
  private locallyActiveSubscriptions;
1856
1855
  constructor(options: ConnectionManagerOptions);
1856
+ get connector(): PowerSyncBackendConnector | null;
1857
+ get connectionOptions(): InternalConnectionOptions | null;
1857
1858
  get logger(): ILogger;
1858
1859
  close(): Promise<void>;
1859
1860
  connect(connector: PowerSyncBackendConnector, options: InternalConnectionOptions): Promise<void>;
@@ -2899,6 +2900,18 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
2899
2900
  protected connectionManager: ConnectionManager;
2900
2901
  private subscriptions;
2901
2902
  get syncStreamImplementation(): StreamingSyncImplementation | null;
2903
+ /**
2904
+ * The connector used to connect to the PowerSync service.
2905
+ *
2906
+ * @returns The connector used to connect to the PowerSync service or null if `connect()` has not been called.
2907
+ */
2908
+ get connector(): PowerSyncBackendConnector | null;
2909
+ /**
2910
+ * The resolved connection options used to connect to the PowerSync service.
2911
+ *
2912
+ * @returns The resolved connection options used to connect to the PowerSync service or null if `connect()` has not been called.
2913
+ */
2914
+ get connectionOptions(): InternalConnectionOptions | null;
2902
2915
  protected _schema: Schema;
2903
2916
  private _database;
2904
2917
  protected runExclusiveMutex: Mutex;
@@ -12,7 +12,7 @@ import { PowerSyncBackendConnector } from './connection/PowerSyncBackendConnecto
12
12
  import { BucketStorageAdapter } from './sync/bucket/BucketStorageAdapter.js';
13
13
  import { CrudBatch } from './sync/bucket/CrudBatch.js';
14
14
  import { CrudTransaction } from './sync/bucket/CrudTransaction.js';
15
- import { StreamingSyncImplementation, StreamingSyncImplementationListener, type AdditionalConnectionOptions, type PowerSyncConnectionOptions, type RequiredAdditionalConnectionOptions } from './sync/stream/AbstractStreamingSyncImplementation.js';
15
+ import { InternalConnectionOptions, StreamingSyncImplementation, StreamingSyncImplementationListener, type AdditionalConnectionOptions, type PowerSyncConnectionOptions, type RequiredAdditionalConnectionOptions } from './sync/stream/AbstractStreamingSyncImplementation.js';
16
16
  import { TriggerManager } from './triggers/TriggerManager.js';
17
17
  import { WatchCompatibleQuery } from './watched/WatchedQuery.js';
18
18
  import { WatchedQueryComparator } from './watched/processors/comparators.js';
@@ -132,6 +132,18 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
132
132
  protected connectionManager: ConnectionManager;
133
133
  private subscriptions;
134
134
  get syncStreamImplementation(): StreamingSyncImplementation | null;
135
+ /**
136
+ * The connector used to connect to the PowerSync service.
137
+ *
138
+ * @returns The connector used to connect to the PowerSync service or null if `connect()` has not been called.
139
+ */
140
+ get connector(): PowerSyncBackendConnector | null;
141
+ /**
142
+ * The resolved connection options used to connect to the PowerSync service.
143
+ *
144
+ * @returns The resolved connection options used to connect to the PowerSync service or null if `connect()` has not been called.
145
+ */
146
+ get connectionOptions(): InternalConnectionOptions | null;
135
147
  protected _schema: Schema;
136
148
  private _database;
137
149
  protected runExclusiveMutex: Mutex;
@@ -63,6 +63,22 @@ export class AbstractPowerSyncDatabase extends BaseObserver {
63
63
  get syncStreamImplementation() {
64
64
  return this.connectionManager.syncStreamImplementation;
65
65
  }
66
+ /**
67
+ * The connector used to connect to the PowerSync service.
68
+ *
69
+ * @returns The connector used to connect to the PowerSync service or null if `connect()` has not been called.
70
+ */
71
+ get connector() {
72
+ return this.connectionManager.connector;
73
+ }
74
+ /**
75
+ * The resolved connection options used to connect to the PowerSync service.
76
+ *
77
+ * @returns The resolved connection options used to connect to the PowerSync service or null if `connect()` has not been called.
78
+ */
79
+ get connectionOptions() {
80
+ return this.connectionManager.connectionOptions;
81
+ }
66
82
  _schema;
67
83
  _database;
68
84
  runExclusiveMutex;
@@ -85,6 +85,8 @@ export declare class ConnectionManager extends BaseObserver<ConnectionManagerLis
85
85
  */
86
86
  private locallyActiveSubscriptions;
87
87
  constructor(options: ConnectionManagerOptions);
88
+ get connector(): PowerSyncBackendConnector | null;
89
+ get connectionOptions(): InternalConnectionOptions | null;
88
90
  get logger(): ILogger;
89
91
  close(): Promise<void>;
90
92
  connect(connector: PowerSyncBackendConnector, options: InternalConnectionOptions): Promise<void>;
@@ -48,6 +48,12 @@ export class ConnectionManager extends BaseObserver {
48
48
  this.syncStreamImplementation = null;
49
49
  this.syncDisposer = null;
50
50
  }
51
+ get connector() {
52
+ return this.pendingConnectionOptions?.connector ?? null;
53
+ }
54
+ get connectionOptions() {
55
+ return this.pendingConnectionOptions?.options ?? null;
56
+ }
51
57
  get logger() {
52
58
  return this.options.logger;
53
59
  }
@@ -50,6 +50,5 @@ export declare class Schema<S extends SchemaType = SchemaType> {
50
50
  }[];
51
51
  raw_tables: RawTable[];
52
52
  };
53
- private convertToClassicTables;
54
53
  }
55
54
  export {};
@@ -25,8 +25,9 @@ export class Schema {
25
25
  this.tables = tables;
26
26
  }
27
27
  else {
28
- this.props = tables;
29
- this.tables = this.convertToClassicTables(this.props);
28
+ // Update the table entries with the provided table name key
29
+ this.props = Object.fromEntries(Object.entries(tables).map(([tableName, table]) => [tableName, table.copyWithName(tableName)]));
30
+ this.tables = Object.values(this.props);
30
31
  }
31
32
  this.rawTables = [];
32
33
  }
@@ -52,14 +53,8 @@ export class Schema {
52
53
  }
53
54
  toJSON() {
54
55
  return {
55
- // This is required because "name" field is not present in TableV2
56
56
  tables: this.tables.map((t) => t.toJSON()),
57
57
  raw_tables: this.rawTables
58
58
  };
59
59
  }
60
- convertToClassicTables(props) {
61
- return Object.entries(props).map(([name, table]) => {
62
- return table.copyWithName(name);
63
- });
64
- }
65
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powersync/common",
3
- "version": "1.39.0",
3
+ "version": "1.41.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"