@borodindmitriy/base-code
Advanced tools
| import { IEditCompositionActions, IEditCompositionAdapter } from "./IEditComposition"; | ||
| import { IListCompositionActions, IListCompositionAdapter } from "./IListComposition"; | ||
| export interface IUnionCompositionAdapter<T> extends IListCompositionAdapter<T>, IEditCompositionAdapter { | ||
| } | ||
| export interface IUnionCompositionActions<CHANGE> extends IListCompositionActions, IEditCompositionActions<CHANGE> { | ||
| } | ||
| export interface IUnionComposition<T, CHANGE> { | ||
| adapter: IUnionCompositionAdapter<T>; | ||
| actions: IUnionCompositionActions<CHANGE>; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| import { History } from "history"; | ||
| import { IListComposition, IListCompositionActions, IListCompositionAdapter } from "./interfaces/IListComposition"; | ||
| import { IRepository } from "./interfaces/IRepository"; | ||
| export declare class ListAdapter<T, R extends IRepository<T> = IRepository<T>, H extends History = History> implements IListComposition<T> { | ||
| adapter: IListCompositionAdapter<T>; | ||
| actions: IListCompositionActions; | ||
| protected repository: R; | ||
| protected history: H; | ||
| constructor(repository: R, history: H); | ||
| private onDidMount; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const tslib_1 = require("tslib"); | ||
| const mobx_1 = require("mobx"); | ||
| class ListAdapter { | ||
| constructor(repository, history) { | ||
| this.repository = repository; | ||
| this.history = history; | ||
| this.onDidMount = this.onDidMount.bind(this); | ||
| const self = this; | ||
| this.adapter = mobx_1.observable.object({ | ||
| get history() { | ||
| return self.history; | ||
| }, | ||
| get isInit() { | ||
| return self.repository.isInit; | ||
| }, | ||
| get isLoading() { | ||
| return self.repository.isLoading; | ||
| }, | ||
| get list() { | ||
| return self.repository.list; | ||
| }, | ||
| }); | ||
| this.actions = { | ||
| // HOOKS | ||
| onDidMount: this.onDidMount, | ||
| }; | ||
| } | ||
| onDidMount() { | ||
| return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
| yield this.repository.init(); | ||
| }); | ||
| } | ||
| } | ||
| exports.ListAdapter = ListAdapter; |
| import { History } from "history"; | ||
| import { IForm } from "../interfaces/IForm"; | ||
| import { IPersist } from "../interfaces/IPersist"; | ||
| import { EditAdapter } from "./EditAdapter"; | ||
| import { IRepository } from "./interfaces/IRepository"; | ||
| import { IRepositoryFormStore } from "./interfaces/IRepositoryFormStore"; | ||
| import { IUnionComposition, IUnionCompositionActions, IUnionCompositionAdapter } from "./interfaces/IUnionComposition"; | ||
| export declare class UnionAdapter<P extends IPersist, F extends IForm, CHANGE, REP extends IRepository<P>, FS extends IRepositoryFormStore<F, CHANGE>, H extends History = History> extends EditAdapter<P, F, CHANGE, FS, REP, H> implements IUnionComposition<P, CHANGE> { | ||
| adapter: IUnionCompositionAdapter<P>; | ||
| actions: IUnionCompositionActions<CHANGE>; | ||
| constructor(repository: REP, formStore: FS, history: H); | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const mobx_1 = require("mobx"); | ||
| const EditAdapter_1 = require("./EditAdapter"); | ||
| class UnionAdapter extends EditAdapter_1.EditAdapter { | ||
| constructor(repository, formStore, history) { | ||
| super(repository, formStore, history); | ||
| // API | ||
| const self = this; | ||
| this.adapter = Object.assign(self.adapter, mobx_1.observable.object({ | ||
| get list() { | ||
| return self.repository.list; | ||
| }, | ||
| })); | ||
| } | ||
| } | ||
| exports.UnionAdapter = UnionAdapter; |
+5
-3
@@ -8,4 +8,5 @@ export { IUserRepository } from "./front/interfaces/IUserRepository"; | ||
| export { IComposition } from "./front/interfaces/IComposition"; | ||
| export { IListComposition } from "./front/interfaces/IListComposition"; | ||
| export { IEditComposition } from "./front/interfaces/IEditComposition"; | ||
| export { IListComposition, IListCompositionAdapter, IListCompositionActions, } from "./front/interfaces/IListComposition"; | ||
| export { IEditComposition, IEditCompositionAdapter, IEditCompositionActions, } from "./front/interfaces/IEditComposition"; | ||
| export { IUnionComposition, IUnionCompositionActions, IUnionCompositionAdapter, } from "./front/interfaces/IUnionComposition"; | ||
| export { IFormStore } from "./front/interfaces/IFormStore"; | ||
@@ -20,5 +21,6 @@ export { IRepositoryFormStore } from "./front/interfaces/IRepositoryFormStore"; | ||
| export { Mediator } from "./front/Mediator"; | ||
| export { ListAdapter } from "./front/ListAdapter"; | ||
| export { EditAdapter } from "./front/EditAdapter"; | ||
| export { ListAdapter } from "./front/ListAdapter"; | ||
| export { UnionAdapter } from "./front/UnionAdapter"; | ||
| export { RepositoryFormStore } from "./front/RepositoryFormStore"; | ||
| export { Link } from "./front/components/Link"; |
+4
-2
@@ -16,6 +16,8 @@ "use strict"; | ||
| exports.Mediator = Mediator_1.Mediator; | ||
| var ListAdapter_1 = require("./front/ListAdapter"); | ||
| exports.ListAdapter = ListAdapter_1.ListAdapter; | ||
| var EditAdapter_1 = require("./front/EditAdapter"); | ||
| exports.EditAdapter = EditAdapter_1.EditAdapter; | ||
| var ListAdapter_1 = require("./front/ListAdapter"); | ||
| exports.ListAdapter = ListAdapter_1.ListAdapter; | ||
| var UnionAdapter_1 = require("./front/UnionAdapter"); | ||
| exports.UnionAdapter = UnionAdapter_1.UnionAdapter; | ||
| var RepositoryFormStore_1 = require("./front/RepositoryFormStore"); | ||
@@ -22,0 +24,0 @@ exports.RepositoryFormStore = RepositoryFormStore_1.RepositoryFormStore; |
| import { History } from "history"; | ||
| import { IForm } from "../interfaces/IForm"; | ||
| import { IPersist } from "../interfaces/IPersist"; | ||
| import { IValidateResult } from "../interfaces/IValidateResult"; | ||
| import { IEditComposition } from "./interfaces/IEditComposition"; | ||
| import { IEditComposition, IEditCompositionActions, IEditCompositionAdapter } from "./interfaces/IEditComposition"; | ||
| import { IRepository } from "./interfaces/IRepository"; | ||
| import { IRepositoryFormStore } from "./interfaces/IRepositoryFormStore"; | ||
| export declare class EditAdapter<P extends IPersist, F extends IForm, CHANGE, FS extends IRepositoryFormStore<F, CHANGE>, REP extends IRepository<P>, H extends History = History> implements IEditComposition<CHANGE> { | ||
| isLoading: boolean; | ||
| showAlerts: boolean; | ||
| shockDelay: number; | ||
| history: H; | ||
| adapter: IEditCompositionAdapter; | ||
| actions: IEditCompositionActions<CHANGE>; | ||
| protected repository: REP; | ||
| protected formStore: FS; | ||
| protected history: H; | ||
| protected isLoading: boolean; | ||
| protected showAlerts: boolean; | ||
| constructor(repository: REP, formStore: FS, history: H); | ||
| readonly isInit: boolean; | ||
| readonly isOpen: boolean; | ||
| readonly isEdit: boolean; | ||
| readonly validate: IValidateResult; | ||
| onDidMount(): Promise<void>; | ||
| change(change: CHANGE): void; | ||
| save(): Promise<void>; | ||
| remove(): Promise<void>; | ||
| cancel(): void; | ||
| protected start(): void; | ||
@@ -29,2 +20,7 @@ protected end(): void; | ||
| protected hide(): void; | ||
| protected onDidMount(): Promise<void>; | ||
| protected change(change: CHANGE): void; | ||
| protected save(): Promise<void>; | ||
| protected remove(): Promise<void>; | ||
| protected cancel(): void; | ||
| } |
+57
-44
@@ -9,3 +9,3 @@ "use strict"; | ||
| constructor(repository, formStore, history) { | ||
| // PROPS | ||
| // RIVATE_OBSERVABLE_PROPS | ||
| this.isLoading = false; | ||
@@ -17,6 +17,3 @@ this.showAlerts = false; | ||
| this.history = history; | ||
| // PROPS | ||
| this.shockDelay = 1000; | ||
| // BINDS | ||
| this.onDidMount = this.onDidMount.bind(this); | ||
| this.change = this.change.bind(this); | ||
@@ -26,16 +23,55 @@ this.save = this.save.bind(this); | ||
| this.cancel = this.cancel.bind(this); | ||
| this.onDidMount = this.onDidMount.bind(this); | ||
| const self = this; | ||
| // API | ||
| this.adapter = Object.assign({ | ||
| get isEdit() { | ||
| const { id } = qs.parse(self.history.location.search); | ||
| return isType_1.isString(id); | ||
| }, | ||
| }, mobx_1.observable.object({ | ||
| get history() { | ||
| return self.history; | ||
| }, | ||
| get isInit() { | ||
| return self.repository.isInit; | ||
| }, | ||
| get isLoading() { | ||
| return self.repository.isLoading || self.isLoading; | ||
| }, | ||
| get isOpen() { | ||
| return !isType_1.isUndefined(self.formStore.form); | ||
| }, | ||
| get showAlerts() { | ||
| return self.formStore.showAlerts || self.showAlerts; | ||
| }, | ||
| get validate() { | ||
| return self.formStore.validate; | ||
| }, | ||
| })); | ||
| // API | ||
| this.actions = { | ||
| change: this.change, | ||
| save: this.save, | ||
| // tslint:disable-next-line:object-literal-sort-keys | ||
| remove: this.remove, | ||
| cancel: this.cancel, | ||
| // HOOKS | ||
| onDidMount: this.onDidMount, | ||
| }; | ||
| } | ||
| get isInit() { | ||
| return this.repository.isInit; | ||
| // HELPERS | ||
| start() { | ||
| this.isLoading = true; | ||
| } | ||
| get isOpen() { | ||
| return !isType_1.isUndefined(this.formStore.form); | ||
| end() { | ||
| this.isLoading = false; | ||
| } | ||
| get isEdit() { | ||
| const { id } = qs.parse(this.history.location.search); | ||
| return isType_1.isString(id); | ||
| show() { | ||
| this.showAlerts = true; | ||
| } | ||
| get validate() { | ||
| return this.formStore.validate; | ||
| hide() { | ||
| this.showAlerts = false; | ||
| } | ||
| // HOOKS | ||
| onDidMount() { | ||
@@ -46,2 +82,3 @@ return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
| } | ||
| // FORM | ||
| change(change) { | ||
@@ -98,14 +135,2 @@ this.formStore.change(change); | ||
| } | ||
| start() { | ||
| this.isLoading = true; | ||
| } | ||
| end() { | ||
| this.isLoading = false; | ||
| } | ||
| show() { | ||
| this.showAlerts = true; | ||
| } | ||
| hide() { | ||
| this.showAlerts = false; | ||
| } | ||
| } | ||
@@ -119,34 +144,22 @@ tslib_1.__decorate([ | ||
| tslib_1.__decorate([ | ||
| mobx_1.computed | ||
| ], EditAdapter.prototype, "isInit", null); | ||
| tslib_1.__decorate([ | ||
| mobx_1.computed | ||
| ], EditAdapter.prototype, "isOpen", null); | ||
| tslib_1.__decorate([ | ||
| mobx_1.computed | ||
| ], EditAdapter.prototype, "isEdit", null); | ||
| tslib_1.__decorate([ | ||
| mobx_1.computed | ||
| ], EditAdapter.prototype, "validate", null); | ||
| tslib_1.__decorate([ | ||
| mobx_1.action | ||
| ], EditAdapter.prototype, "save", null); | ||
| ], EditAdapter.prototype, "start", null); | ||
| tslib_1.__decorate([ | ||
| mobx_1.action | ||
| ], EditAdapter.prototype, "remove", null); | ||
| ], EditAdapter.prototype, "end", null); | ||
| tslib_1.__decorate([ | ||
| mobx_1.action | ||
| ], EditAdapter.prototype, "cancel", null); | ||
| ], EditAdapter.prototype, "show", null); | ||
| tslib_1.__decorate([ | ||
| mobx_1.action | ||
| ], EditAdapter.prototype, "start", null); | ||
| ], EditAdapter.prototype, "hide", null); | ||
| tslib_1.__decorate([ | ||
| mobx_1.action | ||
| ], EditAdapter.prototype, "end", null); | ||
| ], EditAdapter.prototype, "save", null); | ||
| tslib_1.__decorate([ | ||
| mobx_1.action | ||
| ], EditAdapter.prototype, "show", null); | ||
| ], EditAdapter.prototype, "remove", null); | ||
| tslib_1.__decorate([ | ||
| mobx_1.action | ||
| ], EditAdapter.prototype, "hide", null); | ||
| ], EditAdapter.prototype, "cancel", null); | ||
| exports.EditAdapter = EditAdapter; |
@@ -0,9 +1,12 @@ | ||
| import { History } from "history"; | ||
| import { IValidateResult } from "../../interfaces/IValidateResult"; | ||
| import { IComposition } from "./IComposition"; | ||
| export interface IEditComposition<CHANGE> extends IComposition { | ||
| export interface IEditCompositionAdapter extends IComposition { | ||
| isOpen: boolean; | ||
| isEdit: boolean; | ||
| history: History; | ||
| showAlerts: boolean; | ||
| validate: IValidateResult; | ||
| onDidMount(): Promise<void>; | ||
| } | ||
| export interface IEditCompositionActions<CHANGE> { | ||
| change(chage: CHANGE): void; | ||
@@ -13,2 +16,7 @@ save(): Promise<void>; | ||
| cancel(): void; | ||
| onDidMount(): Promise<void>; | ||
| } | ||
| export interface IEditComposition<CHANGE> { | ||
| adapter: IEditCompositionAdapter; | ||
| actions: IEditCompositionActions<CHANGE>; | ||
| } |
@@ -0,5 +1,13 @@ | ||
| import { History } from "history"; | ||
| import { IComposition } from "./IComposition"; | ||
| export interface IListComposition<T> extends IComposition { | ||
| export interface IListCompositionAdapter<T> extends IComposition { | ||
| history: History; | ||
| list: T[]; | ||
| } | ||
| export interface IListCompositionActions { | ||
| onDidMount(): Promise<void>; | ||
| } | ||
| export interface IListComposition<T> { | ||
| adapter: IListCompositionAdapter<T>; | ||
| actions: IListCompositionActions; | ||
| } |
@@ -1,10 +0,11 @@ | ||
| import { IListComposition } from "./interfaces/IListComposition"; | ||
| import { History } from "history"; | ||
| import { IListComposition, IListCompositionActions, IListCompositionAdapter } from "./interfaces/IListComposition"; | ||
| import { IRepository } from "./interfaces/IRepository"; | ||
| export declare class ListAdapter<T, R extends IRepository<T> = IRepository<T>> implements IListComposition<T> { | ||
| export declare class ListAdapter<T, R extends IRepository<T> = IRepository<T>, H extends History = History> implements IListComposition<T> { | ||
| adapter: IListCompositionAdapter<T>; | ||
| actions: IListCompositionActions; | ||
| protected repository: R; | ||
| constructor(repository: R); | ||
| readonly isInit: boolean; | ||
| readonly isLoading: boolean; | ||
| readonly list: T[]; | ||
| onDidMount(): Promise<void>; | ||
| protected history: H; | ||
| constructor(repository: R, history: H); | ||
| private onDidMount; | ||
| } |
+21
-19
@@ -6,15 +6,26 @@ "use strict"; | ||
| class ListAdapter { | ||
| constructor(repository) { | ||
| constructor(repository, history) { | ||
| this.repository = repository; | ||
| this.history = history; | ||
| this.onDidMount = this.onDidMount.bind(this); | ||
| const self = this; | ||
| this.adapter = mobx_1.observable.object({ | ||
| get history() { | ||
| return self.history; | ||
| }, | ||
| get isInit() { | ||
| return self.repository.isInit; | ||
| }, | ||
| get isLoading() { | ||
| return self.repository.isLoading; | ||
| }, | ||
| get list() { | ||
| return self.repository.list; | ||
| }, | ||
| }); | ||
| this.actions = { | ||
| // HOOKS | ||
| onDidMount: this.onDidMount, | ||
| }; | ||
| } | ||
| get isInit() { | ||
| return this.repository.isInit; | ||
| } | ||
| get isLoading() { | ||
| return this.repository.isLoading; | ||
| } | ||
| get list() { | ||
| return this.repository.list; | ||
| } | ||
| onDidMount() { | ||
@@ -26,11 +37,2 @@ return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
| } | ||
| tslib_1.__decorate([ | ||
| mobx_1.computed | ||
| ], ListAdapter.prototype, "isInit", null); | ||
| tslib_1.__decorate([ | ||
| mobx_1.computed | ||
| ], ListAdapter.prototype, "isLoading", null); | ||
| tslib_1.__decorate([ | ||
| mobx_1.computed | ||
| ], ListAdapter.prototype, "list", null); | ||
| exports.ListAdapter = ListAdapter; |
+2
-2
| { | ||
| "name": "@borodindmitriy/base-code", | ||
| "description": "Common classes's library.", | ||
| "version": "4.3.1", | ||
| "version": "5.0.0", | ||
| "engines": { | ||
@@ -32,5 +32,5 @@ "node": ">=8", | ||
| "scripts": { | ||
| "start": "npm run build && tsc --watch", | ||
| "build": " npm run lint && tsc", | ||
| "build:relink": "del lib && npm run build && npm link", | ||
| "build:watch": "npm run build && tsc --watch", | ||
| "lint": "tslint -c tslint.json src/**/*.ts --fix", | ||
@@ -37,0 +37,0 @@ "test": "mocha --require ./tests/setup.js tests/unit/**/*.spec.ts", |
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 8 instances in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 8 instances in 1 package
250828
2.15%212
2.91%6189
1.98%