@drawbridge/drawbridge-utils 0.0.158 → 0.0.159
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/connections/index.cjs +15 -5
- package/dist/connections/index.d.cts +14 -2
- package/dist/connections/index.d.ts +14 -2
- package/dist/connections/index.js +15 -5
- package/dist/providers.cjs +15 -5
- package/dist/providers.js +15 -5
- package/package.json +1 -1
|
@@ -2265,11 +2265,11 @@ var drawbridge_default2 = {
|
|
|
2265
2265
|
// and repeat STOPs collapse onto the unique { channel, address,
|
|
2266
2266
|
// organization } index instead of erroring.
|
|
2267
2267
|
process: ({ context }) => {
|
|
2268
|
-
var _a, _b;
|
|
2269
|
-
if ((context == null ? void 0 : context.topic) === "email.events") return summariseEvents(context == null ? void 0 : context.data);
|
|
2268
|
+
var _a, _b, _c;
|
|
2269
|
+
if ((context == null ? void 0 : context.topic) === "email.events") return summariseEvents((_a = context == null ? void 0 : context.data) == null ? void 0 : _a.events);
|
|
2270
2270
|
if ((context == null ? void 0 : context.topic) === "sms.status") return statusCallback(context == null ? void 0 : context.data);
|
|
2271
|
-
const keyword = String(((
|
|
2272
|
-
const address = toE164((
|
|
2271
|
+
const keyword = String(((_b = context == null ? void 0 : context.data) == null ? void 0 : _b.Body) || "").trim().toUpperCase();
|
|
2272
|
+
const address = toE164((_c = context == null ? void 0 : context.data) == null ? void 0 : _c.From);
|
|
2273
2273
|
if (!address) return { message: "Inbound SMS carried no usable sender number.", skipped: true };
|
|
2274
2274
|
if (STOP_KEYWORDS.includes(keyword)) {
|
|
2275
2275
|
return {
|
|
@@ -2318,8 +2318,18 @@ var drawbridge_default2 = {
|
|
|
2318
2318
|
// acceptable because SendGrid only retries a non-2xx, and the cost of a
|
|
2319
2319
|
// duplicate here is a second buffer row rather than a repeated side
|
|
2320
2320
|
// effect. Revisit if this ever writes suppressions.
|
|
2321
|
+
//
|
|
2322
|
+
// THE BATCH IS WRAPPED, and it has to be. SendGrid posts a JSON ARRAY
|
|
2323
|
+
// where every other vendor posts an object, and drawbridge-api's
|
|
2324
|
+
// schema/buffer.js declares `data : { bsonType : 'object' }` — which in
|
|
2325
|
+
// JSON Schema does NOT match an array. Writing the array raw fails
|
|
2326
|
+
// validation, answers 500, and puts SendGrid into a retry loop for a
|
|
2327
|
+
// webhook we would never accept.
|
|
2328
|
+
//
|
|
2329
|
+
// Wrapped here rather than widening the schema: `data` stays one shape
|
|
2330
|
+
// for every consumer, and the vendor that is odd carries the oddity.
|
|
2321
2331
|
receive: ({ channel, payload }) => ({
|
|
2322
|
-
data: payload,
|
|
2332
|
+
data: channel === "email" ? { events: payload } : payload,
|
|
2323
2333
|
provider: { id: channel === "email" ? null : (payload == null ? void 0 : payload.MessageSid) || null }
|
|
2324
2334
|
}),
|
|
2325
2335
|
// TWILIO'S SCHEME, from docs.twilio.com/usage/security: take the full
|
|
@@ -2463,7 +2463,9 @@ var drawbridge = {
|
|
|
2463
2463
|
// hook, so without the branch a SendGrid batch falls into the Twilio
|
|
2464
2464
|
// path below, finds no `Body`, and logs itself as an inbound SMS that
|
|
2465
2465
|
// carried no usable sender number.
|
|
2466
|
-
|
|
2466
|
+
// `.events` because receive wraps the batch — schema/buffer.js types
|
|
2467
|
+
// `data` as an object and SendGrid posts an array.
|
|
2468
|
+
if( context?.topic === 'email.events' ) return summariseEvents( context?.data?.events );
|
|
2467
2469
|
if( context?.topic === 'sms.status' ) return statusCallback( context?.data );
|
|
2468
2470
|
|
|
2469
2471
|
const keyword = String( context?.data?.Body || '' ).trim().toUpperCase();
|
|
@@ -2526,8 +2528,18 @@ var drawbridge = {
|
|
|
2526
2528
|
// acceptable because SendGrid only retries a non-2xx, and the cost of a
|
|
2527
2529
|
// duplicate here is a second buffer row rather than a repeated side
|
|
2528
2530
|
// effect. Revisit if this ever writes suppressions.
|
|
2531
|
+
//
|
|
2532
|
+
// THE BATCH IS WRAPPED, and it has to be. SendGrid posts a JSON ARRAY
|
|
2533
|
+
// where every other vendor posts an object, and drawbridge-api's
|
|
2534
|
+
// schema/buffer.js declares `data : { bsonType : 'object' }` — which in
|
|
2535
|
+
// JSON Schema does NOT match an array. Writing the array raw fails
|
|
2536
|
+
// validation, answers 500, and puts SendGrid into a retry loop for a
|
|
2537
|
+
// webhook we would never accept.
|
|
2538
|
+
//
|
|
2539
|
+
// Wrapped here rather than widening the schema: `data` stays one shape
|
|
2540
|
+
// for every consumer, and the vendor that is odd carries the oddity.
|
|
2529
2541
|
receive : ({ channel, payload }) => ({
|
|
2530
|
-
data : payload,
|
|
2542
|
+
data : channel === 'email' ? { events : payload } : payload,
|
|
2531
2543
|
provider : { id : channel === 'email' ? null : payload?.MessageSid || null }
|
|
2532
2544
|
}),
|
|
2533
2545
|
|
|
@@ -2463,7 +2463,9 @@ var drawbridge = {
|
|
|
2463
2463
|
// hook, so without the branch a SendGrid batch falls into the Twilio
|
|
2464
2464
|
// path below, finds no `Body`, and logs itself as an inbound SMS that
|
|
2465
2465
|
// carried no usable sender number.
|
|
2466
|
-
|
|
2466
|
+
// `.events` because receive wraps the batch — schema/buffer.js types
|
|
2467
|
+
// `data` as an object and SendGrid posts an array.
|
|
2468
|
+
if( context?.topic === 'email.events' ) return summariseEvents( context?.data?.events );
|
|
2467
2469
|
if( context?.topic === 'sms.status' ) return statusCallback( context?.data );
|
|
2468
2470
|
|
|
2469
2471
|
const keyword = String( context?.data?.Body || '' ).trim().toUpperCase();
|
|
@@ -2526,8 +2528,18 @@ var drawbridge = {
|
|
|
2526
2528
|
// acceptable because SendGrid only retries a non-2xx, and the cost of a
|
|
2527
2529
|
// duplicate here is a second buffer row rather than a repeated side
|
|
2528
2530
|
// effect. Revisit if this ever writes suppressions.
|
|
2531
|
+
//
|
|
2532
|
+
// THE BATCH IS WRAPPED, and it has to be. SendGrid posts a JSON ARRAY
|
|
2533
|
+
// where every other vendor posts an object, and drawbridge-api's
|
|
2534
|
+
// schema/buffer.js declares `data : { bsonType : 'object' }` — which in
|
|
2535
|
+
// JSON Schema does NOT match an array. Writing the array raw fails
|
|
2536
|
+
// validation, answers 500, and puts SendGrid into a retry loop for a
|
|
2537
|
+
// webhook we would never accept.
|
|
2538
|
+
//
|
|
2539
|
+
// Wrapped here rather than widening the schema: `data` stays one shape
|
|
2540
|
+
// for every consumer, and the vendor that is odd carries the oddity.
|
|
2529
2541
|
receive : ({ channel, payload }) => ({
|
|
2530
|
-
data : payload,
|
|
2542
|
+
data : channel === 'email' ? { events : payload } : payload,
|
|
2531
2543
|
provider : { id : channel === 'email' ? null : payload?.MessageSid || null }
|
|
2532
2544
|
}),
|
|
2533
2545
|
|
|
@@ -2189,11 +2189,11 @@ var drawbridge_default2 = {
|
|
|
2189
2189
|
// and repeat STOPs collapse onto the unique { channel, address,
|
|
2190
2190
|
// organization } index instead of erroring.
|
|
2191
2191
|
process: ({ context }) => {
|
|
2192
|
-
var _a, _b;
|
|
2193
|
-
if ((context == null ? void 0 : context.topic) === "email.events") return summariseEvents(context == null ? void 0 : context.data);
|
|
2192
|
+
var _a, _b, _c;
|
|
2193
|
+
if ((context == null ? void 0 : context.topic) === "email.events") return summariseEvents((_a = context == null ? void 0 : context.data) == null ? void 0 : _a.events);
|
|
2194
2194
|
if ((context == null ? void 0 : context.topic) === "sms.status") return statusCallback(context == null ? void 0 : context.data);
|
|
2195
|
-
const keyword = String(((
|
|
2196
|
-
const address = toE164((
|
|
2195
|
+
const keyword = String(((_b = context == null ? void 0 : context.data) == null ? void 0 : _b.Body) || "").trim().toUpperCase();
|
|
2196
|
+
const address = toE164((_c = context == null ? void 0 : context.data) == null ? void 0 : _c.From);
|
|
2197
2197
|
if (!address) return { message: "Inbound SMS carried no usable sender number.", skipped: true };
|
|
2198
2198
|
if (STOP_KEYWORDS.includes(keyword)) {
|
|
2199
2199
|
return {
|
|
@@ -2242,8 +2242,18 @@ var drawbridge_default2 = {
|
|
|
2242
2242
|
// acceptable because SendGrid only retries a non-2xx, and the cost of a
|
|
2243
2243
|
// duplicate here is a second buffer row rather than a repeated side
|
|
2244
2244
|
// effect. Revisit if this ever writes suppressions.
|
|
2245
|
+
//
|
|
2246
|
+
// THE BATCH IS WRAPPED, and it has to be. SendGrid posts a JSON ARRAY
|
|
2247
|
+
// where every other vendor posts an object, and drawbridge-api's
|
|
2248
|
+
// schema/buffer.js declares `data : { bsonType : 'object' }` — which in
|
|
2249
|
+
// JSON Schema does NOT match an array. Writing the array raw fails
|
|
2250
|
+
// validation, answers 500, and puts SendGrid into a retry loop for a
|
|
2251
|
+
// webhook we would never accept.
|
|
2252
|
+
//
|
|
2253
|
+
// Wrapped here rather than widening the schema: `data` stays one shape
|
|
2254
|
+
// for every consumer, and the vendor that is odd carries the oddity.
|
|
2245
2255
|
receive: ({ channel, payload }) => ({
|
|
2246
|
-
data: payload,
|
|
2256
|
+
data: channel === "email" ? { events: payload } : payload,
|
|
2247
2257
|
provider: { id: channel === "email" ? null : (payload == null ? void 0 : payload.MessageSid) || null }
|
|
2248
2258
|
}),
|
|
2249
2259
|
// TWILIO'S SCHEME, from docs.twilio.com/usage/security: take the full
|
package/dist/providers.cjs
CHANGED
|
@@ -2171,11 +2171,11 @@ var drawbridge_default2 = {
|
|
|
2171
2171
|
// and repeat STOPs collapse onto the unique { channel, address,
|
|
2172
2172
|
// organization } index instead of erroring.
|
|
2173
2173
|
process: ({ context }) => {
|
|
2174
|
-
var _a, _b;
|
|
2175
|
-
if ((context == null ? void 0 : context.topic) === "email.events") return summariseEvents(context == null ? void 0 : context.data);
|
|
2174
|
+
var _a, _b, _c;
|
|
2175
|
+
if ((context == null ? void 0 : context.topic) === "email.events") return summariseEvents((_a = context == null ? void 0 : context.data) == null ? void 0 : _a.events);
|
|
2176
2176
|
if ((context == null ? void 0 : context.topic) === "sms.status") return statusCallback(context == null ? void 0 : context.data);
|
|
2177
|
-
const keyword = String(((
|
|
2178
|
-
const address = toE164((
|
|
2177
|
+
const keyword = String(((_b = context == null ? void 0 : context.data) == null ? void 0 : _b.Body) || "").trim().toUpperCase();
|
|
2178
|
+
const address = toE164((_c = context == null ? void 0 : context.data) == null ? void 0 : _c.From);
|
|
2179
2179
|
if (!address) return { message: "Inbound SMS carried no usable sender number.", skipped: true };
|
|
2180
2180
|
if (STOP_KEYWORDS.includes(keyword)) {
|
|
2181
2181
|
return {
|
|
@@ -2224,8 +2224,18 @@ var drawbridge_default2 = {
|
|
|
2224
2224
|
// acceptable because SendGrid only retries a non-2xx, and the cost of a
|
|
2225
2225
|
// duplicate here is a second buffer row rather than a repeated side
|
|
2226
2226
|
// effect. Revisit if this ever writes suppressions.
|
|
2227
|
+
//
|
|
2228
|
+
// THE BATCH IS WRAPPED, and it has to be. SendGrid posts a JSON ARRAY
|
|
2229
|
+
// where every other vendor posts an object, and drawbridge-api's
|
|
2230
|
+
// schema/buffer.js declares `data : { bsonType : 'object' }` — which in
|
|
2231
|
+
// JSON Schema does NOT match an array. Writing the array raw fails
|
|
2232
|
+
// validation, answers 500, and puts SendGrid into a retry loop for a
|
|
2233
|
+
// webhook we would never accept.
|
|
2234
|
+
//
|
|
2235
|
+
// Wrapped here rather than widening the schema: `data` stays one shape
|
|
2236
|
+
// for every consumer, and the vendor that is odd carries the oddity.
|
|
2227
2237
|
receive: ({ channel, payload }) => ({
|
|
2228
|
-
data: payload,
|
|
2238
|
+
data: channel === "email" ? { events: payload } : payload,
|
|
2229
2239
|
provider: { id: channel === "email" ? null : (payload == null ? void 0 : payload.MessageSid) || null }
|
|
2230
2240
|
}),
|
|
2231
2241
|
// TWILIO'S SCHEME, from docs.twilio.com/usage/security: take the full
|
package/dist/providers.js
CHANGED
|
@@ -2125,11 +2125,11 @@ var drawbridge_default2 = {
|
|
|
2125
2125
|
// and repeat STOPs collapse onto the unique { channel, address,
|
|
2126
2126
|
// organization } index instead of erroring.
|
|
2127
2127
|
process: ({ context }) => {
|
|
2128
|
-
var _a, _b;
|
|
2129
|
-
if ((context == null ? void 0 : context.topic) === "email.events") return summariseEvents(context == null ? void 0 : context.data);
|
|
2128
|
+
var _a, _b, _c;
|
|
2129
|
+
if ((context == null ? void 0 : context.topic) === "email.events") return summariseEvents((_a = context == null ? void 0 : context.data) == null ? void 0 : _a.events);
|
|
2130
2130
|
if ((context == null ? void 0 : context.topic) === "sms.status") return statusCallback(context == null ? void 0 : context.data);
|
|
2131
|
-
const keyword = String(((
|
|
2132
|
-
const address = toE164((
|
|
2131
|
+
const keyword = String(((_b = context == null ? void 0 : context.data) == null ? void 0 : _b.Body) || "").trim().toUpperCase();
|
|
2132
|
+
const address = toE164((_c = context == null ? void 0 : context.data) == null ? void 0 : _c.From);
|
|
2133
2133
|
if (!address) return { message: "Inbound SMS carried no usable sender number.", skipped: true };
|
|
2134
2134
|
if (STOP_KEYWORDS.includes(keyword)) {
|
|
2135
2135
|
return {
|
|
@@ -2178,8 +2178,18 @@ var drawbridge_default2 = {
|
|
|
2178
2178
|
// acceptable because SendGrid only retries a non-2xx, and the cost of a
|
|
2179
2179
|
// duplicate here is a second buffer row rather than a repeated side
|
|
2180
2180
|
// effect. Revisit if this ever writes suppressions.
|
|
2181
|
+
//
|
|
2182
|
+
// THE BATCH IS WRAPPED, and it has to be. SendGrid posts a JSON ARRAY
|
|
2183
|
+
// where every other vendor posts an object, and drawbridge-api's
|
|
2184
|
+
// schema/buffer.js declares `data : { bsonType : 'object' }` — which in
|
|
2185
|
+
// JSON Schema does NOT match an array. Writing the array raw fails
|
|
2186
|
+
// validation, answers 500, and puts SendGrid into a retry loop for a
|
|
2187
|
+
// webhook we would never accept.
|
|
2188
|
+
//
|
|
2189
|
+
// Wrapped here rather than widening the schema: `data` stays one shape
|
|
2190
|
+
// for every consumer, and the vendor that is odd carries the oddity.
|
|
2181
2191
|
receive: ({ channel, payload }) => ({
|
|
2182
|
-
data: payload,
|
|
2192
|
+
data: channel === "email" ? { events: payload } : payload,
|
|
2183
2193
|
provider: { id: channel === "email" ? null : (payload == null ? void 0 : payload.MessageSid) || null }
|
|
2184
2194
|
}),
|
|
2185
2195
|
// TWILIO'S SCHEME, from docs.twilio.com/usage/security: take the full
|
package/package.json
CHANGED