UNPKG

@aitianyu.cn/tianyu-store

Version:
60 lines 2.44 kB
"use strict"; /** @format */ Object.defineProperty(exports, "__esModule", { value: true }); exports.TianyuStoreEntityInterface = void 0; const ActionFactor_1 = require("./ActionFactor"); const StoreState_1 = require("./storage/interface/StoreState"); const StoreEntitySelector_1 = require("./storage/StoreEntitySelector"); const StoreEntityAction_1 = require("./storage/StoreEntityAction"); const UtilsSelectorImpl_1 = require("./storage/UtilsSelectorImpl"); const DefaultInstanceCreationConfig = { config: { redoUndo: true, }, instanceMap: { parentMap: {}, childrenMap: {}, }, }; const CreateActionCreator = ActionFactor_1.ActionFactor.makeCreateStoreAction(); const DestroyActionCreator = ActionFactor_1.ActionFactor.makeDestroyStoreAction(); const CreateAction = CreateActionCreator.withReducer(function (_state, data) { const state = { [StoreState_1.STORE_STATE_SYSTEM]: DefaultInstanceCreationConfig, [StoreState_1.STORE_STATE_INSTANCE]: {}, }; state[StoreState_1.STORE_STATE_SYSTEM].config.redoUndo = /* istanbul ignore next */ data?.redoUndo === undefined ? state[StoreState_1.STORE_STATE_SYSTEM].config.redoUndo : data.redoUndo; return state; }); const DestroyAction = DestroyActionCreator; exports.TianyuStoreEntityInterface = { core: { /** To create a new store entity */ creator: CreateAction, /** To delete a exist store entity */ destroy: DestroyAction, }, action: { /** To create a new instance if the instance does not exist */ createInstanceIfNotExist: StoreEntityAction_1.CreateInstanceIfNotExist, /** To delete a instance if the instance does exist */ destroyInstanceIfExist: StoreEntityAction_1.DestroyInstanceIfExist, }, selector: { /** Get the specified instance does exist */ getInstanceExist: StoreEntitySelector_1.GetInstanceExist, instance: { /** Get the parent of specified instance */ parent: StoreEntitySelector_1.GetParentInstance, /** Get all children of specified instance */ children: StoreEntitySelector_1.GetChildInstances, }, }, utils: { toBoolean: UtilsSelectorImpl_1.ConvertAnyToBoolean, }, }; exports.TianyuStoreEntityInterface; //# sourceMappingURL=SystemActionFactor.js.map