pulse-ts-sdk 0.0.53 → 0.0.55

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 (90) hide show
  1. package/README.md +44 -3
  2. package/dist/cjs/BaseClient.js +2 -2
  3. package/dist/cjs/Client.d.ts +8 -10
  4. package/dist/cjs/Client.js +113 -16
  5. package/dist/cjs/api/client/index.d.ts +1 -0
  6. package/dist/cjs/api/client/index.js +17 -0
  7. package/dist/{esm/api/types/ExtractJsonInput.d.mts → cjs/api/client/requests/ExtractAsyncRequest.d.ts} +13 -9
  8. package/dist/cjs/api/{types/ExtractMultipartInput.d.ts → client/requests/ExtractRequest.d.ts} +10 -8
  9. package/dist/cjs/api/client/requests/index.d.ts +2 -0
  10. package/dist/cjs/api/{types/JsonSource.js → client/requests/index.js} +0 -1
  11. package/dist/cjs/api/index.d.ts +1 -0
  12. package/dist/cjs/api/index.js +1 -0
  13. package/dist/cjs/api/types/ExtractInput.d.ts +63 -1
  14. package/dist/cjs/api/types/{MultipartSource.d.ts → ExtractSource.d.ts} +1 -1
  15. package/dist/cjs/api/types/index.d.ts +1 -5
  16. package/dist/cjs/api/types/index.js +1 -5
  17. package/dist/cjs/core/exports.d.ts +1 -0
  18. package/dist/cjs/core/exports.js +1 -0
  19. package/dist/cjs/core/file/exports.d.ts +1 -0
  20. package/dist/cjs/core/file/exports.js +2 -0
  21. package/dist/cjs/core/file/file.d.ts +10 -0
  22. package/dist/cjs/core/file/file.js +221 -0
  23. package/dist/cjs/core/file/index.d.ts +2 -0
  24. package/dist/cjs/core/file/index.js +18 -0
  25. package/dist/cjs/core/file/types.d.ts +66 -0
  26. package/dist/cjs/core/file/types.js +2 -0
  27. package/dist/cjs/core/form-data-utils/FormDataWrapper.d.ts +15 -0
  28. package/dist/cjs/core/form-data-utils/FormDataWrapper.js +185 -0
  29. package/dist/cjs/core/form-data-utils/encodeAsFormParameter.d.ts +1 -0
  30. package/dist/cjs/core/form-data-utils/encodeAsFormParameter.js +12 -0
  31. package/dist/cjs/core/form-data-utils/index.d.ts +2 -0
  32. package/dist/cjs/core/form-data-utils/index.js +20 -0
  33. package/dist/cjs/core/index.d.ts +2 -0
  34. package/dist/cjs/core/index.js +3 -1
  35. package/dist/cjs/environments.d.ts +1 -1
  36. package/dist/cjs/environments.js +1 -1
  37. package/dist/cjs/version.d.ts +1 -1
  38. package/dist/cjs/version.js +1 -1
  39. package/dist/esm/BaseClient.mjs +2 -2
  40. package/dist/esm/Client.d.mts +8 -10
  41. package/dist/esm/Client.mjs +114 -17
  42. package/dist/esm/api/client/index.d.mts +1 -0
  43. package/dist/esm/api/client/index.mjs +1 -0
  44. package/dist/{cjs/api/types/ExtractJsonInput.d.ts → esm/api/client/requests/ExtractAsyncRequest.d.mts} +13 -9
  45. package/dist/esm/api/{types/ExtractMultipartInput.d.mts → client/requests/ExtractRequest.d.mts} +10 -8
  46. package/dist/esm/api/client/requests/index.d.mts +2 -0
  47. package/dist/esm/api/client/requests/index.mjs +1 -0
  48. package/dist/esm/api/index.d.mts +1 -0
  49. package/dist/esm/api/index.mjs +1 -0
  50. package/dist/esm/api/types/ExtractInput.d.mts +63 -1
  51. package/dist/esm/api/types/{MultipartSource.d.mts → ExtractSource.d.mts} +1 -1
  52. package/dist/esm/api/types/index.d.mts +1 -5
  53. package/dist/esm/api/types/index.mjs +1 -5
  54. package/dist/esm/core/exports.d.mts +1 -0
  55. package/dist/esm/core/exports.mjs +1 -0
  56. package/dist/esm/core/file/exports.d.mts +1 -0
  57. package/dist/esm/core/file/exports.mjs +1 -0
  58. package/dist/esm/core/file/file.d.mts +10 -0
  59. package/dist/esm/core/file/file.mjs +184 -0
  60. package/dist/esm/core/file/index.d.mts +2 -0
  61. package/dist/esm/core/file/index.mjs +2 -0
  62. package/dist/esm/core/file/types.d.mts +66 -0
  63. package/dist/esm/core/file/types.mjs +1 -0
  64. package/dist/esm/core/form-data-utils/FormDataWrapper.d.mts +15 -0
  65. package/dist/esm/core/form-data-utils/FormDataWrapper.mjs +147 -0
  66. package/dist/esm/core/form-data-utils/encodeAsFormParameter.d.mts +1 -0
  67. package/dist/esm/core/form-data-utils/encodeAsFormParameter.mjs +9 -0
  68. package/dist/esm/core/form-data-utils/index.d.mts +2 -0
  69. package/dist/esm/core/form-data-utils/index.mjs +2 -0
  70. package/dist/esm/core/index.d.mts +2 -0
  71. package/dist/esm/core/index.mjs +2 -0
  72. package/dist/esm/environments.d.mts +1 -1
  73. package/dist/esm/environments.mjs +1 -1
  74. package/dist/esm/version.d.mts +1 -1
  75. package/dist/esm/version.mjs +1 -1
  76. package/package.json +1 -1
  77. package/reference.md +4 -8
  78. package/dist/cjs/api/types/ExtractAsyncInput.d.ts +0 -1
  79. package/dist/cjs/api/types/JsonSource.d.ts +0 -7
  80. package/dist/cjs/api/types/MultipartSource.js +0 -3
  81. package/dist/esm/api/types/ExtractAsyncInput.d.mts +0 -1
  82. package/dist/esm/api/types/JsonSource.d.mts +0 -7
  83. package/dist/esm/api/types/JsonSource.mjs +0 -2
  84. package/dist/esm/api/types/MultipartSource.mjs +0 -2
  85. /package/dist/cjs/api/{types/ExtractAsyncInput.js → client/requests/ExtractAsyncRequest.js} +0 -0
  86. /package/dist/cjs/api/{types/ExtractJsonInput.js → client/requests/ExtractRequest.js} +0 -0
  87. /package/dist/cjs/api/types/{ExtractMultipartInput.js → ExtractSource.js} +0 -0
  88. /package/dist/esm/api/{types/ExtractAsyncInput.mjs → client/requests/ExtractAsyncRequest.mjs} +0 -0
  89. /package/dist/esm/api/{types/ExtractJsonInput.mjs → client/requests/ExtractRequest.mjs} +0 -0
  90. /package/dist/esm/api/types/{ExtractMultipartInput.mjs → ExtractSource.mjs} +0 -0
