Skip to content

Commit ab4f132

Browse files
update peer dep @op-engineering/op-sqlite with TypeScript augmentation for compatibility
1 parent cd6bc45 commit ab4f132

File tree

5 files changed

+60
-14
lines changed

5 files changed

+60
-14
lines changed

.changeset/short-lamps-vanish.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@effect/sql-sqlite-react-native": minor
3+
---
4+
5+
update op-sqlite for @effect/sql-sqlite-react-native

packages/sql-sqlite-react-native/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@
4848
"devDependencies": {
4949
"@effect/experimental": "workspace:^",
5050
"@effect/sql": "workspace:^",
51-
"@op-engineering/op-sqlite": "7.1.0",
51+
"@op-engineering/op-sqlite": ">=12.0.0",
5252
"effect": "workspace:^"
5353
},
5454
"peerDependencies": {
5555
"@effect/experimental": "workspace:^",
5656
"@effect/sql": "workspace:^",
57-
"@op-engineering/op-sqlite": "7.1.0",
57+
"@op-engineering/op-sqlite": ">=12.0.0",
5858
"effect": "workspace:^"
5959
}
6060
}

packages/sql-sqlite-react-native/src/SqliteClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ export const make = (
117117
try: () => db.executeAsync(sql, params as Array<any>),
118118
catch: (cause) => new SqlError({ cause, message: "Failed to execute statement (async)" })
119119
}),
120-
(result) => result.rows?._array ?? []
120+
(result) => result.rows ?? []
121121
)
122122
}
123123
return Effect.try({
124-
try: () => db.execute(sql, params as Array<any>).rows?._array ?? [],
124+
try: () => db.executeSync(sql, params as Array<any>).rows ?? [],
125125
catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" })
126126
})
127127
})
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Temporary ambient augmentation for `@op-engineering/op-sqlite`.
3+
*
4+
* Why this file exists
5+
* - Under TypeScript `moduleResolution: "NodeNext"`, value exports that come through
6+
* `export * from './functions'` do not show up in the public type definitions unless
7+
* that subpath is explicitly listed in the package `exports` map.
8+
* - In `@op-engineering/[email protected]`, this means `open` (and friends) are
9+
* available at runtime but are not visible to the type system when doing
10+
* `import * as Sqlite from '@op-engineering/op-sqlite'`.
11+
* - Our code calls `Sqlite.open(...)`, which triggers TS2339/TS2305 without this
12+
* augmentation when using NodeNext.
13+
*
14+
* What this does
15+
* - Minimally augments the module to surface the `open` function and a narrow `DB`
16+
* shape that covers only what we use here (close/executeSync/executeAsync).
17+
* - This merges with the library’s existing types; it does not replace them.
18+
*
19+
* Removal plan
20+
* - TODO: Remove this file once upstream publishes a fix that explicitly re‑exports
21+
* these functions in the types entry (see tracking PR below). At that point,
22+
* `Sqlite.open` should type‑check without any local augmentation.
23+
*
24+
* More details
25+
* - Upstream PR: https://github.com/OP-Engineering/op-sqlite/pull/324
26+
*/
27+
28+
declare module "@op-engineering/op-sqlite" {
29+
/** Minimal DB shape needed by this package */
30+
export type DB = {
31+
close(): void
32+
executeSync(query: string, params?: Array<unknown>): { rows?: Array<unknown> }
33+
executeAsync(query: string, params?: Array<unknown>): Promise<{ rows?: Array<unknown> }>
34+
}
35+
36+
/** Open a local sqlite/sqlcipher database */
37+
export function open(options: {
38+
name: string
39+
location?: string
40+
encryptionKey?: string
41+
}): DB
42+
}

pnpm-lock.yaml

Lines changed: 9 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)