Skip to content

Commit

Permalink
Add docs (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroki0525 authored Nov 29, 2023
1 parent 159a6c2 commit 82cdb52
Show file tree
Hide file tree
Showing 8 changed files with 449 additions and 252 deletions.
6 changes: 6 additions & 0 deletions .changeset/polite-months-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@dandori/cli": patch
"@dandori/ui": patch
---

change command and types
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"license": "MIT",
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@changesets/cli": "^2.27.1",
"@types/node": "18.18.13",
"@typescript-eslint/eslint-plugin": "6.12.0",
"@typescript-eslint/parser": "6.12.0",
Expand All @@ -39,7 +39,7 @@
"lint-staged": "^15.1.0",
"prettier": "3.1.0",
"tsup": "^8.0.1",
"tsx": "^4.2.0",
"tsx": "^4.6.0",
"turbo": "^1.10.16",
"typescript": "5.3.2",
"vitest": "^0.34.6"
Expand Down
50 changes: 38 additions & 12 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@

This repository is responsible for executing `@dandori/*` packages.

## Installation

```bash
# It isn't necessary to install this package if you use the command like `npx` .
npm install @dandori/cli
yarn add @dandori/cli
pnpm add @dandori/cli
```

## Usage

This is an example of using Miro.

First, please create `.env` file and set environment variables like below.

```text
Expand All @@ -32,15 +25,48 @@ Today's My Tasks
Finally, please execute the following command.

```bash
npx -p @dandori/cli dandori-miro your_tasks.txt -b your_miro_board_id
yarn dlx -p @dandori/cli dandori-miro your_tasks.txt -b your_miro_board_id
pnpm --package=@dandori/cli dlx dandori-miro your_tasks.txt -b your_miro_board_id
npx --package=@dandori/cli -- miro your_tasks.txt -b your_miro_board_id
yarn dlx -p @dandori/cli miro your_tasks.txt -b your_miro_board_id
pnpm --package=@dandori/cli dlx miro your_tasks.txt -b your_miro_board_id
```

## Requirements

* Please see [@dandori/core](../core/README.md) and [@dandori/ui](../ui/README.md) before using `@dandori/cli`.

## Commands

### core

This command is to execute `generateDandoriTasks` of `@dandori/core`.

```bash
% pnpm --package=@dandori/cli dlx core -h
Options:
-V, --version output the version number
-e, --env-file <env-file> env file path
-m, --model <model> Chat GPT model which supports function_calling
-o, --optional-task-props <optional-task-props> optional output task props which delimiter is a comma
-h, --help display help for command
```

### miro

This command is to execute `generateDandoriMiroCards` of `@dandori/ui`.

```bash
% pnpm --package=@dandori/cli dlx miro -h

Options:
-V, --version output the version number
-e, --env-file <env-file> env file path
-m, --model <model> Chat GPT model which supports function_calling
-o, --optional-task-props <optional-task-props> optional output task props which delimiter is a comma
-a, --app-card
-b, --board-id <board-id>
-h, --help display help for command
```

## Supported External APIs

* [Miro](https://miro.com/)
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"dev:miro": "tsx src/miro/cli.ts"
},
"bin": {
"dandori": "./dist/core/cli.js",
"dandori-miro": "./dist/miro/cli.js"
"core": "./dist/core/cli.js",
"miro": "./dist/miro/cli.js"
},
"keywords": [],
"author": "Hiroki Miyaji",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
"license": "MIT",
"dependencies": {
"@dandori/libs": "workspace:*",
"openai": "^4.19.1"
"openai": "^4.20.1"
}
}
133 changes: 132 additions & 1 deletion packages/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,135 @@ await generateDandoriMiroCards(tasks, {
## Supported External APIs

* [Miro](https://miro.com/)
* [Notion](https://www.notion.so/)
* [Notion](https://www.notion.so/)

## API

### generateDandoriMiroCards

```ts
async function generateDandoriMiroCards(
tasks: DandoriTask[],
options?: GenerateDandoriMiroCardsOptions,
): Promise<void> {}
```

`generateDandoriMiroCards` creates miro cards from `generateDandoriTasks` result.

<img src="../../media/miro_example.png" alt="miro output example" width="422">

#### Parameters

##### tasks

The tasks which are generated by `generateDandoriTasks` of `@dandori/core`.

##### options

```ts
interface GenerateDandoriMiroCardsOptions {
boardId: string;
isAppCard?: boolean;
}
```

* boardId

The existing board id of miro.

You can get the board id from the miro url of the board.

For example, if the url is `https://miro.com/app/board/1234567890/`, the board id is `1234567890`.

* isAppCard

**default is `false`**

If you set `true` , the cards are created as [App cards](https://developers.miro.com/docs/app-card).

### generateDandoriNotionTasks

```ts
async function generateDandoriNotionPages(
tasks: DandoriTask[],
options?: GenerateDandoriNotionPagesOptions,
): Promise<void> {}
```

`generateDandoriNotionTasks` creates notion pages from `generateDandoriTasks` result.

<img src="../../media/notion_example.png" alt="notion output example" width="426">

#### Parameters

##### tasks

The tasks which are generated by `generateDandoriTasks` of `@dandori/core`.

##### options

```ts
interface GenerateDandoriNotionPagesOptions {
databaseId: string;
databasePropertiesMap?: DatabasePropertiesMap;
}
```

* databaseId

The existing database id of notion.

You can get the database id from the notion url of the database.

For example, if the url is `https://www.notion.so/myworkspace/1234567890?v=123`, the database id is `1234567890`.

* databasePropertiesMap

**default is `{ name: 'Name' }`**

The map which key is defined by dandori and value is your notion database properties.

You can set the key like belows.

```ts
const databasePropertiesMap = {
name: "",
deadline: "",
description: "",
status: "",
"status.todo": "",
"status.doing": "",
"status.done": "",
};
```

```ts
import generateDandoriTasks from '@dandori/core';
import { generateDandoriNotionPages } from "@dandori/ui";

const text = `
Today's My Tasks
* Send Email to John
* Send Email to Mary
* Report to Boss after sending emails
`;

const databasePropertiesMap = {
status: "Status",
"status.todo": "ToDo",
"status.doing": "Doing",
"status.done": "Done 🙌",
};

const tasks = await generateDandoriTasks(text);
await generateDandoriNotionPages(tasks, {
databaseId: '1234567890',
databasePropertiesMap,
});
```

This is an example. In this case, the output is like belows.

<img src="../../media/notion_example.png" alt="notion output example" width="426">

For more details about database properties, please see [Notion API](https://developers.notion.com/reference/page#page-property-value).
6 changes: 3 additions & 3 deletions packages/ui/src/notion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export type DatabasePropertiesMap =
| BaseDatabasePropertiesMap
| DatabasePropertiesMapWithStatus;

export type GenerateDandoriNotionDatabaseItemsOptions = {
export type GenerateDandoriNotionPagesOptions = {
databaseId: string;
databasePropertiesMap?: DatabasePropertiesMap;
};
Expand All @@ -66,7 +66,7 @@ const hasStatusProperty = (

const createPageParams = (
task: DandoriTask,
options: GenerateDandoriNotionDatabaseItemsOptions,
options: GenerateDandoriNotionPagesOptions,
): Parameters<InstanceType<typeof Client>["pages"]["create"]>[0] => {
const propsMap = options.databasePropertiesMap ?? {};
const { deadline, description, status, name } = task;
Expand Down Expand Up @@ -143,7 +143,7 @@ const getNotionLogLevel = () => {

export async function generateDandoriNotionPages(
tasks: DandoriTask[],
options: GenerateDandoriNotionDatabaseItemsOptions,
options: GenerateDandoriNotionPagesOptions,
): Promise<void> {
const logger = getLogger();
const client = new Client({
Expand Down
Loading

0 comments on commit 82cdb52

Please sign in to comment.