@doclo/core 0.2.2 → 0.2.4
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 +16 -15
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -12
- package/dist/index.js.map +1 -1
- package/dist/internal/validation-utils.d.ts +1 -1
- package/dist/internal/validation-utils.js +1 -1
- package/dist/internal/validation-utils.js.map +1 -1
- package/dist/pdf-utils.d.ts +12 -7
- package/dist/pdf-utils.js +10 -11
- package/dist/pdf-utils.js.map +1 -1
- package/dist/{validation-BQO54qAY.d.ts → validation-C_RN-Xqr.d.ts} +35 -8
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
# @doclo/core
|
|
2
2
|
|
|
3
|
-
Core types, utilities, and
|
|
3
|
+
Core types, utilities, and runtime features for the Doclo SDK.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @doclo/core
|
|
9
|
-
# or
|
|
10
8
|
pnpm add @doclo/core
|
|
11
9
|
```
|
|
12
10
|
|
|
13
11
|
## Features
|
|
14
12
|
|
|
15
|
-
- Core type definitions
|
|
16
|
-
-
|
|
13
|
+
- Core type definitions (DocumentIR, FlowInput, providers)
|
|
14
|
+
- Validation utilities (JSON schema validation, node compatibility)
|
|
15
|
+
- Security utilities (SSRF protection, safe JSON parsing)
|
|
17
16
|
- Runtime utilities (crypto, base64, environment detection)
|
|
18
|
-
-
|
|
19
|
-
-
|
|
17
|
+
- PDF utilities (page counting, splitting)
|
|
18
|
+
- Observability helpers (tracing, metrics)
|
|
20
19
|
|
|
21
20
|
## Exports
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
| Export Path | Description |
|
|
23
|
+
|-------------|-------------|
|
|
24
|
+
| `.` | Core types, validation, file utilities |
|
|
25
|
+
| `./validation` | Input validation utilities |
|
|
26
|
+
| `./security` | SSRF protection, fetchWithTimeout, safeJsonParse |
|
|
27
|
+
| `./observability` | Tracing and metrics hooks |
|
|
28
|
+
| `./runtime/crypto` | Cryptographic utilities |
|
|
29
|
+
| `./runtime/base64` | Base64 encoding/decoding |
|
|
30
|
+
| `./runtime/env` | Environment detection |
|
|
31
|
+
| `./pdf-utils` | PDF manipulation utilities |
|
|
31
32
|
|
|
32
33
|
## License
|
|
33
34
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as ProviderVendor, A as AccessMethod } from './validation-
|
|
2
|
-
export { G as AggregatedMetrics, B as BBox, r as CategorizeNodeConfig, t as ChunkMetadata, v as ChunkNodeConfig, u as ChunkOutput, n as CitationConfig, k as CitationSourceType, w as CombineNodeConfig,
|
|
1
|
+
import { P as ProviderVendor, A as AccessMethod } from './validation-C_RN-Xqr.js';
|
|
2
|
+
export { G as AggregatedMetrics, B as BBox, r as CategorizeNodeConfig, t as ChunkMetadata, v as ChunkNodeConfig, u as ChunkOutput, n as CitationConfig, k as CitationSourceType, w as CombineNodeConfig, W as CompatibilityRule, C as ConsensusConfig, e as ConsensusMetadata, d as ConsensusRunResult, D as DocumentIR, b as DocumentIRExtras, y as EnhancedExtractionSchema, s as ExtractInputMode, E as ExtractNodeConfig, a1 as ExtractedImage, m as FieldCitation, F as FieldVotingDetails, H as FlowContext, a9 as FlowExecutionError, h as FlowInput, i as FlowInputValidation, j as FlowResult, a5 as FlowStepLocation, aa as FlowValidationError, I as IRLine, a as IRPage, Y as JSONSchemaNode, c as LLMJsonProvider, L as LLMProvider, $ as LanguageOptions, l as LineCitation, g as MaybeWithConsensusMetadata, M as MultimodalInput, ab as NODE_COMPATIBILITY_MATRIX, J as NodeCtx, Q as NodeDef, K as NodeTypeInfo, U as NodeTypeName, N as NormalizedBBox, O as OCRProvider, a2 as OCRProviderOptions, x as OutputNodeConfig, o as OutputWithCitations, f as OutputWithConsensus, _ as PageRangeOptions, p as ParseNodeConfig, Z as ProcessingMode, a4 as ProviderCitation, an as ProviderIdentity, ak as RESERVED_VARIABLES, R as ReasoningConfig, a0 as SegmentationResult, S as SplitDocument, q as SplitNodeConfig, z as StepMetric, T as TextResponse, V as VLMProvider, a3 as VLMProviderOptions, X as ValidationResult, a6 as aggregateMetrics, ai as canStartForEachItemFlow, ar as createIdentity, am as extractErrorMessage, ae as getCompatibleTargets, ad as getNodeTypeInfo, ac as getNodeTypeName, af as getSuggestedConnections, ah as getValidForEachStarters, aq as isLocalEndpoint, a7 as node, ap as parseProviderString, al as protectReservedVariables, a8 as runPipeline, ao as toProviderString, aj as validateJson, ag as validateNodeConnection } from './validation-C_RN-Xqr.js';
|
|
3
3
|
export { getDocumentPageCount, getPDFPageCount, getPageCountMetadata, getTotalPageCount, splitPDFIntoChunks } from './pdf-utils.js';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -610,7 +610,7 @@ function validateJson(data, schema) {
|
|
|
610
610
|
const dangerousProps = ["__proto__", "constructor", "prototype"];
|
|
611
611
|
if (schema2.additionalProperties === false && schema2.properties) {
|
|
612
612
|
const allowedProps = Object.keys(schema2.properties);
|
|
613
|
-
const requiredProps = schema2.required
|
|
613
|
+
const requiredProps = Array.isArray(schema2.required) ? schema2.required : [];
|
|
614
614
|
const allAllowedProps = /* @__PURE__ */ new Set([...allowedProps, ...requiredProps]);
|
|
615
615
|
for (const key of [...Object.keys(value), ...Object.getOwnPropertyNames(value)]) {
|
|
616
616
|
if (dangerousProps.includes(key)) {
|
|
@@ -1204,22 +1204,21 @@ function validateFlowInputFormat(input, acceptedFormats) {
|
|
|
1204
1204
|
|
|
1205
1205
|
// src/pdf-utils.ts
|
|
1206
1206
|
import { PDFDocument } from "pdf-lib";
|
|
1207
|
-
|
|
1208
|
-
const
|
|
1209
|
-
if (
|
|
1210
|
-
|
|
1207
|
+
function extractPDFBase64(input) {
|
|
1208
|
+
const dataUrlMatch = input.match(/^data:application\/pdf;base64,(.+)$/);
|
|
1209
|
+
if (dataUrlMatch) {
|
|
1210
|
+
return dataUrlMatch[1];
|
|
1211
1211
|
}
|
|
1212
|
-
|
|
1212
|
+
return input;
|
|
1213
|
+
}
|
|
1214
|
+
async function getPDFPageCount(input) {
|
|
1215
|
+
const base64Data = extractPDFBase64(input);
|
|
1213
1216
|
const pdfBytes = base64ToArrayBuffer(base64Data);
|
|
1214
1217
|
const pdfDoc = await PDFDocument.load(pdfBytes);
|
|
1215
1218
|
return pdfDoc.getPageCount();
|
|
1216
1219
|
}
|
|
1217
|
-
async function splitPDFIntoChunks(
|
|
1218
|
-
const
|
|
1219
|
-
if (!base64Match) {
|
|
1220
|
-
throw new Error("Invalid PDF data URL format. Expected: data:application/pdf;base64,{base64data}");
|
|
1221
|
-
}
|
|
1222
|
-
const base64Data = base64Match[1];
|
|
1220
|
+
async function splitPDFIntoChunks(input, pageRanges) {
|
|
1221
|
+
const base64Data = extractPDFBase64(input);
|
|
1223
1222
|
const pdfBytes = base64ToArrayBuffer(base64Data);
|
|
1224
1223
|
const pdfDoc = await PDFDocument.load(pdfBytes);
|
|
1225
1224
|
const totalPages = pdfDoc.getPageCount();
|