@corsair-dev/webscraperio 0.0.0-stage → 0.1.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/LICENSE +191 -0
- package/README.md +33 -2
- package/dist/api.test.d.ts +2 -0
- package/dist/api.test.d.ts.map +1 -0
- package/dist/client.d.ts +58 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.test.d.ts +2 -0
- package/dist/client.test.d.ts.map +1 -0
- package/dist/endpoints/call.d.ts +19 -0
- package/dist/endpoints/call.d.ts.map +1 -0
- package/dist/endpoints/index.d.ts +4 -0
- package/dist/endpoints/index.d.ts.map +1 -0
- package/dist/endpoints/sitemaps.d.ts +12 -0
- package/dist/endpoints/sitemaps.d.ts.map +1 -0
- package/dist/endpoints/types.d.ts +150 -0
- package/dist/endpoints/types.d.ts.map +1 -0
- package/dist/endpoints.test.d.ts +2 -0
- package/dist/endpoints.test.d.ts.map +1 -0
- package/dist/error-handlers.d.ts +62 -0
- package/dist/error-handlers.d.ts.map +1 -0
- package/dist/error-handlers.test.d.ts +2 -0
- package/dist/error-handlers.test.d.ts.map +1 -0
- package/dist/index.d.ts +96 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/plugin.test.d.ts +2 -0
- package/dist/plugin.test.d.ts.map +1 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema.test.d.ts +2 -0
- package/dist/schema.test.d.ts.map +1 -0
- package/dist/test-fixtures.d.ts +75 -0
- package/dist/test-fixtures.d.ts.map +1 -0
- package/dist/test-support.d.ts +30 -0
- package/dist/test-support.d.ts.map +1 -0
- package/dist/tsup.config.d.ts +3 -0
- package/dist/tsup.config.d.ts.map +1 -0
- package/package.json +51 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(which shall not include Communications that are clearly marked or
|
|
39
|
+
otherwise designated in writing by the copyright owner as "Not a Work").
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution".
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright (c) 2026 Corsair
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @corsair-dev/webscraperio
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Web Scraper Cloud plugin for Corsair - list and read sitemaps with their selectors and start URLs, create a sitemap from an exported definition, and read the account's page credits.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @corsair-dev/webscraperio
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Endpoints
|
|
12
|
+
|
|
13
|
+
| Operation | Operation ID | Risk | Description |
|
|
14
|
+
|-----------|--------------|------|-------------|
|
|
15
|
+
| `account.get` | `webscraperio.api.account.get` | `read` | Read the account user and the page credits left; the cheapest way to check a token |
|
|
16
|
+
| `sitemaps.create` | `webscraperio.api.sitemaps.create` | `write` | Create a sitemap from the definition the browser extension exports, selectors included |
|
|
17
|
+
| `sitemaps.get` | `webscraperio.api.sitemaps.get` | `read` | Read one sitemap: its id, name and definition (start URLs and selectors) as a JSON string |
|
|
18
|
+
| `sitemaps.list` | `webscraperio.api.sitemaps.list` | `read` | List the sitemaps on the account (id and name), a page at a time, optionally filtered by tag |
|
|
19
|
+
|
|
20
|
+
## Auth
|
|
21
|
+
|
|
22
|
+
Auth: API key. Corsair prompts your tenant for credentials on first use.
|
|
23
|
+
|
|
24
|
+
## Webhooks
|
|
25
|
+
|
|
26
|
+
No webhooks.
|
|
27
|
+
|
|
28
|
+
## Reference
|
|
29
|
+
|
|
30
|
+
Full docs, types, and examples: https://docs.corsair.dev/plugins/webscraperio
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
Apache-2.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.test.d.ts","sourceRoot":"","sources":["../api.test.ts"],"names":[],"mappings":""}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export declare const WEBSCRAPERIO_API_BASE = "https://api.webscraper.io/api/v1";
|
|
2
|
+
/**
|
|
3
|
+
* The Cloud API answers two different error shapes, depending on which layer
|
|
4
|
+
* refused the call:
|
|
5
|
+
*
|
|
6
|
+
* - a **handled** failure is `{ success: false, error: "..." }` — this is what
|
|
7
|
+
* a bad token produces;
|
|
8
|
+
* - an **unrouted** request is Laravel's own `{ message: "The route ... could
|
|
9
|
+
* not be found." }`, which means the path is wrong rather than the key.
|
|
10
|
+
*
|
|
11
|
+
* The second is worth distinguishing: on this API a 404 is a typo in the
|
|
12
|
+
* route, not a missing sitemap.
|
|
13
|
+
*/
|
|
14
|
+
export declare class WebscraperioAPIError extends Error {
|
|
15
|
+
readonly status?: number;
|
|
16
|
+
/** True when the call reached the application and was refused by it. */
|
|
17
|
+
readonly handled: boolean;
|
|
18
|
+
/** Milliseconds from a Retry-After header, when sent. */
|
|
19
|
+
readonly retryAfter?: number;
|
|
20
|
+
/** The HTTP method of the failed request. */
|
|
21
|
+
readonly method?: string;
|
|
22
|
+
readonly body?: unknown;
|
|
23
|
+
constructor(message: string, options?: {
|
|
24
|
+
cause?: Error;
|
|
25
|
+
status?: number;
|
|
26
|
+
body?: unknown;
|
|
27
|
+
retryAfter?: number;
|
|
28
|
+
method?: string;
|
|
29
|
+
});
|
|
30
|
+
/** True when the token was rejected, for any credential reason. */
|
|
31
|
+
get isAuthError(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* True when the token itself is wrong. A 403 means a working token without
|
|
34
|
+
* access to the resource (the API's answer for a missing or foreign sitemap),
|
|
35
|
+
* which is the permission case rather than this one.
|
|
36
|
+
*/
|
|
37
|
+
get isInvalidToken(): boolean;
|
|
38
|
+
/** True when the route does not exist, which is a mistyped path. */
|
|
39
|
+
get isRouteNotFound(): boolean;
|
|
40
|
+
/** True when the sitemap itself is missing. */
|
|
41
|
+
get isNotFound(): boolean;
|
|
42
|
+
}
|
|
43
|
+
export declare function describeWebscraperioError(status: number | undefined, body: unknown, fallback: string, apiKey?: string): string;
|
|
44
|
+
export type WebscraperioQuery = Record<string, string | number | boolean | undefined>;
|
|
45
|
+
export type WebscraperioRequest = {
|
|
46
|
+
method: 'GET' | 'POST' | 'DELETE';
|
|
47
|
+
path: string;
|
|
48
|
+
query?: WebscraperioQuery;
|
|
49
|
+
body?: unknown;
|
|
50
|
+
};
|
|
51
|
+
/** Encodes one path segment; sitemap ids are numeric but passed as strings. */
|
|
52
|
+
export declare function segment(value: string | number): string;
|
|
53
|
+
export declare function makeWebscraperioRequest(apiKey: string, { method, path, query, body }: WebscraperioRequest): Promise<unknown>;
|
|
54
|
+
/** Removes the submitted token anywhere the provider echoed it back. */
|
|
55
|
+
export declare function redactToken(text: string, apiKey: string): string;
|
|
56
|
+
/** Narrows a caught value to this plugin's error. */
|
|
57
|
+
export declare function isWebscraperioFailure(error: unknown): error is WebscraperioAPIError;
|
|
58
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../client.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,qBAAqB,qCAAqC,CAAC;AAqBxE;;;;;;;;;;;GAWG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,yDAAyD;IACzD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;gBAGvB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QACR,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAEhB,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;KACX;IAcP,mEAAmE;IACnE,IAAI,WAAW,IAAI,OAAO,CAGzB;IAED;;;;OAIG;IACH,IAAI,cAAc,IAAI,OAAO,CAM5B;IAED,oEAAoE;IACpE,IAAI,eAAe,IAAI,OAAO,CAI7B;IAED,+CAA+C;IAC/C,IAAI,UAAU,IAAI,OAAO,CAExB;CACD;AAGD,wBAAgB,yBAAyB,CACxC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,GACb,MAAM,CAOR;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,CACrC,MAAM,EACN,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CACrC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IACjC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAE1B,IAAI,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,+EAA+E;AAC/E,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAEtD;AAGD,wBAAsB,uBAAuB,CAC5C,MAAM,EAAE,MAAM,EACd,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,mBAAmB,GAChD,OAAO,CAAC,OAAO,CAAC,CAuDlB;AAED,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGhE;AAsBD,qDAAqD;AACrD,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,OAAO,GACZ,KAAK,IAAI,oBAAoB,CAE/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../client.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { WebscraperioContext } from '..';
|
|
3
|
+
import type { WebscraperioRequest } from '../client';
|
|
4
|
+
type LogFields = Record<string, string | number | boolean | undefined>;
|
|
5
|
+
/**
|
|
6
|
+
* Validates the input, sends the request, shapes and validates the response,
|
|
7
|
+
* then logs the event. A sitemap holds the target URLs and selectors, which can
|
|
8
|
+
* name a customer's pages, so `log` picks the fields.
|
|
9
|
+
*/
|
|
10
|
+
export declare function call<Input extends z.ZodType, Output extends z.ZodType>(ctx: WebscraperioContext, operation: {
|
|
11
|
+
event: string;
|
|
12
|
+
input: Input;
|
|
13
|
+
output: Output;
|
|
14
|
+
}, rawInput: unknown, toRequest: (parsed: z.output<Input>) => WebscraperioRequest, options?: {
|
|
15
|
+
shape?: (raw: unknown, parsed: z.output<Input>) => unknown;
|
|
16
|
+
log?: (parsed: z.output<Input>, result: z.output<Output>) => LogFields;
|
|
17
|
+
}): Promise<z.output<Output>>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=call.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../../endpoints/call.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGrD,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;AAEvE;;;;GAIG;AACH,wBAAsB,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,OAAO,EAAE,MAAM,SAAS,CAAC,CAAC,OAAO,EAC3E,GAAG,EAAE,mBAAmB,EACxB,SAAS,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAE1D,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,mBAAmB,EAC3D,OAAO,GAAE;IAGR,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC;IAC3D,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC;CAClE,GACJ,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAc3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../endpoints/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WebscraperioEndpoints } from '..';
|
|
2
|
+
export declare const list: WebscraperioEndpoints['sitemapsList'];
|
|
3
|
+
export declare const get: WebscraperioEndpoints['sitemapsGet'];
|
|
4
|
+
/**
|
|
5
|
+
* Creates a sitemap from the definition the Web Scraper app exports. The body
|
|
6
|
+
* is passed through unchanged: its shape belongs to the builder, and the API
|
|
7
|
+
* accepts it as given.
|
|
8
|
+
*/
|
|
9
|
+
export declare const create: WebscraperioEndpoints['sitemapsCreate'];
|
|
10
|
+
/** The user behind the token and the page credits left on the account. */
|
|
11
|
+
export declare const account: WebscraperioEndpoints['accountGet'];
|
|
12
|
+
//# sourceMappingURL=sitemaps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sitemaps.d.ts","sourceRoot":"","sources":["../../endpoints/sitemaps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,IAAI,CAAC;AAQhD,eAAO,MAAM,IAAI,EAAE,qBAAqB,CAAC,cAAc,CAqBrD,CAAC;AAEH,eAAO,MAAM,GAAG,EAAE,qBAAqB,CAAC,aAAa,CAgBnD,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,MAAM,EAAE,qBAAqB,CAAC,gBAAgB,CAazD,CAAC;AAEH,0EAA0E;AAC1E,eAAO,MAAM,OAAO,EAAE,qBAAqB,CAAC,YAAY,CAgBtD,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* A sitemap, which is the Cloud product's scraping configuration. The list
|
|
4
|
+
* returns `id` and `name`; a single read adds `sitemap`, the definition itself
|
|
5
|
+
* as a JSON string (start URLs and selectors).
|
|
6
|
+
*/
|
|
7
|
+
declare const SitemapSchema: z.ZodObject<{
|
|
8
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
9
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
10
|
+
sitemap: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
11
|
+
}, z.core.$loose>;
|
|
12
|
+
export type WebscraperioSitemap = z.infer<typeof SitemapSchema>;
|
|
13
|
+
/** The Cloud API wraps its answers in `{ success, data }`. */
|
|
14
|
+
declare const SitemapResponseSchema: z.ZodObject<{
|
|
15
|
+
success: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
16
|
+
data: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
17
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
18
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
19
|
+
sitemap: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
20
|
+
}, z.core.$loose>>>;
|
|
21
|
+
}, z.core.$loose>;
|
|
22
|
+
export type SitemapResponse = z.infer<typeof SitemapResponseSchema>;
|
|
23
|
+
/**
|
|
24
|
+
* The list is paginated by a 1-based `page`; the response reports `current_page`
|
|
25
|
+
* and `last_page`, so a caller pages until it reaches `last_page`.
|
|
26
|
+
*/
|
|
27
|
+
declare const SitemapsListInputSchema: z.ZodObject<{
|
|
28
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
tag: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export type SitemapsListInput = z.infer<typeof SitemapsListInputSchema>;
|
|
32
|
+
/**
|
|
33
|
+
* A list answer: `data` is a flat array of `{ id, name }`, and the page fields
|
|
34
|
+
* sit at the root beside it.
|
|
35
|
+
*/
|
|
36
|
+
declare const SitemapsListResponseSchema: z.ZodObject<{
|
|
37
|
+
success: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
38
|
+
data: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
39
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
40
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
|
+
sitemap: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
|
+
}, z.core.$loose>>>>;
|
|
43
|
+
current_page: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
44
|
+
last_page: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
45
|
+
total: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
46
|
+
per_page: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
47
|
+
}, z.core.$loose>;
|
|
48
|
+
export type SitemapsListResponse = z.infer<typeof SitemapsListResponseSchema>;
|
|
49
|
+
declare const SitemapsGetInputSchema: z.ZodObject<{
|
|
50
|
+
id: z.ZodNumber;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export type SitemapsGetInput = z.infer<typeof SitemapsGetInputSchema>;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a sitemap from a selector configuration. `sitemap` is the JSON the
|
|
55
|
+
* Web Scraper app exports, so its shape belongs to the builder and is passed
|
|
56
|
+
* through unchanged rather than modelled here.
|
|
57
|
+
*/
|
|
58
|
+
declare const SitemapsCreateInputSchema: z.ZodObject<{
|
|
59
|
+
sitemap: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
export type SitemapsCreateInput = z.infer<typeof SitemapsCreateInputSchema>;
|
|
62
|
+
/**
|
|
63
|
+
* The user behind the token and the page credits left on the account. This is
|
|
64
|
+
* also the cheapest way to check that a token works.
|
|
65
|
+
*/
|
|
66
|
+
declare const AccountSchema: z.ZodObject<{
|
|
67
|
+
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
68
|
+
firstname: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
69
|
+
lastname: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
70
|
+
page_credits: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
71
|
+
}, z.core.$loose>;
|
|
72
|
+
export type WebscraperioAccount = z.infer<typeof AccountSchema>;
|
|
73
|
+
declare const AccountGetInputSchema: z.ZodObject<{}, z.core.$strip>;
|
|
74
|
+
export type AccountGetInput = z.infer<typeof AccountGetInputSchema>;
|
|
75
|
+
declare const AccountResponseSchema: z.ZodObject<{
|
|
76
|
+
success: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
77
|
+
data: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
78
|
+
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
79
|
+
firstname: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
80
|
+
lastname: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
81
|
+
page_credits: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
82
|
+
}, z.core.$loose>>>;
|
|
83
|
+
}, z.core.$loose>;
|
|
84
|
+
export type AccountResponse = z.infer<typeof AccountResponseSchema>;
|
|
85
|
+
export type WebscraperioEndpointInputs = {
|
|
86
|
+
sitemapsList: SitemapsListInput;
|
|
87
|
+
sitemapsGet: SitemapsGetInput;
|
|
88
|
+
sitemapsCreate: SitemapsCreateInput;
|
|
89
|
+
accountGet: AccountGetInput;
|
|
90
|
+
};
|
|
91
|
+
export type WebscraperioEndpointOutputs = {
|
|
92
|
+
sitemapsList: SitemapsListResponse;
|
|
93
|
+
sitemapsGet: SitemapResponse;
|
|
94
|
+
sitemapsCreate: SitemapResponse;
|
|
95
|
+
accountGet: AccountResponse;
|
|
96
|
+
};
|
|
97
|
+
export declare const WebscraperioEndpointInputSchemas: {
|
|
98
|
+
readonly sitemapsList: z.ZodObject<{
|
|
99
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
tag: z.ZodOptional<z.ZodString>;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
readonly sitemapsGet: z.ZodObject<{
|
|
103
|
+
id: z.ZodNumber;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
readonly sitemapsCreate: z.ZodObject<{
|
|
106
|
+
sitemap: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
readonly accountGet: z.ZodObject<{}, z.core.$strip>;
|
|
109
|
+
};
|
|
110
|
+
export declare const WebscraperioEndpointOutputSchemas: {
|
|
111
|
+
readonly sitemapsList: z.ZodObject<{
|
|
112
|
+
success: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
113
|
+
data: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
114
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
115
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
116
|
+
sitemap: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
117
|
+
}, z.core.$loose>>>>;
|
|
118
|
+
current_page: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
119
|
+
last_page: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
120
|
+
total: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
121
|
+
per_page: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
122
|
+
}, z.core.$loose>;
|
|
123
|
+
readonly sitemapsGet: z.ZodObject<{
|
|
124
|
+
success: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
125
|
+
data: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
126
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
127
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
128
|
+
sitemap: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
129
|
+
}, z.core.$loose>>>;
|
|
130
|
+
}, z.core.$loose>;
|
|
131
|
+
readonly sitemapsCreate: z.ZodObject<{
|
|
132
|
+
success: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
133
|
+
data: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
134
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
135
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
136
|
+
sitemap: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
137
|
+
}, z.core.$loose>>>;
|
|
138
|
+
}, z.core.$loose>;
|
|
139
|
+
readonly accountGet: z.ZodObject<{
|
|
140
|
+
success: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
141
|
+
data: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
142
|
+
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
143
|
+
firstname: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
144
|
+
lastname: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
145
|
+
page_credits: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
146
|
+
}, z.core.$loose>>>;
|
|
147
|
+
}, z.core.$loose>;
|
|
148
|
+
};
|
|
149
|
+
export {};
|
|
150
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../endpoints/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB;;;;GAIG;AACH,QAAA,MAAM,aAAa;;;;iBAWV,CAAC;AAEV,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEhE,8DAA8D;AAC9D,QAAA,MAAM,qBAAqB;;;;;;;iBAKlB,CAAC;AAEV,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;GAGG;AACH,QAAA,MAAM,uBAAuB;;;iBAY3B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;GAGG;AACH,QAAA,MAAM,0BAA0B;;;;;;;;;;;iBASvB,CAAC;AAEV,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,QAAA,MAAM,sBAAsB;;iBAM1B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE;;;;GAIG;AACH,QAAA,MAAM,yBAAyB;;iBAM7B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E;;;GAGG;AACH,QAAA,MAAM,aAAa;;;;;iBAQV,CAAC;AAEV,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEhE,QAAA,MAAM,qBAAqB,gCAAe,CAAC;AAE3C,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,QAAA,MAAM,qBAAqB;;;;;;;;iBAKlB,CAAC;AAEV,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAIpE,MAAM,MAAM,0BAA0B,GAAG;IACxC,YAAY,EAAE,iBAAiB,CAAC;IAChC,WAAW,EAAE,gBAAgB,CAAC;IAC9B,cAAc,EAAE,mBAAmB,CAAC;IACpC,UAAU,EAAE,eAAe,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACzC,YAAY,EAAE,oBAAoB,CAAC;IACnC,WAAW,EAAE,eAAe,CAAC;IAC7B,cAAc,EAAE,eAAe,CAAC;IAChC,UAAU,EAAE,eAAe,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;CAKnC,CAAC;AAEX,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoints.test.d.ts","sourceRoot":"","sources":["../endpoints.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { CorsairErrorHandler } from 'corsair/core';
|
|
2
|
+
/**
|
|
3
|
+
* The Cloud API has no error codes. A handled failure is
|
|
4
|
+
* `{ success: false, error }` and a bad token is a **401** carrying
|
|
5
|
+
* `"Unauthorized, invalid Bearer token."`; an unrouted path is Laravel's own
|
|
6
|
+
* 404 `{ message: "The route ... could not be found." }`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const errorHandlers: {
|
|
9
|
+
RATE_LIMIT_ERROR: {
|
|
10
|
+
match: (error: Error) => boolean;
|
|
11
|
+
handler: (error: Error) => Promise<{
|
|
12
|
+
maxRetries: number;
|
|
13
|
+
headersRetryAfterMs: number | undefined;
|
|
14
|
+
retryStrategy: "exponential_backoff";
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
AUTH_ERROR: {
|
|
18
|
+
match: (error: Error) => boolean;
|
|
19
|
+
handler: () => Promise<{
|
|
20
|
+
maxRetries: number;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
PERMISSION_ERROR: {
|
|
24
|
+
match: (error: Error) => boolean;
|
|
25
|
+
handler: () => Promise<{
|
|
26
|
+
maxRetries: number;
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
29
|
+
ROUTE_NOT_FOUND_ERROR: {
|
|
30
|
+
match: (error: Error) => boolean;
|
|
31
|
+
handler: () => Promise<{
|
|
32
|
+
maxRetries: number;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
NOT_FOUND_ERROR: {
|
|
36
|
+
match: (error: Error) => boolean;
|
|
37
|
+
handler: () => Promise<{
|
|
38
|
+
maxRetries: number;
|
|
39
|
+
}>;
|
|
40
|
+
};
|
|
41
|
+
VALIDATION_ERROR: {
|
|
42
|
+
match: (error: Error) => boolean;
|
|
43
|
+
handler: () => Promise<{
|
|
44
|
+
maxRetries: number;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
SERVER_ERROR: {
|
|
48
|
+
match: (error: Error) => boolean;
|
|
49
|
+
handler: () => Promise<{
|
|
50
|
+
maxRetries: number;
|
|
51
|
+
retryStrategy: "exponential_backoff";
|
|
52
|
+
}>;
|
|
53
|
+
};
|
|
54
|
+
DEFAULT: {
|
|
55
|
+
match: () => true;
|
|
56
|
+
handler: () => Promise<{
|
|
57
|
+
maxRetries: number;
|
|
58
|
+
}>;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export declare function mergeErrorHandlers(builtin: CorsairErrorHandler, user: CorsairErrorHandler | undefined): CorsairErrorHandler;
|
|
62
|
+
//# sourceMappingURL=error-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handlers.d.ts","sourceRoot":"","sources":["../error-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAOxD;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;uBAET,KAAK;yBAEG,KAAK;;;;;;;uBAWb,KAAK;;;;;;uBAOL,KAAK;;;;;;uBAOL,KAAK;;;;;;uBAKL,KAAK;;;;;;uBAML,KAAK;;;;;;uBAaL,KAAK;;;;;;;;;;;;CAaS,CAAC;AAIhC,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,mBAAmB,GAAG,SAAS,GACnC,mBAAmB,CAQrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handlers.test.d.ts","sourceRoot":"","sources":["../error-handlers.test.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { BindEndpoints, CorsairEndpoint, CorsairErrorHandler, CorsairPlugin, CorsairPluginContext, KeyBuilderContext, PickAuth, PluginPermissionsConfig } from 'corsair/core';
|
|
2
|
+
import type { WebscraperioEndpointInputs, WebscraperioEndpointOutputs } from './endpoints/types';
|
|
3
|
+
import { WebscraperioSchema } from './schema';
|
|
4
|
+
export type WebscraperioPluginOptions = {
|
|
5
|
+
authType?: PickAuth<'api_key'>;
|
|
6
|
+
key?: string;
|
|
7
|
+
hooks?: InternalWebscraperioPlugin['hooks'];
|
|
8
|
+
errorHandlers?: CorsairErrorHandler;
|
|
9
|
+
permissions?: PluginPermissionsConfig<typeof webscraperioEndpointsNested>;
|
|
10
|
+
};
|
|
11
|
+
export type WebscraperioContext = CorsairPluginContext<typeof WebscraperioSchema, WebscraperioPluginOptions>;
|
|
12
|
+
export type WebscraperioKeyBuilderContext = KeyBuilderContext<WebscraperioPluginOptions>;
|
|
13
|
+
export type WebscraperioBoundEndpoints = BindEndpoints<typeof webscraperioEndpointsNested>;
|
|
14
|
+
type WebscraperioEndpoint<K extends keyof WebscraperioEndpointOutputs> = CorsairEndpoint<WebscraperioContext, WebscraperioEndpointInputs[K], WebscraperioEndpointOutputs[K]>;
|
|
15
|
+
export type WebscraperioEndpoints = {
|
|
16
|
+
sitemapsList: WebscraperioEndpoint<'sitemapsList'>;
|
|
17
|
+
sitemapsGet: WebscraperioEndpoint<'sitemapsGet'>;
|
|
18
|
+
sitemapsCreate: WebscraperioEndpoint<'sitemapsCreate'>;
|
|
19
|
+
accountGet: WebscraperioEndpoint<'accountGet'>;
|
|
20
|
+
};
|
|
21
|
+
declare const webscraperioEndpointsNested: {
|
|
22
|
+
readonly sitemaps: {
|
|
23
|
+
readonly list: WebscraperioEndpoint<"sitemapsList">;
|
|
24
|
+
readonly get: WebscraperioEndpoint<"sitemapsGet">;
|
|
25
|
+
readonly create: WebscraperioEndpoint<"sitemapsCreate">;
|
|
26
|
+
};
|
|
27
|
+
readonly account: {
|
|
28
|
+
readonly get: WebscraperioEndpoint<"accountGet">;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare const webscraperioEndpointSchemas: {
|
|
32
|
+
readonly 'sitemaps.list': {
|
|
33
|
+
readonly input: import("zod").ZodObject<{
|
|
34
|
+
page: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
35
|
+
tag: import("zod").ZodOptional<import("zod").ZodString>;
|
|
36
|
+
}, import("zod/v4/core").$strip>;
|
|
37
|
+
readonly output: import("zod").ZodObject<{
|
|
38
|
+
success: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodBoolean>>;
|
|
39
|
+
data: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodArray<import("zod").ZodObject<{
|
|
40
|
+
id: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
41
|
+
name: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
42
|
+
sitemap: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
43
|
+
}, import("zod/v4/core").$loose>>>>;
|
|
44
|
+
current_page: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
45
|
+
last_page: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
46
|
+
total: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
47
|
+
per_page: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
48
|
+
}, import("zod/v4/core").$loose>;
|
|
49
|
+
};
|
|
50
|
+
readonly 'sitemaps.get': {
|
|
51
|
+
readonly input: import("zod").ZodObject<{
|
|
52
|
+
id: import("zod").ZodNumber;
|
|
53
|
+
}, import("zod/v4/core").$strip>;
|
|
54
|
+
readonly output: import("zod").ZodObject<{
|
|
55
|
+
success: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodBoolean>>;
|
|
56
|
+
data: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodObject<{
|
|
57
|
+
id: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
58
|
+
name: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
59
|
+
sitemap: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
60
|
+
}, import("zod/v4/core").$loose>>>;
|
|
61
|
+
}, import("zod/v4/core").$loose>;
|
|
62
|
+
};
|
|
63
|
+
readonly 'sitemaps.create': {
|
|
64
|
+
readonly input: import("zod").ZodObject<{
|
|
65
|
+
sitemap: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>;
|
|
66
|
+
}, import("zod/v4/core").$strip>;
|
|
67
|
+
readonly output: import("zod").ZodObject<{
|
|
68
|
+
success: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodBoolean>>;
|
|
69
|
+
data: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodObject<{
|
|
70
|
+
id: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
71
|
+
name: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
72
|
+
sitemap: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
73
|
+
}, import("zod/v4/core").$loose>>>;
|
|
74
|
+
}, import("zod/v4/core").$loose>;
|
|
75
|
+
};
|
|
76
|
+
readonly 'account.get': {
|
|
77
|
+
readonly input: import("zod").ZodObject<{}, import("zod/v4/core").$strip>;
|
|
78
|
+
readonly output: import("zod").ZodObject<{
|
|
79
|
+
success: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodBoolean>>;
|
|
80
|
+
data: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodObject<{
|
|
81
|
+
email: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
82
|
+
firstname: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
83
|
+
lastname: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
84
|
+
page_credits: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
85
|
+
}, import("zod/v4/core").$loose>>>;
|
|
86
|
+
}, import("zod/v4/core").$loose>;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
declare const defaultAuthType: "api_key";
|
|
90
|
+
export type BaseWebscraperioPlugin<T extends WebscraperioPluginOptions> = CorsairPlugin<'webscraperio', typeof WebscraperioSchema, typeof webscraperioEndpointsNested, {}, T, typeof defaultAuthType>;
|
|
91
|
+
export type InternalWebscraperioPlugin = BaseWebscraperioPlugin<WebscraperioPluginOptions>;
|
|
92
|
+
export type ExternalWebscraperioPlugin<T extends WebscraperioPluginOptions> = BaseWebscraperioPlugin<T>;
|
|
93
|
+
export declare function webscraperio<const T extends WebscraperioPluginOptions>(incomingOptions?: WebscraperioPluginOptions & T): ExternalWebscraperioPlugin<T>;
|
|
94
|
+
export { isWebscraperioFailure, segment, WEBSCRAPERIO_API_BASE, WebscraperioAPIError, } from './client';
|
|
95
|
+
export type { AccountGetInput, AccountResponse, SitemapResponse, SitemapsCreateInput, SitemapsGetInput, SitemapsListInput, SitemapsListResponse, WebscraperioAccount, WebscraperioEndpointInputs, WebscraperioEndpointOutputs, WebscraperioSitemap, } from './endpoints/types';
|
|
96
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,QAAQ,EACR,uBAAuB,EAGvB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EACX,0BAA0B,EAC1B,2BAA2B,EAC3B,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,MAAM,MAAM,yBAAyB,GAAG;IACvC,QAAQ,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,0BAA0B,CAAC,OAAO,CAAC,CAAC;IAC5C,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC,WAAW,CAAC,EAAE,uBAAuB,CAAC,OAAO,2BAA2B,CAAC,CAAC;CAC1E,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CACrD,OAAO,kBAAkB,EACzB,yBAAyB,CACzB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GACxC,iBAAiB,CAAC,yBAAyB,CAAC,CAAC;AAE9C,MAAM,MAAM,0BAA0B,GAAG,aAAa,CACrD,OAAO,2BAA2B,CAClC,CAAC;AAEF,KAAK,oBAAoB,CAAC,CAAC,SAAS,MAAM,2BAA2B,IACpE,eAAe,CACd,mBAAmB,EACnB,0BAA0B,CAAC,CAAC,CAAC,EAC7B,2BAA2B,CAAC,CAAC,CAAC,CAC9B,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG;IACnC,YAAY,EAAE,oBAAoB,CAAC,cAAc,CAAC,CAAC;IACnD,WAAW,EAAE,oBAAoB,CAAC,aAAa,CAAC,CAAC;IACjD,cAAc,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IACvD,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAC;CAC/C,CAAC;AAEF,QAAA,MAAM,2BAA2B;;;;;;;;;CASvB,CAAC;AAEX,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmBvC,CAAC;AAEF,QAAA,MAAM,eAAe,EAAG,SAAkB,CAAC;AA2B3C,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,yBAAyB,IACrE,aAAa,CACZ,cAAc,EACd,OAAO,kBAAkB,EACzB,OAAO,2BAA2B,EAClC,EAAE,EACF,CAAC,EACD,OAAO,eAAe,CACtB,CAAC;AAEH,MAAM,MAAM,0BAA0B,GACrC,sBAAsB,CAAC,yBAAyB,CAAC,CAAC;AAEnD,MAAM,MAAM,0BAA0B,CAAC,CAAC,SAAS,yBAAyB,IACzE,sBAAsB,CAAC,CAAC,CAAC,CAAC;AAE3B,wBAAgB,YAAY,CAAC,KAAK,CAAC,CAAC,SAAS,yBAAyB,EAGrE,eAAe,GAAE,yBAAyB,GACzC,CAAuC,GACtC,0BAA0B,CAAC,CAAC,CAAC,CA6B/B;AAED,OAAO,EACN,qBAAqB,EACrB,OAAO,EACP,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,UAAU,CAAC;AAElB,YAAY,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,EAC1B,2BAA2B,EAC3B,mBAAmB,GACnB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var k=Object.defineProperty;var w=(e,t)=>{for(var r in t)k(e,r,{get:t[r],enumerable:!0})};import{AuthMissingError as $}from"corsair/core";var m={};w(m,{account:()=>v,create:()=>M,get:()=>U,list:()=>D});import{asRecord as f}from"corsair/core";import{ApiError as E,request as O}from"corsair/http";var R="https://api.webscraper.io/api/v1",T={enabled:!0,maxRetries:0,initialRetryDelay:1e3,backoffMultiplier:2,headerNames:{retryAfter:"retry-after",resetTime:"x-ratelimit-reset"},isRateLimitError:e=>e===429};function b(e,t){let r=e?.[t];return typeof r=="string"&&r.length>0?r:void 0}var i=class extends Error{status;handled;retryAfter;method;body;constructor(t,r={}){super(t,r.cause?{cause:r.cause}:void 0),this.name="WebscraperioAPIError";let s=r.cause instanceof E?r.cause:void 0;this.status=r.status??s?.status,this.body=r.body??s?.body,this.retryAfter=r.retryAfter??s?.retryAfter,this.method=r.method??s?.request.method,this.handled=f(this.body)?.success===!1}get isAuthError(){return this.status===403?!0:this.isInvalidToken}get isInvalidToken(){if(this.status===401)return!0;let t=(b(f(this.body),"error")??"").toLowerCase();return t.includes("api_token")||t.includes("bearer token")}get isRouteNotFound(){return this.status!==404?!1:(b(f(this.body),"message")??"").includes("could not be found")}get isNotFound(){return this.status===404&&!this.isRouteNotFound}};function P(e,t,r,s){let o=f(t),p=b(o,"error")??b(o,"message")??r,c=s?y(p,s):p;return e?`Web Scraper Cloud ${e}: ${c}`:c}function h(e){return encodeURIComponent(String(e))}async function S(e,{method:t,path:r,query:s,body:o}){let p={BASE:R,VERSION:"1.0.0",WITH_CREDENTIALS:!1,CREDENTIALS:"omit",HEADERS:{Accept:"application/json"},TOKEN:e},c={method:t,url:r,query:s,body:o,mediaType:o===void 0?void 0:"application/json"};try{return await O(p,c,{rateLimitConfig:T})}catch(a){throw a instanceof E?new i(P(a.status,a.body,y(a.message,e),e),{status:a.status,body:L(a.body,e),retryAfter:a.retryAfter,method:t}):a instanceof Error||a instanceof DOMException?new i(a.message,{cause:a,method:t}):new i("Unknown Web Scraper Cloud error",{method:t})}}function y(e,t){return t?e.split(t).join("[redacted]"):e}function L(e,t){if(!t||typeof e!="object"||e===null)return e;let r=s=>typeof s=="string"?y(s,t):Array.isArray(s)?s.map(r):typeof s=="object"&&s!==null?Object.fromEntries(Object.entries(s).map(([o,p])=>[o,r(p)])):s;return r(e)}function _(e){return e instanceof i}import{logEventFromContext as G}from"corsair/core";async function l(e,t,r,s,o={}){let p=t.input.parse(r??{}),c=await S(e.key,s(p)),a=t.output.parse(o.shape?o.shape(c,p):c);return await G(e,`webscraperio.${t.event}`,o.log?.(p,a)??{},"completed"),a}import{z as n}from"zod";var W=n.object({id:n.number().nullish(),name:n.string().nullish(),sitemap:n.string().nullish().describe("The sitemap definition as a JSON string: `_id`, `startUrl` and `selectors`, in the form the browser extension exports.")}).loose(),x=n.object({success:n.boolean().nullish(),data:W.nullish()}).loose(),N=n.object({page:n.number().int().min(1).optional().describe("The page to return, 1-based. Defaults to 1."),tag:n.string().min(1).optional().describe("Only return sitemaps carrying this tag.")}),z=n.object({success:n.boolean().nullish(),data:n.array(W).nullish(),current_page:n.number().nullish(),last_page:n.number().nullish(),total:n.number().nullish(),per_page:n.number().nullish()}).loose(),B=n.object({id:n.number().int().positive().describe("The sitemap id, from sitemaps.list.")}),q=n.object({sitemap:n.record(n.string(),n.unknown()).describe("The sitemap definition in the form the browser extension exports: `_id`, `startUrl` (an array of URLs) and `selectors`.")}),F=n.object({email:n.string().nullish(),firstname:n.string().nullish(),lastname:n.string().nullish(),page_credits:n.number().nullish()}).loose(),H=n.object({}),j=n.object({success:n.boolean().nullish(),data:F.nullish()}).loose(),u={sitemapsList:N,sitemapsGet:B,sitemapsCreate:q,accountGet:H},d={sitemapsList:z,sitemapsGet:x,sitemapsCreate:x,accountGet:j};var D=(e,t)=>l(e,{event:"sitemaps.list",input:u.sitemapsList,output:d.sitemapsList},t,({page:r,tag:s})=>({method:"GET",path:"/sitemaps",query:{page:r,tag:s}}),{log:(r,s)=>({count:s.data?.length??0,page:s.current_page??void 0,lastPage:s.last_page??void 0})}),U=(e,t)=>l(e,{event:"sitemaps.get",input:u.sitemapsGet,output:d.sitemapsGet},t,({id:r})=>({method:"GET",path:`/sitemap/${h(r)}`}),{log:(r,s)=>({id:s.data?.id??void 0,name:s.data?.name??void 0})}),M=(e,t)=>l(e,{event:"sitemaps.create",input:u.sitemapsCreate,output:d.sitemapsCreate},t,({sitemap:r})=>({method:"POST",path:"/sitemap",body:r}),{log:(r,s)=>({id:s.data?.id??void 0})}),v=(e,t)=>l(e,{event:"account.get",input:u.accountGet,output:d.accountGet},t,()=>({method:"GET",path:"/account"}),{log:(r,s)=>({pageCredits:s.data?.page_credits??void 0})});function g(e){return e instanceof i?e.status:void 0}var I={RATE_LIMIT_ERROR:{match:e=>e instanceof i&&e.status===429,handler:async e=>({maxRetries:3,headersRetryAfterMs:e instanceof i?e.retryAfter:void 0,retryStrategy:"exponential_backoff"})},AUTH_ERROR:{match:e=>e instanceof i&&e.isInvalidToken,handler:async()=>({maxRetries:0})},PERMISSION_ERROR:{match:e=>g(e)===403,handler:async()=>({maxRetries:0})},ROUTE_NOT_FOUND_ERROR:{match:e=>e instanceof i&&e.isRouteNotFound,handler:async()=>({maxRetries:0})},NOT_FOUND_ERROR:{match:e=>e instanceof i&&e.isNotFound,handler:async()=>({maxRetries:0})},VALIDATION_ERROR:{match:e=>{let t=g(e);return e.name==="ZodError"||t===400||t===405||t===422},handler:async()=>({maxRetries:0})},SERVER_ERROR:{match:e=>e instanceof i&&e.method==="GET"&&(g(e)??0)>=500,handler:async()=>({maxRetries:2,retryStrategy:"exponential_backoff"})},DEFAULT:{match:()=>!0,handler:async()=>({maxRetries:0})}};function A(e,t){if(!t)return e;let{DEFAULT:r,...s}=e,{DEFAULT:o,...p}=t,c=o??r;return c?{...s,...p,DEFAULT:c}:{...s,...p}}var C={version:"1.0.0",entities:{}};var V={sitemaps:{list:m.list,get:m.get,create:m.create},account:{get:m.account}},Z={"sitemaps.list":{input:u.sitemapsList,output:d.sitemapsList},"sitemaps.get":{input:u.sitemapsGet,output:d.sitemapsGet},"sitemaps.create":{input:u.sitemapsCreate,output:d.sitemapsCreate},"account.get":{input:u.accountGet,output:d.accountGet}},J="api_key",K={"sitemaps.list":{riskLevel:"read",description:"List the sitemaps on the account (id and name), a page at a time, optionally filtered by tag"},"sitemaps.get":{riskLevel:"read",description:"Read one sitemap: its id, name and definition (start URLs and selectors) as a JSON string"},"sitemaps.create":{riskLevel:"write",description:"Create a sitemap from the definition the browser extension exports, selectors included"},"account.get":{riskLevel:"read",description:"Read the account user and the page credits left; the cheapest way to check a token"}};function Ee(e={}){let t={...e,authType:e.authType??J};return{id:"webscraperio",schema:C,options:t,hooks:t.hooks,endpoints:V,webhooks:{},endpointMeta:K,endpointSchemas:Z,pluginWebhookMatcher:()=>!1,errorHandlers:A(I,t.errorHandlers),keyBuilder:async(r,s)=>{if(s==="endpoint"&&t.key)return t.key;if(s==="endpoint"&&r.authType==="api_key"){let o=await r.keys.get_api_key();if(o)return o}throw new $("webscraperio",r.authType??"api_key")}}}export{R as WEBSCRAPERIO_API_BASE,i as WebscraperioAPIError,_ as isWebscraperioFailure,h as segment,Ee as webscraperio,Z as webscraperioEndpointSchemas};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.test.d.ts","sourceRoot":"","sources":["../plugin.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../schema/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB;;;CAGrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.test.d.ts","sourceRoot":"","sources":["../schema.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** One sitemap as `GET /sitemap/{id}` returns it: the definition is a string. */
|
|
2
|
+
export declare const sitemap: {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
sitemap: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const sitemapResponse: {
|
|
8
|
+
success: boolean;
|
|
9
|
+
data: {
|
|
10
|
+
id: number;
|
|
11
|
+
name: string;
|
|
12
|
+
sitemap: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
/** `POST /sitemap` answers with the new id only. */
|
|
16
|
+
export declare const sitemapCreatedResponse: {
|
|
17
|
+
success: boolean;
|
|
18
|
+
data: {
|
|
19
|
+
id: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/** A list answer: `{ id, name }` items, with the page fields at the root. */
|
|
23
|
+
export declare const sitemapsListResponse: {
|
|
24
|
+
success: boolean;
|
|
25
|
+
data: {
|
|
26
|
+
id: number;
|
|
27
|
+
name: string;
|
|
28
|
+
}[];
|
|
29
|
+
current_page: number;
|
|
30
|
+
last_page: number;
|
|
31
|
+
total: number;
|
|
32
|
+
per_page: number;
|
|
33
|
+
};
|
|
34
|
+
export declare const account: {
|
|
35
|
+
email: string;
|
|
36
|
+
firstname: string;
|
|
37
|
+
lastname: string;
|
|
38
|
+
page_credits: number;
|
|
39
|
+
};
|
|
40
|
+
export declare const accountResponse: {
|
|
41
|
+
success: boolean;
|
|
42
|
+
data: {
|
|
43
|
+
email: string;
|
|
44
|
+
firstname: string;
|
|
45
|
+
lastname: string;
|
|
46
|
+
page_credits: number;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
/** A bad token: the handled shape, with a 401 (as the live API answers). */
|
|
50
|
+
export declare const invalidToken: {
|
|
51
|
+
success: boolean;
|
|
52
|
+
error: string;
|
|
53
|
+
};
|
|
54
|
+
/** A mistyped path: Laravel's own answer, which is not a missing sitemap. */
|
|
55
|
+
export declare const routeNotFound: {
|
|
56
|
+
message: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* What the live API answers for a sitemap id that is missing or belongs to
|
|
60
|
+
* another account: a 403, not a 404 (captured 11-12).
|
|
61
|
+
*/
|
|
62
|
+
export declare const sitemapForbidden: {
|
|
63
|
+
success: boolean;
|
|
64
|
+
error: string;
|
|
65
|
+
};
|
|
66
|
+
/** A 404 that is not a routing error, kept for the NOT_FOUND handler. */
|
|
67
|
+
export declare const sitemapNotFound: {
|
|
68
|
+
success: boolean;
|
|
69
|
+
error: string;
|
|
70
|
+
};
|
|
71
|
+
export declare const badRequest: {
|
|
72
|
+
success: boolean;
|
|
73
|
+
error: string;
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=test-fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-fixtures.d.ts","sourceRoot":"","sources":["../test-fixtures.ts"],"names":[],"mappings":"AAiBA,iFAAiF;AACjF,eAAO,MAAM,OAAO;;;;CAInB,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;CAAmC,CAAC;AAEhE,oDAAoD;AACpD,eAAO,MAAM,sBAAsB;;;;;CAAsC,CAAC;AAE1E,6EAA6E;AAC7E,eAAO,MAAM,oBAAoB;;;;;;;;;;CAOhC,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;CAKnB,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;CAAmC,CAAC;AAEhE,4EAA4E;AAC5E,eAAO,MAAM,YAAY;;;CAGxB,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,aAAa;;CAEzB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;CAAyC,CAAC;AAEvE,yEAAyE;AACzE,eAAO,MAAM,eAAe;;;CAG3B,CAAC;AAEF,eAAO,MAAM,UAAU;;;CAGtB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WebscraperioAPIError } from './client';
|
|
2
|
+
export declare const API_KEY = "ws-test-token";
|
|
3
|
+
/**
|
|
4
|
+
* A fake context carrying only what the endpoints read. It is cast to never
|
|
5
|
+
* because it is not a full WebscraperioContext, and every endpoint accepts it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const testContext: never;
|
|
8
|
+
export declare function invoke<Output>(endpoint: (ctx: never, input: never) => Promise<Output>, input: unknown): Promise<Output>;
|
|
9
|
+
/**
|
|
10
|
+
* Awaits a call that must fail with a WebscraperioAPIError and returns the
|
|
11
|
+
* error. The instanceof check replaces a cast, and a call that succeeds or
|
|
12
|
+
* throws anything else fails the test.
|
|
13
|
+
*/
|
|
14
|
+
export declare function rejection(promise: Promise<unknown>): Promise<WebscraperioAPIError>;
|
|
15
|
+
export declare function installFetchMock(): jest.SpyInstance<Promise<Response>, [input: string | URL | Request, init?: RequestInit | undefined], any>;
|
|
16
|
+
export declare function respond(fetchMock: jest.SpyInstance, body: unknown, status?: number): void;
|
|
17
|
+
export type RecordedRequest = {
|
|
18
|
+
origin: string;
|
|
19
|
+
path: string;
|
|
20
|
+
query: Record<string, string>;
|
|
21
|
+
queryPairs: [string, string][];
|
|
22
|
+
method: string | undefined;
|
|
23
|
+
/** Header names are lowercased by the Headers class. */
|
|
24
|
+
headers: Record<string, string>;
|
|
25
|
+
body: unknown;
|
|
26
|
+
};
|
|
27
|
+
export declare function lastRequest(fetchMock: jest.SpyInstance): RecordedRequest;
|
|
28
|
+
/** The token travels as a Bearer header, never on the query string. */
|
|
29
|
+
export declare function expectAuthenticated(fetchMock: jest.SpyInstance): void;
|
|
30
|
+
//# sourceMappingURL=test-support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-support.d.ts","sourceRoot":"","sources":["../test-support.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,eAAO,MAAM,OAAO,kBAAkB,CAAC;AAEvC;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAuB,KAAK,CAAC;AAMrD,wBAAsB,MAAM,CAAC,MAAM,EAClC,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,MAAM,CAAC,EACvD,KAAK,EAAE,OAAO,GACZ,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAE9B,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAU/B;AAQD,wBAAgB,gBAAgB,8GAS/B;AAGD,wBAAgB,OAAO,CACtB,SAAS,EAAE,IAAI,CAAC,WAAW,EAC3B,IAAI,EAAE,OAAO,EACb,MAAM,SAAM,QAQZ;AAED,MAAM,MAAM,eAAe,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC,IAAI,EAAE,OAAO,CAAC;CACd,CAAC;AAEF,wBAAgB,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,GAAG,eAAe,CAiBxE;AAED,uEAAuE;AACvE,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,QAM9D"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const _default: import("tsup").Options | import("tsup").Options[] | ((overrideOptions: import("tsup").Options) => import("tsup").Options | import("tsup").Options[] | Promise<import("tsup").Options | import("tsup").Options[]>);
|
|
2
|
+
export default _default;
|
|
3
|
+
//# sourceMappingURL=tsup.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsup.config.d.ts","sourceRoot":"","sources":["../tsup.config.ts"],"names":[],"mappings":";AAEA,wBAYG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corsair-dev/webscraperio",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Web Scraper Cloud plugin for Corsair - list and read sitemaps with their selectors and start URLs, create a sitemap from an exported definition, and read the account's page credits",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"dev-source": "./index.ts",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"corsair": ">=0.1.0",
|
|
18
|
+
"zod": "^4.1.13"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/jest": "^29.5.14",
|
|
22
|
+
"jest": "^29.7.0",
|
|
23
|
+
"ts-jest": "^29.4.9",
|
|
24
|
+
"tsup": "^8.0.1",
|
|
25
|
+
"typescript": "^5.9.3",
|
|
26
|
+
"zod": "^4.1.13",
|
|
27
|
+
"corsair": "0.1.178"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"corsair",
|
|
31
|
+
"webscraperio",
|
|
32
|
+
"web-scraping",
|
|
33
|
+
"cloud-scraper",
|
|
34
|
+
"sitemap",
|
|
35
|
+
"plugin"
|
|
36
|
+
],
|
|
37
|
+
"author": "Corsair (https://corsair.dev)",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/corsairdev/corsair.git",
|
|
41
|
+
"directory": "packages/webscraperio"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://docs.corsair.dev/plugins/webscraperio",
|
|
44
|
+
"license": "Apache-2.0",
|
|
45
|
+
"files": [
|
|
46
|
+
"dist"
|
|
47
|
+
],
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "rm -rf dist && tsc --build --force && tsup",
|
|
50
|
+
"typecheck": "tsc --noEmit",
|
|
51
|
+
"test": "jest",
|
|
52
|
+
"test:live": "jest --testPathIgnorePatterns=/node_modules/ --testPathPattern=api\\.test\\.ts"
|
|
53
|
+
}
|
|
6
54
|
}
|