7});
8
9export async function createDatabasePagesParallel(databaseId: string, pages: []) {
10 const creations = pages.map((page) =>
11 notion.pages.create({
43
44// delete all database rows
45export async function deleteAllDatabasePagesParallel(databaseId: string) {
46 const pageIds = await notion.databases.query({
47 database_id: databaseId,
59}
60
61export async function getDatabaseId(databaseTitle: string) {
62 // getDatabaseId(databaseTitle)
63 const database = await notion.databases
66}
67
68export async function getDatabaseTitle(databaseId: string) {
69 // getDatabaseTitle(databaseId)
70 const database = await notion.databases.retrieve({ database_id: databaseId });
73}
74
75export async function getDatabaseParentPageId(databaseId: string) {
76 let currentBlockId = databaseId;
77
98}
99
100export async function getCalloutProperties(askingFor: string) {
101 const blockProperties = (askingFor != "val.town")
102 ? {
121}
122
123export async function findChildDatabaseBlocks(rootBlockId: string, blockIdentifier: string) {
124 const matchingBlocks = [];
125
126 async function searchBlock(blockId) {
127 const res = await notion.blocks.children.list({ block_id: blockId });
128
165}
166
167export async function findCalloutBlocks(rootBlockId: string, blockIdentifier: string) {
168 const matchingBlocks = [];
169
170 async function searchBlock(blockId) {
171 const res = await notion.blocks.children.list({ block_id: blockId });
172
200}
201
202export async function getBostonTime() {
203 const now = new Date();
204
213}
214
215export async function listChildrenChildPages(blockId: string) {
216 try {
217 const response = await notion.blocks.children.list({
229}
230
231export async function addFavicon(data?: any) {
232 const pageId = data?.id;
233 // use notion if nothing if the URL property is empty
234 const url = await getWebhookPropertyValue(data, "Website") || "notion.com";
235 // send the URL value to the function that will get the site's favicon location
236 const faviconURL = await helpers.scrapeFaviconUrl(url);
237 console.log({ "Verified favicon URL": faviconURL });
242}
243
244export async function setPageStatus(object: any) {
245 const { data, section, step } = object;
246 const pageId = data?.id;
282}
283
284export async function updatePageIcon(pageId: string, faviconURL?: string) {
285 try {
286 const response = await notion.pages.update({
302}
303
304export async function listChildren(pageId: string) {
305 // get page properties
306 try {
318}
319
320// Helper function to get property value from webhook payload
321export async function getWebhookPropertyValue(payload: any, propertyName: any) {
322 let result = null;
323 // check to see if the whole payload was sent, or just the data object
357}
358
359export async function getNotionPage(pageId: string) {
360 // get page properties
361 try {