@equinor/fusion-framework-module-context
Advanced tools
Comparing version 4.0.10 to 4.0.12
# Change Log | ||
## 4.0.12 | ||
### Patch Changes | ||
- Updated dependencies [[`05accaaa`](https://github.com/equinor/fusion-framework/commit/05accaaa72085b07483008fac822dd5e7c56a8b9)]: | ||
- @equinor/fusion-query@3.0.6 | ||
## 4.0.11 | ||
### Patch Changes | ||
- [#1109](https://github.com/equinor/fusion-framework/pull/1109) [`7ec195d4`](https://github.com/equinor/fusion-framework/commit/7ec195d42098fec8794db13e83b71ef7753ff862) Thanks [@odinr](https://github.com/odinr)! - Change packaged manager from yarn to pnpm | ||
conflicts of `@types/react` made random outcomes when using `yarn` | ||
this change should not affect consumer of the packages, but might conflict dependent on local package manager. | ||
- [#1145](https://github.com/equinor/fusion-framework/pull/1145) [`d276fc5d`](https://github.com/equinor/fusion-framework/commit/d276fc5d514566d05c64705076a1cb91c6a44272) Thanks [@dependabot](https://github.com/apps/dependabot)! - build(deps): bump rxjs from 7.5.7 to [7.8.1](https://github.com/ReactiveX/rxjs/blob/7.8.1/CHANGELOG.md) | ||
- Updated dependencies [[`7ec195d4`](https://github.com/equinor/fusion-framework/commit/7ec195d42098fec8794db13e83b71ef7753ff862), [`2dccccd1`](https://github.com/equinor/fusion-framework/commit/2dccccd124fbe3cdde2132c29c27d3da9fc6f1f5), [`d276fc5d`](https://github.com/equinor/fusion-framework/commit/d276fc5d514566d05c64705076a1cb91c6a44272)]: | ||
- @equinor/fusion-framework-module@4.2.3 | ||
- @equinor/fusion-query@3.0.5 | ||
## 4.0.10 | ||
@@ -4,0 +27,0 @@ |
101
package.json
{ | ||
"name": "@equinor/fusion-framework-module-context", | ||
"version": "4.0.10", | ||
"description": "", | ||
"main": "./dist/esm/index.js", | ||
"exports": { | ||
".": "./dist/esm/index.js", | ||
"./package.json": "./package.json", | ||
"./utils": "./dist/esm/utils/index.js" | ||
}, | ||
"types": "index.d.ts", | ||
"typesVersions": { | ||
">=4.2": { | ||
"*": [ | ||
"dist/types/*" | ||
], | ||
"utils": [ | ||
"dist/types/utils/index.d.ts" | ||
] | ||
} | ||
}, | ||
"scripts": { | ||
"build": "tsc -b", | ||
"prepack": "yarn build" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/equinor/fusion-framework.git", | ||
"directory": "packages/modules/context" | ||
}, | ||
"dependencies": { | ||
"@equinor/fusion-query": "^3.0.2", | ||
"fast-deep-equal": "^3.1.3" | ||
}, | ||
"devDependencies": { | ||
"@equinor/fusion-framework-module": "^4.2.1", | ||
"@equinor/fusion-framework-module-event": "^4.0.2", | ||
"@equinor/fusion-framework-module-navigation": "^3.0.1", | ||
"@equinor/fusion-framework-module-services": "^3.1.3", | ||
"rxjs": "^7.5.7", | ||
"typescript": "^5.1.3" | ||
}, | ||
"peerDependencies": { | ||
"@equinor/fusion-framework-module": ">=1.2.5", | ||
"rxjs": "^7.5.7" | ||
"name": "@equinor/fusion-framework-module-context", | ||
"version": "4.0.12", | ||
"description": "", | ||
"main": "./dist/esm/index.js", | ||
"exports": { | ||
".": "./dist/esm/index.js", | ||
"./package.json": "./package.json", | ||
"./utils": "./dist/esm/utils/index.js" | ||
}, | ||
"types": "index.d.ts", | ||
"typesVersions": { | ||
">=4.2": { | ||
"*": [ | ||
"dist/types/*" | ||
], | ||
"utils": [ | ||
"dist/types/utils/index.d.ts" | ||
] | ||
} | ||
} | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/equinor/fusion-framework.git", | ||
"directory": "packages/modules/context" | ||
}, | ||
"dependencies": { | ||
"fast-deep-equal": "^3.1.3", | ||
"@equinor/fusion-query": "^3.0.6" | ||
}, | ||
"devDependencies": { | ||
"rxjs": "^7.8.1", | ||
"typescript": "^5.1.3", | ||
"@equinor/fusion-framework-module": "^4.2.3", | ||
"@equinor/fusion-framework-module-event": "^4.0.4", | ||
"@equinor/fusion-framework-module-navigation": "^3.0.4", | ||
"@equinor/fusion-framework-module-services": "^3.1.4" | ||
}, | ||
"peerDependencies": { | ||
"rxjs": "^7.8.1", | ||
"@equinor/fusion-framework-module": "^4.2.3" | ||
}, | ||
"scripts": { | ||
"build": "tsc -b" | ||
} | ||
} |
@@ -57,3 +57,3 @@ import { Observable, BehaviorSubject, EMPTY, lastValueFrom, firstValueFrom } from 'rxjs'; | ||
throw err; | ||
}) | ||
}), | ||
); | ||
@@ -60,0 +60,0 @@ } |
@@ -53,3 +53,3 @@ import { ObservableInput } from 'rxjs'; | ||
this: IContextProvider, | ||
item: ContextItem | null | ||
item: ContextItem | null, | ||
) => ReturnType<IContextProvider['resolveContext']>; | ||
@@ -59,3 +59,3 @@ | ||
this: IContextProvider, | ||
item: ContextItem | null | ||
item: ContextItem | null, | ||
) => ReturnType<IContextProvider['validateContext']>; | ||
@@ -84,3 +84,3 @@ | ||
protected async _getServiceProvider( | ||
init: ModuleInitializerArgs<IContextModuleConfigurator, [ServicesModule]> | ||
init: ModuleInitializerArgs<IContextModuleConfigurator, [ServicesModule]>, | ||
): Promise<IApiProvider> { | ||
@@ -100,10 +100,13 @@ if (init.hasModule('services')) { | ||
public async createConfig( | ||
init: ModuleInitializerArgs<IContextModuleConfigurator, [ServicesModule, NavigationModule]> | ||
init: ModuleInitializerArgs<IContextModuleConfigurator, [ServicesModule, NavigationModule]>, | ||
): Promise<ContextModuleConfig> { | ||
const config = await this.#configBuilders.reduce(async (cur, cb) => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const builder = new ContextConfigBuilder<any, any>(init, await cur); | ||
await Promise.resolve(cb(builder)); | ||
return Object.assign(cur, builder.config); | ||
}, Promise.resolve({} as Partial<ContextModuleConfig>)); | ||
const config = await this.#configBuilders.reduce( | ||
async (cur, cb) => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const builder = new ContextConfigBuilder<any, any>(init, await cur); | ||
await Promise.resolve(cb(builder)); | ||
return Object.assign(cur, builder.config); | ||
}, | ||
Promise.resolve({} as Partial<ContextModuleConfig>), | ||
); | ||
@@ -131,3 +134,3 @@ config.resolveInitialContext ??= resolveInitialContext(); | ||
{ query }, | ||
{ selector: queryContextSelector } | ||
{ selector: queryContextSelector }, | ||
), | ||
@@ -145,3 +148,3 @@ }, | ||
{ id: args.item.id, query: { filter: args.filter } }, | ||
{ selector: relatedContextSelector } | ||
{ selector: relatedContextSelector }, | ||
); | ||
@@ -148,0 +151,0 @@ }, |
@@ -21,3 +21,3 @@ import type { | ||
export type ContextConfigBuilderCallback = <TDeps extends Array<AnyModule> = []>( | ||
builder: ContextConfigBuilder<TDeps, ModuleInitializerArgs<IContextModuleConfigurator, TDeps>> | ||
builder: ContextConfigBuilder<TDeps, ModuleInitializerArgs<IContextModuleConfigurator, TDeps>>, | ||
) => void | Promise<void>; | ||
@@ -31,6 +31,9 @@ | ||
TModules | ||
> | ||
>, | ||
> { | ||
#init: TInit; | ||
constructor(init: TInit, public config: Partial<ContextModuleConfig> = {}) { | ||
constructor( | ||
init: TInit, | ||
public config: Partial<ContextModuleConfig> = {}, | ||
) { | ||
this.#init = init; | ||
@@ -40,3 +43,3 @@ } | ||
requireInstance<TKey extends string = Extract<keyof Modules, string>>( | ||
module: TKey | ||
module: TKey, | ||
): Promise<ModuleType<Modules[TKey]>>; | ||
@@ -91,3 +94,3 @@ | ||
}, | ||
expire = 1 * 60 * 1000 | ||
expire = 1 * 60 * 1000, | ||
): void { | ||
@@ -94,0 +97,0 @@ this.config.client = { |
@@ -43,6 +43,6 @@ import { EMPTY, lastValueFrom, Observable, of, Subject, Subscription, throwError } from 'rxjs'; | ||
relatedContexts: ( | ||
args: RelatedContextParameters | ||
args: RelatedContextParameters, | ||
) => Observable<Array<ContextItem<Record<string, unknown>>>>; | ||
relatedContextsAsync: ( | ||
args: RelatedContextParameters | ||
args: RelatedContextParameters, | ||
) => Promise<Array<ContextItem<Record<string, unknown>>>>; | ||
@@ -56,3 +56,3 @@ clearCurrentContext: VoidFunction; | ||
context: ContextItem<Record<string, unknown>> | null, | ||
opt?: { validate?: boolean; resolve?: boolean } | ||
opt?: { validate?: boolean; resolve?: boolean }, | ||
): Observable<ContextItem<Record<string, unknown>> | null>; | ||
@@ -62,3 +62,3 @@ | ||
context: ContextItem<Record<string, unknown>> | null, | ||
opt?: { validate?: boolean; resolve?: boolean } | ||
opt?: { validate?: boolean; resolve?: boolean }, | ||
): Promise<ContextItem<Record<string, unknown>> | null>; | ||
@@ -103,3 +103,3 @@ } | ||
'ContextProvider.currentContext', | ||
'use setCurrentContextById|setCurrentContext|clearCurrentContext' | ||
'use setCurrentContextById|setCurrentContext|clearCurrentContext', | ||
); | ||
@@ -123,3 +123,3 @@ if (context === undefined) { | ||
'@deprecated', | ||
'parentContext as arg is deprecated, use ContextProvider.connectParentContext' | ||
'parentContext as arg is deprecated, use ContextProvider.connectParentContext', | ||
); | ||
@@ -158,3 +158,3 @@ } | ||
}); | ||
}) | ||
}), | ||
); | ||
@@ -168,3 +168,3 @@ this.#subscriptions.add( | ||
} | ||
}) | ||
}), | ||
); | ||
@@ -177,5 +177,5 @@ } | ||
switchMap((next) => next), | ||
tap((x) => console.debug('ContextProvider::#contextQueue', x)) | ||
tap((x) => console.debug('ContextProvider::#contextQueue', x)), | ||
) | ||
.subscribe((context) => this.#contextClient.setCurrentContext(context ?? null)) | ||
.subscribe((context) => this.#contextClient.setCurrentContext(context ?? null)), | ||
); | ||
@@ -186,3 +186,3 @@ } | ||
provider: IContextProvider, | ||
opt?: { skipFirst: boolean } | ||
opt?: { skipFirst: boolean }, | ||
): Subscription { | ||
@@ -197,3 +197,3 @@ const parentContext$ = provider.currentContext$.pipe( | ||
'skipping first item', | ||
next | ||
next, | ||
); | ||
@@ -212,3 +212,3 @@ return false; | ||
cancelable: true, | ||
} | ||
}, | ||
); | ||
@@ -229,6 +229,6 @@ return { next, canceled: onParentContextChanged?.canceled }; | ||
'setCurrentContext', | ||
err | ||
err, | ||
); | ||
return EMPTY; | ||
}) | ||
}), | ||
); | ||
@@ -239,3 +239,3 @@ }), | ||
return EMPTY; | ||
}) | ||
}), | ||
); | ||
@@ -255,3 +255,3 @@ | ||
filter((item): item is ContextItem => !!item), | ||
switchMap((item) => this.setCurrentContext(item)) | ||
switchMap((item) => this.setCurrentContext(item)), | ||
) | ||
@@ -282,3 +282,3 @@ .subscribe(subscriber); | ||
context: T, | ||
opt?: { validate?: boolean; resolve?: boolean } | ||
opt?: { validate?: boolean; resolve?: boolean }, | ||
): Observable<T> { | ||
@@ -304,3 +304,3 @@ /** signal for aborting the queue entry */ | ||
return EMPTY; | ||
}) | ||
}), | ||
); | ||
@@ -313,3 +313,3 @@ | ||
/** if caller subscribes, unsubscribe should abort queue entry */ | ||
finalize(() => abort$.next(true)) | ||
finalize(() => abort$.next(true)), | ||
); | ||
@@ -320,3 +320,3 @@ } | ||
context: T, | ||
opt?: { validate?: boolean; resolve?: boolean } | ||
opt?: { validate?: boolean; resolve?: boolean }, | ||
): Observable<T> { | ||
@@ -348,3 +348,3 @@ return new Observable((subscriber) => { | ||
detail: { context }, | ||
} | ||
}, | ||
); | ||
@@ -362,4 +362,4 @@ if (event?.canceled) { | ||
resolved, | ||
})) | ||
) | ||
})), | ||
), | ||
), | ||
@@ -374,3 +374,3 @@ /** notify event observers that context was resolved */ | ||
detail: { context, resolved }, | ||
} | ||
}, | ||
); | ||
@@ -384,4 +384,4 @@ if (event?.canceled) { | ||
switchMap((resolved) => | ||
this._setCurrentContext(resolved as unknown as T) | ||
) | ||
this._setCurrentContext(resolved as unknown as T), | ||
), | ||
) | ||
@@ -407,3 +407,3 @@ .subscribe(subscriber); | ||
return context; | ||
}) | ||
}), | ||
) | ||
@@ -419,3 +419,3 @@ .subscribe((context) => { | ||
context: T, | ||
opt?: { validate?: boolean; resolve?: boolean } | ||
opt?: { validate?: boolean; resolve?: boolean }, | ||
): Promise<T> { | ||
@@ -431,3 +431,3 @@ return lastValueFrom(this.setCurrentContext(context, opt)); | ||
/* @ts-ignore */ | ||
this.#contextParameterFn({ search, type: this.#contextType }) | ||
this.#contextParameterFn({ search, type: this.#contextType }), | ||
) | ||
@@ -449,3 +449,3 @@ .pipe(map((x) => x.value)); | ||
public resolveContext( | ||
item: ContextItem<Record<string, unknown>> | ||
item: ContextItem<Record<string, unknown>>, | ||
): Observable<ContextItem<Record<string, unknown>>> { | ||
@@ -463,7 +463,7 @@ return this.relatedContexts({ item, filter: { type: this.#contextType } }).pipe( | ||
'multiple items found 🤣', | ||
values | ||
values, | ||
); | ||
} | ||
return value; | ||
}) | ||
}), | ||
); | ||
@@ -473,3 +473,3 @@ } | ||
public resolveContextAsync( | ||
item: ContextItem<Record<string, unknown>> | ||
item: ContextItem<Record<string, unknown>>, | ||
): Promise<ContextItem<Record<string, unknown>>> { | ||
@@ -480,3 +480,3 @@ return lastValueFrom(this.resolveContext(item)); | ||
public relatedContexts( | ||
args: RelatedContextParameters | ||
args: RelatedContextParameters, | ||
): Observable<Array<ContextItem<Record<string, unknown>>>> { | ||
@@ -486,4 +486,4 @@ if (!this.#contextRelated) { | ||
Error( | ||
'ContextProvider::relatedContexts - no client defined for resolving related context' | ||
) | ||
'ContextProvider::relatedContexts - no client defined for resolving related context', | ||
), | ||
); | ||
@@ -498,3 +498,3 @@ } | ||
throw err; | ||
}) | ||
}), | ||
); | ||
@@ -504,3 +504,3 @@ } | ||
public relatedContextsAsync( | ||
args: RelatedContextParameters | ||
args: RelatedContextParameters, | ||
): Promise<Array<ContextItem<Record<string, unknown>>>> { | ||
@@ -507,0 +507,0 @@ return lastValueFrom(this.relatedContexts(args)); |
@@ -11,3 +11,3 @@ import { catchError, EMPTY, from, Observable, switchMap, filter, Subscription } from 'rxjs'; | ||
import { IContextProvider, ContextProvider } from './ContextProvider'; | ||
import { ContextItem } from 'types'; | ||
import { ContextItem } from './types'; | ||
@@ -45,4 +45,4 @@ export type ContextModuleKey = 'context'; | ||
resolve: true, | ||
}) | ||
) | ||
}), | ||
), | ||
) | ||
@@ -58,6 +58,6 @@ : EMPTY; | ||
'failed to resolve initial context', | ||
err | ||
err, | ||
); | ||
return EMPTY; | ||
}) | ||
}), | ||
) | ||
@@ -69,3 +69,3 @@ .subscribe({ | ||
`initial context was resolved to [${item ? item.id : 'none'}]`, | ||
item | ||
item, | ||
); | ||
@@ -79,3 +79,3 @@ }, | ||
}, | ||
}) | ||
}), | ||
); | ||
@@ -82,0 +82,0 @@ }); |
@@ -22,4 +22,4 @@ import type { | ||
ModuleInitializerArgs<IContextModuleConfigurator, TDeps> | ||
> | ||
) => void | Promise<void> | ||
>, | ||
) => void | Promise<void>, | ||
): void => { | ||
@@ -26,0 +26,0 @@ configurator.addConfig({ |
@@ -25,3 +25,3 @@ import { ModulesInstance } from '@equinor/fusion-framework-module'; | ||
navigation ? pathResolver(navigation.path.pathname) : EMPTY, | ||
resolveContextFromParent({ ref, modules }) | ||
resolveContextFromParent({ ref, modules }), | ||
).pipe(first()); | ||
@@ -28,0 +28,0 @@ }; |
@@ -7,3 +7,3 @@ { | ||
"declarationDir": "./dist/types", | ||
"baseUrl": "src", | ||
}, | ||
@@ -10,0 +10,0 @@ "references": [ |
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
Mixed license
License(Experimental) Package contains multiple licenses.
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
57
2000
267945
1
Updated@equinor/fusion-query@^3.0.6