@memberjunction/core-actions 2.47.0 → 2.49.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/business-days-calculator.action.d.ts +65 -0
- package/dist/custom/business-days-calculator.action.d.ts.map +1 -0
- package/dist/custom/business-days-calculator.action.js +299 -0
- package/dist/custom/business-days-calculator.action.js.map +1 -0
- package/dist/custom/calculate-expression.action.d.ts +56 -0
- package/dist/custom/calculate-expression.action.d.ts.map +1 -0
- package/dist/custom/calculate-expression.action.js +226 -0
- package/dist/custom/calculate-expression.action.js.map +1 -0
- package/dist/custom/census-data-lookup.action.d.ts +54 -0
- package/dist/custom/census-data-lookup.action.d.ts.map +1 -0
- package/dist/custom/census-data-lookup.action.js +378 -0
- package/dist/custom/census-data-lookup.action.js.map +1 -0
- package/dist/custom/color-converter.action.d.ts +59 -0
- package/dist/custom/color-converter.action.d.ts.map +1 -0
- package/dist/custom/color-converter.action.js +295 -0
- package/dist/custom/color-converter.action.js.map +1 -0
- package/dist/custom/external-change-detection.action.js +1 -1
- package/dist/custom/external-change-detection.action.js.map +1 -1
- package/dist/custom/get-stock-price.action.d.ts +48 -0
- package/dist/custom/get-stock-price.action.d.ts.map +1 -0
- package/dist/custom/get-stock-price.action.js +153 -0
- package/dist/custom/get-stock-price.action.js.map +1 -0
- package/dist/custom/get-weather.action.d.ts +52 -0
- package/dist/custom/get-weather.action.d.ts.map +1 -0
- package/dist/custom/get-weather.action.js +172 -0
- package/dist/custom/get-weather.action.js.map +1 -0
- package/dist/custom/ip-geolocation.action.d.ts +43 -0
- package/dist/custom/ip-geolocation.action.d.ts.map +1 -0
- package/dist/custom/ip-geolocation.action.js +259 -0
- package/dist/custom/ip-geolocation.action.js.map +1 -0
- package/dist/custom/send-single-message.action.js +1 -1
- package/dist/custom/text-analyzer.action.d.ts +53 -0
- package/dist/custom/text-analyzer.action.d.ts.map +1 -0
- package/dist/custom/text-analyzer.action.js +218 -0
- package/dist/custom/text-analyzer.action.js.map +1 -0
- package/dist/custom/unit-converter.action.d.ts +63 -0
- package/dist/custom/unit-converter.action.d.ts.map +1 -0
- package/dist/custom/unit-converter.action.js +357 -0
- package/dist/custom/unit-converter.action.js.map +1 -0
- package/dist/custom/vectorize-entity.action.d.ts +45 -9
- package/dist/custom/vectorize-entity.action.d.ts.map +1 -1
- package/dist/custom/vectorize-entity.action.js +46 -10
- package/dist/custom/vectorize-entity.action.js.map +1 -1
- package/dist/index.d.ts +9 -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 +10 -9
|
@@ -0,0 +1,172 @@
|
|
|
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.LoadGetWeatherAction = exports.GetWeatherAction = void 0;
|
|
13
|
+
const actions_1 = require("@memberjunction/actions");
|
|
14
|
+
const global_1 = require("@memberjunction/global");
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
16
|
+
/**
|
|
17
|
+
* Action that retrieves current weather information for a specified location
|
|
18
|
+
* using the Open-Meteo API which provides free weather data without requiring an API key.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Get weather by city name
|
|
23
|
+
* await runAction({
|
|
24
|
+
* ActionName: 'Get Weather',
|
|
25
|
+
* Params: [{
|
|
26
|
+
* Name: 'Location',
|
|
27
|
+
* Value: 'New York'
|
|
28
|
+
* }]
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Get weather by coordinates
|
|
32
|
+
* await runAction({
|
|
33
|
+
* ActionName: 'Get Weather',
|
|
34
|
+
* Params: [{
|
|
35
|
+
* Name: 'Latitude',
|
|
36
|
+
* Value: 40.7128
|
|
37
|
+
* }, {
|
|
38
|
+
* Name: 'Longitude',
|
|
39
|
+
* Value: -74.0060
|
|
40
|
+
* }]
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
let GetWeatherAction = class GetWeatherAction extends actions_1.BaseAction {
|
|
45
|
+
/**
|
|
46
|
+
* Executes the weather retrieval action
|
|
47
|
+
*
|
|
48
|
+
* @param params - The action parameters containing either:
|
|
49
|
+
* - Location: A city name to search for (will use geocoding)
|
|
50
|
+
* - Latitude & Longitude: Specific coordinates for weather data
|
|
51
|
+
*
|
|
52
|
+
* @returns A promise resolving to an ActionResultSimple with:
|
|
53
|
+
* - Success: true if weather data was retrieved
|
|
54
|
+
* - ResultCode: "SUCCESS" or "FAILED"
|
|
55
|
+
* - ResultData: Object containing weather information
|
|
56
|
+
* - Message: Error message if failed
|
|
57
|
+
*/
|
|
58
|
+
async InternalRunAction(params) {
|
|
59
|
+
try {
|
|
60
|
+
const locationParam = params.Params.find(p => p.Name === 'Location');
|
|
61
|
+
const latitudeParam = params.Params.find(p => p.Name === 'Latitude');
|
|
62
|
+
const longitudeParam = params.Params.find(p => p.Name === 'Longitude');
|
|
63
|
+
let latitude;
|
|
64
|
+
let longitude;
|
|
65
|
+
let locationName = '';
|
|
66
|
+
// If location name is provided, geocode it first
|
|
67
|
+
if (locationParam && locationParam.Value) {
|
|
68
|
+
const geocodeUrl = `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(locationParam.Value)}&count=1&language=en&format=json`;
|
|
69
|
+
const geocodeResponse = await axios_1.default.get(geocodeUrl);
|
|
70
|
+
if (!geocodeResponse.data.results || geocodeResponse.data.results.length === 0) {
|
|
71
|
+
return {
|
|
72
|
+
Success: false,
|
|
73
|
+
Message: `Location '${locationParam.Value}' not found`,
|
|
74
|
+
ResultCode: "LOCATION_NOT_FOUND"
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const location = geocodeResponse.data.results[0];
|
|
78
|
+
latitude = location.latitude;
|
|
79
|
+
longitude = location.longitude;
|
|
80
|
+
locationName = `${location.name}, ${location.admin1 || ''} ${location.country || ''}`.trim();
|
|
81
|
+
}
|
|
82
|
+
// If coordinates are provided, use them directly
|
|
83
|
+
else if (latitudeParam && longitudeParam) {
|
|
84
|
+
latitude = parseFloat(latitudeParam.Value);
|
|
85
|
+
longitude = parseFloat(longitudeParam.Value);
|
|
86
|
+
locationName = `${latitude}, ${longitude}`;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
return {
|
|
90
|
+
Success: false,
|
|
91
|
+
Message: "Either 'Location' or both 'Latitude' and 'Longitude' parameters are required",
|
|
92
|
+
ResultCode: "MISSING_PARAMETERS"
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// Get weather data
|
|
96
|
+
const weatherUrl = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t=temperature_2m,relative_humidity_2m,apparent_temperature,is_day,precipitation,rain,weather_code,cloud_cover,pressure_msl,wind_speed_10m,wind_direction_10m&temperature_unit=fahrenheit&wind_speed_unit=mph&precipitation_unit=inch`;
|
|
97
|
+
const weatherResponse = await axios_1.default.get(weatherUrl);
|
|
98
|
+
const current = weatherResponse.data.current;
|
|
99
|
+
const weatherCodes = {
|
|
100
|
+
0: 'Clear sky',
|
|
101
|
+
1: 'Mainly clear',
|
|
102
|
+
2: 'Partly cloudy',
|
|
103
|
+
3: 'Overcast',
|
|
104
|
+
45: 'Foggy',
|
|
105
|
+
48: 'Depositing rime fog',
|
|
106
|
+
51: 'Light drizzle',
|
|
107
|
+
53: 'Moderate drizzle',
|
|
108
|
+
55: 'Dense drizzle',
|
|
109
|
+
61: 'Slight rain',
|
|
110
|
+
63: 'Moderate rain',
|
|
111
|
+
65: 'Heavy rain',
|
|
112
|
+
71: 'Slight snow fall',
|
|
113
|
+
73: 'Moderate snow fall',
|
|
114
|
+
75: 'Heavy snow fall',
|
|
115
|
+
77: 'Snow grains',
|
|
116
|
+
80: 'Slight rain showers',
|
|
117
|
+
81: 'Moderate rain showers',
|
|
118
|
+
82: 'Violent rain showers',
|
|
119
|
+
85: 'Slight snow showers',
|
|
120
|
+
86: 'Heavy snow showers',
|
|
121
|
+
95: 'Thunderstorm',
|
|
122
|
+
96: 'Thunderstorm with slight hail',
|
|
123
|
+
99: 'Thunderstorm with heavy hail'
|
|
124
|
+
};
|
|
125
|
+
const weatherData = {
|
|
126
|
+
location: locationName,
|
|
127
|
+
coordinates: {
|
|
128
|
+
latitude,
|
|
129
|
+
longitude
|
|
130
|
+
},
|
|
131
|
+
current: {
|
|
132
|
+
temperature: `${current.temperature_2m}°F`,
|
|
133
|
+
feelsLike: `${current.apparent_temperature}°F`,
|
|
134
|
+
humidity: `${current.relative_humidity_2m}%`,
|
|
135
|
+
pressure: `${current.pressure_msl} hPa`,
|
|
136
|
+
windSpeed: `${current.wind_speed_10m} mph`,
|
|
137
|
+
windDirection: `${current.wind_direction_10m}°`,
|
|
138
|
+
cloudCover: `${current.cloud_cover}%`,
|
|
139
|
+
precipitation: `${current.precipitation} in`,
|
|
140
|
+
conditions: weatherCodes[current.weather_code] || 'Unknown',
|
|
141
|
+
isDay: current.is_day === 1,
|
|
142
|
+
time: current.time
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
Success: true,
|
|
147
|
+
ResultCode: "SUCCESS",
|
|
148
|
+
Message: JSON.stringify(weatherData, null, 2)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
return {
|
|
153
|
+
Success: false,
|
|
154
|
+
Message: `Failed to retrieve weather data: ${error instanceof Error ? error.message : String(error)}`,
|
|
155
|
+
ResultCode: "FAILED"
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
exports.GetWeatherAction = GetWeatherAction;
|
|
161
|
+
exports.GetWeatherAction = GetWeatherAction = __decorate([
|
|
162
|
+
(0, global_1.RegisterClass)(actions_1.BaseAction, "__GetWeather")
|
|
163
|
+
], GetWeatherAction);
|
|
164
|
+
/**
|
|
165
|
+
* Loader function to ensure the GetWeatherAction class is included in the bundle.
|
|
166
|
+
* This prevents tree-shaking from removing the class during the build process.
|
|
167
|
+
*/
|
|
168
|
+
function LoadGetWeatherAction() {
|
|
169
|
+
// this function is a stub that is used to force the bundler to include the above class in the final bundle and not tree shake them out
|
|
170
|
+
}
|
|
171
|
+
exports.LoadGetWeatherAction = LoadGetWeatherAction;
|
|
172
|
+
//# sourceMappingURL=get-weather.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-weather.action.js","sourceRoot":"","sources":["../../src/custom/get-weather.action.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qDAAqD;AACrD,mDAAuD;AACvD,kDAA0B;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,oBAAU;IAC5C;;;;;;;;;;;;OAYG;IACO,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;YACrE,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM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C;AAFD,oDAEC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
3
|
+
/**
|
|
4
|
+
* Action that retrieves geolocation information for an IP address using free public APIs.
|
|
5
|
+
* Provides location, timezone, ISP, and other relevant data about the IP address.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Get location for specific IP
|
|
10
|
+
* await runAction({
|
|
11
|
+
* ActionName: 'IP Geolocation',
|
|
12
|
+
* Params: [{
|
|
13
|
+
* Name: 'IPAddress',
|
|
14
|
+
* Value: '8.8.8.8'
|
|
15
|
+
* }]
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Get location for current user's IP
|
|
19
|
+
* await runAction({
|
|
20
|
+
* ActionName: 'IP Geolocation',
|
|
21
|
+
* Params: [] // No IP provided will use caller's IP
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class IPGeolocationAction extends BaseAction {
|
|
26
|
+
/**
|
|
27
|
+
* Executes the IP geolocation lookup
|
|
28
|
+
*
|
|
29
|
+
* @param params - The action parameters containing:
|
|
30
|
+
* - IPAddress: The IP address to lookup (optional - uses caller's IP if not provided)
|
|
31
|
+
*
|
|
32
|
+
* @returns Geolocation data including country, city, coordinates, timezone, etc.
|
|
33
|
+
*/
|
|
34
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
35
|
+
private fetchGeolocationData;
|
|
36
|
+
private isValidIP;
|
|
37
|
+
private detectIPType;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Loader function to ensure the IPGeolocationAction class is included in the bundle.
|
|
41
|
+
*/
|
|
42
|
+
export declare function LoadIPGeolocationAction(): void;
|
|
43
|
+
//# sourceMappingURL=ip-geolocation.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ip-geolocation.action.d.ts","sourceRoot":"","sources":["../../src/custom/ip-geolocation.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAe,MAAM,8BAA8B,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBACa,mBAAoB,SAAQ,UAAU;IAC/C;;;;;;;OAOG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAkFzE,oBAAoB;IAiGlC,OAAO,CAAC,SAAS;IAoBjB,OAAO,CAAC,YAAY;CASvB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,SAEtC"}
|
|
@@ -0,0 +1,259 @@
|
|
|
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.LoadIPGeolocationAction = exports.IPGeolocationAction = void 0;
|
|
13
|
+
const actions_1 = require("@memberjunction/actions");
|
|
14
|
+
const global_1 = require("@memberjunction/global");
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
16
|
+
/**
|
|
17
|
+
* Action that retrieves geolocation information for an IP address using free public APIs.
|
|
18
|
+
* Provides location, timezone, ISP, and other relevant data about the IP address.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Get location for specific IP
|
|
23
|
+
* await runAction({
|
|
24
|
+
* ActionName: 'IP Geolocation',
|
|
25
|
+
* Params: [{
|
|
26
|
+
* Name: 'IPAddress',
|
|
27
|
+
* Value: '8.8.8.8'
|
|
28
|
+
* }]
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Get location for current user's IP
|
|
32
|
+
* await runAction({
|
|
33
|
+
* ActionName: 'IP Geolocation',
|
|
34
|
+
* Params: [] // No IP provided will use caller's IP
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
let IPGeolocationAction = class IPGeolocationAction extends actions_1.BaseAction {
|
|
39
|
+
/**
|
|
40
|
+
* Executes the IP geolocation lookup
|
|
41
|
+
*
|
|
42
|
+
* @param params - The action parameters containing:
|
|
43
|
+
* - IPAddress: The IP address to lookup (optional - uses caller's IP if not provided)
|
|
44
|
+
*
|
|
45
|
+
* @returns Geolocation data including country, city, coordinates, timezone, etc.
|
|
46
|
+
*/
|
|
47
|
+
async InternalRunAction(params) {
|
|
48
|
+
try {
|
|
49
|
+
const ipParam = params.Params.find(p => p.Name === 'IPAddress');
|
|
50
|
+
let ipAddress = ipParam?.Value || '';
|
|
51
|
+
// Validate IP address format if provided
|
|
52
|
+
if (ipAddress && !this.isValidIP(ipAddress)) {
|
|
53
|
+
return {
|
|
54
|
+
Success: false,
|
|
55
|
+
Message: "Invalid IP address format",
|
|
56
|
+
ResultCode: "INVALID_IP"
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// Use multiple free APIs for redundancy and more complete data
|
|
60
|
+
const geoData = await this.fetchGeolocationData(ipAddress);
|
|
61
|
+
if (!geoData) {
|
|
62
|
+
return {
|
|
63
|
+
Success: false,
|
|
64
|
+
Message: "Failed to retrieve geolocation data",
|
|
65
|
+
ResultCode: "LOOKUP_FAILED"
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
// Calculate additional useful information
|
|
69
|
+
const currentTime = geoData.timezone ?
|
|
70
|
+
new Date().toLocaleString('en-US', { timeZone: geoData.timezone }) : null;
|
|
71
|
+
const result = {
|
|
72
|
+
ip: geoData.ip,
|
|
73
|
+
location: {
|
|
74
|
+
country: geoData.country,
|
|
75
|
+
countryCode: geoData.countryCode,
|
|
76
|
+
region: geoData.region,
|
|
77
|
+
regionCode: geoData.regionCode,
|
|
78
|
+
city: geoData.city,
|
|
79
|
+
postalCode: geoData.postalCode,
|
|
80
|
+
coordinates: {
|
|
81
|
+
latitude: geoData.latitude,
|
|
82
|
+
longitude: geoData.longitude
|
|
83
|
+
},
|
|
84
|
+
accuracy: geoData.accuracy || 'city'
|
|
85
|
+
},
|
|
86
|
+
timezone: {
|
|
87
|
+
id: geoData.timezone,
|
|
88
|
+
offset: geoData.timezoneOffset,
|
|
89
|
+
currentTime: currentTime
|
|
90
|
+
},
|
|
91
|
+
network: {
|
|
92
|
+
isp: geoData.isp,
|
|
93
|
+
organization: geoData.org,
|
|
94
|
+
asn: geoData.asn,
|
|
95
|
+
type: this.detectIPType(geoData)
|
|
96
|
+
},
|
|
97
|
+
privacy: {
|
|
98
|
+
isVPN: geoData.vpn || false,
|
|
99
|
+
isProxy: geoData.proxy || false,
|
|
100
|
+
isTor: geoData.tor || false,
|
|
101
|
+
isHosting: geoData.hosting || false
|
|
102
|
+
},
|
|
103
|
+
continent: geoData.continent,
|
|
104
|
+
languages: geoData.languages,
|
|
105
|
+
currency: geoData.currency,
|
|
106
|
+
callingCode: geoData.callingCode
|
|
107
|
+
};
|
|
108
|
+
return {
|
|
109
|
+
Success: true,
|
|
110
|
+
ResultCode: "SUCCESS",
|
|
111
|
+
Message: JSON.stringify(result, null, 2)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
return {
|
|
116
|
+
Success: false,
|
|
117
|
+
Message: `Failed to get IP geolocation: ${error instanceof Error ? error.message : String(error)}`,
|
|
118
|
+
ResultCode: "FAILED"
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async fetchGeolocationData(ipAddress) {
|
|
123
|
+
// Try multiple free APIs in order of preference
|
|
124
|
+
const apis = [
|
|
125
|
+
{
|
|
126
|
+
name: 'ipapi.co',
|
|
127
|
+
url: ipAddress ? `https://ipapi.co/${ipAddress}/json/` : 'https://ipapi.co/json/',
|
|
128
|
+
transform: (data) => ({
|
|
129
|
+
ip: data.ip,
|
|
130
|
+
country: data.country_name,
|
|
131
|
+
countryCode: data.country_code,
|
|
132
|
+
region: data.region,
|
|
133
|
+
regionCode: data.region_code,
|
|
134
|
+
city: data.city,
|
|
135
|
+
postalCode: data.postal,
|
|
136
|
+
latitude: data.latitude,
|
|
137
|
+
longitude: data.longitude,
|
|
138
|
+
timezone: data.timezone,
|
|
139
|
+
timezoneOffset: data.utc_offset,
|
|
140
|
+
isp: data.org,
|
|
141
|
+
org: data.org,
|
|
142
|
+
asn: data.asn,
|
|
143
|
+
continent: data.continent_code,
|
|
144
|
+
languages: data.languages?.split(',') || [],
|
|
145
|
+
currency: data.currency,
|
|
146
|
+
callingCode: data.country_calling_code
|
|
147
|
+
})
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'ip-api.com',
|
|
151
|
+
url: `http://ip-api.com/json/${ipAddress || ''}?fields=status,message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,offset,currency,isp,org,as,asname,reverse,mobile,proxy,hosting,query`,
|
|
152
|
+
transform: (data) => {
|
|
153
|
+
if (data.status !== 'success') {
|
|
154
|
+
throw new Error(data.message || 'API request failed');
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
ip: data.query,
|
|
158
|
+
country: data.country,
|
|
159
|
+
countryCode: data.countryCode,
|
|
160
|
+
region: data.regionName,
|
|
161
|
+
regionCode: data.region,
|
|
162
|
+
city: data.city,
|
|
163
|
+
postalCode: data.zip,
|
|
164
|
+
latitude: data.lat,
|
|
165
|
+
longitude: data.lon,
|
|
166
|
+
timezone: data.timezone,
|
|
167
|
+
timezoneOffset: data.offset,
|
|
168
|
+
isp: data.isp,
|
|
169
|
+
org: data.org,
|
|
170
|
+
asn: data.as,
|
|
171
|
+
continent: data.continentCode,
|
|
172
|
+
proxy: data.proxy,
|
|
173
|
+
hosting: data.hosting,
|
|
174
|
+
mobile: data.mobile
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
];
|
|
179
|
+
// Try each API until one succeeds
|
|
180
|
+
for (const api of apis) {
|
|
181
|
+
try {
|
|
182
|
+
const response = await axios_1.default.get(api.url, {
|
|
183
|
+
timeout: 5000,
|
|
184
|
+
headers: {
|
|
185
|
+
'Accept': 'application/json',
|
|
186
|
+
'User-Agent': 'MemberJunction-IPGeolocation-Action/1.0'
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
if (response.data) {
|
|
190
|
+
return api.transform(response.data);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
// Continue to next API
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// If we have an IP, try a basic API that just gives country
|
|
199
|
+
if (ipAddress) {
|
|
200
|
+
try {
|
|
201
|
+
const response = await axios_1.default.get(`https://api.country.is/${ipAddress}`);
|
|
202
|
+
if (response.data) {
|
|
203
|
+
return {
|
|
204
|
+
ip: ipAddress,
|
|
205
|
+
country: response.data.country,
|
|
206
|
+
countryCode: response.data.country
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
// Fall through
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
isValidIP(ip) {
|
|
217
|
+
// IPv4 pattern
|
|
218
|
+
const ipv4Pattern = /^(\d{1,3}\.){3}\d{1,3}$/;
|
|
219
|
+
// IPv6 pattern (simplified)
|
|
220
|
+
const ipv6Pattern = /^([\da-f]{1,4}:){7}[\da-f]{1,4}$/i;
|
|
221
|
+
const ipv6CompressedPattern = /^([\da-f]{1,4}:){1,7}:$/i;
|
|
222
|
+
if (ipv4Pattern.test(ip)) {
|
|
223
|
+
// Validate IPv4 octets
|
|
224
|
+
const octets = ip.split('.');
|
|
225
|
+
return octets.every(octet => {
|
|
226
|
+
const num = parseInt(octet, 10);
|
|
227
|
+
return num >= 0 && num <= 255;
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
return ipv6Pattern.test(ip) || ipv6CompressedPattern.test(ip);
|
|
231
|
+
}
|
|
232
|
+
detectIPType(geoData) {
|
|
233
|
+
if (geoData.mobile)
|
|
234
|
+
return 'Mobile';
|
|
235
|
+
if (geoData.hosting)
|
|
236
|
+
return 'Hosting/Datacenter';
|
|
237
|
+
if (geoData.proxy)
|
|
238
|
+
return 'Proxy';
|
|
239
|
+
if (geoData.vpn)
|
|
240
|
+
return 'VPN';
|
|
241
|
+
if (geoData.tor)
|
|
242
|
+
return 'Tor';
|
|
243
|
+
if (geoData.org?.toLowerCase().includes('corporate'))
|
|
244
|
+
return 'Corporate';
|
|
245
|
+
return 'Residential';
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
exports.IPGeolocationAction = IPGeolocationAction;
|
|
249
|
+
exports.IPGeolocationAction = IPGeolocationAction = __decorate([
|
|
250
|
+
(0, global_1.RegisterClass)(actions_1.BaseAction, "__IPGeolocation")
|
|
251
|
+
], IPGeolocationAction);
|
|
252
|
+
/**
|
|
253
|
+
* Loader function to ensure the IPGeolocationAction class is included in the bundle.
|
|
254
|
+
*/
|
|
255
|
+
function LoadIPGeolocationAction() {
|
|
256
|
+
// this function is a stub that is used to force the bundler to include the above class in the final bundle and not tree shake them out
|
|
257
|
+
}
|
|
258
|
+
exports.LoadIPGeolocationAction = LoadIPGeolocationAction;
|
|
259
|
+
//# sourceMappingURL=ip-geolocation.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ip-geolocation.action.js","sourceRoot":"","sources":["../../src/custom/ip-geolocation.action.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qDAAqD;AACrD,mDAAuD;AACvD,kDAA0B;AAE1B;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,oBAAU;IAC/C;;;;;;;OAOG;IACO,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;YAChE,IAAI,SAAS,GAAG,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC;YAErC,yCAAyC;YACzC,IAAI,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC1C,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,2BAA2B;oBACpC,UAAU,EAAE,YAAY;iBAC3B,CAAC;YACN,CAAC;YAED,+DAA+D;YAC/D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;YAE3D,IAAI,CAAC,OAAO,EAAE,CAAC;gBACX,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,qCAAqC;oBAC9C,UAAU,EAAE,eAAe;iBAC9B,CAAC;YACN,CAAC;YAED,0CAA0C;YAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAClC,IAAI,IAAI,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,C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,KAAK,CAAC,KAAK,CAAC,EAAE;gBACxB,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBAChC,OAAO,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC;YAClC,CAAC,CAAC,CAAC;QACP,CAAC;QAED,OAAO,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClE,CAAC;IAEO,YAAY,CAAC,OAAY;QAC7B,IAAI,OAAO,CAAC,MAAM;YAAE,OAAO,QAAQ,CAAC;QACpC,IAAI,OAAO,CAAC,OAAO;YAAE,OAAO,oBAAoB,CAAC;QACjD,IAAI,OAAO,CAAC,KAAK;YAAE,OAAO,OAAO,CAAC;QAClC,IAAI,OAAO,CAAC,GAAG;YAAE,OAAO,KAAK,CAAC;QAC9B,IAAI,OAAO,CAAC,GAAG;YAAE,OAAO,KAAK,CAAC;QAC9B,IAAI,OAAO,CAAC,GAAG,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;YAAE,OAAO,WAAW,CAAC;QACzE,OAAO,aAAa,CAAC;IACzB,CAAC;CACJ,CAAA;AAzNY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,sBAAa,EAAC,oBAAU,EAAE,iBAAiB,CAAC;GAChC,mBAAmB,CAyN/B;AAED;;GAEG;AACH,SAAgB,uBAAuB;IACnC,uIAAuI;AAC3I,CAAC;AAFD,0DAEC"}
|
|
@@ -58,7 +58,7 @@ let SendSingleMessageAction = class SendSingleMessageAction extends actions_1.Ba
|
|
|
58
58
|
};
|
|
59
59
|
exports.SendSingleMessageAction = SendSingleMessageAction;
|
|
60
60
|
exports.SendSingleMessageAction = SendSingleMessageAction = __decorate([
|
|
61
|
-
(0, global_1.RegisterClass)(actions_1.BaseAction, "
|
|
61
|
+
(0, global_1.RegisterClass)(actions_1.BaseAction, "__SendSingleMessage")
|
|
62
62
|
], SendSingleMessageAction);
|
|
63
63
|
function LoadSendSingleMessageAction() {
|
|
64
64
|
// this function is a stub that is used to force the bundler to include the above class in the final bundle and not tree shake them out
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
3
|
+
/**
|
|
4
|
+
* Action that analyzes text content and provides various statistics including
|
|
5
|
+
* word count, character count, readability scores, and common word analysis.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Analyze a simple text
|
|
10
|
+
* await runAction({
|
|
11
|
+
* ActionName: 'Text Analyzer',
|
|
12
|
+
* Params: [{
|
|
13
|
+
* Name: 'Text',
|
|
14
|
+
* Value: 'The quick brown fox jumps over the lazy dog.'
|
|
15
|
+
* }]
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Analyze with custom options
|
|
19
|
+
* await runAction({
|
|
20
|
+
* ActionName: 'Text Analyzer',
|
|
21
|
+
* Params: [{
|
|
22
|
+
* Name: 'Text',
|
|
23
|
+
* Value: 'Your text here...'
|
|
24
|
+
* }, {
|
|
25
|
+
* Name: 'IncludeWordFrequency',
|
|
26
|
+
* Value: true
|
|
27
|
+
* }]
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class TextAnalyzerAction extends BaseAction {
|
|
32
|
+
/**
|
|
33
|
+
* Executes the text analysis action
|
|
34
|
+
*
|
|
35
|
+
* @param params - The action parameters containing:
|
|
36
|
+
* - Text: The text content to analyze
|
|
37
|
+
* - IncludeWordFrequency: Optional boolean to include word frequency analysis
|
|
38
|
+
*
|
|
39
|
+
* @returns A promise resolving to an ActionResultSimple with text analysis data
|
|
40
|
+
*/
|
|
41
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
42
|
+
private extractWords;
|
|
43
|
+
private extractSentences;
|
|
44
|
+
private calculateWordFrequency;
|
|
45
|
+
private calculateFleschReadingEase;
|
|
46
|
+
private getReadingLevel;
|
|
47
|
+
private guessTextType;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Loader function to ensure the TextAnalyzerAction class is included in the bundle.
|
|
51
|
+
*/
|
|
52
|
+
export declare function LoadTextAnalyzerAction(): void;
|
|
53
|
+
//# sourceMappingURL=text-analyzer.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-analyzer.action.d.ts","sourceRoot":"","sources":["../../src/custom/text-analyzer.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAe,MAAM,8BAA8B,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBACa,kBAAmB,SAAQ,UAAU;IAC9C;;;;;;;;OAQG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA+GvF,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,sBAAsB;IAgB9B,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,aAAa;CAOxB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,SAErC"}
|