@rebasepro/server 0.12.0 → 0.12.1-canary.gdfba2a1
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/GCSStorageController-BEmDYFKc.js +216 -0
- package/dist/GCSStorageController-BEmDYFKc.js.map +1 -0
- package/dist/S3StorageController-CK7r5yZb.js +243 -0
- package/dist/S3StorageController-CK7r5yZb.js.map +1 -0
- package/dist/admin_block-BGQFSAuV.js +123 -0
- package/dist/admin_block-BGQFSAuV.js.map +1 -0
- package/dist/auth-Bb7XFCKN.js +8898 -0
- package/dist/auth-Bb7XFCKN.js.map +1 -0
- package/dist/backend-CIxN4FVm.js +15 -0
- package/dist/backend-CIxN4FVm.js.map +1 -0
- package/dist/backup-C3Bah7XZ.js +163 -0
- package/dist/backup-C3Bah7XZ.js.map +1 -0
- package/dist/boot/boot.d.ts +20 -0
- package/dist/boot/fetch-bundle.d.ts +43 -0
- package/dist/contract-routes-Dj8i5AiM.js +264 -0
- package/dist/contract-routes-Dj8i5AiM.js.map +1 -0
- package/dist/cron/cron-scheduler.d.ts +34 -0
- package/dist/cron-loader-B1S2MCSl.js +63 -0
- package/dist/cron-loader-B1S2MCSl.js.map +1 -0
- package/dist/cron-routes-Do325hDt.js +62 -0
- package/dist/cron-routes-Do325hDt.js.map +1 -0
- package/dist/cron-scheduler-B3RFt0HS.js +647 -0
- package/dist/cron-scheduler-B3RFt0HS.js.map +1 -0
- package/dist/cron-store-BywZsyfZ.js +164 -0
- package/dist/cron-store-BywZsyfZ.js.map +1 -0
- package/dist/dynamic-import-Dvh-K5fl.js.map +1 -1
- package/dist/errors-BYAQztMf.js +222 -0
- package/dist/errors-BYAQztMf.js.map +1 -0
- package/dist/function-loader-B_1fYfUY.js +86 -0
- package/dist/function-loader-B_1fYfUY.js.map +1 -0
- package/dist/function-routes-C0cLIy3N.js +28 -0
- package/dist/function-routes-C0cLIy3N.js.map +1 -0
- package/dist/index.es.js +7480 -17861
- package/dist/index.es.js.map +1 -1
- package/dist/{jwt-D-eI6TTu.js → jwt-DD6EtpGj.js} +32 -13
- package/dist/{jwt-D-eI6TTu.js.map → jwt-DD6EtpGj.js.map} +1 -1
- package/dist/logger-BYU66ENZ.js.map +1 -1
- package/dist/logs-routes-BYA72C_C.js +100 -0
- package/dist/logs-routes-BYA72C_C.js.map +1 -0
- package/dist/{openapi-generator-Bjzmb5cn.js → openapi-generator-DFDS7kVk.js} +9 -3
- package/dist/openapi-generator-DFDS7kVk.js.map +1 -0
- package/dist/{schema-editor-routes-DDxfOIid.js → schema-editor-routes-CZVW2iBr.js} +4 -3
- package/dist/{schema-editor-routes-DDxfOIid.js.map → schema-editor-routes-CZVW2iBr.js.map} +1 -1
- package/dist/{src-CoOAMnBh.js → src-DymRyxdb.js} +196 -65
- package/dist/src-DymRyxdb.js.map +1 -0
- package/dist/src-_qQ3RNCK.js +279 -0
- package/dist/src-_qQ3RNCK.js.map +1 -0
- package/dist/types-DSnOC4mF.js +38 -0
- package/dist/types-DSnOC4mF.js.map +1 -0
- package/package.json +10 -10
- package/dist/openapi-generator-Bjzmb5cn.js.map +0 -1
- package/dist/src-CoOAMnBh.js.map +0 -1
- package/dist/src-Ivjud8jD.js +0 -957
- package/dist/src-Ivjud8jD.js.map +0 -1
- /package/dist/{chunk-DSJWtz9O.js → rolldown-runtime-DSJWtz9O.js} +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "module";
|
|
2
|
+
import "process";
|
|
3
|
+
__createRequire(import.meta.url);
|
|
4
|
+
import { n as __exportAll } from "./rolldown-runtime-DSJWtz9O.js";
|
|
5
|
+
import { t as logger } from "./logger-BYU66ENZ.js";
|
|
6
|
+
import { t as nativeDynamicImport } from "./dynamic-import-Dvh-K5fl.js";
|
|
7
|
+
import * as fs$1 from "fs";
|
|
8
|
+
import * as path$1 from "path";
|
|
9
|
+
import { pathToFileURL } from "url";
|
|
10
|
+
//#region src/functions/function-loader.ts
|
|
11
|
+
var function_loader_exports = /* @__PURE__ */ __exportAll({ loadFunctionsFromDirectory: () => loadFunctionsFromDirectory });
|
|
12
|
+
/**
|
|
13
|
+
* Auto-discover Hono route files from a directory.
|
|
14
|
+
*
|
|
15
|
+
* Each file should default-export a Hono app (or router).
|
|
16
|
+
* The filename (without extension) becomes the mount path:
|
|
17
|
+
* `functions/send-invoice.ts` → mounted at `/send-invoice`
|
|
18
|
+
*
|
|
19
|
+
* This mirrors how `loadCollectionsFromDirectory` works for collections.
|
|
20
|
+
*/
|
|
21
|
+
async function loadFunctionsFromDirectory(directory, importModule = nativeDynamicImport) {
|
|
22
|
+
const functions = [];
|
|
23
|
+
const problems = [];
|
|
24
|
+
if (!fs$1.existsSync(directory)) return functions;
|
|
25
|
+
const files = fs$1.readdirSync(directory);
|
|
26
|
+
for (const file of files) if ((file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith(".") && !file.includes(".test.") && !file.endsWith(".d.ts") && file !== "index.ts" && file !== "index.js") {
|
|
27
|
+
const filePath = path$1.join(directory, file);
|
|
28
|
+
try {
|
|
29
|
+
const fileUrl = pathToFileURL(filePath).href;
|
|
30
|
+
const exported = (await importModule(fileUrl)).default;
|
|
31
|
+
if (!exported) {
|
|
32
|
+
logger.warn(`[functions] ${file}: no default export. Skipping.`);
|
|
33
|
+
problems.push(`${file} (no default export)`);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (isHonoLike(exported)) {
|
|
37
|
+
const name = path$1.basename(file, path$1.extname(file));
|
|
38
|
+
functions.push({
|
|
39
|
+
name,
|
|
40
|
+
app: exported
|
|
41
|
+
});
|
|
42
|
+
logger.info(`⚡ Loaded function route: ${name}`);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (typeof exported === "function") {
|
|
46
|
+
const result = exported();
|
|
47
|
+
if (isHonoLike(result)) {
|
|
48
|
+
const name = path$1.basename(file, path$1.extname(file));
|
|
49
|
+
functions.push({
|
|
50
|
+
name,
|
|
51
|
+
app: result
|
|
52
|
+
});
|
|
53
|
+
logger.info(`⚡ Loaded function route: ${name}`);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const exportType = typeof exported;
|
|
58
|
+
const keys = exported && typeof exported === "object" ? Object.getOwnPropertyNames(Object.getPrototypeOf(exported)).slice(0, 10).join(", ") : "N/A";
|
|
59
|
+
logger.warn(`[functions] ${file}: default export is not a Hono app or factory. Skipping.\n export type: ${exportType}${exported?.constructor?.name ? ` (${exported.constructor.name})` : ""}\n prototype methods: ${keys}\n Hint: ensure the function exports a Hono app created with the same hono version as the server.
|
|
60
|
+
Author with \`defineFunction(...)\` from @rebasepro/server for a typed, checked contract.
|
|
61
|
+
The loader checks for .fetch() and .routes — any Hono-compatible app will work.`);
|
|
62
|
+
problems.push(`${file} (not a Hono app or factory)`);
|
|
63
|
+
} catch (err) {
|
|
64
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
65
|
+
logger.error(`[functions] Failed to load ${file}: ${message}`);
|
|
66
|
+
problems.push(`${file} (threw: ${message})`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (problems.length > 0) logger.warn(`[functions] ${problems.length} function file(s) were skipped and will NOT be served:\n` + problems.map((p) => ` - ${p}`).join("\n") + "\n Fix these or author them with `defineFunction(...)` for a typed, compile-checked contract.");
|
|
70
|
+
return functions;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Duck-type check for Hono apps.
|
|
74
|
+
* We avoid `instanceof Hono` because different Hono versions
|
|
75
|
+
* installed in the user's project vs. our dependencies will
|
|
76
|
+
* not share the same prototype, causing false negatives.
|
|
77
|
+
*/
|
|
78
|
+
function isHonoLike(obj) {
|
|
79
|
+
if (!obj || typeof obj !== "object") return false;
|
|
80
|
+
const record = obj;
|
|
81
|
+
return typeof record.fetch === "function" && Array.isArray(record.routes);
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { loadFunctionsFromDirectory as n, function_loader_exports as t };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=function-loader-B_1fYfUY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-loader-B_1fYfUY.js","names":[],"sources":["../src/functions/function-loader.ts"],"sourcesContent":["import * as fs from \"fs\";\nimport * as path from \"path\";\nimport { pathToFileURL } from \"url\";\nimport { Hono } from \"hono\";\nimport { logger } from \"../utils/logger.js\";\nimport { nativeDynamicImport, type ModuleImporter } from \"../utils/dynamic-import.js\";\n\nexport interface LoadedFunction {\n /** Endpoint name derived from filename (e.g., \"send-invoice\") */\n name: string;\n /** The Hono sub-app to mount */\n app: Hono<import(\"hono\").Env>;\n}\n\n/**\n * Auto-discover Hono route files from a directory.\n *\n * Each file should default-export a Hono app (or router).\n * The filename (without extension) becomes the mount path:\n * `functions/send-invoice.ts` → mounted at `/send-invoice`\n *\n * This mirrors how `loadCollectionsFromDirectory` works for collections.\n */\nexport async function loadFunctionsFromDirectory(\n directory: string,\n importModule: ModuleImporter = nativeDynamicImport\n): Promise<LoadedFunction[]> {\n const functions: LoadedFunction[] = [];\n // Aggregate problem files so a broken function surfaces as one loud\n // summary line, not just a warning buried per-file. We still don't throw:\n // a single malformed function must not crash server boot.\n const problems: string[] = [];\n\n if (!fs.existsSync(directory)) {\n return functions;\n }\n\n const files = fs.readdirSync(directory);\n for (const file of files) {\n if (\n (file.endsWith(\".ts\") || file.endsWith(\".js\")) &&\n // Dotfiles: notably macOS bsdtar AppleDouble sidecars (`._foo.ts`),\n // binary blobs that cannot be imported.\n !file.startsWith(\".\") &&\n !file.includes(\".test.\") &&\n !file.endsWith(\".d.ts\") &&\n file !== \"index.ts\" &&\n file !== \"index.js\"\n ) {\n const filePath = path.join(directory, file);\n try {\n const fileUrl = pathToFileURL(filePath).href;\n\n const mod = await importModule(fileUrl);\n\n const exported = mod.default;\n\n if (!exported) {\n logger.warn(`[functions] ${file}: no default export. Skipping.`);\n problems.push(`${file} (no default export)`);\n continue;\n }\n\n // Accept a Hono instance — use duck-typing to handle different\n // Hono versions which may not share the same prototype.\n if (isHonoLike(exported)) {\n const name = path.basename(file, path.extname(file));\n functions.push({ name,\napp: exported as Hono });\n logger.info(`⚡ Loaded function route: ${name}`);\n continue;\n }\n\n // Also accept a factory function that returns a Hono instance\n if (typeof exported === \"function\") {\n const result = exported();\n if (isHonoLike(result)) {\n const name = path.basename(file, path.extname(file));\n functions.push({ name,\napp: result as Hono });\n logger.info(`⚡ Loaded function route: ${name}`);\n continue;\n }\n }\n\n // Provide actionable diagnostics\n const exportType = typeof exported;\n const keys = exported && typeof exported === \"object\"\n ? Object.getOwnPropertyNames(Object.getPrototypeOf(exported)).slice(0, 10).join(\", \")\n : \"N/A\";\n logger.warn(\n `[functions] ${file}: default export is not a Hono app or factory. Skipping.\\n` +\n ` export type: ${exportType}${exported?.constructor?.name ? ` (${exported.constructor.name})` : \"\"}\\n` +\n ` prototype methods: ${keys}\\n` +\n \" Hint: ensure the function exports a Hono app created with the same hono version as the server.\\n\" +\n \" Author with `defineFunction(...)` from @rebasepro/server for a typed, checked contract.\\n\" +\n \" The loader checks for .fetch() and .routes — any Hono-compatible app will work.\"\n );\n problems.push(`${file} (not a Hono app or factory)`);\n } catch (err: unknown) {\n const message =\n err instanceof Error ? err.message : String(err);\n logger.error(`[functions] Failed to load ${file}: ${message}`);\n problems.push(`${file} (threw: ${message})`);\n }\n }\n }\n\n if (problems.length > 0) {\n logger.warn(\n `[functions] ${problems.length} function file(s) were skipped and will NOT be served:\\n` +\n problems.map((p) => ` - ${p}`).join(\"\\n\") + \"\\n\" +\n \" Fix these or author them with `defineFunction(...)` for a typed, compile-checked contract.\"\n );\n }\n\n return functions;\n}\n\n/**\n * Duck-type check for Hono apps.\n * We avoid `instanceof Hono` because different Hono versions\n * installed in the user's project vs. our dependencies will\n * not share the same prototype, causing false negatives.\n */\nfunction isHonoLike(obj: unknown): boolean {\n if (!obj || typeof obj !== \"object\") return false;\n // Hono instances always have .fetch() and .routes\n const record = obj as Record<string, unknown>;\n return (\n typeof record.fetch === \"function\" &&\n Array.isArray(record.routes)\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,eAAsB,2BAClB,WACA,eAA+B,qBACN;CACzB,MAAM,YAA8B,CAAC;CAIrC,MAAM,WAAqB,CAAC;CAE5B,IAAI,CAAC,KAAG,WAAW,SAAS,GACxB,OAAO;CAGX,MAAM,QAAQ,KAAG,YAAY,SAAS;CACtC,KAAK,MAAM,QAAQ,OACf,KACK,KAAK,SAAS,KAAK,KAAK,KAAK,SAAS,KAAK,MAG5C,CAAC,KAAK,WAAW,GAAG,KACpB,CAAC,KAAK,SAAS,QAAQ,KACvB,CAAC,KAAK,SAAS,OAAO,KACtB,SAAS,cACT,SAAS,YACX;EACE,MAAM,WAAW,OAAK,KAAK,WAAW,IAAI;EAC1C,IAAI;GACA,MAAM,UAAU,cAAc,QAAQ,CAAC,CAAC;GAIxC,MAAM,YAAW,MAFC,aAAa,OAAO,EAAA,CAEjB;GAErB,IAAI,CAAC,UAAU;IACX,OAAO,KAAK,eAAe,KAAK,+BAA+B;IAC/D,SAAS,KAAK,GAAG,KAAK,qBAAqB;IAC3C;GACJ;GAIA,IAAI,WAAW,QAAQ,GAAG;IACtB,MAAM,OAAO,OAAK,SAAS,MAAM,OAAK,QAAQ,IAAI,CAAC;IACnD,UAAU,KAAK;KAAE;KACrC,KAAK;IAAiB,CAAC;IACH,OAAO,KAAK,4BAA4B,MAAM;IAC9C;GACJ;GAGA,IAAI,OAAO,aAAa,YAAY;IAChC,MAAM,SAAS,SAAS;IACxB,IAAI,WAAW,MAAM,GAAG;KACpB,MAAM,OAAO,OAAK,SAAS,MAAM,OAAK,QAAQ,IAAI,CAAC;KACnD,UAAU,KAAK;MAAE;MACzC,KAAK;KAAe,CAAC;KACG,OAAO,KAAK,4BAA4B,MAAM;KAC9C;IACJ;GACJ;GAGA,MAAM,aAAa,OAAO;GAC1B,MAAM,OAAO,YAAY,OAAO,aAAa,WACvC,OAAO,oBAAoB,OAAO,eAAe,QAAQ,CAAC,CAAC,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,IAAI,IAClF;GACN,OAAO,KACH,eAAe,KAAK,2EACF,aAAa,UAAU,aAAa,OAAO,KAAK,SAAS,YAAY,KAAK,KAAK,GAAG,yBAC5E,KAAK;;kFAIjC;GACA,SAAS,KAAK,GAAG,KAAK,6BAA6B;EACvD,SAAS,KAAc;GACnB,MAAM,UACF,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;GACnD,OAAO,MAAM,8BAA8B,KAAK,IAAI,SAAS;GAC7D,SAAS,KAAK,GAAG,KAAK,WAAW,QAAQ,EAAE;EAC/C;CACJ;CAGJ,IAAI,SAAS,SAAS,GAClB,OAAO,KACH,eAAe,SAAS,OAAO,4DAC/B,SAAS,KAAK,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,IAAI,IAAI,gGAEjD;CAGJ,OAAO;AACX;;;;;;;AAQA,SAAS,WAAW,KAAuB;CACvC,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,OAAO;CAE5C,MAAM,SAAS;CACf,OACI,OAAO,OAAO,UAAU,cACxB,MAAM,QAAQ,OAAO,MAAM;AAEnC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "module";
|
|
2
|
+
import "process";
|
|
3
|
+
__createRequire(import.meta.url);
|
|
4
|
+
import { n as __exportAll } from "./rolldown-runtime-DSJWtz9O.js";
|
|
5
|
+
import { Hono } from "hono";
|
|
6
|
+
//#region src/functions/function-routes.ts
|
|
7
|
+
var function_routes_exports = /* @__PURE__ */ __exportAll({ createFunctionRoutes: () => createFunctionRoutes });
|
|
8
|
+
/**
|
|
9
|
+
* Mount all loaded function routes under a single Hono router.
|
|
10
|
+
*
|
|
11
|
+
* Each function is mounted at `/<function-name>`, preserving
|
|
12
|
+
* whatever HTTP methods and middleware the Hono sub-app defines.
|
|
13
|
+
*/
|
|
14
|
+
function createFunctionRoutes(functions) {
|
|
15
|
+
const router = new Hono();
|
|
16
|
+
router.get("/", (c) => {
|
|
17
|
+
return c.json({ functions: functions.map((fn) => ({
|
|
18
|
+
name: fn.name,
|
|
19
|
+
endpoint: `/functions/${fn.name}`
|
|
20
|
+
})) });
|
|
21
|
+
});
|
|
22
|
+
for (const fn of functions) router.route(`/${fn.name}`, fn.app);
|
|
23
|
+
return router;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { function_routes_exports as n, createFunctionRoutes as t };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=function-routes-C0cLIy3N.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-routes-C0cLIy3N.js","names":[],"sources":["../src/functions/function-routes.ts"],"sourcesContent":["import { Hono } from \"hono\";\nimport { HonoEnv } from \"../api/types\";\nimport { LoadedFunction } from \"./function-loader\";\n\n/**\n * Mount all loaded function routes under a single Hono router.\n *\n * Each function is mounted at `/<function-name>`, preserving\n * whatever HTTP methods and middleware the Hono sub-app defines.\n */\nexport function createFunctionRoutes(\n functions: LoadedFunction[]\n): Hono<HonoEnv> {\n const router = new Hono<HonoEnv>();\n\n // Listing endpoint: GET / → list available functions\n router.get(\"/\", (c) => {\n return c.json({\n functions: functions.map((fn) => ({\n name: fn.name,\n endpoint: `/functions/${fn.name}`\n }))\n });\n });\n\n for (const fn of functions) {\n router.route(`/${fn.name}`, fn.app);\n }\n\n return router;\n}\n"],"mappings":";;;;;;;;;;;;;AAUA,SAAgB,qBACZ,WACa;CACb,MAAM,SAAS,IAAI,KAAc;CAGjC,OAAO,IAAI,MAAM,MAAM;EACnB,OAAO,EAAE,KAAK,EACV,WAAW,UAAU,KAAK,QAAQ;GAC9B,MAAM,GAAG;GACT,UAAU,cAAc,GAAG;EAC/B,EAAE,EACN,CAAC;CACL,CAAC;CAED,KAAK,MAAM,MAAM,WACb,OAAO,MAAM,IAAI,GAAG,QAAQ,GAAG,GAAG;CAGtC,OAAO;AACX"}
|