@treatwell/moleculer-call-wrapper 1.0.0

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,38 @@
1
+ import { Service } from 'moleculer';
2
+ import { TypeReferenceNode, TypeNode, NodeArray, TypeParameterDeclaration, SourceFile, Node } from 'typescript';
3
+
4
+ type HandlerTypes = {
5
+ params?: TypeNode;
6
+ returnType?: TypeNode;
7
+ typeParameters?: NodeArray<TypeParameterDeclaration>;
8
+ };
9
+ type ActionRef = HandlerTypes & {
10
+ actionName?: string;
11
+ };
12
+ type Imports = Map<string, string>;
13
+ type ImportMapping = Map<TypeReferenceNode, string>;
14
+ type InjectBuiltinFn = (context: CallWrapperContext, actions: ActionRef[], service: Service, sourceFile: SourceFile) => void;
15
+ type CallWrapperContext = {
16
+ imports: Imports;
17
+ wrapperPath: string;
18
+ currentFilePath: string;
19
+ importMapping: ImportMapping;
20
+ builtins: InjectBuiltinFn[];
21
+ };
22
+
23
+ declare function fillImports(context: CallWrapperContext, sourceFile: SourceFile, node: Node): void;
24
+ declare function addDepToImports(imports: Imports, key: string): string;
25
+
26
+ /**
27
+ * Create a TS file that add typings to the call method of the Moleculer service.
28
+ * It works by creating a new call method that replace the ctx.call method.
29
+ *
30
+ * @param wrapperPath Path to the file that will be created
31
+ * @param services List of services to be parsed
32
+ * @param svcFiles List of those services file paths (must be in the same order as services)
33
+ * @param additionalBuiltins List of additional builtins to be injected. By default, it includes the database mixin v2.
34
+ */
35
+ declare function createWrapperCall(wrapperPath: string, services: Service[], svcFiles: string[], additionalBuiltins: InjectBuiltinFn[]): Promise<void>;
36
+
37
+ export { addDepToImports, createWrapperCall, fillImports };
38
+ export type { ActionRef, CallWrapperContext };
@@ -0,0 +1,38 @@
1
+ import { Service } from 'moleculer';
2
+ import { TypeReferenceNode, TypeNode, NodeArray, TypeParameterDeclaration, SourceFile, Node } from 'typescript';
3
+
4
+ type HandlerTypes = {
5
+ params?: TypeNode;
6
+ returnType?: TypeNode;
7
+ typeParameters?: NodeArray<TypeParameterDeclaration>;
8
+ };
9
+ type ActionRef = HandlerTypes & {
10
+ actionName?: string;
11
+ };
12
+ type Imports = Map<string, string>;
13
+ type ImportMapping = Map<TypeReferenceNode, string>;
14
+ type InjectBuiltinFn = (context: CallWrapperContext, actions: ActionRef[], service: Service, sourceFile: SourceFile) => void;
15
+ type CallWrapperContext = {
16
+ imports: Imports;
17
+ wrapperPath: string;
18
+ currentFilePath: string;
19
+ importMapping: ImportMapping;
20
+ builtins: InjectBuiltinFn[];
21
+ };
22
+
23
+ declare function fillImports(context: CallWrapperContext, sourceFile: SourceFile, node: Node): void;
24
+ declare function addDepToImports(imports: Imports, key: string): string;
25
+
26
+ /**
27
+ * Create a TS file that add typings to the call method of the Moleculer service.
28
+ * It works by creating a new call method that replace the ctx.call method.
29
+ *
30
+ * @param wrapperPath Path to the file that will be created
31
+ * @param services List of services to be parsed
32
+ * @param svcFiles List of those services file paths (must be in the same order as services)
33
+ * @param additionalBuiltins List of additional builtins to be injected. By default, it includes the database mixin v2.
34
+ */
35
+ declare function createWrapperCall(wrapperPath: string, services: Service[], svcFiles: string[], additionalBuiltins: InjectBuiltinFn[]): Promise<void>;
36
+
37
+ export { addDepToImports, createWrapperCall, fillImports };
38
+ export type { ActionRef, CallWrapperContext };