@uploadista/flow-documents-unpdf 0.0.18-beta.9 → 0.0.18

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.
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @uploadista/flow-documents-unpdf@0.0.18-beta.8 build /Users/denislaboureyras/Documents/uploadista/dev/uploadista-workspace/uploadista-sdk/packages/flow/documents/unpdf
3
+ > @uploadista/flow-documents-unpdf@0.0.18-beta.17 build /Users/denislaboureyras/Documents/uploadista/dev/uploadista-workspace/uploadista-sdk/packages/flow/documents/unpdf
4
4
  > tsdown
5
5
 
6
6
  ℹ tsdown v0.16.8 powered by rolldown v1.0.0-beta.52
@@ -8,9 +8,17 @@
8
8
  ℹ tsconfig: tsconfig.json
9
9
  ℹ Build start
10
10
  ℹ Cleaning 4 files
11
- ℹ dist/index.mjs 2.25 kB │ gzip: 0.76 kB
12
- ℹ dist/index.mjs.map 4.30 kB │ gzip: 1.27 kB
11
+ ℹ dist/index.mjs 2.41 kB │ gzip: 0.83 kB
12
+ ℹ dist/index.mjs.map 4.58 kB │ gzip: 1.38 kB
13
13
  ℹ dist/index.d.mts.map 0.18 kB │ gzip: 0.15 kB
14
14
  ℹ dist/index.d.mts 0.39 kB │ gzip: 0.21 kB
15
- ℹ 4 files, total: 7.12 kB
16
- ✔ Build complete in 5465ms
15
+ ℹ 4 files, total: 7.56 kB
16
+ [UNRESOLVED_IMPORT] Warning: Could not resolve '@uploadista/observability' in src/document-plugin.ts
17
+ ╭─[ src/document-plugin.ts:3:35 ]
18
+ │
19
+ 3 │ import { withOperationSpan } from "@uploadista/observability";
20
+  │ ─────────────┬─────────────
21
+  │ ╰─────────────── Module not found, treating it as an external dependency
22
+ ───╯
23
+
24
+ ✔ Build complete in 4744ms
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/document-plugin.ts"],"sourcesContent":[],"mappings":";;;;cAKa,qBAAmB,KAAA,CAAA,MAAA;cAqFnB,yBAAuB,KAAA,CAAA,MAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/document-plugin.ts"],"sourcesContent":[],"mappings":";;;;cAMa,qBAAmB,KAAA,CAAA,MAAA;cAyFnB,yBAAuB,KAAA,CAAA,MAAA"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { UploadistaError } from "@uploadista/core/errors";
2
2
  import { DocumentPlugin } from "@uploadista/core/flow";
3
+ import { withOperationSpan } from "@uploadista/observability";
3
4
  import { Effect, Layer } from "effect";
4
5
  import { extractText } from "unpdf";
5
6
 
@@ -20,7 +21,7 @@ const unpdfDocumentPlugin = Layer.succeed(DocumentPlugin, DocumentPlugin.of({
20
21
  });
21
22
  if (!text || text.trim().length === 0) yield* Effect.logWarning("No text extracted from PDF. This might be a scanned document or image-based PDF. Consider using OCR instead.");
22
23
  return text;
23
- });
24
+ }).pipe(withOperationSpan("document", "extract-text", { "document.input_size": input.byteLength }));
24
25
  },
