@memberjunction/core-actions 5.38.0 → 5.40.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/ai/run-cluster-analysis.action.d.ts +49 -0
- package/dist/custom/ai/run-cluster-analysis.action.d.ts.map +1 -0
- package/dist/custom/ai/run-cluster-analysis.action.js +187 -0
- package/dist/custom/ai/run-cluster-analysis.action.js.map +1 -0
- package/dist/custom/data/search-entity.action.d.ts +48 -0
- package/dist/custom/data/search-entity.action.d.ts.map +1 -0
- package/dist/custom/data/search-entity.action.js +138 -0
- package/dist/custom/data/search-entity.action.js.map +1 -0
- package/dist/custom/esignature/base-esignature.action.d.ts +24 -0
- package/dist/custom/esignature/base-esignature.action.d.ts.map +1 -0
- package/dist/custom/esignature/base-esignature.action.js +68 -0
- package/dist/custom/esignature/base-esignature.action.js.map +1 -0
- package/dist/custom/esignature/download-signed-document.action.d.ts +15 -0
- package/dist/custom/esignature/download-signed-document.action.d.ts.map +1 -0
- package/dist/custom/esignature/download-signed-document.action.js +50 -0
- package/dist/custom/esignature/download-signed-document.action.js.map +1 -0
- package/dist/custom/esignature/get-signature-status.action.d.ts +15 -0
- package/dist/custom/esignature/get-signature-status.action.d.ts.map +1 -0
- package/dist/custom/esignature/get-signature-status.action.js +48 -0
- package/dist/custom/esignature/get-signature-status.action.js.map +1 -0
- package/dist/custom/esignature/send-document-for-signature.action.d.ts +24 -0
- package/dist/custom/esignature/send-document-for-signature.action.d.ts.map +1 -0
- package/dist/custom/esignature/send-document-for-signature.action.js +112 -0
- package/dist/custom/esignature/send-document-for-signature.action.js.map +1 -0
- package/dist/custom/esignature/void-signature-request.action.d.ts +15 -0
- package/dist/custom/esignature/void-signature-request.action.d.ts.map +1 -0
- package/dist/custom/esignature/void-signature-request.action.js +47 -0
- package/dist/custom/esignature/void-signature-request.action.js.map +1 -0
- package/dist/custom/geo/scheduled-geocoding.action.d.ts +27 -0
- package/dist/custom/geo/scheduled-geocoding.action.d.ts.map +1 -1
- package/dist/custom/geo/scheduled-geocoding.action.js +96 -13
- package/dist/custom/geo/scheduled-geocoding.action.js.map +1 -1
- package/dist/custom/integration/generate-integration-action.action.d.ts +60 -0
- package/dist/custom/integration/generate-integration-action.action.d.ts.map +1 -0
- package/dist/custom/integration/generate-integration-action.action.js +182 -0
- package/dist/custom/integration/generate-integration-action.action.js.map +1 -0
- package/dist/custom/integration/integration-action-executor.d.ts +28 -5
- package/dist/custom/integration/integration-action-executor.d.ts.map +1 -1
- package/dist/custom/integration/integration-action-executor.js +65 -11
- package/dist/custom/integration/integration-action-executor.js.map +1 -1
- package/dist/custom/utilities/vectorize-entity.action.d.ts.map +1 -1
- package/dist/custom/utilities/vectorize-entity.action.js +7 -2
- package/dist/custom/utilities/vectorize-entity.action.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/package.json +36 -34
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
2
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
3
|
+
/**
|
|
4
|
+
* Action: "Run Cluster Analysis"
|
|
5
|
+
*
|
|
6
|
+
* Thin wrapper over {@link ClusteringEngine.RunPipeline}. Fetches embedding
|
|
7
|
+
* vectors for an entity / entity document, clusters them (KMeans or DBSCAN),
|
|
8
|
+
* projects them to 2D/3D, optionally names clusters with an LLM, and — when a
|
|
9
|
+
* `PersistAs` name is supplied — persists the result to `MJ: Cluster Analysis`.
|
|
10
|
+
*
|
|
11
|
+
* All business logic lives in the engine; this action only maps params and
|
|
12
|
+
* returns a summary.
|
|
13
|
+
*
|
|
14
|
+
* Parameters (Input):
|
|
15
|
+
* - EntityID: ID of the entity to cluster (alternative to EntityDocumentID).
|
|
16
|
+
* - EntityDocumentID: specific Entity Document supplying vectors.
|
|
17
|
+
* - Algorithm: 'kmeans' (default) or 'dbscan'.
|
|
18
|
+
* - K: number of clusters for KMeans (default 4).
|
|
19
|
+
* - Epsilon: DBSCAN neighbourhood radius (default 0.3).
|
|
20
|
+
* - MinPoints: DBSCAN minimum points (default 3).
|
|
21
|
+
* - DistanceMetric: 'cosine' (default) | 'euclidean' | 'dotproduct'.
|
|
22
|
+
* - MaxRecords: max records to fetch (default 500).
|
|
23
|
+
* - Filter: optional SQL filter applied to the source records.
|
|
24
|
+
* - NameClusters: 'true' to run LLM cluster naming (default false).
|
|
25
|
+
* - PersistAs: when set, the analysis is saved with this name.
|
|
26
|
+
*
|
|
27
|
+
* Output params: AnalysisID (when persisted), ClusterCount, RecordCount, SilhouetteScore.
|
|
28
|
+
*/
|
|
29
|
+
export declare class RunClusterAnalysisAction extends BaseAction {
|
|
30
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
31
|
+
/** Build a {@link ClusterConfig} from the action params. */
|
|
32
|
+
private buildConfig;
|
|
33
|
+
/** Persist the analysis when a PersistAs name is supplied; return its ID or null. */
|
|
34
|
+
private maybePersist;
|
|
35
|
+
/** Add output params summarizing the run. */
|
|
36
|
+
private addOutputs;
|
|
37
|
+
/** Build a human-readable summary message. */
|
|
38
|
+
private buildSummary;
|
|
39
|
+
/** Coerce the engine metric onto the supported union, defaulting to cosine. */
|
|
40
|
+
private normalizeMetric;
|
|
41
|
+
private findParam;
|
|
42
|
+
private getString;
|
|
43
|
+
private getNumber;
|
|
44
|
+
private getBoolean;
|
|
45
|
+
private addOutput;
|
|
46
|
+
}
|
|
47
|
+
/** Tree-shaking prevention — call from index to keep the @RegisterClass alive. */
|
|
48
|
+
export declare function LoadRunClusterAnalysisAction(): void;
|
|
49
|
+
//# sourceMappingURL=run-cluster-analysis.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-cluster-analysis.action.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/run-cluster-analysis.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAe,MAAM,8BAA8B,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAYrD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBACa,wBAAyB,SAAQ,UAAU;cACpC,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAyCvF,4DAA4D;IAC5D,OAAO,CAAC,WAAW;IAkBnB,qFAAqF;YACvE,YAAY;IAkB1B,6CAA6C;IAC7C,OAAO,CAAC,UAAU;IASlB,8CAA8C;IAC9C,OAAO,CAAC,YAAY;IAcpB,+EAA+E;IAC/E,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,UAAU;IAWlB,OAAO,CAAC,SAAS;CASpB;AAED,kFAAkF;AAClF,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD"}
|
|
@@ -0,0 +1,187 @@
|
|
|
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 { BaseAction } from '@memberjunction/actions';
|
|
8
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
9
|
+
import { LogError } from '@memberjunction/core';
|
|
10
|
+
import { ClusteringEngine, EntityDocumentVectorSource, } from '@memberjunction/clustering-engine';
|
|
11
|
+
/**
|
|
12
|
+
* Action: "Run Cluster Analysis"
|
|
13
|
+
*
|
|
14
|
+
* Thin wrapper over {@link ClusteringEngine.RunPipeline}. Fetches embedding
|
|
15
|
+
* vectors for an entity / entity document, clusters them (KMeans or DBSCAN),
|
|
16
|
+
* projects them to 2D/3D, optionally names clusters with an LLM, and — when a
|
|
17
|
+
* `PersistAs` name is supplied — persists the result to `MJ: Cluster Analysis`.
|
|
18
|
+
*
|
|
19
|
+
* All business logic lives in the engine; this action only maps params and
|
|
20
|
+
* returns a summary.
|
|
21
|
+
*
|
|
22
|
+
* Parameters (Input):
|
|
23
|
+
* - EntityID: ID of the entity to cluster (alternative to EntityDocumentID).
|
|
24
|
+
* - EntityDocumentID: specific Entity Document supplying vectors.
|
|
25
|
+
* - Algorithm: 'kmeans' (default) or 'dbscan'.
|
|
26
|
+
* - K: number of clusters for KMeans (default 4).
|
|
27
|
+
* - Epsilon: DBSCAN neighbourhood radius (default 0.3).
|
|
28
|
+
* - MinPoints: DBSCAN minimum points (default 3).
|
|
29
|
+
* - DistanceMetric: 'cosine' (default) | 'euclidean' | 'dotproduct'.
|
|
30
|
+
* - MaxRecords: max records to fetch (default 500).
|
|
31
|
+
* - Filter: optional SQL filter applied to the source records.
|
|
32
|
+
* - NameClusters: 'true' to run LLM cluster naming (default false).
|
|
33
|
+
* - PersistAs: when set, the analysis is saved with this name.
|
|
34
|
+
*
|
|
35
|
+
* Output params: AnalysisID (when persisted), ClusterCount, RecordCount, SilhouetteScore.
|
|
36
|
+
*/
|
|
37
|
+
let RunClusterAnalysisAction = class RunClusterAnalysisAction extends BaseAction {
|
|
38
|
+
async InternalRunAction(params) {
|
|
39
|
+
try {
|
|
40
|
+
const config = this.buildConfig(params);
|
|
41
|
+
if (!config.EntityID && !config.EntityDocumentID) {
|
|
42
|
+
return {
|
|
43
|
+
Success: false,
|
|
44
|
+
ResultCode: 'MISSING_PARAMETER',
|
|
45
|
+
Message: "One of 'EntityID' or 'EntityDocumentID' is required.",
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const engine = new ClusteringEngine();
|
|
49
|
+
const source = new EntityDocumentVectorSource(params.ContextUser, params.Provider);
|
|
50
|
+
const result = await engine.RunPipeline(config, source, params.ContextUser);
|
|
51
|
+
if (result.Metrics.RecordCount === 0) {
|
|
52
|
+
return {
|
|
53
|
+
Success: false,
|
|
54
|
+
ResultCode: 'NO_VECTORS',
|
|
55
|
+
Message: 'No vectors were found for the supplied entity / document / filter.',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const analysisID = await this.maybePersist(params, engine, result, config);
|
|
59
|
+
this.addOutputs(params, result, analysisID);
|
|
60
|
+
return {
|
|
61
|
+
Success: true,
|
|
62
|
+
ResultCode: 'SUCCESS',
|
|
63
|
+
Message: this.buildSummary(result, analysisID),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
LogError(`RunClusterAnalysisAction: ${error}`);
|
|
68
|
+
return {
|
|
69
|
+
Success: false,
|
|
70
|
+
ResultCode: 'UNEXPECTED_ERROR',
|
|
71
|
+
Message: error instanceof Error ? error.message : String(error),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** Build a {@link ClusterConfig} from the action params. */
|
|
76
|
+
buildConfig(params) {
|
|
77
|
+
const algorithm = this.getString(params, 'algorithm', 'kmeans').toLowerCase();
|
|
78
|
+
const metric = this.getString(params, 'distancemetric', 'cosine').toLowerCase();
|
|
79
|
+
return {
|
|
80
|
+
EntityID: this.getString(params, 'entityid', ''),
|
|
81
|
+
EntityDocumentID: this.getString(params, 'entitydocumentid', ''),
|
|
82
|
+
Algorithm: (algorithm === 'dbscan' ? 'dbscan' : 'kmeans'),
|
|
83
|
+
K: this.getNumber(params, 'k', 4),
|
|
84
|
+
Epsilon: this.getNumber(params, 'epsilon', 0.3),
|
|
85
|
+
MinPoints: this.getNumber(params, 'minpoints', 3),
|
|
86
|
+
DistanceMetric: this.normalizeMetric(metric),
|
|
87
|
+
MaxRecords: this.getNumber(params, 'maxrecords', 500),
|
|
88
|
+
Filter: this.getString(params, 'filter', ''),
|
|
89
|
+
NameClusters: this.getBoolean(params, 'nameclusters', false),
|
|
90
|
+
Dimensions: 2,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Persist the analysis when a PersistAs name is supplied; return its ID or null. */
|
|
94
|
+
async maybePersist(params, engine, result, config) {
|
|
95
|
+
const persistAs = this.getString(params, 'persistas', '');
|
|
96
|
+
if (!persistAs) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
const user = params.ContextUser;
|
|
100
|
+
if (!user) {
|
|
101
|
+
LogError('RunClusterAnalysisAction: PersistAs supplied but no ContextUser available — skipping persistence.');
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
return engine.SaveAnalysis(result, config, { Name: persistAs, UserID: user.ID }, user, params.Provider);
|
|
105
|
+
}
|
|
106
|
+
/** Add output params summarizing the run. */
|
|
107
|
+
addOutputs(params, result, analysisID) {
|
|
108
|
+
if (analysisID) {
|
|
109
|
+
this.addOutput(params, 'AnalysisID', analysisID);
|
|
110
|
+
}
|
|
111
|
+
this.addOutput(params, 'ClusterCount', result.Metrics.ClusterCount);
|
|
112
|
+
this.addOutput(params, 'RecordCount', result.Metrics.RecordCount);
|
|
113
|
+
this.addOutput(params, 'SilhouetteScore', result.Metrics.SilhouetteScore);
|
|
114
|
+
}
|
|
115
|
+
/** Build a human-readable summary message. */
|
|
116
|
+
buildSummary(result, analysisID) {
|
|
117
|
+
const m = result.Metrics;
|
|
118
|
+
const parts = [
|
|
119
|
+
`Clustered ${m.RecordCount} records into ${m.ClusterCount} clusters`,
|
|
120
|
+
`silhouette=${m.SilhouetteScore.toFixed(3)}`,
|
|
121
|
+
`outliers=${m.OutlierCount}`,
|
|
122
|
+
`time=${m.ComputationTimeMs}ms`,
|
|
123
|
+
];
|
|
124
|
+
if (analysisID) {
|
|
125
|
+
parts.push(`saved as ${analysisID}`);
|
|
126
|
+
}
|
|
127
|
+
return parts.join(', ');
|
|
128
|
+
}
|
|
129
|
+
/** Coerce the engine metric onto the supported union, defaulting to cosine. */
|
|
130
|
+
normalizeMetric(metric) {
|
|
131
|
+
if (metric === 'euclidean' || metric === 'dotproduct') {
|
|
132
|
+
return metric;
|
|
133
|
+
}
|
|
134
|
+
return 'cosine';
|
|
135
|
+
}
|
|
136
|
+
// ---- param helpers -------------------------------------------------
|
|
137
|
+
findParam(params, name) {
|
|
138
|
+
return params.Params.find((p) => p.Name.trim().toLowerCase() === name.toLowerCase());
|
|
139
|
+
}
|
|
140
|
+
getString(params, name, defaultValue) {
|
|
141
|
+
const param = this.findParam(params, name);
|
|
142
|
+
if (!param || param.Value === undefined || param.Value === null) {
|
|
143
|
+
return defaultValue;
|
|
144
|
+
}
|
|
145
|
+
const value = String(param.Value).trim();
|
|
146
|
+
return value.length > 0 ? value : defaultValue;
|
|
147
|
+
}
|
|
148
|
+
getNumber(params, name, defaultValue) {
|
|
149
|
+
const param = this.findParam(params, name);
|
|
150
|
+
if (!param || param.Value === undefined || param.Value === null) {
|
|
151
|
+
return defaultValue;
|
|
152
|
+
}
|
|
153
|
+
const parsed = Number(param.Value);
|
|
154
|
+
return Number.isNaN(parsed) ? defaultValue : parsed;
|
|
155
|
+
}
|
|
156
|
+
getBoolean(params, name, defaultValue) {
|
|
157
|
+
const param = this.findParam(params, name);
|
|
158
|
+
if (!param || param.Value === undefined || param.Value === null) {
|
|
159
|
+
return defaultValue;
|
|
160
|
+
}
|
|
161
|
+
const value = String(param.Value).trim().toLowerCase();
|
|
162
|
+
if (value === 'true' || value === '1' || value === 'yes')
|
|
163
|
+
return true;
|
|
164
|
+
if (value === 'false' || value === '0' || value === 'no')
|
|
165
|
+
return false;
|
|
166
|
+
return defaultValue;
|
|
167
|
+
}
|
|
168
|
+
addOutput(params, name, value) {
|
|
169
|
+
const existing = this.findParam(params, name);
|
|
170
|
+
if (existing) {
|
|
171
|
+
existing.Value = value;
|
|
172
|
+
existing.Type = 'Output';
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
params.Params.push({ Name: name, Type: 'Output', Value: value });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
RunClusterAnalysisAction = __decorate([
|
|
180
|
+
RegisterClass(BaseAction, 'Run Cluster Analysis')
|
|
181
|
+
], RunClusterAnalysisAction);
|
|
182
|
+
export { RunClusterAnalysisAction };
|
|
183
|
+
/** Tree-shaking prevention — call from index to keep the @RegisterClass alive. */
|
|
184
|
+
export function LoadRunClusterAnalysisAction() {
|
|
185
|
+
// no-op
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=run-cluster-analysis.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-cluster-analysis.action.js","sourceRoot":"","sources":["../../../src/custom/ai/run-cluster-analysis.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EACH,gBAAgB,EAGhB,0BAA0B,GAG7B,MAAM,mCAAmC,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,UAAU;IAC1C,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACxC,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;gBAC/C,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,UAAU,EAAE,mBAAmB;oBAC/B,OAAO,EAAE,sDAAsD;iBAClE,CAAC;YACN,CAAC;YAED,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7JY,wBAAwB;IADpC,aAAa,CAAC,UAAU,EAAE,sBAAsB,CAAC;GACrC,wBAAwB,CA6JpC;;AAED,kFAAkF;AAClF,MAAM,UAAU,4BAA4B;IACxC,QAAQ;AACZ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
3
|
+
/**
|
|
4
|
+
* Action wrapper around {@link Metadata.Provider.SearchEntity}: ranked hybrid
|
|
5
|
+
* (lexical + semantic) search over one entity's records, with permission
|
|
6
|
+
* filtering. The classic agent prompt-seeding case — swap a 1500-row entity
|
|
7
|
+
* dump for "here are 10 likely candidates" — is just
|
|
8
|
+
* `SearchEntity({ entityName: 'MJ: Entities', searchText: userText, options: { topK: 10 } })`.
|
|
9
|
+
*
|
|
10
|
+
* ## When to use this Action vs. the others MJ already exposes
|
|
11
|
+
*
|
|
12
|
+
* - **Search Entity** (this action): "Find me the N most relevant *records* of
|
|
13
|
+
* one entity for this free-text request." Hybrid lexical + semantic ranking,
|
|
14
|
+
* backed by an `EntityDocument` of type `Search`. Use for agent prompt
|
|
15
|
+
* seeding, in-app "find a customer/invoice/document" UX.
|
|
16
|
+
* - **Get Entity Details / Get Entity List**: deterministic metadata or row
|
|
17
|
+
* reads, no ranking. Use when you already know which entity / which records.
|
|
18
|
+
* - **Search Query Catalog** / unified `Search` actions (`@memberjunction/ai-search`):
|
|
19
|
+
* cross-source search across vectors, full-text, entities, storage — broader
|
|
20
|
+
* in scope, slower, requires SearchScope configuration. Use when the agent
|
|
21
|
+
* doesn't know which entity to look in.
|
|
22
|
+
*
|
|
23
|
+
* Returns a JSON payload of `{ count, results: EntitySearchResult[] }` in the
|
|
24
|
+
* action `Message`, plus `Count` and `Results` output params.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* await runAction({
|
|
29
|
+
* ActionName: 'Search Entity',
|
|
30
|
+
* Params: [
|
|
31
|
+
* { Name: 'EntityName', Value: 'MJ: Entities' },
|
|
32
|
+
* { Name: 'SearchText', Value: 'invoices' },
|
|
33
|
+
* { Name: 'TopK', Value: 10 },
|
|
34
|
+
* { Name: 'Mode', Value: 'hybrid' }
|
|
35
|
+
* ]
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare class SearchEntityAction extends BaseAction {
|
|
40
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
41
|
+
private getStringParam;
|
|
42
|
+
private getNumericParam;
|
|
43
|
+
private addOutputParam;
|
|
44
|
+
}
|
|
45
|
+
/** Tree-shaking prevention export — called from the package's barrel to keep
|
|
46
|
+
* the class registration alive under aggressive bundlers. */
|
|
47
|
+
export declare function LoadSearchEntityAction(): void;
|
|
48
|
+
//# sourceMappingURL=search-entity.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-entity.action.d.ts","sourceRoot":"","sources":["../../../src/custom/data/search-entity.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBACa,kBAAmB,SAAQ,UAAU;cAE9B,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAqEvF,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,cAAc;CAGzB;AAED;8DAC8D;AAC9D,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
|
|
@@ -0,0 +1,138 @@
|
|
|
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 { LogError } from "@memberjunction/core";
|
|
10
|
+
/**
|
|
11
|
+
* Action wrapper around {@link Metadata.Provider.SearchEntity}: ranked hybrid
|
|
12
|
+
* (lexical + semantic) search over one entity's records, with permission
|
|
13
|
+
* filtering. The classic agent prompt-seeding case — swap a 1500-row entity
|
|
14
|
+
* dump for "here are 10 likely candidates" — is just
|
|
15
|
+
* `SearchEntity({ entityName: 'MJ: Entities', searchText: userText, options: { topK: 10 } })`.
|
|
16
|
+
*
|
|
17
|
+
* ## When to use this Action vs. the others MJ already exposes
|
|
18
|
+
*
|
|
19
|
+
* - **Search Entity** (this action): "Find me the N most relevant *records* of
|
|
20
|
+
* one entity for this free-text request." Hybrid lexical + semantic ranking,
|
|
21
|
+
* backed by an `EntityDocument` of type `Search`. Use for agent prompt
|
|
22
|
+
* seeding, in-app "find a customer/invoice/document" UX.
|
|
23
|
+
* - **Get Entity Details / Get Entity List**: deterministic metadata or row
|
|
24
|
+
* reads, no ranking. Use when you already know which entity / which records.
|
|
25
|
+
* - **Search Query Catalog** / unified `Search` actions (`@memberjunction/ai-search`):
|
|
26
|
+
* cross-source search across vectors, full-text, entities, storage — broader
|
|
27
|
+
* in scope, slower, requires SearchScope configuration. Use when the agent
|
|
28
|
+
* doesn't know which entity to look in.
|
|
29
|
+
*
|
|
30
|
+
* Returns a JSON payload of `{ count, results: EntitySearchResult[] }` in the
|
|
31
|
+
* action `Message`, plus `Count` and `Results` output params.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* await runAction({
|
|
36
|
+
* ActionName: 'Search Entity',
|
|
37
|
+
* Params: [
|
|
38
|
+
* { Name: 'EntityName', Value: 'MJ: Entities' },
|
|
39
|
+
* { Name: 'SearchText', Value: 'invoices' },
|
|
40
|
+
* { Name: 'TopK', Value: 10 },
|
|
41
|
+
* { Name: 'Mode', Value: 'hybrid' }
|
|
42
|
+
* ]
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
let SearchEntityAction = class SearchEntityAction extends BaseAction {
|
|
47
|
+
async InternalRunAction(params) {
|
|
48
|
+
try {
|
|
49
|
+
const entityName = this.getStringParam(params, "EntityName");
|
|
50
|
+
const searchText = this.getStringParam(params, "SearchText");
|
|
51
|
+
if (!entityName) {
|
|
52
|
+
return { Success: false, ResultCode: "MISSING_PARAMETER", Message: "Parameter 'EntityName' is required" };
|
|
53
|
+
}
|
|
54
|
+
if (!searchText) {
|
|
55
|
+
return { Success: false, ResultCode: "MISSING_PARAMETER", Message: "Parameter 'SearchText' is required" };
|
|
56
|
+
}
|
|
57
|
+
const mode = this.getStringParam(params, "Mode")?.toLowerCase();
|
|
58
|
+
const validModes = ['lexical', 'semantic', 'hybrid'];
|
|
59
|
+
if (mode && !validModes.includes(mode)) {
|
|
60
|
+
return {
|
|
61
|
+
Success: false,
|
|
62
|
+
ResultCode: "INVALID_PARAMETER",
|
|
63
|
+
Message: `Mode must be one of: ${validModes.join(', ')}`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const options = {
|
|
67
|
+
mode: mode ?? 'hybrid',
|
|
68
|
+
topK: this.getNumericParam(params, "TopK", 10),
|
|
69
|
+
minScore: this.getNumericParam(params, "MinScore", 0),
|
|
70
|
+
rrfK: this.getNumericParam(params, "RRFK", 60),
|
|
71
|
+
weights: {
|
|
72
|
+
lexical: this.getNumericParam(params, "LexicalWeight", 1.0),
|
|
73
|
+
semantic: this.getNumericParam(params, "SemanticWeight", 1.0),
|
|
74
|
+
},
|
|
75
|
+
entityDocumentId: this.getStringParam(params, "EntityDocumentID"),
|
|
76
|
+
contextUser: params.ContextUser,
|
|
77
|
+
};
|
|
78
|
+
// Always thread the invoking provider through — the action must run
|
|
79
|
+
// against the same metadata layer the caller is bound to (multi-server
|
|
80
|
+
// clients, request-scoped server-side providers). Falling back to the
|
|
81
|
+
// global `new Metadata()` would silently land on the wrong server in
|
|
82
|
+
// multi-provider scenarios. See CLAUDE.md "Don't Reach for the Global
|
|
83
|
+
// Metadata Provider in Per-Provider Code Paths".
|
|
84
|
+
const md = params.Provider;
|
|
85
|
+
if (!md) {
|
|
86
|
+
return {
|
|
87
|
+
Success: false,
|
|
88
|
+
ResultCode: "MISSING_PROVIDER",
|
|
89
|
+
Message: "RunActionParams.Provider is required — SearchEntity must run against the caller's metadata provider.",
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const searchParams = { entityName, searchText, options };
|
|
93
|
+
const results = await md.SearchEntity(searchParams);
|
|
94
|
+
this.addOutputParam(params, "Count", results.length);
|
|
95
|
+
this.addOutputParam(params, "Results", results);
|
|
96
|
+
return {
|
|
97
|
+
Success: true,
|
|
98
|
+
ResultCode: "SUCCESS",
|
|
99
|
+
Message: JSON.stringify({ count: results.length, results }),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
LogError(`SearchEntityAction failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
104
|
+
return {
|
|
105
|
+
Success: false,
|
|
106
|
+
ResultCode: "UNEXPECTED_ERROR",
|
|
107
|
+
Message: error instanceof Error ? error.message : String(error),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
getStringParam(params, name) {
|
|
112
|
+
const p = params.Params.find(x => x.Name.trim().toLowerCase() === name.toLowerCase());
|
|
113
|
+
if (!p || p.Value == null)
|
|
114
|
+
return undefined;
|
|
115
|
+
const v = String(p.Value).trim();
|
|
116
|
+
return v.length > 0 ? v : undefined;
|
|
117
|
+
}
|
|
118
|
+
getNumericParam(params, name, defaultValue) {
|
|
119
|
+
const p = params.Params.find(x => x.Name.trim().toLowerCase() === name.toLowerCase());
|
|
120
|
+
if (!p || p.Value == null)
|
|
121
|
+
return defaultValue;
|
|
122
|
+
const n = Number(p.Value);
|
|
123
|
+
return Number.isFinite(n) ? n : defaultValue;
|
|
124
|
+
}
|
|
125
|
+
addOutputParam(params, name, value) {
|
|
126
|
+
params.Params.push({ Name: name, Type: "Output", Value: value });
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
SearchEntityAction = __decorate([
|
|
130
|
+
RegisterClass(BaseAction, "Search Entity")
|
|
131
|
+
], SearchEntityAction);
|
|
132
|
+
export { SearchEntityAction };
|
|
133
|
+
/** Tree-shaking prevention export — called from the package's barrel to keep
|
|
134
|
+
* the class registration alive under aggressive bundlers. */
|
|
135
|
+
export function LoadSearchEntityAction() {
|
|
136
|
+
// intentionally empty
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=search-entity.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-entity.action.js","sourceRoot":"","sources":["../../../src/custom/data/search-entity.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,UAAU;IAEpC,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAA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AE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACrE,CAAC;CACJ,CAAA;AAxFY,kBAAkB;IAD9B,aAAa,CAAC,UAAU,EAAE,eAAe,CAAC;GAC9B,kBAAkB,CAwF9B;;AAED;8DAC8D;AAC9D,MAAM,UAAU,sBAAsB;IAClC,sBAAsB;AAC1B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RunActionParams } from '@memberjunction/actions-base';
|
|
2
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
3
|
+
import { SignatureEngine } from '@memberjunction/esignature/server';
|
|
4
|
+
/**
|
|
5
|
+
* Shared base for the thin eSignature Actions. Each concrete Action extracts its params, ensures the
|
|
6
|
+
* {@link SignatureEngine} is configured, and delegates to it — Actions are the boundary, the engine
|
|
7
|
+
* is the substance (per CLAUDE.md Actions philosophy).
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class BaseSignatureAction extends BaseAction {
|
|
10
|
+
/** Lazy-config the engine with the action's context user. */
|
|
11
|
+
protected ensureEngine(params: RunActionParams): Promise<SignatureEngine>;
|
|
12
|
+
/** Case-insensitive string param lookup; returns undefined when absent/blank. */
|
|
13
|
+
protected getStringParam(params: RunActionParams, name: string): string | undefined;
|
|
14
|
+
/** Case-insensitive boolean param with default. */
|
|
15
|
+
protected getBooleanParam(params: RunActionParams, name: string, defaultValue: boolean): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Case-insensitive param that may already be an object/array or a JSON string. Returns undefined
|
|
18
|
+
* when absent or unparseable.
|
|
19
|
+
*/
|
|
20
|
+
protected getObjectParam<T>(params: RunActionParams, name: string): T | undefined;
|
|
21
|
+
/** Push an output param onto the action's param list. */
|
|
22
|
+
protected addOutput(params: RunActionParams, name: string, value: unknown): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=base-esignature.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-esignature.action.d.ts","sourceRoot":"","sources":["../../../src/custom/esignature/base-esignature.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEpE;;;;GAIG;AACH,8BAAsB,mBAAoB,SAAQ,UAAU;IACxD,6DAA6D;cAC7C,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAK/E,iFAAiF;IACjF,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IASnF,mDAAmD;IACnD,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO;IAchG;;;OAGG;IACH,SAAS,CAAC,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAejF,yDAAyD;IACzD,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;CAOnF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ActionParam } from '@memberjunction/actions-base';
|
|
2
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
3
|
+
import { SignatureEngine } from '@memberjunction/esignature/server';
|
|
4
|
+
/**
|
|
5
|
+
* Shared base for the thin eSignature Actions. Each concrete Action extracts its params, ensures the
|
|
6
|
+
* {@link SignatureEngine} is configured, and delegates to it — Actions are the boundary, the engine
|
|
7
|
+
* is the substance (per CLAUDE.md Actions philosophy).
|
|
8
|
+
*/
|
|
9
|
+
export class BaseSignatureAction extends BaseAction {
|
|
10
|
+
/** Lazy-config the engine with the action's context user. */
|
|
11
|
+
async ensureEngine(params) {
|
|
12
|
+
await SignatureEngine.Instance.Config(false, params.ContextUser);
|
|
13
|
+
return SignatureEngine.Instance;
|
|
14
|
+
}
|
|
15
|
+
/** Case-insensitive string param lookup; returns undefined when absent/blank. */
|
|
16
|
+
getStringParam(params, name) {
|
|
17
|
+
const param = params.Params.find((p) => p.Name.trim().toLowerCase() === name.toLowerCase());
|
|
18
|
+
if (!param || param.Value == null) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const value = String(param.Value).trim();
|
|
22
|
+
return value.length > 0 ? value : undefined;
|
|
23
|
+
}
|
|
24
|
+
/** Case-insensitive boolean param with default. */
|
|
25
|
+
getBooleanParam(params, name, defaultValue) {
|
|
26
|
+
const param = params.Params.find((p) => p.Name.trim().toLowerCase() === name.toLowerCase());
|
|
27
|
+
if (!param || param.Value == null) {
|
|
28
|
+
return defaultValue;
|
|
29
|
+
}
|
|
30
|
+
if (typeof param.Value === 'boolean') {
|
|
31
|
+
return param.Value;
|
|
32
|
+
}
|
|
33
|
+
const value = String(param.Value).trim().toLowerCase();
|
|
34
|
+
if (value === 'true' || value === '1' || value === 'yes')
|
|
35
|
+
return true;
|
|
36
|
+
if (value === 'false' || value === '0' || value === 'no')
|
|
37
|
+
return false;
|
|
38
|
+
return defaultValue;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Case-insensitive param that may already be an object/array or a JSON string. Returns undefined
|
|
42
|
+
* when absent or unparseable.
|
|
43
|
+
*/
|
|
44
|
+
getObjectParam(params, name) {
|
|
45
|
+
const param = params.Params.find((p) => p.Name.trim().toLowerCase() === name.toLowerCase());
|
|
46
|
+
if (!param || param.Value == null) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
if (typeof param.Value === 'string') {
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(param.Value);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return param.Value;
|
|
58
|
+
}
|
|
59
|
+
/** Push an output param onto the action's param list. */
|
|
60
|
+
addOutput(params, name, value) {
|
|
61
|
+
const out = new ActionParam();
|
|
62
|
+
out.Name = name;
|
|
63
|
+
out.Type = 'Output';
|
|
64
|
+
out.Value = value;
|
|
65
|
+
params.Params.push(out);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=base-esignature.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-esignature.action.js","sourceRoot":"","sources":["../../../src/custom/esignature/base-esignature.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAmB,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,OAAgB,mBAAoB,SAAQ,UAAU;IACxD,6DAA6D;IACnD,KAAK,CAAC,YAAY,CAAC,MAAuB;QAChD,MAAM,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QACjE,OAAO,eAAe,CAAC,QAAQ,CAAC;IACpC,CAAC;IAED,iFAAiF;IACvE,cAAc,CAAC,MAAuB,EAAE,IAAY;QAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QAC5F,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YAChC,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI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E,CAAC;YAChC,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YAClC,IAAI,CAAC;gBACD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAM,CAAC;YACxC,CAAC;YAAC,MAAM,CAAC;gBACL,OAAO,SAAS,CAAC;YACrB,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC,KAAU,CAAC;IAC5B,CAAC;IAED,yDAAyD;IAC/C,SAAS,CAAC,MAAuB,EAAE,IAAY,EAAE,KAAc;QACrE,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;QAChB,GAAG,CAAC,IAAI,GAAG,QAAQ,CAAC;QACpB,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;QAClB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACJ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
2
|
+
import { BaseSignatureAction } from './base-esignature.action.js';
|
|
3
|
+
/**
|
|
4
|
+
* Action: "Download Signed Document".
|
|
5
|
+
*
|
|
6
|
+
* Downloads the executed/signed document for a completed signature request and records it as a
|
|
7
|
+
* `Signed`-role document. Thin wrapper over {@link SignatureEngine.DownloadSigned}.
|
|
8
|
+
*
|
|
9
|
+
* Inputs: SignatureRequestID (required).
|
|
10
|
+
* Outputs: DocumentBase64, Filename, ContentType.
|
|
11
|
+
*/
|
|
12
|
+
export declare class DownloadSignedDocumentAction extends BaseSignatureAction {
|
|
13
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=download-signed-document.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download-signed-document.action.d.ts","sourceRoot":"","sources":["../../../src/custom/esignature/download-signed-document.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAGnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;;;;;;GAQG;AACH,qBACa,4BAA6B,SAAQ,mBAAmB;cACjD,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA2B1F"}
|
|
@@ -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 { BaseSignatureAction } from './base-esignature.action.js';
|
|
10
|
+
/**
|
|
11
|
+
* Action: "Download Signed Document".
|
|
12
|
+
*
|
|
13
|
+
* Downloads the executed/signed document for a completed signature request and records it as a
|
|
14
|
+
* `Signed`-role document. Thin wrapper over {@link SignatureEngine.DownloadSigned}.
|
|
15
|
+
*
|
|
16
|
+
* Inputs: SignatureRequestID (required).
|
|
17
|
+
* Outputs: DocumentBase64, Filename, ContentType.
|
|
18
|
+
*/
|
|
19
|
+
let DownloadSignedDocumentAction = class DownloadSignedDocumentAction extends BaseSignatureAction {
|
|
20
|
+
async InternalRunAction(params) {
|
|
21
|
+
const requestId = this.getStringParam(params, 'SignatureRequestID');
|
|
22
|
+
if (!requestId) {
|
|
23
|
+
return { Success: false, ResultCode: 'PROVIDER_ERROR', Message: "Parameter 'SignatureRequestID' is required." };
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const engine = await this.ensureEngine(params);
|
|
27
|
+
const result = await engine.DownloadSigned(requestId, params.ContextUser);
|
|
28
|
+
if (!result.Success || !result.document) {
|
|
29
|
+
const notCompleted = (result.ErrorMessage ?? '').includes('not been sent');
|
|
30
|
+
return {
|
|
31
|
+
Success: false,
|
|
32
|
+
ResultCode: notCompleted ? 'NOT_COMPLETED' : 'PROVIDER_ERROR',
|
|
33
|
+
Message: result.ErrorMessage ?? 'Download failed.',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
this.addOutput(params, 'DocumentBase64', result.document.bytes.toString('base64'));
|
|
37
|
+
this.addOutput(params, 'Filename', result.document.filename);
|
|
38
|
+
this.addOutput(params, 'ContentType', result.document.contentType);
|
|
39
|
+
return { Success: true, ResultCode: 'OK', Message: `Downloaded ${result.document.filename}.`, Params: params.Params };
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
return { Success: false, ResultCode: 'PROVIDER_ERROR', Message: e instanceof Error ? e.message : String(e) };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
DownloadSignedDocumentAction = __decorate([
|
|
47
|
+
RegisterClass(BaseAction, 'Download Signed Document')
|
|
48
|
+
], DownloadSignedDocumentAction);
|
|
49
|
+
export { DownloadSignedDocumentAction };
|
|
50
|
+
//# sourceMappingURL=download-signed-document.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download-signed-document.action.js","sourceRoot":"","sources":["../../../src/custom/esignature/download-signed-document.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,O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