@rivetkit/rivetkit-native 0.0.0-pr.4673.028a93e → 0.0.0-pr.4673.2953c20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -4,54 +4,58 @@
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
6
  export interface JsBindParam {
7
- kind: string;
8
- intValue?: number;
9
- floatValue?: number;
10
- textValue?: string;
11
- blobValue?: Buffer;
7
+ kind: string
8
+ intValue?: number
9
+ floatValue?: number
10
+ textValue?: string
11
+ blobValue?: Buffer
12
12
  }
13
13
  export interface ExecuteResult {
14
- changes: number;
14
+ changes: number
15
15
  }
16
16
  export interface QueryResult {
17
- columns: Array<string>;
18
- rows: Array<Array<any>>;
17
+ columns: Array<string>
18
+ rows: Array<Array<any>>
19
+ }
20
+ export interface JsSqliteVfsMetrics {
21
+ requestBuildNs: number
22
+ serializeNs: number
23
+ transportNs: number
24
+ stateUpdateNs: number
25
+ totalNs: number
26
+ commitCount: number
19
27
  }
20
28
  /** Open a native SQLite database backed by the envoy's KV channel. */
21
- export declare function openDatabaseFromEnvoy(
22
- jsHandle: JsEnvoyHandle,
23
- actorId: string,
24
- preloadedEntries?: Array<JsKvEntry> | undefined | null,
25
- ): Promise<JsNativeDatabase>;
29
+ export declare function openDatabaseFromEnvoy(jsHandle: JsEnvoyHandle, actorId: string, preloadedEntries?: Array<JsKvEntry> | undefined | null): Promise<JsNativeDatabase>
26
30
  /** Configuration for starting the native envoy client. */
27
31
  export interface JsEnvoyConfig {
28
- endpoint: string;
29
- token: string;
30
- namespace: string;
31
- poolName: string;
32
- version: number;
33
- metadata?: any;
34
- notGlobal: boolean;
35
- /**
36
- * Log level for the Rust tracing subscriber (e.g. "trace", "debug", "info", "warn", "error").
37
- * Falls back to RIVET_LOG_LEVEL, then LOG_LEVEL, then RUST_LOG env vars. Defaults to "warn".
38
- */
39
- logLevel?: string;
32
+ endpoint: string
33
+ token: string
34
+ namespace: string
35
+ poolName: string
36
+ version: number
37
+ metadata?: any
38
+ notGlobal: boolean
39
+ /**
40
+ * Log level for the Rust tracing subscriber (e.g. "trace", "debug", "info", "warn", "error").
41
+ * Falls back to RIVET_LOG_LEVEL, then LOG_LEVEL, then RUST_LOG env vars. Defaults to "warn".
42
+ */
43
+ logLevel?: string
40
44
  }
41
45
  /** Options for KV list operations. */
42
46
  export interface JsKvListOptions {
43
- reverse?: boolean;
44
- limit?: number;
47
+ reverse?: boolean
48
+ limit?: number
45
49
  }
46
50
  /** A key-value entry returned from KV list operations. */
47
51
  export interface JsKvEntry {
48
- key: Buffer;
49
- value: Buffer;
52
+ key: Buffer
53
+ value: Buffer
50
54
  }
51
55
  /** A single hibernating request entry. */
52
56
  export interface HibernatingRequestEntry {
53
- gatewayId: Buffer;
54
- requestId: Buffer;
57
+ gatewayId: Buffer
58
+ requestId: Buffer
55
59
  }
56
60
  /**
57
61
  * Start the native envoy client synchronously.
@@ -59,93 +63,40 @@ export interface HibernatingRequestEntry {
59
63
  * Returns a handle immediately. The caller must call `await handle.started()`
60
64
  * to wait for the connection to be ready.
61
65
  */
62
- export declare function startEnvoySyncJs(
63
- config: JsEnvoyConfig,
64
- eventCallback: (event: any) => void,
65
- ): JsEnvoyHandle;
66
+ export declare function startEnvoySyncJs(config: JsEnvoyConfig, eventCallback: (event: any) => void): JsEnvoyHandle
66
67
  /** Start the native envoy client asynchronously. */
