Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/short-lamps-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/sql-sqlite-react-native": minor
---

update op-sqlite for @effect/sql-sqlite-react-native
4 changes: 2 additions & 2 deletions packages/sql-sqlite-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@
"devDependencies": {
"@effect/experimental": "workspace:^",
"@effect/sql": "workspace:^",
"@op-engineering/op-sqlite": "7.1.0",
"@op-engineering/op-sqlite": ">=12.0.0",
"effect": "workspace:^"
},
"peerDependencies": {
"@effect/experimental": "workspace:^",
"@effect/sql": "workspace:^",
"@op-engineering/op-sqlite": "7.1.0",
"@op-engineering/op-sqlite": ">=12.0.0",
"effect": "workspace:^"
}
}
44 changes: 42 additions & 2 deletions packages/sql-sqlite-react-native/src/SqliteClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,46 @@ import * as Scope from "effect/Scope"

const ATTR_DB_SYSTEM_NAME = "db.system.name"

/**
* Temporary ambient augmentation for `@op-engineering/op-sqlite`.
*
* Why this file exists
* - Under TypeScript `moduleResolution: "NodeNext"`, value exports that come through
* `export * from './functions'` do not show up in the public type definitions unless
* that subpath is explicitly listed in the package `exports` map.
* - In `@op-engineering/[email protected]`, this means `open` (and friends) are
* available at runtime but are not visible to the type system when doing
* `import * as Sqlite from '@op-engineering/op-sqlite'`.
* - Our code calls `Sqlite.open(...)`, which triggers TS2339/TS2305 without this
* augmentation when using NodeNext.
*
* What this does
* - Minimally augments the module to surface the `open` function and a narrow `OPDB`
* shape that covers only what we use here (close/executeSync/executeAsync).
* - This merges with the library’s existing types; it does not replace them.
*
* Removal plan
* - TODO: Remove this file once upstream publishes a fix that explicitly re‑exports
* these functions in the types entry (see tracking PR below). At that point,
* `Sqlite.open` should type‑check without any local augmentation.
*
* More details
* - Upstream PR: https://github.com/OP-Engineering/op-sqlite/pull/324
*/
declare module "@op-engineering/op-sqlite" {
export type OPDB = {
close(): void
executeSync(query: string, params?: Array<unknown>): { rows?: Array<unknown> }
executeAsync(query: string, params?: Array<unknown>): Promise<{ rows?: Array<unknown> }>
}

export function open(options: {
name: string
location?: string
encryptionKey?: string
}): OPDB
}
Comment on lines +48 to +60
Copy link
Contributor Author

@subtleGradient subtleGradient Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ DONE: move temporary declare module into packages/sql-sqlite-react-native/src/SqliteClient.ts
✅ DONE: Land upstream PR: OP-Engineering/op-sqlite#324
✅ DONE: Release @op-engineering/op-sqlite@^15.0.4 https://github.com/OP-Engineering/op-sqlite/releases/tag/15.0.4
☑️ TODO: Update the dev deps to @op-engineering/op-sqlite@^15.0.4 and drop the declare module (not blocking this PR)


/**
* @category type ids
* @since 1.0.0
Expand Down Expand Up @@ -117,11 +157,11 @@ export const make = (
try: () => db.executeAsync(sql, params as Array<any>),
catch: (cause) => new SqlError({ cause, message: "Failed to execute statement (async)" })
}),
(result) => result.rows?._array ?? []
(result) => result.rows ?? []
)
}
return Effect.try({
try: () => db.execute(sql, params as Array<any>).rows?._array ?? [],
try: () => db.executeSync(sql, params as Array<any>).rows ?? [],
catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" })
})
})
Expand Down
19 changes: 9 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.