From e9f729b4a95f9c45ea7c6b377941753780b4c3a4 Mon Sep 17 00:00:00 2001 From: takker99 <37929109+takker99@users.noreply.github.com> Date: Tue, 4 Jan 2022 11:00:33 +0900 Subject: [PATCH 1/4] :recycle: Convert `type` to `interface` --- api/error.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/api/error.ts b/api/error.ts index 9fe9f35..b693a9d 100644 --- a/api/error.ts +++ b/api/error.ts @@ -1,9 +1,11 @@ -export type NotMemberError = { - name: "NotMemberError"; +export interface ErrorLike { + name: string; message: string; -}; +} +export interface NotMemberError extends ErrorLike { + name: "NotMemberError"; +} -export type NotFoundError = { +export interface NotFoundError extends ErrorLike { name: "NotFoundError"; - message: string; -}; +} From f34c7f4076232c70d45a9b344039cbb384148638 Mon Sep 17 00:00:00 2001 From: takker99 <37929109+takker99@users.noreply.github.com> Date: Tue, 4 Jan 2022 11:01:47 +0900 Subject: [PATCH 2/4] :bulb: JSDoc --- api/error.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/error.ts b/api/error.ts index b693a9d..199a2f4 100644 --- a/api/error.ts +++ b/api/error.ts @@ -1,11 +1,15 @@ +/** Scrapbox REST APIが返すエラーの型 */ export interface ErrorLike { - name: string; - message: string; + /** error name */ name: string; + /** error message */ message: string; } + +/** 参加していないprivate projectに対してAPIを叩いたときに発生するエラー */ export interface NotMemberError extends ErrorLike { name: "NotMemberError"; } +/** 指定したprojectやpageが見つからないときに発生するエラー */ export interface NotFoundError extends ErrorLike { name: "NotFoundError"; } From aae09536f240a3db0b33078d3e3727ba6ca250dd Mon Sep 17 00:00:00 2001 From: takker99 <37929109+takker99@users.noreply.github.com> Date: Tue, 4 Jan 2022 11:03:05 +0900 Subject: [PATCH 3/4] :sparkles: Add `NotPrivilegeError` --- api/error.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/error.ts b/api/error.ts index 199a2f4..7c4f2df 100644 --- a/api/error.ts +++ b/api/error.ts @@ -13,3 +13,8 @@ export interface NotMemberError extends ErrorLike { export interface NotFoundError extends ErrorLike { name: "NotFoundError"; } + +/** owner/admin権限が不足しているときに発生するエラー */ +export interface NotPrivilegeError extends ErrorLike { + name: "NotPrivilegeError"; +} From 098660a8ee3ed6741876f809dcd1157de5d842f8 Mon Sep 17 00:00:00 2001 From: takker99 <37929109+takker99@users.noreply.github.com> Date: Tue, 4 Jan 2022 11:27:16 +0900 Subject: [PATCH 4/4] :sparkles: Add `NotLoggedInError` --- api/error.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/api/error.ts b/api/error.ts index 7c4f2df..1d6bbb2 100644 --- a/api/error.ts +++ b/api/error.ts @@ -18,3 +18,19 @@ export interface NotFoundError extends ErrorLike { export interface NotPrivilegeError extends ErrorLike { name: "NotPrivilegeError"; } + +/** Loginが必要なAPIをloginせずに叩いたときに発生するエラー */ +export interface NotLoggedInError extends ErrorLike { + name: "NotLoggedInError"; + /** 詳細情報 */ details: { + /** 使用できるログイン方法 */ loginStrategies: ( + | "google" + | "github" + | "microsoft" + | "gyazo" + | "email" + | "saml" + | "easy-trial" + )[]; + }; +}