rastack 0.0.63 → 0.0.69
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/CHANGELOG.md +32 -0
- package/README.md +19 -24
- package/admin/AdminApp.tsx +56 -3
- package/admin/httpEngine.ts +5 -6
- package/admin/index.tsx +11 -85
- package/admin/ui/icons.tsx +9 -0
- package/admin/ui/styles.ts +3 -0
- package/admin/useAdmin.ts +41 -4
- package/dist/admin.js +17 -22
- package/dist/compile/analyze.js +11 -1
- package/dist/compile/model.d.ts +1 -1
- package/dist/compile/run.d.ts +2 -2
- package/dist/compile/run.js +2 -2
- package/dist/define/index.d.ts +10 -4
- package/dist/define/index.js +2 -2
- package/dist/define/manifest.js +7 -1
- package/dist/deploy/io.d.ts +50 -0
- package/dist/deploy/io.js +124 -0
- package/dist/deploy/workflows.js +1 -1
- package/dist/dev/harness.d.ts +19 -27
- package/dist/dev/harness.js +31 -40
- package/dist/dev/native-server.d.ts +29 -0
- package/dist/dev/native-server.js +174 -0
- package/dist/external/envelope.d.ts +1 -1
- package/dist/external/envelope.js +1 -1
- package/dist/external/service.d.ts +2 -2
- package/dist/external/service.js +2 -2
- package/dist/external/types.d.ts +1 -1
- package/dist/external/types.js +1 -1
- package/dist/rastack-admin.d.ts +6 -14
- package/dist/rastack-admin.js +60 -88
- package/dist/rastack-bootstrap.js +18 -47
- package/dist/rastack-design.d.ts +1 -2
- package/dist/rastack-design.js +1 -2
- package/dist/rastack-dev.d.ts +7 -10
- package/dist/rastack-dev.js +68 -80
- package/dist/rastack-init.d.ts +6 -3
- package/dist/rastack-init.js +43 -30
- package/dist/rastack.d.ts +1 -1
- package/dist/rastack.js +5 -6
- package/dist/validate/transitions.d.ts +1 -1
- package/dist/validate/transitions.js +1 -1
- package/hooks/query/api.ts +4 -6
- package/package.json +2 -2
- package/provider/index.ts +0 -1
- package/provider/provider.tsx +31 -134
- package/provider/types.ts +30 -69
- package/src/compile/analyze.ts +11 -1
- package/src/compile/model.ts +1 -1
- package/src/compile/run.ts +2 -2
- package/src/define/index.ts +7 -4
- package/src/define/manifest.ts +7 -1
- package/src/deploy/io.ts +162 -1
- package/src/deploy/workflows.ts +1 -1
- package/src/dev/harness.ts +30 -43
- package/src/dev/native-server.ts +164 -0
- package/src/external/envelope.ts +1 -1
- package/src/external/service.ts +2 -2
- package/src/external/types.ts +1 -1
- package/src/rastack-admin.ts +66 -107
- package/src/rastack-bootstrap.ts +24 -69
- package/src/rastack-design.ts +1 -2
- package/src/rastack-dev.ts +79 -91
- package/src/rastack-init.ts +50 -41
- package/src/rastack.ts +5 -6
- package/src/validate/transitions.ts +1 -1
- package/dist/rastack-wasm-build.d.ts +0 -19
- package/dist/rastack-wasm-build.js +0 -94
- package/dist/wasm/package.json +0 -4
- package/dist/wasm/rastack_wasm.d.ts +0 -100
- package/dist/wasm/rastack_wasm.js +0 -745
- package/dist/wasm/rastack_wasm_bg.wasm +0 -0
- package/dist/wasm/rastack_wasm_bg.wasm.d.ts +0 -28
- package/provider/wasm.ts +0 -126
- package/scripts/copy-wasm.js +0 -35
- package/src/rastack-wasm-build.ts +0 -113
package/src/rastack-init.ts
CHANGED
|
@@ -12,14 +12,17 @@
|
|
|
12
12
|
* 1. writes `.rastack/deploy.json` + `.github/workflows/{ci,deploy-backend}.yml`
|
|
13
13
|
* (GitHub coordinates default from the `origin` remote; missing fields are
|
|
14
14
|
* prompted for on a TTY);
|
|
15
|
-
* 2.
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* 2. verifies the AWS CLI is logged in, then ensures the tier-0 bootstrap stack
|
|
16
|
+
* exists — creating it (the S3 template/placeholder buckets + GitHub OIDC
|
|
17
|
+
* provider) when missing, reconciling it when it already does;
|
|
18
18
|
* 3. uploads the Lambda placeholder bundle to that bucket;
|
|
19
19
|
* 4. deploys the per-app backend (app.yaml) with the resolved ArtifactsBucket;
|
|
20
20
|
* 5. reads the stack Outputs back into the config and prints the two GitHub repo
|
|
21
21
|
* Variables CI needs.
|
|
22
22
|
*
|
|
23
|
+
* The CloudFormation templates ship inside the `rastack` package; a partial
|
|
24
|
+
* install falls back to downloading them from reactapistack.com.
|
|
25
|
+
*
|
|
23
26
|
* Thereafter the recurring code deploy is CI's job — `rastack ci deploy`, which
|
|
24
27
|
* `rastack deploy` also runs. `--no-deploy` scaffolds only; `--print` shows the
|
|
25
28
|
* exact single-line `aws cloudformation deploy` commands without running them.
|
|
@@ -30,12 +33,12 @@ import * as path from "path";
|
|
|
30
33
|
import {
|
|
31
34
|
APP_STACK_OUTPUTS,
|
|
32
35
|
BOOTSTRAP_ARTIFACTS_OUTPUT,
|
|
33
|
-
BOOTSTRAP_TEMPLATES_OUTPUT,
|
|
34
36
|
DeployConfig,
|
|
35
37
|
DeployOutputs,
|
|
36
38
|
EnvName,
|
|
37
39
|
ENV_NAMES,
|
|
38
40
|
PartialDeployConfig,
|
|
41
|
+
bootstrapStackCommand,
|
|
39
42
|
bootstrapStackName,
|
|
40
43
|
deployStackCommandForEnv,
|
|
41
44
|
deployStackArgsForEnv,
|
|
@@ -58,8 +61,10 @@ import {
|
|
|
58
61
|
import {
|
|
59
62
|
ask,
|
|
60
63
|
awsAvailable,
|
|
64
|
+
awsIdentity,
|
|
61
65
|
awsRun,
|
|
62
66
|
canPrompt,
|
|
67
|
+
ensureBootstrapStack,
|
|
63
68
|
ghAuthLogin,
|
|
64
69
|
ghAuthenticated,
|
|
65
70
|
ghAvailable,
|
|
@@ -67,6 +72,7 @@ import {
|
|
|
67
72
|
gitRemoteUrl,
|
|
68
73
|
loadConfig,
|
|
69
74
|
resolveDeployAsset,
|
|
75
|
+
resolveTemplateFile,
|
|
70
76
|
saveConfig,
|
|
71
77
|
setRepoVariable,
|
|
72
78
|
stackOutput,
|
|
@@ -281,8 +287,10 @@ function envLabel(cfg: DeployConfig, env: EnvName): string {
|
|
|
281
287
|
|
|
282
288
|
/**
|
|
283
289
|
* Print the exact commands `init` would run, without touching the cloud
|
|
284
|
-
* (`--print`).
|
|
285
|
-
*
|
|
290
|
+
* (`--print`). init stands up *both* stacks, so both `aws cloudformation deploy`
|
|
291
|
+
* commands are shown: the tier-0 bootstrap stack (created only when missing) and
|
|
292
|
+
* the per-app backend. The artifacts bucket is read from an existing bootstrap
|
|
293
|
+
* stack when the AWS CLI is available, else shown as a placeholder.
|
|
286
294
|
*/
|
|
287
295
|
function printPlan(cfg: DeployConfig, envs: EnvName[]): void {
|
|
288
296
|
const bucket = awsAvailable()
|
|
@@ -295,16 +303,15 @@ function printPlan(cfg: DeployConfig, envs: EnvName[]): void {
|
|
|
295
303
|
const withBucket = mergeConfig(cfg, {
|
|
296
304
|
artifactsBucket: bucket ?? "<ArtifactsBucketName from bootstrap stack>",
|
|
297
305
|
});
|
|
306
|
+
const bootstrapTemplate = resolveDeployAsset("bootstrap.yaml") ?? undefined;
|
|
298
307
|
const appTemplate = resolveDeployAsset("app.yaml") ?? undefined;
|
|
299
308
|
console.log(`\n Deployment plan (${envs.join(" + ")} @ ${cfg.region})\n`);
|
|
300
309
|
console.log(
|
|
301
|
-
` ──
|
|
302
|
-
);
|
|
303
|
-
console.log(
|
|
304
|
-
` Create it once per account+region (init does not): rastack bootstrap --region ${cfg.region}\n`,
|
|
310
|
+
` ── 1. Tier-0 bootstrap stack (${bootstrapStackName(cfg)}) — created only when missing ──`,
|
|
305
311
|
);
|
|
312
|
+
console.log("\n " + bootstrapStackCommand(cfg, false, bootstrapTemplate) + "\n");
|
|
306
313
|
console.log(
|
|
307
|
-
" ──
|
|
314
|
+
" ── 2. Per-app backend (app.yaml) — one stack per environment ──",
|
|
308
315
|
);
|
|
309
316
|
for (const env of envs) {
|
|
310
317
|
const e = resolveEnvironment(withBucket, env);
|
|
@@ -330,9 +337,12 @@ function printPlan(cfg: DeployConfig, envs: EnvName[]): void {
|
|
|
330
337
|
}
|
|
331
338
|
|
|
332
339
|
/**
|
|
333
|
-
* Stand the infrastructure up:
|
|
334
|
-
*
|
|
335
|
-
*
|
|
340
|
+
* Stand the infrastructure up: verify the AWS CLI is logged in, ensure the
|
|
341
|
+
* tier-0 bootstrap stack (creating it when missing), upload the Lambda
|
|
342
|
+
* placeholder, deploy app.yaml, and read the Outputs back into the config.
|
|
343
|
+
* `init` is the single command that stands up *everything* — there is no
|
|
344
|
+
* separate manual bootstrap step. Returns the config enriched with the resolved
|
|
345
|
+
* buckets + outputs.
|
|
336
346
|
*/
|
|
337
347
|
async function standUp(
|
|
338
348
|
cfg: DeployConfig,
|
|
@@ -347,33 +357,32 @@ async function standUp(
|
|
|
347
357
|
process.exit(1);
|
|
348
358
|
}
|
|
349
359
|
|
|
350
|
-
//
|
|
351
|
-
//
|
|
352
|
-
//
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
// so a missing bootstrap stack is a clear, actionable error, not an implicit
|
|
356
|
-
// account mutation buried inside an app deploy.
|
|
357
|
-
const artifactsBucket = stackOutput(
|
|
358
|
-
bootstrapStackName(cfg),
|
|
359
|
-
BOOTSTRAP_ARTIFACTS_OUTPUT,
|
|
360
|
-
cfg.region,
|
|
361
|
-
);
|
|
362
|
-
const templatesBucket = stackOutput(
|
|
363
|
-
bootstrapStackName(cfg),
|
|
364
|
-
BOOTSTRAP_TEMPLATES_OUTPUT,
|
|
365
|
-
cfg.region,
|
|
366
|
-
);
|
|
367
|
-
if (!artifactsBucket) {
|
|
360
|
+
// Verify the AWS CLI is actually logged in before creating any stacks, so a
|
|
361
|
+
// missing/expired credential fails fast with an actionable message rather than
|
|
362
|
+
// a cryptic `cloudformation deploy` error partway through.
|
|
363
|
+
const account = awsIdentity(cfg.region);
|
|
364
|
+
if (!account) {
|
|
368
365
|
console.error(
|
|
369
|
-
|
|
370
|
-
"
|
|
371
|
-
"
|
|
372
|
-
"
|
|
373
|
-
|
|
366
|
+
" ✗ the AWS CLI has no usable credentials — it is not logged in.\n" +
|
|
367
|
+
" Configure credentials, then re-run `rastack init`:\n" +
|
|
368
|
+
" aws configure # static access key / secret\n" +
|
|
369
|
+
" aws sso login # or an existing SSO session\n" +
|
|
370
|
+
" Or re-run with --print to see the commands, or --no-deploy to skip.",
|
|
374
371
|
);
|
|
375
372
|
process.exit(1);
|
|
376
373
|
}
|
|
374
|
+
console.log(` ✓ AWS account ${account} (${cfg.region})`);
|
|
375
|
+
|
|
376
|
+
// 1. Ensure the tier-0 bootstrap stack exists — the S3 buckets that host the
|
|
377
|
+
// templates + Lambda placeholder and the GitHub OIDC provider. init creates
|
|
378
|
+
// it when missing (idempotent for an existing one), so a single command
|
|
379
|
+
// takes an account+repo from nothing to a deployed backend.
|
|
380
|
+
const { artifactsBucket, templatesBucket } = await ensureBootstrapStack(
|
|
381
|
+
cfg,
|
|
382
|
+
).catch((err: Error) => {
|
|
383
|
+
console.error(`\n ✗ ${err.message}`);
|
|
384
|
+
process.exit(1);
|
|
385
|
+
});
|
|
377
386
|
console.log(` ✓ artifacts bucket: ${artifactsBucket}`);
|
|
378
387
|
|
|
379
388
|
// 2. Upload the placeholder the function is created from (shared by all envs).
|
|
@@ -389,11 +398,11 @@ async function standUp(
|
|
|
389
398
|
artifactsBucket,
|
|
390
399
|
templatesBucket: templatesBucket ?? undefined,
|
|
391
400
|
});
|
|
392
|
-
const appTemplate =
|
|
401
|
+
const appTemplate = await resolveTemplateFile("app.yaml");
|
|
393
402
|
if (!appTemplate) {
|
|
394
403
|
console.error(
|
|
395
|
-
" ✗ app.yaml template not found in the rastack package
|
|
396
|
-
" (`npm i -g rastack`)
|
|
404
|
+
" ✗ app.yaml template not found in the rastack package and could not be\n" +
|
|
405
|
+
" downloaded from reactapistack.com. Reinstall rastack (`npm i -g rastack`).",
|
|
397
406
|
);
|
|
398
407
|
process.exit(1);
|
|
399
408
|
}
|
|
@@ -623,7 +632,7 @@ async function main(argv: string[]): Promise<void> {
|
|
|
623
632
|
.map((env) => resolveEnvironment(cfg, env).stackName)
|
|
624
633
|
.join(" + ");
|
|
625
634
|
const ok = await confirm(
|
|
626
|
-
`Deploy ${stacks} to AWS ${cfg.region} now? (
|
|
635
|
+
`Deploy ${stacks} to AWS ${cfg.region} now? (creates the bootstrap stack if missing) [y/N]`,
|
|
627
636
|
);
|
|
628
637
|
if (!ok) {
|
|
629
638
|
console.log(
|
package/src/rastack.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* rastack generate [--schema-only] Generate typed hooks from OpenAPI
|
|
14
14
|
* rastack tokens [input] [outDir] Compile design tokens → CSS vars + typed theme
|
|
15
15
|
* rastack design [input] [--port n] Live design-system studio (showcase + edit)
|
|
16
|
-
* rastack dev [--port n] [--warehouse d] Local dev:
|
|
16
|
+
* rastack dev [--port n] [--warehouse d] Local dev: your app in the browser, the API in native Rust
|
|
17
17
|
* rastack admin [--warehouse dir] [--port n] Full admin console — React UI (rastack/components) over the native server
|
|
18
18
|
* rastack import <file> --resource app.model Load CSV/XLSX/PDF data and validate it (state machine)
|
|
19
19
|
* rastack scan [files...] [--fail-on-pii] (LEGACY, pre-Rust) Scan CSVs for PII and schema info
|
|
@@ -72,7 +72,7 @@ switch (command) {
|
|
|
72
72
|
console.error(
|
|
73
73
|
"`rastack compile` has been removed — compilation now runs automatically\n" +
|
|
74
74
|
"inside the two modalities of use:\n" +
|
|
75
|
-
" • rastack dev local development (compiles, then
|
|
75
|
+
" • rastack dev local development (compiles, then proxies /api to native rastack-server)\n" +
|
|
76
76
|
" • rastack ci the deploy pipeline (compiles the manifest + OpenAPI)\n\n" +
|
|
77
77
|
"Introspect the resource graph with: rastack check | list | urls\n",
|
|
78
78
|
);
|
|
@@ -85,9 +85,8 @@ switch (command) {
|
|
|
85
85
|
run("rastack-compile.js", [command, ...rest]);
|
|
86
86
|
break;
|
|
87
87
|
case "dev":
|
|
88
|
-
// Local development: serve your app
|
|
89
|
-
//
|
|
90
|
-
// `rastack admin`. Replaces `serve` + `wasm`.
|
|
88
|
+
// Local development: serve your app and proxy /api to native rastack-server.
|
|
89
|
+
// The admin console is a separate command, `rastack admin`.
|
|
91
90
|
run("rastack-dev.js", rest);
|
|
92
91
|
break;
|
|
93
92
|
case "admin":
|
|
@@ -162,7 +161,7 @@ switch (command) {
|
|
|
162
161
|
` rastack generate [--schema-only]\n` +
|
|
163
162
|
` rastack tokens [input] [outDir] [--prefix p] Compile design tokens → CSS vars + typed theme\n` +
|
|
164
163
|
` rastack design [input] [--port n] Live design-system studio (showcase + edit)\n` +
|
|
165
|
-
` rastack dev [--port n] [--warehouse dir] [--app dir] [--no-open]
|
|
164
|
+
` rastack dev [--port n] [--warehouse dir] [--app dir] [--no-open] App in the browser, API in native rastack-server\n` +
|
|
166
165
|
` rastack admin [--warehouse dir] [--port n] [--no-open] Full admin console (React UI over the native server; needs a built rastack-server)\n` +
|
|
167
166
|
` rastack import <file.csv|.xlsx|.pdf> --resource app.model [--related app.model=<file>] [--out cleaned.json]\n` +
|
|
168
167
|
` rastack scan [files...] [--fail-on-pii] (legacy, pre-Rust)\n` +
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* list), and this module is the *shared executable form* of it: the same pure
|
|
24
24
|
* functions guard a form submit (`useForm(...).transition("board")`), the
|
|
25
25
|
* record machine (`runRecordMachine` with a `previous` row in context), and —
|
|
26
|
-
* re-implemented 1:1 in `rastack-api-core` — every server
|
|
26
|
+
* re-implemented 1:1 in `rastack-api-core` — every native-server write. A write
|
|
27
27
|
* that jumps between states without a declared edge is rejected on every
|
|
28
28
|
* surface, which is what makes a transition "a backend function that is
|
|
29
29
|
* state-machine safe": the only way to move a record between states is a
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Compile the Rust API to WebAssembly for in-browser local dev — the engine
|
|
4
|
-
* `rastack dev` serves and `<RAStackProvider mode="local">` loads.
|
|
5
|
-
*
|
|
6
|
-
* Pipeline:
|
|
7
|
-
* 1. cargo build -p rastack-wasm --release --target wasm32-unknown-unknown
|
|
8
|
-
* 2. wasm-bindgen --target web → wasm/rastack_wasm.js + rastack_wasm_bg.wasm
|
|
9
|
-
* 3. wasm-opt -Oz (if available) to shrink the binary
|
|
10
|
-
*
|
|
11
|
-
* This is invoked by the release CI (to bundle a prebuilt engine into the npm
|
|
12
|
-
* package) and by `rastack dev` as a from-source fallback when no prebuilt
|
|
13
|
-
* bundle is present but the toolchain is. Prereqs:
|
|
14
|
-
* rustup target add wasm32-unknown-unknown
|
|
15
|
-
* cargo install wasm-bindgen-cli (version must match the wasm-bindgen crate)
|
|
16
|
-
*/
|
|
17
|
-
/** Run the full compile → wasm-bindgen → optimise pipeline. Throws via `run`'s
|
|
18
|
-
* `process.exit` on a missing tool or a non-zero step. */
|
|
19
|
-
export declare function buildWasm(): void;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
/**
|
|
4
|
-
* Compile the Rust API to WebAssembly for in-browser local dev — the engine
|
|
5
|
-
* `rastack dev` serves and `<RAStackProvider mode="local">` loads.
|
|
6
|
-
*
|
|
7
|
-
* Pipeline:
|
|
8
|
-
* 1. cargo build -p rastack-wasm --release --target wasm32-unknown-unknown
|
|
9
|
-
* 2. wasm-bindgen --target web → wasm/rastack_wasm.js + rastack_wasm_bg.wasm
|
|
10
|
-
* 3. wasm-opt -Oz (if available) to shrink the binary
|
|
11
|
-
*
|
|
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:
|
|
15
|
-
* rustup target add wasm32-unknown-unknown
|
|
16
|
-
* cargo install wasm-bindgen-cli (version must match the wasm-bindgen crate)
|
|
17
|
-
*/
|
|
18
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.buildWasm = buildWasm;
|
|
23
|
-
const child_process_1 = require("child_process");
|
|
24
|
-
const fs_1 = __importDefault(require("fs"));
|
|
25
|
-
const path_1 = __importDefault(require("path"));
|
|
26
|
-
const repoRoot = path_1.default.resolve(__dirname, "..");
|
|
27
|
-
const rustDir = path_1.default.join(repoRoot, "engine");
|
|
28
|
-
const outDir = path_1.default.join(repoRoot, "wasm");
|
|
29
|
-
const wasmPath = path_1.default.join(rustDir, "target", "wasm32-unknown-unknown", "release", "rastack_wasm.wasm");
|
|
30
|
-
function run(cmd, args, cwd = repoRoot) {
|
|
31
|
-
// Local build tool: `cmd`/`args` are the fixed toolchain invocations below
|
|
32
|
-
// (cargo, wasm-bindgen, wasm-opt), not untrusted input — no injection surface.
|
|
33
|
-
// nosemgrep: javascript.lang.security.detect-child-process.detect-child-process
|
|
34
|
-
const result = (0, child_process_1.spawnSync)(cmd, args, {
|
|
35
|
-
stdio: "inherit",
|
|
36
|
-
cwd,
|
|
37
|
-
env: process.env,
|
|
38
|
-
});
|
|
39
|
-
if (result.error) {
|
|
40
|
-
console.error(`\nCould not run \`${cmd}\`. Is it installed and on PATH?`);
|
|
41
|
-
if (cmd === "wasm-bindgen") {
|
|
42
|
-
console.error(" cargo install wasm-bindgen-cli");
|
|
43
|
-
}
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
if (result.status !== 0) {
|
|
47
|
-
process.exit(result.status ?? 1);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function has(cmd) {
|
|
51
|
-
// Probes a fixed toolchain name (e.g. "wasm-opt") for availability; not
|
|
52
|
-
// untrusted input.
|
|
53
|
-
// nosemgrep: javascript.lang.security.detect-child-process.detect-child-process
|
|
54
|
-
return (0, child_process_1.spawnSync)(cmd, ["--version"], { stdio: "ignore" }).status === 0;
|
|
55
|
-
}
|
|
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 → 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: wasm/ (${(size / 1024).toFixed(0)} KB)`);
|
|
91
|
-
}
|
|
92
|
-
if (require.main === module) {
|
|
93
|
-
buildWasm();
|
|
94
|
-
}
|
package/dist/wasm/package.json
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
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_ac0f9960a408a037___convert__closures_____invoke___wasm_bindgen_ac0f9960a408a037___JsValue__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_ac0f9960a408a037___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
69
|
-
readonly wasm_bindgen_ac0f9960a408a037___convert__closures_____invoke___js_sys_10c47e7ecd0a94ab___Function_fn_wasm_bindgen_ac0f9960a408a037___JsValue_____wasm_bindgen_ac0f9960a408a037___sys__Undefined___js_sys_10c47e7ecd0a94ab___Function_fn_wasm_bindgen_ac0f9960a408a037___JsValue_____wasm_bindgen_ac0f9960a408a037___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>;
|