rastack 0.0.42 → 0.0.44

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 (41) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/admin/AdminApp.tsx +308 -0
  3. package/admin/adapters.ts +247 -0
  4. package/admin/index.tsx +88 -0
  5. package/admin/useAdmin.ts +299 -0
  6. package/dist/admin.js +81 -0
  7. package/dist/dev/harness.d.ts +53 -0
  8. package/dist/dev/harness.js +151 -0
  9. package/dist/rastack-dev.d.ts +18 -0
  10. package/dist/rastack-dev.js +197 -0
  11. package/dist/rastack-init.d.ts +3 -2
  12. package/dist/rastack-init.js +23 -44
  13. package/dist/rastack-update.js +16 -8
  14. package/dist/rastack-wasm-build.d.ts +9 -4
  15. package/dist/rastack-wasm-build.js +44 -33
  16. package/dist/rastack.d.ts +1 -2
  17. package/dist/rastack.js +7 -10
  18. package/dist/update.d.ts +11 -0
  19. package/dist/update.js +14 -0
  20. package/dist/wasm/package.json +4 -0
  21. package/dist/wasm/rastack_wasm.d.ts +100 -0
  22. package/dist/wasm/rastack_wasm.js +745 -0
  23. package/dist/wasm/rastack_wasm_bg.wasm +0 -0
  24. package/dist/wasm/rastack_wasm_bg.wasm.d.ts +28 -0
  25. package/package.json +6 -2
  26. package/scripts/build-admin.js +48 -0
  27. package/scripts/copy-wasm.js +35 -0
  28. package/src/dev/harness.ts +130 -0
  29. package/src/rastack-dev.ts +197 -0
  30. package/src/rastack-init.ts +26 -62
  31. package/src/rastack-update.ts +22 -9
  32. package/src/rastack-wasm-build.ts +52 -41
  33. package/src/rastack.ts +7 -10
  34. package/src/update.ts +14 -0
  35. package/test/dev.spec.ts +277 -0
  36. package/test/update.spec.ts +13 -0
  37. package/wasm/package.json +4 -0
  38. package/wasm/rastack_wasm.d.ts +100 -0
  39. package/wasm/rastack_wasm.js +745 -0
  40. package/wasm/rastack_wasm_bg.wasm +0 -0
  41. package/wasm/rastack_wasm_bg.wasm.d.ts +28 -0
@@ -1,14 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * `rastack wasm` — compile the Rust API to WebAssembly for in-browser local dev.
4
+ * Compile the Rust API to WebAssembly for in-browser local dev — the engine
5
+ * `rastack dev` serves and `<RAStackProvider mode="local">` loads.
5
6
  *
6
7
  * Pipeline:
7
8
  * 1. cargo build -p rastack-wasm --release --target wasm32-unknown-unknown
8
- * 2. wasm-bindgen --target web → stack/wasm/rastack_wasm.js + rastack_wasm_bg.wasm
9
+ * 2. wasm-bindgen --target web → tools/wasm/rastack_wasm.js + rastack_wasm_bg.wasm
9
10
  * 3. wasm-opt -Oz (if available) to shrink the binary
10
11
  *
11
- * The generated bundle is what `<RAStackProvider mode="local">` loads. Prereqs:
12
+ * This is invoked by the release CI (to bundle a prebuilt engine into the npm
13
+ * package) and by `rastack dev` as a from-source fallback when no prebuilt
14
+ * bundle is present but the toolchain is. Prereqs:
12
15
  * rustup target add wasm32-unknown-unknown
13
16
  * cargo install wasm-bindgen-cli (version must match the wasm-bindgen crate)
14
17
  */
@@ -56,47 +59,55 @@ function has(cmd: string): boolean {
56
59
  return spawnSync(cmd, ["--version"], { stdio: "ignore" }).status === 0;
57
60
  }
58
61
 
