Package Exports
- @narkdown/notion-faker
- @narkdown/notion-faker/dist/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@narkdown/notion-faker) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@narkdown/notion-faker
Generate massive amounts of fake contextual data for Notion
Demo
Why?
To mocking Notion API request data.
Install
$ npm install @narkdown/notion-faker
Usage
const {NotionFaker} = require('@narkdown/notion-faker');
const notionFaker = new NotionFaker({
seedValue: 100,
locale: 'en',
});
Example
Prep Work
- Create a Notion API Integration
- Create Page in Notion to add database.
- Create an Example Database with your own properties.
- Share Page with your integration
const {Client} = require('@notionhq/client');
const {NotionFaker} = require('@narkdown/notion-faker');
const NOTION_API_KEY = ''; // Notion API Key
const EXAMPLE_DATABASE_ID = ''; // Database for importing Property Scheme.
const PARENT_PAGE_ID = ''; // Parent page to create database.
const ROW_COUNT = 100; // ⚠️ Creating too many pages using the Notion API is a heavy task.
const notion = new Client({auth: NOTION_API_KEY});
const notionFaker = new NotionFaker();
(async () => {
const {properties: scheme} = await notion.databases.retrieve({
database_id: EXAMPLE_DATABASE_ID,
});
const {id: databaseId} = await notion.databases.create({
parent: {
page_id: PARENT_PAGE_ID,
},
title: notionFaker.database.title()()(),
properties: notionFaker.database.properties.propertiesByScheme(scheme),
icon: notionFaker.icon.emoji(),
cover: notionFaker.cover()(),
});
for (const _ of Array.from({length: ROW_COUNT})) {
await narkdown.pages.create({
parent: {database_id: TEST_DATABASE_ID},
properties: notionFaker.page.properties.propertiesByScheme(scheme),
});
}
})();
API
const notionFaker = new NotionFaker(options?)
notionFaker.icon.emoji()
notionFaker.icon.external(methodPath?)(...args?)
notionFaker.cover(methodPath?)(...args?)
notionFaker.database.title(methodPath?)(...args?)(options?)
notionFaker.database.properties
title(options?)
rich_text(options?)
number(options?)
select(options?)
multi_select(options?)
date(options?)
files(options?)
checkbox(options?)
url(options?)
email(options?)
phone_number(options?)
formula(options?)
relation(options)
rollup(options)
people(options?)
created_by(options?)
created_time(options?)
last_edited_by(options?)
last_edited_time(options?)
propertiesByScheme(propertyScheme)
notionFaker.page.properties
title(methodPath?)(...args)(options?)
,rich_text(methodPath?)(...args)(options?)
,number(methodPath?)(...args)
,select(methodPath?)(...args)(options?)
,multi_select(methodPath?)(...args)(options?)
,date(methodPath?)(...args)(options?)
,files(methodPath?)(...args)(options?)
,checkbox()
,url()
,email(...args)
,phone_number(methodPath?)(...args)(options?)
,propertiesByScheme(propertyScheme)
Support
Database Object
Property | Supported |
---|---|
object |
❌ |
id |
❌ |
created_time |
❌ |
last_edited_time |
❌ |
title |
✅ |
icon |
✅ |
cover |
✅ |
properties |
✅ |
parent |
❌ |
url |
❌ |
Page Object
Property | Supported |
---|---|
object |
❌ |
id |
❌ |
created_time |
❌ |
last_edited_time |
❌ |
archived |
❌ |
icon |
✅ |
cover |
✅ |
properties |
⚠️ |
parent |
❌ |
url |
❌ |
Property Object
Property | Page (Child of Database) | Page (Child of Page) |
---|---|---|
title |
✅ | ✅ |
rich_text |
✅ | ❌ |
number |
✅ | ❌ |
select |
✅ | ❌ |
multi_select |
✅ | ❌ |
date |
✅ | ❌ |
files |
✅ | ❌ |
checkbox |
✅ | ❌ |
url |
✅ | ❌ |
email |
✅ | ❌ |
phone_number |
✅ | ❌ |
formula |
❌ | ❌ |
relation |
❌ | ❌ |
rollup |
❌ | ❌ |
people |
❌ | ❌ |
created_by |
❌ | ❌ |
created_time |
❌ | ❌ |
last_edited_by |
❌ | ❌ |
last_edited_time |
❌ | ❌ |