UNPKG

notion-helper

Version:

A library of functions for working more easily with the Notion API

99 lines 3.74 kB
/** * Checks if a string contains only a single emoji. * * @param {string} string * @returns {boolean} */ export function isSingleEmoji(string: string): boolean; /** * Checks if a string is a valid URL. * * @param {string} string * @returns {boolean} */ export function isValidURL(string: string): boolean; /** * Checks if a string is a valid UUID. * * @param {string} string * @returns {boolean} */ export function isValidUUID(string: string): boolean; /** * Checks if an image URL is both a valid URL and has a supported image file type. * * @param {url} url - the URL to be checked * @returns {boolean} */ export function validateImageURL(url: any): boolean; /** * Checks if a video URL is both a valid URL and will be accepted by the API, based on a list of supported file extensions and embed websites. * * @param {url} url - the URL to be checked * @returns {boolean} */ export function validateVideoURL(url: any): boolean; /** * Checks if a audio URL is both a valid URL and will be accepted by the API, based on a list of supported file extensions. * * @param {url} url - the URL to be checked * @returns {boolean} */ export function validateAudioURL(url: any): boolean; /** * Checks if a PDF URL is both a valid URL and ends with the .pdf extension. * * @param {url} url - the URL to be checked * @returns {boolean} */ export function validatePDFURL(url: any): boolean; /** * Enforces a length limit on a string. Returns the original string in a single-element array if it is under the limit. If not, returns an array with string chunks under the limit. * * @param {string} string - the string to be tested * @param {number} limit - optional string-length limit * @returns {Array<string>} - array with the original string, or chunks of the string if it was over the limit. */ export function enforceStringLength(string: string, limit: number): Array<string>; /** * Validates Date object or string input that represents a date, and converts it to an ISO-8601 date string if possible. * * @param {(string|Date)} date - a Date object or string representing a date * @returns {string} */ export function validateDate(dateInput: any): string; /** * Checks a provided array of child blocks to see how many nested levels of child blocks are present. Used by requests.blocks.children.append to determine if recursive calls need to be used. * * @param {Array<Object>} arr - The array of child blocks to be depth-checked. * @param {number} [level = 1] - The current level. * * @returns {number} */ export function getDepth(arr: Array<Object>, level?: number | undefined): number; /** * Gets the total number of blocks within an array of child blocks, including * child blocks of those blocks (and so on). Used to ensure that requests * do not exceed the 1,000 total block limit of the Notion API. * * @param {Array<Object>} arr - The array of block objects to be counted. * @returns {number} */ export function getTotalCount(arr: Array<Object>): number; /** * Gets the length of the longest array within a nested block array. * * @param {Array<Object>} arr - The array to check * @param {number} count - The length of the array one level up from the array being checked, or 0 if this is the initial call of the function * @returns {number} */ export function getLongestArray(arr: Array<Object>, count?: number): number; /** * Gets the size in bytes of a block array when converted to JSON. * Used to ensure API requests don't exceed Notion's payload size limits. * * @param {Array<Object>} arr - The array of block objects to measure * @returns {number} Size in bytes */ export function getPayloadSize(arr: Array<Object>): number; //# sourceMappingURL=utils.d.mts.map