@@ -12,8 +12,9 @@ import * as Pulse from "./api/index.mjs";
12
12
  import { JobsClient } from "./api/resources/jobs/client/Client.mjs";
13
13
  import { WebhooksClient } from "./api/resources/webhooks/client/Client.mjs";
14
14
  import { normalizeClientOptions } from "./BaseClient.mjs";
15
- import { mergeHeaders } from "./core/headers.mjs";
15
+ import { mergeHeaders, mergeOnlyDefinedHeaders } from "./core/headers.mjs";
16
16
  import * as core from "./core/index.mjs";
17
+ import { toJson } from "./core/json.mjs";
17
18
  import * as environments from "./environments.mjs";
18
19
  import { handleNonStatusCodeError } from "./errors/handleNonStatusCodeError.mjs";
19
20
  import * as errors from "./errors/index.mjs";
@@ -34,7 +35,7 @@ export class PulseClient {
34
35
  * file URLs and returns rich markdown content with optional structured data
35
36
  * extraction based on user-provided schemas and extraction options.
36
37
  *
37
- * @param {Pulse.ExtractJsonInput} request
38
+ * @param {Pulse.ExtractRequest} request
38
39
  * @param {PulseClient.RequestOptions} requestOptions - Request-specific configuration.
39
40
  *
40
41
  * @throws {@link Pulse.BadRequestError}
@@ -42,9 +43,8 @@ export class PulseClient {
42
43
  * @throws {@link Pulse.TooManyRequestsError}
43
44
  *
44
45
  * @example
45
- * await client.extract({
46
- * fileUrl: "fileUrl"
47
- * })
46
+ * import { createReadStream } from "fs";
47
+ * await client.extract({})
48
48
  */
49
49
  extract(request, requestOptions) {
50
50
  return core.HttpResponsePromise.fromPromise(this.__extract(request, requestOptions));
@@ -52,15 +52,64 @@ export class PulseClient {
52
52
  __extract(request, requestOptions) {
53
53
  return __awaiter(this, void 0, void 0, function* () {
54
54
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
55
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
55
+ const _request = yield core.newFormData();
56
+ if (request.file != null) {
57
+ yield _request.appendFile("file", request.file);
58
+ }
59
+ if (request.fileUrl != null) {
60
+ _request.append("fileUrl", request.fileUrl);
61
+ }
62
+ if (request.structuredOutput != null) {
63
+ _request.append("structuredOutput", toJson(request.structuredOutput));
64
+ }
65
+ if (request.schema != null) {
66
+ _request.append("schema", typeof request.schema === "string" ? request.schema : toJson(request.schema));
67
+ }
68
+ if (request.experimentalSchema != null) {
69
+ _request.append("experimentalSchema", typeof request.experimentalSchema === "string"
70
+ ? request.experimentalSchema
71
+ : toJson(request.experimentalSchema));
72
+ }
73
+ if (request.schemaPrompt != null) {
74
+ _request.append("schemaPrompt", request.schemaPrompt);
75
+ }
76
+ if (request.customPrompt != null) {
77
+ _request.append("customPrompt", request.customPrompt);
78
+ }
79
+ if (request.chunking != null) {
80
+ _request.append("chunking", request.chunking);
81
+ }
82
+ if (request.chunkSize != null) {
83
+ _request.append("chunkSize", request.chunkSize.toString());
84
+ }
85
+ if (request.pages != null) {
86
+ _request.append("pages", request.pages);
87
+ }
88
+ if (request.extractFigure != null) {
89
+ _request.append("extractFigure", request.extractFigure.toString());
90
+ }
91
+ if (request.figureDescription != null) {
92
+ _request.append("figureDescription", request.figureDescription.toString());
93
+ }
94
+ if (request.returnHtml != null) {
95
+ _request.append("returnHtml", request.returnHtml.toString());
96
+ }
97
+ if (request.thinking != null) {
98
+ _request.append("thinking", request.thinking.toString());
99
+ }
100
+ if (request.storage != null) {
101
+ _request.append("storage", toJson(request.storage));
102
+ }
103
+ const _maybeEncodedRequest = yield _request.getRequest();
104
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
56
105
  const _response = yield core.fetcher({
57
106
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PulseEnvironment.Default, "extract"),
58
107
  method: "POST",
59
108
  headers: _headers,
60
- contentType: "application/json",
61
109
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
62
- requestType: "json",
63
- body: request,
110
+ requestType: "file",
111
+ duplex: _maybeEncodedRequest.duplex,
112
+ body: _maybeEncodedRequest.body,
64
113
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
65
114
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
66
115
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
@@ -94,7 +143,7 @@ export class PulseClient {
94
143
  * synchronous options but returns immediately with a job identifier that
95
144
  * clients can poll for completion status.
96
145
  *
97
- * @param {Pulse.ExtractJsonInput} request
146
+ * @param {Pulse.ExtractAsyncRequest} request
98
147
  * @param {PulseClient.RequestOptions} requestOptions - Request-specific configuration.
99
148
  *
100
149
  * @throws {@link Pulse.BadRequestError}
@@ -102,9 +151,8 @@ export class PulseClient {
102
151
  * @throws {@link Pulse.TooManyRequestsError}
103
152
  *
104
153
  * @example
105
- * await client.extractAsync({
106
- * fileUrl: "fileUrl"
107
- * })
154
+ * import { createReadStream } from "fs";
155
+ * await client.extractAsync({})
108
156
  */
109
157
  extractAsync(request, requestOptions) {
110
158
  return core.HttpResponsePromise.fromPromise(this.__extractAsync(request, requestOptions));
@@ -112,15 +160,64 @@ export class PulseClient {
112
160
  __extractAsync(request, requestOptions) {
113
161
  return __awaiter(this, void 0, void 0, function* () {
114
162
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
115
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
163
+ const _request = yield core.newFormData();
164
+ if (request.file != null) {
165
+ yield _request.appendFile("file", request.file);
166
+ }
167
+ if (request.fileUrl != null) {
168
+ _request.append("fileUrl", request.fileUrl);
169
+ }
170
+ if (request.structuredOutput != null) {
171
+ _request.append("structuredOutput", toJson(request.structuredOutput));
172
+ }
173
+ if (request.schema != null) {
174
+ _request.append("schema", typeof request.schema === "string" ? request.schema : toJson(request.schema));
175
+ }
176
+ if (request.experimentalSchema != null) {
177
+ _request.append("experimentalSchema", typeof request.experimentalSchema === "string"
178
+ ? request.experimentalSchema
179
+ : toJson(request.experimentalSchema));
180
+ }
181
+ if (request.schemaPrompt != null) {
182
+ _request.append("schemaPrompt", request.schemaPrompt);
183
+ }
184
+ if (request.customPrompt != null) {
185
+ _request.append("customPrompt", request.customPrompt);
186
+ }
187
+ if (request.chunking != null) {
188
+ _request.append("chunking", request.chunking);
189
+ }
190
+ if (request.chunkSize != null) {
191
+ _request.append("chunkSize", request.chunkSize.toString());
192
+ }
193
+ if (request.pages != null) {
194
+ _request.append("pages", request.pages);
195
+ }
196
+ if (request.extractFigure != null) {
197
+ _request.append("extractFigure", request.extractFigure.toString());
198
+ }
199
+ if (request.figureDescription != null) {
200
+ _request.append("figureDescription", request.figureDescription.toString());
201
+ }
202
+ if (request.returnHtml != null) {
203
+ _request.append("returnHtml", request.returnHtml.toString());
204
+ }
205
+ if (request.thinking != null) {
206
+ _request.append("thinking", request.thinking.toString());
207
+ }
208
+ if (request.storage != null) {
209
+ _request.append("storage", toJson(request.storage));
210
+ }
211
+ const _maybeEncodedRequest = yield _request.getRequest();
212
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
116
213
  const _response = yield core.fetcher({
117
214
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PulseEnvironment.Default, "extract_async"),
118
215
  method: "POST",
119
216
  headers: _headers,
120
- contentType: "application/json",
121
217
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
122
- requestType: "json",
123
- body: request,
218
+ requestType: "file",
219
+ duplex: _maybeEncodedRequest.duplex,
220
+ body: _maybeEncodedRequest.body,
124
221
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
125
222
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
126
223
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
@@ -0,0 +1 @@
1
+ export * from "./requests/index.mjs";
@@ -0,0 +1 @@
1
+ export * from "./requests/index.mjs";
@@ -1,15 +1,19 @@
1
+ import type * as core from "../../../core/index.mjs";
1
2
  /**
2
- * Input schema for JSON requests (fileUrl only).
3
+ * @example
4
+ * {}
3
5
  */
4
- export interface ExtractJsonInput {
5
- /** Public or pre-signed URL that Pulse will download and extract. */
6
- fileUrl: string;
6
+ export interface ExtractAsyncRequest {
7
+ /** Document to upload directly. Required unless fileUrl is provided. */
8
+ file?: core.file.Uploadable | undefined;
9
+ /** Public or pre-signed URL that Pulse will download and extract. Required unless file is provided. */
10
+ fileUrl?: string;
7
11
  /** Recommended method for schema-guided extraction. Contains the schema and optional prompt in a single object. */
8
- structuredOutput?: ExtractJsonInput.StructuredOutput;
12
+ structuredOutput?: ExtractAsyncRequest.StructuredOutput;
9
13
  /** (Deprecated) JSON schema describing structured data to extract. Use structuredOutput instead. Accepts either a JSON object or a stringified JSON representation. */
10
- schema?: ExtractJsonInput.Schema;
14
+ schema?: ExtractAsyncRequest.Schema;
11
15
  /** (Deprecated) Experimental schema definition used for feature flagged behaviour. Accepts either a JSON object or a stringified JSON representation. */
12
- experimentalSchema?: ExtractJsonInput.ExperimentalSchema;
16
+ experimentalSchema?: ExtractAsyncRequest.ExperimentalSchema;
13
17
  /** (Deprecated) Natural language prompt for schema-guided extraction. Use structuredOutput.schemaPrompt instead. */
14
18
  schemaPrompt?: string;
15
19
  /** (Deprecated) Custom instructions that augment the default extraction behaviour. */
@@ -29,9 +33,9 @@ export interface ExtractJsonInput {
29
33
  /** (Deprecated) Enables expanded rationale output for debugging. */
30
34
  thinking?: boolean;
31
35
  /** Options for persisting extraction artifacts. When enabled (default), artifacts are saved to storage and a database record is created. */
32
- storage?: ExtractJsonInput.Storage;
36
+ storage?: ExtractAsyncRequest.Storage;
33
37
  }
34
- export declare namespace ExtractJsonInput {
38
+ export declare namespace ExtractAsyncRequest {
35
39
  /**
36
40
  * Recommended method for schema-guided extraction. Contains the schema and optional prompt in a single object.
37
41
  */
@@ -1,17 +1,19 @@
1
+ import type * as core from "../../../core/index.mjs";
1
2
  /**
2
- * Input schema for multipart/form-data requests (file upload or fileUrl).
3
+ * @example
4
+ * {}
3
5
  */
4
- export interface ExtractMultipartInput {
6
+ export interface ExtractRequest {
5
7
  /** Document to upload directly. Required unless fileUrl is provided. */
6
- file?: string;
8
+ file?: core.file.Uploadable | undefined;
7
9
  /** Public or pre-signed URL that Pulse will download and extract. Required unless file is provided. */
8
10
  fileUrl?: string;
9
11
  /** Recommended method for schema-guided extraction. Contains the schema and optional prompt in a single object. */
10
- structuredOutput?: ExtractMultipartInput.StructuredOutput;
12
+ structuredOutput?: ExtractRequest.StructuredOutput;
11
13
  /** (Deprecated) JSON schema describing structured data to extract. Use structuredOutput instead. Accepts either a JSON object or a stringified JSON representation. */
12
- schema?: ExtractMultipartInput.Schema;
14
+ schema?: ExtractRequest.Schema;
13
15
  /** (Deprecated) Experimental schema definition used for feature flagged behaviour. Accepts either a JSON object or a stringified JSON representation. */
14
- experimentalSchema?: ExtractMultipartInput.ExperimentalSchema;
16
+ experimentalSchema?: ExtractRequest.ExperimentalSchema;
15
17
  /** (Deprecated) Natural language prompt for schema-guided extraction. Use structuredOutput.schemaPrompt instead. */
16
18
  schemaPrompt?: string;
17
19
  /** (Deprecated) Custom instructions that augment the default extraction behaviour. */
@@ -31,9 +33,9 @@ export interface ExtractMultipartInput {
31
33
  /** (Deprecated) Enables expanded rationale output for debugging. */
32
34
  thinking?: boolean;
33
35
  /** Options for persisting extraction artifacts. When enabled (default), artifacts are saved to storage and a database record is created. */
34
- storage?: ExtractMultipartInput.Storage;
36
+ storage?: ExtractRequest.Storage;
35
37
  }
36
- export declare namespace ExtractMultipartInput {
38
+ export declare namespace ExtractRequest {
37
39
  /**
38
40
  * Recommended method for schema-guided extraction. Contains the schema and optional prompt in a single object.
39
41
  */
@@ -0,0 +1,2 @@
1
+ export type { ExtractAsyncRequest } from "./ExtractAsyncRequest.mjs";
2
+ export type { ExtractRequest } from "./ExtractRequest.mjs";
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ export * from "./client/index.mjs";
1
2
  export * from "./errors/index.mjs";
2
3
  export * from "./resources/index.mjs";
3
4
  export * from "./types/index.mjs";
@@ -1,3 +1,4 @@
1
+ export * from "./client/index.mjs";
1
2
  export * from "./errors/index.mjs";
2
3
  export * from "./resources/index.mjs";
3
4
  export * from "./types/index.mjs";
@@ -1 +1,63 @@
1
- export type ExtractInput = unknown;
1
+ /**
2
+ * Input schema for extraction requests. Provide either file (direct upload) or fileUrl (remote URL).
3
+ */
4
+ export interface ExtractInput {
5
+ /** Document to upload directly. Required unless fileUrl is provided. */
6
+ file?: string;
7
+ /** Public or pre-signed URL that Pulse will download and extract. Required unless file is provided. */
8
+ fileUrl?: string;
9
+ /** Recommended method for schema-guided extraction. Contains the schema and optional prompt in a single object. */
10
+ structuredOutput?: ExtractInput.StructuredOutput;
11
+ /** (Deprecated) JSON schema describing structured data to extract. Use structuredOutput instead. Accepts either a JSON object or a stringified JSON representation. */
12
+ schema?: ExtractInput.Schema;
13
+ /** (Deprecated) Experimental schema definition used for feature flagged behaviour. Accepts either a JSON object or a stringified JSON representation. */
14
+ experimentalSchema?: ExtractInput.ExperimentalSchema;
15
+ /** (Deprecated) Natural language prompt for schema-guided extraction. Use structuredOutput.schemaPrompt instead. */
16
+ schemaPrompt?: string;
17
+ /** (Deprecated) Custom instructions that augment the default extraction behaviour. */
18
+ customPrompt?: string;
19
+ /** Comma-separated list of chunking strategies to apply (for example `semantic,header,page,recursive`). */
20
+ chunking?: string;
21
+ /** Override for maximum characters per chunk when chunking is enabled. */
22
+ chunkSize?: number;
23
+ /** Page range filter supporting segments such as `1-2` or mixed ranges like `1-2,5`. */
24
+ pages?: string;
25
+ /** Toggle to enable figure extraction in results. */
26
+ extractFigure?: boolean;
27
+ /** Toggle to generate descriptive captions for extracted figures. */
28
+ figureDescription?: boolean;
29
+ /** Whether to include HTML representation alongside markdown in the response. */
30
+ returnHtml?: boolean;
31
+ /** (Deprecated) Enables expanded rationale output for debugging. */
32
+ thinking?: boolean;
33
+ /** Options for persisting extraction artifacts. When enabled (default), artifacts are saved to storage and a database record is created. */
34
+ storage?: ExtractInput.Storage;
35
+ }
36
+ export declare namespace ExtractInput {
37
+ /**
38
+ * Recommended method for schema-guided extraction. Contains the schema and optional prompt in a single object.
39
+ */
40
+ interface StructuredOutput {
41
+ /** JSON schema describing the structured data to extract. */
42
+ schema?: Record<string, unknown>;
43
+ /** Natural language prompt with additional extraction instructions. */
44
+ schemaPrompt?: string;
45
+ }
46
+ /**
47
+ * (Deprecated) JSON schema describing structured data to extract. Use structuredOutput instead. Accepts either a JSON object or a stringified JSON representation.
48
+ */
49
+ type Schema = Record<string, unknown> | string;
50
+ /**
51
+ * (Deprecated) Experimental schema definition used for feature flagged behaviour. Accepts either a JSON object or a stringified JSON representation.
52
+ */
53
+ type ExperimentalSchema = Record<string, unknown> | string;
54
+ /**
55
+ * Options for persisting extraction artifacts. When enabled (default), artifacts are saved to storage and a database record is created.
56
+ */
57
+ interface Storage {
58
+ /** Whether to persist extraction artifacts. Set to false for temporary extractions with no storage or database record. */
59
+ enabled?: boolean;
60
+ /** Target folder name to save the extraction to. Creates the folder if it doesn't exist. */
61
+ folderName?: string;
62
+ }
63
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Document source definition for multipart/form-data requests. Provide exactly one of `file` (direct upload) or `fileUrl` (remote URL).
3
3
  */
4
- export interface MultipartSource {
4
+ export interface ExtractSource {
5
5
  /** Document to upload directly. Required unless fileUrl is provided. */
6
6
  file?: string;
7
7
  /** Public or pre-signed URL that Pulse will download and extract. Required unless file is provided. */
@@ -1,12 +1,8 @@
1
- export * from "./ExtractAsyncInput.mjs";
2
1
  export * from "./ExtractAsyncResponse.mjs";
3
2
  export * from "./ExtractInput.mjs";
4
- export * from "./ExtractJsonInput.mjs";
5
- export * from "./ExtractMultipartInput.mjs";
6
3
  export * from "./ExtractOptions.mjs";
7
4
  export * from "./ExtractResponse.mjs";
5
+ export * from "./ExtractSource.mjs";
8
6
  export * from "./JobCancellationResponse.mjs";
9
7
  export * from "./JobStatus.mjs";
10
8
  export * from "./JobStatusResponse.mjs";
11
- export * from "./JsonSource.mjs";
12
- export * from "./MultipartSource.mjs";
@@ -1,12 +1,8 @@
1
- export * from "./ExtractAsyncInput.mjs";
2
1
  export * from "./ExtractAsyncResponse.mjs";
3
2
  export * from "./ExtractInput.mjs";
4
- export * from "./ExtractJsonInput.mjs";
5
- export * from "./ExtractMultipartInput.mjs";
6
3
  export * from "./ExtractOptions.mjs";
7
4
  export * from "./ExtractResponse.mjs";
5
+ export * from "./ExtractSource.mjs";
8
6
  export * from "./JobCancellationResponse.mjs";
9
7
  export * from "./JobStatus.mjs";
10
8
  export * from "./JobStatusResponse.mjs";
11
- export * from "./JsonSource.mjs";
12
- export * from "./MultipartSource.mjs";
@@ -1 +1,2 @@
1
+ export * from "./file/exports.mjs";
1
2
  export * from "./logging/exports.mjs";
@@ -1 +1,2 @@
1
+ export * from "./file/exports.mjs";
1
2
  export * from "./logging/exports.mjs";
@@ -0,0 +1 @@
1
+ export type { Uploadable } from "./types.mjs";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { Uploadable } from "./types.mjs";
2
+ export declare function toBinaryUploadRequest(file: Uploadable): Promise<{
3
+ body: Uploadable.FileLike;
4
+ headers?: Record<string, string>;
5
+ }>;
6
+ export declare function toMultipartDataPart(file: Uploadable): Promise<{
7
+ data: Uploadable.FileLike;
8
+ filename?: string;
9
+ contentType?: string;
10
+ }>;
@@ -0,0 +1,184 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export function toBinaryUploadRequest(file) {
11
+ return __awaiter(this, void 0, void 0, function* () {
12
+ const { data, filename, contentLength, contentType } = yield getFileWithMetadata(file);
13
+ const request = {
14
+ body: data,
15
+ headers: {},
16
+ };
17
+ if (filename) {
18
+ request.headers["Content-Disposition"] = `attachment; filename="${filename}"`;
19
+ }
20
+ if (contentType) {
21
+ request.headers["Content-Type"] = contentType;
22
+ }
23
+ if (contentLength != null) {
24
+ request.headers["Content-Length"] = contentLength.toString();
25
+ }
26
+ return request;
27
+ });
28
+ }
29
+ export function toMultipartDataPart(file) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const { data, filename, contentType } = yield getFileWithMetadata(file, {
32
+ noSniffFileSize: true,
33
+ });
34
+ return {
35
+ data,
36
+ filename,
37
+ contentType,
38
+ };
39
+ });
40
+ }
41
+ function getFileWithMetadata(file_1) {
42
+ return __awaiter(this, arguments, void 0, function* (file, { noSniffFileSize } = {}) {
43
+ var _a, _b, _c, _d, _e;
44
+ if (isFileLike(file)) {
45
+ return getFileWithMetadata({
46
+ data: file,
47
+ }, { noSniffFileSize });
48
+ }
49
+ if ("path" in file) {
50
+ const fs = yield import("fs");
51
+ if (!fs || !fs.createReadStream) {
52
+ throw new Error("File path uploads are not supported in this environment.");
53
+ }
54
+ const data = fs.createReadStream(file.path);
55
+ const contentLength = (_a = file.contentLength) !== null && _a !== void 0 ? _a : (noSniffFileSize === true ? undefined : yield tryGetFileSizeFromPath(file.path));
56
+ const filename = (_b = file.filename) !== null && _b !== void 0 ? _b : getNameFromPath(file.path);
57
+ return {
58
+ data,
59
+ filename,
60
+ contentType: file.contentType,
61
+ contentLength,
62
+ };
63
+ }
64
+ if ("data" in file) {
65
+ const data = file.data;
66
+ const contentLength = (_c = file.contentLength) !== null && _c !== void 0 ? _c : (yield tryGetContentLengthFromFileLike(data, {
67
+ noSniffFileSize,
68
+ }));
69
+ const filename = (_d = file.filename) !== null && _d !== void 0 ? _d : tryGetNameFromFileLike(data);
70
+ return {
71
+ data,
72
+ filename,
73
+ contentType: (_e = file.contentType) !== null && _e !== void 0 ? _e : tryGetContentTypeFromFileLike(data),
74
+ contentLength,
75
+ };
76
+ }
77
+ throw new Error(`Invalid FileUpload of type ${typeof file}: ${JSON.stringify(file)}`);
78
+ });
79
+ }
80
+ function isFileLike(value) {
81
+ return (isBuffer(value) ||
82
+ isArrayBufferView(value) ||
83
+ isArrayBuffer(value) ||
84
+ isUint8Array(value) ||
85
+ isBlob(value) ||
86
+ isFile(value) ||
87
+ isStreamLike(value) ||
88
+ isReadableStream(value));
89
+ }
90
+ function tryGetFileSizeFromPath(path) {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ try {
93
+ const fs = yield import("fs");
94
+ if (!fs || !fs.promises || !fs.promises.stat) {
95
+ return undefined;
96
+ }
97
+ const fileStat = yield fs.promises.stat(path);
98
+ return fileStat.size;
99
+ }
100
+ catch (_fallbackError) {
101
+ return undefined;
102
+ }
103
+ });
104
+ }
105
+ function tryGetNameFromFileLike(data) {
106
+ if (isNamedValue(data)) {
107
+ return data.name;
108
+ }
109
+ if (isPathedValue(data)) {
110
+ return getNameFromPath(data.path.toString());
111
+ }
112
+ return undefined;
113
+ }
114
+ function tryGetContentLengthFromFileLike(data_1) {
115
+ return __awaiter(this, arguments, void 0, function* (data, { noSniffFileSize } = {}) {
116
+ if (isBuffer(data)) {
117
+ return data.length;
118
+ }
119
+ if (isArrayBufferView(data)) {
120
+ return data.byteLength;
121
+ }
122
+ if (isArrayBuffer(data)) {
123
+ return data.byteLength;
124
+ }
125
+ if (isBlob(data)) {
126
+ return data.size;
127
+ }
128
+ if (isFile(data)) {
129
+ return data.size;
130
+ }
131
+ if (noSniffFileSize === true) {
132
+ return undefined;
133
+ }
134
+ if (isPathedValue(data)) {
135
+ return yield tryGetFileSizeFromPath(data.path.toString());
136
+ }
137
+ return undefined;
138
+ });
139
+ }
140
+ function tryGetContentTypeFromFileLike(data) {
141
+ if (isBlob(data)) {
142
+ return data.type;
143
+ }
144
+ if (isFile(data)) {
145
+ return data.type;
146
+ }
147
+ return undefined;
148
+ }
149
+ function getNameFromPath(path) {
150
+ const lastForwardSlash = path.lastIndexOf("/");
151
+ const lastBackSlash = path.lastIndexOf("\\");
152
+ const lastSlashIndex = Math.max(lastForwardSlash, lastBackSlash);
153
+ return lastSlashIndex >= 0 ? path.substring(lastSlashIndex + 1) : path;
154
+ }
155
+ function isNamedValue(value) {
156
+ return typeof value === "object" && value != null && "name" in value;
157
+ }
158
+ function isPathedValue(value) {
159
+ return typeof value === "object" && value != null && "path" in value;
160
+ }
161
+ function isStreamLike(value) {
162
+ return typeof value === "object" && value != null && ("read" in value || "pipe" in value);
163
+ }
164
+ function isReadableStream(value) {
165
+ return typeof value === "object" && value != null && "getReader" in value;
166
+ }
167
+ function isBuffer(value) {
168
+ return typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(value);
169
+ }
170
+ function isArrayBufferView(value) {
171
+ return typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView(value);
172
+ }
173
+ function isArrayBuffer(value) {
174
+ return typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer;
175
+ }
176
+ function isUint8Array(value) {
177
+ return typeof Uint8Array !== "undefined" && value instanceof Uint8Array;
178
+ }
179
+ function isBlob(value) {
180
+ return typeof Blob !== "undefined" && value instanceof Blob;
181
+ }
182
+ function isFile(value) {
183
+ return typeof File !== "undefined" && value instanceof File;
184
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./file.mjs";
2
+ export * from "./types.mjs";
@@ -0,0 +1,2 @@
1
+ export * from "./file.mjs";
2
+ export * from "./types.mjs";