@samva/webhooks 0.53.0 → 0.55.0

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/effect.js CHANGED
@@ -1,7 +1,7 @@
1
- import { a as generateWebhookSecret, c as verifyWebhookAt, d as MalformedWebhookPayloadError, f as WebhookCryptoError, g as isKnownEvent, h as WebhookVerificationError, i as WEBHOOK_TIMESTAMP_HEADER, l as InvalidWebhookHeadersError, m as WebhookTimestampError, n as WEBHOOK_ID_HEADER, p as WebhookSignatureError, r as WEBHOOK_SIGNATURE_HEADER, s as signWebhook, t as DEFAULT_TOLERANCE_SECONDS, u as InvalidWebhookSecretError } from "./protocol-Q3-Vd3-K.js";
2
- import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-Du5pts9S.js";
3
- import { ContactConsentChangedEventSchema, ContactCreatedEventSchema, ContactDeletedEventSchema, ContactResubscribedEventSchema, ContactSubscribedEventSchema, ContactUnsubscribedEventSchema, ContactUpdatedEventSchema, ConversationArchivedEventSchema, ConversationCreatedEventSchema, ConversationUpdatedEventSchema, DomainUpdatedEventSchema, DomainWarmingUpdatedEventSchema, EmailSendingPausedEventSchema, EmailSendingResumedEventSchema, FlowRegistrationUpdatedEventSchema, JourneyWebhookEventSchema, MailboxActionPendingApprovalEventSchema, MailboxActionResolvedEventSchema, MailboxMessageDeliveredEventSchema, MailboxMessageDiscardedEventSchema, MailboxMessageFailedEventSchema, MailboxMessageReadEventSchema, MailboxMessageReceivedEventSchema, MailboxMessageSentEventSchema, MailboxMessageSpamEventSchema, MailboxThreadDeletedEventSchema, MessageBouncedEventSchema, MessageClickedEventSchema, MessageComplainedEventSchema, MessageDeliveredEventSchema, MessageFailedEventSchema, MessageOpenedEventSchema, MessageReadEventSchema, MessageReceivedEventSchema, MessageSentEventSchema, SamvaWebhookEventSchema, TemplateRegistrationUpdatedEventSchema, WebhookCreatedEventSchema, WebhookDeletedEventSchema, WebhookTestEventSchema, WebhookUpdatedEventSchema, WhatsappNumberConnectedEventSchema } from "./schemas.gen.js";
4
1
  import { Clock, Effect } from "effect";
2
+ import { a as generateWebhookSecret, c as verifyWebhookAt, d as MalformedWebhookPayloadError, f as WebhookCryptoError, g as isKnownEvent, h as WebhookVerificationError, i as WEBHOOK_TIMESTAMP_HEADER, l as InvalidWebhookHeadersError, m as WebhookTimestampError, n as WEBHOOK_ID_HEADER, p as WebhookSignatureError, r as WEBHOOK_SIGNATURE_HEADER, s as signWebhook, t as DEFAULT_TOLERANCE_SECONDS, u as InvalidWebhookSecretError } from "./protocol-CwGXBskp.js";
3
+ import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-t9dUV5my.js";
4
+ import { ContactConsentChangedEventSchema, ContactCreatedEventSchema, ContactDeletedEventSchema, ContactResubscribedEventSchema, ContactSubscribedEventSchema, ContactUnsubscribedEventSchema, ContactUpdatedEventSchema, ConversationArchivedEventSchema, ConversationCreatedEventSchema, ConversationUpdatedEventSchema, DomainUpdatedEventSchema, DomainWarmingUpdatedEventSchema, EmailSendingPausedEventSchema, EmailSendingResumedEventSchema, FlowRegistrationUpdatedEventSchema, JourneyWebhookEventSchema, MailboxActionPendingApprovalEventSchema, MailboxActionResolvedEventSchema, MailboxMessageDeliveredEventSchema, MailboxMessageDiscardedEventSchema, MailboxMessageFailedEventSchema, MailboxMessageReadEventSchema, MailboxMessageReceivedEventSchema, MailboxMessageSentEventSchema, MailboxMessageSpamEventSchema, MailboxThreadDeletedEventSchema, MessageBouncedEventSchema, MessageClickedEventSchema, MessageComplainedEventSchema, MessageDeliveredEventSchema, MessageFailedEventSchema, MessageOpenedEventSchema, MessageReadEventSchema, MessageReceivedEventSchema, MessageSentEventSchema, SamvaWebhookEventSchema, TemplateRegistrationUpdatedEventSchema, WebhookCreatedEventSchema, WebhookDeletedEventSchema, WebhookTestEventSchema, WebhookUpdatedEventSchema, WhatsappNumberConnectedEventSchema } from "./schemas.gen.js";
5
5
  // src/effect.ts
