@memberjunction/core-actions 2.54.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.
Files changed (118) hide show
  1. package/dist/custom/ai/execute-ai-prompt.action.d.ts +94 -0
  2. package/dist/custom/ai/execute-ai-prompt.action.d.ts.map +1 -0
  3. package/dist/custom/ai/execute-ai-prompt.action.js +274 -0
  4. package/dist/custom/ai/execute-ai-prompt.action.js.map +1 -0
  5. package/dist/custom/communication/slack-webhook.action.d.ts +101 -0
  6. package/dist/custom/communication/slack-webhook.action.d.ts.map +1 -0
  7. package/dist/custom/communication/slack-webhook.action.js +269 -0
  8. package/dist/custom/communication/slack-webhook.action.js.map +1 -0
  9. package/dist/custom/communication/teams-webhook.action.d.ts +96 -0
  10. package/dist/custom/communication/teams-webhook.action.d.ts.map +1 -0
  11. package/dist/custom/communication/teams-webhook.action.js +275 -0
  12. package/dist/custom/communication/teams-webhook.action.js.map +1 -0
  13. package/dist/custom/data/aggregate-data.action.d.ts +91 -0
  14. package/dist/custom/data/aggregate-data.action.d.ts.map +1 -0
  15. package/dist/custom/data/aggregate-data.action.js +333 -0
  16. package/dist/custom/data/aggregate-data.action.js.map +1 -0
  17. package/dist/custom/data/csv-parser.action.d.ts +68 -0
  18. package/dist/custom/data/csv-parser.action.d.ts.map +1 -0
  19. package/dist/custom/data/csv-parser.action.js +184 -0
  20. package/dist/custom/data/csv-parser.action.js.map +1 -0
  21. package/dist/custom/data/data-mapper.action.d.ts +89 -0
  22. package/dist/custom/data/data-mapper.action.d.ts.map +1 -0
  23. package/dist/custom/data/data-mapper.action.js +325 -0
  24. package/dist/custom/data/data-mapper.action.js.map +1 -0
  25. package/dist/custom/data/json-transform.action.d.ts +57 -0
  26. package/dist/custom/data/json-transform.action.d.ts.map +1 -0
  27. package/dist/custom/data/json-transform.action.js +205 -0
  28. package/dist/custom/data/json-transform.action.js.map +1 -0
  29. package/dist/custom/data/xml-parser.action.d.ts +85 -0
  30. package/dist/custom/data/xml-parser.action.d.ts.map +1 -0
  31. package/dist/custom/data/xml-parser.action.js +326 -0
  32. package/dist/custom/data/xml-parser.action.js.map +1 -0
  33. package/dist/custom/files/excel-reader.action.d.ts +86 -0
  34. package/dist/custom/files/excel-reader.action.d.ts.map +1 -0
  35. package/dist/custom/files/excel-reader.action.js +348 -0
  36. package/dist/custom/files/excel-reader.action.js.map +1 -0
  37. package/dist/custom/files/excel-writer.action.d.ts +79 -0
  38. package/dist/custom/files/excel-writer.action.d.ts.map +1 -0
  39. package/dist/custom/files/excel-writer.action.js +325 -0
  40. package/dist/custom/files/excel-writer.action.js.map +1 -0
  41. package/dist/custom/files/file-compress.action.d.ts +90 -0
  42. package/dist/custom/files/file-compress.action.d.ts.map +1 -0
  43. package/dist/custom/files/file-compress.action.js +346 -0
  44. package/dist/custom/files/file-compress.action.js.map +1 -0
  45. package/dist/custom/files/pdf-extractor.action.d.ts +86 -0
  46. package/dist/custom/files/pdf-extractor.action.d.ts.map +1 -0
  47. package/dist/custom/files/pdf-extractor.action.js +247 -0
  48. package/dist/custom/files/pdf-extractor.action.js.map +1 -0
  49. package/dist/custom/files/pdf-generator.action.d.ts +70 -0
  50. package/dist/custom/files/pdf-generator.action.d.ts.map +1 -0
  51. package/dist/custom/files/pdf-generator.action.js +286 -0
  52. package/dist/custom/files/pdf-generator.action.js.map +1 -0
  53. package/dist/custom/integration/api-rate-limiter.action.d.ts +88 -0
  54. package/dist/custom/integration/api-rate-limiter.action.d.ts.map +1 -0
  55. package/dist/custom/integration/api-rate-limiter.action.js +363 -0
  56. package/dist/custom/integration/api-rate-limiter.action.js.map +1 -0
  57. package/dist/custom/integration/graphql-query.action.d.ts +92 -0
  58. package/dist/custom/integration/graphql-query.action.d.ts.map +1 -0
  59. package/dist/custom/integration/graphql-query.action.js +251 -0
  60. package/dist/custom/integration/graphql-query.action.js.map +1 -0
  61. package/dist/custom/integration/http-request.action.d.ts +96 -0
  62. package/dist/custom/integration/http-request.action.d.ts.map +1 -0
  63. package/dist/custom/integration/http-request.action.js +316 -0
  64. package/dist/custom/integration/http-request.action.js.map +1 -0
  65. package/dist/custom/integration/oauth-flow.action.d.ts +130 -0
  66. package/dist/custom/integration/oauth-flow.action.d.ts.map +1 -0
  67. package/dist/custom/integration/oauth-flow.action.js +624 -0
  68. package/dist/custom/integration/oauth-flow.action.js.map +1 -0
  69. package/dist/custom/security/password-strength.action.d.ts +129 -0
  70. package/dist/custom/security/password-strength.action.d.ts.map +1 -0
  71. package/dist/custom/security/password-strength.action.js +463 -0
  72. package/dist/custom/security/password-strength.action.js.map +1 -0
  73. package/dist/custom/utilities/base-file-handler.d.ts +54 -0
  74. package/dist/custom/utilities/base-file-handler.d.ts.map +1 -0
  75. package/dist/custom/utilities/base-file-handler.js +167 -0
  76. package/dist/custom/utilities/base-file-handler.js.map +1 -0
  77. package/dist/custom/utilities/index.d.ts +3 -0
  78. package/dist/custom/utilities/index.d.ts.map +1 -0
  79. package/dist/custom/utilities/index.js +19 -0
  80. package/dist/custom/utilities/index.js.map +1 -0
  81. package/dist/custom/utilities/json-param-helper.d.ts +33 -0
  82. package/dist/custom/utilities/json-param-helper.d.ts.map +1 -0
  83. package/dist/custom/utilities/json-param-helper.js +66 -0
  84. package/dist/custom/utilities/json-param-helper.js.map +1 -0
  85. package/dist/custom/web/duckduckgo-rate-limiter.d.ts +72 -0
  86. package/dist/custom/web/duckduckgo-rate-limiter.d.ts.map +1 -0
  87. package/dist/custom/web/duckduckgo-rate-limiter.js +175 -0
  88. package/dist/custom/web/duckduckgo-rate-limiter.js.map +1 -0
  89. package/dist/custom/web/web-search.action.d.ts +1 -0
  90. package/dist/custom/web/web-search.action.d.ts.map +1 -1
  91. package/dist/custom/web/web-search.action.js +48 -20
  92. package/dist/custom/web/web-search.action.js.map +1 -1
  93. package/dist/custom/workflow/conditional.action.d.ts +94 -0
  94. package/dist/custom/workflow/conditional.action.d.ts.map +1 -0
  95. package/dist/custom/workflow/conditional.action.js +274 -0
  96. package/dist/custom/workflow/conditional.action.js.map +1 -0
  97. package/dist/custom/workflow/delay.action.d.ts +76 -0
  98. package/dist/custom/workflow/delay.action.d.ts.map +1 -0
  99. package/dist/custom/workflow/delay.action.js +187 -0
  100. package/dist/custom/workflow/delay.action.js.map +1 -0
  101. package/dist/custom/workflow/loop.action.d.ts +112 -0
  102. package/dist/custom/workflow/loop.action.d.ts.map +1 -0
  103. package/dist/custom/workflow/loop.action.js +380 -0
  104. package/dist/custom/workflow/loop.action.js.map +1 -0
  105. package/dist/custom/workflow/parallel-execute.action.d.ts +105 -0
  106. package/dist/custom/workflow/parallel-execute.action.d.ts.map +1 -0
  107. package/dist/custom/workflow/parallel-execute.action.js +457 -0
  108. package/dist/custom/workflow/parallel-execute.action.js.map +1 -0
  109. package/dist/custom/workflow/retry.action.d.ts +90 -0
  110. package/dist/custom/workflow/retry.action.d.ts.map +1 -0
  111. package/dist/custom/workflow/retry.action.js +378 -0
  112. package/dist/custom/workflow/retry.action.js.map +1 -0
  113. package/dist/index.d.ts +23 -0
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +75 -0
  116. package/dist/index.js.map +1 -1
  117. package/package.json +25 -10
  118. package/readme.md +11270 -101
