An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

        

# tasks-domain

Contains a description of the entities

- icon
- priority
- task category
- task

their 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

![Data model](data_schema.png)

## 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