@rivetkit/rivetkit-napi 2.3.4 → 2.3.5-rc.1
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 +68 -5
- package/index.js +4 -1
- package/package.json +9 -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,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>
|
|
@@ -72,6 +81,7 @@ export interface JsActorConfig {
|
|
|
72
81
|
icon?: string
|
|
73
82
|
hasDatabase?: boolean
|
|
74
83
|
remoteSqlite?: boolean
|
|
84
|
+
enableActorRuntimeSocket?: boolean
|
|
75
85
|
hasState?: boolean
|
|
76
86
|
canHibernateWebsocket?: boolean
|
|
77
87
|
stateSaveIntervalMs?: number
|
|
@@ -92,11 +102,10 @@ export interface JsActorConfig {
|
|
|
92
102
|
connectionLivenessTimeoutMs?: number
|
|
93
103
|
connectionLivenessIntervalMs?: number
|
|
94
104
|
maxQueueSize?: number
|
|
105
|
+
maxSchedules?: number
|
|
95
106
|
maxQueueMessageSize?: number
|
|
96
107
|
maxIncomingMessageSize?: number
|
|
97
108
|
maxOutgoingMessageSize?: number
|
|
98
|
-
preloadMaxWorkflowBytes?: number
|
|
99
|
-
preloadMaxConnectionsBytes?: number
|
|
100
109
|
actions?: Array<JsActionDefinition>
|
|
101
110
|
inspectorTabs?: Array<JsInspectorTabEntry>
|
|
102
111
|
}
|
|
@@ -120,6 +129,10 @@ export interface NativeExecuteResult {
|
|
|
120
129
|
changes: number
|
|
121
130
|
lastInsertRowId?: number
|
|
122
131
|
}
|
|
132
|
+
export interface JsSqliteBatchStatement {
|
|
133
|
+
sql: string
|
|
134
|
+
params?: Array<JsBindParam>
|
|
135
|
+
}
|
|
123
136
|
export interface JsSqliteVfsMetrics {
|
|
124
137
|
requestBuildNs: number
|
|
125
138
|
serializeNs: number
|
|
@@ -217,6 +230,38 @@ export interface JsServerlessStreamError {
|
|
|
217
230
|
code: string
|
|
218
231
|
message: string
|
|
219
232
|
}
|
|
233
|
+
export interface JsScheduledEventInfo {
|
|
234
|
+
id: string
|
|
235
|
+
action: string
|
|
236
|
+
args: Buffer
|
|
237
|
+
runAt: number
|
|
238
|
+
}
|
|
239
|
+
export interface JsCronJobInfo {
|
|
240
|
+
name: string
|
|
241
|
+
kind: string
|
|
242
|
+
action: string
|
|
243
|
+
args: Buffer
|
|
244
|
+
nextRunAt: number
|
|
245
|
+
lastRunAt?: number
|
|
246
|
+
expression?: string
|
|
247
|
+
timezone?: string
|
|
248
|
+
intervalMs?: number
|
|
249
|
+
maxHistory: number
|
|
250
|
+
}
|
|
251
|
+
export interface JsScheduleErrorInfo {
|
|
252
|
+
group: string
|
|
253
|
+
code: string
|
|
254
|
+
message: string
|
|
255
|
+
metadata?: any
|
|
256
|
+
}
|
|
257
|
+
export interface JsCronFire {
|
|
258
|
+
action: string
|
|
259
|
+
scheduledAt: number
|
|
260
|
+
firedAt: number
|
|
261
|
+
finishedAt?: number
|
|
262
|
+
result: string
|
|
263
|
+
error?: JsScheduleErrorInfo
|
|
264
|
+
}
|
|
220
265
|
/** Options for KV list operations. */
|
|
221
266
|
export interface JsKvListOptions {
|
|
222
267
|
reverse?: boolean
|
|
@@ -229,12 +274,12 @@ export interface JsKvEntry {
|
|
|
229
274
|
}
|
|
230
275
|
/** N-API wrapper around `rivetkit-core::ActorContext`. */
|
|
231
276
|
export declare class ActorContext {
|
|
232
|
-
constructor(actorId: string, name: string, region: string)
|
|
233
277
|
state(): Buffer
|
|
234
278
|
beginOnStateChange(): void
|
|
235
279
|
endOnStateChange(): void
|
|
236
280
|
kv(): Kv
|
|
237
281
|
sql(): JsNativeDatabase
|
|
282
|
+
provisionActorRuntimeSocket(): Promise<JsActorRuntimeSocketEndpointInfo>
|
|
238
283
|
schedule(): Schedule
|
|
239
284
|
queue(): Queue
|
|
240
285
|
setAlarm(timestampMs?: number | undefined | null): void
|
|
@@ -249,6 +294,7 @@ export declare class ActorContext {
|
|
|
249
294
|
takePendingHibernationChanges(): Array<string>
|
|
250
295
|
dirtyHibernatableConns(): Array<ConnHandle>
|
|
251
296
|
saveState(payload: StateDeltaPayload): Promise<void>
|
|
297
|
+
saveStateAndWorkflowBatch(writes: Array<WorkflowKvWritePayload>): Promise<void>
|
|
252
298
|
actorId(): string
|
|
253
299
|
name(): string
|
|
254
300
|
key(): Array<JsActorKeySegment>
|
|
@@ -304,8 +350,16 @@ export declare class JsNativeDatabase {
|
|
|
304
350
|
run(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<ExecuteResult>
|
|
305
351
|
query(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<QueryResult>
|
|
306
352
|
execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
|
|
353
|
+
executeBatch(statements: Array<JsSqliteBatchStatement>): Promise<Array<NativeExecuteResult>>
|
|
307
354
|
exec(sql: string): Promise<QueryResult>
|
|
308
355
|
close(): Promise<void>
|
|
356
|
+
beginTransaction(timeoutMs?: number | undefined | null): Promise<JsSqliteTransaction>
|
|
357
|
+
}
|
|
358
|
+
export declare class JsSqliteTransaction {
|
|
359
|
+
execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
|
|
360
|
+
exec(sql: string): Promise<QueryResult>
|
|
361
|
+
commit(): Promise<void>
|
|
362
|
+
rollback(): Promise<void>
|
|
309
363
|
}
|
|
310
364
|
export declare class Kv {
|
|
311
365
|
get(key: Buffer): Promise<Buffer | null>
|
|
@@ -359,8 +413,17 @@ export declare class CoreRegistry {
|
|
|
359
413
|
handleServerlessRequest(req: JsServerlessRequest, onStreamEvent: (...args: any[]) => any, cancelToken: CancellationToken, config: JsServeConfig): Promise<JsServerlessResponseHead>
|
|
360
414
|
}
|
|
361
415
|
export declare class Schedule {
|
|
362
|
-
after(durationMs: number, actionName: string, args: Buffer):
|
|
363
|
-
at(timestampMs: number, actionName: string, args: Buffer):
|
|
416
|
+
after(durationMs: number, actionName: string, args: Buffer): Promise<string>
|
|
417
|
+
at(timestampMs: number, actionName: string, args: Buffer): Promise<string>
|
|
418
|
+
cancel(id: string): Promise<boolean>
|
|
419
|
+
get(id: string): Promise<JsScheduledEventInfo | null>
|
|
420
|
+
list(): Promise<Array<JsScheduledEventInfo>>
|
|
421
|
+
cronSet(name: string, expression: string, timezone: string | undefined | null, actionName: string, args: Buffer, maxHistory?: number | undefined | null): Promise<void>
|
|
422
|
+
cronEvery(name: string, intervalMs: number, actionName: string, args: Buffer, maxHistory?: number | undefined | null): Promise<void>
|
|
423
|
+
cronGet(name: string): Promise<JsCronJobInfo | null>
|
|
424
|
+
cronList(): Promise<Array<JsCronJobInfo>>
|
|
425
|
+
cronDelete(name: string): Promise<boolean>
|
|
426
|
+
cronHistory(name: string, limit?: number | undefined | null): Promise<Array<JsCronFire>>
|
|
364
427
|
}
|
|
365
428
|
export declare class WebSocket {
|
|
366
429
|
send(data: Buffer, binary: boolean): void
|
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": "2.3.
|
|
3
|
+
"version": "2.3.5-rc.1",
|
|
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",
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@napi-rs/cli": "^2.18.4",
|
|
47
|
-
"@rivetkit/engine-envoy-protocol": "2.3.
|
|
47
|
+
"@rivetkit/engine-envoy-protocol": "2.3.5-rc.1"
|
|
48
48
|
},
|
|
49
49
|
"optionalDependencies": {
|
|
50
|
-
"@rivetkit/rivetkit-napi-darwin-arm64": "2.3.
|
|
51
|
-
"@rivetkit/rivetkit-napi-darwin-x64": "2.3.
|
|
52
|
-
"@rivetkit/rivetkit-napi-linux-arm64-gnu": "2.3.
|
|
53
|
-
"@rivetkit/rivetkit-napi-linux-arm64-musl": "2.3.
|
|
54
|
-
"@rivetkit/rivetkit-napi-linux-x64-gnu": "2.3.
|
|
55
|
-
"@rivetkit/rivetkit-napi-linux-x64-musl": "2.3.
|
|
56
|
-
"@rivetkit/rivetkit-napi-win32-x64-msvc": "2.3.
|
|
50
|
+
"@rivetkit/rivetkit-napi-darwin-arm64": "2.3.5-rc.1",
|
|
51
|
+
"@rivetkit/rivetkit-napi-darwin-x64": "2.3.5-rc.1",
|
|
52
|
+
"@rivetkit/rivetkit-napi-linux-arm64-gnu": "2.3.5-rc.1",
|
|
53
|
+
"@rivetkit/rivetkit-napi-linux-arm64-musl": "2.3.5-rc.1",
|
|
54
|
+
"@rivetkit/rivetkit-napi-linux-x64-gnu": "2.3.5-rc.1",
|
|
55
|
+
"@rivetkit/rivetkit-napi-linux-x64-musl": "2.3.5-rc.1",
|
|
56
|
+
"@rivetkit/rivetkit-napi-win32-x64-msvc": "2.3.5-rc.1"
|
|
57
57
|
}
|
|
58
58
|
}
|