https://github.com/budarin/tasks-domain
Domain for Tasks
https://github.com/budarin/tasks-domain
Last synced: 4 months ago
JSON representation
Domain for Tasks
- Host: GitHub
- URL: https://github.com/budarin/tasks-domain
- Owner: budarin
- License: mit
- Created: 2023-12-10T12:47:19.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-09-21T10:46:36.000Z (8 months ago)
- Last Synced: 2024-12-18T19:03:50.572Z (5 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@budarin/tasks-domain
- Size: 243 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tasks-domain
Contains a description of the entities
- icon
- priority
- task category
- tasktheir types, constructors, object extraction and validation methods.
It also describes the structure of storing entities in the application state store and methods for changing them for reuse in various applications.
## Data model

## Install
```bash
yarn add @budarin/tasks-domain
```## Usage
```ts
import type { TasksStoreState } from '@budarin/tasks-domain';
import { tasksStoreState, initTasksStore } from '@budarin/tasks-domain';import { storeLogger } from '../app/providers';
import { INBOX_KEY, OVERDUE_KEY, RECYCLE_BIN_KEY } from '../app/entities/index.ts';type AppState = TasksStoreState && SomeOtherState;
useAppStore = create()({
...tasksStoreState,navigationFilter: {...},
tasks: {
...tasksStoreState.tasks,idsByExpireDate: {},
idsByCategoryId: {},
idsByFilterId: {
[INBOX_KEY]: [],
[RECYCLE_BIN_KEY]: [],
[OVERDUE_KEY]: [],
},
},
});// you need to initialize store first after creating useAppStore
// with the instance of real store for using in entities methods and with the logger for store
initTasksStore(useAppStore, storeLogger);
```extending domain store logic in use cases
```ts
import { addTask, createTask } from '@budarin/tasks-domain';function storeAddTask(task: unknown): ResultOrError {
const addResult = addTask(task);if (addResult.error) {
return addResult;
}const state = useAppStore.getState();
// additional logic for managing filters & categories
{...}
}// using extended logic
storeAddTask(createTask({
taskId: 1,
title: 'TaskTitle',
priorityId: 1,
deleted: false,
completed: false,
}))```
## License
MIT