@memberjunction/core-actions 2.113.2 → 2.115.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.
Files changed (31) hide show
  1. package/dist/custom/ai/find-candidate-agents.action.js +3 -3
  2. package/dist/custom/ai/find-candidate-agents.action.js.map +1 -1
  3. package/dist/custom/ai/load-agent-spec.action.d.ts +10 -0
  4. package/dist/custom/ai/load-agent-spec.action.d.ts.map +1 -1
  5. package/dist/custom/ai/load-agent-spec.action.js +44 -3
  6. package/dist/custom/ai/load-agent-spec.action.js.map +1 -1
  7. package/dist/custom/code-execution/execute-code.action.d.ts +1 -0
  8. package/dist/custom/code-execution/execute-code.action.d.ts.map +1 -1
  9. package/dist/custom/code-execution/execute-code.action.js +6 -2
  10. package/dist/custom/code-execution/execute-code.action.js.map +1 -1
  11. package/dist/custom/crud/base-record-mutation.action.d.ts.map +1 -1
  12. package/dist/custom/crud/base-record-mutation.action.js +83 -14
  13. package/dist/custom/crud/base-record-mutation.action.js.map +1 -1
  14. package/dist/custom/crud/get-records.action.d.ts +57 -0
  15. package/dist/custom/crud/get-records.action.d.ts.map +1 -0
  16. package/dist/custom/crud/get-records.action.js +245 -0
  17. package/dist/custom/crud/get-records.action.js.map +1 -0
  18. package/dist/custom/crud/index.d.ts +1 -0
  19. package/dist/custom/crud/index.d.ts.map +1 -1
  20. package/dist/custom/crud/index.js +1 -0
  21. package/dist/custom/crud/index.js.map +1 -1
  22. package/dist/custom/visualization/create-svg-chart.action.d.ts +88 -24
  23. package/dist/custom/visualization/create-svg-chart.action.d.ts.map +1 -1
  24. package/dist/custom/visualization/create-svg-chart.action.js +779 -79
  25. package/dist/custom/visualization/create-svg-chart.action.js.map +1 -1
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +6 -0
  29. package/dist/index.js.map +1 -1
  30. package/package.json +17 -17
  31. package/readme.md +52 -0
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.LoadGetRecordsAction = exports.GetRecordsAction = void 0;
10
+ const global_1 = require("@memberjunction/global");
11
+ const actions_1 = require("@memberjunction/actions");
12
+ const core_1 = require("@memberjunction/core");
13
+ /**
14
+ * Generic action for retrieving multiple records from any entity with filtering and sorting capabilities.
15
+ * This action provides a flexible way to fetch filtered and sorted datasets for any entity type
16
+ * by accepting the entity name, optional filter clause, and ordering parameters.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Get all active events sorted by start date
21
+ * await runAction({
22
+ * ActionName: 'Get Records',
23
+ * Params: [
24
+ * {
25
+ * Name: 'EntityName',
26
+ * Value: 'Events'
27
+ * }, {
28
+ * Name: 'Filter',
29
+ * Value: 'Status = 'Active' AND StartDate >= GETDATE()'
30
+ * }, {
31
+ * Name: 'OrderBy',
32
+ * Value: 'StartDate ASC'
33
+ * }, {
34
+ * Name: 'MaxRows',
35
+ * Value: 100
36
+ * }
37
+ * ]
38
+ * });
39
+ *
40
+ * // Get recent submissions for a specific event
41
+ * await runAction({
42
+ * ActionName: 'Get Records',
43
+ * Params: [
44
+ * {
45
+ * Name: 'EntityName',
46
+ * Value: 'Submissions'
47
+ * }, {
48
+ * Name: 'Filter',
49
+ * Value: 'EventID = '123e4567-e89b-12d3-a456-426614174000' AND CreatedAt >= DATEADD(day, -30, GETDATE())'
50
+ * }, {
51
+ * Name: 'OrderBy',
52
+ * Value: 'CreatedAt DESC'
53
+ * }
54
+ * ]
55
+ * });
56
+ * ```
57
+ */
58
+ let GetRecordsAction = class GetRecordsAction extends actions_1.BaseAction {
59
+ async InternalRunAction(params) {
60
+ try {
61
+ // Extract parameters
62
+ const entityName = this.getStringParam(params, "EntityName");
63
+ if (!entityName) {
64
+ return {
65
+ Success: false,
66
+ ResultCode: "MISSING_ENTITY_NAME",
67
+ Message: "EntityName parameter is required"
68
+ };
69
+ }
70
+ const filter = this.getStringParam(params, "Filter");
71
+ const orderBy = this.getStringParam(params, "OrderBy");
72
+ const maxRows = this.getNumericParam(params, "MaxRows", 100);
73
+ const includeCount = this.getBooleanParam(params, "IncludeCount", true);
74
+ // Validate parameters
75
+ if (maxRows && (maxRows < 1 || maxRows > 10000)) {
76
+ return {
77
+ Success: false,
78
+ ResultCode: "INVALID_MAX_ROWS",
79
+ Message: "MaxRows must be between 1 and 10000"
80
+ };
81
+ }
82
+ // Use RunView to execute the query
83
+ const rv = new core_1.RunView();
84
+ const runViewParams = {
85
+ EntityName: entityName,
86
+ MaxRows: maxRows,
87
+ ResultType: 'simple'
88
+ };
89
+ // Add filter if provided
90
+ if (filter) {
91
+ runViewParams.Filter = filter;
92
+ }
93
+ // Add ordering if provided
94
+ if (orderBy) {
95
+ runViewParams.OrderBy = orderBy;
96
+ }
97
+ const result = await rv.RunView(runViewParams, params.ContextUser);
98
+ if (!result.Success) {
99
+ return {
100
+ Success: false,
101
+ ResultCode: "QUERY_FAILED",
102
+ Message: `Failed to retrieve records: ${result.ErrorMessage}`
103
+ };
104
+ }
105
+ const records = result.Results || [];
106
+ const totalCount = result.TotalRowCount || records.length;
107
+ // Build success message
108
+ let message = `Successfully retrieved ${records.length} records`;
109
+ if (includeCount && totalCount > records.length) {
110
+ message += ` (showing ${records.length} of ${totalCount} total)`;
111
+ }
112
+ if (filter) {
113
+ message += ` with filter: ${filter}`;
114
+ }
115
+ if (orderBy) {
116
+ message += ` ordered by: ${orderBy}`;
117
+ }
118
+ return {
119
+ Success: true,
120
+ ResultCode: "SUCCESS",
121
+ Message: message,
122
+ Params: [
123
+ {
124
+ Name: 'Records',
125
+ Type: 'Output',
126
+ Value: records
127
+ },
128
+ {
129
+ Name: 'TotalCount',
130
+ Type: 'Output',
131
+ Value: totalCount
132
+ },
133
+ {
134
+ Name: 'EntityName',
135
+ Type: 'Output',
136
+ Value: entityName
137
+ },
138
+ {
139
+ Name: 'Filter',
140
+ Type: 'Output',
141
+ Value: filter
142
+ },
143
+ {
144
+ Name: 'OrderBy',
145
+ Type: 'Output',
146
+ Value: orderBy
147
+ }
148
+ ]
149
+ };
150
+ }
151
+ catch (error) {
152
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
153
+ return {
154
+ Success: false,
155
+ ResultCode: "ERROR",
156
+ Message: `Error retrieving records: ${errorMessage}`
157
+ };
158
+ }
159
+ }
160
+ get Params() {
161
+ return [
162
+ {
163
+ Name: 'EntityName',
164
+ Type: 'Input',
165
+ Value: null
166
+ },
167
+ {
168
+ Name: 'Filter',
169
+ Type: 'Input',
170
+ Value: null
171
+ },
172
+ {
173
+ Name: 'OrderBy',
174
+ Type: 'Input',
175
+ Value: null
176
+ },
177
+ {
178
+ Name: 'MaxRows',
179
+ Type: 'Input',
180
+ Value: null
181
+ },
182
+ {
183
+ Name: 'IncludeCount',
184
+ Type: 'Input',
185
+ Value: null
186
+ }
187
+ ];
188
+ }
189
+ get Returns() {
190
+ return [
191
+ {
192
+ Name: 'Records',
193
+ Type: 'Output',
194
+ Value: null
195
+ },
196
+ {
197
+ Name: 'TotalCount',
198
+ Type: 'Output',
199
+ Value: null
200
+ },
201
+ {
202
+ Name: 'EntityName',
203
+ Type: 'Output',
204
+ Value: null
205
+ }
206
+ ];
207
+ }
208
+ getStringParam(params, paramName) {
209
+ const param = params.Params.find(p => p.Name.toLowerCase() === paramName.toLowerCase() &&
210
+ p.Type === 'Input');
211
+ return param?.Value ? String(param.Value) : undefined;
212
+ }
213
+ getNumericParam(params, paramName, defaultValue) {
214
+ const param = params.Params.find(p => p.Name.toLowerCase() === paramName.toLowerCase() &&
215
+ p.Type === 'Input');
216
+ if (param?.Value != null) {
217
+ const num = Number(param.Value);
218
+ return isNaN(num) ? defaultValue : num;
219
+ }
220
+ return defaultValue;
221
+ }
222
+ getBooleanParam(params, paramName, defaultValue) {
223
+ const param = params.Params.find(p => p.Name.toLowerCase() === paramName.toLowerCase() &&
224
+ p.Type === 'Input');
225
+ if (param?.Value != null) {
226
+ const val = String(param.Value).toLowerCase();
227
+ if (val === 'true' || val === '1' || val === 'yes')
228
+ return true;
229
+ if (val === 'false' || val === '0' || val === 'no')
230
+ return false;
231
+ }
232
+ return defaultValue;
233
+ }
234
+ };
235
+ exports.GetRecordsAction = GetRecordsAction;
236
+ exports.GetRecordsAction = GetRecordsAction = __decorate([
237
+ (0, global_1.RegisterClass)(actions_1.BaseAction, "GetRecordsAction")
238
+ ], GetRecordsAction);
239
+ function LoadGetRecordsAction() {
240
+ // This function exists to prevent tree-shaking
241
+ // Call it from consuming packages to ensure the action is included
242
+ return;
243
+ }
244
+ exports.LoadGetRecordsAction = LoadGetRecordsAction;
245
+ //# sourceMappingURL=get-records.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-records.action.js","sourceRoot":"","sources":["../../../src/custom/crud/get-records.action.ts"],"names":[],"mappings":";;;;;;;;;AACA,mDAAuD;AACvD,qDAAqD;AACrD,+CAA+C;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,oBAAU;IAElC,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,qBAAqB;YACrB,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YAC7D,IAAI,CAAC,UAAU,EAAE,CAAC;gBACd,OAAO;oBACH,OAAO,EAAE,KAAK;oBAC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AAC;IACxB,CAAC;CACJ,CAAA;AApMY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAa,EAAC,oBAAU,EAAE,kBAAkB,CAAC;GACjC,gBAAgB,CAoM5B;AAED,SAAgB,oBAAoB;IAChC,+CAA+C;IAC/C,mEAAmE;IACnE,OAAO;AACX,CAAC;AAJD,oDAIC"}
@@ -10,6 +10,7 @@
10
10
  export * from './base-record-mutation.action';
