@adatechnology/meta-whatsapp-contracts 0.2.0 → 0.3.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.
@@ -552,6 +552,34 @@ declare const whatsAppPhoneNumberQualityUpdateSchema: z.ZodObject<{
552
552
  old_limit?: string | undefined;
553
553
  }>;
554
554
  type WhatsAppPhoneNumberQualityUpdate = z.infer<typeof whatsAppPhoneNumberQualityUpdateSchema>;
555
+ /**
556
+ * O contato que a Meta manda junto das mensagens. `profile.name` é o nome que a PESSOA escolheu no
557
+ * WhatsApp dela — é o único nome que existe antes de alguém digitar um, e sem ele o cliente criado
558
+ * por mensagem nasce sem nome nenhum.
559
+ *
560
+ * `profile` é opcional: a pessoa pode não ter nome definido, e a Meta omite o objeto nesse caso.
561
+ */
562
+ declare const whatsAppContactSchema: z.ZodObject<{
563
+ wa_id: z.ZodString;
564
+ profile: z.ZodOptional<z.ZodObject<{
565
+ name: z.ZodString;
566
+ }, "strip", z.ZodTypeAny, {
567
+ name: string;
568
+ }, {
569
+ name: string;
570
+ }>>;
571
+ }, "strip", z.ZodTypeAny, {
572
+ wa_id: string;
573
+ profile?: {
574
+ name: string;
575
+ } | undefined;
576
+ }, {
577
+ wa_id: string;
578
+ profile?: {
579
+ name: string;
580
+ } | undefined;
581
+ }>;
582
+ type WhatsAppContact = z.infer<typeof whatsAppContactSchema>;
555
583
  declare const whatsAppWebhookValueSchema: z.ZodObject<{
556
584
  messaging_product: z.ZodOptional<z.ZodString>;
557
585
  messages: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -915,6 +943,26 @@ declare const whatsAppWebhookValueSchema: z.ZodObject<{
915
943
  } | undefined;
916
944
  } | undefined;
917
945
  }>, "many">>;
946
+ contacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
947
+ wa_id: z.ZodString;
948
+ profile: z.ZodOptional<z.ZodObject<{
949
+ name: z.ZodString;
950
+ }, "strip", z.ZodTypeAny, {
951
+ name: string;
952
+ }, {
953
+ name: string;
954
+ }>>;
955
+ }, "strip", z.ZodTypeAny, {
956
+ wa_id: string;
957
+ profile?: {
958
+ name: string;
959
+ } | undefined;
960
+ }, {
961
+ wa_id: string;
962
+ profile?: {
963
+ name: string;
964
+ } | undefined;
965
+ }>, "many">>;
918
966
  message_echoes: z.ZodOptional<z.ZodArray<z.ZodObject<{
919
967
  id: z.ZodString;
920
968
  from: z.ZodString;
@@ -1320,6 +1368,26 @@ declare const whatsAppWebhookValueSchema: z.ZodObject<{
1320
1368
  } | undefined;
1321
1369
  } | undefined;
1322
1370
  }>, "many">>;
1371
+ contacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
1372
+ wa_id: z.ZodString;
1373
+ profile: z.ZodOptional<z.ZodObject<{
1374
+ name: z.ZodString;
1375
+ }, "strip", z.ZodTypeAny, {
1376
+ name: string;
1377
+ }, {
1378
+ name: string;
1379
+ }>>;
1380
+ }, "strip", z.ZodTypeAny, {
1381
+ wa_id: string;
1382
+ profile?: {
1383
+ name: string;
1384
+ } | undefined;
1385
+ }, {
1386
+ wa_id: string;
1387
+ profile?: {
1388
+ name: string;
1389
+ } | undefined;
1390
+ }>, "many">>;
1323
1391
  message_echoes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1324
1392
  id: z.ZodString;
1325
1393
  from: z.ZodString;
@@ -1725,6 +1793,26 @@ declare const whatsAppWebhookValueSchema: z.ZodObject<{
1725
1793
  } | undefined;
1726
1794
  } | undefined;
