@deessejs/functions 0.0.17 → 0.0.19
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/dist/context/define.d.ts +7 -6
- package/dist/context/define.js +12 -8
- package/dist/extensions/rpc.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/dist/context/define.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { UnionToIntersection } from "../utils";
|
|
2
|
-
type MergeExtensions<TContext, TExtensions extends
|
|
3
|
-
export declare function defineContext<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
export type MergeExtensions<TContext, TExtensions extends Array<(...args: any) => any>> = UnionToIntersection<ReturnType<TExtensions[number]>>;
|
|
3
|
+
export declare function defineContext<TContext extends Record<string, unknown>>(): {
|
|
4
|
+
withExtensions: <TExtensions extends Array<(...args: any) => any>>(config: {
|
|
5
|
+
extensions: TExtensions;
|
|
6
|
+
}) => MergeExtensions<TContext, TExtensions> & {
|
|
7
|
+
context: TContext;
|
|
8
|
+
};
|
|
7
9
|
};
|
|
8
|
-
export {};
|
package/dist/context/define.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defineContext = defineContext;
|
|
4
|
-
function defineContext(
|
|
5
|
-
const builder = {};
|
|
6
|
-
for (const createExtension of config.extensions) {
|
|
7
|
-
const extensionInstance = createExtension();
|
|
8
|
-
Object.assign(builder, extensionInstance);
|
|
9
|
-
}
|
|
4
|
+
function defineContext() {
|
|
10
5
|
return {
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
withExtensions: (config) => {
|
|
7
|
+
const builder = {};
|
|
8
|
+
for (const createExtension of config.extensions) {
|
|
9
|
+
const extensionInstance = createExtension();
|
|
10
|
+
Object.assign(builder, extensionInstance);
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
...builder,
|
|
14
|
+
context: {},
|
|
15
|
+
};
|
|
16
|
+
},
|
|
13
17
|
};
|
|
14
18
|
}
|
package/dist/extensions/rpc.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { CommandsDefinition, MutationDefinition, QueryDefinition } from "../cont
|
|
|
5
5
|
export type APINode = CommandsDefinition | {
|
|
6
6
|
[key: string]: APINode;
|
|
7
7
|
};
|
|
8
|
-
export declare const rpc: () =>
|
|
8
|
+
export declare const rpc: <TContext>() => () => {
|
|
9
9
|
query: <TArgs extends ZodType<any, any, any>, TOutput, TError extends Exception = Exception>(options: {
|
|
10
10
|
args: TArgs;
|
|
11
11
|
handler: (ctx: TContext, // <--- Le contexte est injecté ici
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -18,5 +18,6 @@ __exportStar(require("./api"), exports);
|
|
|
18
18
|
__exportStar(require("./api/types"), exports);
|
|
19
19
|
__exportStar(require("./functions"), exports);
|
|
20
20
|
__exportStar(require("./types"), exports);
|
|
21
|
+
__exportStar(require("./extensions/rpc"), exports);
|
|
21
22
|
// Context and typing exports
|
|
22
23
|
__exportStar(require("./context"), exports);
|
package/package.json
CHANGED