@equinor/fusion-framework-module-context 0.0.0-context-error-20240131144633

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 (61) hide show
  1. package/CHANGELOG.md +522 -0
  2. package/LICENSE +21 -0
  3. package/dist/esm/ContextConfigBuilder.js +79 -0
  4. package/dist/esm/ContextConfigBuilder.js.map +1 -0
  5. package/dist/esm/ContextProvider.js +279 -0
  6. package/dist/esm/ContextProvider.js.map +1 -0
  7. package/dist/esm/client/ContextClient.js +62 -0
  8. package/dist/esm/client/ContextClient.js.map +1 -0
  9. package/dist/esm/configurator.js +86 -0
  10. package/dist/esm/configurator.js.map +1 -0
  11. package/dist/esm/errors.js +26 -0
  12. package/dist/esm/errors.js.map +1 -0
  13. package/dist/esm/index.js +6 -0
  14. package/dist/esm/index.js.map +1 -0
  15. package/dist/esm/module.js +55 -0
  16. package/dist/esm/module.js.map +1 -0
  17. package/dist/esm/selectors.js +44 -0
  18. package/dist/esm/selectors.js.map +1 -0
  19. package/dist/esm/types.js +2 -0
  20. package/dist/esm/types.js.map +1 -0
  21. package/dist/esm/utils/enable-context.js +10 -0
  22. package/dist/esm/utils/enable-context.js.map +1 -0
  23. package/dist/esm/utils/index.js +3 -0
  24. package/dist/esm/utils/index.js.map +1 -0
  25. package/dist/esm/utils/resolve-context-from-path.js +17 -0
  26. package/dist/esm/utils/resolve-context-from-path.js.map +1 -0
  27. package/dist/esm/utils/resolve-initial-context.js +16 -0
  28. package/dist/esm/utils/resolve-initial-context.js.map +1 -0
  29. package/dist/esm/version.js +2 -0
  30. package/dist/esm/version.js.map +1 -0
  31. package/dist/tsconfig.tsbuildinfo +1 -0
  32. package/dist/types/ContextConfigBuilder.d.ts +25 -0
  33. package/dist/types/ContextProvider.d.ts +99 -0
  34. package/dist/types/client/ContextClient.d.ts +22 -0
  35. package/dist/types/configurator.d.ts +41 -0
  36. package/dist/types/errors.d.ts +8 -0
  37. package/dist/types/index.d.ts +5 -0
  38. package/dist/types/module.d.ts +20 -0
  39. package/dist/types/selectors.d.ts +4 -0
  40. package/dist/types/types.d.ts +34 -0
  41. package/dist/types/utils/enable-context.d.ts +4 -0
  42. package/dist/types/utils/index.d.ts +2 -0
  43. package/dist/types/utils/resolve-context-from-path.d.ts +8 -0
  44. package/dist/types/utils/resolve-initial-context.d.ts +7 -0
  45. package/dist/types/version.d.ts +1 -0
  46. package/package.json +65 -0
  47. package/src/ContextConfigBuilder.ts +131 -0
  48. package/src/ContextProvider.ts +555 -0
  49. package/src/client/ContextClient.ts +71 -0
  50. package/src/configurator.ts +158 -0
  51. package/src/errors.ts +19 -0
  52. package/src/index.ts +18 -0
  53. package/src/module.ts +91 -0
  54. package/src/selectors.ts +41 -0
  55. package/src/types.ts +33 -0
  56. package/src/utils/enable-context.ts +31 -0
  57. package/src/utils/index.ts +2 -0
  58. package/src/utils/resolve-context-from-path.ts +34 -0
  59. package/src/utils/resolve-initial-context.ts +29 -0
  60. package/src/version.ts +2 -0
  61. package/tsconfig.json +33 -0
