@lad-tech/nsc-toolkit 1.10.0 → 1.11.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +9 -2
  2. package/coverage/clover.xml +120 -116
  3. package/coverage/coverage-final.json +15 -15
  4. package/coverage/lcov-report/examples/LogicService/adapters/Configurator.ts.html +1 -1
  5. package/coverage/lcov-report/examples/LogicService/adapters/Repository.ts.html +1 -1
  6. package/coverage/lcov-report/examples/LogicService/adapters/index.html +1 -1
  7. package/coverage/lcov-report/examples/LogicService/adapters/index.ts.html +1 -1
  8. package/coverage/lcov-report/examples/LogicService/index.html +1 -1
  9. package/coverage/lcov-report/examples/LogicService/index.ts.html +1 -1
  10. package/coverage/lcov-report/examples/LogicService/inversion.types.ts.html +1 -1
  11. package/coverage/lcov-report/examples/LogicService/methods/GetUser.ts.html +1 -1
  12. package/coverage/lcov-report/examples/LogicService/methods/GetUserV2.ts.html +3 -3
  13. package/coverage/lcov-report/examples/LogicService/methods/WeirdSum.ts.html +1 -1
  14. package/coverage/lcov-report/examples/LogicService/methods/index.html +7 -7
  15. package/coverage/lcov-report/examples/LogicService/service.ts.html +1 -1
  16. package/coverage/lcov-report/examples/MathService/index.html +1 -1
  17. package/coverage/lcov-report/examples/MathService/index.ts.html +10 -13
  18. package/coverage/lcov-report/examples/MathService/methods/Fibonacci.ts.html +2 -2
  19. package/coverage/lcov-report/examples/MathService/methods/Sum.ts.html +2 -2
  20. package/coverage/lcov-report/examples/MathService/methods/SumStream.ts.html +2 -2
  21. package/coverage/lcov-report/examples/MathService/methods/index.html +5 -5
  22. package/coverage/lcov-report/examples/MathService/service.ts.html +6 -6
  23. package/coverage/lcov-report/index.html +19 -19
  24. package/coverage/lcov.info +237 -232
  25. package/dist/Client.js +8 -3
  26. package/dist/Client.js.map +1 -1
  27. package/dist/injector.js.map +1 -1
  28. package/dist/interfaces.js.map +1 -1
  29. package/dist/types/Client.d.ts +4 -3
  30. package/dist/types/Container.d.ts +5 -5
  31. package/dist/types/Union/Broker.d.ts +1 -1
  32. package/dist/types/injector.d.ts +5 -5
  33. package/dist/types/interfaces.d.ts +9 -8
  34. package/package.json +4 -4
@@ -1,9 +1,9 @@
1
1
  import { DependencyType, ClientService } from '.';