1727
1795
  }>, "many">>;
1796
+ contacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
1797
+ wa_id: z.ZodString;
1798
+ profile: z.ZodOptional<z.ZodObject<{
1799
+ name: z.ZodString;
1800
+ }, "strip", z.ZodTypeAny, {
1801
+ name: string;
1802
+ }, {
1803
+ name: string;
1804
+ }>>;
1805
+ }, "strip", z.ZodTypeAny, {
1806
+ wa_id: string;
1807
+ profile?: {
1808
+ name: string;
1809
+ } | undefined;
1810
+ }, {
1811
+ wa_id: string;
1812
+ profile?: {
1813
+ name: string;
1814
+ } | undefined;
1815
+ }>, "many">>;
1728
1816
  message_echoes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1729
1817
  id: z.ZodString;
1730
1818
  from: z.ZodString;
@@ -2134,6 +2222,26 @@ declare const whatsAppWebhookChangeSchema: z.ZodObject<{
2134
2222
  } | undefined;
2135
2223
  } | undefined;
2136
2224
  }>, "many">>;
2225
+ contacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
2226
+ wa_id: z.ZodString;
2227
+ profile: z.ZodOptional<z.ZodObject<{
2228
+ name: z.ZodString;
2229
+ }, "strip", z.ZodTypeAny, {
2230
+ name: string;
2231
+ }, {
2232
+ name: string;
2233
+ }>>;
2234
+ }, "strip", z.ZodTypeAny, {
2235
+ wa_id: string;
2236
+ profile?: {
2237
+ name: string;
2238
+ } | undefined;
2239
+ }, {
2240
+ wa_id: string;
2241
+ profile?: {
2242
+ name: string;
2243
+ } | undefined;
2244
+ }>, "many">>;
2137
2245
  message_echoes: z.ZodOptional<z.ZodArray<z.ZodObject<{
2138
2246
  id: z.ZodString;
2139
2247
  from: z.ZodString;
@@ -2539,6 +2647,26 @@ declare const whatsAppWebhookChangeSchema: z.ZodObject<{
2539
2647
  } | undefined;
2540
2648
  } | undefined;
2541
2649
  }>, "many">>;
2650
+ contacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
2651
+ wa_id: z.ZodString;
2652
+ profile: z.ZodOptional<z.ZodObject<{
2653
+ name: z.ZodString;
2654
+ }, "strip", z.ZodTypeAny, {
2655
+ name: string;
2656
+ }, {
2657
+ name: string;
2658
+ }>>;
2659
+ }, "strip", z.ZodTypeAny, {
2660
+ wa_id: string;
2661
+ profile?: {
2662
+ name: string;
2663
+ } | undefined;
2664
+ }, {
2665
+ wa_id: string;
2666
+ profile?: {
2667
+ name: string;
2668
+ } | undefined;
2669
+ }>, "many">>;
2542
2670
  message_echoes: z.ZodOptional<z.ZodArray<z.ZodObject<{
2543
2671
  id: z.ZodString;
2544
2672
  from: z.ZodString;
@@ -2944,6 +3072,26 @@ declare const whatsAppWebhookChangeSchema: z.ZodObject<{
2944
3072
  } | undefined;
2945
3073
  } | undefined;
2946
3074
  }>, "many">>;
