@microlink/mql 0.10.34 → 0.10.35

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/index.d.ts CHANGED
@@ -1,111 +1,27 @@
1
- export type ColorScheme = | "dark" | "light";
1
+ import { MqlPayload, MqlOptions, MicrolinkApiOptions } from './lightweight'
2
2
 
3
- export type WaitUntilEvent = "load" | "domcontentloaded" | "networkidle0" | "networkidle2";
4
-
5
- export type PixelUnit = string | number;
6
-
7
- export type ScreenshotOverlay = {
8
- background?: string,
9
- browser?: 'dark' | 'light'
10
- }
11
-
12
- export type MqlOptions = {
13
- endpoint?: string;
14
- apiKey?: string;
15
- retry?: number;
16
- cache?: Map<string, any>;
17
- }
18
-
19
- export type PdfMargin = {
20
- top?: string | number;
21
- bottom?: string | number;
22
- left?: string | number;
23
- right?: string | number;
24
- }
25
-
26
- export interface MqlQuery {
27
- [field: string]: MqlQueryOptions;
28
- }
29
-
30
- export type MqlQueryOptions = {
31
- attr?: string | string[] | MqlQuery;
32
- evaluate?: string;
33
- selector?: string | string[];
34
- selectorAll?: string | string[];
35
- type?: "audio" | "author" | "auto" | "boolean" | "date" | "description" | "email" | "image" | "ip" | "lang" | "logo" | "number" | "object" | "publisher" | "regexp" | "string" | "title" | "url" | "video";
36
- }
37
-
38
- export type PdfOptions = {
39
- format?: string;
40
- height?: PixelUnit;
41
- landscape?: string;
42
- margin?: string | PdfMargin;
43
- pageRanges?: string;
44
- scale?: number;
45
- width?: PixelUnit;
46
- }
47
-
48
- export type ScreenshotOptions = {
49
- codeScheme?: string;
50
- omitBackground?: boolean;
51
- type?: "jpeg" | "png";
52
- element?: string;
53
- fullPage?: boolean;
54
- overlay?: ScreenshotOverlay
55
- }
56
-
57
- export type MicrolinkApiOptions = {
58
- adblock?: boolean;
59
- animations?: boolean;
60
- audio?: boolean;
61
- click?: string | string[];
62
- colorScheme?: ColorScheme;
63
- data?: MqlQuery;
64
- device?: string;
65
- embed?: string;
66
- filename?: string;
67
- filter?: string;
68
- force?: boolean;
69
- function?: string;
70
- headers?: Record<string, string>;
71
- iframe?: boolean | { maxWidth?: number, maxHeight?: number };
72
- insights?: boolean | { lighthouse?: boolean | object, technologies?: boolean };
73
- javascript?: boolean;
74
- mediaType?: string;
75
- meta?: boolean | { logo: { square: boolean } };
76
- modules?: string | string[];
77
- palette?: boolean;
78
- pdf?: boolean | PdfOptions;
79
- ping?: boolean | object;
80
- prerender?: boolean | "auto";
81
- proxy?: string | { countryCode?: string };
82
- retry?: number;
83
- screenshot?: boolean | ScreenshotOptions;
84
- scripts?: string | string[];
85
- scroll?: string;
86
- styles?: string | string[];
87
- staleTtl?: string | number;
88
- timeout?: number;
89
- ttl?: string | number;
90
- video?: boolean;
91
- viewport?: object;
92
- waitForSelector?: string;
93
- waitForTimeout?: number;
94
- waitUntil?: WaitUntilEvent | WaitUntilEvent[];
3
+ type MqlResponse = MqlPayload & {
4
+ response: {
5
+ url: string;
6
+ isFromCache?: boolean;
7
+ statusCode: number;
8
+ headers: { [key: string]: string };
9
+ body: MqlPayload
10
+ };
95
11
  }
96
12
 
97
13
  declare function mql(
98
14
  url: string,
99
15
  opts?: MqlOptions & MicrolinkApiOptions,
100
- // TODO: gotOpts could be different depends the environment where the library is being used
101
- // - Under Node.js context, types are from `got`
102
- // https://github.com/microlinkhq/mql/blob/fbb55f4758495fa42d35822867763f95ac5ae960/src/node.js#L5
103
- // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/90a4ec8f0a9c76f33fdeeef0118f26c5d3df5cfa/types/got/index.d.ts#L212
104
- //
105
- // - Under brower context, types are from `ky`
106
- // https://github.com/microlinkhq/mql/blob/fbb55f4758495fa42d35822867763f95ac5ae960/src/browser.js#L9
107
- // https://github.com/sindresorhus/ky/blob/main/source/types/options.ts#L30
108
16
  gotOpts?: object
109
- ): Promise<object>;
17
+ ): Promise<MqlResponse>;
18
+
19
+ declare namespace mql {
20
+ function stream(
21
+ url: string,
22
+ opts?: MqlOptions & MicrolinkApiOptions,
23
+ gotOpts?: object
24
+ ): NodeJS.ReadableStream;
25
+ }
110
26
 