@@ -0,0 +1,251 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.LoadGraphQLQueryAction = exports.GraphQLQueryAction = void 0;
13
+ const global_1 = require("@memberjunction/global");
14
+ const actions_1 = require("@memberjunction/actions");
15
+ const axios_1 = __importDefault(require("axios"));
16
+ const json_param_helper_1 = require("../utilities/json-param-helper");
17
+ /**
18
+ * Action that executes GraphQL queries and mutations
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // Simple query
23
+ * await runAction({
24
+ * ActionName: 'GraphQL Query',
25
+ * Params: [{
26
+ * Name: 'Endpoint',
27
+ * Value: 'https://api.example.com/graphql'
28
+ * }, {
29
+ * Name: 'Query',
30
+ * Value: `
31
+ * query GetUser($id: ID!) {
32
+ * user(id: $id) {
33
+ * id
34
+ * name
35
+ * email
36
+ * }
37
+ * }
38
+ * `
39
+ * }, {
40
+ * Name: 'Variables',
41
+ * Value: { id: '123' }
42
+ * }]
43
+ * });
44
+ *
45
+ * // Mutation with headers
46
+ * await runAction({
47
+ * ActionName: 'GraphQL Query',
48
+ * Params: [{
49
+ * Name: 'Endpoint',
50
+ * Value: 'https://api.example.com/graphql'
51
+ * }, {
52
+ * Name: 'Query',
53
+ * Value: `
54
+ * mutation CreateUser($input: CreateUserInput!) {
55
+ * createUser(input: $input) {
56
+ * id
57
+ * name
58
+ * }
59
+ * }
60
+ * `
61
+ * }, {
62
+ * Name: 'Variables',
63
+ * Value: {
64
+ * input: {
65
+ * name: 'John Doe',
66
+ * email: 'john@example.com'
67
+ * }
68
+ * }
69
+ * }, {
70
+ * Name: 'Headers',
71
+ * Value: {
72
+ * 'Authorization': 'Bearer token123'
73
+ * }
74
+ * }]
75
+ * });
76
+ * ```
77
+ */
78
+ let GraphQLQueryAction = class GraphQLQueryAction extends actions_1.BaseAction {
79
+ /**
80
+ * Executes a GraphQL query or mutation
81
+ *
82
+ * @param params - The action parameters containing:
83
+ * - Endpoint: GraphQL endpoint URL (required)
84
+ * - Query: GraphQL query/mutation string (required)
85
+ * - Variables: Variables object for the query (optional)
86
+ * - Headers: Additional headers for the request (optional)
87
+ * - OperationName: For multi-operation documents (optional)
88
+ * - Timeout: Request timeout in milliseconds - default: 30000
89
+ *
90
+ * @returns GraphQL response data
91
+ */
92
+ async InternalRunAction(params) {
93
+ try {
94
+ const endpoint = this.getParamValue(params, 'endpoint');
95
+ const query = this.getParamValue(params, 'query');
96
+ const variables = json_param_helper_1.JSONParamHelper.getJSONParam(params, 'variables');
97
+ const headers = json_param_helper_1.JSONParamHelper.getJSONParam(params, 'headers') || {};
98
+ const operationName = this.getParamValue(params, 'operationname');
99
+ const timeout = this.getNumericParam(params, 'timeout', 30000);
100
+ // Validate required parameters
101
+ if (!endpoint) {
102
+ return {
103
+ Success: false,
104
+ Message: "Endpoint parameter is required",
105
+ ResultCode: "MISSING_ENDPOINT"
106
+ };
107
+ }
108
+ if (!query) {
109
+ return {
110
+ Success: false,
111
+ Message: "Query parameter is required",
112
+ ResultCode: "MISSING_QUERY"
113
+ };
114
+ }
115
+ // Validate endpoint URL
116
+ try {
117
+ new URL(endpoint);
118
+ }
119
+ catch (e) {
120
+ return {
121
+ Success: false,
122
+ Message: `Invalid endpoint URL: ${endpoint}`,
123
+ ResultCode: "INVALID_URL"
124
+ };
125
+ }
126
+ // Prepare GraphQL request body
127
+ const requestBody = { query };
128
+ if (variables) {
129
+ requestBody.variables = variables;
130
+ }
131
+ if (operationName) {
132
+ requestBody.operationName = operationName;
133
+ }
134
+ // Prepare headers
135
+ const requestHeaders = {
136
+ 'Content-Type': 'application/json',
137
+ 'Accept': 'application/json',
138
+ ...headers
139
+ };
140
+ // Make GraphQL request
141
+ const response = await axios_1.default.post(endpoint, requestBody, {
142
+ headers: requestHeaders,
143
+ timeout,
144
+ validateStatus: () => true // Handle all status codes
145
+ });
146
+ // Check for HTTP errors
147
+ if (response.status < 200 || response.status >= 300) {
148
+ return {
149
+ Success: false,
150
+ Message: `HTTP error ${response.status}: ${response.statusText}`,
151
+ ResultCode: `HTTP_${response.status}`
152
+ };
153
+ }
154
+ // Check for GraphQL errors
155
+ const responseData = response.data;
156
+ const hasErrors = responseData.errors && responseData.errors.length > 0;
157
+ // Add output parameters
158
+ if (responseData.data) {
159
+ params.Params.push({
160
+ Name: 'Data',
161
+ Type: 'Output',
162
+ Value: responseData.data
163
+ });
164
+ }
165
+ if (responseData.errors) {
166
+ params.Params.push({
167
+ Name: 'Errors',
168
+ Type: 'Output',
169
+ Value: responseData.errors
170
+ });
171
+ }
172
+ if (responseData.extensions) {
173
+ params.Params.push({
174
+ Name: 'Extensions',
175
+ Type: 'Output',
176
+ Value: responseData.extensions
177
+ });
178
+ }
179
+ // Determine success based on GraphQL response
180
+ if (hasErrors && !responseData.data) {
181
+ // Only errors, no data - complete failure
182
+ return {
183
+ Success: false,
184
+ Message: `GraphQL errors: ${JSON.stringify(responseData.errors, null, 2)}`,
185
+ ResultCode: "GRAPHQL_ERROR"
186
+ };
187
+ }
188
+ else if (hasErrors && responseData.data) {
189
+ // Partial success - has both data and errors
190
+ return {
191
+ Success: true,
192
+ ResultCode: "PARTIAL_SUCCESS",
193
+ Message: JSON.stringify({
194
+ message: "GraphQL query completed with errors",
195
+ data: responseData.data,
196
+ errors: responseData.errors,
197
+ extensions: responseData.extensions
198
+ }, null, 2)
199
+ };
200
+ }
201
+ else {
202
+ // Complete success
203
+ return {
204
+ Success: true,
205
+ ResultCode: "SUCCESS",
206
+ Message: JSON.stringify({
207
+ message: "GraphQL query executed successfully",
208
+ data: responseData.data,
209
+ extensions: responseData.extensions
210
+ }, null, 2)
211
+ };
212
+ }
213
+ }
214
+ catch (error) {
215
+ return {
216
+ Success: false,
217
+ Message: `GraphQL request failed: ${error instanceof Error ? error.message : String(error)}`,
218
+ ResultCode: "REQUEST_FAILED"
219
+ };
220
+ }
221
+ }
222
+ /**
223
+ * Get numeric parameter with default
224
+ */
225
+ getNumericParam(params, name, defaultValue) {
226
+ const value = this.getParamValue(params, name);
227
+ if (value === undefined || value === null)
228
+ return defaultValue;
229
+ const num = Number(value);
230
+ return isNaN(num) ? defaultValue : num;
231
+ }
232
+ /**
233
+ * Get parameter value by name (case-insensitive)
234
+ */
235
+ getParamValue(params, name) {
236
+ const param = params.Params.find(p => p.Name.toLowerCase() === name.toLowerCase());
237
+ return param?.Value;
238
+ }
239
+ };
240
+ exports.GraphQLQueryAction = GraphQLQueryAction;
241
+ exports.GraphQLQueryAction = GraphQLQueryAction = __decorate([
242
+ (0, global_1.RegisterClass)(actions_1.BaseAction, "GraphQL Query")
243
+ ], GraphQLQueryAction);
244
+ /**
245
+ * Loader function to ensure the GraphQLQueryAction class is included in the bundle
246
+ */
247
+ function LoadGraphQLQueryAction() {
248
+ // Stub function to prevent tree shaking
249
+ }
250
+ exports.LoadGraphQLQueryAction = LoadGraphQLQueryAction;
251
+ //# sourceMappingURL=graphql-query.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql-query.action.js","sourceRoot":"","sources":["../../../src/custom/integration/graphql-query.action.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,mDAAuD;AACvD,qDAAqD;AACrD,kDAA0B;AAC1B,sEAAiE;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,oBAAU;IAE9C;;;;;;;;;;;;OAYG;IACO,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACxD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAClD,MAAM,SAAS,GAAG,mCAAe,CAAC,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YACpE,MAAM,OAAO,GAAG,mCAAe,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC;YACtE,MAAM,aAAa,GAA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AC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC/C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,YAAY,CAAC;QAC/D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3C,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,MAAuB,EAAE,IAAY;QACvD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACnF,OAAO,KAAK,EAAE,KAAK,CAAC;IACxB,CAAC;CACJ,CAAA;AA9KY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,sBAAa,EAAC,oBAAU,EAAE,eAAe,CAAC;GAC9B,kBAAkB,CA8K9B;AAED;;GAEG;AACH,SAAgB,sBAAsB;IAClC,wCAAwC;AAC5C,CAAC;AAFD,wDAEC"}
@@ -0,0 +1,96 @@
1
+ import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
2
+ import { BaseAction } from "@memberjunction/actions";
3
+ /**
4
+ * Action that makes HTTP requests with full control over headers, authentication, and request options
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * // Simple GET request
9
+ * await runAction({
10
+ * ActionName: 'HTTP Request',
11
+ * Params: [{
12
+ * Name: 'URL',
13
+ * Value: 'https://api.example.com/data'
14
+ * }]
15
+ * });
16
+ *
17
+ * // POST request with JSON body
18
+ * await runAction({
19
+ * ActionName: 'HTTP Request',
20
+ * Params: [{
21
+ * Name: 'URL',
22
+ * Value: 'https://api.example.com/users'
23
+ * }, {
24
+ * Name: 'Method',
25
+ * Value: 'POST'
26
+ * }, {
27
+ * Name: 'Body',
28
+ * Value: { name: 'John Doe', email: 'john@example.com' }
29
+ * }, {
30
+ * Name: 'Headers',
31
+ * Value: { 'Content-Type': 'application/json' }
32
+ * }]
33
+ * });
34
+ *
35
+ * // Request with authentication
36
+ * await runAction({
37
+ * ActionName: 'HTTP Request',
38
+ * Params: [{
39
+ * Name: 'URL',
40
+ * Value: 'https://api.example.com/protected'
41
+ * }, {
42
+ * Name: 'Authentication',
43
+ * Value: {
44
+ * type: 'bearer',
45
+ * token: 'your-api-token'
46
+ * }
47
+ * }]
48
+ * });
49
+ * ```
50
+ */
51
+ export declare class HTTPRequestAction extends BaseAction {
52
+ /**
53
+ * Makes an HTTP request with configurable options
54
+ *
55
+ * @param params - The action parameters containing:
56
+ * - URL: Target URL (required)
57
+ * - Method: HTTP method (GET, POST, PUT, DELETE, etc.) - default: GET
58
+ * - Headers: Object with request headers
59
+ * - Body: Request body (string or object)
60
+ * - BodyType: "json" | "form" | "text" | "binary" - default: "json"
61
+ * - Authentication: Auth config object { type: 'basic'|'bearer', username?, password?, token? }
62
+ * - Timeout: Request timeout in milliseconds - default: 30000
63
+ * - FollowRedirects: Boolean - default: true
64
+ * - MaxRedirects: Number - default: 5
65
+ * - ValidateStatus: Function string to validate response status
66
+ * - ResponseType: "json" | "text" | "arraybuffer" | "stream" - default: "json"
67
+ *
68
+ * @returns Response object with status, headers, and body
69
+ */
70
+ protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
71
+ /**
72
+ * Configure authentication for the request
73
+ */
74
+ private configureAuthentication;
75
+ /**
76
+ * Configure request body based on type
77
+ */
78
+ private configureRequestBody;
79
+ /**
80
+ * Get numeric parameter with default
81
+ */
82
+ private getNumericParam;
83
+ /**
84
+ * Get boolean parameter with default
85
+ */
86
+ private getBooleanParam;
87
+ /**
88
+ * Get parameter value by name (case-insensitive)
89
+ */
90
+ private getParamValue;
91
+ }
92
+ /**
93
+ * Loader function to ensure the HTTPRequestAction class is included in the bundle
94
+ */
95
+ export declare function LoadHTTPRequestAction(): void;
96
+ //# sourceMappingURL=http-request.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-request.action.d.ts","sourceRoot":"","sources":["../../../src/custom/integration/http-request.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,qBACa,iBAAkB,SAAQ,UAAU;IAE7C;;;;;;;;;;;;;;;;;OAiBG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA8GvF;;OAEG;IACH,OAAO,CAAC,uBAAuB;IA4C/B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAkD5B;;OAEG;IACH,OAAO,CAAC,eAAe;IAOvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAUvB;;OAEG;IACH,OAAO,CAAC,aAAa;CAIxB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,SAEpC"}
@@ -0,0 +1,316 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.LoadHTTPRequestAction = exports.HTTPRequestAction = void 0;
13
+ const global_1 = require("@memberjunction/global");
14
+ const actions_1 = require("@memberjunction/actions");
15
+ const axios_1 = __importDefault(require("axios"));
16
+ const json_param_helper_1 = require("../utilities/json-param-helper");
17
+ /**
18
+ * Action that makes HTTP requests with full control over headers, authentication, and request options
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // Simple GET request
23
+ * await runAction({
24
+ * ActionName: 'HTTP Request',
25
+ * Params: [{
26
+ * Name: 'URL',
27
+ * Value: 'https://api.example.com/data'
28
+ * }]
29
+ * });
30
+ *
31
+ * // POST request with JSON body
32
+ * await runAction({
33
+ * ActionName: 'HTTP Request',
34
+ * Params: [{
35
+ * Name: 'URL',
36
+ * Value: 'https://api.example.com/users'
37
+ * }, {
38
+ * Name: 'Method',
39
+ * Value: 'POST'
40
+ * }, {
41
+ * Name: 'Body',
42
+ * Value: { name: 'John Doe', email: 'john@example.com' }
43
+ * }, {
44
+ * Name: 'Headers',
45
+ * Value: { 'Content-Type': 'application/json' }
46
+ * }]
47
+ * });
48
+ *
49
+ * // Request with authentication
50
+ * await runAction({
51
+ * ActionName: 'HTTP Request',
52
+ * Params: [{
53
+ * Name: 'URL',
54
+ * Value: 'https://api.example.com/protected'
55
+ * }, {
56
+ * Name: 'Authentication',
57
+ * Value: {
58
+ * type: 'bearer',
59
+ * token: 'your-api-token'
60
+ * }
61
+ * }]
62
+ * });
63
+ * ```
64
+ */
65
+ let HTTPRequestAction = class HTTPRequestAction extends actions_1.BaseAction {
66
+ /**
67
+ * Makes an HTTP request with configurable options
68
+ *
69
+ * @param params - The action parameters containing:
70
+ * - URL: Target URL (required)
71
+ * - Method: HTTP method (GET, POST, PUT, DELETE, etc.) - default: GET
72
+ * - Headers: Object with request headers
73
+ * - Body: Request body (string or object)
74
+ * - BodyType: "json" | "form" | "text" | "binary" - default: "json"
75
+ * - Authentication: Auth config object { type: 'basic'|'bearer', username?, password?, token? }
76
+ * - Timeout: Request timeout in milliseconds - default: 30000
77
+ * - FollowRedirects: Boolean - default: true
78
+ * - MaxRedirects: Number - default: 5
79
+ * - ValidateStatus: Function string to validate response status
80
+ * - ResponseType: "json" | "text" | "arraybuffer" | "stream" - default: "json"
81
+ *
82
+ * @returns Response object with status, headers, and body
83
+ */
84
+ async InternalRunAction(params) {
85
+ try {
86
+ const url = this.getParamValue(params, 'url');
87
+ const method = (this.getParamValue(params, 'method') || 'GET').toUpperCase();
88
+ const headers = json_param_helper_1.JSONParamHelper.getJSONParam(params, 'headers') || {};
89
+ const body = json_param_helper_1.JSONParamHelper.getJSONParam(params, 'body');
90
+ const bodyType = this.getParamValue(params, 'bodytype') || 'json';
91
+ const authentication = json_param_helper_1.JSONParamHelper.getJSONParam(params, 'authentication');
92
+ const timeout = this.getNumericParam(params, 'timeout', 30000);
93
+ const followRedirects = this.getBooleanParam(params, 'followredirects', true);
94
+ const maxRedirects = this.getNumericParam(params, 'maxredirects', 5);
95
+ const responseType = this.getParamValue(params, 'responsetype') || 'json';
96
+ // Validate URL
97
+ if (!url) {
98
+ return {
99
+ Success: false,
100
+ Message: "URL parameter is required",
101
+ ResultCode: "MISSING_URL"
102
+ };
103
+ }
104
+ // Build request config
105
+ const config = {
106
+ url,
107
+ method,
108
+ headers: { ...headers },
109
+ timeout,
110
+ maxRedirects: followRedirects ? maxRedirects : 0,
111
+ responseType: responseType,
112
+ validateStatus: () => true // We'll handle status validation ourselves
113
+ };
114
+ // Handle authentication
115
+ if (authentication) {
116
+ const authResult = this.configureAuthentication(config, authentication);
117
+ if (!authResult.success) {
118
+ return {
119
+ Success: false,
120
+ Message: authResult.error,
121
+ ResultCode: "AUTH_CONFIG_ERROR"
122
+ };
123
+ }
124
+ }
125
+ // Handle request body
126
+ if (body && ['POST', 'PUT', 'PATCH'].includes(method)) {
127
+ const bodyResult = this.configureRequestBody(config, body, bodyType);
128
+ if (!bodyResult.success) {
129
+ return {
130
+ Success: false,
131
+ Message: bodyResult.error,
132
+ ResultCode: "BODY_CONFIG_ERROR"
133
+ };
134
+ }
135
+ }
136
+ // Make request
137
+ const response = await (0, axios_1.default)(config);
138
+ // Prepare response data
139
+ let responseData = response.data;
140
+ if (responseType === 'arraybuffer' && Buffer.isBuffer(responseData)) {
141
+ responseData = responseData.toString('base64');
142
+ }
143
+ // Add output parameters
144
+ params.Params.push({
145
+ Name: 'ResponseStatus',
146
+ Type: 'Output',
147
+ Value: response.status
148
+ });
149
+ params.Params.push({
150
+ Name: 'ResponseHeaders',
151
+ Type: 'Output',
152
+ Value: response.headers
153
+ });
154
+ params.Params.push({
155
+ Name: 'ResponseData',
156
+ Type: 'Output',
157
+ Value: responseData
158
+ });
159
+ // Check if request was successful (2xx status)
160
+ const isSuccess = response.status >= 200 && response.status < 300;
161
+ return {
162
+ Success: true,
163
+ ResultCode: isSuccess ? "SUCCESS" : `HTTP_${response.status}`,
164
+ Message: JSON.stringify({
165
+ status: response.status,
166
+ statusText: response.statusText,
167
+ headers: response.headers,
168
+ data: responseData,
169
+ requestUrl: url,
170
+ requestMethod: method
171
+ }, null, 2)
172
+ };
173
+ }
174
+ catch (error) {
175
+ return {
176
+ Success: false,
177
+ Message: `HTTP request failed: ${error instanceof Error ? error.message : String(error)}`,
178
+ ResultCode: "REQUEST_FAILED"
179
+ };
180
+ }
181
+ }
182
+ /**
183
+ * Configure authentication for the request
184
+ */
185
+ configureAuthentication(config, auth) {
186
+ if (!auth.type) {
187
+ return { success: false, error: "Authentication type is required" };
188
+ }
189
+ switch (auth.type.toLowerCase()) {
190
+ case 'basic':
191
+ if (!auth.username || !auth.password) {
192
+ return { success: false, error: "Basic auth requires username and password" };
193
+ }
194
+ config.auth = {
195
+ username: auth.username,
196
+ password: auth.password
197
+ };
198
+ break;
199
+ case 'bearer':
200
+ if (!auth.token) {
201
+ return { success: false, error: "Bearer auth requires token" };
202
+ }
203
+ config.headers = config.headers || {};
204
+ config.headers['Authorization'] = `Bearer ${auth.token}`;
205
+ break;
206
+ case 'apikey':
207
+ if (!auth.key || !auth.value) {
208
+ return { success: false, error: "API key auth requires key name and value" };
209
+ }
210
+ if (auth.location === 'query') {
211
+ config.params = config.params || {};
212
+ config.params[auth.key] = auth.value;
213
+ }
214
+ else {
215
+ config.headers = config.headers || {};
216
+ config.headers[auth.key] = auth.value;
217
+ }
218
+ break;
219
+ default:
220
+ return { success: false, error: `Unsupported authentication type: ${auth.type}` };
221
+ }
222
+ return { success: true };
223
+ }
224
+ /**
225
+ * Configure request body based on type
226
+ */
227
+ configureRequestBody(config, body, bodyType) {
228
+ switch (bodyType.toLowerCase()) {
229
+ case 'json':
230
+ config.data = body;
231
+ if (!config.headers['Content-Type']) {
232
+ config.headers['Content-Type'] = 'application/json';
233
+ }
234
+ break;
235
+ case 'form':
236
+ if (typeof body === 'object') {
237
+ const formData = new URLSearchParams();
238
+ for (const [key, value] of Object.entries(body)) {
239
+ formData.append(key, String(value));
240
+ }
241
+ config.data = formData.toString();
242
+ if (!config.headers['Content-Type']) {
243
+ config.headers['Content-Type'] = 'application/x-www-form-urlencoded';
244
+ }
245
+ }
246
+ else {
247
+ return { success: false, error: "Form body type requires an object" };
248
+ }
249
+ break;
250
+ case 'text':
251
+ config.data = String(body);
252
+ if (!config.headers['Content-Type']) {
253
+ config.headers['Content-Type'] = 'text/plain';
254
+ }
255
+ break;
256
+ case 'binary':
257
+ if (typeof body === 'string') {
258
+ // Assume base64 encoded
259
+ config.data = Buffer.from(body, 'base64');
260
+ }
261
+ else {
262
+ config.data = body;
263
+ }
264
+ if (!config.headers['Content-Type']) {
265
+ config.headers['Content-Type'] = 'application/octet-stream';
266
+ }
267
+ break;
268
+ default:
269
+ return { success: false, error: `Unsupported body type: ${bodyType}` };
270
+ }
271
+ return { success: true };
272
+ }
273
+ /**
274
+ * Get numeric parameter with default
275
+ */
276
+ getNumericParam(params, name, defaultValue) {
277
+ const value = this.getParamValue(params, name);
278
+ if (value === undefined || value === null)
279
+ return defaultValue;
280
+ const num = Number(value);
281
+ return isNaN(num) ? defaultValue : num;
282
+ }
283
+ /**
284
+ * Get boolean parameter with default
285
+ */
286
+ getBooleanParam(params, name, defaultValue) {
287
+ const value = this.getParamValue(params, name);
288
+ if (value === undefined || value === null)
289
+ return defaultValue;
290
+ if (typeof value === 'boolean')
291
+ return value;
292
+ if (typeof value === 'string') {
293
+ return value.toLowerCase() === 'true';
294
+ }
295
+ return defaultValue;
296
+ }
297
+ /**
298
+ * Get parameter value by name (case-insensitive)
299
+ */
300
+ getParamValue(params, name) {
301
+ const param = params.Params.find(p => p.Name.toLowerCase() === name.toLowerCase());
302
+ return param?.Value;
303
+ }
304
+ };
305
+ exports.HTTPRequestAction = HTTPRequestAction;
306
+ exports.HTTPRequestAction = HTTPRequestAction = __decorate([
307
+ (0, global_1.RegisterClass)(actions_1.BaseAction, "HTTP Request")
308
+ ], HTTPRequestAction);
309
+ /**
310
+ * Loader function to ensure the HTTPRequestAction class is included in the bundle
311
+ */
312
+ function LoadHTTPRequestAction() {
313
+ // Stub function to prevent tree shaking
314
+ }
315
+ exports.LoadHTTPRequestAction = LoadHTTPRequestAction;
316
+ //# sourceMappingURL=http-request.action.js.map