Mirror of https://github.com/roostorg/coop github.com/roostorg/coop
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make Kysely work with NoOp data warehouse adapter (#354)

* make kysely work with noop data warehouse adapter

* Update server/storage/dataWarehouse/DataWarehouseFactory.ts

Co-authored-by: Juan Mrad <juansmrad@gmail.com>

* guard against then and symbols

---------

Co-authored-by: Juan Mrad <juansmrad@gmail.com>

authored by

Dom Rettig
Juan Mrad
and committed by
GitHub
dcc9313b f68c741e

+20 -1
+20 -1
server/storage/dataWarehouse/DataWarehouseFactory.ts
··· 27 27 type DataWarehouseProvider as IDataWarehouseProvider, 28 28 type TransactionFunction, 29 29 } from './IDataWarehouse.js'; 30 + import { type Kysely } from 'kysely'; 30 31 import type { 31 32 AnalyticsSchema, 32 33 BulkWriteConfig, ··· 70 71 provider: 'noop'; 71 72 analyticsProvider?: AnalyticsProvider; 72 73 }; 74 + 75 + class NoOpKyselyDialect implements IDataWarehouseDialect { 76 + getKyselyInstance(): Kysely<any> { 77 + // Return a proxy so services can hold a Kysely reference without 78 + // crashing at startup; any attempt to build or execute a query throws. 79 + return new Proxy({} as Kysely<any>, { 80 + get(_target, prop) { 81 + if (prop === 'destroy') return async () => {}; 82 + if (prop === 'then') return undefined; // not thenable 83 + if (typeof prop === 'symbol') return undefined; 84 + return () => { 85 + throw new Error('NoOp dialect: Kysely queries are not supported'); 86 + }; 87 + }, 88 + }); 89 + } 90 + async destroy(): Promise<void> {} 91 + } 73 92 74 93 class WarehouseAdapterBridge implements IDataWarehouse { 75 94 constructor( ··· 225 244 case 'postgresql': 226 245 throw new Error('PostgreSQL Kysely dialect not yet implemented'); 227 246 case 'noop': 228 - throw new Error('NoOp provider does not support Kysely dialect'); 247 + return new NoOpKyselyDialect(); 229 248 default: 230 249 return assertUnreachable( 231 250 config,