11import { once } from 'node:events' ;
2+ import { readFileSync } from 'node:fs' ;
3+ import { dirname , join } from 'node:path' ;
24import repl_factory from 'node:repl' ;
5+ import { fileURLToPath } from 'node:url' ;
36import { Worker } from 'node:worker_threads' ;
47
58import {
@@ -10,10 +13,9 @@ import {
1013 SyncStreamConnectionMethod
1114} from '@powersync/node' ;
1215import { exit } from 'node:process' ;
16+ import { WorkerOpener } from 'node_modules/@powersync/node/src/db/options.js' ;
1317import { AppSchema , DemoConnector } from './powersync.js' ;
1418import { enableUncidiDiagnostics } from './UndiciDiagnostics.js' ;
15- import { WorkerOpener } from 'node_modules/@powersync/node/src/db/options.js' ;
16- import { LockContext } from 'node_modules/@powersync/node/dist/bundle.cjs' ;
1719
1820const main = async ( ) => {
1921 const baseLogger = createBaseLogger ( ) ;
@@ -60,9 +62,19 @@ const main = async () => {
6062 } ) ;
6163 console . log ( await db . get ( 'SELECT powersync_rs_version();' ) ) ;
6264
65+ // Read package version for metadata
66+ const __filename = fileURLToPath ( import . meta. url ) ;
67+ const __dirname = dirname ( __filename ) ;
68+ const packageJsonPath = join ( __dirname , '..' , 'package.json' ) ;
69+ const packageJson = JSON . parse ( readFileSync ( packageJsonPath , 'utf-8' ) ) ;
70+ const packageVersion = packageJson . version ;
71+
6372 await db . connect ( new DemoConnector ( ) , {
6473 connectionMethod : SyncStreamConnectionMethod . WEB_SOCKET ,
65- clientImplementation : SyncClientImplementation . RUST
74+ clientImplementation : SyncClientImplementation . RUST ,
75+ appMetadata : {
76+ package_version : packageVersion
77+ }
6678 } ) ;
6779 // Example using a proxy agent for more control over the connection:
6880 // const proxyAgent = new (await import('undici')).ProxyAgent({
0 commit comments