plugin-file-preview-auth 1.3.5 → 1.3.8

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 (105) hide show
  1. package/client-v2.d.ts +2 -0
  2. package/client-v2.js +1 -0
  3. package/dist/client/713.79a55458f5b67f39.js +30 -0
  4. package/dist/client/823.8b0ab22c181d4523.js +10 -0
  5. package/dist/client/828.ae8e47a2e7a3bc9e.js +49 -0
  6. package/dist/client/892.a568eb42fd6f0047.js +10 -0
  7. package/dist/client/index.js +1 -1
  8. package/dist/client-v2/index.js +10 -0
  9. package/dist/externalVersion.js +8 -7
  10. package/dist/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +3086 -3725
  11. package/dist/node_modules/@aws-sdk/client-s3/node_modules/.bin/fxparser +16 -0
  12. package/dist/node_modules/@aws-sdk/client-s3/node_modules/.bin/fxparser.cmd +17 -0
  13. package/dist/node_modules/@aws-sdk/client-s3/node_modules/.bin/fxparser.ps1 +28 -0
  14. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/index.js +110 -0
  15. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/signature-v4-multi-region/dist-es/SignatureV4MultiRegion.js +66 -0
  16. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/signature-v4-multi-region/dist-es/index.js +2 -0
  17. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/signature-v4-multi-region/dist-es/signature-v4-crt-container.js +3 -0
  18. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/signature-v4-multi-region/dist-types/SignatureV4MultiRegion.d.ts +30 -0
  19. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/signature-v4-multi-region/dist-types/index.d.ts +5 -0
  20. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/signature-v4-multi-region/dist-types/signature-v4-crt-container.d.ts +28 -0
  21. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/signature-v4-multi-region/dist-types/ts3.4/SignatureV4MultiRegion.d.ts +40 -0
  22. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/signature-v4-multi-region/dist-types/ts3.4/index.d.ts +2 -0
  23. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/signature-v4-multi-region/dist-types/ts3.4/signature-v4-crt-container.d.ts +20 -0
  24. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/signature-v4-multi-region/package.json +57 -0
  25. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-cjs/AdaptiveRetryStrategy.js +1 -0
  26. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-cjs/ConfiguredRetryStrategy.js +1 -0
  27. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-cjs/DefaultRateLimiter.js +1 -0
  28. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-cjs/StandardRetryStrategy.js +1 -0
  29. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-cjs/config.js +1 -0
  30. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-cjs/constants.js +1 -0
  31. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-cjs/defaultRetryBackoffStrategy.js +1 -0
  32. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-cjs/defaultRetryToken.js +1 -0
  33. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-cjs/index.js +358 -0
  34. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-cjs/types.js +1 -0
  35. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-es/AdaptiveRetryStrategy.js +24 -0
  36. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-es/ConfiguredRetryStrategy.js +18 -0
  37. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-es/DefaultRateLimiter.js +100 -0
  38. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-es/StandardRetryStrategy.js +65 -0
  39. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-es/config.js +7 -0
  40. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-es/constants.js +9 -0
  41. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-es/defaultRetryBackoffStrategy.js +14 -0
  42. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-es/defaultRetryToken.js +11 -0
  43. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-es/index.js +7 -0
  44. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-es/types.js +1 -0
  45. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/AdaptiveRetryStrategy.d.ts +33 -0
  46. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/ConfiguredRetryStrategy.d.ts +32 -0
  47. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/DefaultRateLimiter.d.ts +49 -0
  48. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/StandardRetryStrategy.d.ts +26 -0
  49. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/config.d.ts +20 -0
  50. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/constants.d.ts +59 -0
  51. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/defaultRetryBackoffStrategy.d.ts +5 -0
  52. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/defaultRetryToken.d.ts +9 -0
  53. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/index.d.ts +7 -0
  54. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/ts3.4/AdaptiveRetryStrategy.d.ts +33 -0
  55. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/ts3.4/ConfiguredRetryStrategy.d.ts +32 -0
  56. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/ts3.4/DefaultRateLimiter.d.ts +49 -0
  57. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/ts3.4/StandardRetryStrategy.d.ts +26 -0
  58. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/ts3.4/config.d.ts +20 -0
  59. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/ts3.4/constants.d.ts +59 -0
  60. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/ts3.4/defaultRetryBackoffStrategy.d.ts +5 -0
  61. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/ts3.4/defaultRetryToken.d.ts +9 -0
  62. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/ts3.4/index.d.ts +7 -0
  63. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/ts3.4/types.d.ts +19 -0
  64. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/dist-types/types.d.ts +19 -0
  65. package/dist/node_modules/@aws-sdk/client-s3/node_modules/@smithy/util-retry/package.json +68 -0
  66. package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
  67. package/dist/node_modules/xlsx/package.json +1 -1
  68. package/dist/server/ocr/tesseract-runner.js +3 -1
  69. package/dist/server/plugin.js +22 -4
  70. package/package.json +57 -45
  71. package/src/client/AIFilePreviewAction.tsx +282 -0
  72. package/src/client/__tests__/ocr-utils.test.ts +85 -0
  73. package/src/client/client.d.ts +258 -0
  74. package/src/client/index.tsx +1807 -0
  75. package/src/client/locale.ts +21 -0
  76. package/src/client-v2/index.tsx +1 -0
  77. package/src/client-v2/plugin.tsx +7 -0
  78. package/{dist/index.d.ts → src/index.ts} +11 -10
  79. package/src/locale/en-US.json +14 -0
  80. package/src/locale/vi-VN.json +14 -0
  81. package/src/locale/zh-CN.json +14 -0
  82. package/src/server/__tests__/smoke.test.ts +17 -0
  83. package/src/server/collections/attachment-ocr-results.ts +40 -0
  84. package/{dist/server/collections/file-preview-auth.d.ts → src/server/collections/file-preview-auth.ts} +15 -14
  85. package/src/server/excel-parser-handler.ts +128 -0
  86. package/{dist/server/index.d.ts → src/server/index.ts} +10 -9
  87. package/src/server/migrations/20260528000000-move-ocr-fields-out-of-attachments.ts +39 -0
  88. package/src/server/ocr/tesseract-runner.ts +389 -0
  89. package/src/server/ocr/tesseract-worker.ts +235 -0
  90. package/src/server/plugin.ts +1470 -0
  91. package/dist/client/166.17caa11c2ba40313.js +0 -10
  92. package/dist/client/351.0f0ce45c92425c8f.js +0 -10
  93. package/dist/client/374.96762d13b15e7467.js +0 -30
  94. package/dist/client/514.2a8b6aa0d2fcd4b2.js +0 -49
  95. package/dist/client/AIFilePreviewAction.d.ts +0 -42
  96. package/dist/client/index.d.ts +0 -14
  97. package/dist/client/locale.d.ts +0 -10
  98. package/dist/node_modules/xlsx/node_modules/.bin/crc32 +0 -15
  99. package/dist/node_modules/xlsx/node_modules/.bin/crc32.cmd +0 -7
  100. package/dist/server/collections/attachment-ocr-results.d.ts +0 -2
  101. package/dist/server/excel-parser-handler.d.ts +0 -60
  102. package/dist/server/migrations/20260528000000-move-ocr-fields-out-of-attachments.d.ts +0 -5
  103. package/dist/server/ocr/tesseract-runner.d.ts +0 -34
  104. package/dist/server/ocr/tesseract-worker.d.ts +0 -27
  105. package/dist/server/plugin.d.ts +0 -54
