@jmuchovej/paperpile-notion
Version:
CLI to sync your Paperpile with Notion
88 lines (87 loc) • 3.22 kB
TypeScript
import { CMS, CMSPageOf, NotionClient, Property } from "@jitl/notion-api";
import { Config as CLIConfig } from "@oclif/core";
import { ArticlesDB, AuthorsDB, StrictConfig as PNConfig } from "./config";
import BaseCommand from "./base";
export declare type Title = Property<"title">;
export declare type Relation = Property<"relation">;
export declare type RichText = Property<"rich_text">;
export declare type Select = Omit<Property<"select">, "type">;
export declare type MultiSelect = Property<"multi_select">;
export declare type URL = Property<"url">;
export declare const makeTitle: (content: string) => Title;
export declare const makeRichText: (content: string) => RichText | undefined;
export declare const makeSelect: (option: string) => Select | undefined;
export declare const makeMultiSelect: (options: string[]) => MultiSelect | undefined;
export declare const makeRelation: (relations: any[]) => Relation | undefined;
export declare const makeURL: (url: string) => URL | undefined;
declare type DBTypes = ArticlesDB | AuthorsDB;
declare type DBStrings<T> = T extends ArticlesDB ? "articles" : T extends AuthorsDB ? "authors" : never;
declare type DBSchemas<T> = T extends ArticlesDB ? ArticleSchema : T extends AuthorsDB ? AuthorSchema : never;
export declare type AuthorCMS = CMS<any, AuthorSchema>;
export declare type ArticleCMS = CMS<any, ArticleSchema>;
export declare type ArticleSchema = {
title: {
type: "title";
name: string;
};
ID: {
type: "rich_text";
name: string;
};
authors: {
type: "relation" | "multi_select";
name: string;
};
status: {
type: "select";
name: string;
};
topics: {
type: "multi_select";
name: string;
};
fields: {
type: "multi_select";
name: string;
};
methods: {
type: "multi_select";
name: string;
};
folders: {
type: "multi_select";
name: string;
};
venue: {
type: "select";
name: string;
};
url: {
type: "url";
name: string;
};
};
export declare type AuthorSchema = {
name: {
type: "title";
name: string;
};
articles: {
type: "relation";
name: string;
};
aliases: {
type: "rich_text";
name: string;
};
};
export declare type AuthorPage = CMSPageOf<AuthorCMS>;
export declare type AuthorIteratorResult = IteratorYieldResult<AuthorPage> | IteratorReturnResult<AuthorPage>;
export declare type ArticlePage = CMSPageOf<ArticleCMS>;
export declare type ArticleIteratorResult = IteratorYieldResult<ArticlePage> | IteratorReturnResult<ArticlePage>;
export declare function createCMS<T extends DBTypes>(cliConfig: CLIConfig, appConfig: PNConfig, notion: NotionClient, db: DBStrings<T>): CMS<any, DBSchemas<T>>;
export declare const buildCache: (cms: ArticleCMS | AuthorCMS) => Promise<void>;
export declare const archiveEmptyFilters: (CLI: BaseCommand, cms: ArticleCMS | AuthorCMS, filter: any) => Promise<void>;
export declare const BATCH_SIZE = 10;
export declare const batchEntries: (CLI: BaseCommand, entries: any[], toNotion: Function) => Promise<any[]>;
export {};