///
///
///
type CanBeArray = T | Array
type ActionsAndN = CanBeArray | GetActions>
type IModelCore = Atomized>> & OnlyFunc>
type IModelState = PureState>
type INucleusInitEventData = {
rune?: any
nucleus: INucleus
}
type INucleusChangeEventData = {
value: any
key: string
atomId: string
nucleus: INucleus
}
type IAtomLifeCycleEventData = {
name: string
atom: IUnionAtom
}
type IAlakCoreEvents = {
UNION_ATOM_DECAY: IAtomLifeCycleEventData
ATOM_INIT: IAtomLifeCycleEventData
NUCLEUS_CHANGE: INucleusChangeEventData
NUCLEUS_INIT: INucleusInitEventData
}
interface IUnionAtom {
readonly state: IModelState
readonly core: OnlyPublicKeys>
readonly actions: OnlyPublicKeys>>
readonly bus: IQuarkBus
readonly known: IAtomKnown
decay(): void
}
type QuantumAtom = {
id?: any
name: string
data?: any
bus?: IQuarkBus
union: IUnionCore
atom?: IAtom
eventListeners?: string[]
}
type IAlakAtomFactory = {
get(id: string | number, target?: any): IUnionAtom
delete(id: string | number): void
readonly broadcast: IModelCore
readonly bus: IQuarkBus
}
type IStartupStrategy = 'lazy' | 'immediately'
interface IAlakConstructor {
name: string
namespace?: string
model?: Model
nucleusStrategy?: NucleusStrategy
emitChanges?: boolean
startup?: IStartupStrategy
globalBus?: boolean
disableSpringModel?: boolean
}
type IUnionSynthesis = {
namespace?: string
models?: M
factories?: F
events?: E
services?: S
emitChanges?: boolean
}
interface IUnionCoreService {
readonly atoms: { [K in keyof Models]: IUnionAtom }
readonly bus: IQuarkBus
readonly _injector: any
readonly ns: string
}
type IFAInjector = {
[K in keyof O as `${Capitalize}${N}`]: O[K]
}
type IFUnionInjector = {
[K in keyof (Models & Factory) as `${Capitalize}Atom`]: (IAtomicModels<
Models,
Events
> &
IAtomicFactory)[K]
} & {
[K in keyof Models as `${Capitalize}Core`]: IAtomCore>
} & {
[K in keyof Models as `${Capitalize}State`]: IModelState
} & {
[K in keyof Models as `${Capitalize}Bus`]: IQuarkBus
}
type IUnionCore = {
readonly addAtom(c:IAlakConstructor):IAtom
readonly facade: IUnionFacade & Services
readonly services: IUnionCoreService
readonly bus: IQuarkBus
}
// type IUnionDevCore = IUnionCore
type IAtomicModels = {
[K in keyof Models]: IUnionAtom
}
type IAtomicFactory = {
[K in keyof F]: IAlakAtomFactory
}
type IUnionFacade = {
readonly atoms: IAtomicModels & IAtomicFactory
readonly cores: { [K in keyof Models]: IAtomCore> }
readonly states: { [K in keyof Models]: IModelState }
readonly buses: { [K in keyof Models]: IQuarkBus }
readonly bus: IQuarkBus
} & IFUnionInjector