Skip to content
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

fix: modify response types to intersection #445

Closed
wants to merge 285 commits into from

Conversation

devjiwonchoi
Copy link

@devjiwonchoi devjiwonchoi commented Aug 18, 2023

Description

Since Response types are currently in a union, the users cannot access response objects' property directly.

Example:

const response = await notion.blocks.children.list({
  block_id: block_id,
})

const archives = response.results.filter((block) => block.archived) // Error here
Property 'archived' does not exist on type 'PartialBlockObjectResponse | BlockObjectResponse'.
Property 'archived' does not exist on type 'PartialBlockObjectResponse'.ts(2339)

Fix

Current:

export type ListBlockChildrenResponse = {
type: "block"
block: EmptyObject
object: "list"
next_cursor: string | null
has_more: boolean
results: Array<PartialBlockObjectResponse | BlockObjectResponse>
}

Fix:

// api-endpoints.ts
export type ListBlockChildrenResponse = {
    type: "block";
    block: EmptyObject;
    object: "list";
    next_cursor: string | null;
    has_more: boolean;
    results: Array<PartialBlockObjectResponse & BlockObjectResponse>; // union to intersection
};

Fixes #425 (comment) #443

aoberoi and others added 30 commits May 13, 2021 02:27
this emits a warning from ava@typescipt which can be safely ignored
This adds a warning in npm install for ava@typescript that can be safely ignored
LitoMore and others added 26 commits March 7, 2023 16:02
Co-authored-by: Ryan Hart <ryan@makenotion.com>
Error Handling example uses `notion` variable without instantiating it first.

Co-authored-by: Julie <julie@makenotion.com>
Co-authored-by: Ryan Hart <ryan@makenotion.com>
Co-authored-by: Ryan Hart <ryan@makenotion.com>
…makenotion#394)

* add instruction for giving integration access to database

* update notion-github-sync with integration access instructions
* add block text example

* clean up comments

* add embed option

* update comment:

* pr feeedback: name change, updated switch case, join richtext array without comma

* use iteratePaginatedAPI helper to capture all blocks on page
* Wiki related changes

* Remove oauth related endpoints
* add fullstack webform example app

* update package.json detail

* make linter happy

* delete old folder (name change

* Update examples/web-form-with-express/public/client.js

Co-authored-by: Ron Yehoshua <ron@makenotion.com>

* update var naming for improved readbility

* add console back to match appendApiResponse()

---------

Co-authored-by: Ron Yehoshua <ron@makenotion.com>
@CLAassistant
Copy link

CLAassistant commented Aug 18, 2023

CLA assistant check
All committers have signed the CLA.

@rhart92
Copy link
Contributor

rhart92 commented Oct 3, 2023

Unfortunately we had to remove an old .env file from the repo which required completely re-writing the commit history causing this PR's commit history to be out of date. Please re-submit this PR after pulling a fresh copy of this repo 🙏 Apologies for any inconvenience.

@rhart92 rhart92 closed this Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

notionhq/client and Next.js 13.4.9 with server action