Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions examples/nm/change-member-emails.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ const dataSourceId = '527dfb28-a457-4b45-99d3-8ee18497a725';
// Remove old user from workspace
await removeMemberFromWorkspace(oldMember.id);

// const oldMember = {
// id: '24bd872b-594c-8191-ad2a-0002d5e040a0',
// email: oldEmail,
// };

// const user = {
// id: '245d872b-594c-81e4-afea-00028f30d6ab',
// email: newEmail,
// };

// Fetch the record in the student database by the previous email
const {
results: [student],
Expand Down
64 changes: 64 additions & 0 deletions examples/pages/move-page/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Arguments:
*
* --page-id (-p): ID of the page to move
* --target-page-id (-t): ID of the page to move to
* --target-data-source-id (-d): ID of the data source to move to
*/

const { notion, yargs } = require('../../shared');
const { log } = require('../../shared/utils');

// 2af1c1cce3f3802985bdecfa26194f94 (page)
// 2ae1c1cce3f3815a8140ce2cac1a27b8 (target page)
// 2ce1c1cce3f3800592fb000b3279a7d2 (target data source)

const argv = yargs
.option('pageId', {
alias: 'p',
describe: 'The ID of the block to move',
demand: true,
})
.option('targetPageId', {
alias: 't',
describe: 'The ID of the page to move the selected block to',
})
.option('targetDataSourceId', {
alias: 'd',
describe: 'The ID of the data source to move the selected block to',
}).argv;

(async () => {
let page = await notion.pages.retrieve({
page_id: argv.pageId,
});

let type;
let target;

// Find the target
if (argv.targetPageId) {
type = 'page_id';
target = await notion.pages.retrieve({
page_id: argv.targetPageId,
});
} else {
type = 'data_source_id';
target = await notion.dataSources.retrieve({
data_source_id: argv.targetDataSourceId,
});
}

// Move the block
// SEE: https://developers.notion.com/reference/move-page

page = await notion.pages.move({
page_id: page.id,
parent: {
type,
[type]: target.id,
},
});

log(page);
})();
3 changes: 1 addition & 2 deletions examples/shared/notion-api.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

const { default: axios } = require('axios');
const dotenv = require('dotenv');
dotenv.config();

const NOTION_VERSION = '2025-09-03'
const NOTION_VERSION = '2025-09-03';

const NOTION_HEADERS = {
Authorization: `Bearer ${process.env.NOTION_API_TOKEN}`,
Expand Down
Loading