UNPKG

12.3 kBTypeScriptView Raw
1/// <reference types="node" />
2import { URL } from 'url';
3/**
4 * How frequently the page is likely to change. This value provides general
5 * information to search engines and may not correlate exactly to how often they crawl the page. Please note that the
6 * value of this tag is considered a hint and not a command. See
7 * <https://www.sitemaps.org/protocol.html#xmlTagDefinitions> for the acceptable
8 * values
9 */
10export declare enum EnumChangefreq {
11 DAILY = "daily",
12 MONTHLY = "monthly",
13 ALWAYS = "always",
14 HOURLY = "hourly",
15 WEEKLY = "weekly",
16 YEARLY = "yearly",
17 NEVER = "never"
18}
19export declare const validators: {
20 [index: string]: RegExp;
21};
22export declare function isPriceType(pt: string | PriceType): pt is PriceType;
23export declare function isResolution(res: string): res is Resolution;
24export declare const CHANGEFREQ: EnumChangefreq[];
25export declare function isValidChangeFreq(freq: string): freq is EnumChangefreq;
26export declare enum EnumYesNo {
27 YES = "YES",
28 NO = "NO",
29 Yes = "Yes",
30 No = "No",
31 yes = "yes",
32 no = "no"
33}
34export declare function isValidYesNo(yn: string): yn is EnumYesNo;
35export declare enum EnumAllowDeny {
36 ALLOW = "allow",
37 DENY = "deny"
38}
39export declare function isAllowDeny(ad: string): ad is EnumAllowDeny;
40/**
41 * https://support.google.com/webmasters/answer/74288?hl=en&ref_topic=4581190
42 */
43export interface NewsItem {
44 access?: 'Registration' | 'Subscription';
45 publication: {
46 name: string;
47 /**
48 * The `<language>` is the language of your publication. Use an ISO 639
49 * language code (2 or 3 letters).
50 */
51 language: string;
52 };
53 /**
54 * @example 'PressRelease, Blog'
55 */
56 genres?: string;
57 /**
58 * Article publication date in W3C format, using either the "complete date" (YYYY-MM-DD) format or the "complete date
59 * plus hours, minutes, and seconds"
60 */
61 publication_date: string;
62 /**
63 * The title of the news article
64 * @example 'Companies A, B in Merger Talks'
65 */
66 title: string;
67 /**
68 * @example 'business, merger, acquisition'
69 */
70 keywords?: string;
71 /**
72 * @example 'NASDAQ:A, NASDAQ:B'
73 */
74 stock_tickers?: string;
75}
76/**
77 * Sitemap Image
78 * https://support.google.com/webmasters/answer/178636?hl=en&ref_topic=4581190
79 */
80export interface Img {
81 /**
82 * The URL of the image
83 * @example 'https://example.com/image.jpg'
84 */
85 url: string;
86 /**
87 * The caption of the image
88 * @example 'Thanksgiving dinner'
89 */
90 caption?: string;
91 /**
92 * The title of the image
93 * @example 'Star Wars EP IV'
94 */
95 title?: string;
96 /**
97 * The geographic location of the image.
98 * @example 'Limerick, Ireland'
99 */
100 geoLocation?: string;
101 /**
102 * A URL to the license of the image.
103 * @example 'https://example.com/license.txt'
104 */
105 license?: string;
106}
107interface VideoItemBase {
108 /**
109 * A URL pointing to the video thumbnail image file
110 * @example "https://rtv3-img-roosterteeth.akamaized.net/store/0e841100-289b-4184-ae30-b6a16736960a.jpg/sm/thumb3.jpg"
111 */
112 thumbnail_loc: string;
113 /**
114 * The title of the video
115 * @example '2018:E6 - GoldenEye: Source'
116 */
117 title: string;
118 /**
119 * A description of the video. Maximum 2048 characters.
120 * @example 'We play gun game in GoldenEye: Source with a good friend of ours. His name is Gruchy. Dan Gruchy.'
121 */
122 description: string;
123 /**
124 * A URL pointing to the actual video media file. Should be one of the supported formats. HTML is not a supported
125 * format. Flash is allowed, but no longer supported on most mobile platforms, and so may be indexed less well. Must
126 * not be the same as the `<loc>` URL.
127 * @example "http://streamserver.example.com/video123.mp4"
128 */
129 content_loc?: string;
130 /**
131 * A URL pointing to a player for a specific video. Usually this is the information in the src element of an `<embed>`
132 * tag. Must not be the same as the `<loc>` URL
133 * @example "https://roosterteeth.com/embed/rouletsplay-2018-goldeneye-source"
134 */
135 player_loc?: string;
136 /**
137 * A string the search engine can append as a query param to enable automatic
138 * playback. Equivilant to auto play attr on player_loc tag.
139 * @example 'ap=1'
140 */
141 'player_loc:autoplay'?: string;
142 /**
143 * Whether the search engine can embed the video in search results. Allowed values are yes or no.
144 */
145 'player_loc:allow_embed'?: EnumYesNo;
146 /**
147 * The length of the video in seconds
148 * @example 600
149 */
150 duration?: number;
151 /**
152 * The date after which the video will no longer be available.
153 * @example "2012-07-16T19:20:30+08:00"
154 */
155 expiration_date?: string;
156 /**
157 * The number of times the video has been viewed
158 */
159 view_count?: number;
160 /**
161 * The date the video was first published, in W3C format.
162 * @example "2012-07-16T19:20:30+08:00"
163 */
164 publication_date?: string;
165 /**
166 * A short description of the broad category that the video belongs to. This is a string no longer than 256 characters.
167 * @example Baking
168 */
169 category?: string;
170 /**
171 * Whether to show or hide your video in search results from specific countries.
172 * @example "IE GB US CA"
173 */
174 restriction?: string;
175 /**
176 * Whether the countries in restriction are allowed or denied
177 * @example 'deny'
178 */
179 'restriction:relationship'?: EnumAllowDeny;
180 gallery_loc?: string;
181 /**
182 * [Optional] Specifies the URL of a webpage with additional information about this uploader. This URL must be in the same domain as the <loc> tag.
183 * @see https://developers.google.com/search/docs/advanced/sitemaps/video-sitemaps
184 * @example http://www.example.com/users/grillymcgrillerson
185 */
186 'uploader:info'?: string;
187 'gallery_loc:title'?: string;
188 /**
189 * The price to download or view the video. Omit this tag for free videos.
190 * @example "1.99"
191 */
192 price?: string;
193 /**
194 * Specifies the resolution of the purchased version. Supported values are hd and sd.
195 * @example "HD"
196 */
197 'price:resolution'?: Resolution;
198 /**
199 * Specifies the currency in ISO4217 format.
200 * @example "USD"
201 */
202 'price:currency'?: string;
203 /**
204 * Specifies the purchase option. Supported values are rend and own.
205 * @example "rent"
206 */
207 'price:type'?: PriceType;
208 /**
209 * The video uploader's name. Only one <video:uploader> is allowed per video. String value, max 255 characters.
210 * @example "GrillyMcGrillerson"
211 */
212 uploader?: string;
213 /**
214 * Whether to show or hide your video in search results on specified platform types. This is a list of space-delimited
215 * platform types. See <https://support.google.com/webmasters/answer/80471?hl=en&ref_topic=4581190> for more detail
216 * @example "tv"
217 */
218 platform?: string;
219 id?: string;
220 'platform:relationship'?: EnumAllowDeny;
221}
222export declare type PriceType = 'rent' | 'purchase' | 'RENT' | 'PURCHASE';
223export declare type Resolution = 'HD' | 'hd' | 'sd' | 'SD';
224/**
225 * Sitemap video. <https://support.google.com/webmasters/answer/80471?hl=en&ref_topic=4581190>
226 */
227export interface VideoItem extends VideoItemBase {
228 /**
229 * An arbitrary string tag describing the video. Tags are generally very short descriptions of key concepts associated
230 * with a video or piece of content.
231 * @example ['Baking']
232 */
233 tag: string[];
234 /**
235 * The rating of the video. Supported values are float numbers.
236 * @example 2.5
237 */
238 rating?: number;
239 family_friendly?: EnumYesNo;
240 /**
241 * Indicates whether a subscription (either paid or free) is required to view
242 * the video. Allowed values are yes or no.
243 */
244 requires_subscription?: EnumYesNo;
245 /**
246 * Indicates whether the video is a live stream. Supported values are yes or no.
247 */
248 live?: EnumYesNo;
249}
250/**
251 * Sitemap video. <https://support.google.com/webmasters/answer/80471?hl=en&ref_topic=4581190>
252 */
253export interface VideoItemLoose extends VideoItemBase {
254 /**
255 * An arbitrary string tag describing the video. Tags are generally very short descriptions of key concepts associated
256 * with a video or piece of content.
257 * @example ['Baking']
258 */
259 tag?: string | string[];
260 /**
261 * The rating of the video. Supported values are float numbers.
262 * @example 2.5
263 */
264 rating?: string | number;
265 family_friendly?: EnumYesNo | boolean;
266 requires_subscription?: EnumYesNo | boolean;
267 /**
268 * Indicates whether the video is a live stream. Supported values are yes or no.
269 */
270 live?: EnumYesNo | boolean;
271}
272/**
273 * https://support.google.com/webmasters/answer/189077
274 */
275export interface LinkItem {
276 /**
277 * @example 'en'
278 */
279 lang: string;
280 /**
281 * @example 'en-us'
282 */
283 hreflang?: string;
284 url: string;
285}
286export interface IndexItem {
287 url: string;
288 lastmod?: string;
289}
290interface SitemapItemBase {
291 lastmod?: string;
292 changefreq?: EnumChangefreq;
293 fullPrecisionPriority?: boolean;
294 priority?: number;
295 news?: NewsItem;
296 expires?: string;
297 androidLink?: string;
298 ampLink?: string;
299 url: string;
300}
301/**
302 * Strict options for individual sitemap entries
303 */
304export interface SitemapItem extends SitemapItemBase {
305 img: Img[];
306 video: VideoItem[];
307 links: LinkItem[];
308}
309/**
310 * Options for individual sitemap entries prior to normalization
311 */
312export interface SitemapItemLoose extends SitemapItemBase {
313 video?: VideoItemLoose | VideoItemLoose[];
314 img?: string | Img | (string | Img)[];
315 links?: LinkItem[];
316 lastmodfile?: string | Buffer | URL;
317 lastmodISO?: string;
318 lastmodrealtime?: boolean;
319}
320/**
321 * How to handle errors in passed in urls
322 */
323export declare enum ErrorLevel {
324 /**
325 * Validation will be skipped and nothing logged or thrown.
326 */
327 SILENT = "silent",
328 /**
329 * If an invalid value is encountered, a console.warn will be called with details
330 */
331 WARN = "warn",
332 /**
333 * An Error will be thrown on encountering invalid data.
334 */
335 THROW = "throw"
336}
337export declare type ErrorHandler = (error: Error, level: ErrorLevel) => void;
338export declare enum TagNames {
339 url = "url",
340 loc = "loc",
341 urlset = "urlset",
342 lastmod = "lastmod",
343 changefreq = "changefreq",
344 priority = "priority",
345 'video:thumbnail_loc' = "video:thumbnail_loc",
346 'video:video' = "video:video",
347 'video:title' = "video:title",
348 'video:description' = "video:description",
349 'video:tag' = "video:tag",
350 'video:duration' = "video:duration",
351 'video:player_loc' = "video:player_loc",
352 'video:content_loc' = "video:content_loc",
353 'image:image' = "image:image",
354 'image:loc' = "image:loc",
355 'image:geo_location' = "image:geo_location",
356 'image:license' = "image:license",
357 'image:title' = "image:title",
358 'image:caption' = "image:caption",
359 'video:requires_subscription' = "video:requires_subscription",
360 'video:publication_date' = "video:publication_date",
361 'video:id' = "video:id",
362 'video:restriction' = "video:restriction",
363 'video:family_friendly' = "video:family_friendly",
364 'video:view_count' = "video:view_count",
365 'video:uploader' = "video:uploader",
366 'video:expiration_date' = "video:expiration_date",
367 'video:platform' = "video:platform",
368 'video:price' = "video:price",
369 'video:rating' = "video:rating",
370 'video:category' = "video:category",
371 'video:live' = "video:live",
372 'video:gallery_loc' = "video:gallery_loc",
373 'news:news' = "news:news",
374 'news:publication' = "news:publication",
375 'news:name' = "news:name",
376 'news:access' = "news:access",
377 'news:genres' = "news:genres",
378 'news:publication_date' = "news:publication_date",
379 'news:title' = "news:title",
380 'news:keywords' = "news:keywords",
381 'news:stock_tickers' = "news:stock_tickers",
382 'news:language' = "news:language",
383 'mobile:mobile' = "mobile:mobile",
384 'xhtml:link' = "xhtml:link",
385 'expires' = "expires"
386}
387export {};