25
26
  getMetadata: () => {
26
27
  return Effect.gen(function* () {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/document-plugin.ts"],"sourcesContent":["import { UploadistaError } from \"@uploadista/core/errors\";\nimport { DocumentPlugin } from \"@uploadista/core/flow\";\nimport { Effect, Layer } from \"effect\";\nimport { extractText } from \"unpdf\";\n\nexport const unpdfDocumentPlugin = Layer.succeed(\n DocumentPlugin,\n DocumentPlugin.of({\n extractText: (input) => {\n return Effect.gen(function* () {\n const text = yield* Effect.tryPromise({\n try: async () => {\n const result = await extractText(input, {\n mergePages: true,\n });\n return result.text;\n },\n catch: (error) => {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n\n if (\n errorMessage.toLowerCase().includes(\"encrypt\") ||\n errorMessage.toLowerCase().includes(\"password\")\n ) {\n return UploadistaError.fromCode(\"PDF_ENCRYPTED\", {\n cause: errorMessage,\n });\n }\n\n if (\n errorMessage.toLowerCase().includes(\"corrupt\") ||\n errorMessage.toLowerCase().includes(\"invalid\") ||\n errorMessage.toLowerCase().includes(\"malformed\")\n ) {\n return UploadistaError.fromCode(\"PDF_CORRUPTED\", {\n cause: errorMessage,\n });\n }\n\n return UploadistaError.fromCode(\"DOCUMENT_PROCESSING_FAILED\", {\n cause: errorMessage,\n });\n },\n });\n\n // If no text was extracted, log a warning\n if (!text || text.trim().length === 0) {\n yield* Effect.logWarning(\n \"No text extracted from PDF. This might be a scanned document or image-based PDF. Consider using OCR instead.\",\n );\n }\n\n return text;\n });\n },\n\n getMetadata: () => {\n return Effect.gen(function* () {\n // unpdf doesn't support metadata extraction\n // Return an error indicating that pdf-lib should be used instead\n return yield* UploadistaError.fromCode(\"DOCUMENT_PROCESSING_FAILED\", {\n cause:\n \"unpdf does not support metadata extraction. Use @uploadista/flow-documents-pdflib instead.\",\n }).toEffect();\n });\n },\n\n splitPdf: () => {\n return Effect.gen(function* () {\n // unpdf doesn't support PDF splitting\n return yield* UploadistaError.fromCode(\"DOCUMENT_PROCESSING_FAILED\", {\n cause:\n \"unpdf does not support PDF splitting. Use @uploadista/flow-documents-pdflib instead.\",\n }).toEffect();\n });\n },\n\n mergePdfs: () => {\n return Effect.gen(function* () {\n // unpdf doesn't support PDF merging\n return yield* UploadistaError.fromCode(\"DOCUMENT_PROCESSING_FAILED\", {\n cause:\n \"unpdf does not support PDF merging. Use @uploadista/flow-documents-pdflib instead.\",\n }).toEffect();\n });\n },\n }),\n);\n\nexport const UnpdfDocumentPluginLive = unpdfDocumentPlugin;\n"],"mappings":";;;;;;AAKA,MAAa,sBAAsB,MAAM,QACvC,gBACA,eAAe,GAAG;CAChB,cAAc,UAAU;AACtB,SAAO,OAAO,IAAI,aAAa;GAC7B,MAAM,OAAO,OAAO,OAAO,WAAW;IACpC,KAAK,YAAY;AAIf,aAHe,MAAM,YAAY,OAAO,EACtC,YAAY,MACb,CAAC,EACY;;IAEhB,QAAQ,UAAU;KAChB,MAAM,eACJ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAExD,SACE,aAAa,aAAa,CAAC,SAAS,UAAU,IAC9C,aAAa,aAAa,CAAC,SAAS,WAAW,CAE/C,QAAO,gBAAgB,SAAS,iBAAiB,EAC/C,OAAO,cACR,CAAC;AAGJ,SACE,aAAa,aAAa,CAAC,SAAS,UAAU,IAC9C,aAAa,aAAa,CAAC,SAAS,UAAU,IAC9C,aAAa,aAAa,CAAC,SAAS,YAAY,CAEhD,QAAO,gBAAgB,SAAS,iBAAiB,EAC/C,OAAO,cACR,CAAC;AAGJ,YAAO,gBAAgB,SAAS,8BAA8B,EAC5D,OAAO,cACR,CAAC;;IAEL,CAAC;AAGF,OAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,WAAW,EAClC,QAAO,OAAO,WACZ,+GACD;AAGH,UAAO;IACP;;CAGJ,mBAAmB;AACjB,SAAO,OAAO,IAAI,aAAa;AAG7B,UAAO,OAAO,gBAAgB,SAAS,8BAA8B,EACnE,OACE,8FACH,CAAC,CAAC,UAAU;IACb;;CAGJ,gBAAgB;AACd,SAAO,OAAO,IAAI,aAAa;AAE7B,UAAO,OAAO,gBAAgB,SAAS,8BAA8B,EACnE,OACE,wFACH,CAAC,CAAC,UAAU;IACb;;CAGJ,iBAAiB;AACf,SAAO,OAAO,IAAI,aAAa;AAE7B,UAAO,OAAO,gBAAgB,SAAS,8BAA8B,EACnE,OACE,sFACH,CAAC,CAAC,UAAU;IACb;;CAEL,CAAC,CACH;AAED,MAAa,0BAA0B"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/document-plugin.ts"],"sourcesContent":["import { UploadistaError } from \"@uploadista/core/errors\";\nimport { DocumentPlugin } from \"@uploadista/core/flow\";\nimport { withOperationSpan } from \"@uploadista/observability\";\nimport { Effect, Layer } from \"effect\";\nimport { extractText } from \"unpdf\";\n\nexport const unpdfDocumentPlugin = Layer.succeed(\n DocumentPlugin,\n DocumentPlugin.of({\n extractText: (input) => {\n return Effect.gen(function* () {\n const text = yield* Effect.tryPromise({\n try: async () => {\n const result = await extractText(input, {\n mergePages: true,\n });\n return result.text;\n },\n catch: (error) => {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n\n if (\n errorMessage.toLowerCase().includes(\"encrypt\") ||\n errorMessage.toLowerCase().includes(\"password\")\n ) {\n return UploadistaError.fromCode(\"PDF_ENCRYPTED\", {\n cause: errorMessage,\n });\n }\n\n if (\n errorMessage.toLowerCase().includes(\"corrupt\") ||\n errorMessage.toLowerCase().includes(\"invalid\") ||\n errorMessage.toLowerCase().includes(\"malformed\")\n ) {\n return UploadistaError.fromCode(\"PDF_CORRUPTED\", {\n cause: errorMessage,\n });\n }\n\n return UploadistaError.fromCode(\"DOCUMENT_PROCESSING_FAILED\", {\n cause: errorMessage,\n });\n },\n });\n\n // If no text was extracted, log a warning\n if (!text || text.trim().length === 0) {\n yield* Effect.logWarning(\n \"No text extracted from PDF. This might be a scanned document or image-based PDF. Consider using OCR instead.\",\n );\n }\n\n return text;\n }).pipe(\n withOperationSpan(\"document\", \"extract-text\", {\n \"document.input_size\": input.byteLength,\n }),\n );\n },\n\n getMetadata: () => {\n return Effect.gen(function* () {\n // unpdf doesn't support metadata extraction\n // Return an error indicating that pdf-lib should be used instead\n return yield* UploadistaError.fromCode(\"DOCUMENT_PROCESSING_FAILED\", {\n cause:\n \"unpdf does not support metadata extraction. Use @uploadista/flow-documents-pdflib instead.\",\n }).toEffect();\n });\n },\n\n splitPdf: () => {\n return Effect.gen(function* () {\n // unpdf doesn't support PDF splitting\n return yield* UploadistaError.fromCode(\"DOCUMENT_PROCESSING_FAILED\", {\n cause:\n \"unpdf does not support PDF splitting. Use @uploadista/flow-documents-pdflib instead.\",\n }).toEffect();\n });\n },\n\n mergePdfs: () => {\n return Effect.gen(function* () {\n // unpdf doesn't support PDF merging\n return yield* UploadistaError.fromCode(\"DOCUMENT_PROCESSING_FAILED\", {\n cause:\n \"unpdf does not support PDF merging. Use @uploadista/flow-documents-pdflib instead.\",\n }).toEffect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7B,UAAO,OAAO,gBAAgB,SAAS,8BAA8B,EACnE,OACE,sFACH,CAAC,CAAC,UAAU;IACb;;CAEL,CAAC,CACH;AAED,MAAa,0BAA0B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uploadista/flow-documents-unpdf",
3
3
  "type": "module",
4
- "version": "0.0.18-beta.9",
4
+ "version": "0.0.18",
5
5
  "description": "unpdf plugin for Uploadista document text extraction",
6
6
  "license": "MIT",
7
7
  "author": "Uploadista",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "unpdf": "^1.4.0",
18
- "@uploadista/core": "0.0.18-beta.9"
18
+ "@uploadista/core": "0.0.18"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "effect": "^3.0.0"
@@ -26,8 +26,8 @@
26
26
  "effect": "3.19.8",
27
27
  "pdf-lib": "^1.17.1",
28
28
  "tsdown": "0.16.8",
29
- "vitest": "4.0.14",
30
- "@uploadista/typescript-config": "0.0.18-beta.9"
29
+ "vitest": "4.0.15",
30
+ "@uploadista/typescript-config": "0.0.18"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsdown",
@@ -1,5 +1,6 @@
1
1
  import { UploadistaError } from "@uploadista/core/errors";
2
2
  import { DocumentPlugin } from "@uploadista/core/flow";
3
+ import { withOperationSpan } from "@uploadista/observability";
3
4
  import { Effect, Layer } from "effect";
4
5
  import { extractText } from "unpdf";
5
6
 
@@ -52,7 +53,11 @@ export const unpdfDocumentPlugin = Layer.succeed(
52
53
  }
53
54
 
54
55
  return text;
55
- });
56
+ }).pipe(
57
+ withOperationSpan("document", "extract-text", {
58
+ "document.input_size": input.byteLength,
59
+ }),
60
+ );
56
61
  },
57
62
 
58
63
  getMetadata: () => {