@microlink/mql 0.10.34 → 0.10.36-0

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,9 +2,16 @@
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.36-0",
6
+ "browser": "src/lightweight.js",
7
7
  "main": "src/node.js",
8
+ "types": "index.d.ts",
9
+ "umd:main": "dist/mql.js",
10
+ "unpkg": "dist/mql.js",
11
+ "exports": {
12
+ "import": "./dist/mql.js",
13
+ "require": "./src/node.js"
14
+ },
8
15
  "author": {
9
16
  "email": "josefrancisco.verdu@gmail.com",
10
17
  "name": "Kiko Beats",
@@ -56,22 +63,15 @@
56
63
  "@rollup/plugin-node-resolve": "latest",
57
64
  "@rollup/plugin-replace": "latest",
58
65
  "@rollup/plugin-terser": "latest",
59
- "abort-controller": "latest",
60
66
  "async-listen": "latest",
61
67
  "ava": "3",
62
- "beauty-error": "latest",
63
68
  "c8": "latest",
64
- "chalk": "latest",
65
69
  "ci-publish": "latest",
66
70
  "conventional-github-releaser": "latest",
67
- "eachdir": "latest",
68
71
  "esm": "latest",
69
- "exists-file": "latest",
70
72
  "git-authors-cli": "latest",
71
73
  "ky": "latest",
72
- "meow": "latest",
73
74
  "nano-staged": "latest",
74
- "node-fetch": "2",
75
75
  "npm-check-updates": "latest",
76
76
  "prettier-standard": "latest",
77
77
  "rollup": "latest",
@@ -82,8 +82,7 @@
82
82
  "standard-markdown": "latest",
83
83
  "standard-version": "latest",
84
84
  "stream-to-promise": "latest",
85
- "tsd": "latest",
86
- "web-streams-polyfill": "latest"
85
+ "tsd": "latest"
87
86
  },
88
87
  "engines": {
89
88
  "node": ">= 12"
@@ -94,25 +93,6 @@
94
93
  "lightweight",
95
94
  "src"
96
95
  ],
97
- "scripts": {
98
- "build": "rollup -c rollup.config.js --bundleConfigAsCjs",
99
- "build:kys": "[ -f src/ky.js ] || rollup node_modules/ky/distribution/index.js --format=umd --name=ky --exports=named --file=src/ky.js",
100
- "clean": "rm -rf node_modules",
101
- "clean:build": "rm -rf dist",
102
- "contributors": "(npx git-authors-cli && npx finepack --sort-ignore-object-at ava && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
103
- "dev": "npm run build -- -w",
104
- "lint": "standard && tsd",
105
- "postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
106
- "prebuild": "npm run clean:build && npm run build:kys",
107
- "prerelease": "npm run update:check",
108
- "pretest": "npm run lint && npm run build",
109
- "release": "standard-version -a",
110
- "release:github": "conventional-github-releaser -p angular",
111
- "release:tags": "git push --follow-tags origin HEAD:master",
112
- "test": "c8 ava --verbose",
113
- "update": "ncu -u",
114
- "update:check": "ncu -- --error-level 2"
115
- },
116
96
  "license": "MIT",
117
97
  "ava": {
118
98
  "files": [
@@ -160,7 +140,23 @@
160
140
  "tsd": {
161
141
  "directory": "test"
162
142
  },
163
- "types": "index.d.ts",
164
- "umd:main": "dist/mql.js",
165
- "unpkg": "dist/mql.js"
166
- }
143
+ "scripts": {
144
+ "build": "rollup -c rollup.config.js --bundleConfigAsCjs",
145
+ "build:kys": "[ -f src/ky.js ] || rollup node_modules/ky/distribution/index.js --format=umd --name=ky --exports=named --file=src/ky.js",
146
+ "clean": "rm -rf node_modules",
147
+ "clean:build": "rm -rf dist",
148
+ "contributors": "(npx git-authors-cli && npx finepack --sort-ignore-object-at ava && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
149
+ "dev": "npm run build -- -w",
150
+ "lint": "standard && tsd",
151
+ "postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
152
+ "prebuild": "npm run clean:build && npm run build:kys",
153
+ "prerelease": "npm run update:check",
154
+ "pretest": "npm run lint && npm run build",
155
+ "release": "standard-version -a",
156
+ "release:github": "conventional-github-releaser -p angular",
157
+ "release:tags": "git push --follow-tags origin HEAD:master",
158
+ "test": "c8 ava --verbose",
159
+ "update": "ncu -u",
160
+ "update:check": "ncu -- --error-level 2"
161
+ }
162
+ }
File without changes