Skip to content

Commit

Permalink
Fix default notion props (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroki0525 committed Jan 22, 2024
1 parent 4c68159 commit 4b52daa
Show file tree
Hide file tree
Showing 11 changed files with 227 additions and 203 deletions.
7 changes: 7 additions & 0 deletions .changeset/poor-trees-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@dandori/core": patch
"@dandori/libs": patch
"@dandori/ui": patch
---

Fix default notion props
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@types/node": "^18",
"@typescript-eslint/eslint-plugin": "6.18.1",
"@typescript-eslint/parser": "6.18.1",
"@typescript-eslint/eslint-plugin": "6.19.0",
"@typescript-eslint/parser": "6.19.0",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
Expand All @@ -36,17 +36,17 @@
"eslint-plugin-vitest": "^0.3.20",
"husky": "^8.0.3",
"lint-staged": "^15.2.0",
"prettier": "3.2.1",
"prettier": "3.2.4",
"tsup": "^8.0.1",
"tsx": "^4.7.0",
"turbo": "^1.11.3",
"typescript": "5.3.3",
"vitest": "^1.1.3"
"vitest": "^1.2.1"
},
"packageManager": "pnpm@8.14.1",
"packageManager": "pnpm@8.14.2",
"engines": {
"node": ">=18.18.1",
"pnpm": "8.14.1"
"pnpm": "8.14.2"
},
"husky": {
"hooks": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/notion/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe("DandoriNotionCli", () => {
});

describe("with --name option", () => {
const name = "Name";
const name = "title";

beforeEach(async () => {
loadProcessArgv(["--name", name]);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
"license": "MIT",
"dependencies": {
"@dandori/libs": "workspace:*",
"openai": "^4.24.1"
"openai": "^4.25.0"
}
}
2 changes: 1 addition & 1 deletion packages/libs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"author": "Hiroki Miyaji",
"license": "MIT",
"dependencies": {
"dotenv": "^16.3.1",
"dotenv": "^16.3.2",
"winston": "^3.11.0"
}
}
2 changes: 1 addition & 1 deletion packages/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ For example, if the url is `https://www.notion.so/myworkspace/1234567890?v=123`,

* databasePropertiesMap

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

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

Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/__tests__/notion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe("generateDandoriNotionPages", () => {

const findPagePropertiesMockParam = (
taskName: string,
nameProp: string = "Name",
nameProp: string = "title",
) => {
const params = (client.pages.create as Mock).mock.calls.flat();
return params.find(
Expand Down Expand Up @@ -141,7 +141,7 @@ describe("generateDandoriNotionPages", () => {
expect(
findPagePropertiesMockParam(withAllPropsTaskName).properties,
).toMatchObject({
Name: {
title: {
title: [
{
text: {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/notion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const createPageParams = (
const {
deadline: deadlineProp,
description: descriptionProp,
name: nameProp = "Name",
name: nameProp = "title",
} = propsMap;
const pageProperties: Record<string, any> = {
[nameProp]: {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/trello/trello.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DandoriTask, DandoriTaskStatus } from "@dandori/core";
import { checkApiKey, runPromisesSequentially } from "@dandori/libs";
import { TrelloClient } from "./client";

type TrelloListPropertiesMap =
export type TrelloListPropertiesMap =
| {
"status.todo": string;
"status.doing"?: string;
Expand Down
16 changes: 16 additions & 0 deletions packages/ui/templates/generateDandoriNotionPages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { loadEnvFile } from "@dandori/libs";
import { tasks } from "./mock";
import { generateDandoriNotionPages } from "@dandori/ui";
import { Client } from "@notionhq/client";

// set environment variables like access token
loadEnvFile();
Expand All @@ -16,6 +17,21 @@ const databasePropertiesMap = {
"status.done": "",
};

const notion = new Client({ auth: process.env.NOTION_API_KEY });
async function getDatabaseSchema() {
try {
const response = await notion.databases.retrieve({
database_id: databaseId,
});
console.log(response);
} catch (error) {
console.error(error);
}
}

// check database schema if you want
await getDatabaseSchema();

await generateDandoriNotionPages(tasks, {
databaseId,
databasePropertiesMap,
Expand Down
Loading

0 comments on commit 4b52daa

Please sign in to comment.