Skip to content

FM-PS-LYNX-014 T3: replace callNative overloads with NativeSql - #41

Merged
darekaze merged 1 commit into
mainfrom
drkz/fm-ps-lynx-014-t3-native-sql-721c
Sep 10, 2026
Merged

darekaze merged 1 commit into
mainfrom
drkz/fm-ps-lynx-014-t3-native-sql-721c

Conversation

@djwok

@djwok djwok commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Implements T3 only of FM-PS-LYNX-014 / #34 on current main.

Replaces the four callNative overloads + switch + SAFETY casts with one nativeSql value: promise-returning functions derived from NativePowerSyncModule, each built on withNativeCallback. ADR-0001 public SQL RPC wire (callback open / close / execute / executeBatch) is unchanged. Fake Native Module tests still drive the callback module.

Resulting interface

type NativeSqlFn<T> = T extends (...args: [...infer Args, NativeCallback]) => void
  ? (...args: Args) => Promise<NativeOkEnvelope>
  : never;

export type NativeSql = {
  readonly [K in keyof NativePowerSyncModule]: NativeSqlFn<NativePowerSyncModule[K]>;
};

export const nativeSql: NativeSql = {
  open(payload): Promise<NativeOkEnvelope>;
  close(dbId): Promise<NativeOkEnvelope>;
  execute(dbId, sql, params): Promise<NativeOkEnvelope>;
  executeBatch(dbId, sql, params): Promise<NativeOkEnvelope>;
};

Callers: LynxConnection (execute / executeBatch / close) and LynxDBAdapter.openConnection (open).

Deleted

  • Four callNative overloads + implementation signature
  • switch (method) dispatcher
  • Four SAFETY casts (as OpenPayload, as string, as BindValues, as BindValueRows)

Untouched: PowerSyncDatabase, HTTP transport, NativeSyncHttp, host helper, native Android/iOS, policy/UTF-8/build.

Tests

  • Existing fake-module adapter + host tests now call nativeSql.*
  • New: all four ops go through callback RPC
  • New: missing NativePowerSyncModule throws

Verification

pnpm typecheck, pnpm lint, and pnpm test (108 passing) are green on this revision.

Paste-ready note for #34

Could not comment on #34 from this environment (issue API 403 / not resolvable). Paste:

T3 is up: callNative overloads/switch/SAFETY casts are gone. Adapter SQL now uses nativeSql — a mapped NativeSql of promise functions over withNativeCallback. Wire contract and fake Native Module tests unchanged. PR: #41

Closes the T3 slice of #34 only.

Open in Web Open in Cursor 

Map NativePowerSyncModule to a nativeSql object of promise functions
built on withNativeCallback. Drops the four overloads, switch, and
SAFETY casts. ADR-0001 callback wire is unchanged.

Co-authored-by: 達達 <djwok@users.noreply.github.com>
@darekaze
darekaze merged commit 7849bf7 into main Sep 10, 2026
1 check passed
darekaze added a commit that referenced this pull request Sep 10, 2026
…4cd2

FM-PS-LYNX-015: land #34 integrate tip (#41–#47) onto main per captain.
@darekaze
darekaze deleted the drkz/fm-ps-lynx-014-t3-native-sql-721c branch September 10, 2026 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants