@rivetkit/rivetkit-napi 0.0.0-main.9d355a2 → 0.0.0-main.b2d3b94
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 +127 -10
- package/index.js +7 -1
- package/package.json +15 -9
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,10 +41,8 @@ export interface JsInspectorSnapshot {
|
|
|
35
41
|
queueSize: number
|
|
36
42
|
connectedClients: number
|
|
37
43
|
}
|
|
38
|
-
export interface
|
|
39
|
-
|
|
40
|
-
headers?: Record<string, string>
|
|
41
|
-
body?: Buffer
|
|
44
|
+
export interface JsActorRuntimeSocketEndpointInfo {
|
|
45
|
+
path: string
|
|
42
46
|
}
|
|
43
47
|
export interface JsQueueSendResult {
|
|
44
48
|
status: string
|
|
@@ -67,11 +71,30 @@ export interface JsInspectorTabEntry {
|
|
|
67
71
|
/** Set to true for HideBuiltin entries. */
|
|
68
72
|
hidden?: boolean
|
|
69
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Experimental SQLite profiling configuration. This entire configuration
|
|
76
|
+
* surface is subject to change without notice.
|
|
77
|
+
*/
|
|
78
|
+
export interface JsSqliteProfilingConfig {
|
|
79
|
+
enabled?: boolean
|
|
80
|
+
maxTrackedStatementFingerprints?: number
|
|
81
|
+
maxTrackedTransactionFingerprints?: number
|
|
82
|
+
maxPrometheusSeries?: number
|
|
83
|
+
maxStatementsPerTransactionTrace?: number
|
|
84
|
+
maxGetPagesRequestsPerTrace?: number
|
|
85
|
+
maxTransactionNameBytes?: number
|
|
86
|
+
slowOperationThresholdMs?: number
|
|
87
|
+
baselineSampleRate?: number
|
|
88
|
+
maxDiagnosticEventsPerMinute?: number
|
|
89
|
+
diagnosticEventQueueCapacity?: number
|
|
90
|
+
}
|
|
70
91
|
export interface JsActorConfig {
|
|
71
92
|
name?: string
|
|
72
93
|
icon?: string
|
|
73
94
|
hasDatabase?: boolean
|
|
74
95
|
remoteSqlite?: boolean
|
|
96
|
+
sqliteProfiling?: JsSqliteProfilingConfig
|
|
97
|
+
enableActorRuntimeSocket?: boolean
|
|
75
98
|
hasState?: boolean
|
|
76
99
|
canHibernateWebsocket?: boolean
|
|
77
100
|
stateSaveIntervalMs?: number
|
|
@@ -92,11 +115,10 @@ export interface JsActorConfig {
|
|
|
92
115
|
connectionLivenessTimeoutMs?: number
|
|
93
116
|
connectionLivenessIntervalMs?: number
|
|
94
117
|
maxQueueSize?: number
|
|
118
|
+
maxSchedules?: number
|
|
95
119
|
maxQueueMessageSize?: number
|
|
96
120
|
maxIncomingMessageSize?: number
|
|
97
121
|
maxOutgoingMessageSize?: number
|
|
98
|
-
preloadMaxWorkflowBytes?: number
|
|
99
|
-
preloadMaxConnectionsBytes?: number
|
|
100
122
|
actions?: Array<JsActionDefinition>
|
|
101
123
|
inspectorTabs?: Array<JsInspectorTabEntry>
|
|
102
124
|
}
|
|
@@ -120,6 +142,10 @@ export interface NativeExecuteResult {
|
|
|
120
142
|
changes: number
|
|
121
143
|
lastInsertRowId?: number
|
|
122
144
|
}
|
|
145
|
+
export interface JsSqliteBatchStatement {
|
|
146
|
+
sql: string
|
|
147
|
+
params?: Array<JsBindParam>
|
|
148
|
+
}
|
|
123
149
|
export interface JsSqliteVfsMetrics {
|
|
124
150
|
requestBuildNs: number
|
|
125
151
|
serializeNs: number
|
|
@@ -133,6 +159,12 @@ export interface JsSqliteVfsMetrics {
|
|
|
133
159
|
writeBufferDirtyPages: number
|
|
134
160
|
dbSizePages: number
|
|
135
161
|
}
|
|
162
|
+
export interface JsHttpResponse {
|
|
163
|
+
status?: number
|
|
164
|
+
headers?: Record<string, string>
|
|
165
|
+
body?: Buffer
|
|
166
|
+
stream?: boolean
|
|
167
|
+
}
|
|
136
168
|
export interface JsQueueNextOptions {
|
|
137
169
|
names?: Array<string>
|
|
138
170
|
timeoutMs?: number
|
|
@@ -207,6 +239,12 @@ export interface JsServerlessResponseHead {
|
|
|
207
239
|
status: number
|
|
208
240
|
headers: Record<string, string>
|
|
209
241
|
}
|
|
242
|
+
export interface JsApplicationResponse {
|
|
243
|
+
status: number
|
|
244
|
+
headers: Record<string, string>
|
|
245
|
+
body?: Buffer
|
|
246
|
+
stream?: boolean
|
|
247
|
+
}
|
|
210
248
|
export interface JsRegistryRouteResponse {
|
|
211
249
|
status: number
|
|
212
250
|
headers: Record<string, string>
|
|
@@ -217,6 +255,38 @@ export interface JsServerlessStreamError {
|
|
|
217
255
|
code: string
|
|
218
256
|
message: string
|
|
219
257
|
}
|
|
258
|
+
export interface JsScheduledEventInfo {
|
|
259
|
+
id: string
|
|
260
|
+
action: string
|
|
261
|
+
args: Buffer
|
|
262
|
+
runAt: number
|
|
263
|
+
}
|
|
264
|
+
export interface JsCronJobInfo {
|
|
265
|
+
name: string
|
|
266
|
+
kind: string
|
|
267
|
+
action: string
|
|
268
|
+
args: Buffer
|
|
269
|
+
nextRunAt: number
|
|
270
|
+
lastRunAt?: number
|
|
271
|
+
expression?: string
|
|
272
|
+
timezone?: string
|
|
273
|
+
intervalMs?: number
|
|
274
|
+
maxHistory: number
|
|
275
|
+
}
|
|
276
|
+
export interface JsScheduleErrorInfo {
|
|
277
|
+
group: string
|
|
278
|
+
code: string
|
|
279
|
+
message: string
|
|
280
|
+
metadata?: any
|
|
281
|
+
}
|
|
282
|
+
export interface JsCronFire {
|
|
283
|
+
action: string
|
|
284
|
+
scheduledAt: number
|
|
285
|
+
firedAt: number
|
|
286
|
+
finishedAt?: number
|
|
287
|
+
result: string
|
|
288
|
+
error?: JsScheduleErrorInfo
|
|
289
|
+
}
|
|
220
290
|
/** Options for KV list operations. */
|
|
221
291
|
export interface JsKvListOptions {
|
|
222
292
|
reverse?: boolean
|
|
@@ -229,12 +299,12 @@ export interface JsKvEntry {
|
|
|
229
299
|
}
|
|
230
300
|
/** N-API wrapper around `rivetkit-core::ActorContext`. */
|
|
231
301
|
export declare class ActorContext {
|
|
232
|
-
constructor(actorId: string, name: string, region: string)
|
|
233
302
|
state(): Buffer
|
|
234
303
|
beginOnStateChange(): void
|
|
235
304
|
endOnStateChange(): void
|
|
236
305
|
kv(): Kv
|
|
237
306
|
sql(): JsNativeDatabase
|
|
307
|
+
provisionActorRuntimeSocket(): Promise<JsActorRuntimeSocketEndpointInfo>
|
|
238
308
|
schedule(): Schedule
|
|
239
309
|
queue(): Queue
|
|
240
310
|
setAlarm(timestampMs?: number | undefined | null): void
|
|
@@ -249,6 +319,8 @@ export declare class ActorContext {
|
|
|
249
319
|
takePendingHibernationChanges(): Array<string>
|
|
250
320
|
dirtyHibernatableConns(): Array<ConnHandle>
|
|
251
321
|
saveState(payload: StateDeltaPayload): Promise<void>
|
|
322
|
+
beginStateTransaction(timeoutMs?: number | undefined | null): Promise<JsActorStateTransaction>
|
|
323
|
+
saveStateAndWorkflowBatch(writes: Array<WorkflowKvWritePayload>): Promise<void>
|
|
252
324
|
actorId(): string
|
|
253
325
|
name(): string
|
|
254
326
|
key(): Array<JsActorKeySegment>
|
|
@@ -262,6 +334,7 @@ export declare class ActorContext {
|
|
|
262
334
|
aborted(): boolean
|
|
263
335
|
runHandlerActive(): boolean
|
|
264
336
|
restartRunHandler(): void
|
|
337
|
+
setRunWakeAt(timestampMs?: number | undefined | null): Promise<void>
|
|
265
338
|
beginKeepAwake(): number
|
|
266
339
|
endKeepAwake(regionId: number): void
|
|
267
340
|
keepAwake(promise: Promise<any>): void
|
|
@@ -304,8 +377,33 @@ export declare class JsNativeDatabase {
|
|
|
304
377
|
run(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<ExecuteResult>
|
|
305
378
|
query(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<QueryResult>
|
|
306
379
|
execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
|
|
380
|
+
executeBatch(statements: Array<JsSqliteBatchStatement>): Promise<Array<NativeExecuteResult>>
|
|
307
381
|
exec(sql: string): Promise<QueryResult>
|
|
308
382
|
close(): Promise<void>
|
|
383
|
+
beginTransaction(timeoutMs?: number | undefined | null, name?: string | undefined | null): Promise<JsSqliteTransaction>
|
|
384
|
+
}
|
|
385
|
+
export declare class JsSqliteTransaction {
|
|
386
|
+
execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
|
|
387
|
+
exec(sql: string): Promise<QueryResult>
|
|
388
|
+
commit(): Promise<void>
|
|
389
|
+
rollback(): Promise<void>
|
|
390
|
+
}
|
|
391
|
+
export declare class JsActorStateTransaction {
|
|
392
|
+
execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
|
|
393
|
+
commit(payload: StateDeltaPayload): Promise<void>
|
|
394
|
+
rollback(): Promise<void>
|
|
395
|
+
}
|
|
396
|
+
/** JavaScript-facing writer for a streaming actor HTTP response. */
|
|
397
|
+
export declare class HttpResponseBodyStream {
|
|
398
|
+
cancelled(): Promise<void>
|
|
399
|
+
write(chunk: Buffer): Promise<void>
|
|
400
|
+
end(): Promise<void>
|
|
401
|
+
error(message: string): Promise<void>
|
|
402
|
+
}
|
|
403
|
+
/** JavaScript-facing reader for a streaming actor HTTP request. */
|
|
404
|
+
export declare class HttpRequestBodyStream {
|
|
405
|
+
read(): Promise<Buffer | null>
|
|
406
|
+
cancel(): Promise<void>
|
|
309
407
|
}
|
|
310
408
|
export declare class Kv {
|
|
311
409
|
get(key: Buffer): Promise<Buffer | null>
|
|
@@ -324,10 +422,12 @@ export declare class Queue {
|
|
|
324
422
|
nextBatch(options?: JsQueueNextBatchOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<Array<QueueMessage>>
|
|
325
423
|
waitForNames(names: Array<string>, options?: JsQueueWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<QueueMessage>
|
|
326
424
|
waitForNamesAvailable(names: Array<string>, options?: JsQueueWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<void>
|
|
425
|
+
completePersisted(messageId: bigint, expectedName: string, response?: Buffer | undefined | null): Promise<boolean>
|
|
327
426
|
enqueueAndWait(name: string, body: Buffer, options?: JsQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<Buffer | null>
|
|
328
427
|
tryNext(options?: JsQueueTryNextOptions | undefined | null): QueueMessage | null
|
|
329
428
|
tryNextBatch(options?: JsQueueTryNextBatchOptions | undefined | null): Array<QueueMessage>
|
|
330
429
|
maxSize(): number
|
|
430
|
+
reset(): Promise<void>
|
|
331
431
|
inspectMessages(): Promise<Array<JsQueueInspectMessage>>
|
|
332
432
|
}
|
|
333
433
|
export declare class QueueMessage {
|
|
@@ -342,6 +442,13 @@ export declare class CoreRegistry {
|
|
|
342
442
|
constructor()
|
|
343
443
|
register(name: string, factory: NapiActorFactory): void
|
|
344
444
|
serve(config: JsServeConfig): Promise<void>
|
|
445
|
+
/**
|
|
446
|
+
* Wait until the serverful envoy has completed its Engine registration.
|
|
447
|
+
*
|
|
448
|
+
* Readiness is the envoy client's `ToEnvoyInit` signal, not HTTP health or
|
|
449
|
+
* merely constructing the envoy handle.
|
|
450
|
+
*/
|
|
451
|
+
waitReady(): Promise<void>
|
|
345
452
|
/**
|
|
346
453
|
* Trip the shutdown token and tear down any live serverless runtime.
|
|
347
454
|
*
|
|
@@ -354,12 +461,22 @@ export declare class CoreRegistry {
|
|
|
354
461
|
health(): Promise<JsRegistryRouteResponse>
|
|
355
462
|
metadata(): JsRegistryRouteResponse
|
|
356
463
|
metrics(): JsRegistryRouteResponse
|
|
357
|
-
|
|
464
|
+
serveApplicationListener(listener: JsListenerConfig, application: (...args: any[]) => any, config: JsServeConfig): Promise<void>
|
|
465
|
+
serveListener(listener: JsListenerConfig, config: JsServeConfig, application?: (...args: any[]) => any | undefined | null): Promise<void>
|
|
358
466
|
handleServerlessRequest(req: JsServerlessRequest, onStreamEvent: (...args: any[]) => any, cancelToken: CancellationToken, config: JsServeConfig): Promise<JsServerlessResponseHead>
|
|
359
467
|
}
|
|
360
468
|
export declare class Schedule {
|
|
361
|
-
after(durationMs: number, actionName: string, args: Buffer):
|
|
362
|
-
at(timestampMs: number, actionName: string, args: Buffer):
|
|
469
|
+
after(durationMs: number, actionName: string, args: Buffer): Promise<string>
|
|
470
|
+
at(timestampMs: number, actionName: string, args: Buffer): Promise<string>
|
|
471
|
+
cancel(id: string): Promise<boolean>
|
|
472
|
+
get(id: string): Promise<JsScheduledEventInfo | null>
|
|
473
|
+
list(): Promise<Array<JsScheduledEventInfo>>
|
|
474
|
+
cronSet(name: string, expression: string, timezone: string | undefined | null, actionName: string, args: Buffer, maxHistory?: number | undefined | null): Promise<void>
|
|
475
|
+
cronEvery(name: string, intervalMs: number, actionName: string, args: Buffer, maxHistory?: number | undefined | null): Promise<void>
|
|
476
|
+
cronGet(name: string): Promise<JsCronJobInfo | null>
|
|
477
|
+
cronList(): Promise<Array<JsCronJobInfo>>
|
|
478
|
+
cronDelete(name: string): Promise<boolean>
|
|
479
|
+
cronHistory(name: string, limit?: number | undefined | null): Promise<Array<JsCronFire>>
|
|
363
480
|
}
|
|
364
481
|
export declare class WebSocket {
|
|
365
482
|
send(data: Buffer, binary: boolean): void
|
package/index.js
CHANGED
|
@@ -310,13 +310,19 @@ 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, JsActorStateTransaction, HttpResponseBodyStream, HttpRequestBodyStream, 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
|
|
323
|
+
module.exports.JsActorStateTransaction = JsActorStateTransaction
|
|
324
|
+
module.exports.HttpResponseBodyStream = HttpResponseBodyStream
|
|
325
|
+
module.exports.HttpRequestBodyStream = HttpRequestBodyStream
|
|
320
326
|
module.exports.Kv = Kv
|
|
321
327
|
module.exports.Queue = Queue
|
|
322
328
|
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.b2d3b94",
|
|
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,18 +39,24 @@
|
|
|
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.b2d3b94"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/rivet-dev/actors.git",
|
|
52
|
+
"directory": "rivetkit-typescript/packages/rivetkit-napi"
|
|
47
53
|
},
|
|
48
54
|
"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-darwin-arm64": "0.0.0-main.b2d3b94",
|
|
56
|
+
"@rivetkit/rivetkit-napi-darwin-x64": "0.0.0-main.b2d3b94",
|
|
57
|
+
"@rivetkit/rivetkit-napi-linux-arm64-gnu": "0.0.0-main.b2d3b94",
|
|
58
|
+
"@rivetkit/rivetkit-napi-linux-arm64-musl": "0.0.0-main.b2d3b94",
|
|
59
|
+
"@rivetkit/rivetkit-napi-linux-x64-gnu": "0.0.0-main.b2d3b94",
|
|
60
|
+
"@rivetkit/rivetkit-napi-linux-x64-musl": "0.0.0-main.b2d3b94"
|
|
55
61
|
}
|
|
56
62
|
}
|