@powersync/node 0.8.0 → 0.9.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/README.md CHANGED
@@ -11,9 +11,9 @@ Using this package is not necessary for PowerSync on servers, see [our documenta
11
11
 
12
12
  See a summary of features [here](https://docs.powersync.com/client-sdk-references/node).
13
13
 
14
- ## Alpha Release
14
+ ## Beta Release
15
15
 
16
- The `@powersync/node` package is currently in an Alpha release.
16
+ The `@powersync/node` package is currently in a Beta release.
17
17
 
18
18
  # Installation
19
19
 
@@ -0,0 +1,75 @@
1
+ import { SQLOpenOptions, PowerSyncDatabaseOptions, DBAdapter, SQLOpenFactory, AbstractRemoteOptions, AdditionalConnectionOptions, PowerSyncConnectionOptions, AbstractPowerSyncDatabase, PowerSyncDatabaseOptionsWithSettings, BucketStorageAdapter, PowerSyncBackendConnector, AbstractStreamingSyncImplementation } from '@powersync/common';
2
+ export * from '@powersync/common';
3
+ import { Dispatcher } from 'undici';
4
+ import { Worker } from 'node:worker_threads';
5
+
6
+ type NodeCustomConnectionOptions = {
7
+ /**
8
+ * Optional custom dispatcher for HTTP or WEB_SOCKET connections.
9
+ *
10
+ * This can be used to customize proxy usage (using undici ProxyAgent),
11
+ * or other connection options.
12
+ */
13
+ dispatcher?: Dispatcher;
14
+ };
15
+
16
+ type WorkerOpener = (...args: ConstructorParameters<typeof Worker>) => InstanceType<typeof Worker>;
17
+ /**
18
+ * The {@link SQLOpenOptions} available across all PowerSync SDKs for JavaScript extended with
19
+ * Node.JS-specific options.
20
+ */
21
+ interface NodeSQLOpenOptions extends SQLOpenOptions {
22
+ /**
23
+ * The Node.JS SDK will use one worker to run writing queries and additional workers to run reads.
24
+ * This option controls how many workers to use for reads.
25
+ */
26
+ readWorkerCount?: number;
27
+ /**
28
+ * A callback to allow customizing how the Node.JS SDK loads workers. This can be customized to
29
+ * use workers at different paths.
30
+ *
31
+ * @param args The arguments that would otherwise be passed to the {@link Worker} constructor.
32
+ * @returns the resolved worker.
33
+ */
34
+ openWorker?: WorkerOpener;
35
+ }
36
+
37
+ type NodePowerSyncDatabaseOptions = PowerSyncDatabaseOptions & {
38
+ database: DBAdapter | SQLOpenFactory | NodeSQLOpenOptions;
39
+ /**
40
+ * Options to override how the SDK will connect to the sync service.
41
+ *
42
+ * This option is intended to be used for internal tests.
43
+ */
44
+ remoteOptions?: Partial<AbstractRemoteOptions>;
45
+ };
46
+ type NodeAdditionalConnectionOptions = AdditionalConnectionOptions & NodeCustomConnectionOptions;
47
+ type NodePowerSyncConnectionOptions = PowerSyncConnectionOptions & NodeAdditionalConnectionOptions;
48
+ /**
49
+ * A PowerSync database which provides SQLite functionality
50
+ * which is automatically synced.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * export const db = new PowerSyncDatabase({
55
+ * schema: AppSchema,
56
+ * database: {
57
+ * dbFilename: 'example.db'
58
+ * }
59
+ * });
60
+ * ```
61
+ */
62
+ declare class PowerSyncDatabase extends AbstractPowerSyncDatabase {
63
+ constructor(options: NodePowerSyncDatabaseOptions);
64
+ _initialize(): Promise<void>;
65
+ /**
66
+ * Opens a DBAdapter using better-sqlite3 as the default SQLite open factory.
67
+ */
68
+ protected openDBAdapter(options: PowerSyncDatabaseOptionsWithSettings): DBAdapter;
69
+ protected generateBucketStorageAdapter(): BucketStorageAdapter;
70
+ connect(connector: PowerSyncBackendConnector, options?: PowerSyncConnectionOptions & NodeCustomConnectionOptions): Promise<void>;
71
+ protected generateSyncStreamImplementation(connector: PowerSyncBackendConnector, options: NodeAdditionalConnectionOptions): AbstractStreamingSyncImplementation;
72
+ }
73
+
74
+ export { PowerSyncDatabase };
75
+ export type { NodeAdditionalConnectionOptions, NodePowerSyncConnectionOptions, NodePowerSyncDatabaseOptions };
@@ -0,0 +1,12 @@
1
+ interface PowerSyncWorkerOptions {
2
+ /**
3
+ * A function responsible for finding the powersync DLL/so/dylib file.
4
+ *
5
+ * @returns The absolute path of the PowerSync SQLite core extensions library.
6
+ */
7
+ extensionPath: () => string;
8
+ }
9
+ declare function startPowerSyncWorker(options?: Partial<PowerSyncWorkerOptions>): void;
10
+
11
+ export { startPowerSyncWorker };
12
+ export type { PowerSyncWorkerOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powersync/node",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -15,14 +15,24 @@
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
18
- "import": "./lib/index.js",
19
- "require": "./dist/bundle.cjs",
20
- "types": "./lib/index.d.ts"
18
+ "import": {
19
+ "types": "./lib/index.d.ts",
20
+ "default": "./lib/index.js"
21
+ },
22
+ "require": {
23
+ "types": "./dist/bundle.d.cts",
24
+ "default": "./dist/bundle.cjs"
25
+ }
21
26
  },
22
27
  "./worker.js": {
23
- "import": "./lib/worker.js",
24
- "require": "./dist/worker.cjs",
25
- "types": "./lib/worker.d.ts"
28
+ "import": {
29
+ "types": "./lib/worker.d.ts",
30
+ "default": "./lib/worker.js"
31
+ },
32
+ "require": {
33
+ "types": "./dist/worker.d.cts",
34
+ "default": "./dist/worker.cjs"
35
+ }
26
36
  },
27
37
  "./package.json": "./package.json"
28
38
  },
@@ -37,7 +47,7 @@
37
47
  },