111
27
  export default mql;
@@ -0,0 +1,172 @@
1
+ type ColorScheme = | "dark" | "light";
2
+
3
+ type WaitUntilEvent = "load" | "domcontentloaded" | "networkidle0" | "networkidle2";
4
+
5
+ type PixelUnit = string | number;
6
+
7
+ type ScreenshotOverlay = {
8
+ background?: string,
9
+ browser?: 'dark' | 'light'
10
+ }
11
+
12
+ type PdfMargin = {
13
+ top?: string | number;
14
+ bottom?: string | number;
15
+ left?: string | number;
16
+ right?: string | number;
17
+ }
18
+
19
+ type PdfOptions = {
20
+ format?: string;
21
+ height?: PixelUnit;
22
+ landscape?: string;
23
+ margin?: string | PdfMargin;
24
+ pageRanges?: string;
25
+ scale?: number;
26
+ width?: PixelUnit;
27
+ }
28
+
29
+ type ScreenshotOptions = {
30
+ codeScheme?: string;
31
+ omitBackground?: boolean;
32
+ type?: "jpeg" | "png";
33
+ element?: string;
34
+ fullPage?: boolean;
35
+ overlay?: ScreenshotOverlay
36
+ }
37
+
38
+ export type MqlOptions = {
39
+ endpoint?: string;
40
+ apiKey?: string;
41
+ retry?: number;
42
+ cache?: Map<string, any>;
43
+ }
44
+
45
+ type MqlQuery = {
46
+ [field: string]: MqlQueryOptions;
47
+ }
48
+
49
+ type MqlQueryOptions = {
50
+ attr?: string | string[] | MqlQuery;
51
+ evaluate?: string;
52
+ selector?: string | string[];
53
+ selectorAll?: string | string[];
54
+ type?: "audio" | "author" | "auto" | "boolean" | "date" | "description" | "email" | "image" | "ip" | "lang" | "logo" | "number" | "object" | "publisher" | "regexp" | "string" | "title" | "url" | "video";
55
+ }
56
+
57
+ export type MicrolinkApiOptions = {
58
+ adblock?: boolean;
59
+ animations?: boolean;
60
+ audio?: boolean;
61
+ click?: string | string[];
62
+ colorScheme?: ColorScheme;
63
+ data?: MqlQuery;
64
+ device?: string;
65
+ embed?: string;
66
+ filename?: string;
67
+ filter?: string;
68
+ force?: boolean;
69
+ function?: string;
70
+ headers?: Record<string, string>;
71
+ iframe?: boolean | { maxWidth?: number, maxHeight?: number };
72
+ insights?: boolean | { lighthouse?: boolean | object, technologies?: boolean };
73
+ javascript?: boolean;
74
+ mediaType?: string;
75
+ meta?: boolean | { logo: { square: boolean } };
76
+ modules?: string | string[];
77
+ palette?: boolean;
78
+ pdf?: boolean | PdfOptions;
79
+ ping?: boolean | object;
80
+ prerender?: boolean | "auto";
81
+ proxy?: string | { countryCode?: string };
82
+ retry?: number;
83
+ screenshot?: boolean | ScreenshotOptions;
84
+ scripts?: string | string[];
85
+ scroll?: string;
86
+ styles?: string | string[];
87
+ staleTtl?: string | number;
88
+ timeout?: number;
89
+ ttl?: string | number;
90
+ video?: boolean;
91
+ viewport?: object;
92
+ waitForSelector?: string;
93
+ waitForTimeout?: number;
94
+ waitUntil?: WaitUntilEvent | WaitUntilEvent[];
95
+ }
96
+
97
+ type IframeInfo = {
98
+ html: string;
99
+ scripts: Record<string, unknown>;
100
+ }
101
+
102
+ type MediaInfo = {
103
+ type?: string;
104
+ palette?: string[];
105
+ background_color?: string;
106
+ color?: string;
107
+ alternative_color?: string;
108
+ width?: number;
109
+ height?: number;
110
+ duration?: number;
111
+ duration_pretty?: string;
112
+ }
113
+
114
+ type MqlResponseData = {
115
+ // A human-readable representation of the author's name.
116
+ author?: string | null;
117
+ // An ISO 8601 representation of the date the article was published.
118
+ date?: string | null;
119
+ // The publisher's chosen description of the article.
120
+ description?: string | null;
121
+ // An ISO 639-1 representation of the url content language.
122
+ lang?: string | null;
123
+ // An image URL that best represents the publisher brand.
124
+ logo?: MediaInfo | null;
125
+ // A human-readable representation of the publisher's name.
126
+ publisher?: string | null;
127
+ // The publisher's chosen title of the article.
128
+ title?: string | null;
129
+ // The URL of the article.
130
+ url?: string;
131
+ image?: MediaInfo | null;
132
+ screenshot?: MediaInfo | null;
133
+ video?: MediaInfo | null;
134
+ audio?: MediaInfo | null;
135
+ iframe?: IframeInfo | null;
136
+ function?: MqlFunctionResult;
137
+ }
138
+
139
+ type MqlFunctionResult = {
140
+ isFulfilled: boolean;
141
+ isRejected: boolean;
142
+ value: any;
143
+ };
144
+
145
+ type MqlStatus = "success" | "fail" | "error";
146
+
147
+ export type MqlPayload = {
148
+ status: MqlStatus;
149
+ data: MqlResponseData;
150
+ statusCode: number;
151
+ headers: { [key: string]: string };
152
+ more?: string,
153
+ code?: string,
154
+ url?: string
155
+ }
156
+
157
+ type MqlResponse = MqlPayload & {
158
+ response: {
159
+ url: string;
160
+ statusCode: number;
161
+ headers: Headers;
162
+ body: MqlPayload
163
+ };
164
+ }
165
+
166
+ declare function mql(
167
+ url: string,
168
+ opts?: MqlOptions & MicrolinkApiOptions,
169
+ gotOpts?: object
170
+ ): Promise<MqlResponse>;
171
+
172
+ export default mql;
@@ -1,4 +1,4 @@
1
1
  {
2
- "main": "../src/browser.js",
3
- "types": "../index.d.ts"
2
+ "main": "../src/lightweight.js",
3
+ "types": "index.d.ts"
4
4
  }
