@bedolla/enrivision 0.1.5 → 0.1.7
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/README.md +43 -9
- package/dist/client/EnriProxyClient.d.ts +296 -248
- package/dist/client/EnriProxyClient.d.ts.map +1 -1
- package/dist/client/EnriProxyClient.js +849 -119
- package/dist/client/EnriProxyClient.js.map +1 -1
- package/dist/client/EnriProxyClientContract.d.ts +478 -0
- package/dist/client/EnriProxyClientContract.d.ts.map +1 -0
- package/dist/client/EnriProxyClientContract.js +136 -0
- package/dist/client/EnriProxyClientContract.js.map +1 -0
- package/dist/index.js +23 -12
- package/dist/index.js.map +1 -1
- package/dist/package-info.d.ts +28 -0
- package/dist/package-info.d.ts.map +1 -1
- package/dist/package-info.js +28 -0
- package/dist/package-info.js.map +1 -1
- package/dist/server/EnriVisionServer.d.ts +186 -0
- package/dist/server/EnriVisionServer.d.ts.map +1 -1
- package/dist/server/EnriVisionServer.js +804 -94
- package/dist/server/EnriVisionServer.js.map +1 -1
- package/dist/shared/codepointTruncation.d.ts +61 -0
- package/dist/shared/codepointTruncation.d.ts.map +1 -0
- package/dist/shared/codepointTruncation.js +73 -0
- package/dist/shared/codepointTruncation.js.map +1 -0
- package/dist/shared/mediaUrlFetcher.d.ts +247 -9
- package/dist/shared/mediaUrlFetcher.d.ts.map +1 -1
- package/dist/shared/mediaUrlFetcher.js +712 -53
- package/dist/shared/mediaUrlFetcher.js.map +1 -1
- package/dist/shared/tar.d.ts +82 -2
- package/dist/shared/tar.d.ts.map +1 -1
- package/dist/shared/tar.js +106 -43
- package/dist/shared/tar.js.map +1 -1
- package/dist/shared/validation.d.ts +96 -2
- package/dist/shared/validation.d.ts.map +1 -1
- package/dist/shared/validation.js +169 -10
- package/dist/shared/validation.js.map +1 -1
- package/dist/tools/AnalyzeMediaContract.d.ts +462 -0
- package/dist/tools/AnalyzeMediaContract.d.ts.map +1 -0
- package/dist/tools/AnalyzeMediaContract.js +161 -0
- package/dist/tools/AnalyzeMediaContract.js.map +1 -0
- package/dist/tools/AnalyzeMediaExtractionSanitizer.d.ts +35 -0
- package/dist/tools/AnalyzeMediaExtractionSanitizer.d.ts.map +1 -0
- package/dist/tools/AnalyzeMediaExtractionSanitizer.js +214 -0
- package/dist/tools/AnalyzeMediaExtractionSanitizer.js.map +1 -0
- package/dist/tools/AnalyzeMediaInputResolver.d.ts +250 -0
- package/dist/tools/AnalyzeMediaInputResolver.d.ts.map +1 -0
- package/dist/tools/AnalyzeMediaInputResolver.js +430 -0
- package/dist/tools/AnalyzeMediaInputResolver.js.map +1 -0
- package/dist/tools/AnalyzeMediaParamParser.d.ts +307 -0
- package/dist/tools/AnalyzeMediaParamParser.d.ts.map +1 -0
- package/dist/tools/AnalyzeMediaParamParser.js +843 -0
- package/dist/tools/AnalyzeMediaParamParser.js.map +1 -0
- package/dist/tools/AnalyzeMediaResumableUploader.d.ts +244 -0
- package/dist/tools/AnalyzeMediaResumableUploader.d.ts.map +1 -0
- package/dist/tools/AnalyzeMediaResumableUploader.js +549 -0
- package/dist/tools/AnalyzeMediaResumableUploader.js.map +1 -0
- package/dist/tools/AnalyzeMediaTarPackager.d.ts +42 -0
- package/dist/tools/AnalyzeMediaTarPackager.d.ts.map +1 -0
- package/dist/tools/AnalyzeMediaTarPackager.js +245 -0
- package/dist/tools/AnalyzeMediaTarPackager.js.map +1 -0
- package/dist/tools/AnalyzeMediaTool.d.ts +156 -294
- package/dist/tools/AnalyzeMediaTool.d.ts.map +1 -1
- package/dist/tools/AnalyzeMediaTool.js +611 -457
- package/dist/tools/AnalyzeMediaTool.js.map +1 -1
- package/package.json +2 -1
|
@@ -2,102 +2,45 @@
|
|
|
2
2
|
* ENRIPROXY CLIENT
|
|
3
3
|
*
|
|
4
4
|
* Minimal HTTP client for EnriProxy endpoints used by EnriVision:
|
|
5
|
-
* - POST
|
|
6
|
-
* - HEAD
|
|
7
|
-
* - PATCH
|
|
8
|
-
* -
|
|
5
|
+
* - POST /v1/uploads
|
|
6
|
+
* - HEAD /v1/uploads/:id
|
|
7
|
+
* - PATCH /v1/uploads/:id
|
|
8
|
+
* - DELETE /v1/uploads/:id
|
|
9
|
+
* - POST /v1/vision/analyze
|
|
10
|
+
* - POST /v1/vision/segments
|
|
11
|
+
* - GET /v1/account/models
|
|
9
12
|
*
|
|
10
13
|
* @module client/EnriProxyClient
|
|
11
14
|
*/
|
|
15
|
+
import { type AnalyzeVisionParams, type AnalyzeVisionResponse, type AppendUploadChunkParams, type CreateUploadSessionParams, type CreateUploadSessionResponse, type EnriProxyClientConfig, type FetchSegmentPageParams, type SegmentPageResponse } from "./EnriProxyClientContract.js";
|
|
16
|
+
export { EnriProxyHttpError } from "./EnriProxyClientContract.js";
|
|
17
|
+
export type { AnalyzeVisionElement, AnalyzeVisionParams, AnalyzeVisionResponse, AppendUploadChunkParams, CreateUploadSessionParams, CreateUploadSessionResponse, FetchSegmentPageParams, EnriProxyAudioTuning, EnriProxyClientConfig, EnriProxyDocumentTuning, EnriProxyHttpResult, EnriProxyImageRegion, EnriProxyImagesTuning, EnriProxyVideoTuning, SegmentPageResponse, } from "./EnriProxyClientContract.js";
|
|
12
18
|
/**
|
|
13
|
-
*
|
|
19
|
+
* Timeout for upload session creation (`POST /v1/uploads`, 60 s).
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Mirrors EnriCode `VisionAnalyzeMediaUploadCoordinator` (60 s create
|
|
23
|
+
* budget): session creation is a tiny metadata call, but it deserves more
|
|
24
|
+
* headroom than offset probes. Capped by the operator timeout via `Math.min`.
|
|
14
25
|
*/
|
|
15
|
-
export
|
|
16
|
-
/**
|
|
17
|
-
* EnriProxy base URL (e.g., https://proxy.example.com).
|
|
18
|
-
*/
|
|
19
|
-
readonly baseUrl: string;
|
|
20
|
-
/**
|
|
21
|
-
* EnriProxy API key (sent as Authorization: Bearer ...).
|
|
22
|
-
*/
|
|
23
|
-
readonly apiKey: string;
|
|
24
|
-
/**
|
|
25
|
-
* Default request timeout in milliseconds.
|
|
26
|
-
*/
|
|
27
|
-
readonly timeoutMs: number;
|
|
28
|
-
}
|
|
26
|
+
export declare const CREATE_CONTROL_TIMEOUT_MS: number;
|
|
29
27
|
/**
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*/
|
|
36
|
-
readonly upload_id: string;
|
|
37
|
-
/**
|
|
38
|
-
* Recommended chunk size in bytes.
|
|
39
|
-
*/
|
|
40
|
-
readonly chunk_size_bytes: number;
|
|
41
|
-
/**
|
|
42
|
-
* Expiration timestamp in ms since epoch.
|
|
43
|
-
*/
|
|
44
|
-
readonly expires_at: number;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Response from POST `/v1/vision/analyze`.
|
|
28
|
+
* Timeout for upload offset probes (`HEAD /v1/uploads/:id`, 15 s).
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Mirrors EnriCode (15 s probe budget): offset queries are single-header
|
|
32
|
+
* reads and must fail fast. Capped by the operator timeout via `Math.min`.
|
|
48
33
|
*/
|
|
49
|
-
export
|
|
50
|
-
/**
|
|
51
|
-
* Text analysis.
|
|
52
|
-
*/
|
|
53
|
-
readonly analysis: string;
|
|
54
|
-
/**
|
|
55
|
-
* Grounded element boxes for image analyses (original-relative [0,1]).
|
|
56
|
-
*/
|
|
57
|
-
readonly elements?: ReadonlyArray<{
|
|
58
|
-
readonly label: string;
|
|
59
|
-
readonly box: {
|
|
60
|
-
readonly x: number;
|
|
61
|
-
readonly y: number;
|
|
62
|
-
readonly width: number;
|
|
63
|
-
readonly height: number;
|
|
64
|
-
};
|
|
65
|
-
}>;
|
|
66
|
-
/**
|
|
67
|
-
* Detected media type.
|
|
68
|
-
*/
|
|
69
|
-
readonly media_type: string;
|
|
70
|
-
/**
|
|
71
|
-
* Extraction metadata.
|
|
72
|
-
*/
|
|
73
|
-
readonly extraction: Record<string, unknown>;
|
|
74
|
-
}
|
|
34
|
+
export declare const PROBE_CONTROL_TIMEOUT_MS: number;
|
|
75
35
|
/**
|
|
76
|
-
*
|
|
36
|
+
* Budget for the fail-open vision-capability probe (`GET /v1/account/models`, 15 s).
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* Mirrors EnriCode `assertRemoteVisionCapable` and
|
|
40
|
+
* `ANALYZE_MEDIA_LIMITS.visionProbeTimeoutMs` (pinned equal by tests): the
|
|
41
|
+
* probe must never stall session creation.
|
|
77
42
|
*/
|
|
78
|
-
export declare
|
|
79
|
-
/**
|
|
80
|
-
* HTTP status code returned by the server.
|
|
81
|
-
*/
|
|
82
|
-
readonly status: number;
|
|
83
|
-
/**
|
|
84
|
-
* Response headers returned by the server.
|
|
85
|
-
*/
|
|
86
|
-
readonly headers: Record<string, string | string[] | undefined>;
|
|
87
|
-
/**
|
|
88
|
-
* Response body returned by the server (best-effort UTF-8).
|
|
89
|
-
*/
|
|
90
|
-
readonly body: string;
|
|
91
|
-
/**
|
|
92
|
-
* Creates a new {@link EnriProxyHttpError}.
|
|
93
|
-
*
|
|
94
|
-
* @param message - Error message
|
|
95
|
-
* @param status - HTTP status code
|
|
96
|
-
* @param headers - Response headers
|
|
97
|
-
* @param body - Response body
|
|
98
|
-
*/
|
|
99
|
-
constructor(message: string, status: number, headers: Record<string, string | string[] | undefined>, body: string);
|
|
100
|
-
}
|
|
43
|
+
export declare const ACCOUNT_MODELS_PROBE_TIMEOUT_MS: number;
|
|
101
44
|
/**
|
|
102
45
|
* Minimal client for EnriProxy HTTP endpoints.
|
|
103
46
|
*/
|
|
@@ -125,192 +68,295 @@ export declare class EnriProxyClient {
|
|
|
125
68
|
*
|
|
126
69
|
* @param params - Session parameters
|
|
127
70
|
* @returns Session response
|
|
71
|
+
* @throws Error with the parsed server detail when creation fails, or when the success body is not valid JSON.
|
|
128
72
|
*/
|
|
129
|
-
createUploadSession(params:
|
|
130
|
-
/**
|
|
131
|
-
* Original filename.
|
|
132
|
-
*/
|
|
133
|
-
readonly filename: string;
|
|
134
|
-
/**
|
|
135
|
-
* Total file size in bytes.
|
|
136
|
-
*/
|
|
137
|
-
readonly sizeBytes: number;
|
|
138
|
-
/**
|
|
139
|
-
* MIME type.
|
|
140
|
-
*/
|
|
141
|
-
readonly contentType: string;
|
|
142
|
-
/**
|
|
143
|
-
* Optional client trace id.
|
|
144
|
-
*/
|
|
145
|
-
readonly clientTraceId?: string;
|
|
146
|
-
}): Promise<CreateUploadSessionResponse>;
|
|
73
|
+
createUploadSession(params: CreateUploadSessionParams): Promise<CreateUploadSessionResponse>;
|
|
147
74
|
/**
|
|
148
75
|
* Queries the current upload offset for a session.
|
|
149
76
|
*
|
|
150
77
|
* @param uploadId - Upload id
|
|
78
|
+
* @param signal - Optional cancellation signal.
|
|
151
79
|
* @returns Offset in bytes
|
|
80
|
+
* @throws Error with the parsed server detail when the query fails.
|
|
152
81
|
*/
|
|
153
|
-
getUploadOffset(uploadId: string): Promise<number>;
|
|
82
|
+
getUploadOffset(uploadId: string, signal?: AbortSignal): Promise<number>;
|
|
83
|
+
/**
|
|
84
|
+
* Deletes an upload session and its stored bytes (best-effort orphan cleanup).
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* Mirrors `DELETE /v1/uploads/:id` on EnriProxy. Callers must invoke this
|
|
88
|
+
* with an independent timeout signal (never the already-cancelled caller
|
|
89
|
+
* signal) and swallow failures: cleanup must never mask the original
|
|
90
|
+
* upload/analysis error.
|
|
91
|
+
*
|
|
92
|
+
* @param uploadId - Upload id to delete.
|
|
93
|
+
* @param signal - Optional cancellation signal (prefer an independent timeout).
|
|
94
|
+
* @throws Error with an Spanish-first bilingual message when the server rejects the deletion.
|
|
95
|
+
*/
|
|
96
|
+
deleteUploadSession(uploadId: string, signal?: AbortSignal): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Fetches the account model catalog for the fail-open vision probe.
|
|
99
|
+
*
|
|
100
|
+
* @remarks
|
|
101
|
+
* Thin `GET /v1/account/models` reader for `AnalyzeMediaTool` (mirrors
|
|
102
|
+
* EnriCode `assertRemoteVisionCapable`): callers treat every failure as
|
|
103
|
+
* fail-open (proceed with the upload) and only reject on an explicit
|
|
104
|
+
* `vision === false` match, so a stale discovery snapshot never blocks a
|
|
105
|
+
* valid upload. Non-2xx responses throw {@link EnriProxyHttpError} (the
|
|
106
|
+
* caller uses the status to invalidate cached verdicts on 401/404);
|
|
107
|
+
* non-JSON 2xx bodies throw an Spanish-first bilingual error.
|
|
108
|
+
*
|
|
109
|
+
* @param signal - Optional cancellation signal.
|
|
110
|
+
* @returns Parsed response body.
|
|
111
|
+
* @throws Error with an Spanish-first bilingual message when the probe request fails.
|
|
112
|
+
*/
|
|
113
|
+
getAccountModels(signal?: AbortSignal): Promise<unknown>;
|
|
154
114
|
/**
|
|
155
115
|
* Appends a chunk to an upload session.
|
|
156
116
|
*
|
|
157
117
|
* @param params - Chunk parameters
|
|
158
118
|
* @returns New upload offset in bytes
|
|
159
119
|
*/
|
|
160
|
-
appendUploadChunk(params:
|
|
161
|
-
/**
|
|
162
|
-
* Upload session id.
|
|
163
|
-
*/
|
|
164
|
-
readonly uploadId: string;
|
|
165
|
-
/**
|
|
166
|
-
* Expected offset in bytes.
|
|
167
|
-
*/
|
|
168
|
-
readonly offset: number;
|
|
169
|
-
/**
|
|
170
|
-
* Chunk bytes.
|
|
171
|
-
*/
|
|
172
|
-
readonly chunk: Buffer;
|
|
173
|
-
/**
|
|
174
|
-
* Optional timeout override in milliseconds.
|
|
175
|
-
*/
|
|
176
|
-
readonly timeoutMs?: number;
|
|
177
|
-
}): Promise<number>;
|
|
120
|
+
appendUploadChunk(params: AppendUploadChunkParams): Promise<number>;
|
|
178
121
|
/**
|
|
179
122
|
* Triggers server-side vision analysis for an uploaded file.
|
|
180
123
|
*
|
|
181
124
|
* @param params - Analysis parameters
|
|
182
125
|
* @returns Analysis response
|
|
126
|
+
* @throws Error with the parsed server detail when analysis fails, or when the success body is not valid JSON.
|
|
127
|
+
*/
|
|
128
|
+
analyze(params: AnalyzeVisionParams): Promise<AnalyzeVisionResponse>;
|
|
129
|
+
/**
|
|
130
|
+
* Reads one continuation window over a truncated media list.
|
|
131
|
+
*
|
|
132
|
+
* @param params - Cursor plus optional offset/limit.
|
|
133
|
+
* @returns Page entries with totals and continuation state.
|
|
134
|
+
* @throws Error with a Spanish-first bilingual message on invalid
|
|
135
|
+
* cursors, expired cursors, or malformed responses.
|
|
136
|
+
*/
|
|
137
|
+
fetchSegmentPage(params: FetchSegmentPageParams): Promise<SegmentPageResponse>;
|
|
138
|
+
/**
|
|
139
|
+
* Validates one continuation page body.
|
|
140
|
+
*
|
|
141
|
+
* @param raw - Parsed response body.
|
|
142
|
+
* @returns Validated page.
|
|
143
|
+
* @throws Error with a Spanish-first bilingual message when the body
|
|
144
|
+
* carries no usable page.
|
|
145
|
+
*/
|
|
146
|
+
private static requireValidSegmentPage;
|
|
147
|
+
/**
|
|
148
|
+
* Rejects oversized prompt text before any byte is uploaded.
|
|
149
|
+
*
|
|
150
|
+
* @remarks
|
|
151
|
+
* Mirrors the parser gate (2000 chars): the server 400s after upload cost.
|
|
152
|
+
*
|
|
153
|
+
* @param value - Optional prompt text.
|
|
154
|
+
* @param fieldName - `question` or `context`.
|
|
155
|
+
* @throws Error in Spanish naming the 2000-character cap.
|
|
156
|
+
*/
|
|
157
|
+
private static requireBoundedPromptText;
|
|
158
|
+
/**
|
|
159
|
+
* Rejects mistyped tuning before any upload cost on the direct-client path.
|
|
160
|
+
*
|
|
161
|
+
* @remarks
|
|
162
|
+
* Mirrors `AnalyzeMediaParamParser` (enum, language pattern, section
|
|
163
|
+
* key closure): direct callers bypass the tool parser, and a typo would
|
|
164
|
+
* otherwise analyze the whole file at full cost. Exposed for reuse and
|
|
165
|
+
* unit-pinned against the parser key sets.
|
|
166
|
+
*
|
|
167
|
+
* @param params - Analysis parameters about to travel.
|
|
168
|
+
* @throws Error with a Spanish-first bilingual message on the first defect.
|
|
169
|
+
*/
|
|
170
|
+
static requirePreUploadTuning(params: AnalyzeVisionParams): void;
|
|
171
|
+
/**
|
|
172
|
+
* Validates one language hint against the parser pattern.
|
|
173
|
+
*
|
|
174
|
+
* @param value - Candidate hint.
|
|
175
|
+
* @param fieldName - Dotted field name for error messages.
|
|
176
|
+
* @returns Nothing.
|
|
177
|
+
* @throws Error with a Spanish-first bilingual message on mismatch.
|
|
178
|
+
*/
|
|
179
|
+
private static requireLanguageHint;
|
|
180
|
+
/**
|
|
181
|
+
* Rejects unknown keys inside one tuning section.
|
|
182
|
+
*
|
|
183
|
+
* @param section - Candidate section object.
|
|
184
|
+
* @param knownKeys - Parser-owned accepted spellings.
|
|
185
|
+
* @param sectionName - Section name for error messages.
|
|
186
|
+
* @returns Nothing.
|
|
187
|
+
* @throws Error with a Spanish-first bilingual message on unknown keys.
|
|
188
|
+
*/
|
|
189
|
+
private static requireKnownSectionKeys;
|
|
190
|
+
/**
|
|
191
|
+
* Rejects per-batch sizes exceeding their totals on the direct-client path.
|
|
192
|
+
*
|
|
193
|
+
* @remarks
|
|
194
|
+
* The tool parser already guards this; direct callers bypass it, and the
|
|
195
|
+
* server would truncate after paid multipass work.
|
|
196
|
+
*
|
|
197
|
+
* @param perBatch - Per-batch value, or undefined when absent.
|
|
198
|
+
* @param total - Total value, or undefined when absent.
|
|
199
|
+
* @param family - `document` or `images`.
|
|
200
|
+
* @throws Error with an Spanish-first bilingual message when the batch exceeds the total.
|
|
201
|
+
*/
|
|
202
|
+
private static throwOnBatchExceedingTotal;
|
|
203
|
+
/**
|
|
204
|
+
* Coerces an optional integer tuning knob, failing loudly on garbage.
|
|
205
|
+
*
|
|
206
|
+
* @remarks
|
|
207
|
+
* Parity with `AnalyzeMediaParamParser` (`optionalInt` accepts `"60"`):
|
|
208
|
+
* integers and complete integer strings travel floored; any other present
|
|
209
|
+
* value throws bilingually instead of being silently dropped (a dropped
|
|
210
|
+
* knob would analyze the whole file at full cost with default tuning).
|
|
211
|
+
*
|
|
212
|
+
* @param raw - Raw knob value.
|
|
213
|
+
* @param fieldName - Dotted field name for error messages.
|
|
214
|
+
* @param min - Inclusive minimum (shares the parser range table so direct
|
|
215
|
+
* callers fail pre-upload like parser-gated calls).
|
|
216
|
+
* @param max - Inclusive maximum (shares the parser range table).
|
|
217
|
+
* @returns Floored integer, or undefined when absent.
|
|
218
|
+
* @throws Error with an Spanish-first bilingual message when present but not an integer within range.
|
|
219
|
+
*/
|
|
220
|
+
private static requireOptionalInt;
|
|
221
|
+
/**
|
|
222
|
+
* Coerces an optional float tuning knob, failing loudly on garbage.
|
|
223
|
+
*
|
|
224
|
+
* @remarks
|
|
225
|
+
* Parity with `AnalyzeMediaParamParser` (`optionalNumber` accepts
|
|
226
|
+
* `"12.5"`): numbers and complete numeric strings travel; any other
|
|
227
|
+
* present value throws bilingually instead of being silently dropped.
|
|
228
|
+
*
|
|
229
|
+
* @param raw - Raw knob value.
|
|
230
|
+
* @param fieldName - Dotted field name for error messages.
|
|
231
|
+
* @param min - Inclusive minimum (shares the parser range table).
|
|
232
|
+
* @param max - Inclusive maximum (shares the parser range table).
|
|
233
|
+
* @returns Finite number, or undefined when absent.
|
|
234
|
+
* @throws Error with an Spanish-first bilingual message when present but not a number within range.
|
|
235
|
+
*/
|
|
236
|
+
private static requireOptionalNumber;
|
|
237
|
+
/**
|
|
238
|
+
* Coerces an optional boolean tuning knob, failing loudly on garbage.
|
|
239
|
+
*
|
|
240
|
+
* @remarks
|
|
241
|
+
* Parity with `AnalyzeMediaParamParser` (`assertOptionalBoolean` accepts
|
|
242
|
+
* `"true"`/`"false"`): booleans and true/false strings travel; any
|
|
243
|
+
* other present value throws bilingually instead of being silently dropped.
|
|
244
|
+
*
|
|
245
|
+
* @param raw - Raw knob value.
|
|
246
|
+
* @param fieldName - Dotted field name for error messages.
|
|
247
|
+
* @returns Boolean, or undefined when absent.
|
|
248
|
+
* @throws Error with an Spanish-first bilingual message when present but not a boolean.
|
|
249
|
+
*/
|
|
250
|
+
private static requireOptionalBoolean;
|
|
251
|
+
/**
|
|
252
|
+
* Resolves the `transcribe` knob, defaulting to true like EnriCode.
|
|
253
|
+
*
|
|
254
|
+
* @remarks
|
|
255
|
+
* A `"false"` string must never collapse to the `true` default (that
|
|
256
|
+
* would pay a full transcription the caller explicitly disabled):
|
|
257
|
+
* true/false strings coerce, anything else present throws in Spanish.
|
|
258
|
+
*
|
|
259
|
+
* @param raw - Raw transcribe value.
|
|
260
|
+
* @returns Resolved transcribe flag.
|
|
261
|
+
* @throws Error with an Spanish-first bilingual message when present but not a boolean nor a true/false string.
|
|
183
262
|
*/
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
readonly video?: {
|
|
230
|
-
/**
|
|
231
|
-
* Clip start offset in seconds for targeted analysis.
|
|
232
|
-
*/
|
|
233
|
-
readonly clipStartSeconds?: number;
|
|
234
|
-
/**
|
|
235
|
-
* Clip duration in seconds for targeted analysis.
|
|
236
|
-
*/
|
|
237
|
-
readonly clipDurationSeconds?: number;
|
|
238
|
-
/**
|
|
239
|
-
* Segment duration in seconds.
|
|
240
|
-
*/
|
|
241
|
-
readonly segmentSeconds?: number;
|
|
242
|
-
/**
|
|
243
|
-
* Maximum number of segments to analyze.
|
|
244
|
-
*/
|
|
245
|
-
readonly maxSegments?: number;
|
|
246
|
-
/**
|
|
247
|
-
* Maximum frames per segment.
|
|
248
|
-
*/
|
|
249
|
-
readonly maxFramesPerSegment?: number;
|
|
250
|
-
};
|
|
251
|
-
/**
|
|
252
|
-
* Optional document multipass tuning (PDF).
|
|
253
|
-
*/
|
|
254
|
-
readonly document?: {
|
|
255
|
-
/**
|
|
256
|
-
* Maximum pages to analyze in total.
|
|
257
|
-
*/
|
|
258
|
-
readonly maxPagesTotal?: number;
|
|
259
|
-
/**
|
|
260
|
-
* Pages per batch.
|
|
261
|
-
*/
|
|
262
|
-
readonly pagesPerBatch?: number;
|
|
263
|
-
/**
|
|
264
|
-
* Maximum rendered pages per batch.
|
|
265
|
-
*/
|
|
266
|
-
readonly maxImagesPerBatch?: number;
|
|
267
|
-
/**
|
|
268
|
-
* Minimum extracted text length to treat a page as textual.
|
|
269
|
-
*/
|
|
270
|
-
readonly scannedTextThresholdChars?: number;
|
|
271
|
-
};
|
|
272
|
-
/**
|
|
273
|
-
* Optional audio multipass tuning.
|
|
274
|
-
*/
|
|
275
|
-
readonly audio?: {
|
|
276
|
-
/**
|
|
277
|
-
* Whether to include timestamped segments in the extracted transcript.
|
|
278
|
-
*/
|
|
279
|
-
readonly timestamps?: boolean;
|
|
280
|
-
/**
|
|
281
|
-
* Segment duration in seconds for audio multipass.
|
|
282
|
-
*/
|
|
283
|
-
readonly segmentSeconds?: number;
|
|
284
|
-
/**
|
|
285
|
-
* Maximum number of audio segments to analyze.
|
|
286
|
-
*/
|
|
287
|
-
readonly maxSegments?: number;
|
|
288
|
-
};
|
|
289
|
-
/**
|
|
290
|
-
* Optional image-set multipass tuning.
|
|
291
|
-
*/
|
|
292
|
-
readonly images?: {
|
|
293
|
-
/**
|
|
294
|
-
* Maximum number of images to analyze in total.
|
|
295
|
-
*/
|
|
296
|
-
readonly maxImagesTotal?: number;
|
|
297
|
-
/**
|
|
298
|
-
* Images per batch for multipass map calls.
|
|
299
|
-
*/
|
|
300
|
-
readonly imagesPerBatch?: number;
|
|
301
|
-
/**
|
|
302
|
-
* Maximum dimension for images (width/height).
|
|
303
|
-
*/
|
|
304
|
-
readonly maxDimension?: number;
|
|
305
|
-
};
|
|
306
|
-
}): Promise<AnalyzeVisionResponse>;
|
|
263
|
+
private static requireTranscribe;
|
|
264
|
+
/**
|
|
265
|
+
* Validates a `POST /v1/vision/analyze` response body for third-party callers.
|
|
266
|
+
*
|
|
267
|
+
* @remarks
|
|
268
|
+
* A malformed 200 body (`{}`, `analysis: 123`, missing `media_type`)
|
|
269
|
+
* must surface as a Spanish coaching error, never as an English
|
|
270
|
+
* `TypeError` from downstream formatters (model-facing text is always
|
|
271
|
+
* Spanish). Malformed `elements` entries are sanitized (dropped), not
|
|
272
|
+
* fatal: partial grounding still analyzes.
|
|
273
|
+
*
|
|
274
|
+
* @param raw - Parsed response body.
|
|
275
|
+
* @returns Validated analysis response.
|
|
276
|
+
* @throws Error with an Spanish-first bilingual message when the body shape is invalid.
|
|
277
|
+
*/
|
|
278
|
+
private static requireValidAnalyzeResponse;
|
|
279
|
+
/**
|
|
280
|
+
* Keeps only well-formed grounded element boxes.
|
|
281
|
+
*
|
|
282
|
+
* @remarks
|
|
283
|
+
* Malformed entries (non-string label, non-finite box coordinates) are
|
|
284
|
+
* dropped so one bad box never fails the whole analysis; downstream
|
|
285
|
+
* formatters can assume `{label, box: {x, y, width, height}}`.
|
|
286
|
+
*
|
|
287
|
+
* @param elements - Raw elements array from the server.
|
|
288
|
+
* @returns Sanitized element boxes.
|
|
289
|
+
*/
|
|
290
|
+
private static sanitizeAnalyzeElements;
|
|
291
|
+
/**
|
|
292
|
+
* Builds an {@link EnriProxyHttpError} embedding the parsed server detail.
|
|
293
|
+
*
|
|
294
|
+
* @param baseMessage - Base message naming the failed operation with its HTTP status.
|
|
295
|
+
* @param result - Raw HTTP result carrying headers and body.
|
|
296
|
+
* @returns HTTP error preserving status, headers, and body.
|
|
297
|
+
*/
|
|
298
|
+
private static buildHttpError;
|
|
299
|
+
/**
|
|
300
|
+
* Parses a 2xx JSON body with a bilingual guard for non-JSON payloads.
|
|
301
|
+
*
|
|
302
|
+
* @param body - Raw response body.
|
|
303
|
+
* @param status - HTTP status code (reported in the error).
|
|
304
|
+
* @returns Parsed body.
|
|
305
|
+
* @throws Error with an Spanish-first bilingual message when the body is not valid JSON.
|
|
306
|
+
*/
|
|
307
|
+
private static parseJsonBody;
|
|
307
308
|
/**
|
|
308
309
|
* Builds an absolute URL relative to the configured base URL.
|
|
309
310
|
*
|
|
310
|
-
* @
|
|
311
|
+
* @remarks
|
|
312
|
+
* The base subpath is preserved (`http://host/proxy` + `/v1/uploads` =
|
|
313
|
+
* `http://host/proxy/v1/uploads`): `new URL(path, base)` alone would
|
|
314
|
+
* discard it. A root base keeps working exactly as before.
|
|
315
|
+
*
|
|
316
|
+
* @param pathname - Pathname to append (must start with `/`).
|
|
311
317
|
* @returns URL instance
|
|
318
|
+
* @throws Error with an Spanish-first bilingual message when the configured base URL is malformed.
|
|
312
319
|
*/
|
|
313
320
|
private buildUrl;
|
|
321
|
+
/**
|
|
322
|
+
* Parses a strict `Upload-Offset` response header.
|
|
323
|
+
*
|
|
324
|
+
* @remarks
|
|
325
|
+
* Strict by design: only `^\d+$` (after trimming) is accepted, so
|
|
326
|
+
* `"12abc"` or `"1.5"` fail bilingually instead of being prefix-parsed
|
|
327
|
+
* (`parseInt("12abc") === 12`) and resuming at a wrong offset.
|
|
328
|
+
*
|
|
329
|
+
* @param headers - Response headers.
|
|
330
|
+
* @returns Offset in bytes.
|
|
331
|
+
* @throws Error with an Spanish-first bilingual message when the header is missing or malformed.
|
|
332
|
+
*/
|
|
333
|
+
private parseUploadOffsetHeader;
|
|
334
|
+
/**
|
|
335
|
+
* Validates a relative image region for native-resolution zoom.
|
|
336
|
+
*
|
|
337
|
+
* @remarks
|
|
338
|
+
* Mirrors the `AnalyzeMediaParamParser` region contract (`[0,1]` bounds,
|
|
339
|
+
* positive size, `x+width<=1`/`y+height<=1`, complete numeric strings
|
|
340
|
+
* coerced via `optionalFraction`) so direct client callers get the same
|
|
341
|
+
* Spanish coaching instead of a late server rejection.
|
|
342
|
+
*
|
|
343
|
+
* @param region - Raw region value.
|
|
344
|
+
* @returns Validated region payload.
|
|
345
|
+
* @throws Error with an Spanish-first bilingual message when the region is malformed or out of range.
|
|
346
|
+
*/
|
|
347
|
+
private static requireValidRegion;
|
|
348
|
+
/**
|
|
349
|
+
* Resolves the session-creation control timeout (60 s, mirrors EnriCode).
|
|
350
|
+
*
|
|
351
|
+
* @returns Control timeout in milliseconds (never above 60 s).
|
|
352
|
+
*/
|
|
353
|
+
private createControlTimeoutMs;
|
|
354
|
+
/**
|
|
355
|
+
* Resolves the offset-probe control timeout (15 s, mirrors EnriCode).
|
|
356
|
+
*
|
|
357
|
+
* @returns Control timeout in milliseconds (never above 15 s).
|
|
358
|
+
*/
|
|
359
|
+
private probeControlTimeoutMs;
|
|
314
360
|
/**
|
|
315
361
|
* Extracts a response header as a single string.
|
|
316
362
|
*
|
|
@@ -326,6 +372,7 @@ export declare class EnriProxyClient {
|
|
|
326
372
|
* @param url - Target URL
|
|
327
373
|
* @param jsonBody - JSON payload
|
|
328
374
|
* @param timeoutMs - Timeout in milliseconds
|
|
375
|
+
* @param signal - Optional cancellation signal.
|
|
329
376
|
* @returns HTTP result
|
|
330
377
|
*/
|
|
331
378
|
private requestJson;
|
|
@@ -337,6 +384,7 @@ export declare class EnriProxyClient {
|
|
|
337
384
|
* @param headers - Request headers
|
|
338
385
|
* @param body - Request body
|
|
339
386
|
* @param timeoutMs - Timeout in milliseconds
|
|
387
|
+
* @param signal - Optional cancellation signal; aborts with a Spanish error.
|
|
340
388
|
* @returns HTTP result
|
|
341
389
|
*/
|
|
342
390
|
private requestRaw;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnriProxyClient.d.ts","sourceRoot":"","sources":["../../src/client/EnriProxyClient.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"EnriProxyClient.d.ts","sourceRoot":"","sources":["../../src/client/EnriProxyClient.ts"],"names":[],"mappings":"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"}
|