@rebasepro/server 0.28.2 → 0.29.0-canary.g0e3a0e7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/{GCSStorageController-LXeAF6Ks.js → GCSStorageController-Ch3Ridyt.js} +4 -4
  2. package/dist/{GCSStorageController-LXeAF6Ks.js.map → GCSStorageController-Ch3Ridyt.js.map} +1 -1
  3. package/dist/{S3StorageController-CVKMUXo_.js → S3StorageController-CmNMg7Gu.js} +4 -4
  4. package/dist/{S3StorageController-CVKMUXo_.js.map → S3StorageController-CmNMg7Gu.js.map} +1 -1
  5. package/dist/{access-BDz4FO9D.js → access-BZjeLhf5.js} +7 -7
  6. package/dist/{access-BDz4FO9D.js.map → access-BZjeLhf5.js.map} +1 -1
  7. package/dist/api/rest/api-generator.d.ts +19 -0
  8. package/dist/{ast-schema-editor-C4bDSb61.js → ast-schema-editor-Dg7BWKE3.js} +3 -3
  9. package/dist/{ast-schema-editor-C4bDSb61.js.map → ast-schema-editor-Dg7BWKE3.js.map} +1 -1
  10. package/dist/auth/cookie-utils.d.ts +14 -6
  11. package/dist/auth/rate-limiter.d.ts +8 -0
  12. package/dist/{auth-CZGfVKcL.js → auth-CSWKaSgJ.js} +70 -18
  13. package/dist/auth-CSWKaSgJ.js.map +1 -0
  14. package/dist/{auth_adapter-B7RUMk6e.js → auth_adapter-HFv5axIT.js} +20 -2
  15. package/dist/auth_adapter-HFv5axIT.js.map +1 -0
  16. package/dist/backend/options.d.ts +3 -0
  17. package/dist/backend-CaG_Jyso.js.map +1 -1
  18. package/dist/{backup-BmzY9xdN.js → backup-woinIDjt.js} +9 -9
  19. package/dist/{backup-BmzY9xdN.js.map → backup-woinIDjt.js.map} +1 -1
  20. package/dist/boot/driver.d.ts +4 -0
  21. package/dist/boot/sources.d.ts +7 -0
  22. package/dist/{branch-routes-DpgaeTJl.js → branch-routes-F5VIJrZp.js} +3 -3
  23. package/dist/{branch-routes-DpgaeTJl.js.map → branch-routes-F5VIJrZp.js.map} +1 -1
  24. package/dist/{contract-routes-vYiBHbjI.js → contract-routes-D8Vsxjx8.js} +3 -3
  25. package/dist/{contract-routes-vYiBHbjI.js.map → contract-routes-D8Vsxjx8.js.map} +1 -1
  26. package/dist/{cron-loader-C_C-lNgG.js → cron-loader-n9Uh_E1a.js} +3 -3
  27. package/dist/{cron-loader-C_C-lNgG.js.map → cron-loader-n9Uh_E1a.js.map} +1 -1
  28. package/dist/{cron-routes-DlwOV6zl.js → cron-routes-mLexIC9F.js} +4 -4
  29. package/dist/{cron-routes-DlwOV6zl.js.map → cron-routes-mLexIC9F.js.map} +1 -1
  30. package/dist/{cron-scheduler-6ipIm5mm.js → cron-scheduler-DhxuCDuI.js} +2 -2
  31. package/dist/{cron-scheduler-6ipIm5mm.js.map → cron-scheduler-DhxuCDuI.js.map} +1 -1
  32. package/dist/{cron-store-KIOM8LCC.js → cron-store-DzKz7jXF.js} +2 -2
  33. package/dist/{cron-store-KIOM8LCC.js.map → cron-store-DzKz7jXF.js.map} +1 -1
  34. package/dist/data_driver-D0mg1Y_x.js.map +1 -1
  35. package/dist/dist-B4YtgTMh.js +19359 -0
  36. package/dist/dist-B4YtgTMh.js.map +1 -0
  37. package/dist/env.d.ts +7 -0
  38. package/dist/{errors-DIWnZIDY.js → errors-DpTMfX77.js} +58 -8
  39. package/dist/errors-DpTMfX77.js.map +1 -0
  40. package/dist/{field-access-KYk8RGOx.js → field-access-CzKjatID.js} +3 -3
  41. package/dist/{field-access-KYk8RGOx.js.map → field-access-CzKjatID.js.map} +1 -1
  42. package/dist/{filter-dialect-CE4bloug.js → filter-dialect-C5wfpopB.js} +110 -9
  43. package/dist/{filter-dialect-CE4bloug.js.map → filter-dialect-C5wfpopB.js.map} +1 -1
  44. package/dist/{function-loader-CKB9b4uP.js → function-loader-BzKo2Oiu.js} +2 -2
  45. package/dist/{function-loader-CKB9b4uP.js.map → function-loader-BzKo2Oiu.js.map} +1 -1
  46. package/dist/{function-routes-DLaXaiQA.js → function-routes-CQ0z3WDt.js} +2 -2
  47. package/dist/{function-routes-DLaXaiQA.js.map → function-routes-CQ0z3WDt.js.map} +1 -1
  48. package/dist/functions/index.d.ts +1 -0
  49. package/dist/functions/index.js +10 -29
  50. package/dist/functions/index.js.map +1 -1
  51. package/dist/functions/wait-until.d.ts +29 -1
  52. package/dist/{history-recorder-BE4HWR-M.js → history-recorder-wkBuX7Np.js} +2 -2
  53. package/dist/{history-recorder-BE4HWR-M.js.map → history-recorder-wkBuX7Np.js.map} +1 -1
  54. package/dist/index.d.ts +4 -1
  55. package/dist/index.es.js +2260 -1284
  56. package/dist/index.es.js.map +1 -1
  57. package/dist/init/surfaces.d.ts +19 -3
  58. package/dist/{jobs-CXTs9qXH.js → jobs-D61qYEGt.js} +2 -2
  59. package/dist/{jobs-CXTs9qXH.js.map → jobs-D61qYEGt.js.map} +1 -1
  60. package/dist/{jwt-5EvX3lQa.js → jwt-CBmQXYs-.js} +2 -2
  61. package/dist/{jwt-5EvX3lQa.js.map → jwt-CBmQXYs-.js.map} +1 -1
  62. package/dist/{keys-DJ1ZNcZi.js → keys-Cd_4l48g.js} +2 -2
  63. package/dist/{keys-DJ1ZNcZi.js.map → keys-Cd_4l48g.js.map} +1 -1
  64. package/dist/{logs-routes-DXLvMasE.js → logs-routes-08LiyYua.js} +2 -2
  65. package/dist/{logs-routes-DXLvMasE.js.map → logs-routes-08LiyYua.js.map} +1 -1
  66. package/dist/mcp/consent-page.d.ts +14 -1
  67. package/dist/mcp/mcp-apps.d.ts +51 -17
  68. package/dist/mcp/mcp-routes.d.ts +6 -1
  69. package/dist/mcp/mcp-tools.d.ts +44 -1
  70. package/dist/mcp/mcp-view.d.ts +107 -0
  71. package/dist/mcp/oauth-metadata.d.ts +7 -1
  72. package/dist/mcp/show-app-guide.d.ts +1 -0
  73. package/dist/metrics/database.d.ts +69 -0
  74. package/dist/metrics/db-connection-errors.d.ts +21 -0
  75. package/dist/{offline-BjJdcVBb-BOzzsnrh.js → offline-BjJdcVBb-B_bOcnDC.js} +4 -4
  76. package/dist/{offline-BjJdcVBb-BOzzsnrh.js.map → offline-BjJdcVBb-B_bOcnDC.js.map} +1 -1
  77. package/dist/{offline-store-Cxhh99Q--FB6fSf5A.js → offline-store-Cxhh99Q--DQ-M1M8d.js} +4 -4
  78. package/dist/{offline-store-Cxhh99Q--FB6fSf5A.js.map → offline-store-Cxhh99Q--DQ-M1M8d.js.map} +1 -1
  79. package/dist/{openapi-generator-B6aw_KuR.js → openapi-generator-B3LsKCon.js} +4 -4
  80. package/dist/{openapi-generator-B6aw_KuR.js.map → openapi-generator-B3LsKCon.js.map} +1 -1
  81. package/dist/{proxy-2nS5N63I.js → proxy-LUsudeht.js} +2 -2
  82. package/dist/{proxy-2nS5N63I.js.map → proxy-LUsudeht.js.map} +1 -1
  83. package/dist/{query-parser-DFVCjW5i.js → query-parser-C90z8csB.js} +6 -6
  84. package/dist/{query-parser-DFVCjW5i.js.map → query-parser-C90z8csB.js.map} +1 -1
  85. package/dist/{request-timeout-Cqm4JXtZ.js → request-timeout-DW2OBWfJ.js} +2 -2
  86. package/dist/{request-timeout-Cqm4JXtZ.js.map → request-timeout-DW2OBWfJ.js.map} +1 -1
  87. package/dist/{rls-simulator-routes-D5-XfjzW.js → rls-simulator-routes-igGu-giT.js} +4 -4
  88. package/dist/{rls-simulator-routes-D5-XfjzW.js.map → rls-simulator-routes-igGu-giT.js.map} +1 -1
  89. package/dist/{schema-editor-routes-DzSe6V0a.js → schema-editor-routes-kF1ZKCB2.js} +4 -4
  90. package/dist/{schema-editor-routes-DzSe6V0a.js.map → schema-editor-routes-kF1ZKCB2.js.map} +1 -1
  91. package/dist/serve-spa.d.ts +2 -10
  92. package/dist/{soft-delete-params-9lKBAlDw.js → soft-delete-params-DDRmxT2z.js} +2 -2
  93. package/dist/{soft-delete-params-9lKBAlDw.js.map → soft-delete-params-DDRmxT2z.js.map} +1 -1
  94. package/dist/{sql-export-routes-BxMqgAFX.js → sql-export-routes-DObpbf8x.js} +3 -3
  95. package/dist/{sql-export-routes-BxMqgAFX.js.map → sql-export-routes-DObpbf8x.js.map} +1 -1
  96. package/dist/{src-JQNz7cWv.js → src-BXDkXOtq.js} +2 -1
  97. package/dist/{src-JQNz7cWv.js.map → src-BXDkXOtq.js.map} +1 -1
  98. package/dist/{upload-validation-IYXn4xcm.js → upload-validation-B-psYLaN.js} +2 -2
  99. package/dist/{upload-validation-IYXn4xcm.js.map → upload-validation-B-psYLaN.js.map} +1 -1
  100. package/package.json +5 -5
  101. package/dist/auth-CZGfVKcL.js.map +0 -1
  102. package/dist/auth_adapter-B7RUMk6e.js.map +0 -1
  103. package/dist/dist-CT9HJehq.js +0 -22
  104. package/dist/dist-CT9HJehq.js.map +0 -1
  105. package/dist/errors-DIWnZIDY.js.map +0 -1