11
11
  export * from './create-record.action';
12
12
  export * from './get-record.action';
13
+ export * from './get-records.action';
13
14
  export * from './update-record.action';
14
15
  export * from './delete-record.action';
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/custom/crud/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/custom/crud/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  __exportStar(require("./base-record-mutation.action"), exports);
27
27
  __exportStar(require("./create-record.action"), exports);
28
28
  __exportStar(require("./get-record.action"), exports);
29
+ __exportStar(require("./get-records.action"), exports);
29
30
  __exportStar(require("./update-record.action"), exports);
30
31
  __exportStar(require("./delete-record.action"), exports);
31
32
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/custom/crud/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;AAEH,gEAA8C;AAC9C,yDAAuC;AACvC,sDAAoC;AACpC,yDAAuC;AACvC,yDAAuC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/custom/crud/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;AAEH,gEAA8C;AAC9C,yDAAuC;AACvC,sDAAoC;AACpC,uDAAqC;AACrC,yDAAuC;AACvC,yDAAuC"}
@@ -1,8 +1,9 @@
1
- import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
1
+ import { RunActionParams } from "@memberjunction/actions-base";
2
2
  import { BaseAction } from "@memberjunction/actions";
3
+ import { SVGActionResult } from './shared/svg-types';
3
4
  /**
4
- * Action that generates SVG charts from data using Vega-Lite.
5
- * Supports various chart types including bar, line, pie, scatter, area, and more.
5
+ * Action that generates SVG charts from data using D3.
6
+ * Supports bar, line, pie, scatter, and area charts.
6
7
  *
7
8
  * This action is designed for AI agents and workflows to create publication-quality
8
9
  * visualizations from structured data without writing visualization code.
@@ -15,29 +16,36 @@ import { BaseAction } from "@memberjunction/actions";
15
16
  * Params: [
16
17
  * { Name: 'ChartType', Value: 'bar' },
17
18
  * { Name: 'Data', Value: JSON.stringify([
18
- * { category: 'A', value: 28 },
19
- * { category: 'B', value: 55 },
20
- * { category: 'C', value: 43 }
19
+ * { label: 'A', value: 28 },
20
+ * { label: 'B', value: 55 },
21
+ * { label: 'C', value: 43 }
21
22
  * ]) },
22
- * { Name: 'XField', Value: 'category' },
23
- * { Name: 'YField', Value: 'value' },
24
23
  * { Name: 'Title', Value: 'Sample Bar Chart' }
25
24
  * ]
26
25
  * });
27
26
  *
27
+ * // Line chart with X/Y data
28
+ * await runAction({
29
+ * ActionName: 'Create SVG Chart',
30
+ * Params: [
31
+ * { Name: 'ChartType', Value: 'line' },
32
+ * { Name: 'Data', Value: JSON.stringify([
33
+ * { x: 1, y: 10 },
34
+ * { x: 2, y: 25 },
35
+ * { x: 3, y: 15 }
36
+ * ]) }
37
+ * ]
38
+ * });
39
+ *
28
40
  * // Pie chart
29
41
  * await runAction({
30
42
  * ActionName: 'Create SVG Chart',
31
43
  * Params: [
32
44
  * { Name: 'ChartType', Value: 'pie' },
33
45
  * { Name: 'Data', Value: JSON.stringify([
34
- * { category: 'LLM', count: 67 },
35
- * { category: 'Embeddings', count: 10 }
36
- * ]) },
37
- * { Name: 'ThetaField', Value: 'count' },
38
- * { Name: 'ColorField', Value: 'category' },
39
- * { Name: 'Width', Value: '400' },
40
- * { Name: 'Height', Value: '300' }
46
+ * { label: 'LLM', value: 67 },
47
+ * { label: 'Embeddings', value: 10 }
48
+ * ]) }
41
49
  * ]
42
50
  * });
43
51
  * ```
@@ -47,23 +55,79 @@ export declare class CreateSVGChartAction extends BaseAction {
47
55
  * Generates an SVG chart from the provided data and configuration
48
56
  *
49
57
  * @param params - The action parameters containing:
50
- * - ChartType: Type of chart (bar, line, pie, scatter, area, etc.)
58
+ * - ChartType: Type of chart (bar, line, pie, scatter, area)
51
59
  * - Data: JSON array of data objects
52
- * - XField: Field name for X axis (for bar, line, scatter, area)
53
- * - YField: Field name for Y axis (for bar, line, scatter, area)
54
- * - ThetaField: Field name for pie slice size (for pie charts)
55
- * - ColorField: Field name for color encoding (optional)
56
60
  * - Title: Chart title (optional)
57
- * - Width: Chart width in pixels (optional, default: 400)
58
- * - Height: Chart height in pixels (optional, default: 300)
59
- * - VegaLiteSpec: Full Vega-Lite JSON spec (optional, overrides other params)
61
+ * - XAxisLabel: X-axis label (optional)
62
+ * - YAxisLabel: Y-axis label (optional)
63
+ * - Width: Chart width in pixels (optional, default: 800)
64
+ * - Height: Chart height in pixels (optional, default: 600)
65
+ * - Palette: Color palette name (optional, default: 'mjDefault')
66
+ * - ShowGrid: Show grid lines (optional, default: false)
67
+ * - ShowLegend: Show legend (optional, default: false)
60
68
  *
61
69
  * @returns A promise resolving to an ActionResultSimple with:
62
70
  * - Success: true if chart was generated successfully
63
71
  * - ResultCode: "SUCCESS" or error code
64
72
  * - Message: The SVG string or error message
65
73
  */
