helloruntime 0.0.4 → 0.0.6
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/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 +1 -1
- package/dist/cli/packager.d.ts.map +1 -1
- package/dist/cli/packager.js +4 -13
- package/dist/cli/packager.js.map +1 -1
- package/dist/sdk/index.d.ts +1 -4
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +5 -5
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/nitro-migrations.d.ts +24 -0
- package/dist/sdk/nitro-migrations.d.ts.map +1 -0
- package/dist/sdk/nitro-migrations.js +21 -0
- package/dist/sdk/nitro-migrations.js.map +1 -0
- package/dist/sdk/nitro-module.d.ts +43 -0
- package/dist/sdk/nitro-module.d.ts.map +1 -0
- package/dist/sdk/nitro-module.js +58 -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/package.json +18 -5
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,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
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,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,W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EAAE,CAAC;IAC5B,SAAS,CAAC;QACR,MAAM,MAAM,GAAG,MAAM,mBAAmB,CACtC,MAAM,EACN,mBAAmB,OAAO,CAAC,YAAY,EAAE,CAC1C,CAAC;QACF,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YAC5B,2EAA2E;YAC3E,6EAA6E;YAC7E,yDAAyD;YACzD,IAAI,KAAK,KAAK,EAAE;gBAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;YAC1F,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YAC7C,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;YACtB,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC1B,CAAC;QACD,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC3B,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC/B,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
|
@@ -5,7 +5,7 @@ import { destroyCommand } from "./destroy.js";
|
|
|
5
5
|
import { loginCommand } from "./login.js";
|
|
6
6
|
import { cronList, cronTrigger, jobsList, jobsTrigger } from "./triggers.js";
|
|
7
7
|
const program = new Command();
|
|
8
|
-
program.name("helloruntime").description("Deploy server-rendered JS/TS apps to Helloruntime").version("0.0.
|
|
8
|
+
program.name("helloruntime").description("Deploy server-rendered JS/TS apps to Helloruntime").version("0.0.5");
|
|
9
9
|
program
|
|
10
10
|
.command("login")
|
|
11
11
|
.description("Authenticate via the browser (device flow)")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packager.d.ts","sourceRoot":"","sources":["../../src/cli/packager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"packager.d.ts","sourceRoot":"","sources":["../../src/cli/packager.ts"],"names":[],"mappings":"AAwBA,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB3E;AAgBD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAKD,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAsCxE"}
|
package/dist/cli/packager.js
CHANGED
|
@@ -8,9 +8,6 @@ import { pipeline } from "node:stream/promises";
|
|
|
8
8
|
import * as tar from "tar";
|
|
9
9
|
const OUTPUT_DIR = ".output";
|
|
10
10
|
const ENTRY = join(OUTPUT_DIR, "server", "index.mjs");
|
|
11
|
-
// Drizzle migrations live here by convention; packaged alongside .output so the platform
|
|
12
|
-
// migrator (run as a pre-cutover Job) can apply them against the managed database.
|
|
13
|
-
const MIGRATIONS_DIR = join("db", "migrations");
|
|
14
11
|
// Detect the package manager from the lockfile so `<pm> run build` matches what the
|
|
15
12
|
// developer uses. Defaults to npm.
|
|
16
13
|
function detectPackageManager(files) {
|
|
@@ -70,19 +67,13 @@ export async function packageBundle(cwd) {
|
|
|
70
67
|
native.map((n) => ` - ${n}`).join("\n") +
|
|
71
68
|
`\nRemove the native dependency, or request it be added to the runtime image.`);
|
|
72
69
|
}
|
|
73
|
-
// Package .output and, if present, ./db/migrations (Drizzle convention) so the
|
|
74
|
-
// platform can run migrations from /app/db/migrations before cutover.
|
|
75
|
-
const entries = [OUTPUT_DIR];
|
|
76
|
-
const hasMigrations = await access(join(cwd, MIGRATIONS_DIR))
|
|
77
|
-
.then(() => true)
|
|
78
|
-
.catch(() => false);
|
|
79
|
-
if (hasMigrations)
|
|
80
|
-
entries.push(MIGRATIONS_DIR);
|
|
81
70
|
const outDir = join(cwd, ".helloruntime", "artifacts");
|
|
82
71
|
await mkdir(outDir, { recursive: true });
|
|
83
72
|
const tarPath = join(outDir, "bundle.tgz");
|
|
84
|
-
//
|
|
85
|
-
|
|
73
|
+
// Ship ONLY .output — whatever the app's nitro.config put there (incl. db/migrations
|
|
74
|
+
// via the `helloruntime/migrations` module). The CLI knows nothing app-specific.
|
|
75
|
+
// The loader extracts to /app → /app/.output/server/index.mjs.
|
|
76
|
+
await tar.c({ gzip: true, file: tarPath, cwd, portable: true }, [OUTPUT_DIR]);
|
|
86
77
|
const hash = createHash("sha256");
|
|
87
78
|
await pipeline(createReadStream(tarPath), new Transform({
|
|
88
79
|
transform(chunk, _enc, cb) {
|
package/dist/cli/packager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packager.js","sourceRoot":"","sources":["../../src/cli/packager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChD,OAA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AAC,IAAI,CAAC;YACxC,8EAA8E,CACjF,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC;IACvD,MAAM,KAAK,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC3C,qFAAqF;IACrF,iFAAiF;IACjF,+DAA+D;IAC/D,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAE9E,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,QAAQ,CACZ,gBAAgB,CAAC,OAAO,CAAC,EACzB,IAAI,SAAS,CAAC;QACZ,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YACvB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnB,EAAE,EAAE,CAAC;QACP,CAAC;KACF,CAAC,CACH,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;AAC7E,CAAC"}
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
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
5
|
export { helloruntimeExpress } from "./runtime/express.js";
|
|
7
6
|
export { helloruntimeHono } from "./runtime/hono.js";
|
|
8
|
-
export {
|
|
9
|
-
export { registerHelloruntime } from "./runtime/register.js";
|
|
10
|
-
export type { JobContext, CronContext, JobHandler, CronHandler } from "@helloruntime/protocol";
|
|
7
|
+
export type { JobContext, JobHandler } from "@helloruntime/protocol";
|
|
11
8
|
//# 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;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/sdk/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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
|
-
// Runtime: serve platform job
|
|
7
|
+
// Runtime: serve platform job dispatch from inside the app's own HTTP server. Nitro apps
|
|
8
|
+
// use the `helloruntime/nitro` build module instead (it injects the route automatically).
|
|
7
9
|
export { createHelloruntimeHandler } from "./runtime/handler.js";
|
|
8
10
|
export { helloruntimeExpress } from "./runtime/express.js";
|
|
9
11
|
export { helloruntimeHono } from "./runtime/hono.js";
|
|
10
|
-
export { helloruntimeNitro } from "./runtime/nitro.js";
|
|
11
|
-
export { registerHelloruntime } from "./runtime/register.js";
|
|
12
12
|
//# 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,yFAAyF;AACzF,0FAA0F;AAC1F,OAAO,EAAE,yBAAyB,EAAmC,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface NitroLike {
|
|
2
|
+
options: {
|
|
3
|
+
rootDir: string;
|
|
4
|
+
output: {
|
|
5
|
+
dir: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
hooks: {
|
|
9
|
+
hook(name: string, cb: (nitro: NitroLike) => void | Promise<void>): void;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Nitro build module that copies `./db/migrations` (Drizzle's output folder) into the
|
|
14
|
+
* build output, so migrations ride inside `.output` (→ `/app/.output/db/migrations` at
|
|
15
|
+
* runtime) and the platform migrator applies them before cutover. Keeps bundle
|
|
16
|
+
* composition in the app's nitro.config — the CLI just ships `.output`, with no
|
|
17
|
+
* knowledge of the Drizzle convention.
|
|
18
|
+
*
|
|
19
|
+
* // nitro.config.ts
|
|
20
|
+
* export default defineConfig({ modules: ["helloruntime/migrations"] });
|
|
21
|
+
*/
|
|
22
|
+
export default function helloruntimeMigrations(nitro: NitroLike): void;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=nitro-migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nitro-migrations.d.ts","sourceRoot":"","sources":["../../src/sdk/nitro-migrations.ts"],"names":[],"mappings":"AAKA,UAAU,SAAS;IACjB,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IACtD,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;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAMrE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { cpSync, existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Nitro build module that copies `./db/migrations` (Drizzle's output folder) into the
|
|
5
|
+
* build output, so migrations ride inside `.output` (→ `/app/.output/db/migrations` at
|
|
6
|
+
* runtime) and the platform migrator applies them before cutover. Keeps bundle
|
|
7
|
+
* composition in the app's nitro.config — the CLI just ships `.output`, with no
|
|
8
|
+
* knowledge of the Drizzle convention.
|
|
9
|
+
*
|
|
10
|
+
* // nitro.config.ts
|
|
11
|
+
* export default defineConfig({ modules: ["helloruntime/migrations"] });
|
|
12
|
+
*/
|
|
13
|
+
export default function helloruntimeMigrations(nitro) {
|
|
14
|
+
nitro.hooks.hook("compiled", (instance) => {
|
|
15
|
+
const src = join(instance.options.rootDir, "db", "migrations");
|
|
16
|
+
if (!existsSync(src))
|
|
17
|
+
return;
|
|
18
|
+
cpSync(src, join(instance.options.output.dir, "db", "migrations"), { recursive: true });
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=nitro-migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nitro-migrations.js","sourceRoot":"","sources":["../../src/sdk/nitro-migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AASjC;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,KAAgB;IAC7D,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QAC/D,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,OAAO;QAC7B,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1F,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
handlers: Array<{
|
|
12
|
+
route: string;
|
|
13
|
+
handler: string;
|
|
14
|
+
lazy?: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
hooks: {
|
|
18
|
+
hook(name: string, cb: (nitro: NitroLike) => void | Promise<void>): void;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Nitro build module for helloruntime tenant apps. Add it (after `helloruntime/migrations`):
|
|
23
|
+
*
|
|
24
|
+
* // nitro.config.ts
|
|
25
|
+
* export default defineConfig({
|
|
26
|
+
* preset: "node-server",
|
|
27
|
+
* experimental: { tasks: true },
|
|
28
|
+
* scheduledTasks: { "0 * * * *": ["cleanup"] }, // crons are Nitro tasks
|
|
29
|
+
* modules: ["helloruntime/migrations", "helloruntime/nitro"],
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* It does three things:
|
|
33
|
+
* 1. Mounts the platform→app dispatch route at `/_helloruntime/**` (HMAC-verified;
|
|
34
|
+
* jobs → registered handler, crons → `runTask`). No server plugin / route file needed.
|
|
35
|
+
* 2. Harvests `scheduledTasks` into `.output/helloruntime/triggers.json` at build time —
|
|
36
|
+
* the deterministic, deploy-shipped source of an app's crons (no runtime self-register).
|
|
37
|
+
* 3. Clears `scheduledTasks` so Nitro's in-process croner never starts: the PLATFORM owns
|
|
38
|
+
* cron timing (tenant pods scale to zero), so an in-tenant timer would be wrong. `tasks`
|
|
39
|
+
* is left intact, so `runTask(name)` still works when the platform dispatches a firing.
|
|
40
|
+
*/
|
|
41
|
+
export default function helloruntimeNitro(nitro: NitroLike): void;
|
|
42
|
+
export {};
|
|
43
|
+
//# 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,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,CAsChE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
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.
|
|
52
|
+
nitro.hooks.hook("compiled", (instance) => {
|
|
53
|
+
const dir = join(instance.options.output.dir, "helloruntime");
|
|
54
|
+
mkdirSync(dir, { recursive: true });
|
|
55
|
+
writeFileSync(join(dir, "triggers.json"), JSON.stringify({ crons: harvested, jobs: [] }, null, 2));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=nitro-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nitro-module.js","sourceRoot":"","sources":["../../src/sdk/nitro-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAoBjC,MAAM,gBAAgB,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,6BAA6B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAAgB;IACxD,2FAA2F;IAC3F,KAAK,CAAC,OAAO,CAAC,YAAY,GAAG,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAE5E,kCAAkC;IAClC,I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C,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAC9D,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACpC,aAAa,CACX,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,EAC1B,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CACxD,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,CA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D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,KAAK,MAAM,CAAC,IAAI,KAAK;gBAAE,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;aACnE,IAAI,KAAK,IAAI,IAAI;YAAE,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,IAAI,OAAO,CAAC,UAAU,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE,EAAE;QAC7C,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;AAEhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;
|
|
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;AAEhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AA2BpD,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE1C,SAAS,IAAI,CAAC,MAAc,EAAE,IAAa;IACzC,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC;AACzG,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,EAAoC,EAAE,EAAU;IAC5E,IAAI,KAAgD,CAAC;IACrD,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,IAAI,CAAC;YACjB,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,IAAI,OAAO,CAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;gBAC/B,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,EAAE,IAAI,CAAC,CA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,CAAC,OAAO,CAAC,OAAO;oBAAE,OAAO,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,6CAA6C,EAAE,CAAC,CAAC;gBACjG,MAAM,cAAc,CAClB,GAAG,EAAE,CACH,OAAO,CAAC,OAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE;oBACvC,cAAc,EAAE,QAAQ,CAAC,cAAc;oBACvC,OAAO,EAAE,QAAQ,CAAC,OAAO;oBACzB,WAAW,EAAE,IAAI,IAAI,CAAC,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "helloruntime",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
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,12 @@
|
|
|
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
|
+
},
|
|
33
|
+
"./migrations": {
|
|
34
|
+
"types": "./dist/sdk/nitro-migrations.d.ts",
|
|
35
|
+
"default": "./dist/sdk/nitro-migrations.js"
|
|
32
36
|
}
|
|
33
37
|
},
|
|
34
38
|
"files": [
|
|
@@ -41,11 +45,20 @@
|
|
|
41
45
|
"pg": "^8.16.2",
|
|
42
46
|
"tar": "^7.4.3",
|
|
43
47
|
"zod": "^3.25.67",
|
|
44
|
-
"@helloruntime/protocol": "^0.0.
|
|
48
|
+
"@helloruntime/protocol": "^0.0.5"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"nitro": ">=3.0.0-beta"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"nitro": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
45
57
|
},
|
|
46
58
|
"devDependencies": {
|
|
47
59
|
"@types/pg": "^8.15.4",
|
|
48
|
-
"@types/tar": "^6.1.13"
|
|
60
|
+
"@types/tar": "^6.1.13",
|
|
61
|
+
"nitro": "^3.0.260311-beta"
|
|
49
62
|
},
|
|
50
63
|
"scripts": {
|
|
51
64
|
"build": "tsc -p tsconfig.json",
|