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
  "use strict";
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
  */
@@ -16,6 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
19
  return (mod && mod.__esModule) ? mod : { "default": mod };
17
20
  };
18
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.buildWasm = buildWasm;
19
23
  const child_process_1 = require("child_process");
20
24
  const fs_1 = __importDefault(require("fs"));
21
25
  const path_1 = __importDefault(require("path"));
@@ -49,35 +53,42 @@ function has(cmd) {
49
53
  // nosemgrep: javascript.lang.security.detect-child-process.detect-child-process
50
54
  return (0, child_process_1.spawnSync)(cmd, ["--version"], { stdio: "ignore" }).status === 0;
51
55
  }
52
- console.log("→ cargo build -p rastack-wasm --release (wasm32-unknown-unknown)");
53
- run("cargo", [
54
- "build",
55
- "-p",
56
- "rastack-wasm",
57
- "--release",
58
- "--target",
59
- "wasm32-unknown-unknown",
60
- ], rustDir);
61
- console.log("→ wasm-bindgen → stack/wasm/");
62
- run("wasm-bindgen", [
63
- "--target",
64
- "web",
65
- "--out-dir",
66
- outDir,
67
- "--out-name",
68
- "rastack_wasm",
69
- wasmPath,
70
- ]);
71
- // Mark the emitted bundle as ESM so Node and bundlers treat it correctly
72
- // without forcing the parent rastack package to be a module.
73
- fs_1.default.writeFileSync(path_1.default.join(outDir, "package.json"), JSON.stringify({ type: "module", sideEffects: false }, null, 2) + "\n");
74
- if (has("wasm-opt")) {
75
- console.log("→ wasm-opt -Oz");
76
- const bg = path_1.default.join(outDir, "rastack_wasm_bg.wasm");
77
- run("wasm-opt", ["-Oz", "-o", bg, bg]);
56
+ /** Run the full compile → wasm-bindgen → optimise pipeline. Throws via `run`'s
57
+ * `process.exit` on a missing tool or a non-zero step. */
58
+ function buildWasm() {
59
+ console.log("→ cargo build -p rastack-wasm --release (wasm32-unknown-unknown)");
60
+ run("cargo", [
61
+ "build",
62
+ "-p",
63
+ "rastack-wasm",
64
+ "--release",
65
+ "--target",
66
+ "wasm32-unknown-unknown",
67
+ ], rustDir);
68
+ console.log("→ wasm-bindgen → tools/wasm/");
69
+ run("wasm-bindgen", [
70
+ "--target",
71
+ "web",
72
+ "--out-dir",
73
+ outDir,
74
+ "--out-name",
75
+ "rastack_wasm",
76
+ wasmPath,
77
+ ]);
78
+ // Mark the emitted bundle as ESM so Node and bundlers treat it correctly
79
+ // without forcing the parent rastack package to be a module.
80
+ fs_1.default.writeFileSync(path_1.default.join(outDir, "package.json"), JSON.stringify({ type: "module", sideEffects: false }, null, 2) + "\n");
81
+ if (has("wasm-opt")) {
82
+ console.log("→ wasm-opt -Oz");
83
+ const bg = path_1.default.join(outDir, "rastack_wasm_bg.wasm");
84
+ run("wasm-opt", ["-Oz", "-o", bg, bg]);
85
+ }
86
+ else {
87
+ console.log("· wasm-opt not found — skipping size optimisation (optional)");
88
+ }
89
+ const size = fs_1.default.statSync(path_1.default.join(outDir, "rastack_wasm_bg.wasm")).size;
90
+ console.log(`✓ wasm engine built: tools/wasm/ (${(size / 1024).toFixed(0)} KB)`);
78
91
  }
79
- else {
80
- console.log("· wasm-opt not found — skipping size optimisation (optional)");
92
+ if (require.main === module) {
93
+ buildWasm();
81
94
  }
82
- const size = fs_1.default.statSync(path_1.default.join(outDir, "rastack_wasm_bg.wasm")).size;
83
- console.log(`✓ wasm engine built: stack/wasm/ (${(size / 1024).toFixed(0)} KB)`);
package/dist/rastack.d.ts CHANGED
@@ -10,9 +10,8 @@
10
10
  * rastack generate [--schema-only] Generate typed hooks from OpenAPI
11
11
  * rastack tokens [input] [outDir] Compile design tokens → CSS vars + typed theme
12
12
  * rastack design [input] [--port n] Live design-system studio (showcase + edit)
13
- * rastack serve [--warehouse dir] Run the Rust API over an Iceberg warehouse
13
+ * rastack dev [--port n] [--warehouse d] Local dev: run the app + admin in-browser over WASM
14
14
  * rastack admin [--warehouse dir] Run the Rust admin (Django-admin-style DB browser)
15
- * rastack wasm Compile the API to WebAssembly (in-browser local dev)
16
15
  * rastack scan [files...] [--fail-on-pii] Scan CSVs for PII and schema info
17
16
  * rastack seed [--env dev] [--source gs://] Load CSVs into Iceberg namespace
18
17
  * rastack bootstrap [--owner o] [--repo r] Stand the tier-0 AWS account stack up (once per account+region)
package/dist/rastack.js 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)
@@ -90,16 +89,14 @@ switch (command) {
90
89
  // rastack-compile dispatches on its own first argument, so pass the command.
91
90
  run("rastack-compile.js", [command, ...rest]);
92
91
  break;
93
- case "serve":
94
- runRust("serve");
92
+ case "dev":
93
+ // Local development: serve the app + admin in the browser over the WASM
94
+ // engine (no native server, no cargo). Replaces `serve` + `wasm`.
95
+ run("rastack-dev.js", rest);
95
96
  break;
96
97
  case "admin":
97
98
  runRust("admin");
98
99
  break;
99
- case "wasm":
100
- // Compile the API to WebAssembly for in-browser local dev.
101
- run("rastack-wasm-build.js", rest);
102
- break;
103
100
  case "tokens":
104
101
  // Design tokens → CSS custom properties + typed theme.
105
102
  run("rastack-tokens.js", rest);
@@ -150,8 +147,8 @@ switch (command) {
150
147
  ` rastack generate [--schema-only]\n` +
151
148
  ` rastack tokens [input] [outDir] [--prefix p] Compile design tokens → CSS vars + typed theme\n` +
152
149
  ` rastack design [input] [--port n] Live design-system studio (showcase + edit)\n` +
153
- ` rastack serve | admin [--warehouse dir]\n` +
154
- ` rastack wasm Compile the API to WebAssembly (browser local dev)\n` +
150
+ ` rastack dev [--port n] [--warehouse dir] [--no-open] Run the app + admin in-browser over WASM (local dev)\n` +
151
+ ` rastack admin [--warehouse dir] Run the native Rust admin (needs a built rastack-server)\n` +
155
152
  ` rastack scan [files...] [--fail-on-pii]\n` +
156
153
  ` rastack seed [--env dev|staging] [--source gs://bucket/ | ./myapp-dev/]\n` +
157
154
  ` rastack bootstrap [--owner o] [--repo r] [--region r] [--prefix p] [--reuse-oidc] [--print] Stand the AWS account stack up\n` +
package/dist/update.d.ts CHANGED
@@ -52,6 +52,17 @@ export declare function npmBinary(platform?: string): string;
52
52
  * shell means no injection surface).
53
53
  */
54
54
  export declare function npmSpawnShell(platform?: string): boolean;
55
+ /**
56
+ * The single command string used to launch npm on platforms that must go through
57
+ * a shell (Windows — see `npmSpawnShell`). Node 22+ deprecates passing an args
58
+ * *array* together with `shell: true` (DEP0190: the args are concatenated, not
59
+ * escaped), so the shell path builds one string and runs it via `execSync`
60
+ * instead. Joining with spaces is safe here because every token is a fixed
61
+ * literal except the version, which `sanitizeVersion` constrains to
62
+ * `[A-Za-z0-9._-]` (no shell metacharacters). POSIX never uses this — it keeps
63
+ * the shell-free, array-based `execFile`, which has no concatenation at all.
64
+ */
65
+ export declare function npmShellCommand(binary: string, args: string[]): string;
55
66
  /** The npm package spec to install for a target version. */
56
67
  export declare function installSpec(version: string): string;
57
68
  /** The `npm <args>` (after the `npm` binary) that installs the target globally. */
package/dist/update.js CHANGED
@@ -15,6 +15,7 @@ exports.parseUpdateFlags = parseUpdateFlags;
15
15
  exports.sanitizeVersion = sanitizeVersion;
16
16
  exports.npmBinary = npmBinary;
17
17
  exports.npmSpawnShell = npmSpawnShell;
18
+ exports.npmShellCommand = npmShellCommand;
18
19
  exports.installSpec = installSpec;
19
20
  exports.npmInstallArgs = npmInstallArgs;
20
21
  exports.globalPrefixFromPackageDir = globalPrefixFromPackageDir;
@@ -88,6 +89,19 @@ function npmBinary(platform = process.platform) {
88
89
  function npmSpawnShell(platform = process.platform) {
89
90
  return platform === "win32";
90
91
  }
92
+ /**
93
+ * The single command string used to launch npm on platforms that must go through
94
+ * a shell (Windows — see `npmSpawnShell`). Node 22+ deprecates passing an args
95
+ * *array* together with `shell: true` (DEP0190: the args are concatenated, not
96
+ * escaped), so the shell path builds one string and runs it via `execSync`
97
+ * instead. Joining with spaces is safe here because every token is a fixed
98
+ * literal except the version, which `sanitizeVersion` constrains to
99
+ * `[A-Za-z0-9._-]` (no shell metacharacters). POSIX never uses this — it keeps
100
+ * the shell-free, array-based `execFile`, which has no concatenation at all.
101
+ */
102
+ function npmShellCommand(binary, args) {
103
+ return [binary, ...args].join(" ");
104
+ }
91
105
  /** The npm package spec to install for a target version. */
92
106
  function installSpec(version) {
93
107
  return !version || version === "latest" ? "rastack" : `rastack@${version}`;
@@ -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>;