udic 0.3.0 → 0.3.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/index.d.ts +11 -12
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -19,12 +19,11 @@ export interface Compute<
|
|
|
19
19
|
}
|
|
20
20
|
export interface Layer<
|
|
21
21
|
K extends string,
|
|
22
|
-
|
|
22
|
+
D,
|
|
23
|
+
R
|
|
23
24
|
> {
|
|
24
|
-
[_t]: { [k in K] :
|
|
25
|
-
[_d]:
|
|
26
|
-
0: K;
|
|
27
|
-
1: C;
|
|
25
|
+
[_t]: { [k in K] : R };
|
|
26
|
+
[_d]: D;
|
|
28
27
|
}
|
|
29
28
|
export type InferResult<T extends {
|
|
30
29
|
[_t]: any
|
|
@@ -36,7 +35,7 @@ export type InferDependency<T extends {
|
|
|
36
35
|
* Create a service
|
|
37
36
|
* @param name - The service name
|
|
38
37
|
*/
|
|
39
|
-
export declare const service: <T extends string>(name: T) => (<K>() => Service<T, K> & T);
|
|
38
|
+
export declare const service: <const T extends string>(name: T) => (<K>() => Service<T, K> & T);
|
|
40
39
|
/**
|
|
41
40
|
* Create a compute that relies on other services or computes
|
|
42
41
|
* @param deps - The service dependencies
|
|
@@ -44,7 +43,7 @@ export declare const service: <T extends string>(name: T) => (<K>() => Service<T
|
|
|
44
43
|
*/
|
|
45
44
|
export declare const derive: <
|
|
46
45
|
const T extends (Service<any, any> | Compute<any, any>)[],
|
|
47
|
-
|
|
46
|
+
R
|
|
48
47
|
>(deps: T, f: (...args: { [K in keyof T] : InferResult<T[K]> }) => R) => Compute<InferDependency<T[number]>, R>;
|
|
49
48
|
/**
|
|
50
49
|
* Inject dependencies to the compute
|
|
@@ -57,12 +56,12 @@ export declare const inject: <
|
|
|
57
56
|
D extends Partial<T>
|
|
58
57
|
>(compute: Compute<T, R>, d: D) => Compute<Prettify<Omit<T, keyof D>>, R>;
|
|
59
58
|
export declare const layer: <
|
|
60
|
-
T,
|
|
61
59
|
K extends string,
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
T,
|
|
61
|
+
D
|
|
62
|
+
>(service: Service<K, T>, compute: Compute<D, T>) => Layer<K, D, T>;
|
|
64
63
|
export declare const provide: <
|
|
65
|
-
const T extends Layer<any, any>[],
|
|
66
|
-
|
|
64
|
+
const T extends Layer<any, any, any>[],
|
|
65
|
+
D extends InferDependency<T[number]>
|
|
67
66
|
>(layers: T, deps: D) => Prettify<D & InferResult<T[number]>>;
|
|
68
67
|
export {};
|