@neondatabase/functions 0.0.0

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/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # @neondatabase/functions
2
+
3
+ Runtime helpers for [Neon Functions](https://neon.com). Currently provides a `waitUntil` primitive for deferring background work past a response.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @neondatabase/functions
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { waitUntil } from "@neondatabase/functions/v1";
15
+
16
+ export default {
17
+ async fetch(req: Request): Promise<Response> {
18
+ const defer = waitUntil();
19
+ // Fire-and-forget background work that should outlive the response.
20
+ defer(logRequest(req));
21
+ return new Response("ok");
22
+ },
23
+ };
24
+ ```
25
+
26
+ > **Status: not implemented yet.** `waitUntil()` currently returns a no-op function — the
27
+ > promise you pass is accepted and ignored. Once the Neon Functions runtime ships, it will
28
+ > register the promise with the host so the invocation stays alive until it settles.
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@neondatabase/functions",
3
+ "version": "0.0.0",
4
+ "description": "Runtime helpers for Neon Functions. Currently provides a `waitUntil` primitive for deferring async work past a response.",
5
+ "keywords": [
6
+ "neon",
7
+ "database",
8
+ "postgres",
9
+ "functions",
10
+ "serverless",
11
+ "platform"
12
+ ],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/neondatabase/neon-pkgs.git"
16
+ },
17
+ "license": "Apache-2.0",
18
+ "author": {
19
+ "name": "Neon",
20
+ "url": "https://neon.com"
21
+ }
22
+ }
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The default entry point re-exports the latest stable version. New consumers should import
3
+ * directly from `@neondatabase/functions/v1` to opt in to a specific major.
4
+ */
5
+ export * from "./v1.js";
@@ -0,0 +1,21 @@
1
+ /**
2
+ * `waitUntil` extends the lifetime of a Neon Function invocation so background work
3
+ * (logging, cache writes, analytics, …) can finish after the response has been sent.
4
+ *
5
+ * It mirrors the platform primitive exposed by Cloudflare Workers / Vercel
6
+ * (`ctx.waitUntil(promise)`).
7
+ */
8
+ export type WaitUntil = (promise: Promise<unknown>) => void;
9
+
10
+ /**
11
+ * Returns a `waitUntil` function for the current invocation.
12
+ *
13
+ * NOT IMPLEMENTED YET: this is a no-op placeholder. The returned function accepts a
14
+ * promise and ignores it. Once the Neon Functions runtime ships, this will register the
15
+ * promise with the host so the invocation stays alive until it settles.
16
+ */
17
+ export function waitUntil(): WaitUntil {
18
+ return (_promise: Promise<unknown>): void => {
19
+ // no-op: the runtime integration is not implemented yet.
20
+ };
21
+ }
package/src/v1.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * `@neondatabase/functions/v1` — runtime helpers for Neon Functions.
3
+ *
4
+ * - `waitUntil()` — returns a function that defers async work past the response.
5
+ * Currently a no-op placeholder; the runtime integration is not implemented yet.
6
+ */
7
+
8
+ export type { WaitUntil } from "./lib/wait-until.js";
9
+ export { waitUntil } from "./lib/wait-until.js";
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "include": ["src", "vitest.config.ts", "tsdown.config.ts"]
4
+ }
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from "tsdown";
2
+
3
+ export default defineConfig({
4
+ name: "@neondatabase/functions",
5
+ bundle: false,
6
+ clean: true,
7
+ dts: true,
8
+ entry: ["src/index.ts", "src/v1.ts", "src/lib/**/*.ts", "!src/**/*.test.*"],
9
+ format: "esm",
10
+ outDir: "dist",
11
+ treeshake: true,
12
+ });
@@ -0,0 +1,17 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ clearMocks: true,
6
+ mockReset: true,
7
+ unstubEnvs: true,
8
+ coverage: {
9
+ all: true,
10
+ include: ["src"],
11
+ exclude: ["src/**/*.test.ts"],
12
+ reporter: ["html", "lcov"],
13
+ },
14
+ exclude: ["lib", "node_modules", "dist"],
15
+ setupFiles: ["console-fail-test/setup"],
16
+ },
17
+ });