@@ -0,0 +1,99 @@
1
+ import { Observable, Subscription } from 'rxjs';
2
+ import { ContextModuleConfig } from './configurator';
3
+ import { ContextClient } from './client/ContextClient';
4
+ import { ContextItem, QueryContextParameters, RelatedContextParameters } from './types';
5
+ import { ModuleType } from '@equinor/fusion-framework-module';
6
+ import { EventModule, FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framework-module-event';
7
+ import Query from '@equinor/fusion-query';
8
+ export interface IContextProvider {
9
+ readonly contextClient: ContextClient;
10
+ readonly queryClient: Query<ContextItem[], QueryContextParameters>;
11
+ readonly currentContext$: Observable<ContextItem | null | undefined>;
12
+ currentContext: ContextItem | null | undefined;
13
+ queryContext(search: string): Observable<Array<ContextItem>>;
14
+ queryContextAsync(search: string): Promise<Array<ContextItem>>;
15
+ validateContext(item: ContextItem<Record<string, unknown>>): boolean;
16
+ resolveContext: (current: ContextItem) => Observable<ContextItem>;
17
+ resolveContextAsync: (current: ContextItem) => Promise<ContextItem>;
18
+ relatedContexts: (args: RelatedContextParameters) => Observable<Array<ContextItem<Record<string, unknown>>>>;
19
+ relatedContextsAsync: (args: RelatedContextParameters) => Promise<Array<ContextItem<Record<string, unknown>>>>;
20
+ clearCurrentContext: VoidFunction;
21
+ setCurrentContextById(id: string): Observable<ContextItem<Record<string, unknown>>>;
22
+ setCurrentContextByIdAsync(id: string): Promise<ContextItem<Record<string, unknown>>>;
23
+ setCurrentContext(context: ContextItem<Record<string, unknown>> | null, opt?: {
24
+ validate?: boolean;
25
+ resolve?: boolean;
26
+ }): Observable<ContextItem<Record<string, unknown>> | null>;
27
+ setCurrentContextAsync(context: ContextItem<Record<string, unknown>> | null, opt?: {
28
+ validate?: boolean;
29
+ resolve?: boolean;
30
+ }): Promise<ContextItem<Record<string, unknown>> | null>;
31
+ }
32
+ export declare class ContextProvider implements IContextProvider {
33
+ #private;
34
+ get contextClient(): ContextClient;
35
+ get queryClient(): Query<ContextItem[], QueryContextParameters>;
36
+ get currentContext$(): Observable<ContextItem | null | undefined>;
37
+ get currentContext(): ContextItem | undefined | null;
38
+ set currentContext(context: ContextItem | null | undefined);
39
+ constructor(args: {
40
+ config: ContextModuleConfig;
41
+ event?: ModuleType<EventModule>;
42
+ parentContext?: IContextProvider;
43
+ });
44
+ connectParentContext(provider: IContextProvider, opt?: {
45
+ skipFirst: boolean;
46
+ }): Subscription;
47
+ setCurrentContextById(id: string): Observable<ContextItem<Record<string, unknown>>>;
48
+ setCurrentContextByIdAsync(id: string): Promise<ContextItem<Record<string, unknown>>>;
49
+ setCurrentContext<T extends ContextItem<Record<string, unknown>> | null>(context: T, opt?: {
50
+ validate?: boolean;
51
+ resolve?: boolean;
52
+ }): Observable<T>;
53
+ protected _setCurrentContext<T extends ContextItem<Record<string, unknown>> | null>(context: T, opt?: {
54
+ validate?: boolean;
55
+ resolve?: boolean;
56
+ }): Observable<T>;
57
+ setCurrentContextAsync<T extends ContextItem<Record<string, unknown>> | null>(context: T, opt?: {
58
+ validate?: boolean;
59
+ resolve?: boolean;
60
+ }): Promise<T>;
61
+ queryContext(search: string): Observable<Array<ContextItem>>;
62
+ queryContextAsync(search: string): Promise<Array<ContextItem>>;
63
+ validateContext(item: ContextItem<Record<string, unknown>>): boolean;
64
+ resolveContext(item: ContextItem<Record<string, unknown>>): Observable<ContextItem<Record<string, unknown>>>;
65
+ resolveContextAsync(item: ContextItem<Record<string, unknown>>): Promise<ContextItem<Record<string, unknown>>>;
66
+ relatedContexts(args: RelatedContextParameters): Observable<Array<ContextItem<Record<string, unknown>>>>;
67
+ relatedContextsAsync(args: RelatedContextParameters): Promise<Array<ContextItem<Record<string, unknown>>>>;
68
+ clearCurrentContext(): void;
69
+ dispose(): void;
70
+ }
71
+ export default ContextProvider;
72
+ declare module '@equinor/fusion-framework-module-event' {
73
+ interface FrameworkEventMap {
74
+ onCurrentContextChange: FrameworkEvent<FrameworkEventInit<{
75
+ context: ContextItem | null;
76
+ }, IContextProvider>>;
77
+ onCurrentContextChanged: FrameworkEvent<FrameworkEventInit<{
78
+ next: ContextItem | null;
79
+ previous?: ContextItem | null;
80
+ }, IContextProvider>>;
81
+ onParentContextChanged: FrameworkEvent<FrameworkEventInit<{
82
+ context: ContextItem | null;
83
+ }, IContextProvider>>;
84
+ onSetContextResolve: FrameworkEvent<FrameworkEventInit<{
85
+ context: ContextItem;
86
+ }, IContextProvider>>;
87
+ onSetContextResolved: FrameworkEvent<FrameworkEventInit<{
88
+ context: ContextItem;
89
+ resolved?: ContextItem | null;
90
+ }, IContextProvider>>;
91
+ onSetContextValidationFailed: FrameworkEvent<FrameworkEventInit<{
92
+ context: ContextItem;
93
+ }, IContextProvider>>;
94
+ onSetContextResolveFailed: FrameworkEvent<FrameworkEventInit<{
95
+ context: ContextItem;
96
+ error: unknown;
97
+ }, IContextProvider>>;
98
+ }
99
+ }
@@ -0,0 +1,22 @@
1
+ import { Observable } from 'rxjs';
2
+ import { Query, QueryCtorOptions } from '@equinor/fusion-query';
3
+ import { ContextItem } from '../types';
4
+ export type GetContextParameters = {
5
+ id: string;
6
+ };
7
+ export declare class ContextClient extends Observable<ContextItem | null> {
8
+ #private;
9
+ get currentContext(): ContextItem | null | undefined;
10
+ get currentContext$(): Observable<ContextItem | null | undefined>;
11
+ get client(): Query<ContextItem, {
12
+ id: string;
13
+ }>;
14
+ constructor(options: QueryCtorOptions<ContextItem, GetContextParameters>);
15
+ setCurrentContext(idOrItem?: string | ContextItem | null): void;
16
+ resolveContext(id: string): Observable<ContextItem>;
17
+ resolveContextAsync(id: string, opt?: {
18
+ awaitResolve: boolean;
19
+ }): Promise<ContextItem>;
20
+ dispose(): void;
21
+ }
22
+ export default ContextClient;
@@ -0,0 +1,41 @@
1
+ import { ObservableInput } from 'rxjs';
2
+ import { AnyModuleInstance, ModuleInitializerArgs, ModuleInstance } from '@equinor/fusion-framework-module';
3
+ import { ServicesModule, IApiProvider } from '@equinor/fusion-framework-module-services';
4
+ import { NavigationModule } from '@equinor/fusion-framework-module-navigation';
5
+ import { QueryCtorOptions } from '@equinor/fusion-query';
6
+ import { ContextFilterFn, ContextItem, QueryContextParameters, RelatedContextParameters } from './types';
7
+ import { GetContextParameters } from './client/ContextClient';
8
+ import { ContextConfigBuilderCallback } from './ContextConfigBuilder';
9
+ import { type IContextProvider } from './ContextProvider';
10
+ export interface ContextModuleConfig {
11
+ client: {
12
+ get: QueryCtorOptions<ContextItem, GetContextParameters>;
13
+ query: QueryCtorOptions<ContextItem[], QueryContextParameters>;
14
+ related?: QueryCtorOptions<ContextItem[], RelatedContextParameters>;
15
+ };
16
+ contextType?: string[];
17
+ contextFilter?: ContextFilterFn;
18
+ connectParentContext?: boolean;
19
+ skipInitialContext?: boolean;
20
+ contextParameterFn?: (args: {
21
+ search: string;
22
+ type: ContextModuleConfig['contextType'];
23
+ }) => string | QueryContextParameters;
24
+ resolveContext?: (this: IContextProvider, item: ContextItem | null) => ReturnType<IContextProvider['resolveContext']>;
25
+ validateContext?: (this: IContextProvider, item: ContextItem | null) => ReturnType<IContextProvider['validateContext']>;
26
+ resolveInitialContext?: (args: {
27
+ ref?: AnyModuleInstance | any;
28
+ modules: ModuleInstance;
29
+ }) => ObservableInput<ContextItem | void>;
30
+ }
31
+ export interface IContextModuleConfigurator {
32
+ addConfigBuilder: (init: ContextConfigBuilderCallback) => void;
33
+ }
34
+ export declare class ContextModuleConfigurator implements IContextModuleConfigurator {
35
+ #private;
36
+ defaultExpireTime: number;
37
+ addConfigBuilder(init: ContextConfigBuilderCallback): void;
38
+ protected _getServiceProvider(init: ModuleInitializerArgs<IContextModuleConfigurator, [ServicesModule]>): Promise<IApiProvider>;
39
+ createConfig(init: ModuleInitializerArgs<IContextModuleConfigurator, [ServicesModule, NavigationModule]>): Promise<ContextModuleConfig>;
40
+ }
41
+ export default ContextModuleConfigurator;
@@ -0,0 +1,8 @@
1
+ export declare class FusionContextSearchError extends Error {
2
+ #private;
3
+ get title(): string;
4
+ constructor(details: {
5
+ title: string;
6
+ description?: string;
7
+ }, options?: ErrorOptions);
8
+ }
@@ -0,0 +1,5 @@
1
+ export { ContextModuleConfigurator, IContextModuleConfigurator, ContextModuleConfig, } from './configurator';
2
+ export { IContextProvider, ContextProvider } from './ContextProvider';
3
+ export { default, ContextModule, module as contextModule, moduleKey as contextModuleKey, } from './module';
4
+ export { enableContext } from './utils/enable-context';
5
+ export * from './types';
@@ -0,0 +1,20 @@
1
+ import { Module } from '@equinor/fusion-framework-module';
2
+ import { EventModule } from '@equinor/fusion-framework-module-event';
3
+ import { ServicesModule } from '@equinor/fusion-framework-module-services';
4
+ import { NavigationModule } from '@equinor/fusion-framework-module-navigation';
5
+ import { IContextModuleConfigurator } from './configurator';
6
+ import { IContextProvider } from './ContextProvider';
7
+ export type ContextModuleKey = 'context';
8
+ export declare const moduleKey: ContextModuleKey;
9
+ export type ContextModule = Module<ContextModuleKey, IContextProvider, IContextModuleConfigurator, [
10
+ ServicesModule,
11
+ EventModule,
12
+ NavigationModule
13
+ ]>;
14
+ export declare const module: ContextModule;
15
+ declare module '@equinor/fusion-framework-module' {
16
+ interface Modules {
17
+ context: ContextModule;
18
+ }
19
+ }
20
+ export default module;
@@ -0,0 +1,4 @@
1
+ import type { ContextItem } from './types';
2
+ export declare const getContextSelector: (response: Response) => Promise<ContextItem>;
3
+ export declare const queryContextSelector: (response: Response) => Promise<ContextItem[]>;
4
+ export declare const relatedContextSelector: (response: Response) => Promise<ContextItem[]>;
@@ -0,0 +1,34 @@
1
+ export type ContextItem<TType extends Record<string, unknown> = Record<string, unknown>> = {
2
+ id: string;
3
+ externalId?: string;
4
+ source?: string;
5
+ type: ContextItemType;
6
+ value: TType;
7
+ title?: string;
8
+ subTitle?: string;
9
+ isActive?: boolean;
10
+ isDeleted?: boolean;
11
+ created?: Date;
12
+ updated?: Date;
13
+ graphic?: string;
14
+ meta?: string;
15
+ };
16
+ export interface ContextItemType {
17
+ id: string;
18
+ isChildType?: boolean;
19
+ parentTypeIds?: string[];
20
+ }
21
+ export type QueryContextParameters = {
22
+ search?: string;
23
+ filter?: {
24
+ type?: string[];
25
+ externalId?: string;
26
+ };
27
+ };
28
+ export type RelatedContextParameters = {
29
+ item: ContextItem;
30
+ filter?: {
31
+ type?: string[];
32
+ };
33
+ };
34
+ export type ContextFilterFn = (items: ContextItem[]) => ContextItem[];
@@ -0,0 +1,4 @@
1
+ import type { IModulesConfigurator, AnyModule, ModuleInitializerArgs } from '@equinor/fusion-framework-module';
2
+ import type { IContextModuleConfigurator } from '../configurator';
3
+ import type { ContextConfigBuilder } from '../ContextConfigBuilder';
4
+ export declare const enableContext: (configurator: IModulesConfigurator<any, any>, builder?: (<TDeps extends AnyModule[] = []>(builder: ContextConfigBuilder<TDeps, ModuleInitializerArgs<IContextModuleConfigurator, TDeps>>) => void | Promise<void>) | undefined) => void;
@@ -0,0 +1,2 @@
1
+ export { enableContext } from './enable-context';
2
+ export { resolveInitialContext } from './resolve-initial-context';
@@ -0,0 +1,8 @@
1
+ import { ModuleType } from '@equinor/fusion-framework-module';
2
+ import { type ContextModule } from '../module';
3
+ export type ContextPathResolveArgs = {
4
+ extract?: (path: string) => string | undefined;
5
+ validate?: (contextId: string) => boolean;
6
+ };
7
+ export declare const resolveContextFromPath: (context: ModuleType<ContextModule>, args?: ContextPathResolveArgs) => (path: string) => import("rxjs").Observable<import("..").ContextItem>;
8
+ export default resolveContextFromPath;
@@ -0,0 +1,7 @@
1
+ import { type ContextModuleConfig } from '../configurator';
2
+ import { ContextPathResolveArgs } from './resolve-context-from-path';
3
+ export declare const resolveContextFromParent: ContextModuleConfig['resolveInitialContext'];
4
+ export declare const resolveInitialContext: (options?: {
5
+ path?: ContextPathResolveArgs;
6
+ }) => Required<ContextModuleConfig>['resolveInitialContext'];
7
+ export default resolveInitialContext;
@@ -0,0 +1 @@
1
+ export declare const version = "4.0.19";
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@equinor/fusion-framework-module-context",
3
+ "version": "0.0.0-context-error-20240131144633",
4
+ "description": "",
5
+ "main": "./dist/esm/index.js",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/esm/index.js",
9
+ "types": "./dist/types/index.d.ts"
10
+ },
11
+ "./errors.js": {
12
+ "import": "./dist/esm/errors.js",
13
+ "types": "./dist/types/errors.d.ts"
14
+ },
15
+ "./package.json": "./package.json",
16
+ "./utils": {
17
+ "import": "./dist/esm/utils/index.js",
18
+ "types": "./dist/types/utils/index.d.ts"
19
+ }
20
+ },
21
+ "types": "index.d.ts",
22
+ "typesVersions": {
23
+ ">=4.2": {
24
+ "*": [
25
+ "dist/types/*"
26
+ ],
27
+ "utils": [
28
+ "dist/types/utils/index.d.ts"
29
+ ],
30
+ "./errors.js": [
31
+ ".dist/types/errors.d.ts"
32
+ ]
33
+ }
34
+ },
35
+ "keywords": [],
36
+ "author": "",
37
+ "license": "ISC",
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/equinor/fusion-framework.git",
44
+ "directory": "packages/modules/context"
45
+ },
46
+ "dependencies": {
47
+ "fast-deep-equal": "^3.1.3",
48
+ "@equinor/fusion-query": "^4.0.5"
49
+ },
50
+ "devDependencies": {
51
+ "rxjs": "^7.8.1",
52
+ "typescript": "^5.1.3",
53
+ "@equinor/fusion-framework-module": "^4.2.6",
54
+ "@equinor/fusion-framework-module-event": "^4.0.7",
55
+ "@equinor/fusion-framework-module-navigation": "^3.1.3",
56
+ "@equinor/fusion-framework-module-services": "^3.2.3"
57
+ },
58
+ "peerDependencies": {
59
+ "rxjs": "^7.8.1",
60
+ "@equinor/fusion-framework-module": "^4.2.6"
61
+ },
62
+ "scripts": {
63
+ "build": "tsc -b"
64
+ }
65
+ }
@@ -0,0 +1,131 @@
1
+ import type {
2
+ AnyModule,
3
+ ModuleInitializerArgs,
4
+ Modules,
5
+ ModuleType,
6
+ } from '@equinor/fusion-framework-module';
7
+
8
+ import type { QueryCtorOptions, QueryFn } from '@equinor/fusion-query';
9
+
10
+ import type { GetContextParameters } from './client/ContextClient';
11
+
12
+ import type {
13
+ ContextModuleConfig,
14
+ ContextModuleConfigurator,
15
+ IContextModuleConfigurator,
16
+ } from './configurator';
17
+
18
+ import type { ContextItem, QueryContextParameters, RelatedContextParameters } from './types';
19
+
20
+ export type ContextConfigBuilderCallback = <TDeps extends Array<AnyModule> = []>(
21
+ builder: ContextConfigBuilder<TDeps, ModuleInitializerArgs<IContextModuleConfigurator, TDeps>>,
22
+ ) => void | Promise<void>;
23
+
24
+ export class ContextConfigBuilder<
25
+ TModules extends Array<AnyModule> = [],
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+ TInit extends ModuleInitializerArgs<any, any> = ModuleInitializerArgs<
28
+ ContextModuleConfigurator,
29
+ TModules
30
+ >,
31
+ > {
32
+ #init: TInit;
33
+ constructor(
34
+ init: TInit,
35
+ public config: Partial<ContextModuleConfig> = {},
36
+ ) {
37
+ this.#init = init;
38
+ }
39
+
40
+ requireInstance<TKey extends string = Extract<keyof Modules, string>>(
41
+ module: TKey,
42
+ ): Promise<ModuleType<Modules[TKey]>>;
43
+
44
+ requireInstance<T>(module: string): Promise<T>;
45
+
46
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
+ requireInstance(module: string): Promise<any> {
48
+ return this.#init.requireInstance(module);
49
+ }
50
+
51
+ setContextType(type: ContextModuleConfig['contextType']) {
52
+ this.config.contextType = type;
53
+ }
54
+
55
+ setContextFilter(filter: ContextModuleConfig['contextFilter']) {
56
+ this.config.contextFilter = filter;
57
+ }
58
+
59
+ connectParentContext(connect: ContextModuleConfig['connectParentContext']) {
60
+ this.config.connectParentContext = connect;
61
+ }
62
+
63
+ setContextParameterFn(fn: ContextModuleConfig['contextParameterFn']) {
64
+ this.config.contextParameterFn = fn;
65
+ }
66
+
67
+ setValidateContext(fn: ContextModuleConfig['validateContext']) {
68
+ this.config.validateContext = fn;
69
+ }
70
+
71
+ setResolveContext(fn: ContextModuleConfig['resolveContext']) {
72
+ this.config.resolveContext = fn;
73
+ }
74
+
75
+ setResolveInitialContext(fn: ContextModuleConfig['resolveInitialContext']) {
76
+ this.config.resolveInitialContext = fn;
77
+ }
78
+
79
+ setContextClient(
80
+ client: {
81
+ get:
82
+ | QueryFn<ContextItem, GetContextParameters>
83
+ | QueryCtorOptions<ContextItem, GetContextParameters>;
84
+ query:
85
+ | QueryFn<ContextItem[], QueryContextParameters>
86
+ | QueryCtorOptions<ContextItem[], QueryContextParameters>;
87
+ related?:
88
+ | QueryFn<ContextItem[], RelatedContextParameters>
89
+ | QueryCtorOptions<ContextItem[], RelatedContextParameters>;
90
+ },
91
+ expire = 1 * 60 * 1000,
92
+ ): void {
93
+ this.config.client = {
94
+ get:
95
+ typeof client.get === 'function'
96
+ ? {
97
+ key: ({ id }) => id,
98
+ client: {
99
+ fn: client.get,
100
+ },
101
+ expire,
102
+ }
103
+ : client.get,
104
+ query:
105
+ typeof client.query === 'function'
106
+ ? {
107
+ // TODO - might cast to checksum
108
+ key: (args) => JSON.stringify(args),
109
+ client: {
110
+ fn: client.query,
111
+ },
112
+ expire,
113
+ }
114
+ : client.query,
115
+ };
116
+ if (client.related) {
117
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
118
+ this.config.client!.related =
119
+ typeof client.related === 'function'
120
+ ? {
121
+ // TODO - might cast to checksum
122
+ key: (args) => JSON.stringify(args),
123
+ client: {
124
+ fn: client.related,
125
+ },
126
+ expire,
127
+ }
128
+ : client.related;
129
+ }
130
+ }
131
+ }