@powersync/common 0.0.0-dev-20240905154001 → 0.0.0-dev-20240920093037

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.
Files changed (101) hide show
  1. package/dist/bundle.mjs +18 -0
  2. package/dist/bundle.mjs.map +1 -0
  3. package/lib/client/AbstractPowerSyncDatabase.d.ts +15 -15
  4. package/lib/client/AbstractPowerSyncDatabase.js +15 -16
  5. package/lib/client/AbstractPowerSyncOpenFactory.d.ts +5 -5
  6. package/lib/client/AbstractPowerSyncOpenFactory.js +0 -1
  7. package/lib/client/SQLOpenFactory.d.ts +1 -1
  8. package/lib/client/SQLOpenFactory.js +0 -1
  9. package/lib/client/connection/PowerSyncBackendConnector.d.ts +2 -2
  10. package/lib/client/connection/PowerSyncBackendConnector.js +0 -1
  11. package/lib/client/connection/PowerSyncCredentials.js +0 -1
  12. package/lib/client/constants.js +0 -1
  13. package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +4 -4
  14. package/lib/client/sync/bucket/BucketStorageAdapter.js +0 -1
  15. package/lib/client/sync/bucket/CrudBatch.d.ts +1 -1
  16. package/lib/client/sync/bucket/CrudBatch.js +0 -1
  17. package/lib/client/sync/bucket/CrudEntry.js +0 -1
  18. package/lib/client/sync/bucket/CrudTransaction.d.ts +2 -2
  19. package/lib/client/sync/bucket/CrudTransaction.js +1 -2
  20. package/lib/client/sync/bucket/OpType.js +0 -1
  21. package/lib/client/sync/bucket/OplogEntry.d.ts +2 -2
  22. package/lib/client/sync/bucket/OplogEntry.js +1 -2
  23. package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +6 -6
  24. package/lib/client/sync/bucket/SqliteBucketStorage.js +5 -6
  25. package/lib/client/sync/bucket/SyncDataBatch.d.ts +1 -1
  26. package/lib/client/sync/bucket/SyncDataBatch.js +1 -2
  27. package/lib/client/sync/bucket/SyncDataBucket.d.ts +2 -2
  28. package/lib/client/sync/bucket/SyncDataBucket.js +1 -2
  29. package/lib/client/sync/stream/AbstractRemote.d.ts +6 -6
  30. package/lib/client/sync/stream/AbstractRemote.js +4 -5
  31. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +8 -8
  32. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +8 -9
  33. package/lib/client/sync/stream/streaming-sync-types.d.ts +3 -3
  34. package/lib/client/sync/stream/streaming-sync-types.js +0 -1
  35. package/lib/db/DBAdapter.d.ts +1 -1
  36. package/lib/db/DBAdapter.js +0 -1
  37. package/lib/db/crud/SyncStatus.js +0 -1
  38. package/lib/db/crud/UploadQueueStatus.js +0 -1
  39. package/lib/db/schema/Column.d.ts +30 -0
  40. package/lib/db/{Column.js → schema/Column.js} +17 -1
  41. package/lib/db/schema/Index.d.ts +3 -3
  42. package/lib/db/schema/Index.js +1 -2
  43. package/lib/db/schema/IndexedColumn.d.ts +2 -2
  44. package/lib/db/schema/IndexedColumn.js +1 -2
  45. package/lib/db/schema/Schema.d.ts +6 -7
  46. package/lib/db/schema/Schema.js +11 -3
  47. package/lib/db/schema/Table.d.ts +90 -10
  48. package/lib/db/schema/Table.js +61 -11
  49. package/lib/db/schema/TableV2.d.ts +8 -30
  50. package/lib/db/schema/TableV2.js +5 -62
  51. package/lib/index.d.ts +34 -34
  52. package/lib/index.js +34 -35
  53. package/lib/types/types.js +0 -1
  54. package/lib/utils/AbortOperation.js +0 -1
  55. package/lib/utils/BaseObserver.js +0 -1
  56. package/lib/utils/ControlledExecutor.js +0 -1
  57. package/lib/utils/DataStream.d.ts +1 -1
  58. package/lib/utils/DataStream.js +1 -2
  59. package/lib/utils/mutex.js +0 -1
  60. package/lib/utils/parseQuery.d.ts +1 -1
  61. package/lib/utils/parseQuery.js +0 -1
  62. package/lib/utils/throttle.d.ts +14 -0
  63. package/lib/utils/throttle.js +45 -0
  64. package/package.json +13 -5
  65. package/dist/index.js +0 -16
  66. package/lib/client/AbstractPowerSyncDatabase.js.map +0 -1
  67. package/lib/client/AbstractPowerSyncOpenFactory.js.map +0 -1
  68. package/lib/client/SQLOpenFactory.js.map +0 -1
  69. package/lib/client/connection/PowerSyncBackendConnector.js.map +0 -1
  70. package/lib/client/connection/PowerSyncCredentials.js.map +0 -1
  71. package/lib/client/constants.js.map +0 -1
  72. package/lib/client/sync/bucket/BucketStorageAdapter.js.map +0 -1
  73. package/lib/client/sync/bucket/CrudBatch.js.map +0 -1
  74. package/lib/client/sync/bucket/CrudEntry.js.map +0 -1
  75. package/lib/client/sync/bucket/CrudTransaction.js.map +0 -1
  76. package/lib/client/sync/bucket/OpType.js.map +0 -1
  77. package/lib/client/sync/bucket/OplogEntry.js.map +0 -1
  78. package/lib/client/sync/bucket/SqliteBucketStorage.js.map +0 -1
  79. package/lib/client/sync/bucket/SyncDataBatch.js.map +0 -1
  80. package/lib/client/sync/bucket/SyncDataBucket.js.map +0 -1
  81. package/lib/client/sync/stream/AbstractRemote.js.map +0 -1
  82. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +0 -1
  83. package/lib/client/sync/stream/streaming-sync-types.js.map +0 -1
  84. package/lib/db/Column.d.ts +0 -19
  85. package/lib/db/Column.js.map +0 -1
  86. package/lib/db/DBAdapter.js.map +0 -1
  87. package/lib/db/crud/SyncStatus.js.map +0 -1
  88. package/lib/db/crud/UploadQueueStatus.js.map +0 -1
  89. package/lib/db/schema/Index.js.map +0 -1
  90. package/lib/db/schema/IndexedColumn.js.map +0 -1
  91. package/lib/db/schema/Schema.js.map +0 -1
  92. package/lib/db/schema/Table.js.map +0 -1
  93. package/lib/db/schema/TableV2.js.map +0 -1
  94. package/lib/index.js.map +0 -1
  95. package/lib/types/types.js.map +0 -1
  96. package/lib/utils/AbortOperation.js.map +0 -1
  97. package/lib/utils/BaseObserver.js.map +0 -1
  98. package/lib/utils/ControlledExecutor.js.map +0 -1
  99. package/lib/utils/DataStream.js.map +0 -1
  100. package/lib/utils/mutex.js.map +0 -1
  101. package/lib/utils/parseQuery.js.map +0 -1
