@rivetkit/rivetkit-napi 0.0.0-fix-ws-size.7d55b4f → 0.0.0-http-body-streaming.064e07d

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.
Files changed (3) hide show
  1. package/index.d.ts +87 -5
  2. package/index.js +6 -1
  3. package/package.json +8 -8
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,14 @@ 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>
41
50
  body?: Buffer
51
+ stream?: boolean
42
52
  }
43
53
  export interface JsQueueSendResult {
44
54
  status: string
@@ -72,6 +82,7 @@ export interface JsActorConfig {
72
82
  icon?: string
73
83
  hasDatabase?: boolean
74
84
  remoteSqlite?: boolean
85
+ enableActorRuntimeSocket?: boolean
75
86
  hasState?: boolean
76
87
  canHibernateWebsocket?: boolean
77
88
  stateSaveIntervalMs?: number
@@ -92,11 +103,10 @@ export interface JsActorConfig {
92
103
  connectionLivenessTimeoutMs?: number
93
104
  connectionLivenessIntervalMs?: number
94
105
  maxQueueSize?: number
106
+ maxSchedules?: number
95
107
  maxQueueMessageSize?: number
96
108
  maxIncomingMessageSize?: number
97
109
  maxOutgoingMessageSize?: number
98
- preloadMaxWorkflowBytes?: number
99
- preloadMaxConnectionsBytes?: number
100
110
  actions?: Array<JsActionDefinition>
101
111
  inspectorTabs?: Array<JsInspectorTabEntry>
102
112
  }
@@ -120,6 +130,10 @@ export interface NativeExecuteResult {
120
130
  changes: number
121
131
  lastInsertRowId?: number
122
132
  }
133
+ export interface JsSqliteBatchStatement {
134
+ sql: string
135
+ params?: Array<JsBindParam>
136
+ }
123
137
  export interface JsSqliteVfsMetrics {
124
138
  requestBuildNs: number
125
139
  serializeNs: number
@@ -217,6 +231,38 @@ export interface JsServerlessStreamError {
217
231
  code: string
218
232
  message: string
219
233
  }
234
+ export interface JsScheduledEventInfo {
235
+ id: string
236
+ action: string
237
+ args: Buffer
238
+ runAt: number
239
+ }
240
+ export interface JsCronJobInfo {
241
+ name: string
242
+ kind: string
243
+ action: string
244
+ args: Buffer
245
+ nextRunAt: number
246
+ lastRunAt?: number
247
+ expression?: string
248
+ timezone?: string
249
+ intervalMs?: number
250
+ maxHistory: number
251
+ }
252
+ export interface JsScheduleErrorInfo {
253
+ group: string
254
+ code: string
255
+ message: string
256
+ metadata?: any
257
+ }
258
+ export interface JsCronFire {
259
+ action: string
260
+ scheduledAt: number
261
+ firedAt: number
262
+ finishedAt?: number
263
+ result: string
264
+ error?: JsScheduleErrorInfo
265
+ }
220
266
  /** Options for KV list operations. */
221
267
  export interface JsKvListOptions {
222
268
  reverse?: boolean
@@ -229,12 +275,12 @@ export interface JsKvEntry {
229
275
  }
230
276
  /** N-API wrapper around `rivetkit-core::ActorContext`. */
231
277
  export declare class ActorContext {
232
- constructor(actorId: string, name: string, region: string)
233
278
  state(): Buffer
234
279
  beginOnStateChange(): void
235
280
  endOnStateChange(): void
236
281
  kv(): Kv
237
282
  sql(): JsNativeDatabase
283
+ provisionActorRuntimeSocket(): Promise<JsActorRuntimeSocketEndpointInfo>
238
284
  schedule(): Schedule
239
285
  queue(): Queue
240
286
  setAlarm(timestampMs?: number | undefined | null): void
@@ -249,6 +295,7 @@ export declare class ActorContext {
249
295
  takePendingHibernationChanges(): Array<string>
250
296
  dirtyHibernatableConns(): Array<ConnHandle>
251
297
  saveState(payload: StateDeltaPayload): Promise<void>
298
+ saveStateAndWorkflowBatch(writes: Array<WorkflowKvWritePayload>): Promise<void>
252
299
  actorId(): string
253
300
  name(): string
254
301
  key(): Array<JsActorKeySegment>
@@ -280,6 +327,16 @@ export declare class ActorContext {
280
327
  runtimeState(): object
281
328
  clearRuntimeState(): void
282
329
  }
330
+ export declare class HttpResponseBodyStream {
331
+ cancelled(): Promise<void>
332
+ write(chunk: Buffer): Promise<void>
333
+ end(): Promise<void>
334
+ error(message: string): Promise<void>
335
+ }
336
+ export declare class HttpRequestBodyStream {
337
+ read(): Promise<Buffer | null>
338
+ cancel(): Promise<void>
339
+ }
283
340
  export declare class NapiActorFactory {
284
341
  constructor(callbacks: object, config?: JsActorConfig | undefined | null)
285
342
  }
@@ -304,8 +361,16 @@ export declare class JsNativeDatabase {
304
361
  run(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<ExecuteResult>
305
362
  query(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<QueryResult>
306
363
  execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
364
+ executeBatch(statements: Array<JsSqliteBatchStatement>): Promise<Array<NativeExecuteResult>>
307
365
  exec(sql: string): Promise<QueryResult>
308
366
  close(): Promise<void>
367
+ beginTransaction(timeoutMs?: number | undefined | null): Promise<JsSqliteTransaction>
368
+ }
369
+ export declare class JsSqliteTransaction {
370
+ execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
371
+ exec(sql: string): Promise<QueryResult>
372
+ commit(): Promise<void>
373
+ rollback(): Promise<void>
309
374
  }
310
375
  export declare class Kv {
311
376
  get(key: Buffer): Promise<Buffer | null>
@@ -328,6 +393,7 @@ export declare class Queue {
328
393
  tryNext(options?: JsQueueTryNextOptions | undefined | null): QueueMessage | null
329
394
  tryNextBatch(options?: JsQueueTryNextBatchOptions | undefined | null): Array<QueueMessage>
330
395
  maxSize(): number
396
+ reset(): Promise<void>
331
397
  inspectMessages(): Promise<Array<JsQueueInspectMessage>>
332
398
  }
333
399
  export declare class QueueMessage {
@@ -342,6 +408,13 @@ export declare class CoreRegistry {
342
408
  constructor()
343
409
  register(name: string, factory: NapiActorFactory): void
344
410
  serve(config: JsServeConfig): Promise<void>
411
+ /**
412
+ * Wait until the serverful envoy has completed its Engine registration.
413
+ *
414
+ * Readiness is the envoy client's `ToEnvoyInit` signal, not HTTP health or
415
+ * merely constructing the envoy handle.
416
+ */
417
+ waitReady(): Promise<void>
345
418
  /**
346
419
  * Trip the shutdown token and tear down any live serverless runtime.
347
420
  *
@@ -358,8 +431,17 @@ export declare class CoreRegistry {
358
431
  handleServerlessRequest(req: JsServerlessRequest, onStreamEvent: (...args: any[]) => any, cancelToken: CancellationToken, config: JsServeConfig): Promise<JsServerlessResponseHead>
359
432
  }
360
433
  export declare class Schedule {
361
- after(durationMs: number, actionName: string, args: Buffer): void
362
- at(timestampMs: number, actionName: string, args: Buffer): void
434
+ after(durationMs: number, actionName: string, args: Buffer): Promise<string>
435
+ at(timestampMs: number, actionName: string, args: Buffer): Promise<string>
436
+ cancel(id: string): Promise<boolean>
437
+ get(id: string): Promise<JsScheduledEventInfo | null>
438
+ list(): Promise<Array<JsScheduledEventInfo>>
439
+ cronSet(name: string, expression: string, timezone: string | undefined | null, actionName: string, args: Buffer, maxHistory?: number | undefined | null): Promise<void>
440
+ cronEvery(name: string, intervalMs: number, actionName: string, args: Buffer, maxHistory?: number | undefined | null): Promise<void>
441
+ cronGet(name: string): Promise<JsCronJobInfo | null>
442
+ cronList(): Promise<Array<JsCronJobInfo>>
443
+ cronDelete(name: string): Promise<boolean>
444
+ cronHistory(name: string, limit?: number | undefined | null): Promise<Array<JsCronFire>>
363
445
  }
364
446
  export declare class WebSocket {
365
447
  send(data: Buffer, binary: boolean): void
package/index.js CHANGED
@@ -310,13 +310,18 @@ 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, HttpResponseBodyStream, HttpRequestBodyStream, 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
318
+ module.exports.HttpResponseBodyStream = HttpResponseBodyStream
319
+ module.exports.HttpRequestBodyStream = HttpRequestBodyStream
316
320
  module.exports.NapiActorFactory = NapiActorFactory
317
321
  module.exports.CancellationToken = CancellationToken
318
322
  module.exports.ConnHandle = ConnHandle
319
323
  module.exports.JsNativeDatabase = JsNativeDatabase
324
+ module.exports.JsSqliteTransaction = JsSqliteTransaction
320
325
  module.exports.Kv = Kv
321
326
  module.exports.Queue = Queue
322
327
  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-fix-ws-size.7d55b4f",
3
+ "version": "0.0.0-http-body-streaming.064e07d",
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,14 +44,14 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@napi-rs/cli": "^2.18.4",
47
- "@rivetkit/engine-envoy-protocol": "0.0.0-fix-ws-size.7d55b4f"
47
+ "@rivetkit/engine-envoy-protocol": "0.0.0-http-body-streaming.064e07d"
48
48
  },
49
49
  "optionalDependencies": {
50
- "@rivetkit/rivetkit-napi-darwin-arm64": "0.0.0-fix-ws-size.7d55b4f",
51
- "@rivetkit/rivetkit-napi-darwin-x64": "0.0.0-fix-ws-size.7d55b4f",
52
- "@rivetkit/rivetkit-napi-linux-arm64-gnu": "0.0.0-fix-ws-size.7d55b4f",
53
- "@rivetkit/rivetkit-napi-linux-arm64-musl": "0.0.0-fix-ws-size.7d55b4f",
54
- "@rivetkit/rivetkit-napi-linux-x64-gnu": "0.0.0-fix-ws-size.7d55b4f",
55
- "@rivetkit/rivetkit-napi-linux-x64-musl": "0.0.0-fix-ws-size.7d55b4f"
50
+ "@rivetkit/rivetkit-napi-darwin-arm64": "0.0.0-http-body-streaming.064e07d",
51
+ "@rivetkit/rivetkit-napi-darwin-x64": "0.0.0-http-body-streaming.064e07d",
52
+ "@rivetkit/rivetkit-napi-linux-arm64-gnu": "0.0.0-http-body-streaming.064e07d",
53
+ "@rivetkit/rivetkit-napi-linux-arm64-musl": "0.0.0-http-body-streaming.064e07d",
54
+ "@rivetkit/rivetkit-napi-linux-x64-gnu": "0.0.0-http-body-streaming.064e07d",
55
+ "@rivetkit/rivetkit-napi-linux-x64-musl": "0.0.0-http-body-streaming.064e07d"
56
56
  }
57
57
  }