@rivetkit/rivetkit-napi 0.0.0-main.17f6330 → 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.
Files changed (3) hide show
  1. package/index.d.ts +25 -3
  2. package/index.js +4 -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,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
@@ -95,8 +105,6 @@ export interface JsActorConfig {
95
105
  maxQueueMessageSize?: number
96
106
  maxIncomingMessageSize?: number
97
107
  maxOutgoingMessageSize?: number
98
- preloadMaxWorkflowBytes?: number
99
- preloadMaxConnectionsBytes?: number
100
108
  actions?: Array<JsActionDefinition>
101
109
  inspectorTabs?: Array<JsInspectorTabEntry>
102
110
  }
@@ -120,6 +128,10 @@ export interface NativeExecuteResult {
120
128
  changes: number
121
129
  lastInsertRowId?: number
122
130
  }
131
+ export interface JsSqliteBatchStatement {
132
+ sql: string
133
+ params?: Array<JsBindParam>
134
+ }
123
135
  export interface JsSqliteVfsMetrics {
124
136
  requestBuildNs: number
125
137
  serializeNs: number
@@ -229,12 +241,12 @@ export interface JsKvEntry {
229
241
  }
230
242
  /** N-API wrapper around `rivetkit-core::ActorContext`. */
231
243
  export declare class ActorContext {
232
- constructor(actorId: string, name: string, region: string)
233
244
  state(): Buffer
234
245
  beginOnStateChange(): void
235
246
  endOnStateChange(): void
236
247
  kv(): Kv
237
248
  sql(): JsNativeDatabase
249
+ provisionActorRuntimeSocket(): Promise<JsActorRuntimeSocketEndpointInfo>
238
250
  schedule(): Schedule
239
251
  queue(): Queue
240
252
  setAlarm(timestampMs?: number | undefined | null): void
@@ -249,6 +261,7 @@ export declare class ActorContext {
249
261
  takePendingHibernationChanges(): Array<string>
250
262
  dirtyHibernatableConns(): Array<ConnHandle>
251
263
  saveState(payload: StateDeltaPayload): Promise<void>
264
+ saveStateAndWorkflowBatch(writes: Array<WorkflowKvWritePayload>): Promise<void>
252
265
  actorId(): string
253
266
  name(): string
254
267
  key(): Array<JsActorKeySegment>
@@ -304,8 +317,16 @@ export declare class JsNativeDatabase {
304
317
  run(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<ExecuteResult>
305
318
  query(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<QueryResult>
306
319
  execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
320
+ executeBatch(statements: Array<JsSqliteBatchStatement>): Promise<Array<NativeExecuteResult>>
307
321
  exec(sql: string): Promise<QueryResult>
308
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>
309
330
  }
310
331
  export declare class Kv {
311
332
  get(key: Buffer): Promise<Buffer | null>
@@ -328,6 +349,7 @@ export declare class Queue {
328
349
  tryNext(options?: JsQueueTryNextOptions | undefined | null): QueueMessage | null
329
350
  tryNextBatch(options?: JsQueueTryNextBatchOptions | undefined | null): Array<QueueMessage>
330
351
  maxSize(): number
352
+ reset(): Promise<void>
331
353
  inspectMessages(): Promise<Array<JsQueueInspectMessage>>
332
354
  }
333
355
  export declare class QueueMessage {
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.17f6330",
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",
@@ -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-main.17f6330"
47
+ "@rivetkit/engine-envoy-protocol": "0.0.0-main.3118df2"
48
48
  },
49
49
  "optionalDependencies": {
50
- "@rivetkit/rivetkit-napi-darwin-arm64": "0.0.0-main.17f6330",
51
- "@rivetkit/rivetkit-napi-darwin-x64": "0.0.0-main.17f6330",
52
- "@rivetkit/rivetkit-napi-linux-arm64-gnu": "0.0.0-main.17f6330",
53
- "@rivetkit/rivetkit-napi-linux-arm64-musl": "0.0.0-main.17f6330",
54
- "@rivetkit/rivetkit-napi-linux-x64-gnu": "0.0.0-main.17f6330",
55
- "@rivetkit/rivetkit-napi-linux-x64-musl": "0.0.0-main.17f6330"
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
  }