Skip to content

Commit

Permalink
Fix miro log (#87)
Browse files Browse the repository at this point in the history
* fix miro log
  * miro sdk don't support log level
*
https://github.com/miroapp/api-clients/blob/main/packages/miro-api/api/apis.ts#L4905-L4926
* `apiKey` allows undefined and null
* this assumes a case where is is not returned by oauth authentification
  • Loading branch information
hiroki0525 committed Dec 14, 2023
1 parent b9a1ca4 commit d3a1cfc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/cuddly-lobsters-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@dandori/libs": patch
"@dandori/ui": patch
---

fix miro log
2 changes: 1 addition & 1 deletion packages/libs/src/checkApiKey.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function checkApiKey(
keyName: string,
targetKey?: string,
alternativeKey?: string,
alternativeKey?: string | undefined | null,
): string {
if (targetKey) {
return targetKey;
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const setLogger = (newLogger: Logger): void => {
logger = newLogger;
};

type LogLevel = "debug" | "info" | "warn" | "error";
export type LogLevel = typeof process.env.LOG_LEVEL;

export const getLogLevel = (): LogLevel => {
return process.env.LOG_LEVEL ?? "info";
Expand Down
9 changes: 7 additions & 2 deletions packages/ui/src/miro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
export type GenerateDandoriMiroCardsOptions = {
boardId: Parameters<MiroApi["getBoard"]>[0];
isAppCard?: boolean;
apiKey?: string;
apiKey?: Parameters<typeof checkApiKey>[2];
};

// miro settings
Expand Down Expand Up @@ -66,7 +66,12 @@ export async function generateDandoriMiroCards(
);
const logger = getLogger();
const miroApi = new MiroApi(key, undefined, (...thing) => {
logger[getLogLevel()](thing);
// miro api sdk has no log level setting, so dandori only log debug level.
// https://github.com/miroapp/api-clients/blob/main/packages/miro-api/api/apis.ts#L4905-L4926
const logLevel = getLogLevel();
if (logLevel === "debug") {
logger[logLevel](thing);
}
});
const miroBoard = await miroApi.getBoard(options.boardId);
const taskFlat: (DandoriTask & { [taskParentPropName]?: string })[] = tasks
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 @@ -61,7 +61,7 @@ export type DatabasePropertiesMap =
export type GenerateDandoriNotionPagesOptions = {
databaseId: string;
databasePropertiesMap?: DatabasePropertiesMap;
apiKey?: string;
apiKey?: Parameters<typeof checkApiKey>[2];
};

const hasStatusProperty = (
Expand Down

0 comments on commit d3a1cfc

Please sign in to comment.