@comasoft/nestjs 0.1.46 → 0.1.47

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.
@@ -13,7 +13,7 @@ export declare class EmailService {
13
13
  user_id: number;
14
14
  recipient: string;
15
15
  success: boolean;
16
- messageId: string;
16
+ content: string;
17
17
  status: string;
18
18
  }[] | import("@aws-sdk/client-ses").SendEmailCommandOutput>;
19
19
  sendAws(recipients: Array<{
@@ -26,7 +26,7 @@ export declare class EmailService {
26
26
  user_id: number;
27
27
  recipient: string;
28
28
  success: boolean;
29
- messageId: string;
29
+ content: string;
30
30
  status: string;
31
31
  }[] | import("@aws-sdk/client-ses").SendEmailCommandOutput>;
32
32
  }
@@ -1 +1 @@
1
- var e=this&&this.__decorate||function(e,t,i,n){var s,r=arguments.length,c=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,i,n);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(c=(r<3?s(c):r>3?s(t,i,c):s(t,i))||c);return r>3&&c&&Object.defineProperty(t,i,c),c},t=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},i=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(s,r){function fulfilled(e){try{step(n.next(e))}catch(e){r(e)}}function rejected(e){try{step(n.throw(e))}catch(e){r(e)}}function step(e){e.done?s(e.value):function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.EmailService=void 0;const n=require("@aws-sdk/client-ses"),s=require("@nestjs/common"),r=require("@nestjs/config");let c=class EmailService{constructor(e){this.configService=e,"aws"===this.configService.get("EMAIL_PROVIDER")&&(this.sesClient=new n.SESClient({region:this.configService.get("AWS_REGION"),credentials:{accessKeyId:this.configService.get("AWS_ACCESS_KEY_ID"),secretAccessKey:this.configService.get("AWS_SECRET_ACCESS_KEY")}}))}send(e){return i(this,void 0,void 0,function*(){const t=this.configService.get("EMAIL_PROVIDER");if(!t||!this.configService.get("EMAIL_FROM"))throw new Error("EMAIL_PROVIDER or EMAIL_FROM is not set");return"aws"===t?this.sendAws(e):[]})}sendAws(e){return i(this,void 0,void 0,function*(){if("production"!==process.env.NODE_ENV)return e.map(e=>({user_id:e.user_id,recipient:e.recipient,success:!0,messageId:`aws-${Date.now()}-${e.user_id}`,status:"sent"}));for(const t of e){const e=new n.SendEmailCommand({Source:this.configService.get("EMAIL_NOREPLY_SOURCE"),Destination:{ToAddresses:[t.recipient]},Message:{Subject:{Data:t.subject,Charset:"UTF-8"},Body:{Html:{Data:t.text,Charset:"UTF-8"}}}});return yield this.sesClient.send(e)}})}};exports.EmailService=c,exports.EmailService=c=e([(0,s.Injectable)(),t("design:paramtypes",[r.ConfigService])],c);
1
+ var e=this&&this.__decorate||function(e,t,i,n){var s,r=arguments.length,c=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,i,n);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(c=(r<3?s(c):r>3?s(t,i,c):s(t,i))||c);return r>3&&c&&Object.defineProperty(t,i,c),c},t=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},i=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(s,r){function fulfilled(e){try{step(n.next(e))}catch(e){r(e)}}function rejected(e){try{step(n.throw(e))}catch(e){r(e)}}function step(e){e.done?s(e.value):function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.EmailService=void 0;const n=require("@aws-sdk/client-ses"),s=require("@nestjs/common"),r=require("@nestjs/config");let c=class EmailService{constructor(e){this.configService=e,"aws"===this.configService.get("EMAIL_PROVIDER")&&(this.sesClient=new n.SESClient({region:this.configService.get("AWS_REGION"),credentials:{accessKeyId:this.configService.get("AWS_ACCESS_KEY_ID"),secretAccessKey:this.configService.get("AWS_SECRET_ACCESS_KEY")}}))}send(e){return i(this,void 0,void 0,function*(){const t=this.configService.get("EMAIL_PROVIDER");if(!t||!this.configService.get("EMAIL_FROM"))throw new Error("EMAIL_PROVIDER or EMAIL_FROM is not set");return"aws"===t?this.sendAws(e):[]})}sendAws(e){return i(this,void 0,void 0,function*(){if("production"!==process.env.NODE_ENV)return e.map(e=>({user_id:e.user_id,recipient:e.recipient,success:!0,content:e.text,status:"sent"}));for(const t of e){const e=new n.SendEmailCommand({Source:this.configService.get("EMAIL_NOREPLY_SOURCE"),Destination:{ToAddresses:[t.recipient]},Message:{Subject:{Data:t.subject,Charset:"UTF-8"},Body:{Html:{Data:t.text,Charset:"UTF-8"}}}});return yield this.sesClient.send(e)}})}};exports.EmailService=c,exports.EmailService=c=e([(0,s.Injectable)(),t("design:paramtypes",[r.ConfigService])],c);
@@ -1 +1 @@
1
- function validateAndParseDate(e){if(!/^\d{8}T\d{6}Z$/.test(e))throw new Error("Invalid date format. Use YYYYMMDDTHHMMSSZ (e.g., 20250122T150000Z)");const n=e.substring(0,4),t=e.substring(4,6),r=e.substring(6,8),a=e.substring(9,11),i=e.substring(11,13),s=e.substring(13,15),l=new Date(`${n}-${t}-${r}T${a}:${i}:${s}Z`);if(isNaN(l.getTime()))throw new Error("Invalid date");return l}Object.defineProperty(exports,"__esModule",{value:!0}),exports.applyFiltersAndSorting=function applyFiltersAndSorting(n,t){const{_keyword:r,_group:a,_sort:i,aliasName:s="a",keywordFields:l=["name"],groupFields:o=[]}=t;return function applyKeywordFilter(e,n,t,r){if(n){const a=r.map(e=>`${t}.${e} LIKE :keyword`);e.andWhere(`(${a.join(" OR ")})`,{keyword:`${n}`})}}(n,r,s,l),function applyGroupFilter(n,t,r,a){if(!t)return;if(0===a.length)return;const i=t.split("|");if(i.some(e=>{const[n]=e.split("-");return!a.includes(n)}))throw new Error("Invalid field detected in group filter");const s=[],l={};i.forEach((n,t)=>{const[a,i]=n.split(/-(.+)/),o=a.includes(".")?a:`${r}.${a}`;let $;$=i.includes("__")?a.includes("_at")||a.includes("_date")?e.handleDateRange(o,i,t):e.handleNumberRange(o,i,t):e.handleEquals(o,i,t),$.condition&&(s.push($.condition),Object.assign(l,$.parameters))}),s.length>0&&n.andWhere(`(${s.join(" AND ")})`,l)}(n,a,s,o),function applySorting(e,n,t){if(n){n.split("|").forEach((n,r)=>{const[a,i]=n.split("-"),s=i.toUpperCase();if("ASC"!==s&&"DESC"!==s)throw new Error(`Invalid sort order: ${i}`);0===r?e.orderBy(`${t}.${a}`,s):e.addOrderBy(`${t}.${a}`,s)})}else{Object.keys(e.expressionMap.orderBys).length>0||e.orderBy(`${t}.id`,"DESC")}}(n,i,s),n};const e={handleEquals:(e,n,t)=>({condition:`${e} = :${e}${t}`,parameters:{[`${e}${t}`]:n}}),handleNumberRange(e,n,t){const[r,a]=n.split("__").map(e=>""===e?null:Number(e)),i=[],s={};return null!==r&&null!==a?(i.push(`${e} BETWEEN :${e}Min${t} AND :${e}Max${t}`),s[`${e}Min${t}`]=r,s[`${e}Max${t}`]=a):null!==r?(i.push(`${e} >= :${e}Min${t}`),s[`${e}Min${t}`]=r):null!==a&&(i.push(`${e} <= :${e}Max${t}`),s[`${e}Max${t}`]=a),{condition:i.join(" AND "),parameters:s}},handleDateRange(e,n,t){const[r,a]=n.split("__").map(e=>""===e?null:e),i=[],s={};return null!==r&&null!==a?(i.push(`${e} BETWEEN :${e}Min${t} AND :${e}Max${t}`),s[`${e}Min${t}`]=validateAndParseDate(r),s[`${e}Max${t}`]=validateAndParseDate(a)):null!==r?(i.push(`${e} >= :${e}Min${t}`),s[`${e}Min${t}`]=validateAndParseDate(r)):null!==a&&(i.push(`${e} <= :${e}Max${t}`),s[`${e}Max${t}`]=validateAndParseDate(a)),{condition:i.join(" AND "),parameters:s}}};
1
+ function validateAndParseDate(e){if(!/^\d{8}T\d{6}Z$/.test(e))throw new Error("Invalid date format. Use YYYYMMDDTHHMMSSZ (e.g., 20250122T150000Z)");const n=e.substring(0,4),r=e.substring(4,6),t=e.substring(6,8),i=e.substring(9,11),a=e.substring(11,13),s=e.substring(13,15),l=new Date(`${n}-${r}-${t}T${i}:${a}:${s}Z`);if(isNaN(l.getTime()))throw new Error("Invalid date");return l}Object.defineProperty(exports,"__esModule",{value:!0}),exports.applyFiltersAndSorting=function applyFiltersAndSorting(n,r){const{_keyword:t,_group:i,_sort:a,aliasName:s="a",keywordFields:l=["name"],groupFields:$=[]}=r;return function applyKeywordFilter(e,n,r,t){if(n){const i=[],a={};t.forEach((e,t)=>{if(e.endsWith("*")){const s=e.slice(0,-1);i.push(`${r}.${s} = :keyword${t}`),a[`keyword${t}`]=n}else i.push(`${r}.${e} LIKE :keyword${t}`),a[`keyword${t}`]=`%${n}%`}),e.andWhere(`(${i.join(" OR ")})`,a)}}(n,t,s,l),function applyGroupFilter(n,r,t,i){if(!r)return;if(0===i.length)return;const a=r.split("|");if(a.some(e=>{const[n]=e.split("-");return!i.includes(n)}))throw new Error("Invalid field detected in group filter");const s=[],l={};a.forEach((n,r)=>{const[i,a]=n.split(/-(.+)/),$=i.includes(".")?i:`${t}.${i}`;let o;o=a.includes("__")?i.includes("_at")||i.includes("_date")?e.handleDateRange($,a,r):e.handleNumberRange($,a,r):e.handleEquals($,a,r),o.condition&&(s.push(o.condition),Object.assign(l,o.parameters))}),s.length>0&&n.andWhere(`(${s.join(" AND ")})`,l)}(n,i,s,$),function applySorting(e,n,r){if(n){n.split("|").forEach((n,t)=>{const[i,a]=n.split("-"),s=a.toUpperCase();if("ASC"!==s&&"DESC"!==s)throw new Error(`Invalid sort order: ${a}`);0===t?e.orderBy(`${r}.${i}`,s):e.addOrderBy(`${r}.${i}`,s)})}else{Object.keys(e.expressionMap.orderBys).length>0||e.orderBy(`${r}.id`,"DESC")}}(n,a,s),n};const e={handleEquals(e,n,r){if(n.includes(",")){const t=n.split(",").map(e=>e.trim()).filter(e=>e);return{condition:`${e} IN (:...${e}${r})`,parameters:{[`${e}${r}`]:t}}}return{condition:`${e} = :${e}${r}`,parameters:{[`${e}${r}`]:n}}},handleNumberRange(e,n,r){const[t,i]=n.split("__").map(e=>""===e?null:Number(e)),a=[],s={};return null!==t&&null!==i?(a.push(`${e} BETWEEN :${e}Min${r} AND :${e}Max${r}`),s[`${e}Min${r}`]=t,s[`${e}Max${r}`]=i):null!==t?(a.push(`${e} >= :${e}Min${r}`),s[`${e}Min${r}`]=t):null!==i&&(a.push(`${e} <= :${e}Max${r}`),s[`${e}Max${r}`]=i),{condition:a.join(" AND "),parameters:s}},handleDateRange(e,n,r){const[t,i]=n.split("__").map(e=>""===e?null:e),a=[],s={};return null!==t&&null!==i?(a.push(`${e} BETWEEN :${e}Min${r} AND :${e}Max${r}`),s[`${e}Min${r}`]=validateAndParseDate(t),s[`${e}Max${r}`]=validateAndParseDate(i)):null!==t?(a.push(`${e} >= :${e}Min${r}`),s[`${e}Min${r}`]=validateAndParseDate(t)):null!==i&&(a.push(`${e} <= :${e}Max${r}`),s[`${e}Max${r}`]=validateAndParseDate(i)),{condition:a.join(" AND "),parameters:s}}};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comasoft/nestjs",
3
- "version": "0.1.46",
3
+ "version": "0.1.47",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "exports": {