helloruntime 0.0.5 → 0.0.8
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/dist/cli/app-args.d.ts +5 -0
- package/dist/cli/app-args.d.ts.map +1 -0
- package/dist/cli/app-args.js +24 -0
- package/dist/cli/app-args.js.map +1 -0
- package/dist/cli/config.d.ts +2 -0
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +13 -1
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/deploy.d.ts.map +1 -1
- package/dist/cli/deploy.js +22 -1
- package/dist/cli/deploy.js.map +1 -1
- package/dist/cli/index.js +16 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/logout.d.ts +2 -0
- package/dist/cli/logout.d.ts.map +1 -0
- package/dist/cli/logout.js +6 -0
- package/dist/cli/logout.js.map +1 -0
- package/dist/cli/tasks.d.ts +8 -0
- package/dist/cli/tasks.d.ts.map +1 -0
- package/dist/cli/tasks.js +32 -0
- package/dist/cli/tasks.js.map +1 -0
- package/dist/cli/triggers.d.ts +0 -6
- package/dist/cli/triggers.d.ts.map +1 -1
- package/dist/cli/triggers.js +1 -41
- package/dist/cli/triggers.js.map +1 -1
- package/dist/sdk/db.d.ts +4 -4
- package/dist/sdk/db.d.ts.map +1 -1
- package/dist/sdk/db.js +18 -18
- package/dist/sdk/db.js.map +1 -1
- package/dist/sdk/index.d.ts +1 -6
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +5 -7
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/jobs.d.ts +2 -2
- package/dist/sdk/jobs.js +2 -2
- package/dist/sdk/nitro-module.d.ts +47 -0
- package/dist/sdk/nitro-module.d.ts.map +1 -0
- package/dist/sdk/nitro-module.js +64 -0
- package/dist/sdk/nitro-module.js.map +1 -0
- package/dist/sdk/runtime/express.d.ts.map +1 -1
- package/dist/sdk/runtime/express.js +4 -5
- package/dist/sdk/runtime/express.js.map +1 -1
- package/dist/sdk/runtime/handler.d.ts +14 -1
- package/dist/sdk/runtime/handler.d.ts.map +1 -1
- package/dist/sdk/runtime/handler.js +6 -8
- package/dist/sdk/runtime/handler.js.map +1 -1
- package/dist/sdk/runtime/hono.d.ts.map +1 -1
- package/dist/sdk/runtime/hono.js +3 -4
- package/dist/sdk/runtime/hono.js.map +1 -1
- package/dist/sdk/runtime/nitro-dispatch.d.ts +3 -0
- package/dist/sdk/runtime/nitro-dispatch.d.ts.map +1 -0
- package/dist/sdk/runtime/nitro-dispatch.js +23 -0
- package/dist/sdk/runtime/nitro-dispatch.js.map +1 -0
- package/helloruntime.schema.json +12 -0
- package/package.json +14 -6
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Resolve the target app slug: explicit flag, else package.json name, else cwd basename. */
|
|
2
|
+
export declare function resolveAppSlug(explicit?: string): Promise<string>;
|
|
3
|
+
/** --payload accepts inline JSON, @file.json, or a bare string. */
|
|
4
|
+
export declare function loadPayload(raw?: string): Promise<unknown>;
|
|
5
|
+
//# sourceMappingURL=app-args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-args.d.ts","sourceRoot":"","sources":["../../src/cli/app-args.ts"],"names":[],"mappings":"AAGA,6FAA6F;AAC7F,wBAAsB,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMvE;AAED,mEAAmE;AACnE,wBAAsB,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQhE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
/** Resolve the target app slug: explicit flag, else package.json name, else cwd basename. */
|
|
4
|
+
export async function resolveAppSlug(explicit) {
|
|
5
|
+
if (explicit)
|
|
6
|
+
return explicit;
|
|
7
|
+
const pkg = await readFile("package.json", "utf8")
|
|
8
|
+
.then((raw) => JSON.parse(raw))
|
|
9
|
+
.catch(() => ({}));
|
|
10
|
+
return pkg.name ?? basename(process.cwd());
|
|
11
|
+
}
|
|
12
|
+
/** --payload accepts inline JSON, @file.json, or a bare string. */
|
|
13
|
+
export async function loadPayload(raw) {
|
|
14
|
+
if (raw == null)
|
|
15
|
+
return undefined;
|
|
16
|
+
const text = raw.startsWith("@") ? await readFile(raw.slice(1), "utf8") : raw;
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(text);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return text;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=app-args.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-args.js","sourceRoot":"","sources":["../../src/cli/app-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,6FAA6F;AAC7F,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,QAAiB;IACpD,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;SAC/C,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAsB,CAAC;SACnD,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAsB,CAAC,CAAC;IAC1C,OAAO,GAAG,CAAC,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAY;IAC5C,IAAI,GAAG,IAAI,IAAI;QAAE,OAAO,SAAS,CAAC;IAClC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC9E,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/cli/config.d.ts
CHANGED
|
@@ -13,5 +13,7 @@ export type CliConfig = z.infer<typeof configSchema>;
|
|
|
13
13
|
export declare function configPath(): string;
|
|
14
14
|
export declare function readConfig(): Promise<CliConfig>;
|
|
15
15
|
export declare function writeConfig(config: CliConfig): Promise<void>;
|
|
16
|
+
/** Remove stored credentials. Returns false if there was nothing to clear. */
|
|
17
|
+
export declare function clearConfig(): Promise<boolean>;
|
|
16
18
|
export {};
|
|
17
19
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/cli/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,YAAY;;;;;;;;;EAGhB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAErD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC,CAIrD;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAGlE"}
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,YAAY;;;;;;;;;EAGhB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAErD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC,CAIrD;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAGlE;AAED,8EAA8E;AAC9E,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAQpD"}
|
package/dist/cli/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
1
|
+
import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { z } from "zod";
|
|
@@ -19,4 +19,16 @@ export async function writeConfig(config) {
|
|
|
19
19
|
await mkdir(join(homedir(), ".helloruntime"), { recursive: true, mode: 0o700 });
|
|
20
20
|
await writeFile(configPath(), `${JSON.stringify(config, null, 2)}\n`, { mode: 0o600 });
|
|
21
21
|
}
|
|
22
|
+
/** Remove stored credentials. Returns false if there was nothing to clear. */
|
|
23
|
+
export async function clearConfig() {
|
|
24
|
+
try {
|
|
25
|
+
await unlink(configPath());
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (error.code === "ENOENT")
|
|
30
|
+
return false;
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
22
34
|
//# sourceMappingURL=config.js.map
|
package/dist/cli/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAk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EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACzF,CAAC;AAED,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA2B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QACjE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/cli/deploy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/cli/deploy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/cli/deploy.ts"],"names":[],"mappings":"AAsDA,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAqE5E"}
|
package/dist/cli/deploy.js
CHANGED
|
@@ -4,6 +4,22 @@ import { readConfig } from "./config.js";
|
|
|
4
4
|
import { helloruntimeRequest } from "./http.js";
|
|
5
5
|
import { packageBundle, runBuild } from "./packager.js";
|
|
6
6
|
import { readProjectConfig } from "./project-config.js";
|
|
7
|
+
// The `helloruntime/nitro` build module writes this during `nitro build`. It is the
|
|
8
|
+
// authoritative, deterministic source of the app's crons — shipped in the deploy request
|
|
9
|
+
// so the platform reconciles schedules without ever running the app.
|
|
10
|
+
async function readTriggers(cwd) {
|
|
11
|
+
const empty = { crons: [], jobs: [] };
|
|
12
|
+
const raw = await readFile(join(cwd, ".output", "helloruntime", "triggers.json"), "utf8").catch(() => null);
|
|
13
|
+
if (!raw)
|
|
14
|
+
return empty;
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(raw);
|
|
17
|
+
return { crons: parsed.crons ?? [], jobs: parsed.jobs ?? [] };
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return empty;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
7
23
|
const TERMINAL = new Set(["active", "failed"]);
|
|
8
24
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
9
25
|
function formatDuration(ms) {
|
|
@@ -23,6 +39,10 @@ export async function deployCommand(options) {
|
|
|
23
39
|
const appName = options.app ?? pkg.name ?? basename(cwd);
|
|
24
40
|
// Build locally (Vite/Nitro → .output), then package the bundle and reject natives.
|
|
25
41
|
await runBuild(cwd, projectConfig.build?.command);
|
|
42
|
+
const triggers = await readTriggers(cwd);
|
|
43
|
+
if (triggers.crons.length) {
|
|
44
|
+
console.log(`Crons: ${triggers.crons.map((c) => `${c.name} (${c.schedule})`).join(", ")}`);
|
|
45
|
+
}
|
|
26
46
|
process.stdout.write("Packaging bundle… ");
|
|
27
47
|
const { tarPath, bundleSha, fileCount } = await packageBundle(cwd);
|
|
28
48
|
console.log(`${fileCount} files (${bundleSha.slice(0, 12)})`);
|
|
@@ -38,7 +58,8 @@ export async function deployCommand(options) {
|
|
|
38
58
|
bundleSha,
|
|
39
59
|
artifactKey: uploaded.artifactKey,
|
|
40
60
|
artifactSizeBytes: uploaded.artifactSizeBytes,
|
|
41
|
-
manifest: projectConfig
|
|
61
|
+
manifest: projectConfig,
|
|
62
|
+
triggers
|
|
42
63
|
})
|
|
43
64
|
});
|
|
44
65
|
console.log(`Deploying v${created.version}…`);
|
package/dist/cli/deploy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/cli/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MA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,MAAM,IAAI,KAAK,CAAC,kBAAkB,MAAM,CAAC,KAAK,IAAI,eAAe,EAAE,CAAC,CAAC;YACvE,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;YAC/C,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;YAC/B,OAAO;QACT,CAAC;QACD,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC"}
|
package/dist/cli/index.js
CHANGED
|
@@ -3,14 +3,17 @@ import { Command } from "commander";
|
|
|
3
3
|
import { deployCommand } from "./deploy.js";
|
|
4
4
|
import { destroyCommand } from "./destroy.js";
|
|
5
5
|
import { loginCommand } from "./login.js";
|
|
6
|
-
import {
|
|
6
|
+
import { logoutCommand } from "./logout.js";
|
|
7
|
+
import { taskList, taskRun } from "./tasks.js";
|
|
8
|
+
import { jobsList, jobsTrigger } from "./triggers.js";
|
|
7
9
|
const program = new Command();
|
|
8
|
-
program.name("helloruntime").description("Deploy server-rendered JS/TS apps to Helloruntime").version("0.0.
|
|
10
|
+
program.name("helloruntime").description("Deploy server-rendered JS/TS apps to Helloruntime").version("0.0.7");
|
|
9
11
|
program
|
|
10
12
|
.command("login")
|
|
11
13
|
.description("Authenticate via the browser (device flow)")
|
|
12
14
|
.option("--api-url <url>", "Helloruntime API URL", process.env.HELLORUNTIME_API_URL ?? "http://localhost:3000")
|
|
13
15
|
.action(loginCommand);
|
|
16
|
+
program.command("logout").description("Remove stored credentials").action(logoutCommand);
|
|
14
17
|
program
|
|
15
18
|
.command("deploy")
|
|
16
19
|
.description("Build + deploy the app in the current directory")
|
|
@@ -36,18 +39,19 @@ jobs
|
|
|
36
39
|
.option("--status <status>", "Filter by status (pending|leased|succeeded|dead)")
|
|
37
40
|
.option("--app <name>", "App name")
|
|
38
41
|
.action(jobsList);
|
|
39
|
-
// ───
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
.command("trigger <name>")
|
|
43
|
-
.description("Fire a cron out-of-schedule")
|
|
44
|
-
.option("--app <name>", "App name")
|
|
45
|
-
.action(cronTrigger);
|
|
46
|
-
cron
|
|
42
|
+
// ─── Tasks (Nitro tasks: scheduledTasks + tasks/) ─────────────────────────────
|
|
43
|
+
const task = program.command("task").description("Inspect and run the app's tasks");
|
|
44
|
+
task
|
|
47
45
|
.command("list")
|
|
48
|
-
.description("List
|
|
46
|
+
.description("List the app's tasks (scheduled ones show their cron + next run)")
|
|
49
47
|
.option("--app <name>", "App name")
|
|
50
|
-
.action(
|
|
48
|
+
.action(taskList);
|
|
49
|
+
task
|
|
50
|
+
.command("run <name>")
|
|
51
|
+
.description("Run a task once now (enqueued + dispatched; returns a job id)")
|
|
52
|
+
.option("--payload <json>", "JSON payload, @file.json, or a bare string")
|
|
53
|
+
.option("--app <name>", "App name (defaults to package.json name / dir)")
|
|
54
|
+
.action(taskRun);
|
|
51
55
|
const notYet = (command) => () => {
|
|
52
56
|
console.error(`helloruntime ${command}: not implemented yet`);
|
|
53
57
|
process.exitCode = 1;
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,E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,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACpE,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;AACpG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAEtE,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC5C,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/cli/logout.ts"],"names":[],"mappings":"AAEA,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAGnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/cli/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,MAAM,OAAO,GAAG,MAAM,WAAW,EAAE,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,uBAAuB,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/cli/tasks.ts"],"names":[],"mappings":"AAeA,wBAAsB,QAAQ,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBvE;AAKD,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAUtG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { resolveAppSlug, loadPayload } from "./app-args.js";
|
|
2
|
+
import { readConfig } from "./config.js";
|
|
3
|
+
import { helloruntimeRequest } from "./http.js";
|
|
4
|
+
// `helloruntime task list` — every task the app defines (mirrors `nitro task list`),
|
|
5
|
+
// scheduled ones annotated with their cron expression + next run.
|
|
6
|
+
export async function taskList(options) {
|
|
7
|
+
const config = await readConfig();
|
|
8
|
+
const slug = await resolveAppSlug(options.app);
|
|
9
|
+
const { tasks } = await helloruntimeRequest(config, `/v1/apps/${encodeURIComponent(slug)}/tasks`);
|
|
10
|
+
if (!tasks.length) {
|
|
11
|
+
console.log("No tasks. (Define them in tasks/ and redeploy.)");
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
for (const t of tasks) {
|
|
15
|
+
const sched = t.schedule
|
|
16
|
+
? `${t.schedule}${t.nextRunAt ? ` next=${t.nextRunAt}` : ""}`
|
|
17
|
+
: "(on-demand)";
|
|
18
|
+
const desc = t.description ? ` — ${t.description}` : "";
|
|
19
|
+
console.log(`${t.name.padEnd(24)} ${sched}${desc}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// `helloruntime task run <name> --payload <json>` — run a task once now. Async: the
|
|
23
|
+
// platform enqueues + dispatches it to the (remote, scale-to-zero) app, so we return the
|
|
24
|
+
// jobId rather than the task result. Track it with `helloruntime jobs list`.
|
|
25
|
+
export async function taskRun(name, options) {
|
|
26
|
+
const config = await readConfig();
|
|
27
|
+
const slug = await resolveAppSlug(options.app);
|
|
28
|
+
const payload = await loadPayload(options.payload);
|
|
29
|
+
const res = await helloruntimeRequest(config, `/v1/apps/${encodeURIComponent(slug)}/tasks/${encodeURIComponent(name)}/run`, { method: "POST", body: JSON.stringify({ payload }) });
|
|
30
|
+
console.log(`Ran task "${name}" → ${res.jobId}`);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=tasks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../src/cli/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAWhD,qFAAqF;AACrF,kEAAkE;AAClE,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAyB;IACtD,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,mBAAmB,CACzC,MAAM,EACN,YAAY,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAC7C,CAAC;IACF,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;QAC/D,OAAO;IACT,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,CAAC,CAAC,QAAQ;YACtB,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;YAC7D,CAAC,CAAC,aAAa,CAAC;QAClB,MAAM,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;AACH,CAAC;AAED,oFAAoF;AACpF,yFAAyF;AACzF,6EAA6E;AAC7E,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,OAA2C;IACrF,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,GAAG,GAAG,MAAM,mBAAmB,CACnC,MAAM,EACN,YAAY,kBAAkB,CAAC,IAAI,CAAC,UAAU,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAC5E,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CACtD,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,OAAO,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;AACnD,CAAC"}
|
package/dist/cli/triggers.d.ts
CHANGED
|
@@ -2,14 +2,8 @@ export declare function jobsTrigger(name: string, options: {
|
|
|
2
2
|
payload?: string;
|
|
3
3
|
app?: string;
|
|
4
4
|
}): Promise<void>;
|
|
5
|
-
export declare function cronTrigger(name: string, options: {
|
|
6
|
-
app?: string;
|
|
7
|
-
}): Promise<void>;
|
|
8
5
|
export declare function jobsList(options: {
|
|
9
6
|
status?: string;
|
|
10
7
|
app?: string;
|
|
11
8
|
}): Promise<void>;
|
|
12
|
-
export declare function cronList(options: {
|
|
13
|
-
app?: string;
|
|
14
|
-
}): Promise<void>;
|
|
15
9
|
//# sourceMappingURL=triggers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../../src/cli/triggers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../../src/cli/triggers.ts"],"names":[],"mappings":"AAIA,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAS1G;AAYD,wBAAsB,QAAQ,CAAC,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBxF"}
|
package/dist/cli/triggers.js
CHANGED
|
@@ -1,27 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { basename } from "node:path";
|
|
1
|
+
import { resolveAppSlug, loadPayload } from "./app-args.js";
|
|
3
2
|
import { readConfig } from "./config.js";
|
|
4
3
|
import { helloruntimeRequest } from "./http.js";
|
|
5
|
-
async function resolveAppSlug(explicit) {
|
|
6
|
-
if (explicit)
|
|
7
|
-
return explicit;
|
|
8
|
-
const pkg = await readFile("package.json", "utf8")
|
|
9
|
-
.then((raw) => JSON.parse(raw))
|
|
10
|
-
.catch(() => ({}));
|
|
11
|
-
return pkg.name ?? basename(process.cwd());
|
|
12
|
-
}
|
|
13
|
-
// --payload accepts inline JSON, @file.json, or a bare string.
|
|
14
|
-
async function loadPayload(raw) {
|
|
15
|
-
if (raw == null)
|
|
16
|
-
return undefined;
|
|
17
|
-
const text = raw.startsWith("@") ? await readFile(raw.slice(1), "utf8") : raw;
|
|
18
|
-
try {
|
|
19
|
-
return JSON.parse(text);
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
return text;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
4
|
export async function jobsTrigger(name, options) {
|
|
26
5
|
const config = await readConfig();
|
|
27
6
|
const slug = await resolveAppSlug(options.app);
|
|
@@ -32,12 +11,6 @@ export async function jobsTrigger(name, options) {
|
|
|
32
11
|
});
|
|
33
12
|
console.log(`Enqueued job "${name}" → ${res.jobId}`);
|
|
34
13
|
}
|
|
35
|
-
export async function cronTrigger(name, options) {
|
|
36
|
-
const config = await readConfig();
|
|
37
|
-
const slug = await resolveAppSlug(options.app);
|
|
38
|
-
const res = await helloruntimeRequest(config, `/v1/apps/${encodeURIComponent(slug)}/crons/${encodeURIComponent(name)}/trigger`, { method: "POST", body: "{}" });
|
|
39
|
-
console.log(`Triggered cron "${name}" → ${res.jobId}`);
|
|
40
|
-
}
|
|
41
14
|
export async function jobsList(options) {
|
|
42
15
|
const config = await readConfig();
|
|
43
16
|
const slug = await resolveAppSlug(options.app);
|
|
@@ -52,17 +25,4 @@ export async function jobsList(options) {
|
|
|
52
25
|
console.log(`${j.status.padEnd(10)} ${j.kind.padEnd(5)} ${j.name.padEnd(20)} attempt=${j.attempt} ${j.id}${err}`);
|
|
53
26
|
}
|
|
54
27
|
}
|
|
55
|
-
export async function cronList(options) {
|
|
56
|
-
const config = await readConfig();
|
|
57
|
-
const slug = await resolveAppSlug(options.app);
|
|
58
|
-
const { crons } = await helloruntimeRequest(config, `/v1/apps/${encodeURIComponent(slug)}/crons`);
|
|
59
|
-
if (!crons.length) {
|
|
60
|
-
console.log("No crons registered.");
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
for (const c of crons) {
|
|
64
|
-
const next = c.nextRunAt ? `next=${c.nextRunAt}` : "next=—";
|
|
65
|
-
console.log(`${c.name.padEnd(20)} ${c.schedule.padEnd(16)} ${c.enabled ? "enabled " : "disabled"} ${next}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
28
|
//# sourceMappingURL=triggers.js.map
|
package/dist/cli/triggers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triggers.js","sourceRoot":"","sources":["../../src/cli/triggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"triggers.js","sourceRoot":"","sources":["../../src/cli/triggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAY,EAAE,OAA2C;IACzF,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,GAAG,GAAG,MAAM,mBAAmB,CAAoB,MAAM,EAAE,YAAY,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE;QAC5G,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KACxC,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,OAAO,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;AACvD,CAAC;AAYD,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAA0C;IACvE,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACpF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,mBAAmB,CACxC,MAAM,EACN,YAAY,kBAAkB,CAAC,IAAI,CAAC,QAAQ,KAAK,EAAE,CACpD,CAAC;IACF,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACxB,OAAO;IACT,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,GAAG,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC;IACpH,CAAC;AACH,CAAC"}
|
package/dist/sdk/db.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare function getDb():
|
|
1
|
+
import { type PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
export declare function getDb(): PostgresJsDatabase;
|
|
3
3
|
/** Lazily-initialized Drizzle handle. Use with your own schema: `db.select().from(table)`. */
|
|
4
|
-
export declare const db:
|
|
4
|
+
export declare const db: PostgresJsDatabase;
|
|
5
5
|
/**
|
|
6
6
|
* Create a Drizzle database bound to your schema, over the injected pooled
|
|
7
7
|
* DATABASE_URL. The recommended entry point:
|
|
@@ -10,5 +10,5 @@ export declare const db: NodePgDatabase;
|
|
|
10
10
|
* import * as schema from "./schema";
|
|
11
11
|
* export const db = createDatabase(schema);
|
|
12
12
|
*/
|
|
13
|
-
export declare function createDatabase<TSchema extends Record<string, unknown>>(schema: TSchema):
|
|
13
|
+
export declare function createDatabase<TSchema extends Record<string, unknown>>(schema: TSchema): PostgresJsDatabase<TSchema>;
|
|
14
14
|
//# sourceMappingURL=db.d.ts.map
|
package/dist/sdk/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/sdk/db.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/sdk/db.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAqB3E,wBAAgB,KAAK,IAAI,kBAAkB,CAK1C;AAED,8FAA8F;AAC9F,eAAO,MAAM,EAAE,EAAE,kBAIf,CAAC;AAEH;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpE,MAAM,EAAE,OAAO,GACd,kBAAkB,CAAC,OAAO,CAAC,CAG7B"}
|
package/dist/sdk/db.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { DEFAULT_DB_POOL_MAX, HELLORUNTIME_ENV } from "@helloruntime/protocol";
|
|
2
|
-
import { drizzle } from "drizzle-orm/
|
|
3
|
-
import
|
|
4
|
-
// Drizzle over
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// are unreliable.
|
|
2
|
+
import { drizzle } from "drizzle-orm/postgres-js";
|
|
3
|
+
import postgres from "postgres";
|
|
4
|
+
// Drizzle over postgres-js on the injected POOLED endpoint. Small pool (the app runs at
|
|
5
|
+
// maxScale=1 with bounded concurrency). prepare:false because the pooled endpoint runs in
|
|
6
|
+
// transaction mode (PgBouncer), where persistent prepared statements are unreliable.
|
|
8
7
|
let instance = null;
|
|
9
|
-
|
|
10
|
-
if (instance)
|
|
11
|
-
return instance;
|
|
8
|
+
function connectionUrl() {
|
|
12
9
|
const url = process.env[HELLORUNTIME_ENV.DATABASE_URL];
|
|
13
10
|
if (!url) {
|
|
14
11
|
throw new Error(`${HELLORUNTIME_ENV.DATABASE_URL} is not set — is this running inside a Helloruntime app?`);
|
|
15
12
|
}
|
|
13
|
+
return url;
|
|
14
|
+
}
|
|
15
|
+
function poolMax() {
|
|
16
16
|
const max = Number(process.env[HELLORUNTIME_ENV.DB_POOL_MAX] ?? DEFAULT_DB_POOL_MAX);
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
return Number.isFinite(max) ? max : DEFAULT_DB_POOL_MAX;
|
|
18
|
+
}
|
|
19
|
+
export function getDb() {
|
|
20
|
+
if (instance)
|
|
21
|
+
return instance;
|
|
22
|
+
const sql = postgres(connectionUrl(), { max: poolMax(), prepare: false });
|
|
23
|
+
instance = drizzle(sql);
|
|
19
24
|
return instance;
|
|
20
25
|
}
|
|
21
26
|
/** Lazily-initialized Drizzle handle. Use with your own schema: `db.select().from(table)`. */
|
|
@@ -33,12 +38,7 @@ export const db = new Proxy({}, {
|
|
|
33
38
|
* export const db = createDatabase(schema);
|
|
34
39
|
*/
|
|
35
40
|
export function createDatabase(schema) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
throw new Error(`${HELLORUNTIME_ENV.DATABASE_URL} is not set — is this running inside a Helloruntime app?`);
|
|
39
|
-
}
|
|
40
|
-
const max = Number(process.env[HELLORUNTIME_ENV.DB_POOL_MAX] ?? DEFAULT_DB_POOL_MAX);
|
|
41
|
-
const pool = new pg.Pool({ connectionString: url, max: Number.isFinite(max) ? max : DEFAULT_DB_POOL_MAX });
|
|
42
|
-
return drizzle(pool, { schema });
|
|
41
|
+
const sql = postgres(connectionUrl(), { max: poolMax(), prepare: false });
|
|
42
|
+
return drizzle(sql, { schema });
|
|
43
43
|
}
|
|
44
44
|
//# sourceMappingURL=db.js.map
|
package/dist/sdk/db.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.js","sourceRoot":"","sources":["../../src/sdk/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"db.js","sourceRoot":"","sources":["../../src/sdk/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,OAAO,EAA2B,MAAM,yBAAyB,CAAC;AAC3E,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,wFAAwF;AACxF,0FAA0F;AAC1F,qFAAqF;AACrF,IAAI,QAAQ,GAA8B,IAAI,CAAC;AAE/C,SAAS,aAAa;IACpB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;IACvD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,GAAG,gBAAgB,CAAC,YAAY,0DAA0D,CAAC,CAAC;IAC9G,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,OAAO;IACd,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,WAAW,CAAC,IAAI,mBAAmB,CAAC,CAAC;IACrF,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,mBAAmB,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,KAAK;IACnB,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACxB,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,8FAA8F;AAC9F,MAAM,CAAC,MAAM,EAAE,GAAuB,IAAI,KAAK,CAAC,EAAwB,EAAE;IACxE,GAAG,CAAC,OAAO,EAAE,QAAQ;QACnB,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAY,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;CACF,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAe;IAEf,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,OAAO,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
export { db, getDb, createDatabase } from "./db.js";
|
|
2
2
|
export { defineJob, type JobDefinition } from "./jobs.js";
|
|
3
|
-
export { defineCron, type CronDefinition } from "./cron.js";
|
|
4
3
|
export { sendJob, type SendJobOptions, type SendJobResult } from "./send-job.js";
|
|
5
4
|
export { createHelloruntimeHandler, type HelloruntimeHandlerOptions } from "./runtime/handler.js";
|
|
6
|
-
export {
|
|
7
|
-
export { helloruntimeHono } from "./runtime/hono.js";
|
|
8
|
-
export { helloruntimeNitro, type HelloruntimeNitroPlugin } from "./runtime/nitro.js";
|
|
9
|
-
export { registerHelloruntime } from "./runtime/register.js";
|
|
10
|
-
export type { JobContext, CronContext, JobHandler, CronHandler } from "@helloruntime/protocol";
|
|
5
|
+
export type { JobContext, JobHandler } from "@helloruntime/protocol";
|
|
11
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/sdk/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAIjF,OAAO,EAAE,yBAAyB,EAAE,KAAK,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElG,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/sdk/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
// The public `helloruntime` SDK surface: import { db,
|
|
1
|
+
// The public `helloruntime` SDK surface: import { db, defineJob, sendJob } from "helloruntime".
|
|
2
|
+
// Crons are Nitro tasks (declare via `scheduledTasks` + `tasks/`) wired by the
|
|
3
|
+
// `helloruntime/nitro` build module — there is no `defineCron`.
|
|
2
4
|
export { db, getDb, createDatabase } from "./db.js";
|
|
3
5
|
export { defineJob } from "./jobs.js";
|
|
4
|
-
export { defineCron } from "./cron.js";
|
|
5
6
|
export { sendJob } from "./send-job.js";
|
|
6
|
-
//
|
|
7
|
+
// Low-level dispatch handler. Tenant apps don't need this — the `helloruntime/nitro`
|
|
8
|
+
// build module injects the dispatch route automatically. Exposed for custom runtimes.
|
|
7
9
|
export { createHelloruntimeHandler } from "./runtime/handler.js";
|
|
8
|
-
export { helloruntimeExpress } from "./runtime/express.js";
|
|
9
|
-
export { helloruntimeHono } from "./runtime/hono.js";
|
|
10
|
-
export { helloruntimeNitro } from "./runtime/nitro.js";
|
|
11
|
-
export { registerHelloruntime } from "./runtime/register.js";
|
|
12
10
|
//# sourceMappingURL=index.js.map
|
package/dist/sdk/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,+EAA+E;AAC/E,gEAAgE;AAChE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,SAAS,EAAsB,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,OAAO,EAA2C,MAAM,eAAe,CAAC;AAEjF,qFAAqF;AACrF,sFAAsF;AACtF,OAAO,EAAE,yBAAyB,EAAmC,MAAM,sBAAsB,CAAC"}
|
package/dist/sdk/jobs.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export interface JobDefinition<T = unknown> {
|
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* Register a job handler. The call is an import side-effect that fills the runtime
|
|
8
|
-
* registry;
|
|
9
|
-
*
|
|
8
|
+
* registry; the `helloruntime/nitro` build module serves `_helloruntime/jobs/<name>`
|
|
9
|
+
* from it. Enqueue work with `sendJob(name, payload)`.
|
|
10
10
|
*/
|
|
11
11
|
export declare function defineJob<T = unknown>(name: string, handler: JobHandler<T>): JobDefinition<T>;
|
|
12
12
|
//# sourceMappingURL=jobs.d.ts.map
|
package/dist/sdk/jobs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { registerJob } from "@helloruntime/protocol";
|
|
2
2
|
/**
|
|
3
3
|
* Register a job handler. The call is an import side-effect that fills the runtime
|
|
4
|
-
* registry;
|
|
5
|
-
*
|
|
4
|
+
* registry; the `helloruntime/nitro` build module serves `_helloruntime/jobs/<name>`
|
|
5
|
+
* from it. Enqueue work with `sendJob(name, payload)`.
|
|
6
6
|
*/
|
|
7
7
|
export function defineJob(name, handler) {
|
|
8
8
|
registerJob(name, handler);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
interface NitroLike {
|
|
2
|
+
options: {
|
|
3
|
+
rootDir: string;
|
|
4
|
+
output: {
|
|
5
|
+
dir: string;
|
|
6
|
+
};
|
|
7
|
+
experimental?: {
|
|
8
|
+
tasks?: boolean;
|
|
9
|
+
};
|
|
10
|
+
scheduledTasks?: Record<string, string | string[]>;
|
|
11
|
+
/** Merged task registry (file-scanned + config), populated by the time `compiled` runs. */
|
|
12
|
+
tasks?: Record<string, {
|
|
13
|
+
description?: string;
|
|
14
|
+
}>;
|
|
15
|
+
handlers: Array<{
|
|
16
|
+
route: string;
|
|
17
|
+
handler: string;
|
|
18
|
+
lazy?: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
};
|
|
21
|
+
hooks: {
|
|
22
|
+
hook(name: string, cb: (nitro: NitroLike) => void | Promise<void>): void;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Nitro build module for helloruntime tenant apps. Add it (after `helloruntime/migrations`):
|
|
27
|
+
*
|
|
28
|
+
* // nitro.config.ts
|
|
29
|
+
* export default defineConfig({
|
|
30
|
+
* preset: "node-server",
|
|
31
|
+
* experimental: { tasks: true },
|
|
32
|
+
* scheduledTasks: { "0 * * * *": ["cleanup"] }, // crons are Nitro tasks
|
|
33
|
+
* modules: ["helloruntime/migrations", "helloruntime/nitro"],
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* It does three things:
|
|
37
|
+
* 1. Mounts the platform→app dispatch route at `/_helloruntime/**` (HMAC-verified;
|
|
38
|
+
* jobs → registered handler, crons → `runTask`). No server plugin / route file needed.
|
|
39
|
+
* 2. Harvests `scheduledTasks` into `.output/helloruntime/triggers.json` at build time —
|
|
40
|
+
* the deterministic, deploy-shipped source of an app's crons (no runtime self-register).
|
|
41
|
+
* 3. Clears `scheduledTasks` so Nitro's in-process croner never starts: the PLATFORM owns
|
|
42
|
+
* cron timing (tenant pods scale to zero), so an in-tenant timer would be wrong. `tasks`
|
|
43
|
+
* is left intact, so `runTask(name)` still works when the platform dispatches a firing.
|
|
44
|
+
*/
|
|
45
|
+
export default function helloruntimeNitro(nitro: NitroLike): void;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=nitro-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nitro-module.d.ts","sourceRoot":"","sources":["../../src/sdk/nitro-module.ts"],"names":[],"mappings":"AAMA,UAAU,SAAS;IACjB,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;QACxB,YAAY,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE,OAAO,CAAA;SAAE,CAAC;QACnC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;QACnD,2FAA2F;QAC3F,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,WAAW,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QACjD,QAAQ,EAAE,KAAK,CAAC;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,OAAO,CAAA;SAAE,CAAC,CAAC;KACrE,CAAC;IACF,KAAK,EAAE;QAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;KAAE,CAAC;CACrF;AASD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CA4ChE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
const DISPATCH_HANDLER = fileURLToPath(new URL("./runtime/nitro-dispatch.js", import.meta.url));
|
|
5
|
+
/**
|
|
6
|
+
* Nitro build module for helloruntime tenant apps. Add it (after `helloruntime/migrations`):
|
|
7
|
+
*
|
|
8
|
+
* // nitro.config.ts
|
|
9
|
+
* export default defineConfig({
|
|
10
|
+
* preset: "node-server",
|
|
11
|
+
* experimental: { tasks: true },
|
|
12
|
+
* scheduledTasks: { "0 * * * *": ["cleanup"] }, // crons are Nitro tasks
|
|
13
|
+
* modules: ["helloruntime/migrations", "helloruntime/nitro"],
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* It does three things:
|
|
17
|
+
* 1. Mounts the platform→app dispatch route at `/_helloruntime/**` (HMAC-verified;
|
|
18
|
+
* jobs → registered handler, crons → `runTask`). No server plugin / route file needed.
|
|
19
|
+
* 2. Harvests `scheduledTasks` into `.output/helloruntime/triggers.json` at build time —
|
|
20
|
+
* the deterministic, deploy-shipped source of an app's crons (no runtime self-register).
|
|
21
|
+
* 3. Clears `scheduledTasks` so Nitro's in-process croner never starts: the PLATFORM owns
|
|
22
|
+
* cron timing (tenant pods scale to zero), so an in-tenant timer would be wrong. `tasks`
|
|
23
|
+
* is left intact, so `runTask(name)` still works when the platform dispatches a firing.
|
|
24
|
+
*/
|
|
25
|
+
export default function helloruntimeNitro(nitro) {
|
|
26
|
+
// Tasks must be enabled for `runTask` + task scanning (the route calls runTask for crons).
|
|
27
|
+
nitro.options.experimental = { ...nitro.options.experimental, tasks: true };
|
|
28
|
+
// Inject the dispatch route once.
|
|
29
|
+
if (!nitro.options.handlers.some((h) => h.handler === DISPATCH_HANDLER)) {
|
|
30
|
+
nitro.options.handlers.push({ route: "/_helloruntime/**", handler: DISPATCH_HANDLER, lazy: true });
|
|
31
|
+
}
|
|
32
|
+
let harvested = [];
|
|
33
|
+
// Before the build emits the virtual tasks module: snapshot the schedules, then clear
|
|
34
|
+
// them so the croner stays off. (Reading config-level scheduledTasks here is safe — it
|
|
35
|
+
// is populated from nitro.config before build hooks run.)
|
|
36
|
+
nitro.hooks.hook("build:before", (instance) => {
|
|
37
|
+
const scheduled = instance.options.scheduledTasks ?? {};
|
|
38
|
+
const crons = [];
|
|
39
|
+
const seen = new Set();
|
|
40
|
+
for (const [schedule, names] of Object.entries(scheduled)) {
|
|
41
|
+
for (const name of Array.isArray(names) ? names : [names]) {
|
|
42
|
+
if (seen.has(name))
|
|
43
|
+
continue; // one schedule per task name (crons.name is unique)
|
|
44
|
+
seen.add(name);
|
|
45
|
+
crons.push({ name, schedule });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
harvested = crons;
|
|
49
|
+
instance.options.scheduledTasks = {};
|
|
50
|
+
});
|
|
51
|
+
// After the build: write the manifest the CLI ships in the deploy request. The full
|
|
52
|
+
// task registry is read here (not build:before) — file-scanned tasks aren't populated
|
|
53
|
+
// until after the scan phase. Mirrors what Nitro's `/_nitro/tasks` exposes.
|
|
54
|
+
nitro.hooks.hook("compiled", (instance) => {
|
|
55
|
+
const tasks = Object.entries(instance.options.tasks ?? {}).map(([name, t]) => ({
|
|
56
|
+
name,
|
|
57
|
+
description: t?.description || undefined
|
|
58
|
+
}));
|
|
59
|
+
const dir = join(instance.options.output.dir, "helloruntime");
|
|
60
|
+
mkdirSync(dir, { recursive: true });
|
|
61
|
+
writeFileSync(join(dir, "triggers.json"), JSON.stringify({ tasks, crons: harvested, jobs: [] }, null, 2));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=nitro-module.js.map
|
|
@@ -0,0 +1 @@
|
|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,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAC/D,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../../src/sdk/runtime/express.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,EAA6B,KAAK,0BAA0B,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../../src/sdk/runtime/express.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,EAA6B,KAAK,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAI1F,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;AAMtC,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,0BAA+B,IAGnC,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,MAAM,KAAG,IAAI,CAgBtG"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { createHelloruntimeHandler } from "./handler.js";
|
|
2
|
-
import { registerHelloruntime } from "./register.js";
|
|
3
2
|
const HELLORUNTIME_PREFIX = "/_helloruntime/";
|
|
4
|
-
// Express middleware: terminates `/_helloruntime/*` dispatch (verifying HMAC + running
|
|
5
|
-
// the registered
|
|
6
|
-
//
|
|
3
|
+
// Express middleware: terminates `/_helloruntime/*` job dispatch (verifying HMAC + running
|
|
4
|
+
// the registered handler) and calls next() for everything else. Mount it BEFORE any
|
|
5
|
+
// body-parser — the HMAC covers the exact raw bytes, which a parser consumes. Cron
|
|
6
|
+
// dispatch needs Nitro's `runTask`; pass `runCron` if serving crons outside Nitro.
|
|
7
7
|
export function helloruntimeExpress(options = {}) {
|
|
8
8
|
const handle = createHelloruntimeHandler(options);
|
|
9
|
-
setImmediate(() => void registerHelloruntime()); // after the entry module's defineJob/defineCron run
|
|
10
9
|
return function helloruntimeMiddleware(req, res, next) {
|
|
11
10
|
if (!req.url?.startsWith(HELLORUNTIME_PREFIX)) {
|
|
12
11
|
next();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../../src/sdk/runtime/express.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAmC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../../src/sdk/runtime/express.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAmC,MAAM,cAAc,CAAC;AAE1F,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAI9C,2FAA2F;AAC3F,oFAAoF;AACpF,mFAAmF;AACnF,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CAAC,UAAsC,EAAE;IAC1E,MAAM,MAAM,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAElD,OAAO,SAAS,sBAAsB,CAAC,GAAoB,EAAE,GAAmB,EAAE,IAAY;QAC5F,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAC9C,IAAI,EAAE,CAAC;YACP,OAAO;QACT,CAAC;QACD,QAAQ,CAAC,GAAG,CAAC;aACV,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YACnB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;YACvD,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,IAAI,EAAE,CAAC;gBACP,OAAO;YACT,CAAC;YACD,MAAM,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACrC,CAAC,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AC7C,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,KAAK;QAC3B,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;KACrC,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,GAAmB,EAAE,QAAkB;IAClE,GAAG,CAAC,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IACpE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { type RuntimeRegistry } from "@helloruntime/protocol";
|
|
2
|
+
/** Context handed to a cron runner alongside the (usually empty) payload. */
|
|
3
|
+
export interface CronDispatchContext {
|
|
4
|
+
idempotencyKey: string;
|
|
5
|
+
attempt: number;
|
|
6
|
+
scheduledAt: Date;
|
|
7
|
+
}
|
|
2
8
|
export interface HelloruntimeHandlerOptions {
|
|
3
|
-
/** The populated job
|
|
9
|
+
/** The populated job registry. Defaults to the global registry defineJob fills. */
|
|
4
10
|
registry?: RuntimeRegistry;
|
|
5
11
|
/** Per-app HMAC secret; defaults to HELLORUNTIME_DISPATCH_SECRET. Verification fails closed if absent. */
|
|
6
12
|
dispatchSecret?: string;
|
|
@@ -8,6 +14,13 @@ export interface HelloruntimeHandlerOptions {
|
|
|
8
14
|
handlerTimeoutMs?: number;
|
|
9
15
|
/** Current unix seconds (injectable for tests). */
|
|
10
16
|
now?: () => number;
|
|
17
|
+
/**
|
|
18
|
+
* Runs a cron firing by task name. Crons are Nitro tasks now, so the Nitro build module
|
|
19
|
+
* supplies `(name, payload, ctx) => runTask(name, { payload, context: ctx })`. When
|
|
20
|
+
* absent, cron dispatch is unsupported (501) — e.g. the raw Express/Hono shims, which
|
|
21
|
+
* have no task runner.
|
|
22
|
+
*/
|
|
23
|
+
runCron?: (name: string, payload: unknown, ctx: CronDispatchContext) => Promise<unknown> | unknown;
|
|
11
24
|
}
|
|
12
25
|
export declare function createHelloruntimeHandler(options?: HelloruntimeHandlerOptions): (request: Request) => Promise<Response | null>;
|
|
13
26
|
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/sdk/runtime/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAIhC,MAAM,WAAW,0BAA0B;IACzC,
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/sdk/runtime/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAIhC,6EAA6E;AAC7E,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,0BAA0B;IACzC,mFAAmF;IACnF,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,0GAA0G;IAC1G,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mDAAmD;IACnD,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,mBAAmB,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CACpG;AA0BD,wBAAgB,yBAAyB,CACvC,OAAO,GAAE,0BAA+B,GACvC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CA6DhD"}
|
|
@@ -21,8 +21,8 @@ async function runWithTimeout(fn, ms) {
|
|
|
21
21
|
}
|
|
22
22
|
// The platform's job/cron dispatch handler, as a plain WHATWG fetch function.
|
|
23
23
|
// Returns a Response for a verified `/_helloruntime/jobs|cron/:name` POST, or `null`
|
|
24
|
-
// for any other request so the host app serves its own routes.
|
|
25
|
-
//
|
|
24
|
+
// for any other request so the host app serves its own routes. Jobs run the registered
|
|
25
|
+
// handler (defineJob); crons run via the injected `runCron` (Nitro `runTask`).
|
|
26
26
|
export function createHelloruntimeHandler(options = {}) {
|
|
27
27
|
const registry = options.registry ?? getRegistry();
|
|
28
28
|
const timeoutMs = options.handlerTimeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
@@ -65,13 +65,11 @@ export function createHelloruntimeHandler(options = {}) {
|
|
|
65
65
|
}), timeoutMs);
|
|
66
66
|
}
|
|
67
67
|
else {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
await runWithTimeout(() => entry.handler({
|
|
72
|
-
name,
|
|
73
|
-
schedule: entry.schedule,
|
|
68
|
+
if (!options.runCron)
|
|
69
|
+
return json(501, { error: "cron dispatch not supported in this runtime" });
|
|
70
|
+
await runWithTimeout(() => options.runCron(name, envelope.payload, {
|
|
74
71
|
idempotencyKey: envelope.idempotencyKey,
|
|
72
|
+
attempt: envelope.attempt,
|
|
75
73
|
scheduledAt: new Date(envelope.enqueuedAt)
|
|
76
74
|
}), timeoutMs);
|
|
77
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/sdk/runtime/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EACzB,wBAAwB,EACxB,gBAAgB,EAEjB,MAAM,wBAAwB,CAAC;AAEh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AC,QAAQ,CAAC,UAAU,CAAC;iBAC3C,CAAC,EACJ,SAAS,CACV,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACtF,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../../src/sdk/runtime/hono.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,0BAA0B,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../../src/sdk/runtime/hono.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAI1F,UAAU,eAAe;IACvB,GAAG,EAAE;QAAE,GAAG,EAAE,OAAO,CAAA;KAAE,CAAC;CACvB;AACD,KAAK,QAAQ,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAMpC,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,0BAA+B,IAG1B,GAAG,eAAe,EAAE,MAAM,QAAQ,KAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAK3G"}
|
package/dist/sdk/runtime/hono.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { createHelloruntimeHandler } from "./handler.js";
|
|
2
|
-
|
|
3
|
-
// Hono middleware: terminates `/_helloruntime/*` dispatch, falls through otherwise.
|
|
2
|
+
// Hono middleware: terminates `/_helloruntime/*` job dispatch, falls through otherwise.
|
|
4
3
|
// `app.use(helloruntimeHono())`. The handler inspects the path before touching the body,
|
|
5
|
-
// so non-dispatch requests pass through with their body intact.
|
|
4
|
+
// so non-dispatch requests pass through with their body intact. Cron dispatch needs
|
|
5
|
+
// Nitro's `runTask`; pass `runCron` if serving crons outside Nitro.
|
|
6
6
|
export function helloruntimeHono(options = {}) {
|
|
7
7
|
const handle = createHelloruntimeHandler(options);
|
|
8
|
-
setImmediate(() => void registerHelloruntime());
|
|
9
8
|
return async function helloruntimeMiddleware(c, next) {
|
|
10
9
|
const response = await handle(c.req.raw);
|
|
11
10
|
if (response)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono.js","sourceRoot":"","sources":["../../../src/sdk/runtime/hono.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAmC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"hono.js","sourceRoot":"","sources":["../../../src/sdk/runtime/hono.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAmC,MAAM,cAAc,CAAC;AAS1F,wFAAwF;AACxF,yFAAyF;AACzF,oFAAoF;AACpF,oEAAoE;AACpE,MAAM,UAAU,gBAAgB,CAAC,UAAsC,EAAE;IACvE,MAAM,MAAM,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAElD,OAAO,KAAK,UAAU,sBAAsB,CAAC,CAAkB,EAAE,IAAc;QAC7E,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACzC,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAC9B,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nitro-dispatch.d.ts","sourceRoot":"","sources":["../../../src/sdk/runtime/nitro-dispatch.ts"],"names":[],"mappings":"wBA0BgC,OAAO;AAAvC,wBAAwC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineHandler } from "nitro";
|
|
2
|
+
import { runTask } from "nitro/task";
|
|
3
|
+
import { createHelloruntimeHandler } from "./handler.js";
|
|
4
|
+
// The platform→app dispatch route, injected by the `helloruntime/nitro` build module at
|
|
5
|
+
// `/_helloruntime/**`. Jobs run the registered handler (defineJob); crons are Nitro
|
|
6
|
+
// tasks, run via `runTask` (idempotent — safe under runTask's name-level single-flight).
|
|
7
|
+
// Nitro 3 / h3 v2: `event.req` is a WHATWG Request and we can return a Response directly.
|
|
8
|
+
const handle = createHelloruntimeHandler({
|
|
9
|
+
runCron: (name, payload, ctx) => runTask(name, {
|
|
10
|
+
// A scheduled firing carries no payload; tolerate one if a manual trigger sends an object.
|
|
11
|
+
payload: (payload && typeof payload === "object" ? payload : {}),
|
|
12
|
+
context: { ...ctx, scheduledAt: ctx.scheduledAt.toISOString() }
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
const dispatchRoute = defineHandler(async (event) => {
|
|
16
|
+
const response = await handle(event.req);
|
|
17
|
+
return response ?? new Response("Not found", { status: 404 });
|
|
18
|
+
});
|
|
19
|
+
// `defineHandler`'s return type references h3 internals TS can't name portably in the
|
|
20
|
+
// emitted .d.ts (TS2742). Nitro resolves this handler by path at build and only uses the
|
|
21
|
+
// runtime value, so erasing the declared type is safe.
|
|
22
|
+
export default dispatchRoute;
|
|
23
|
+
//# sourceMappingURL=nitro-dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nitro-dispatch.js","sourceRoot":"","sources":["../../../src/sdk/runtime/nitro-dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,wFAAwF;AACxF,oFAAoF;AACpF,yFAAyF;AACzF,0FAA0F;AAC1F,MAAM,MAAM,GAAG,yBAAyB,CAAC;IACvC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,CAC9B,OAAO,CAAC,IAAI,EAAE;QACZ,2FAA2F;QAC3F,OAAO,EAAE,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAA4B;QAC3F,OAAO,EAAE,EAAE,GAAG,GAAG,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC,WAAW,EAAE,EAA6B;KAC3F,CAAC;CACL,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IAClD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzC,OAAO,QAAQ,IAAI,IAAI,QAAQ,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC;AAEH,sFAAsF;AACtF,yFAAyF;AACzF,uDAAuD;AACvD,eAAe,aAAwB,CAAC"}
|
package/helloruntime.schema.json
CHANGED
|
@@ -37,6 +37,18 @@
|
|
|
37
37
|
"description": "Run Drizzle migrations from ./db/migrations against the managed database before cutover. The deploy fails if a migration errors. Set false to opt out."
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
},
|
|
41
|
+
"redis": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"additionalProperties": false,
|
|
44
|
+
"description": "Managed Redis (shared instance, per-app ACL user).",
|
|
45
|
+
"properties": {
|
|
46
|
+
"enabled": {
|
|
47
|
+
"type": "boolean",
|
|
48
|
+
"default": false,
|
|
49
|
+
"description": "Provision a per-app Redis user and inject REDIS_URL + HELLORUNTIME_REDIS_PREFIX (the key/channel prefix the ACL restricts you to). Opt-in."
|
|
50
|
+
}
|
|
51
|
+
}
|
|
40
52
|
}
|
|
41
53
|
}
|
|
42
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "helloruntime",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "CLI + runtime SDK for Helloruntime — a small self-hostable PaaS for server-rendered JS/TS apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://helloruntime.com",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"default": "./dist/sdk/index.js"
|
|
28
28
|
},
|
|
29
29
|
"./nitro": {
|
|
30
|
-
"types": "./dist/sdk/
|
|
31
|
-
"default": "./dist/sdk/
|
|
30
|
+
"types": "./dist/sdk/nitro-module.d.ts",
|
|
31
|
+
"default": "./dist/sdk/nitro-module.js"
|
|
32
32
|
},
|
|
33
33
|
"./migrations": {
|
|
34
34
|
"types": "./dist/sdk/nitro-migrations.d.ts",
|
|
@@ -42,14 +42,22 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"commander": "^14.0.0",
|
|
44
44
|
"drizzle-orm": "^0.44.7",
|
|
45
|
-
"
|
|
45
|
+
"postgres": "^3.4.9",
|
|
46
46
|
"tar": "^7.4.3",
|
|
47
47
|
"zod": "^3.25.67",
|
|
48
48
|
"@helloruntime/protocol": "^0.0.5"
|
|
49
49
|
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"nitro": ">=3.0.0-beta"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"nitro": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
50
58
|
"devDependencies": {
|
|
51
|
-
"@types/
|
|
52
|
-
"
|
|
59
|
+
"@types/tar": "^6.1.13",
|
|
60
|
+
"nitro": "^3.0.260311-beta"
|
|
53
61
|
},
|
|
54
62
|
"scripts": {
|
|
55
63
|
"build": "tsc -p tsconfig.json",
|