@@ -28,6 +28,8 @@
28
28
  * @module
29
29
  */
30
30
  import type { Context } from "hono";
31
+ /** What {@link waitUntil} keeps alive: a promise, or a function that starts one. */
32
+ export type BackgroundWork = Promise<unknown> | (() => Promise<unknown> | unknown);
31
33
  /**
32
34
  * Keep `work` alive past the response, on any runtime.
33
35
  *
@@ -55,7 +57,33 @@ import type { Context } from "hono";
55
57
  * });
56
58
  * ```
57
59
  */
58
- export declare function waitUntil(c: Context, work: Promise<unknown> | (() => Promise<unknown> | unknown)): void;
60
+ export declare function waitUntil(c: Context, work: BackgroundWork): void;
61
+ /**
62
+ * Keep `work` alive with no request to attach it to.
63
+ *
64
+ * For code that runs outside a request — a module-level initialiser, a helper
65
+ * several callers share, work a cron run starts and does not wait for. The
66
+ * promise is tracked exactly as with a context, so graceful shutdown waits for
67
+ * it and a rejection is logged rather than left floating.
68
+ *
69
+ * What it cannot do is tell an isolate host to stay alive: that is the
70
+ * request's execution context, and there is none here. Pass `c` whenever there
71
+ * is a request. Work that a cron run, a job or a queue handler can simply
72
+ * await should be awaited instead: the run is what shutdown waits for, and it
73
+ * is recorded with the run.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * let ready: Promise<void> | undefined;
78
+ * export function ensureCatalogue(): Promise<void> {
79
+ * ready ??= loadCatalogue().then(() => {
80
+ * waitUntil(rateNewSongs()); // no request here to hand it to
81
+ * });
82
+ * return ready;
83
+ * }
84
+ * ```
85
+ */
86
+ export declare function waitUntil(work: BackgroundWork): void;
59
87
  /** How many background promises are still in flight. Diagnostics and tests. */
