@memberjunction/core-actions 6.3.0-edge.0 → 6.3.0-edge.2
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 +13 -0
- package/dist/custom/ai/agent-channel.action.d.ts +29 -0
- package/dist/custom/ai/agent-channel.action.d.ts.map +1 -0
- package/dist/custom/ai/agent-channel.action.js +843 -0
- package/dist/custom/ai/agent-channel.action.js.map +1 -0
- package/dist/custom/ai/chief-of-staff-approval-helper.d.ts +16 -0
- package/dist/custom/ai/chief-of-staff-approval-helper.d.ts.map +1 -0
- package/dist/custom/ai/chief-of-staff-approval-helper.js +63 -0
- package/dist/custom/ai/chief-of-staff-approval-helper.js.map +1 -0
- package/dist/custom/ai/chief-of-staff-core-reads.action.d.ts +64 -0
- package/dist/custom/ai/chief-of-staff-core-reads.action.d.ts.map +1 -0
- package/dist/custom/ai/chief-of-staff-core-reads.action.js +1097 -0
- package/dist/custom/ai/chief-of-staff-core-reads.action.js.map +1 -0
- package/dist/custom/ai/chief-of-staff-rhythms-suggestions.action.d.ts +28 -0
- package/dist/custom/ai/chief-of-staff-rhythms-suggestions.action.d.ts.map +1 -0
- package/dist/custom/ai/chief-of-staff-rhythms-suggestions.action.js +817 -0
- package/dist/custom/ai/chief-of-staff-rhythms-suggestions.action.js.map +1 -0
- package/dist/custom/ai/configure-agent-user-policy.action.d.ts +1 -0
- package/dist/custom/ai/configure-agent-user-policy.action.d.ts.map +1 -1
- package/dist/custom/ai/configure-agent-user-policy.action.js +5 -1
- package/dist/custom/ai/configure-agent-user-policy.action.js.map +1 -1
- package/dist/custom/ai/manage-my-agent-instance.action.d.ts +39 -0
- package/dist/custom/ai/manage-my-agent-instance.action.d.ts.map +1 -0
- package/dist/custom/ai/manage-my-agent-instance.action.js +752 -0
- package/dist/custom/ai/manage-my-agent-instance.action.js.map +1 -0
- package/dist/custom/ai/prepare-outbound-call-brief.action.js +1 -1
- package/dist/custom/ai/prepare-outbound-call-brief.action.js.map +1 -1
- package/dist/custom/ai/schedule-next-agent-wake.action.d.ts +2 -0
- package/dist/custom/ai/schedule-next-agent-wake.action.d.ts.map +1 -1
- package/dist/custom/ai/schedule-next-agent-wake.action.js +105 -2
- package/dist/custom/ai/schedule-next-agent-wake.action.js.map +1 -1
- package/dist/custom/ai/send-inter-agent-request.action.d.ts +1 -0
- package/dist/custom/ai/send-inter-agent-request.action.d.ts.map +1 -1
- package/dist/custom/ai/send-inter-agent-request.action.js +72 -18
- package/dist/custom/ai/send-inter-agent-request.action.js.map +1 -1
- package/dist/custom/ai/test-runtime-action.action.d.ts.map +1 -1
- package/dist/custom/ai/test-runtime-action.action.js +6 -1
- package/dist/custom/ai/test-runtime-action.action.js.map +1 -1
- package/dist/custom/ai/trigger-agent-wake.action.d.ts +1 -0
- package/dist/custom/ai/trigger-agent-wake.action.d.ts.map +1 -1
- package/dist/custom/ai/trigger-agent-wake.action.js +3 -0
- package/dist/custom/ai/trigger-agent-wake.action.js.map +1 -1
- package/dist/custom/ai/user-scoped-communication.action.d.ts +20 -0
- package/dist/custom/ai/user-scoped-communication.action.d.ts.map +1 -1
- package/dist/custom/ai/user-scoped-communication.action.js +140 -23
- package/dist/custom/ai/user-scoped-communication.action.js.map +1 -1
- package/dist/custom/artifacts/base-governed-artifact.action.d.ts +30 -0
- package/dist/custom/artifacts/base-governed-artifact.action.d.ts.map +1 -0
- package/dist/custom/artifacts/base-governed-artifact.action.js +201 -0
- package/dist/custom/artifacts/base-governed-artifact.action.js.map +1 -0
- package/dist/custom/artifacts/create-governed-artifact.action.d.ts +11 -0
- package/dist/custom/artifacts/create-governed-artifact.action.d.ts.map +1 -0
- package/dist/custom/artifacts/create-governed-artifact.action.js +104 -0
- package/dist/custom/artifacts/create-governed-artifact.action.js.map +1 -0
- package/dist/custom/artifacts/index.d.ts +6 -0
- package/dist/custom/artifacts/index.d.ts.map +1 -0
- package/dist/custom/artifacts/index.js +6 -0
- package/dist/custom/artifacts/index.js.map +1 -0
- package/dist/custom/artifacts/inspect-governed-artifact.action.d.ts +11 -0
- package/dist/custom/artifacts/inspect-governed-artifact.action.d.ts.map +1 -0
- package/dist/custom/artifacts/inspect-governed-artifact.action.js +84 -0
- package/dist/custom/artifacts/inspect-governed-artifact.action.js.map +1 -0
- package/dist/custom/artifacts/list-workspace-artifacts.action.d.ts +11 -0
- package/dist/custom/artifacts/list-workspace-artifacts.action.d.ts.map +1 -0
- package/dist/custom/artifacts/list-workspace-artifacts.action.js +63 -0
- package/dist/custom/artifacts/list-workspace-artifacts.action.js.map +1 -0
- package/dist/custom/artifacts/mutate-governed-artifact.action.d.ts +12 -0
- package/dist/custom/artifacts/mutate-governed-artifact.action.d.ts.map +1 -0
- package/dist/custom/artifacts/mutate-governed-artifact.action.js +110 -0
- package/dist/custom/artifacts/mutate-governed-artifact.action.js.map +1 -0
- package/dist/custom/crud/agent-data-policy-guard.d.ts +9 -1
- package/dist/custom/crud/agent-data-policy-guard.d.ts.map +1 -1
- package/dist/custom/crud/agent-data-policy-guard.js +49 -16
- package/dist/custom/crud/agent-data-policy-guard.js.map +1 -1
- package/dist/custom/data/adhoc-sql-gate.d.ts +40 -0
- package/dist/custom/data/adhoc-sql-gate.d.ts.map +1 -0
- package/dist/custom/data/adhoc-sql-gate.js +102 -0
- package/dist/custom/data/adhoc-sql-gate.js.map +1 -0
- package/dist/custom/data/data-mapper.action.d.ts +8 -0
- package/dist/custom/data/data-mapper.action.d.ts.map +1 -1
- package/dist/custom/data/data-mapper.action.js +21 -3
- package/dist/custom/data/data-mapper.action.js.map +1 -1
- package/dist/custom/data/find-graph-path.action.d.ts +37 -0
- package/dist/custom/data/find-graph-path.action.d.ts.map +1 -0
- package/dist/custom/data/find-graph-path.action.js +114 -0
- package/dist/custom/data/find-graph-path.action.js.map +1 -0
- package/dist/custom/data/get-graph-context.action.d.ts +22 -12
- package/dist/custom/data/get-graph-context.action.d.ts.map +1 -1
- package/dist/custom/data/get-graph-context.action.js +102 -239
- package/dist/custom/data/get-graph-context.action.js.map +1 -1
- package/dist/custom/data/graph-action-params.d.ts +51 -0
- package/dist/custom/data/graph-action-params.d.ts.map +1 -0
- package/dist/custom/data/graph-action-params.js +164 -0
- package/dist/custom/data/graph-action-params.js.map +1 -0
- package/dist/custom/data/mapping-template-guard.d.ts +18 -0
- package/dist/custom/data/mapping-template-guard.d.ts.map +1 -0
- package/dist/custom/data/mapping-template-guard.js +106 -0
- package/dist/custom/data/mapping-template-guard.js.map +1 -0
- package/dist/custom/data/propose-canon-domains.action.d.ts +26 -0
- package/dist/custom/data/propose-canon-domains.action.d.ts.map +1 -0
- package/dist/custom/data/propose-canon-domains.action.js +105 -0
- package/dist/custom/data/propose-canon-domains.action.js.map +1 -0
- package/dist/custom/data/run-adhoc-query.action.d.ts +4 -21
- package/dist/custom/data/run-adhoc-query.action.d.ts.map +1 -1
- package/dist/custom/data/run-adhoc-query.action.js +15 -105
- package/dist/custom/data/run-adhoc-query.action.js.map +1 -1
- package/dist/custom/demo/text-analyzer.action.d.ts +8 -0
- package/dist/custom/demo/text-analyzer.action.d.ts.map +1 -1
- package/dist/custom/demo/text-analyzer.action.js +34 -2
- package/dist/custom/demo/text-analyzer.action.js.map +1 -1
- package/dist/custom/files/excel-reader.action.d.ts +14 -0
- package/dist/custom/files/excel-reader.action.d.ts.map +1 -1
- package/dist/custom/files/excel-reader.action.js +51 -6
- package/dist/custom/files/excel-reader.action.js.map +1 -1
- package/dist/custom/github/github-client.d.ts.map +1 -1
- package/dist/custom/github/github-client.js +72 -11
- package/dist/custom/github/github-client.js.map +1 -1
- package/dist/custom/integration/http-request.action.d.ts.map +1 -1
- package/dist/custom/integration/http-request.action.js +5 -1
- package/dist/custom/integration/http-request.action.js.map +1 -1
- package/dist/custom/lists/create-list-from-query.action.d.ts +39 -0
- package/dist/custom/lists/create-list-from-query.action.d.ts.map +1 -0
- package/dist/custom/lists/create-list-from-query.action.js +179 -0
- package/dist/custom/lists/create-list-from-query.action.js.map +1 -0
- package/dist/custom/lists/index.d.ts +2 -0
- package/dist/custom/lists/index.d.ts.map +1 -1
- package/dist/custom/lists/index.js +2 -0
- package/dist/custom/lists/index.js.map +1 -1
- package/dist/custom/lists/refresh-list-from-source.action.d.ts.map +1 -1
- package/dist/custom/lists/refresh-list-from-source.action.js +3 -2
- package/dist/custom/lists/refresh-list-from-source.action.js.map +1 -1
- package/dist/custom/search/scoped-search.action.d.ts +12 -1
- package/dist/custom/search/scoped-search.action.d.ts.map +1 -1
- package/dist/custom/search/scoped-search.action.js +44 -6
- package/dist/custom/search/scoped-search.action.js.map +1 -1
- package/dist/custom/search/search-query.util.d.ts +24 -0
- package/dist/custom/search/search-query.util.d.ts.map +1 -0
- package/dist/custom/search/search-query.util.js +211 -0
- package/dist/custom/search/search-query.util.js.map +1 -0
- package/dist/custom/search/search.action.js +2 -2
- package/dist/custom/search/search.action.js.map +1 -1
- package/dist/custom/user-management/validate-email-unique.action.d.ts.map +1 -1
- package/dist/custom/user-management/validate-email-unique.action.js +2 -3
- package/dist/custom/user-management/validate-email-unique.action.js.map +1 -1
- package/dist/custom/utilities/refresh-and-snapshot-artifact.action.d.ts +48 -0
- package/dist/custom/utilities/refresh-and-snapshot-artifact.action.d.ts.map +1 -0
- package/dist/custom/utilities/refresh-and-snapshot-artifact.action.js +248 -0
- package/dist/custom/utilities/refresh-and-snapshot-artifact.action.js.map +1 -0
- package/dist/custom/web/rss-feed-parsing.d.ts.map +1 -1
- package/dist/custom/web/rss-feed-parsing.js +80 -6
- package/dist/custom/web/rss-feed-parsing.js.map +1 -1
- package/dist/custom/web/url-link-validator.action.d.ts.map +1 -1
- package/dist/custom/web/url-link-validator.action.js +3 -1
- package/dist/custom/web/url-link-validator.action.js.map +1 -1
- package/dist/custom/web/web-content-transforms.d.ts +35 -0
- package/dist/custom/web/web-content-transforms.d.ts.map +1 -0
- package/dist/custom/web/web-content-transforms.js +157 -0
- package/dist/custom/web/web-content-transforms.js.map +1 -0
- package/dist/custom/web/web-page-content.action.d.ts +4 -20
- package/dist/custom/web/web-page-content.action.d.ts.map +1 -1
- package/dist/custom/web/web-page-content.action.js +23 -168
- package/dist/custom/web/web-page-content.action.js.map +1 -1
- package/dist/custom/web/worker/ServeWorkerRequests.d.ts +26 -0
- package/dist/custom/web/worker/ServeWorkerRequests.d.ts.map +1 -0
- package/dist/custom/web/worker/ServeWorkerRequests.js +33 -0
- package/dist/custom/web/worker/ServeWorkerRequests.js.map +1 -0
- package/dist/custom/web/worker/WebContentWorker.d.ts +9 -0
- package/dist/custom/web/worker/WebContentWorker.d.ts.map +1 -0
- package/dist/custom/web/worker/WebContentWorker.js +11 -0
- package/dist/custom/web/worker/WebContentWorker.js.map +1 -0
- package/dist/custom/web/worker/WebContentWorkerHandler.d.ts +11 -0
- package/dist/custom/web/worker/WebContentWorkerHandler.d.ts.map +1 -0
- package/dist/custom/web/worker/WebContentWorkerHandler.js +19 -0
- package/dist/custom/web/worker/WebContentWorkerHandler.js.map +1 -0
- package/dist/custom/web/worker/WebContentWorkerHost.d.ts +26 -0
- package/dist/custom/web/worker/WebContentWorkerHost.d.ts.map +1 -0
- package/dist/custom/web/worker/WebContentWorkerHost.js +37 -0
- package/dist/custom/web/worker/WebContentWorkerHost.js.map +1 -0
- package/dist/custom/web/worker/WebContentWorkerProtocol.d.ts +23 -0
- package/dist/custom/web/worker/WebContentWorkerProtocol.d.ts.map +1 -0
- package/dist/custom/web/worker/WebContentWorkerProtocol.js +8 -0
- package/dist/custom/web/worker/WebContentWorkerProtocol.js.map +1 -0
- package/dist/custom/web/worker/WorkerProtocol.d.ts +36 -0
- package/dist/custom/web/worker/WorkerProtocol.d.ts.map +1 -0
- package/dist/custom/web/worker/WorkerProtocol.js +9 -0
- package/dist/custom/web/worker/WorkerProtocol.js.map +1 -0
- package/dist/custom/web/worker/WorkerThreadHost.d.ts +88 -0
- package/dist/custom/web/worker/WorkerThreadHost.d.ts.map +1 -0
- package/dist/custom/web/worker/WorkerThreadHost.js +174 -0
- package/dist/custom/web/worker/WorkerThreadHost.js.map +1 -0
- package/dist/custom/workflow/loop.action.d.ts +8 -0
- package/dist/custom/workflow/loop.action.d.ts.map +1 -1
- package/dist/custom/workflow/loop.action.js +36 -4
- package/dist/custom/workflow/loop.action.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +45 -45
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-link-validator.action.js","sourceRoot":"","sources":["../../../src/custom/web/url-link-validator.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,UAAU;IAA/C;;QAEc,oBAAe,GAAG,IAAI,CAAC,CAAC,YAAY;QACpC,gBAAW,GAAG,KAAK,CAAC,CAAC,aAAa;QAClC,aAAQ,GAAG,EAAE,CAAC,CAAC,0CAA0C;
|
|
1
|
+
{"version":3,"file":"url-link-validator.action.js","sourceRoot":"","sources":["../../../src/custom/web/url-link-validator.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,UAAU;IAA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E;gBAC3E,mDAAmD;gBACnD,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,WAAW,QAAQ,EAAE,EAAE;oBACpD,MAAM,EAAE,MAAM;oBACd,MAAM,EAAE,UAAU,CAAC,MAAM;iBAC5B,CAAC,CAAC;gBAEH,YAAY,CAAC,SAAS,CAAC,CAAC;gBAExB,OAAO;oBACH,OAAO,EAAE,IAAI;oBACb,QAAQ;oBACR,QAAQ,EAAE,KAAK;oBACf,KAAK,EAAE,IAAI;iBACd,CAAC;YACN,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,YAAY,CAAC,SAAS,CAAC,CAAC;gBACxB,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,QAAQ;oBACR,QAAQ,EAAE,KAAK;oBACf,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;iBAChE,CAAC;YACN,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO;gBACH,OAAO,EAAE,KAAK;gBACd,QAAQ;gBACR,QAAQ,EAAE,KAAK;gBACf,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAChE,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAA;AAjRY,sBAAsB;IADlC,aAAa,CAAC,UAAU,EAAE,oBAAoB,CAAC;GACnC,sBAAsB,CAiRlC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The CPU-heavy half of {@link WebPageContentAction}: turning fetched HTML and PDF
|
|
3
|
+
* bytes into text, Markdown and metadata. jsdom, turndown and pdf-parse are synchronous, and on a
|
|
4
|
+
* real page they block the thread they run on for up to seconds (1.4s for HTML-to-Markdown and
|
|
5
|
+
* 0.7s for one PDF in a live MJAPI profile, MJ #5510). These functions have no MemberJunction
|
|
6
|
+
* imports so the same code runs on the worker thread {@link WebContentWorkerHost} owns, or
|
|
7
|
+
* in-process when no worker is available.
|
|
8
|
+
*
|
|
9
|
+
* @module @memberjunction/core-actions
|
|
10
|
+
*/
|
|
11
|
+
import TurndownService from 'turndown';
|
|
12
|
+
/** What to produce from an HTML page. */
|
|
13
|
+
export interface HtmlTransformOptions {
|
|
14
|
+
OutputType: string;
|
|
15
|
+
ExtractMainContent: boolean;
|
|
16
|
+
IncludeMetadata: boolean;
|
|
17
|
+
MaxLength: number;
|
|
18
|
+
}
|
|
19
|
+
/** What to produce from a PDF. */
|
|
20
|
+
export interface PdfTransformOptions {
|
|
21
|
+
OutputType: string;
|
|
22
|
+
IncludeMetadata: boolean;
|
|
23
|
+
MaxLength: number;
|
|
24
|
+
}
|
|
25
|
+
/** The shared HTML-to-Markdown converter, configured the way the action always has. */
|
|
26
|
+
export declare function GetTurndown(): TurndownService;
|
|
27
|
+
/** Truncates content to the given length, marking the cut with an ellipsis. */
|
|
28
|
+
export declare function TruncateContent(content: string, maxLength: number): string;
|
|
29
|
+
/** Converts an HTML page into the requested output, the shape `processHtml` has always returned. */
|
|
30
|
+
export declare function TransformHtml(html: string, options: HtmlTransformOptions): Record<string, unknown>;
|
|
31
|
+
/** Extracts a PDF's text and metadata, the shape `processPdf` has always returned. */
|
|
32
|
+
export declare function TransformPdf(data: Uint8Array, options: PdfTransformOptions): Promise<Record<string, unknown>>;
|
|
33
|
+
/** Plain text, without scripts or styles. */
|
|
34
|
+
export declare function HtmlToText(html: string): string;
|
|
35
|
+
//# sourceMappingURL=web-content-transforms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-content-transforms.d.ts","sourceRoot":"","sources":["../../../src/custom/web/web-content-transforms.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,eAAe,MAAM,UAAU,CAAC;AAIvC,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,kCAAkC;AAClC,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AAID,uFAAuF;AACvF,wBAAgB,WAAW,IAAI,eAAe,CAS7C;AAED,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAK1E;AAED,oGAAoG;AACpG,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAkClG;AAED,sFAAsF;AACtF,wBAAsB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA8BnH;AAiDD,6CAA6C;AAC7C,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK/C"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The CPU-heavy half of {@link WebPageContentAction}: turning fetched HTML and PDF
|
|
3
|
+
* bytes into text, Markdown and metadata. jsdom, turndown and pdf-parse are synchronous, and on a
|
|
4
|
+
* real page they block the thread they run on for up to seconds (1.4s for HTML-to-Markdown and
|
|
5
|
+
* 0.7s for one PDF in a live MJAPI profile, MJ #5510). These functions have no MemberJunction
|
|
6
|
+
* imports so the same code runs on the worker thread {@link WebContentWorkerHost} owns, or
|
|
7
|
+
* in-process when no worker is available.
|
|
8
|
+
*
|
|
9
|
+
* @module @memberjunction/core-actions
|
|
10
|
+
*/
|
|
11
|
+
import TurndownService from 'turndown';
|
|
12
|
+
import { JSDOM } from 'jsdom';
|
|
13
|
+
import { ParsePdf } from '@memberjunction/document-parsing';
|
|
14
|
+
let turndownService = null;
|
|
15
|
+
/** The shared HTML-to-Markdown converter, configured the way the action always has. */
|
|
16
|
+
export function GetTurndown() {
|
|
17
|
+
if (!turndownService) {
|
|
18
|
+
turndownService = new TurndownService({
|
|
19
|
+
headingStyle: 'atx',
|
|
20
|
+
codeBlockStyle: 'fenced',
|
|
21
|
+
emDelimiter: '*',
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return turndownService;
|
|
25
|
+
}
|
|
26
|
+
/** Truncates content to the given length, marking the cut with an ellipsis. */
|
|
27
|
+
export function TruncateContent(content, maxLength) {
|
|
28
|
+
if (content.length <= maxLength) {
|
|
29
|
+
return content;
|
|
30
|
+
}
|
|
31
|
+
return content.substring(0, maxLength) + '...';
|
|
32
|
+
}
|
|
33
|
+
/** Converts an HTML page into the requested output, the shape `processHtml` has always returned. */
|
|
34
|
+
export function TransformHtml(html, options) {
|
|
35
|
+
const { OutputType: outputType, ExtractMainContent: extractMain, IncludeMetadata: includeMetadata, MaxLength: maxLength } = options;
|
|
36
|
+
const result = {
|
|
37
|
+
detectedType: 'html',
|
|
38
|
+
outputType,
|
|
39
|
+
extractMainContent: extractMain,
|
|
40
|
+
};
|
|
41
|
+
if (includeMetadata) {
|
|
42
|
+
result.metadata = extractHtmlMetadata(html);
|
|
43
|
+
}
|
|
44
|
+
const contentHtml = extractMain ? extractMainContent(html) : html;
|
|
45
|
+
let content;
|
|
46
|
+
if (outputType === 'markdown') {
|
|
47
|
+
content = GetTurndown().turndown(contentHtml);
|
|
48
|
+
}
|
|
49
|
+
else if (outputType === 'text') {
|
|
50
|
+
content = HtmlToText(contentHtml);
|
|
51
|
+
}
|
|
52
|
+
else if (outputType === 'json') {
|
|
53
|
+
const dom = new JSDOM(contentHtml);
|
|
54
|
+
result.content = {
|
|
55
|
+
html: TruncateContent(contentHtml, maxLength),
|
|
56
|
+
text: TruncateContent(HtmlToText(contentHtml), maxLength),
|
|
57
|
+
markdown: TruncateContent(GetTurndown().turndown(contentHtml), maxLength),
|
|
58
|
+
structure: extractStructure(dom.window.document),
|
|
59
|
+
};
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
content = contentHtml;
|
|
64
|
+
}
|
|
65
|
+
result.content = TruncateContent(content, maxLength);
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
/** Extracts a PDF's text and metadata, the shape `processPdf` has always returned. */
|
|
69
|
+
export async function TransformPdf(data, options) {
|
|
70
|
+
const { OutputType: outputType, IncludeMetadata: includeMetadata, MaxLength: maxLength } = options;
|
|
71
|
+
const pdfData = await ParsePdf(data);
|
|
72
|
+
const result = {
|
|
73
|
+
detectedType: 'pdf',
|
|
74
|
+
outputType,
|
|
75
|
+
};
|
|
76
|
+
if (includeMetadata) {
|
|
77
|
+
result.metadata = {
|
|
78
|
+
pages: pdfData.Pages,
|
|
79
|
+
info: pdfData.Info,
|
|
80
|
+
version: pdfData.Version,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const text = pdfData.Text || '';
|
|
84
|
+
if (outputType === 'json') {
|
|
85
|
+
result.content = {
|
|
86
|
+
text: TruncateContent(text, maxLength),
|
|
87
|
+
pages: pdfData.Pages,
|
|
88
|
+
metadata: pdfData.Info,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
result.content = TruncateContent(text, maxLength);
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
/** Title, meta tags and canonical URL. */
|
|
97
|
+
function extractHtmlMetadata(html) {
|
|
98
|
+
const dom = new JSDOM(html);
|
|
99
|
+
const doc = dom.window.document;
|
|
100
|
+
const metadata = {};
|
|
101
|
+
const title = doc.querySelector('title');
|
|
102
|
+
if (title) {
|
|
103
|
+
metadata.title = title.textContent?.trim();
|
|
104
|
+
}
|
|
105
|
+
const metas = doc.querySelectorAll('meta');
|
|
106
|
+
metas.forEach((meta) => {
|
|
107
|
+
const name = meta.getAttribute('name') || meta.getAttribute('property');
|
|
108
|
+
const content = meta.getAttribute('content');
|
|
109
|
+
if (name && content) {
|
|
110
|
+
metadata[name] = content;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
const canonical = doc.querySelector('link[rel="canonical"]');
|
|
114
|
+
if (canonical) {
|
|
115
|
+
metadata.canonical = canonical.getAttribute('href');
|
|
116
|
+
}
|
|
117
|
+
return metadata;
|
|
118
|
+
}
|
|
119
|
+
/** The page's main content container, or the body without navigation chrome. */
|
|
120
|
+
function extractMainContent(html) {
|
|
121
|
+
const dom = new JSDOM(html);
|
|
122
|
+
const doc = dom.window.document;
|
|
123
|
+
doc.querySelectorAll('script, style, nav, header, footer, aside').forEach((el) => el.remove());
|
|
124
|
+
const mainSelectors = ['main', 'article', '[role="main"]', '.content', '#content', '.post', '.article'];
|
|
125
|
+
for (const selector of mainSelectors) {
|
|
126
|
+
const element = doc.querySelector(selector);
|
|
127
|
+
if (element && element.textContent && element.textContent.trim().length > 100) {
|
|
128
|
+
return element.innerHTML;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const body = doc.querySelector('body');
|
|
132
|
+
return body ? body.innerHTML : html;
|
|
133
|
+
}
|
|
134
|
+
/** Plain text, without scripts or styles. */
|
|
135
|
+
export function HtmlToText(html) {
|
|
136
|
+
const dom = new JSDOM(html);
|
|
137
|
+
const doc = dom.window.document;
|
|
138
|
+
doc.querySelectorAll('script, style').forEach((el) => el.remove());
|
|
139
|
+
return doc.body.textContent || '';
|
|
140
|
+
}
|
|
141
|
+
/** Headings, links and images. */
|
|
142
|
+
function extractStructure(doc) {
|
|
143
|
+
const headings = Array.from(doc.querySelectorAll('h1, h2, h3, h4, h5, h6')).map((h) => ({
|
|
144
|
+
level: parseInt(h.tagName[1]),
|
|
145
|
+
text: h.textContent?.trim() || '',
|
|
146
|
+
}));
|
|
147
|
+
const links = Array.from(doc.querySelectorAll('a[href]')).map((a) => ({
|
|
148
|
+
url: a.getAttribute('href'),
|
|
149
|
+
text: a.textContent?.trim() || '',
|
|
150
|
+
}));
|
|
151
|
+
const images = Array.from(doc.querySelectorAll('img[src]')).map((img) => ({
|
|
152
|
+
src: img.getAttribute('src'),
|
|
153
|
+
alt: img.getAttribute('alt') || '',
|
|
154
|
+
}));
|
|
155
|
+
return { headings, links, images };
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=web-content-transforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-content-transforms.js","sourceRoot":"","sources":["../../../src/custom/web/web-content-transforms.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,eAAe,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAiB5D,IAAI,eAAe,GAA2B,IAAI,CAAC;AAEnD,uFAAuF;AACvF,MAAM,UAAU,WAAW;IACzB,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,eAAe,GAAG,IAAI,eAAe,CAAC;YACpC,YAAY,EAAE,KAAK;YACnB,cAAc,EAAE,QAAQ;YACxB,WAAW,EAAE,GAAG;SACjB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,SAAiB;IAChE,IAAI,OAAO,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;AACjD,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,OAA6B;IACvE,MAAM,EAAE,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AAC,GAAG,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACpE,GAAG,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC;QAC3B,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE;KAClC,CAAC,CAAC,CAAC;IACJ,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACxE,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC;QAC5B,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE;KACnC,CAAC,CAAC,CAAC;IACJ,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -46,8 +46,6 @@ import { BaseAction } from "@memberjunction/actions";
|
|
|
46
46
|
export declare class WebPageContentAction extends BaseAction {
|
|
47
47
|
private readonly MAX_CONTENT_SIZE;
|
|
48
48
|
private readonly MAX_IMAGE_SIZE;
|
|
49
|
-
private turndown;
|
|
50
|
-
constructor();
|
|
51
49
|
/**
|
|
52
50
|
* Executes web content retrieval and processing
|
|
53
51
|
*
|
|
@@ -78,7 +76,8 @@ export declare class WebPageContentAction extends BaseAction {
|
|
|
78
76
|
*/
|
|
79
77
|
private processJson;
|
|
80
78
|
/**
|
|
81
|
-
* Process PDF content
|
|
79
|
+
* Process PDF content. Parsing runs on the web-content worker thread when one is available:
|
|
80
|
+
* pdf-parse is synchronous and blocks the thread it runs on (MJ #5510).
|
|
82
81
|
*/
|
|
83
82
|
private processPdf;
|
|
84
83
|
/**
|
|
@@ -94,7 +93,8 @@ export declare class WebPageContentAction extends BaseAction {
|
|
|
94
93
|
*/
|
|
95
94
|
private processXml;
|
|
96
95
|
/**
|
|
97
|
-
* Process HTML content
|
|
96
|
+
* Process HTML content. Conversion runs on the web-content worker thread when one is
|
|
97
|
+
* available: jsdom and turndown are synchronous and block the thread they run on (MJ #5510).
|
|
98
98
|
*/
|
|
99
99
|
private processHtml;
|
|
100
100
|
/**
|
|
@@ -105,22 +105,6 @@ export declare class WebPageContentAction extends BaseAction {
|
|
|
105
105
|
* Process plain text content
|
|
106
106
|
*/
|
|
107
107
|
private processText;
|
|
108
|
-
/**
|
|
109
|
-
* Extracts HTML metadata
|
|
110
|
-
*/
|
|
111
|
-
private extractHtmlMetadata;
|
|
112
|
-
/**
|
|
113
|
-
* Attempts to extract main content from HTML
|
|
114
|
-
*/
|
|
115
|
-
private extractMainContent;
|
|
116
|
-
/**
|
|
117
|
-
* Converts HTML to plain text
|
|
118
|
-
*/
|
|
119
|
-
private htmlToText;
|
|
120
|
-
/**
|
|
121
|
-
* Extracts document structure from HTML
|
|
122
|
-
*/
|
|
123
|
-
private extractStructure;
|
|
124
108
|
/**
|
|
125
109
|
* Converts CSV data to markdown table
|
|
126
110
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-page-content.action.d.ts","sourceRoot":"","sources":["../../../src/custom/web/web-page-content.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AASrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,qBACa,oBAAqB,SAAQ,UAAU;IAEhD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAoB;IACrD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAmB;
|
|
1
|
+
{"version":3,"file":"web-page-content.action.d.ts","sourceRoot":"","sources":["../../../src/custom/web/web-page-content.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AASrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,qBACa,oBAAqB,SAAQ,UAAU;IAEhD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAoB;IACrD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAmB;IAElD;;;;;;;;;;;OAWG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgHvF;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA6BzB;;OAEG;YACW,eAAe;IAuC7B;;OAEG;IACH,OAAO,CAAC,eAAe;IAgBvB;;OAEG;YACW,WAAW;IA6BzB;;;OAGG;YACW,UAAU;IASxB;;OAEG;YACW,WAAW;IAsCzB;;OAEG;YACW,UAAU;IAgCxB;;OAEG;YACW,UAAU;IAiCxB;;;OAGG;YACW,WAAW;IAezB;;OAEG;YACW,YAAY;IA8B1B;;OAEG;YACW,WAAW;IAoBzB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAwB1B;;OAEG;IACH,OAAO,CAAC,eAAe;IAIvB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAmBzB;;OAEG;YACW,cAAc;IA6C5B;;OAEG;IACH,OAAO,CAAC,WAAW;IAKnB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAYxB;;OAEG;IACH,OAAO,CAAC,aAAa;IAKrB;;OAEG;IACH,OAAO,CAAC,KAAK;CAGhB"}
|
|
@@ -4,15 +4,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
7
|
import { BaseAction } from "@memberjunction/actions";
|
|
11
8
|
import { RegisterClass } from "@memberjunction/global";
|
|
12
9
|
import { SafeFetch, SSRFError, DrainResponseBody } from "@memberjunction/network-utils";
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
10
|
+
import { GetTurndown, HtmlToText, TransformHtml, TransformPdf, TruncateContent } from './web-content-transforms.js';
|
|
11
|
+
import { WebContentWorkerHost } from './worker/WebContentWorkerHost.js';
|
|
12
|
+
import { ParseWordToHtml } from '@memberjunction/document-parsing';
|
|
16
13
|
import xml2js from 'xml2js';
|
|
17
14
|
import Papa from 'papaparse';
|
|
18
15
|
/**
|
|
@@ -60,14 +57,9 @@ import Papa from 'papaparse';
|
|
|
60
57
|
*/
|
|
61
58
|
let WebPageContentAction = class WebPageContentAction extends BaseAction {
|
|
62
59
|
constructor() {
|
|
63
|
-
super();
|
|
60
|
+
super(...arguments);
|
|
64
61
|
this.MAX_CONTENT_SIZE = 10 * 1024 * 1024; // 10MB limit
|
|
65
62
|
this.MAX_IMAGE_SIZE = 5 * 1024 * 1024; // 5MB limit for images
|
|
66
|
-
this.turndown = new TurndownService({
|
|
67
|
-
headingStyle: 'atx',
|
|
68
|
-
codeBlockStyle: 'fenced',
|
|
69
|
-
emDelimiter: '*'
|
|
70
|
-
});
|
|
71
63
|
}
|
|
72
64
|
/**
|
|
73
65
|
* Executes web content retrieval and processing
|
|
@@ -293,34 +285,16 @@ let WebPageContentAction = class WebPageContentAction extends BaseAction {
|
|
|
293
285
|
return result;
|
|
294
286
|
}
|
|
295
287
|
/**
|
|
296
|
-
* Process PDF content
|
|
288
|
+
* Process PDF content. Parsing runs on the web-content worker thread when one is available:
|
|
289
|
+
* pdf-parse is synchronous and blocks the thread it runs on (MJ #5510).
|
|
297
290
|
*/
|
|
298
291
|
async processPdf(response, outputType, includeMetadata, maxLength) {
|
|
299
|
-
const
|
|
300
|
-
const
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
if (includeMetadata) {
|
|
306
|
-
result.metadata = {
|
|
307
|
-
pages: pdfData.Pages,
|
|
308
|
-
info: pdfData.Info,
|
|
309
|
-
version: pdfData.Version
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
const text = pdfData.Text || '';
|
|
313
|
-
if (outputType === 'json') {
|
|
314
|
-
result.content = {
|
|
315
|
-
text: this.truncateContent(text, maxLength),
|
|
316
|
-
pages: pdfData.Pages,
|
|
317
|
-
metadata: pdfData.Info
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
result.content = this.truncateContent(text, maxLength);
|
|
322
|
-
}
|
|
323
|
-
return result;
|
|
292
|
+
const data = new Uint8Array(await response.arrayBuffer());
|
|
293
|
+
const options = { OutputType: outputType, IncludeMetadata: includeMetadata, MaxLength: maxLength };
|
|
294
|
+
const host = WebContentWorkerHost.Instance;
|
|
295
|
+
return host.IsAvailable
|
|
296
|
+
? host.Run({ Kind: 'pdf', Data: data, Options: options })
|
|
297
|
+
: TransformPdf(data, options);
|
|
324
298
|
}
|
|
325
299
|
/**
|
|
326
300
|
* Process DOCX content
|
|
@@ -341,13 +315,13 @@ let WebPageContentAction = class WebPageContentAction extends BaseAction {
|
|
|
341
315
|
}
|
|
342
316
|
let content;
|
|
343
317
|
if (outputType === 'markdown') {
|
|
344
|
-
content =
|
|
318
|
+
content = GetTurndown().turndown(htmlContent);
|
|
345
319
|
}
|
|
346
320
|
else if (outputType === 'html') {
|
|
347
321
|
content = htmlContent;
|
|
348
322
|
}
|
|
349
323
|
else {
|
|
350
|
-
content =
|
|
324
|
+
content = HtmlToText(htmlContent);
|
|
351
325
|
}
|
|
352
326
|
if (outputType === 'json') {
|
|
353
327
|
result.content = {
|
|
@@ -425,44 +399,16 @@ let WebPageContentAction = class WebPageContentAction extends BaseAction {
|
|
|
425
399
|
return result;
|
|
426
400
|
}
|
|
427
401
|
/**
|
|
428
|
-
* Process HTML content
|
|
402
|
+
* Process HTML content. Conversion runs on the web-content worker thread when one is
|
|
403
|
+
* available: jsdom and turndown are synchronous and block the thread they run on (MJ #5510).
|
|
429
404
|
*/
|
|
430
405
|
async processHtml(response, outputType, extractMain, includeMetadata, maxLength) {
|
|
431
406
|
const html = await response.text();
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
if (includeMetadata) {
|
|
438
|
-
result.metadata = this.extractHtmlMetadata(html);
|
|
439
|
-
}
|
|
440
|
-
let contentHtml = html;
|
|
441
|
-
if (extractMain) {
|
|
442
|
-
contentHtml = this.extractMainContent(html);
|
|
443
|
-
}
|
|
444
|
-
let content;
|
|
445
|
-
if (outputType === 'markdown') {
|
|
446
|
-
content = this.turndown.turndown(contentHtml);
|
|
447
|
-
}
|
|
448
|
-
else if (outputType === 'text') {
|
|
449
|
-
content = this.htmlToText(contentHtml);
|
|
450
|
-
}
|
|
451
|
-
else if (outputType === 'json') {
|
|
452
|
-
const dom = new JSDOM(contentHtml);
|
|
453
|
-
result.content = {
|
|
454
|
-
html: this.truncateContent(contentHtml, maxLength),
|
|
455
|
-
text: this.truncateContent(this.htmlToText(contentHtml), maxLength),
|
|
456
|
-
markdown: this.truncateContent(this.turndown.turndown(contentHtml), maxLength),
|
|
457
|
-
structure: this.extractStructure(dom.window.document)
|
|
458
|
-
};
|
|
459
|
-
return result;
|
|
460
|
-
}
|
|
461
|
-
else {
|
|
462
|
-
content = contentHtml;
|
|
463
|
-
}
|
|
464
|
-
result.content = this.truncateContent(content, maxLength);
|
|
465
|
-
return result;
|
|
407
|
+
const options = { OutputType: outputType, ExtractMainContent: extractMain, IncludeMetadata: includeMetadata, MaxLength: maxLength };
|
|
408
|
+
const host = WebContentWorkerHost.Instance;
|
|
409
|
+
return host.IsAvailable
|
|
410
|
+
? host.Run({ Kind: 'html', Html: html, Options: options })
|
|
411
|
+
: TransformHtml(html, options);
|
|
466
412
|
}
|
|
467
413
|
/**
|
|
468
414
|
* Process image content
|
|
@@ -511,93 +457,6 @@ let WebPageContentAction = class WebPageContentAction extends BaseAction {
|
|
|
511
457
|
}
|
|
512
458
|
return result;
|
|
513
459
|
}
|
|
514
|
-
/**
|
|
515
|
-
* Extracts HTML metadata
|
|
516
|
-
*/
|
|
517
|
-
extractHtmlMetadata(html) {
|
|
518
|
-
const dom = new JSDOM(html);
|
|
519
|
-
const doc = dom.window.document;
|
|
520
|
-
const metadata = {};
|
|
521
|
-
// Title
|
|
522
|
-
const title = doc.querySelector('title');
|
|
523
|
-
if (title) {
|
|
524
|
-
metadata.title = title.textContent?.trim();
|
|
525
|
-
}
|
|
526
|
-
// Meta tags
|
|
527
|
-
const metas = doc.querySelectorAll('meta');
|
|
528
|
-
metas.forEach(meta => {
|
|
529
|
-
const name = meta.getAttribute('name') || meta.getAttribute('property');
|
|
530
|
-
const content = meta.getAttribute('content');
|
|
531
|
-
if (name && content) {
|
|
532
|
-
metadata[name] = content;
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
// Canonical URL
|
|
536
|
-
const canonical = doc.querySelector('link[rel="canonical"]');
|
|
537
|
-
if (canonical) {
|
|
538
|
-
metadata.canonical = canonical.getAttribute('href');
|
|
539
|
-
}
|
|
540
|
-
return metadata;
|
|
541
|
-
}
|
|
542
|
-
/**
|
|
543
|
-
* Attempts to extract main content from HTML
|
|
544
|
-
*/
|
|
545
|
-
extractMainContent(html) {
|
|
546
|
-
const dom = new JSDOM(html);
|
|
547
|
-
const doc = dom.window.document;
|
|
548
|
-
// Remove scripts and styles
|
|
549
|
-
doc.querySelectorAll('script, style, nav, header, footer, aside').forEach(el => el.remove());
|
|
550
|
-
// Try to find main content containers
|
|
551
|
-
const mainSelectors = ['main', 'article', '[role="main"]', '.content', '#content', '.post', '.article'];
|
|
552
|
-
for (const selector of mainSelectors) {
|
|
553
|
-
const element = doc.querySelector(selector);
|
|
554
|
-
if (element && element.textContent && element.textContent.trim().length > 100) {
|
|
555
|
-
return element.innerHTML;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
// If no main content found, return body without nav/header/footer
|
|
559
|
-
const body = doc.querySelector('body');
|
|
560
|
-
return body ? body.innerHTML : html;
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* Converts HTML to plain text
|
|
564
|
-
*/
|
|
565
|
-
htmlToText(html) {
|
|
566
|
-
const dom = new JSDOM(html);
|
|
567
|
-
const doc = dom.window.document;
|
|
568
|
-
// Remove script and style elements
|
|
569
|
-
doc.querySelectorAll('script, style').forEach(el => el.remove());
|
|
570
|
-
return doc.body.textContent || '';
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Extracts document structure from HTML
|
|
574
|
-
*/
|
|
575
|
-
extractStructure(doc) {
|
|
576
|
-
const structure = {
|
|
577
|
-
headings: [],
|
|
578
|
-
links: [],
|
|
579
|
-
images: []
|
|
580
|
-
};
|
|
581
|
-
// Extract headings
|
|
582
|
-
const headings = doc.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
|
583
|
-
structure.headings = Array.from(headings).map(h => ({
|
|
584
|
-
level: parseInt(h.tagName[1]),
|
|
585
|
-
text: h.textContent?.trim() || ''
|
|
586
|
-
}));
|
|
587
|
-
// Extract links
|
|
588
|
-
const links = doc.querySelectorAll('a[href]');
|
|
589
|
-
structure.links = Array.from(links).map(a => ({
|
|
590
|
-
url: a.getAttribute('href'),
|
|
591
|
-
text: a.textContent?.trim() || ''
|
|
592
|
-
}));
|
|
593
|
-
// Extract images
|
|
594
|
-
const images = doc.querySelectorAll('img[src]');
|
|
595
|
-
structure.images = Array.from(images).map(img => ({
|
|
596
|
-
src: img.getAttribute('src'),
|
|
597
|
-
alt: img.getAttribute('alt') || ''
|
|
598
|
-
}));
|
|
599
|
-
return structure;
|
|
600
|
-
}
|
|
601
460
|
/**
|
|
602
461
|
* Converts CSV data to markdown table
|
|
603
462
|
*/
|
|
@@ -625,10 +484,7 @@ let WebPageContentAction = class WebPageContentAction extends BaseAction {
|
|
|
625
484
|
* Truncates content to specified length
|
|
626
485
|
*/
|
|
627
486
|
truncateContent(content, maxLength) {
|
|
628
|
-
|
|
629
|
-
return content;
|
|
630
|
-
}
|
|
631
|
-
return content.substring(0, maxLength) + '...';
|
|
487
|
+
return TruncateContent(content, maxLength);
|
|
632
488
|
}
|
|
633
489
|
/**
|
|
634
490
|
* Returns browser-like headers to avoid bot detection
|
|
@@ -722,8 +578,7 @@ let WebPageContentAction = class WebPageContentAction extends BaseAction {
|
|
|
722
578
|
}
|
|
723
579
|
};
|
|
724
580
|
WebPageContentAction = __decorate([
|
|
725
|
-
RegisterClass(BaseAction, "__WebPageContent")
|
|
726
|
-
__metadata("design:paramtypes", [])
|
|
581
|
+
RegisterClass(BaseAction, "__WebPageContent")
|
|
727
582
|
], WebPageContentAction);
|
|
728
583
|
export { WebPageContentAction };
|
|
729
584
|
//# sourceMappingURL=web-page-content.action.js.map
|