@powersync/common 1.47.0 → 1.48.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/bundle.cjs +42 -45
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +43 -45
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +42 -45
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +43 -45
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +124 -79
- package/lib/db/schema/RawTable.d.ts +61 -26
- package/lib/db/schema/RawTable.js +1 -32
- package/lib/db/schema/RawTable.js.map +1 -1
- package/lib/db/schema/Schema.d.ts +14 -7
- package/lib/db/schema/Schema.js +25 -3
- package/lib/db/schema/Schema.js.map +1 -1
- package/lib/db/schema/Table.d.ts +13 -8
- package/lib/db/schema/Table.js +3 -8
- package/lib/db/schema/Table.js.map +1 -1
- package/lib/db/schema/internal.d.ts +12 -0
- package/lib/db/schema/internal.js +15 -0
- package/lib/db/schema/internal.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/db/schema/RawTable.ts +66 -31
- package/src/db/schema/Schema.ts +27 -2
- package/src/db/schema/Table.ts +11 -11
- package/src/db/schema/internal.ts +17 -0
- package/src/index.ts +1 -1
package/dist/bundle.mjs
CHANGED
|
@@ -101,6 +101,21 @@ class Index {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* @internal Not exported from `index.ts`.
|
|
106
|
+
*/
|
|
107
|
+
function encodeTableOptions(options) {
|
|
108
|
+
const trackPrevious = options.trackPrevious;
|
|
109
|
+
return {
|
|
110
|
+
local_only: options.localOnly,
|
|
111
|
+
insert_only: options.insertOnly,
|
|
112
|
+
include_old: trackPrevious && (trackPrevious.columns ?? true),
|
|
113
|
+
include_old_only_when_changed: typeof trackPrevious == 'object' && trackPrevious.onlyWhenChanged == true,
|
|
114
|
+
include_metadata: options.trackMetadata,
|
|
115
|
+
ignore_empty_update: options.ignoreEmptyUpdates
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
104
119
|
const DEFAULT_TABLE_OPTIONS = {
|
|
105
120
|
indexes: [],
|
|
106
121
|
insertOnly: false,
|
|
@@ -290,18 +305,12 @@ class Table {
|
|
|
290
305
|
}
|
|
291
306
|
}
|
|
292
307
|
toJSON() {
|
|
293
|
-
const trackPrevious = this.trackPrevious;
|
|
294
308
|
return {
|
|
295
309
|
name: this.name,
|
|
296
310
|
view_name: this.viewName,
|
|
297
|
-
local_only: this.localOnly,
|
|
298
|
-
insert_only: this.insertOnly,
|
|
299
|
-
include_old: trackPrevious && (trackPrevious.columns ?? true),
|
|
300
|
-
include_old_only_when_changed: typeof trackPrevious == 'object' && trackPrevious.onlyWhenChanged == true,
|
|
301
|
-
include_metadata: this.trackMetadata,
|
|
302
|
-
ignore_empty_update: this.ignoreEmptyUpdates,
|
|
303
311
|
columns: this.columns.map((c) => c.toJSON()),
|
|
304
|
-
indexes: this.indexes.map((e) => e.toJSON(this))
|
|
312
|
+
indexes: this.indexes.map((e) => e.toJSON(this)),
|
|
313
|
+
...encodeTableOptions(this)
|
|
305
314
|
};
|
|
306
315
|
}
|
|
307
316
|
}
|
|
@@ -10446,7 +10455,7 @@ function requireDist () {
|
|
|
10446
10455
|
|
|
10447
10456
|
var distExports = requireDist();
|
|
10448
10457
|
|
|
10449
|
-
var version = "1.
|
|
10458
|
+
var version = "1.48.0";
|
|
10450
10459
|
var PACKAGE = {
|
|
10451
10460
|
version: version};
|
|
10452
10461
|
|
|
@@ -14127,39 +14136,6 @@ class ConnectionClosedError extends Error {
|
|
|
14127
14136
|
}
|
|
14128
14137
|
}
|
|
14129
14138
|
|
|
14130
|
-
/**
|
|
14131
|
-
* Instructs PowerSync to sync data into a "raw" table.
|
|
14132
|
-
*
|
|
14133
|
-
* Since raw tables are not backed by JSON, running complex queries on them may be more efficient. Further, they allow
|
|
14134
|
-
* using client-side table and column constraints.
|
|
14135
|
-
*
|
|
14136
|
-
* To collect local writes to raw tables with PowerSync, custom triggers are required. See
|
|
14137
|
-
* {@link https://docs.powersync.com/usage/use-case-examples/raw-tables the documentation} for details and an example on
|
|
14138
|
-
* using raw tables.
|
|
14139
|
-
*
|
|
14140
|
-
* Note that raw tables are only supported when using the new `SyncClientImplementation.rust` sync client.
|
|
14141
|
-
*
|
|
14142
|
-
* @experimental Please note that this feature is experimental at the moment, and not covered by PowerSync semver or
|
|
14143
|
-
* stability guarantees.
|
|
14144
|
-
*/
|
|
14145
|
-
class RawTable {
|
|
14146
|
-
/**
|
|
14147
|
-
* The name of the table.
|
|
14148
|
-
*
|
|
14149
|
-
* This does not have to match the actual table name in the schema - {@link put} and {@link delete} are free to use
|
|
14150
|
-
* another table. Instead, this name is used by the sync client to recognize that operations on this table (as it
|
|
14151
|
-
* appears in the source / backend database) are to be handled specially.
|
|
14152
|
-
*/
|
|
14153
|
-
name;
|
|
14154
|
-
put;
|
|
14155
|
-
delete;
|
|
14156
|
-
constructor(name, type) {
|
|
14157
|
-
this.name = name;
|
|
14158
|
-
this.put = type.put;
|
|
14159
|
-
this.delete = type.delete;
|
|
14160
|
-
}
|
|
14161
|
-
}
|
|
14162
|
-
|
|
14163
14139
|
/**
|
|
14164
14140
|
* A schema is a collection of tables. It is used to define the structure of a database.
|
|
14165
14141
|
*/
|
|
@@ -14204,7 +14180,7 @@ class Schema {
|
|
|
14204
14180
|
*/
|
|
14205
14181
|
withRawTables(tables) {
|
|
14206
14182
|
for (const [name, rawTableDefinition] of Object.entries(tables)) {
|
|
14207
|
-
this.rawTables.push(
|
|
14183
|
+
this.rawTables.push({ name, ...rawTableDefinition });
|
|
14208
14184
|
}
|
|
14209
14185
|
}
|
|
14210
14186
|
validate() {
|
|
@@ -14215,8 +14191,30 @@ class Schema {
|
|
|
14215
14191
|
toJSON() {
|
|
14216
14192
|
return {
|
|
14217
14193
|
tables: this.tables.map((t) => t.toJSON()),
|
|
14218
|
-
raw_tables: this.rawTables
|
|
14194
|
+
raw_tables: this.rawTables.map(Schema.rawTableToJson)
|
|
14195
|
+
};
|
|
14196
|
+
}
|
|
14197
|
+
/**
|
|
14198
|
+
* Returns a representation of the raw table that is understood by the PowerSync SQLite core extension.
|
|
14199
|
+
*
|
|
14200
|
+
* The output of this can be passed through `JSON.serialize` and then used in `powersync_create_raw_table_crud_trigger`
|
|
14201
|
+
* to define triggers for this table.
|
|
14202
|
+
*/
|
|
14203
|
+
static rawTableToJson(table) {
|
|
14204
|
+
const serialized = {
|
|
14205
|
+
name: table.name,
|
|
14206
|
+
put: table.put,
|
|
14207
|
+
delete: table.delete,
|
|
14208
|
+
clear: table.clear
|
|
14219
14209
|
};
|
|
14210
|
+
if ('schema' in table) {
|
|
14211
|
+
// We have schema options, those are flattened into the outer JSON object for the core extension.
|
|
14212
|
+
const schema = table.schema;
|
|
14213
|
+
serialized.table_name = schema.tableName ?? table.name;
|
|
14214
|
+
serialized.synced_columns = schema.syncedColumns;
|
|
14215
|
+
Object.assign(serialized, encodeTableOptions(table.schema));
|
|
14216
|
+
}
|
|
14217
|
+
return serialized;
|
|
14220
14218
|
}
|
|
14221
14219
|
}
|
|
14222
14220
|
|
|
@@ -14375,5 +14373,5 @@ const parseQuery = (query, parameters) => {
|
|
|
14375
14373
|
return { sqlStatement, parameters: parameters };
|
|
14376
14374
|
};
|
|
14377
14375
|
|
|
14378
|
-
export { ATTACHMENT_TABLE, AbortOperation, AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, AbstractQueryProcessor, AbstractRemote, AbstractStreamingSyncImplementation, ArrayComparator, AttachmentContext, AttachmentQueue, AttachmentService, AttachmentState, AttachmentTable, BaseObserver, Column, ColumnType, ConnectionClosedError, 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, EncodingType, FalsyComparator, FetchImplementationProvider, FetchStrategy, GetAllQuery, Index, IndexedColumn, InvalidSQLCharacters, LockType, LogLevel, MAX_AMOUNT_OF_COLUMNS, MAX_OP_ID, MEMORY_TRIGGER_CLAIM_MANAGER, OnChangeQueryProcessor, OpType, OpTypeEnum, OplogEntry, PSInternalTable, PowerSyncControlCommand,
|
|
14376
|
+
export { ATTACHMENT_TABLE, AbortOperation, AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, AbstractQueryProcessor, AbstractRemote, AbstractStreamingSyncImplementation, ArrayComparator, AttachmentContext, AttachmentQueue, AttachmentService, AttachmentState, AttachmentTable, BaseObserver, Column, ColumnType, ConnectionClosedError, 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, EncodingType, FalsyComparator, FetchImplementationProvider, FetchStrategy, GetAllQuery, Index, IndexedColumn, InvalidSQLCharacters, LockType, LogLevel, MAX_AMOUNT_OF_COLUMNS, MAX_OP_ID, MEMORY_TRIGGER_CLAIM_MANAGER, OnChangeQueryProcessor, OpType, OpTypeEnum, OplogEntry, PSInternalTable, PowerSyncControlCommand, RowUpdateType, Schema, SqliteBucketStorage, SyncClientImplementation, SyncDataBatch, SyncDataBucket, SyncProgress, SyncStatus, SyncStreamConnectionMethod, SyncingService, Table, TableV2, TriggerManagerImpl, UpdateType, UploadQueueStats, WatchedQueryListenerEvent, attachmentFromSql, column, compilableQueryWatch, createBaseLogger, createLogger, extractTableUpdates, isBatchedUpdateNotification, isContinueCheckpointRequest, isDBAdapter, isPowerSyncDatabaseOptionsWithSettings, isSQLOpenFactory, isSQLOpenOptions, isStreamingKeepalive, isStreamingSyncCheckpoint, isStreamingSyncCheckpointComplete, isStreamingSyncCheckpointDiff, isStreamingSyncCheckpointPartiallyComplete, isStreamingSyncData, isSyncNewCheckpointRequest, mutexRunExclusive, parseQuery, runOnSchemaChange, sanitizeSQL, sanitizeUUID };
|
|
14379
14377
|
//# sourceMappingURL=bundle.mjs.map
|