60
88
  export declare function pendingBackgroundWork(): number;
61
89
  /**
@@ -2,7 +2,7 @@ import { createRequire as __rebaseCreateRequire } from "module";
2
2
  import __rebaseProcess from "process";
3
3
  globalThis.process ??= __rebaseProcess;
4
4
  __rebaseCreateRequire(import.meta.url);
5
- import "./src-JQNz7cWv.js";
5
+ import "./src-BXDkXOtq.js";
6
6
  import { n as isSQLAdmin } from "./backend-CaG_Jyso.js";
7
7
  import { a as logger } from "./logger-SigQ2oZJ.js";
8
8
  import { a as readSeries, i as ensureMetricsHistory, n as SAMPLE_INTERVAL_MS, o as recordSamples, r as adoptExistingMetricsHistory, s as sampleSelf } from "./history-store-D-jDz4Nv.js";
@@ -75,4 +75,4 @@ function createMetricsHistory(driver, options = {}) {
75
75
  //#endregion
76
76
  export { createMetricsHistory };
77
77
 
78
- //# sourceMappingURL=history-recorder-BE4HWR-M.js.map
78
+ //# sourceMappingURL=history-recorder-wkBuX7Np.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"history-recorder-BE4HWR-M.js","names":[],"sources":["../src/metrics/history-recorder.ts"],"sourcesContent":["/**\n * Wiring the history store to a driver and a timer.\n *\n * Split from `history-store.ts` so the store stays pure — every rule in it is\n * testable with a fake executor, and nothing there knows what a DataDriver is.\n * This half is the part that cannot be unit-tested meaningfully: it opens a\n * connection and starts an interval.\n */\nimport { monitorEventLoopDelay } from \"node:perf_hooks\";\nimport { logger } from \"../utils/logger.js\";\nimport { isSQLAdmin, type DataDriver } from \"@rebasepro/types\";\nimport {\n ensureMetricsHistory,\n adoptExistingMetricsHistory,\n recordSamples,\n readSeries,\n sampleSelf,\n SAMPLE_INTERVAL_MS,\n type Exec,\n type MetricSeries,\n type SeriesPoint\n} from \"./history-store.js\";\n\nexport interface MetricsHistory {\n /** Create the table and sweep what has aged out. */\n ensure(): Promise<void>;\n /** Begin sampling this process. Returns a stop. */\n start(): () => void;\n /** Read one series, for the route and for anything else that asks. */\n read(series: MetricSeries, sinceMinutes: number): Promise<SeriesPoint[]>;\n}\n\n/** The driver's SQL executor, when its admin can run SQL at all. */\nfunction sqlExecutorOf(driver: DataDriver): Exec | undefined {\n const admin = driver.admin;\n if (!isSQLAdmin(admin)) return undefined;\n return (sql, params) => admin.executeSql(sql, params ? { params } : undefined);\n}\n\n/**\n * History for this deployment, or `undefined` when it cannot have any.\n *\n * Undefined rather than a no-op: the route turns it into a named 501, because a\n * chart that renders empty is indistinguishable from a quiet period and this is\n * exactly the class of silence the panel it feeds exists to remove.\n */\nexport function createMetricsHistory(\n driver: DataDriver,\n options: {\n /** Default `true`. `false` uses the table if it is there and never creates it. */\n provision?: boolean;\n } = {}\n): MetricsHistory | undefined {\n const exec = sqlExecutorOf(driver);\n if (!exec) {\n logger.debug(\"[metrics] driver has no SQL admin — no metrics history will be kept.\");\n return undefined;\n }\n\n return {\n ensure: () => options.provision === false ? adoptExistingMetricsHistory(exec) : ensureMetricsHistory(exec),\n read: (series, sinceMinutes) => readSeries(exec, series, sinceMinutes),\n start(): () => void {\n // Which process this is. A tenant's replicas share one database and\n // each records its own numbers, so a row needs to say whose they\n // are — without it they overwrite each other and a scaled-out app\n // charts one arbitrary pod.\n //\n // HOSTNAME is the pod name on Kubernetes and the container id under\n // Docker; the pid fallback keeps two local processes distinct.\n const instance = process.env.HOSTNAME?.trim() || `pid-${process.pid}`;\n let cursor: { cpu: NodeJS.CpuUsage; at: number } | null = null;\n let stopped = false;\n\n // Event-loop delay: how long a callback waited past its schedule.\n // The one number here that says whether this process is *healthy*\n // rather than how much it is consuming — a pod can sit at 20% CPU\n // and still be unable to answer, and nothing else recorded would\n // show it.\n //\n // `monitorEventLoopDelay` samples in libuv at a fixed resolution and\n // costs effectively nothing; `.enable()` is required, and the\n // histogram is reset each tick so every sample describes its own\n // minute rather than the process's whole life.\n interface LoopHistogram { mean: number; enable(): void; disable(): void; reset(): void }\n let loop: LoopHistogram | null = null;\n try {\n loop = monitorEventLoopDelay({ resolution: 20 }) as LoopHistogram;\n loop.enable();\n } catch {\n // A runtime without it still records the other two.\n loop = null;\n }\n\n const tick = async () => {\n if (stopped) return;\n // Nanoseconds from the histogram, milliseconds on the wire.\n const delayMs = loop ? loop.mean / 1e6 : undefined;\n loop?.reset();\n const { samples, cursor: next } = sampleSelf(cursor, Date.now(), delayMs);\n cursor = next;\n try {\n await recordSamples(exec, samples, instance);\n } catch (err) {\n // Never fatal, and never noisy: a sampler that crash-loops a\n // pod over a chart would be a far worse trade than a gap in\n // one. The gap is visible in the data; a restart loop is not.\n logger.debug(\"[metrics] could not record a sample\", { err });\n }\n };\n\n // The first tick establishes the CPU cursor and publishes memory;\n // the rate needs a second reading, which is why nothing claims a CPU\n // figure until one interval has passed.\n void tick();\n const timer = setInterval(() => void tick(), SAMPLE_INTERVAL_MS);\n // Not the reason this process should stay alive.\n timer.unref?.();\n\n // The histogram samples in libuv until it is disabled, so the stop\n // ends both — a backend shut down in-process leaves nothing running.\n return () => {\n stopped = true;\n clearInterval(timer);\n loop?.disable();\n };\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiCA,SAAS,cAAc,QAAsC;CACzD,MAAM,QAAQ,OAAO;CACrB,IAAI,CAAC,WAAW,KAAK,GAAG,OAAO,KAAA;CAC/B,QAAQ,KAAK,WAAW,MAAM,WAAW,KAAK,SAAS,EAAE,OAAO,IAAI,KAAA,CAAS;AACjF;;;;;;;;AASA,SAAgB,qBACZ,QACA,UAGI,CAAC,GACqB;CAC1B,MAAM,OAAO,cAAc,MAAM;CACjC,IAAI,CAAC,MAAM;EACP,OAAO,MAAM,sEAAsE;EACnF;CACJ;CAEA,OAAO;EACH,cAAc,QAAQ,cAAc,QAAQ,4BAA4B,IAAI,IAAI,qBAAqB,IAAI;EACzG,OAAO,QAAQ,iBAAiB,WAAW,MAAM,QAAQ,YAAY;EACrE,QAAoB;GAQhB,MAAM,WAAW,QAAQ,IAAI,UAAU,KAAK,KAAK,OAAO,QAAQ;GAChE,IAAI,SAAsD;GAC1D,IAAI,UAAU;GAad,IAAI,OAA6B;GACjC,IAAI;IACA,OAAO,sBAAsB,EAAE,YAAY,GAAG,CAAC;IAC/C,KAAK,OAAO;GAChB,QAAQ;IAEJ,OAAO;GACX;GAEA,MAAM,OAAO,YAAY;IACrB,IAAI,SAAS;IAEb,MAAM,UAAU,OAAO,KAAK,OAAO,MAAM,KAAA;IACzC,MAAM,MAAM;IACZ,MAAM,EAAE,SAAS,QAAQ,SAAS,WAAW,QAAQ,KAAK,IAAI,GAAG,OAAO;IACxE,SAAS;IACT,IAAI;KACA,MAAM,cAAc,MAAM,SAAS,QAAQ;IAC/C,SAAS,KAAK;KAIV,OAAO,MAAM,uCAAuC,EAAE,IAAI,CAAC;IAC/D;GACJ;GAKA,KAAU;GACV,MAAM,QAAQ,kBAAkB,KAAK,KAAK,GAAG,kBAAkB;GAE/D,MAAM,QAAQ;GAId,aAAa;IACT,UAAU;IACV,cAAc,KAAK;IACnB,MAAM,QAAQ;GAClB;EACJ;CACJ;AACJ"}
1
+ {"version":3,"file":"history-recorder-wkBuX7Np.js","names":[],"sources":["../src/metrics/history-recorder.ts"],"sourcesContent":["/**\n * Wiring the history store to a driver and a timer.\n *\n * Split from `history-store.ts` so the store stays pure — every rule in it is\n * testable with a fake executor, and nothing there knows what a DataDriver is.\n * This half is the part that cannot be unit-tested meaningfully: it opens a\n * connection and starts an interval.\n */\nimport { monitorEventLoopDelay } from \"node:perf_hooks\";\nimport { logger } from \"../utils/logger.js\";\nimport { isSQLAdmin, type DataDriver } from \"@rebasepro/types\";\nimport {\n ensureMetricsHistory,\n adoptExistingMetricsHistory,\n recordSamples,\n readSeries,\n sampleSelf,\n SAMPLE_INTERVAL_MS,\n type Exec,\n type MetricSeries,\n type SeriesPoint\n} from \"./history-store.js\";\n\nexport interface MetricsHistory {\n /** Create the table and sweep what has aged out. */\n ensure(): Promise<void>;\n /** Begin sampling this process. Returns a stop. */\n start(): () => void;\n /** Read one series, for the route and for anything else that asks. */\n read(series: MetricSeries, sinceMinutes: number): Promise<SeriesPoint[]>;\n}\n\n/** The driver's SQL executor, when its admin can run SQL at all. */\nfunction sqlExecutorOf(driver: DataDriver): Exec | undefined {\n const admin = driver.admin;\n if (!isSQLAdmin(admin)) return undefined;\n return (sql, params) => admin.executeSql(sql, params ? { params } : undefined);\n}\n\n/**\n * History for this deployment, or `undefined` when it cannot have any.\n *\n * Undefined rather than a no-op: the route turns it into a named 501, because a\n * chart that renders empty is indistinguishable from a quiet period and this is\n * exactly the class of silence the panel it feeds exists to remove.\n */\nexport function createMetricsHistory(\n driver: DataDriver,\n options: {\n /** Default `true`. `false` uses the table if it is there and never creates it. */\n provision?: boolean;\n } = {}\n): MetricsHistory | undefined {\n const exec = sqlExecutorOf(driver);\n if (!exec) {\n logger.debug(\"[metrics] driver has no SQL admin — no metrics history will be kept.\");\n return undefined;\n }\n\n return {\n ensure: () => options.provision === false ? adoptExistingMetricsHistory(exec) : ensureMetricsHistory(exec),\n read: (series, sinceMinutes) => readSeries(exec, series, sinceMinutes),\n start(): () => void {\n // Which process this is. A tenant's replicas share one database and\n // each records its own numbers, so a row needs to say whose they\n // are — without it they overwrite each other and a scaled-out app\n // charts one arbitrary pod.\n //\n // HOSTNAME is the pod name on Kubernetes and the container id under\n // Docker; the pid fallback keeps two local processes distinct.\n const instance = process.env.HOSTNAME?.trim() || `pid-${process.pid}`;\n let cursor: { cpu: NodeJS.CpuUsage; at: number } | null = null;\n let stopped = false;\n\n // Event-loop delay: how long a callback waited past its schedule.\n // The one number here that says whether this process is *healthy*\n // rather than how much it is consuming — a pod can sit at 20% CPU\n // and still be unable to answer, and nothing else recorded would\n // show it.\n //\n // `monitorEventLoopDelay` samples in libuv at a fixed resolution and\n // costs effectively nothing; `.enable()` is required, and the\n // histogram is reset each tick so every sample describes its own\n // minute rather than the process's whole life.\n interface LoopHistogram { mean: number; enable(): void; disable(): void; reset(): void }\n let loop: LoopHistogram | null = null;\n try {\n loop = monitorEventLoopDelay({ resolution: 20 }) as LoopHistogram;\n loop.enable();\n } catch {\n // A runtime without it still records the other two.\n loop = null;\n }\n\n const tick = async () => {\n if (stopped) return;\n // Nanoseconds from the histogram, milliseconds on the wire.\n const delayMs = loop ? loop.mean / 1e6 : undefined;\n loop?.reset();\n const { samples, cursor: next } = sampleSelf(cursor, Date.now(), delayMs);\n cursor = next;\n try {\n await recordSamples(exec, samples, instance);\n } catch (err) {\n // Never fatal, and never noisy: a sampler that crash-loops a\n // pod over a chart would be a far worse trade than a gap in\n // one. The gap is visible in the data; a restart loop is not.\n logger.debug(\"[metrics] could not record a sample\", { err });\n }\n };\n\n // The first tick establishes the CPU cursor and publishes memory;\n // the rate needs a second reading, which is why nothing claims a CPU\n // figure until one interval has passed.\n void tick();\n const timer = setInterval(() => void tick(), SAMPLE_INTERVAL_MS);\n // Not the reason this process should stay alive.\n timer.unref?.();\n\n // The histogram samples in libuv until it is disabled, so the stop\n // ends both — a backend shut down in-process leaves nothing running.\n return () => {\n stopped = true;\n clearInterval(timer);\n loop?.disable();\n };\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiCA,SAAS,cAAc,QAAsC;CACzD,MAAM,QAAQ,OAAO;CACrB,IAAI,CAAC,WAAW,KAAK,GAAG,OAAO,KAAA;CAC/B,QAAQ,KAAK,WAAW,MAAM,WAAW,KAAK,SAAS,EAAE,OAAO,IAAI,KAAA,CAAS;AACjF;;;;;;;;AASA,SAAgB,qBACZ,QACA,UAGI,CAAC,GACqB;CAC1B,MAAM,OAAO,cAAc,MAAM;CACjC,IAAI,CAAC,MAAM;EACP,OAAO,MAAM,sEAAsE;EACnF;CACJ;CAEA,OAAO;EACH,cAAc,QAAQ,cAAc,QAAQ,4BAA4B,IAAI,IAAI,qBAAqB,IAAI;EACzG,OAAO,QAAQ,iBAAiB,WAAW,MAAM,QAAQ,YAAY;EACrE,QAAoB;GAQhB,MAAM,WAAW,QAAQ,IAAI,UAAU,KAAK,KAAK,OAAO,QAAQ;GAChE,IAAI,SAAsD;GAC1D,IAAI,UAAU;GAad,IAAI,OAA6B;GACjC,IAAI;IACA,OAAO,sBAAsB,EAAE,YAAY,GAAG,CAAC;IAC/C,KAAK,OAAO;GAChB,QAAQ;IAEJ,OAAO;GACX;GAEA,MAAM,OAAO,YAAY;IACrB,IAAI,SAAS;IAEb,MAAM,UAAU,OAAO,KAAK,OAAO,MAAM,KAAA;IACzC,MAAM,MAAM;IACZ,MAAM,EAAE,SAAS,QAAQ,SAAS,WAAW,QAAQ,KAAK,IAAI,GAAG,OAAO;IACxE,SAAS;IACT,IAAI;KACA,MAAM,cAAc,MAAM,SAAS,QAAQ;IAC/C,SAAS,KAAK;KAIV,OAAO,MAAM,uCAAuC,EAAE,IAAI,CAAC;IAC/D;GACJ;GAKA,KAAU;GACV,MAAM,QAAQ,kBAAkB,KAAK,KAAK,GAAG,kBAAkB;GAE/D,MAAM,QAAQ;GAId,aAAa;IACT,UAAU;IACV,cAAc,KAAK;IACnB,MAAM,QAAQ;GAClB;EACJ;CACJ;AACJ"}
package/dist/index.d.ts CHANGED
@@ -37,6 +37,9 @@ export type { VerifiedCredential } from "./auth/verify-credential.js";
37
37
  export type { ApiKeyIdentity, ApiKeyRefusal } from "./auth/api-keys/index.js";
38
38
  export { McpToolError } from "./mcp/mcp-tools.js";
39
39
  export type { McpToolDefinition, McpToolContext, McpCaller, McpToolAnnotations } from "./mcp/mcp-tools.js";
40
+ export { MCP_APP_URI, MCP_VIEW_TOOLS, mcpViewToolInputSchema, SHOW_APP_CODE_GUIDE } from "./mcp/mcp-tools.js";
41
+ export type { McpViewToolName } from "./mcp/mcp-tools.js";
42
+ export { versionedMcpAppUri, mcpAppBaseUri } from "./mcp/mcp-apps.js";
40
43
  export { DATA_SCOPE_VOCABULARY } from "./mcp/oauth-metadata.js";
41
44
  export type { McpScopeVocabulary } from "./mcp/oauth-metadata.js";
42
45
  export * from "./api/types.js";
@@ -63,7 +66,7 @@ export type { FunctionApp, FunctionsRecord, LoadDirectoryOptions, LoadedFunction
63
66
  export { defineFunction } from "./functions/index.js";
64
67
  export type { RebaseFunctionContext } from "./functions/index.js";
65
68
  export { getUser, getUserId, getRoles, hasRole, isAdmin, isAuthenticated, getDriver, requireDriver, getApiKey, getRequestId, identityResolved, requireRole, getEnv, requireEnv, runtimeKey, isNodeRuntime, lazyResource, waitUntil } from "./functions/index.js";
66
- export type { FunctionUser } from "./functions/index.js";
69
+ export type { FunctionUser, BackgroundWork } from "./functions/index.js";
67
70
  export { drainBackgroundWork, pendingBackgroundWork } from "./functions/wait-until.js";
68
71
  export { loadCrons, declareCrons, loadCronJobsFromDirectory, loadCronJobsWithDiagnostics, CronScheduler, validateCronExpression, createCronRoutes, createCronStore, defineCron } from "./cron/index.js";
69
72
  export type { CronsRecord, LoadedCronJob, CronStore, CronJobPersistedState, CronRunLease, CronJobRunSummary, CronLogSweep } from "./cron/index.js";