@revoengine/sdk 1.0.0 → 2.0.0
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/README.md +145 -19
- package/dist/{errors-ieF9jeMP.d.cts → errors-nuya4h6b.d.cts} +357 -57
- package/dist/{errors-ieF9jeMP.d.ts → errors-nuya4h6b.d.ts} +357 -57
- package/dist/hosted.cjs +3241 -1235
- package/dist/hosted.cjs.map +1 -1
- package/dist/hosted.d.cts +2 -2
- package/dist/hosted.d.ts +2 -2
- package/dist/hosted.js +3241 -1235
- package/dist/hosted.js.map +1 -1
- package/dist/index.cjs +3245 -1236
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4395 -2543
- package/dist/index.d.ts +4395 -2543
- package/dist/index.js +3245 -1236
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
# @revoengine/sdk
|
|
2
2
|
|
|
3
3
|
Official Node.js SDK for RevoEngine. It provides the modern `api`, `utils`,
|
|
4
|
-
`storage`, and `agents` namespaces
|
|
4
|
+
`storage`, and `agents` namespaces, top-level `execute()`, and the `batch` controller in both
|
|
5
5
|
Revo-hosted `CUSTOM_NODEJS` components and standalone Node.js applications.
|
|
6
6
|
|
|
7
7
|
Requirements: Node.js 22 or newer.
|
|
8
8
|
|
|
9
|
+
## SDK 2.0.0 compatibility
|
|
10
|
+
|
|
11
|
+
This major release synchronizes the complete public SDK contract with the current
|
|
12
|
+
platform low-code declarations. Remote calls require a platform runtime that admits
|
|
13
|
+
the bundled contract revision; publishing the SDK alone does not deploy that runtime.
|
|
14
|
+
Use SDK 1.0.1 with older deployments until their platform contract is upgraded.
|
|
15
|
+
|
|
16
|
+
HTTP Storage requests/responses now use `requestType: 'storage'` and
|
|
17
|
+
`responseType: 'storage'`, with flat Storage-only `source` / `target` objects.
|
|
18
|
+
Legacy HTTP Files references and the old Storage `stream` mode are rejected.
|
|
19
|
+
Byte/SSE response iterators remain local to V8 and are blocked by the SDK before
|
|
20
|
+
network or hosted bridge dispatch. Automation schedules use `{ scheduleFor }`
|
|
21
|
+
options instead of positional dates. Regenerated types also include the current
|
|
22
|
+
Storage and database contracts; use those declarations when migrating callers.
|
|
23
|
+
|
|
9
24
|
## Choose your runtime
|
|
10
25
|
|
|
11
26
|
| Environment | How to start | Authentication |
|
|
@@ -13,14 +28,14 @@ Requirements: Node.js 22 or newer.
|
|
|
13
28
|
| Revo-hosted `CUSTOM_NODEJS` | Export `async function init(runtime)` | Revo injects an execution-bound runtime; user code receives no API key. |
|
|
14
29
|
| Standalone Node.js | Create `new RevoClient(options)` | Supply a RevoEngine API key explicitly or through an environment variable. |
|
|
15
30
|
|
|
16
|
-
Both modes expose the same `api`, `utils`, `storage`, `agents`, and `batch`
|
|
31
|
+
Both modes expose the same `api`, `utils`, `storage`, `agents`, `execute`, and `batch`
|
|
17
32
|
properties, but return types reflect where the work happens:
|
|
18
33
|
|
|
19
34
|
| Call kind | Revo-hosted | Standalone |
|
|
20
35
|
| --- | --- | --- |
|
|
21
36
|
| Execution snapshot, cache, debug, and logging | Synchronous | Throws synchronously because no execution context exists |
|
|
22
37
|
| Current user and instance | Synchronous injected snapshot | Asynchronous lazy `/api/v1/me` discovery |
|
|
23
|
-
| Remote `api`, `storage`, and `
|
|
38
|
+
| Remote `api`, `storage`, `agents`, and `execute()` calls | Asynchronous | Asynchronous |
|
|
24
39
|
| Local `utils` and `batch.configure()` | Synchronous unless the utility is inherently asynchronous | Same |
|
|
25
40
|
|
|
26
41
|
## Installation
|
|
@@ -31,22 +46,14 @@ Standalone applications install the SDK normally:
|
|
|
31
46
|
npm install @revoengine/sdk
|
|
32
47
|
```
|
|
33
48
|
|
|
34
|
-
New Revo-hosted components receive
|
|
49
|
+
New Revo-hosted components receive the exact platform-supported SDK version and a JSDoc
|
|
35
50
|
`RevoRuntime` type import in their generated starter files.
|
|
36
51
|
RevoEngine pins that version again in the deployment package and injects the
|
|
37
52
|
runtime into the component entrypoint. Component code does not construct a
|
|
38
53
|
`RevoClient`.
|
|
39
54
|
|
|
40
|
-
The
|
|
41
|
-
|
|
42
|
-
```json
|
|
43
|
-
{
|
|
44
|
-
"type": "module",
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"@revoengine/sdk": "1.0.0"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
```
|
|
55
|
+
The platform chooses the hosted package version; publishing SDK 2.0.0 does not
|
|
56
|
+
upgrade existing hosted deployments or their generated package pins.
|
|
50
57
|
|
|
51
58
|
Hosted user code receives neither a tenant API key nor the private runtime
|
|
52
59
|
credential and does not perform `/api/v1/me` discovery. The generated parent
|
|
@@ -64,7 +71,7 @@ separate initialization method.
|
|
|
64
71
|
```js
|
|
65
72
|
/** @param {import('@revoengine/sdk').RevoRuntime} runtime */
|
|
66
73
|
export async function init(runtime) {
|
|
67
|
-
const { api, utils, storage, agents, batch } = runtime;
|
|
74
|
+
const { api, utils, storage, agents, execute, batch } = runtime;
|
|
68
75
|
const { data: rows, next } = await api.getDatabaseData('Sales', {
|
|
69
76
|
fields: ['saleId', 'customerId', 'total', 'createdAt'],
|
|
70
77
|
sort: ['-createdAt'],
|
|
@@ -186,6 +193,77 @@ console.log(result.data);
|
|
|
186
193
|
|
|
187
194
|
There is no `init()` or connection method.
|
|
188
195
|
|
|
196
|
+
## Execute active low-code libraries
|
|
197
|
+
|
|
198
|
+
`execute(code, options)` runs one transient JavaScript or TypeScript component inside
|
|
199
|
+
RevoEngine. The source has the normal low-code `api` and active tenant `libs.*`
|
|
200
|
+
surface. Library functions and source never move into the Node.js process; only the
|
|
201
|
+
JSON-serializable request and execution result cross the runtime transport.
|
|
202
|
+
|
|
203
|
+
Revo-hosted `CUSTOM_NODEJS`:
|
|
204
|
+
|
|
205
|
+
```js
|
|
206
|
+
/** @param {import('@revoengine/sdk').RevoRuntime} runtime */
|
|
207
|
+
export async function init(runtime) {
|
|
208
|
+
const customerId = runtime.api.input('customerId');
|
|
209
|
+
const execution = await runtime.execute(
|
|
210
|
+
`
|
|
211
|
+
const customerId = api.input('customerId');
|
|
212
|
+
const customer = await libs.Customers.Queries.get(customerId);
|
|
213
|
+
const balance = await libs.Billing.Balance.current(customerId);
|
|
214
|
+
return { customer, balance };
|
|
215
|
+
`,
|
|
216
|
+
{
|
|
217
|
+
inputs: { customerId },
|
|
218
|
+
timeoutMs: 10_000,
|
|
219
|
+
},
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
return execution.results;
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Standalone Node.js:
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
import { RevoClient } from '@revoengine/sdk';
|
|
230
|
+
|
|
231
|
+
const revo = new RevoClient({
|
|
232
|
+
apiKey: process.env.REVO_API_KEY,
|
|
233
|
+
executionDefaults: {
|
|
234
|
+
timeoutMs: 60_000,
|
|
235
|
+
memory: 256,
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
type CustomerSummary = {
|
|
240
|
+
customerId: string;
|
|
241
|
+
name: string;
|
|
242
|
+
balance: number;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const execution = await revo.execute<CustomerSummary>(
|
|
246
|
+
`
|
|
247
|
+
const customerId = api.input('customerId');
|
|
248
|
+
return libs.Customers.Summary.build(customerId);
|
|
249
|
+
`,
|
|
250
|
+
{
|
|
251
|
+
inputs: { customerId: 'customer-1' },
|
|
252
|
+
timeoutMs: 10_000,
|
|
253
|
+
},
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
console.log(execution.results);
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
JavaScript is selected with `language: 'javascript'`; TypeScript is the default.
|
|
260
|
+
The default timeout is 60 seconds. Standalone `executionDefaults` set reusable
|
|
261
|
+
language, timeout, or memory defaults, and per-call options override them.
|
|
262
|
+
One `execute()` call creates one isolated execution. Put related `libs.*`
|
|
263
|
+
operations in the same source when they belong to one workflow. Concurrent separate
|
|
264
|
+
calls still use the SDK's automatic JSON-RPC batching but execute in separate isolates.
|
|
265
|
+
Low-code runtime batches are not retried because source can perform writes.
|
|
266
|
+
|
|
189
267
|
### Environment configuration
|
|
190
268
|
|
|
191
269
|
```ts
|
|
@@ -216,6 +294,11 @@ const revo = new RevoClient({
|
|
|
216
294
|
baseUrl: 'https://api.revoengine.com',
|
|
217
295
|
apiKey,
|
|
218
296
|
requestTimeoutMs: 30_000,
|
|
297
|
+
executionDefaults: {
|
|
298
|
+
language: 'typescript',
|
|
299
|
+
timeoutMs: 60_000,
|
|
300
|
+
memory: 256,
|
|
301
|
+
},
|
|
219
302
|
batch: {
|
|
220
303
|
failureMode: 'independent',
|
|
221
304
|
maxCalls: 16,
|
|
@@ -267,7 +350,7 @@ mutations. If transport is interrupted after dispatch, unresolved calls reject
|
|
|
267
350
|
with `RevoTransportError` and `indeterminate: true`.
|
|
268
351
|
|
|
269
352
|
Batching is not a transaction. `api.transactionDatabaseData` is intentionally
|
|
270
|
-
not part of SDK
|
|
353
|
+
not part of the SDK.
|
|
271
354
|
|
|
272
355
|
## Local utils
|
|
273
356
|
|
|
@@ -323,6 +406,49 @@ Other context methods throw `RevoRuntimeContextUnavailableError` synchronously
|
|
|
323
406
|
outside a hosted execution. The distinct `RevoApi` and `RevoStandaloneApi` types
|
|
324
407
|
make the hosted snapshot and standalone discovery behavior explicit.
|
|
325
408
|
|
|
409
|
+
## HTTP calls
|
|
410
|
+
|
|
411
|
+
`api.httpCall(request, options)` supports ordinary JSON/text/base64/document responses
|
|
412
|
+
and HTTP-to-Storage transfers through both the standalone and hosted SDK:
|
|
413
|
+
|
|
414
|
+
```ts
|
|
415
|
+
const response = await revo.api.httpCall(
|
|
416
|
+
{ url: 'https://example.com/report.pdf', method: 'GET' },
|
|
417
|
+
{ responseType: 'storage', target: { name: 'report.pdf' } },
|
|
418
|
+
);
|
|
419
|
+
if (response.status >= 200 && response.status < 300 && response.storage) {
|
|
420
|
+
console.log(response.storage.entry);
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
Use `requestType: 'storage'` with `source: { storageEntryId }` for a Storage request
|
|
425
|
+
body. Request and response modes are independent. Source/target references are flat
|
|
426
|
+
Storage objects; Files, nested `storage` and raw string identifiers are rejected.
|
|
427
|
+
Targets can create an entry, replace it using `{ storageEntryId, replace: true }`,
|
|
428
|
+
or fill and finalize an existing empty direct session using `{ storageUploadSessionId }`.
|
|
429
|
+
Only 2xx responses write Storage; other statuses return bounded diagnostic data.
|
|
430
|
+
|
|
431
|
+
`responseType: 'stream'` (bytes/SSE) is deliberately absent from SDK declarations
|
|
432
|
+
and rejects before discovery, queueing or transport, including the hosted
|
|
433
|
+
`CUSTOM_NODEJS` bridge. Storage responses remain supported. Local low-code V8 and
|
|
434
|
+
agent `code_exec` do support stream iterators: consume them inside the low-code
|
|
435
|
+
body, then return bounded serializable data. An SDK `execute(...)` call may run
|
|
436
|
+
such a body; it cannot return its iterator through the JSON transport.
|
|
437
|
+
|
|
438
|
+
### Developing coordinated platform contracts
|
|
439
|
+
|
|
440
|
+
After regenerating platform declarations, synchronize this checkout with:
|
|
441
|
+
|
|
442
|
+
```sh
|
|
443
|
+
REVOENGINE_PLATFORM_PATH=/path/to/platform node scripts/sync-contract.mjs --working-tree
|
|
444
|
+
REVOENGINE_PLATFORM_PATH=/path/to/platform npm run contract:check -- --working-tree
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
Working-tree snapshots are explicitly unreleasable: the normal provenance/CI check
|
|
448
|
+
continues to require committed platform sources. After committing the platform
|
|
449
|
+
changes, run `sync-contract.mjs` without `--working-tree`, then run the normal
|
|
450
|
+
`contract:check` against that pinned commit before releasing the SDK.
|
|
451
|
+
|
|
326
452
|
## Storage
|
|
327
453
|
|
|
328
454
|
### Small text or binary objects
|
|
@@ -628,12 +754,12 @@ Common subclasses include:
|
|
|
628
754
|
- `RevoProtocolError`
|
|
629
755
|
- `RevoTransportError`
|
|
630
756
|
|
|
631
|
-
## SDK
|
|
757
|
+
## SDK compatibility notes
|
|
632
758
|
|
|
633
759
|
- Node.js 22 or newer is required.
|
|
634
760
|
- The package provides ESM, CommonJS, and TypeScript declarations.
|
|
635
761
|
- The package has no runtime dependencies.
|
|
636
|
-
- No package-level `api`, `utils`, `storage`, or `
|
|
762
|
+
- No package-level `api`, `utils`, `storage`, `agents`, or `execute` singleton is exported.
|
|
637
763
|
- Deprecated low-code methods and aliases are excluded.
|
|
638
|
-
- `api.transactionDatabaseData` is excluded
|
|
764
|
+
- `api.transactionDatabaseData` is excluded.
|
|
639
765
|
- Runtime batches are non-transactional and are not retried automatically.
|