@bella-baxter/adonis 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,102 @@
1
+ /**
2
+ * @bella-baxter/adonis
3
+ *
4
+ * Adonis.js v6 Service Provider — registers BellaConfig in the IoC container.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * // adonisrc.ts
9
+ * import { defineConfig } from '@adonisjs/core/build/config.js';
10
+ *
11
+ * export default defineConfig({
12
+ * providers: [
13
+ * // ... other providers
14
+ * () => import('@bella-baxter/adonis'),
15
+ * ],
16
+ * });
17
+ * ```
18
+ *
19
+ * ```ts
20
+ * // config/bella.ts
21
+ * import env from '#start/env'
22
+ *
23
+ * const bellaConfig = {
24
+ * baxterUrl: env.get('BELLA_BAXTER_URL'),
25
+ * environmentSlug: env.get('BELLA_ENV_SLUG', 'production'),
26
+ * apiKey: env.get('BELLA_BAXTER_API_KEY'),
27
+ *
28
+ * }
29
+ *
30
+ * export default bellaConfig
31
+ * ```
32
+ *
33
+ * ```ts
34
+ * // In any controller / service — inject via constructor
35
+ * import BellaService from '@bella-baxter/adonis'
36
+ *
37
+ * export default class SecretsController {
38
+ * constructor(protected bella: BellaService) {}
39
+ *
40
+ * async show() {
41
+ * return { dbUrl: this.bella.getOrThrow('DATABASE_URL') }
42
+ * }
43
+ * }
44
+ * ```
45
+ */
46
+ import { BellaConfig, BellaSecrets, type BellaConfigOptions } from '@bella-baxter/sdk';
47
+ /**
48
+ * Thin injectable wrapper over BellaConfig with Adonis-style naming.
49
+ * Registered as a singleton in the IoC container under 'bella'.
50
+ *
51
+ * After running `bella secrets generate typescript --declaration`, the generated
52
+ * `bella-secrets.d.ts` augments `BellaSecrets`, giving this service typed property access:
53
+ * ```ts
54
+ * this.bella.DATABASE_URL // string — typed!
55
+ * ```
56
+ */
57
+ export declare class BellaService {
58
+ private readonly _inner;
59
+ constructor(config: BellaConfig);
60
+ get(key: string): string | undefined;
61
+ getOrThrow(key: string): string;
62
+ getAll(): Record<string, string>;
63
+ /** Write all secrets into process.env (useful for legacy Adonis code). */
64
+ intoProcessEnv(): void;
65
+ shutdown(): void;
66
+ }
67
+ export interface BellaService extends BellaSecrets {
68
+ }
69
+ /**
70
+ * BellaServiceProvider for Adonis.js v6/v7.
71
+ *
72
+ * Registers `BellaService` in the container during `boot()`.
73
+ * Uses the config from `config/bella.ts`.
74
+ *
75
+ * Bound by class constructor so `@inject()` can resolve it via TypeScript
76
+ * decorator metadata (`design:paramtypes`).
77
+ */
78
+ export default class BellaServiceProvider {
79
+ protected app: {
80
+ config: {
81
+ get: <T>(key: string, defaultValue?: T) => T;
82
+ };
83
+ container: {
84
+ singleton: (key: any, factory: () => unknown) => void;
85
+ make: (key: any) => unknown;
86
+ };
87
+ terminating: (cb: () => void | Promise<void>) => void;
88
+ };
89
+ constructor(app: {
90
+ config: {
91
+ get: <T>(key: string, defaultValue?: T) => T;
92
+ };
93
+ container: {
94
+ singleton: (key: any, factory: () => unknown) => void;
95
+ make: (key: any) => unknown;
96
+ };
97
+ terminating: (cb: () => void | Promise<void>) => void;
98
+ });
99
+ boot(): Promise<void>;
100
+ }
101
+ export { BellaConfig, type BellaConfigOptions };
102
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAqB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAI1G;;;;;;;;;GASG;AACH,qBAAa,YAAY;IACvB,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,G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dist/index.js ADDED
@@ -0,0 +1,114 @@
1
+ /**
2
+ * @bella-baxter/adonis
3
+ *
4
+ * Adonis.js v6 Service Provider — registers BellaConfig in the IoC container.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * // adonisrc.ts
9
+ * import { defineConfig } from '@adonisjs/core/build/config.js';
10
+ *
11
+ * export default defineConfig({
12
+ * providers: [
13
+ * // ... other providers
14
+ * () => import('@bella-baxter/adonis'),
15
+ * ],
16
+ * });
17
+ * ```
18
+ *
19
+ * ```ts
20
+ * // config/bella.ts
21
+ * import env from '#start/env'
22
+ *
23
+ * const bellaConfig = {
24
+ * baxterUrl: env.get('BELLA_BAXTER_URL'),
25
+ * environmentSlug: env.get('BELLA_ENV_SLUG', 'production'),
26
+ * apiKey: env.get('BELLA_BAXTER_API_KEY'),
27
+ *
28
+ * }
29
+ *
30
+ * export default bellaConfig
31
+ * ```
32
+ *
33
+ * ```ts
34
+ * // In any controller / service — inject via constructor
35
+ * import BellaService from '@bella-baxter/adonis'
36
+ *
37
+ * export default class SecretsController {
38
+ * constructor(protected bella: BellaService) {}
39
+ *
40
+ * async show() {
41
+ * return { dbUrl: this.bella.getOrThrow('DATABASE_URL') }
42
+ * }
43
+ * }
44
+ * ```
45
+ */
46
+ import { BellaConfig, createBellaConfig } from '@bella-baxter/sdk';
47
+ // ── Injectable Service ───────────────────────────────────────────────────────
48
+ /**
49
+ * Thin injectable wrapper over BellaConfig with Adonis-style naming.
50
+ * Registered as a singleton in the IoC container under 'bella'.
51
+ *
52
+ * After running `bella secrets generate typescript --declaration`, the generated
53
+ * `bella-secrets.d.ts` augments `BellaSecrets`, giving this service typed property access:
54
+ * ```ts
55
+ * this.bella.DATABASE_URL // string — typed!
56
+ * ```
57
+ */
58
+ export class BellaService {
59
+ constructor(config) {
60
+ this._inner = config;
61
+ // Intercept property access so typed secret keys (e.g. this.bella.DATABASE_URL)
62
+ // delegate to config.get() at runtime.
63
+ return new Proxy(this, {
64
+ get(target, key) {
65
+ if (typeof key === 'symbol' || key in BellaService.prototype || key in target) {
66
+ return Reflect.get(target, key);
67
+ }
68
+ return target._inner.get(key);
69
+ },
70
+ });
71
+ }
72
+ get(key) {
73
+ return this._inner.get(key);
74
+ }
75
+ getOrThrow(key) {
76
+ return this._inner.getOrThrow(key);
77
+ }
78
+ getAll() {
79
+ return this._inner.getAll();
80
+ }
81
+ /** Write all secrets into process.env (useful for legacy Adonis code). */
82
+ intoProcessEnv() {
83
+ this._inner.intoProcessEnv();
84
+ }
85
+ shutdown() {
86
+ this._inner.destroy();
87
+ }
88
+ }
89
+ // ── Service Provider ─────────────────────────────────────────────────────────
90
+ /**
91
+ * BellaServiceProvider for Adonis.js v6/v7.
92
+ *
93
+ * Registers `BellaService` in the container during `boot()`.
94
+ * Uses the config from `config/bella.ts`.
95
+ *
96
+ * Bound by class constructor so `@inject()` can resolve it via TypeScript
97
+ * decorator metadata (`design:paramtypes`).
98
+ */
99
+ export default class BellaServiceProvider {
100
+ constructor(app) {
101
+ this.app = app;
102
+ }
103
+ async boot() {
104
+ const options = this.app.config.get('bella');
105
+ // Register by class so @inject() can resolve by design:paramtypes.
106
+ this.app.container.singleton(BellaService, () => createBellaConfig(options).then((cfg) => new BellaService(cfg)));
107
+ this.app.terminating(() => {
108
+ const service = this.app.container.make(BellaService);
109
+ service.shutdown();
110
+ });
111
+ }
112
+ }
113
+ export { BellaConfig };
114
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAE,WAAW,EAAgB,iBAAiB,EAA2B,MAAM,mBAAmB,CAAC;AAE1G,gFAAgF;AAEhF;;;;;;;;;GASG;AACH,MAAM,OAAO,YAAY;IAGvB,YAAY,MAAmB;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,gFAAg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AC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC,CAChE,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,EAAE;YACxB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAiB,CAAC;YACtE,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,OAAO,EAAE,WAAW,EAA2B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@bella-baxter/adonis",
3
+ "version": "0.1.1-preview.11",
4
+ "description": "Bella Baxter AdonisJS v6 service provider — registers BellaService in the IoC container",
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
+ "@adonisjs/core": ">=6"
22
+ },
23
+ "devDependencies": {
24
+ "typescript": "^5.9.3",
25
+ "@types/node": "^25.5.0"
26
+ },
27
+ "keywords": [
28
+ "bella-baxter",
29
+ "secrets",
30
+ "adonisjs",
31
+ "adonis"
32
+ ],
33
+ "license": "MIT",
34
+ "scripts": {
35
+ "build": "tsc",
36
+ "typecheck": "tsc --noEmit"
37
+ }
38
+ }