@wraps.dev/cli 2.17.9 → 2.17.12
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/cli.js +62 -37
- package/dist/cli.js.map +1 -1
- package/dist/console/assets/{index-DYY5rtzO.css → index-DF7apuYC.css} +1 -1
- package/dist/console/index.html +2 -2
- package/dist/lambda/event-processor/.bundled +1 -1
- package/dist/lambda/event-processor/index.js +3 -1
- package/dist/lambda/event-processor/index.ts +10 -1
- package/dist/lambda/inbound-processor/.bundled +1 -1
- package/dist/lambda/inbound-processor/index.js +58 -56
- package/dist/lambda/inbound-processor/index.ts +11 -2
- package/dist/lambda/sms-event-processor/.bundled +1 -1
- package/dist/lambda/sms-event-processor/index.js +3 -1
- package/dist/lambda/sms-event-processor/index.ts +10 -1
- package/package.json +3 -3
- /package/dist/console/assets/{index-Wy-UKvho.js → index-CNn3fWLq.js} +0 -0
|
@@ -8,11 +8,20 @@ import {
|
|
|
8
8
|
PutObjectCommand,
|
|
9
9
|
S3Client,
|
|
10
10
|
} from "@aws-sdk/client-s3";
|
|
11
|
+
import { NodeHttpHandler } from "@smithy/node-http-handler";
|
|
11
12
|
import type { Context, S3Event } from "aws-lambda";
|
|
12
13
|
import { simpleParser } from "mailparser";
|
|
13
14
|
|
|
14
|
-
const
|
|
15
|
-
|
|
15
|
+
const awsDefaults = {
|
|
16
|
+
requestHandler: new NodeHttpHandler({
|
|
17
|
+
requestTimeout: 10_000,
|
|
18
|
+
connectionTimeout: 5000,
|
|
19
|
+
}),
|
|
20
|
+
maxAttempts: 5,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const s3 = new S3Client(awsDefaults);
|
|
24
|
+
const eventbridge = new EventBridgeClient(awsDefaults);
|
|
16
25
|
|
|
17
26
|
const BUCKET_NAME = process.env.BUCKET_NAME!;
|
|
18
27
|
const INBOUND_EVENT_SOURCE =
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Built at: 2026-03-
|
|
1
|
+
Built at: 2026-03-09T19:42:42.097Z
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var ge=Object.create;var P=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var Te=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var D=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Se=(t,e)=>{for(var n in e)P(t,n,{get:e[n],enumerable:!0})},Y=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ye(e))!Ee.call(t,o)&&o!==n&&P(t,o,{get:()=>e[o],enumerable:!(s=pe(e,o))||s.enumerable});return t};var Ce=(t,e,n)=>(n=t!=null?ge(Te(t)):{},Y(e||!t||!t.__esModule?P(n,"default",{value:t,enumerable:!0}):n,t)),we=t=>Y(P({},"__esModule",{value:!0}),t);var z=D(u=>{"use strict";u.HttpAuthLocation=void 0;(function(t){t.HEADER="header",t.QUERY="query"})(u.HttpAuthLocation||(u.HttpAuthLocation={}));u.HttpApiKeyAuthLocation=void 0;(function(t){t.HEADER="header",t.QUERY="query"})(u.HttpApiKeyAuthLocation||(u.HttpApiKeyAuthLocation={}));u.EndpointURLScheme=void 0;(function(t){t.HTTP="http",t.HTTPS="https"})(u.EndpointURLScheme||(u.EndpointURLScheme={}));u.AlgorithmId=void 0;(function(t){t.MD5="md5",t.CRC32="crc32",t.CRC32C="crc32c",t.SHA1="sha1",t.SHA256="sha256"})(u.AlgorithmId||(u.AlgorithmId={}));var ve=t=>{let e=[];return t.sha256!==void 0&&e.push({algorithmId:()=>u.AlgorithmId.SHA256,checksumConstructor:()=>t.sha256}),t.md5!=null&&e.push({algorithmId:()=>u.AlgorithmId.MD5,checksumConstructor:()=>t.md5}),{addChecksumAlgorithm(n){e.push(n)},checksumAlgorithms(){return e}}},Ae=t=>{let e={};return t.checksumAlgorithms().forEach(n=>{e[n.algorithmId()]=n.checksumConstructor()}),e},be=t=>ve(t),Re=t=>Ae(t);u.FieldPosition=void 0;(function(t){t[t.HEADER=0]="HEADER",t[t.TRAILER=1]="TRAILER"})(u.FieldPosition||(u.FieldPosition={}));var He="__smithy_context";u.IniSectionType=void 0;(function(t){t.PROFILE="profile",t.SSO_SESSION="sso-session",t.SERVICES="services"})(u.IniSectionType||(u.IniSectionType={}));u.RequestHandlerProtocol=void 0;(function(t){t.HTTP_0_9="http/0.9",t.HTTP_1_0="http/1.0",t.TDS_8_0="tds/8.0"})(u.RequestHandlerProtocol||(u.RequestHandlerProtocol={}));u.SMITHY_CONTEXT_KEY=He;u.getDefaultClientConfiguration=be;u.resolveDefaultRuntimeConfig=Re});var G=D(w=>{"use strict";var ke=z(),De=t=>({setHttpHandler(e){t.httpHandler=e},httpHandler(){return t.httpHandler},updateHttpClientConfig(e,n){t.httpHandler?.updateHttpClientConfig(e,n)},httpHandlerConfigs(){return t.httpHandler.httpHandlerConfigs()}}),_e=t=>({httpHandler:t.httpHandler()}),$=class{name;kind;values;constructor({name:e,kind:n=ke.FieldPosition.HEADER,values:s=[]}){this.name=e,this.kind=n,this.values=s}add(e){this.values.push(e)}set(e){this.values=e}remove(e){this.values=this.values.filter(n=>n!==e)}toString(){return this.values.map(e=>e.includes(",")||e.includes(" ")?`"${e}"`:e).join(", ")}get(){return this.values}},O=class{entries={};encoding;constructor({fields:e=[],encoding:n="utf-8"}){e.forEach(this.setField.bind(this)),this.encoding=n}setField(e){this.entries[e.name.toLowerCase()]=e}getField(e){return this.entries[e.toLowerCase()]}removeField(e){delete this.entries[e.toLowerCase()]}getByType(e){return Object.values(this.entries).filter(n=>n.kind===e)}},B=class t{method;protocol;hostname;port;path;query;headers;username;password;fragment;body;constructor(e){this.method=e.method||"GET",this.hostname=e.hostname||"localhost",this.port=e.port,this.query=e.query||{},this.headers=e.headers||{},this.body=e.body,this.protocol=e.protocol?e.protocol.slice(-1)!==":"?`${e.protocol}:`:e.protocol:"https:",this.path=e.path?e.path.charAt(0)!=="/"?`/${e.path}`:e.path:"/",this.username=e.username,this.password=e.password,this.fragment=e.fragment}static clone(e){let n=new t({...e,headers:{...e.headers}});return n.query&&(n.query=Ne(n.query)),n}static isInstance(e){if(!e)return!1;let n=e;return"method"in n&&"protocol"in n&&"hostname"in n&&"path"in n&&typeof n.query=="object"&&typeof n.headers=="object"}clone(){return t.clone(this)}};function Ne(t){return Object.keys(t).reduce((e,n)=>{let s=t[n];return{...e,[n]:Array.isArray(s)?[...s]:s}},{})}var M=class{statusCode;reason;headers;body;constructor(e){this.statusCode=e.statusCode,this.reason=e.reason,this.headers=e.headers||{},this.body=e.body}static isInstance(e){if(!e)return!1;let n=e;return typeof n.statusCode=="number"&&typeof n.headers=="object"}};function Pe(t){return/^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/.test(t)}w.Field=$;w.Fields=O;w.HttpRequest=B;w.HttpResponse=M;w.getHttpHandlerExtensionConfiguration=De;w.isValidHostname=Pe;w.resolveHttpHandlerRuntimeConfig=_e});var ee=D(j=>{"use strict";var Z=t=>encodeURIComponent(t).replace(/[!'()*]/g,Ie),Ie=t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`,xe=t=>t.split("/").map(Z).join("/");j.escapeUri=Z;j.escapeUriPath=xe});var ne=D(te=>{"use strict";var q=ee();function Le(t){let e=[];for(let n of Object.keys(t).sort()){let s=t[n];if(n=q.escapeUri(n),Array.isArray(s))for(let o=0,r=s.length;o<r;o++)e.push(`${n}=${q.escapeUri(s[o])}`);else{let o=n;(s||typeof s=="string")&&(o+=`=${q.escapeUri(s)}`),e.push(o)}}return e.join("&")}te.buildQueryString=Le});var fe=D(_=>{"use strict";var ie=G(),ce=ne(),I=require("http"),x=require("https"),ae=require("stream"),F=require("http2");function L(t){let e=t&&typeof t=="object"&&"reason"in t?t.reason:void 0;if(e){if(e instanceof Error)return e;let s=new Error(String(e));return s.name="AbortError",s}let n=new Error("Request aborted");return n.name="AbortError",n}var Ue=["ECONNRESET","EPIPE","ETIMEDOUT"],ue=t=>{let e={};for(let n of Object.keys(t)){let s=t[n];e[n]=Array.isArray(s)?s.join(","):s}return e},p={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},se=1e3,$e=(t,e,n=0)=>{if(!n)return-1;let s=o=>{let r=p.setTimeout(()=>{t.destroy(),e(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${n} ms.`),{name:"TimeoutError"}))},n-o),i=a=>{a?.connecting?a.on("connect",()=>{p.clearTimeout(r)}):p.clearTimeout(r)};t.socket?i(t.socket):t.on("socket",i)};return n<2e3?(s(0),0):p.setTimeout(s.bind(null,se),se)},Oe=(t,e,n=0,s,o)=>n?p.setTimeout(()=>{let r=`@smithy/node-http-handler - [${s?"ERROR":"WARN"}] a request has exceeded the configured ${n} ms requestTimeout.`;if(s){let i=Object.assign(new Error(r),{name:"TimeoutError",code:"ETIMEDOUT"});t.destroy(i),e(i)}else r+=" Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.",o?.warn?.(r)},n):-1,Be=3e3,Me=(t,{keepAlive:e,keepAliveMsecs:n},s=Be)=>{if(e!==!0)return-1;let o=()=>{t.socket?t.socket.setKeepAlive(e,n||0):t.on("socket",r=>{r.setKeepAlive(e,n||0)})};return s===0?(o(),0):p.setTimeout(o,s)},oe=3e3,je=(t,e,n=0)=>{let s=o=>{let r=n-o,i=()=>{t.destroy(),e(Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${n} ms of inactivity (configured by client requestHandler).`),{name:"TimeoutError"}))};t.socket?(t.socket.setTimeout(r,i),t.on("close",()=>t.socket?.removeListener("timeout",i))):t.setTimeout(r,i)};return 0<n&&n<6e3?(s(0),0):p.setTimeout(s.bind(null,n===0?0:oe),oe)},re=6e3;async function de(t,e,n=re,s=!1){let o=e.headers??{},r=o.Expect||o.expect,i=-1,a=!0;!s&&r==="100-continue"&&(a=await Promise.race([new Promise(c=>{i=Number(p.setTimeout(()=>c(!0),Math.max(re,n)))}),new Promise(c=>{t.on("continue",()=>{p.clearTimeout(i),c(!0)}),t.on("response",()=>{p.clearTimeout(i),c(!1)}),t.on("error",()=>{p.clearTimeout(i),c(!1)})})])),a&&qe(t,e.body)}function qe(t,e){if(e instanceof ae.Readable){e.pipe(t);return}if(e){let n=Buffer.isBuffer(e);if(n||typeof e=="string"){n&&e.byteLength===0?t.end():t.end(e);return}let o=e;if(typeof o=="object"&&o.buffer&&typeof o.byteOffset=="number"&&typeof o.byteLength=="number"){t.end(Buffer.from(o.buffer,o.byteOffset,o.byteLength));return}t.end(Buffer.from(e));return}t.end()}var Fe=0,Q=class t{config;configProvider;socketWarningTimestamp=0;externalAgent=!1;metadata={handlerProtocol:"http/1.1"};static create(e){return typeof e?.handle=="function"?e:new t(e)}static checkSocketUsage(e,n,s=console){let{sockets:o,requests:r,maxSockets:i}=e;if(typeof i!="number"||i===1/0||Date.now()-15e3<n)return n;if(o&&r)for(let c in o){let g=o[c]?.length??0,l=r[c]?.length??0;if(g>=i&&l>=2*i)return s?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${g} and ${l} additional requests are enqueued.
|
|
2
|
+
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
3
|
+
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`),Date.now()}return n}constructor(e){this.configProvider=new Promise((n,s)=>{typeof e=="function"?e().then(o=>{n(this.resolveDefaultConfig(o))}).catch(s):n(this.resolveDefaultConfig(e))})}resolveDefaultConfig(e){let{requestTimeout:n,connectionTimeout:s,socketTimeout:o,socketAcquisitionWarningTimeout:r,httpAgent:i,httpsAgent:a,throwOnRequestTimeout:c,logger:g}=e||{},l=!0,T=50;return{connectionTimeout:s,requestTimeout:n,socketTimeout:o,socketAcquisitionWarningTimeout:r,throwOnRequestTimeout:c,httpAgent:i instanceof I.Agent||typeof i?.destroy=="function"?(this.externalAgent=!0,i):new I.Agent({keepAlive:l,maxSockets:T,...i}),httpsAgent:a instanceof x.Agent||typeof a?.destroy=="function"?(this.externalAgent=!0,a):new x.Agent({keepAlive:l,maxSockets:T,...a}),logger:g}}destroy(){this.config?.httpAgent?.destroy(),this.config?.httpsAgent?.destroy()}async handle(e,{abortSignal:n,requestTimeout:s}={}){return this.config||(this.config=await this.configProvider),new Promise((o,r)=>{let i=this.config,a,c=[],g=async d=>{await a,c.forEach(p.clearTimeout),o(d)},l=async d=>{await a,c.forEach(p.clearTimeout),r(d)};if(n?.aborted){let d=L(n);l(d);return}let T=e.protocol==="https:",v=e.headers??{},y=(v.Expect??v.expect)==="100-continue",A=T?i.httpsAgent:i.httpAgent;y&&!this.externalAgent&&(A=new(T?x.Agent:I.Agent)({keepAlive:!1,maxSockets:1/0})),c.push(p.setTimeout(()=>{this.socketWarningTimestamp=t.checkSocketUsage(A,this.socketWarningTimestamp,i.logger)},i.socketAcquisitionWarningTimeout??(i.requestTimeout??2e3)+(i.connectionTimeout??1e3)));let b=ce.buildQueryString(e.query||{}),N;if(e.username!=null||e.password!=null){let d=e.username??"",f=e.password??"";N=`${d}:${f}`}let H=e.path;b&&(H+=`?${b}`),e.fragment&&(H+=`#${e.fragment}`);let C=e.hostname??"";C[0]==="["&&C.endsWith("]")?C=e.hostname.slice(1,-1):C=e.hostname;let k={headers:e.headers,host:C,method:e.method,path:H,port:e.port,agent:A,auth:N},m=(T?x.request:I.request)(k,d=>{let f=new ie.HttpResponse({statusCode:d.statusCode||-1,reason:d.statusMessage,headers:ue(d.headers),body:d});g({response:f})});if(m.on("error",d=>{Ue.includes(d.code)?l(Object.assign(d,{name:"TimeoutError"})):l(d)}),n){let d=()=>{m.destroy();let f=L(n);l(f)};if(typeof n.addEventListener=="function"){let f=n;f.addEventListener("abort",d,{once:!0}),m.once("close",()=>f.removeEventListener("abort",d))}else n.onabort=d}let S=s??i.requestTimeout;c.push($e(m,l,i.connectionTimeout)),c.push(Oe(m,l,S,i.throwOnRequestTimeout,i.logger??console)),c.push(je(m,l,i.socketTimeout));let R=k.agent;typeof R=="object"&&"keepAlive"in R&&c.push(Me(m,{keepAlive:R.keepAlive,keepAliveMsecs:R.keepAliveMsecs})),a=de(m,e,S,this.externalAgent).catch(d=>(c.forEach(p.clearTimeout),r(d)))})}updateHttpClientConfig(e,n){this.config=void 0,this.configProvider=this.configProvider.then(s=>({...s,[e]:n}))}httpHandlerConfigs(){return this.config??{}}},W=class{sessions=[];constructor(e){this.sessions=e??[]}poll(){if(this.sessions.length>0)return this.sessions.shift()}offerLast(e){this.sessions.push(e)}contains(e){return this.sessions.includes(e)}remove(e){this.sessions=this.sessions.filter(n=>n!==e)}[Symbol.iterator](){return this.sessions[Symbol.iterator]()}destroy(e){for(let n of this.sessions)n===e&&(n.destroyed||n.destroy())}},X=class{constructor(e){if(this.config=e,this.config.maxConcurrency&&this.config.maxConcurrency<=0)throw new RangeError("maxConcurrency must be greater than zero.")}config;sessionCache=new Map;lease(e,n){let s=this.getUrlString(e),o=this.sessionCache.get(s);if(o){let c=o.poll();if(c&&!this.config.disableConcurrency)return c}let r=F.connect(s);this.config.maxConcurrency&&r.settings({maxConcurrentStreams:this.config.maxConcurrency},c=>{if(c)throw new Error("Fail to set maxConcurrentStreams to "+this.config.maxConcurrency+"when creating new session for "+e.destination.toString())}),r.unref();let i=()=>{r.destroy(),this.deleteSession(s,r)};r.on("goaway",i),r.on("error",i),r.on("frameError",i),r.on("close",()=>this.deleteSession(s,r)),n.requestTimeout&&r.setTimeout(n.requestTimeout,i);let a=this.sessionCache.get(s)||new W;return a.offerLast(r),this.sessionCache.set(s,a),r}deleteSession(e,n){let s=this.sessionCache.get(e);s&&s.contains(n)&&(s.remove(n),this.sessionCache.set(e,s))}release(e,n){let s=this.getUrlString(e);this.sessionCache.get(s)?.offerLast(n)}destroy(){for(let[e,n]of this.sessionCache){for(let s of n)s.destroyed||s.destroy(),n.remove(s);this.sessionCache.delete(e)}}setMaxConcurrentStreams(e){if(e&&e<=0)throw new RangeError("maxConcurrentStreams must be greater than zero.");this.config.maxConcurrency=e}setDisableConcurrentStreams(e){this.config.disableConcurrency=e}getUrlString(e){return e.destination.toString()}},K=class t{config;configProvider;metadata={handlerProtocol:"h2"};connectionManager=new X({});static create(e){return typeof e?.handle=="function"?e:new t(e)}constructor(e){this.configProvider=new Promise((n,s)=>{typeof e=="function"?e().then(o=>{n(o||{})}).catch(s):n(e||{})})}destroy(){this.connectionManager.destroy()}async handle(e,{abortSignal:n,requestTimeout:s}={}){this.config||(this.config=await this.configProvider,this.connectionManager.setDisableConcurrentStreams(this.config.disableConcurrentStreams||!1),this.config.maxConcurrentStreams&&this.connectionManager.setMaxConcurrentStreams(this.config.maxConcurrentStreams));let{requestTimeout:o,disableConcurrentStreams:r}=this.config,i=s??o;return new Promise((a,c)=>{let g=!1,l,T=async h=>{await l,a(h)},v=async h=>{await l,c(h)};if(n?.aborted){g=!0;let h=L(n);v(h);return}let{hostname:y,method:A,port:b,protocol:N,query:H}=e,C="";if(e.username!=null||e.password!=null){let h=e.username??"",E=e.password??"";C=`${h}:${E}@`}let k=`${N}//${C}${y}${b?`:${b}`:""}`,J={destination:new URL(k)},m=this.connectionManager.lease(J,{requestTimeout:this.config?.sessionTimeout,disableConcurrentStreams:r||!1}),S=h=>{r&&this.destroySession(m),g=!0,v(h)},R=ce.buildQueryString(H||{}),d=e.path;R&&(d+=`?${R}`),e.fragment&&(d+=`#${e.fragment}`);let f=m.request({...e.headers,[F.constants.HTTP2_HEADER_PATH]:d,[F.constants.HTTP2_HEADER_METHOD]:A});if(m.ref(),f.on("response",h=>{let E=new ie.HttpResponse({statusCode:h[":status"]||-1,headers:ue(h),body:f});g=!0,T({response:E}),r&&(m.close(),this.connectionManager.deleteSession(k,m))}),i&&f.setTimeout(i,()=>{f.close();let h=new Error(`Stream timed out because of no activity for ${i} ms`);h.name="TimeoutError",S(h)}),n){let h=()=>{f.close();let E=L(n);S(E)};if(typeof n.addEventListener=="function"){let E=n;E.addEventListener("abort",h,{once:!0}),f.once("close",()=>E.removeEventListener("abort",h))}else n.onabort=h}f.on("frameError",(h,E,me)=>{S(new Error(`Frame type id ${h} in stream id ${me} has failed with code ${E}.`))}),f.on("error",S),f.on("aborted",()=>{S(new Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${f.rstCode}.`))}),f.on("close",()=>{m.unref(),r&&m.destroy(),g||S(new Error("Unexpected error: http2 request did not get a response"))}),l=de(f,e,i)})}updateHttpClientConfig(e,n){this.config=void 0,this.configProvider=this.configProvider.then(s=>({...s,[e]:n}))}httpHandlerConfigs(){return this.config??{}}destroySession(e){e.destroyed||e.destroy()}},V=class extends ae.Writable{bufferedBytes=[];_write(e,n,s){this.bufferedBytes.push(e),s()}},Qe=t=>We(t)?Xe(t):new Promise((e,n)=>{let s=new V;t.pipe(s),t.on("error",o=>{s.end(),n(o)}),s.on("error",n),s.on("finish",function(){let o=new Uint8Array(Buffer.concat(this.bufferedBytes));e(o)})}),We=t=>typeof ReadableStream=="function"&&t instanceof ReadableStream;async function Xe(t){let e=[],n=t.getReader(),s=!1,o=0;for(;!s;){let{done:a,value:c}=await n.read();c&&(e.push(c),o+=c.length),s=a}let r=new Uint8Array(o),i=0;for(let a of e)r.set(a,i),i+=a.length;return r}_.DEFAULT_REQUEST_TIMEOUT=Fe;_.NodeHttp2Handler=K;_.NodeHttpHandler=Q;_.streamCollector=Qe});var ze={};Se(ze,{handler:()=>Ye});module.exports=we(ze);var U=require("@aws-sdk/client-dynamodb"),le=Ce(fe(),1),Ke={requestHandler:new le.NodeHttpHandler({requestTimeout:1e4,connectionTimeout:5e3}),maxAttempts:5},Ve=new U.DynamoDBClient(Ke),he=(t,e)=>console.info(JSON.stringify({msg:t,...e})),Je=(t,e,n)=>console.error(JSON.stringify({msg:t,error:String(e),...n}));async function Ye(t){let e=process.env.TABLE_NAME;if(!e)throw new Error("TABLE_NAME environment variable not set");let n=Number.parseInt(process.env.RETENTION_DAYS||"90",10);for(let s of t.Records)try{let o=JSON.parse(s.body),r=o.eventType||o.messageStatus||"UNKNOWN",i=o.messageId,a=o.destinationPhoneNumber,c=o.originationPhoneNumber,g=o.messageBody||"",l=o.isoCountryCode||"US",T=o.messageType||"TRANSACTIONAL",v=o.eventTimestamp?new Date(o.eventTimestamp).getTime():Date.now();he("Processing SMS event",{messageId:i,eventType:r});let y={isoCountryCode:l,messageType:T};r==="TEXT_DELIVERED"||r==="TEXT_SUCCESSFUL"?y={...y,deliveryTimestamp:o.deliveryTimestamp,carrierName:o.carrierName,providerResponse:o.providerResponse}:r==="TEXT_FAILED"||r==="TEXT_INVALID"||r==="TEXT_CARRIER_UNREACHABLE"||r==="TEXT_BLOCKED"?y={...y,failureReason:o.failureReason||o.statusMessage,failureCode:o.failureCode||o.statusCode,providerResponse:o.providerResponse}:r==="TEXT_QUEUED"||r==="TEXT_SENT"?y={...y,queuedTimestamp:o.queuedTimestamp,sentTimestamp:o.sentTimestamp}:r==="TEXT_TTL_EXPIRED"&&(y={...y,expirationTimestamp:o.expirationTimestamp,ttlSeconds:o.ttlSeconds});let A=g?Math.ceil(g.length/160):1,b=n>0?Date.now()+n*24*60*60*1e3:Date.now()+365*24*60*60*1e3;await Ve.send(new U.PutItemCommand({TableName:e,Item:{messageId:{S:i},sentAt:{N:v.toString()},accountId:{S:process.env.AWS_ACCOUNT_ID||"unknown"},destinationNumber:{S:a||""},originationNumber:{S:c||""},messageBody:{S:g},eventType:{S:r},segments:{N:A.toString()},eventData:{S:JSON.stringify(o)},additionalData:{S:JSON.stringify(y)},createdAt:{N:Date.now().toString()},expiresAt:{N:b.toString()}}})),he("Stored SMS event",{eventType:r,messageId:i})}catch(o){Je("Error processing SMS record",o,{recordId:s.messageId})}return{statusCode:200,body:JSON.stringify({message:"SMS events processed successfully"})}}0&&(module.exports={handler});
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { DynamoDBClient, PutItemCommand } from "@aws-sdk/client-dynamodb";
|
|
2
|
+
import { NodeHttpHandler } from "@smithy/node-http-handler";
|
|
2
3
|
import type { SQSEvent } from "aws-lambda";
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
+
const awsDefaults = {
|
|
6
|
+
requestHandler: new NodeHttpHandler({
|
|
7
|
+
requestTimeout: 10_000,
|
|
8
|
+
connectionTimeout: 5000,
|
|
9
|
+
}),
|
|
10
|
+
maxAttempts: 5,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const dynamodb = new DynamoDBClient(awsDefaults);
|
|
5
14
|
|
|
6
15
|
const log = (msg: string, data?: Record<string, unknown>) =>
|
|
7
16
|
console.info(JSON.stringify({ msg, ...data }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wraps.dev/cli",
|
|
3
|
-
"version": "2.17.
|
|
3
|
+
"version": "2.17.12",
|
|
4
4
|
"description": "CLI for deploying Wraps email infrastructure to your AWS account",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cli.js",
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"tsx": "4.20.6",
|
|
87
87
|
"typescript": "^5.9.3",
|
|
88
88
|
"vitest": "^4.0.7",
|
|
89
|
-
"@wraps/
|
|
90
|
-
"@wraps/
|
|
89
|
+
"@wraps/core": "0.1.1",
|
|
90
|
+
"@wraps/email-check": "1.0.0"
|
|
91
91
|
},
|
|
92
92
|
"engines": {
|
|
93
93
|
"node": ">=20.0.0"
|
|
File without changes
|