mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Cleanup types to remove multiple cast locations
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
337189bc32
commit
4caf77aec6
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type Config from "conf";
|
import type Config from "conf";
|
||||||
import type { Options as ConfOptions } from "conf/dist/source/types";
|
import type { Migrations, Options as ConfOptions } from "conf/dist/source/types";
|
||||||
import type { IEqualsComparer } from "mobx";
|
import type { IEqualsComparer } from "mobx";
|
||||||
import { reaction } from "mobx";
|
import { reaction } from "mobx";
|
||||||
import { disposer, isPromiseLike } from "@k8slens/utilities";
|
import { disposer, isPromiseLike } from "@k8slens/utilities";
|
||||||
@ -18,13 +18,15 @@ import type { GetBasenameOfPath } from "../path/get-basename.injectable";
|
|||||||
import type { EnlistMessageChannelListener } from "@k8slens/messaging";
|
import type { EnlistMessageChannelListener } from "@k8slens/messaging";
|
||||||
import { toJS } from "../utils";
|
import { toJS } from "../utils";
|
||||||
|
|
||||||
export interface BaseStoreParams<T> extends ConfOptions<T> {
|
export interface BaseStoreParams<T> extends Omit<ConfOptions<T>, "migrations"> {
|
||||||
syncOptions?: {
|
syncOptions?: {
|
||||||
fireImmediately?: boolean;
|
fireImmediately?: boolean;
|
||||||
equals?: IEqualsComparer<T>;
|
equals?: IEqualsComparer<T>;
|
||||||
};
|
};
|
||||||
readonly configName: string;
|
readonly configName: string;
|
||||||
|
|
||||||
|
migrations?: Migrations<Record<string, unknown>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fromStore is called internally when a child class syncs with the file
|
* fromStore is called internally when a child class syncs with the file
|
||||||
* system.
|
* system.
|
||||||
@ -85,7 +87,7 @@ export class BaseStore<T extends object> {
|
|||||||
const config = this.dependencies.getConfigurationFileModel({
|
const config = this.dependencies.getConfigurationFileModel({
|
||||||
projectName: "lens",
|
projectName: "lens",
|
||||||
cwd: this.cwd(),
|
cwd: this.cwd(),
|
||||||
...this.params,
|
...this.params as ConfOptions<T>,
|
||||||
});
|
});
|
||||||
|
|
||||||
const res = this.params.fromStore(config.store);
|
const res = this.params.fromStore(config.store);
|
||||||
|
|||||||
@ -40,7 +40,7 @@ export class ClusterStore {
|
|||||||
equals: comparer.structural,
|
equals: comparer.structural,
|
||||||
},
|
},
|
||||||
projectVersion: this.dependencies.storeMigrationVersion,
|
projectVersion: this.dependencies.storeMigrationVersion,
|
||||||
migrations: this.dependencies.migrations as unknown as Migrations<ClusterStoreModel>,
|
migrations: this.dependencies.migrations,
|
||||||
fromStore: action(({ clusters = [] }) => {
|
fromStore: action(({ clusters = [] }) => {
|
||||||
const currentClusters = new Map(this.clusters);
|
const currentClusters = new Map(this.clusters);
|
||||||
const newClusters = new Map<ClusterId, Cluster>();
|
const newClusters = new Map<ClusterId, Cluster>();
|
||||||
|
|||||||
@ -39,7 +39,7 @@ export class UserStore {
|
|||||||
this.store = this.dependencies.createBaseStore({
|
this.store = this.dependencies.createBaseStore({
|
||||||
configName: "lens-user-store",
|
configName: "lens-user-store",
|
||||||
projectVersion: this.dependencies.storeMigrationVersion,
|
projectVersion: this.dependencies.storeMigrationVersion,
|
||||||
migrations: this.dependencies.migrations as unknown as Migrations<UserStoreModel>,
|
migrations: this.dependencies.migrations,
|
||||||
fromStore: action(({ preferences }) => {
|
fromStore: action(({ preferences }) => {
|
||||||
this.dependencies.logger.debug("UserStore.fromStore()", { preferences });
|
this.dependencies.logger.debug("UserStore.fromStore()", { preferences });
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import { persistStateToConfigInjectionToken } from "../common/base-store/save-to
|
|||||||
import getBasenameOfPathInjectable from "../common/path/get-basename.injectable";
|
import getBasenameOfPathInjectable from "../common/path/get-basename.injectable";
|
||||||
import { enlistMessageChannelListenerInjectionToken } from "@k8slens/messaging";
|
import { enlistMessageChannelListenerInjectionToken } from "@k8slens/messaging";
|
||||||
|
|
||||||
export interface ExtensionStoreParams<T extends object> extends BaseStoreParams<T> {
|
export interface ExtensionStoreParams<T extends object> extends Omit<BaseStoreParams<T>, "migrations"> {
|
||||||
migrations?: Migrations<T>;
|
migrations?: Migrations<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user