@bella-baxter/next 0.1.1-preview.11

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.
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @bella-baxter/next
3
+ *
4
+ * Next.js integration — load secrets once in instrumentation.ts and
5
+ * access them anywhere in server components / API routes.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // instrumentation.ts (Next.js 14+ / App Router)
10
+ * import { initBella } from '@bella-baxter/next';
11
+ *
12
+ * export async function register() {
13
+ * await initBella({
14
+ * baxterUrl: process.env.BELLA_BAXTER_URL!,
15
+ * apiKey: process.env.BELLA_BAXTER_API_KEY!,
16
+ * });
17
+ * }
18
+ *
19
+ * // app/api/route.ts (any server component or route handler)
20
+ * import { getBella } from '@bella-baxter/next';
21
+ *
22
+ * export async function GET() {
23
+ * const bella = getBella();
24
+ * return Response.json({ db: bella.DATABASE_URL });
25
+ * }
26
+ * ```
27
+ *
28
+ * ⚠️ Only works in the Node.js runtime (not Edge runtime).
29
+ * For Edge routes, fetch secrets at deploy time:
30
+ * bella secrets get -o .env.production
31
+ * then read from process.env in your edge functions.
32
+ */
33
+ import type { BellaConfig, BellaSecrets, BellaConfigOptions } from '@bella-baxter/sdk';
34
+ /**
35
+ * Initialize Bella secrets. Call this once from `instrumentation.ts`.
36
+ * Starts the polling timer in the background.
37
+ */
38
+ export declare function initBella(options: BellaConfigOptions): Promise<BellaConfig & BellaSecrets>;
39
+ /**
40
+ * Get the initialized BellaConfig instance.
41
+ * Throws if initBella() has not been called yet.
42
+ */
43
+ export declare function getBella(): BellaConfig & BellaSecrets;
44
+ /** Direct shorthand: bella('DATABASE_URL') */
45
+ export declare function bella(key: string): string | undefined;
46
+ export type { BellaConfig, BellaSecrets, BellaConfigOptions };
47
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAWH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAkBvF;;;GAGG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC,CAWhG;AAED;;;GAGG;AACH,wBAAgB,QAAQ,IAAI,WAAW,GAAG,YAAY,CAKrD;AAED,8CAA8C;AAC9C,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAErD;AAED,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @bella-baxter/next
3
+ *
4
+ * Next.js integration — load secrets once in instrumentation.ts and
5
+ * access them anywhere in server components / API routes.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // instrumentation.ts (Next.js 14+ / App Router)
10
+ * import { initBella } from '@bella-baxter/next';
11
+ *
12
+ * export async function register() {
13
+ * await initBella({
14
+ * baxterUrl: process.env.BELLA_BAXTER_URL!,
15
+ * apiKey: process.env.BELLA_BAXTER_API_KEY!,
16
+ * });
17
+ * }
18
+ *
19
+ * // app/api/route.ts (any server component or route handler)
20
+ * import { getBella } from '@bella-baxter/next';
21
+ *
22
+ * export async function GET() {
23
+ * const bella = getBella();
24
+ * return Response.json({ db: bella.DATABASE_URL });
25
+ * }
26
+ * ```
27
+ *
28
+ * ⚠️ Only works in the Node.js runtime (not Edge runtime).
29
+ * For Edge routes, fetch secrets at deploy time:
30
+ * bella secrets get -o .env.production
31
+ * then read from process.env in your edge functions.
32
+ */
33
+ // Store singleton on `process` (NOT `globalThis`).
34
+ //
35
+ // Next.js RSC bundles run through webpack which replaces `globalThis` with its own
36
+ // polyfill object — a value set on `globalThis` in instrumentation.ts is NOT visible
37
+ // in the RSC route bundle. `process` is the real Node.js process object and is never
38
+ // polyfilled by webpack for server-side bundles, making it a reliable cross-bundle carrier.
39
+ const PROCESS_KEY = '__bella_baxter_instance__';
40
+ function getInstance() {
41
+ return process[PROCESS_KEY] ?? null;
42
+ }
43
+ function setInstance(val) {
44
+ process[PROCESS_KEY] = val;
45
+ }
46
+ /**
47
+ * Initialize Bella secrets. Call this once from `instrumentation.ts`.
48
+ * Starts the polling timer in the background.
49
+ */
50
+ export async function initBella(options) {
51
+ if (getInstance()) {
52
+ console.warn('[Bella] initBella() called more than once — reusing existing instance.');
53
+ return getInstance();
54
+ }
55
+ // Dynamic import keeps Node.js-only modules (fs, path, crypto) out of the
56
+ // edge bundler's static analysis path, preventing spurious edge-runtime warnings.
57
+ const { createBellaConfig } = await import('@bella-baxter/sdk');
58
+ const instance = await createBellaConfig(options);
59
+ setInstance(instance);
60
+ return instance;
61
+ }
62
+ /**
63
+ * Get the initialized BellaConfig instance.
64
+ * Throws if initBella() has not been called yet.
65
+ */
66
+ export function getBella() {
67
+ const instance = getInstance();
68
+ if (!instance)
69
+ throw new Error('[Bella] getBella() called before initBella(). Check instrumentation.ts.');
70
+ return instance;
71
+ }
72
+ /** Direct shorthand: bella('DATABASE_URL') */
73
+ export function bella(key) {
74
+ return getBella().get(key);
75
+ }
76
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAaH,mDAAmD;AACnD,EAAE;AACF,mFAAmF;AACnF,qFAAqF;AACrF,qFAAqF;AACrF,4FAA4F;AAC5F,MAAM,WAAW,GAAG,2BAA2B,CAAC;AAEhD,SAAS,WAAW;IAClB,OAAQ,OAA8C,CAAC,WAAW,CAAwC,IAAI,IAAI,CAAC;AACrH,CAAC;AAED,SAAS,WAAW,CAAC,GAA+B;IACjD,OAA8C,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAA2B;IACzD,IAAI,WAAW,EAAE,EAAE,CAAC;QAClB,OAAO,CAAC,IAAI,CAAC,wEAAwE,CAAC,CAAC;QACvF,OAAO,WAAW,EAAG,CAAC;IACxB,CAAC;IACD,0EAA0E;IAC1E,kFAAkF;IAClF,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAClD,WAAW,CAAC,QAAQ,CAAC,CAAC;IACtB,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ;IACtB,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,IAAI,CAAC,QAAQ;QACX,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC;IAC7F,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,KAAK,CAAC,GAAW;IAC/B,OAAO,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@bella-baxter/next",
3
+ "version": "0.1.1-preview.11",
4
+ "description": "Bella Baxter Next.js integration — load secrets in instrumentation.ts and access anywhere server-side",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "dependencies": {
18
+ "@bella-baxter/sdk": "0.1.1-preview.11"
19
+ },
20
+ "peerDependencies": {
21
+ "next": ">=14"
22
+ },
23
+ "devDependencies": {
24
+ "typescript": "^5.9.3",
25
+ "@types/node": "^25.5.0"
26
+ },
27
+ "keywords": [
28
+ "bella-baxter",
29
+ "secrets",
30
+ "nextjs",
31
+ "next"
32
+ ],
33
+ "license": "MIT",
34
+ "scripts": {
35
+ "build": "tsc",
36
+ "typecheck": "tsc --noEmit"
37
+ }
38
+ }