@equinor/fusion-framework-module-context
Advanced tools
Comparing version 1.1.9 to 1.1.10
@@ -6,2 +6,9 @@ # Change Log | ||
## [1.1.10](https://github.com/equinor/fusion-framework/compare/@equinor/fusion-framework-module-context@1.1.9...@equinor/fusion-framework-module-context@1.1.10) (2022-12-12) | ||
### Bug Fixes | ||
- **context:** method for contextParameterFn on enableContext ([398658d](https://github.com/equinor/fusion-framework/commit/398658de26355a8ca99aea291963b8c302df3ddc)) | ||
- linting issues fixed ([2e62877](https://github.com/equinor/fusion-framework/commit/2e628770754b40425e97c7be2ec770824c42c6ff)) | ||
## [1.1.9](https://github.com/equinor/fusion-framework/compare/@equinor/fusion-framework-module-context@1.1.8...@equinor/fusion-framework-module-context@1.1.9) (2022-12-12) | ||
@@ -8,0 +15,0 @@ |
@@ -28,2 +28,5 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
} | ||
setContextParameterFn(fn) { | ||
this.config.contextParameterFn = fn; | ||
} | ||
setContextClient(client, expire = 1 * 60 * 1000) { | ||
@@ -30,0 +33,0 @@ this.config.client = { |
@@ -12,3 +12,3 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
}; | ||
var _ContextProvider_contextClient, _ContextProvider_contextQuery, _ContextProvider_event, _ContextProvider_subscriptions, _ContextProvider_contextType, _ContextProvider_contextFilter; | ||
var _ContextProvider_contextClient, _ContextProvider_contextQuery, _ContextProvider_event, _ContextProvider_subscriptions, _ContextProvider_contextType, _ContextProvider_contextFilter, _ContextProvider_contextParameterFn; | ||
import { lastValueFrom, Subscription } from 'rxjs'; | ||
@@ -27,8 +27,3 @@ import { map, pairwise } from 'rxjs/operators'; | ||
const query$ = this.queryClient | ||
.query({ | ||
search, | ||
filter: { | ||
type: __classPrivateFieldGet(this, _ContextProvider_contextType, "f"), | ||
}, | ||
}) | ||
.query(__classPrivateFieldGet(this, _ContextProvider_contextParameterFn, "f").call(this, { search, type: __classPrivateFieldGet(this, _ContextProvider_contextType, "f") })) | ||
.pipe(map((x) => x.value)); | ||
@@ -66,2 +61,3 @@ return __classPrivateFieldGet(this, _ContextProvider_contextFilter, "f") ? query$.pipe(map(__classPrivateFieldGet(this, _ContextProvider_contextFilter, "f"))) : query$; | ||
constructor(args) { | ||
var _a; | ||
_ContextProvider_contextClient.set(this, void 0); | ||
@@ -73,2 +69,3 @@ _ContextProvider_contextQuery.set(this, void 0); | ||
_ContextProvider_contextFilter.set(this, void 0); | ||
_ContextProvider_contextParameterFn.set(this, void 0); | ||
const { config, event, parentContext } = args; | ||
@@ -79,2 +76,6 @@ __classPrivateFieldSet(this, _ContextProvider_contextType, config.contextType, "f"); | ||
__classPrivateFieldSet(this, _ContextProvider_contextQuery, new Query(config.client.query), "f"); | ||
__classPrivateFieldSet(this, _ContextProvider_contextParameterFn, (_a = config.contextParameterFn) !== null && _a !== void 0 ? _a : ((args) => ({ | ||
search: args.search, | ||
filter: { type: args.type }, | ||
})), "f"); | ||
if (event) { | ||
@@ -105,4 +106,4 @@ __classPrivateFieldSet(this, _ContextProvider_event, event, "f"); | ||
} | ||
_ContextProvider_contextClient = new WeakMap(), _ContextProvider_contextQuery = new WeakMap(), _ContextProvider_event = new WeakMap(), _ContextProvider_subscriptions = new WeakMap(), _ContextProvider_contextType = new WeakMap(), _ContextProvider_contextFilter = new WeakMap(); | ||
_ContextProvider_contextClient = new WeakMap(), _ContextProvider_contextQuery = new WeakMap(), _ContextProvider_event = new WeakMap(), _ContextProvider_subscriptions = new WeakMap(), _ContextProvider_contextType = new WeakMap(), _ContextProvider_contextFilter = new WeakMap(), _ContextProvider_contextParameterFn = new WeakMap(); | ||
export default ContextProvider; | ||
//# sourceMappingURL=provider.js.map |
@@ -14,2 +14,6 @@ import { ModuleInitializerArgs } from '@equinor/fusion-framework-module'; | ||
contextFilter?: ContextFilterFn; | ||
contextParameterFn?: (args: { | ||
search: string; | ||
type: ContextModuleConfig['contextType']; | ||
}) => string | QueryContextParameters; | ||
} | ||
@@ -16,0 +20,0 @@ export interface IContextModuleConfigurator { |
@@ -15,2 +15,3 @@ import type { AnyModule, ModuleInitializerArgs, Modules, ModuleType } from '@equinor/fusion-framework-module'; | ||
setContextFilter(filter: ContextModuleConfig['contextFilter']): void; | ||
setContextParameterFn(fn: ContextModuleConfig['contextParameterFn']): void; | ||
setContextClient(client: { | ||
@@ -17,0 +18,0 @@ get: QueryFn<ContextItem, GetContextParameters> | QueryCtorOptions<ContextItem, GetContextParameters>; |
{ | ||
"name": "@equinor/fusion-framework-module-context", | ||
"version": "1.1.9", | ||
"version": "1.1.10", | ||
"description": "", | ||
@@ -46,3 +46,3 @@ "main": "./dist/esm/index.js", | ||
}, | ||
"gitHead": "acfc1533fae1e5a95f8463cc2d6e3a2ad94c252e" | ||
"gitHead": "6d839d4a55dad458d406b467b5723595601f960b" | ||
} |
@@ -16,2 +16,10 @@ import { ModuleInitializerArgs, ModulesInstanceType } from '@equinor/fusion-framework-module'; | ||
contextFilter?: ContextFilterFn; | ||
/** | ||
* Method for generating context query parameters. | ||
*/ | ||
contextParameterFn?: (args: { | ||
search: string; | ||
type: ContextModuleConfig['contextType']; | ||
}) => string | QueryContextParameters; | ||
} | ||
@@ -18,0 +26,0 @@ |
@@ -56,2 +56,6 @@ import type { | ||
setContextParameterFn(fn: ContextModuleConfig['contextParameterFn']) { | ||
this.config.contextParameterFn = fn; | ||
} | ||
setContextClient( | ||
@@ -58,0 +62,0 @@ client: { |
@@ -42,2 +42,3 @@ import { lastValueFrom, Observable, Subscription } from 'rxjs'; | ||
#contextFilter: ContextModuleConfig['contextFilter']; | ||
#contextParameterFn: Required<ContextModuleConfig['contextParameterFn']>; | ||
@@ -54,8 +55,8 @@ public get contextClient() { | ||
const query$ = this.queryClient | ||
.query({ | ||
search, | ||
filter: { | ||
type: this.#contextType, | ||
}, | ||
}) | ||
.query( | ||
// TODO | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
/* @ts-ignore */ | ||
this.#contextParameterFn({ search, type: this.#contextType }) | ||
) | ||
.pipe(map((x) => x.value)); | ||
@@ -111,2 +112,8 @@ | ||
this.#contextQuery = new Query(config.client.query); | ||
this.#contextParameterFn = | ||
config.contextParameterFn ?? | ||
((args: Parameters<Required<ContextModuleConfig>['contextParameterFn']>[0]) => ({ | ||
search: args.search, | ||
filter: { type: args.type }, | ||
})); | ||
@@ -113,0 +120,0 @@ if (event) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
183231
1049