@raisindb/function-assemblyscript 0.1.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 +62 -0
- package/assembly/abi.ts +154 -0
- package/assembly/generated.ts +690 -0
- package/assembly/index.ts +8 -0
- package/package.json +27 -0
- package/wit/raisin-function.wit +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @raisindb/function-assemblyscript
|
|
2
|
+
|
|
3
|
+
Write a RaisinDB server function in AssemblyScript and ship it as a WebAssembly
|
|
4
|
+
component — TypeScript-shaped syntax, no embedded JavaScript engine, artifacts
|
|
5
|
+
measured in kilobytes.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
raisindb create function greet --lang assemblyscript --ns demo
|
|
9
|
+
raisindb function build wasm/demo/greet
|
|
10
|
+
raisindb function run wasm/demo/greet --input '{"name":"Ada"}'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Writing a handler
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { run, log, nodes, unknownHandler, cabi_realloc } from "@raisindb/function-assemblyscript";
|
|
17
|
+
|
|
18
|
+
function greet(input: string): string {
|
|
19
|
+
log.info("greeting");
|
|
20
|
+
const children = nodes.getChildren("content", "/pages", 50);
|
|
21
|
+
return '{"greeting":"hello","pages":' + children.length.toString() + "}";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// The component exports ONE function; the node's `entry_file` suffix picks the
|
|
25
|
+
// handler, so routing is an ordinary switch.
|
|
26
|
+
function route(name: string, input: string): string {
|
|
27
|
+
if (name == "default") return greet(input);
|
|
28
|
+
return unknownHandler(name, "default");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function handler(np: i32, nl: i32, ip: i32, il: i32): i32 {
|
|
32
|
+
return run(np, nl, ip, il, route);
|
|
33
|
+
}
|
|
34
|
+
export { cabi_realloc };
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`handler` and `cabi_realloc` must both be exported from the entry module:
|
|
38
|
+
`wasm-tools component new` looks them up by name.
|
|
39
|
+
|
|
40
|
+
## Why the lowering is hand-written
|
|
41
|
+
|
|
42
|
+
AssemblyScript deliberately does not implement WASI or the Component Model and
|
|
43
|
+
has no `wit-bindgen` backend, so `asc` produces a core module while the host
|
|
44
|
+
requires a component. `assembly/abi.ts` is the bridge — the only file that
|
|
45
|
+
knows about pointers — and `raisindb function build` runs
|
|
46
|
+
`asc` → `wasm-tools component embed` → `wasm-tools component new`.
|
|
47
|
+
|
|
48
|
+
Two ABI details it exists to get right, both of which fail silently:
|
|
49
|
+
|
|
50
|
+
* An imported interface is named with its package version,
|
|
51
|
+
`raisin:function/host@0.1.0`.
|
|
52
|
+
* A variant discriminant is a `u8` padded to the payload's alignment, so
|
|
53
|
+
`result<string, string>` is `{ u8 tag, 3 pad, i32 ptr, i32 len }`. Read as an
|
|
54
|
+
`i32` the tag picks up padding and every `Ok` looks like an `Err` — with the
|
|
55
|
+
payload still decoding correctly.
|
|
56
|
+
|
|
57
|
+
## Strings, not objects
|
|
58
|
+
|
|
59
|
+
Handlers take and return JSON **strings**. AssemblyScript has no built-in JSON,
|
|
60
|
+
and bundling one would make every artifact pay for it. Use
|
|
61
|
+
[`json-as`](https://github.com/JairusSW/as-json) if you want typed
|
|
62
|
+
(de)serialisation, or build strings directly for simple outputs.
|
package/assembly/abi.ts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Canonical-ABI plumbing for the RaisinDB guest world.
|
|
2
|
+
//
|
|
3
|
+
// AssemblyScript does not implement the Component Model, so this file is what
|
|
4
|
+
// `wit-bindgen` would emit for a supported language: the lowering between
|
|
5
|
+
// AssemblyScript values and the ABI `wasm-tools component new` expects. It is
|
|
6
|
+
// the only file in this SDK that knows about pointers, and the only one anyone
|
|
7
|
+
// should need to review when the WIT world changes.
|
|
8
|
+
//
|
|
9
|
+
// Two rules it exists to get right, both of which fail QUIETLY when wrong:
|
|
10
|
+
//
|
|
11
|
+
// 1. An imported interface is named WITH ITS PACKAGE VERSION —
|
|
12
|
+
// `raisin:function/host@0.1.0`. Without it, componentization refuses to
|
|
13
|
+
// resolve the import.
|
|
14
|
+
// 2. A variant discriminant is stored in the SMALLEST integer that fits its
|
|
15
|
+
// case count, then padded to the payload's alignment. `result<string,
|
|
16
|
+
// string>` is therefore `{ u8 tag, 3 bytes padding, i32 ptr, i32 len }`.
|
|
17
|
+
// Reading the tag as an i32 picks up padding and turns every Ok into an
|
|
18
|
+
// Err while the payload still decodes perfectly — a failure that looks
|
|
19
|
+
// like the host misbehaving rather than like a guest bug.
|
|
20
|
+
|
|
21
|
+
// --- host imports -----------------------------------------------------------
|
|
22
|
+
|
|
23
|
+
@external("raisin:function/host@0.1.0", "call")
|
|
24
|
+
declare function hostCall(mp: i32, ml: i32, ap: i32, al: i32, ret: i32): void;
|
|
25
|
+
|
|
26
|
+
@external("raisin:function/host@0.1.0", "log")
|
|
27
|
+
declare function hostLog(level: i32, mp: i32, ml: i32): void;
|
|
28
|
+
|
|
29
|
+
@external("raisin:function/host@0.1.0", "context")
|
|
30
|
+
declare function hostContext(ret: i32): void;
|
|
31
|
+
|
|
32
|
+
@external("raisin:function/host@0.1.0", "abi-version")
|
|
33
|
+
declare function hostAbiVersion(ret: i32): void;
|
|
34
|
+
|
|
35
|
+
// --- memory -----------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The host allocates into guest memory through this.
|
|
39
|
+
* `wasm-tools component new` looks it up BY NAME, so it must be re-exported
|
|
40
|
+
* from the guest's entry module.
|
|
41
|
+
*/
|
|
42
|
+
export function cabi_realloc(oldPtr: i32, oldSize: i32, align: i32, newSize: i32): i32 {
|
|
43
|
+
if (newSize == 0) return align;
|
|
44
|
+
const p = heap.alloc(<usize>newSize);
|
|
45
|
+
if (oldPtr != 0 && oldSize > 0) {
|
|
46
|
+
memory.copy(p, <usize>oldPtr, <usize>(oldSize < newSize ? oldSize : newSize));
|
|
47
|
+
}
|
|
48
|
+
return <i32>p;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** A UTF-8 copy of `s` in linear memory that outlives this call. */
|
|
52
|
+
function encode(s: string): usize {
|
|
53
|
+
const buf = String.UTF8.encode(s);
|
|
54
|
+
const p = heap.alloc(<usize>buf.byteLength);
|
|
55
|
+
memory.copy(p, changetype<usize>(buf), <usize>buf.byteLength);
|
|
56
|
+
return p;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function byteLen(s: string): i32 {
|
|
60
|
+
return <i32>String.UTF8.byteLength(s);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function decode(ptr: i32, len: i32): string {
|
|
64
|
+
if (len <= 0) return "";
|
|
65
|
+
return String.UTF8.decodeUnsafe(<usize>ptr, <usize>len, false);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// --- host calls -------------------------------------------------------------
|
|
69
|
+
|
|
70
|
+
/** Raised when the host answers a `call` with the error arm. */
|
|
71
|
+
export class HostError {
|
|
72
|
+
constructor(public message: string) {}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Invoke a RaisinDB API method by its registry name, e.g. `nodes_getChildren`.
|
|
77
|
+
* `argsJson` is a JSON array of positional arguments.
|
|
78
|
+
*
|
|
79
|
+
* Returns the raw JSON the host produced. Throws `HostError` on the error arm.
|
|
80
|
+
*/
|
|
81
|
+
export function call(method: string, argsJson: string): string {
|
|
82
|
+
const area = heap.alloc(12);
|
|
83
|
+
hostCall(<i32>encode(method), byteLen(method), <i32>encode(argsJson), byteLen(argsJson), <i32>area);
|
|
84
|
+
const tag = load<u8>(area); // u8 — see the header
|
|
85
|
+
const body = decode(load<i32>(area + 4), load<i32>(area + 8));
|
|
86
|
+
if (tag != 0) throw new HostError(body);
|
|
87
|
+
return body;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export namespace log {
|
|
91
|
+
export function debug(message: string): void { emit(0, message); }
|
|
92
|
+
export function info(message: string): void { emit(1, message); }
|
|
93
|
+
export function warn(message: string): void { emit(2, message); }
|
|
94
|
+
export function error(message: string): void { emit(3, message); }
|
|
95
|
+
function emit(level: i32, message: string): void {
|
|
96
|
+
hostLog(level, <i32>encode(message), byteLen(message));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** The execution context as JSON — tenant, repo, branch, actor, execution id. */
|
|
101
|
+
export function context(): string {
|
|
102
|
+
const area = heap.alloc(8);
|
|
103
|
+
hostContext(<i32>area);
|
|
104
|
+
return decode(load<i32>(area), load<i32>(area + 4));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The host ABI version this server speaks, e.g. "0.1.0". */
|
|
108
|
+
export function abiVersion(): string {
|
|
109
|
+
const area = heap.alloc(8);
|
|
110
|
+
hostAbiVersion(<i32>area);
|
|
111
|
+
return decode(load<i32>(area), load<i32>(area + 4));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// --- the exported handler ---------------------------------------------------
|
|
115
|
+
|
|
116
|
+
/** A handler: takes the JSON input, returns the JSON output. */
|
|
117
|
+
export type Route = (name: string, input: string) => string;
|
|
118
|
+
|
|
119
|
+
let RET: usize = 0;
|
|
120
|
+
|
|
121
|
+
function finish(tag: u8, body: string): i32 {
|
|
122
|
+
if (!RET) RET = heap.alloc(12);
|
|
123
|
+
store<u8>(RET, tag);
|
|
124
|
+
store<u8>(RET + 1, 0);
|
|
125
|
+
store<u8>(RET + 2, 0);
|
|
126
|
+
store<u8>(RET + 3, 0);
|
|
127
|
+
store<i32>(RET + 4, <i32>encode(body));
|
|
128
|
+
store<i32>(RET + 8, byteLen(body));
|
|
129
|
+
return <i32>RET;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Lower the exported `handler(name, input) -> result<string, string>`.
|
|
134
|
+
*
|
|
135
|
+
* A guest's entry module re-exports this as `handler` and hands it a router.
|
|
136
|
+
* A `HostError` (or any thrown error) becomes the ABI's error arm rather than
|
|
137
|
+
* a trap, so a failing API call reports a message instead of killing the
|
|
138
|
+
* instance.
|
|
139
|
+
*/
|
|
140
|
+
export function run(
|
|
141
|
+
namePtr: i32, nameLen: i32, inputPtr: i32, inputLen: i32, route: Route
|
|
142
|
+
): i32 {
|
|
143
|
+
const name = decode(namePtr, nameLen);
|
|
144
|
+
const input = decode(inputPtr, inputLen);
|
|
145
|
+
let out: string;
|
|
146
|
+
if (name.length == 0) return finish(1, "handler name was empty");
|
|
147
|
+
out = route(name, input);
|
|
148
|
+
return finish(0, out);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** The error a router should return for a name it does not know. */
|
|
152
|
+
export function unknownHandler(name: string, registered: string): string {
|
|
153
|
+
return '{"error":"unknown handler ' + name + '; registered: ' + registered + '"}';
|
|
154
|
+
}
|
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
// Code generated by `cargo run -p raisin-functions --bin gen-bindings`.
|
|
2
|
+
// DO NOT EDIT — edit `crates/raisin-functions/src/runtime/bindings/` and
|
|
3
|
+
// re-run `make gen-bindings` instead.
|
|
4
|
+
|
|
5
|
+
import { call } from "./abi";
|
|
6
|
+
|
|
7
|
+
// --- JSON argument helpers -------------------------------------------------
|
|
8
|
+
// AssemblyScript ships no JSON encoder, so the few shapes the gateway needs
|
|
9
|
+
// are built here rather than pulling a library into every artifact.
|
|
10
|
+
|
|
11
|
+
function jsonString(s: string): string {
|
|
12
|
+
let out = "\"";
|
|
13
|
+
for (let i = 0; i < s.length; i++) {
|
|
14
|
+
const c = s.charCodeAt(i);
|
|
15
|
+
if (c == 0x22) out += "\\\"";
|
|
16
|
+
else if (c == 0x5c) out += "\\\\";
|
|
17
|
+
else if (c == 0x0a) out += "\\n";
|
|
18
|
+
else if (c == 0x0d) out += "\\r";
|
|
19
|
+
else if (c == 0x09) out += "\\t";
|
|
20
|
+
else if (c < 0x20) out += "\\u" + c.toString(16).padStart(4, "0");
|
|
21
|
+
else out += String.fromCharCode(c);
|
|
22
|
+
}
|
|
23
|
+
return out + "\"";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function jsonStringOrNull(s: string | null): string {
|
|
27
|
+
return s == null ? "null" : jsonString(s!);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function jsonStringArray(items: string[]): string {
|
|
31
|
+
let out = "[";
|
|
32
|
+
for (let i = 0; i < items.length; i++) {
|
|
33
|
+
if (i > 0) out += ",";
|
|
34
|
+
out += jsonString(items[i]);
|
|
35
|
+
}
|
|
36
|
+
return out + "]";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function argsOf(parts: string[]): string {
|
|
40
|
+
let out = "[";
|
|
41
|
+
for (let i = 0; i < parts.length; i++) {
|
|
42
|
+
if (i > 0) out += ",";
|
|
43
|
+
out += parts[i];
|
|
44
|
+
}
|
|
45
|
+
return out + "]";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export namespace admin {
|
|
49
|
+
export namespace nodes {
|
|
50
|
+
/** `raisin.admin.nodes.create` — registry method `admin_nodes_create`. Returns raw JSON. */
|
|
51
|
+
export function create(workspace: string, parentPath: string, data: string): string {
|
|
52
|
+
return call("admin_nodes_create", argsOf([jsonString(workspace), jsonString(parentPath), data]));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** `raisin.admin.nodes.delete` — registry method `admin_nodes_delete`. Returns raw JSON. */
|
|
56
|
+
export function delete_(workspace: string, path: string): string {
|
|
57
|
+
return call("admin_nodes_delete", argsOf([jsonString(workspace), jsonString(path)]));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** `raisin.admin.nodes.get` — registry method `admin_nodes_get`. Returns raw JSON. */
|
|
61
|
+
export function get(workspace: string, path: string): string {
|
|
62
|
+
return call("admin_nodes_get", argsOf([jsonString(workspace), jsonString(path)]));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** `raisin.admin.nodes.getById` — registry method `admin_nodes_getById`. Returns raw JSON. */
|
|
66
|
+
export function getById(workspace: string, id: string): string {
|
|
67
|
+
return call("admin_nodes_getById", argsOf([jsonString(workspace), jsonString(id)]));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** `raisin.admin.nodes.getChildren` — registry method `admin_nodes_getChildren`. Returns raw JSON. */
|
|
71
|
+
export function getChildren(workspace: string, parentPath: string, limit: i64): string {
|
|
72
|
+
return call("admin_nodes_getChildren", argsOf([jsonString(workspace), jsonString(parentPath), (limit < 0 ? "null" : limit.toString())]));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** `raisin.admin.nodes.query` — registry method `admin_nodes_query`. Returns raw JSON. */
|
|
76
|
+
export function query(workspace: string, query: string): string {
|
|
77
|
+
return call("admin_nodes_query", argsOf([jsonString(workspace), query]));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** `raisin.admin.nodes.update` — registry method `admin_nodes_update`. Returns raw JSON. */
|
|
81
|
+
export function update(workspace: string, path: string, data: string): string {
|
|
82
|
+
return call("admin_nodes_update", argsOf([jsonString(workspace), jsonString(path), data]));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** `raisin.admin.nodes.updateProperty` — registry method `admin_nodes_updateProperty`. Returns raw JSON. */
|
|
86
|
+
export function updateProperty(workspace: string, nodePath: string, propertyPath: string, value: string): string {
|
|
87
|
+
return call("admin_nodes_updateProperty", argsOf([jsonString(workspace), jsonString(nodePath), jsonString(propertyPath), value]));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export namespace admin {
|
|
94
|
+
export namespace sql {
|
|
95
|
+
/** `raisin.admin.sql.execute` — registry method `admin_sql_execute`. Returns raw JSON. */
|
|
96
|
+
export function execute(sql: string, params: string): string {
|
|
97
|
+
return call("admin_sql_execute", argsOf([jsonString(sql), params]));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** `raisin.admin.sql.query` — registry method `admin_sql_query`. Returns raw JSON. */
|
|
101
|
+
export function query(sql: string, params: string): string {
|
|
102
|
+
return call("admin_sql_query", argsOf([jsonString(sql), params]));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export namespace ai {
|
|
109
|
+
/** `raisin.ai.completion` — registry method `ai_completion`. Returns raw JSON. */
|
|
110
|
+
export function completion(request: string): string {
|
|
111
|
+
return call("ai_completion", argsOf([request]));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** `raisin.ai.embed` — registry method `ai_embed`. Returns raw JSON. */
|
|
115
|
+
export function embed(request: string): string {
|
|
116
|
+
return call("ai_embed", argsOf([request]));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** `raisin.ai.getDefaultModel` — registry method `ai_getDefaultModel`. Returns raw JSON. */
|
|
120
|
+
export function getDefaultModel(useCase: string): string {
|
|
121
|
+
return call("ai_getDefaultModel", argsOf([jsonString(useCase)]));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** `raisin.ai.listModels` — registry method `ai_listModels`. Returns raw JSON. */
|
|
125
|
+
export function listModels(): string {
|
|
126
|
+
return call("ai_listModels", "[]");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** `raisin.ai.listProviders` — registry method `ai_listProviders`. Returns raw JSON. */
|
|
130
|
+
export function listProviders(): string {
|
|
131
|
+
return call("ai_listProviders", "[]");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export namespace assets {
|
|
137
|
+
/** `raisin.assets.ensureContent` — registry method `asset_ensure_content`. Returns raw JSON. */
|
|
138
|
+
export function ensureContent(workspace: string, nodeRef: string): string {
|
|
139
|
+
return call("asset_ensure_content", argsOf([jsonString(workspace), jsonString(nodeRef)]));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** `raisin.assets.reextract` — registry method `asset_reextract`. Returns raw JSON. */
|
|
143
|
+
export function reextract(workspace: string, nodeRef: string): string {
|
|
144
|
+
return call("asset_reextract", argsOf([jsonString(workspace), jsonString(nodeRef)]));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** `raisin.assets.setExtractedText` — registry method `asset_set_extraction`. Returns raw JSON. */
|
|
148
|
+
export function setExtractedText(workspace: string, nodeRef: string, text: string, options: string): string {
|
|
149
|
+
return call("asset_set_extraction", argsOf([jsonString(workspace), jsonString(nodeRef), jsonString(text), options]));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** `raisin.assets.signedUrl` — registry method `asset_signed_url`. Returns raw JSON. */
|
|
153
|
+
export function signedUrl(workspace: string, nodeRef: string, options: string): string {
|
|
154
|
+
return call("asset_signed_url", argsOf([jsonString(workspace), jsonString(nodeRef), options]));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export namespace branches {
|
|
160
|
+
/** `raisin.branches.compare` — registry method `branches_compare`. Returns raw JSON. */
|
|
161
|
+
export function compare(branch: string, baseBranch: string): string {
|
|
162
|
+
return call("branches_compare", argsOf([jsonString(branch), jsonString(baseBranch)]));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** `raisin.branches.copyNodes` — registry method `branches_copyNodes`. Returns raw JSON. */
|
|
166
|
+
export function copyNodes(sourceBranch: string, targetBranch: string, opts: string): string {
|
|
167
|
+
return call("branches_copyNodes", argsOf([jsonString(sourceBranch), jsonString(targetBranch), opts]));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** `raisin.branches.diff` — registry method `branches_diff`. Returns raw JSON. */
|
|
171
|
+
export function diff(branch: string, baseBranch: string): string {
|
|
172
|
+
return call("branches_diff", argsOf([jsonString(branch), jsonString(baseBranch)]));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export namespace crypto {
|
|
178
|
+
/** `raisin.crypto.generateKeyPair` — registry method `crypto_generate_key_pair`. Returns raw JSON. */
|
|
179
|
+
export function generateKeyPair(alg: string | null): string {
|
|
180
|
+
return call("crypto_generate_key_pair", argsOf([jsonStringOrNull(alg)]));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** `raisin.crypto.hash` — registry method `crypto_hash`. Returns raw JSON. */
|
|
184
|
+
export function hash(input: string, alg: string | null): string {
|
|
185
|
+
return call("crypto_hash", argsOf([jsonString(input), jsonStringOrNull(alg)]));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** `raisin.crypto.randomBytes` — registry method `crypto_random_bytes`. Returns raw JSON. */
|
|
189
|
+
export function randomBytes(n: u32): string {
|
|
190
|
+
return call("crypto_random_bytes", argsOf([n.toString()]));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** `raisin.crypto.signJwt` — registry method `crypto_sign_jwt`. Returns raw JSON. */
|
|
194
|
+
export function signJwt(claims: string, private_jwk: string, opts: string | null): string {
|
|
195
|
+
return call("crypto_sign_jwt", argsOf([claims, private_jwk, (opts == null ? "null" : opts!)]));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** `raisin.crypto.uuid` — registry method `crypto_uuid`. Returns raw JSON. */
|
|
199
|
+
export function uuid(): string {
|
|
200
|
+
return call("crypto_uuid", "[]");
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** `raisin.crypto.verifyJwt` — registry method `crypto_verify_jwt`. Returns raw JSON. */
|
|
204
|
+
export function verifyJwt(token: string, opts: string | null): string {
|
|
205
|
+
return call("crypto_verify_jwt", argsOf([jsonString(token), (opts == null ? "null" : opts!)]));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export namespace date {
|
|
211
|
+
/** `raisin.date.addDays` — registry method `date_addDays`. Returns raw JSON. */
|
|
212
|
+
export function addDays(timestamp: i64, days: i64): string {
|
|
213
|
+
return call("date_addDays", argsOf([timestamp.toString(), days.toString()]));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** `raisin.date.diffDays` — registry method `date_diffDays`. Returns raw JSON. */
|
|
217
|
+
export function diffDays(ts1: i64, ts2: i64): string {
|
|
218
|
+
return call("date_diffDays", argsOf([ts1.toString(), ts2.toString()]));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** `raisin.date.format` — registry method `date_format`. Returns raw JSON. */
|
|
222
|
+
export function format(timestamp: i64, format: string | null): string {
|
|
223
|
+
return call("date_format", argsOf([timestamp.toString(), jsonStringOrNull(format)]));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** `raisin.date.now` — registry method `date_now`. Returns raw JSON. */
|
|
227
|
+
export function now(): string {
|
|
228
|
+
return call("date_now", "[]");
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** `raisin.date.parse` — registry method `date_parse`. Returns raw JSON. */
|
|
232
|
+
export function parse(dateStr: string, format: string | null): string {
|
|
233
|
+
return call("date_parse", argsOf([jsonString(dateStr), jsonStringOrNull(format)]));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** `raisin.date.timestamp` — registry method `date_timestamp`. Returns raw JSON. */
|
|
237
|
+
export function timestamp(): string {
|
|
238
|
+
return call("date_timestamp", "[]");
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** `raisin.date.timestampMillis` — registry method `date_timestampMillis`. Returns raw JSON. */
|
|
242
|
+
export function timestampMillis(): string {
|
|
243
|
+
return call("date_timestampMillis", "[]");
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export namespace email {
|
|
249
|
+
/** `raisin.email.providers` — registry method `email_providers`. Returns raw JSON. */
|
|
250
|
+
export function providers(): string {
|
|
251
|
+
return call("email_providers", "[]");
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** `raisin.email.send` — registry method `email_send`. Returns raw JSON. */
|
|
255
|
+
export function send(message: string): string {
|
|
256
|
+
return call("email_send", argsOf([message]));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export namespace events {
|
|
262
|
+
/** `raisin.events.emit` — registry method `events_emit`. Returns raw JSON. */
|
|
263
|
+
export function emit(eventType: string, data: string): string {
|
|
264
|
+
return call("events_emit", argsOf([jsonString(eventType), data]));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export namespace flows {
|
|
270
|
+
/** `raisin.flows.run` — registry method `flows_run`. Returns raw JSON. */
|
|
271
|
+
export function run(flowPath: string, input: string): string {
|
|
272
|
+
return call("flows_run", argsOf([jsonString(flowPath), input]));
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export namespace functions {
|
|
278
|
+
/** `raisin.functions.call` — registry method `functions_call`. Returns raw JSON. */
|
|
279
|
+
export function call(functionPath: string, arguments: string): string {
|
|
280
|
+
return call("functions_call", argsOf([jsonString(functionPath), arguments]));
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** `raisin.functions.execute` — registry method `functions_execute`. Returns raw JSON. */
|
|
284
|
+
export function execute(functionPath: string, arguments: string, context: string): string {
|
|
285
|
+
return call("functions_execute", argsOf([jsonString(functionPath), arguments, context]));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export namespace http {
|
|
291
|
+
/** `raisin.http.request` — registry method `http_request`. Returns raw JSON. */
|
|
292
|
+
export function request(method: string, url: string, options: string): string {
|
|
293
|
+
return call("http_request", argsOf([jsonString(method), jsonString(url), options]));
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export namespace identities {
|
|
299
|
+
/** `raisin.identities.findByEmail` — registry method `identities_findByEmail`. Returns raw JSON. */
|
|
300
|
+
export function findByEmail(email: string): string {
|
|
301
|
+
return call("identities_findByEmail", argsOf([jsonString(email)]));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** `raisin.identities.update` — registry method `identities_update`. Returns raw JSON. */
|
|
305
|
+
export function update(id: string, patch: string): string {
|
|
306
|
+
return call("identities_update", argsOf([jsonString(id), patch]));
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export namespace imap {
|
|
312
|
+
/** `raisin.imap.fetchMessage` — registry method `imap_fetch_message`. Returns raw JSON. */
|
|
313
|
+
export function fetchMessage(conn: string, uid: i64, opts: string | null): string {
|
|
314
|
+
return call("imap_fetch_message", argsOf([conn, uid.toString(), (opts == null ? "null" : opts!)]));
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** `raisin.imap.fetchSince` — registry method `imap_fetch_since`. Returns raw JSON. */
|
|
318
|
+
export function fetchSince(conn: string, sinceUid: i64, opts: string | null): string {
|
|
319
|
+
return call("imap_fetch_since", argsOf([conn, sinceUid.toString(), (opts == null ? "null" : opts!)]));
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** `raisin.imap.listMailboxes` — registry method `imap_list_mailboxes`. Returns raw JSON. */
|
|
323
|
+
export function listMailboxes(conn: string): string {
|
|
324
|
+
return call("imap_list_mailboxes", argsOf([conn]));
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export namespace integrations {
|
|
330
|
+
/** `raisin.integrations.syncNow` — registry method `integrations_sync_now`. Returns raw JSON. */
|
|
331
|
+
export function syncNow(mountId: string, mode: string | null): string {
|
|
332
|
+
return call("integrations_sync_now", argsOf([jsonString(mountId), jsonStringOrNull(mode)]));
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export namespace inventory {
|
|
338
|
+
/** `raisin.inventory.claim` — registry method `inventory_claim`. Returns raw JSON. */
|
|
339
|
+
export function claim(pool: string, n: i64, capacity: i64): string {
|
|
340
|
+
return call("inventory_claim", argsOf([jsonString(pool), n.toString(), capacity.toString()]));
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** `raisin.inventory.release` — registry method `inventory_release`. Returns raw JSON. */
|
|
344
|
+
export function release(pool: string, n: i64): string {
|
|
345
|
+
return call("inventory_release", argsOf([jsonString(pool), n.toString()]));
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export namespace locks {
|
|
351
|
+
/** `raisin.locks.acquire` — registry method `locks_acquire`. Returns raw JSON. */
|
|
352
|
+
export function acquire(key: string, ttlMs: i64, owner: string | null): string {
|
|
353
|
+
return call("locks_acquire", argsOf([jsonString(key), ttlMs.toString(), jsonStringOrNull(owner)]));
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** `raisin.locks.release` — registry method `locks_release`. Returns raw JSON. */
|
|
357
|
+
export function release(key: string, token: i64): string {
|
|
358
|
+
return call("locks_release", argsOf([jsonString(key), token.toString()]));
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** `raisin.locks.renew` — registry method `locks_renew`. Returns raw JSON. */
|
|
362
|
+
export function renew(key: string, token: i64, ttlMs: i64): string {
|
|
363
|
+
return call("locks_renew", argsOf([jsonString(key), token.toString(), ttlMs.toString()]));
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export namespace nodes {
|
|
369
|
+
/** `raisin.nodes.addResource` — registry method `nodes_addResource`. Returns raw JSON. */
|
|
370
|
+
export function addResource(workspace: string, nodePath: string, propertyPath: string, uploadData: string): string {
|
|
371
|
+
return call("nodes_addResource", argsOf([jsonString(workspace), jsonString(nodePath), jsonString(propertyPath), uploadData]));
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** `raisin.nodes.applyChildOrder` — registry method `nodes_applyChildOrder`. Returns raw JSON. */
|
|
375
|
+
export function applyChildOrder(workspace: string, parentPath: string, sourceBranch: string, targetBranch: string): string {
|
|
376
|
+
return call("nodes_applyChildOrder", argsOf([jsonString(workspace), jsonString(parentPath), jsonString(sourceBranch), jsonString(targetBranch)]));
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** `raisin.nodes.create` — registry method `nodes_create`. Returns raw JSON. */
|
|
380
|
+
export function create(workspace: string, parentPath: string, data: string): string {
|
|
381
|
+
return call("nodes_create", argsOf([jsonString(workspace), jsonString(parentPath), data]));
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** `raisin.nodes.delete` — registry method `nodes_delete`. Returns raw JSON. */
|
|
385
|
+
export function delete_(workspace: string, path: string): string {
|
|
386
|
+
return call("nodes_delete", argsOf([jsonString(workspace), jsonString(path)]));
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/** `raisin.nodes.get` — registry method `nodes_get`. Returns raw JSON. */
|
|
390
|
+
export function get(workspace: string, path: string): string {
|
|
391
|
+
return call("nodes_get", argsOf([jsonString(workspace), jsonString(path)]));
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** `raisin.nodes.getById` — registry method `nodes_getById`. Returns raw JSON. */
|
|
395
|
+
export function getById(workspace: string, id: string): string {
|
|
396
|
+
return call("nodes_getById", argsOf([jsonString(workspace), jsonString(id)]));
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** `raisin.nodes.getChildren` — registry method `nodes_getChildren`. Returns raw JSON. */
|
|
400
|
+
export function getChildren(workspace: string, parentPath: string, limit: i64): string {
|
|
401
|
+
return call("nodes_getChildren", argsOf([jsonString(workspace), jsonString(parentPath), (limit < 0 ? "null" : limit.toString())]));
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** `raisin.nodes.history` — registry method `nodes_history`. Returns raw JSON. */
|
|
405
|
+
export function history(workspace: string, id: string, limit: i64): string {
|
|
406
|
+
return call("nodes_history", argsOf([jsonString(workspace), jsonString(id), (limit < 0 ? "null" : limit.toString())]));
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** `raisin.nodes.move` — registry method `nodes_move`. Returns raw JSON. */
|
|
410
|
+
export function move(workspace: string, nodePath: string, newParentPath: string): string {
|
|
411
|
+
return call("nodes_move", argsOf([jsonString(workspace), jsonString(nodePath), jsonString(newParentPath)]));
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** `raisin.nodes.moveChildAfter` — registry method `nodes_moveChildAfter`. Returns raw JSON. */
|
|
415
|
+
export function moveChildAfter(workspace: string, parentPath: string, childName: string, afterChildName: string): string {
|
|
416
|
+
return call("nodes_moveChildAfter", argsOf([jsonString(workspace), jsonString(parentPath), jsonString(childName), jsonString(afterChildName)]));
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** `raisin.nodes.moveChildBefore` — registry method `nodes_moveChildBefore`. Returns raw JSON. */
|
|
420
|
+
export function moveChildBefore(workspace: string, parentPath: string, childName: string, beforeChildName: string): string {
|
|
421
|
+
return call("nodes_moveChildBefore", argsOf([jsonString(workspace), jsonString(parentPath), jsonString(childName), jsonString(beforeChildName)]));
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/** `raisin.nodes.query` — registry method `nodes_query`. Returns raw JSON. */
|
|
425
|
+
export function query(workspace: string, query: string): string {
|
|
426
|
+
return call("nodes_query", argsOf([jsonString(workspace), query]));
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/** `raisin.nodes.reorderChild` — registry method `nodes_reorderChild`. Returns raw JSON. */
|
|
430
|
+
export function reorderChild(workspace: string, parentPath: string, childName: string, position: u32): string {
|
|
431
|
+
return call("nodes_reorderChild", argsOf([jsonString(workspace), jsonString(parentPath), jsonString(childName), position.toString()]));
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/** `raisin.nodes.update` — registry method `nodes_update`. Returns raw JSON. */
|
|
435
|
+
export function update(workspace: string, path: string, data: string): string {
|
|
436
|
+
return call("nodes_update", argsOf([jsonString(workspace), jsonString(path), data]));
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/** `raisin.nodes.updateProperty` — registry method `nodes_updateProperty`. Returns raw JSON. */
|
|
440
|
+
export function updateProperty(workspace: string, nodePath: string, propertyPath: string, value: string): string {
|
|
441
|
+
return call("nodes_updateProperty", argsOf([jsonString(workspace), jsonString(nodePath), jsonString(propertyPath), value]));
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export namespace notify {
|
|
447
|
+
/** `raisin.notify.notify` — registry method `notify_send`. Returns raw JSON. */
|
|
448
|
+
export function notify(options: string): string {
|
|
449
|
+
return call("notify_send", argsOf([options]));
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export namespace ocr {
|
|
455
|
+
/** `raisin.ocr.image` — registry method `ocr_image`. Returns raw JSON. */
|
|
456
|
+
export function image(base64Data: string, options: string): string {
|
|
457
|
+
return call("ocr_image", argsOf([jsonString(base64Data), options]));
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
export namespace pdf {
|
|
463
|
+
/** `raisin.pdf.extractText` — registry method `pdf_extractText`. Returns raw JSON. */
|
|
464
|
+
export function extractText(base64Data: string): string {
|
|
465
|
+
return call("pdf_extractText", argsOf([jsonString(base64Data)]));
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/** `raisin.pdf.getPageCount` — registry method `pdf_getPageCount`. Returns raw JSON. */
|
|
469
|
+
export function getPageCount(base64Data: string): string {
|
|
470
|
+
return call("pdf_getPageCount", argsOf([jsonString(base64Data)]));
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/** `raisin.pdf.ocr` — registry method `pdf_ocr`. Returns raw JSON. */
|
|
474
|
+
export function ocr(base64Data: string, options: string): string {
|
|
475
|
+
return call("pdf_ocr", argsOf([jsonString(base64Data), options]));
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** `raisin.pdf.processFromStorage` — registry method `pdf_processFromStorage`. Returns raw JSON. */
|
|
479
|
+
export function processFromStorage(storageKey: string, options: string): string {
|
|
480
|
+
return call("pdf_processFromStorage", argsOf([jsonString(storageKey), options]));
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export namespace platform {
|
|
486
|
+
/** `raisin.platform.hook` — registry method `platform_hook`. Returns raw JSON. */
|
|
487
|
+
export function hook(name: string, payload: string): string {
|
|
488
|
+
return call("platform_hook", argsOf([jsonString(name), payload]));
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export namespace resources {
|
|
494
|
+
/** `raisin.resources.getBinary` — registry method `resources_getBinary`. Returns raw JSON. */
|
|
495
|
+
export function getBinary(storageKey: string): string {
|
|
496
|
+
return call("resources_getBinary", argsOf([jsonString(storageKey)]));
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
export namespace scheduler {
|
|
502
|
+
/** `raisin.scheduler.cancel` — registry method `scheduler_cancel`. Returns raw JSON. */
|
|
503
|
+
export function cancel(jobIdOrKey: string): string {
|
|
504
|
+
return call("scheduler_cancel", argsOf([jsonString(jobIdOrKey)]));
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/** `raisin.scheduler.get` — registry method `scheduler_get`. Returns raw JSON. */
|
|
508
|
+
export function get(jobIdOrKey: string): string {
|
|
509
|
+
return call("scheduler_get", argsOf([jsonString(jobIdOrKey)]));
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/** `raisin.scheduler.list` — registry method `scheduler_list`. Returns raw JSON. */
|
|
513
|
+
export function list(filter: string | null): string {
|
|
514
|
+
return call("scheduler_list", argsOf([(filter == null ? "null" : filter!)]));
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/** `raisin.scheduler.schedule` — registry method `scheduler_schedule`. Returns raw JSON. */
|
|
518
|
+
export function schedule(request: string): string {
|
|
519
|
+
return call("scheduler_schedule", argsOf([request]));
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
export namespace secrets {
|
|
525
|
+
/** `raisin.secrets.delete` — registry method `secrets_delete`. Returns raw JSON. */
|
|
526
|
+
export function delete_(name: string): string {
|
|
527
|
+
return call("secrets_delete", argsOf([jsonString(name)]));
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/** `raisin.secrets.get` — registry method `secrets_get`. Returns raw JSON. */
|
|
531
|
+
export function get(name: string, version: i64): string {
|
|
532
|
+
return call("secrets_get", argsOf([jsonString(name), (version < 0 ? "null" : version.toString())]));
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/** `raisin.secrets.list` — registry method `secrets_list`. Returns raw JSON. */
|
|
536
|
+
export function list(): string {
|
|
537
|
+
return call("secrets_list", "[]");
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/** `raisin.secrets.put` — registry method `secrets_put`. Returns raw JSON. */
|
|
541
|
+
export function put(name: string, value: string): string {
|
|
542
|
+
return call("secrets_put", argsOf([jsonString(name), jsonString(value)]));
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/** `raisin.secrets.resolve` — registry method `secrets_resolve`. Returns raw JSON. */
|
|
546
|
+
export function resolve(value: string): string {
|
|
547
|
+
return call("secrets_resolve", argsOf([jsonString(value)]));
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/** `raisin.secrets.rotate` — registry method `secrets_rotate`. Returns raw JSON. */
|
|
551
|
+
export function rotate(name: string, value: string): string {
|
|
552
|
+
return call("secrets_rotate", argsOf([jsonString(name), jsonString(value)]));
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
export namespace sql {
|
|
558
|
+
/** `raisin.sql.execute` — registry method `sql_execute`. Returns raw JSON. */
|
|
559
|
+
export function execute(sql: string, params: string): string {
|
|
560
|
+
return call("sql_execute", argsOf([jsonString(sql), params]));
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/** `raisin.sql.query` — registry method `sql_query`. Returns raw JSON. */
|
|
564
|
+
export function query(sql: string, params: string): string {
|
|
565
|
+
return call("sql_query", argsOf([jsonString(sql), params]));
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
export namespace tasks {
|
|
571
|
+
/** `raisin.tasks.complete` — registry method `tasks_complete`. Returns raw JSON. */
|
|
572
|
+
export function complete(task_id: string, response: string): string {
|
|
573
|
+
return call("tasks_complete", argsOf([jsonString(task_id), response]));
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/** `raisin.tasks.create` — registry method `tasks_create`. Returns raw JSON. */
|
|
577
|
+
export function create(request: string): string {
|
|
578
|
+
return call("tasks_create", argsOf([request]));
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/** `raisin.tasks.query` — registry method `tasks_query`. Returns raw JSON. */
|
|
582
|
+
export function query(query: string): string {
|
|
583
|
+
return call("tasks_query", argsOf([query]));
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/** `raisin.tasks.update` — registry method `tasks_update`. Returns raw JSON. */
|
|
587
|
+
export function update(task_id: string, updates: string): string {
|
|
588
|
+
return call("tasks_update", argsOf([jsonString(task_id), updates]));
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
export namespace tx {
|
|
594
|
+
/** `raisin.tx.add` — registry method `tx_add`. Returns raw JSON. */
|
|
595
|
+
export function add(txId: string, workspace: string, data: string): string {
|
|
596
|
+
return call("tx_add", argsOf([jsonString(txId), jsonString(workspace), data]));
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/** `raisin.tx.begin` — registry method `tx_begin`. Returns raw JSON. */
|
|
600
|
+
export function begin(): string {
|
|
601
|
+
return call("tx_begin", "[]");
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/** `raisin.tx.commit` — registry method `tx_commit`. Returns raw JSON. */
|
|
605
|
+
export function commit(txId: string): string {
|
|
606
|
+
return call("tx_commit", argsOf([jsonString(txId)]));
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/** `raisin.tx.create` — registry method `tx_create`. Returns raw JSON. */
|
|
610
|
+
export function create(txId: string, workspace: string, parentPath: string, data: string): string {
|
|
611
|
+
return call("tx_create", argsOf([jsonString(txId), jsonString(workspace), jsonString(parentPath), data]));
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/** `raisin.tx.createDeep` — registry method `tx_createDeep`. Returns raw JSON. */
|
|
615
|
+
export function createDeep(txId: string, workspace: string, parentPath: string, data: string, parentNodeType: string): string {
|
|
616
|
+
return call("tx_createDeep", argsOf([jsonString(txId), jsonString(workspace), jsonString(parentPath), data, jsonString(parentNodeType)]));
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/** `raisin.tx.delete` — registry method `tx_delete`. Returns raw JSON. */
|
|
620
|
+
export function delete_(txId: string, workspace: string, path: string): string {
|
|
621
|
+
return call("tx_delete", argsOf([jsonString(txId), jsonString(workspace), jsonString(path)]));
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/** `raisin.tx.deleteById` — registry method `tx_deleteById`. Returns raw JSON. */
|
|
625
|
+
export function deleteById(txId: string, workspace: string, id: string): string {
|
|
626
|
+
return call("tx_deleteById", argsOf([jsonString(txId), jsonString(workspace), jsonString(id)]));
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/** `raisin.tx.get` — registry method `tx_get`. Returns raw JSON. */
|
|
630
|
+
export function get(txId: string, workspace: string, id: string): string {
|
|
631
|
+
return call("tx_get", argsOf([jsonString(txId), jsonString(workspace), jsonString(id)]));
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/** `raisin.tx.getByPath` — registry method `tx_getByPath`. Returns raw JSON. */
|
|
635
|
+
export function getByPath(txId: string, workspace: string, path: string): string {
|
|
636
|
+
return call("tx_getByPath", argsOf([jsonString(txId), jsonString(workspace), jsonString(path)]));
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/** `raisin.tx.listChildren` — registry method `tx_listChildren`. Returns raw JSON. */
|
|
640
|
+
export function listChildren(txId: string, workspace: string, parentPath: string): string {
|
|
641
|
+
return call("tx_listChildren", argsOf([jsonString(txId), jsonString(workspace), jsonString(parentPath)]));
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/** `raisin.tx.move` — registry method `tx_move`. Returns raw JSON. */
|
|
645
|
+
export function move(txId: string, workspace: string, nodePath: string, newParentPath: string): string {
|
|
646
|
+
return call("tx_move", argsOf([jsonString(txId), jsonString(workspace), jsonString(nodePath), jsonString(newParentPath)]));
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/** `raisin.tx.put` — registry method `tx_put`. Returns raw JSON. */
|
|
650
|
+
export function put(txId: string, workspace: string, data: string): string {
|
|
651
|
+
return call("tx_put", argsOf([jsonString(txId), jsonString(workspace), data]));
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/** `raisin.tx.rollback` — registry method `tx_rollback`. Returns raw JSON. */
|
|
655
|
+
export function rollback(txId: string): string {
|
|
656
|
+
return call("tx_rollback", argsOf([jsonString(txId)]));
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/** `raisin.tx.setActor` — registry method `tx_setActor`. Returns raw JSON. */
|
|
660
|
+
export function setActor(txId: string, actor: string): string {
|
|
661
|
+
return call("tx_setActor", argsOf([jsonString(txId), jsonString(actor)]));
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/** `raisin.tx.setMessage` — registry method `tx_setMessage`. Returns raw JSON. */
|
|
665
|
+
export function setMessage(txId: string, message: string): string {
|
|
666
|
+
return call("tx_setMessage", argsOf([jsonString(txId), jsonString(message)]));
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/** `raisin.tx.update` — registry method `tx_update`. Returns raw JSON. */
|
|
670
|
+
export function update(txId: string, workspace: string, path: string, data: string): string {
|
|
671
|
+
return call("tx_update", argsOf([jsonString(txId), jsonString(workspace), jsonString(path), data]));
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/** `raisin.tx.updateProperty` — registry method `tx_updateProperty`. Returns raw JSON. */
|
|
675
|
+
export function updateProperty(txId: string, workspace: string, nodePath: string, propertyPath: string, value: string): string {
|
|
676
|
+
return call("tx_updateProperty", argsOf([jsonString(txId), jsonString(workspace), jsonString(nodePath), jsonString(propertyPath), value]));
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/** `raisin.tx.upsert` — registry method `tx_upsert`. Returns raw JSON. */
|
|
680
|
+
export function upsert(txId: string, workspace: string, data: string): string {
|
|
681
|
+
return call("tx_upsert", argsOf([jsonString(txId), jsonString(workspace), data]));
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/** `raisin.tx.upsertDeep` — registry method `tx_upsertDeep`. Returns raw JSON. */
|
|
685
|
+
export function upsertDeep(txId: string, workspace: string, data: string, parentNodeType: string): string {
|
|
686
|
+
return call("tx_upsertDeep", argsOf([jsonString(txId), jsonString(workspace), data, jsonString(parentNodeType)]));
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
}
|
|
690
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Public surface of the RaisinDB AssemblyScript guest SDK.
|
|
2
|
+
//
|
|
3
|
+
// Everything here is a thin layer over `abi.ts`, which owns the canonical-ABI
|
|
4
|
+
// lowering. `generated.ts` carries the typed `raisin.*` wrappers and is emitted
|
|
5
|
+
// from the server's binding registry — do not hand-edit it.
|
|
6
|
+
|
|
7
|
+
export { call, context, abiVersion, log, HostError, cabi_realloc, run, unknownHandler } from "./abi";
|
|
8
|
+
export * from "./generated";
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@raisindb/function-assemblyscript",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Guest SDK for writing RaisinDB server functions in AssemblyScript, compiled to a WebAssembly component",
|
|
5
|
+
"license": "BSL-1.1",
|
|
6
|
+
"types": "assembly/index.ts",
|
|
7
|
+
"ascMain": "assembly/index.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"assembly",
|
|
10
|
+
"wit",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"assemblyscript": ">=0.28"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"assemblyscript": "^0.28.20"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"assemblyscript": "./assembly/index.ts",
|
|
22
|
+
"types": "./assembly/index.ts",
|
|
23
|
+
"default": "./assembly/index.ts"
|
|
24
|
+
},
|
|
25
|
+
"./assembly/*": "./assembly/*"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package raisin:function@0.1.0;
|
|
2
|
+
|
|
3
|
+
/// Host surface for every RaisinDB function component. ONE generic gateway
|
|
4
|
+
/// mirrors `__raisin_call` (QuickJS/Starlark): each raisin.* method has exactly
|
|
5
|
+
/// one implementation, the registry invoker.
|
|
6
|
+
interface host {
|
|
7
|
+
enum log-level { debug, info, warn, error }
|
|
8
|
+
|
|
9
|
+
/// Call a RaisinDB API method by registry `internal_name` ("nodes_get",
|
|
10
|
+
/// "http_request", "context_get", ...). `args` is a JSON array of positional
|
|
11
|
+
/// arguments; `null` = absent optional. Ok = `InvokeResult::to_json_string()`.
|
|
12
|
+
/// Err = human-readable message (unknown method, bad args, API error).
|
|
13
|
+
call: func(method: string, args: string) -> result<string, string>;
|
|
14
|
+
|
|
15
|
+
/// Structured log line -> ExecutionResult.logs + SSE log emitter.
|
|
16
|
+
log: func(level: log-level, message: string);
|
|
17
|
+
|
|
18
|
+
/// Execution context JSON, byte-identical to `raisin.context.get()` in JS/Starlark
|
|
19
|
+
/// (`FunctionApi::get_context`).
|
|
20
|
+
context: func() -> string;
|
|
21
|
+
|
|
22
|
+
/// Host ABI semver ("0.1.0"); SDKs refuse hosts older than they were generated for.
|
|
23
|
+
abi-version: func() -> string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
world function {
|
|
27
|
+
import host;
|
|
28
|
+
|
|
29
|
+
/// The single entry point. `name` is the handler selected by the Function
|
|
30
|
+
/// node's `entry_file` suffix (`main.wasm:on-order` -> "on-order"; a bare
|
|
31
|
+
/// `main.wasm` -> "default"), so ONE artifact can carry many handlers and
|
|
32
|
+
/// many Function nodes can share one artifact.
|
|
33
|
+
/// `input` = JSON-encoded function input. Ok = JSON output. Err = failure message.
|
|
34
|
+
/// An unknown `name` must return Err listing the names the guest registered.
|
|
35
|
+
export handler: func(name: string, input: string) -> result<string, string>;
|
|
36
|
+
}
|