3075
+ contacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
3076
+ wa_id: z.ZodString;
3077
+ profile: z.ZodOptional<z.ZodObject<{
3078
+ name: z.ZodString;
3079
+ }, "strip", z.ZodTypeAny, {
3080
+ name: string;
3081
+ }, {
3082
+ name: string;
3083
+ }>>;
3084
+ }, "strip", z.ZodTypeAny, {
3085
+ wa_id: string;
3086
+ profile?: {
3087
+ name: string;
3088
+ } | undefined;
3089
+ }, {
3090
+ wa_id: string;
3091
+ profile?: {
3092
+ name: string;
3093
+ } | undefined;
3094
+ }>, "many">>;
2947
3095
  message_echoes: z.ZodOptional<z.ZodArray<z.ZodObject<{
2948
3096
  id: z.ZodString;
2949
3097
  from: z.ZodString;
@@ -3069,6 +3217,12 @@ declare const whatsAppWebhookChangeSchema: z.ZodObject<{
3069
3217
  timestamp: string;
3070
3218
  }[] | undefined;
3071
3219
  messaging_product?: string | undefined;
3220
+ contacts?: {
3221
+ wa_id: string;
3222
+ profile?: {
3223
+ name: string;
3224
+ } | undefined;
3225
+ }[] | undefined;
3072
3226
  statuses?: {
3073
3227
  id: string;
3074
3228
  status: "sent" | "delivered" | "read" | "failed";
@@ -3165,6 +3319,12 @@ declare const whatsAppWebhookChangeSchema: z.ZodObject<{
3165
3319
  timestamp: string;
3166
3320
  }[] | undefined;
3167
3321
  messaging_product?: string | undefined;
3322
+ contacts?: {
3323
+ wa_id: string;
3324
+ profile?: {
3325
+ name: string;
3326
+ } | undefined;
3327
+ }[] | undefined;
3168
3328
  statuses?: {
3169
3329
  id: string;
3170
3330
  status: "sent" | "delivered" | "read" | "failed";
@@ -3550,6 +3710,26 @@ declare const whatsAppWebhookPayloadSchema: z.ZodObject<{
3550
3710
  } | undefined;
3551
3711
  } | undefined;
3552
3712
  }>, "many">>;
3713
+ contacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
3714
+ wa_id: z.ZodString;
3715
+ profile: z.ZodOptional<z.ZodObject<{
3716
+ name: z.ZodString;
3717
+ }, "strip", z.ZodTypeAny, {
3718
+ name: string;
3719
+ }, {
3720
+ name: string;
3721
+ }>>;
3722
+ }, "strip", z.ZodTypeAny, {
3723
+ wa_id: string;
3724
+ profile?: {
3725
+ name: string;
3726
+ } | undefined;
3727
+ }, {
3728
+ wa_id: string;
3729
+ profile?: {
3730
+ name: string;
3731
+ } | undefined;
3732
+ }>, "many">>;
3553
3733
  message_echoes: z.ZodOptional<z.ZodArray<z.ZodObject<{
3554
3734
  id: z.ZodString;
3555
3735
  from: z.ZodString;
@@ -3955,6 +4135,26 @@ declare const whatsAppWebhookPayloadSchema: z.ZodObject<{
3955
4135
  } | undefined;
3956
4136
  } | undefined;
3957
4137
  }>, "many">>;
4138
+ contacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
4139
+ wa_id: z.ZodString;
4140
+ profile: z.ZodOptional<z.ZodObject<{
4141
+ name: z.ZodString;
4142
+ }, "strip", z.ZodTypeAny, {
4143
+ name: string;
4144
+ }, {
4145
+ name: string;
4146
+ }>>;
4147
+ }, "strip", z.ZodTypeAny, {
4148
+ wa_id: string;
4149
+ profile?: {
4150
+ name: string;
4151
+ } | undefined;
4152
+ }, {
4153
+ wa_id: string;
4154
+ profile?: {
4155
+ name: string;
4156
+ } | undefined;
4157
+ }>, "many">>;
3958
4158
  message_echoes: z.ZodOptional<z.ZodArray<z.ZodObject<{
3959
4159
  id: z.ZodString;
3960
4160
  from: z.ZodString;
@@ -4360,6 +4560,26 @@ declare const whatsAppWebhookPayloadSchema: z.ZodObject<{
4360
4560
  } | undefined;
4361
4561
  } | undefined;
4362
4562
  }>, "many">>;
