@prismicio/client 5.0.0-alpha.0 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +561 -72
- package/cjs/@prismicio/client.js +1280 -0
- package/cjs/@prismicio/client.js.map +1 -0
- package/cjs/@prismicio/client.min.js +16 -0
- package/cjs/@prismicio/client.min.js.map +1 -0
- package/esm/@prismicio/client.min.mjs +16 -0
- package/esm/@prismicio/client.min.mjs.map +1 -0
- package/esm/@prismicio/client.mjs +1276 -0
- package/esm/@prismicio/client.mjs.map +1 -0
- package/package.json +42 -67
- package/types/Api.d.ts +27 -0
- package/types/ApiSearchResponse.d.ts +11 -0
- package/types/Cookies.d.ts +9 -0
- package/types/HttpClient.d.ts +16 -0
- package/types/LazySearchForm.d.ts +24 -0
- package/types/Predicates.d.ts +58 -0
- package/types/PreviewResolver.d.ts +9 -0
- package/types/ResolvedApi.d.ts +126 -0
- package/types/SearchForm.d.ts +47 -0
- package/types/TagsForm.d.ts +7 -0
- package/types/cache.d.ts +17 -0
- package/types/client.d.ts +34 -0
- package/types/documents.d.ts +20 -0
- package/types/experiments.d.ts +22 -0
- package/types/form.d.ts +25 -0
- package/types/index.d.ts +129 -0
- package/types/lru.d.ts +25 -0
- package/types/request.d.ts +13 -0
- package/umd/@prismicio/client.js +1284 -0
- package/umd/@prismicio/client.js.map +1 -0
- package/umd/@prismicio/client.min.js +17 -0
- package/umd/@prismicio/client.min.js.map +1 -0
- package/CHANGELOG.md +0 -100
- package/LICENSE.md +0 -202
- package/dist/index.d.ts +0 -1038
- package/dist/index.es.js +0 -397
- package/dist/index.js +0 -407
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface AlternateLanguage {
|
|
2
|
+
id: string;
|
|
3
|
+
uid?: string;
|
|
4
|
+
type: string;
|
|
5
|
+
lang: string;
|
|
6
|
+
}
|
|
7
|
+
export interface Document<T = any> {
|
|
8
|
+
id: string;
|
|
9
|
+
uid?: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
type: string;
|
|
12
|
+
href: string;
|
|
13
|
+
tags: string[];
|
|
14
|
+
slugs: string[];
|
|
15
|
+
lang?: string;
|
|
16
|
+
alternate_languages: AlternateLanguage[];
|
|
17
|
+
first_publication_date: string | null;
|
|
18
|
+
last_publication_date: string | null;
|
|
19
|
+
data: T;
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class Variation {
|
|
2
|
+
data: any;
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
id(): string;
|
|
5
|
+
ref(): string;
|
|
6
|
+
label(): string;
|
|
7
|
+
}
|
|
8
|
+
export declare class Experiment {
|
|
9
|
+
variations: Variation[];
|
|
10
|
+
data: any;
|
|
11
|
+
constructor(data: any);
|
|
12
|
+
id(): string;
|
|
13
|
+
googleId(): string;
|
|
14
|
+
name(): string;
|
|
15
|
+
}
|
|
16
|
+
export declare class Experiments {
|
|
17
|
+
drafts: Experiment[];
|
|
18
|
+
running: Experiment[];
|
|
19
|
+
constructor(data: any);
|
|
20
|
+
current(): Experiment | null;
|
|
21
|
+
refFromCookie(cookie: string): string | null;
|
|
22
|
+
}
|
package/types/form.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import HttpClient from './HttpClient';
|
|
2
|
+
import { RequestCallback } from './request';
|
|
3
|
+
export declare type Fields = {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
};
|
|
6
|
+
export interface FormData {
|
|
7
|
+
fields: Fields;
|
|
8
|
+
action: string;
|
|
9
|
+
name: string;
|
|
10
|
+
rel: string;
|
|
11
|
+
form_method: string;
|
|
12
|
+
enctype: string;
|
|
13
|
+
}
|
|
14
|
+
export declare abstract class Form {
|
|
15
|
+
httpClient: HttpClient;
|
|
16
|
+
form: FormData;
|
|
17
|
+
data: any;
|
|
18
|
+
constructor(form: FormData, httpClient: HttpClient);
|
|
19
|
+
protected set(field: string, value: any): void;
|
|
20
|
+
url(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Submits the query, and calls the callback function.
|
|
23
|
+
*/
|
|
24
|
+
submit<T>(cb?: RequestCallback<T>): Promise<T>;
|
|
25
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import ResolvedApi from './ResolvedApi';
|
|
2
|
+
import { Experiments } from './experiments';
|
|
3
|
+
import Api, { ApiOptions } from './Api';
|
|
4
|
+
import { DefaultClient } from './client';
|
|
5
|
+
declare const _default: {
|
|
6
|
+
experimentCookie: string;
|
|
7
|
+
previewCookie: string;
|
|
8
|
+
Predicates: {
|
|
9
|
+
at(fragment: string, value: string | number | boolean | Date | (string | number | boolean | Date)[]): string;
|
|
10
|
+
not(fragment: string, value: string | number | boolean | Date | (string | number | boolean | Date)[]): string;
|
|
11
|
+
missing(fragment: string): string;
|
|
12
|
+
has(fragment: string): string;
|
|
13
|
+
any(fragment: string, values: (string | number | boolean | Date)[]): string;
|
|
14
|
+
in(fragment: string, values: string[]): string;
|
|
15
|
+
fulltext(fragment: string, value: string): string;
|
|
16
|
+
similar(documentId: string, maxResults: number): string;
|
|
17
|
+
date: {
|
|
18
|
+
before(fragment: string, before: string | number | boolean | Date): string;
|
|
19
|
+
after(fragment: string, after: string | number | boolean | Date): string;
|
|
20
|
+
between(fragment: string, before: string | number | boolean | Date, after: string | number | boolean | Date): string;
|
|
21
|
+
dayOfMonth(fragment: string, day: number): string;
|
|
22
|
+
dayOfMonthAfter(fragment: string, day: number): string;
|
|
23
|
+
dayOfMonthBefore(fragment: string, day: number): string;
|
|
24
|
+
dayOfWeek(fragment: string, day: string | number): string;
|
|
25
|
+
dayOfWeekAfter(fragment: string, day: string | number): string;
|
|
26
|
+
dayOfWeekBefore(fragment: string, day: string | number): string;
|
|
27
|
+
month(fragment: string, month: string | number): string;
|
|
28
|
+
monthBefore(fragment: string, month: string | number): string;
|
|
29
|
+
monthAfter(fragment: string, month: string | number): string;
|
|
30
|
+
year(fragment: string, year: number): string;
|
|
31
|
+
hour(fragment: string, hour: number): string;
|
|
32
|
+
hourBefore(fragment: string, hour: number): string;
|
|
33
|
+
hourAfter(fragment: string, hour: number): string;
|
|
34
|
+
};
|
|
35
|
+
dateBefore: (fragment: string, before: string | number | boolean | Date) => string;
|
|
36
|
+
dateAfter: (fragment: string, after: string | number | boolean | Date) => string;
|
|
37
|
+
dateBetween: (fragment: string, before: string | number | boolean | Date, after: string | number | boolean | Date) => string;
|
|
38
|
+
dayOfMonth: (fragment: string, day: number) => string;
|
|
39
|
+
dayOfMonthAfter: (fragment: string, day: number) => string;
|
|
40
|
+
dayOfMonthBefore: (fragment: string, day: number) => string;
|
|
41
|
+
dayOfWeek: (fragment: string, day: string | number) => string;
|
|
42
|
+
dayOfWeekAfter: (fragment: string, day: string | number) => string;
|
|
43
|
+
dayOfWeekBefore: (fragment: string, day: string | number) => string;
|
|
44
|
+
month: (fragment: string, month: string | number) => string;
|
|
45
|
+
monthBefore: (fragment: string, month: string | number) => string;
|
|
46
|
+
monthAfter: (fragment: string, month: string | number) => string;
|
|
47
|
+
year: (fragment: string, year: number) => string;
|
|
48
|
+
hour: (fragment: string, hour: number) => string;
|
|
49
|
+
hourBefore: (fragment: string, hour: number) => string;
|
|
50
|
+
hourAfter: (fragment: string, hour: number) => string;
|
|
51
|
+
number: {
|
|
52
|
+
gt(fragment: string, value: number): string;
|
|
53
|
+
lt(fragment: string, value: number): string;
|
|
54
|
+
inRange(fragment: string, before: number, after: number): string;
|
|
55
|
+
};
|
|
56
|
+
gt: (fragment: string, value: number) => string;
|
|
57
|
+
lt: (fragment: string, value: number) => string;
|
|
58
|
+
inRange: (fragment: string, before: number, after: number) => string;
|
|
59
|
+
near: (fragment: string, latitude: number, longitude: number, radius: number) => string;
|
|
60
|
+
geopoint: {
|
|
61
|
+
near(fragment: string, latitude: number, longitude: number, radius: number): string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
predicates: {
|
|
65
|
+
at(fragment: string, value: string | number | boolean | Date | (string | number | boolean | Date)[]): string;
|
|
66
|
+
not(fragment: string, value: string | number | boolean | Date | (string | number | boolean | Date)[]): string;
|
|
67
|
+
missing(fragment: string): string;
|
|
68
|
+
has(fragment: string): string;
|
|
69
|
+
any(fragment: string, values: (string | number | boolean | Date)[]): string;
|
|
70
|
+
in(fragment: string, values: string[]): string;
|
|
71
|
+
fulltext(fragment: string, value: string): string;
|
|
72
|
+
similar(documentId: string, maxResults: number): string;
|
|
73
|
+
date: {
|
|
74
|
+
before(fragment: string, before: string | number | boolean | Date): string;
|
|
75
|
+
after(fragment: string, after: string | number | boolean | Date): string;
|
|
76
|
+
between(fragment: string, before: string | number | boolean | Date, after: string | number | boolean | Date): string;
|
|
77
|
+
dayOfMonth(fragment: string, day: number): string;
|
|
78
|
+
dayOfMonthAfter(fragment: string, day: number): string;
|
|
79
|
+
dayOfMonthBefore(fragment: string, day: number): string;
|
|
80
|
+
dayOfWeek(fragment: string, day: string | number): string;
|
|
81
|
+
dayOfWeekAfter(fragment: string, day: string | number): string;
|
|
82
|
+
dayOfWeekBefore(fragment: string, day: string | number): string;
|
|
83
|
+
month(fragment: string, month: string | number): string;
|
|
84
|
+
monthBefore(fragment: string, month: string | number): string;
|
|
85
|
+
monthAfter(fragment: string, month: string | number): string;
|
|
86
|
+
year(fragment: string, year: number): string;
|
|
87
|
+
hour(fragment: string, hour: number): string;
|
|
88
|
+
hourBefore(fragment: string, hour: number): string;
|
|
89
|
+
hourAfter(fragment: string, hour: number): string;
|
|
90
|
+
};
|
|
91
|
+
dateBefore: (fragment: string, before: string | number | boolean | Date) => string;
|
|
92
|
+
dateAfter: (fragment: string, after: string | number | boolean | Date) => string;
|
|
93
|
+
dateBetween: (fragment: string, before: string | number | boolean | Date, after: string | number | boolean | Date) => string;
|
|
94
|
+
dayOfMonth: (fragment: string, day: number) => string;
|
|
95
|
+
dayOfMonthAfter: (fragment: string, day: number) => string;
|
|
96
|
+
dayOfMonthBefore: (fragment: string, day: number) => string;
|
|
97
|
+
dayOfWeek: (fragment: string, day: string | number) => string;
|
|
98
|
+
dayOfWeekAfter: (fragment: string, day: string | number) => string;
|
|
99
|
+
dayOfWeekBefore: (fragment: string, day: string | number) => string;
|
|
100
|
+
month: (fragment: string, month: string | number) => string;
|
|
101
|
+
monthBefore: (fragment: string, month: string | number) => string;
|
|
102
|
+
monthAfter: (fragment: string, month: string | number) => string;
|
|
103
|
+
year: (fragment: string, year: number) => string;
|
|
104
|
+
hour: (fragment: string, hour: number) => string;
|
|
105
|
+
hourBefore: (fragment: string, hour: number) => string;
|
|
106
|
+
hourAfter: (fragment: string, hour: number) => string;
|
|
107
|
+
number: {
|
|
108
|
+
gt(fragment: string, value: number): string;
|
|
109
|
+
lt(fragment: string, value: number): string;
|
|
110
|
+
inRange(fragment: string, before: number, after: number): string;
|
|
111
|
+
};
|
|
112
|
+
gt: (fragment: string, value: number) => string;
|
|
113
|
+
lt: (fragment: string, value: number) => string;
|
|
114
|
+
inRange: (fragment: string, before: number, after: number) => string;
|
|
115
|
+
near: (fragment: string, latitude: number, longitude: number, radius: number) => string;
|
|
116
|
+
geopoint: {
|
|
117
|
+
near(fragment: string, latitude: number, longitude: number, radius: number): string;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
Experiments: typeof Experiments;
|
|
121
|
+
Api: typeof Api;
|
|
122
|
+
client: typeof client;
|
|
123
|
+
getApi: typeof getApi;
|
|
124
|
+
api: typeof api;
|
|
125
|
+
};
|
|
126
|
+
export default _default;
|
|
127
|
+
declare function client(url: string, options?: ApiOptions): DefaultClient;
|
|
128
|
+
declare function getApi(url: string, options?: ApiOptions): Promise<ResolvedApi>;
|
|
129
|
+
declare function api(url: string, options?: ApiOptions): Promise<ResolvedApi>;
|
package/types/lru.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most
|
|
3
|
+
* recently used items while discarding least recently used items when its limit
|
|
4
|
+
* is reached.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson <http://hunch.se/>
|
|
7
|
+
* Typescript-ified by Oleksandr Nikitin <https://tvori.info>
|
|
8
|
+
*
|
|
9
|
+
* Illustration of the design:
|
|
10
|
+
*
|
|
11
|
+
* entry entry entry entry
|
|
12
|
+
* ______ ______ ______ ______
|
|
13
|
+
* | head |.newer => | |.newer => | |.newer => | tail |
|
|
14
|
+
* | A | | B | | C | | D |
|
|
15
|
+
* |______| <= older.|______| <= older.|______| <= older.|______|
|
|
16
|
+
*
|
|
17
|
+
* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added
|
|
18
|
+
*/
|
|
19
|
+
export declare function MakeLRUCache(limit: number): ILRUCache;
|
|
20
|
+
export interface ILRUCache {
|
|
21
|
+
put(key: string, value: any): void;
|
|
22
|
+
get(key: string, Entry: boolean): any;
|
|
23
|
+
remove(key: String): void;
|
|
24
|
+
removeAll(): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare type RequestCallback<T> = (error: Error | null, result?: T | null, resp?: Response, ttl?: number) => void;
|
|
2
|
+
export interface RequestHandlerOption {
|
|
3
|
+
proxyAgent?: any;
|
|
4
|
+
timeoutInMs?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface RequestHandler {
|
|
7
|
+
request<T>(url: string, cb: RequestCallback<T>): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class DefaultRequestHandler implements RequestHandler {
|
|
10
|
+
options: RequestHandlerOption;
|
|
11
|
+
constructor(options?: RequestHandlerOption);
|
|
12
|
+
request<T>(url: string, callback: RequestCallback<T>): void;
|
|
13
|
+
}
|