@drawbridge/drawbridge-utils 0.0.158 → 0.0.160

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.
@@ -1450,7 +1450,6 @@ var organization = {
1450
1450
 
1451
1451
  // index.js
1452
1452
  var import_currency_codes = require("currency-codes");
1453
- var import_nanoid = require("nanoid");
1454
1453
 
1455
1454
  // lib/color.js
1456
1455
  var import_tinycolor2 = __toESM(require("tinycolor2"), 1);
@@ -1513,8 +1512,11 @@ var style = {
1513
1512
  }
1514
1513
  };
1515
1514
 
1515
+ // lib/nanoid.js
1516
+ var import_nanoid = require("nanoid");
1517
+ var generate = (0, import_nanoid.customAlphabet)("0123456789abcdefghijklmnopqrstuvwxyz", 8);
1518
+
1516
1519
  // index.js
1517
- var nanoid = (0, import_nanoid.customAlphabet)("0123456789abcdefghijklmnopqrstuvwxyz", 8);
1518
1520
  var infinite = 1e300;
1519
1521
  var megabyte = 1024 * 1024;
1520
1522
  var gigabyte = megabyte * 1024;
@@ -2265,11 +2267,11 @@ var drawbridge_default2 = {
2265
2267
  // and repeat STOPs collapse onto the unique { channel, address,
2266
2268
  // organization } index instead of erroring.
2267
2269
  process: ({ context }) => {
2268
- var _a, _b;
2269
- if ((context == null ? void 0 : context.topic) === "email.events") return summariseEvents(context == null ? void 0 : context.data);
2270
+ var _a, _b, _c;
2271
+ if ((context == null ? void 0 : context.topic) === "email.events") return summariseEvents((_a = context == null ? void 0 : context.data) == null ? void 0 : _a.events);
2270
2272
  if ((context == null ? void 0 : context.topic) === "sms.status") return statusCallback(context == null ? void 0 : context.data);
2271
- const keyword = String(((_a = context == null ? void 0 : context.data) == null ? void 0 : _a.Body) || "").trim().toUpperCase();
2272
- const address = toE164((_b = context == null ? void 0 : context.data) == null ? void 0 : _b.From);
2273
+ const keyword = String(((_b = context == null ? void 0 : context.data) == null ? void 0 : _b.Body) || "").trim().toUpperCase();
2274
+ const address = toE164((_c = context == null ? void 0 : context.data) == null ? void 0 : _c.From);
2273
2275
  if (!address) return { message: "Inbound SMS carried no usable sender number.", skipped: true };
2274
2276
  if (STOP_KEYWORDS.includes(keyword)) {
2275
2277
  return {
@@ -2318,8 +2320,18 @@ var drawbridge_default2 = {
2318
2320
  // acceptable because SendGrid only retries a non-2xx, and the cost of a
2319
2321
  // duplicate here is a second buffer row rather than a repeated side
2320
2322
  // effect. Revisit if this ever writes suppressions.
2323
+ //
2324
+ // THE BATCH IS WRAPPED, and it has to be. SendGrid posts a JSON ARRAY
2325
+ // where every other vendor posts an object, and drawbridge-api's
2326
+ // schema/buffer.js declares `data : { bsonType : 'object' }` — which in
2327
+ // JSON Schema does NOT match an array. Writing the array raw fails
2328
+ // validation, answers 500, and puts SendGrid into a retry loop for a
2329
+ // webhook we would never accept.
2330
+ //
2331
+ // Wrapped here rather than widening the schema: `data` stays one shape
2332
+ // for every consumer, and the vendor that is odd carries the oddity.
2321
2333
  receive: ({ channel, payload }) => ({
2322
- data: payload,
2334
+ data: channel === "email" ? { events: payload } : payload,
2323
2335
  provider: { id: channel === "email" ? null : (payload == null ? void 0 : payload.MessageSid) || null }
2324
2336
  }),
2325
2337
  // TWILIO'S SCHEME, from docs.twilio.com/usage/security: take the full
@@ -2654,8 +2666,8 @@ var drawbridge_default2 = {
2654
2666
  // owner is not a member document, so a solo merchant has nothing to
2655
2667
  // pick and could never save the step.
2656
2668
  members: { of: "string", type: "array" },
2657
- message: { required: true, type: "string" },
2658
- subject: { required: true, type: "string" }
2669
+ message: { max: 2e3, required: true, type: "string" },
2670
+ subject: { max: 150, required: true, type: "string" }
2659
2671
  },
2660
2672
  triggers: ["schedule.day", "schedule.week", "schedule.month"],
2661
2673
  usage: { actions: 0 }
@@ -2678,8 +2690,8 @@ var drawbridge_default2 = {
2678
2690
  queue: "notification",
2679
2691
  settings: {
2680
2692
  members: { of: "string", type: "array" },
2681
- message: { type: "string" },
2682
- subject: { type: "string" }
2693
+ message: { max: 2e3, type: "string" },
2694
+ subject: { max: 150, type: "string" }
2683
2695
  },
2684
2696
  triggers: ["lead.insert"],
2685
2697
  // Zero is a PRICE, and a deliberate one. Declared rather than omitted
@@ -2693,8 +2705,8 @@ var drawbridge_default2 = {
2693
2705
  key: "Email \u2014 Send email",
2694
2706
  queue: "notification",
2695
2707
  settings: {
2696
- message: { required: true, type: "string" },
2697
- subject: { required: true, type: "string" }
2708
+ message: { max: 2e3, required: true, type: "string" },
2709
+ subject: { max: 150, required: true, type: "string" }
2698
2710
  },
2699
2711
  triggers: ["lead.insert"],
2700
2712
  // ONE SOURCE FOR THE PRICE. lib/pricing.js is the index of every
@@ -2723,8 +2735,8 @@ var drawbridge_default2 = {
2723
2735
  key: "Send an SMS",
2724
2736
  queue: "notification",
2725
2737
  settings: {
2726
- message: { required: true, type: "string" },
2727
- subject: { required: true, type: "string" }
2738
+ message: { max: 1600, required: true, type: "string" },
2739
+ subject: { max: 150, required: true, type: "string" }
2728
2740
  },
2729
2741
  // Priced per SEGMENT and billed from the first, which the send
2730
2742
  // resolves from the message length. This is the floor.
@@ -3687,7 +3699,7 @@ var mailchimp_default2 = {
3687
3699
 
3688
3700
  // lib/connections/providers/shopify.js
3689
3701
  var import_node_crypto5 = require("crypto");
3690
- var import_nanoid2 = require("nanoid");
3702
+ var import_nanoid3 = require("nanoid");
3691
3703
 
3692
3704
  // lib/connections/icons/shopify.js
3693
3705
  var shopify_default = `<svg width="500" height="500" viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -3782,7 +3794,7 @@ var attributeLineItems = (lineItems = []) => lineItems.reduce(
3782
3794
  },
3783
3795
  { attrMap: {}, attributedGross: 0, attributedLines: [] }
3784
3796
  );
3785
- var generateDiscountCode = (0, import_nanoid2.customAlphabet)("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 8);
3797
+ var generateDiscountCode = (0, import_nanoid3.customAlphabet)("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 8);
3786
3798
  var ORDER_EVENT_HANDLE = slugify("drawbridge-orders");
3787
3799
  var REFRESH_TOKEN_FRESHNESS_BUFFER_MS = 5 * 24 * 60 * 60 * 1e3;
3788
3800
  var OAUTH_ERROR_SOURCE = "oauth";
@@ -20,6 +20,7 @@ import '../index.cjs';
20
20
  import 'currency-codes';
21
21
  import '../color.cjs';
22
22
  import 'tinycolor2';
23
+ import '../nanoid.cjs';
23
24
  import 'crypto';
24
25
  import '../token.cjs';
25
26
  import 'slugify';
@@ -2463,7 +2464,9 @@ var drawbridge = {
2463
2464
  // hook, so without the branch a SendGrid batch falls into the Twilio
2464
2465
  // path below, finds no `Body`, and logs itself as an inbound SMS that
2465
2466
  // carried no usable sender number.
2466
- if( context?.topic === 'email.events' ) return summariseEvents( context?.data );
2467
+ // `.events` because receive wraps the batch schema/buffer.js types
2468
+ // `data` as an object and SendGrid posts an array.
2469
+ if( context?.topic === 'email.events' ) return summariseEvents( context?.data?.events );
2467
2470
  if( context?.topic === 'sms.status' ) return statusCallback( context?.data );
2468
2471
 
2469
2472
  const keyword = String( context?.data?.Body || '' ).trim().toUpperCase();
@@ -2526,8 +2529,18 @@ var drawbridge = {
2526
2529
  // acceptable because SendGrid only retries a non-2xx, and the cost of a
2527
2530
  // duplicate here is a second buffer row rather than a repeated side
2528
2531
  // effect. Revisit if this ever writes suppressions.
2532
+ //
2533
+ // THE BATCH IS WRAPPED, and it has to be. SendGrid posts a JSON ARRAY
2534
+ // where every other vendor posts an object, and drawbridge-api's
2535
+ // schema/buffer.js declares `data : { bsonType : 'object' }` — which in
2536
+ // JSON Schema does NOT match an array. Writing the array raw fails
2537
+ // validation, answers 500, and puts SendGrid into a retry loop for a
2538
+ // webhook we would never accept.
2539
+ //
2540
+ // Wrapped here rather than widening the schema: `data` stays one shape
2541
+ // for every consumer, and the vendor that is odd carries the oddity.
2529
2542
  receive : ({ channel, payload }) => ({
2530
- data : payload,
2543
+ data : channel === 'email' ? { events : payload } : payload,
2531
2544
  provider : { id : channel === 'email' ? null : payload?.MessageSid || null }
2532
2545
  }),
2533
2546
 
@@ -2972,8 +2985,8 @@ var drawbridge = {
2972
2985
  // owner is not a member document, so a solo merchant has nothing to
2973
2986
  // pick and could never save the step.
2974
2987
  members : { of : 'string', type : 'array' },
2975
- message : { required : true, type : 'string' },
2976
- subject : { required : true, type : 'string' }
2988
+ message : { max : 2000, required : true, type : 'string' },
2989
+ subject : { max : 150, required : true, type : 'string' }
2977
2990
  },
2978
2991
  triggers : [ 'schedule.day', 'schedule.week', 'schedule.month' ],
2979
2992
  usage : { actions : 0 }
@@ -2997,8 +3010,8 @@ var drawbridge = {
2997
3010
  queue : 'notification',
2998
3011
  settings : {
2999
3012
  members : { of : 'string', type : 'array' },
3000
- message : { type : 'string' },
3001
- subject : { type : 'string' }
3013
+ message : { max : 2000, type : 'string' },
3014
+ subject : { max : 150, type : 'string' }
3002
3015
  },
3003
3016
  triggers : [ 'lead.insert' ],
3004
3017
  // Zero is a PRICE, and a deliberate one. Declared rather than omitted
@@ -3013,8 +3026,8 @@ var drawbridge = {
3013
3026
  key : 'Email — Send email',
3014
3027
  queue : 'notification',
3015
3028
  settings : {
3016
- message : { required : true, type : 'string' },
3017
- subject : { required : true, type : 'string' }
3029
+ message : { max : 2000, required : true, type : 'string' },
3030
+ subject : { max : 150, required : true, type : 'string' }
3018
3031
  },
3019
3032
  triggers : [ 'lead.insert' ],
3020
3033
  // ONE SOURCE FOR THE PRICE. lib/pricing.js is the index of every
@@ -3046,8 +3059,8 @@ var drawbridge = {
3046
3059
  key : 'Send an SMS',
3047
3060
  queue : 'notification',
3048
3061
  settings : {
3049
- message : { required : true, type : 'string' },
3050
- subject : { required : true, type : 'string' }
3062
+ message : { max : 1600, required : true, type : 'string' },
3063
+ subject : { max : 150, required : true, type : 'string' }
3051
3064
  },
3052
3065
  // Priced per SEGMENT and billed from the first, which the send
3053
3066
  // resolves from the message length. This is the floor.
@@ -20,6 +20,7 @@ import '../index.js';
20
20
  import 'currency-codes';
21
21
  import '../color.js';
22
22
  import 'tinycolor2';
23
+ import '../nanoid.js';
23
24
  import 'crypto';
24
25
  import '../token.js';
25
26
  import 'slugify';
@@ -2463,7 +2464,9 @@ var drawbridge = {
2463
2464
  // hook, so without the branch a SendGrid batch falls into the Twilio
2464
2465
  // path below, finds no `Body`, and logs itself as an inbound SMS that
2465
2466
  // carried no usable sender number.
2466
- if( context?.topic === 'email.events' ) return summariseEvents( context?.data );
2467
+ // `.events` because receive wraps the batch schema/buffer.js types
2468
+ // `data` as an object and SendGrid posts an array.
2469
+ if( context?.topic === 'email.events' ) return summariseEvents( context?.data?.events );
2467
2470
  if( context?.topic === 'sms.status' ) return statusCallback( context?.data );
2468
2471
 
2469
2472
  const keyword = String( context?.data?.Body || '' ).trim().toUpperCase();
@@ -2526,8 +2529,18 @@ var drawbridge = {
2526
2529
  // acceptable because SendGrid only retries a non-2xx, and the cost of a
2527
2530
  // duplicate here is a second buffer row rather than a repeated side
2528
2531
  // effect. Revisit if this ever writes suppressions.
2532
+ //
2533
+ // THE BATCH IS WRAPPED, and it has to be. SendGrid posts a JSON ARRAY
2534
+ // where every other vendor posts an object, and drawbridge-api's
2535
+ // schema/buffer.js declares `data : { bsonType : 'object' }` — which in
2536
+ // JSON Schema does NOT match an array. Writing the array raw fails
2537
+ // validation, answers 500, and puts SendGrid into a retry loop for a
2538
+ // webhook we would never accept.
2539
+ //
2540
+ // Wrapped here rather than widening the schema: `data` stays one shape
2541
+ // for every consumer, and the vendor that is odd carries the oddity.
2529
2542
  receive : ({ channel, payload }) => ({
2530
- data : payload,
2543
+ data : channel === 'email' ? { events : payload } : payload,
2531
2544
  provider : { id : channel === 'email' ? null : payload?.MessageSid || null }
2532
2545
  }),
2533
2546
 
@@ -2972,8 +2985,8 @@ var drawbridge = {
2972
2985
  // owner is not a member document, so a solo merchant has nothing to
2973
2986
  // pick and could never save the step.
2974
2987
  members : { of : 'string', type : 'array' },
2975
- message : { required : true, type : 'string' },
2976
- subject : { required : true, type : 'string' }
2988
+ message : { max : 2000, required : true, type : 'string' },
2989
+ subject : { max : 150, required : true, type : 'string' }
2977
2990
  },
2978
2991
  triggers : [ 'schedule.day', 'schedule.week', 'schedule.month' ],
2979
2992
  usage : { actions : 0 }
@@ -2997,8 +3010,8 @@ var drawbridge = {
2997
3010
  queue : 'notification',
2998
3011
  settings : {
2999
3012
  members : { of : 'string', type : 'array' },
3000
- message : { type : 'string' },
3001
- subject : { type : 'string' }
3013
+ message : { max : 2000, type : 'string' },
3014
+ subject : { max : 150, type : 'string' }
3002
3015
  },
3003
3016
  triggers : [ 'lead.insert' ],
3004
3017
  // Zero is a PRICE, and a deliberate one. Declared rather than omitted
@@ -3013,8 +3026,8 @@ var drawbridge = {
3013
3026
  key : 'Email — Send email',
3014
3027
  queue : 'notification',
3015
3028
  settings : {
3016
- message : { required : true, type : 'string' },
3017
- subject : { required : true, type : 'string' }
3029
+ message : { max : 2000, required : true, type : 'string' },
3030
+ subject : { max : 150, required : true, type : 'string' }
3018
3031
  },
3019
3032
  triggers : [ 'lead.insert' ],
3020
3033
  // ONE SOURCE FOR THE PRICE. lib/pricing.js is the index of every
@@ -3046,8 +3059,8 @@ var drawbridge = {
3046
3059
  key : 'Send an SMS',
3047
3060
  queue : 'notification',
3048
3061
  settings : {
3049
- message : { required : true, type : 'string' },
3050
- subject : { required : true, type : 'string' }
3062
+ message : { max : 1600, required : true, type : 'string' },
3063
+ subject : { max : 150, required : true, type : 'string' }
3051
3064
  },
3052
3065
  // Priced per SEGMENT and billed from the first, which the send
3053
3066
  // resolves from the message length. This is the floor.
@@ -1374,7 +1374,6 @@ var organization = {
1374
1374
 
1375
1375
  // index.js
1376
1376
  import { code, data } from "currency-codes";
1377
- import { customAlphabet } from "nanoid";
1378
1377
 
1379
1378
  // lib/color.js
1380
1379
  import tinycolor from "tinycolor2";
@@ -1437,8 +1436,11 @@ var style = {
1437
1436
  }
1438
1437
  };
1439
1438
 
1439
+ // lib/nanoid.js
1440
+ import { customAlphabet } from "nanoid";
1441
+ var generate = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz", 8);
1442
+
1440
1443
  // index.js
1441
- var nanoid = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz", 8);
1442
1444
  var infinite = 1e300;
1443
1445
  var megabyte = 1024 * 1024;
1444
1446
  var gigabyte = megabyte * 1024;
@@ -2189,11 +2191,11 @@ var drawbridge_default2 = {
2189
2191
  // and repeat STOPs collapse onto the unique { channel, address,
2190
2192
  // organization } index instead of erroring.
2191
2193
  process: ({ context }) => {
2192
- var _a, _b;
2193
- if ((context == null ? void 0 : context.topic) === "email.events") return summariseEvents(context == null ? void 0 : context.data);
2194
+ var _a, _b, _c;
2195
+ if ((context == null ? void 0 : context.topic) === "email.events") return summariseEvents((_a = context == null ? void 0 : context.data) == null ? void 0 : _a.events);
2194
2196
  if ((context == null ? void 0 : context.topic) === "sms.status") return statusCallback(context == null ? void 0 : context.data);
2195
- const keyword = String(((_a = context == null ? void 0 : context.data) == null ? void 0 : _a.Body) || "").trim().toUpperCase();
2196
- const address = toE164((_b = context == null ? void 0 : context.data) == null ? void 0 : _b.From);
2197
+ const keyword = String(((_b = context == null ? void 0 : context.data) == null ? void 0 : _b.Body) || "").trim().toUpperCase();
2198
+ const address = toE164((_c = context == null ? void 0 : context.data) == null ? void 0 : _c.From);
2197
2199
  if (!address) return { message: "Inbound SMS carried no usable sender number.", skipped: true };
2198
2200
  if (STOP_KEYWORDS.includes(keyword)) {
2199
2201
  return {
@@ -2242,8 +2244,18 @@ var drawbridge_default2 = {
2242
2244
  // acceptable because SendGrid only retries a non-2xx, and the cost of a
2243
2245
  // duplicate here is a second buffer row rather than a repeated side
2244
2246
  // effect. Revisit if this ever writes suppressions.
2247
+ //
2248
+ // THE BATCH IS WRAPPED, and it has to be. SendGrid posts a JSON ARRAY
2249
+ // where every other vendor posts an object, and drawbridge-api's
2250
+ // schema/buffer.js declares `data : { bsonType : 'object' }` — which in
2251
+ // JSON Schema does NOT match an array. Writing the array raw fails
2252
+ // validation, answers 500, and puts SendGrid into a retry loop for a
2253
+ // webhook we would never accept.
2254
+ //
2255
+ // Wrapped here rather than widening the schema: `data` stays one shape
2256
+ // for every consumer, and the vendor that is odd carries the oddity.
2245
2257
  receive: ({ channel, payload }) => ({
2246
- data: payload,
2258
+ data: channel === "email" ? { events: payload } : payload,
2247
2259
  provider: { id: channel === "email" ? null : (payload == null ? void 0 : payload.MessageSid) || null }
2248
2260
  }),
2249
2261
  // TWILIO'S SCHEME, from docs.twilio.com/usage/security: take the full
@@ -2578,8 +2590,8 @@ var drawbridge_default2 = {
2578
2590
  // owner is not a member document, so a solo merchant has nothing to
2579
2591
  // pick and could never save the step.
2580
2592
  members: { of: "string", type: "array" },
2581
- message: { required: true, type: "string" },
2582
- subject: { required: true, type: "string" }
2593
+ message: { max: 2e3, required: true, type: "string" },
2594
+ subject: { max: 150, required: true, type: "string" }
2583
2595
  },
2584
2596
  triggers: ["schedule.day", "schedule.week", "schedule.month"],
2585
2597
  usage: { actions: 0 }
@@ -2602,8 +2614,8 @@ var drawbridge_default2 = {
2602
2614
  queue: "notification",
2603
2615
  settings: {
2604
2616
  members: { of: "string", type: "array" },
2605
- message: { type: "string" },
2606
- subject: { type: "string" }
2617
+ message: { max: 2e3, type: "string" },
2618
+ subject: { max: 150, type: "string" }
2607
2619
  },
2608
2620
  triggers: ["lead.insert"],
2609
2621
  // Zero is a PRICE, and a deliberate one. Declared rather than omitted
@@ -2617,8 +2629,8 @@ var drawbridge_default2 = {
2617
2629
  key: "Email \u2014 Send email",
2618
2630
  queue: "notification",
2619
2631
  settings: {
2620
- message: { required: true, type: "string" },
2621
- subject: { required: true, type: "string" }
2632
+ message: { max: 2e3, required: true, type: "string" },
2633
+ subject: { max: 150, required: true, type: "string" }
2622
2634
  },
2623
2635
  triggers: ["lead.insert"],
2624
2636
  // ONE SOURCE FOR THE PRICE. lib/pricing.js is the index of every
@@ -2647,8 +2659,8 @@ var drawbridge_default2 = {
2647
2659
  key: "Send an SMS",
2648
2660
  queue: "notification",
2649
2661
  settings: {
2650
- message: { required: true, type: "string" },
2651
- subject: { required: true, type: "string" }
2662
+ message: { max: 1600, required: true, type: "string" },
2663
+ subject: { max: 150, required: true, type: "string" }
2652
2664
  },
2653
2665
  // Priced per SEGMENT and billed from the first, which the send
2654
2666
  // resolves from the message length. This is the floor.
package/dist/index.cjs CHANGED
@@ -55,7 +55,6 @@ __export(index_exports, {
55
55
  });
56
56
  module.exports = __toCommonJS(index_exports);
57
57
  var import_currency_codes = require("currency-codes");
58
- var import_nanoid = require("nanoid");
59
58
 
60
59
  // lib/color.js
61
60
  var import_tinycolor2 = __toESM(require("tinycolor2"), 1);
@@ -144,10 +143,24 @@ var constants_default = {
144
143
  rejection: "You have already submitted",
145
144
  email: "You were selected"
146
145
  },
146
+ // THE COPY EVERY DRAW NOTIFICATION SHIPS WITH, and — because no merchant
147
+ // had ever edited it — the copy every winner email had actually been sent
148
+ // with. It is seeded onto the campaign at creation, so changing it here
149
+ // only reaches NEW campaigns; the existing ones are moved by
150
+ // backfillDrawNotifications in drawbridge-api/scripts.js.
151
+ //
152
+ // `message`, not `body`: every other notification in the product names
153
+ // this field message — the workflow step settings, the notification
154
+ // document the draw route writes, and sync's render.notification().
155
+ //
156
+ // Both strings pass the notificationWarnings rules the form applies to
157
+ // the merchant's own copy, which would be a poor rule set if the shipped
158
+ // default failed it. Neither names a brand because a static default
159
+ // cannot know one; the form's brand rule is what asks for that.
147
160
  notifications: {
148
161
  draw: {
149
- subject: "You have been selected",
150
- body: "Thanks for being part of our giveaway"
162
+ subject: "Your prize is ready to claim",
163
+ message: "You were selected in our giveaway. Follow the link to confirm your details and claim your prize."
151
164
  }
152
165
  },
153
166
  settings: {
@@ -285,6 +298,20 @@ var constants_default = {
285
298
  }
286
299
  };
287
300
 
301
+ // lib/nanoid.js
302
+ var import_nanoid = require("nanoid");
303
+ var generate = (0, import_nanoid.customAlphabet)("0123456789abcdefghijklmnopqrstuvwxyz", 8);
304
+ var NOVOWEL = /[bcdfgjklmnpqrstvwxz]{7}/i;
305
+ var ATTEMPTS = 10;
306
+ var nanoid = () => {
307
+ let value = generate();
308
+ for (let attempt = 1; attempt < ATTEMPTS && NOVOWEL.test(value); attempt++) {
309
+ value = generate();
310
+ }
311
+ ;
312
+ return value;
313
+ };
314
+
288
315
  // lib/usage.js
289
316
  var incrementUsageTotals = async ({ controller, usageId, $inc, session }) => {
290
317
  if (!usageId || !$inc) return;
@@ -308,7 +335,6 @@ var incrementUsageTotals = async ({ controller, usageId, $inc, session }) => {
308
335
  var isDuplicateKey = (error) => (error == null ? void 0 : error.code) === 11e3 || (error == null ? void 0 : error.code) === "11000" || /E11000|duplicate key/i.test((error == null ? void 0 : error.message) || "");
309
336
 
310
337
  // index.js
311
- var nanoid = (0, import_nanoid.customAlphabet)("0123456789abcdefghijklmnopqrstuvwxyz", 8);
312
338
  var constants = constants_default;
313
339
  var infinite = 1e300;
314
340
  var isInfinite = (value) => value === infinite;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { data, code } from 'currency-codes';
2
- import { customAlphabet } from 'nanoid';
3
2
  import { colorFormatted, colorAccessible } from './color.cjs';
3
+ export { nanoid } from './nanoid.cjs';
4
4
  export { incrementUsageTotals, isDuplicateKey } from './usage.cjs';
5
5
  import 'tinycolor2';
6
+ import 'nanoid';
6
7
 
7
8
  const font = {
8
9
  family : 'Roboto Flex',
@@ -67,10 +68,24 @@ var constantsData = {
67
68
  rejection : 'You have already submitted',
68
69
  email : 'You were selected'
69
70
  },
71
+ // THE COPY EVERY DRAW NOTIFICATION SHIPS WITH, and — because no merchant
72
+ // had ever edited it — the copy every winner email had actually been sent
73
+ // with. It is seeded onto the campaign at creation, so changing it here
74
+ // only reaches NEW campaigns; the existing ones are moved by
75
+ // backfillDrawNotifications in drawbridge-api/scripts.js.
76
+ //
77
+ // `message`, not `body`: every other notification in the product names
78
+ // this field message — the workflow step settings, the notification
79
+ // document the draw route writes, and sync's render.notification().
80
+ //
81
+ // Both strings pass the notificationWarnings rules the form applies to
82
+ // the merchant's own copy, which would be a poor rule set if the shipped
83
+ // default failed it. Neither names a brand because a static default
84
+ // cannot know one; the form's brand rule is what asks for that.
70
85
  notifications : {
71
86
  draw : {
72
- subject : 'You have been selected',
73
- body : 'Thanks for being part of our giveaway'
87
+ subject : 'Your prize is ready to claim',
88
+ message : 'You were selected in our giveaway. Follow the link to confirm your details and claim your prize.'
74
89
  }
75
90
  },
76
91
  settings : {
@@ -208,8 +223,6 @@ var constantsData = {
208
223
  }
209
224
  };
210
225
 
211
- const nanoid = customAlphabet( '0123456789abcdefghijklmnopqrstuvwxyz', 8 );
212
-
213
226
  const constants = constantsData;
214
227
 
215
228
  const infinite = 1e300;
@@ -441,4 +454,4 @@ const currencies = data.map( ( item ) => ({
441
454
 
442
455
  const currency = ( val ) => code( val );
443
456
 
444
- export { bytesToGB, bytesToMB, capitalize, constants, currencies, currency, expiredPaymentMethod, formatCurrency, formatDateString, formatNumber, getPlanFeature, gigabyte, infinite, isInfinite, megabyte, nanoid, percentage, reducers, regex, shareUrls, urlRoot };
457
+ export { bytesToGB, bytesToMB, capitalize, constants, currencies, currency, expiredPaymentMethod, formatCurrency, formatDateString, formatNumber, getPlanFeature, gigabyte, infinite, isInfinite, megabyte, percentage, reducers, regex, shareUrls, urlRoot };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { data, code } from 'currency-codes';
2
- import { customAlphabet } from 'nanoid';
3
2
  import { colorFormatted, colorAccessible } from './color.js';
3
+ export { nanoid } from './nanoid.js';
4
4
  export { incrementUsageTotals, isDuplicateKey } from './usage.js';
5
5
  import 'tinycolor2';
6
+ import 'nanoid';
6
7
 
7
8
  const font = {
8
9
  family : 'Roboto Flex',
@@ -67,10 +68,24 @@ var constantsData = {
67
68
  rejection : 'You have already submitted',
68
69
  email : 'You were selected'
69
70
  },
71
+ // THE COPY EVERY DRAW NOTIFICATION SHIPS WITH, and — because no merchant
72
+ // had ever edited it — the copy every winner email had actually been sent
73
+ // with. It is seeded onto the campaign at creation, so changing it here
74
+ // only reaches NEW campaigns; the existing ones are moved by
75
+ // backfillDrawNotifications in drawbridge-api/scripts.js.
76
+ //
77
+ // `message`, not `body`: every other notification in the product names
78
+ // this field message — the workflow step settings, the notification
79
+ // document the draw route writes, and sync's render.notification().
80
+ //
81
+ // Both strings pass the notificationWarnings rules the form applies to
82
+ // the merchant's own copy, which would be a poor rule set if the shipped
83
+ // default failed it. Neither names a brand because a static default
84
+ // cannot know one; the form's brand rule is what asks for that.
70
85
  notifications : {
71
86
  draw : {
72
- subject : 'You have been selected',
73
- body : 'Thanks for being part of our giveaway'
87
+ subject : 'Your prize is ready to claim',
88
+ message : 'You were selected in our giveaway. Follow the link to confirm your details and claim your prize.'
74
89
  }
75
90
  },
76
91
  settings : {
@@ -208,8 +223,6 @@ var constantsData = {
208
223
  }
209
224
  };
210
225
 
211
- const nanoid = customAlphabet( '0123456789abcdefghijklmnopqrstuvwxyz', 8 );
212
-
213
226
  const constants = constantsData;
214
227
 
215
228
  const infinite = 1e300;
@@ -441,4 +454,4 @@ const currencies = data.map( ( item ) => ({
441
454
 
442
455
  const currency = ( val ) => code( val );
443
456
 
444
- export { bytesToGB, bytesToMB, capitalize, constants, currencies, currency, expiredPaymentMethod, formatCurrency, formatDateString, formatNumber, getPlanFeature, gigabyte, infinite, isInfinite, megabyte, nanoid, percentage, reducers, regex, shareUrls, urlRoot };
457
+ export { bytesToGB, bytesToMB, capitalize, constants, currencies, currency, expiredPaymentMethod, formatCurrency, formatDateString, formatNumber, getPlanFeature, gigabyte, infinite, isInfinite, megabyte, percentage, reducers, regex, shareUrls, urlRoot };
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  // index.js
2
2
  import { code, data } from "currency-codes";
3
- import { customAlphabet } from "nanoid";
4
3
 
5
4
  // lib/color.js
6
5
  import tinycolor from "tinycolor2";
@@ -89,10 +88,24 @@ var constants_default = {
89
88
  rejection: "You have already submitted",
90
89
  email: "You were selected"
91
90
  },
91
+ // THE COPY EVERY DRAW NOTIFICATION SHIPS WITH, and — because no merchant
92
+ // had ever edited it — the copy every winner email had actually been sent
93
+ // with. It is seeded onto the campaign at creation, so changing it here
94
+ // only reaches NEW campaigns; the existing ones are moved by
95
+ // backfillDrawNotifications in drawbridge-api/scripts.js.
96
+ //
97
+ // `message`, not `body`: every other notification in the product names
98
+ // this field message — the workflow step settings, the notification
99
+ // document the draw route writes, and sync's render.notification().
100
+ //
101
+ // Both strings pass the notificationWarnings rules the form applies to
102
+ // the merchant's own copy, which would be a poor rule set if the shipped
103
+ // default failed it. Neither names a brand because a static default
104
+ // cannot know one; the form's brand rule is what asks for that.
92
105
  notifications: {
93
106
  draw: {
94
- subject: "You have been selected",
95
- body: "Thanks for being part of our giveaway"
107
+ subject: "Your prize is ready to claim",
108
+ message: "You were selected in our giveaway. Follow the link to confirm your details and claim your prize."
96
109
  }
97
110
  },
98
111
  settings: {
@@ -230,6 +243,20 @@ var constants_default = {
230
243
  }
231
244
  };
232
245
 
246
+ // lib/nanoid.js
247
+ import { customAlphabet } from "nanoid";
248
+ var generate = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz", 8);
249
+ var NOVOWEL = /[bcdfgjklmnpqrstvwxz]{7}/i;
250
+ var ATTEMPTS = 10;
251
+ var nanoid = () => {
252
+ let value = generate();
253
+ for (let attempt = 1; attempt < ATTEMPTS && NOVOWEL.test(value); attempt++) {
254
+ value = generate();
255
+ }
256
+ ;
257
+ return value;
258
+ };
259
+
233
260
  // lib/usage.js
234
261
  var incrementUsageTotals = async ({ controller, usageId, $inc, session }) => {
235
262
  if (!usageId || !$inc) return;
@@ -253,7 +280,6 @@ var incrementUsageTotals = async ({ controller, usageId, $inc, session }) => {
253
280
  var isDuplicateKey = (error) => (error == null ? void 0 : error.code) === 11e3 || (error == null ? void 0 : error.code) === "11000" || /E11000|duplicate key/i.test((error == null ? void 0 : error.message) || "");
254
281
 
255
282
  // index.js
256
- var nanoid = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz", 8);
257
283
  var constants = constants_default;
258
284
  var infinite = 1e300;
259
285
  var isInfinite = (value) => value === infinite;
package/dist/nanoid.cjs CHANGED
@@ -24,7 +24,17 @@ __export(nanoid_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(nanoid_exports);
26
26
  var import_nanoid = require("nanoid");
27
- var nanoid = (0, import_nanoid.customAlphabet)("0123456789abcdefghijklmnopqrstuvwxyz", 8);
27
+ var generate = (0, import_nanoid.customAlphabet)("0123456789abcdefghijklmnopqrstuvwxyz", 8);
28
+ var NOVOWEL = /[bcdfgjklmnpqrstvwxz]{7}/i;
29
+ var ATTEMPTS = 10;
30
+ var nanoid = () => {
31
+ let value = generate();
32
+ for (let attempt = 1; attempt < ATTEMPTS && NOVOWEL.test(value); attempt++) {
33
+ value = generate();
34
+ }
35
+ ;
36
+ return value;
37
+ };
28
38
  var DEFAULT_MAX_RETRIES = 5;
29
39
  var retry = async ({
30
40
  field,