@samva/webhooks 0.52.0 → 0.54.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,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, p as WebhookSignatureError, r as WEBHOOK_SIGNATURE_HEADER, s as signWebhook, t as DEFAULT_TOLERANCE_SECONDS, u as InvalidWebhookSecretError } from "./protocol-COaro8fP.js";
2
- import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-CE5C7st9.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, p as WebhookSignatureError, r as WEBHOOK_SIGNATURE_HEADER, s as signWebhook, t as DEFAULT_TOLERANCE_SECONDS, u as InvalidWebhookSecretError } from "./protocol-DwRceAlj.js";
2
+ import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-Ck8UIxoX.js";
3
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
4
  import { Clock, Effect } from "effect";
5
5
  // src/effect.ts
@@ -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" }] },
@@ -579,9 +775,14 @@ const WebhookEventJsonSchemas = {
579
775
  required: ["campaignId", "runId"],
580
776
  additionalProperties: true
581
777
  }, { type: "null" }] },
778
+ replyToMetadata: { type: "object" },
582
779
  whatsapp: { anyOf: [{
583
780
  type: "object",
584
781
  properties: {
782
+ appHandlesFlowSubmission: {
783
+ type: "boolean",
784
+ enum: [true]
785
+ },
585
786
  text: { anyOf: [{ type: "string" }, { type: "null" }] },
586
787
  template: { anyOf: [{
587
788
  type: "object",
@@ -675,7 +876,10 @@ const WebhookEventJsonSchemas = {
675
876
  coupon_code: { anyOf: [{ type: "string" }, { type: "null" }] },
676
877
  action: { anyOf: [{
677
878
  type: "object",
678
- properties: { flow_token: { type: "string" } },
879
+ properties: {
880
+ flow_token: { type: "string" },
881
+ flow_action_data: { type: "object" }
882
+ },
679
883
  required: ["flow_token"],
680
884
  additionalProperties: true
681
885
  }, { type: "null" }] }
@@ -1354,6 +1558,10 @@ const WebhookEventJsonSchemas = {
1354
1558
  type: "object",
1355
1559
  properties: {
1356
1560
  flowToken: { anyOf: [{ type: "string" }, { type: "null" }] },
1561
+ submissionHandler: {
1562
+ type: "string",
1563
+ enum: ["app"]
1564
+ },
1357
1565
  response: { type: "object" },
1358
1566
  body: { type: "string" }
1359
1567
  },
@@ -3246,6 +3454,10 @@ const WebhookEventJsonSchemas = {
3246
3454
  message: {
3247
3455
  type: "object",
3248
3456
  properties: {
3457
+ flowSubmissionHandledBy: {
3458
+ type: "string",
3459
+ enum: ["app"]
3460
+ },
3249
3461
  id: {
3250
3462
  type: "string",
3251
3463
  pattern: "^msg_[0-9a-hjkmnp-tv-z]{16,24}$"
@@ -3444,6 +3656,10 @@ const WebhookEventJsonSchemas = {
3444
3656
  message: {
3445
3657
  type: "object",
3446
3658
  properties: {
3659
+ flowSubmissionHandledBy: {
3660
+ type: "string",
3661
+ enum: ["app"]
3662
+ },
3447
3663
  id: {
3448
3664
  type: "string",
3449
3665
  pattern: "^msg_[0-9a-hjkmnp-tv-z]{16,24}$"
@@ -4612,4 +4828,4 @@ const WebhookEventJsonSchemas = {
4612
4828
  };
4613
4829
  export { WebhookEventJsonSchemas as t };
4614
4830
 
4615
- //# sourceMappingURL=json-schemas.gen-CE5C7st9.js.map
4831
+ //# sourceMappingURL=json-schemas.gen-Ck8UIxoX.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-COaro8fP.js";
2
- import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-CE5C7st9.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-DwRceAlj.js";
2
+ import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-Ck8UIxoX.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