67
- export declare function startEnvoyJs(
68
- config: JsEnvoyConfig,
69
- eventCallback: (event: any) => void,
70
- ): JsEnvoyHandle;
71
- /** Native SQLite database handle exposed to JavaScript. */
68
+ export declare function startEnvoyJs(config: JsEnvoyConfig, eventCallback: (event: any) => void): JsEnvoyHandle
72
69
  export declare class JsNativeDatabase {
73
- takeLastKvError(): string | null;
74
- run(
75
- sql: string,
76
- params?: Array<JsBindParam> | undefined | null,
77
- ): Promise<ExecuteResult>;
78
- query(
79
- sql: string,
80
- params?: Array<JsBindParam> | undefined | null,
81
- ): Promise<QueryResult>;
82
- exec(sql: string): Promise<QueryResult>;
83
- close(): Promise<void>;
70
+ takeLastKvError(): string | null
71
+ getSqliteVfsMetrics(): JsSqliteVfsMetrics | null
72
+ run(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<ExecuteResult>
73
+ query(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<QueryResult>
74
+ exec(sql: string): Promise<QueryResult>
75
+ close(): Promise<void>
84
76
  }
85
77
  /** Native envoy handle exposed to JavaScript via N-API. */
86
78
  export declare class JsEnvoyHandle {
87
- started(): Promise<void>;
88
- shutdown(immediate: boolean): void;
89
- get envoyKey(): string;
90
- sleepActor(actorId: string, generation?: number | undefined | null): void;
91
- stopActor(
92
- actorId: string,
93
- generation?: number | undefined | null,
94
- error?: string | undefined | null,
95
- ): void;
96
- destroyActor(actorId: string, generation?: number | undefined | null): void;
97
- setAlarm(
98
- actorId: string,
99
- alarmTs?: number | undefined | null,
100
- generation?: number | undefined | null,
101
- ): void;
102
- kvGet(
103
- actorId: string,
104
- keys: Array<Buffer>,
105
- ): Promise<Array<Buffer | undefined | null>>;
106
- kvPut(actorId: string, entries: Array<JsKvEntry>): Promise<void>;
107
- kvDelete(actorId: string, keys: Array<Buffer>): Promise<void>;
108
- kvDeleteRange(actorId: string, start: Buffer, end: Buffer): Promise<void>;
109
- kvListAll(
110
- actorId: string,
111
- options?: JsKvListOptions | undefined | null,
112
- ): Promise<Array<JsKvEntry>>;
113
- kvListRange(
114
- actorId: string,
115
- start: Buffer,
116
- end: Buffer,
117
- exclusive?: boolean | undefined | null,
118
- options?: JsKvListOptions | undefined | null,
119
- ): Promise<Array<JsKvEntry>>;
120
- kvListPrefix(
121
- actorId: string,
122
- prefix: Buffer,
123
- options?: JsKvListOptions | undefined | null,
124
- ): Promise<Array<JsKvEntry>>;
125
- kvDrop(actorId: string): Promise<void>;
126
- restoreHibernatingRequests(
127
- actorId: string,
128
- requests: Array<HibernatingRequestEntry>,
129
- ): void;
130
- sendHibernatableWebSocketMessageAck(
131
- gatewayId: Buffer,
132
- requestId: Buffer,
133
- clientMessageIndex: number,
134
- ): void;
135
- /** Send a message on an open WebSocket connection identified by messageIdHex. */
136
- sendWsMessage(
137
- gatewayId: Buffer,
138
- requestId: Buffer,
139
- data: Buffer,
140
- binary: boolean,
141
- ): Promise<void>;
142
- /** Close an open WebSocket connection. */
143
- closeWebsocket(
144
- gatewayId: Buffer,
145
- requestId: Buffer,
146
- code?: number | undefined | null,
147
- reason?: string | undefined | null,
148
- ): Promise<void>;
149
- startServerless(payload: Buffer): Promise<void>;
150
- respondCallback(responseId: string, data: any): Promise<void>;
79
+ started(): Promise<void>
80
+ shutdown(immediate: boolean): void
81
+ get envoyKey(): string
82
+ sleepActor(actorId: string, generation?: number | undefined | null): void
83
+ stopActor(actorId: string, generation?: number | undefined | null, error?: string | undefined | null): void
84
+ destroyActor(actorId: string, generation?: number | undefined | null): void
85
+ setAlarm(actorId: string, alarmTs?: number | undefined | null, generation?: number | undefined | null): void
86
+ kvGet(actorId: string, keys: Array<Buffer>): Promise<Array<Buffer | undefined | null>>
87
+ kvPut(actorId: string, entries: Array<JsKvEntry>): Promise<void>
88
+ kvDelete(actorId: string, keys: Array<Buffer>): Promise<void>
89
+ kvDeleteRange(actorId: string, start: Buffer, end: Buffer): Promise<void>
90
+ kvListAll(actorId: string, options?: JsKvListOptions | undefined | null): Promise<Array<JsKvEntry>>
91
+ kvListRange(actorId: string, start: Buffer, end: Buffer, exclusive?: boolean | undefined | null, options?: JsKvListOptions | undefined | null): Promise<Array<JsKvEntry>>
92
+ kvListPrefix(actorId: string, prefix: Buffer, options?: JsKvListOptions | undefined | null): Promise<Array<JsKvEntry>>
93
+ kvDrop(actorId: string): Promise<void>
94
+ restoreHibernatingRequests(actorId: string, requests: Array<HibernatingRequestEntry>): void
95
+ sendHibernatableWebSocketMessageAck(gatewayId: Buffer, requestId: Buffer, clientMessageIndex: number): void
96
+ /** Send a message on an open WebSocket connection identified by messageIdHex. */
97
+ sendWsMessage(gatewayId: Buffer, requestId: Buffer, data: Buffer, binary: boolean): Promise<void>
98
+ /** Close an open WebSocket connection. */
99
+ closeWebsocket(gatewayId: Buffer, requestId: Buffer, code?: number | undefined | null, reason?: string | undefined | null): Promise<void>
100
+ startServerless(payload: Buffer): Promise<void>
101
+ respondCallback(responseId: string, data: any): Promise<void>
151
102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivetkit/rivetkit-native",
3
- "version": "0.0.0-pr.4673.028a93e",
3
+ "version": "0.0.0-pr.4673.2953c20",
4
4
  "description": "Native N-API addon for RivetKit providing envoy client and SQLite access",
5
5
  "license": "Apache-2.0",
6
6
  "main": "index.js",
@@ -49,15 +49,15 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@napi-rs/cli": "^2.18.4",
52
- "@rivetkit/engine-envoy-protocol": "0.0.0-pr.4673.028a93e"
52
+ "@rivetkit/engine-envoy-protocol": "0.0.0-pr.4673.2953c20"
53
53
  },
54
54
  "optionalDependencies": {
55
- "@rivetkit/rivetkit-native-darwin-arm64": "0.0.0-pr.4673.028a93e",
56
- "@rivetkit/rivetkit-native-darwin-x64": "0.0.0-pr.4673.028a93e",
57
- "@rivetkit/rivetkit-native-linux-arm64-gnu": "0.0.0-pr.4673.028a93e",
58
- "@rivetkit/rivetkit-native-linux-arm64-musl": "0.0.0-pr.4673.028a93e",
59
- "@rivetkit/rivetkit-native-linux-x64-gnu": "0.0.0-pr.4673.028a93e",
60
- "@rivetkit/rivetkit-native-linux-x64-musl": "0.0.0-pr.4673.028a93e",
61
- "@rivetkit/rivetkit-native-win32-x64-msvc": "0.0.0-pr.4673.028a93e"
55
+ "@rivetkit/rivetkit-native-darwin-arm64": "0.0.0-pr.4673.2953c20",
56
+ "@rivetkit/rivetkit-native-darwin-x64": "0.0.0-pr.4673.2953c20",
57
+ "@rivetkit/rivetkit-native-linux-arm64-gnu": "0.0.0-pr.4673.2953c20",
58
+ "@rivetkit/rivetkit-native-linux-arm64-musl": "0.0.0-pr.4673.2953c20",
59
+ "@rivetkit/rivetkit-native-linux-x64-gnu": "0.0.0-pr.4673.2953c20",
60
+ "@rivetkit/rivetkit-native-linux-x64-musl": "0.0.0-pr.4673.2953c20",
61
+ "@rivetkit/rivetkit-native-win32-x64-msvc": "0.0.0-pr.4673.2953c20"
62
62
  }
63
63
  }
package/wrapper.d.ts CHANGED
@@ -119,6 +119,10 @@ export interface EnvoyConfig {
119
119
  preloadedKv:
120
120
  | import("@rivetkit/engine-envoy-protocol").PreloadedKv
121
121
  | null,
122
+ sqliteSchemaVersion: number,
123
+ sqliteStartupData:
124
+ | import("@rivetkit/engine-envoy-protocol").SqliteStartupData
125
+ | null,
122
126
  ) => Promise<void>;
123
127
  onActorStop: (
124
128
  envoyHandle: EnvoyHandle,
package/wrapper.js CHANGED
@@ -194,6 +194,32 @@ function decodePreloadedKv(preloadedKv) {
194
194
  };
195
195
  }
196
196
 
197
+ function decodeSqliteStartupData(sqliteStartupData) {
198
+ if (!sqliteStartupData) {
199
+ return null;
200
+ }
201
+
202
+ const decodeBytes = (value) => Uint8Array.from(Buffer.from(value, "base64"));
203
+
204
+ return {
205
+ generation: sqliteStartupData.generation,
206
+ meta: {
207
+ schemaVersion: sqliteStartupData.meta.schemaVersion,
208
+ generation: sqliteStartupData.meta.generation,
209
+ headTxid: sqliteStartupData.meta.headTxid,
210
+ materializedTxid: sqliteStartupData.meta.materializedTxid,
211
+ dbSizePages: sqliteStartupData.meta.dbSizePages,
212
+ pageSize: sqliteStartupData.meta.pageSize,
213
+ creationTsMs: sqliteStartupData.meta.creationTsMs,
214
+ maxDeltaBytes: sqliteStartupData.meta.maxDeltaBytes,
215
+ },
216
+ preloadedPages: (sqliteStartupData.preloadedPages || []).map((page) => ({
217
+ pgno: page.pgno,
218
+ bytes: page.bytes ? decodeBytes(page.bytes) : null,
219
+ })),
220
+ };
221
+ }
222
+
197
223
  /**
198
224
  * Route callback envelopes from the native addon to EnvoyConfig callbacks.
199
225
  */
@@ -216,6 +242,8 @@ function handleEvent(event, config, wrappedHandle) {
216
242
  event.generation,
217
243
  actorConfig,
218
244
  decodePreloadedKv(event.preloadedKv),
245
+ event.sqliteSchemaVersion,
246
+ decodeSqliteStartupData(event.sqliteStartupData),
219
247
  ),
220
248
  ).then(
221
249
  async () => {