powr-sdk-api 4.1.6 → 4.1.9

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.
@@ -301,6 +301,9 @@ class ToolsManager {
301
301
  switch (tool.name.toLowerCase()) {
302
302
  case 'gmail':
303
303
  return await this.executeGmailAction(actionId, params, config);
304
+ case 'weather':
305
+ case 'openweather':
306
+ return await this.executeWeatherAction(actionId, params, config, tool);
304
307
  case 'slack':
305
308
  return await this.executeSlackAction(actionId, params, config);
306
309
  case 'github':
@@ -322,12 +325,14 @@ class ToolsManager {
322
325
  async executeGmailAction(actionId, params, config) {
323
326
  const nodemailer = require('nodemailer');
324
327
  try {
325
- // Create transporter
326
- const transporter = nodemailer.createTransporter({
327
- service: 'gmail',
328
+ // Create transporter using the exact config from ai-pitcher
329
+ const transporter = nodemailer.createTransport({
330
+ host: 'smtp.gmail.com',
331
+ port: 465,
332
+ secure: true,
328
333
  auth: {
329
334
  user: config.email,
330
- pass: config.appPassword // Use app password for Gmail
335
+ pass: config.appPassword
331
336
  }
332
337
  });
333
338
  switch (actionId) {
@@ -362,6 +367,65 @@ class ToolsManager {
362
367
  };
363
368
  }
364
369
  }
370
+ async executeWeatherAction(actionId, params, config, tool) {
371
+ const axios = require('axios');
372
+ try {
373
+ var _tool$systemConfig;
374
+ // Get weather data from system config (database) or fallback to env var
375
+ const weatherApiKey = (tool === null || tool === void 0 || (_tool$systemConfig = tool.systemConfig) === null || _tool$systemConfig === void 0 ? void 0 : _tool$systemConfig.apiKey) || process.env.WEATHER_API_KEY || 'demo';
376
+ const location = config.location;
377
+ let weatherData;
378
+ if (weatherApiKey === 'demo') {
379
+ // Demo weather data for testing
380
+ weatherData = {
381
+ weather: [{
382
+ main: params.condition || 'Rain',
383
+ description: 'light rain'
384
+ }]
385
+ };
386
+ console.log('🌤️ Using demo weather data');
387
+ } else {
388
+ // Real weather API call
389
+ const weatherResponse = await axios.get(`https://api.openweathermap.org/data/2.5/weather?q=${encodeURIComponent(location)}&appid=${weatherApiKey}&units=metric`);
390
+ weatherData = weatherResponse.data;
391
+ }
392
+
393
+ // Check if condition matches
394
+ const currentWeather = weatherData.weather[0].main.toLowerCase();
395
+ const targetCondition = params.condition.toLowerCase();
396
+ const operator = params.operator || 'is';
397
+ let conditionMet = false;
398
+ switch (operator) {
399
+ case 'is':
400
+ conditionMet = currentWeather === targetCondition;
401
+ break;
402
+ case 'is_not':
403
+ conditionMet = currentWeather !== targetCondition;
404
+ break;
405
+ case 'contains':
406
+ conditionMet = currentWeather.includes(targetCondition) || weatherData.weather[0].description.toLowerCase().includes(targetCondition);
407
+ break;
408
+ default:
409
+ conditionMet = currentWeather === targetCondition;
410
+ }
411
+ return {
412
+ success: true,
413
+ message: `Weather check completed. Current: ${currentWeather}, Required: ${targetCondition}`,
414
+ data: {
415
+ currentWeather: currentWeather,
416
+ requiredCondition: targetCondition,
417
+ conditionMet: conditionMet,
418
+ location: location
419
+ }
420
+ };
421
+ } catch (error) {
422
+ console.error('❌ Weather check error:', error);
423
+ return {
424
+ success: false,
425
+ message: `Failed to check weather: ${error.message}`
426
+ };
427
+ }
428
+ }
365
429
  async executeSlackAction(actionId, params, config) {
366
430
  // TODO: Implement Slack actions
367
431
  return {
package/package.json CHANGED
@@ -1,68 +1,69 @@
1
- {
2
- "name": "powr-sdk-api",
3
- "version": "4.1.6",
4
- "description": "Shared API core library for PowrStack projects",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "files": [
8
- "dist",
9
- "README.md"
10
- ],
11
- "scripts": {
12
- "test": "jest --passWithNoTests",
13
- "lint": "eslint .",
14
- "build": "babel src -d dist",
15
- "prepare": "npm run build",
16
- "prepublishOnly": "npm run test"
17
- },
18
- "keywords": [
19
- "api",
20
- "express",
21
- "middleware",
22
- "error-handling",
23
- "response-formatting",
24
- "logging",
25
- "swagger",
26
- "documentation"
27
- ],
28
- "author": "Lawazia Tech",
29
- "license": "ISC",
30
- "repository": {
31
- "type": "git",
32
- "url": "git+https://github.com/powrstack/powr-sdk-api.git"
33
- },
34
- "bugs": {
35
- "url": "https://github.com/powrstack/powr-sdk-api/issues"
36
- },
37
- "homepage": "https://github.com/powrstack/powr-sdk-api#readme",
38
- "dependencies": {
39
- "@aws-sdk/client-s3": "^3.787.0",
40
- "@google-cloud/storage": "^7.16.0",
41
- "express": "^4.18.2",
42
- "jsonwebtoken": "^9.0.2",
43
- "swagger-jsdoc": "^6.2.8",
44
- "swagger-ui-express": "^5.0.0",
45
- "winston": "^3.17.0",
46
- "mongodb": "^6.3.0",
47
- "multer": "^1.4.5-lts.1",
48
- "bcrypt": "^5.1.1",
49
- "nodemailer": "^6.10.0"
50
- },
51
- "devDependencies": {
52
- "@babel/cli": "^7.23.9",
53
- "@babel/core": "^7.24.0",
54
- "@babel/preset-env": "^7.24.0",
55
- "@types/express": "^4.17.21",
56
- "@types/swagger-jsdoc": "^6.0.4",
57
- "@types/swagger-ui-express": "^4.1.6",
58
- "eslint": "^8.57.0",
59
- "jest": "^29.7.0",
60
- "typescript": "^5.3.3"
61
- },
62
- "peerDependencies": {
63
- "express": "^4.18.2"
64
- },
65
- "engines": {
66
- "node": ">=14.0.0"
67
- }
68
- }
1
+ {
2
+ "name": "powr-sdk-api",
3
+ "version": "4.1.9",
4
+ "description": "Shared API core library for PowrStack projects",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "README.md"
10
+ ],
11
+ "scripts": {
12
+ "test": "jest --passWithNoTests",
13
+ "lint": "eslint .",
14
+ "build": "babel src -d dist",
15
+ "prepare": "npm run build",
16
+ "prepublishOnly": "npm run test"
17
+ },
18
+ "keywords": [
19
+ "api",
20
+ "express",
21
+ "middleware",
22
+ "error-handling",
23
+ "response-formatting",
24
+ "logging",
25
+ "swagger",
26
+ "documentation"
27
+ ],
28
+ "author": "Lawazia Tech",
29
+ "license": "ISC",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/powrstack/powr-sdk-api.git"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/powrstack/powr-sdk-api/issues"
36
+ },
37
+ "homepage": "https://github.com/powrstack/powr-sdk-api#readme",
38
+ "dependencies": {
39
+ "@aws-sdk/client-s3": "^3.787.0",
40
+ "@google-cloud/storage": "^7.16.0",
41
+ "axios": "^1.6.0",
42
+ "express": "^4.18.2",
43
+ "jsonwebtoken": "^9.0.2",
44
+ "swagger-jsdoc": "^6.2.8",
45
+ "swagger-ui-express": "^5.0.0",
46
+ "winston": "^3.17.0",
47
+ "mongodb": "^6.3.0",
48
+ "multer": "^1.4.5-lts.1",
49
+ "bcrypt": "^5.1.1",
50
+ "nodemailer": "^6.10.0"
51
+ },
52
+ "devDependencies": {
53
+ "@babel/cli": "^7.23.9",
54
+ "@babel/core": "^7.24.0",
55
+ "@babel/preset-env": "^7.24.0",
56
+ "@types/express": "^4.17.21",
57
+ "@types/swagger-jsdoc": "^6.0.4",
58
+ "@types/swagger-ui-express": "^4.1.6",
59
+ "eslint": "^8.57.0",
60
+ "jest": "^29.7.0",
61
+ "typescript": "^5.3.3"
62
+ },
63
+ "peerDependencies": {
64
+ "express": "^4.18.2"
65
+ },
66
+ "engines": {
67
+ "node": ">=14.0.0"
68
+ }
69
+ }