38
48
  "homepage": "https://docs.powersync.com/",
39
49
  "peerDependencies": {
40
- "@powersync/common": "^1.34.0"
50
+ "@powersync/common": "^1.36.0"
41
51
  },
42
52
  "dependencies": {
43
53
  "@powersync/better-sqlite3": "^0.2.0",
@@ -45,15 +55,15 @@
45
55
  "bson": "^6.6.0",
46
56
  "comlink": "^4.4.2",
47
57
  "undici": "^7.11.0",
48
- "@powersync/common": "1.34.0"
58
+ "@powersync/common": "1.36.0"
49
59
  },
50
60
  "devDependencies": {
51
61
  "@types/async-lock": "^1.4.0",
52
62
  "drizzle-orm": "^0.35.2",
53
63
  "rollup": "4.14.3",
54
64
  "typescript": "^5.5.3",
55
- "vitest": "^3.0.5",
56
- "@powersync/drizzle-driver": "0.4.0"
65
+ "vitest": "^3.2.4",
66
+ "@powersync/drizzle-driver": "0.5.0"
57
67
  },
58
68
  "keywords": [
59
69
  "data sync",
@@ -66,8 +76,9 @@
66
76
  "install": "node download_core.js",
67
77
  "build": "tsc -b && rollup --config",
68
78
  "build:prod": "tsc -b --sourceMap false && rollup --config",
69
- "clean": "rm -rf lib dist tsconfig.tsbuildinfo dist",
79
+ "clean": "rm -rf lib dist tsconfig.tsbuildinfo",
70
80
  "watch": "tsc -b -w",
71
- "test": "vitest"
81
+ "test": "vitest",
82
+ "test:exports": "attw --pack . --ignore-rules no-resolution"
72
83
  }
73
84
  }