harn-stdlib 0.10.118

Embedded Harn standard library source catalog
Documentation
import { filter_nil } from "std/collections"
import { merge } from "std/json"

let notion_connector_config = {}

pub fn configure(config: dict?) {
  notion_connector_config = filter_nil(config ?? {})
  return notion_connector_config
}

pub fn reset() {
  notion_connector_config = {}
}

fn __call(net: HarnessNet, method: string, params: dict? = {}) {
  return net.connector_call(
    "notion",
    method,
    filter_nil(merge(notion_connector_config, params ?? {})),
  )
}

pub fn get_page(net: HarnessNet, id: any, options: dict? = nil) {
  return __call(net, "get_page", (options ?? {}) + {id: id})
}

pub fn update_page(net: HarnessNet, id: any, properties: any, options: dict? = nil) {
  return __call(net, "update_page", (options ?? {}) + {id: id, properties: properties})
}

pub fn append_blocks(net: HarnessNet, page_id: any, blocks: any, options: dict? = nil) {
  return __call(net, "append_blocks", (options ?? {}) + {page_id: page_id, blocks: blocks})
}

pub fn query_database(
  net: HarnessNet,
  id: any,
  filter: any = nil,
  sorts: any = nil,
  options: dict? = nil,
) {
  return __call(
    net,
    "query_database",
    filter_nil((options ?? {}) + {id: id, filter: filter, sorts: sorts}),
  )
}

pub fn search(net: HarnessNet, query: any, options: dict? = nil) {
  return __call(net, "search", (options ?? {}) + {query: query})
}

pub fn create_comment(net: HarnessNet, page_id: any, rich_text: any, options: dict? = nil) {
  return __call(net, "create_comment", (options ?? {}) + {page_id: page_id, rich_text: rich_text})
}

pub fn api_call(net: HarnessNet, path: any, method: any, body: any = nil, options: dict? = nil) {
  return __call(
    net,
    "api_call",
    filter_nil((options ?? {}) + {path: path, method: method, body: body}),
  )
}