@bella-baxter/nestjs 0.1.1-preview.100

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,76 @@
1
+ # @bella-baxter/nestjs
2
+
3
+ [![npm](https://img.shields.io/npm/v/@bella-baxter/nestjs)](https://www.npmjs.com/package/@bella-baxter/nestjs)
4
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
+
6
+ [Bella Baxter](https://github.com/Cosmic-Chimps/bella-baxter) module for NestJS — registers `BellaConfigService` as a globally injectable service backed by live-reloading secrets.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @bella-baxter/nestjs @nestjs/common @nestjs/core
12
+ # or
13
+ pnpm add @bella-baxter/nestjs @nestjs/common @nestjs/core
14
+ ```
15
+
16
+ ## Setup
17
+
18
+ ```ts
19
+ // app.module.ts
20
+ import { Module } from '@nestjs/common';
21
+ import { BellaModule } from '@bella-baxter/nestjs';
22
+
23
+ @Module({
24
+ imports: [
25
+ BellaModule.register({
26
+ baxterUrl: process.env.BELLA_BAXTER_URL!,
27
+ apiKey: process.env.BELLA_BAXTER_API_KEY!,
28
+ projectSlug: 'my-app', // or BELLA_BAXTER_PROJECT env var
29
+ environmentSlug: 'production', // or BELLA_BAXTER_ENV env var
30
+ }),
31
+ ],
32
+ })
33
+ export class AppModule {}
34
+ ```
35
+
36
+ ## Inject secrets
37
+
38
+ ```ts
39
+ // your.service.ts
40
+ import { Injectable } from '@nestjs/common';
41
+ import { BellaConfigService } from '@bella-baxter/nestjs';
42
+
43
+ @Injectable()
44
+ export class YourService {
45
+ constructor(private readonly bella: BellaConfigService) {}
46
+
47
+ getDbUrl(): string {
48
+ return this.bella.getOrThrow('DATABASE_URL');
49
+ }
50
+ }
51
+ ```
52
+
53
+ ## Typed secrets
54
+
55
+ Run `bella secrets generate typescript --declaration` to generate `bella-secrets.d.ts`. The `BellaConfigService` proxy picks up the augmented `BellaSecrets` interface automatically:
56
+
57
+ ```ts
58
+ this.bella.DATABASE_URL // string — typed!
59
+ this.bella.PORT // number — after adding coercions
60
+ ```
61
+
62
+ ## Environment variables
63
+
64
+ | Variable | Description |
65
+ |----------|-------------|
66
+ | `BELLA_BAXTER_URL` | Base URL of the Bella Baxter API |
67
+ | `BELLA_BAXTER_API_KEY` | API key (`bax-...`) |
68
+ | `BELLA_BAXTER_PROJECT` | Project slug |
69
+ | `BELLA_BAXTER_ENV` | Environment slug |
70
+ | `BELLA_BAXTER_PRIVATE_KEY` | Private key for ZKE (optional) |
71
+
72
+ ## Links
73
+
74
+ - [GitHub](https://github.com/Cosmic-Chimps/bella-baxter)
75
+ - [Issues](https://github.com/Cosmic-Chimps/bella-baxter/issues)
76
+ - [Core SDK](https://www.npmjs.com/package/@bella-baxter/sdk)
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @bella-baxter/nestjs
3
+ *
4
+ * NestJS DI module — provides BellaConfig as an injectable service.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * // app.module.ts
9
+ * import { BellaModule } from '@bella-baxter/nestjs';
10
+ *
11
+ * @Module({
12
+ * imports: [
13
+ * BellaModule.register({
14
+ * baxterUrl: process.env.BELLA_BAXTER_URL!,
15
+ * apiKey: process.env.BELLA_BAXTER_API_KEY!,
16
+ *
17
+ * }),
18
+ * ],
19
+ * })
20
+ * export class AppModule {}
21
+ *
22
+ * // your.service.ts
23
+ * import { BellaConfigService } from '@bella-baxter/nestjs';
24
+ *
25
+ * @Injectable()
26
+ * export class YourService {
27
+ * constructor(private readonly bella: BellaConfigService) {}
28
+ *
29
+ * getDbUrl(): string {
30
+ * return this.bella.getOrThrow('DATABASE_URL');
31
+ * }
32
+ * }
33
+ * ```
34
+ */
35
+ import { type DynamicModule, type OnModuleDestroy } from '@nestjs/common';
36
+ import { BellaConfig, BellaSecrets, type BellaConfigOptions } from '@bella-baxter/sdk';
37
+ export declare const BELLA_CONFIG: unique symbol;
38
+ /**
39
+ * Injectable wrapper — thin proxy over BellaConfig with NestJS lifecycle hooks.
40
+ *
41
+ * After running `bella secrets generate typescript --declaration`, the generated
42
+ * `bella-secrets.d.ts` augments `BellaSecrets`, giving this service typed property access:
43
+ * ```ts
44
+ * this.bella.DATABASE_URL // string — typed!
45
+ * ```
46
+ */
47
+ export declare class BellaConfigService implements OnModuleDestroy {
48
+ private readonly _inner;
49
+ constructor(config: BellaConfig);
50
+ get(key: string): string | undefined;
51
+ getOrThrow(key: string): string;
52
+ getAll(): Record<string, string>;
53
+ onModuleDestroy(): void;
54
+ }
55
+ export interface BellaConfigService extends BellaSecrets {
56
+ }
57
+ export declare class BellaModule {
58
+ /**
59
+ * Register BellaModule synchronously with inline options.
60
+ * Bella secrets are loaded during module initialisation (onModuleInit).
61
+ */
62
+ static register(options: BellaConfigOptions): DynamicModule;
63
+ }
64
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAsB,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,YAAY,EAAqB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE1G,eAAO,MAAM,YAAY,eAAyB,CAAC;AAEnD;;;;;;;;GAQG;AACH,qBACa,kBAAmB,YAAW,eAAe;IACxD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,MAAM,EAAE,WAAW;IAc/B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIpC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAI/B,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIhC,eAAe,IAAI,IAAI;CAGxB;AAKD,MAAM,WAAW,kBAAmB,SAAQ,YAAY;CAAG;AAE3D,qBACa,WAAW;IACtB;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,aAAa;CAkB5D"}
package/dist/index.js ADDED
@@ -0,0 +1,168 @@
1
+ /**
2
+ * @bella-baxter/nestjs
3
+ *
4
+ * NestJS DI module — provides BellaConfig as an injectable service.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * // app.module.ts
9
+ * import { BellaModule } from '@bella-baxter/nestjs';
10
+ *
11
+ * @Module({
12
+ * imports: [
13
+ * BellaModule.register({
14
+ * baxterUrl: process.env.BELLA_BAXTER_URL!,
15
+ * apiKey: process.env.BELLA_BAXTER_API_KEY!,
16
+ *
17
+ * }),
18
+ * ],
19
+ * })
20
+ * export class AppModule {}
21
+ *
22
+ * // your.service.ts
23
+ * import { BellaConfigService } from '@bella-baxter/nestjs';
24
+ *
25
+ * @Injectable()
26
+ * export class YourService {
27
+ * constructor(private readonly bella: BellaConfigService) {}
28
+ *
29
+ * getDbUrl(): string {
30
+ * return this.bella.getOrThrow('DATABASE_URL');
31
+ * }
32
+ * }
33
+ * ```
34
+ */
35
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
36
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
37
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
38
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
39
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
40
+ var _, done = false;
41
+ for (var i = decorators.length - 1; i >= 0; i--) {
42
+ var context = {};
43
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
44
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
45
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
46
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
47
+ if (kind === "accessor") {
48
+ if (result === void 0) continue;
49
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
50
+ if (_ = accept(result.get)) descriptor.get = _;
51
+ if (_ = accept(result.set)) descriptor.set = _;
52
+ if (_ = accept(result.init)) initializers.unshift(_);
53
+ }
54
+ else if (_ = accept(result)) {
55
+ if (kind === "field") initializers.unshift(_);
56
+ else descriptor[key] = _;
57
+ }
58
+ }
59
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
60
+ done = true;
61
+ };
62
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
63
+ var useValue = arguments.length > 2;
64
+ for (var i = 0; i < initializers.length; i++) {
65
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
66
+ }
67
+ return useValue ? value : void 0;
68
+ };
69
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
70
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
71
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
72
+ };
73
+ import { Module, Injectable } from '@nestjs/common';
74
+ import { createBellaConfig } from '@bella-baxter/sdk';
75
+ export const BELLA_CONFIG = Symbol('BELLA_CONFIG');
76
+ /**
77
+ * Injectable wrapper — thin proxy over BellaConfig with NestJS lifecycle hooks.
78
+ *
79
+ * After running `bella secrets generate typescript --declaration`, the generated
80
+ * `bella-secrets.d.ts` augments `BellaSecrets`, giving this service typed property access:
81
+ * ```ts
82
+ * this.bella.DATABASE_URL // string — typed!
83
+ * ```
84
+ */
85
+ let BellaConfigService = (() => {
86
+ let _classDecorators = [Injectable()];
87
+ let _classDescriptor;
88
+ let _classExtraInitializers = [];
89
+ let _classThis;
90
+ var BellaConfigService = _classThis = class {
91
+ constructor(config) {
92
+ this._inner = config;
93
+ // Intercept property access so typed secret keys (e.g. this.bella.DATABASE_URL)
94
+ // delegate to config.get() at runtime.
95
+ return new Proxy(this, {
96
+ get(target, key) {
97
+ if (typeof key === 'symbol' || key in BellaConfigService.prototype || key in target) {
98
+ return Reflect.get(target, key);
99
+ }
100
+ return target._inner.get(key);
101
+ },
102
+ });
103
+ }
104
+ get(key) {
105
+ return this._inner.get(key);
106
+ }
107
+ getOrThrow(key) {
108
+ return this._inner.getOrThrow(key);
109
+ }
110
+ getAll() {
111
+ return this._inner.getAll();
112
+ }
113
+ onModuleDestroy() {
114
+ this._inner.destroy();
115
+ }
116
+ };
117
+ __setFunctionName(_classThis, "BellaConfigService");
118
+ (() => {
119
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
120
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
121
+ BellaConfigService = _classThis = _classDescriptor.value;
122
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
123
+ __runInitializers(_classThis, _classExtraInitializers);
124
+ })();
125
+ return BellaConfigService = _classThis;
126
+ })();
127
+ export { BellaConfigService };
128
+ let BellaModule = (() => {
129
+ let _classDecorators = [Module({})];
130
+ let _classDescriptor;
131
+ let _classExtraInitializers = [];
132
+ let _classThis;
133
+ var BellaModule = _classThis = class {
134
+ /**
135
+ * Register BellaModule synchronously with inline options.
136
+ * Bella secrets are loaded during module initialisation (onModuleInit).
137
+ */
138
+ static register(options) {
139
+ return {
140
+ module: BellaModule,
141
+ global: true, // available across all modules without re-importing
142
+ providers: [
143
+ {
144
+ provide: BELLA_CONFIG,
145
+ useFactory: () => createBellaConfig(options),
146
+ },
147
+ {
148
+ provide: BellaConfigService,
149
+ useFactory: (config) => new BellaConfigService(config),
150
+ inject: [BELLA_CONFIG],
151
+ },
152
+ ],
153
+ exports: [BellaConfigService],
154
+ };
155
+ }
156
+ };
157
+ __setFunctionName(_classThis, "BellaModule");
158
+ (() => {
159
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
160
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
161
+ BellaModule = _classThis = _classDescriptor.value;
162
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
163
+ __runInitializers(_classThis, _classExtraInitializers);
164
+ })();
165
+ return BellaModule = _classThis;
166
+ })();
167
+ export { BellaModule };
168
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,EAAsB,MAAM,EAAE,UAAU,EAAwB,MAAM,gBAAgB,CAAC;AAC9F,OAAO,EAA6B,iBAAiB,EAA2B,MAAM,mBAAmB,CAAC;AAE1G,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AAEnD;;;;;;;;GAQG;IAEU,kBAAkB;4BAD9B,UAAU,EAAE;;;;;QAIX,YAAY,MAAmB;YAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,gFAAgF;YAChF,uCAAuC;YACvC,OAAO,IAAI,KAAK,CAAC,IAAI,EAAE;gBACrB,GAAG,CAAC,MAAM,EAAE,GAAG;oBACb,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,IAAK,kBAAkB,CAAC,SAAoB,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;wBAChG,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;oBAClC,CAAC;oBACD,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAa,CAAC,CAAC;gBAC1C,CAAC;aACF,CAAuB,CAAC;QAC3B,CAAC;QAED,GAAG,CAAC,GAAW;YACb,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC;QAED,UAAU,CAAC,GAAW;YACpB,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC;QAED,MAAM;YACJ,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9B,CAAC;QAED,eAAe;YACb,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACxB,CAAC;;;;;QA/BH,6KAgCC;;;QAhCY,uDAAkB;;;;SAAlB,kBAAkB;IAwClB,WAAW;4BADvB,MAAM,CAAC,EAAE,CAAC;;;;;QAET;;;WAGG;QACH,MAAM,CAAC,QAAQ,CAAC,OAA2B;YACzC,OAAO;gBACL,MAAM,EAAE,WAAW;gBACnB,MAAM,EAAE,IAAI,EAAE,oDAAoD;gBAClE,SAAS,EAAE;oBACT;wBACE,OAAO,EAAE,YAAY;wBACrB,UAAU,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC;qBAC7C;oBACD;wBACE,OAAO,EAAE,kBAAkB;wBAC3B,UAAU,EAAE,CAAC,MAAmB,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC;wBACnE,MAAM,EAAE,CAAC,YAAY,CAAC;qBACvB;iBACF;gBACD,OAAO,EAAE,CAAC,kBAAkB,CAAC;aAC9B,CAAC;QACJ,CAAC;;;;;QAtBH,6KAuBC;;;QAvBY,uDAAW;;;;SAAX,WAAW"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@bella-baxter/nestjs",
3
+ "version": "0.1.1-preview.100",
4
+ "description": "Bella Baxter NestJS module — registers BellaConfig as an injectable service",
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
+ "README.md",
16
+ "dist"
17
+ ],
18
+ "dependencies": {
19
+ "@bella-baxter/sdk": "0.1.1-preview.100"
20
+ },
21
+ "peerDependencies": {
22
+ "@nestjs/common": ">=10",
23
+ "@nestjs/core": ">=10"
24
+ },
25
+ "devDependencies": {
26
+ "typescript": "^6.0.2",
27
+ "@types/node": "^25.5.0",
28
+ "@nestjs/common": "^11.0.0",
29
+ "@nestjs/core": "^11.0.0",
30
+ "reflect-metadata": "^0.2.0"
31
+ },
32
+ "keywords": [
33
+ "bella-baxter",
34
+ "secrets",
35
+ "nestjs",
36
+ "module"
37
+ ],
38
+ "license": "MIT",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/Cosmic-Chimps/bella-baxter-js.git",
42
+ "directory": "apps/sdk/js/packages/nestjs"
43
+ },
44
+ "homepage": "https://github.com/Cosmic-Chimps/bella-baxter-js/tree/main/packages/nestjs#readme",
45
+ "bugs": {
46
+ "url": "https://github.com/Cosmic-Chimps/bella-baxter-js/issues"
47
+ },
48
+ "scripts": {
49
+ "build": "tsc",
50
+ "typecheck": "tsc --noEmit"
51
+ }
52
+ }