diff --git a/ActionStrategy.md b/ActionStrategy.md index 2cb24fb..2972903 100644 --- a/ActionStrategy.md +++ b/ActionStrategy.md @@ -37,7 +37,7 @@ export interface ActionNode { ``` * action - Is an union data pattern to bind the functionality of the ActionNode, ActionStrategy, and Action. This allows for each part to be responsible for itself and to allow for additional functionality at runtime. * actionType - Is merely the type of action to be created at runtime, these should be verbose as to their intended effect as it informs the STRX sentence structure's body. -* payload - Is set to unknown to allow for the explicit typecasting during consumption, reducer, method, or principle. Use createPayload<_Type>(payload: _Type) to ensure type casting in the reducer will be the same type as used in createPayload. This is a logical determination in line with Javascript core functionality. +* payload - Is set to unknown to allow for the explicit typecasting during consumption, reducer, method, or principle. Be sure to import actions directly to ensure payload type safety in the reducer. This is a logical determination in line with Javascript core functionality. * keyedSelectors - An Array of KeyedSelector that locks some property during the life time of the created action. * semaphore - First is concept's index, second is the quality's index, and the final is the generation of the sets of concepts currently stored on the Axium. *Explicitly setting this value, denotes a primed action without additional look up at runtime.* * agreement - Is time in milliseconds of the lock's expiration time. Default is currently 5000, but such will be reduced upon testing and feedback. diff --git a/README.md b/README.md index 7cdfcb6..2946ded 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ let finalRun = true; const axium = createAxium('ownershipTest', [ createOwnershipConcept(), createCounterConcept(), - createExperimentConcept(createExperimentActionQueState(), [checkInQuality], [experimentActionQuePrinciple]) + createExperimentConcept(createExperimentActionQueState(), [checkInStrategyQuality], [experimentActionQuePrinciple]) ], true, true); const plan = axium.stage( 'Testing Ownership Staging', [ @@ -56,7 +56,7 @@ const plan = axium.stage( // This will place a counting strategy in the experiment actionQue to be later dispatched. // Via its principle, to simulate an action moving off premise. dispatch(strategyBegin(puntCountingStrategy()), { - iterateStep: true + iterateStage: true }); } }, @@ -65,7 +65,7 @@ const plan = axium.stage( // Will be ran after both counting strategies conclude. const ownership = selectState(cpts, ownershipName); console.log('Stage 2', ownership.ownershipLedger, ownership.pendingActions); - dispatch(counterSetCount(createPayload({newCount: 1000}), undefined, 7000), { iterateStep: true}); + dispatch(counterSetCount({newCount: 1000}, undefined, 7000), { iterateStage: true}); }, (cpts, dispatch) => { const ownership = selectState(cpts, ownershipName); @@ -73,7 +73,7 @@ const plan = axium.stage( const counter = selectState(cpts, counterName); console.log('Count: ', counter.count); dispatch(strategyBegin(experimentPrimedCountingStrategy(cpts)), { - iterateStep: true + iterateStage: true }); }, (cpts, dispatch) => { @@ -134,15 +134,15 @@ const sub = axium.subscribe((concepts: Concept[]) => { } }); ``` -The above demonstrates two solutions. One of the ability to network axiums together unlike the design of FLUX that would restrict all calculations to a singular source of truth. That is accomplished via the ownership pattern and halts upon multiple concluding strategies that would have some race condition within the network. The second would be the comments to demonstrate the power of a finite state machine and its ability to return some output that can be logically determined. Noting the comment selections. This is presented as such to provide a testable back and forth with the developer to inform some intuition as to STRX's inner workings. +the above demonstrates two solutions. one of the ability to network axiums together unlike the design of flux that would restrict all calculations to a singular source of truth. that is accomplished via the ownership pattern and halts upon multiple concluding strategies that would have some race condition within the network. the second would be the comments to demonstrate the power of a finite state machine and its ability to return some output that can be logically determined. noting the comment selections. this is presented as such to provide a testable back and forth with the developer to inform some intuition as to strx's inner workings. -### STRX - *ST*rategic *R*eactive(X) Framework -STRX is the graph computational framework release of a new Unified Turing Machine. The internal structure of this machine directly relays to a form of written intelligence of doing, over that of knowledge retrieval, and data entry. But may be written to facilitate any preexisting paradigm such as that same expert system paradigm of classic. The importance of this machine to the now of 2023, is the functionality of the ActionStrategy pattern as it relays to human and machine intelligence. As the pattern itself is a unified set of logical explanations of doing as a series of functions. Unified to the mechanism of that doing via code implementations of that logical explanation. We organize using concepts as it relays to a historic pursuit of unifying all fields of science in addition to a logical explanation. And is the comparable comparison to a graph of machine learning universal functions, and the generated Neural Network of layers that aggregate to greater universal functions. The comparison to that of LLM, during runtime these actions are outputted to an ActionList that is later composed as a STRX sentence. +### strx - *st*rategic *r*eactive(x) framework +strx is the graph computational framework release of a new unified turing machine. the internal structure of this machine directly relays to a form of written intelligence of doing, over that of knowledge retrieval, and data entry. but may be written to facilitate any preexisting paradigm such as that same expert system paradigm of classic. the importance of this machine to the now of 2023, is the functionality of the actionstrategy pattern as it relays to human and machine intelligence. as the pattern itself is a unified set of logical explanations of doing as a series of functions. unified to the mechanism of that doing via code implementations of that logical explanation. we organize using concepts as it relays to a historic pursuit of unifying all fields of science in addition to a logical explanation. and is the comparable comparison to a graph of machine learning universal functions, and the generated neural network of layers that aggregate to greater universal functions. the comparison to that of llm, during runtime these actions are outputted to an actionlist that is later composed as a strx sentence. -#### The Anatomy of a STRX Sentence +#### the anatomy of a strx sentence ``` -Preposition(/+)Decision + Body + Denoter -Example: Finally + Open Axium + to Notify Subscribers of State changes. +preposition(/+)decision + body + denoter +example: Finally + Open Axium + to Notify Subscribers of State changes. ``` This allows for a STRX Dialog to be constructed in the same formalization of that of a paragraph. Where the strategy topic is the literal topic sentence of a paragraph. And is followed by all steps and possible decision that create a unified paragraph. ``` diff --git a/package.json b/package.json index 23e81f0..06a983e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@phuire/strx", - "version": "0.0.25", + "version": "0.0.26", "description": "Unified Turing Machine", "main": "dist/index.js", "module": "dist/index.mjs", diff --git a/src/concepts/axium/qualities/addConceptsFromQue.quality.ts b/src/concepts/axium/qualities/addConceptsFromQue.quality.ts index eff461a..7d351d9 100644 --- a/src/concepts/axium/qualities/addConceptsFromQue.quality.ts +++ b/src/concepts/axium/qualities/addConceptsFromQue.quality.ts @@ -1,15 +1,12 @@ import { Observable, Subject, Subscriber, catchError } from 'rxjs'; import { defaultMethodCreator } from '../../../model/concept'; import { AxiumState } from '../axium.concept'; -import { Action, ActionType } from '../../../model/action'; +import { Action, ActionType, prepareActionCreator } from '../../../model/action'; import { createQuality } from '../../../model/concept'; import { blockingMethodSubscription } from '../../../model/axium'; export const axiumAddConceptFromQueType: ActionType = 'Add Concepts from Axium Concept Que'; - -export type AddConceptsFromQuePayload = { - action$: Subject; -} +export const axiumAddConceptFromQue = prepareActionCreator(axiumAddConceptFromQueType); function addConceptsFromQueReducer(state: AxiumState, _ : Action) { const methodSubscribers = state.methodSubscribers; diff --git a/src/concepts/axium/qualities/appendActionListToDialog.quality.ts b/src/concepts/axium/qualities/appendActionListToDialog.quality.ts index 4a8b2d5..359178f 100644 --- a/src/concepts/axium/qualities/appendActionListToDialog.quality.ts +++ b/src/concepts/axium/qualities/appendActionListToDialog.quality.ts @@ -1,41 +1,17 @@ import { map, Subject } from 'rxjs'; import { Method, MethodCreator } from '../../../model/concept'; -import { Action, ActionType } from '../../../model/action'; -import { createAction } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { createQuality } from '../../../model/concept'; import { AxiumState } from '../axium.concept'; -import { axiumConcludeType } from './conclude.quality'; import { selectPayload } from '../../../model/selector'; -export const axiumAppendActionListToDialogType: ActionType = 'append Action List to Axium\'s Dialog'; - export type AppendActionListToDialogPayload = { actionList: Array; strategyTopic: string; } - -// const createAppendActionListToDialogMethodCreator: MethodCreator = (concepts$: UnifiedSubject) => { -const createAppendActionListToDialogMethodCreator: MethodCreator = () => { - const logSubject = new Subject(); - const logMethod: Method = logSubject.pipe( - // withLatestFrom(subConcepts$), - // map(([action, concepts]) => { - map(() => { - // const axiumState = concepts[0].state as AxiumState; - // if (axiumState.logging) { - // const payload = action.payload as AppendActionListToDialogPayload; - // let newDialog = payload.strategyKey + '. '; - // payload.actionList.forEach(str => {newDialog += str + ' ';}); - // console.log(newDialog); - // } - return createAction(axiumConcludeType); - }) - ); - return [ - logMethod, - logSubject - ]; -}; +export const axiumAppendActionListToDialogType: ActionType = 'append Action List to Axium\'s Dialog'; +export const axiumAppendActionListToDialog = + prepareActionWithPayloadCreator(axiumAppendActionListToDialogType); export function appendActionListToDialogReducer(state: AxiumState, action: Action) { const payload = selectPayload(action); diff --git a/src/concepts/axium/qualities/appendConceptsToAddQue.quality.ts b/src/concepts/axium/qualities/appendConceptsToAddQue.quality.ts index b04c046..cf7a040 100644 --- a/src/concepts/axium/qualities/appendConceptsToAddQue.quality.ts +++ b/src/concepts/axium/qualities/appendConceptsToAddQue.quality.ts @@ -1,14 +1,15 @@ import { Concept, defaultMethodCreator } from '../../../model/concept'; import { AxiumState } from '../axium.concept'; -import { Action, ActionType } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { createQuality } from '../../../model/concept'; import { selectPayload } from '../../../model/selector'; -export const axiumAppendConceptsToAddQueType: ActionType = 'append Concepts to Axium\'s Add Concept Que'; - export type AppendConceptsToAddQuePayload = { concepts: Concept[] } +export const axiumAppendConceptsToAddQueType: ActionType = 'append Concepts to Axium\'s Add Concept Que'; +export const axiumAppendConceptsToAddQue = + prepareActionWithPayloadCreator(axiumAppendConceptsToAddQueType); export function appendConceptsToAddQueReducer(state: AxiumState, action: Action) { const payload = selectPayload(action); diff --git a/src/concepts/axium/qualities/appendConceptsToRemoveQue.quality.ts b/src/concepts/axium/qualities/appendConceptsToRemoveQue.quality.ts index 651c868..6c05214 100644 --- a/src/concepts/axium/qualities/appendConceptsToRemoveQue.quality.ts +++ b/src/concepts/axium/qualities/appendConceptsToRemoveQue.quality.ts @@ -1,14 +1,15 @@ import { Concept, defaultMethodCreator } from '../../../model/concept'; import { AxiumState } from '../axium.concept'; -import { Action, ActionType } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { createQuality } from '../../../model/concept'; import { selectPayload } from '../../../model/selector'; -export const axiumAppendConceptsToRemoveQueType: ActionType = 'append Concepts to Axium\'s Remove Concept Que'; - export type AppendConceptsToRemoveQuePayload = { concepts: Concept[] } +export const axiumAppendConceptsToRemoveQueType: ActionType = 'append Concepts to Axium\'s Remove Concept Que'; +export const axiumAppendConceptsToRemoveQue = + prepareActionWithPayloadCreator(axiumAppendConceptsToRemoveQueType); export function appendConceptsToRemoveQueReducer(state: AxiumState, action: Action) { const payload = selectPayload(action); diff --git a/src/concepts/axium/qualities/badAction.quality.ts b/src/concepts/axium/qualities/badAction.quality.ts index 582d965..6d8673c 100644 --- a/src/concepts/axium/qualities/badAction.quality.ts +++ b/src/concepts/axium/qualities/badAction.quality.ts @@ -1,10 +1,11 @@ -import { Action, ActionType } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { createQuality } from '../../../model/concept'; import { selectPayload } from '../../../model/selector'; import { AxiumState } from '../axium.concept'; -export const axiumBadActionType: ActionType = 'Axium received a Bad Action'; export type BadActionPayload = Action[]; +export const axiumBadActionType: ActionType = 'Axium received a Bad Action'; +export const axiumBadAction = prepareActionWithPayloadCreator(axiumBadActionType); export function badActionReducer(state: AxiumState, action: Action) { const payload = selectPayload(action); diff --git a/src/concepts/axium/qualities/clearBadActionTypeFromBadActionList.quality.ts b/src/concepts/axium/qualities/clearBadActionTypeFromBadActionList.quality.ts index 49cc262..1c0c764 100644 --- a/src/concepts/axium/qualities/clearBadActionTypeFromBadActionList.quality.ts +++ b/src/concepts/axium/qualities/clearBadActionTypeFromBadActionList.quality.ts @@ -1,11 +1,12 @@ import { defaultMethodCreator, createQuality } from '../../../model/concept'; -import { Action, ActionType, prepareActionCreator } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { AxiumState } from '../axium.concept'; import { selectPayload } from '../../../model/selector'; -export const axiumClearBadActionTypeFromBadActionListType: ActionType = 'clear ActionType from Axium\'s badAction list'; -export const axiumClearBadActionTypeFromBadActionList = prepareActionCreator(axiumClearBadActionTypeFromBadActionListType); export type ClearBadActionTypeFromBadActionListPayload = ActionType; +export const axiumClearBadActionTypeFromBadActionListType: ActionType = 'clear ActionType from Axium\'s badAction list'; +export const axiumClearBadActionTypeFromBadActionList = + prepareActionWithPayloadCreator(axiumClearBadActionTypeFromBadActionListType); function clearBadActionTypeFromBadActionListReducer(state: AxiumState, action: Action): AxiumState { const actionType = selectPayload(action); diff --git a/src/concepts/axium/qualities/clearBadPlanFromBadPlanList.quality.ts b/src/concepts/axium/qualities/clearBadPlanFromBadPlanList.quality.ts index 3b7f13d..1b6d63f 100644 --- a/src/concepts/axium/qualities/clearBadPlanFromBadPlanList.quality.ts +++ b/src/concepts/axium/qualities/clearBadPlanFromBadPlanList.quality.ts @@ -1,11 +1,12 @@ import { defaultMethodCreator, createQuality } from '../../../model/concept'; -import { Action, ActionType, prepareActionCreator } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { AxiumState } from '../axium.concept'; import { selectPayload } from '../../../model/selector'; -export const axiumClearBadPlanFromBadPlanListType: ActionType = 'clear Plan Topic from Axium\'s badPlan list'; -export const axiumClearBadPlanFromBadPlanList = prepareActionCreator(axiumClearBadPlanFromBadPlanListType); export type ClearBadPlanFromBadPlanListPayload = string; +export const axiumClearBadPlanFromBadPlanListType: ActionType = 'clear Plan Topic from Axium\'s badPlan list'; +export const axiumClearBadPlanFromBadPlanList = + prepareActionWithPayloadCreator(axiumClearBadPlanFromBadPlanListType); function clearBadPlanFromBadPlanListReducer(state: AxiumState, action: Action): AxiumState { const title = selectPayload(action); diff --git a/src/concepts/axium/qualities/clearBadStrategyTopicFromBadActionList.quality.ts b/src/concepts/axium/qualities/clearBadStrategyTopicFromBadActionList.quality.ts index a04f64d..032b9ea 100644 --- a/src/concepts/axium/qualities/clearBadStrategyTopicFromBadActionList.quality.ts +++ b/src/concepts/axium/qualities/clearBadStrategyTopicFromBadActionList.quality.ts @@ -1,11 +1,12 @@ import { defaultMethodCreator, createQuality } from '../../../model/concept'; -import { Action, ActionType, prepareActionCreator } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { AxiumState } from '../axium.concept'; import { selectPayload } from '../../../model/selector'; -export const axiumClearBadStrategyTopicFromBadActionListType: ActionType = 'clear Strategy Topic from Axium\'s badAction list'; -export const axiumClearBadStrategyTopicFromBadActionList = prepareActionCreator(axiumClearBadStrategyTopicFromBadActionListType); export type ClearBadStrategyTopicFromBadActionListPayload = string; +export const axiumClearBadStrategyTopicFromBadActionListType: ActionType = 'clear Strategy Topic from Axium\'s badAction list'; +export const axiumClearBadStrategyTopicFromBadActionList = + prepareActionWithPayloadCreator(axiumClearBadStrategyTopicFromBadActionListType); function clearBadStrategyTopicFromBadActionListReducer(state: AxiumState, action: Action): AxiumState { const strategyTopic = selectPayload(action); diff --git a/src/concepts/axium/qualities/conclude.quality.ts b/src/concepts/axium/qualities/conclude.quality.ts index 28092fc..09f3415 100644 --- a/src/concepts/axium/qualities/conclude.quality.ts +++ b/src/concepts/axium/qualities/conclude.quality.ts @@ -1,4 +1,4 @@ -import { ActionType } from '../../../model/action'; +import { ActionType, prepareActionCreator } from '../../../model/action'; /** * axiumConcludeType @@ -9,3 +9,4 @@ import { ActionType } from '../../../model/action'; * This should not be used Directly */ export const axiumConcludeType: ActionType = 'Conclude'; +export const axiumConclude = prepareActionCreator(axiumConcludeType); diff --git a/src/concepts/axium/qualities/initializePrinciples.quality.ts b/src/concepts/axium/qualities/initializePrinciples.quality.ts index e9ace4a..0618647 100644 --- a/src/concepts/axium/qualities/initializePrinciples.quality.ts +++ b/src/concepts/axium/qualities/initializePrinciples.quality.ts @@ -1,17 +1,18 @@ import { Subject, Subscriber } from 'rxjs'; import { Concept, defaultMethodCreator } from '../../../model/concept'; import { createPrinciple$ } from '../../../model/principle'; -import { Action, ActionType } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { AxiumState } from '../axium.concept'; import { createQuality } from '../../../model/concept'; import { UnifiedSubject } from '../../../model/unifiedSubject'; import { selectPayload } from '../../../model/selector'; -export const axiumInitializePrinciplesType: ActionType = 'initialize Principles and set new Subscribers to General Subscribers list'; - export type InitializePrinciplesPayload = { concepts: Concept[]; } +export const axiumInitializePrinciplesType: ActionType = 'initialize Principles and set new Subscribers to General Subscribers list'; +export const axiumInitializePrinciples = + prepareActionWithPayloadCreator(axiumInitializePrinciplesType); export function initializePrinciplesReducer(state: AxiumState, _action: Action) { const payload = selectPayload(_action); diff --git a/src/concepts/axium/qualities/log.quality.ts b/src/concepts/axium/qualities/log.quality.ts index 1750acb..5ab13ac 100644 --- a/src/concepts/axium/qualities/log.quality.ts +++ b/src/concepts/axium/qualities/log.quality.ts @@ -1,9 +1,8 @@ import { map, Subject } from 'rxjs'; import { Method, MethodCreator, defaultReducer } from '../../../model/concept'; import { Action, ActionType, prepareActionCreator } from '../../../model/action'; -import { createAction } from '../../../model/action'; import { createQuality } from '../../../model/concept'; -import { axiumConcludeType } from './conclude.quality'; +import { axiumConclude } from './conclude.quality'; import { strategySuccess } from '../../../model/actionStrategy'; export const axiumLogType: ActionType = 'logged a message passed to Axium'; @@ -17,7 +16,7 @@ const createLogMethodCreator: MethodCreator = () => { if (action.strategy) { return strategySuccess(action.strategy); } - return createAction(axiumConcludeType); + return axiumConclude(); }) ); return [ diff --git a/src/concepts/axium/qualities/open.quality.ts b/src/concepts/axium/qualities/open.quality.ts index 59fef23..6912ffe 100644 --- a/src/concepts/axium/qualities/open.quality.ts +++ b/src/concepts/axium/qualities/open.quality.ts @@ -1,20 +1,18 @@ import { defaultMethodCreator, createQuality } from '../../../model/concept'; -import { Action, ActionType, prepareActionCreator } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { AxiumState } from '../axium.concept'; import { selectPayload } from '../../../model/selector'; -export const axiumOpenType: ActionType = 'Open Axium'; -export const axiumOpen = prepareActionCreator(axiumOpenType); +export type OpenPayload = boolean; -export type OpenPayload = { - open?: boolean; -} | undefined; +export const axiumOpenType: ActionType = 'Open Axium'; +export const axiumOpen = prepareActionWithPayloadCreator(axiumOpenType); export function openReducer(state: AxiumState, action: Action) { const payload = selectPayload(action); return { ...state, - open: payload?.open ? payload.open : true + open: payload, }; } export const openQuality = createQuality( diff --git a/src/concepts/axium/qualities/registerSubscriber.quality.ts b/src/concepts/axium/qualities/registerSubscriber.quality.ts index 3895646..6db13fb 100644 --- a/src/concepts/axium/qualities/registerSubscriber.quality.ts +++ b/src/concepts/axium/qualities/registerSubscriber.quality.ts @@ -1,16 +1,17 @@ import { Subscriber } from 'rxjs'; import { defaultMethodCreator } from '../../../model/concept'; -import { Action, ActionType } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { AxiumState } from '../axium.concept'; import { createQuality } from '../../../model/concept'; import { selectPayload } from '../../../model/selector'; -export const axiumRegisterSubscriberType: ActionType = 'register Subscriber to Axium\'s General Subscriber list'; - export type RegisterSubscriberPayload = { subscriber: Subscriber; name: string; } +export const axiumRegisterSubscriberType: ActionType = 'register Subscriber to Axium\'s General Subscriber list'; +export const axiumRegisterSubscriber = + prepareActionWithPayloadCreator(axiumRegisterSubscriberType); export function registerSubscriberReducer(state: AxiumState, action: Action) { const payload = selectPayload(action); diff --git a/src/concepts/axium/qualities/removeConceptsViaQue.quality.ts b/src/concepts/axium/qualities/removeConceptsViaQue.quality.ts index 01890b6..3852411 100644 --- a/src/concepts/axium/qualities/removeConceptsViaQue.quality.ts +++ b/src/concepts/axium/qualities/removeConceptsViaQue.quality.ts @@ -1,10 +1,11 @@ import { defaultMethodCreator } from '../../../model/concept'; import { NamedSubscriber } from '../axium.concept'; -import { Action, ActionType, } from '../../../model/action'; +import { Action, ActionType, prepareActionCreator, } from '../../../model/action'; import { AxiumState } from '../axium.concept'; import { createQuality } from '../../../model/concept'; export const axiumRemoveConceptsViaQueType: ActionType = 'remove Concepts via Axium\'s Removal Concept Que'; +export const axiumRemoveConceptsViaQue = prepareActionCreator(axiumRemoveConceptsViaQueType); export function removeConceptsViaQueReducer(state: AxiumState, _action: Action) { const methodSubscribers = state.methodSubscribers; diff --git a/src/concepts/axium/qualities/setBlockingMode.quality.ts b/src/concepts/axium/qualities/setBlockingMode.quality.ts index b9d7dab..08e6d56 100644 --- a/src/concepts/axium/qualities/setBlockingMode.quality.ts +++ b/src/concepts/axium/qualities/setBlockingMode.quality.ts @@ -1,16 +1,16 @@ import { Observable, Subject, Subscriber, catchError } from 'rxjs'; import { Concept, defaultMethodCreator } from '../../../model/concept'; -import { Action, ActionType } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { AxiumState } from '../axium.concept'; import { createQuality } from '../../../model/concept'; import { blockingMethodSubscription } from '../../../model/axium'; import { selectPayload } from '../../../model/selector'; -export const axiumSetBlockingModeType: ActionType = 'set Axium to Blocking Mode'; - export type SetBlockingModePayload = { concepts: Concept[] } +export const axiumSetBlockingModeType: ActionType = 'set Axium to Blocking Mode'; +export const axiumSetBlockingMode = prepareActionWithPayloadCreator(axiumSetBlockingModeType); export function setBlockingModeReducer(state: AxiumState, _action: Action) { let methodSubscribers = state.methodSubscribers; diff --git a/src/concepts/axium/qualities/setDefaultMode.quality.ts b/src/concepts/axium/qualities/setDefaultMode.quality.ts index 2a1af41..2e5f268 100644 --- a/src/concepts/axium/qualities/setDefaultMode.quality.ts +++ b/src/concepts/axium/qualities/setDefaultMode.quality.ts @@ -1,16 +1,16 @@ import { Subject, Subscriber } from 'rxjs'; import { Concept, defaultMethodCreator } from '../../../model/concept'; -import { Action, ActionType } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { AxiumState } from '../axium.concept'; import { createQuality } from '../../../model/concept'; import { defaultMethodSubscription } from '../../../model/axium'; import { selectPayload } from '../../../model/selector'; -export const axiumSetDefaultModeType: ActionType = 'set Axium to its current Default Mode Index'; - export type SetDefaultModePayload = { concepts: Concept[] } +export const axiumSetDefaultModeType: ActionType = 'set Axium to its current Default Mode Index'; +export const axiumSetDefaultMode = prepareActionWithPayloadCreator(axiumSetDefaultModeType); export function setDefaultModeReducer(state: AxiumState, _action: Action) { let methodSubscribers = state.methodSubscribers; diff --git a/src/concepts/axium/qualities/setDefaultModeIndex.quality.ts b/src/concepts/axium/qualities/setDefaultModeIndex.quality.ts index ada759f..ba07ad6 100644 --- a/src/concepts/axium/qualities/setDefaultModeIndex.quality.ts +++ b/src/concepts/axium/qualities/setDefaultModeIndex.quality.ts @@ -1,13 +1,13 @@ import { defaultMethodCreator, createQuality } from '../../../model/concept'; -import { Action, ActionType } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { AxiumState } from '../axium.concept'; import { selectPayload } from '../../../model/selector'; -export const axiumSetDefaultModeIndexType: ActionType = 'set Axium\'s Default Mode Index'; - export type SetDefaultModeIndexPayload = { index: number; }; +export const axiumSetDefaultModeIndexType: ActionType = 'set Axium\'s Default Mode Index'; +export const axiumSetDefaultModeIndex = prepareActionWithPayloadCreator(axiumSetDefaultModeIndexType); export function setDefaultModeIndexReducer(state: AxiumState, action: Action) { const payload = selectPayload(action); diff --git a/src/concepts/axium/qualities/setMode.quality.ts b/src/concepts/axium/qualities/setMode.quality.ts index 24efe20..3a0345e 100644 --- a/src/concepts/axium/qualities/setMode.quality.ts +++ b/src/concepts/axium/qualities/setMode.quality.ts @@ -1,18 +1,19 @@ import { AxiumState } from '../axium.concept'; -import { Action, createAction} from '../../../model/action'; +import { Action, createAction, prepareActionWithPayloadCreator} from '../../../model/action'; import { createQuality, MethodCreator, Method } from '../../../model/concept'; import { Subject, map } from 'rxjs'; import { axiumConcludeType } from './conclude.quality'; import { strategySuccess } from '../../../model/actionStrategy'; import { selectPayload } from '../../../model/selector'; -export const axiumSetModeType = 'set Axium Mode'; - export type SetModePayload = { modeIndex: number; modeName: string; } +export const axiumSetModeType = 'set Axium Mode'; +export const axiumSetMode = prepareActionWithPayloadCreator(axiumSetModeType); + export const createOwnershipMethodCreator: MethodCreator = () : [Method, Subject] => { const defaultSubject = new Subject(); const defaultMethod: Method = defaultSubject.pipe( diff --git a/src/concepts/axium/strategies/addConcept.strategy.ts b/src/concepts/axium/strategies/addConcept.strategy.ts index ec75fca..625abcd 100644 --- a/src/concepts/axium/strategies/addConcept.strategy.ts +++ b/src/concepts/axium/strategies/addConcept.strategy.ts @@ -1,38 +1,33 @@ import { Subject } from 'rxjs'; -import { createStrategy, ActionNode, ActionStrategy, ActionStrategyParameters } from '../../../model/actionStrategy'; +import { createStrategy, ActionNode, ActionStrategy, ActionStrategyParameters, createActionNode } from '../../../model/actionStrategy'; import { Concept } from '../../../model/concept'; import { Action, getSemaphore} from '../../../model/action'; -import { AddConceptsFromQuePayload, axiumAddConceptFromQueType } from '../qualities/addConceptsFromQue.quality'; -import { AppendConceptsToAddQuePayload, axiumAppendConceptsToAddQueType } from '../qualities/appendConceptsToAddQue.quality'; -import { axiumOpenType } from '../qualities/open.quality'; -import { axiumSetBlockingModeType } from '../qualities/setBlockingMode.quality'; -import { SetDefaultModePayload, axiumSetDefaultModeType } from '../qualities/setDefaultMode.quality'; +import { axiumAddConceptFromQue, axiumAddConceptFromQueType } from '../qualities/addConceptsFromQue.quality'; +import { axiumAppendConceptsToAddQue, axiumAppendConceptsToAddQueType } from '../qualities/appendConceptsToAddQue.quality'; +import { axiumOpen, axiumOpenType } from '../qualities/open.quality'; +import { axiumSetBlockingMode, axiumSetBlockingModeType } from '../qualities/setBlockingMode.quality'; +import { axiumSetDefaultMode, axiumSetDefaultModeType } from '../qualities/setDefaultMode.quality'; import { axiumName } from '../axium.concept'; -import { createPayload } from '../../../model/selector'; // Step One to Add Concepts to Axium export const addConceptsToAddQueThenBlockTopic = 'Add Concepts to add que then set Axium Mode to Blocking'; export function addConceptsToAddQueThenBlockStrategy(concepts: Concept[], newConcepts: Concept[]) { - const stepTwo: ActionNode = { - actionType: axiumAppendConceptsToAddQueType, + const stepTwo: ActionNode = createActionNode(axiumAppendConceptsToAddQue({concepts: newConcepts}),{ successNode: null, successNotes: { preposition: 'Then Safely' }, failureNode: null, semaphore: getSemaphore(concepts, axiumName, axiumAppendConceptsToAddQueType), - payload: createPayload({concepts: newConcepts}), - }; - const stepOne: ActionNode = { - actionType: axiumSetBlockingModeType, + }); + const stepOne: ActionNode = createActionNode(axiumSetBlockingMode({concepts}), { successNode: stepTwo, successNotes: { preposition: 'Immediately' }, failureNode: null, semaphore: getSemaphore(concepts, axiumName, axiumSetBlockingModeType), - payload: createPayload({concepts}), - }; + }); const params: ActionStrategyParameters = { topic: addConceptsToAddQueThenBlockTopic, @@ -47,8 +42,7 @@ export function addConceptsFromQueThenUnblockStrategy(action$: Subject, const setDefaultModeSemaphore = getSemaphore(conceptualSet, axiumName, axiumSetDefaultModeType); const openSemaphore = getSemaphore(conceptualSet, axiumName, axiumOpenType); - const stepThree: ActionNode = { - actionType: axiumOpenType, + const stepThree: ActionNode = createActionNode(axiumOpen(true), { successNode: null, successNotes: { preposition: 'Reinstate', @@ -56,27 +50,23 @@ export function addConceptsFromQueThenUnblockStrategy(action$: Subject, }, failureNode: null, semaphore: openSemaphore, - }; - const stepTwo: ActionNode = { - actionType: axiumSetDefaultModeType, + }); + const stepTwo: ActionNode = createActionNode(axiumSetDefaultMode({concepts: conceptualSet}), { semaphore: setDefaultModeSemaphore, successNode: stepThree, successNotes: { preposition: 'Then' }, failureNode: null, - payload: createPayload({concepts: conceptualSet}), - }; - const stepOne: ActionNode = { - actionType: axiumAddConceptFromQueType, + }); + const stepOne: ActionNode = createActionNode(axiumAddConceptFromQue(),{ semaphore: addConceptsFromQueSemaphore, successNode: stepTwo, successNotes: { preposition: 'First' }, failureNode: null, - payload: createPayload({action$}), - }; + }); const params: ActionStrategyParameters = { topic: addConceptsFromQueThenUnblockTopic, diff --git a/src/concepts/axium/strategies/initialization.strategy.ts b/src/concepts/axium/strategies/initialization.strategy.ts index 76c5e4e..73b7a3a 100644 --- a/src/concepts/axium/strategies/initialization.strategy.ts +++ b/src/concepts/axium/strategies/initialization.strategy.ts @@ -1,11 +1,10 @@ -import { createStrategy, ActionNode, ActionStrategy, ActionStrategyParameters } from '../../../model/actionStrategy'; +import { createStrategy, ActionNode, ActionStrategy, ActionStrategyParameters, createActionNode } from '../../../model/actionStrategy'; import { Concept } from '../../../model/concept'; import { getSemaphore } from '../../../model/action'; -import { OpenPayload, axiumOpenType } from '../qualities/open.quality'; -import { InitializePrinciplesPayload, axiumInitializePrinciplesType } from '../qualities/initializePrinciples.quality'; -import { SetDefaultModePayload, axiumSetDefaultModeType } from '../qualities/setDefaultMode.quality'; +import { axiumOpen, axiumOpenType } from '../qualities/open.quality'; +import { axiumInitializePrinciples, axiumInitializePrinciplesType } from '../qualities/initializePrinciples.quality'; +import { axiumSetDefaultMode, axiumSetDefaultModeType } from '../qualities/setDefaultMode.quality'; import { axiumName } from '../axium.concept'; -import { createPayload } from '../../../model/selector'; export const initializeTopic = 'Axium Initialization Strategy'; export function initializationStrategy(concepts: Concept[]): ActionStrategy { @@ -13,8 +12,7 @@ export function initializationStrategy(concepts: Concept[]): ActionStrategy { const setDefaultModeSemaphore = getSemaphore(concepts, axiumName, axiumSetDefaultModeType); const openSemaphore = getSemaphore(concepts, axiumName, axiumOpenType); - const stepThree: ActionNode = { - actionType: axiumOpenType, + const stepThree: ActionNode = createActionNode(axiumOpen(true), { semaphore: openSemaphore, successNode: null, successNotes: { @@ -22,28 +20,23 @@ export function initializationStrategy(concepts: Concept[]): ActionStrategy { denoter: 'to Notify Subscribers of State changes.' }, failureNode: null, - payload: createPayload({open: true}), - }; - const stepTwo: ActionNode = { - actionType: axiumSetDefaultModeType, + }); + const stepTwo: ActionNode = createActionNode(axiumSetDefaultMode({concepts}), { semaphore: setDefaultModeSemaphore, successNode: stepThree, successNotes: { preposition: 'Then' }, failureNode: null, - payload: createPayload({concepts}), - }; - const stepOne: ActionNode = { - actionType: axiumInitializePrinciplesType, + }); + const stepOne: ActionNode = createActionNode(axiumInitializePrinciples({concepts}),{ semaphore: initSemaphore, successNode: stepTwo, successNotes: { preposition: 'Begin with' }, failureNode: null, - payload: createPayload({concepts}), - }; + }); const params: ActionStrategyParameters = { topic: initializeTopic, diff --git a/src/concepts/axium/strategies/removeConcept.strategy.ts b/src/concepts/axium/strategies/removeConcept.strategy.ts index 7302c4c..bb67794 100644 --- a/src/concepts/axium/strategies/removeConcept.strategy.ts +++ b/src/concepts/axium/strategies/removeConcept.strategy.ts @@ -1,33 +1,28 @@ -import { createStrategy, ActionNode, ActionStrategy, ActionStrategyParameters } from '../../../model/actionStrategy'; +import { createStrategy, ActionNode, ActionStrategy, ActionStrategyParameters, createActionNode } from '../../../model/actionStrategy'; import { Concept } from '../../../model/concept'; import { getSemaphore } from '../../../model/action'; -import { axiumRemoveConceptsViaQueType } from '../qualities/removeConceptsViaQue.quality'; -import { AppendConceptsToRemoveQuePayload, axiumAppendConceptsToRemoveQueType } from '../qualities/appendConceptsToRemoveQue.quality'; -import { SetBlockingModePayload, axiumSetBlockingModeType } from '../qualities/setBlockingMode.quality'; -import { axiumOpenType } from '../qualities/open.quality'; -import { SetDefaultModePayload, axiumSetDefaultModeType } from '../qualities/setDefaultMode.quality'; +import { axiumRemoveConceptsViaQue, axiumRemoveConceptsViaQueType } from '../qualities/removeConceptsViaQue.quality'; +import { axiumAppendConceptsToRemoveQue, axiumAppendConceptsToRemoveQueType } from '../qualities/appendConceptsToRemoveQue.quality'; +import { axiumSetBlockingMode, axiumSetBlockingModeType } from '../qualities/setBlockingMode.quality'; +import { axiumOpen, axiumOpenType } from '../qualities/open.quality'; +import { axiumSetDefaultMode, axiumSetDefaultModeType } from '../qualities/setDefaultMode.quality'; import { axiumName } from '../axium.concept'; -import { createPayload } from '../../../model/selector'; export const addConceptsToRemovalQueThenBlockTopic = 'Add Concepts to removal Que then set Axium Mode to Blocking'; export function addConceptsToRemovalQueThenBlockStrategy(concepts: Concept[], targetConcepts: Concept[]) { const setBlockingModeSemaphore = getSemaphore(concepts, axiumName, axiumSetBlockingModeType); const appendConceptsToRemoveQueSemaphore = getSemaphore(concepts, axiumName, axiumAppendConceptsToRemoveQueType); - const stepTwo: ActionNode = { - actionType: axiumAppendConceptsToRemoveQueType, + const stepTwo: ActionNode = createActionNode(axiumAppendConceptsToRemoveQue({concepts: targetConcepts}), { semaphore: appendConceptsToRemoveQueSemaphore, successNode: null, failureNode: null, - payload: createPayload({concepts: targetConcepts}) - }; - const stepOne: ActionNode = { - actionType: axiumSetBlockingModeType, + }); + const stepOne: ActionNode = createActionNode(axiumSetBlockingMode({concepts}), { semaphore: setBlockingModeSemaphore, successNode: stepTwo, failureNode: null, - payload: createPayload({concepts}) - }; + }); const params: ActionStrategyParameters = { topic: addConceptsToRemovalQueThenBlockTopic, initialNode: stepOne @@ -41,8 +36,7 @@ export function removeConceptsViaQueThenUnblockStrategy(concepts: Concept[]): Ac const setDefaultModeSemaphore = getSemaphore(concepts, axiumName, axiumSetDefaultModeType); const openSemaphore = getSemaphore(concepts, axiumName, axiumOpenType); - const stepThree: ActionNode = { - actionType: axiumOpenType, + const stepThree: ActionNode = createActionNode(axiumOpen(true), { semaphore: openSemaphore, successNode: null, successNotes: { @@ -50,26 +44,23 @@ export function removeConceptsViaQueThenUnblockStrategy(concepts: Concept[]): Ac denoter: 'State.' }, failureNode: null, - }; - const stepTwo: ActionNode = { - actionType: axiumSetDefaultModeType, + }); + const stepTwo: ActionNode = createActionNode(axiumSetDefaultMode({concepts}), { semaphore: setDefaultModeSemaphore, successNode: stepThree, successNotes: { preposition: 'Then' }, failureNode: null, - payload: createPayload({concepts}), - }; - const stepOne: ActionNode = { - actionType: axiumRemoveConceptsViaQueType, + }); + const stepOne: ActionNode = createActionNode(axiumRemoveConceptsViaQue(), { semaphore: removeConceptsViaQueSemaphore, successNode: stepTwo, successNotes: { preposition: 'To Begin' }, failureNode: null, - }; + }); const params: ActionStrategyParameters = { topic: removeConceptsViaQueThenUnblockTopic, diff --git a/src/concepts/chain/qualities/prepareChain.quality.ts b/src/concepts/chain/qualities/prepareChain.quality.ts index 566482c..0ba3016 100644 --- a/src/concepts/chain/qualities/prepareChain.quality.ts +++ b/src/concepts/chain/qualities/prepareChain.quality.ts @@ -1,15 +1,13 @@ -import { Action, ActionType, prepareActionCreator } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { createQuality } from '../../../model/concept'; import { selectPayload } from '../../../model/selector'; import { Chain } from '../chain.concept'; -export const chainDispatchActionsType: ActionType = 'dispatch Actions from Action Que via Payload to be Chained'; - -export const chainDispatchActions = prepareActionCreator(chainDispatchActionsType); - export type ChainDispatchActionsPayload = { actions: Action[] } +export const chainDispatchActionsType: ActionType = 'dispatch Actions from Action Que via Payload to be Chained'; +export const chainDispatchActions = prepareActionWithPayloadCreator(chainDispatchActionsType); export function prepareChainReducer(state: Chain, action: Action) { const payload = selectPayload(action); diff --git a/src/concepts/counter/qualities/add.quality.ts b/src/concepts/counter/qualities/add.quality.ts index daeb53c..be146c1 100644 --- a/src/concepts/counter/qualities/add.quality.ts +++ b/src/concepts/counter/qualities/add.quality.ts @@ -3,10 +3,9 @@ import { Action, ActionType, prepareActionCreator } from '../../../model/action' import { Method, MethodCreator } from '../../../model/concept'; import { strategySuccess } from '../../../model/actionStrategy'; import { Counter } from '../counter.concept'; -import { createAction } from '../../../model/action'; import { createQuality } from '../../../model/concept'; import { counterSelectCount } from '../counter.selector'; -import { axiumConcludeType } from '../../axium/qualities/conclude.quality'; +import { axiumConclude } from '../../axium/qualities/conclude.quality'; export const counterAddType: ActionType = 'Counter Add'; @@ -26,7 +25,7 @@ const addMethodCreator: MethodCreator = () => { if (action.strategy) { return strategySuccess(action.strategy); } - return createAction(axiumConcludeType); + return axiumConclude(); }) ); return [ diff --git a/src/concepts/counter/qualities/setCount.quality.ts b/src/concepts/counter/qualities/setCount.quality.ts index a47aeaf..7508f3c 100644 --- a/src/concepts/counter/qualities/setCount.quality.ts +++ b/src/concepts/counter/qualities/setCount.quality.ts @@ -1,5 +1,5 @@ import { defaultMethodCreator, defaultReducer } from '../../../model/concept'; -import { Action, prepareActionCreator } from '../../../model/action'; +import { Action, prepareActionWithPayloadCreator } from '../../../model/action'; import { createQuality } from '../../../model/concept'; import { Counter } from '../counter.concept'; import { counterSelectCount } from '../counter.selector'; @@ -7,10 +7,10 @@ import { selectPayload } from '../../../model/selector'; export const counterSetCountType = 'set Count'; -export const counterSetCount = prepareActionCreator(counterSetCountType); export type SetCountPayload = { newCount: number } +export const counterSetCount = prepareActionWithPayloadCreator(counterSetCountType); export function setCountReducer(state: Counter, action: Action) { const payload = selectPayload(action); diff --git a/src/concepts/counter/qualities/subtract.quality.ts b/src/concepts/counter/qualities/subtract.quality.ts index ebd0455..c751d5c 100644 --- a/src/concepts/counter/qualities/subtract.quality.ts +++ b/src/concepts/counter/qualities/subtract.quality.ts @@ -5,7 +5,7 @@ import { Counter } from '../counter.concept'; import { Action, ActionType, createAction, prepareActionCreator } from '../../../model/action'; import { createQuality } from '../../../model/concept'; import { counterSelectCount } from '../counter.selector'; -import { axiumConcludeType } from '../../axium/qualities/conclude.quality'; +import { axiumConclude } from '../../axium/qualities/conclude.quality'; export const counterSubtractType: ActionType = 'Counter Subtract'; @@ -25,7 +25,7 @@ const subtractMethodCreator: MethodCreator = () => { if (action.strategy) { return strategySuccess(action.strategy); } - return createAction(axiumConcludeType); + return axiumConclude(); }) ); return [ diff --git a/src/concepts/counter/strategies/counting.strategy.ts b/src/concepts/counter/strategies/counting.strategy.ts index a358b6c..72864bc 100644 --- a/src/concepts/counter/strategies/counting.strategy.ts +++ b/src/concepts/counter/strategies/counting.strategy.ts @@ -1,58 +1,52 @@ -import { createStrategy, ActionNode, ActionStrategy, ActionStrategyParameters } from '../../../model/actionStrategy'; +import { createStrategy, ActionNode, ActionStrategy, ActionStrategyParameters, createActionNode } from '../../../model/actionStrategy'; import { Concept} from '../../../model/concept'; import { getSemaphore } from '../../../model/action'; -import { counterAddType } from '../qualities/add.quality'; -import { counterSubtractType } from '../qualities/subtract.quality'; +import { counterAdd, counterAddType } from '../qualities/add.quality'; +import { counterSubtract, counterSubtractType } from '../qualities/subtract.quality'; import { counterName } from '../counter.concept'; -import { counterSelectCount } from '../counter.selector'; export const countingTopic = 'Counting Strategy'; export function countingStrategy(): ActionStrategy { - const stepFive: ActionNode = { - actionType: counterSubtractType, + const stepFive: ActionNode = createActionNode(counterSubtract(), { successNode: null, successNotes: { preposition: 'and finally', denoter: 'One.', }, failureNode: null, - }; - const stepFour: ActionNode = { - actionType: counterAddType, + }); + const stepFour: ActionNode = createActionNode(counterAdd(), { successNode: stepFive, successNotes: { preposition: '', denoter: 'One;', }, failureNode: null, - }; - const stepThree: ActionNode = { - actionType: counterAddType, + }); + const stepThree: ActionNode = createActionNode(counterAdd(), { successNode: stepFour, successNotes: { preposition: '', denoter: 'One;', }, failureNode: null, - }; - const stepTwo: ActionNode = { - actionType: counterSubtractType, + }); + const stepTwo: ActionNode = createActionNode(counterSubtract(), { successNode: stepThree, successNotes: { preposition: '', denoter: 'One;', }, failureNode: null, - }; - const stepOne: ActionNode = { - actionType: counterAddType, + }); + const stepOne: ActionNode = createActionNode(counterAdd(), { successNode: stepTwo, successNotes: { preposition: '', denoter: 'One;', }, failureNode: null, - }; + }); const params: ActionStrategyParameters = { topic: countingTopic, @@ -66,8 +60,7 @@ export const primedCountingTopic = 'Counting Strategy with Primed Actions'; export function primedCountingStrategy(concepts: Concept[]): ActionStrategy { const addSemaphore = getSemaphore(concepts, counterName, counterAddType); const subtractSemaphore = getSemaphore(concepts, counterName, counterSubtractType); - const stepFour: ActionNode = { - actionType: counterAddType, + const stepFour: ActionNode = createActionNode(counterAdd(), { semaphore: addSemaphore, successNode: null, successNotes: { @@ -75,9 +68,8 @@ export function primedCountingStrategy(concepts: Concept[]): ActionStrategy { denoter: 'One.', }, failureNode: null, - }; - const stepThree: ActionNode = { - actionType: counterAddType, + }); + const stepThree: ActionNode = createActionNode(counterAdd(), { semaphore: addSemaphore, successNode: stepFour, successNotes: { @@ -85,9 +77,8 @@ export function primedCountingStrategy(concepts: Concept[]): ActionStrategy { denoter: 'One;', }, failureNode: null, - }; - const stepTwo: ActionNode = { - actionType: counterSubtractType, + }); + const stepTwo: ActionNode = createActionNode(counterSubtract(), { semaphore: subtractSemaphore, successNode: stepThree, successNotes: { @@ -95,9 +86,8 @@ export function primedCountingStrategy(concepts: Concept[]): ActionStrategy { denoter: 'One;', }, failureNode: null, - }; - const stepOne: ActionNode = { - actionType: counterAddType, + }); + const stepOne: ActionNode = createActionNode(counterAdd(), { semaphore: subtractSemaphore, successNode: stepTwo, successNotes: { @@ -105,7 +95,7 @@ export function primedCountingStrategy(concepts: Concept[]): ActionStrategy { denoter: 'One;', }, failureNode: null, - }; + }); const params: ActionStrategyParameters = { topic: primedCountingTopic, diff --git a/src/concepts/experiment/qualities/checkIn.quality.ts b/src/concepts/experiment/qualities/checkInStrategy.quality.ts similarity index 68% rename from src/concepts/experiment/qualities/checkIn.quality.ts rename to src/concepts/experiment/qualities/checkInStrategy.quality.ts index 1c1926b..c2f45d1 100644 --- a/src/concepts/experiment/qualities/checkIn.quality.ts +++ b/src/concepts/experiment/qualities/checkInStrategy.quality.ts @@ -5,11 +5,11 @@ import { strategySuccess } from '../../../model/actionStrategy'; import { axiumConcludeType } from '../../axium/qualities/conclude.quality'; import { ExperimentActionQueState } from '../experiment.concept'; -export const experimentCheckInType = 'Experiment Check in Action'; +export const experimentCheckInStrategyType = 'Experiment Check in Action'; -export const experimentCheckIn = prepareActionCreator(experimentCheckInType); +export const experimentCheckInStrategy = prepareActionCreator(experimentCheckInStrategyType); -export function checkInReducer(state: ExperimentActionQueState, action: Action): ExperimentActionQueState { +export function checkInStrategyReducer(state: ExperimentActionQueState, action: Action): ExperimentActionQueState { if (action.strategy) { // console.log('Check in reducer', action); const nextAction = strategySuccess(action.strategy); @@ -26,7 +26,7 @@ export function checkInReducer(state: ExperimentActionQueState, action: Action): }; } -export const checkInQuality = createQuality( - experimentCheckInType, - checkInReducer, +export const checkInStrategyQuality = createQuality( + experimentCheckInStrategyType, + checkInStrategyReducer, ); diff --git a/src/concepts/experiment/strategies/experimentCounting.strategy.ts b/src/concepts/experiment/strategies/experimentCounting.strategy.ts index 589a5b6..917009d 100644 --- a/src/concepts/experiment/strategies/experimentCounting.strategy.ts +++ b/src/concepts/experiment/strategies/experimentCounting.strategy.ts @@ -1,22 +1,20 @@ -import { createStrategy, ActionNode, ActionStrategy, ActionStrategyParameters } from '../../../model/actionStrategy'; +import { createStrategy, ActionNode, ActionStrategy, ActionStrategyParameters, createActionNode } from '../../../model/actionStrategy'; import { Concept} from '../../../model/concept'; import { getSemaphore } from '../../../model/action'; -import { counterAddType } from '../../counter/qualities/add.quality'; -import { counterSubtractType } from '../../counter/qualities/subtract.quality'; +import { counterAdd, counterAddType } from '../../counter/qualities/add.quality'; +import { counterSubtract, counterSubtractType } from '../../counter/qualities/subtract.quality'; import { counterName } from '../../counter/counter.concept'; import { counterSelectCount } from '../../counter/counter.selector'; -import { ownershipBackTrackType } from '../../ownership/qualities/backTrack.quality'; +import { ownershipBackTrack, ownershipBackTrackType } from '../../ownership/qualities/backTrack.quality'; import { ownershipName } from '../../ownership/ownership.concept'; export const experimentCountingTopic = 'Counting Strategy'; export function experimentCountingStrategy(): ActionStrategy { - const backTrack: ActionNode = { - actionType: ownershipBackTrackType, + const backTrack = createActionNode(ownershipBackTrack(), { successNode: null, failureNode: null, - }; - const stepFive: ActionNode = { - actionType: counterSubtractType, + }); + const stepFive = createActionNode(counterSubtract(),{ successNode: null, successNotes: { preposition: 'and finally', @@ -25,9 +23,8 @@ export function experimentCountingStrategy(): ActionStrategy { failureNode: backTrack, agreement: 1000, keyedSelectors: [counterSelectCount] - }; - const stepFour: ActionNode = { - actionType: counterAddType, + }); + const stepFour = createActionNode(counterAdd(), { successNode: stepFive, successNotes: { preposition: '', @@ -36,9 +33,8 @@ export function experimentCountingStrategy(): ActionStrategy { failureNode: backTrack, agreement: 1000, keyedSelectors: [counterSelectCount] - }; - const stepThree: ActionNode = { - actionType: counterAddType, + }); + const stepThree = createActionNode(counterAdd(), { successNode: stepFour, successNotes: { preposition: '', @@ -47,9 +43,8 @@ export function experimentCountingStrategy(): ActionStrategy { failureNode: backTrack, agreement: 1000, keyedSelectors: [counterSelectCount] - }; - const stepTwo: ActionNode = { - actionType: counterSubtractType, + }); + const stepTwo = createActionNode(counterSubtract(), { successNode: stepThree, successNotes: { preposition: '', @@ -58,9 +53,8 @@ export function experimentCountingStrategy(): ActionStrategy { failureNode: backTrack, agreement: 1000, keyedSelectors: [counterSelectCount] - }; - const stepOne: ActionNode = { - actionType: counterAddType, + }); + const stepOne = createActionNode(counterAdd(), { successNode: stepTwo, successNotes: { preposition: '', @@ -69,7 +63,7 @@ export function experimentCountingStrategy(): ActionStrategy { failureNode: backTrack, agreement: 1000, keyedSelectors: [counterSelectCount] - }; + }); const params: ActionStrategyParameters = { topic: experimentCountingTopic, @@ -84,14 +78,12 @@ export function experimentPrimedCountingStrategy(concepts: Concept[]): ActionStr const addSemaphore = getSemaphore(concepts, counterName, counterAddType); const subtractSemaphore = getSemaphore(concepts, counterName, counterSubtractType); const backTrackSemaphore = getSemaphore(concepts, ownershipName, ownershipBackTrackType); - const backTrack: ActionNode = { - actionType: ownershipBackTrackType, + const backTrack = createActionNode(ownershipBackTrack(), { semaphore: backTrackSemaphore, successNode: null, failureNode: null, - }; - const stepFour: ActionNode = { - actionType: counterAddType, + }); + const stepFour = createActionNode(counterAdd(), { semaphore: addSemaphore, successNode: null, successNotes: { @@ -101,9 +93,8 @@ export function experimentPrimedCountingStrategy(concepts: Concept[]): ActionStr failureNode: backTrack, agreement: 1000, keyedSelectors: [counterSelectCount] - }; - const stepThree: ActionNode = { - actionType: counterAddType, + }); + const stepThree = createActionNode(counterAdd(), { semaphore: addSemaphore, successNode: stepFour, successNotes: { @@ -113,9 +104,8 @@ export function experimentPrimedCountingStrategy(concepts: Concept[]): ActionStr failureNode: backTrack, agreement: 1000, keyedSelectors: [counterSelectCount] - }; - const stepTwo: ActionNode = { - actionType: counterSubtractType, + }); + const stepTwo = createActionNode(counterSubtract(), { semaphore: subtractSemaphore, successNode: stepThree, successNotes: { @@ -125,9 +115,8 @@ export function experimentPrimedCountingStrategy(concepts: Concept[]): ActionStr failureNode: backTrack, agreement: 1000, keyedSelectors: [counterSelectCount] - }; - const stepOne: ActionNode = { - actionType: counterAddType, + }); + const stepOne = createActionNode(counterAdd(), { semaphore: subtractSemaphore, successNode: stepTwo, successNotes: { @@ -137,7 +126,7 @@ export function experimentPrimedCountingStrategy(concepts: Concept[]): ActionStr failureNode: backTrack, agreement: 1000, keyedSelectors: [counterSelectCount] - }; + }); const params: ActionStrategyParameters = { topic: experimentPrimedCountingTopic, diff --git a/src/concepts/experiment/strategies/puntCounting.strategy.ts b/src/concepts/experiment/strategies/puntCounting.strategy.ts index a66aeb9..6fffbf7 100644 --- a/src/concepts/experiment/strategies/puntCounting.strategy.ts +++ b/src/concepts/experiment/strategies/puntCounting.strategy.ts @@ -1,16 +1,15 @@ -import { ActionNode, ActionStrategy, ActionStrategyParameters, createStrategy, puntStrategy } from '../../../model/actionStrategy'; +import { ActionNode, ActionStrategy, ActionStrategyParameters, createActionNode, createStrategy, puntStrategy } from '../../../model/actionStrategy'; import { counterSelectCount } from '../../counter/counter.selector'; -import { experimentCheckInType } from '../qualities/checkIn.quality'; +import { experimentCheckInStrategy } from '../qualities/checkInStrategy.quality'; import { experimentCountingStrategy } from './experimentCounting.strategy'; export const puntCountingStrategyTopic = 'This will Punt the Counting Strategy into the Experiment\'s Action Que'; export function puntCountingStrategy(): ActionStrategy { - const stepOne: ActionNode = { - actionType: experimentCheckInType, + const stepOne: ActionNode = createActionNode(experimentCheckInStrategy(), { successNode: null, failureNode: null, keyedSelectors: [counterSelectCount] - }; + }); const params: ActionStrategyParameters = { topic: puntCountingStrategyTopic, diff --git a/src/concepts/ownership/qualities/backTrack.quality.ts b/src/concepts/ownership/qualities/backTrack.quality.ts index 2a89518..1b537d6 100644 --- a/src/concepts/ownership/qualities/backTrack.quality.ts +++ b/src/concepts/ownership/qualities/backTrack.quality.ts @@ -1,10 +1,11 @@ import { Method, MethodCreator, createQuality, defaultMethodCreator, defaultReducer } from '../../../model/concept'; -import { Action, ActionType, createAction } from '../../../model/action'; +import { Action, ActionType, prepareActionCreator } from '../../../model/action'; import { Subject, map } from 'rxjs'; import { backTrack } from '../../../model/actionStrategy'; -import { axiumConcludeType } from '../../axium/qualities/conclude.quality'; +import { axiumConclude } from '../../axium/qualities/conclude.quality'; export const ownershipBackTrackType: ActionType = 'backtracking to previous ActionNode'; +export const ownershipBackTrack = prepareActionCreator(ownershipBackTrackType); const createBackTrackMethodCreator: MethodCreator = () => { const backTrackSubject = new Subject(); @@ -14,7 +15,7 @@ const createBackTrackMethodCreator: MethodCreator = () => { const newAction = backTrack(action.strategy); return newAction; } - return createAction(axiumConcludeType); + return axiumConclude(); }) ); return [ @@ -23,7 +24,6 @@ const createBackTrackMethodCreator: MethodCreator = () => { ]; }; - export const backTrackQuality = createQuality( ownershipBackTrackType, defaultReducer, diff --git a/src/concepts/ownership/qualities/clearPayloadStubs.quality.ts b/src/concepts/ownership/qualities/clearPayloadStubs.quality.ts index b39d4b3..191502f 100644 --- a/src/concepts/ownership/qualities/clearPayloadStubs.quality.ts +++ b/src/concepts/ownership/qualities/clearPayloadStubs.quality.ts @@ -1,11 +1,12 @@ import { createQuality, defaultMethodCreator } from '../../../model/concept'; -import { Action, ActionType } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { OwnershipState } from '../ownership.concept'; import { OwnershipTicket, OwnershipTicketStub } from '../../../model/ownership'; import { selectPayload } from '../../../model/selector'; -export const ownershipClearPayloadStubsType: ActionType = 'clear payload Stubs from Ownership Ledger'; export type ClearPayloadStubsPayload = OwnershipTicketStub[]; +export const ownershipClearPayloadStubsType: ActionType = 'clear payload Stubs from Ownership Ledger'; +export const ownershipClearPayloadStubs = prepareActionWithPayloadCreator(ownershipClearPayloadStubsType); export function clearPayloadStubsReducer(state: OwnershipState, action: Action): OwnershipState { const stubs = selectPayload(action); diff --git a/src/concepts/ownership/qualities/clearPendingActions.quality.ts b/src/concepts/ownership/qualities/clearPendingActions.quality.ts index ec159c9..0f2beef 100644 --- a/src/concepts/ownership/qualities/clearPendingActions.quality.ts +++ b/src/concepts/ownership/qualities/clearPendingActions.quality.ts @@ -1,8 +1,9 @@ import { createQuality, defaultMethodCreator } from '../../../model/concept'; -import { Action, ActionType } from '../../../model/action'; +import { Action, ActionType, prepareActionCreator } from '../../../model/action'; import { OwnershipState } from '../ownership.concept'; export const ownershipClearPendingActionsType: ActionType = 'clear Ownership\'s Pending Actions'; +export const ownershipClearPendingActions = prepareActionCreator(ownershipClearPendingActionsType); export function clearPendingActionsReducer(state: OwnershipState, _: Action): OwnershipState { return { diff --git a/src/concepts/ownership/qualities/clearPendingActionsOfStrategy.quality.ts b/src/concepts/ownership/qualities/clearPendingActionsOfStrategy.quality.ts index 096cc01..ad67118 100644 --- a/src/concepts/ownership/qualities/clearPendingActionsOfStrategy.quality.ts +++ b/src/concepts/ownership/qualities/clearPendingActionsOfStrategy.quality.ts @@ -1,11 +1,13 @@ import { createQuality, defaultMethodCreator } from '../../../model/concept'; -import { Action, ActionType } from '../../../model/action'; +import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action'; import { OwnershipState } from '../ownership.concept'; import { ActionStrategyTopic } from '../../../model/actionStrategy'; import { selectPayload } from '../../../model/selector'; -export const ownershipClearPendingActionsOfStrategyType: ActionType = 'clear Ownership\'s Pending Actions of Strategy Topic'; export type ClearPendingActionsOfStrategyPayload = ActionStrategyTopic; +export const ownershipClearPendingActionsOfStrategyType: ActionType = 'clear Ownership\'s Pending Actions of Strategy Topic'; +export const ownershipClearPendingActionsOfStrategy = + prepareActionWithPayloadCreator(ownershipClearPendingActionsOfStrategyType); export function clearPendingActionsOfStrategyReducer(state: OwnershipState, action: Action): OwnershipState { const topic = selectPayload(action); diff --git a/src/concepts/ownership/qualities/clearStrategyStubsFromLedgerAndSelf.quality.ts b/src/concepts/ownership/qualities/clearStrategyStubsFromLedgerAndSelf.quality.ts index 783920b..4235cca 100644 --- a/src/concepts/ownership/qualities/clearStrategyStubsFromLedgerAndSelf.quality.ts +++ b/src/concepts/ownership/qualities/clearStrategyStubsFromLedgerAndSelf.quality.ts @@ -1,12 +1,13 @@ import { Method, MethodCreator, createQuality, defaultMethodCreator } from '../../../model/concept'; -import { Action, ActionType, createAction } from '../../../model/action'; +import { Action, ActionType, createAction, prepareActionCreator } from '../../../model/action'; import { OwnershipState } from '../ownership.concept'; import { OwnershipTicket } from '../../../model/ownership'; import { Subject, map } from 'rxjs'; import { strategySuccess } from '../../../model/actionStrategy'; -import { axiumConcludeType } from '../../axium/qualities/conclude.quality'; +import { axiumConclude } from '../../axium/qualities/conclude.quality'; export const ownershipClearStrategyStubsFromLedgerAndSelfType: ActionType = 'clear current Strategy Stubs from Ownership Ledger and Itself'; +export const ownershipClearStrategyStubsFromLedgerAndSelf = prepareActionCreator(ownershipClearStrategyStubsFromLedgerAndSelfType); const createClearStrategyStubsFromLedgerAndSelfMethodCreator: MethodCreator = () => { const logSubject = new Subject(); @@ -16,7 +17,7 @@ const createClearStrategyStubsFromLedgerAndSelfMethodCreator: MethodCreator = () action.strategy.stubs = undefined; return strategySuccess(action.strategy); } - return createAction(axiumConcludeType); + return axiumConclude(); }) ); return [ diff --git a/src/concepts/ownership/qualities/initializeOwnership.quality.ts b/src/concepts/ownership/qualities/initializeOwnership.quality.ts index 6a5f4b9..1d4d61a 100644 --- a/src/concepts/ownership/qualities/initializeOwnership.quality.ts +++ b/src/concepts/ownership/qualities/initializeOwnership.quality.ts @@ -1,8 +1,9 @@ import { createQuality, defaultMethodCreator } from '../../../model/concept'; -import { Action, ActionType } from '../../../model/action'; +import { Action, ActionType, prepareActionCreator } from '../../../model/action'; import { OwnershipState } from '../ownership.concept'; export const ownershipInitializeOwnershipType: ActionType = 'Ownership Initialize to True to enable Ownership Principle'; +export const ownershipInitializeOwnership = prepareActionCreator(ownershipInitializeOwnershipType); export function initializeOwnershipReducer(state: OwnershipState, _: Action) { return { diff --git a/src/concepts/ownership/qualities/resetOwnershipLedger.quality.ts b/src/concepts/ownership/qualities/resetOwnershipLedger.quality.ts index 515c22a..cf447ec 100644 --- a/src/concepts/ownership/qualities/resetOwnershipLedger.quality.ts +++ b/src/concepts/ownership/qualities/resetOwnershipLedger.quality.ts @@ -1,9 +1,10 @@ import { createQuality, defaultMethodCreator } from '../../../model/concept'; -import { Action, ActionType } from '../../../model/action'; +import { Action, ActionType, prepareActionCreator } from '../../../model/action'; import { OwnershipState } from '../ownership.concept'; import { createOwnershipLedger } from '../../../model/ownership'; export const ownershipResetOwnershipLedgerType: ActionType = 'reset Ownership Ledger'; +export const ownershipResetOwnershipLedger = prepareActionCreator(ownershipResetOwnershipLedgerType); export function resetOwnershipLedgerReducer(state: OwnershipState, _: Action): OwnershipState { return { diff --git a/src/concepts/ownership/strategies/setOwnerShipMode.strategy.ts b/src/concepts/ownership/strategies/setOwnerShipMode.strategy.ts index f25d88e..752acc4 100644 --- a/src/concepts/ownership/strategies/setOwnerShipMode.strategy.ts +++ b/src/concepts/ownership/strategies/setOwnerShipMode.strategy.ts @@ -1,12 +1,10 @@ -import { createStrategy, ActionNode, ActionStrategy, ActionStrategyParameters } from '../../../model/actionStrategy'; +import { createStrategy, ActionNode, ActionStrategy, ActionStrategyParameters, createActionNode } from '../../../model/actionStrategy'; import { Concept } from '../../../model/concept'; import { getSemaphore } from '../../../model/action'; -import { ownershipInitializeOwnershipType } from '../qualities/initializeOwnership.quality'; -import { SetModePayload, axiumSetModeType } from '../../axium/qualities/setMode.quality'; +import { ownershipInitializeOwnership, ownershipInitializeOwnershipType } from '../qualities/initializeOwnership.quality'; +import { axiumSetMode, axiumSetModeType } from '../../axium/qualities/setMode.quality'; import { ownershipName } from '../ownership.concept'; -import { SetDefaultModeIndexPayload, axiumSetDefaultModeIndexType } from '../../axium/qualities/setDefaultModeIndex.quality'; import { AxiumState } from '../../axium/axium.concept'; -import { createPayload } from '../../../model/selector'; export const setOwnerShipModeTopic = 'Axium set Mode to Ownership then Initialize Ownership Principle'; export function setOwnershipModeStrategy(concepts: Concept[], modeName: string): ActionStrategy { @@ -19,25 +17,22 @@ export function setOwnershipModeStrategy(concepts: Concept[], modeName: string): } }); - const stepTwo: ActionNode = { - actionType: ownershipInitializeOwnershipType, + const stepTwo: ActionNode = createActionNode(ownershipInitializeOwnership(), { semaphore: initializeOwnershipSemaphore, successNode: null, successNotes: { preposition: 'Set', }, failureNode: null, - }; - const stepOne: ActionNode = { - actionType: axiumSetModeType, + }); + const stepOne: ActionNode = createActionNode(axiumSetMode({ modeIndex: ownershipModeIndex, modeName }), { semaphore: setModeSemaphore, successNode: stepTwo, successNotes: { preposition: 'Successfully' }, failureNode: null, - payload: createPayload({ modeIndex: ownershipModeIndex, modeName }), - }; + }); const params: ActionStrategyParameters = { topic: setOwnerShipModeTopic, initialNode: stepOne, diff --git a/src/index.ts b/src/index.ts index 6bfa9e7..bbc2843 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,7 +25,7 @@ export type { MethodCreator } from './model/concept'; export type { KeyedSelector } from './model/selector'; -export { selectState, selectConcept, selectSlice, createPayload, selectPayload } from './model/selector'; +export { selectState, selectConcept, selectSlice, selectPayload } from './model/selector'; export { PrincipleFunction } from './model/principle'; export type { dispatchOptions, Staging, UnifiedSubject } from './model/unifiedSubject'; export type { OwnershipTicket, OwnershipTicketStub, OwnershipLedger } from './model/ownership'; @@ -36,15 +36,19 @@ export { AxiumState, axiumName, createAxiumConcept } from './concepts/axium/axiu export { blockingMode, permissiveMode } from './concepts/axium/axium.mode'; export { axiumSelectOpen, axiumSelectLastStrategy, axiumSelectBadActions, axiumSelectBadPlans } from './concepts/axium/axium.selector'; // Qualities -export { axiumConcludeType } from './concepts/axium/qualities/conclude.quality'; +export { axiumConclude, axiumConcludeType } from './concepts/axium/qualities/conclude.quality'; export { axiumOpen, axiumOpenType } from './concepts/axium/qualities/open.quality'; export { axiumLog, axiumLogType } from './concepts/axium/qualities/log.quality'; export { axiumClose, axiumCloseType } from './concepts/axium/qualities/close.quality'; -export { axiumSetModeType, SetModePayload } from './concepts/axium/qualities/setMode.quality'; -export { axiumSetDefaultModeIndexType, SetDefaultModeIndexPayload } from './concepts/axium/qualities/setDefaultModeIndex.quality'; +export { axiumSetMode, axiumSetModeType, SetModePayload } from './concepts/axium/qualities/setMode.quality'; +export { + axiumSetDefaultModeIndex, + axiumSetDefaultModeIndexType, + SetDefaultModeIndexPayload +} from './concepts/axium/qualities/setDefaultModeIndex.quality'; export { axiumClearDialog, axiumClearDialogType } from './concepts/axium/qualities/clearDialog.quality'; -export { axiumSetDefaultModeType, SetDefaultModePayload } from './concepts/axium/qualities/setDefaultMode.quality'; -export { axiumSetBlockingModeType, SetBlockingModePayload } from './concepts/axium/qualities/setBlockingMode.quality'; +export { axiumSetDefaultMode, axiumSetDefaultModeType, SetDefaultModePayload } from './concepts/axium/qualities/setDefaultMode.quality'; +export { axiumSetBlockingMode, axiumSetBlockingModeType, SetBlockingModePayload } from './concepts/axium/qualities/setBlockingMode.quality'; // Strategies export { addConceptsToAddQueThenBlockStrategy, @@ -83,17 +87,27 @@ export { export { OwnershipState, ownershipName, createOwnershipConcept } from './concepts/ownership/ownership.concept'; export { ownershipMode } from './concepts/ownership/ownership.mode'; export { selectOwnershipLedger } from './concepts/ownership/ownership.selector'; -export { ownershipBackTrackType } from './concepts/ownership/qualities/backTrack.quality'; -export { ClearPayloadStubsPayload, ownershipClearPayloadStubsType } from './concepts/ownership/qualities/clearPayloadStubs.quality'; -export { ownershipClearPendingActionsType } from './concepts/ownership/qualities/clearPendingActions.quality'; +// Qualities +export { ownershipBackTrack, ownershipBackTrackType } from './concepts/ownership/qualities/backTrack.quality'; +export { + ownershipClearPayloadStubs, + ClearPayloadStubsPayload, + ownershipClearPayloadStubsType +} from './concepts/ownership/qualities/clearPayloadStubs.quality'; +export { ownershipClearPendingActions, ownershipClearPendingActionsType } from './concepts/ownership/qualities/clearPendingActions.quality'; export { + ownershipClearPendingActionsOfStrategy, ClearPendingActionsOfStrategyPayload, ownershipClearPendingActionsOfStrategyType } from './concepts/ownership/qualities/clearPendingActionsOfStrategy.quality'; export { + ownershipClearStrategyStubsFromLedgerAndSelf, ownershipClearStrategyStubsFromLedgerAndSelfType } from './concepts/ownership/qualities/clearStrategyStubsFromLedgerAndSelf.quality'; -export { ownershipResetOwnershipLedgerType } from './concepts/ownership/qualities/resetOwnershipLedger.quality'; +export { + ownershipResetOwnershipLedger, + ownershipResetOwnershipLedgerType +} from './concepts/ownership/qualities/resetOwnershipLedger.quality'; // Experiment export { @@ -102,7 +116,11 @@ export { createExperimentConcept, experimentName } from './concepts/experiment/experiment.concept'; -export {checkInQuality, experimentCheckIn, experimentCheckInType} from './concepts/experiment/qualities/checkIn.quality'; +export { + checkInStrategyQuality, + experimentCheckInStrategy, + experimentCheckInStrategyType +} from './concepts/experiment/qualities/checkInStrategy.quality'; export { experimentCountingStrategy, experimentCountingTopic, diff --git a/src/model/action.ts b/src/model/action.ts index 98a59c5..04d723b 100644 --- a/src/model/action.ts +++ b/src/model/action.ts @@ -17,6 +17,7 @@ export type Action = { payload?: unknown; strategy?: ActionStrategy; keyedSelectors?: KeyedSelector[]; + agreement?: number; expiration: number; axium?: string; }; @@ -120,14 +121,23 @@ export function createAction( semaphore, payload, keyedSelectors, - // Temporary until we have proper SLA + agreement, expiration: Date.now() + (agreement !== undefined ? agreement : 5000), }; } export function prepareActionCreator(actionType: ActionType) { return ( - payload?: unknown, + keyedSelectors?: KeyedSelector[], + agreement?: number, + _semaphore?: [number, number, number, number] + ) => { + return createAction(actionType, undefined, keyedSelectors, agreement, _semaphore); + }; +} +export function prepareActionWithPayloadCreator(actionType: ActionType) { + return ( + payload: T, keyedSelectors?: KeyedSelector[], agreement?: number, _semaphore?: [number, number, number, number] diff --git a/src/model/actionStrategy.ts b/src/model/actionStrategy.ts index a785609..dabc414 100644 --- a/src/model/actionStrategy.ts +++ b/src/model/actionStrategy.ts @@ -1,4 +1,4 @@ -import { axiumConcludeType } from '../concepts/axium/qualities/conclude.quality'; +import { axiumConclude, axiumConcludeType } from '../concepts/axium/qualities/conclude.quality'; import { Action, ActionType, createAction, nullActionType } from './action'; import { OwnershipTicketStub } from './ownership'; import { KeyedSelector } from './selector'; @@ -41,6 +41,47 @@ export interface ActionNode { lastActionNode?: ActionNode; } +export interface ActionNodeOptions { + keyedSelectors?: KeyedSelector[]; + semaphore?: [number, number, number, number]; + agreement?: number; + decisionNodes?: Record; + decisionNotes?: ActionNotes; + successNode: ActionNode | null; + successNotes?: ActionNotes; + failureNode: ActionNode | null; + failureNotes?: ActionNotes; + lastActionNode?: ActionNode; +} + +/** + * Decomposes an action into an ActionNode to be later Recomposed. + * @param action Action properties of KeyedSelector, Agreement, and Semaphore take priority over options. + * @param options successNode and failureNodes are always required. If using decisionNodes, set both to null. + * @returns ActionNode + */ +export function createActionNode(action: Action, options: ActionNodeOptions): ActionNode { + return { + actionType: action.type, + payload: action.payload, + keyedSelectors: action.keyedSelectors ? action.keyedSelectors : options.keyedSelectors, + agreement: action.agreement ? action.agreement : options.agreement, + semaphore: action.semaphore ? action.semaphore : options.semaphore, + successNode: options.successNode, + successNotes: options.successNotes, + failureNode: options.failureNode, + failureNotes: options.failureNotes, + decisionNodes: options.decisionNodes, + decisionNotes: options.decisionNotes, + lastActionNode: options.lastActionNode + }; +} + +/** + * Will decorate the final STRX sentence + * @preposition - Would append your string. + * @denoter - Would include some string ending in punctuation. + */ export interface ActionNotes { preposition?: string; denoter?: string; @@ -49,11 +90,9 @@ export interface ActionNotes { /** * ActionStrategyParams * Interface of ActionStrategy Construction - * - * @param payload - Payload to be carried throughout the strategy. + * @param data - Payload to be carried throughout the strategy. * @param initialNode - Starting point of your ActionStrategy */ - export interface ActionStrategyParameters { topic: string; data?: unknown; @@ -135,7 +174,7 @@ export const strategyBegin = (strategy: ActionStrategy, data?: unknown): Action if (strategy.currentNode.action !== null) { return strategy.currentNode.action; } else { - return createAction(axiumConcludeType); + return axiumConclude(); } }; @@ -374,11 +413,8 @@ export const backTrack = (_strategy: ActionStrategy): Action => { strategy.actionList[strategy.actionList.length - 1], ]; } - // strategy.currentNode = newNode; return newNode.action as Action; } else { - const conclude = createAction(axiumConcludeType); - // Later - return conclude; + return axiumConclude(); } }; diff --git a/src/model/axium.ts b/src/model/axium.ts index d107389..2b93456 100644 --- a/src/model/axium.ts +++ b/src/model/axium.ts @@ -17,6 +17,7 @@ import { axiumBadActionType } from '../concepts/axium/qualities/badAction.qualit import { axiumCloseType } from '../concepts/axium/qualities/close.quality'; import { AppendActionListToDialogPayload, + axiumAppendActionListToDialog, axiumAppendActionListToDialogType } from '../concepts/axium/qualities/appendActionListToDialog.quality'; @@ -27,11 +28,10 @@ export const blockingMethodSubscription = (action$: Subject, action: Act action.semaphore[3] === 3 ) { // Allows for reducer next in sequence - const appendToDialog = createAction(axiumAppendActionListToDialogType); - appendToDialog.payload = { + const appendToDialog = axiumAppendActionListToDialog({ actionList: action.strategy.actionList, strategyTopic: action.strategy.topic - } as AppendActionListToDialogPayload; + }); action$.next(appendToDialog); action$.next(action); } else if ( @@ -49,11 +49,10 @@ export const defaultMethodSubscription = (action$: Subject, action: Acti action.semaphore[3] === 3 ) { // Allows for reducer next in sequence - const appendToDialog = createAction(axiumAppendActionListToDialogType); - appendToDialog.payload = { + const appendToDialog = axiumAppendActionListToDialog({ actionList: action.strategy.actionList, strategyTopic: action.strategy.topic - } as AppendActionListToDialogPayload; + }); setTimeout(() => { action$.next(appendToDialog); action$.next(action); @@ -122,6 +121,7 @@ export function createAxium(name: string, initialConcepts: Concept[], logging?: // Would be notifying methods const _axiumState = _concepts[0].state as AxiumState; const modeIndex = _axiumState.modeIndex; + // console.log('CHECK ACTION STREAM', action); const modes = _concepts[0].mode as Mode[]; const mode = modes[modeIndex] as Mode; mode([action, _concepts, _axiumState.action$, _axiumState.concepts$]); diff --git a/src/model/concept.ts b/src/model/concept.ts index 2ba44e5..6217e9e 100644 --- a/src/model/concept.ts +++ b/src/model/concept.ts @@ -4,7 +4,7 @@ import { PrincipleFunction } from '../model/principle'; import { strategySuccess } from './actionStrategy'; import { map } from 'rxjs'; import { KeyedSelector } from './selector'; -import { axiumConcludeType } from '../concepts/axium/qualities/conclude.quality'; +import { axiumConclude } from '../concepts/axium/qualities/conclude.quality'; import { UnifiedSubject } from './unifiedSubject'; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -127,7 +127,7 @@ export const defaultMethodCreator: MethodCreator = () : [Method, Subject if (action.strategy) { return strategySuccess(action.strategy); } - return createAction(axiumConcludeType); + return axiumConclude(); }), ); return [defaultMethod, defaultSubject]; diff --git a/src/model/ownership.ts b/src/model/ownership.ts index 1b5ea5c..19ee2e2 100644 --- a/src/model/ownership.ts +++ b/src/model/ownership.ts @@ -167,7 +167,6 @@ export const checkIn = } else { ownershipLedger.set(key, [newTicket]); } - console.log('Check Ticket', newTicket); } }); } diff --git a/src/model/selector.ts b/src/model/selector.ts index 5bfd91e..8ffc3c1 100644 --- a/src/model/selector.ts +++ b/src/model/selector.ts @@ -24,21 +24,11 @@ export function selectState(concepts: Concept[], name: string): T { /** * Simple helper function that returns payload casted to T. - * Prior to emitting action, use createPayload with the action's payload type to provide the logical guarantee. - * As Typescript does not care if payload is undefined or the entire window object. - * You must set the payload, if the payload is required in your logic. */ export function selectPayload(action: Action): T { return action.payload as T; } -/** - * Provides logical guarantee that your payload is set to the appropriate type without casting. - */ -export function createPayload(payload: T): T { - return payload; -} - // Note: The Concept Key within the selector has to be set Explicitly for now export function selectSlice( concepts: Concept[], diff --git a/src/test/addConcepts.test.ts b/src/test/addConcepts.test.ts index 73ecea7..1f58463 100644 --- a/src/test/addConcepts.test.ts +++ b/src/test/addConcepts.test.ts @@ -1,8 +1,7 @@ import { createAxium } from '../model/axium'; -import { Concept } from '../model/concept'; import { strategyBegin } from '../model/actionStrategy'; import { selectState } from '../model/selector'; -import { Counter, createCounterConcept, countingStrategy, primedCountingStrategy, counterName } from '../concepts/counter/counter.concept'; +import { Counter, createCounterConcept, countingStrategy, counterName } from '../concepts/counter/counter.concept'; import { addConceptsToAddQueThenBlockStrategy } from '../concepts/axium/strategies/addConcept.strategy'; import { AxiumState } from '../concepts/axium/axium.concept'; import { countingTopic } from '../concepts/counter/strategies/counting.strategy'; diff --git a/src/test/chain.test.ts b/src/test/chain.test.ts index a897b8d..12f4ed2 100644 --- a/src/test/chain.test.ts +++ b/src/test/chain.test.ts @@ -1,7 +1,7 @@ import { createAxium } from '../model/axium'; import { Concept } from '../model/concept'; import { primeAction } from '../model/action'; -import { createPayload, selectState } from '../model/selector'; +import { selectState } from '../model/selector'; import { Counter, createCounterConcept, counterName } from '../concepts/counter/counter.concept'; import { createChainConcept } from '../concepts/chain/chain.concept'; import { ChainDispatchActionsPayload, chainDispatchActions } from '../concepts/chain/qualities/prepareChain.quality'; @@ -20,19 +20,16 @@ test('Axium Test', (done) => { const primedSubtract = primeAction(concepts, counterSubtract()); const primedPrepareChain = primeAction(concepts, - chainDispatchActions( - createPayload({ - actions: [ - primedAdd, - primedAdd, - primedSubtract, - primedAdd, - primedSubtract, - primedAdd, - ] - }) - ) - ); + chainDispatchActions({ + actions: [ + primedAdd, + primedAdd, + primedSubtract, + primedAdd, + primedSubtract, + primedAdd, + ] + })); axium.dispatch(primedPrepareChain); } else if (count === 7) { diff --git a/src/test/ownership.test.ts b/src/test/ownership.test.ts index 6e51867..30c28e0 100644 --- a/src/test/ownership.test.ts +++ b/src/test/ownership.test.ts @@ -1,6 +1,6 @@ import { createAxium } from '../model/axium'; import { Concept } from '../model/concept'; -import { createPayload, selectState } from '../model/selector'; +import { selectState } from '../model/selector'; import { OwnershipState, createOwnershipConcept, ownershipName } from '../concepts/ownership/ownership.concept'; import { AxiumState } from '../concepts/axium/axium.concept'; import { setOwnerShipModeTopic } from '../concepts/ownership/strategies/setOwnerShipMode.strategy'; @@ -14,8 +14,8 @@ import { experimentPrimedCountingTopic } from '../concepts/experiment/strategies/experimentCounting.strategy'; import { axiumLog } from '../concepts/axium/qualities/log.quality'; -import { SetCountPayload, counterSetCount } from '../concepts/counter/qualities/setCount.quality'; -import { checkInQuality } from '../concepts/experiment/qualities/checkIn.quality'; +import { counterSetCount } from '../concepts/counter/qualities/setCount.quality'; +import { checkInStrategyQuality } from '../concepts/experiment/qualities/checkInStrategy.quality'; import { experimentActionQuePrinciple } from '../concepts/experiment/experiment.principle'; test('Ownership Test', (done) => { @@ -24,7 +24,7 @@ test('Ownership Test', (done) => { const axium = createAxium('ownershipTest', [ createOwnershipConcept(), createCounterConcept(), - createExperimentConcept(createExperimentActionQueState(), [checkInQuality], [experimentActionQuePrinciple]) + createExperimentConcept(createExperimentActionQueState(), [checkInStrategyQuality], [experimentActionQuePrinciple]) ], true, true); const plan = axium.stage( 'Testing Ownership Staging', [ @@ -47,7 +47,7 @@ test('Ownership Test', (done) => { // Will be ran after both counting strategies conclude. const ownership = selectState(cpts, ownershipName); console.log('Stage 2', ownership.ownershipLedger, ownership.pendingActions); - dispatch(counterSetCount(createPayload({newCount: 1000}), undefined, 7000), { iterateStage: true}); + dispatch(counterSetCount({newCount: 1000}, undefined, 7000), { iterateStage: true}); }, (cpts, dispatch) => { const ownership = selectState(cpts, ownershipName); diff --git a/src/test/removeConcepts.test.ts b/src/test/removeConcepts.test.ts index a0e5dcc..3aa5977 100644 --- a/src/test/removeConcepts.test.ts +++ b/src/test/removeConcepts.test.ts @@ -1,7 +1,5 @@ import { createAxium } from '../model/axium'; -import { Concept } from '../model/concept'; import { strategyBegin } from '../model/actionStrategy'; -import { selectState } from '../model/selector'; import { createCounterConcept, counterName } from '../concepts/counter/counter.concept'; import { addConceptsToRemovalQueThenBlockStrategy, diff --git a/src/test/selector.test.ts b/src/test/selector.test.ts index f06711f..f25869c 100644 --- a/src/test/selector.test.ts +++ b/src/test/selector.test.ts @@ -1,6 +1,6 @@ import { createAxium } from '../model/axium'; import { Concept } from '../model/concept'; -import { createPayload, selectPayload, selectSlice, selectState } from '../model/selector'; +import { selectPayload, selectSlice, selectState } from '../model/selector'; import { Counter, createCounterConcept, counterName } from '../concepts/counter/counter.concept'; import { counterSelectCount } from '../concepts/counter/counter.selector'; import { SetCountPayload, counterSetCount } from '../concepts/counter/qualities/setCount.quality'; @@ -12,6 +12,7 @@ test('Axium Selector Test', (done) => { const axium = createAxium('axiumSelectorTest', [counter], true, true); const sub = axium.subscribe((concepts: Concept[]) => { const state = selectState(concepts, counterName); + console.log('CHECK COUNT', state.count); expect(state.count).toBe(10); done(); }); @@ -30,7 +31,7 @@ test('Axium Selector State Slice Test', (done) => { }); test('Axium Selector Payload Test', (done) => { - const setCount = counterSetCount(createPayload({newCount: 10 })); + const setCount = counterSetCount({newCount: 10 }); const payload = selectPayload(setCount); expect(payload.newCount).toBe(10); done(); diff --git a/src/test/stageDispatchOptions.test.ts b/src/test/stageDispatchOptions.test.ts index 9e7e7d7..f7275ba 100644 --- a/src/test/stageDispatchOptions.test.ts +++ b/src/test/stageDispatchOptions.test.ts @@ -1,6 +1,6 @@ import { createAxium } from '../model/axium'; import { selectState } from '../model/selector'; -import { Counter, createCounterConcept, countingStrategy, counterName } from '../concepts/counter/counter.concept'; +import { Counter, createCounterConcept, counterName } from '../concepts/counter/counter.concept'; import { AxiumState } from '../concepts/axium/axium.concept'; import { counterAdd } from '../concepts/counter/qualities/add.quality'; import { counterSubtract } from '../concepts/counter/qualities/subtract.quality'; diff --git a/src/test/strategy.test.ts b/src/test/strategy.test.ts index dbab7a7..0070b04 100644 --- a/src/test/strategy.test.ts +++ b/src/test/strategy.test.ts @@ -1,5 +1,4 @@ import { createAxium } from '../model/axium'; -import { Concept } from '../model/concept'; import { strategyBegin } from '../model/actionStrategy'; import { selectState } from '../model/selector'; import { Counter, createCounterConcept, countingStrategy, counterName } from '../concepts/counter/counter.concept';