59
- console.log("→ cargo build -p rastack-wasm --release (wasm32-unknown-unknown)");
60
- run(
61
- "cargo",
62
- [
63
- "build",
64
- "-p",
65
- "rastack-wasm",
66
- "--release",
62
+ /** Run the full compile → wasm-bindgen → optimise pipeline. Throws via `run`'s
63
+ * `process.exit` on a missing tool or a non-zero step. */
64
+ export function buildWasm(): void {
65
+ console.log(
66
+ "→ cargo build -p rastack-wasm --release (wasm32-unknown-unknown)",
67
+ );
68
+ run(
69
+ "cargo",
70
+ [
71
+ "build",
72
+ "-p",
73
+ "rastack-wasm",
74
+ "--release",
75
+ "--target",
76
+ "wasm32-unknown-unknown",
77
+ ],
78
+ rustDir,
79
+ );
80
+
81
+ console.log("→ wasm-bindgen → tools/wasm/");
82
+ run("wasm-bindgen", [
67
83
  "--target",
68
- "wasm32-unknown-unknown",
69
- ],
70
- rustDir,
71
- );
84
+ "web",
85
+ "--out-dir",
86
+ outDir,
87
+ "--out-name",
88
+ "rastack_wasm",
89
+ wasmPath,
90
+ ]);
72
91
 
73
- console.log("→ wasm-bindgen → stack/wasm/");
74
- run("wasm-bindgen", [
75
- "--target",
76
- "web",
77
- "--out-dir",
78
- outDir,
79
- "--out-name",
80
- "rastack_wasm",
81
- wasmPath,
82
- ]);
92
+ // Mark the emitted bundle as ESM so Node and bundlers treat it correctly
93
+ // without forcing the parent rastack package to be a module.
94
+ fs.writeFileSync(
95
+ path.join(outDir, "package.json"),
96
+ JSON.stringify({ type: "module", sideEffects: false }, null, 2) + "\n",
97
+ );
83
98
 
84
- // Mark the emitted bundle as ESM so Node and bundlers treat it correctly
85
- // without forcing the parent rastack package to be a module.
86
- fs.writeFileSync(
87
- path.join(outDir, "package.json"),
88
- JSON.stringify({ type: "module", sideEffects: false }, null, 2) + "\n",
89
- );
99
+ if (has("wasm-opt")) {
100
+ console.log("→ wasm-opt -Oz");
101
+ const bg = path.join(outDir, "rastack_wasm_bg.wasm");
102
+ run("wasm-opt", ["-Oz", "-o", bg, bg]);
103
+ } else {
104
+ console.log("· wasm-opt not found — skipping size optimisation (optional)");
105
+ }
90
106
 
91
- if (has("wasm-opt")) {
92
- console.log("→ wasm-opt -Oz");
93
- const bg = path.join(outDir, "rastack_wasm_bg.wasm");
94
- run("wasm-opt", ["-Oz", "-o", bg, bg]);
95
- } else {
96
- console.log("· wasm-opt not found — skipping size optimisation (optional)");
107
+ const size = fs.statSync(path.join(outDir, "rastack_wasm_bg.wasm")).size;
108
+ console.log(`✓ wasm engine built: tools/wasm/ (${(size / 1024).toFixed(0)} KB)`);
97
109
  }
98
110
 
99
- const size = fs.statSync(path.join(outDir, "rastack_wasm_bg.wasm")).size;
100
- console.log(
101
- `✓ wasm engine built: stack/wasm/ (${(size / 1024).toFixed(0)} KB)`,
102
- );
111
+ if (require.main === module) {
112
+ buildWasm();
113
+ }
package/src/rastack.ts CHANGED
@@ -11,9 +11,8 @@
11
11
  * rastack generate [--schema-only] Generate typed hooks from OpenAPI
12
12
  * rastack tokens [input] [outDir] Compile design tokens → CSS vars + typed theme
13
13
  * rastack design [input] [--port n] Live design-system studio (showcase + edit)
14
- * rastack serve [--warehouse dir] Run the Rust API over an Iceberg warehouse
14
+ * rastack dev [--port n] [--warehouse d] Local dev: run the app + admin in-browser over WASM
15
15
  * rastack admin [--warehouse dir] Run the Rust admin (Django-admin-style DB browser)
16
- * rastack wasm Compile the API to WebAssembly (in-browser local dev)
17
16
  * rastack scan [files...] [--fail-on-pii] Scan CSVs for PII and schema info
18
17
  * rastack seed [--env dev] [--source gs://] Load CSVs into Iceberg namespace
19
18
  * rastack bootstrap [--owner o] [--repo r] Stand the tier-0 AWS account stack up (once per account+region)
@@ -95,16 +94,14 @@ switch (command) {
95
94
  // rastack-compile dispatches on its own first argument, so pass the command.
96
95
  run("rastack-compile.js", [command, ...rest]);
97
96
  break;
98
- case "serve":
99
- runRust("serve");
97
+ case "dev":
98
+ // Local development: serve the app + admin in the browser over the WASM
99
+ // engine (no native server, no cargo). Replaces `serve` + `wasm`.
100
+ run("rastack-dev.js", rest);
100
101
  break;
101
102
  case "admin":
102
103
  runRust("admin");
103
104
  break;
104
- case "wasm":
105
- // Compile the API to WebAssembly for in-browser local dev.
106
- run("rastack-wasm-build.js", rest);
107
- break;
108
105
  case "tokens":
109
106
  // Design tokens → CSS custom properties + typed theme.
110
107
  run("rastack-tokens.js", rest);
@@ -156,8 +153,8 @@ switch (command) {
156
153
  ` rastack generate [--schema-only]\n` +
157
154
  ` rastack tokens [input] [outDir] [--prefix p] Compile design tokens → CSS vars + typed theme\n` +
158
155
  ` rastack design [input] [--port n] Live design-system studio (showcase + edit)\n` +
159
- ` rastack serve | admin [--warehouse dir]\n` +
160
- ` rastack wasm Compile the API to WebAssembly (browser local dev)\n` +
156
+ ` rastack dev [--port n] [--warehouse dir] [--no-open] Run the app + admin in-browser over WASM (local dev)\n` +
157
+ ` rastack admin [--warehouse dir] Run the native Rust admin (needs a built rastack-server)\n` +
161
158
  ` rastack scan [files...] [--fail-on-pii]\n` +
162
159
  ` rastack seed [--env dev|staging] [--source gs://bucket/ | ./myapp-dev/]\n` +
163
160
  ` rastack bootstrap [--owner o] [--repo r] [--region r] [--prefix p] [--reuse-oidc] [--print] Stand the AWS account stack up\n` +
package/src/update.ts CHANGED
@@ -90,6 +90,20 @@ export function npmSpawnShell(platform: string = process.platform): boolean {
90
90
  return platform === "win32";
91
91
  }
92
92
 
93
+ /**
94
+ * The single command string used to launch npm on platforms that must go through
95
+ * a shell (Windows — see `npmSpawnShell`). Node 22+ deprecates passing an args
96
+ * *array* together with `shell: true` (DEP0190: the args are concatenated, not
97
+ * escaped), so the shell path builds one string and runs it via `execSync`
98
+ * instead. Joining with spaces is safe here because every token is a fixed
99
+ * literal except the version, which `sanitizeVersion` constrains to
100
+ * `[A-Za-z0-9._-]` (no shell metacharacters). POSIX never uses this — it keeps
101
+ * the shell-free, array-based `execFile`, which has no concatenation at all.
102
+ */
103
+ export function npmShellCommand(binary: string, args: string[]): string {
104
+ return [binary, ...args].join(" ");
105
+ }
106
+
93
107
  /** The npm package spec to install for a target version. */
94
108
  export function installSpec(version: string): string {
95
109
  return !version || version === "latest" ? "rastack" : `rastack@${version}`;
@@ -0,0 +1,277 @@
1
+ import {
2
+ DEV_DEFAULTS,
3
+ WASM_ENTRY,
4
+ contentType,
5
+ parseDevArgs,
6
+ renderShell,
7
+ wasmBundleCandidates,
8
+ } from "../src/dev/harness";
9
+ import {
10
+ buildWriteBody,
11
+ changelistHeaders,
12
+ coerceFormValue,
13
+ errorDetail,
14
+ fieldControlType,
15
+ findResource,
16
+ formFields,
17
+ initialFormValues,
18
+ listPath,
19
+ detailPath,
20
+ optionLabel,
21
+ optionsFromRows,
22
+ pageCount,
23
+ parseManifest,
24
+ readListEnvelope,
25
+ PAGE_SIZE,
26
+ type AdminResource,
27
+ } from "../admin/adapters";
28
+
29
+ // -- harness core -----------------------------------------------------------
30
+
31
+ describe("rastack dev — arg parsing", () => {
32
+ it("defaults resources/out/warehouse/port and opens the browser", () => {
33
+ expect(parseDevArgs([])).toEqual(DEV_DEFAULTS);
34
+ expect(DEV_DEFAULTS.port).toBe(4321);
35
+ expect(DEV_DEFAULTS.warehouseDir).toBe("data/warehouse");
36
+ });
37
+
38
+ it("reads --port, --warehouse, --out, --no-open and a positional dir", () => {
39
+ const args = parseDevArgs([
40
+ "app/resources",
41
+ "--port",
42
+ "5000",
43
+ "--warehouse",
44
+ "data/wh",
45
+ "--out",
46
+ "build",
47
+ "--no-open",
48
+ ]);
49
+ expect(args).toEqual({
50
+ resourcesDir: "app/resources",
51
+ outDir: "build",
52
+ warehouseDir: "data/wh",
53
+ port: 5000,
54
+ open: false,
55
+ });
56
+ });
57
+
58
+ it("ignores a non-numeric --port (keeps the default)", () => {
59
+ expect(parseDevArgs(["--port", "abc"]).port).toBe(4321);
60
+ });
61
+ });
62
+
63
+ describe("rastack dev — content types", () => {
64
+ it("maps wasm to application/wasm (required for streaming instantiation)", () => {
65
+ expect(contentType("/wasm/rastack_wasm_bg.wasm")).toBe("application/wasm");
66
+ });
67
+ it("maps the common asset types", () => {
68
+ expect(contentType("/dev/admin.js")).toBe("text/javascript; charset=utf-8");
69
+ expect(contentType("/schema.rastack.json")).toBe(
70
+ "application/json; charset=utf-8",
71
+ );
72
+ expect(contentType("a/version-hint.text")).toBe("text/plain; charset=utf-8");
73
+ expect(contentType("data/v3.parquet")).toBe("application/octet-stream");
74
+ });
75
+ it("falls back to octet-stream for unknown extensions", () => {
76
+ expect(contentType("mystery.bin")).toBe("application/octet-stream");
77
+ });
78
+ });
79
+
80
+ describe("rastack dev — wasm bundle resolution", () => {
81
+ it("includes the installed dist/wasm and repo tools/wasm locations", () => {
82
+ const dirs = wasmBundleCandidates("/opt/rastack/dist", "/repo");
83
+ expect(dirs).toContain("/opt/rastack/dist/wasm");
84
+ expect(dirs).toContain("/repo/tools/wasm");
85
+ // The entry filename the resolver probes for.
86
+ expect(WASM_ENTRY).toBe("rastack_wasm.js");
87
+ });
88
+ });
89
+
90
+ describe("rastack dev — HTML shell", () => {
91
+ it("mounts #root and loads the bundled admin", () => {
92
+ const html = renderShell();
93
+ expect(html).toContain('<div id="root">');
94
+ expect(html).toContain('<script src="/dev/admin.js">');
95
+ expect(html.startsWith("<!doctype html>")).toBe(true);
96
+ });
97
+ });
98
+
99
+ // -- admin adapters ---------------------------------------------------------
100
+
101
+ /** The in-repo airline fixtures, in manifest JSON shape. */
102
+ const MANIFEST = {
103
+ version: 1,
104
+ resources: [
105
+ {
106
+ app: "airports",
107
+ model: "airport",
108
+ fields: [
109
+ { name: "code", type: "string", maxLength: 3, unique: true },
110
+ { name: "name", type: "string", maxLength: 120 },
111
+ ],
112
+ search: ["code", "name"],
113
+ admin: { listDisplay: ["code", "name"] },
114
+ },
115
+ {
116
+ app: "airports",
117
+ model: "terminal",
118
+ fields: [
119
+ {
120
+ name: "airport",
121
+ type: "fk",
122
+ relation: { app: "airports", model: "airport" },
123
+ },
124
+ { name: "label", type: "string", maxLength: 20 },
125
+ { name: "active", type: "bool", null: true },
126
+ ],
127
+ },
128
+ {
129
+ app: "airports",
130
+ model: "secret",
131
+ fields: [{ name: "value", type: "string" }],
132
+ admin: false,
133
+ },
134
+ ],
135
+ };
136
+
137
+ describe("admin adapters — manifest parsing", () => {
138
+ const resources = parseManifest(MANIFEST);
139
+
140
+ it("parses resources, fields, search, listDisplay and admin visibility", () => {
141
+ const airport = findResource(resources, "airports", "airport")!;
142
+ expect(airport.key).toBe("airports.airport");
143
+ expect(airport.label).toBe("Airport");
144
+ expect(airport.search).toEqual(["code", "name"]);
145
+ expect(airport.listDisplay).toEqual(["code", "name"]);
146
+ expect(airport.adminEnabled).toBe(true);
147
+
148
+ const secret = findResource(resources, "airports", "secret")!;
149
+ expect(secret.adminEnabled).toBe(false);
150
+ });
151
+
152
+ it("accepts a JSON string as well as an object", () => {
153
+ expect(parseManifest(JSON.stringify(MANIFEST)).length).toBe(3);
154
+ });
155
+
156
+ it("carries FK relation + nullability on fields", () => {
157
+ const terminal = findResource(resources, "airports", "terminal")!;
158
+ const fk = terminal.fields.find((f) => f.name === "airport")!;
159
+ expect(fk.type).toBe("fk");
160
+ expect(fk.relation).toEqual({ app: "airports", model: "airport" });
161
+ const active = terminal.fields.find((f) => f.name === "active")!;
162
+ expect(active.nullable).toBe(true);
163
+ });
164
+ });
165
+
166
+ describe("admin adapters — changelist", () => {
167
+ const resources = parseManifest(MANIFEST);
168
+ const airport = findResource(resources, "airports", "airport")!;
169
+ const terminal = findResource(resources, "airports", "terminal")!;
170
+
171
+ it("prepends an id column, then listDisplay (else all fields)", () => {
172
+ expect(changelistHeaders(airport).map((h) => h.key)).toEqual([
173
+ "id",
174
+ "code",
175
+ "name",
176
+ ]);
177
+ // terminal has no listDisplay → all fields after id
178
+ expect(changelistHeaders(terminal).map((h) => h.key)).toEqual([
179
+ "id",
180
+ "airport",
181
+ "label",
182
+ "active",
183
+ ]);
184
+ });
185
+
186
+ it("uses the admin's fixed page size and correct page count", () => {
187
+ expect(PAGE_SIZE).toBe(25);
188
+ expect(pageCount(0, 25)).toBe(1);
189
+ expect(pageCount(25, 25)).toBe(1);
190
+ expect(pageCount(26, 25)).toBe(2);
191
+ });
192
+
193
+ it("reads the DRF list envelope defensively", () => {
194
+ expect(readListEnvelope({ count: 2, results: [{ id: 1 }] })).toEqual({
195
+ count: 2,
196
+ results: [{ id: 1 }],
197
+ });
198
+ expect(readListEnvelope(undefined)).toEqual({ count: 0, results: [] });
199
+ });
200
+
201
+ it("builds the REST paths the WASM engine answers", () => {
202
+ expect(listPath("airports", "airport")).toBe("/api/airports/v1/airport/");
203
+ expect(detailPath("airports", "airport", 7)).toBe(
204
+ "/api/airports/v1/airport/7/",
205
+ );
206
+ });
207
+ });
208
+
209
+ describe("admin adapters — forms", () => {
210
+ const resources = parseManifest(MANIFEST);
211
+ const airport = findResource(resources, "airports", "airport")!;
212
+ const terminal = findResource(resources, "airports", "terminal")!;
213
+
214
+ it("chooses controls from the field datatype (FK → select)", () => {
215
+ const fk = terminal.fields.find((f) => f.name === "airport")!;
216
+ const label = terminal.fields.find((f) => f.name === "label")!;
217
+ const active = terminal.fields.find((f) => f.name === "active")!;
218
+ expect(fieldControlType(fk)).toBe("select");
219
+ expect(fieldControlType(label)).toBe("text");
220
+ expect(fieldControlType(active)).toBe("boolean");
221
+ });
222
+
223
+ it("seeds initial values (blank strings, false for booleans)", () => {
224
+ expect(initialFormValues(terminal)).toEqual({
225
+ airport: "",
226
+ label: "",
227
+ active: false,
228
+ });
229
+ });
230
+
231
+ it("coerces values like the Rust admin (numbers/bools parsed, empties omitted)", () => {
232
+ const fk = terminal.fields.find((f) => f.name === "airport")!;
233
+ const active = terminal.fields.find((f) => f.name === "active")!;
234
+ const label = terminal.fields.find((f) => f.name === "label")!;
235
+ expect(coerceFormValue(fk, "12")).toBe(12);
236
+ expect(coerceFormValue(active, "true")).toBe(true);
237
+ expect(coerceFormValue(active, false)).toBe(false);
238
+ expect(coerceFormValue(label, "")).toBeUndefined(); // omitted
239
+ });
240
+
241
+ it("builds a write body, omitting empty non-bool fields", () => {
242
+ const body = buildWriteBody(terminal, {
243
+ airport: "3",
244
+ label: "",
245
+ active: true,
246
+ });
247
+ expect(body).toEqual({ airport: 3, active: true });
248
+ expect("label" in body).toBe(false);
249
+ });
250
+
251
+ it("labels FK options by the first string field, else #id", () => {
252
+ expect(optionLabel({ id: 5, code: "JFK", name: "Kennedy" })).toBe(
253
+ "JFK (#5)",
254
+ );
255
+ expect(optionLabel({ id: 9 })).toBe("#9");
256
+ expect(optionsFromRows([{ id: 1, code: "LAX" }])).toEqual([
257
+ { label: "LAX (#1)", value: 1 },
258
+ ]);
259
+ });
260
+
261
+ it("form fields exclude the primary key", () => {
262
+ const withPk: AdminResource = {
263
+ ...airport,
264
+ fields: [
265
+ { name: "id", type: "int", primaryKey: true, nullable: false },
266
+ ...airport.fields,
267
+ ],
268
+ };
269
+ expect(formFields(withPk).map((f) => f.name)).toEqual(["code", "name"]);
270
+ });
271
+
272
+ it("extracts a {detail} error message", () => {
273
+ expect(errorDetail({ detail: "nope" })).toBe("nope");
274
+ expect(errorDetail("raw string")).toBe("raw string");
275
+ expect(errorDetail({})).toBe("Request failed");
276
+ });
277
+ });
@@ -4,6 +4,7 @@ import {
4
4
  installSpec,
5
5
  npmBinary,
6
6
  npmInstallArgs,
7
+ npmShellCommand,
7
8
  npmSpawnShell,
8
9
  parseUpdateFlags,
9
10
  sanitizeVersion,
@@ -67,6 +68,18 @@ describe("update — npm spec + args", () => {
67
68
  expect(npmSpawnShell("linux")).toBe(false);
68
69
  expect(npmSpawnShell("darwin")).toBe(false);
69
70
  });
71
+
72
+ it("joins the shell command as one string (avoids the Node DEP0190 warning)", () => {
73
+ // The Windows path runs npm via `execSync(<string>)` rather than
74
+ // `execFileSync(npm, args, { shell: true })`, which Node 22+ deprecates
75
+ // (args concatenated, not escaped). The sanitized version keeps it safe.
76
+ expect(npmShellCommand("npm.cmd", npmInstallArgs("latest"))).toBe(
77
+ "npm.cmd install -g rastack --no-fund --no-audit --loglevel=error",
78
+ );
79
+ expect(npmShellCommand("npm.cmd", npmInstallArgs("0.0.42"))).toContain(
80
+ "rastack@0.0.42",
81
+ );
82
+ });
70
83
  });
71
84
 
72
85
  describe("update — version sanitization", () => {
@@ -0,0 +1,4 @@
1
+ {
2
+ "type": "module",
3
+ "sideEffects": false
4
+ }
@@ -0,0 +1,100 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * The in-browser API engine. Cheap to clone (everything behind `Arc`), which
6
+ * is what lets each async call own its state without borrowing across `await`.
7
+ */
8
+ export class RastackApi {
9
+ free(): void;
10
+ [Symbol.dispose](): void;
11
+ /**
12
+ * Snapshot the entire warehouse to a blob for persistence (`data/` folder,
13
+ * IndexedDB, or an upload to S3).
14
+ */
15
+ exportWarehouse(): Promise<any>;
16
+ /**
17
+ * Handle one request. `query` is a `{ [k]: string }` object, `body` any
18
+ * JSON value (or `undefined`). Resolves to `{ status, body }`.
19
+ */
20
+ handle(method: string, path: string, query: any, body: any): Promise<any>;
21
+ /**
22
+ * Seed the warehouse from a blob previously produced by
23
+ * [`export_warehouse`](Self::export_warehouse) (the `data/` folder or an
24
+ * IndexedDB/OPFS snapshot).
25
+ */
26
+ importWarehouse(blob: Uint8Array): Promise<any>;
27
+ /**
28
+ * Build an engine from the compiled manifest (`schema.rastack.json`) and an
29
+ * optional OpenAPI document (`openapi.json`, served at `/api/schema/`).
30
+ */
31
+ constructor(manifest_json: string, openapi_json?: string | null);
32
+ /**
33
+ * Seed one Iceberg file (metadata or data file) at its warehouse key. The
34
+ * provider walks the committed `data/warehouse` Iceberg tree over HTTP and
35
+ * calls this for each file, so the browser reads the *actual* Iceberg files
36
+ * — no bundled blob.
37
+ */
38
+ seedFile(key: string, bytes: Uint8Array): Promise<any>;
39
+ /**
40
+ * Run subsequent requests as a signed-in identity (the Cognito `sub` and
41
+ * `cognito:groups` claims). Owner fields are stamped from — and row
42
+ * filters and tenant scoping keyed by — this subject, matching the server
43
+ * byte-for-byte. Pass no subject to fall back to the trusted local
44
+ * context.
45
+ */
46
+ setAuth(subject: string | null | undefined, groups: any): void;
47
+ }
48
+
49
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
50
+
51
+ export interface InitOutput {
52
+ readonly memory: WebAssembly.Memory;
53
+ readonly __wbg_rastackapi_free: (a: number, b: number) => void;
54
+ readonly rastackapi_exportWarehouse: (a: number) => any;
55
+ readonly rastackapi_handle: (a: number, b: number, c: number, d: number, e: number, f: any, g: any) => any;
56
+ readonly rastackapi_importWarehouse: (a: number, b: number, c: number) => any;
57
+ readonly rastackapi_new: (a: number, b: number, c: number, d: number) => [number, number, number];
58
+ readonly rastackapi_seedFile: (a: number, b: number, c: number, d: number, e: number) => any;
59
+ readonly rastackapi_setAuth: (a: number, b: number, c: number, d: any) => [number, number];
60
+ readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
61
+ readonly rust_zstd_wasm_shim_free: (a: number) => void;
62
+ readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
63
+ readonly rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
64
+ readonly rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
65
+ readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
66
+ readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
67
+ readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
68
+ readonly wasm_bindgen_1a7aa9db5392c486___convert__closures_____invoke___wasm_bindgen_1a7aa9db5392c486___JsValue__core_7d5f0a2ba6a62c33___result__Result_____wasm_bindgen_1a7aa9db5392c486___JsError___true_: (a: number, b: number, c: any) => [number, number];
69
+ readonly wasm_bindgen_1a7aa9db5392c486___convert__closures_____invoke___js_sys_191ff9fb2bd47800___Function_fn_wasm_bindgen_1a7aa9db5392c486___JsValue_____wasm_bindgen_1a7aa9db5392c486___sys__Undefined___js_sys_191ff9fb2bd47800___Function_fn_wasm_bindgen_1a7aa9db5392c486___JsValue_____wasm_bindgen_1a7aa9db5392c486___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
70
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
71
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
72
+ readonly __wbindgen_exn_store: (a: number) => void;
73
+ readonly __externref_table_alloc: () => number;
74
+ readonly __wbindgen_externrefs: WebAssembly.Table;
75
+ readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
76
+ readonly __externref_table_dealloc: (a: number) => void;
77
+ readonly __wbindgen_start: () => void;
78
+ }
79
+
80
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
81
+
82
+ /**
83
+ * Instantiates the given `module`, which can either be bytes or
84
+ * a precompiled `WebAssembly.Module`.
85
+ *
86
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
87
+ *
88
+ * @returns {InitOutput}
89
+ */
90
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
91
+
92
+ /**
93
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
94
+ * for everything else, calls `WebAssembly.instantiate` directly.
95
+ *
96
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
97
+ *
98
+ * @returns {Promise<InitOutput>}
99
+ */
100
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;