6
6
  /**
7
7
  * Fails with the verification errors `verifyWebhookAt` rejects with. Any other rejection, such as
@@ -25,7 +25,35 @@ const WebhookEventJsonSchemas = {
25
25
  },
26
26
  status: { anyOf: [{ type: "string" }, { type: "null" }] },
27
27
  metadata: { anyOf: [{ type: "object" }, { type: "null" }] },
28
- cost: { anyOf: [{ type: "number" }, { type: "null" }] },
28
+ cost: { anyOf: [{
29
+ type: "number",
30
+ description: "The cost reported by the SMS provider, when available."
31
+ }, { type: "null" }] },
32
+ estimatedProviderCost: {
33
+ type: "object",
34
+ properties: {
35
+ amount: {
36
+ type: "string",
37
+ pattern: "^\\d+\\.\\d+$"
38
+ },
39
+ currency: { type: "string" },
40
+ category: {
41
+ type: "string",
42
+ enum: [
43
+ "marketing",
44
+ "utility",
45
+ "authentication",
46
+ "service"
47
+ ]
48
+ }
49
+ },
50
+ required: [
51
+ "amount",
52
+ "currency",
53
+ "category"
54
+ ],
55
+ additionalProperties: true
56
+ },
29
57
  recipient: { anyOf: [{ type: "string" }, { type: "null" }] },
30
58
  occurredAt: { anyOf: [{ type: "string" }, { type: "null" }] },
31
59
  failureReason: { anyOf: [{ type: "string" }, { type: "null" }] },
@@ -104,7 +132,35 @@ const WebhookEventJsonSchemas = {
104
132
  },
105
133
  status: { anyOf: [{ type: "string" }, { type: "null" }] },
106
134
  metadata: { anyOf: [{ type: "object" }, { type: "null" }] },
107
- cost: { anyOf: [{ type: "number" }, { type: "null" }] },
135
+ cost: { anyOf: [{
136
+ type: "number",
137
+ description: "The cost reported by the SMS provider, when available."
138
+ }, { type: "null" }] },
139
+ estimatedProviderCost: {
140
+ type: "object",
141
+ properties: {
142
+ amount: {
143
+ type: "string",
144
+ pattern: "^\\d+\\.\\d+$"
145
+ },
146
+ currency: { type: "string" },
147
+ category: {
148
+ type: "string",
149
+ enum: [
150
+ "marketing",
151
+ "utility",
152
+ "authentication",
153
+ "service"
154
+ ]
155
+ }
156
+ },
157
+ required: [
158
+ "amount",
159
+ "currency",
160
+ "category"
161
+ ],
162
+ additionalProperties: true
163
+ },
108
164
  recipient: { anyOf: [{ type: "string" }, { type: "null" }] },
109
165
  occurredAt: { anyOf: [{ type: "string" }, { type: "null" }] },
110
166
  failureReason: { anyOf: [{ type: "string" }, { type: "null" }] },
@@ -183,7 +239,35 @@ const WebhookEventJsonSchemas = {
183
239
  },
184
240
  status: { anyOf: [{ type: "string" }, { type: "null" }] },
185
241
  metadata: { anyOf: [{ type: "object" }, { type: "null" }] },
186
- cost: { anyOf: [{ type: "number" }, { type: "null" }] },
242
+ cost: { anyOf: [{
243
+ type: "number",
244
+ description: "The cost reported by the SMS provider, when available."
245
+ }, { type: "null" }] },
246
+ estimatedProviderCost: {
247
+ type: "object",
248
+ properties: {
249
+ amount: {
250
+ type: "string",
251
+ pattern: "^\\d+\\.\\d+$"
252
+ },
253
+ currency: { type: "string" },
254
+ category: {
255
+ type: "string",
256
+ enum: [
257
+ "marketing",
258
+ "utility",
259
+ "authentication",
260
+ "service"
261
+ ]
262
+ }
263
+ },
264
+ required: [
265
+ "amount",
266
+ "currency",
267
+ "category"
268
+ ],
269
+ additionalProperties: true
270
+ },
187
271
  recipient: { anyOf: [{ type: "string" }, { type: "null" }] },
188
272
  occurredAt: { anyOf: [{ type: "string" }, { type: "null" }] },
189
273
  failureReason: { anyOf: [{ type: "string" }, { type: "null" }] },
@@ -262,7 +346,35 @@ const WebhookEventJsonSchemas = {
262
346
  },
263
347
  status: { anyOf: [{ type: "string" }, { type: "null" }] },
264
348
  metadata: { anyOf: [{ type: "object" }, { type: "null" }] },
265
- cost: { anyOf: [{ type: "number" }, { type: "null" }] },
349
+ cost: { anyOf: [{
350
+ type: "number",
351
+ description: "The cost reported by the SMS provider, when available."
352
+ }, { type: "null" }] },
353
+ estimatedProviderCost: {
354
+ type: "object",
355
+ properties: {
356
+ amount: {
357
+ type: "string",
358
+ pattern: "^\\d+\\.\\d+$"
359
+ },
360
+ currency: { type: "string" },
361
+ category: {
362
+ type: "string",
363
+ enum: [
364
+ "marketing",
365
+ "utility",
366
+ "authentication",
367
+ "service"
368
+ ]
369
+ }
370
+ },
371
+ required: [
372
+ "amount",
373
+ "currency",
374
+ "category"
375
+ ],
376
+ additionalProperties: true
377
+ },
266
378
  recipient: { anyOf: [{ type: "string" }, { type: "null" }] },
267
379
  occurredAt: { anyOf: [{ type: "string" }, { type: "null" }] },
268
380
  failureReason: { anyOf: [{ type: "string" }, { type: "null" }] },
@@ -341,7 +453,35 @@ const WebhookEventJsonSchemas = {
341
453
  },
342
454
  status: { anyOf: [{ type: "string" }, { type: "null" }] },
343
455
  metadata: { anyOf: [{ type: "object" }, { type: "null" }] },
344
- cost: { anyOf: [{ type: "number" }, { type: "null" }] },
456
+ cost: { anyOf: [{
457
+ type: "number",
458
+ description: "The cost reported by the SMS provider, when available."
459
+ }, { type: "null" }] },
460
+ estimatedProviderCost: {
461
+ type: "object",
462
+ properties: {
463
+ amount: {
464
+ type: "string",
465
+ pattern: "^\\d+\\.\\d+$"
466
+ },
467
+ currency: { type: "string" },
468
+ category: {
469
+ type: "string",
470
+ enum: [
471
+ "marketing",
472
+ "utility",
473
+ "authentication",
474
+ "service"
475
+ ]
476
+ }
477
+ },
478
+ required: [
479
+ "amount",
480
+ "currency",
481
+ "category"
482
+ ],
483
+ additionalProperties: true
484
+ },
345
485
  recipient: { type: "string" },
346
486
  occurredAt: { type: "string" },
347
487
  failureReason: { anyOf: [{ type: "string" }, { type: "null" }] },
@@ -422,7 +562,35 @@ const WebhookEventJsonSchemas = {
422
562
  },
423
563
  status: { anyOf: [{ type: "string" }, { type: "null" }] },
424
564
  metadata: { anyOf: [{ type: "object" }, { type: "null" }] },
425
- cost: { anyOf: [{ type: "number" }, { type: "null" }] },
565
+ cost: { anyOf: [{
566
+ type: "number",
567
+ description: "The cost reported by the SMS provider, when available."
568
+ }, { type: "null" }] },
569
+ estimatedProviderCost: {
570
+ type: "object",
571
+ properties: {
572
+ amount: {
573
+ type: "string",
574
+ pattern: "^\\d+\\.\\d+$"
575
+ },
576
+ currency: { type: "string" },
577
+ category: {
578
+ type: "string",
579
+ enum: [
580
+ "marketing",
581
+ "utility",
582
+ "authentication",
583
+ "service"
584
+ ]
585
+ }
586
+ },
587
+ required: [
588
+ "amount",
589
+ "currency",
590
+ "category"
591
+ ],
592
+ additionalProperties: true
593
+ },
426
594
  recipient: { type: "string" },
427
595
  occurredAt: { type: "string" },
428
596
  failureReason: { anyOf: [{ type: "string" }, { type: "null" }] },
@@ -503,7 +671,35 @@ const WebhookEventJsonSchemas = {
503
671
  },
504
672
  status: { anyOf: [{ type: "string" }, { type: "null" }] },
505
673
  metadata: { anyOf: [{ type: "object" }, { type: "null" }] },
506
- cost: { anyOf: [{ type: "number" }, { type: "null" }] },
674
+ cost: { anyOf: [{
675
+ type: "number",
676
+ description: "The cost reported by the SMS provider, when available."
677
+ }, { type: "null" }] },
678
+ estimatedProviderCost: {
679
+ type: "object",
680
+ properties: {
681
+ amount: {
682
+ type: "string",
683
+ pattern: "^\\d+\\.\\d+$"
684
+ },
685
+ currency: { type: "string" },
686
+ category: {
687
+ type: "string",
688
+ enum: [
689
+ "marketing",
690
+ "utility",
691
+ "authentication",
692
+ "service"
693
+ ]
694
+ }
695
+ },
696
+ required: [
697
+ "amount",
698
+ "currency",
699
+ "category"
700
+ ],
701
+ additionalProperties: true
702
+ },
507
703
  recipient: { anyOf: [{ type: "string" }, { type: "null" }] },
508
704
  occurredAt: { anyOf: [{ type: "string" }, { type: "null" }] },
509
705
  failureReason: { anyOf: [{ type: "string" }, { type: "null" }] },
@@ -2599,28 +2795,28 @@ const WebhookEventJsonSchemas = {
2599
2795
  observed: { type: "boolean" },
2600
2796
  total: {
2601
2797
  type: "integer",
2602
- minimum: -9007199254740991,
2603
- maximum: 9007199254740991
2798
+ minimum: -0x1fffffffffffff,
2799
+ maximum: 0x1fffffffffffff
2604
2800
  },
2605
2801
  satisfied: {
2606
2802
  type: "integer",
2607
- minimum: -9007199254740991,
2608
- maximum: 9007199254740991
2803
+ minimum: -0x1fffffffffffff,
2804
+ maximum: 0x1fffffffffffff
2609
2805
  },
2610
2806
  missing: {
2611
2807
  type: "integer",
2612
- minimum: -9007199254740991,
2613
- maximum: 9007199254740991
2808
+ minimum: -0x1fffffffffffff,
2809
+ maximum: 0x1fffffffffffff
2614
2810
  },
2615
2811
  mismatch: {
2616
2812
  type: "integer",
2617
- minimum: -9007199254740991,
2618
- maximum: 9007199254740991
2813
+ minimum: -0x1fffffffffffff,
2814
+ maximum: 0x1fffffffffffff
2619
2815
  },
2620
2816
  unknown: {
2621
2817
  type: "integer",
2622
- minimum: -9007199254740991,
2623
- maximum: 9007199254740991
2818
+ minimum: -0x1fffffffffffff,
2819
+ maximum: 0x1fffffffffffff
2624
2820
  }
2625
2821
  },
2626
2822
  required: [
@@ -3054,8 +3250,8 @@ const WebhookEventJsonSchemas = {
3054
3250
  },
3055
3251
  versionNumber: {
3056
3252
  type: "integer",
3057
- minimum: -9007199254740991,
3058
- maximum: 9007199254740991
3253
+ minimum: -0x1fffffffffffff,
3254
+ maximum: 0x1fffffffffffff
3059
3255
  },
3060
3256
  wabaId: { type: "string" },
3061
3257
  providerFlowId: { anyOf: [{ type: "string" }, { type: "null" }] },
@@ -3080,13 +3276,13 @@ const WebhookEventJsonSchemas = {
3080
3276
  path: { type: "string" },
3081
3277
  line: {
3082
3278
  type: "integer",
3083
- minimum: -9007199254740991,
3084
- maximum: 9007199254740991
3279
+ minimum: -0x1fffffffffffff,
3280
+ maximum: 0x1fffffffffffff
3085
3281
  },
3086
3282
  column: {
3087
3283
  type: "integer",
3088
- minimum: -9007199254740991,
3089
- maximum: 9007199254740991
3284
+ minimum: -0x1fffffffffffff,
3285
+ maximum: 0x1fffffffffffff
3090
3286
  }
3091
3287
  },
3092
3288
  required: ["error", "message"],
@@ -3615,7 +3811,7 @@ const WebhookEventJsonSchemas = {
3615
3811
  },
3616
3812
  reviewRound: {
3617
3813
  type: "integer",
3618
- maximum: 9007199254740991,
3814
+ maximum: 0x1fffffffffffff,
3619
3815
  exclusiveMinimum: 0
3620
3816
  },
3621
3817
  state: {
@@ -3632,7 +3828,7 @@ const WebhookEventJsonSchemas = {
3632
3828
  },
3633
3829
  reviewRound: {
3634
3830
  type: "integer",
3635
- maximum: 9007199254740991,
3831
+ maximum: 0x1fffffffffffff,
3636
3832
  exclusiveMinimum: 0
3637
3833
  },
3638
3834
  requirement: {
@@ -3716,7 +3912,7 @@ const WebhookEventJsonSchemas = {
3716
3912
  index: {
3717
3913
  type: "integer",
3718
3914
  minimum: 0,
3719
- maximum: 9007199254740991
3915
+ maximum: 0x1fffffffffffff
3720
3916
  }
3721
3917
  },
3722
3918
  required: ["scope", "index"],
@@ -3952,7 +4148,7 @@ const WebhookEventJsonSchemas = {
3952
4148
  },
3953
4149
  reviewRound: {
3954
4150
  type: "integer",
3955
- maximum: 9007199254740991,
4151
+ maximum: 0x1fffffffffffff,
3956
4152
  exclusiveMinimum: 0
3957
4153
  },
3958
4154
  threadId: { anyOf: [{
@@ -4583,8 +4779,8 @@ const WebhookEventJsonSchemas = {
4583
4779
  },
4584
4780
  journeyVersion: {
4585
4781
  type: "integer",
4586
- minimum: -9007199254740991,
4587
- maximum: 9007199254740991
4782
+ minimum: -0x1fffffffffffff,
4783
+ maximum: 0x1fffffffffffff
4588
4784
  },
4589
4785
  runId: {
4590
4786
  type: "string",
@@ -4632,4 +4828,4 @@ const WebhookEventJsonSchemas = {
4632
4828
  };
4633
4829
  export { WebhookEventJsonSchemas as t };
4634
4830
 
4635
- //# sourceMappingURL=json-schemas.gen-Du5pts9S.js.map
4831
+ //# sourceMappingURL=json-schemas.gen-t9dUV5my.js.map
package/dist/promise.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a as generateWebhookSecret, c as verifyWebhookAt, d as MalformedWebhookPayloadError, f as WebhookCryptoError, g as isKnownEvent, h as WebhookVerificationError, i as WEBHOOK_TIMESTAMP_HEADER, l as InvalidWebhookHeadersError, m as WebhookTimestampError, n as WEBHOOK_ID_HEADER, o as readWebhookHeaders, p as WebhookSignatureError, r as WEBHOOK_SIGNATURE_HEADER, s as signWebhook, t as DEFAULT_TOLERANCE_SECONDS, u as InvalidWebhookSecretError } from "./protocol-Q3-Vd3-K.js";
2
- import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-Du5pts9S.js";
1
+ import { a as generateWebhookSecret, c as verifyWebhookAt, d as MalformedWebhookPayloadError, f as WebhookCryptoError, g as isKnownEvent, h as WebhookVerificationError, i as WEBHOOK_TIMESTAMP_HEADER, l as InvalidWebhookHeadersError, m as WebhookTimestampError, n as WEBHOOK_ID_HEADER, o as readWebhookHeaders, p as WebhookSignatureError, r as WEBHOOK_SIGNATURE_HEADER, s as signWebhook, t as DEFAULT_TOLERANCE_SECONDS, u as InvalidWebhookSecretError } from "./protocol-CwGXBskp.js";
2
+ import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-t9dUV5my.js";
3
3
  // src/promise.ts
4
4
  /**
5
5
  * Verifies a Samva webhook delivery from its body and header values, then returns its ID and