@memberjunction/core-actions 2.53.0 → 2.55.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/execute-ai-prompt.action.d.ts +94 -0
- package/dist/custom/ai/execute-ai-prompt.action.d.ts.map +1 -0
- package/dist/custom/ai/execute-ai-prompt.action.js +274 -0
- package/dist/custom/ai/execute-ai-prompt.action.js.map +1 -0
- package/dist/custom/communication/slack-webhook.action.d.ts +101 -0
- package/dist/custom/communication/slack-webhook.action.d.ts.map +1 -0
- package/dist/custom/communication/slack-webhook.action.js +269 -0
- package/dist/custom/communication/slack-webhook.action.js.map +1 -0
- package/dist/custom/communication/teams-webhook.action.d.ts +96 -0
- package/dist/custom/communication/teams-webhook.action.d.ts.map +1 -0
- package/dist/custom/communication/teams-webhook.action.js +275 -0
- package/dist/custom/communication/teams-webhook.action.js.map +1 -0
- package/dist/custom/data/aggregate-data.action.d.ts +91 -0
- package/dist/custom/data/aggregate-data.action.d.ts.map +1 -0
- package/dist/custom/data/aggregate-data.action.js +333 -0
- package/dist/custom/data/aggregate-data.action.js.map +1 -0
- package/dist/custom/data/csv-parser.action.d.ts +68 -0
- package/dist/custom/data/csv-parser.action.d.ts.map +1 -0
- package/dist/custom/data/csv-parser.action.js +184 -0
- package/dist/custom/data/csv-parser.action.js.map +1 -0
- package/dist/custom/data/data-mapper.action.d.ts +89 -0
- package/dist/custom/data/data-mapper.action.d.ts.map +1 -0
- package/dist/custom/data/data-mapper.action.js +325 -0
- package/dist/custom/data/data-mapper.action.js.map +1 -0
- package/dist/custom/data/json-transform.action.d.ts +57 -0
- package/dist/custom/data/json-transform.action.d.ts.map +1 -0
- package/dist/custom/data/json-transform.action.js +205 -0
- package/dist/custom/data/json-transform.action.js.map +1 -0
- package/dist/custom/data/xml-parser.action.d.ts +85 -0
- package/dist/custom/data/xml-parser.action.d.ts.map +1 -0
- package/dist/custom/data/xml-parser.action.js +326 -0
- package/dist/custom/data/xml-parser.action.js.map +1 -0
- package/dist/custom/files/excel-reader.action.d.ts +86 -0
- package/dist/custom/files/excel-reader.action.d.ts.map +1 -0
- package/dist/custom/files/excel-reader.action.js +348 -0
- package/dist/custom/files/excel-reader.action.js.map +1 -0
- package/dist/custom/files/excel-writer.action.d.ts +79 -0
- package/dist/custom/files/excel-writer.action.d.ts.map +1 -0
- package/dist/custom/files/excel-writer.action.js +325 -0
- package/dist/custom/files/excel-writer.action.js.map +1 -0
- package/dist/custom/files/file-compress.action.d.ts +90 -0
- package/dist/custom/files/file-compress.action.d.ts.map +1 -0
- package/dist/custom/files/file-compress.action.js +346 -0
- package/dist/custom/files/file-compress.action.js.map +1 -0
- package/dist/custom/files/pdf-extractor.action.d.ts +86 -0
- package/dist/custom/files/pdf-extractor.action.d.ts.map +1 -0
- package/dist/custom/files/pdf-extractor.action.js +247 -0
- package/dist/custom/files/pdf-extractor.action.js.map +1 -0
- package/dist/custom/files/pdf-generator.action.d.ts +70 -0
- package/dist/custom/files/pdf-generator.action.d.ts.map +1 -0
- package/dist/custom/files/pdf-generator.action.js +286 -0
- package/dist/custom/files/pdf-generator.action.js.map +1 -0
- package/dist/custom/integration/api-rate-limiter.action.d.ts +88 -0
- package/dist/custom/integration/api-rate-limiter.action.d.ts.map +1 -0
- package/dist/custom/integration/api-rate-limiter.action.js +363 -0
- package/dist/custom/integration/api-rate-limiter.action.js.map +1 -0
- package/dist/custom/integration/graphql-query.action.d.ts +92 -0
- package/dist/custom/integration/graphql-query.action.d.ts.map +1 -0
- package/dist/custom/integration/graphql-query.action.js +251 -0
- package/dist/custom/integration/graphql-query.action.js.map +1 -0
- package/dist/custom/integration/http-request.action.d.ts +96 -0
- package/dist/custom/integration/http-request.action.d.ts.map +1 -0
- package/dist/custom/integration/http-request.action.js +316 -0
- package/dist/custom/integration/http-request.action.js.map +1 -0
- package/dist/custom/integration/oauth-flow.action.d.ts +130 -0
- package/dist/custom/integration/oauth-flow.action.d.ts.map +1 -0
- package/dist/custom/integration/oauth-flow.action.js +624 -0
- package/dist/custom/integration/oauth-flow.action.js.map +1 -0
- package/dist/custom/security/password-strength.action.d.ts +129 -0
- package/dist/custom/security/password-strength.action.d.ts.map +1 -0
- package/dist/custom/security/password-strength.action.js +463 -0
- package/dist/custom/security/password-strength.action.js.map +1 -0
- package/dist/custom/utilities/base-file-handler.d.ts +54 -0
- package/dist/custom/utilities/base-file-handler.d.ts.map +1 -0
- package/dist/custom/utilities/base-file-handler.js +167 -0
- package/dist/custom/utilities/base-file-handler.js.map +1 -0
- package/dist/custom/utilities/index.d.ts +3 -0
- package/dist/custom/utilities/index.d.ts.map +1 -0
- package/dist/custom/utilities/index.js +19 -0
- package/dist/custom/utilities/index.js.map +1 -0
- package/dist/custom/utilities/json-param-helper.d.ts +33 -0
- package/dist/custom/utilities/json-param-helper.d.ts.map +1 -0
- package/dist/custom/utilities/json-param-helper.js +66 -0
- package/dist/custom/utilities/json-param-helper.js.map +1 -0
- package/dist/custom/web/duckduckgo-rate-limiter.d.ts +72 -0
- package/dist/custom/web/duckduckgo-rate-limiter.d.ts.map +1 -0
- package/dist/custom/web/duckduckgo-rate-limiter.js +175 -0
- package/dist/custom/web/duckduckgo-rate-limiter.js.map +1 -0
- package/dist/custom/web/web-search.action.d.ts +1 -0
- package/dist/custom/web/web-search.action.d.ts.map +1 -1
- package/dist/custom/web/web-search.action.js +48 -20
- package/dist/custom/web/web-search.action.js.map +1 -1
- package/dist/custom/workflow/conditional.action.d.ts +94 -0
- package/dist/custom/workflow/conditional.action.d.ts.map +1 -0
- package/dist/custom/workflow/conditional.action.js +274 -0
- package/dist/custom/workflow/conditional.action.js.map +1 -0
- package/dist/custom/workflow/delay.action.d.ts +76 -0
- package/dist/custom/workflow/delay.action.d.ts.map +1 -0
- package/dist/custom/workflow/delay.action.js +187 -0
- package/dist/custom/workflow/delay.action.js.map +1 -0
- package/dist/custom/workflow/loop.action.d.ts +112 -0
- package/dist/custom/workflow/loop.action.d.ts.map +1 -0
- package/dist/custom/workflow/loop.action.js +380 -0
- package/dist/custom/workflow/loop.action.js.map +1 -0
- package/dist/custom/workflow/parallel-execute.action.d.ts +105 -0
- package/dist/custom/workflow/parallel-execute.action.d.ts.map +1 -0
- package/dist/custom/workflow/parallel-execute.action.js +457 -0
- package/dist/custom/workflow/parallel-execute.action.js.map +1 -0
- package/dist/custom/workflow/retry.action.d.ts +90 -0
- package/dist/custom/workflow/retry.action.d.ts.map +1 -0
- package/dist/custom/workflow/retry.action.js +378 -0
- package/dist/custom/workflow/retry.action.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +75 -0
- package/dist/index.js.map +1 -1
- package/package.json +25 -10
- package/readme.md +11270 -101
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
3
|
+
/**
|
|
4
|
+
* Action that transforms JSON data using JSONPath or JMESPath expressions
|
|
5
|
+
* Enables powerful querying and transformation of JSON structures
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Extract values using JSONPath
|
|
10
|
+
* await runAction({
|
|
11
|
+
* ActionName: 'JSON Transform',
|
|
12
|
+
* Params: [{
|
|
13
|
+
* Name: 'InputData',
|
|
14
|
+
* Value: { users: [{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }] }
|
|
15
|
+
* }, {
|
|
16
|
+
* Name: 'Expression',
|
|
17
|
+
* Value: '$.users[?(@.age > 26)].name'
|
|
18
|
+
* }]
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Transform using JMESPath
|
|
22
|
+
* await runAction({
|
|
23
|
+
* ActionName: 'JSON Transform',
|
|
24
|
+
* Params: [{
|
|
25
|
+
* Name: 'InputData',
|
|
26
|
+
* Value: { items: [{ price: 10, qty: 2 }, { price: 20, qty: 1 }] }
|
|
27
|
+
* }, {
|
|
28
|
+
* Name: 'Expression',
|
|
29
|
+
* Value: 'items[].{total: price * qty}'
|
|
30
|
+
* }, {
|
|
31
|
+
* Name: 'TransformType',
|
|
32
|
+
* Value: 'JMESPath'
|
|
33
|
+
* }]
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare class JSONTransformAction extends BaseAction {
|
|
38
|
+
/**
|
|
39
|
+
* Transforms JSON data using JSONPath or JMESPath expressions
|
|
40
|
+
*
|
|
41
|
+
* @param params - The action parameters containing:
|
|
42
|
+
* - InputData: JSON object or array to transform
|
|
43
|
+
* - Expression: JSONPath or JMESPath query expression
|
|
44
|
+
* - TransformType: "JSONPath" | "JMESPath" (default: "JSONPath")
|
|
45
|
+
* - Multiple: Boolean - return all matches vs first match (JSONPath only, default: true)
|
|
46
|
+
* - Flatten: Boolean - flatten array results (default: false)
|
|
47
|
+
* - WrapScalar: Boolean - wrap scalar results in object (default: false)
|
|
48
|
+
*
|
|
49
|
+
* @returns Transformed data based on the expression
|
|
50
|
+
*/
|
|
51
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Loader function to ensure the JSONTransformAction class is included in the bundle
|
|
55
|
+
*/
|
|
56
|
+
export declare function LoadJSONTransformAction(): void;
|
|
57
|
+
//# sourceMappingURL=json-transform.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-transform.action.d.ts","sourceRoot":"","sources":["../../../src/custom/data/json-transform.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAMrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBACa,mBAAoB,SAAQ,UAAU;IAE/C;;;;;;;;;;;;OAYG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAiH1F;AAED;;GAEG;AACH,wBAAgB,uBAAuB,SAEtC"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.LoadJSONTransformAction = exports.JSONTransformAction = void 0;
|
|
33
|
+
const actions_1 = require("@memberjunction/actions");
|
|
34
|
+
const global_1 = require("@memberjunction/global");
|
|
35
|
+
const jsonpath_plus_1 = require("jsonpath-plus");
|
|
36
|
+
const jmespath = __importStar(require("jmespath"));
|
|
37
|
+
const json_param_helper_1 = require("../utilities/json-param-helper");
|
|
38
|
+
/**
|
|
39
|
+
* Action that transforms JSON data using JSONPath or JMESPath expressions
|
|
40
|
+
* Enables powerful querying and transformation of JSON structures
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* // Extract values using JSONPath
|
|
45
|
+
* await runAction({
|
|
46
|
+
* ActionName: 'JSON Transform',
|
|
47
|
+
* Params: [{
|
|
48
|
+
* Name: 'InputData',
|
|
49
|
+
* Value: { users: [{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }] }
|
|
50
|
+
* }, {
|
|
51
|
+
* Name: 'Expression',
|
|
52
|
+
* Value: '$.users[?(@.age > 26)].name'
|
|
53
|
+
* }]
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* // Transform using JMESPath
|
|
57
|
+
* await runAction({
|
|
58
|
+
* ActionName: 'JSON Transform',
|
|
59
|
+
* Params: [{
|
|
60
|
+
* Name: 'InputData',
|
|
61
|
+
* Value: { items: [{ price: 10, qty: 2 }, { price: 20, qty: 1 }] }
|
|
62
|
+
* }, {
|
|
63
|
+
* Name: 'Expression',
|
|
64
|
+
* Value: 'items[].{total: price * qty}'
|
|
65
|
+
* }, {
|
|
66
|
+
* Name: 'TransformType',
|
|
67
|
+
* Value: 'JMESPath'
|
|
68
|
+
* }]
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
let JSONTransformAction = class JSONTransformAction extends actions_1.BaseAction {
|
|
73
|
+
/**
|
|
74
|
+
* Transforms JSON data using JSONPath or JMESPath expressions
|
|
75
|
+
*
|
|
76
|
+
* @param params - The action parameters containing:
|
|
77
|
+
* - InputData: JSON object or array to transform
|
|
78
|
+
* - Expression: JSONPath or JMESPath query expression
|
|
79
|
+
* - TransformType: "JSONPath" | "JMESPath" (default: "JSONPath")
|
|
80
|
+
* - Multiple: Boolean - return all matches vs first match (JSONPath only, default: true)
|
|
81
|
+
* - Flatten: Boolean - flatten array results (default: false)
|
|
82
|
+
* - WrapScalar: Boolean - wrap scalar results in object (default: false)
|
|
83
|
+
*
|
|
84
|
+
* @returns Transformed data based on the expression
|
|
85
|
+
*/
|
|
86
|
+
async InternalRunAction(params) {
|
|
87
|
+
try {
|
|
88
|
+
// Extract parameters
|
|
89
|
+
let inputData;
|
|
90
|
+
try {
|
|
91
|
+
inputData = json_param_helper_1.JSONParamHelper.getRequiredJSONParam(params, 'InputData');
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return {
|
|
95
|
+
Success: false,
|
|
96
|
+
Message: error instanceof Error ? error.message : String(error),
|
|
97
|
+
ResultCode: "MISSING_PARAMETERS"
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const expressionParam = params.Params.find(p => p.Name.trim().toLowerCase() === 'expression');
|
|
101
|
+
const transformTypeParam = params.Params.find(p => p.Name.trim().toLowerCase() === 'transformtype');
|
|
102
|
+
const multipleParam = params.Params.find(p => p.Name.trim().toLowerCase() === 'multiple');
|
|
103
|
+
const flattenParam = params.Params.find(p => p.Name.trim().toLowerCase() === 'flatten');
|
|
104
|
+
const wrapScalarParam = params.Params.find(p => p.Name.trim().toLowerCase() === 'wrapscalar');
|
|
105
|
+
// Validate required parameters
|
|
106
|
+
if (!expressionParam?.Value) {
|
|
107
|
+
return {
|
|
108
|
+
Success: false,
|
|
109
|
+
Message: "Expression parameter is required",
|
|
110
|
+
ResultCode: "MISSING_PARAMETERS"
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const expression = expressionParam.Value.toString();
|
|
114
|
+
const transformType = (transformTypeParam?.Value?.toString() || 'JSONPath').toUpperCase();
|
|
115
|
+
const multiple = multipleParam?.Value?.toString()?.toLowerCase() === 'true' ?? true;
|
|
116
|
+
const flatten = flattenParam?.Value?.toString()?.toLowerCase() === 'true' ?? false;
|
|
117
|
+
const wrapScalar = wrapScalarParam?.Value?.toString()?.toLowerCase() === 'true' ?? false;
|
|
118
|
+
let result;
|
|
119
|
+
if (transformType === 'JSONPATH') {
|
|
120
|
+
// Use JSONPath
|
|
121
|
+
try {
|
|
122
|
+
const options = {
|
|
123
|
+
path: expression,
|
|
124
|
+
json: inputData,
|
|
125
|
+
resultType: (multiple ? 'all' : 'value'),
|
|
126
|
+
wrap: false,
|
|
127
|
+
flatten: flatten
|
|
128
|
+
};
|
|
129
|
+
result = (0, jsonpath_plus_1.JSONPath)(options);
|
|
130
|
+
// Handle empty results
|
|
131
|
+
if (result === undefined || (Array.isArray(result) && result.length === 0)) {
|
|
132
|
+
result = null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
return {
|
|
137
|
+
Success: false,
|
|
138
|
+
Message: `JSONPath error: ${error instanceof Error ? error.message : String(error)}`,
|
|
139
|
+
ResultCode: "EXPRESSION_ERROR"
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else if (transformType === 'JMESPATH') {
|
|
144
|
+
// Use JMESPath
|
|
145
|
+
try {
|
|
146
|
+
result = jmespath.search(inputData, expression);
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
return {
|
|
150
|
+
Success: false,
|
|
151
|
+
Message: `JMESPath error: ${error instanceof Error ? error.message : String(error)}`,
|
|
152
|
+
ResultCode: "EXPRESSION_ERROR"
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
return {
|
|
158
|
+
Success: false,
|
|
159
|
+
Message: `Invalid TransformType: ${transformType}. Must be 'JSONPath' or 'JMESPath'`,
|
|
160
|
+
ResultCode: "INVALID_PARAMETERS"
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
// Wrap scalar results if requested
|
|
164
|
+
if (wrapScalar && (typeof result === 'string' || typeof result === 'number' || typeof result === 'boolean')) {
|
|
165
|
+
result = { value: result };
|
|
166
|
+
}
|
|
167
|
+
// Prepare output
|
|
168
|
+
const output = {
|
|
169
|
+
result: result,
|
|
170
|
+
transformType: transformType,
|
|
171
|
+
expression: expression,
|
|
172
|
+
inputType: Array.isArray(inputData) ? 'array' : typeof inputData,
|
|
173
|
+
resultType: result === null ? 'null' : Array.isArray(result) ? 'array' : typeof result
|
|
174
|
+
};
|
|
175
|
+
// Add match count for arrays
|
|
176
|
+
if (Array.isArray(result)) {
|
|
177
|
+
output['matchCount'] = result.length;
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
Success: true,
|
|
181
|
+
ResultCode: "SUCCESS",
|
|
182
|
+
Message: JSON.stringify(output, null, 2)
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
return {
|
|
187
|
+
Success: false,
|
|
188
|
+
Message: `Failed to transform JSON: ${error instanceof Error ? error.message : String(error)}`,
|
|
189
|
+
ResultCode: "FAILED"
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
exports.JSONTransformAction = JSONTransformAction;
|
|
195
|
+
exports.JSONTransformAction = JSONTransformAction = __decorate([
|
|
196
|
+
(0, global_1.RegisterClass)(actions_1.BaseAction, "JSON Transform")
|
|
197
|
+
], JSONTransformAction);
|
|
198
|
+
/**
|
|
199
|
+
* Loader function to ensure the JSONTransformAction class is included in the bundle
|
|
200
|
+
*/
|
|
201
|
+
function LoadJSONTransformAction() {
|
|
202
|
+
// Stub function to prevent tree shaking
|
|
203
|
+
}
|
|
204
|
+
exports.LoadJSONTransformAction = LoadJSONTransformAction;
|
|
205
|
+
//# sourceMappingURL=json-transform.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-transform.action.js","sourceRoot":"","sources":["../../../src/custom/data/json-transform.action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qDAAqD;AACrD,mDAAuD;AACvD,iDAAyC;AACzC,mDAAqC;AACrC,sEAAiE;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,oBAAU;IAE/C;;;;;;;;;;;;OAYG;IACO,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,qBAAqB;YACrB,IAAI,SAAc,CAAC;YACnB,IAAI,CAAC;gBACD,SAAS,GAAG,mCAAe,CAAC,oBAAoB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YAC1E,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;oBAC/D,UAAU,EAAE,oBAAoB;iBACnC,CAAC;YACN,CAAC;YAED,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,YAAY,CAAC,CAAC;YAC9F,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,eAAe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AC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;gBAC9F,UAAU,EAAE,QAAQ;aACvB,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAA;AAhIY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,sBAAa,EAAC,oBAAU,EAAE,gBAAgB,CAAC;GAC/B,mBAAmB,CAgI/B;AAED;;GAEG;AACH,SAAgB,uBAAuB;IACnC,wCAAwC;AAC5C,CAAC;AAFD,0DAEC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import { BaseFileHandlerAction } from "../utilities/base-file-handler";
|
|
3
|
+
/**
|
|
4
|
+
* Action that parses XML data and extracts content using XPath expressions
|
|
5
|
+
* Supports namespaces, various return types, and multiple input sources
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Parse XML and extract with XPath
|
|
10
|
+
* await runAction({
|
|
11
|
+
* ActionName: 'XML Parser',
|
|
12
|
+
* Params: [{
|
|
13
|
+
* Name: 'XMLData',
|
|
14
|
+
* Value: '<users><user id="1"><name>John</name></user><user id="2"><name>Jane</name></user></users>'
|
|
15
|
+
* }, {
|
|
16
|
+
* Name: 'XPathExpression',
|
|
17
|
+
* Value: '//user[@id="1"]/name/text()'
|
|
18
|
+
* }]
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Parse XML with namespaces
|
|
22
|
+
* await runAction({
|
|
23
|
+
* ActionName: 'XML Parser',
|
|
24
|
+
* Params: [{
|
|
25
|
+
* Name: 'XMLData',
|
|
26
|
+
* Value: '<ns:root xmlns:ns="http://example.com"><ns:value>Test</ns:value></ns:root>'
|
|
27
|
+
* }, {
|
|
28
|
+
* Name: 'XPathExpression',
|
|
29
|
+
* Value: '//ns:value/text()'
|
|
30
|
+
* }, {
|
|
31
|
+
* Name: 'NamespaceMap',
|
|
32
|
+
* Value: { ns: 'http://example.com' }
|
|
33
|
+
* }]
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* // Convert entire XML to JSON
|
|
37
|
+
* await runAction({
|
|
38
|
+
* ActionName: 'XML Parser',
|
|
39
|
+
* Params: [{
|
|
40
|
+
* Name: 'XMLData',
|
|
41
|
+
* Value: '<root><item>Value 1</item><item>Value 2</item></root>'
|
|
42
|
+
* }]
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare class XMLParserAction extends BaseFileHandlerAction {
|
|
47
|
+
/**
|
|
48
|
+
* Parses XML and extracts data using XPath expressions
|
|
49
|
+
*
|
|
50
|
+
* @param params - The action parameters containing:
|
|
51
|
+
* - XMLData: String containing XML data (direct input)
|
|
52
|
+
* - FileID: UUID of MJ Storage file (alternative)
|
|
53
|
+
* - FileURL: URL of XML file (alternative)
|
|
54
|
+
* - XPathExpression: XPath query to extract data (optional - if not provided, converts entire XML to JSON)
|
|
55
|
+
* - NamespaceMap: Object mapping namespace prefixes to URIs
|
|
56
|
+
* - ReturnType: "string" | "number" | "boolean" | "node" | "nodes" | "json" (default: "string")
|
|
57
|
+
* - PreserveAttributes: Boolean - include attributes in JSON conversion (default: true)
|
|
58
|
+
* - ExplicitArray: Boolean - always put child nodes in array (default: false)
|
|
59
|
+
* - IgnoreAttributes: Boolean - ignore attributes in conversion (default: false)
|
|
60
|
+
*
|
|
61
|
+
* @returns Extracted data based on XPath or full JSON conversion
|
|
62
|
+
*/
|
|
63
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
64
|
+
/**
|
|
65
|
+
* Extract data using XPath
|
|
66
|
+
*/
|
|
67
|
+
private extractWithXPath;
|
|
68
|
+
/**
|
|
69
|
+
* Convert node to string
|
|
70
|
+
*/
|
|
71
|
+
private nodeToString;
|
|
72
|
+
/**
|
|
73
|
+
* Convert node to JSON representation
|
|
74
|
+
*/
|
|
75
|
+
private nodeToJSON;
|
|
76
|
+
/**
|
|
77
|
+
* Convert entire XML to JSON using xml2js
|
|
78
|
+
*/
|
|
79
|
+
private convertToJSON;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Loader function to ensure the XMLParserAction class is included in the bundle
|
|
83
|
+
*/
|
|
84
|
+
export declare function LoadXMLParserAction(): void;
|
|
85
|
+
//# sourceMappingURL=xml-parser.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xml-parser.action.d.ts","sourceRoot":"","sources":["../../../src/custom/data/xml-parser.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAMvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,qBACa,eAAgB,SAAQ,qBAAqB;IAEtD;;;;;;;;;;;;;;;OAeG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAwEvF;;OAEG;YACW,gBAAgB;IAiE9B;;OAEG;IACH,OAAO,CAAC,YAAY;IASpB;;OAEG;IACH,OAAO,CAAC,UAAU;IA4DlB;;OAEG;YACW,aAAa;CAqB9B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,SAElC"}
|