@nxara/olio-di 0.0.0-stage → 0.1.0-rc.1
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/LICENSE +21 -0
- package/README.md +102 -2
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +98 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nxara contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,103 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @nxara/olio-di
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Typed dependency injection for olio apps, on [Awilix](https://github.com/jeffijoe/awilix).
|
|
4
|
+
|
|
5
|
+
Modules already share code through plain imports. DI adds what imports can't:
|
|
6
|
+
|
|
7
|
+
- **Per-operation instances:** a DataLoader, a transaction or a "current user" repository, one per request and shared by every resolver in it.
|
|
8
|
+
- **Swapping implementations in tests,** without rewiring imports.
|
|
9
|
+
- **Lifecycle:** lazy creation, and cleanup when an operation or the app ends.
|
|
10
|
+
|
|
11
|
+
Awilix does the work underneath: lifetimes, lazy proxy injection, catching a singleton that holds a per-operation instance, cycle detection, disposal. This package puts typed providers on top: resolvers reach services by name, with autocomplete, and a typo is a compile error.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
bun add @nxara/olio-di
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Providers
|
|
18
|
+
|
|
19
|
+
Providers are plain values, declared next to the code that uses them. A factory asks for what it needs with `get(Provider)`.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { operation, singleton } from "@nxara/olio-di";
|
|
23
|
+
|
|
24
|
+
export const Db = singleton(() => new Pool(env.DATABASE_URL), {
|
|
25
|
+
dispose: (pool) => pool.end()
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const ProductLoader = operation(
|
|
29
|
+
({ get }) =>
|
|
30
|
+
new DataLoader((skus: readonly string[]) => get(Db).products.bySkus(skus))
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
export const Orders = operation(
|
|
34
|
+
({ get, ctx }) => new OrderRepo(get(Db), ctx.viewer)
|
|
35
|
+
);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
| | Lives | Its factory gets |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| `singleton(factory, { dispose? })` | As long as the container | `{ get }`, for other singletons only |
|
|
41
|
+
| `operation(factory, { dispose? })` | One operation (one scope) | `{ get, ctx }`, for any provider, plus the operation's context |
|
|
42
|
+
|
|
43
|
+
A singleton that asks for an operation provider is a type error, and Awilix rejects it at runtime too. So do cycles (`Cyclic dependencies detected`).
|
|
44
|
+
|
|
45
|
+
## With olio
|
|
46
|
+
|
|
47
|
+
Tell DI what an operation's context looks like, the same way you register olio's:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
declare module "@nxara/olio-di" {
|
|
51
|
+
interface Register {
|
|
52
|
+
ctx: RequestInfo; // what your context has, apart from `di` itself
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Create one container, naming the services resolvers use. Give every operation a scope in its context, and dispose the scope when the operation ends:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
// di.ts: the keys are the names. Providers these depend on (Db) needn't be listed.
|
|
61
|
+
export const container = createContainer({
|
|
62
|
+
productLoader: ProductLoader,
|
|
63
|
+
orders: Orders
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// in your context type
|
|
67
|
+
di: ScopeOf<typeof container>;
|
|
68
|
+
|
|
69
|
+
fetchHandler(app, {
|
|
70
|
+
context: (request) => {
|
|
71
|
+
const info = requestInfo(request);
|
|
72
|
+
return { ...info, di: container.scope(info) };
|
|
73
|
+
},
|
|
74
|
+
onOperationEnd: (ctx) => ctx.di.dispose() // @nxara/olio-http
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// in a resolver
|
|
78
|
+
product: (line, _args, ctx) => ctx.di.productLoader.load(line.sku); // typed, autocompletes, created on first access
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Subscriptions work the same way: give each one a scope in its context and dispose it when it ends. With graphql-ws that's its `context(ctx, id)` hook, which runs once per subscription, and `onComplete`; with graphql-sse, `context` and `onComplete`. `@nxara/olio-http`'s README shows both.
|
|
82
|
+
|
|
83
|
+
## Tests
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
const container = createContainer(services, { override: [override(Db, fakeDb)] }); // fakeDb must fit Db
|
|
87
|
+
await using scope = container.scope(testInfo); // disposed at the end of the block
|
|
88
|
+
expect(await scope.orders.list()).toEqual([...]);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`dispose` and `ctx` are reserved and can't be service names. Factories use tokens (`get(Db)`) rather than names: typing a factory's dependencies from the list it's part of is circular, and TypeScript can't resolve it.
|
|
92
|
+
|
|
93
|
+
Each container is independent, so tests don't share singletons.
|
|
94
|
+
|
|
95
|
+
## API
|
|
96
|
+
|
|
97
|
+
| | |
|
|
98
|
+
| --- | --- |
|
|
99
|
+
| `createContainer(services, { override? })` | The root: `scope(ctx)`, `dispose()`, `Symbol.asyncDispose` |
|
|
100
|
+
| `scope.<name>` | An instance for this operation: its own for `operation` providers, the shared one for singletons |
|
|
101
|
+
| `ScopeOf<typeof container>` | The scope's type, for `ctx.di` |
|
|
102
|
+
| `scope.dispose()` | Disposes this operation's instances, newest first. Also `Symbol.asyncDispose` |
|
|
103
|
+
| `override(provider, value)` | A typed replacement for tests |
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface Register {
|
|
2
|
+
}
|
|
3
|
+
type Ctx = Register extends {
|
|
4
|
+
ctx: infer C;
|
|
5
|
+
} ? C : unknown;
|
|
6
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
7
|
+
export type Lifetime = "singleton" | "operation";
|
|
8
|
+
declare const provides: unique symbol;
|
|
9
|
+
export interface Provider<T, L extends Lifetime = Lifetime> {
|
|
10
|
+
readonly lifetime: L;
|
|
11
|
+
readonly create: (deps: OperationDeps) => T;
|
|
12
|
+
dispose?(value: T): MaybePromise<unknown>;
|
|
13
|
+
readonly [provides]?: T;
|
|
14
|
+
}
|
|
15
|
+
export interface SingletonDeps {
|
|
16
|
+
get<T>(provider: Provider<T, "singleton">): T;
|
|
17
|
+
}
|
|
18
|
+
export interface OperationDeps {
|
|
19
|
+
get<T>(provider: Provider<T>): T;
|
|
20
|
+
readonly ctx: Ctx;
|
|
21
|
+
}
|
|
22
|
+
interface Options<T> {
|
|
23
|
+
dispose?: (value: T) => MaybePromise<unknown>;
|
|
24
|
+
}
|
|
25
|
+
export declare function singleton<T>(create: (deps: SingletonDeps) => T, options?: Options<T>): Provider<T, "singleton">;
|
|
26
|
+
export declare function operation<T>(create: (deps: OperationDeps) => T, options?: Options<T>): Provider<T, "operation">;
|
|
27
|
+
export interface Override {
|
|
28
|
+
readonly provider: Provider<unknown>;
|
|
29
|
+
readonly value: unknown;
|
|
30
|
+
}
|
|
31
|
+
export declare const override: <T>(provider: Provider<T>, value: T) => Override;
|
|
32
|
+
export type Services = Readonly<Record<string, Provider<unknown>>> & {
|
|
33
|
+
readonly dispose?: never;
|
|
34
|
+
readonly ctx?: never;
|
|
35
|
+
};
|
|
36
|
+
export type Scope<S extends Services> = {
|
|
37
|
+
readonly [K in keyof S]: S[K] extends Provider<infer T> ? T : never;
|
|
38
|
+
} & AsyncDisposable & {
|
|
39
|
+
dispose(): Promise<void>;
|
|
40
|
+
};
|
|
41
|
+
export interface Container<S extends Services> extends AsyncDisposable {
|
|
42
|
+
scope(ctx: Ctx): Scope<S>;
|
|
43
|
+
dispose(): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export type ScopeOf<C> = C extends Container<infer S> ? Scope<S> : never;
|
|
46
|
+
export declare function createContainer<const S extends Services>(services: S, options?: {
|
|
47
|
+
override?: readonly Override[];
|
|
48
|
+
}): Container<S>;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,QAAQ;CAAG;AAE5B,KAAK,GAAG,GAAG,QAAQ,SAAS;IAAE,GAAG,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,OAAO,CAAC;AAC3D,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,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AA;CAAO,GAC/C,SAAS,CAAC,CAAC,CAAC,CAgGd"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { asFunction, asValue, createContainer as createAwilix, InjectionMode } from "awilix";
|
|
2
|
+
export function singleton(create, options = {}) {
|
|
3
|
+
return { lifetime: "singleton", create, dispose: options.dispose };
|
|
4
|
+
}
|
|
5
|
+
export function operation(create, options = {}) {
|
|
6
|
+
return { lifetime: "operation", create, dispose: options.dispose };
|
|
7
|
+
}
|
|
8
|
+
export const override = (provider, value) => ({
|
|
9
|
+
provider,
|
|
10
|
+
value
|
|
11
|
+
});
|
|
12
|
+
const CTX = "ctx";
|
|
13
|
+
const RESERVED = new Set([CTX, "dispose"]);
|
|
14
|
+
const RESOLVE = Symbol("resolve");
|
|
15
|
+
const DISPOSED = Promise.resolve();
|
|
16
|
+
export function createContainer(services, options = {}) {
|
|
17
|
+
const root = createAwilix({
|
|
18
|
+
injectionMode: InjectionMode.PROXY,
|
|
19
|
+
strict: true
|
|
20
|
+
});
|
|
21
|
+
const replaced = new Map(options.override?.map((o) => [o.provider, o.value]));
|
|
22
|
+
const names = new Map();
|
|
23
|
+
const register = (provider, name) => {
|
|
24
|
+
names.set(provider, name);
|
|
25
|
+
if (replaced.has(provider)) {
|
|
26
|
+
root.register(name, asValue(replaced.get(provider)));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const resolver = asFunction((cradle) => provider.create({
|
|
30
|
+
get: (dep) => cradle[ensure(dep)],
|
|
31
|
+
get ctx() {
|
|
32
|
+
return cradle[CTX];
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
const lifetime = provider.lifetime === "singleton"
|
|
36
|
+
? resolver.singleton()
|
|
37
|
+
: resolver.scoped();
|
|
38
|
+
const { dispose } = provider;
|
|
39
|
+
root.register(name, dispose ? lifetime.disposer(dispose) : lifetime);
|
|
40
|
+
};
|
|
41
|
+
const ensure = (provider) => {
|
|
42
|
+
const known = names.get(provider);
|
|
43
|
+
if (known)
|
|
44
|
+
return known;
|
|
45
|
+
const name = `#${names.size + 1}`;
|
|
46
|
+
register(provider, name);
|
|
47
|
+
return name;
|
|
48
|
+
};
|
|
49
|
+
for (const [name, provider] of Object.entries(services)) {
|
|
50
|
+
if (RESERVED.has(name)) {
|
|
51
|
+
throw new Error(`"${name}" is reserved; give the service another name`);
|
|
52
|
+
}
|
|
53
|
+
if (!names.has(provider))
|
|
54
|
+
register(provider, name);
|
|
55
|
+
}
|
|
56
|
+
class OperationScope {
|
|
57
|
+
#ctx;
|
|
58
|
+
#awilix;
|
|
59
|
+
constructor(ctx) {
|
|
60
|
+
this.#ctx = ctx;
|
|
61
|
+
}
|
|
62
|
+
[RESOLVE](provider) {
|
|
63
|
+
const name = ensure(provider);
|
|
64
|
+
if (provider.lifetime === "singleton")
|
|
65
|
+
return root.resolve(name);
|
|
66
|
+
if (!this.#awilix) {
|
|
67
|
+
this.#awilix = root.createScope();
|
|
68
|
+
this.#awilix.register(CTX, asValue(this.#ctx));
|
|
69
|
+
}
|
|
70
|
+
return this.#awilix.resolve(name);
|
|
71
|
+
}
|
|
72
|
+
dispose() {
|
|
73
|
+
return this.#awilix
|
|
74
|
+
? this.#awilix.dispose().then(() => undefined)
|
|
75
|
+
: DISPOSED;
|
|
76
|
+
}
|
|
77
|
+
[Symbol.asyncDispose]() {
|
|
78
|
+
return this.dispose();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
for (const [name, provider] of Object.entries(services)) {
|
|
82
|
+
Object.defineProperty(OperationScope.prototype, name, {
|
|
83
|
+
get() {
|
|
84
|
+
return this[RESOLVE](provider);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
scope: (ctx) => new OperationScope(ctx),
|
|
90
|
+
dispose: async () => {
|
|
91
|
+
await root.dispose();
|
|
92
|
+
},
|
|
93
|
+
[Symbol.asyncDispose]: async () => {
|
|
94
|
+
await root.dispose();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BACjB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;gBAC9C,CAAC,CAAC,QAAQ,CAAC;QACf,CAAC;QAED,CAAC,MAAM,CAAC,YAAY,CAAC;YACnB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;QACxB,CAAC;KACF;IACD,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxD,MAAM,CAAC,cAAc,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,EAAE;YACpD,GAAG;gBACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;YACjC,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,GAAG,CAAwB;QAC9D,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC;QACD,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,KAAK,IAAI,EAAE;YAChC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxara/olio-di",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-rc.1",
|
|
4
|
+
"description": "Typed dependency injection for olio apps, on Awilix.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"awilix",
|
|
7
|
+
"dependency-injection",
|
|
8
|
+
"di",
|
|
9
|
+
"graphql",
|
|
10
|
+
"nxara"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/nxara-hub/olio.git",
|
|
16
|
+
"directory": "packages/di"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc",
|
|
34
|
+
"test": "bun test",
|
|
35
|
+
"check-types": "tsc -p tsconfig.test.json"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"awilix": "^13.0.5"
|
|
39
|
+
}
|
|
40
|
+
}
|