@@ -1,42 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
- import React from 'react';
10
- import type { Application } from '@nocobase/client';
11
- export declare const FILE_PREVIEW_WORK_CONTEXT_TYPE = "file-preview";
12
- export declare function createFilePreviewWorkContext(file: any): {
13
- type: string;
14
- uid: string;
15
- title: string;
16
- content: {
17
- source: string;
18
- file: {
19
- id: any;
20
- uid: any;
21
- url: any;
22
- preview: any;
23
- filename: any;
24
- name: any;
25
- title: any;
26
- extname: any;
27
- mimetype: any;
28
- size: any;
29
- path: any;
30
- storageId: any;
31
- storage_id: any;
32
- storageType: any;
33
- storageName: any;
34
- storage: any;
35
- collectionName: any;
36
- };
37
- };
38
- };
39
- export declare const AIFilePreviewAction: React.FC<{
40
- file: any;
41
- }>;
42
- export declare function registerFilePreviewAIWorkContext(app: Application): void;
@@ -1,14 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
- import { Plugin } from '@nocobase/client';
10
- export declare class PluginFilePreviewAuthClient extends Plugin {
11
- load(): Promise<void>;
12
- private patchUploadPreviewBase64Fallback;
13
- }
14
- export default PluginFilePreviewAuthClient;
@@ -1,10 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
- export declare function useT(): (str: string) => string;
10
- export declare function tStr(key: string): string;
@@ -1,15 +0,0 @@
1
- #!/bin/sh
2
- basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
-
4
- case `uname` in
5
- *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
- esac
7
-
8
- if [ -x "$basedir/node" ]; then
9
- "$basedir/node" "$basedir/../../../crc-32/bin/crc32.njs" "$@"
10
- ret=$?
11
- else
12
- node "$basedir/../../../crc-32/bin/crc32.njs" "$@"
13
- ret=$?
14
- fi
15
- exit $ret
@@ -1,7 +0,0 @@
1
- @IF EXIST "%~dp0\node.exe" (
2
- "%~dp0\node.exe" "%~dp0\..\..\..\crc-32\bin\crc32.njs" %*
3
- ) ELSE (
4
- @SETLOCAL
5
- @SET PATHEXT=%PATHEXT:;.JS;=;%
6
- node "%~dp0\..\..\..\crc-32\bin\crc32.njs" %*
7
- )
@@ -1,2 +0,0 @@
1
- declare const _default: import("@nocobase/database").CollectionOptions;
2
- export default _default;
@@ -1,60 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
- import type { Context } from '@nocobase/actions';
10
- interface AttachmentLike {
11
- id?: string | number;
12
- filename?: string;
13
- name?: string;
14
- mimetype?: string;
15
- extname?: string;
16
- url?: string;
17
- storageId?: number;
18
- size?: number;
19
- meta?: Record<string, any>;
20
- [key: string]: any;
21
- }
22
- interface InternalParseResult {
23
- text: string;
24
- handled: boolean;
25
- }
26
- export interface InternalParserHandler {
27
- name: string;
28
- supports(attachment: AttachmentLike): boolean;
29
- parse(attachment: AttachmentLike, ctx: Context): Promise<InternalParseResult>;
30
- }
31
- /**
32
- * Server-side Excel parser handler.
33
- *
34
- * Uses SheetJS (xlsx) — the same library already bundled by this plugin for
35
- * client-side XLSX preview — to extract plain text from .xlsx/.xls files on
36
- * the server.
37
- *
38
- * Each worksheet is converted to CSV and separated by a section header so LLMs
39
- * can distinguish sheet boundaries:
40
- *
41
- * === Sheet: Sheet1 ===
42
- * col1,col2,col3
43
- * val1,val2,val3
44
- *
45
- * === Sheet: Sheet2 ===
46
- * ...
47
- *
48
- * This handler is registered into plugin-document-parser's InternalParserRegistry
49
- * by PluginFilePreviewAuthServer with `prepend: true` so it takes priority over
50
- * any other handlers that might be registered later.
51
- *
52
- * File bytes are fetched via plugin-document-parser's public `fetchFileBuffer`
53
- * helper, which transparently handles both S3 URLs and local file paths.
54
- */
55
- export declare class ExcelParserHandler implements InternalParserHandler {
56
- readonly name = "file-preview-auth-excel-parser";
57
- supports(attachment: AttachmentLike): boolean;
58
- parse(attachment: AttachmentLike, ctx: Context): Promise<InternalParseResult>;
59
- }
60
- export {};
@@ -1,5 +0,0 @@
1
- import { Migration } from '@nocobase/server';
2
- export default class extends Migration {
3
- on: string;
4
- up(): Promise<void>;
5
- }
@@ -1,34 +0,0 @@
1
- export interface OcrRect {
2
- x: number;
3
- y: number;
4
- width: number;
5
- height: number;
6
- unit: string;
7
- }
8
- export interface OcrWordItem {
9
- id: string;
10
- key: string;
11
- value: string;
12
- page: number;
13
- confidence: number;
14
- rect: OcrRect;
15
- status: string;
16
- }
17
- export declare class TesseractRunner {
18
- private log;
19
- constructor(app: any);
20
- /**
21
- * Run Tesseract OCR on a file (PDF or Image).
22
- * Generates word-level coordinates and text.
23
- */
24
- runOcr(filePath: string, attachmentId: number): Promise<{
25
- pages: Array<{
26
- page_number: number;
27
- items: OcrWordItem[];
28
- }>;
29
- }>;
30
- private executeTesseract;
31
- private parseTsv;
32
- private convertPdfToImages;
33
- private generateMockOcrData;
34
- }
@@ -1,27 +0,0 @@
1
- export declare class TesseractWorker {
2
- private app;
3
- private db;
4
- private log;
5
- private runner;
6
- private isRunning;
7
- private pollTimer;
8
- private redisKey;
9
- constructor(app: any);
10
- /**
11
- * Start the background worker.
12
- */
13
- start(): Promise<void>;
14
- /**
15
- * Stop the background worker.
16
- */
17
- stop(): void;
18
- /**
19
- * Enqueue a new OCR job.
20
- */
21
- enqueue(attachmentId: number): Promise<boolean>;
22
- private getRedisClient;
23
- private listenRedisQueue;
24
- private startDbPolling;
25
- private processJob;
26
- private updateOcrResult;
27
- }
@@ -1,54 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
- import { Plugin } from '@nocobase/server';
10
- export declare class PluginFilePreviewAuthServer extends Plugin {
11
- private cache;
12
- private ocrWorker;
13
- beforeLoad(): Promise<void>;
14
- load(): Promise<void>;
15
- afterEnable(): Promise<void>;
16
- beforeDisable(): Promise<void>;
17
- beforeDestroy(): Promise<void>;
18
- private syncOcrResultCollection;
19
- /**
20
- * Disable NocoBase's built-in Office previewer after plugins have loaded.
21
- * This keeps this authenticated previewer as the active Office handler without causing a restart loop.
22
- */
23
- private disableBuiltinOfficePreviewer;
24
- private registerDownloadApi;
25
- private getOcrResultByAttachmentId;
26
- private upsertOcrResult;
27
- private serializeOcrResult;
28
- private registerAIWorkContext;
29
- private resolveAttachment;
30
- private getParentCollections;
31
- private checkParentCollectionAccess;
32
- private assertCanAccessAttachment;
33
- private assertAuthenticated;
34
- private consumeUploadedParseFile;
35
- private extractUploadedFileText;
36
- private getMarkItDownParserPlugin;
37
- private extractAttachmentText;
38
- private readAttachmentAsText;
39
- private prepareAttachmentForFileManager;
40
- private resolveCollection;
41
- private resolveStorageId;
42
- private resolveStorageIdFromRecordTable;
43
- private ensureFileFields;
44
- private copyFileFieldsFromRecord;
45
- private resolveFileFieldsFromRecordTable;
46
- private formatAttachmentWorkContext;
47
- /**
48
- * Register Excel handler into plugin-document-parser's InternalParserRegistry.
49
- * Uses prepend:true so SheetJS takes priority over the AI-loader fallback.
50
- * Silent no-op when plugin-document-parser is not loaded.
51
- */
52
- private registerExcelParser;
53
- }
54
- export default PluginFilePreviewAuthServer;