@@ -1,6 +1,5 @@
1
- import { Table as ClassicTable } from './Table';
2
- import { RowType, TableV2 } from './TableV2';
3
- type SchemaType = Record<string, TableV2<any>>;
1
+ import { RowType, Table } from './Table.js';
2
+ type SchemaType = Record<string, Table<any>>;
4
3
  type SchemaTableType<S extends SchemaType> = {
5
4
  [K in keyof S]: RowType<S[K]>;
6
5
  };
@@ -10,8 +9,8 @@ type SchemaTableType<S extends SchemaType> = {
10
9
  export declare class Schema<S extends SchemaType = SchemaType> {
11
10
  readonly types: SchemaTableType<S>;
12
11
  readonly props: S;
13
- readonly tables: ClassicTable[];
14
- constructor(tables: ClassicTable[] | S);
12
+ readonly tables: Table[];
13
+ constructor(tables: Table[] | S);
15
14
  validate(): void;
16
15
  toJSON(): {
17
16
  tables: {
@@ -21,14 +20,14 @@ export declare class Schema<S extends SchemaType = SchemaType> {
21
20
  insert_only: boolean;
22
21
  columns: {
23
22
  name: string;
24
- type: import("../Column").ColumnType | undefined;
23
+ type: import("./Column.js").ColumnType | undefined;
25
24
  }[];
26
25
  indexes: {
27
26
  name: string;
28
27
  columns: {
29
28
  name: string;
30
29
  ascending: boolean | undefined;
31
- type: import("../Column").ColumnType;
30
+ type: import("./Column.js").ColumnType;
32
31
  }[];
33
32
  }[];
34
33
  }[];
@@ -1,4 +1,4 @@
1
- import { Table as ClassicTable } from './Table';
1
+ import { Table } from './Table.js';
2
2
  /**
3
3
  * A schema is a collection of tables. It is used to define the structure of a database.
4
4
  */
@@ -25,13 +25,21 @@ export class Schema {
25
25
  }
26
26
  toJSON() {
27
27
  return {
28
+ // This is required because "name" field is not present in TableV2
28
29
  tables: this.tables.map((t) => t.toJSON())
29
30
  };
30
31
  }
31
32
  convertToClassicTables(props) {
32
33
  return Object.entries(props).map(([name, table]) => {
33
- return ClassicTable.createTable(name, table);
34
+ const convertedTable = new Table({
35
+ name,
36
+ columns: table.columns,
37
+ indexes: table.indexes,
38
+ localOnly: table.localOnly,
39
+ insertOnly: table.insertOnly,
40
+ viewName: table.viewNameOverride || name
41
+ });
42
+ return convertedTable;
34
43
  });
35
44
  }
36
45
  }
37
- //# sourceMappingURL=Schema.js.map
@@ -1,6 +1,6 @@
1
- import { Column } from '../Column';
2
- import type { Index } from './Index';
3
- import { TableV2 } from './TableV2';
1
+ import { Column, ColumnsType, ColumnType, ExtractColumnValueType } from './Column.js';
2
+ import { Index } from './Index.js';
3
+ import { TableV2 } from './TableV2.js';
4
4
  export interface TableOptions {
5
5
  /**
6
6
  * The synced table name, matching sync rules
@@ -12,18 +12,98 @@ export interface TableOptions {
12
12
  insertOnly?: boolean;
13
13
  viewName?: string;
14
14
  }
15
- export declare const DEFAULT_TABLE_OPTIONS: Partial<TableOptions>;
15
+ export type RowType<T extends TableV2<any>> = {
16
+ [K in keyof T['columnMap']]: ExtractColumnValueType<T['columnMap'][K]>;
17
+ } & {
18
+ id: string;
19
+ };
20
+ export type IndexShorthand = Record<string, string[]>;
21
+ export interface TableV2Options {
22
+ indexes?: IndexShorthand;
23
+ localOnly?: boolean;
24
+ insertOnly?: boolean;
25
+ viewName?: string;
26
+ }
27
+ export declare const DEFAULT_TABLE_OPTIONS: {
28
+ indexes: never[];
29
+ insertOnly: boolean;
30
+ localOnly: boolean;
31
+ };
16
32
  export declare const InvalidSQLCharacters: RegExp;
17
- export declare class Table {
33
+ export declare class Table<Columns extends ColumnsType = ColumnsType> {
18
34
  protected options: TableOptions;
19
- static createLocalOnly(options: TableOptions): Table;
20
- static createInsertOnly(options: TableOptions): Table;
21
- static createTable(name: string, table: TableV2): Table;
35
+ protected _mappedColumns: Columns;
36
+ static createLocalOnly(options: TableOptions): Table<ColumnsType>;
37
+ static createInsertOnly(options: TableOptions): Table<ColumnsType>;
38
+ /**
39
+ * Create a table.
40
+ * @deprecated This was only only included for TableV2 and is no longer necessary.
41
+ * Prefer to use new Table() directly.
42
+ *
43
+ * TODO remove in the next major release.
44
+ */
45
+ static createTable(name: string, table: Table): Table<ColumnsType>;
46
+ /**
47
+ * Creates a new Table instance.
48
+ *
49
+ * This constructor supports two different versions:
50
+ * 1. New constructor: Using a Columns object and an optional TableV2Options object
51
+ * 2. Deprecated constructor: Using a TableOptions object (will be removed in the next major release)
52
+ *
53
+ * @constructor
54
+ * @param {Columns | TableOptions} optionsOrColumns - Either a Columns object (for V2 syntax) or a TableOptions object (for V1 syntax)
55
+ * @param {TableV2Options} [v2Options] - Optional configuration options for V2 syntax
56
+ *
57
+ * @example
58
+ * ```javascript
59
+ * // New Constructor
60
+ * const table = new Table(
61
+ * {
62
+ * name: column.text,
63
+ * age: column.integer
64
+ * },
65
+ * { indexes: { nameIndex: ['name'] } }
66
+ * );
67
+ *```
68
+ *
69
+ *
70
+ * @example
71
+ * ```javascript
72
+ * // Deprecated Constructor
73
+ * const table = new Table({
74
+ * name: 'users',
75
+ * columns: [
76
+ * new Column({ name: 'name', type: ColumnType.TEXT }),
77
+ * new Column({ name: 'age', type: ColumnType.INTEGER })
78
+ * ]
79
+ * });
80
+ *```
81
+ */
82
+ constructor(columns: Columns, options?: TableV2Options);
83
+ /**
84
+ * @deprecated This constructor will be removed in the next major release.
85
+ * Use the new constructor shown below instead as this does not show types.
86
+ * @example
87
+ * <caption>Use this instead</caption>
88
+ * ```javascript
89
+ * const table = new Table(
90
+ * {
91
+ * name: column.text,
92
+ * age: column.integer
93
+ * },
94
+ * { indexes: { nameIndex: ['name'] } }
95
+ * );
96
+ *```
97
+ */
22
98
  constructor(options: TableOptions);
99
+ private isTableV1;
100
+ private initTableV1;
101
+ private initTableV2;
23
102
  get name(): string;
24
103
  get viewNameOverride(): string | undefined;
25
104
  get viewName(): string;
26
105
  get columns(): Column[];
106
+ get columnMap(): Columns;
27
107
  get indexes(): Index[];
28
108
  get localOnly(): boolean;
29
109
  get insertOnly(): boolean;
@@ -37,14 +117,14 @@ export declare class Table {
37
117
  insert_only: boolean;
38
118
  columns: {
39
119
  name: string;
40
- type: import("../Column").ColumnType | undefined;
120
+ type: ColumnType | undefined;
41
121
  }[];
42
122
  indexes: {
43
123
  name: string;
44
124
  columns: {
45
125
  name: string;
46
126
  ascending: boolean | undefined;
47
- type: import("../Column").ColumnType;
127
+ type: ColumnType;
48
128
  }[];
49
129
  }[];
50
130
  };
@@ -1,31 +1,75 @@
1
- import { Column } from '../Column';
1
+ import { Column, ColumnType, MAX_AMOUNT_OF_COLUMNS } from './Column.js';
2
+ import { Index } from './Index.js';
3
+ import { IndexedColumn } from './IndexedColumn.js';
2
4
  export const DEFAULT_TABLE_OPTIONS = {
3
5
  indexes: [],
4
6
  insertOnly: false,
5
7
  localOnly: false
6
8
  };
7
- const MAX_AMOUNT_OF_COLUMNS = 63;
8
9
  export const InvalidSQLCharacters = /["'%,.#\s[\]]/;
9
10
  export class Table {
10
11
  options;
12
+ _mappedColumns;
11
13
  static createLocalOnly(options) {
12
14
  return new Table({ ...options, localOnly: true, insertOnly: false });
13
15
  }
14
16
  static createInsertOnly(options) {
15
17
  return new Table({ ...options, localOnly: false, insertOnly: true });
16
18
  }
19
+ /**
20
+ * Create a table.
21
+ * @deprecated This was only only included for TableV2 and is no longer necessary.
22
+ * Prefer to use new Table() directly.
23
+ *
24
+ * TODO remove in the next major release.
25
+ */
17
26
  static createTable(name, table) {
18
27
  return new Table({
19
28
  name,
20
- columns: Object.entries(table.columns).map(([name, col]) => new Column({ name, type: col.type })),
29
+ columns: table.columns,
21
30
  indexes: table.indexes,
22
31
  localOnly: table.options.localOnly,
23
32
  insertOnly: table.options.insertOnly,
24
33
  viewName: table.options.viewName
25
34
  });
26
35
  }
27
- constructor(options) {
28
- this.options = { ...DEFAULT_TABLE_OPTIONS, ...options };
36
+ constructor(optionsOrColumns, v2Options) {
37
+ if (this.isTableV1(optionsOrColumns)) {
38
+ this.initTableV1(optionsOrColumns);
39
+ }
40
+ else {
41
+ this.initTableV2(optionsOrColumns, v2Options);
42
+ }
43
+ }
44
+ isTableV1(arg) {
45
+ return 'columns' in arg && Array.isArray(arg.columns);
46
+ }
47
+ initTableV1(options) {
48
+ this.options = {
49
+ ...options,
50
+ indexes: options.indexes || [],
51
+ insertOnly: options.insertOnly ?? DEFAULT_TABLE_OPTIONS.insertOnly,
52
+ localOnly: options.localOnly ?? DEFAULT_TABLE_OPTIONS.localOnly
53
+ };
54
+ }
55
+ initTableV2(columns, options) {
56
+ const convertedColumns = Object.entries(columns).map(([name, columnInfo]) => new Column({ name, type: columnInfo.type }));
57
+ const convertedIndexes = Object.entries(options?.indexes ?? {}).map(([name, columnNames]) => new Index({
58
+ name,
59
+ columns: columnNames.map((name) => new IndexedColumn({
60
+ name: name.replace(/^-/, ''),
61
+ ascending: !name.startsWith('-')
62
+ }))
63
+ }));
64
+ this.options = {
65
+ name: '',
66
+ columns: convertedColumns,
67
+ indexes: convertedIndexes,
68
+ insertOnly: options?.insertOnly ?? DEFAULT_TABLE_OPTIONS.insertOnly,
69
+ localOnly: options?.localOnly ?? DEFAULT_TABLE_OPTIONS.localOnly,
70
+ viewName: options?.viewName
71
+ };
72
+ this._mappedColumns = columns;
29
73
  }
30
74
  get name() {
31
75
  return this.options.name;
@@ -39,6 +83,13 @@ export class Table {
39
83
  get columns() {
40
84
  return this.options.columns;
41
85
  }
86
+ get columnMap() {
87
+ return (this._mappedColumns ??
88
+ this.columns.reduce((hash, column) => {
89
+ hash[column.name] = { type: column.type ?? ColumnType.TEXT };
90
+ return hash;
91
+ }, {}));
92
+ }
42
93
  get indexes() {
43
94
  return this.options.indexes ?? [];
44
95
  }
@@ -71,30 +122,30 @@ export class Table {
71
122
  throw new Error(`Invalid characters in view name: ${this.viewNameOverride}`);
72
123
  }
73
124
  if (this.columns.length > MAX_AMOUNT_OF_COLUMNS) {
74
- throw new Error(`Table ${this.name} has too many columns. The maximum number of columns is ${MAX_AMOUNT_OF_COLUMNS}.`);
125
+ throw new Error(`Table has too many columns. The maximum number of columns is ${MAX_AMOUNT_OF_COLUMNS}.`);
75
126
  }
76
127
  const columnNames = new Set();
77
128
  columnNames.add('id');
78
129
  for (const column of this.columns) {
79
130
  const { name: columnName } = column;
80
131
  if (column.name === 'id') {
81
- throw new Error(`${this.name}: id column is automatically added, custom id columns are not supported`);
132
+ throw new Error(`An id column is automatically added, custom id columns are not supported`);
82
133
  }
83
134
  if (columnNames.has(columnName)) {
84
135
  throw new Error(`Duplicate column ${columnName}`);
85
136
  }
86
137
  if (InvalidSQLCharacters.test(columnName)) {
87
- throw new Error(`Invalid characters in column name: $name.${column}`);
138
+ throw new Error(`Invalid characters in column name: ${column.name}`);
88
139
  }
89
140
  columnNames.add(columnName);
90
141
  }
91
142
  const indexNames = new Set();
92
143
  for (const index of this.indexes) {
93
144
  if (indexNames.has(index.name)) {
94
- throw new Error(`Duplicate index $name.${index}`);
145
+ throw new Error(`Duplicate index ${index.name}`);
95
146
  }
96
147
  if (InvalidSQLCharacters.test(index.name)) {
97
- throw new Error(`Invalid characters in index name: $name.${index}`);
148
+ throw new Error(`Invalid characters in index name: ${index.name}`);
98
149
  }
99
150
  for (const column of index.columns) {
100
151
  if (!columnNames.has(column.name)) {
@@ -115,4 +166,3 @@ export class Table {
115
166
  };
116
167
  }
117
168
  }
118
- //# sourceMappingURL=Table.js.map
@@ -1,31 +1,9 @@
1
- import { ColumnType } from '../Column';
2
- import { Index } from './Index';
3
- export type BaseColumnType<T extends number | string | null> = {
4
- type: ColumnType;
5
- };
6
- export declare const column: {
7
- text: BaseColumnType<string | null>;
8
- integer: BaseColumnType<number | null>;
9
- real: BaseColumnType<number | null>;
10
- };
11
- export type ColumnsType = Record<string, BaseColumnType<any>>;
12
- export type ExtractColumnValueType<T extends BaseColumnType<any>> = T extends BaseColumnType<infer R> ? R : unknown;
13
- export type RowType<T extends TableV2<any>> = {
14
- [K in keyof T['columns']]: ExtractColumnValueType<T['columns'][K]>;
15
- } & {
16
- id: string;
17
- };
18
- export type IndexShorthand = Record<string, string[]>;
19
- export interface TableV2Options {
20
- indexes?: IndexShorthand;
21
- localOnly?: boolean;
22
- insertOnly?: boolean;
23
- viewName?: string;
24
- }
25
- export declare class TableV2<Columns extends ColumnsType = ColumnsType> {
26
- columns: Columns;
27
- options: TableV2Options;
28
- indexes: Index[];
29
- constructor(columns: Columns, options?: TableV2Options);
30
- private validateTable;
1
+ import { ColumnsType } from './Column.js';
2
+ import { Table } from './Table.js';
3
+ /**
4
+ Generate a new table from the columns and indexes
5
+ @deprecated You should use {@link Table} instead as it now allows TableV2 syntax.
6
+ This will be removed in the next major release.
7
+ */
8
+ export declare class TableV2<Columns extends ColumnsType = ColumnsType> extends Table<Columns> {
31
9
  }
@@ -1,65 +1,8 @@
1
- import { ColumnType } from '../Column';
2
- import { Index } from './Index';
3
- import { IndexedColumn } from './IndexedColumn';
4
- import { InvalidSQLCharacters } from './Table';
5
- const text = {
6
- type: ColumnType.TEXT
7
- };
8
- const integer = {
9
- type: ColumnType.INTEGER
10
- };
11
- const real = {
12
- type: ColumnType.REAL
13
- };
14
- // There is maximum of 127 arguments for any function in SQLite. Currently we use json_object which uses 1 arg per key (column name)
15
- // and one per value, which limits it to 63 arguments.
16
- const MAX_AMOUNT_OF_COLUMNS = 63;
17
- export const column = {
18
- text,
19
- integer,
20
- real
21
- };
22
- /*
1
+ import { Table } from './Table.js';
2
+ /**
23
3
  Generate a new table from the columns and indexes
4
+ @deprecated You should use {@link Table} instead as it now allows TableV2 syntax.
5
+ This will be removed in the next major release.
24
6
  */
25
- export class TableV2 {
26
- columns;
27
- options;
28
- indexes;
29
- constructor(columns, options = {}) {
30
- this.columns = columns;
31
- this.options = options;
32
- this.validateTable(columns);
33
- if (options?.indexes) {
34
- this.indexes = Object.entries(options.indexes).map(([name, columns]) => {
35
- if (name.startsWith('-')) {
36
- return new Index({
37
- name: name.substring(1),
38
- columns: columns.map((c) => new IndexedColumn({ name: c, ascending: false }))
39
- });
40
- }
41
- return new Index({
42
- name: name,
43
- columns: columns.map((c) => new IndexedColumn({ name: c, ascending: true }))
44
- });
45
- });
46
- }
47
- }
48
- validateTable(columns) {
49
- const columnNames = Object.keys(columns);
50
- const columnLength = columnNames.length;
51
- if (columnNames.includes('id')) {
52
- throw new Error(`An id column is automatically added, custom id columns are not supported`);
53
- }
54
- if (columnLength > MAX_AMOUNT_OF_COLUMNS) {
55
- throw new Error(`TableV2 cannot have more than ${MAX_AMOUNT_OF_COLUMNS} columns`);
56
- }
57
- columnNames
58
- .map((column) => {
59
- if (InvalidSQLCharacters.test(column)) {
60
- throw new Error(`Invalid characters in column name: ${column}`);
61
- }
62
- });
63
- }
7
+ export class TableV2 extends Table {
64
8
  }
65
- //# sourceMappingURL=TableV2.js.map
package/lib/index.d.ts CHANGED
@@ -1,34 +1,34 @@
1
- export * from './client/AbstractPowerSyncDatabase';
2
- export * from './client/AbstractPowerSyncOpenFactory';
3
- export * from './client/SQLOpenFactory';
4
- export * from './client/connection/PowerSyncBackendConnector';
5
- export * from './client/connection/PowerSyncCredentials';
6
- export * from './client/sync/bucket/BucketStorageAdapter';
7
- export { UpdateType, CrudEntry, OpId } from './client/sync/bucket/CrudEntry';
8
- export * from './client/sync/bucket/SqliteBucketStorage';
9
- export * from './client/sync/bucket/CrudBatch';
10
- export * from './client/sync/bucket/CrudTransaction';
11
- export * from './client/sync/bucket/SyncDataBatch';
12
- export * from './client/sync/bucket/SyncDataBucket';
13
- export * from './client/sync/bucket/OpType';
14
- export * from './client/sync/bucket/OplogEntry';
15
- export * from './client/sync/stream/AbstractRemote';
16
- export * from './client/sync/stream/AbstractStreamingSyncImplementation';
17
- export * from './client/sync/stream/streaming-sync-types';
18
- export { MAX_OP_ID } from './client/constants';
19
- export * from './db/crud/SyncStatus';
20
- export * from './db/crud/UploadQueueStatus';
21
- export * from './db/schema/Schema';
22
- export * from './db/schema/Table';
23
- export * from './db/schema/Index';
24
- export * from './db/schema/IndexedColumn';
25
- export * from './db/crud/SyncStatus';
26
- export * from './db/crud/UploadQueueStatus';
27
- export * from './db/DBAdapter';
28
- export * from './db/Column';
29
- export * from './db/schema/TableV2';
30
- export * from './utils/AbortOperation';
31
- export * from './utils/BaseObserver';
32
- export * from './utils/DataStream';
33
- export * from './utils/parseQuery';
34
- export * from './types/types';
1
+ export * from './client/AbstractPowerSyncDatabase.js';
2
+ export * from './client/AbstractPowerSyncOpenFactory.js';
3
+ export * from './client/SQLOpenFactory.js';
4
+ export * from './client/connection/PowerSyncBackendConnector.js';
5
+ export * from './client/connection/PowerSyncCredentials.js';
6
+ export * from './client/sync/bucket/BucketStorageAdapter.js';
7
+ export { UpdateType, CrudEntry, OpId } from './client/sync/bucket/CrudEntry.js';
8
+ export * from './client/sync/bucket/SqliteBucketStorage.js';
9
+ export * from './client/sync/bucket/CrudBatch.js';
10
+ export * from './client/sync/bucket/CrudTransaction.js';
11
+ export * from './client/sync/bucket/SyncDataBatch.js';
12
+ export * from './client/sync/bucket/SyncDataBucket.js';
13
+ export * from './client/sync/bucket/OpType.js';
14
+ export * from './client/sync/bucket/OplogEntry.js';
15
+ export * from './client/sync/stream/AbstractRemote.js';
16
+ export * from './client/sync/stream/AbstractStreamingSyncImplementation.js';
17
+ export * from './client/sync/stream/streaming-sync-types.js';
18
+ export { MAX_OP_ID } from './client/constants.js';
19
+ export * from './db/crud/SyncStatus.js';
20
+ export * from './db/crud/UploadQueueStatus.js';
21
+ export * from './db/schema/Schema.js';
22
+ export * from './db/schema/Table.js';
23
+ export * from './db/schema/Index.js';
24
+ export * from './db/schema/IndexedColumn.js';
25
+ export * from './db/schema/Column.js';
26
+ export * from './db/schema/TableV2.js';
27
+ export * from './db/crud/SyncStatus.js';
28
+ export * from './db/crud/UploadQueueStatus.js';
29
+ export * from './db/DBAdapter.js';
30
+ export * from './utils/AbortOperation.js';
31
+ export * from './utils/BaseObserver.js';
32
+ export * from './utils/DataStream.js';
33
+ export * from './utils/parseQuery.js';
34
+ export * from './types/types.js';
package/lib/index.js CHANGED
@@ -1,35 +1,34 @@
1
- export * from './client/AbstractPowerSyncDatabase';
2
- export * from './client/AbstractPowerSyncOpenFactory';
3
- export * from './client/SQLOpenFactory';
4
- export * from './client/connection/PowerSyncBackendConnector';
5
- export * from './client/connection/PowerSyncCredentials';
6
- export * from './client/sync/bucket/BucketStorageAdapter';
7
- export { UpdateType, CrudEntry } from './client/sync/bucket/CrudEntry';
8
- export * from './client/sync/bucket/SqliteBucketStorage';
9
- export * from './client/sync/bucket/CrudBatch';
10
- export * from './client/sync/bucket/CrudTransaction';
11
- export * from './client/sync/bucket/SyncDataBatch';
12
- export * from './client/sync/bucket/SyncDataBucket';
13
- export * from './client/sync/bucket/OpType';
14
- export * from './client/sync/bucket/OplogEntry';
15
- export * from './client/sync/stream/AbstractRemote';
16
- export * from './client/sync/stream/AbstractStreamingSyncImplementation';
17
- export * from './client/sync/stream/streaming-sync-types';
18
- export { MAX_OP_ID } from './client/constants';
19
- export * from './db/crud/SyncStatus';
20
- export * from './db/crud/UploadQueueStatus';
21
- export * from './db/schema/Schema';
22
- export * from './db/schema/Table';
23
- export * from './db/schema/Index';
24
- export * from './db/schema/IndexedColumn';
25
- export * from './db/crud/SyncStatus';
26
- export * from './db/crud/UploadQueueStatus';
27
- export * from './db/DBAdapter';
28
- export * from './db/Column';
29
- export * from './db/schema/TableV2';
30
- export * from './utils/AbortOperation';
31
- export * from './utils/BaseObserver';
32
- export * from './utils/DataStream';
33
- export * from './utils/parseQuery';
34
- export * from './types/types';
35
- //# sourceMappingURL=index.js.map
1
+ export * from './client/AbstractPowerSyncDatabase.js';
2
+ export * from './client/AbstractPowerSyncOpenFactory.js';
3
+ export * from './client/SQLOpenFactory.js';
4
+ export * from './client/connection/PowerSyncBackendConnector.js';
5
+ export * from './client/connection/PowerSyncCredentials.js';
6
+ export * from './client/sync/bucket/BucketStorageAdapter.js';
7
+ export { UpdateType, CrudEntry } from './client/sync/bucket/CrudEntry.js';
8
+ export * from './client/sync/bucket/SqliteBucketStorage.js';
9
+ export * from './client/sync/bucket/CrudBatch.js';
10
+ export * from './client/sync/bucket/CrudTransaction.js';
11
+ export * from './client/sync/bucket/SyncDataBatch.js';
12
+ export * from './client/sync/bucket/SyncDataBucket.js';
13
+ export * from './client/sync/bucket/OpType.js';
14
+ export * from './client/sync/bucket/OplogEntry.js';
15
+ export * from './client/sync/stream/AbstractRemote.js';
16
+ export * from './client/sync/stream/AbstractStreamingSyncImplementation.js';
17
+ export * from './client/sync/stream/streaming-sync-types.js';
18
+ export { MAX_OP_ID } from './client/constants.js';
19
+ export * from './db/crud/SyncStatus.js';
20
+ export * from './db/crud/UploadQueueStatus.js';
21
+ export * from './db/schema/Schema.js';
22
+ export * from './db/schema/Table.js';
23
+ export * from './db/schema/Index.js';
24
+ export * from './db/schema/IndexedColumn.js';
25
+ export * from './db/schema/Column.js';
26
+ export * from './db/schema/TableV2.js';
27
+ export * from './db/crud/SyncStatus.js';
28
+ export * from './db/crud/UploadQueueStatus.js';
29
+ export * from './db/DBAdapter.js';
30
+ export * from './utils/AbortOperation.js';
31
+ export * from './utils/BaseObserver.js';
32
+ export * from './utils/DataStream.js';
33
+ export * from './utils/parseQuery.js';
34
+ export * from './types/types.js';
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -16,4 +16,3 @@ export class AbortOperation extends Error {
16
16
  }
17
17
  }
18
18
  }
19
- //# sourceMappingURL=AbortOperation.js.map
@@ -21,4 +21,3 @@ export class BaseObserver {
21
21
  }
22
22
  }
23
23
  }
24
- //# sourceMappingURL=BaseObserver.js.map
@@ -48,4 +48,3 @@ export class ControlledExecutor {
48
48
  }
49
49
  }
50
50
  }
51
- //# sourceMappingURL=ControlledExecutor.js.map
@@ -1,5 +1,5 @@
1
1
  import { ILogger } from 'js-logger';
2
- import { BaseListener, BaseObserver } from './BaseObserver';
2
+ import { BaseListener, BaseObserver } from './BaseObserver.js';
3
3
  export type DataStreamOptions = {
4
4
  /**
5
5
  * Close the stream if any consumer throws an error
@@ -1,5 +1,5 @@
1
1
  import Logger from 'js-logger';
2
- import { BaseObserver } from './BaseObserver';
2
+ import { BaseObserver } from './BaseObserver.js';
3
3
  export const DEFAULT_PRESSURE_LIMITS = {
4
4
  highWater: 10,
5
5
  lowWater: 0
@@ -160,4 +160,3 @@ export class DataStream extends BaseObserver {
160
160
  }
161
161
  }
162
162
  }
163
- //# sourceMappingURL=DataStream.js.map
@@ -26,4 +26,3 @@ export async function mutexRunExclusive(mutex, callback, options) {
26
26
  });
27
27
  });
28
28
  }
29
- //# sourceMappingURL=mutex.js.map
@@ -1,4 +1,4 @@
1
- import type { CompilableQuery } from '../types/types';
1
+ import type { CompilableQuery } from '../types/types.js';
2
2
  export interface ParsedQuery {
3
3
  sqlStatement: string;
4
4
  parameters: any[];
@@ -14,4 +14,3 @@ export const parseQuery = (query, parameters) => {
14
14
  }
15
15
  return { sqlStatement, parameters: parameters };
16
16
  };
17
- //# sourceMappingURL=parseQuery.js.map