@rivetkit/rivetkit-napi 0.0.0-main.17e6a1a → 0.0.0-main.3118df2
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 +88 -6
- package/index.js +4 -1
- package/package.json +10 -10
- package/scripts/build.mjs +8 -0
package/index.d.ts
CHANGED
|
@@ -23,10 +23,16 @@ export interface StateDeltaPayload {
|
|
|
23
23
|
connHibernation: Array<StateDeltaConnHibernationEntry>
|
|
24
24
|
connHibernationRemoved: Array<string>
|
|
25
25
|
}
|
|
26
|
+
export interface WorkflowKvWritePayload {
|
|
27
|
+
key: Buffer
|
|
28
|
+
value: Buffer
|
|
29
|
+
}
|
|
26
30
|
export interface JsRequestSaveOpts {
|
|
27
31
|
immediate?: boolean
|
|
28
32
|
maxWaitMs?: number
|
|
29
33
|
}
|
|
34
|
+
export declare function decodeInspectorRequest(bytes: Buffer, advertisedVersion: number): Buffer
|
|
35
|
+
export declare function encodeInspectorResponse(bytes: Buffer, targetVersion: number): Buffer
|
|
30
36
|
export interface JsInspectorSnapshot {
|
|
31
37
|
stateRevision: number
|
|
32
38
|
connectionsRevision: number
|
|
@@ -35,6 +41,9 @@ export interface JsInspectorSnapshot {
|
|
|
35
41
|
queueSize: number
|
|
36
42
|
connectedClients: number
|
|
37
43
|
}
|
|
44
|
+
export interface JsActorRuntimeSocketEndpointInfo {
|
|
45
|
+
path: string
|
|
46
|
+
}
|
|
38
47
|
export interface JsHttpResponse {
|
|
39
48
|
status?: number
|
|
40
49
|
headers?: Record<string, string>
|
|
@@ -47,10 +56,32 @@ export interface JsQueueSendResult {
|
|
|
47
56
|
export interface JsActionDefinition {
|
|
48
57
|
name: string
|
|
49
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* One entry in the actor's `inspector.tabs[]` declaration. Either a
|
|
61
|
+
* custom-tab descriptor (id + label + source dir) or a built-in modifier
|
|
62
|
+
* (id + hidden=true). Validation already happened on the TS side; the
|
|
63
|
+
* runtime just splits the discriminator.
|
|
64
|
+
*/
|
|
65
|
+
export interface JsInspectorTabEntry {
|
|
66
|
+
id: string
|
|
67
|
+
/** Required for custom entries; omitted for HideBuiltin. */
|
|
68
|
+
label?: string
|
|
69
|
+
/** Required for custom entries — absolute path to the source directory. */
|
|
70
|
+
source?: string
|
|
71
|
+
/**
|
|
72
|
+
* Optional icon id for custom entries. Dashboard maps strings to
|
|
73
|
+
* glyphs; unknown ids fall back to a generic icon.
|
|
74
|
+
*/
|
|
75
|
+
icon?: string
|
|
76
|
+
/** Set to true for HideBuiltin entries. */
|
|
77
|
+
hidden?: boolean
|
|
78
|
+
}
|
|
50
79
|
export interface JsActorConfig {
|
|
51
80
|
name?: string
|
|
52
81
|
icon?: string
|
|
53
82
|
hasDatabase?: boolean
|
|
83
|
+
remoteSqlite?: boolean
|
|
84
|
+
enableActorRuntimeSocket?: boolean
|
|
54
85
|
hasState?: boolean
|
|
55
86
|
canHibernateWebsocket?: boolean
|
|
56
87
|
stateSaveIntervalMs?: number
|
|
@@ -74,9 +105,8 @@ export interface JsActorConfig {
|
|
|
74
105
|
maxQueueMessageSize?: number
|
|
75
106
|
maxIncomingMessageSize?: number
|
|
76
107
|
maxOutgoingMessageSize?: number
|
|
77
|
-
preloadMaxWorkflowBytes?: number
|
|
78
|
-
preloadMaxConnectionsBytes?: number
|
|
79
108
|
actions?: Array<JsActionDefinition>
|
|
109
|
+
inspectorTabs?: Array<JsInspectorTabEntry>
|
|
80
110
|
}
|
|
81
111
|
export interface JsBindParam {
|
|
82
112
|
kind: string
|
|
@@ -92,6 +122,16 @@ export interface QueryResult {
|
|
|
92
122
|
columns: Array<string>
|
|
93
123
|
rows: Array<Array<any>>
|
|
94
124
|
}
|
|
125
|
+
export interface NativeExecuteResult {
|
|
126
|
+
columns: Array<string>
|
|
127
|
+
rows: Array<Array<any>>
|
|
128
|
+
changes: number
|
|
129
|
+
lastInsertRowId?: number
|
|
130
|
+
}
|
|
131
|
+
export interface JsSqliteBatchStatement {
|
|
132
|
+
sql: string
|
|
133
|
+
params?: Array<JsBindParam>
|
|
134
|
+
}
|
|
95
135
|
export interface JsSqliteVfsMetrics {
|
|
96
136
|
requestBuildNs: number
|
|
97
137
|
serializeNs: number
|
|
@@ -99,6 +139,11 @@ export interface JsSqliteVfsMetrics {
|
|
|
99
139
|
stateUpdateNs: number
|
|
100
140
|
totalNs: number
|
|
101
141
|
commitCount: number
|
|
142
|
+
pageCacheEntries: number
|
|
143
|
+
pageCacheWeightedSize: number
|
|
144
|
+
pageCacheCapacityPages: number
|
|
145
|
+
writeBufferDirtyPages: number
|
|
146
|
+
dbSizePages: number
|
|
102
147
|
}
|
|
103
148
|
export interface JsQueueNextOptions {
|
|
104
149
|
names?: Array<string>
|
|
@@ -143,6 +188,8 @@ export interface JsServeConfig {
|
|
|
143
188
|
namespace: string
|
|
144
189
|
poolName: string
|
|
145
190
|
engineBinaryPath?: string
|
|
191
|
+
engineHost?: string
|
|
192
|
+
enginePort?: number
|
|
146
193
|
handleInspectorHttpInRuntime?: boolean
|
|
147
194
|
serverlessBasePath?: string
|
|
148
195
|
serverlessPackageVersion: string
|
|
@@ -152,6 +199,16 @@ export interface JsServeConfig {
|
|
|
152
199
|
serverlessValidateEndpoint: boolean
|
|
153
200
|
serverlessMaxStartPayloadBytes: number
|
|
154
201
|
}
|
|
202
|
+
export interface JsListenerConfig {
|
|
203
|
+
/** Host to bind. Defaults to `0.0.0.0` when not provided. */
|
|
204
|
+
host?: string
|
|
205
|
+
port: number
|
|
206
|
+
/**
|
|
207
|
+
* Optional static file root mounted as a fallback below the framework
|
|
208
|
+
* routes.
|
|
209
|
+
*/
|
|
210
|
+
publicDir?: string
|
|
211
|
+
}
|
|
155
212
|
export interface JsServerlessRequest {
|
|
156
213
|
method: string
|
|
157
214
|
url: string
|
|
@@ -162,6 +219,11 @@ export interface JsServerlessResponseHead {
|
|
|
162
219
|
status: number
|
|
163
220
|
headers: Record<string, string>
|
|
164
221
|
}
|
|
222
|
+
export interface JsRegistryRouteResponse {
|
|
223
|
+
status: number
|
|
224
|
+
headers: Record<string, string>
|
|
225
|
+
body: Buffer
|
|
226
|
+
}
|
|
165
227
|
export interface JsServerlessStreamError {
|
|
166
228
|
group: string
|
|
167
229
|
code: string
|
|
@@ -179,12 +241,12 @@ export interface JsKvEntry {
|
|
|
179
241
|
}
|
|
180
242
|
/** N-API wrapper around `rivetkit-core::ActorContext`. */
|
|
181
243
|
export declare class ActorContext {
|
|
182
|
-
constructor(actorId: string, name: string, region: string)
|
|
183
244
|
state(): Buffer
|
|
184
245
|
beginOnStateChange(): void
|
|
185
246
|
endOnStateChange(): void
|
|
186
247
|
kv(): Kv
|
|
187
248
|
sql(): JsNativeDatabase
|
|
249
|
+
provisionActorRuntimeSocket(): Promise<JsActorRuntimeSocketEndpointInfo>
|
|
188
250
|
schedule(): Schedule
|
|
189
251
|
queue(): Queue
|
|
190
252
|
setAlarm(timestampMs?: number | undefined | null): void
|
|
@@ -199,6 +261,7 @@ export declare class ActorContext {
|
|
|
199
261
|
takePendingHibernationChanges(): Array<string>
|
|
200
262
|
dirtyHibernatableConns(): Array<ConnHandle>
|
|
201
263
|
saveState(payload: StateDeltaPayload): Promise<void>
|
|
264
|
+
saveStateAndWorkflowBatch(writes: Array<WorkflowKvWritePayload>): Promise<void>
|
|
202
265
|
actorId(): string
|
|
203
266
|
name(): string
|
|
204
267
|
key(): Array<JsActorKeySegment>
|
|
@@ -212,6 +275,9 @@ export declare class ActorContext {
|
|
|
212
275
|
aborted(): boolean
|
|
213
276
|
runHandlerActive(): boolean
|
|
214
277
|
restartRunHandler(): void
|
|
278
|
+
beginKeepAwake(): number
|
|
279
|
+
endKeepAwake(regionId: number): void
|
|
280
|
+
keepAwake(promise: Promise<any>): void
|
|
215
281
|
beginWebsocketCallback(): number
|
|
216
282
|
endWebsocketCallback(regionId: number): void
|
|
217
283
|
abortSignal(): AbortSignal
|
|
@@ -221,7 +287,8 @@ export declare class ActorContext {
|
|
|
221
287
|
disconnectConns(predicate: (...args: any[]) => any): Promise<void>
|
|
222
288
|
broadcast(name: string, args: Buffer): void
|
|
223
289
|
waitUntil(promise: Promise<any>): void
|
|
224
|
-
|
|
290
|
+
waitForTrackedShutdownWork(): Promise<boolean>
|
|
291
|
+
waitForTrackedShutdownWorkUnbounded(): Promise<void>
|
|
225
292
|
registerTask(promise: Promise<any>): void
|
|
226
293
|
runtimeState(): object
|
|
227
294
|
clearRuntimeState(): void
|
|
@@ -246,11 +313,20 @@ export declare class ConnHandle {
|
|
|
246
313
|
}
|
|
247
314
|
export declare class JsNativeDatabase {
|
|
248
315
|
takeLastKvError(): string | null
|
|
249
|
-
|
|
316
|
+
metrics(): JsSqliteVfsMetrics | null
|
|
250
317
|
run(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<ExecuteResult>
|
|
251
318
|
query(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<QueryResult>
|
|
319
|
+
execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
|
|
320
|
+
executeBatch(statements: Array<JsSqliteBatchStatement>): Promise<Array<NativeExecuteResult>>
|
|
252
321
|
exec(sql: string): Promise<QueryResult>
|
|
253
322
|
close(): Promise<void>
|
|
323
|
+
beginTransaction(timeoutMs?: number | undefined | null): Promise<JsSqliteTransaction>
|
|
324
|
+
}
|
|
325
|
+
export declare class JsSqliteTransaction {
|
|
326
|
+
execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
|
|
327
|
+
exec(sql: string): Promise<QueryResult>
|
|
328
|
+
commit(): Promise<void>
|
|
329
|
+
rollback(): Promise<void>
|
|
254
330
|
}
|
|
255
331
|
export declare class Kv {
|
|
256
332
|
get(key: Buffer): Promise<Buffer | null>
|
|
@@ -268,11 +344,12 @@ export declare class Queue {
|
|
|
268
344
|
next(options?: JsQueueNextOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<QueueMessage | null>
|
|
269
345
|
nextBatch(options?: JsQueueNextBatchOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<Array<QueueMessage>>
|
|
270
346
|
waitForNames(names: Array<string>, options?: JsQueueWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<QueueMessage>
|
|
271
|
-
waitForNamesAvailable(names: Array<string>, options?: JsQueueWaitOptions | undefined | null): Promise<void>
|
|
347
|
+
waitForNamesAvailable(names: Array<string>, options?: JsQueueWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<void>
|
|
272
348
|
enqueueAndWait(name: string, body: Buffer, options?: JsQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<Buffer | null>
|
|
273
349
|
tryNext(options?: JsQueueTryNextOptions | undefined | null): QueueMessage | null
|
|
274
350
|
tryNextBatch(options?: JsQueueTryNextBatchOptions | undefined | null): Array<QueueMessage>
|
|
275
351
|
maxSize(): number
|
|
352
|
+
reset(): Promise<void>
|
|
276
353
|
inspectMessages(): Promise<Array<JsQueueInspectMessage>>
|
|
277
354
|
}
|
|
278
355
|
export declare class QueueMessage {
|
|
@@ -295,6 +372,11 @@ export declare class CoreRegistry {
|
|
|
295
372
|
* separately to avoid re-entrancy.
|
|
296
373
|
*/
|
|
297
374
|
shutdown(): Promise<void>
|
|
375
|
+
actorStopThresholdMs(): Promise<number | null>
|
|
376
|
+
health(): Promise<JsRegistryRouteResponse>
|
|
377
|
+
metadata(): JsRegistryRouteResponse
|
|
378
|
+
metrics(): JsRegistryRouteResponse
|
|
379
|
+
serveListener(listener: JsListenerConfig, config: JsServeConfig): Promise<void>
|
|
298
380
|
handleServerlessRequest(req: JsServerlessRequest, onStreamEvent: (...args: any[]) => any, cancelToken: CancellationToken, config: JsServeConfig): Promise<JsServerlessResponseHead>
|
|
299
381
|
}
|
|
300
382
|
export declare class Schedule {
|
package/index.js
CHANGED
|
@@ -310,13 +310,16 @@ if (!nativeBinding) {
|
|
|
310
310
|
throw new Error(`Failed to load native binding`)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
const { ActorContext, NapiActorFactory, CancellationToken, ConnHandle, JsNativeDatabase, Kv, Queue, QueueMessage, CoreRegistry, Schedule, WebSocket } = nativeBinding
|
|
313
|
+
const { ActorContext, decodeInspectorRequest, encodeInspectorResponse, NapiActorFactory, CancellationToken, ConnHandle, JsNativeDatabase, JsSqliteTransaction, Kv, Queue, QueueMessage, CoreRegistry, Schedule, WebSocket } = nativeBinding
|
|
314
314
|
|
|
315
315
|
module.exports.ActorContext = ActorContext
|
|
316
|
+
module.exports.decodeInspectorRequest = decodeInspectorRequest
|
|
317
|
+
module.exports.encodeInspectorResponse = encodeInspectorResponse
|
|
316
318
|
module.exports.NapiActorFactory = NapiActorFactory
|
|
317
319
|
module.exports.CancellationToken = CancellationToken
|
|
318
320
|
module.exports.ConnHandle = ConnHandle
|
|
319
321
|
module.exports.JsNativeDatabase = JsNativeDatabase
|
|
322
|
+
module.exports.JsSqliteTransaction = JsSqliteTransaction
|
|
320
323
|
module.exports.Kv = Kv
|
|
321
324
|
module.exports.Queue = Queue
|
|
322
325
|
module.exports.QueueMessage = QueueMessage
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivetkit/rivetkit-napi",
|
|
3
|
-
"version": "0.0.0-main.
|
|
3
|
+
"version": "0.0.0-main.3118df2",
|
|
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",
|
|
@@ -39,19 +39,19 @@
|
|
|
39
39
|
"build": "node scripts/build.mjs",
|
|
40
40
|
"build:release": "node scripts/build.mjs --release",
|
|
41
41
|
"build:force": "node scripts/build.mjs --force",
|
|
42
|
-
"build:force:release": "node scripts/build.mjs --force --release"
|
|
42
|
+
"build:force:release": "node scripts/build.mjs --force --release",
|
|
43
|
+
"build:embed": "node scripts/build.mjs"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"@napi-rs/cli": "^2.18.4",
|
|
46
|
-
"@rivetkit/engine-envoy-protocol": "0.0.0-main.
|
|
47
|
+
"@rivetkit/engine-envoy-protocol": "0.0.0-main.3118df2"
|
|
47
48
|
},
|
|
48
49
|
"optionalDependencies": {
|
|
49
|
-
"@rivetkit/rivetkit-napi-darwin-arm64": "0.0.0-main.
|
|
50
|
-
"@rivetkit/rivetkit-napi-darwin-x64": "0.0.0-main.
|
|
51
|
-
"@rivetkit/rivetkit-napi-linux-arm64-gnu": "0.0.0-main.
|
|
52
|
-
"@rivetkit/rivetkit-napi-linux-arm64-musl": "0.0.0-main.
|
|
53
|
-
"@rivetkit/rivetkit-napi-linux-x64-gnu": "0.0.0-main.
|
|
54
|
-
"@rivetkit/rivetkit-napi-linux-x64-musl": "0.0.0-main.
|
|
55
|
-
"@rivetkit/rivetkit-napi-win32-x64-msvc": "0.0.0-main.17e6a1a"
|
|
50
|
+
"@rivetkit/rivetkit-napi-darwin-arm64": "0.0.0-main.3118df2",
|
|
51
|
+
"@rivetkit/rivetkit-napi-darwin-x64": "0.0.0-main.3118df2",
|
|
52
|
+
"@rivetkit/rivetkit-napi-linux-arm64-gnu": "0.0.0-main.3118df2",
|
|
53
|
+
"@rivetkit/rivetkit-napi-linux-arm64-musl": "0.0.0-main.3118df2",
|
|
54
|
+
"@rivetkit/rivetkit-napi-linux-x64-gnu": "0.0.0-main.3118df2",
|
|
55
|
+
"@rivetkit/rivetkit-napi-linux-x64-musl": "0.0.0-main.3118df2"
|
|
56
56
|
}
|
|
57
57
|
}
|
package/scripts/build.mjs
CHANGED
|
@@ -16,6 +16,14 @@ if (process.env.SKIP_NAPI_BUILD === "1") {
|
|
|
16
16
|
process.exit(0);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
// The per-actor inspector UI (frontend/dist/inspector-ui, embedded into
|
|
20
|
+
// rivetkit-core by its build.rs) must be built before this napi build runs.
|
|
21
|
+
// It is NOT built here: rivetkit-core's embed needs rivetkit/inspector-tab,
|
|
22
|
+
// which is downstream of this package in the build graph, so building it from
|
|
23
|
+
// the napi build would invert the dependency order. CI builds it via
|
|
24
|
+
// `turbo build:inspector-ui` in docker/build/*.Dockerfile before `napi build`;
|
|
25
|
+
// for local builds run `pnpm -F @rivetkit/engine-frontend build:inspector-ui`
|
|
26
|
+
// (or `turbo build:inspector-ui`) first.
|
|
19
27
|
const cmd = ["build", "--platform", ...extraFlags];
|
|
20
28
|
console.log(`[rivetkit-napi/build] running: napi ${cmd.join(" ")}`);
|
|
21
29
|
execFileSync("napi", cmd, { stdio: "inherit" });
|