package/package.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "name": "@microlink/mql",
3
3
  "description": "Microlink Query Language. The official HTTP client to interact with Microlink API for Node.js, browsers & Deno.",
4
4
  "homepage": "https://nicedoc.io/microlinkhq/mql",
5
- "version": "0.10.34",
6
- "browser": "src/browser.js",
5
+ "version": "0.10.35",
6
+ "browser": "src/lightweight.js",
7
7
  "main": "src/node.js",
8
8
  "author": {
9
9
  "email": "josefrancisco.verdu@gmail.com",
@@ -56,22 +56,15 @@
56
56
  "@rollup/plugin-node-resolve": "latest",
57
57
  "@rollup/plugin-replace": "latest",
58
58
  "@rollup/plugin-terser": "latest",
59
- "abort-controller": "latest",
60
59
  "async-listen": "latest",
61
60
  "ava": "3",
62
- "beauty-error": "latest",
63
61
  "c8": "latest",
64
- "chalk": "latest",
65
62
  "ci-publish": "latest",
66
63
  "conventional-github-releaser": "latest",
67
- "eachdir": "latest",
68
64
  "esm": "latest",
69
- "exists-file": "latest",
70
65
  "git-authors-cli": "latest",
71
66
  "ky": "latest",
72
- "meow": "latest",
73
67
  "nano-staged": "latest",
74
- "node-fetch": "2",
75
68
  "npm-check-updates": "latest",
76
69
  "prettier-standard": "latest",
77
70
  "rollup": "latest",
@@ -82,8 +75,7 @@
82
75
  "standard-markdown": "latest",
83
76
  "standard-version": "latest",
84
77
  "stream-to-promise": "latest",
85
- "tsd": "latest",
86
- "web-streams-polyfill": "latest"
78
+ "tsd": "latest"
87
79
  },
88
80
  "engines": {
89
81
  "node": ">= 12"
File without changes