2
- declare type Constant = Record<string, any>;
3
- declare type Service<R extends Constant = Constant> = ClientService<R>;
4
- export declare type Adapter<R extends Constant = Constant> = new (...args: any[]) => R;
5
- declare type Dependency = Service | Adapter | Constant;
6
- declare type ContainerValue = {
2
+ type Constant = Record<string, any>;
3
+ type Service<R extends Constant = Constant> = ClientService<R>;
4
+ export type Adapter<R extends Constant = Constant> = new (...args: any[]) => R;
5
+ type Dependency = Service | Adapter | Constant;
6
+ type ContainerValue = {
7
7
  type: DependencyType;
8
8
  value: Dependency;
9
9
  };
@@ -2,7 +2,7 @@ import { JetStreamClient, JetStreamManager, JetStreamOptions, Msg, NatsConnectio
2
2
  interface Union {
3
3
  isUnion?: boolean;
4
4
  }
5
- export declare type Broker = NatsConnection & Union;
5
+ export type Broker = NatsConnection & Union;
6
6
  export declare class UnionBroker implements Broker {
7
7
  info?: ServerInfo;
8
8
  isUnion: boolean;
@@ -1,9 +1,9 @@
1
1
  import 'reflect-metadata';
2
2
  import { Method, ClientService } from './interfaces';
3
- export declare type Instance = Record<string, (props: any) => Promise<unknown>>;
4
- export declare type Dependency = ClientService<unknown>;
5
- export declare type DependenceStorage = Map<string, Dependency>;
6
- export declare type InstanceStorage = Map<string, Instance>;
3
+ export type Instance = Record<string, (props: any) => Promise<unknown>>;
4
+ export type Dependency = ClientService<unknown>;
5
+ export type DependenceStorage = Map<string, Dependency>;
6
+ export type InstanceStorage = Map<string, Instance>;
7
7
  export declare const dependencyStorageMetaKey: unique symbol;
8
8
  export declare const ServiceContainer: Map<string, DependenceStorage>;
9
9
  export declare const InstanceContainer: Map<string, InstanceStorage>;
@@ -11,4 +11,4 @@ export declare const ConstructorDependencyKey = "constructor";
11
11
  export declare function related<T extends Method>(target: T): void;
12
12
  export declare function service(dependence: Dependency): (target: any, dependenceName: string) => void;
13
13
  export declare function instance(instance: Instance): (target: any, instanceName: string) => void;
14
- export declare function inject(key: symbol): (target: any, property: string, index?: number) => void;
14
+ export declare function inject(key: symbol): (target: any, property: string | symbol | undefined, index?: number) => void;
@@ -1,6 +1,6 @@
1
+ import type { Logs } from '@lad-tech/toolbelt';
1
2
  import type { NatsConnection } from 'nats';
2
3
  import type { Client } from './Client';
3
- import type { Logs } from '@lad-tech/toolbelt';
4
4
  export interface MethodOptions {
5
5
  useStream?: {
6
6
  request?: boolean;
@@ -25,14 +25,14 @@ export interface Method {
25
25
  handler: (params: any) => Promise<any>;
26
26
  };
27
27
  }
28
- export declare type ClientService<C = Client> = new (natsConnection: NatsConnection, baggage?: Baggage, cache?: CacheSettings, loggerOutputFormatter?: Logs.OutputFormatter) => C;
29
- export declare type Baggage = {
28
+ export type ClientService<C = Client> = new (natsConnection: NatsConnection, baggage?: Baggage, cache?: CacheSettings, loggerOutputFormatter?: Logs.OutputFormatter) => C;
29
+ export type Baggage = {
30
30
  traceId: string;
31
31
  spanId: string;
32
32
  traceFlags: number;
33
33
  expired?: number;
34
34
  };
35
- export declare type ExternalBaggage = {
35
+ export type ExternalBaggage = {
36
36
  'nsc-expired'?: number;
37
37
  'nsc-trace-id'?: string;
38
38
  'nsc-span-id'?: string;
@@ -46,7 +46,7 @@ export interface Message<M = any> {
46
46
  code?: number;
47
47
  };
48
48
  }
49
- export declare type Emitter = Record<string, (params: any) => void>;
49
+ export type Emitter = Record<string, (params: any) => void>;
50
50
  export interface CacheSettings {
51
51
  service: CacheService;
52
52
  timeout: number;
@@ -61,6 +61,7 @@ export interface ClientParam<E extends Emitter = Emitter> {
61
61
  cache?: CacheSettings;
62
62
  loggerOutputFormatter?: Logs.OutputFormatter;
63
63
  events?: Events<E>;
64
+ Ref?: object;
64
65
  }
65
66
  export interface GetListenerOptions {
66
67
  queue?: string;
@@ -118,8 +119,8 @@ export interface ServiceOptions<E extends Emitter> {
118
119
  timeout?: number;
119
120
  };
120
121
  }
121
- export declare type EventStreamHandler<P extends Record<string, any>> = (params: EmitterStreamEvent<P>) => void;
122
- export declare type EventHandler<P extends Record<string, any>> = (params: EmitterEvent<P>) => void;
122
+ export type EventStreamHandler<P extends Record<string, any>> = (params: EmitterStreamEvent<P>) => void;
123
+ export type EventHandler<P extends Record<string, any>> = (params: EmitterEvent<P>) => void;
123
124
  export interface Listener<E extends Emitter> {
124
125
  on<A extends keyof E>(action: A, handler: E[A]): void;
125
126
  off<A extends keyof E>(action: A, handler: E[A]): void;
@@ -133,7 +134,7 @@ export interface CacheService {
133
134
  get: (key: string) => Promise<string | undefined>;
134
135
  delete: (key: string) => Promise<void>;
135
136
  }
136
- export declare type DependencyType = typeof DependencyType[keyof typeof DependencyType];
137
+ export type DependencyType = typeof DependencyType[keyof typeof DependencyType];
137
138
  export declare const DependencyType: {
138
139
  readonly SERVICE: "service";
139
140
  readonly ADAPTER: "adapter";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lad-tech/nsc-toolkit",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "Toolkit for create microservices around NATS",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -25,13 +25,13 @@
25
25
  "eslint-plugin-jest": "^26.9.0",
26
26
  "eslint-plugin-node": "^11.1.0",
27
27
  "eslint-plugin-prettier": "^4.0.0",
28
- "jest": "^27.5.1",
28
+ "jest": "^29.5.0",
29
29
  "lefthook": "^1.2.0",
30
30
  "prettier": "^2.6.1",
31
31
  "prettier-eslint": "^13.0.0",
32
32
  "semantic-release": "^19.0.5",
33
- "ts-jest": "^27.1.5",
34
- "typescript": "^4.6.3"
33
+ "ts-jest": "^29.1.0",
34
+ "typescript": "^5.1.3"
35
35
  },
36
36
  "dependencies": {
37
37
  "@lad-tech/toolbelt": "^1.1.1",