66
- protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
74
+ protected InternalRunAction(params: RunActionParams): Promise<SVGActionResult>;
75
+ /**
76
+ * Renders a bar chart
77
+ */
78
+ private renderBarChart;
79
+ /**
80
+ * Renders a line chart
81
+ */
82
+ private renderLineChart;
83
+ /**
84
+ * Renders an area chart
85
+ */
86
+ private renderAreaChart;
87
+ /**
88
+ * Renders a pie chart
89
+ */
90
+ private renderPieChart;
91
+ /**
92
+ * Renders a scatter plot
93
+ */
94
+ private renderScatterChart;
95
+ /**
96
+ * Draws grid lines
97
+ */
98
+ private drawGrid;
99
+ /**
100
+ * Draws X-axis for categorical data
101
+ */
102
+ private drawXAxis;
103
+ /**
104
+ * Draws X-axis for numeric data
105
+ */
106
+ private drawXAxisNumeric;
107
+ /**
108
+ * Draws Y-axis
109
+ */
110
+ private drawYAxis;
111
+ /**
112
+ * Adds a title to the chart
113
+ */
114
+ private addTitle;
115
+ /**
116
+ * Adds a legend for pie charts
117
+ */
118
+ private addLegend;
119
+ /**
120
+ * Helper to safely parse JSON
121
+ */
122
+ private parseJSON;
123
+ /**
124
+ * Helper to ensure a parameter value is a string
125
+ */
126
+ private ensureString;
127
+ /**
128
+ * Helper to get parameter value by name (case-insensitive)
129
+ */
130
+ private getParamValue;
67
131
  }
