@tabstack/sdk 1.0.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 +190 -0
- package/README.md +485 -0
- package/dist/cjs/automate.d.ts +156 -0
- package/dist/cjs/automate.d.ts.map +1 -0
- package/dist/cjs/automate.js +211 -0
- package/dist/cjs/automate.js.map +1 -0
- package/dist/cjs/automate.test.d.ts +5 -0
- package/dist/cjs/automate.test.d.ts.map +1 -0
- package/dist/cjs/automate.test.js +441 -0
- package/dist/cjs/automate.test.js.map +1 -0
- package/dist/cjs/client.d.ts +58 -0
- package/dist/cjs/client.d.ts.map +1 -0
- package/dist/cjs/client.js +58 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/client.test.d.ts +5 -0
- package/dist/cjs/client.test.d.ts.map +1 -0
- package/dist/cjs/client.test.js +256 -0
- package/dist/cjs/client.test.js.map +1 -0
- package/dist/cjs/exceptions.d.ts +57 -0
- package/dist/cjs/exceptions.d.ts.map +1 -0
- package/dist/cjs/exceptions.js +95 -0
- package/dist/cjs/exceptions.js.map +1 -0
- package/dist/cjs/exceptions.test.d.ts +5 -0
- package/dist/cjs/exceptions.test.d.ts.map +1 -0
- package/dist/cjs/exceptions.test.js +239 -0
- package/dist/cjs/exceptions.test.js.map +1 -0
- package/dist/cjs/extract.d.ts +206 -0
- package/dist/cjs/extract.d.ts.map +1 -0
- package/dist/cjs/extract.js +223 -0
- package/dist/cjs/extract.js.map +1 -0
- package/dist/cjs/extract.test.d.ts +5 -0
- package/dist/cjs/extract.test.d.ts.map +1 -0
- package/dist/cjs/extract.test.js +364 -0
- package/dist/cjs/extract.test.js.map +1 -0
- package/dist/cjs/generate.d.ts +113 -0
- package/dist/cjs/generate.d.ts.map +1 -0
- package/dist/cjs/generate.js +124 -0
- package/dist/cjs/generate.js.map +1 -0
- package/dist/cjs/generate.test.d.ts +5 -0
- package/dist/cjs/generate.test.d.ts.map +1 -0
- package/dist/cjs/generate.test.js +314 -0
- package/dist/cjs/generate.test.js.map +1 -0
- package/dist/cjs/index.d.ts +52 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +72 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/types.d.ts +73 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +118 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/types.test.d.ts +5 -0
- package/dist/cjs/types.test.d.ts.map +1 -0
- package/dist/cjs/types.test.js +370 -0
- package/dist/cjs/types.test.js.map +1 -0
- package/dist/cjs/util/http.d.ts +29 -0
- package/dist/cjs/util/http.d.ts.map +1 -0
- package/dist/cjs/util/http.js +201 -0
- package/dist/cjs/util/http.js.map +1 -0
- package/dist/cjs/util/http.test.d.ts +5 -0
- package/dist/cjs/util/http.test.d.ts.map +1 -0
- package/dist/cjs/util/http.test.js +237 -0
- package/dist/cjs/util/http.test.js.map +1 -0
- package/dist/esm/automate.d.ts +156 -0
- package/dist/esm/automate.d.ts.map +1 -0
- package/dist/esm/automate.js +207 -0
- package/dist/esm/automate.js.map +1 -0
- package/dist/esm/automate.test.d.ts +5 -0
- package/dist/esm/automate.test.d.ts.map +1 -0
- package/dist/esm/automate.test.js +439 -0
- package/dist/esm/automate.test.js.map +1 -0
- package/dist/esm/client.d.ts +58 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +54 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/client.test.d.ts +5 -0
- package/dist/esm/client.test.d.ts.map +1 -0
- package/dist/esm/client.test.js +254 -0
- package/dist/esm/client.test.js.map +1 -0
- package/dist/esm/exceptions.d.ts +57 -0
- package/dist/esm/exceptions.d.ts.map +1 -0
- package/dist/esm/exceptions.js +85 -0
- package/dist/esm/exceptions.js.map +1 -0
- package/dist/esm/exceptions.test.d.ts +5 -0
- package/dist/esm/exceptions.test.d.ts.map +1 -0
- package/dist/esm/exceptions.test.js +237 -0
- package/dist/esm/exceptions.test.js.map +1 -0
- package/dist/esm/extract.d.ts +206 -0
- package/dist/esm/extract.d.ts.map +1 -0
- package/dist/esm/extract.js +219 -0
- package/dist/esm/extract.js.map +1 -0
- package/dist/esm/extract.test.d.ts +5 -0
- package/dist/esm/extract.test.d.ts.map +1 -0
- package/dist/esm/extract.test.js +362 -0
- package/dist/esm/extract.test.js.map +1 -0
- package/dist/esm/generate.d.ts +113 -0
- package/dist/esm/generate.d.ts.map +1 -0
- package/dist/esm/generate.js +120 -0
- package/dist/esm/generate.js.map +1 -0
- package/dist/esm/generate.test.d.ts +5 -0
- package/dist/esm/generate.test.d.ts.map +1 -0
- package/dist/esm/generate.test.js +312 -0
- package/dist/esm/generate.test.js.map +1 -0
- package/dist/esm/index.d.ts +52 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +53 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/types.d.ts +73 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +110 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/types.test.d.ts +5 -0
- package/dist/esm/types.test.d.ts.map +1 -0
- package/dist/esm/types.test.js +368 -0
- package/dist/esm/types.test.js.map +1 -0
- package/dist/esm/util/http.d.ts +29 -0
- package/dist/esm/util/http.d.ts.map +1 -0
- package/dist/esm/util/http.js +164 -0
- package/dist/esm/util/http.js.map +1 -0
- package/dist/esm/util/http.test.d.ts +5 -0
- package/dist/esm/util/http.test.d.ts.map +1 -0
- package/dist/esm/util/http.test.js +232 -0
- package/dist/esm/util/http.test.js.map +1 -0
- package/dist/types/automate.d.ts +156 -0
- package/dist/types/automate.d.ts.map +1 -0
- package/dist/types/automate.test.d.ts +5 -0
- package/dist/types/automate.test.d.ts.map +1 -0
- package/dist/types/client.d.ts +58 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/client.test.d.ts +5 -0
- package/dist/types/client.test.d.ts.map +1 -0
- package/dist/types/exceptions.d.ts +57 -0
- package/dist/types/exceptions.d.ts.map +1 -0
- package/dist/types/exceptions.test.d.ts +5 -0
- package/dist/types/exceptions.test.d.ts.map +1 -0
- package/dist/types/extract.d.ts +206 -0
- package/dist/types/extract.d.ts.map +1 -0
- package/dist/types/extract.test.d.ts +5 -0
- package/dist/types/extract.test.d.ts.map +1 -0
- package/dist/types/generate.d.ts +113 -0
- package/dist/types/generate.d.ts.map +1 -0
- package/dist/types/generate.test.d.ts +5 -0
- package/dist/types/generate.test.d.ts.map +1 -0
- package/dist/types/index.d.ts +52 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +73 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.test.d.ts +5 -0
- package/dist/types/types.test.d.ts.map +1 -0
- package/dist/types/util/http.d.ts +29 -0
- package/dist/types/util/http.d.ts.map +1 -0
- package/dist/types/util/http.test.d.ts +5 -0
- package/dist/types/util/http.test.d.ts.map +1 -0
- package/package.json +90 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
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
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a fee
|
|
167
|
+
for, acceptance of support, warranty, indemnity, or other liability
|
|
168
|
+
obligations and/or rights consistent with this License. However, in
|
|
169
|
+
accepting such obligations, You may act only on Your own behalf and
|
|
170
|
+
on Your sole responsibility, not on behalf of any other Contributor,
|
|
171
|
+
and only if You agree to indemnify, defend, and hold each Contributor
|
|
172
|
+
harmless for any liability incurred by, or claims asserted against,
|
|
173
|
+
such Contributor by reason of your accepting any such warranty or
|
|
174
|
+
additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 TABStack
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
# TABStack AI TypeScript SDK
|
|
2
|
+
|
|
3
|
+
TypeScript/JavaScript SDK for [TABStack AI](https://tabstack.ai) - Extract, Generate, and Automate web content with AI.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Extract**: Convert web pages to Markdown, generate schemas, and extract structured JSON data
|
|
8
|
+
- **Generate**: Transform web content using AI with custom instructions
|
|
9
|
+
- **Automate**: Execute complex browser automation tasks with natural language
|
|
10
|
+
- **Type-Safe**: Full TypeScript support with comprehensive type definitions
|
|
11
|
+
- **Zero Dependencies**: Uses only Node.js standard library
|
|
12
|
+
- **Universal Module Support**: Works with CommonJS, ESM, and all TypeScript configurations
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
Install the SDK using your preferred package manager:
|
|
17
|
+
|
|
18
|
+
### npm
|
|
19
|
+
```bash
|
|
20
|
+
npm install @tabstack/sdk
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Yarn
|
|
24
|
+
```bash
|
|
25
|
+
yarn add @tabstack/sdk
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### pnpm
|
|
29
|
+
```bash
|
|
30
|
+
pnpm add @tabstack/sdk
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Bun
|
|
34
|
+
```bash
|
|
35
|
+
bun add @tabstack/sdk
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### From Source
|
|
39
|
+
|
|
40
|
+
Clone and build the SDK locally:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
git clone https://github.com/tabstack/tabs-typescript.git
|
|
44
|
+
cd tabs-typescript
|
|
45
|
+
npm install
|
|
46
|
+
npm run build
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
To use the local build in your project:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Link the package globally
|
|
53
|
+
npm link
|
|
54
|
+
|
|
55
|
+
# In your project directory
|
|
56
|
+
npm link @tabstack/sdk
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Or install directly from the local path:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm install /path/to/tabs-typescript
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Quick Start
|
|
66
|
+
|
|
67
|
+
### Get Your API Key
|
|
68
|
+
|
|
69
|
+
Sign up at [tabstack.ai](https://tabstack.ai) to get your API key.
|
|
70
|
+
|
|
71
|
+
### Basic Usage
|
|
72
|
+
|
|
73
|
+
#### ES Modules (ESM)
|
|
74
|
+
```typescript
|
|
75
|
+
import { TABStack } from '@tabstack/sdk';
|
|
76
|
+
|
|
77
|
+
const tabs = new TABStack({
|
|
78
|
+
apiKey: process.env.TABSTACK_API_KEY!
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Extract markdown from a URL
|
|
82
|
+
const markdown = await tabs.extract.markdown('https://example.com');
|
|
83
|
+
console.log(markdown.content);
|
|
84
|
+
|
|
85
|
+
// Extract structured data with JSON schema
|
|
86
|
+
const schema = {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
stories: {
|
|
90
|
+
type: 'array',
|
|
91
|
+
items: {
|
|
92
|
+
type: 'object',
|
|
93
|
+
properties: {
|
|
94
|
+
title: { type: 'string' },
|
|
95
|
+
points: { type: 'number' },
|
|
96
|
+
author: { type: 'string' }
|
|
97
|
+
},
|
|
98
|
+
required: ['title', 'points', 'author']
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
required: ['stories']
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const data = await tabs.extract.json('https://news.ycombinator.com', schema);
|
|
106
|
+
console.log(data.data);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### CommonJS
|
|
110
|
+
```javascript
|
|
111
|
+
const { TABStack } = require('@tabstack/sdk');
|
|
112
|
+
|
|
113
|
+
const tabs = new TABStack({
|
|
114
|
+
apiKey: process.env.TABSTACK_API_KEY
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Extract markdown
|
|
118
|
+
tabs.extract.markdown('https://example.com')
|
|
119
|
+
.then(result => {
|
|
120
|
+
console.log(result.content);
|
|
121
|
+
})
|
|
122
|
+
.catch(error => {
|
|
123
|
+
console.error('Error:', error.message);
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Core Features
|
|
128
|
+
|
|
129
|
+
### Extract Markdown
|
|
130
|
+
|
|
131
|
+
Convert web pages to clean Markdown format:
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
const result = await tabs.extract.markdown('https://example.com/blog/article', {
|
|
135
|
+
metadata: true, // optional: include page metadata
|
|
136
|
+
nocache: false // optional: bypass cache
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
console.log(result.content);
|
|
140
|
+
console.log(result.metadata); // if metadata: true
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Extract Structured Data
|
|
144
|
+
|
|
145
|
+
Extract data matching a JSON schema:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
const schema = {
|
|
149
|
+
type: 'object',
|
|
150
|
+
properties: {
|
|
151
|
+
products: {
|
|
152
|
+
type: 'array',
|
|
153
|
+
items: {
|
|
154
|
+
type: 'object',
|
|
155
|
+
properties: {
|
|
156
|
+
name: { type: 'string' },
|
|
157
|
+
price: { type: 'number' },
|
|
158
|
+
inStock: { type: 'boolean' }
|
|
159
|
+
},
|
|
160
|
+
required: ['name', 'price', 'inStock']
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
required: ['products']
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const result = await tabs.extract.json('https://example.com/products', schema);
|
|
168
|
+
console.log(result.data);
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Generate Schema
|
|
172
|
+
|
|
173
|
+
Generate a JSON schema from web content:
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
const schema = await tabs.extract.schema('https://news.ycombinator.com', {
|
|
177
|
+
instructions: 'extract top stories with title, points, and author'
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Use the generated schema for extraction
|
|
181
|
+
const result = await tabs.extract.json('https://news.ycombinator.com', schema);
|
|
182
|
+
console.log(result.data);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Generate Content
|
|
186
|
+
|
|
187
|
+
Transform web content using AI:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
const schema = {
|
|
191
|
+
type: 'object',
|
|
192
|
+
properties: {
|
|
193
|
+
summaries: {
|
|
194
|
+
type: 'array',
|
|
195
|
+
items: {
|
|
196
|
+
type: 'object',
|
|
197
|
+
properties: {
|
|
198
|
+
title: { type: 'string' },
|
|
199
|
+
category: { type: 'string' },
|
|
200
|
+
summary: { type: 'string' }
|
|
201
|
+
},
|
|
202
|
+
required: ['title', 'category', 'summary']
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
required: ['summaries']
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const result = await tabs.generate.json(
|
|
210
|
+
'https://news.ycombinator.com',
|
|
211
|
+
schema,
|
|
212
|
+
'Categorize each story and write a one-sentence summary'
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
console.log(result.data);
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Automate Tasks
|
|
219
|
+
|
|
220
|
+
Execute browser automation tasks with streaming updates:
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
for await (const event of tabs.automate.execute(
|
|
224
|
+
'Find the top 3 trending repositories and extract their details',
|
|
225
|
+
{
|
|
226
|
+
url: 'https://github.com/trending',
|
|
227
|
+
guardrails: 'browse and extract only',
|
|
228
|
+
maxIterations: 50
|
|
229
|
+
}
|
|
230
|
+
)) {
|
|
231
|
+
console.log(`Event: ${event.type}`);
|
|
232
|
+
|
|
233
|
+
if (event.type === 'task:completed') {
|
|
234
|
+
console.log('Result:', event.data.get('finalAnswer'));
|
|
235
|
+
} else if (event.type === 'agent:extracted') {
|
|
236
|
+
console.log('Extracted:', event.data.get('extractedData'));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Working with JSON Schemas
|
|
242
|
+
|
|
243
|
+
The SDK uses standard [JSON Schema](https://json-schema.org/) format for defining data structures. You can define schemas manually or generate them automatically:
|
|
244
|
+
|
|
245
|
+
### Manual Schema Definition
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
const schema = {
|
|
249
|
+
type: 'object',
|
|
250
|
+
properties: {
|
|
251
|
+
name: { type: 'string', description: 'Person name' },
|
|
252
|
+
age: { type: 'number', description: 'Person age' },
|
|
253
|
+
isActive: { type: 'boolean', description: 'Active status' },
|
|
254
|
+
tags: {
|
|
255
|
+
type: 'array',
|
|
256
|
+
items: { type: 'string' }
|
|
257
|
+
},
|
|
258
|
+
addresses: {
|
|
259
|
+
type: 'array',
|
|
260
|
+
items: {
|
|
261
|
+
type: 'object',
|
|
262
|
+
properties: {
|
|
263
|
+
street: { type: 'string' },
|
|
264
|
+
city: { type: 'string' },
|
|
265
|
+
zipCode: { type: 'number' }
|
|
266
|
+
},
|
|
267
|
+
required: ['street', 'city', 'zipCode']
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
metadata: {
|
|
271
|
+
type: 'object',
|
|
272
|
+
properties: {
|
|
273
|
+
createdAt: { type: 'string' },
|
|
274
|
+
updatedAt: { type: 'string' }
|
|
275
|
+
},
|
|
276
|
+
required: ['createdAt', 'updatedAt']
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
required: ['name', 'age']
|
|
280
|
+
};
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Automatic Schema Generation
|
|
284
|
+
|
|
285
|
+
Let the AI generate a schema from any webpage:
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
// Generate schema from content
|
|
289
|
+
const schema = await tabs.extract.schema('https://news.ycombinator.com', {
|
|
290
|
+
instructions: 'extract stories with title, points, and author'
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// Use it immediately
|
|
294
|
+
const data = await tabs.extract.json('https://news.ycombinator.com', schema);
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Error Handling
|
|
298
|
+
|
|
299
|
+
Handle errors with specific error classes:
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
import {
|
|
303
|
+
TABStackError,
|
|
304
|
+
UnauthorizedError,
|
|
305
|
+
InvalidURLError,
|
|
306
|
+
BadRequestError,
|
|
307
|
+
ServerError
|
|
308
|
+
} from '@tabstack/sdk';
|
|
309
|
+
|
|
310
|
+
try {
|
|
311
|
+
const result = await tabs.extract.markdown('https://example.com');
|
|
312
|
+
} catch (error) {
|
|
313
|
+
if (error instanceof UnauthorizedError) {
|
|
314
|
+
console.error('Invalid API key');
|
|
315
|
+
} else if (error instanceof InvalidURLError) {
|
|
316
|
+
console.error('Invalid or inaccessible URL');
|
|
317
|
+
} else if (error instanceof TABStackError) {
|
|
318
|
+
console.error(`API error: ${error.message}`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Error Classes
|
|
324
|
+
|
|
325
|
+
- `TABStackError` - Base error class
|
|
326
|
+
- `BadRequestError` - 400: Malformed request
|
|
327
|
+
- `UnauthorizedError` - 401: Invalid API key
|
|
328
|
+
- `InvalidURLError` - 422: Invalid or inaccessible URL
|
|
329
|
+
- `ServerError` - 500: Internal server error
|
|
330
|
+
- `ServiceUnavailableError` - 503: Service unavailable
|
|
331
|
+
- `APIError` - Generic API error with status code
|
|
332
|
+
|
|
333
|
+
## Requirements
|
|
334
|
+
|
|
335
|
+
- Node.js >= 20.0.0
|
|
336
|
+
- TABStack API key ([get one here](https://tabstack.ai))
|
|
337
|
+
|
|
338
|
+
## Development & Testing
|
|
339
|
+
|
|
340
|
+
This SDK includes a comprehensive testing suite with excellent code coverage and type safety.
|
|
341
|
+
|
|
342
|
+
### Running Tests
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
# Run all tests
|
|
346
|
+
npm test
|
|
347
|
+
|
|
348
|
+
# Run unit tests only
|
|
349
|
+
npm run test:unit
|
|
350
|
+
|
|
351
|
+
# Run E2E tests only
|
|
352
|
+
npm run test:e2e
|
|
353
|
+
|
|
354
|
+
# Run tests in watch mode
|
|
355
|
+
npm run test:watch
|
|
356
|
+
|
|
357
|
+
# Run tests with coverage report
|
|
358
|
+
npm run test:coverage
|
|
359
|
+
|
|
360
|
+
# Run TypeScript type tests
|
|
361
|
+
npm run test:types
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Test Structure
|
|
365
|
+
|
|
366
|
+
The SDK includes multiple types of tests:
|
|
367
|
+
|
|
368
|
+
**Unit Tests** (`src/**/*.test.ts`)
|
|
369
|
+
- HTTPClient tests - HTTP request/response handling, error scenarios
|
|
370
|
+
- Exception classes tests - Error creation and inheritance
|
|
371
|
+
- Type classes tests - Serialization, deserialization, data access
|
|
372
|
+
- Extract operator tests - Markdown, schema, and JSON extraction
|
|
373
|
+
- Generate operator tests - AI-powered content generation
|
|
374
|
+
- Automate operator tests - SSE streaming and event parsing
|
|
375
|
+
- Client tests - Main client initialization and configuration
|
|
376
|
+
|
|
377
|
+
**E2E Tests** (`test/e2e/`)
|
|
378
|
+
- Complete workflows from client to operators
|
|
379
|
+
- Real-world use case scenarios
|
|
380
|
+
- Error handling and edge cases
|
|
381
|
+
- Multi-operation workflows
|
|
382
|
+
|
|
383
|
+
**Type Tests** (`test/types/`)
|
|
384
|
+
- TypeScript type safety validation using `tsd`
|
|
385
|
+
- Generic type inference
|
|
386
|
+
- Type guard verification
|
|
387
|
+
- Compile-time type checking
|
|
388
|
+
|
|
389
|
+
### Test Coverage
|
|
390
|
+
|
|
391
|
+
The SDK maintains high test coverage across all modules:
|
|
392
|
+
|
|
393
|
+
- **172+ test cases** covering all major functionality
|
|
394
|
+
- **~70%+ code coverage** across branches, functions, lines, and statements
|
|
395
|
+
- **Mocked HTTP requests** using `nock` for fast, reliable tests
|
|
396
|
+
- **Type-safe tests** with full TypeScript support
|
|
397
|
+
|
|
398
|
+
### Test Technologies
|
|
399
|
+
|
|
400
|
+
- **Jest** - Test runner and assertion library
|
|
401
|
+
- **ts-jest** - TypeScript support for Jest
|
|
402
|
+
- **nock** - HTTP request mocking
|
|
403
|
+
- **tsd** - TypeScript type definition testing
|
|
404
|
+
|
|
405
|
+
### Writing Tests
|
|
406
|
+
|
|
407
|
+
When contributing to the SDK, please:
|
|
408
|
+
|
|
409
|
+
1. Write tests for all new features and bug fixes
|
|
410
|
+
2. Maintain or improve code coverage
|
|
411
|
+
3. Use descriptive test names that explain the behavior being tested
|
|
412
|
+
4. Mock external HTTP requests using `nock`
|
|
413
|
+
5. Test both success and error scenarios
|
|
414
|
+
6. Add type tests for new public APIs
|
|
415
|
+
|
|
416
|
+
Example test structure:
|
|
417
|
+
|
|
418
|
+
```typescript
|
|
419
|
+
describe('Feature', () => {
|
|
420
|
+
describe('method', () => {
|
|
421
|
+
it('should handle success case', async () => {
|
|
422
|
+
// Arrange
|
|
423
|
+
const mockData = { result: 'success' };
|
|
424
|
+
nock('https://api.tabstack.ai')
|
|
425
|
+
.post('/endpoint')
|
|
426
|
+
.reply(200, mockData);
|
|
427
|
+
|
|
428
|
+
// Act
|
|
429
|
+
const result = await client.feature.method();
|
|
430
|
+
|
|
431
|
+
// Assert
|
|
432
|
+
expect(result).toEqual(mockData);
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it('should handle error case', async () => {
|
|
436
|
+
nock('https://api.tabstack.ai')
|
|
437
|
+
.post('/endpoint')
|
|
438
|
+
.reply(400, { error: 'Bad request' });
|
|
439
|
+
|
|
440
|
+
await expect(client.feature.method()).rejects.toThrow(BadRequestError);
|
|
441
|
+
});
|
|
442
|
+
});
|
|
443
|
+
});
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
## Contributing
|
|
447
|
+
|
|
448
|
+
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
449
|
+
|
|
450
|
+
### Quick Start for Contributors
|
|
451
|
+
|
|
452
|
+
```bash
|
|
453
|
+
# Fork and clone the repository
|
|
454
|
+
git clone https://github.com/YOUR_USERNAME/tabs-typescript.git
|
|
455
|
+
cd tabs-typescript
|
|
456
|
+
|
|
457
|
+
# Install dependencies
|
|
458
|
+
npm install
|
|
459
|
+
|
|
460
|
+
# Run checks locally before submitting PR
|
|
461
|
+
npm run lint # Check for linting errors
|
|
462
|
+
npm run format:check # Check formatting
|
|
463
|
+
npm test # Run all tests
|
|
464
|
+
npm run build # Verify builds work
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### Pull Request Requirements
|
|
468
|
+
|
|
469
|
+
All PRs must pass these checks before merging:
|
|
470
|
+
|
|
471
|
+
- ✅ **Lint** - Code style and formatting (ESLint + Prettier)
|
|
472
|
+
- ✅ **Node 20, 22, 24** - Tests and builds on all supported Node versions
|
|
473
|
+
- ✅ **Code Review** - Approval from maintainers
|
|
474
|
+
|
|
475
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
|
|
476
|
+
|
|
477
|
+
## License
|
|
478
|
+
|
|
479
|
+
Apache
|
|
480
|
+
|
|
481
|
+
## Support
|
|
482
|
+
|
|
483
|
+
- Documentation: [https://docs.tabstack.ai](https://docs.tabstack.ai)
|
|
484
|
+
- GitHub Issues: [https://github.com/tabstack/tabs-typescript/issues](https://github.com/tabstack/tabs-typescript/issues)
|
|
485
|
+
- Website: [https://tabstack.ai](https://tabstack.ai)
|