pulse-ts-sdk 0.0.51

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.
Files changed (3) hide show
  1. package/README.md +270 -0
  2. package/package.json +69 -0
  3. package/reference.md +323 -0
package/README.md ADDED
@@ -0,0 +1,270 @@
1
+ # Pulse TypeScript Library
2
+
3
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FPulse-Software-Corp%2Fpulse-ts-sdk)
4
+ [![npm shield](https://img.shields.io/npm/v/pulse-ts-sdk)](https://www.npmjs.com/package/pulse-ts-sdk)
5
+
6
+ The Pulse TypeScript library provides convenient access to the Pulse APIs from TypeScript.
7
+
8
+ ## Table of Contents
9
+
10
+ - [Installation](#installation)
11
+ - [Reference](#reference)
12
+ - [Usage](#usage)
13
+ - [Request and Response Types](#request-and-response-types)
14
+ - [Exception Handling](#exception-handling)
15
+ - [Advanced](#advanced)
16
+ - [Additional Headers](#additional-headers)
17
+ - [Additional Query String Parameters](#additional-query-string-parameters)
18
+ - [Retries](#retries)
19
+ - [Timeouts](#timeouts)
20
+ - [Aborting Requests](#aborting-requests)
21
+ - [Access Raw Response Data](#access-raw-response-data)
22
+ - [Logging](#logging)
23
+ - [Runtime Compatibility](#runtime-compatibility)
24
+ - [Contributing](#contributing)
25
+
26
+ ## Installation
27
+
28
+ ```sh
29
+ npm i -s pulse-ts-sdk
30
+ ```
31
+
32
+ ## Reference
33
+
34
+ A full reference for this library is available [here](https://github.com/Pulse-Software-Corp/pulse-ts-sdk/blob/HEAD/./reference.md).
35
+
36
+ ## Usage
37
+
38
+ Instantiate and use the client with the following:
39
+
40
+ ```typescript
41
+ import { PulseClient } from "pulse-ts-sdk";
42
+
43
+ const client = new PulseClient({ apiKey: "YOUR_API_KEY" });
44
+ await client.extract({
45
+ fileUrl: "fileUrl"
46
+ });
47
+ ```
48
+
49
+ ## Request and Response Types
50
+
51
+ The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
52
+ following namespace:
53
+
54
+ ```typescript
55
+ import { Pulse } from "pulse-ts-sdk";
56
+
57
+ const request: Pulse.GetJobRequest = {
58
+ ...
59
+ };
60
+ ```
61
+
62
+ ## Exception Handling
63
+
64
+ When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
65
+ will be thrown.
66
+
67
+ ```typescript
68
+ import { PulseError } from "pulse-ts-sdk";
69
+
70
+ try {
71
+ await client.extract(...);
72
+ } catch (err) {
73
+ if (err instanceof PulseError) {
74
+ console.log(err.statusCode);
75
+ console.log(err.message);
76
+ console.log(err.body);
77
+ console.log(err.rawResponse);
78
+ }
79
+ }
80
+ ```
81
+
82
+ ## Advanced
83
+
84
+ ### Additional Headers
85
+
86
+ If you would like to send additional headers as part of the request, use the `headers` request option.
87
+
88
+ ```typescript
89
+ import { PulseClient } from "pulse-ts-sdk";
90
+
91
+ const client = new PulseClient({
92
+ ...
93
+ headers: {
94
+ 'X-Custom-Header': 'custom value'
95
+ }
96
+ });
97
+
98
+ const response = await client.extract(..., {
99
+ headers: {
100
+ 'X-Custom-Header': 'custom value'
101
+ }
102
+ });
103
+ ```
104
+
105
+ ### Additional Query String Parameters
106
+
107
+ If you would like to send additional query string parameters as part of the request, use the `queryParams` request option.
108
+
109
+ ```typescript
110
+ const response = await client.extract(..., {
111
+ queryParams: {
112
+ 'customQueryParamKey': 'custom query param value'
113
+ }
114
+ });
115
+ ```
116
+
117
+ ### Retries
118
+
119
+ The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
120
+ as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
121
+ retry limit (default: 2).
122
+
123
+ A request is deemed retryable when any of the following HTTP status codes is returned:
124
+
125
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
126
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
127
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
128
+
129
+ Use the `maxRetries` request option to configure this behavior.
130
+
131
+ ```typescript
132
+ const response = await client.extract(..., {
133
+ maxRetries: 0 // override maxRetries at the request level
134
+ });
135
+ ```
136
+
137
+ ### Timeouts
138
+
139
+ The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.
140
+
141
+ ```typescript
142
+ const response = await client.extract(..., {
143
+ timeoutInSeconds: 30 // override timeout to 30s
144
+ });
145
+ ```
146
+
147
+ ### Aborting Requests
148
+
149
+ The SDK allows users to abort requests at any point by passing in an abort signal.
150
+
151
+ ```typescript
152
+ const controller = new AbortController();
153
+ const response = await client.extract(..., {
154
+ abortSignal: controller.signal
155
+ });
156
+ controller.abort(); // aborts the request
157
+ ```
158
+
159
+ ### Access Raw Response Data
160
+
161
+ The SDK provides access to raw response data, including headers, through the `.withRawResponse()` method.
162
+ The `.withRawResponse()` method returns a promise that results to an object with a `data` and a `rawResponse` property.
163
+
164
+ ```typescript
165
+ const { data, rawResponse } = await client.extract(...).withRawResponse();
166
+
167
+ console.log(data);
168
+ console.log(rawResponse.headers['X-My-Header']);
169
+ ```
170
+
171
+ ### Logging
172
+
173
+ The SDK supports logging. You can configure the logger by passing in a `logging` object to the client options.
174
+
175
+ ```typescript
176
+ import { PulseClient, logging } from "pulse-ts-sdk";
177
+
178
+ const client = new PulseClient({
179
+ ...
180
+ logging: {
181
+ level: logging.LogLevel.Debug, // defaults to logging.LogLevel.Info
182
+ logger: new logging.ConsoleLogger(), // defaults to ConsoleLogger
183
+ silent: false, // defaults to true, set to false to enable logging
184
+ }
185
+ });
186
+ ```
187
+ The `logging` object can have the following properties:
188
+ - `level`: The log level to use. Defaults to `logging.LogLevel.Info`.
189
+ - `logger`: The logger to use. Defaults to a `logging.ConsoleLogger`.
190
+ - `silent`: Whether to silence the logger. Defaults to `true`.
191
+
192
+ The `level` property can be one of the following values:
193
+ - `logging.LogLevel.Debug`
194
+ - `logging.LogLevel.Info`
195
+ - `logging.LogLevel.Warn`
196
+ - `logging.LogLevel.Error`
197
+
198
+ To provide a custom logger, you can pass in an object that implements the `logging.ILogger` interface.
199
+
200
+ <details>
201
+ <summary>Custom logger examples</summary>
202
+
203
+ Here's an example using the popular `winston` logging library.
204
+ ```ts
205
+ import winston from 'winston';
206
+
207
+ const winstonLogger = winston.createLogger({...});
208
+
209
+ const logger: logging.ILogger = {
210
+ debug: (msg, ...args) => winstonLogger.debug(msg, ...args),
211
+ info: (msg, ...args) => winstonLogger.info(msg, ...args),
212
+ warn: (msg, ...args) => winstonLogger.warn(msg, ...args),
213
+ error: (msg, ...args) => winstonLogger.error(msg, ...args),
214
+ };
215
+ ```
216
+
217
+ Here's an example using the popular `pino` logging library.
218
+
219
+ ```ts
220
+ import pino from 'pino';
221
+
222
+ const pinoLogger = pino({...});
223
+
224
+ const logger: logging.ILogger = {
225
+ debug: (msg, ...args) => pinoLogger.debug(args, msg),
226
+ info: (msg, ...args) => pinoLogger.info(args, msg),
227
+ warn: (msg, ...args) => pinoLogger.warn(args, msg),
228
+ error: (msg, ...args) => pinoLogger.error(args, msg),
229
+ };
230
+ ```
231
+ </details>
232
+
233
+
234
+ ### Runtime Compatibility
235
+
236
+
237
+ The SDK works in the following runtimes:
238
+
239
+
240
+
241
+ - Node.js 18+
242
+ - Vercel
243
+ - Cloudflare Workers
244
+ - Deno v1.25+
245
+ - Bun 1.0+
246
+ - React Native
247
+
248
+ ### Customizing Fetch Client
249
+
250
+ The SDK provides a way for you to customize the underlying HTTP client / Fetch function. If you're running in an
251
+ unsupported environment, this provides a way for you to break glass and ensure the SDK works.
252
+
253
+ ```typescript
254
+ import { PulseClient } from "pulse-ts-sdk";
255
+
256
+ const client = new PulseClient({
257
+ ...
258
+ fetcher: // provide your implementation here
259
+ });
260
+ ```
261
+
262
+ ## Contributing
263
+
264
+ While we value open-source contributions to this SDK, this library is generated programmatically.
265
+ Additions made directly to this library would have to be moved over to our generation code,
266
+ otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
267
+ a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
268
+ an issue first to discuss with us!
269
+
270
+ On the other hand, contributions to the README are always very welcome!
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "pulse-ts-sdk",
3
+ "version": "0.0.51",
4
+ "private": false,
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/Pulse-Software-Corp/pulse-ts-sdk.git"
8
+ },
9
+ "type": "commonjs",
10
+ "main": "./dist/cjs/index.js",
11
+ "module": "./dist/esm/index.mjs",
12
+ "types": "./dist/cjs/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/cjs/index.d.ts",
16
+ "import": {
17
+ "types": "./dist/esm/index.d.mts",
18
+ "default": "./dist/esm/index.mjs"
19
+ },
20
+ "require": {
21
+ "types": "./dist/cjs/index.d.ts",
22
+ "default": "./dist/cjs/index.js"
23
+ },
24
+ "default": "./dist/cjs/index.js"
25
+ },
26
+ "./package.json": "./package.json"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "reference.md",
31
+ "README.md",
32
+ "LICENSE"
33
+ ],
34
+ "scripts": {
35
+ "format": "biome format --write --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
36
+ "format:check": "biome format --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
37
+ "lint": "biome lint --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
38
+ "lint:fix": "biome lint --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
39
+ "check": "biome check --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
40
+ "check:fix": "biome check --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
41
+ "build": "pnpm build:cjs && pnpm build:esm",
42
+ "build:cjs": "tsc --project ./tsconfig.cjs.json",
43
+ "build:esm": "tsc --project ./tsconfig.esm.json && node scripts/rename-to-esm-files.js dist/esm",
44
+ "test": "vitest",
45
+ "test:unit": "vitest --project unit",
46
+ "test:wire": "vitest --project wire"
47
+ },
48
+ "dependencies": {},
49
+ "devDependencies": {
50
+ "webpack": "^5.97.1",
51
+ "ts-loader": "^9.5.1",
52
+ "vitest": "^3.2.4",
53
+ "msw": "2.11.2",
54
+ "@types/node": "^18.19.70",
55
+ "typescript": "~5.7.2",
56
+ "@biomejs/biome": "2.3.1"
57
+ },
58
+ "browser": {
59
+ "fs": false,
60
+ "os": false,
61
+ "path": false,
62
+ "stream": false
63
+ },
64
+ "packageManager": "pnpm@10.20.0",
65
+ "engines": {
66
+ "node": ">=18.0.0"
67
+ },
68
+ "sideEffects": false
69
+ }
package/reference.md ADDED
@@ -0,0 +1,323 @@
1
+ # Reference
2
+ <details><summary><code>client.<a href="/src/Client.ts">extract</a>({ ...params }) -> Pulse.ExtractResponse</code></summary>
3
+ <dl>
4
+ <dd>
5
+
6
+ #### 📝 Description
7
+
8
+ <dl>
9
+ <dd>
10
+
11
+ <dl>
12
+ <dd>
13
+
14
+ Performs a synchronous extraction job against an uploaded document or a
15
+ remote file URL. The request accepts a variety of configuration options
16
+ used by the Pulse extraction pipeline.
17
+ </dd>
18
+ </dl>
19
+ </dd>
20
+ </dl>
21
+
22
+ #### 🔌 Usage
23
+
24
+ <dl>
25
+ <dd>
26
+
27
+ <dl>
28
+ <dd>
29
+
30
+ ```typescript
31
+ await client.extract({
32
+ fileUrl: "fileUrl"
33
+ });
34
+
35
+ ```
36
+ </dd>
37
+ </dl>
38
+ </dd>
39
+ </dl>
40
+
41
+ #### ⚙️ Parameters
42
+
43
+ <dl>
44
+ <dd>
45
+
46
+ <dl>
47
+ <dd>
48
+
49
+ **request:** `Pulse.ExtractJsonInput`
50
+
51
+ </dd>
52
+ </dl>
53
+
54
+ <dl>
55
+ <dd>
56
+
57
+ **requestOptions:** `PulseClient.RequestOptions`
58
+
59
+ </dd>
60
+ </dl>
61
+ </dd>
62
+ </dl>
63
+
64
+
65
+ </dd>
66
+ </dl>
67
+ </details>
68
+
69
+ <details><summary><code>client.<a href="/src/Client.ts">extractAsync</a>({ ...params }) -> Pulse.ExtractAsyncResponse</code></summary>
70
+ <dl>
71
+ <dd>
72
+
73
+ #### 📝 Description
74
+
75
+ <dl>
76
+ <dd>
77
+
78
+ <dl>
79
+ <dd>
80
+
81
+ Starts an asynchronous extraction job. The request mirrors the
82
+ synchronous options but returns immediately with a job identifier that
83
+ clients can poll for completion status.
84
+ </dd>
85
+ </dl>
86
+ </dd>
87
+ </dl>
88
+
89
+ #### 🔌 Usage
90
+
91
+ <dl>
92
+ <dd>
93
+
94
+ <dl>
95
+ <dd>
96
+
97
+ ```typescript
98
+ await client.extractAsync({
99
+ fileUrl: "fileUrl"
100
+ });
101
+
102
+ ```
103
+ </dd>
104
+ </dl>
105
+ </dd>
106
+ </dl>
107
+
108
+ #### ⚙️ Parameters
109
+
110
+ <dl>
111
+ <dd>
112
+
113
+ <dl>
114
+ <dd>
115
+
116
+ **request:** `Pulse.ExtractJsonInput`
117
+
118
+ </dd>
119
+ </dl>
120
+
121
+ <dl>
122
+ <dd>
123
+
124
+ **requestOptions:** `PulseClient.RequestOptions`
125
+
126
+ </dd>
127
+ </dl>
128
+ </dd>
129
+ </dl>
130
+
131
+
132
+ </dd>
133
+ </dl>
134
+ </details>
135
+
136
+ ## Jobs
137
+ <details><summary><code>client.jobs.<a href="/src/api/resources/jobs/client/Client.ts">getJob</a>({ ...params }) -> Pulse.JobStatusResponse</code></summary>
138
+ <dl>
139
+ <dd>
140
+
141
+ #### 📝 Description
142
+
143
+ <dl>
144
+ <dd>
145
+
146
+ <dl>
147
+ <dd>
148
+
149
+ Retrieves the latest status and metadata for an asynchronous extraction job
150
+ that was previously submitted via `/extract_async`.
151
+ </dd>
152
+ </dl>
153
+ </dd>
154
+ </dl>
155
+
156
+ #### 🔌 Usage
157
+
158
+ <dl>
159
+ <dd>
160
+
161
+ <dl>
162
+ <dd>
163
+
164
+ ```typescript
165
+ await client.jobs.getJob({
166
+ jobId: "jobId"
167
+ });
168
+
169
+ ```
170
+ </dd>
171
+ </dl>
172
+ </dd>
173
+ </dl>
174
+
175
+ #### ⚙️ Parameters
176
+
177
+ <dl>
178
+ <dd>
179
+
180
+ <dl>
181
+ <dd>
182
+
183
+ **request:** `Pulse.GetJobRequest`
184
+
185
+ </dd>
186
+ </dl>
187
+
188
+ <dl>
189
+ <dd>
190
+
191
+ **requestOptions:** `JobsClient.RequestOptions`
192
+
193
+ </dd>
194
+ </dl>
195
+ </dd>
196
+ </dl>
197
+
198
+
199
+ </dd>
200
+ </dl>
201
+ </details>
202
+
203
+ <details><summary><code>client.jobs.<a href="/src/api/resources/jobs/client/Client.ts">cancelJob</a>({ ...params }) -> Pulse.JobCancellationResponse</code></summary>
204
+ <dl>
205
+ <dd>
206
+
207
+ #### 📝 Description
208
+
209
+ <dl>
210
+ <dd>
211
+
212
+ <dl>
213
+ <dd>
214
+
215
+ Attempts to cancel an asynchronous extraction job that is currently pending
216
+ or processing. Jobs that have already completed will remain unchanged.
217
+ </dd>
218
+ </dl>
219
+ </dd>
220
+ </dl>
221
+
222
+ #### 🔌 Usage
223
+
224
+ <dl>
225
+ <dd>
226
+
227
+ <dl>
228
+ <dd>
229
+
230
+ ```typescript
231
+ await client.jobs.cancelJob({
232
+ jobId: "jobId"
233
+ });
234
+
235
+ ```
236
+ </dd>
237
+ </dl>
238
+ </dd>
239
+ </dl>
240
+
241
+ #### ⚙️ Parameters
242
+
243
+ <dl>
244
+ <dd>
245
+
246
+ <dl>
247
+ <dd>
248
+
249
+ **request:** `Pulse.CancelJobRequest`
250
+
251
+ </dd>
252
+ </dl>
253
+
254
+ <dl>
255
+ <dd>
256
+
257
+ **requestOptions:** `JobsClient.RequestOptions`
258
+
259
+ </dd>
260
+ </dl>
261
+ </dd>
262
+ </dl>
263
+
264
+
265
+ </dd>
266
+ </dl>
267
+ </details>
268
+
269
+ ## Webhooks
270
+ <details><summary><code>client.webhooks.<a href="/src/api/resources/webhooks/client/Client.ts">createWebhookLink</a>() -> Pulse.CreateWebhookLinkResponse</code></summary>
271
+ <dl>
272
+ <dd>
273
+
274
+ #### 📝 Description
275
+
276
+ <dl>
277
+ <dd>
278
+
279
+ <dl>
280
+ <dd>
281
+
282
+ Generates a temporary link to the Svix webhook portal where users can manage their webhook endpoints and view message logs.
283
+ </dd>
284
+ </dl>
285
+ </dd>
286
+ </dl>
287
+
288
+ #### 🔌 Usage
289
+
290
+ <dl>
291
+ <dd>
292
+
293
+ <dl>
294
+ <dd>
295
+
296
+ ```typescript
297
+ await client.webhooks.createWebhookLink();
298
+
299
+ ```
300
+ </dd>
301
+ </dl>
302
+ </dd>
303
+ </dl>
304
+
305
+ #### ⚙️ Parameters
306
+
307
+ <dl>
308
+ <dd>
309
+
310
+ <dl>
311
+ <dd>
312
+
313
+ **requestOptions:** `WebhooksClient.RequestOptions`
314
+
315
+ </dd>
316
+ </dl>
317
+ </dd>
318
+ </dl>
319
+
320
+
321
+ </dd>
322
+ </dl>
323
+ </details>