68
132
  /**
69
133
  * Loader function to ensure the CreateSVGChartAction class is included in the bundle.
@@ -1 +1 @@
1
- {"version":3,"file":"create-svg-chart.action.d.ts","sourceRoot":"","sources":["../../../src/custom/visualization/create-svg-chart.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAMrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBACa,oBAAqB,SAAQ,UAAU;IAChD;;;;;;;;;;;;;;;;;;;OAmBG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA2P1F;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,SAEvC"}
1
+ {"version":3,"file":"create-svg-chart.action.d.ts","sourceRoot":"","sources":["../../../src/custom/visualization/create-svg-chart.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrD,OAAO,EAAE,eAAe,EAAqB,MAAM,oBAAoB,CAAC;AAoBxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,qBACa,oBAAqB,SAAQ,UAAU;IAChD;;;;;;;;;;;;;;;;;;;OAmBG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IA+GpF;;OAEG;YACW,cAAc;IA+F5B;;OAEG;YACW,eAAe;IA2F7B;;OAEG;YACW,eAAe;IAwF7B;;OAEG;YACW,cAAc;IAuF5B;;OAEG;YACW,kBAAkB;IA6EhC;;OAEG;IACH,OAAO,CAAC,QAAQ;IAiDhB;;OAEG;IACH,OAAO,CAAC,SAAS;IAqDjB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAkExB;;OAEG;IACH,OAAO,CAAC,SAAS;IAoEjB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAmBhB;;OAEG;IACH,OAAO,CAAC,SAAS;IAsCjB;;OAEG;IACH,OAAO,CAAC,SAAS;IAoBjB;;OAEG;IACH,OAAO,CAAC,YAAY;IAmBpB;;OAEG;IACH,OAAO,CAAC,aAAa;CASxB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,SAEvC"}