@memberjunction/core-actions 5.23.0 → 5.25.0
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/dist/custom/files/add-document-content.action.d.ts +20 -0
- package/dist/custom/files/add-document-content.action.d.ts.map +1 -0
- package/dist/custom/files/add-document-content.action.js +74 -0
- package/dist/custom/files/add-document-content.action.js.map +1 -0
- package/dist/custom/files/base-file-storage.action.d.ts +6 -9
- package/dist/custom/files/base-file-storage.action.d.ts.map +1 -1
- package/dist/custom/files/base-file-storage.action.js +14 -39
- package/dist/custom/files/base-file-storage.action.js.map +1 -1
- package/dist/custom/files/create-document.action.d.ts +19 -0
- package/dist/custom/files/create-document.action.d.ts.map +1 -0
- package/dist/custom/files/create-document.action.js +65 -0
- package/dist/custom/files/create-document.action.js.map +1 -0
- package/dist/custom/files/excel-reader.action.js +1 -1
- package/dist/custom/files/excel-reader.action.js.map +1 -1
- package/dist/custom/files/finalize-document.action.d.ts +21 -0
- package/dist/custom/files/finalize-document.action.d.ts.map +1 -0
- package/dist/custom/files/finalize-document.action.js +94 -0
- package/dist/custom/files/finalize-document.action.js.map +1 -0
- package/dist/custom/files/index.d.ts +5 -0
- package/dist/custom/files/index.d.ts.map +1 -1
- package/dist/custom/files/index.js +6 -0
- package/dist/custom/files/index.js.map +1 -1
- package/dist/custom/files/list-storage-providers.action.d.ts.map +1 -1
- package/dist/custom/files/list-storage-providers.action.js +6 -33
- package/dist/custom/files/list-storage-providers.action.js.map +1 -1
- package/dist/custom/files/modify-document-section.action.d.ts +19 -0
- package/dist/custom/files/modify-document-section.action.d.ts.map +1 -0
- package/dist/custom/files/modify-document-section.action.js +85 -0
- package/dist/custom/files/modify-document-section.action.js.map +1 -0
- package/dist/custom/files/pdf-extractor.action.d.ts +8 -14
- package/dist/custom/files/pdf-extractor.action.d.ts.map +1 -1
- package/dist/custom/files/pdf-extractor.action.js +89 -91
- package/dist/custom/files/pdf-extractor.action.js.map +1 -1
- package/dist/custom/files/preview-document.action.d.ts +17 -0
- package/dist/custom/files/preview-document.action.d.ts.map +1 -0
- package/dist/custom/files/preview-document.action.js +50 -0
- package/dist/custom/files/preview-document.action.js.map +1 -0
- package/dist/custom/geo/scheduled-geocoding.action.d.ts +135 -0
- package/dist/custom/geo/scheduled-geocoding.action.d.ts.map +1 -0
- package/dist/custom/geo/scheduled-geocoding.action.js +428 -0
- package/dist/custom/geo/scheduled-geocoding.action.js.map +1 -0
- package/dist/custom/search/search.action.d.ts +67 -0
- package/dist/custom/search/search.action.d.ts.map +1 -0
- package/dist/custom/search/search.action.js +211 -0
- package/dist/custom/search/search.action.js.map +1 -0
- package/dist/custom/utilities/artifact-builder-service.d.ts +139 -0
- package/dist/custom/utilities/artifact-builder-service.d.ts.map +1 -0
- package/dist/custom/utilities/artifact-builder-service.js +338 -0
- package/dist/custom/utilities/artifact-builder-service.js.map +1 -0
- package/dist/custom/utilities/base-file-handler.d.ts +25 -3
- package/dist/custom/utilities/base-file-handler.d.ts.map +1 -1
- package/dist/custom/utilities/base-file-handler.js +81 -28
- package/dist/custom/utilities/base-file-handler.js.map +1 -1
- package/dist/custom/utilities/docx-renderer.d.ts +61 -0
- package/dist/custom/utilities/docx-renderer.d.ts.map +1 -0
- package/dist/custom/utilities/docx-renderer.js +409 -0
- package/dist/custom/utilities/docx-renderer.js.map +1 -0
- package/dist/custom/utilities/pdf-renderer.d.ts +53 -0
- package/dist/custom/utilities/pdf-renderer.d.ts.map +1 -0
- package/dist/custom/utilities/pdf-renderer.js +315 -0
- package/dist/custom/utilities/pdf-renderer.js.map +1 -0
- package/dist/custom/utilities/xlsx-renderer.d.ts +120 -0
- package/dist/custom/utilities/xlsx-renderer.d.ts.map +1 -0
- package/dist/custom/utilities/xlsx-renderer.js +165 -0
- package/dist/custom/utilities/xlsx-renderer.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +31 -27
- package/dist/custom/files/excel-writer.action.d.ts +0 -88
- package/dist/custom/files/excel-writer.action.d.ts.map +0 -1
- package/dist/custom/files/excel-writer.action.js +0 -326
- package/dist/custom/files/excel-writer.action.js.map +0 -1
- package/dist/custom/files/pdf-generator.action.d.ts +0 -66
- package/dist/custom/files/pdf-generator.action.d.ts.map +0 -1
- package/dist/custom/files/pdf-generator.action.js +0 -254
- package/dist/custom/files/pdf-generator.action.js.map +0 -1
|
@@ -5,9 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { RegisterClass } from "@memberjunction/global";
|
|
8
|
-
import { RunView } from "@memberjunction/core";
|
|
9
8
|
import { BaseFileStorageAction } from "./base-file-storage.action.js";
|
|
10
9
|
import { BaseAction } from "@memberjunction/actions";
|
|
10
|
+
import { FileStorageEngine } from "@memberjunction/storage";
|
|
11
11
|
/**
|
|
12
12
|
* Action that retrieves a list of configured file storage accounts.
|
|
13
13
|
*
|
|
@@ -41,39 +41,12 @@ let ListStorageAccountsAction = class ListStorageAccountsAction extends BaseFile
|
|
|
41
41
|
// Optional parameter to filter only accounts whose provider supports search
|
|
42
42
|
const searchSupportedOnly = this.getBooleanParam(params, "searchsupportedonly", false);
|
|
43
43
|
try {
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
EntityName: 'MJ: File Storage Accounts',
|
|
49
|
-
ExtraFilter: '',
|
|
50
|
-
OrderBy: 'Name',
|
|
51
|
-
ResultType: 'entity_object'
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
EntityName: 'MJ: File Storage Providers',
|
|
55
|
-
ExtraFilter: 'IsActive=1',
|
|
56
|
-
OrderBy: 'Name',
|
|
57
|
-
ResultType: 'entity_object'
|
|
58
|
-
}
|
|
59
|
-
], params.ContextUser);
|
|
60
|
-
if (!accountsResult.Success) {
|
|
61
|
-
return this.createErrorResult(`Failed to retrieve storage accounts: ${accountsResult.ErrorMessage}`, "QUERY_FAILED");
|
|
62
|
-
}
|
|
63
|
-
if (!providersResult.Success) {
|
|
64
|
-
return this.createErrorResult(`Failed to retrieve storage providers: ${providersResult.ErrorMessage}`, "QUERY_FAILED");
|
|
65
|
-
}
|
|
66
|
-
const accounts = accountsResult.Results || [];
|
|
67
|
-
const providers = providersResult.Results || [];
|
|
68
|
-
// Create provider lookup map
|
|
69
|
-
const providerMap = new Map();
|
|
70
|
-
providers.forEach(p => providerMap.set(p.ID, p));
|
|
44
|
+
await FileStorageEngine.Instance.Config(false, params.ContextUser);
|
|
45
|
+
// Use cached metadata from the engine — no RunView needed
|
|
46
|
+
const accountsWithProviders = FileStorageEngine.Instance.AccountsWithProviders
|
|
47
|
+
.filter(a => a.provider.IsActive !== false);
|
|
71
48
|
const availableAccounts = [];
|
|
72
|
-
for (const account of
|
|
73
|
-
const provider = providerMap.get(account.ProviderID);
|
|
74
|
-
if (!provider) {
|
|
75
|
-
continue; // Skip accounts with inactive/missing providers
|
|
76
|
-
}
|
|
49
|
+
for (const { account, provider } of accountsWithProviders) {
|
|
77
50
|
const supportsSearch = provider.Get('SupportsSearch') ?? false;
|
|
78
51
|
// Skip if filtering for search-only and this provider doesn't support it
|
|
79
52
|
if (searchSupportedOnly && !supportsSearch) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-storage-providers.action.js","sourceRoot":"","sources":["../../../src/custom/files/list-storage-providers.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"list-storage-providers.action.js","sourceRoot":"","sources":["../../../src/custom/files/list-storage-providers.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE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AC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,OAAO,IAAI,CAAC,iBAAiB,CACzB,oCAAoC,YAAY,EAAE,EAClD,aAAa,CAChB,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAA;AA/FY,yBAAyB;IADrC,aAAa,CAAC,UAAU,EAAE,uBAAuB,CAAC;GACtC,yBAAyB,CA+FrC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import { BaseFileHandlerAction } from "../utilities/base-file-handler.js";
|
|
3
|
+
/**
|
|
4
|
+
* Replaces or removes a previously-added section in an in-progress document.
|
|
5
|
+
* Section IDs are returned by Add Document Content and Preview Document.
|
|
6
|
+
*
|
|
7
|
+
* Parameters:
|
|
8
|
+
* - Handle (required): the document handle
|
|
9
|
+
* - SectionID (required): the section to modify
|
|
10
|
+
* - Action (required): 'replace' or 'remove'
|
|
11
|
+
* - Operations (required if Action='replace', JSON array): replacement operations
|
|
12
|
+
*
|
|
13
|
+
* Output:
|
|
14
|
+
* - success, updated section count
|
|
15
|
+
*/
|
|
16
|
+
export declare class ModifyDocumentSectionAction extends BaseFileHandlerAction {
|
|
17
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=modify-document-section.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modify-document-section.action.d.ts","sourceRoot":"","sources":["../../../src/custom/files/modify-document-section.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAGnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAIvE;;;;;;;;;;;;GAYG;AACH,qBACa,2BAA4B,SAAQ,qBAAqB;cAElD,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA4D1F"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { RegisterClass } from "@memberjunction/global";
|
|
8
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
9
|
+
import { BaseFileHandlerAction } from "../utilities/base-file-handler.js";
|
|
10
|
+
import { ArtifactBuilderService } from "../utilities/artifact-builder-service.js";
|
|
11
|
+
import { JSONParamHelper } from "../utilities/json-param-helper.js";
|
|
12
|
+
/**
|
|
13
|
+
* Replaces or removes a previously-added section in an in-progress document.
|
|
14
|
+
* Section IDs are returned by Add Document Content and Preview Document.
|
|
15
|
+
*
|
|
16
|
+
* Parameters:
|
|
17
|
+
* - Handle (required): the document handle
|
|
18
|
+
* - SectionID (required): the section to modify
|
|
19
|
+
* - Action (required): 'replace' or 'remove'
|
|
20
|
+
* - Operations (required if Action='replace', JSON array): replacement operations
|
|
21
|
+
*
|
|
22
|
+
* Output:
|
|
23
|
+
* - success, updated section count
|
|
24
|
+
*/
|
|
25
|
+
let ModifyDocumentSectionAction = class ModifyDocumentSectionAction extends BaseFileHandlerAction {
|
|
26
|
+
async InternalRunAction(params) {
|
|
27
|
+
try {
|
|
28
|
+
const handle = this.getParamValue(params, 'handle');
|
|
29
|
+
if (!handle) {
|
|
30
|
+
return { Success: false, Message: "Handle parameter is required", ResultCode: "MISSING_HANDLE" };
|
|
31
|
+
}
|
|
32
|
+
const sectionId = this.getParamValue(params, 'sectionid');
|
|
33
|
+
if (!sectionId) {
|
|
34
|
+
return { Success: false, Message: "SectionID parameter is required", ResultCode: "MISSING_SECTION_ID" };
|
|
35
|
+
}
|
|
36
|
+
const action = (this.getParamValue(params, 'action') || '').toLowerCase();
|
|
37
|
+
if (!['replace', 'remove'].includes(action)) {
|
|
38
|
+
return { Success: false, Message: "Action must be 'replace' or 'remove'", ResultCode: "INVALID_ACTION" };
|
|
39
|
+
}
|
|
40
|
+
const service = ArtifactBuilderService.Instance;
|
|
41
|
+
if (action === 'remove') {
|
|
42
|
+
service.RemoveSection(handle.toString(), sectionId.toString());
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
let operations;
|
|
46
|
+
try {
|
|
47
|
+
operations = JSONParamHelper.getRequiredJSONParam(params, 'operations');
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return {
|
|
51
|
+
Success: false,
|
|
52
|
+
Message: "Operations parameter is required for 'replace' action",
|
|
53
|
+
ResultCode: "MISSING_OPERATIONS"
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (!Array.isArray(operations) || operations.length === 0) {
|
|
57
|
+
return { Success: false, Message: "Operations must be a non-empty array", ResultCode: "INVALID_OPERATIONS" };
|
|
58
|
+
}
|
|
59
|
+
service.ReplaceSection(handle.toString(), sectionId.toString(), operations);
|
|
60
|
+
}
|
|
61
|
+
const preview = service.GetPreview(handle.toString());
|
|
62
|
+
return {
|
|
63
|
+
Success: true,
|
|
64
|
+
ResultCode: "SUCCESS",
|
|
65
|
+
Message: JSON.stringify({
|
|
66
|
+
message: `Section ${action === 'remove' ? 'removed' : 'replaced'} successfully. Document now has ${preview.sectionCount} section(s).`,
|
|
67
|
+
totalSections: preview.sectionCount,
|
|
68
|
+
totalOperations: preview.totalOperations,
|
|
69
|
+
}, null, 2)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
return {
|
|
74
|
+
Success: false,
|
|
75
|
+
Message: `Failed to modify section: ${error instanceof Error ? error.message : String(error)}`,
|
|
76
|
+
ResultCode: "MODIFY_FAILED"
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
ModifyDocumentSectionAction = __decorate([
|
|
82
|
+
RegisterClass(BaseAction, "__ModifyDocumentSection")
|
|
83
|
+
], ModifyDocumentSectionAction);
|
|
84
|
+
export { ModifyDocumentSectionAction };
|
|
85
|
+
//# sourceMappingURL=modify-document-section.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modify-document-section.action.js","sourceRoot":"","sources":["../../../src/custom/files/modify-document-section.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAqB,MAAM,uCAAuC,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE;;;;;;;;;;;;GAYG;AAEI,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,qBAAqB;IAExD,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACpD,IAAI,CAAC,MAAM,EAAE,CAAC;gBACV,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,8BAA8B,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC;YACrG,CAAC;YAED,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YAC1D,IAAI,CAAC,SAAS,EAAE,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SAAS,CAAC,QAAQ,EAAE,EAAE,UAAU,CAAC,CAAC;YAChF,CAAC;YAED,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;YAEtD,OAAO;gBACH,OAAO,EAAE,IAAI;gBACb,UAAU,EAAE,SAAS;gBACrB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;oBACpB,OAAO,EAAE,WAAW,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,mCAAmC,OAAO,CAAC,YAAY,cAAc;oBACrI,aAAa,EAAE,OAAO,CAAC,YAAY;oBACnC,eAAe,EAAE,OAAO,CAAC,eAAe;iBAC3C,EAAE,IAAI,EAAE,CAAC,CAAC;aACd,CAAC;QAEN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO;gBACH,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,6BAA6B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;gBAC9F,UAAU,EAAE,eAAe;aAC9B,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAA;AA9DY,2BAA2B;IADvC,aAAa,CAAC,UAAU,EAAE,yBAAyB,CAAC;GACxC,2BAA2B,CA8DvC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
2
|
import { BaseFileHandlerAction } from "../utilities/base-file-handler.js";
|
|
3
3
|
/**
|
|
4
|
-
* Action that extracts content from PDF files
|
|
5
|
-
* Can extract text, metadata, or specific pages
|
|
4
|
+
* Action that extracts content from PDF files using pdfjs-dist (Mozilla PDF.js).
|
|
5
|
+
* Can extract text, metadata, or specific pages.
|
|
6
|
+
*
|
|
7
|
+
* Uses pdfjs-dist instead of pdf-parse for broader PDF compatibility,
|
|
8
|
+
* including PDFs generated by pdfkit, and true per-page text extraction.
|
|
6
9
|
*
|
|
7
10
|
* @example
|
|
8
11
|
* ```typescript
|
|
@@ -62,21 +65,12 @@ export declare class PDFExtractorAction extends BaseFileHandlerAction {
|
|
|
62
65
|
* @returns Extracted content based on extraction type
|
|
63
66
|
*/
|
|
64
67
|
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
65
|
-
|
|
66
|
-
* Check if string is base64 encoded
|
|
67
|
-
*/
|
|
68
|
+
private toBuffer;
|
|
68
69
|
private isBase64;
|
|
69
|
-
|
|
70
|
-
* Extract text from PDF
|
|
71
|
-
*/
|
|
70
|
+
private getPageText;
|
|
72
71
|
private extractText;
|
|
73
|
-
/**
|
|
74
|
-
* Extract metadata from PDF
|
|
75
|
-
*/
|
|
76
72
|
private extractMetadata;
|
|
77
|
-
/**
|
|
78
|
-
* Extract specific pages from PDF
|
|
79
|
-
*/
|
|
80
73
|
private extractPages;
|
|
74
|
+
private parsePageNumbers;
|
|
81
75
|
}
|
|
82
76
|
//# sourceMappingURL=pdf-extractor.action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-extractor.action.d.ts","sourceRoot":"","sources":["../../../src/custom/files/pdf-extractor.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"pdf-extractor.action.d.ts","sourceRoot":"","sources":["../../../src/custom/files/pdf-extractor.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAGvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,qBACa,kBAAmB,SAAQ,qBAAqB;IAEzD;;;;;;;;;;;;;OAaG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA4DvF,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,QAAQ;YAQF,WAAW;YASX,WAAW;YA4BX,eAAe;YAiCf,YAAY;IA8B1B,OAAO,CAAC,gBAAgB;CAW3B"}
|
|
@@ -7,10 +7,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { RegisterClass } from "@memberjunction/global";
|
|
8
8
|
import { BaseFileHandlerAction } from "../utilities/base-file-handler.js";
|
|
9
9
|
import { BaseAction } from '@memberjunction/actions';
|
|
10
|
-
import pdfParse from 'pdf-parse';
|
|
11
10
|
/**
|
|
12
|
-
* Action that extracts content from PDF files
|
|
13
|
-
* Can extract text, metadata, or specific pages
|
|
11
|
+
* Action that extracts content from PDF files using pdfjs-dist (Mozilla PDF.js).
|
|
12
|
+
* Can extract text, metadata, or specific pages.
|
|
13
|
+
*
|
|
14
|
+
* Uses pdfjs-dist instead of pdf-parse for broader PDF compatibility,
|
|
15
|
+
* including PDFs generated by pdfkit, and true per-page text extraction.
|
|
14
16
|
*
|
|
15
17
|
* @example
|
|
16
18
|
* ```typescript
|
|
@@ -71,44 +73,29 @@ let PDFExtractorAction = class PDFExtractorAction extends BaseFileHandlerAction
|
|
|
71
73
|
*/
|
|
72
74
|
async InternalRunAction(params) {
|
|
73
75
|
try {
|
|
74
|
-
// Get file content
|
|
75
76
|
const fileContent = await this.getFileContent(params, 'pdfdata', 'fileid', 'fileurl');
|
|
76
|
-
// Get extraction parameters
|
|
77
77
|
const extractType = (this.getParamValue(params, 'extracttype') || 'text').toLowerCase();
|
|
78
78
|
const pageNumbersParam = this.getParamValue(params, 'pagenumbers');
|
|
79
79
|
const mergePages = this.getBooleanParam(params, 'mergepages', true);
|
|
80
80
|
const includePageBreaks = this.getBooleanParam(params, 'includepagebreaks', false);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (fileContent.source === 'direct' && this.isBase64(fileContent.content)) {
|
|
86
|
-
pdfBuffer = Buffer.from(fileContent.content, 'base64');
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
// Assume it's raw PDF data as string
|
|
90
|
-
pdfBuffer = Buffer.from(fileContent.content, 'binary');
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
pdfBuffer = fileContent.content;
|
|
95
|
-
}
|
|
96
|
-
// Parse PDF
|
|
97
|
-
const pdfData = await pdfParse(pdfBuffer);
|
|
81
|
+
const pdfBuffer = this.toBuffer(fileContent.content, fileContent.source);
|
|
82
|
+
// Lazy-load pdfjs-dist (legacy build works in Node without DOM)
|
|
83
|
+
const pdfjsLib = await import('pdfjs-dist/legacy/build/pdf.mjs');
|
|
84
|
+
const pdfDoc = await pdfjsLib.getDocument({ data: new Uint8Array(pdfBuffer) }).promise;
|
|
98
85
|
let result;
|
|
99
86
|
switch (extractType) {
|
|
100
87
|
case 'metadata':
|
|
101
|
-
result = await this.extractMetadata(
|
|
88
|
+
result = await this.extractMetadata(pdfDoc);
|
|
102
89
|
break;
|
|
103
90
|
case 'pages':
|
|
104
|
-
result = await this.extractPages(
|
|
91
|
+
result = await this.extractPages(pdfDoc, pageNumbersParam, mergePages, includePageBreaks);
|
|
105
92
|
break;
|
|
106
93
|
case 'text':
|
|
107
94
|
default:
|
|
108
|
-
result = await this.extractText(
|
|
95
|
+
result = await this.extractText(pdfDoc, mergePages, includePageBreaks);
|
|
109
96
|
break;
|
|
110
97
|
}
|
|
111
|
-
|
|
98
|
+
pdfDoc.destroy();
|
|
112
99
|
if (extractType === 'text' || extractType === 'pages') {
|
|
113
100
|
params.Params.push({
|
|
114
101
|
Name: 'ExtractedText',
|
|
@@ -120,7 +107,7 @@ let PDFExtractorAction = class PDFExtractorAction extends BaseFileHandlerAction
|
|
|
120
107
|
Success: true,
|
|
121
108
|
ResultCode: "SUCCESS",
|
|
122
109
|
Message: JSON.stringify({
|
|
123
|
-
extractType
|
|
110
|
+
extractType,
|
|
124
111
|
source: fileContent.source,
|
|
125
112
|
fileName: fileContent.fileName,
|
|
126
113
|
...result
|
|
@@ -135,9 +122,14 @@ let PDFExtractorAction = class PDFExtractorAction extends BaseFileHandlerAction
|
|
|
135
122
|
};
|
|
136
123
|
}
|
|
137
124
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
125
|
+
toBuffer(content, source) {
|
|
126
|
+
if (Buffer.isBuffer(content))
|
|
127
|
+
return content;
|
|
128
|
+
if (source === 'direct' && this.isBase64(content)) {
|
|
129
|
+
return Buffer.from(content, 'base64');
|
|
130
|
+
}
|
|
131
|
+
return Buffer.from(content, 'binary');
|
|
132
|
+
}
|
|
141
133
|
isBase64(str) {
|
|
142
134
|
try {
|
|
143
135
|
return Buffer.from(str, 'base64').toString('base64') === str;
|
|
@@ -146,93 +138,99 @@ let PDFExtractorAction = class PDFExtractorAction extends BaseFileHandlerAction
|
|
|
146
138
|
return false;
|
|
147
139
|
}
|
|
148
140
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
141
|
+
async getPageText(pdfDoc, pageNum) {
|
|
142
|
+
const page = await pdfDoc.getPage(pageNum);
|
|
143
|
+
const textContent = await page.getTextContent();
|
|
144
|
+
return textContent.items
|
|
145
|
+
.map((item) => item.str)
|
|
146
|
+
.join(' ')
|
|
147
|
+
.trim();
|
|
148
|
+
}
|
|
149
|
+
async extractText(pdfDoc, mergePages, includePageBreaks) {
|
|
150
|
+
const pageTexts = [];
|
|
151
|
+
for (let i = 1; i <= pdfDoc.numPages; i++) {
|
|
152
|
+
pageTexts.push(await this.getPageText(pdfDoc, i));
|
|
158
153
|
}
|
|
154
|
+
const separator = includePageBreaks ? '\n\n--- PAGE BREAK ---\n\n' : '\n\n';
|
|
155
|
+
const text = mergePages ? pageTexts.join(separator) : pageTexts.join(separator);
|
|
156
|
+
const metadata = await pdfDoc.getMetadata().catch(() => null);
|
|
159
157
|
return {
|
|
160
|
-
text
|
|
161
|
-
totalPages:
|
|
158
|
+
text,
|
|
159
|
+
totalPages: pdfDoc.numPages,
|
|
162
160
|
textLength: text.length,
|
|
163
161
|
info: {
|
|
164
|
-
title:
|
|
165
|
-
author:
|
|
166
|
-
subject:
|
|
167
|
-
creator:
|
|
162
|
+
title: metadata?.info?.Title ?? null,
|
|
163
|
+
author: metadata?.info?.Author ?? null,
|
|
164
|
+
subject: metadata?.info?.Subject ?? null,
|
|
165
|
+
creator: metadata?.info?.Creator ?? null
|
|
168
166
|
}
|
|
169
167
|
};
|
|
170
168
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
async extractMetadata(pdfDoc) {
|
|
170
|
+
const metadata = await pdfDoc.getMetadata().catch(() => null);
|
|
171
|
+
const info = (metadata?.info ?? {});
|
|
172
|
+
// Get total text length by extracting all pages
|
|
173
|
+
let totalTextLength = 0;
|
|
174
|
+
for (let i = 1; i <= pdfDoc.numPages; i++) {
|
|
175
|
+
const pageText = await this.getPageText(pdfDoc, i);
|
|
176
|
+
totalTextLength += pageText.length;
|
|
177
|
+
}
|
|
175
178
|
return {
|
|
176
179
|
metadata: {
|
|
177
|
-
...
|
|
178
|
-
pageCount:
|
|
179
|
-
version: pdfData.version,
|
|
180
|
-
isEncrypted: pdfData.isEncrypted || false,
|
|
181
|
-
permissions: pdfData.permissions || null
|
|
180
|
+
...info,
|
|
181
|
+
pageCount: pdfDoc.numPages
|
|
182
182
|
},
|
|
183
183
|
documentInfo: {
|
|
184
|
-
title:
|
|
185
|
-
author:
|
|
186
|
-
subject:
|
|
187
|
-
keywords:
|
|
188
|
-
creator:
|
|
189
|
-
producer:
|
|
190
|
-
creationDate:
|
|
191
|
-
modificationDate:
|
|
184
|
+
title: info.Title ?? null,
|
|
185
|
+
author: info.Author ?? null,
|
|
186
|
+
subject: info.Subject ?? null,
|
|
187
|
+
keywords: info.Keywords ?? null,
|
|
188
|
+
creator: info.Creator ?? null,
|
|
189
|
+
producer: info.Producer ?? null,
|
|
190
|
+
creationDate: info.CreationDate ?? null,
|
|
191
|
+
modificationDate: info.ModDate ?? null
|
|
192
192
|
},
|
|
193
193
|
statistics: {
|
|
194
|
-
totalPages:
|
|
195
|
-
totalTextLength
|
|
194
|
+
totalPages: pdfDoc.numPages,
|
|
195
|
+
totalTextLength
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
*/
|
|
202
|
-
async extractPages(pdfData, pageNumbersParam, mergePages, includePageBreaks) {
|
|
203
|
-
// Parse page numbers
|
|
204
|
-
let pageNumbers = [];
|
|
205
|
-
if (pageNumbersParam) {
|
|
206
|
-
if (Array.isArray(pageNumbersParam)) {
|
|
207
|
-
pageNumbers = pageNumbersParam.map(n => parseInt(n.toString()));
|
|
208
|
-
}
|
|
209
|
-
else if (typeof pageNumbersParam === 'string') {
|
|
210
|
-
// Support comma-separated list
|
|
211
|
-
pageNumbers = pageNumbersParam.split(',').map(n => parseInt(n.trim()));
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
pageNumbers = [parseInt(pageNumbersParam.toString())];
|
|
215
|
-
}
|
|
216
|
-
}
|
|
199
|
+
async extractPages(pdfDoc, pageNumbersParam, mergePages, includePageBreaks) {
|
|
200
|
+
let pageNumbers = this.parsePageNumbers(pageNumbersParam);
|
|
217
201
|
// Validate page numbers
|
|
218
|
-
pageNumbers = pageNumbers.filter(n =>
|
|
202
|
+
pageNumbers = pageNumbers.filter(n => n > 0 && n <= pdfDoc.numPages);
|
|
219
203
|
if (pageNumbers.length === 0) {
|
|
220
204
|
throw new Error('No valid page numbers specified');
|
|
221
205
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
206
|
+
const pageTexts = [];
|
|
207
|
+
for (const pageNum of pageNumbers) {
|
|
208
|
+
pageTexts.push(await this.getPageText(pdfDoc, pageNum));
|
|
209
|
+
}
|
|
210
|
+
const separator = includePageBreaks ? '\n\n--- PAGE BREAK ---\n\n' : '\n\n';
|
|
211
|
+
const text = pageTexts.join(separator);
|
|
225
212
|
return {
|
|
226
|
-
text
|
|
213
|
+
text,
|
|
227
214
|
requestedPages: pageNumbers,
|
|
228
|
-
totalPages:
|
|
229
|
-
|
|
230
|
-
textLength: pdfData.text.length
|
|
215
|
+
totalPages: pdfDoc.numPages,
|
|
216
|
+
textLength: text.length
|
|
231
217
|
};
|
|
232
218
|
}
|
|
219
|
+
parsePageNumbers(param) {
|
|
220
|
+
if (!param)
|
|
221
|
+
return [];
|
|
222
|
+
if (Array.isArray(param)) {
|
|
223
|
+
return param.map(n => parseInt(String(n))).filter(n => !isNaN(n));
|
|
224
|
+
}
|
|
225
|
+
if (typeof param === 'string') {
|
|
226
|
+
return param.split(',').map(n => parseInt(n.trim())).filter(n => !isNaN(n));
|
|
227
|
+
}
|
|
228
|
+
const parsed = parseInt(String(param));
|
|
229
|
+
return isNaN(parsed) ? [] : [parsed];
|
|
230
|
+
}
|
|
233
231
|
};
|
|
234
232
|
PDFExtractorAction = __decorate([
|
|
235
|
-
RegisterClass(BaseAction, "
|
|
233
|
+
RegisterClass(BaseAction, "__PDFExtractor")
|
|
236
234
|
], PDFExtractorAction);
|
|
237
235
|
export { PDFExtractorAction };
|
|
238
236
|
//# sourceMappingURL=pdf-extractor.action.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-extractor.action.js","sourceRoot":"","sources":["../../../src/custom/files/pdf-extractor.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,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AAC;IACzC,CAAC;CACJ,CAAA;AA3MY,kBAAkB;IAD9B,aAAa,CAAC,UAAU,EAAE,gBAAgB,CAAC;GAC/B,kBAAkB,CA2M9B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import { BaseFileHandlerAction } from "../utilities/base-file-handler.js";
|
|
3
|
+
/**
|
|
4
|
+
* Returns a summary of the current state of an in-progress document.
|
|
5
|
+
* Useful for the LLM to check what it has built so far before adding more or finalizing.
|
|
6
|
+
*
|
|
7
|
+
* Parameters:
|
|
8
|
+
* - Handle (required): the document handle from Create Document
|
|
9
|
+
*
|
|
10
|
+
* Output:
|
|
11
|
+
* - Document type, filename, section count
|
|
12
|
+
* - Per-section: ID, operation count, content summary
|
|
13
|
+
*/
|
|
14
|
+
export declare class PreviewDocumentAction extends BaseFileHandlerAction {
|
|
15
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=preview-document.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-document.action.d.ts","sourceRoot":"","sources":["../../../src/custom/files/preview-document.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAGnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAGvE;;;;;;;;;;GAUG;AACH,qBACa,qBAAsB,SAAQ,qBAAqB;cAE5C,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAwB1F"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { RegisterClass } from "@memberjunction/global";
|
|
8
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
9
|
+
import { BaseFileHandlerAction } from "../utilities/base-file-handler.js";
|
|
10
|
+
import { ArtifactBuilderService } from "../utilities/artifact-builder-service.js";
|
|
11
|
+
/**
|
|
12
|
+
* Returns a summary of the current state of an in-progress document.
|
|
13
|
+
* Useful for the LLM to check what it has built so far before adding more or finalizing.
|
|
14
|
+
*
|
|
15
|
+
* Parameters:
|
|
16
|
+
* - Handle (required): the document handle from Create Document
|
|
17
|
+
*
|
|
18
|
+
* Output:
|
|
19
|
+
* - Document type, filename, section count
|
|
20
|
+
* - Per-section: ID, operation count, content summary
|
|
21
|
+
*/
|
|
22
|
+
let PreviewDocumentAction = class PreviewDocumentAction extends BaseFileHandlerAction {
|
|
23
|
+
async InternalRunAction(params) {
|
|
24
|
+
try {
|
|
25
|
+
const handle = this.getParamValue(params, 'handle');
|
|
26
|
+
if (!handle) {
|
|
27
|
+
return { Success: false, Message: "Handle parameter is required", ResultCode: "MISSING_HANDLE" };
|
|
28
|
+
}
|
|
29
|
+
const service = ArtifactBuilderService.Instance;
|
|
30
|
+
const preview = service.GetPreview(handle.toString());
|
|
31
|
+
return {
|
|
32
|
+
Success: true,
|
|
33
|
+
ResultCode: "SUCCESS",
|
|
34
|
+
Message: JSON.stringify(preview, null, 2)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return {
|
|
39
|
+
Success: false,
|
|
40
|
+
Message: `Failed to preview document: ${error instanceof Error ? error.message : String(error)}`,
|
|
41
|
+
ResultCode: "PREVIEW_FAILED"
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
PreviewDocumentAction = __decorate([
|
|
47
|
+
RegisterClass(BaseAction, "__PreviewDocument")
|
|
48
|
+
], PreviewDocumentAction);
|
|
49
|
+
export { PreviewDocumentAction };
|
|
50
|
+
//# sourceMappingURL=preview-document.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-document.action.js","sourceRoot":"","sources":["../../../src/custom/files/preview-document.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E;;;;;;;;;;GAUG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,qBAAqB;IAElD,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACpD,IAAI,CAAC,MAAM,EAAE,CAAC;gBACV,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,8BAA8B,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC;YACrG,CAAC;YAED,MAAM,OAAO,GAAG,sBAAsB,CAAC,QAAQ,CAAC;YAChD,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;YAEtD,OAAO;gBACH,OAAO,EAAE,IAAI;gBACb,UAAU,EAAE,SAAS;gBACrB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;aAC5C,CAAC;QAEN,CAAC;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