4563
+ contacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
4564
+ wa_id: z.ZodString;
4565
+ profile: z.ZodOptional<z.ZodObject<{
4566
+ name: z.ZodString;
4567
+ }, "strip", z.ZodTypeAny, {
4568
+ name: string;
4569
+ }, {
4570
+ name: string;
4571
+ }>>;
4572
+ }, "strip", z.ZodTypeAny, {
4573
+ wa_id: string;
4574
+ profile?: {
4575
+ name: string;
4576
+ } | undefined;
4577
+ }, {
4578
+ wa_id: string;
4579
+ profile?: {
4580
+ name: string;
4581
+ } | undefined;
4582
+ }>, "many">>;
4363
4583
  message_echoes: z.ZodOptional<z.ZodArray<z.ZodObject<{
4364
4584
  id: z.ZodString;
4365
4585
  from: z.ZodString;
@@ -4485,6 +4705,12 @@ declare const whatsAppWebhookPayloadSchema: z.ZodObject<{
4485
4705
  timestamp: string;
4486
4706
  }[] | undefined;
4487
4707
  messaging_product?: string | undefined;
4708
+ contacts?: {
4709
+ wa_id: string;
4710
+ profile?: {
4711
+ name: string;
4712
+ } | undefined;
4713
+ }[] | undefined;
4488
4714
  statuses?: {
4489
4715
  id: string;
4490
4716
  status: "sent" | "delivered" | "read" | "failed";
@@ -4581,6 +4807,12 @@ declare const whatsAppWebhookPayloadSchema: z.ZodObject<{
4581
4807
  timestamp: string;
4582
4808
  }[] | undefined;
4583
4809
  messaging_product?: string | undefined;
4810
+ contacts?: {
4811
+ wa_id: string;
4812
+ profile?: {
4813
+ name: string;
4814
+ } | undefined;
4815
+ }[] | undefined;
4584
4816
  statuses?: {
4585
4817
  id: string;
4586
4818
  status: "sent" | "delivered" | "read" | "failed";
@@ -4680,6 +4912,12 @@ declare const whatsAppWebhookPayloadSchema: z.ZodObject<{
4680
4912
  timestamp: string;
4681
4913
  }[] | undefined;
4682
4914
  messaging_product?: string | undefined;
4915
+ contacts?: {
4916
+ wa_id: string;
4917
+ profile?: {
4918
+ name: string;
4919
+ } | undefined;
4920
+ }[] | undefined;
4683
4921
  statuses?: {
4684
4922
  id: string;
4685
4923
  status: "sent" | "delivered" | "read" | "failed";
@@ -4779,6 +5017,12 @@ declare const whatsAppWebhookPayloadSchema: z.ZodObject<{
4779
5017
  timestamp: string;
4780
5018
  }[] | undefined;
4781
5019
  messaging_product?: string | undefined;
5020
+ contacts?: {
5021
+ wa_id: string;
5022
+ profile?: {
5023
+ name: string;
5024
+ } | undefined;
5025
+ }[] | undefined;
4782
5026
  statuses?: {
4783
5027
  id: string;
4784
5028
  status: "sent" | "delivered" | "read" | "failed";
@@ -4881,6 +5125,12 @@ declare const whatsAppWebhookPayloadSchema: z.ZodObject<{
4881
5125
  timestamp: string;
4882
5126
  }[] | undefined;
4883
5127
  messaging_product?: string | undefined;
5128
+ contacts?: {
5129
+ wa_id: string;
5130
+ profile?: {
5131
+ name: string;
5132
+ } | undefined;
5133
+ }[] | undefined;
4884
5134
  statuses?: {
4885
5135
  id: string;
4886
5136
  status: "sent" | "delivered" | "read" | "failed";
@@ -4983,6 +5233,12 @@ declare const whatsAppWebhookPayloadSchema: z.ZodObject<{
4983
5233
  timestamp: string;
4984
5234
  }[] | undefined;
4985
5235
  messaging_product?: string | undefined;
5236
+ contacts?: {
5237
+ wa_id: string;
5238
+ profile?: {
5239
+ name: string;
5240
+ } | undefined;
5241
+ }[] | undefined;
4986
5242
  statuses?: {
4987
5243
  id: string;
4988
5244
  status: "sent" | "delivered" | "read" | "failed";
@@ -5001,5 +5257,19 @@ declare const whatsAppWebhookPayloadSchema: z.ZodObject<{
5001
5257
  }[];
5002
5258
  }>;
5003
5259
  type WhatsAppWebhookPayload = z.infer<typeof whatsAppWebhookPayloadSchema>;
5260
+ /**
5261
+ * O nome de perfil de quem mandou a mensagem.
5262
+ *
5263
+ * Casa por `wa_id`. Quando nenhum casa e há UM contato só, é dele: a Meta agrupa as mensagens de um
5264
+ * mesmo contato num `change`, e o `wa_id` nem sempre é idêntico ao `from` — no Brasil o nono dígito
5265
+ * aparece num e não no outro, e exigir igualdade perderia o nome exatamente nos números móveis.
5266
+ *
5267
+ * Com dois ou mais contatos sem casamento, devolve `undefined`: pendurar o nome errado numa ficha é
5268
+ * pior que ficha sem nome.
5269
+ */
5270
+ declare function resolveContactProfileName(params: {
5271
+ readonly contacts: readonly WhatsAppContact[] | undefined;
5272
+ readonly from: string;
5273
+ }): string | undefined;
5004
5274
 
5005
- export { whatsAppWebhookChangeSchema as A, whatsAppWebhookPayloadSchema as B, whatsAppWebhookValueSchema as C, WHATSAPP_WEBHOOK_FIELDS as W, type WhatsAppInteractive as a, type WhatsAppMedia as b, type WhatsAppMessage as c, type WhatsAppMessageEcho as d, type WhatsAppMessageStatusValue as e, type WhatsAppOrder as f, type WhatsAppPhoneNumberQualityUpdate as g, type WhatsAppQualityEvent as h, type WhatsAppStatus as i, type WhatsAppTemplateStatusEvent as j, type WhatsAppTemplateStatusUpdate as k, type WhatsAppWebhookChange as l, type WhatsAppWebhookField as m, type WhatsAppWebhookPayload as n, type WhatsAppWebhookValue as o, whatsAppMediaSchema as p, whatsAppMessageEchoSchema as q, whatsAppMessageSchema as r, whatsAppMessageStatusSchema as s, whatsAppOrderSchema as t, whatsAppPhoneNumberQualityUpdateSchema as u, whatsAppQualityEventSchema as v, whatsAppInteractiveSchema as w, whatsAppStatusSchema as x, whatsAppTemplateStatusEventSchema as y, whatsAppTemplateStatusUpdateSchema as z };
5275
+ export { whatsAppStatusSchema as A, whatsAppTemplateStatusEventSchema as B, whatsAppTemplateStatusUpdateSchema as C, whatsAppWebhookChangeSchema as D, whatsAppWebhookPayloadSchema as E, whatsAppWebhookValueSchema as F, WHATSAPP_WEBHOOK_FIELDS as W, type WhatsAppContact as a, type WhatsAppInteractive as b, type WhatsAppMedia as c, type WhatsAppMessage as d, type WhatsAppMessageEcho as e, type WhatsAppMessageStatusValue as f, type WhatsAppOrder as g, type WhatsAppPhoneNumberQualityUpdate as h, type WhatsAppQualityEvent as i, type WhatsAppStatus as j, type WhatsAppTemplateStatusEvent as k, type WhatsAppTemplateStatusUpdate as l, type WhatsAppWebhookChange as m, type WhatsAppWebhookField as n, type WhatsAppWebhookPayload as o, type WhatsAppWebhookValue as p, whatsAppInteractiveSchema as q, resolveContactProfileName as r, whatsAppMediaSchema as s, whatsAppMessageEchoSchema as t, whatsAppMessageSchema as u, whatsAppMessageStatusSchema as v, whatsAppContactSchema as w, whatsAppOrderSchema as x, whatsAppPhoneNumberQualityUpdateSchema as y, whatsAppQualityEventSchema as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adatechnology/meta-whatsapp-contracts",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Shared types, zod schemas, and port interfaces for the meta-whatsapp trio (contracts only — no runtime behavior)",
5
5
  "publishConfig": {
6
6
  "access": "public"