- Notifications
You must be signed in to change notification settings - Fork 688
[v5] Add missing page icon types and other misc fixes #603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2022", | ||
| "module": "ES2022", | ||
| "moduleResolution": "Node", | ||
| "allowSyntheticDefaultImports": true, | ||
| "strict": false, | ||
| "esModuleInterop": true, | ||
| "allowJs": true, | ||
| "checkJs": false, | ||
| "resolveJsonModule": true, | ||
| "forceConsistentCasingInFileNames": true | ||
| }, | ||
| "include": ["**/*.ts", "**/*.js"], | ||
| "ts-node": { | ||
| "esm": true | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| | @@ -119,6 +119,8 @@ export class RequestTimeoutError extends NotionClientErrorBase<ClientErrorCode.R | |||||
| | ||||||
| type HTTPResponseErrorCode = ClientErrorCode.ResponseError | APIErrorCode | ||||||
| | ||||||
| type AdditionalData = Record<string, string | string[]> | ||||||
| | ||||||
| class HTTPResponseError< | ||||||
| Code extends HTTPResponseErrorCode | ||||||
| > extends NotionClientErrorBase<Code> { | ||||||
| | @@ -127,20 +129,23 @@ class HTTPResponseError< | |||||
| readonly status: number | ||||||
| readonly headers: SupportedResponse["headers"] | ||||||
| readonly body: string | ||||||
| readonly additional_data: AdditionalData | undefined | ||||||
| | ||||||
| constructor(args: { | ||||||
| code: Code | ||||||
| status: number | ||||||
| message: string | ||||||
| headers: SupportedResponse["headers"] | ||||||
| rawBodyText: string | ||||||
| additional_data: AdditionalData | undefined | ||||||
| }) { | ||||||
| super(args.message) | ||||||
| const { code, status, headers, rawBodyText } = args | ||||||
| const { code, status, headers, rawBodyText, additional_data } = args | ||||||
| this.code = code | ||||||
| this.status = status | ||||||
| this.headers = headers | ||||||
| this.body = rawBodyText | ||||||
| this.additional_data = additional_data | ||||||
| } | ||||||
| } | ||||||
| | ||||||
| | @@ -193,6 +198,7 @@ export class UnknownHTTPResponseError extends HTTPResponseError<ClientErrorCode. | |||||
| message: | ||||||
| args.message ?? | ||||||
| `Request to Notion API failed with status: ${args.status}`, | ||||||
| additional_data: undefined, | ||||||
| }) | ||||||
| } | ||||||
| | ||||||
| | @@ -243,6 +249,7 @@ export function buildRequestError( | |||||
| headers: response.headers, | ||||||
| status: response.status, | ||||||
| rawBodyText: bodyText, | ||||||
| additional_data: apiErrorResponseBody.additional_data, | ||||||
| }) | ||||||
| } | ||||||
| return new UnknownHTTPResponseError({ | ||||||
| | @@ -253,9 +260,13 @@ export function buildRequestError( | |||||
| }) | ||||||
| } | ||||||
| | ||||||
| function parseAPIErrorResponseBody( | ||||||
| body: string | ||||||
| ): { code: APIErrorCode; message: string } | undefined { | ||||||
| function parseAPIErrorResponseBody(body: string): | ||||||
| | { | ||||||
| code: APIErrorCode | ||||||
| message: string | ||||||
| additional_data: AdditionalData | undefined | ||||||
| } | ||||||
| | undefined { | ||||||
| if (typeof body !== "string") { | ||||||
| return | ||||||
| } | ||||||
| | @@ -279,6 +290,7 @@ function parseAPIErrorResponseBody( | |||||
| ...parsed, | ||||||
| code: parsed["code"], | ||||||
| message: parsed["message"], | ||||||
| additional_data: parsed["additional_data"] as AdditionalData | undefined, | ||||||
| ||||||
| additional_data: parsed["additional_data"] as AdditionalData | undefined, | |
| additional_data: isAdditionalData(parsed["additional_data"]) ? parsed["additional_data"] : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't really think of a good way to do a runtime check of the keys of an object being strings in JS :/ I feel like this is a necessary evil here (at the boundary of the web API call interface) and we kind of have to do some level of casting or ugly code and I chose the casting 😅)
Uh oh!
There was an error while loading. Please reload this page.