-
Notifications
You must be signed in to change notification settings - Fork 4
/
types.ts
126 lines (116 loc) · 3.75 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// deno-fmt-ignore
/** Available tags supported in Telegraph */
export const SUPPORTED_TAGS = [
"a", "aside", "b", "blockquote", "br", "code", "em", "figcaption",
"figure", "h3", "h4", "hr", "i", "iframe", "img", "li", "ol", "p",
"pre", "s", "strong", "u", "ul", "video",
] as const;
/** This object represents a Telegraph account. */
export interface Account {
/**
* Account name, helps users with several accounts remember which they are
* currently using. Displayed to the user above the "Edit/Publish" button on
* Telegra.ph, other users don't see this name.
*/
short_name: string;
/** Default author name used when creating new articles. */
author_name: string;
/**
* Profile link, opened when users click on the author's name below the
* title. Can be any link, not necessarily to a Telegram profile or channel.
*/
author_url: string;
}
export interface PageCount {
/** Number of pages belonging to the Telegraph account. */
page_count: number;
}
/** The access token and auth URL returned after revoking the token. */
export interface AccessToken {
/**
* Only returned by the createAccount and revokeAccessToken method.
* Access token of the Telegraph account.
*/
access_token: string;
}
export interface AuthUrl {
/**
* URL to authorize a browser on telegra.ph and connect it to a
* Telegraph account. This URL is valid for only one use and for 5 minutes
* only.
*/
auth_url: string;
}
/** This object represents the number of page views for a Telegraph article. */
export interface PageViews {
/** Number of page views for the target page. */
views: number;
}
/** Available tags in Telegraph. */
export type SupportedTag = typeof SUPPORTED_TAGS[number];
/** This object represents a DOM element node. */
export interface NodeElement {
/**
* Name of the DOM element. Available tags: a, aside, b, blockquote, br,
* code, em, figcaption, figure, h3, h4, hr, i, iframe, img, li, ol, p, pre,
* s, strong, u, ul, video.
*/
tag: SupportedTag;
/**
* Attributes of the DOM element. Key of object represents name of
* attribute, value represents value of attribute. Available attributes:
* href, src.
*/
attrs?: { href?: string; src?: string };
/** List of child nodes for the DOM element. */
children?: Node[];
}
/**
* This abstract object represents a DOM Node. It can be a String which
* represents a DOM text node or a NodeElement object.
*/
export type Node = string | NodeElement;
/** This object represents a page on Telegraph. */
export type Page<T extends boolean> =
& {
/** Path to the page. */
path: string;
/** URL of the page. */
url: string;
/** Title of the page. */
title: string;
/** Description of the page. */
description: string;
/** Name of the author, displayed below the title. */
author_name?: string;
/**
* Profile link, opened when users click on the author's name below the
* title. Can be any link, not necessarily to a Telegram profile or channel.
*/
author_url?: string;
/** Image URL of the page. */
image_url?: string;
/** Number of page views for the page. */
views: number;
/**
* Only returned if access_token passed. True, if the target Telegraph
* account can edit the page.
*/
can_edit?: boolean;
}
& (T extends true ? {
/** Content of the page. */
content: string | Node[];
}
// deno-lint-ignore ban-types
: {});
/**
* This object represents a list of Telegraph articles belonging to an account.
* Most recently created articles first.
*/
export interface PageList {
/** Total number of pages belonging to the target Telegraph account. */
total_count: number;
/** Requested pages of the target Telegraph account. */
pages: Page<false>[];
}