@adtrackify/at-service-common 5.0.7 → 5.1.2

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.
Files changed (1166) hide show
  1. package/dist/cjs/__tests__/clients/acuity-client.spec.d.ts +1 -1
  2. package/dist/cjs/__tests__/clients/acuity-client.spec.js +44 -43
  3. package/dist/cjs/__tests__/clients/acuity-client.spec.js.map +1 -1
  4. package/dist/cjs/__tests__/clients/client-timeout-inventory.spec.d.ts +1 -0
  5. package/dist/cjs/__tests__/clients/client-timeout-inventory.spec.js +21 -0
  6. package/dist/cjs/__tests__/clients/client-timeout-inventory.spec.js.map +1 -0
  7. package/dist/cjs/__tests__/clients/cross-platform-compression.spec.d.ts +1 -1
  8. package/dist/cjs/__tests__/clients/cross-platform-compression.spec.js +365 -354
  9. package/dist/cjs/__tests__/clients/cross-platform-compression.spec.js.map +1 -1
  10. package/dist/cjs/__tests__/clients/dynamodb-client.spec.d.ts +1 -1
  11. package/dist/cjs/__tests__/clients/dynamodb-client.spec.js +193 -194
  12. package/dist/cjs/__tests__/clients/dynamodb-client.spec.js.map +1 -1
  13. package/dist/cjs/__tests__/clients/event-collector-client.spec.d.ts +1 -1
  14. package/dist/cjs/__tests__/clients/event-collector-client.spec.js +227 -227
  15. package/dist/cjs/__tests__/clients/event-collector-client.spec.js.map +1 -1
  16. package/dist/cjs/__tests__/clients/open-exchange-rates-client.spec.d.ts +1 -1
  17. package/dist/cjs/__tests__/clients/open-exchange-rates-client.spec.js +56 -55
  18. package/dist/cjs/__tests__/clients/open-exchange-rates-client.spec.js.map +1 -1
  19. package/dist/cjs/__tests__/clients/redis-client.spec.d.ts +1 -0
  20. package/dist/cjs/__tests__/clients/redis-client.spec.js +79 -0
  21. package/dist/cjs/__tests__/clients/redis-client.spec.js.map +1 -0
  22. package/dist/cjs/__tests__/clients/sqs-bundled-client.spec.d.ts +1 -1
  23. package/dist/cjs/__tests__/clients/sqs-bundled-client.spec.js +949 -931
  24. package/dist/cjs/__tests__/clients/sqs-bundled-client.spec.js.map +1 -1
  25. package/dist/cjs/__tests__/clients/sqs-bundling-contracts.spec.d.ts +1 -1
  26. package/dist/cjs/__tests__/clients/sqs-bundling-contracts.spec.js +575 -563
  27. package/dist/cjs/__tests__/clients/sqs-bundling-contracts.spec.js.map +1 -1
  28. package/dist/cjs/__tests__/clients/sqs-client.spec.d.ts +1 -1
  29. package/dist/cjs/__tests__/clients/sqs-client.spec.js +192 -191
  30. package/dist/cjs/__tests__/clients/sqs-client.spec.js.map +1 -1
  31. package/dist/cjs/__tests__/clients/sqs-unbundle.spec.d.ts +1 -1
  32. package/dist/cjs/__tests__/clients/sqs-unbundle.spec.js +1358 -1357
  33. package/dist/cjs/__tests__/clients/sqs-unbundle.spec.js.map +1 -1
  34. package/dist/cjs/__tests__/db/contact-enrichments-db-service.spec.d.ts +1 -1
  35. package/dist/cjs/__tests__/db/contact-enrichments-db-service.spec.js +69 -68
  36. package/dist/cjs/__tests__/db/contact-enrichments-db-service.spec.js.map +1 -1
  37. package/dist/cjs/__tests__/db/destinations-db-service.spec.d.ts +1 -1
  38. package/dist/cjs/__tests__/db/destinations-db-service.spec.js +123 -125
  39. package/dist/cjs/__tests__/db/destinations-db-service.spec.js.map +1 -1
  40. package/dist/cjs/__tests__/db/products-db-service.spec.d.ts +1 -1
  41. package/dist/cjs/__tests__/db/products-db-service.spec.js +90 -89
  42. package/dist/cjs/__tests__/db/products-db-service.spec.js.map +1 -1
  43. package/dist/cjs/__tests__/db/shared-read-db-services.spec.d.ts +1 -1
  44. package/dist/cjs/__tests__/db/shared-read-db-services.spec.js +90 -89
  45. package/dist/cjs/__tests__/db/shared-read-db-services.spec.js.map +1 -1
  46. package/dist/cjs/__tests__/db/shopify-app-installs-db-service.spec.d.ts +1 -1
  47. package/dist/cjs/__tests__/db/shopify-app-installs-db-service.spec.js +105 -104
  48. package/dist/cjs/__tests__/db/shopify-app-installs-db-service.spec.js.map +1 -1
  49. package/dist/cjs/__tests__/db/subscriptions-db-service.spec.d.ts +1 -1
  50. package/dist/cjs/__tests__/db/subscriptions-db-service.spec.js +96 -95
  51. package/dist/cjs/__tests__/db/subscriptions-db-service.spec.js.map +1 -1
  52. package/dist/cjs/__tests__/db/user-accounts-db-service.spec.d.ts +1 -1
  53. package/dist/cjs/__tests__/db/user-accounts-db-service.spec.js +77 -76
  54. package/dist/cjs/__tests__/db/user-accounts-db-service.spec.js.map +1 -1
  55. package/dist/cjs/__tests__/helpers/account-users-helper.spec.d.ts +1 -1
  56. package/dist/cjs/__tests__/helpers/account-users-helper.spec.js +221 -220
  57. package/dist/cjs/__tests__/helpers/account-users-helper.spec.js.map +1 -1
  58. package/dist/cjs/__tests__/helpers/acuity-helper.spec.d.ts +1 -1
  59. package/dist/cjs/__tests__/helpers/acuity-helper.spec.js +70 -69
  60. package/dist/cjs/__tests__/helpers/acuity-helper.spec.js.map +1 -1
  61. package/dist/cjs/__tests__/helpers/api-key-auth-helper.spec.d.ts +1 -1
  62. package/dist/cjs/__tests__/helpers/api-key-auth-helper.spec.js +83 -82
  63. package/dist/cjs/__tests__/helpers/api-key-auth-helper.spec.js.map +1 -1
  64. package/dist/cjs/__tests__/helpers/cognito-auth-helper.spec.d.ts +1 -1
  65. package/dist/cjs/__tests__/helpers/cognito-auth-helper.spec.js +47 -46
  66. package/dist/cjs/__tests__/helpers/cognito-auth-helper.spec.js.map +1 -1
  67. package/dist/cjs/__tests__/helpers/order-calculation-helper.spec.d.ts +1 -1
  68. package/dist/cjs/__tests__/helpers/order-calculation-helper.spec.js +153 -152
  69. package/dist/cjs/__tests__/helpers/order-calculation-helper.spec.js.map +1 -1
  70. package/dist/cjs/__tests__/helpers/public-api-response-helper.spec.d.ts +1 -1
  71. package/dist/cjs/__tests__/helpers/public-api-response-helper.spec.js +61 -60
  72. package/dist/cjs/__tests__/helpers/public-api-response-helper.spec.js.map +1 -1
  73. package/dist/cjs/__tests__/identity-cache/helpers.spec.d.ts +1 -1
  74. package/dist/cjs/__tests__/identity-cache/helpers.spec.js +593 -592
  75. package/dist/cjs/__tests__/identity-cache/helpers.spec.js.map +1 -1
  76. package/dist/cjs/__tests__/identity-cache/identity-cache-alias-write.spec.d.ts +1 -1
  77. package/dist/cjs/__tests__/identity-cache/identity-cache-alias-write.spec.js +71 -70
  78. package/dist/cjs/__tests__/identity-cache/identity-cache-alias-write.spec.js.map +1 -1
  79. package/dist/cjs/__tests__/identity-cache/identity-cache-db-service.spec.d.ts +1 -1
  80. package/dist/cjs/__tests__/identity-cache/identity-cache-db-service.spec.js +677 -676
  81. package/dist/cjs/__tests__/identity-cache/identity-cache-db-service.spec.js.map +1 -1
  82. package/dist/cjs/__tests__/identity-cache/identity-cache-dynamodb-db-service.spec.d.ts +1 -1
  83. package/dist/cjs/__tests__/identity-cache/identity-cache-dynamodb-db-service.spec.js +750 -727
  84. package/dist/cjs/__tests__/identity-cache/identity-cache-dynamodb-db-service.spec.js.map +1 -1
  85. package/dist/cjs/__tests__/identity-cache/identity-cache-tier-routing.spec.d.ts +1 -1
  86. package/dist/cjs/__tests__/identity-cache/identity-cache-tier-routing.spec.js +640 -631
  87. package/dist/cjs/__tests__/identity-cache/identity-cache-tier-routing.spec.js.map +1 -1
  88. package/dist/cjs/__tests__/identity-cache/identity-client.spec.d.ts +1 -1
  89. package/dist/cjs/__tests__/identity-cache/identity-client.spec.js +362 -359
  90. package/dist/cjs/__tests__/identity-cache/identity-client.spec.js.map +1 -1
  91. package/dist/cjs/__tests__/identity-cache/identity-gateway-cache-hit.spec.d.ts +1 -1
  92. package/dist/cjs/__tests__/identity-cache/identity-gateway-cache-hit.spec.js +138 -137
  93. package/dist/cjs/__tests__/identity-cache/identity-gateway-cache-hit.spec.js.map +1 -1
  94. package/dist/cjs/__tests__/identity-cache/identity-gateway-cache-miss.spec.d.ts +1 -1
  95. package/dist/cjs/__tests__/identity-cache/identity-gateway-cache-miss.spec.js +165 -152
  96. package/dist/cjs/__tests__/identity-cache/identity-gateway-cache-miss.spec.js.map +1 -1
  97. package/dist/cjs/__tests__/identity-cache/identity-gateway-constructor.spec.d.ts +1 -1
  98. package/dist/cjs/__tests__/identity-cache/identity-gateway-constructor.spec.js +72 -71
  99. package/dist/cjs/__tests__/identity-cache/identity-gateway-constructor.spec.js.map +1 -1
  100. package/dist/cjs/__tests__/identity-cache/identity-gateway-edge-cases.spec.d.ts +1 -1
  101. package/dist/cjs/__tests__/identity-cache/identity-gateway-edge-cases.spec.js +95 -88
  102. package/dist/cjs/__tests__/identity-cache/identity-gateway-edge-cases.spec.js.map +1 -1
  103. package/dist/cjs/__tests__/identity-cache/identity-gateway-enqueue-async.spec.d.ts +1 -1
  104. package/dist/cjs/__tests__/identity-cache/identity-gateway-enqueue-async.spec.js +136 -135
  105. package/dist/cjs/__tests__/identity-cache/identity-gateway-enqueue-async.spec.js.map +1 -1
  106. package/dist/cjs/__tests__/identity-cache/identity-gateway-stale-cache.spec.d.ts +1 -1
  107. package/dist/cjs/__tests__/identity-cache/identity-gateway-stale-cache.spec.js +245 -223
  108. package/dist/cjs/__tests__/identity-cache/identity-gateway-stale-cache.spec.js.map +1 -1
  109. package/dist/cjs/__tests__/identity-cache/identity-gateway-test-setup.d.ts +24 -28
  110. package/dist/cjs/__tests__/identity-cache/identity-gateway-test-setup.js +96 -89
  111. package/dist/cjs/__tests__/identity-cache/identity-gateway-test-setup.js.map +1 -1
  112. package/dist/cjs/__tests__/identity-cache/trait-merging-and-staleness.spec.d.ts +1 -1
  113. package/dist/cjs/__tests__/identity-cache/trait-merging-and-staleness.spec.js +1749 -1770
  114. package/dist/cjs/__tests__/identity-cache/trait-merging-and-staleness.spec.js.map +1 -1
  115. package/dist/cjs/__tests__/identity-cache/volatile-traits-optimization.spec.d.ts +1 -1
  116. package/dist/cjs/__tests__/identity-cache/volatile-traits-optimization.spec.js +819 -818
  117. package/dist/cjs/__tests__/identity-cache/volatile-traits-optimization.spec.js.map +1 -1
  118. package/dist/cjs/__tests__/integration/sqs-bundling-roundtrip.spec.d.ts +1 -1
  119. package/dist/cjs/__tests__/integration/sqs-bundling-roundtrip.spec.js +585 -584
  120. package/dist/cjs/__tests__/integration/sqs-bundling-roundtrip.spec.js.map +1 -1
  121. package/dist/cjs/__tests__/libs/compress-decompress.spec.d.ts +1 -1
  122. package/dist/cjs/__tests__/libs/compress-decompress.spec.js +17 -16
  123. package/dist/cjs/__tests__/libs/compress-decompress.spec.js.map +1 -1
  124. package/dist/cjs/__tests__/libs/contacts.spec.d.ts +1 -1
  125. package/dist/cjs/__tests__/libs/contacts.spec.js +295 -294
  126. package/dist/cjs/__tests__/libs/contacts.spec.js.map +1 -1
  127. package/dist/cjs/__tests__/libs/currency.spec.d.ts +1 -1
  128. package/dist/cjs/__tests__/libs/currency.spec.js +221 -220
  129. package/dist/cjs/__tests__/libs/currency.spec.js.map +1 -1
  130. package/dist/cjs/__tests__/libs/dates.spec.d.ts +1 -1
  131. package/dist/cjs/__tests__/libs/dates.spec.js +131 -130
  132. package/dist/cjs/__tests__/libs/dates.spec.js.map +1 -1
  133. package/dist/cjs/__tests__/libs/domain.spec.d.ts +1 -1
  134. package/dist/cjs/__tests__/libs/domain.spec.js +108 -107
  135. package/dist/cjs/__tests__/libs/domain.spec.js.map +1 -1
  136. package/dist/cjs/__tests__/libs/numbers.spec.d.ts +1 -1
  137. package/dist/cjs/__tests__/libs/numbers.spec.js +262 -261
  138. package/dist/cjs/__tests__/libs/numbers.spec.js.map +1 -1
  139. package/dist/cjs/__tests__/s3-client/s3-client.spec.d.ts +1 -1
  140. package/dist/cjs/__tests__/s3-client/s3-client.spec.js +32 -33
  141. package/dist/cjs/__tests__/s3-client/s3-client.spec.js.map +1 -1
  142. package/dist/cjs/__tests__/services/acuity-api-service.spec.d.ts +1 -1
  143. package/dist/cjs/__tests__/services/acuity-api-service.spec.js +74 -71
  144. package/dist/cjs/__tests__/services/acuity-api-service.spec.js.map +1 -1
  145. package/dist/cjs/__tests__/services/cost/cost-calculation-types.spec.d.ts +1 -1
  146. package/dist/cjs/__tests__/services/cost/cost-calculation-types.spec.js +24 -23
  147. package/dist/cjs/__tests__/services/cost/cost-calculation-types.spec.js.map +1 -1
  148. package/dist/cjs/__tests__/services/cost/cost-calculator-service.spec.d.ts +1 -1
  149. package/dist/cjs/__tests__/services/cost/cost-calculator-service.spec.js +3599 -3361
  150. package/dist/cjs/__tests__/services/cost/cost-calculator-service.spec.js.map +1 -1
  151. package/dist/cjs/__tests__/services/cost/cost-currency-service.spec.d.ts +1 -1
  152. package/dist/cjs/__tests__/services/cost/cost-currency-service.spec.js +115 -114
  153. package/dist/cjs/__tests__/services/cost/cost-currency-service.spec.js.map +1 -1
  154. package/dist/cjs/__tests__/services/cost/cost-filter-service.spec.d.ts +1 -1
  155. package/dist/cjs/__tests__/services/cost/cost-filter-service.spec.js +465 -468
  156. package/dist/cjs/__tests__/services/cost/cost-filter-service.spec.js.map +1 -1
  157. package/dist/cjs/__tests__/services/cost/order-cost/order-cost-resolution-service.spec.d.ts +1 -1
  158. package/dist/cjs/__tests__/services/cost/order-cost/order-cost-resolution-service.spec.js +485 -360
  159. package/dist/cjs/__tests__/services/cost/order-cost/order-cost-resolution-service.spec.js.map +1 -1
  160. package/dist/cjs/__tests__/services/currency-exchange-rate-lookup-service.spec.d.ts +1 -1
  161. package/dist/cjs/__tests__/services/currency-exchange-rate-lookup-service.spec.js +39 -34
  162. package/dist/cjs/__tests__/services/currency-exchange-rate-lookup-service.spec.js.map +1 -1
  163. package/dist/cjs/__tests__/services/email-verification/contact-email-verification-service.spec.d.ts +1 -1
  164. package/dist/cjs/__tests__/services/email-verification/contact-email-verification-service.spec.js +95 -93
  165. package/dist/cjs/__tests__/services/email-verification/contact-email-verification-service.spec.js.map +1 -1
  166. package/dist/cjs/__tests__/services/email-verification/email-verification-service.spec.d.ts +1 -1
  167. package/dist/cjs/__tests__/services/email-verification/email-verification-service.spec.js +62 -57
  168. package/dist/cjs/__tests__/services/email-verification/email-verification-service.spec.js.map +1 -1
  169. package/dist/cjs/__tests__/services/events/collect-queue-tracking-service.spec.d.ts +1 -1
  170. package/dist/cjs/__tests__/services/events/collect-queue-tracking-service.spec.js +232 -229
  171. package/dist/cjs/__tests__/services/events/collect-queue-tracking-service.spec.js.map +1 -1
  172. package/dist/cjs/__tests__/services/events/tracking-event-sqs-service.spec.d.ts +1 -1
  173. package/dist/cjs/__tests__/services/events/tracking-event-sqs-service.spec.js +194 -191
  174. package/dist/cjs/__tests__/services/events/tracking-event-sqs-service.spec.js.map +1 -1
  175. package/dist/cjs/__tests__/shopify/shopify-graphql-transformer.spec.d.ts +1 -1
  176. package/dist/cjs/__tests__/shopify/shopify-graphql-transformer.spec.js +36 -35
  177. package/dist/cjs/__tests__/shopify/shopify-graphql-transformer.spec.js.map +1 -1
  178. package/dist/cjs/__tests__/unit/libs/api-router/public-api-router.spec.d.ts +1 -1
  179. package/dist/cjs/__tests__/unit/libs/api-router/public-api-router.spec.js +192 -181
  180. package/dist/cjs/__tests__/unit/libs/api-router/public-api-router.spec.js.map +1 -1
  181. package/dist/cjs/__tests__/unit/libs/api-router/route-matcher.spec.d.ts +1 -1
  182. package/dist/cjs/__tests__/unit/libs/api-router/route-matcher.spec.js +70 -69
  183. package/dist/cjs/__tests__/unit/libs/api-router/route-matcher.spec.js.map +1 -1
  184. package/dist/cjs/__tests__/utils/custom-measure-formula-utils.spec.d.ts +1 -1
  185. package/dist/cjs/__tests__/utils/custom-measure-formula-utils.spec.js +147 -146
  186. package/dist/cjs/__tests__/utils/custom-measure-formula-utils.spec.js.map +1 -1
  187. package/dist/cjs/clients/generic/cognito-client.d.ts +23 -23
  188. package/dist/cjs/clients/generic/cognito-client.js +209 -209
  189. package/dist/cjs/clients/generic/cognito-client.js.map +1 -1
  190. package/dist/cjs/clients/generic/dynamodb-client.d.ts +20 -20
  191. package/dist/cjs/clients/generic/dynamodb-client.js +235 -235
  192. package/dist/cjs/clients/generic/dynamodb-client.js.map +1 -1
  193. package/dist/cjs/clients/generic/eventbridge-client.d.ts +14 -14
  194. package/dist/cjs/clients/generic/eventbridge-client.js +51 -51
  195. package/dist/cjs/clients/generic/eventbridge-client.js.map +1 -1
  196. package/dist/cjs/clients/generic/http-client.d.ts +14 -14
  197. package/dist/cjs/clients/generic/http-client.js +61 -61
  198. package/dist/cjs/clients/generic/http-client.js.map +1 -1
  199. package/dist/cjs/clients/generic/index.d.ts +13 -13
  200. package/dist/cjs/clients/generic/index.js +29 -29
  201. package/dist/cjs/clients/generic/lambda-invoke-client.d.ts +10 -10
  202. package/dist/cjs/clients/generic/lambda-invoke-client.js +39 -39
  203. package/dist/cjs/clients/generic/lambda-invoke-client.js.map +1 -1
  204. package/dist/cjs/clients/generic/location-client.d.ts +8 -8
  205. package/dist/cjs/clients/generic/location-client.js +31 -31
  206. package/dist/cjs/clients/generic/location-client.js.map +1 -1
  207. package/dist/cjs/clients/generic/redis-client.d.ts +33 -33
  208. package/dist/cjs/clients/generic/redis-client.js +202 -191
  209. package/dist/cjs/clients/generic/redis-client.js.map +1 -1
  210. package/dist/cjs/clients/generic/s3-client.d.ts +22 -23
  211. package/dist/cjs/clients/generic/s3-client.js +216 -216
  212. package/dist/cjs/clients/generic/s3-client.js.map +1 -1
  213. package/dist/cjs/clients/generic/singlestore-db-client.d.ts +21 -21
  214. package/dist/cjs/clients/generic/singlestore-db-client.js +102 -92
  215. package/dist/cjs/clients/generic/singlestore-db-client.js.map +1 -1
  216. package/dist/cjs/clients/generic/sqs-bundled-client.d.ts +15 -15
  217. package/dist/cjs/clients/generic/sqs-bundled-client.js +311 -311
  218. package/dist/cjs/clients/generic/sqs-bundled-client.js.map +1 -1
  219. package/dist/cjs/clients/generic/sqs-bundled-client.types.d.ts +53 -53
  220. package/dist/cjs/clients/generic/sqs-bundled-client.types.js +17 -17
  221. package/dist/cjs/clients/generic/sqs-bundled-client.types.js.map +1 -1
  222. package/dist/cjs/clients/generic/sqs-client.d.ts +53 -53
  223. package/dist/cjs/clients/generic/sqs-client.js +285 -285
  224. package/dist/cjs/clients/generic/sqs-client.js.map +1 -1
  225. package/dist/cjs/clients/generic/sqs-unbundle.d.ts +32 -32
  226. package/dist/cjs/clients/generic/sqs-unbundle.js +143 -144
  227. package/dist/cjs/clients/generic/sqs-unbundle.js.map +1 -1
  228. package/dist/cjs/clients/index.d.ts +3 -3
  229. package/dist/cjs/clients/index.js +19 -19
  230. package/dist/cjs/clients/internal-api/accounts-client.d.ts +91 -91
  231. package/dist/cjs/clients/internal-api/accounts-client.js +129 -129
  232. package/dist/cjs/clients/internal-api/accounts-client.js.map +1 -1
  233. package/dist/cjs/clients/internal-api/cache-lambda-client.d.ts +26 -26
  234. package/dist/cjs/clients/internal-api/cache-lambda-client.js +89 -89
  235. package/dist/cjs/clients/internal-api/cache-lambda-client.js.map +1 -1
  236. package/dist/cjs/clients/internal-api/db-management-client.d.ts +18 -18
  237. package/dist/cjs/clients/internal-api/db-management-client.js +36 -36
  238. package/dist/cjs/clients/internal-api/db-management-client.js.map +1 -1
  239. package/dist/cjs/clients/internal-api/destinations-client.d.ts +34 -34
  240. package/dist/cjs/clients/internal-api/destinations-client.js +79 -79
  241. package/dist/cjs/clients/internal-api/destinations-client.js.map +1 -1
  242. package/dist/cjs/clients/internal-api/event-collector-client.d.ts +122 -122
  243. package/dist/cjs/clients/internal-api/event-collector-client.js +78 -78
  244. package/dist/cjs/clients/internal-api/event-collector-client.js.map +1 -1
  245. package/dist/cjs/clients/internal-api/identity-client.d.ts +41 -41
  246. package/dist/cjs/clients/internal-api/identity-client.js +137 -137
  247. package/dist/cjs/clients/internal-api/identity-client.js.map +1 -1
  248. package/dist/cjs/clients/internal-api/index.d.ts +9 -9
  249. package/dist/cjs/clients/internal-api/index.js +25 -25
  250. package/dist/cjs/clients/internal-api/shopify-app-install-client.d.ts +37 -37
  251. package/dist/cjs/clients/internal-api/shopify-app-install-client.js +81 -81
  252. package/dist/cjs/clients/internal-api/shopify-app-install-client.js.map +1 -1
  253. package/dist/cjs/clients/internal-api/subscriptions-client.d.ts +26 -26
  254. package/dist/cjs/clients/internal-api/subscriptions-client.js +77 -77
  255. package/dist/cjs/clients/internal-api/subscriptions-client.js.map +1 -1
  256. package/dist/cjs/clients/internal-api/users-auth-client.d.ts +35 -35
  257. package/dist/cjs/clients/internal-api/users-auth-client.js +110 -110
  258. package/dist/cjs/clients/internal-api/users-auth-client.js.map +1 -1
  259. package/dist/cjs/clients/third-party/acuity-client.d.ts +10 -10
  260. package/dist/cjs/clients/third-party/acuity-client.js +40 -40
  261. package/dist/cjs/clients/third-party/acuity-client.js.map +1 -1
  262. package/dist/cjs/clients/third-party/emailable-client.d.ts +7 -7
  263. package/dist/cjs/clients/third-party/emailable-client.js +25 -25
  264. package/dist/cjs/clients/third-party/emailable-client.js.map +1 -1
  265. package/dist/cjs/clients/third-party/exchange-rate-api-client.d.ts +17 -17
  266. package/dist/cjs/clients/third-party/exchange-rate-api-client.js +19 -19
  267. package/dist/cjs/clients/third-party/exchange-rate-api-client.js.map +1 -1
  268. package/dist/cjs/clients/third-party/index.d.ts +6 -6
  269. package/dist/cjs/clients/third-party/index.js +22 -22
  270. package/dist/cjs/clients/third-party/loops-client.d.ts +10 -10
  271. package/dist/cjs/clients/third-party/loops-client.js +30 -30
  272. package/dist/cjs/clients/third-party/loops-client.js.map +1 -1
  273. package/dist/cjs/clients/third-party/open-exchange-rates-client.d.ts +8 -8
  274. package/dist/cjs/clients/third-party/open-exchange-rates-client.js +27 -27
  275. package/dist/cjs/clients/third-party/open-exchange-rates-client.js.map +1 -1
  276. package/dist/cjs/clients/third-party/shopify/graphql-analytics-queries.d.ts +18 -18
  277. package/dist/cjs/clients/third-party/shopify/graphql-analytics-queries.js +22 -22
  278. package/dist/cjs/clients/third-party/shopify/graphql-order-queries.d.ts +25 -25
  279. package/dist/cjs/clients/third-party/shopify/graphql-order-queries.js +4 -4
  280. package/dist/cjs/clients/third-party/shopify/graphql-product-queries.d.ts +2 -2
  281. package/dist/cjs/clients/third-party/shopify/graphql-product-queries.js +5 -5
  282. package/dist/cjs/clients/third-party/shopify/shopify-graphql-client.d.ts +42 -42
  283. package/dist/cjs/clients/third-party/shopify/shopify-graphql-client.js +352 -352
  284. package/dist/cjs/clients/third-party/shopify/shopify-graphql-client.js.map +1 -1
  285. package/dist/cjs/clients/third-party/shopify-client.d.ts +29 -29
  286. package/dist/cjs/clients/third-party/shopify-client.js +146 -146
  287. package/dist/cjs/clients/third-party/shopify-client.js.map +1 -1
  288. package/dist/cjs/constants/index.d.ts +1 -1
  289. package/dist/cjs/constants/index.js +17 -17
  290. package/dist/cjs/constants/sqs.d.ts +20 -20
  291. package/dist/cjs/constants/sqs.js +26 -26
  292. package/dist/cjs/constants/sqs.js.map +1 -1
  293. package/dist/cjs/helpers/account-users-helper.d.ts +2 -2
  294. package/dist/cjs/helpers/account-users-helper.js +22 -22
  295. package/dist/cjs/helpers/account-users-helper.js.map +1 -1
  296. package/dist/cjs/helpers/acuity-helper.d.ts +4 -4
  297. package/dist/cjs/helpers/acuity-helper.js +56 -56
  298. package/dist/cjs/helpers/acuity-helper.js.map +1 -1
  299. package/dist/cjs/helpers/api-key-auth-helper.d.ts +10 -9
  300. package/dist/cjs/helpers/api-key-auth-helper.js +40 -40
  301. package/dist/cjs/helpers/api-key-auth-helper.js.map +1 -1
  302. package/dist/cjs/helpers/api-key-authorizer-helper.d.ts +36 -36
  303. package/dist/cjs/helpers/api-key-authorizer-helper.js +87 -87
  304. package/dist/cjs/helpers/api-key-authorizer-helper.js.map +1 -1
  305. package/dist/cjs/helpers/cognito-auth-helper.d.ts +6 -5
  306. package/dist/cjs/helpers/cognito-auth-helper.js +14 -14
  307. package/dist/cjs/helpers/cognito-auth-helper.js.map +1 -1
  308. package/dist/cjs/helpers/index.d.ts +12 -12
  309. package/dist/cjs/helpers/index.js +28 -28
  310. package/dist/cjs/helpers/input-validation-helper.d.ts +3 -3
  311. package/dist/cjs/helpers/input-validation-helper.js +22 -22
  312. package/dist/cjs/helpers/input-validation-helper.js.map +1 -1
  313. package/dist/cjs/helpers/logging-helper.d.ts +16 -16
  314. package/dist/cjs/helpers/logging-helper.js +94 -84
  315. package/dist/cjs/helpers/logging-helper.js.map +1 -1
  316. package/dist/cjs/helpers/order-calculation-helper.d.ts +13 -13
  317. package/dist/cjs/helpers/order-calculation-helper.js +117 -117
  318. package/dist/cjs/helpers/order-calculation-helper.js.map +1 -1
  319. package/dist/cjs/helpers/public-api-response-helper.d.ts +21 -21
  320. package/dist/cjs/helpers/public-api-response-helper.js +45 -45
  321. package/dist/cjs/helpers/public-api-response-helper.js.map +1 -1
  322. package/dist/cjs/helpers/response-helper.d.ts +18 -18
  323. package/dist/cjs/helpers/response-helper.js +43 -43
  324. package/dist/cjs/helpers/response-helper.js.map +1 -1
  325. package/dist/cjs/helpers/shopify-helper.d.ts +9 -9
  326. package/dist/cjs/helpers/shopify-helper.js +26 -26
  327. package/dist/cjs/helpers/shopify-helper.js.map +1 -1
  328. package/dist/cjs/helpers/sqs-utils.d.ts +6 -6
  329. package/dist/cjs/helpers/sqs-utils.js +18 -14
  330. package/dist/cjs/helpers/sqs-utils.js.map +1 -1
  331. package/dist/cjs/index.d.ts +7 -7
  332. package/dist/cjs/index.js +23 -23
  333. package/dist/cjs/libs/api-router/index.d.ts +2 -2
  334. package/dist/cjs/libs/api-router/index.js +18 -18
  335. package/dist/cjs/libs/api-router/public-api-router.d.ts +3 -3
  336. package/dist/cjs/libs/api-router/public-api-router.js +36 -36
  337. package/dist/cjs/libs/api-router/public-api-router.js.map +1 -1
  338. package/dist/cjs/libs/api-router/route-matcher.d.ts +21 -21
  339. package/dist/cjs/libs/api-router/route-matcher.js +36 -36
  340. package/dist/cjs/libs/api-router/route-matcher.js.map +1 -1
  341. package/dist/cjs/libs/click-id-parser.d.ts +23 -23
  342. package/dist/cjs/libs/click-id-parser.js +49 -49
  343. package/dist/cjs/libs/click-id-parser.js.map +1 -1
  344. package/dist/cjs/libs/compression.d.ts +2 -2
  345. package/dist/cjs/libs/compression.js +33 -33
  346. package/dist/cjs/libs/compression.js.map +1 -1
  347. package/dist/cjs/libs/contacts.d.ts +7 -7
  348. package/dist/cjs/libs/contacts.js +152 -152
  349. package/dist/cjs/libs/contacts.js.map +1 -1
  350. package/dist/cjs/libs/cookie.d.ts +17 -17
  351. package/dist/cjs/libs/cookie.js +76 -76
  352. package/dist/cjs/libs/cookie.js.map +1 -1
  353. package/dist/cjs/libs/crypto.d.ts +4 -4
  354. package/dist/cjs/libs/crypto.js +25 -25
  355. package/dist/cjs/libs/crypto.js.map +1 -1
  356. package/dist/cjs/libs/csv.d.ts +2 -2
  357. package/dist/cjs/libs/csv.js +35 -35
  358. package/dist/cjs/libs/csv.js.map +1 -1
  359. package/dist/cjs/libs/currency.d.ts +1 -1
  360. package/dist/cjs/libs/currency.js +29 -29
  361. package/dist/cjs/libs/currency.js.map +1 -1
  362. package/dist/cjs/libs/dates.d.ts +12 -12
  363. package/dist/cjs/libs/dates.js +96 -96
  364. package/dist/cjs/libs/dates.js.map +1 -1
  365. package/dist/cjs/libs/domain.d.ts +2 -2
  366. package/dist/cjs/libs/domain.js +38 -38
  367. package/dist/cjs/libs/domain.js.map +1 -1
  368. package/dist/cjs/libs/emails.d.ts +8 -8
  369. package/dist/cjs/libs/emails.js +154 -154
  370. package/dist/cjs/libs/emails.js.map +1 -1
  371. package/dist/cjs/libs/http-error.d.ts +21 -21
  372. package/dist/cjs/libs/http-error.js +63 -63
  373. package/dist/cjs/libs/http-error.js.map +1 -1
  374. package/dist/cjs/libs/http-status-codes.d.ts +58 -58
  375. package/dist/cjs/libs/http-status-codes.js +62 -62
  376. package/dist/cjs/libs/http-status-codes.js.map +1 -1
  377. package/dist/cjs/libs/index.d.ts +19 -19
  378. package/dist/cjs/libs/index.js +35 -35
  379. package/dist/cjs/libs/numbers.d.ts +1 -1
  380. package/dist/cjs/libs/numbers.js +15 -15
  381. package/dist/cjs/libs/numbers.js.map +1 -1
  382. package/dist/cjs/libs/referrer-parser/index.d.ts +2 -2
  383. package/dist/cjs/libs/referrer-parser/index.js +18 -18
  384. package/dist/cjs/libs/referrer-parser/referrer-data.d.ts +9 -9
  385. package/dist/cjs/libs/referrer-parser/referrer-data.js +3307 -3307
  386. package/dist/cjs/libs/referrer-parser/referrer-parser-util.d.ts +19 -20
  387. package/dist/cjs/libs/referrer-parser/referrer-parser-util.js +131 -131
  388. package/dist/cjs/libs/referrer-parser/referrer-parser-util.js.map +1 -1
  389. package/dist/cjs/libs/strings.d.ts +3 -3
  390. package/dist/cjs/libs/strings.js +46 -46
  391. package/dist/cjs/libs/strings.js.map +1 -1
  392. package/dist/cjs/libs/traits.d.ts +6 -6
  393. package/dist/cjs/libs/traits.js +65 -65
  394. package/dist/cjs/libs/traits.js.map +1 -1
  395. package/dist/cjs/libs/url.d.ts +1 -1
  396. package/dist/cjs/libs/url.js +13 -13
  397. package/dist/cjs/libs/url.js.map +1 -1
  398. package/dist/cjs/services/acuity-api-service.d.ts +9 -9
  399. package/dist/cjs/services/acuity-api-service.js +73 -73
  400. package/dist/cjs/services/acuity-api-service.js.map +1 -1
  401. package/dist/cjs/services/cache/generic-cached-object.d.ts +5 -5
  402. package/dist/cjs/services/cache/generic-cached-object.js +2 -2
  403. package/dist/cjs/services/cache/index.d.ts +1 -1
  404. package/dist/cjs/services/cache/index.js +17 -17
  405. package/dist/cjs/services/cache/product-cache-service.d.ts +21 -21
  406. package/dist/cjs/services/cache/product-cache-service.js +76 -76
  407. package/dist/cjs/services/cache/product-cache-service.js.map +1 -1
  408. package/dist/cjs/services/cost/cost-calculation-types.d.ts +69 -69
  409. package/dist/cjs/services/cost/cost-calculation-types.js +18 -19
  410. package/dist/cjs/services/cost/cost-calculation-types.js.map +1 -1
  411. package/dist/cjs/services/cost/cost-calculator-service.d.ts +24 -24
  412. package/dist/cjs/services/cost/cost-calculator-service.js +495 -462
  413. package/dist/cjs/services/cost/cost-calculator-service.js.map +1 -1
  414. package/dist/cjs/services/cost/cost-currency-service.d.ts +6 -6
  415. package/dist/cjs/services/cost/cost-currency-service.js +87 -87
  416. package/dist/cjs/services/cost/cost-currency-service.js.map +1 -1
  417. package/dist/cjs/services/cost/cost-filter-service.d.ts +10 -10
  418. package/dist/cjs/services/cost/cost-filter-service.js +130 -121
  419. package/dist/cjs/services/cost/cost-filter-service.js.map +1 -1
  420. package/dist/cjs/services/cost/index.d.ts +5 -5
  421. package/dist/cjs/services/cost/index.js +21 -21
  422. package/dist/cjs/services/cost/order-cost/index.d.ts +2 -2
  423. package/dist/cjs/services/cost/order-cost/index.js +18 -18
  424. package/dist/cjs/services/cost/order-cost/order-cost-resolution-service.d.ts +23 -23
  425. package/dist/cjs/services/cost/order-cost/order-cost-resolution-service.js +308 -293
  426. package/dist/cjs/services/cost/order-cost/order-cost-resolution-service.js.map +1 -1
  427. package/dist/cjs/services/cost/order-cost/order-cost-resolution-types.d.ts +31 -31
  428. package/dist/cjs/services/cost/order-cost/order-cost-resolution-types.js +2 -2
  429. package/dist/cjs/services/currency-exchange-rate-lookup-service.d.ts +12 -12
  430. package/dist/cjs/services/currency-exchange-rate-lookup-service.js +97 -94
  431. package/dist/cjs/services/currency-exchange-rate-lookup-service.js.map +1 -1
  432. package/dist/cjs/services/db/accounts-db-service.d.ts +9 -9
  433. package/dist/cjs/services/db/accounts-db-service.js +33 -33
  434. package/dist/cjs/services/db/accounts-db-service.js.map +1 -1
  435. package/dist/cjs/services/db/api-keys-db-service.d.ts +10 -10
  436. package/dist/cjs/services/db/api-keys-db-service.js +36 -36
  437. package/dist/cjs/services/db/api-keys-db-service.js.map +1 -1
  438. package/dist/cjs/services/db/contact-enrichments-db-service.d.ts +15 -15
  439. package/dist/cjs/services/db/contact-enrichments-db-service.js +94 -94
  440. package/dist/cjs/services/db/contact-enrichments-db-service.js.map +1 -1
  441. package/dist/cjs/services/db/currency-exchange-rates-db-service.d.ts +21 -21
  442. package/dist/cjs/services/db/currency-exchange-rates-db-service.js +39 -39
  443. package/dist/cjs/services/db/currency-exchange-rates-db-service.js.map +1 -1
  444. package/dist/cjs/services/db/custom-measures-db-service.d.ts +14 -14
  445. package/dist/cjs/services/db/custom-measures-db-service.js +48 -48
  446. package/dist/cjs/services/db/custom-measures-db-service.js.map +1 -1
  447. package/dist/cjs/services/db/destinations-db-service.d.ts +13 -13
  448. package/dist/cjs/services/db/destinations-db-service.js +74 -74
  449. package/dist/cjs/services/db/destinations-db-service.js.map +1 -1
  450. package/dist/cjs/services/db/identity-cache-db-service.d.ts +28 -28
  451. package/dist/cjs/services/db/identity-cache-db-service.js +320 -320
  452. package/dist/cjs/services/db/identity-cache-db-service.js.map +1 -1
  453. package/dist/cjs/services/db/identity-cache-dynamodb-service/constants.d.ts +3 -3
  454. package/dist/cjs/services/db/identity-cache-dynamodb-service/constants.js +6 -6
  455. package/dist/cjs/services/db/identity-cache-dynamodb-service/identity-cache-dynamodb-db-service.d.ts +25 -25
  456. package/dist/cjs/services/db/identity-cache-dynamodb-service/identity-cache-dynamodb-db-service.js +529 -525
  457. package/dist/cjs/services/db/identity-cache-dynamodb-service/identity-cache-dynamodb-db-service.js.map +1 -1
  458. package/dist/cjs/services/db/identity-cache-dynamodb-service/identity-gateway-service.d.ts +23 -23
  459. package/dist/cjs/services/db/identity-cache-dynamodb-service/identity-gateway-service.js +236 -222
  460. package/dist/cjs/services/db/identity-cache-dynamodb-service/identity-gateway-service.js.map +1 -1
  461. package/dist/cjs/services/db/identity-cache-dynamodb-service/index.d.ts +4 -4
  462. package/dist/cjs/services/db/identity-cache-dynamodb-service/index.js +20 -20
  463. package/dist/cjs/services/db/identity-cache-dynamodb-service/key-builders.d.ts +12 -12
  464. package/dist/cjs/services/db/identity-cache-dynamodb-service/key-builders.js +31 -31
  465. package/dist/cjs/services/db/identity-cache-dynamodb-service/key-builders.js.map +1 -1
  466. package/dist/cjs/services/db/identity-cache-dynamodb-service/types.d.ts +82 -82
  467. package/dist/cjs/services/db/identity-cache-dynamodb-service/types.js +28 -28
  468. package/dist/cjs/services/db/identity-cache-dynamodb-service/types.js.map +1 -1
  469. package/dist/cjs/services/db/index.d.ts +22 -22
  470. package/dist/cjs/services/db/index.js +38 -38
  471. package/dist/cjs/services/db/log-events-db-service.d.ts +11 -11
  472. package/dist/cjs/services/db/log-events-db-service.js +181 -181
  473. package/dist/cjs/services/db/log-events-db-service.js.map +1 -1
  474. package/dist/cjs/services/db/pixels-db-service.d.ts +8 -8
  475. package/dist/cjs/services/db/pixels-db-service.js +35 -35
  476. package/dist/cjs/services/db/pixels-db-service.js.map +1 -1
  477. package/dist/cjs/services/db/products-db-service-types.d.ts +10 -10
  478. package/dist/cjs/services/db/products-db-service-types.js +2 -2
  479. package/dist/cjs/services/db/products-db-service.d.ts +19 -19
  480. package/dist/cjs/services/db/products-db-service.js +310 -281
  481. package/dist/cjs/services/db/products-db-service.js.map +1 -1
  482. package/dist/cjs/services/db/purchasable-contacts-db-service.d.ts +9 -9
  483. package/dist/cjs/services/db/purchasable-contacts-db-service.js +43 -43
  484. package/dist/cjs/services/db/purchasable-contacts-db-service.js.map +1 -1
  485. package/dist/cjs/services/db/purchased-contacts/index.d.ts +2 -2
  486. package/dist/cjs/services/db/purchased-contacts/index.js +18 -18
  487. package/dist/cjs/services/db/purchased-contacts/purchased-contacts-db-service.d.ts +18 -18
  488. package/dist/cjs/services/db/purchased-contacts/purchased-contacts-db-service.js +152 -152
  489. package/dist/cjs/services/db/purchased-contacts/purchased-contacts-db-service.js.map +1 -1
  490. package/dist/cjs/services/db/purchased-contacts/types.d.ts +11 -11
  491. package/dist/cjs/services/db/purchased-contacts/types.js +2 -2
  492. package/dist/cjs/services/db/shopify-app-installs-db-service.d.ts +10 -10
  493. package/dist/cjs/services/db/shopify-app-installs-db-service.js +52 -52
  494. package/dist/cjs/services/db/shopify-app-installs-db-service.js.map +1 -1
  495. package/dist/cjs/services/db/shopify-products-cache-db-service.d.ts +16 -16
  496. package/dist/cjs/services/db/shopify-products-cache-db-service.js +73 -73
  497. package/dist/cjs/services/db/shopify-products-cache-db-service.js.map +1 -1
  498. package/dist/cjs/services/db/subscriptions-db-service.d.ts +11 -11
  499. package/dist/cjs/services/db/subscriptions-db-service.js +38 -38
  500. package/dist/cjs/services/db/subscriptions-db-service.js.map +1 -1
  501. package/dist/cjs/services/db/tracking-events-db-service.d.ts +21 -21
  502. package/dist/cjs/services/db/tracking-events-db-service.js +188 -188
  503. package/dist/cjs/services/db/tracking-events-db-service.js.map +1 -1
  504. package/dist/cjs/services/db/user-accounts-db-service.d.ts +7 -7
  505. package/dist/cjs/services/db/user-accounts-db-service.js +17 -17
  506. package/dist/cjs/services/db/user-accounts-db-service.js.map +1 -1
  507. package/dist/cjs/services/email-verification/contact-email-verification-service.d.ts +7 -7
  508. package/dist/cjs/services/email-verification/contact-email-verification-service.js +101 -101
  509. package/dist/cjs/services/email-verification/contact-email-verification-service.js.map +1 -1
  510. package/dist/cjs/services/email-verification/email-verification-service.d.ts +19 -19
  511. package/dist/cjs/services/email-verification/email-verification-service.js +131 -131
  512. package/dist/cjs/services/email-verification/email-verification-service.js.map +1 -1
  513. package/dist/cjs/services/email-verification/index.d.ts +2 -2
  514. package/dist/cjs/services/email-verification/index.js +18 -18
  515. package/dist/cjs/services/eventbridge-integration-service.d.ts +9 -9
  516. package/dist/cjs/services/eventbridge-integration-service.js +28 -28
  517. package/dist/cjs/services/eventbridge-integration-service.js.map +1 -1
  518. package/dist/cjs/services/events/build-collect-queue-tracking-event.d.ts +11 -11
  519. package/dist/cjs/services/events/build-collect-queue-tracking-event.js +23 -23
  520. package/dist/cjs/services/events/build-collect-queue-tracking-event.js.map +1 -1
  521. package/dist/cjs/services/events/collect-queue-tracking-service.d.ts +12 -12
  522. package/dist/cjs/services/events/collect-queue-tracking-service.js +22 -22
  523. package/dist/cjs/services/events/collect-queue-tracking-service.js.map +1 -1
  524. package/dist/cjs/services/events/index.d.ts +5 -5
  525. package/dist/cjs/services/events/index.js +21 -21
  526. package/dist/cjs/services/events/log-event-service.d.ts +19 -19
  527. package/dist/cjs/services/events/log-event-service.js +77 -77
  528. package/dist/cjs/services/events/log-event-service.js.map +1 -1
  529. package/dist/cjs/services/events/metric-event-service.d.ts +9 -9
  530. package/dist/cjs/services/events/metric-event-service.js +49 -49
  531. package/dist/cjs/services/events/metric-event-service.js.map +1 -1
  532. package/dist/cjs/services/events/tracking-event-sqs-service.d.ts +8 -8
  533. package/dist/cjs/services/events/tracking-event-sqs-service.js +36 -36
  534. package/dist/cjs/services/events/tracking-event-sqs-service.js.map +1 -1
  535. package/dist/cjs/services/generic-cache-service.d.ts +7 -7
  536. package/dist/cjs/services/generic-cache-service.js +33 -33
  537. package/dist/cjs/services/generic-cache-service.js.map +1 -1
  538. package/dist/cjs/services/index.d.ts +11 -11
  539. package/dist/cjs/services/index.js +27 -27
  540. package/dist/cjs/services/ipdata-lookup-service.d.ts +20 -20
  541. package/dist/cjs/services/ipdata-lookup-service.js +112 -112
  542. package/dist/cjs/services/ipdata-lookup-service.js.map +1 -1
  543. package/dist/cjs/services/shopify/index.d.ts +2 -2
  544. package/dist/cjs/services/shopify/index.js +18 -18
  545. package/dist/cjs/services/shopify/products/index.d.ts +1 -1
  546. package/dist/cjs/services/shopify/products/index.js +17 -17
  547. package/dist/cjs/services/shopify/products/shopify-products-serviceV2.d.ts +17 -17
  548. package/dist/cjs/services/shopify/products/shopify-products-serviceV2.js +112 -112
  549. package/dist/cjs/services/shopify/products/shopify-products-serviceV2.js.map +1 -1
  550. package/dist/cjs/services/shopify/shopify-graphql-transformer.d.ts +8 -8
  551. package/dist/cjs/services/shopify/shopify-graphql-transformer.js +141 -141
  552. package/dist/cjs/services/shopify/shopify-graphql-transformer.js.map +1 -1
  553. package/dist/cjs/types/acuity-types.d.ts +74 -74
  554. package/dist/cjs/types/acuity-types.js +2 -2
  555. package/dist/cjs/types/api-response.d.ts +6 -6
  556. package/dist/cjs/types/api-response.js +2 -2
  557. package/dist/cjs/types/index.d.ts +6 -6
  558. package/dist/cjs/types/index.js +45 -35
  559. package/dist/cjs/types/index.js.map +1 -1
  560. package/dist/cjs/types/internal-events/event-detail-types.d.ts +20 -20
  561. package/dist/cjs/types/internal-events/event-detail-types.js +27 -27
  562. package/dist/cjs/types/internal-events/event-detail-types.js.map +1 -1
  563. package/dist/cjs/types/internal-events/index.d.ts +1 -1
  564. package/dist/cjs/types/internal-events/index.js +17 -17
  565. package/dist/cjs/types/open-exchange-rates-types.d.ts +10 -10
  566. package/dist/cjs/types/open-exchange-rates-types.js +2 -2
  567. package/dist/cjs/types/public-api-types.d.ts +24 -24
  568. package/dist/cjs/types/public-api-types.js +13 -13
  569. package/dist/cjs/types/public-api-types.js.map +1 -1
  570. package/dist/cjs/types/shopify-graphql-types/admin.generated.d.ts +123 -123
  571. package/dist/cjs/types/shopify-graphql-types/admin.generated.js +2 -2
  572. package/dist/cjs/types/shopify-graphql-types/admin.types.d.ts +26289 -26289
  573. package/dist/cjs/types/shopify-graphql-types/admin.types.js +5311 -5311
  574. package/dist/cjs/types/shopify-graphql-types/admin.types.js.map +1 -1
  575. package/dist/cjs/types/shopify-graphql-types/index.d.ts +2 -2
  576. package/dist/cjs/types/shopify-graphql-types/index.js +18 -18
  577. package/dist/cjs/types/shopify-rest-types.d.ts +767 -767
  578. package/dist/cjs/types/shopify-rest-types.js +2 -2
  579. package/dist/cjs/utils/compression.d.ts +34 -36
  580. package/dist/cjs/utils/compression.js +198 -198
  581. package/dist/cjs/utils/compression.js.map +1 -1
  582. package/dist/cjs/utils/custom-measure-formula-utils.d.ts +6 -6
  583. package/dist/cjs/utils/custom-measure-formula-utils.js +209 -209
  584. package/dist/cjs/utils/custom-measure-formula-utils.js.map +1 -1
  585. package/dist/cjs/utils/index.d.ts +4 -4
  586. package/dist/cjs/utils/index.js +20 -20
  587. package/dist/cjs/utils/retry-envelope.d.ts +12 -12
  588. package/dist/cjs/utils/retry-envelope.js +27 -28
  589. package/dist/cjs/utils/retry-envelope.js.map +1 -1
  590. package/dist/cjs/utils/size.d.ts +2 -2
  591. package/dist/cjs/utils/size.js +48 -49
  592. package/dist/cjs/utils/size.js.map +1 -1
  593. package/dist/esm/__tests__/clients/acuity-client.spec.d.ts +1 -1
  594. package/dist/esm/__tests__/clients/acuity-client.spec.js +42 -41
  595. package/dist/esm/__tests__/clients/acuity-client.spec.js.map +1 -1
  596. package/dist/esm/__tests__/clients/client-timeout-inventory.spec.d.ts +1 -0
  597. package/dist/esm/__tests__/clients/client-timeout-inventory.spec.js +19 -0
  598. package/dist/esm/__tests__/clients/client-timeout-inventory.spec.js.map +1 -0
  599. package/dist/esm/__tests__/clients/cross-platform-compression.spec.d.ts +1 -1
  600. package/dist/esm/__tests__/clients/cross-platform-compression.spec.js +330 -329
  601. package/dist/esm/__tests__/clients/cross-platform-compression.spec.js.map +1 -1
  602. package/dist/esm/__tests__/clients/dynamodb-client.spec.d.ts +1 -1
  603. package/dist/esm/__tests__/clients/dynamodb-client.spec.js +191 -192
  604. package/dist/esm/__tests__/clients/dynamodb-client.spec.js.map +1 -1
  605. package/dist/esm/__tests__/clients/event-collector-client.spec.d.ts +1 -1
  606. package/dist/esm/__tests__/clients/event-collector-client.spec.js +225 -225
  607. package/dist/esm/__tests__/clients/event-collector-client.spec.js.map +1 -1
  608. package/dist/esm/__tests__/clients/open-exchange-rates-client.spec.d.ts +1 -1
  609. package/dist/esm/__tests__/clients/open-exchange-rates-client.spec.js +54 -53
  610. package/dist/esm/__tests__/clients/open-exchange-rates-client.spec.js.map +1 -1
  611. package/dist/esm/__tests__/clients/redis-client.spec.d.ts +1 -0
  612. package/dist/esm/__tests__/clients/redis-client.spec.js +77 -0
  613. package/dist/esm/__tests__/clients/redis-client.spec.js.map +1 -0
  614. package/dist/esm/__tests__/clients/sqs-bundled-client.spec.d.ts +1 -1
  615. package/dist/esm/__tests__/clients/sqs-bundled-client.spec.js +914 -906
  616. package/dist/esm/__tests__/clients/sqs-bundled-client.spec.js.map +1 -1
  617. package/dist/esm/__tests__/clients/sqs-bundling-contracts.spec.d.ts +1 -1
  618. package/dist/esm/__tests__/clients/sqs-bundling-contracts.spec.js +540 -538
  619. package/dist/esm/__tests__/clients/sqs-bundling-contracts.spec.js.map +1 -1
  620. package/dist/esm/__tests__/clients/sqs-client.spec.d.ts +1 -1
  621. package/dist/esm/__tests__/clients/sqs-client.spec.js +190 -189
  622. package/dist/esm/__tests__/clients/sqs-client.spec.js.map +1 -1
  623. package/dist/esm/__tests__/clients/sqs-unbundle.spec.d.ts +1 -1
  624. package/dist/esm/__tests__/clients/sqs-unbundle.spec.js +1356 -1355
  625. package/dist/esm/__tests__/clients/sqs-unbundle.spec.js.map +1 -1
  626. package/dist/esm/__tests__/db/contact-enrichments-db-service.spec.d.ts +1 -1
  627. package/dist/esm/__tests__/db/contact-enrichments-db-service.spec.js +67 -66
  628. package/dist/esm/__tests__/db/contact-enrichments-db-service.spec.js.map +1 -1
  629. package/dist/esm/__tests__/db/destinations-db-service.spec.d.ts +1 -1
  630. package/dist/esm/__tests__/db/destinations-db-service.spec.js +121 -123
  631. package/dist/esm/__tests__/db/destinations-db-service.spec.js.map +1 -1
  632. package/dist/esm/__tests__/db/products-db-service.spec.d.ts +1 -1
  633. package/dist/esm/__tests__/db/products-db-service.spec.js +88 -87
  634. package/dist/esm/__tests__/db/products-db-service.spec.js.map +1 -1
  635. package/dist/esm/__tests__/db/shared-read-db-services.spec.d.ts +1 -1
  636. package/dist/esm/__tests__/db/shared-read-db-services.spec.js +88 -87
  637. package/dist/esm/__tests__/db/shared-read-db-services.spec.js.map +1 -1
  638. package/dist/esm/__tests__/db/shopify-app-installs-db-service.spec.d.ts +1 -1
  639. package/dist/esm/__tests__/db/shopify-app-installs-db-service.spec.js +103 -102
  640. package/dist/esm/__tests__/db/shopify-app-installs-db-service.spec.js.map +1 -1
  641. package/dist/esm/__tests__/db/subscriptions-db-service.spec.d.ts +1 -1
  642. package/dist/esm/__tests__/db/subscriptions-db-service.spec.js +94 -93
  643. package/dist/esm/__tests__/db/subscriptions-db-service.spec.js.map +1 -1
  644. package/dist/esm/__tests__/db/user-accounts-db-service.spec.d.ts +1 -1
  645. package/dist/esm/__tests__/db/user-accounts-db-service.spec.js +75 -74
  646. package/dist/esm/__tests__/db/user-accounts-db-service.spec.js.map +1 -1
  647. package/dist/esm/__tests__/helpers/account-users-helper.spec.d.ts +1 -1
  648. package/dist/esm/__tests__/helpers/account-users-helper.spec.js +219 -218
  649. package/dist/esm/__tests__/helpers/account-users-helper.spec.js.map +1 -1
  650. package/dist/esm/__tests__/helpers/acuity-helper.spec.d.ts +1 -1
  651. package/dist/esm/__tests__/helpers/acuity-helper.spec.js +68 -67
  652. package/dist/esm/__tests__/helpers/acuity-helper.spec.js.map +1 -1
  653. package/dist/esm/__tests__/helpers/api-key-auth-helper.spec.d.ts +1 -1
  654. package/dist/esm/__tests__/helpers/api-key-auth-helper.spec.js +81 -80
  655. package/dist/esm/__tests__/helpers/api-key-auth-helper.spec.js.map +1 -1
  656. package/dist/esm/__tests__/helpers/cognito-auth-helper.spec.d.ts +1 -1
  657. package/dist/esm/__tests__/helpers/cognito-auth-helper.spec.js +45 -44
  658. package/dist/esm/__tests__/helpers/cognito-auth-helper.spec.js.map +1 -1
  659. package/dist/esm/__tests__/helpers/order-calculation-helper.spec.d.ts +1 -1
  660. package/dist/esm/__tests__/helpers/order-calculation-helper.spec.js +151 -150
  661. package/dist/esm/__tests__/helpers/order-calculation-helper.spec.js.map +1 -1
  662. package/dist/esm/__tests__/helpers/public-api-response-helper.spec.d.ts +1 -1
  663. package/dist/esm/__tests__/helpers/public-api-response-helper.spec.js +56 -55
  664. package/dist/esm/__tests__/helpers/public-api-response-helper.spec.js.map +1 -1
  665. package/dist/esm/__tests__/identity-cache/helpers.spec.d.ts +1 -1
  666. package/dist/esm/__tests__/identity-cache/helpers.spec.js +591 -590
  667. package/dist/esm/__tests__/identity-cache/helpers.spec.js.map +1 -1
  668. package/dist/esm/__tests__/identity-cache/identity-cache-alias-write.spec.d.ts +1 -1
  669. package/dist/esm/__tests__/identity-cache/identity-cache-alias-write.spec.js +69 -68
  670. package/dist/esm/__tests__/identity-cache/identity-cache-alias-write.spec.js.map +1 -1
  671. package/dist/esm/__tests__/identity-cache/identity-cache-db-service.spec.d.ts +1 -1
  672. package/dist/esm/__tests__/identity-cache/identity-cache-db-service.spec.js +675 -674
  673. package/dist/esm/__tests__/identity-cache/identity-cache-db-service.spec.js.map +1 -1
  674. package/dist/esm/__tests__/identity-cache/identity-cache-dynamodb-db-service.spec.d.ts +1 -1
  675. package/dist/esm/__tests__/identity-cache/identity-cache-dynamodb-db-service.spec.js +748 -725
  676. package/dist/esm/__tests__/identity-cache/identity-cache-dynamodb-db-service.spec.js.map +1 -1
  677. package/dist/esm/__tests__/identity-cache/identity-cache-tier-routing.spec.d.ts +1 -1
  678. package/dist/esm/__tests__/identity-cache/identity-cache-tier-routing.spec.js +638 -629
  679. package/dist/esm/__tests__/identity-cache/identity-cache-tier-routing.spec.js.map +1 -1
  680. package/dist/esm/__tests__/identity-cache/identity-client.spec.d.ts +1 -1
  681. package/dist/esm/__tests__/identity-cache/identity-client.spec.js +360 -357
  682. package/dist/esm/__tests__/identity-cache/identity-client.spec.js.map +1 -1
  683. package/dist/esm/__tests__/identity-cache/identity-gateway-cache-hit.spec.d.ts +1 -1
  684. package/dist/esm/__tests__/identity-cache/identity-gateway-cache-hit.spec.js +136 -135
  685. package/dist/esm/__tests__/identity-cache/identity-gateway-cache-hit.spec.js.map +1 -1
  686. package/dist/esm/__tests__/identity-cache/identity-gateway-cache-miss.spec.d.ts +1 -1
  687. package/dist/esm/__tests__/identity-cache/identity-gateway-cache-miss.spec.js +163 -150
  688. package/dist/esm/__tests__/identity-cache/identity-gateway-cache-miss.spec.js.map +1 -1
  689. package/dist/esm/__tests__/identity-cache/identity-gateway-constructor.spec.d.ts +1 -1
  690. package/dist/esm/__tests__/identity-cache/identity-gateway-constructor.spec.js +70 -69
  691. package/dist/esm/__tests__/identity-cache/identity-gateway-constructor.spec.js.map +1 -1
  692. package/dist/esm/__tests__/identity-cache/identity-gateway-edge-cases.spec.d.ts +1 -1
  693. package/dist/esm/__tests__/identity-cache/identity-gateway-edge-cases.spec.js +93 -86
  694. package/dist/esm/__tests__/identity-cache/identity-gateway-edge-cases.spec.js.map +1 -1
  695. package/dist/esm/__tests__/identity-cache/identity-gateway-enqueue-async.spec.d.ts +1 -1
  696. package/dist/esm/__tests__/identity-cache/identity-gateway-enqueue-async.spec.js +134 -133
  697. package/dist/esm/__tests__/identity-cache/identity-gateway-enqueue-async.spec.js.map +1 -1
  698. package/dist/esm/__tests__/identity-cache/identity-gateway-stale-cache.spec.d.ts +1 -1
  699. package/dist/esm/__tests__/identity-cache/identity-gateway-stale-cache.spec.js +243 -221
  700. package/dist/esm/__tests__/identity-cache/identity-gateway-stale-cache.spec.js.map +1 -1
  701. package/dist/esm/__tests__/identity-cache/identity-gateway-test-setup.d.ts +24 -28
  702. package/dist/esm/__tests__/identity-cache/identity-gateway-test-setup.js +89 -82
  703. package/dist/esm/__tests__/identity-cache/identity-gateway-test-setup.js.map +1 -1
  704. package/dist/esm/__tests__/identity-cache/trait-merging-and-staleness.spec.d.ts +1 -1
  705. package/dist/esm/__tests__/identity-cache/trait-merging-and-staleness.spec.js +1747 -1768
  706. package/dist/esm/__tests__/identity-cache/trait-merging-and-staleness.spec.js.map +1 -1
  707. package/dist/esm/__tests__/identity-cache/volatile-traits-optimization.spec.d.ts +1 -1
  708. package/dist/esm/__tests__/identity-cache/volatile-traits-optimization.spec.js +817 -816
  709. package/dist/esm/__tests__/identity-cache/volatile-traits-optimization.spec.js.map +1 -1
  710. package/dist/esm/__tests__/integration/sqs-bundling-roundtrip.spec.d.ts +1 -1
  711. package/dist/esm/__tests__/integration/sqs-bundling-roundtrip.spec.js +583 -582
  712. package/dist/esm/__tests__/integration/sqs-bundling-roundtrip.spec.js.map +1 -1
  713. package/dist/esm/__tests__/libs/compress-decompress.spec.d.ts +1 -1
  714. package/dist/esm/__tests__/libs/compress-decompress.spec.js +15 -14
  715. package/dist/esm/__tests__/libs/compress-decompress.spec.js.map +1 -1
  716. package/dist/esm/__tests__/libs/contacts.spec.d.ts +1 -1
  717. package/dist/esm/__tests__/libs/contacts.spec.js +293 -292
  718. package/dist/esm/__tests__/libs/contacts.spec.js.map +1 -1
  719. package/dist/esm/__tests__/libs/currency.spec.d.ts +1 -1
  720. package/dist/esm/__tests__/libs/currency.spec.js +219 -218
  721. package/dist/esm/__tests__/libs/currency.spec.js.map +1 -1
  722. package/dist/esm/__tests__/libs/dates.spec.d.ts +1 -1
  723. package/dist/esm/__tests__/libs/dates.spec.js +129 -128
  724. package/dist/esm/__tests__/libs/dates.spec.js.map +1 -1
  725. package/dist/esm/__tests__/libs/domain.spec.d.ts +1 -1
  726. package/dist/esm/__tests__/libs/domain.spec.js +106 -105
  727. package/dist/esm/__tests__/libs/domain.spec.js.map +1 -1
  728. package/dist/esm/__tests__/libs/numbers.spec.d.ts +1 -1
  729. package/dist/esm/__tests__/libs/numbers.spec.js +260 -259
  730. package/dist/esm/__tests__/libs/numbers.spec.js.map +1 -1
  731. package/dist/esm/__tests__/s3-client/s3-client.spec.d.ts +1 -1
  732. package/dist/esm/__tests__/s3-client/s3-client.spec.js +30 -31
  733. package/dist/esm/__tests__/s3-client/s3-client.spec.js.map +1 -1
  734. package/dist/esm/__tests__/services/acuity-api-service.spec.d.ts +1 -1
  735. package/dist/esm/__tests__/services/acuity-api-service.spec.js +72 -69
  736. package/dist/esm/__tests__/services/acuity-api-service.spec.js.map +1 -1
  737. package/dist/esm/__tests__/services/cost/cost-calculation-types.spec.d.ts +1 -1
  738. package/dist/esm/__tests__/services/cost/cost-calculation-types.spec.js +22 -21
  739. package/dist/esm/__tests__/services/cost/cost-calculation-types.spec.js.map +1 -1
  740. package/dist/esm/__tests__/services/cost/cost-calculator-service.spec.d.ts +1 -1
  741. package/dist/esm/__tests__/services/cost/cost-calculator-service.spec.js +3597 -3359
  742. package/dist/esm/__tests__/services/cost/cost-calculator-service.spec.js.map +1 -1
  743. package/dist/esm/__tests__/services/cost/cost-currency-service.spec.d.ts +1 -1
  744. package/dist/esm/__tests__/services/cost/cost-currency-service.spec.js +113 -112
  745. package/dist/esm/__tests__/services/cost/cost-currency-service.spec.js.map +1 -1
  746. package/dist/esm/__tests__/services/cost/cost-filter-service.spec.d.ts +1 -1
  747. package/dist/esm/__tests__/services/cost/cost-filter-service.spec.js +463 -466
  748. package/dist/esm/__tests__/services/cost/cost-filter-service.spec.js.map +1 -1
  749. package/dist/esm/__tests__/services/cost/order-cost/order-cost-resolution-service.spec.d.ts +1 -1
  750. package/dist/esm/__tests__/services/cost/order-cost/order-cost-resolution-service.spec.js +450 -358
  751. package/dist/esm/__tests__/services/cost/order-cost/order-cost-resolution-service.spec.js.map +1 -1
  752. package/dist/esm/__tests__/services/currency-exchange-rate-lookup-service.spec.d.ts +1 -1
  753. package/dist/esm/__tests__/services/currency-exchange-rate-lookup-service.spec.js +37 -32
  754. package/dist/esm/__tests__/services/currency-exchange-rate-lookup-service.spec.js.map +1 -1
  755. package/dist/esm/__tests__/services/email-verification/contact-email-verification-service.spec.d.ts +1 -1
  756. package/dist/esm/__tests__/services/email-verification/contact-email-verification-service.spec.js +93 -91
  757. package/dist/esm/__tests__/services/email-verification/contact-email-verification-service.spec.js.map +1 -1
  758. package/dist/esm/__tests__/services/email-verification/email-verification-service.spec.d.ts +1 -1
  759. package/dist/esm/__tests__/services/email-verification/email-verification-service.spec.js +60 -55
  760. package/dist/esm/__tests__/services/email-verification/email-verification-service.spec.js.map +1 -1
  761. package/dist/esm/__tests__/services/events/collect-queue-tracking-service.spec.d.ts +1 -1
  762. package/dist/esm/__tests__/services/events/collect-queue-tracking-service.spec.js +230 -227
  763. package/dist/esm/__tests__/services/events/collect-queue-tracking-service.spec.js.map +1 -1
  764. package/dist/esm/__tests__/services/events/tracking-event-sqs-service.spec.d.ts +1 -1
  765. package/dist/esm/__tests__/services/events/tracking-event-sqs-service.spec.js +192 -189
  766. package/dist/esm/__tests__/services/events/tracking-event-sqs-service.spec.js.map +1 -1
  767. package/dist/esm/__tests__/shopify/shopify-graphql-transformer.spec.d.ts +1 -1
  768. package/dist/esm/__tests__/shopify/shopify-graphql-transformer.spec.js +34 -33
  769. package/dist/esm/__tests__/shopify/shopify-graphql-transformer.spec.js.map +1 -1
  770. package/dist/esm/__tests__/unit/libs/api-router/public-api-router.spec.d.ts +1 -1
  771. package/dist/esm/__tests__/unit/libs/api-router/public-api-router.spec.js +157 -156
  772. package/dist/esm/__tests__/unit/libs/api-router/public-api-router.spec.js.map +1 -1
  773. package/dist/esm/__tests__/unit/libs/api-router/route-matcher.spec.d.ts +1 -1
  774. package/dist/esm/__tests__/unit/libs/api-router/route-matcher.spec.js +68 -67
  775. package/dist/esm/__tests__/unit/libs/api-router/route-matcher.spec.js.map +1 -1
  776. package/dist/esm/__tests__/utils/custom-measure-formula-utils.spec.d.ts +1 -1
  777. package/dist/esm/__tests__/utils/custom-measure-formula-utils.spec.js +145 -144
  778. package/dist/esm/__tests__/utils/custom-measure-formula-utils.spec.js.map +1 -1
  779. package/dist/esm/clients/generic/cognito-client.d.ts +23 -23
  780. package/dist/esm/clients/generic/cognito-client.js +204 -204
  781. package/dist/esm/clients/generic/cognito-client.js.map +1 -1
  782. package/dist/esm/clients/generic/dynamodb-client.d.ts +20 -20
  783. package/dist/esm/clients/generic/dynamodb-client.js +231 -231
  784. package/dist/esm/clients/generic/dynamodb-client.js.map +1 -1
  785. package/dist/esm/clients/generic/eventbridge-client.d.ts +14 -14
  786. package/dist/esm/clients/generic/eventbridge-client.js +47 -47
  787. package/dist/esm/clients/generic/eventbridge-client.js.map +1 -1
  788. package/dist/esm/clients/generic/http-client.d.ts +14 -14
  789. package/dist/esm/clients/generic/http-client.js +53 -53
  790. package/dist/esm/clients/generic/http-client.js.map +1 -1
  791. package/dist/esm/clients/generic/index.d.ts +13 -13
  792. package/dist/esm/clients/generic/index.js +13 -13
  793. package/dist/esm/clients/generic/lambda-invoke-client.d.ts +10 -10
  794. package/dist/esm/clients/generic/lambda-invoke-client.js +35 -35
  795. package/dist/esm/clients/generic/lambda-invoke-client.js.map +1 -1
  796. package/dist/esm/clients/generic/location-client.d.ts +8 -8
  797. package/dist/esm/clients/generic/location-client.js +27 -27
  798. package/dist/esm/clients/generic/location-client.js.map +1 -1
  799. package/dist/esm/clients/generic/redis-client.d.ts +33 -33
  800. package/dist/esm/clients/generic/redis-client.js +195 -184
  801. package/dist/esm/clients/generic/redis-client.js.map +1 -1
  802. package/dist/esm/clients/generic/s3-client.d.ts +22 -23
  803. package/dist/esm/clients/generic/s3-client.js +209 -209
  804. package/dist/esm/clients/generic/s3-client.js.map +1 -1
  805. package/dist/esm/clients/generic/singlestore-db-client.d.ts +21 -21
  806. package/dist/esm/clients/generic/singlestore-db-client.js +65 -65
  807. package/dist/esm/clients/generic/singlestore-db-client.js.map +1 -1
  808. package/dist/esm/clients/generic/sqs-bundled-client.d.ts +15 -15
  809. package/dist/esm/clients/generic/sqs-bundled-client.js +307 -307
  810. package/dist/esm/clients/generic/sqs-bundled-client.js.map +1 -1
  811. package/dist/esm/clients/generic/sqs-bundled-client.types.d.ts +53 -53
  812. package/dist/esm/clients/generic/sqs-bundled-client.types.js +14 -14
  813. package/dist/esm/clients/generic/sqs-client.d.ts +53 -53
  814. package/dist/esm/clients/generic/sqs-client.js +281 -281
  815. package/dist/esm/clients/generic/sqs-client.js.map +1 -1
  816. package/dist/esm/clients/generic/sqs-unbundle.d.ts +32 -32
  817. package/dist/esm/clients/generic/sqs-unbundle.js +137 -137
  818. package/dist/esm/clients/generic/sqs-unbundle.js.map +1 -1
  819. package/dist/esm/clients/index.d.ts +3 -3
  820. package/dist/esm/clients/index.js +3 -3
  821. package/dist/esm/clients/internal-api/accounts-client.d.ts +91 -91
  822. package/dist/esm/clients/internal-api/accounts-client.js +125 -125
  823. package/dist/esm/clients/internal-api/accounts-client.js.map +1 -1
  824. package/dist/esm/clients/internal-api/cache-lambda-client.d.ts +26 -26
  825. package/dist/esm/clients/internal-api/cache-lambda-client.js +85 -85
  826. package/dist/esm/clients/internal-api/cache-lambda-client.js.map +1 -1
  827. package/dist/esm/clients/internal-api/db-management-client.d.ts +18 -18
  828. package/dist/esm/clients/internal-api/db-management-client.js +32 -32
  829. package/dist/esm/clients/internal-api/destinations-client.d.ts +34 -34
  830. package/dist/esm/clients/internal-api/destinations-client.js +75 -75
  831. package/dist/esm/clients/internal-api/destinations-client.js.map +1 -1
  832. package/dist/esm/clients/internal-api/event-collector-client.d.ts +122 -122
  833. package/dist/esm/clients/internal-api/event-collector-client.js +74 -74
  834. package/dist/esm/clients/internal-api/event-collector-client.js.map +1 -1
  835. package/dist/esm/clients/internal-api/identity-client.d.ts +41 -41
  836. package/dist/esm/clients/internal-api/identity-client.js +133 -133
  837. package/dist/esm/clients/internal-api/identity-client.js.map +1 -1
  838. package/dist/esm/clients/internal-api/index.d.ts +9 -9
  839. package/dist/esm/clients/internal-api/index.js +9 -9
  840. package/dist/esm/clients/internal-api/shopify-app-install-client.d.ts +37 -37
  841. package/dist/esm/clients/internal-api/shopify-app-install-client.js +77 -77
  842. package/dist/esm/clients/internal-api/subscriptions-client.d.ts +26 -26
  843. package/dist/esm/clients/internal-api/subscriptions-client.js +73 -73
  844. package/dist/esm/clients/internal-api/users-auth-client.d.ts +35 -35
  845. package/dist/esm/clients/internal-api/users-auth-client.js +106 -106
  846. package/dist/esm/clients/internal-api/users-auth-client.js.map +1 -1
  847. package/dist/esm/clients/third-party/acuity-client.d.ts +10 -10
  848. package/dist/esm/clients/third-party/acuity-client.js +36 -36
  849. package/dist/esm/clients/third-party/emailable-client.d.ts +7 -7
  850. package/dist/esm/clients/third-party/emailable-client.js +21 -21
  851. package/dist/esm/clients/third-party/emailable-client.js.map +1 -1
  852. package/dist/esm/clients/third-party/exchange-rate-api-client.d.ts +17 -17
  853. package/dist/esm/clients/third-party/exchange-rate-api-client.js +15 -15
  854. package/dist/esm/clients/third-party/index.d.ts +6 -6
  855. package/dist/esm/clients/third-party/index.js +6 -6
  856. package/dist/esm/clients/third-party/loops-client.d.ts +10 -10
  857. package/dist/esm/clients/third-party/loops-client.js +26 -26
  858. package/dist/esm/clients/third-party/loops-client.js.map +1 -1
  859. package/dist/esm/clients/third-party/open-exchange-rates-client.d.ts +8 -8
  860. package/dist/esm/clients/third-party/open-exchange-rates-client.js +23 -23
  861. package/dist/esm/clients/third-party/open-exchange-rates-client.js.map +1 -1
  862. package/dist/esm/clients/third-party/shopify/graphql-analytics-queries.d.ts +18 -18
  863. package/dist/esm/clients/third-party/shopify/graphql-analytics-queries.js +19 -19
  864. package/dist/esm/clients/third-party/shopify/graphql-order-queries.d.ts +25 -25
  865. package/dist/esm/clients/third-party/shopify/graphql-order-queries.js +1 -1
  866. package/dist/esm/clients/third-party/shopify/graphql-product-queries.d.ts +2 -2
  867. package/dist/esm/clients/third-party/shopify/graphql-product-queries.js +2 -2
  868. package/dist/esm/clients/third-party/shopify/shopify-graphql-client.d.ts +42 -42
  869. package/dist/esm/clients/third-party/shopify/shopify-graphql-client.js +348 -348
  870. package/dist/esm/clients/third-party/shopify/shopify-graphql-client.js.map +1 -1
  871. package/dist/esm/clients/third-party/shopify-client.d.ts +29 -29
  872. package/dist/esm/clients/third-party/shopify-client.js +142 -142
  873. package/dist/esm/clients/third-party/shopify-client.js.map +1 -1
  874. package/dist/esm/constants/index.d.ts +1 -1
  875. package/dist/esm/constants/index.js +1 -1
  876. package/dist/esm/constants/sqs.d.ts +20 -20
  877. package/dist/esm/constants/sqs.js +22 -22
  878. package/dist/esm/constants/sqs.js.map +1 -1
  879. package/dist/esm/helpers/account-users-helper.d.ts +2 -2
  880. package/dist/esm/helpers/account-users-helper.js +18 -18
  881. package/dist/esm/helpers/account-users-helper.js.map +1 -1
  882. package/dist/esm/helpers/acuity-helper.d.ts +4 -4
  883. package/dist/esm/helpers/acuity-helper.js +51 -51
  884. package/dist/esm/helpers/acuity-helper.js.map +1 -1
  885. package/dist/esm/helpers/api-key-auth-helper.d.ts +10 -9
  886. package/dist/esm/helpers/api-key-auth-helper.js +35 -35
  887. package/dist/esm/helpers/api-key-auth-helper.js.map +1 -1
  888. package/dist/esm/helpers/api-key-authorizer-helper.d.ts +36 -36
  889. package/dist/esm/helpers/api-key-authorizer-helper.js +83 -83
  890. package/dist/esm/helpers/api-key-authorizer-helper.js.map +1 -1
  891. package/dist/esm/helpers/cognito-auth-helper.d.ts +6 -5
  892. package/dist/esm/helpers/cognito-auth-helper.js +10 -10
  893. package/dist/esm/helpers/cognito-auth-helper.js.map +1 -1
  894. package/dist/esm/helpers/index.d.ts +12 -12
  895. package/dist/esm/helpers/index.js +12 -12
  896. package/dist/esm/helpers/input-validation-helper.d.ts +3 -3
  897. package/dist/esm/helpers/input-validation-helper.js +18 -18
  898. package/dist/esm/helpers/input-validation-helper.js.map +1 -1
  899. package/dist/esm/helpers/logging-helper.d.ts +16 -16
  900. package/dist/esm/helpers/logging-helper.js +56 -56
  901. package/dist/esm/helpers/logging-helper.js.map +1 -1
  902. package/dist/esm/helpers/order-calculation-helper.d.ts +13 -13
  903. package/dist/esm/helpers/order-calculation-helper.js +111 -111
  904. package/dist/esm/helpers/order-calculation-helper.js.map +1 -1
  905. package/dist/esm/helpers/public-api-response-helper.d.ts +21 -21
  906. package/dist/esm/helpers/public-api-response-helper.js +38 -38
  907. package/dist/esm/helpers/public-api-response-helper.js.map +1 -1
  908. package/dist/esm/helpers/response-helper.d.ts +18 -18
  909. package/dist/esm/helpers/response-helper.js +37 -37
  910. package/dist/esm/helpers/response-helper.js.map +1 -1
  911. package/dist/esm/helpers/shopify-helper.d.ts +9 -9
  912. package/dist/esm/helpers/shopify-helper.js +21 -21
  913. package/dist/esm/helpers/shopify-helper.js.map +1 -1
  914. package/dist/esm/helpers/sqs-utils.d.ts +6 -6
  915. package/dist/esm/helpers/sqs-utils.js +14 -9
  916. package/dist/esm/helpers/sqs-utils.js.map +1 -1
  917. package/dist/esm/index.d.ts +7 -7
  918. package/dist/esm/index.js +7 -7
  919. package/dist/esm/libs/api-router/index.d.ts +2 -2
  920. package/dist/esm/libs/api-router/index.js +2 -2
  921. package/dist/esm/libs/api-router/public-api-router.d.ts +3 -3
  922. package/dist/esm/libs/api-router/public-api-router.js +32 -32
  923. package/dist/esm/libs/api-router/public-api-router.js.map +1 -1
  924. package/dist/esm/libs/api-router/route-matcher.d.ts +21 -21
  925. package/dist/esm/libs/api-router/route-matcher.js +30 -30
  926. package/dist/esm/libs/api-router/route-matcher.js.map +1 -1
  927. package/dist/esm/libs/click-id-parser.d.ts +23 -23
  928. package/dist/esm/libs/click-id-parser.js +45 -45
  929. package/dist/esm/libs/click-id-parser.js.map +1 -1
  930. package/dist/esm/libs/compression.d.ts +2 -2
  931. package/dist/esm/libs/compression.js +25 -25
  932. package/dist/esm/libs/compression.js.map +1 -1
  933. package/dist/esm/libs/contacts.d.ts +7 -7
  934. package/dist/esm/libs/contacts.js +143 -143
  935. package/dist/esm/libs/contacts.js.map +1 -1
  936. package/dist/esm/libs/cookie.d.ts +17 -17
  937. package/dist/esm/libs/cookie.js +70 -70
  938. package/dist/esm/libs/cookie.js.map +1 -1
  939. package/dist/esm/libs/crypto.d.ts +4 -4
  940. package/dist/esm/libs/crypto.js +15 -15
  941. package/dist/esm/libs/csv.d.ts +2 -2
  942. package/dist/esm/libs/csv.js +30 -30
  943. package/dist/esm/libs/csv.js.map +1 -1
  944. package/dist/esm/libs/currency.d.ts +1 -1
  945. package/dist/esm/libs/currency.js +22 -22
  946. package/dist/esm/libs/currency.js.map +1 -1
  947. package/dist/esm/libs/dates.d.ts +12 -12
  948. package/dist/esm/libs/dates.js +83 -83
  949. package/dist/esm/libs/dates.js.map +1 -1
  950. package/dist/esm/libs/domain.d.ts +2 -2
  951. package/dist/esm/libs/domain.js +33 -33
  952. package/dist/esm/libs/domain.js.map +1 -1
  953. package/dist/esm/libs/emails.d.ts +8 -8
  954. package/dist/esm/libs/emails.js +146 -146
  955. package/dist/esm/libs/emails.js.map +1 -1
  956. package/dist/esm/libs/http-error.d.ts +21 -21
  957. package/dist/esm/libs/http-error.js +59 -59
  958. package/dist/esm/libs/http-error.js.map +1 -1
  959. package/dist/esm/libs/http-status-codes.d.ts +58 -58
  960. package/dist/esm/libs/http-status-codes.js +59 -59
  961. package/dist/esm/libs/index.d.ts +19 -19
  962. package/dist/esm/libs/index.js +19 -19
  963. package/dist/esm/libs/numbers.d.ts +1 -1
  964. package/dist/esm/libs/numbers.js +11 -11
  965. package/dist/esm/libs/numbers.js.map +1 -1
  966. package/dist/esm/libs/referrer-parser/index.d.ts +2 -2
  967. package/dist/esm/libs/referrer-parser/index.js +2 -2
  968. package/dist/esm/libs/referrer-parser/referrer-data.d.ts +9 -9
  969. package/dist/esm/libs/referrer-parser/referrer-data.js +3304 -3304
  970. package/dist/esm/libs/referrer-parser/referrer-parser-util.d.ts +19 -20
  971. package/dist/esm/libs/referrer-parser/referrer-parser-util.js +124 -124
  972. package/dist/esm/libs/referrer-parser/referrer-parser-util.js.map +1 -1
  973. package/dist/esm/libs/strings.d.ts +3 -3
  974. package/dist/esm/libs/strings.js +40 -40
  975. package/dist/esm/libs/strings.js.map +1 -1
  976. package/dist/esm/libs/traits.d.ts +6 -6
  977. package/dist/esm/libs/traits.js +54 -54
  978. package/dist/esm/libs/traits.js.map +1 -1
  979. package/dist/esm/libs/url.d.ts +1 -1
  980. package/dist/esm/libs/url.js +9 -9
  981. package/dist/esm/services/acuity-api-service.d.ts +9 -9
  982. package/dist/esm/services/acuity-api-service.js +69 -69
  983. package/dist/esm/services/acuity-api-service.js.map +1 -1
  984. package/dist/esm/services/cache/generic-cached-object.d.ts +5 -5
  985. package/dist/esm/services/cache/generic-cached-object.js +1 -1
  986. package/dist/esm/services/cache/index.d.ts +1 -1
  987. package/dist/esm/services/cache/index.js +1 -1
  988. package/dist/esm/services/cache/product-cache-service.d.ts +21 -21
  989. package/dist/esm/services/cache/product-cache-service.js +68 -68
  990. package/dist/esm/services/cache/product-cache-service.js.map +1 -1
  991. package/dist/esm/services/cost/cost-calculation-types.d.ts +69 -69
  992. package/dist/esm/services/cost/cost-calculation-types.js +15 -15
  993. package/dist/esm/services/cost/cost-calculation-types.js.map +1 -1
  994. package/dist/esm/services/cost/cost-calculator-service.d.ts +24 -24
  995. package/dist/esm/services/cost/cost-calculator-service.js +489 -456
  996. package/dist/esm/services/cost/cost-calculator-service.js.map +1 -1
  997. package/dist/esm/services/cost/cost-currency-service.d.ts +6 -6
  998. package/dist/esm/services/cost/cost-currency-service.js +84 -84
  999. package/dist/esm/services/cost/cost-currency-service.js.map +1 -1
  1000. package/dist/esm/services/cost/cost-filter-service.d.ts +10 -10
  1001. package/dist/esm/services/cost/cost-filter-service.js +127 -118
  1002. package/dist/esm/services/cost/cost-filter-service.js.map +1 -1
  1003. package/dist/esm/services/cost/index.d.ts +5 -5
  1004. package/dist/esm/services/cost/index.js +5 -5
  1005. package/dist/esm/services/cost/order-cost/index.d.ts +2 -2
  1006. package/dist/esm/services/cost/order-cost/index.js +2 -2
  1007. package/dist/esm/services/cost/order-cost/order-cost-resolution-service.d.ts +23 -23
  1008. package/dist/esm/services/cost/order-cost/order-cost-resolution-service.js +302 -287
  1009. package/dist/esm/services/cost/order-cost/order-cost-resolution-service.js.map +1 -1
  1010. package/dist/esm/services/cost/order-cost/order-cost-resolution-types.d.ts +31 -31
  1011. package/dist/esm/services/cost/order-cost/order-cost-resolution-types.js +1 -1
  1012. package/dist/esm/services/currency-exchange-rate-lookup-service.d.ts +12 -12
  1013. package/dist/esm/services/currency-exchange-rate-lookup-service.js +93 -90
  1014. package/dist/esm/services/currency-exchange-rate-lookup-service.js.map +1 -1
  1015. package/dist/esm/services/db/accounts-db-service.d.ts +9 -9
  1016. package/dist/esm/services/db/accounts-db-service.js +29 -29
  1017. package/dist/esm/services/db/accounts-db-service.js.map +1 -1
  1018. package/dist/esm/services/db/api-keys-db-service.d.ts +10 -10
  1019. package/dist/esm/services/db/api-keys-db-service.js +32 -32
  1020. package/dist/esm/services/db/api-keys-db-service.js.map +1 -1
  1021. package/dist/esm/services/db/contact-enrichments-db-service.d.ts +15 -15
  1022. package/dist/esm/services/db/contact-enrichments-db-service.js +90 -90
  1023. package/dist/esm/services/db/contact-enrichments-db-service.js.map +1 -1
  1024. package/dist/esm/services/db/currency-exchange-rates-db-service.d.ts +21 -21
  1025. package/dist/esm/services/db/currency-exchange-rates-db-service.js +35 -35
  1026. package/dist/esm/services/db/custom-measures-db-service.d.ts +14 -14
  1027. package/dist/esm/services/db/custom-measures-db-service.js +44 -44
  1028. package/dist/esm/services/db/custom-measures-db-service.js.map +1 -1
  1029. package/dist/esm/services/db/destinations-db-service.d.ts +13 -13
  1030. package/dist/esm/services/db/destinations-db-service.js +70 -70
  1031. package/dist/esm/services/db/identity-cache-db-service.d.ts +28 -28
  1032. package/dist/esm/services/db/identity-cache-db-service.js +313 -313
  1033. package/dist/esm/services/db/identity-cache-db-service.js.map +1 -1
  1034. package/dist/esm/services/db/identity-cache-dynamodb-service/constants.d.ts +3 -3
  1035. package/dist/esm/services/db/identity-cache-dynamodb-service/constants.js +3 -3
  1036. package/dist/esm/services/db/identity-cache-dynamodb-service/identity-cache-dynamodb-db-service.d.ts +25 -25
  1037. package/dist/esm/services/db/identity-cache-dynamodb-service/identity-cache-dynamodb-db-service.js +525 -521
  1038. package/dist/esm/services/db/identity-cache-dynamodb-service/identity-cache-dynamodb-db-service.js.map +1 -1
  1039. package/dist/esm/services/db/identity-cache-dynamodb-service/identity-gateway-service.d.ts +23 -23
  1040. package/dist/esm/services/db/identity-cache-dynamodb-service/identity-gateway-service.js +232 -218
  1041. package/dist/esm/services/db/identity-cache-dynamodb-service/identity-gateway-service.js.map +1 -1
  1042. package/dist/esm/services/db/identity-cache-dynamodb-service/index.d.ts +4 -4
  1043. package/dist/esm/services/db/identity-cache-dynamodb-service/index.js +4 -4
  1044. package/dist/esm/services/db/identity-cache-dynamodb-service/key-builders.d.ts +12 -12
  1045. package/dist/esm/services/db/identity-cache-dynamodb-service/key-builders.js +23 -23
  1046. package/dist/esm/services/db/identity-cache-dynamodb-service/types.d.ts +82 -82
  1047. package/dist/esm/services/db/identity-cache-dynamodb-service/types.js +25 -25
  1048. package/dist/esm/services/db/identity-cache-dynamodb-service/types.js.map +1 -1
  1049. package/dist/esm/services/db/index.d.ts +22 -22
  1050. package/dist/esm/services/db/index.js +22 -22
  1051. package/dist/esm/services/db/log-events-db-service.d.ts +11 -11
  1052. package/dist/esm/services/db/log-events-db-service.js +177 -177
  1053. package/dist/esm/services/db/log-events-db-service.js.map +1 -1
  1054. package/dist/esm/services/db/pixels-db-service.d.ts +8 -8
  1055. package/dist/esm/services/db/pixels-db-service.js +31 -31
  1056. package/dist/esm/services/db/products-db-service-types.d.ts +10 -10
  1057. package/dist/esm/services/db/products-db-service-types.js +1 -1
  1058. package/dist/esm/services/db/products-db-service.d.ts +19 -19
  1059. package/dist/esm/services/db/products-db-service.js +306 -277
  1060. package/dist/esm/services/db/products-db-service.js.map +1 -1
  1061. package/dist/esm/services/db/purchasable-contacts-db-service.d.ts +9 -9
  1062. package/dist/esm/services/db/purchasable-contacts-db-service.js +39 -39
  1063. package/dist/esm/services/db/purchasable-contacts-db-service.js.map +1 -1
  1064. package/dist/esm/services/db/purchased-contacts/index.d.ts +2 -2
  1065. package/dist/esm/services/db/purchased-contacts/index.js +2 -2
  1066. package/dist/esm/services/db/purchased-contacts/purchased-contacts-db-service.d.ts +18 -18
  1067. package/dist/esm/services/db/purchased-contacts/purchased-contacts-db-service.js +148 -148
  1068. package/dist/esm/services/db/purchased-contacts/purchased-contacts-db-service.js.map +1 -1
  1069. package/dist/esm/services/db/purchased-contacts/types.d.ts +11 -11
  1070. package/dist/esm/services/db/purchased-contacts/types.js +1 -1
  1071. package/dist/esm/services/db/shopify-app-installs-db-service.d.ts +10 -10
  1072. package/dist/esm/services/db/shopify-app-installs-db-service.js +48 -48
  1073. package/dist/esm/services/db/shopify-app-installs-db-service.js.map +1 -1
  1074. package/dist/esm/services/db/shopify-products-cache-db-service.d.ts +16 -16
  1075. package/dist/esm/services/db/shopify-products-cache-db-service.js +66 -66
  1076. package/dist/esm/services/db/shopify-products-cache-db-service.js.map +1 -1
  1077. package/dist/esm/services/db/subscriptions-db-service.d.ts +11 -11
  1078. package/dist/esm/services/db/subscriptions-db-service.js +34 -34
  1079. package/dist/esm/services/db/subscriptions-db-service.js.map +1 -1
  1080. package/dist/esm/services/db/tracking-events-db-service.d.ts +21 -21
  1081. package/dist/esm/services/db/tracking-events-db-service.js +184 -184
  1082. package/dist/esm/services/db/tracking-events-db-service.js.map +1 -1
  1083. package/dist/esm/services/db/user-accounts-db-service.d.ts +7 -7
  1084. package/dist/esm/services/db/user-accounts-db-service.js +13 -13
  1085. package/dist/esm/services/email-verification/contact-email-verification-service.d.ts +7 -7
  1086. package/dist/esm/services/email-verification/contact-email-verification-service.js +97 -97
  1087. package/dist/esm/services/email-verification/contact-email-verification-service.js.map +1 -1
  1088. package/dist/esm/services/email-verification/email-verification-service.d.ts +19 -19
  1089. package/dist/esm/services/email-verification/email-verification-service.js +127 -127
  1090. package/dist/esm/services/email-verification/email-verification-service.js.map +1 -1
  1091. package/dist/esm/services/email-verification/index.d.ts +2 -2
  1092. package/dist/esm/services/email-verification/index.js +2 -2
  1093. package/dist/esm/services/eventbridge-integration-service.d.ts +9 -9
  1094. package/dist/esm/services/eventbridge-integration-service.js +24 -24
  1095. package/dist/esm/services/events/build-collect-queue-tracking-event.d.ts +11 -11
  1096. package/dist/esm/services/events/build-collect-queue-tracking-event.js +19 -19
  1097. package/dist/esm/services/events/build-collect-queue-tracking-event.js.map +1 -1
  1098. package/dist/esm/services/events/collect-queue-tracking-service.d.ts +12 -12
  1099. package/dist/esm/services/events/collect-queue-tracking-service.js +18 -18
  1100. package/dist/esm/services/events/collect-queue-tracking-service.js.map +1 -1
  1101. package/dist/esm/services/events/index.d.ts +5 -5
  1102. package/dist/esm/services/events/index.js +5 -5
  1103. package/dist/esm/services/events/log-event-service.d.ts +19 -19
  1104. package/dist/esm/services/events/log-event-service.js +73 -73
  1105. package/dist/esm/services/events/log-event-service.js.map +1 -1
  1106. package/dist/esm/services/events/metric-event-service.d.ts +9 -9
  1107. package/dist/esm/services/events/metric-event-service.js +45 -45
  1108. package/dist/esm/services/events/metric-event-service.js.map +1 -1
  1109. package/dist/esm/services/events/tracking-event-sqs-service.d.ts +8 -8
  1110. package/dist/esm/services/events/tracking-event-sqs-service.js +32 -32
  1111. package/dist/esm/services/events/tracking-event-sqs-service.js.map +1 -1
  1112. package/dist/esm/services/generic-cache-service.d.ts +7 -7
  1113. package/dist/esm/services/generic-cache-service.js +29 -29
  1114. package/dist/esm/services/generic-cache-service.js.map +1 -1
  1115. package/dist/esm/services/index.d.ts +11 -11
  1116. package/dist/esm/services/index.js +11 -11
  1117. package/dist/esm/services/ipdata-lookup-service.d.ts +20 -20
  1118. package/dist/esm/services/ipdata-lookup-service.js +108 -108
  1119. package/dist/esm/services/ipdata-lookup-service.js.map +1 -1
  1120. package/dist/esm/services/shopify/index.d.ts +2 -2
  1121. package/dist/esm/services/shopify/index.js +2 -2
  1122. package/dist/esm/services/shopify/products/index.d.ts +1 -1
  1123. package/dist/esm/services/shopify/products/index.js +1 -1
  1124. package/dist/esm/services/shopify/products/shopify-products-serviceV2.d.ts +17 -17
  1125. package/dist/esm/services/shopify/products/shopify-products-serviceV2.js +108 -108
  1126. package/dist/esm/services/shopify/products/shopify-products-serviceV2.js.map +1 -1
  1127. package/dist/esm/services/shopify/shopify-graphql-transformer.d.ts +8 -8
  1128. package/dist/esm/services/shopify/shopify-graphql-transformer.js +138 -138
  1129. package/dist/esm/services/shopify/shopify-graphql-transformer.js.map +1 -1
  1130. package/dist/esm/types/acuity-types.d.ts +74 -74
  1131. package/dist/esm/types/acuity-types.js +1 -1
  1132. package/dist/esm/types/api-response.d.ts +6 -6
  1133. package/dist/esm/types/api-response.js +1 -1
  1134. package/dist/esm/types/index.d.ts +6 -6
  1135. package/dist/esm/types/index.js +6 -6
  1136. package/dist/esm/types/internal-events/event-detail-types.d.ts +20 -20
  1137. package/dist/esm/types/internal-events/event-detail-types.js +24 -24
  1138. package/dist/esm/types/internal-events/index.d.ts +1 -1
  1139. package/dist/esm/types/internal-events/index.js +1 -1
  1140. package/dist/esm/types/open-exchange-rates-types.d.ts +10 -10
  1141. package/dist/esm/types/open-exchange-rates-types.js +1 -1
  1142. package/dist/esm/types/public-api-types.d.ts +24 -24
  1143. package/dist/esm/types/public-api-types.js +10 -10
  1144. package/dist/esm/types/shopify-graphql-types/admin.generated.d.ts +123 -123
  1145. package/dist/esm/types/shopify-graphql-types/admin.generated.js +1 -1
  1146. package/dist/esm/types/shopify-graphql-types/admin.types.d.ts +26289 -26289
  1147. package/dist/esm/types/shopify-graphql-types/admin.types.js +5299 -5299
  1148. package/dist/esm/types/shopify-graphql-types/index.d.ts +2 -2
  1149. package/dist/esm/types/shopify-graphql-types/index.js +2 -2
  1150. package/dist/esm/types/shopify-rest-types.d.ts +767 -767
  1151. package/dist/esm/types/shopify-rest-types.js +1 -1
  1152. package/dist/esm/utils/compression.d.ts +34 -36
  1153. package/dist/esm/utils/compression.js +187 -187
  1154. package/dist/esm/utils/compression.js.map +1 -1
  1155. package/dist/esm/utils/custom-measure-formula-utils.d.ts +6 -6
  1156. package/dist/esm/utils/custom-measure-formula-utils.js +201 -201
  1157. package/dist/esm/utils/custom-measure-formula-utils.js.map +1 -1
  1158. package/dist/esm/utils/index.d.ts +4 -4
  1159. package/dist/esm/utils/index.js +4 -4
  1160. package/dist/esm/utils/retry-envelope.d.ts +12 -12
  1161. package/dist/esm/utils/retry-envelope.js +22 -22
  1162. package/dist/esm/utils/retry-envelope.js.map +1 -1
  1163. package/dist/esm/utils/size.d.ts +2 -2
  1164. package/dist/esm/utils/size.js +44 -44
  1165. package/dist/esm/utils/size.js.map +1 -1
  1166. package/package.json +45 -40
@@ -1,1771 +1,1750 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const at_tracking_event_types_1 = require("@adtrackify/at-tracking-event-types");
4
- const at_shared_utils_1 = require("@adtrackify/at-shared-utils");
5
- describe('Identity Trait Merging Tests', () => {
6
- afterEach(() => {
7
- jest.resetModules();
8
- });
9
- describe('mergeIdentityTraits function', () => {
10
- it('should merge simple string arrays correctly', () => {
11
- const incomingTraits = {
12
- emails: ['new@email.com'],
13
- userIds: ['user1', 'user2'],
14
- };
15
- const cachedTraits = {
16
- emails: ['existing@email.com'],
17
- userIds: ['user2', 'user3'],
18
- phones: ['+1234567890'],
19
- };
20
- const merged = (0, at_shared_utils_1.mergeIdentityTraits)(incomingTraits, cachedTraits);
21
- expect(merged.emails).toEqual(['new@email.com', 'existing@email.com']);
22
- expect(merged.userIds).toEqual(['user1', 'user2', 'user3']);
23
- expect(merged.phones).toEqual(['+1234567890']);
24
- });
25
- it('should handle null and undefined values in arrays', () => {
26
- const incomingTraits = {
27
- emails: ['test@email.com', null, undefined],
28
- userIds: ['user1'],
29
- };
30
- const cachedTraits = {
31
- emails: [null, 'cached@email.com', undefined],
32
- userIds: null,
33
- };
34
- const merged = (0, at_shared_utils_1.mergeIdentityTraits)(incomingTraits, cachedTraits);
35
- expect(merged.emails).toContain('test@email.com');
36
- expect(merged.emails).toContain('cached@email.com');
37
- expect(merged.userIds).toEqual(['user1']);
38
- });
39
- it('should merge addresses correctly', () => {
40
- const incomingTraits = {
41
- addresses: [
42
- {
43
- city: 'New York',
44
- country: 'USA',
45
- countryCode: 'US',
46
- province: 'NY',
47
- provinceCode: '10001',
48
- },
49
- ],
50
- };
51
- const cachedTraits = {
52
- addresses: [
53
- {
54
- city: 'Los Angeles',
55
- country: 'USA',
56
- countryCode: 'US',
57
- province: 'CA',
58
- provinceCode: '90210',
59
- },
60
- ],
61
- };
62
- const merged = (0, at_shared_utils_1.mergeIdentityTraits)(incomingTraits, cachedTraits);
63
- expect(merged.addresses).toHaveLength(2);
64
- expect(merged.addresses).toEqual(expect.arrayContaining([
65
- expect.objectContaining({ city: 'New York' }),
66
- expect.objectContaining({ city: 'Los Angeles' }),
67
- ]));
68
- });
69
- it('should merge click information correctly', () => {
70
- const incomingTraits = {
71
- click: {
72
- fbp: 'fb.new.123',
73
- fbpCollectedAt: '2024-01-01T00:00:00.000Z',
74
- gclid: 'new_gclid',
75
- },
76
- };
77
- const cachedTraits = {
78
- click: {
79
- fbp: 'fb.old.456',
80
- fbpCollectedAt: '2023-12-01T00:00:00.000Z',
81
- fbclid: 'cached_fbclid',
82
- },
83
- };
84
- const merged = (0, at_shared_utils_1.mergeIdentityTraits)(incomingTraits, cachedTraits);
85
- expect(merged.click?.fbp).toBe('fb.new.123');
86
- expect(merged.click?.gclid).toBe('new_gclid');
87
- expect(merged.click?.fbpCollectedAt).toBe('2024-01-01T00:00:00.000Z');
88
- expect(merged.click?.fbclid).toBeUndefined();
89
- });
90
- it('should handle empty traits correctly', () => {
91
- const incomingTraits = {};
92
- const cachedTraits = {
93
- emails: ['cached@email.com'],
94
- userIds: ['user1'],
95
- };
96
- const merged = (0, at_shared_utils_1.mergeIdentityTraits)(incomingTraits, cachedTraits);
97
- expect(merged.emails).toEqual(['cached@email.com']);
98
- expect(merged.userIds).toEqual(['user1']);
99
- });
100
- it('should handle undefined traits correctly', () => {
101
- const merged1 = (0, at_shared_utils_1.mergeIdentityTraits)(undefined, { emails: ['test@email.com'] });
102
- expect(merged1.emails).toEqual(['test@email.com']);
103
- const merged2 = (0, at_shared_utils_1.mergeIdentityTraits)({ emails: ['test@email.com'] }, undefined);
104
- expect(merged2.emails).toEqual(['test@email.com']);
105
- const merged3 = (0, at_shared_utils_1.mergeIdentityTraits)(undefined, undefined);
106
- expect(merged3).toEqual({});
107
- });
108
- it('should preserve version information', () => {
109
- const incomingTraits = {
110
- version: '3',
111
- emails: ['new@email.com'],
112
- };
113
- const cachedTraits = {
114
- version: '2',
115
- emails: ['old@email.com'],
116
- };
117
- const merged = (0, at_shared_utils_1.mergeIdentityTraits)(incomingTraits, cachedTraits);
118
- expect(merged.version).toBe('3');
119
- expect(merged.emails).toEqual(['new@email.com', 'old@email.com']);
120
- });
121
- it('should handle complex nested objects', () => {
122
- const incomingTraits = {
123
- click: {
124
- googleClientInfos: [{ id: 'new1', clickId: 'click1', sessionId: 'session1' }],
125
- },
126
- };
127
- const cachedTraits = {
128
- click: {
129
- googleClientInfos: [{ id: 'cached1', clickId: 'click2', sessionId: 'session2' }],
130
- },
131
- };
132
- const merged = (0, at_shared_utils_1.mergeIdentityTraits)(incomingTraits, cachedTraits);
133
- expect(merged.click?.googleClientInfos).toBeDefined();
134
- expect(Array.isArray(merged.click?.googleClientInfos)).toBe(true);
135
- expect(merged.click?.googleClientInfos).toEqual([{ id: 'cached1', clickId: 'click2', sessionId: 'session2' }]);
136
- });
137
- });
138
- describe('Integration: Merging + Staleness Checking', () => {
139
- it('should not be stale when merged identity matches cached identity', () => {
140
- const cachedIdentity = {
141
- identityId: 'test-id-123',
142
- traits: {
143
- emails: ['cached@email.com', 'shared@email.com'],
144
- userIds: ['user1', 'user2'],
145
- addresses: [
146
- {
147
- city: 'New York',
148
- country: 'USA',
149
- countryCode: 'US',
150
- },
151
- ],
152
- version: '2',
153
- },
154
- };
155
- const incomingIdentity = {
156
- identityId: 'test-id-123',
157
- traits: {
158
- emails: ['shared@email.com'],
159
- userIds: ['user1'],
160
- version: '2',
161
- },
162
- };
163
- const mergedTraits = (0, at_shared_utils_1.mergeIdentityTraits)(incomingIdentity.traits, cachedIdentity.traits);
164
- const mergedIdentity = { ...incomingIdentity, traits: mergedTraits };
165
- const staleTracker = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, mergedIdentity);
166
- expect(staleTracker.isCacheStale).toBe(false);
167
- expect(mergedIdentity.traits?.emails).toEqual(['shared@email.com', 'cached@email.com']);
168
- });
169
- it('should be stale when merged identity has new traits', () => {
170
- const cachedIdentity = {
171
- identityId: 'test-id-123',
172
- traits: {
173
- emails: ['cached@email.com'],
174
- version: '2',
175
- },
176
- };
177
- const incomingIdentity = {
178
- identityId: 'test-id-123',
179
- traits: {
180
- emails: ['cached@email.com', 'new@email.com'],
181
- version: '2',
182
- },
183
- };
184
- const mergedTraits = (0, at_shared_utils_1.mergeIdentityTraits)(incomingIdentity.traits, cachedIdentity.traits);
185
- const mergedIdentity = { ...incomingIdentity, traits: mergedTraits };
186
- const staleTracker = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, mergedIdentity);
187
- expect(staleTracker.isCacheStale).toBe(true);
188
- expect(staleTracker.isEmailsStale).toBe(true);
189
- });
190
- });
191
- });
192
- describe('Identity Cache Staleness Tests', () => {
193
- afterEach(() => {
194
- jest.resetModules();
195
- });
196
- describe('isIdentityCacheStale function', () => {
197
- it('should detect identity ID changes', () => {
198
- const cachedIdentity = {
199
- identityId: 'old-id',
200
- traits: { emails: ['test@email.com'] },
201
- };
202
- const incomingIdentity = {
203
- identityId: 'new-id',
204
- traits: { emails: ['test@email.com'] },
205
- };
206
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
207
- expect(result.isCacheStale).toBe(true);
208
- expect(result.isIdentityIdStale).toBe(true);
209
- });
210
- it('should detect new emails', () => {
211
- const cachedIdentity = {
212
- identityId: 'test-id',
213
- traits: { emails: ['old@email.com'] },
214
- };
215
- const incomingIdentity = {
216
- identityId: 'test-id',
217
- traits: { emails: ['old@email.com', 'new@email.com'] },
218
- };
219
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
220
- expect(result.isCacheStale).toBe(true);
221
- expect(result.isEmailsStale).toBe(true);
222
- });
223
- it('should detect new user IDs', () => {
224
- const cachedIdentity = {
225
- identityId: 'test-id',
226
- traits: { userIds: ['user1'] },
227
- };
228
- const incomingIdentity = {
229
- identityId: 'test-id',
230
- traits: { userIds: ['user1', 'user2'] },
231
- };
232
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
233
- expect(result.isCacheStale).toBe(true);
234
- expect(result.isUserIdsStale).toBe(true);
235
- });
236
- it('should detect new phones', () => {
237
- const cachedIdentity = {
238
- identityId: 'test-id',
239
- traits: { phones: ['+1234567890'] },
240
- };
241
- const incomingIdentity = {
242
- identityId: 'test-id',
243
- traits: { phones: ['+1234567890', '+9876543210'] },
244
- };
245
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
246
- expect(result.isCacheStale).toBe(true);
247
- expect(result.isPhonesStale).toBe(true);
248
- });
249
- it('should detect new addresses (non-IP sourced)', () => {
250
- const cachedIdentity = {
251
- identityId: 'test-id',
252
- traits: {
253
- addresses: [
254
- {
255
- city: 'New York',
256
- country: 'USA',
257
- s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT,
258
- },
259
- ],
260
- },
261
- };
262
- const incomingIdentity = {
263
- identityId: 'test-id',
264
- traits: {
265
- addresses: [
266
- { city: 'New York', country: 'USA', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
267
- { city: 'Los Angeles', country: 'USA', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
268
- ],
269
- },
270
- };
271
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
272
- expect(result.isCacheStale).toBe(true);
273
- expect(result.isAddressesStale).toBe(true);
274
- expect(result.isNonIpAddressesStale).toBe(true);
275
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
276
- });
277
- it('should detect IP address changes but NOT mark cache stale (volatile trait)', () => {
278
- const cachedIdentity = {
279
- identityId: 'test-id',
280
- traits: { ipAddress: '192.168.1.1' },
281
- };
282
- const incomingIdentity = {
283
- identityId: 'test-id',
284
- traits: { ipAddress: '10.0.0.1' },
285
- };
286
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
287
- expect(result.isCacheStale).toBe(false);
288
- expect(result.isIpAddressStale).toBe(true);
289
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
290
- });
291
- it('should detect user agent changes but NOT mark cache stale (volatile trait)', () => {
292
- const cachedIdentity = {
293
- identityId: 'test-id',
294
- traits: { userAgent: 'Mozilla/5.0 (old browser)' },
295
- };
296
- const incomingIdentity = {
297
- identityId: 'test-id',
298
- traits: { userAgent: 'Mozilla/5.0 (new browser)' },
299
- };
300
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
301
- expect(result.isCacheStale).toBe(false);
302
- expect(result.isUserAgentStale).toBe(true);
303
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
304
- });
305
- it('should not be stale when no new information is provided', () => {
306
- const cachedIdentity = {
307
- identityId: 'test-id',
308
- traits: {
309
- emails: ['test@email.com'],
310
- userIds: ['user1'],
311
- phones: ['+1234567890'],
312
- },
313
- };
314
- const incomingIdentity = {
315
- identityId: 'test-id',
316
- traits: {
317
- emails: ['test@email.com'],
318
- userIds: ['user1'],
319
- },
320
- };
321
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
322
- expect(result.isCacheStale).toBe(false);
323
- });
324
- it('should handle empty traits gracefully', () => {
325
- const cachedIdentity = {
326
- identityId: 'test-id',
327
- traits: {},
328
- };
329
- const incomingIdentity = {
330
- identityId: 'test-id',
331
- traits: {},
332
- };
333
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
334
- expect(result.isCacheStale).toBe(false);
335
- });
336
- it('should handle undefined traits gracefully', () => {
337
- const cachedIdentity = {
338
- identityId: 'test-id',
339
- };
340
- const incomingIdentity = {
341
- identityId: 'test-id',
342
- };
343
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
344
- expect(result.isCacheStale).toBe(false);
345
- });
346
- it('should detect multiple stale conditions (identity traits take priority over volatile)', () => {
347
- const cachedIdentity = {
348
- identityId: 'test-id',
349
- traits: {
350
- emails: ['old@email.com'],
351
- userIds: ['user1'],
352
- ipAddress: '192.168.1.1',
353
- },
354
- };
355
- const incomingIdentity = {
356
- identityId: 'test-id',
357
- traits: {
358
- emails: ['old@email.com', 'new@email.com'],
359
- userIds: ['user1', 'user2'],
360
- ipAddress: '10.0.0.1',
361
- },
362
- };
363
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
364
- expect(result.isCacheStale).toBe(true);
365
- expect(result.isEmailsStale).toBe(true);
366
- expect(result.isUserIdsStale).toBe(true);
367
- expect(result.isIpAddressStale).toBe(true);
368
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
369
- });
370
- });
371
- describe('isClickInfosStale function', () => {
372
- it('should detect new FBC values', () => {
373
- const cachedClick = {
374
- fbc: 'fb.1.123.old_fbclid',
375
- };
376
- const incomingClick = {
377
- fbc: 'fb.1.123.new_fbclid',
378
- };
379
- const result = (0, at_shared_utils_1.isClickInfosStale)(cachedClick, incomingClick);
380
- expect(result).toBe(true);
381
- });
382
- it('should detect new click IDs', () => {
383
- const cachedClick = {
384
- gclid: 'old_gclid',
385
- };
386
- const incomingClick = {
387
- gclid: 'new_gclid',
388
- };
389
- const result = (0, at_shared_utils_1.isClickInfosStale)(cachedClick, incomingClick);
390
- expect(result).toBe(true);
391
- });
392
- it('should ignore collection timestamps', () => {
393
- const cachedClick = {
394
- fbp: 'fb.2.123.456',
395
- fbpCollectedAt: '2023-01-01T00:00:00.000Z',
396
- };
397
- const incomingClick = {
398
- fbp: 'fb.2.123.456',
399
- fbpCollectedAt: '2024-01-01T00:00:00.000Z',
400
- };
401
- const result = (0, at_shared_utils_1.isClickInfosStale)(cachedClick, incomingClick);
402
- expect(result).toBe(false);
403
- });
404
- it('should ignore googleClientInfos', () => {
405
- const cachedClick = {
406
- googleClientInfos: [{ id: 'old', clickId: 'old_click' }],
407
- };
408
- const incomingClick = {
409
- googleClientInfos: [{ id: 'new', clickId: 'new_click' }],
410
- };
411
- const result = (0, at_shared_utils_1.isClickInfosStale)(cachedClick, incomingClick);
412
- expect(result).toBe(false);
413
- });
414
- it('should handle empty click info', () => {
415
- const result = (0, at_shared_utils_1.isClickInfosStale)({}, {});
416
- expect(result).toBe(false);
417
- });
418
- it('should detect when incoming has new click info but cached is empty', () => {
419
- const cachedClick = {};
420
- const incomingClick = {
421
- fbp: 'fb.2.123.456',
422
- };
423
- const result = (0, at_shared_utils_1.isClickInfosStale)(cachedClick, incomingClick);
424
- expect(result).toBe(true);
425
- });
426
- });
427
- describe('Edge Cases and Error Handling', () => {
428
- it('should handle malformed FBC values gracefully', () => {
429
- const cachedClick = {
430
- fbc: 'malformed_fbc',
431
- };
432
- const incomingClick = {
433
- fbc: 'also_malformed',
434
- };
435
- const result = (0, at_shared_utils_1.isClickInfosStale)(cachedClick, incomingClick);
436
- expect(result).toBe(true);
437
- });
438
- it('should handle null/undefined arrays in traits', () => {
439
- const cachedIdentity = {
440
- identityId: 'test-id',
441
- traits: {
442
- emails: null,
443
- userIds: undefined,
444
- },
445
- };
446
- const incomingIdentity = {
447
- identityId: 'test-id',
448
- traits: {
449
- emails: ['new@email.com'],
450
- userIds: ['user1'],
451
- },
452
- };
453
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
454
- expect(result.isCacheStale).toBe(true);
455
- expect(result.isEmailsStale).toBe(true);
456
- expect(result.isUserIdsStale).toBe(true);
457
- });
458
- it('should handle arrays with null/undefined elements', () => {
459
- const cachedIdentity = {
460
- identityId: 'test-id',
461
- traits: {
462
- emails: ['valid@email.com', null, undefined],
463
- },
464
- };
465
- const incomingIdentity = {
466
- identityId: 'test-id',
467
- traits: {
468
- emails: ['valid@email.com', null, undefined, 'new@email.com'],
469
- },
470
- };
471
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
472
- expect(result.isCacheStale).toBe(true);
473
- expect(result.isEmailsStale).toBe(true);
474
- });
475
- it('should handle error conditions gracefully', () => {
476
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(null, undefined);
477
- expect(result.isCacheStale).toBe(false);
478
- });
479
- });
480
- describe('Comprehensive Scenario Tests', () => {
481
- it('should handle complex real-world scenario', () => {
482
- const cachedIdentity = {
483
- identityId: '01HXRZ27H4TXWBBTRK09Q7APDP',
484
- traits: {
485
- emails: ['user@domain.com'],
486
- userIds: ['shopify_123'],
487
- addresses: [
488
- {
489
- city: 'New York',
490
- country: 'USA',
491
- countryCode: 'US',
492
- province: 'NY',
493
- provinceCode: '10001',
494
- },
495
- ],
496
- click: {
497
- fbp: 'fb.2.1715603578424.5068754021',
498
- fbpCollectedAt: '2024-05-13T12:32:58.424Z',
499
- gclid: 'original_gclid',
500
- },
501
- ipAddress: '192.168.1.100',
502
- version: '2',
503
- },
504
- };
505
- const incomingIdentity = {
506
- identityId: '01HXRZ27H4TXWBBTRK09Q7APDP',
507
- traits: {
508
- emails: ['user@domain.com', 'user.secondary@domain.com'],
509
- phones: ['+1234567890'],
510
- addresses: [
511
- {
512
- city: 'New York',
513
- country: 'USA',
514
- countryCode: 'US',
515
- province: 'NY',
516
- provinceCode: '10001',
517
- },
518
- ],
519
- click: {
520
- fbp: 'fb.2.1715603578424.5068754021',
521
- fbpCollectedAt: '2024-05-13T15:30:00.000Z',
522
- gclid: 'updated_gclid',
523
- },
524
- ipAddress: '192.168.1.100',
525
- version: '2',
526
- },
527
- };
528
- const mergedTraits = (0, at_shared_utils_1.mergeIdentityTraits)(cachedIdentity.traits, incomingIdentity.traits);
529
- const mergedIdentity = { ...incomingIdentity, traits: mergedTraits };
530
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, mergedIdentity);
531
- expect(result.isCacheStale).toBe(true);
532
- expect(result.isEmailsStale).toBe(true);
533
- expect(result.isPhonesStale).toBe(true);
534
- expect(result.isClickInfosStale).toBe(true);
535
- expect(result.isAddressesStale).toBe(false);
536
- expect(result.isIpAddressStale).toBe(false);
537
- expect(mergedIdentity.traits?.emails).toEqual(['user@domain.com', 'user.secondary@domain.com']);
538
- expect(mergedIdentity.traits?.phones).toEqual(['+1234567890']);
539
- expect(mergedIdentity.traits?.userIds).toEqual(['shopify_123']);
540
- expect(mergedIdentity.traits?.click?.gclid).toEqual('updated_gclid');
541
- });
542
- it('should properly detect click staleness when click info actually differs', () => {
543
- const cachedIdentity = {
544
- identityId: 'test-id',
545
- traits: {
546
- click: {
547
- gclid: 'original_gclid',
548
- gclidCollectedAt: '2024-05-15T12:32:58.424Z',
549
- },
550
- },
551
- };
552
- const incomingIdentity = {
553
- identityId: 'test-id',
554
- traits: {
555
- click: {
556
- gclid: 'completely_different_gclid',
557
- gclidCollectedAt: '2024-05-13T12:32:58.424Z',
558
- },
559
- },
560
- };
561
- const mergedTraits = (0, at_shared_utils_1.mergeIdentityTraits)(cachedIdentity.traits, incomingIdentity.traits);
562
- const mergedIdentity = { ...incomingIdentity, traits: mergedTraits };
563
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, mergedIdentity);
564
- expect(mergedTraits?.click?.gclid).toEqual('original_gclid');
565
- expect(result.isCacheStale).toBe(false);
566
- });
567
- it('should handle scenario where cache is fresh', () => {
568
- const cachedIdentity = {
569
- identityId: 'test-id',
570
- traits: {
571
- emails: ['user@domain.com', 'secondary@domain.com'],
572
- userIds: ['user1', 'user2'],
573
- phones: ['+1234567890'],
574
- version: '2',
575
- },
576
- };
577
- const incomingIdentity = {
578
- identityId: 'test-id',
579
- traits: {
580
- emails: ['user@domain.com'],
581
- userIds: ['user1'],
582
- version: '2',
583
- },
584
- };
585
- const mergedTraits = (0, at_shared_utils_1.mergeIdentityTraits)(cachedIdentity.traits, incomingIdentity.traits);
586
- const mergedIdentity = { ...incomingIdentity, traits: mergedTraits };
587
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, mergedIdentity);
588
- expect(result.isCacheStale).toBe(false);
589
- expect(mergedIdentity.traits?.emails).toEqual(['user@domain.com', 'secondary@domain.com']);
590
- expect(mergedIdentity.traits?.userIds).toEqual(['user1', 'user2']);
591
- expect(mergedIdentity.traits?.phones).toEqual(['+1234567890']);
592
- });
593
- });
594
- });
595
- describe('Three-Tier Staleness Model Tests', () => {
596
- afterEach(() => {
597
- jest.resetModules();
598
- });
599
- describe('TIER 1: VOLATILE_ONLY (no action needed)', () => {
600
- it('should return VOLATILE_ONLY tier when only ipAddress is stale', () => {
601
- const cachedIdentity = {
602
- identityId: 'test-id',
603
- traits: {
604
- emails: ['test@email.com'],
605
- ipAddress: '192.168.1.1',
606
- },
607
- };
608
- const incomingIdentity = {
609
- identityId: 'test-id',
610
- traits: {
611
- emails: ['test@email.com'],
612
- ipAddress: '10.0.0.1',
613
- },
614
- };
615
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
616
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
617
- expect(result.isCacheStale).toBe(false);
618
- expect(result.isIpAddressStale).toBe(true);
619
- });
620
- it('should return VOLATILE_ONLY tier when only userAgent is stale', () => {
621
- const cachedIdentity = {
622
- identityId: 'test-id',
623
- traits: {
624
- emails: ['test@email.com'],
625
- userAgent: 'Mozilla/5.0 (old)',
626
- },
627
- };
628
- const incomingIdentity = {
629
- identityId: 'test-id',
630
- traits: {
631
- emails: ['test@email.com'],
632
- userAgent: 'Mozilla/5.0 (new)',
633
- },
634
- };
635
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
636
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
637
- expect(result.isCacheStale).toBe(false);
638
- expect(result.isUserAgentStale).toBe(true);
639
- });
640
- it('should return VOLATILE_ONLY tier when only IP-sourced addresses are stale', () => {
641
- const cachedIdentity = {
642
- identityId: 'test-id',
643
- traits: {
644
- emails: ['test@email.com'],
645
- addresses: [
646
- { city: 'New York', country: 'USA', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS },
647
- ],
648
- },
649
- };
650
- const incomingIdentity = {
651
- identityId: 'test-id',
652
- traits: {
653
- emails: ['test@email.com'],
654
- addresses: [
655
- { city: 'Los Angeles', country: 'USA', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS },
656
- ],
657
- },
658
- };
659
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
660
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
661
- expect(result.isCacheStale).toBe(false);
662
- expect(result.isIpAddressesStale).toBe(true);
663
- expect(result.isNonIpAddressesStale).toBe(false);
664
- });
665
- it('should return VOLATILE_ONLY tier when multiple volatile traits are stale', () => {
666
- const cachedIdentity = {
667
- identityId: 'test-id',
668
- traits: {
669
- emails: ['test@email.com'],
670
- ipAddress: '192.168.1.1',
671
- userAgent: 'Mozilla/5.0 (old)',
672
- addresses: [
673
- { city: 'New York', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS },
674
- ],
675
- },
676
- };
677
- const incomingIdentity = {
678
- identityId: 'test-id',
679
- traits: {
680
- emails: ['test@email.com'],
681
- ipAddress: '10.0.0.1',
682
- userAgent: 'Mozilla/5.0 (new)',
683
- addresses: [
684
- { city: 'Chicago', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS },
685
- ],
686
- },
687
- };
688
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
689
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
690
- expect(result.isCacheStale).toBe(false);
691
- expect(result.isIpAddressStale).toBe(true);
692
- expect(result.isUserAgentStale).toBe(true);
693
- expect(result.isIpAddressesStale).toBe(true);
694
- });
695
- });
696
- describe('TIER 2: ADDRESS_UPDATE (cache write only, skip Neptune)', () => {
697
- it('should return ADDRESS_UPDATE tier when non-IP address is new', () => {
698
- const cachedIdentity = {
699
- identityId: 'test-id',
700
- traits: {
701
- emails: ['test@email.com'],
702
- addresses: [],
703
- },
704
- };
705
- const incomingIdentity = {
706
- identityId: 'test-id',
707
- traits: {
708
- emails: ['test@email.com'],
709
- addresses: [
710
- { city: 'Boston', province: 'MA', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
711
- ],
712
- },
713
- };
714
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
715
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
716
- expect(result.isCacheStale).toBe(true);
717
- expect(result.isNonIpAddressesStale).toBe(true);
718
- });
719
- it('should return ADDRESS_UPDATE tier when new input address added', () => {
720
- const cachedIdentity = {
721
- identityId: 'test-id',
722
- traits: {
723
- emails: ['test@email.com'],
724
- addresses: [
725
- { city: 'New York', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
726
- ],
727
- },
728
- };
729
- const incomingIdentity = {
730
- identityId: 'test-id',
731
- traits: {
732
- emails: ['test@email.com'],
733
- addresses: [
734
- { city: 'New York', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
735
- { city: 'Boston', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
736
- ],
737
- },
738
- };
739
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
740
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
741
- expect(result.isCacheStale).toBe(true);
742
- expect(result.isNonIpAddressesStale).toBe(true);
743
- });
744
- it('should return ADDRESS_UPDATE tier even when volatile traits are also stale', () => {
745
- const cachedIdentity = {
746
- identityId: 'test-id',
747
- traits: {
748
- emails: ['test@email.com'],
749
- ipAddress: '192.168.1.1',
750
- addresses: [],
751
- },
752
- };
753
- const incomingIdentity = {
754
- identityId: 'test-id',
755
- traits: {
756
- emails: ['test@email.com'],
757
- ipAddress: '10.0.0.1',
758
- addresses: [
759
- { city: 'Boston', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
760
- ],
761
- },
762
- };
763
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
764
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
765
- expect(result.isCacheStale).toBe(true);
766
- expect(result.isIpAddressStale).toBe(true);
767
- expect(result.isNonIpAddressesStale).toBe(true);
768
- });
769
- });
770
- describe('TIER 3: IDENTITY_STALE (full Neptune resolution)', () => {
771
- it('should return IDENTITY_STALE tier when email is new', () => {
772
- const cachedIdentity = {
773
- identityId: 'test-id',
774
- traits: {
775
- emails: ['old@email.com'],
776
- },
777
- };
778
- const incomingIdentity = {
779
- identityId: 'test-id',
780
- traits: {
781
- emails: ['old@email.com', 'new@email.com'],
782
- },
783
- };
784
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
785
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
786
- expect(result.isCacheStale).toBe(true);
787
- expect(result.isEmailsStale).toBe(true);
788
- });
789
- it('should return IDENTITY_STALE tier when identityId changes', () => {
790
- const cachedIdentity = {
791
- identityId: 'old-id',
792
- traits: { emails: ['test@email.com'] },
793
- };
794
- const incomingIdentity = {
795
- identityId: 'new-id',
796
- traits: { emails: ['test@email.com'] },
797
- };
798
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
799
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
800
- expect(result.isCacheStale).toBe(true);
801
- expect(result.isIdentityIdStale).toBe(true);
802
- });
803
- it('should return IDENTITY_STALE tier when phone is new', () => {
804
- const cachedIdentity = {
805
- identityId: 'test-id',
806
- traits: { phones: ['+1234567890'] },
807
- };
808
- const incomingIdentity = {
809
- identityId: 'test-id',
810
- traits: { phones: ['+1234567890', '+9876543210'] },
811
- };
812
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
813
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
814
- expect(result.isCacheStale).toBe(true);
815
- expect(result.isPhonesStale).toBe(true);
816
- });
817
- it('should return IDENTITY_STALE tier when click info changes', () => {
818
- const cachedIdentity = {
819
- identityId: 'test-id',
820
- traits: {
821
- click: { gclid: 'old_gclid' },
822
- },
823
- };
824
- const incomingIdentity = {
825
- identityId: 'test-id',
826
- traits: {
827
- click: { gclid: 'new_gclid' },
828
- },
829
- };
830
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
831
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
832
- expect(result.isCacheStale).toBe(true);
833
- expect(result.isClickInfosStale).toBe(true);
834
- });
835
- it('should return IDENTITY_STALE tier when identity trait is stale even with ADDRESS_UPDATE', () => {
836
- const cachedIdentity = {
837
- identityId: 'test-id',
838
- traits: {
839
- emails: ['old@email.com'],
840
- addresses: [],
841
- },
842
- };
843
- const incomingIdentity = {
844
- identityId: 'test-id',
845
- traits: {
846
- emails: ['old@email.com', 'new@email.com'],
847
- addresses: [
848
- { city: 'Boston', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
849
- ],
850
- },
851
- };
852
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
853
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
854
- expect(result.isCacheStale).toBe(true);
855
- expect(result.isEmailsStale).toBe(true);
856
- expect(result.isNonIpAddressesStale).toBe(true);
857
- });
858
- it('should return IDENTITY_STALE tier when identity trait is stale even with VOLATILE_ONLY', () => {
859
- const cachedIdentity = {
860
- identityId: 'test-id',
861
- traits: {
862
- emails: ['old@email.com'],
863
- ipAddress: '192.168.1.1',
864
- },
865
- };
866
- const incomingIdentity = {
867
- identityId: 'test-id',
868
- traits: {
869
- emails: ['old@email.com', 'new@email.com'],
870
- ipAddress: '10.0.0.1',
871
- },
872
- };
873
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
874
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
875
- expect(result.isCacheStale).toBe(true);
876
- expect(result.isEmailsStale).toBe(true);
877
- expect(result.isIpAddressStale).toBe(true);
878
- });
879
- });
880
- describe('TIER NONE: No staleness', () => {
881
- it('should return NONE tier when nothing is stale', () => {
882
- const cachedIdentity = {
883
- identityId: 'test-id',
884
- traits: {
885
- emails: ['test@email.com'],
886
- phones: ['+1234567890'],
887
- ipAddress: '192.168.1.1',
888
- },
889
- };
890
- const incomingIdentity = {
891
- identityId: 'test-id',
892
- traits: {
893
- emails: ['test@email.com'],
894
- phones: ['+1234567890'],
895
- ipAddress: '192.168.1.1',
896
- },
897
- };
898
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
899
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
900
- expect(result.isCacheStale).toBe(false);
901
- });
902
- it('should return NONE tier when incoming is subset of cached', () => {
903
- const cachedIdentity = {
904
- identityId: 'test-id',
905
- traits: {
906
- emails: ['a@email.com', 'b@email.com'],
907
- phones: ['+1234567890', '+9876543210'],
908
- },
909
- };
910
- const incomingIdentity = {
911
- identityId: 'test-id',
912
- traits: {
913
- emails: ['a@email.com'],
914
- },
915
- };
916
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
917
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
918
- expect(result.isCacheStale).toBe(false);
919
- });
920
- });
921
- describe('Address source filtering', () => {
922
- it('should correctly identify IP-sourced addresses', () => {
923
- const cachedIdentity = {
924
- identityId: 'test-id',
925
- traits: {
926
- addresses: [
927
- { city: 'CachedCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS },
928
- ],
929
- },
930
- };
931
- const incomingIdentity = {
932
- identityId: 'test-id',
933
- traits: {
934
- addresses: [
935
- { city: 'NewCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS },
936
- ],
937
- },
938
- };
939
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
940
- expect(result.isIpAddressesStale).toBe(true);
941
- expect(result.isNonIpAddressesStale).toBe(false);
942
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
943
- });
944
- it('should correctly identify INPUT-sourced addresses', () => {
945
- const cachedIdentity = {
946
- identityId: 'test-id',
947
- traits: {
948
- addresses: [
949
- { city: 'CachedCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
950
- ],
951
- },
952
- };
953
- const incomingIdentity = {
954
- identityId: 'test-id',
955
- traits: {
956
- addresses: [
957
- { city: 'CachedCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
958
- { city: 'NewCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
959
- ],
960
- },
961
- };
962
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
963
- expect(result.isIpAddressesStale).toBe(false);
964
- expect(result.isNonIpAddressesStale).toBe(true);
965
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
966
- });
967
- it('should handle mixed address sources correctly', () => {
968
- const cachedIdentity = {
969
- identityId: 'test-id',
970
- traits: {
971
- addresses: [
972
- { city: 'IPCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS },
973
- { city: 'InputCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
974
- ],
975
- },
976
- };
977
- const incomingIdentity = {
978
- identityId: 'test-id',
979
- traits: {
980
- addresses: [
981
- { city: 'NewIPCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS },
982
- { city: 'InputCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
983
- { city: 'NewInputCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
984
- ],
985
- },
986
- };
987
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
988
- expect(result.isIpAddressesStale).toBe(true);
989
- expect(result.isNonIpAddressesStale).toBe(true);
990
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
991
- expect(result.isCacheStale).toBe(true);
992
- });
993
- it('should handle addresses without source field (default to IP based on PII)', () => {
994
- const cachedIdentity = {
995
- identityId: 'test-id',
996
- traits: {
997
- addresses: [],
998
- },
999
- };
1000
- const incomingIdentity = {
1001
- identityId: 'test-id',
1002
- traits: {
1003
- addresses: [
1004
- { city: 'NoSourceCity' },
1005
- ],
1006
- },
1007
- };
1008
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
1009
- expect(result.isIpAddressesStale).toBe(true);
1010
- expect(result.isNonIpAddressesStale).toBe(false);
1011
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
1012
- expect(result.isCacheStale).toBe(false);
1013
- });
1014
- it('should treat addresses without source but with PII as non-IP', () => {
1015
- const cachedIdentity = {
1016
- identityId: 'test-id',
1017
- traits: {
1018
- addresses: [],
1019
- },
1020
- };
1021
- const incomingIdentity = {
1022
- identityId: 'test-id',
1023
- traits: {
1024
- addresses: [
1025
- { city: 'InputCity', firstName: 'John' },
1026
- ],
1027
- },
1028
- };
1029
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
1030
- expect(result.isNonIpAddressesStale).toBe(true);
1031
- expect(result.isIpAddressesStale).toBe(false);
1032
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
1033
- expect(result.isCacheStale).toBe(true);
1034
- });
1035
- });
1036
- describe('Backward compatibility', () => {
1037
- it('should maintain isAddressesStale for any address change', () => {
1038
- const cachedIdentity = {
1039
- identityId: 'test-id',
1040
- traits: {
1041
- addresses: [
1042
- { city: 'OldCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS },
1043
- ],
1044
- },
1045
- };
1046
- const incomingIdentity = {
1047
- identityId: 'test-id',
1048
- traits: {
1049
- addresses: [
1050
- { city: 'NewCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS },
1051
- ],
1052
- },
1053
- };
1054
- const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
1055
- expect(result.isAddressesStale).toBe(true);
1056
- expect(result.isCacheStale).toBe(false);
1057
- });
1058
- });
1059
- });
1060
- describe('extractStaleTraitNames function', () => {
1061
- it('should return empty array when nothing is stale', () => {
1062
- const cachedIdentity = {
1063
- identityId: 'test-id',
1064
- traits: { emails: ['test@email.com'] },
1065
- };
1066
- const incomingIdentity = {
1067
- identityId: 'test-id',
1068
- traits: { emails: ['test@email.com'] },
1069
- };
1070
- const tracker = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
1071
- const staleTraits = (0, at_shared_utils_1.extractStaleTraitNames)(tracker);
1072
- expect(staleTraits).toEqual([]);
1073
- });
1074
- it('should return identity-defining trait names when stale', () => {
1075
- const cachedIdentity = {
1076
- identityId: 'test-id',
1077
- traits: { emails: ['old@email.com'] },
1078
- };
1079
- const incomingIdentity = {
1080
- identityId: 'test-id',
1081
- traits: { emails: ['old@email.com', 'new@email.com'] },
1082
- };
1083
- const tracker = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
1084
- const staleTraits = (0, at_shared_utils_1.extractStaleTraitNames)(tracker);
1085
- expect(staleTraits).toContain('emails');
1086
- });
1087
- it('should return multiple stale trait names', () => {
1088
- const cachedIdentity = {
1089
- identityId: 'test-id',
1090
- traits: {
1091
- emails: ['old@email.com'],
1092
- phones: ['+1234567890'],
1093
- },
1094
- };
1095
- const incomingIdentity = {
1096
- identityId: 'test-id',
1097
- traits: {
1098
- emails: ['old@email.com', 'new@email.com'],
1099
- phones: ['+1234567890', '+9876543210'],
1100
- },
1101
- };
1102
- const tracker = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
1103
- const staleTraits = (0, at_shared_utils_1.extractStaleTraitNames)(tracker);
1104
- expect(staleTraits).toContain('emails');
1105
- expect(staleTraits).toContain('phones');
1106
- });
1107
- it('should return volatile trait names when stale', () => {
1108
- const cachedIdentity = {
1109
- identityId: 'test-id',
1110
- traits: {
1111
- ipAddress: '192.168.1.1',
1112
- userAgent: 'old-agent',
1113
- },
1114
- };
1115
- const incomingIdentity = {
1116
- identityId: 'test-id',
1117
- traits: {
1118
- ipAddress: '10.0.0.1',
1119
- userAgent: 'new-agent',
1120
- },
1121
- };
1122
- const tracker = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
1123
- const staleTraits = (0, at_shared_utils_1.extractStaleTraitNames)(tracker);
1124
- expect(staleTraits).toContain('ipAddress');
1125
- expect(staleTraits).toContain('userAgent');
1126
- });
1127
- });
1128
- describe('mergeAndComputeIdentityStaleness function', () => {
1129
- describe('NONE tier - cache is fresh', () => {
1130
- it('should return NONE tier when incoming is subset of cached', () => {
1131
- const incomingIdentity = {
1132
- identityId: 'test-id',
1133
- traits: { emails: ['shared@email.com'] },
1134
- };
1135
- const cachedIdentity = {
1136
- identityId: 'test-id',
1137
- traits: {
1138
- emails: ['shared@email.com', 'other@email.com'],
1139
- phones: ['+1234567890'],
1140
- },
1141
- };
1142
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1143
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1144
- expect(result.isCacheStale).toBe(false);
1145
- expect(result.staleTraits).toEqual([]);
1146
- expect(result.mergedIdentity.traits?.emails).toEqual(['shared@email.com', 'other@email.com']);
1147
- expect(result.mergedIdentity.traits?.phones).toEqual(['+1234567890']);
1148
- });
1149
- it('should return NONE tier when identities are identical', () => {
1150
- const incomingIdentity = {
1151
- identityId: 'test-id',
1152
- traits: {
1153
- emails: ['test@email.com'],
1154
- phones: ['+1234567890'],
1155
- },
1156
- };
1157
- const cachedIdentity = {
1158
- identityId: 'test-id',
1159
- traits: {
1160
- emails: ['test@email.com'],
1161
- phones: ['+1234567890'],
1162
- },
1163
- };
1164
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1165
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1166
- expect(result.isCacheStale).toBe(false);
1167
- expect(result.staleTraits).toEqual([]);
1168
- });
1169
- it('should return NONE tier with identical click info', () => {
1170
- const incomingIdentity = {
1171
- identityId: 'test-id',
1172
- traits: {
1173
- emails: ['test@email.com'],
1174
- click: { gclid: 'same_gclid', fbp: 'fb.1.123.456' },
1175
- },
1176
- };
1177
- const cachedIdentity = {
1178
- identityId: 'test-id',
1179
- traits: {
1180
- emails: ['test@email.com'],
1181
- click: { gclid: 'same_gclid', fbp: 'fb.1.123.456' },
1182
- },
1183
- };
1184
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1185
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1186
- expect(result.isCacheStale).toBe(false);
1187
- });
1188
- });
1189
- describe('VOLATILE_ONLY tier - treat as cache hit', () => {
1190
- it('should return VOLATILE_ONLY tier when only ipAddress is new', () => {
1191
- const incomingIdentity = {
1192
- identityId: 'test-id',
1193
- traits: {
1194
- emails: ['test@email.com'],
1195
- ipAddress: '10.0.0.1',
1196
- },
1197
- };
1198
- const cachedIdentity = {
1199
- identityId: 'test-id',
1200
- traits: {
1201
- emails: ['test@email.com'],
1202
- },
1203
- };
1204
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1205
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
1206
- expect(result.isCacheStale).toBe(false);
1207
- expect(result.staleTraits).toContain('ipAddress');
1208
- });
1209
- it('should return VOLATILE_ONLY tier when only userAgent is new', () => {
1210
- const incomingIdentity = {
1211
- identityId: 'test-id',
1212
- traits: {
1213
- emails: ['test@email.com'],
1214
- userAgent: 'new-agent',
1215
- },
1216
- };
1217
- const cachedIdentity = {
1218
- identityId: 'test-id',
1219
- traits: {
1220
- emails: ['test@email.com'],
1221
- },
1222
- };
1223
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1224
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
1225
- expect(result.isCacheStale).toBe(false);
1226
- expect(result.staleTraits).toContain('userAgent');
1227
- });
1228
- it('should return VOLATILE_ONLY tier when only IP-sourced address is new', () => {
1229
- const incomingIdentity = {
1230
- identityId: 'test-id',
1231
- traits: {
1232
- emails: ['test@email.com'],
1233
- addresses: [{ city: 'NewIPCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS }],
1234
- },
1235
- };
1236
- const cachedIdentity = {
1237
- identityId: 'test-id',
1238
- traits: {
1239
- emails: ['test@email.com'],
1240
- addresses: [],
1241
- },
1242
- };
1243
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1244
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
1245
- expect(result.isCacheStale).toBe(false);
1246
- });
1247
- });
1248
- describe('ADDRESS_UPDATE tier - cache write only, skip Neptune', () => {
1249
- it('should return ADDRESS_UPDATE tier when non-IP address is new', () => {
1250
- const incomingIdentity = {
1251
- identityId: 'test-id',
1252
- traits: {
1253
- emails: ['test@email.com'],
1254
- addresses: [{ city: 'Boston', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT }],
1255
- },
1256
- };
1257
- const cachedIdentity = {
1258
- identityId: 'test-id',
1259
- traits: {
1260
- emails: ['test@email.com'],
1261
- addresses: [],
1262
- },
1263
- };
1264
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1265
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
1266
- expect(result.isCacheStale).toBe(true);
1267
- expect(result.staleTraits).toContain('addresses');
1268
- });
1269
- it('should return ADDRESS_UPDATE even with volatile traits stale', () => {
1270
- const incomingIdentity = {
1271
- identityId: 'test-id',
1272
- traits: {
1273
- emails: ['test@email.com'],
1274
- ipAddress: '10.0.0.1',
1275
- addresses: [{ city: 'Boston', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT }],
1276
- },
1277
- };
1278
- const cachedIdentity = {
1279
- identityId: 'test-id',
1280
- traits: {
1281
- emails: ['test@email.com'],
1282
- ipAddress: '192.168.1.1',
1283
- addresses: [],
1284
- },
1285
- };
1286
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1287
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
1288
- expect(result.isCacheStale).toBe(true);
1289
- });
1290
- });
1291
- describe('IDENTITY_STALE tier - full Neptune resolution', () => {
1292
- it('should return IDENTITY_STALE tier when email is new', () => {
1293
- const incomingIdentity = {
1294
- identityId: 'test-id',
1295
- traits: { emails: ['old@email.com', 'new@email.com'] },
1296
- };
1297
- const cachedIdentity = {
1298
- identityId: 'test-id',
1299
- traits: { emails: ['old@email.com'] },
1300
- };
1301
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1302
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1303
- expect(result.isCacheStale).toBe(true);
1304
- expect(result.staleTraits).toContain('emails');
1305
- });
1306
- it('should return IDENTITY_STALE tier when phone is new', () => {
1307
- const incomingIdentity = {
1308
- identityId: 'test-id',
1309
- traits: { phones: ['+1234567890', '+9876543210'] },
1310
- };
1311
- const cachedIdentity = {
1312
- identityId: 'test-id',
1313
- traits: { phones: ['+1234567890'] },
1314
- };
1315
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1316
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1317
- expect(result.isCacheStale).toBe(true);
1318
- expect(result.staleTraits).toContain('phones');
1319
- });
1320
- it('should return IDENTITY_STALE tier when identityId changes', () => {
1321
- const incomingIdentity = {
1322
- identityId: 'new-id',
1323
- traits: { emails: ['test@email.com'] },
1324
- };
1325
- const cachedIdentity = {
1326
- identityId: 'old-id',
1327
- traits: { emails: ['test@email.com'] },
1328
- };
1329
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1330
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1331
- expect(result.isCacheStale).toBe(true);
1332
- expect(result.staleTraits).toContain('identityId');
1333
- });
1334
- it('should return IDENTITY_STALE tier when click info is new', () => {
1335
- const incomingIdentity = {
1336
- identityId: 'test-id',
1337
- traits: { click: { gclid: 'new_gclid' } },
1338
- };
1339
- const cachedIdentity = {
1340
- identityId: 'test-id',
1341
- traits: {},
1342
- };
1343
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1344
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1345
- expect(result.isCacheStale).toBe(true);
1346
- expect(result.staleTraits).toContain('clickInfos');
1347
- });
1348
- it('should return IDENTITY_STALE even with ADDRESS_UPDATE also present', () => {
1349
- const incomingIdentity = {
1350
- identityId: 'test-id',
1351
- traits: {
1352
- emails: ['old@email.com', 'new@email.com'],
1353
- addresses: [{ city: 'Boston', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT }],
1354
- },
1355
- };
1356
- const cachedIdentity = {
1357
- identityId: 'test-id',
1358
- traits: {
1359
- emails: ['old@email.com'],
1360
- addresses: [],
1361
- },
1362
- };
1363
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1364
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1365
- expect(result.isCacheStale).toBe(true);
1366
- expect(result.staleTraits).toContain('emails');
1367
- expect(result.staleTraits).toContain('addresses');
1368
- });
1369
- });
1370
- describe('Merged identity structure', () => {
1371
- it('should preserve incoming identityId in merged identity', () => {
1372
- const incomingIdentity = {
1373
- identityId: 'incoming-id',
1374
- traits: { emails: ['test@email.com'] },
1375
- };
1376
- const cachedIdentity = {
1377
- identityId: 'cached-id',
1378
- traits: { phones: ['+1234567890'] },
1379
- };
1380
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1381
- expect(result.mergedIdentity.identityId).toBe('incoming-id');
1382
- });
1383
- it('should merge traits from both incoming and cached', () => {
1384
- const incomingIdentity = {
1385
- identityId: 'test-id',
1386
- traits: {
1387
- emails: ['incoming@email.com'],
1388
- userIds: ['user1'],
1389
- },
1390
- };
1391
- const cachedIdentity = {
1392
- identityId: 'test-id',
1393
- traits: {
1394
- emails: ['cached@email.com'],
1395
- phones: ['+1234567890'],
1396
- },
1397
- };
1398
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1399
- expect(result.mergedIdentity.traits?.emails).toContain('incoming@email.com');
1400
- expect(result.mergedIdentity.traits?.emails).toContain('cached@email.com');
1401
- expect(result.mergedIdentity.traits?.userIds).toEqual(['user1']);
1402
- expect(result.mergedIdentity.traits?.phones).toEqual(['+1234567890']);
1403
- });
1404
- });
1405
- describe('staleTracker output', () => {
1406
- it('should include full staleTracker with all flags', () => {
1407
- const incomingIdentity = {
1408
- identityId: 'test-id',
1409
- traits: {
1410
- emails: ['old@email.com', 'new@email.com'],
1411
- ipAddress: '10.0.0.1',
1412
- },
1413
- };
1414
- const cachedIdentity = {
1415
- identityId: 'test-id',
1416
- traits: {
1417
- emails: ['old@email.com'],
1418
- },
1419
- };
1420
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1421
- expect(result.staleTracker).toBeDefined();
1422
- expect(result.staleTracker.isEmailsStale).toBe(true);
1423
- expect(result.staleTracker.isIpAddressStale).toBe(true);
1424
- expect(result.staleTracker.isPhonesStale).toBe(false);
1425
- });
1426
- });
1427
- describe('Edge cases - empty traits', () => {
1428
- it('should handle empty traits on incoming identity', () => {
1429
- const incomingIdentity = {
1430
- identityId: 'test-id',
1431
- traits: {},
1432
- };
1433
- const cachedIdentity = {
1434
- identityId: 'test-id',
1435
- traits: {
1436
- emails: ['cached@email.com'],
1437
- phones: ['+1234567890'],
1438
- userIds: ['user1'],
1439
- },
1440
- };
1441
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1442
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1443
- expect(result.isCacheStale).toBe(false);
1444
- expect(result.staleTraits).toEqual([]);
1445
- expect(result.mergedIdentity.traits?.emails).toEqual(['cached@email.com']);
1446
- expect(result.mergedIdentity.traits?.phones).toEqual(['+1234567890']);
1447
- expect(result.mergedIdentity.traits?.userIds).toEqual(['user1']);
1448
- });
1449
- it('should handle empty traits on cached identity', () => {
1450
- const incomingIdentity = {
1451
- identityId: 'test-id',
1452
- traits: {
1453
- emails: ['new@email.com'],
1454
- phones: ['+1234567890'],
1455
- },
1456
- };
1457
- const cachedIdentity = {
1458
- identityId: 'test-id',
1459
- traits: {},
1460
- };
1461
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1462
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1463
- expect(result.isCacheStale).toBe(true);
1464
- expect(result.staleTraits).toContain('emails');
1465
- expect(result.staleTraits).toContain('phones');
1466
- expect(result.mergedIdentity.traits?.emails).toEqual(['new@email.com']);
1467
- expect(result.mergedIdentity.traits?.phones).toEqual(['+1234567890']);
1468
- });
1469
- it('should handle both identities with empty traits', () => {
1470
- const incomingIdentity = {
1471
- identityId: 'test-id',
1472
- traits: {},
1473
- };
1474
- const cachedIdentity = {
1475
- identityId: 'test-id',
1476
- traits: {},
1477
- };
1478
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1479
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1480
- expect(result.isCacheStale).toBe(false);
1481
- expect(result.staleTraits).toEqual([]);
1482
- });
1483
- });
1484
- describe('Edge cases - null/undefined handling', () => {
1485
- it('should handle undefined traits on incoming identity', () => {
1486
- const incomingIdentity = {
1487
- identityId: 'test-id',
1488
- };
1489
- const cachedIdentity = {
1490
- identityId: 'test-id',
1491
- traits: {
1492
- emails: ['cached@email.com'],
1493
- },
1494
- };
1495
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1496
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1497
- expect(result.isCacheStale).toBe(false);
1498
- });
1499
- it('should handle undefined traits on cached identity', () => {
1500
- const incomingIdentity = {
1501
- identityId: 'test-id',
1502
- traits: {
1503
- emails: ['new@email.com'],
1504
- },
1505
- };
1506
- const cachedIdentity = {
1507
- identityId: 'test-id',
1508
- };
1509
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1510
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1511
- expect(result.isCacheStale).toBe(true);
1512
- expect(result.staleTraits).toContain('emails');
1513
- });
1514
- it('should handle both identities with undefined traits', () => {
1515
- const incomingIdentity = {
1516
- identityId: 'test-id',
1517
- };
1518
- const cachedIdentity = {
1519
- identityId: 'test-id',
1520
- };
1521
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1522
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1523
- expect(result.isCacheStale).toBe(false);
1524
- expect(result.staleTraits).toEqual([]);
1525
- });
1526
- it('should handle null values in array traits gracefully', () => {
1527
- const incomingIdentity = {
1528
- identityId: 'test-id',
1529
- traits: {
1530
- emails: ['valid@email.com', null, 'new@email.com'],
1531
- },
1532
- };
1533
- const cachedIdentity = {
1534
- identityId: 'test-id',
1535
- traits: {
1536
- emails: ['valid@email.com'],
1537
- },
1538
- };
1539
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1540
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1541
- expect(result.isCacheStale).toBe(true);
1542
- });
1543
- });
1544
- describe('Edge cases - click trait merging', () => {
1545
- it('should detect staleness when incoming has new click info', () => {
1546
- const incomingIdentity = {
1547
- identityId: 'test-id',
1548
- traits: {
1549
- click: {
1550
- gclid: 'new_gclid',
1551
- fbp: 'fb.1.new.123',
1552
- },
1553
- },
1554
- };
1555
- const cachedIdentity = {
1556
- identityId: 'test-id',
1557
- traits: {},
1558
- };
1559
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1560
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1561
- expect(result.isCacheStale).toBe(true);
1562
- expect(result.staleTraits).toContain('clickInfos');
1563
- });
1564
- it('should preserve cached click info when merging', () => {
1565
- const incomingIdentity = {
1566
- identityId: 'test-id',
1567
- traits: {
1568
- click: {
1569
- gclid: 'incoming_gclid',
1570
- },
1571
- },
1572
- };
1573
- const cachedIdentity = {
1574
- identityId: 'test-id',
1575
- traits: {
1576
- click: {
1577
- gclid: 'cached_gclid',
1578
- fbp: 'fb.1.cached.456',
1579
- },
1580
- },
1581
- };
1582
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1583
- expect(result.mergedIdentity.traits?.click?.gclid).toBe('cached_gclid');
1584
- expect(result.mergedIdentity.traits?.click?.fbp).toBe('fb.1.cached.456');
1585
- });
1586
- it('should not be stale when click timestamps differ but values are same', () => {
1587
- const incomingIdentity = {
1588
- identityId: 'test-id',
1589
- traits: {
1590
- click: {
1591
- fbp: 'fb.1.same.123',
1592
- fbpCollectedAt: '2024-06-01T00:00:00Z',
1593
- },
1594
- },
1595
- };
1596
- const cachedIdentity = {
1597
- identityId: 'test-id',
1598
- traits: {
1599
- click: {
1600
- fbp: 'fb.1.same.123',
1601
- fbpCollectedAt: '2024-01-01T00:00:00Z',
1602
- },
1603
- },
1604
- };
1605
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1606
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1607
- expect(result.isCacheStale).toBe(false);
1608
- });
1609
- it('should detect staleness when fbc changes (incoming has new fbc, cached has none)', () => {
1610
- const incomingIdentity = {
1611
- identityId: 'test-id',
1612
- traits: {
1613
- click: {
1614
- fbc: 'fb.1.1234.new_fbclid',
1615
- },
1616
- },
1617
- };
1618
- const cachedIdentity = {
1619
- identityId: 'test-id',
1620
- traits: {
1621
- click: {},
1622
- },
1623
- };
1624
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1625
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1626
- expect(result.isCacheStale).toBe(true);
1627
- expect(result.staleTraits).toContain('clickInfos');
1628
- });
1629
- });
1630
- describe('staleTraits extraction comprehensive tests', () => {
1631
- it('should return empty array when NONE tier', () => {
1632
- const incomingIdentity = {
1633
- identityId: 'test-id',
1634
- traits: { emails: ['test@email.com'] },
1635
- };
1636
- const cachedIdentity = {
1637
- identityId: 'test-id',
1638
- traits: { emails: ['test@email.com', 'other@email.com'] },
1639
- };
1640
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1641
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1642
- expect(result.staleTraits).toEqual([]);
1643
- });
1644
- it('should return volatile trait names for VOLATILE_ONLY tier', () => {
1645
- const incomingIdentity = {
1646
- identityId: 'test-id',
1647
- traits: {
1648
- emails: ['test@email.com'],
1649
- ipAddress: '10.0.0.1',
1650
- userAgent: 'new-agent',
1651
- },
1652
- };
1653
- const cachedIdentity = {
1654
- identityId: 'test-id',
1655
- traits: {
1656
- emails: ['test@email.com'],
1657
- },
1658
- };
1659
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1660
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
1661
- expect(result.staleTraits).toContain('ipAddress');
1662
- expect(result.staleTraits).toContain('userAgent');
1663
- expect(result.staleTraits).not.toContain('emails');
1664
- });
1665
- it('should return address trait name for ADDRESS_UPDATE tier', () => {
1666
- const incomingIdentity = {
1667
- identityId: 'test-id',
1668
- traits: {
1669
- emails: ['test@email.com'],
1670
- addresses: [{ city: 'Boston', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT }],
1671
- },
1672
- };
1673
- const cachedIdentity = {
1674
- identityId: 'test-id',
1675
- traits: {
1676
- emails: ['test@email.com'],
1677
- addresses: [],
1678
- },
1679
- };
1680
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1681
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
1682
- expect(result.staleTraits).toContain('addresses');
1683
- });
1684
- it('should return all stale identity trait names for IDENTITY_STALE tier', () => {
1685
- const incomingIdentity = {
1686
- identityId: 'test-id',
1687
- traits: {
1688
- emails: ['old@email.com', 'new@email.com'],
1689
- phones: ['+1234567890', '+9876543210'],
1690
- userIds: ['user1', 'user2'],
1691
- },
1692
- };
1693
- const cachedIdentity = {
1694
- identityId: 'test-id',
1695
- traits: {
1696
- emails: ['old@email.com'],
1697
- phones: ['+1234567890'],
1698
- userIds: ['user1'],
1699
- },
1700
- };
1701
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1702
- expect(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1703
- expect(result.staleTraits).toContain('emails');
1704
- expect(result.staleTraits).toContain('phones');
1705
- expect(result.staleTraits).toContain('userIds');
1706
- });
1707
- });
1708
- describe('Merge behavior verification', () => {
1709
- it('should merge incoming and cached array traits (emails, phones, userIds)', () => {
1710
- const incomingIdentity = {
1711
- identityId: 'incoming-id',
1712
- traits: {
1713
- emails: ['incoming@email.com', 'shared@email.com'],
1714
- userIds: ['incominguser'],
1715
- },
1716
- };
1717
- const cachedIdentity = {
1718
- identityId: 'cached-id',
1719
- traits: {
1720
- emails: ['cached@email.com', 'shared@email.com'],
1721
- phones: ['+1234567890'],
1722
- userIds: ['cacheduser'],
1723
- },
1724
- };
1725
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1726
- expect(result.mergedIdentity.traits?.emails).toContain('incoming@email.com');
1727
- expect(result.mergedIdentity.traits?.emails).toContain('cached@email.com');
1728
- expect(result.mergedIdentity.traits?.emails).toContain('shared@email.com');
1729
- expect(result.mergedIdentity.traits?.phones).toEqual(['+1234567890']);
1730
- expect(result.mergedIdentity.traits?.userIds).toContain('incominguser');
1731
- expect(result.mergedIdentity.traits?.userIds).toContain('cacheduser');
1732
- });
1733
- it('should preserve identityId from incoming identity', () => {
1734
- const incomingIdentity = {
1735
- identityId: 'incoming-id-123',
1736
- traits: { emails: ['test@email.com'] },
1737
- };
1738
- const cachedIdentity = {
1739
- identityId: 'cached-id-456',
1740
- traits: { phones: ['+1234567890'] },
1741
- };
1742
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1743
- expect(result.mergedIdentity.identityId).toBe('incoming-id-123');
1744
- });
1745
- it('should merge addresses from both identities', () => {
1746
- const incomingIdentity = {
1747
- identityId: 'test-id',
1748
- traits: {
1749
- addresses: [
1750
- { city: 'IncomingCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
1751
- ],
1752
- },
1753
- };
1754
- const cachedIdentity = {
1755
- identityId: 'test-id',
1756
- traits: {
1757
- addresses: [
1758
- { city: 'CachedCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
1759
- ],
1760
- },
1761
- };
1762
- const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1763
- expect(result.mergedIdentity.traits?.addresses).toHaveLength(2);
1764
- expect(result.mergedIdentity.traits?.addresses).toEqual(expect.arrayContaining([
1765
- expect.objectContaining({ city: 'IncomingCity' }),
1766
- expect.objectContaining({ city: 'CachedCity' }),
1767
- ]));
1768
- });
1769
- });
1770
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const at_tracking_event_types_1 = require("@adtrackify/at-tracking-event-types");
5
+ const at_shared_utils_1 = require("@adtrackify/at-shared-utils");
6
+ (0, vitest_1.describe)('Identity Trait Merging Tests', () => {
7
+ (0, vitest_1.afterEach)(() => {
8
+ vitest_1.vi.resetModules();
9
+ });
10
+ (0, vitest_1.describe)('mergeIdentityTraits function', () => {
11
+ (0, vitest_1.it)('should merge simple string arrays correctly', () => {
12
+ const incomingTraits = {
13
+ emails: ['new@email.com'],
14
+ userIds: ['user1', 'user2'],
15
+ };
16
+ const cachedTraits = {
17
+ emails: ['existing@email.com'],
18
+ userIds: ['user2', 'user3'],
19
+ phones: ['+1234567890'],
20
+ };
21
+ const merged = (0, at_shared_utils_1.mergeIdentityTraits)(incomingTraits, cachedTraits);
22
+ (0, vitest_1.expect)(merged.emails).toEqual(['new@email.com', 'existing@email.com']);
23
+ (0, vitest_1.expect)(merged.userIds).toEqual(['user1', 'user2', 'user3']);
24
+ (0, vitest_1.expect)(merged.phones).toEqual(['+1234567890']);
25
+ });
26
+ (0, vitest_1.it)('should handle null and undefined values in arrays', () => {
27
+ const incomingTraits = {
28
+ emails: ['test@email.com', null, undefined],
29
+ userIds: ['user1'],
30
+ };
31
+ const cachedTraits = {
32
+ emails: [null, 'cached@email.com', undefined],
33
+ userIds: null,
34
+ };
35
+ const merged = (0, at_shared_utils_1.mergeIdentityTraits)(incomingTraits, cachedTraits);
36
+ (0, vitest_1.expect)(merged.emails).toContain('test@email.com');
37
+ (0, vitest_1.expect)(merged.emails).toContain('cached@email.com');
38
+ (0, vitest_1.expect)(merged.userIds).toEqual(['user1']);
39
+ });
40
+ (0, vitest_1.it)('should merge addresses correctly', () => {
41
+ const incomingTraits = {
42
+ addresses: [
43
+ {
44
+ city: 'New York',
45
+ country: 'USA',
46
+ countryCode: 'US',
47
+ province: 'NY',
48
+ provinceCode: '10001',
49
+ },
50
+ ],
51
+ };
52
+ const cachedTraits = {
53
+ addresses: [
54
+ {
55
+ city: 'Los Angeles',
56
+ country: 'USA',
57
+ countryCode: 'US',
58
+ province: 'CA',
59
+ provinceCode: '90210',
60
+ },
61
+ ],
62
+ };
63
+ const merged = (0, at_shared_utils_1.mergeIdentityTraits)(incomingTraits, cachedTraits);
64
+ (0, vitest_1.expect)(merged.addresses).toHaveLength(2);
65
+ (0, vitest_1.expect)(merged.addresses).toEqual(vitest_1.expect.arrayContaining([
66
+ vitest_1.expect.objectContaining({ city: 'New York' }),
67
+ vitest_1.expect.objectContaining({ city: 'Los Angeles' }),
68
+ ]));
69
+ });
70
+ (0, vitest_1.it)('should merge click information correctly', () => {
71
+ const incomingTraits = {
72
+ click: {
73
+ fbp: 'fb.new.123',
74
+ fbpCollectedAt: '2024-01-01T00:00:00.000Z',
75
+ gclid: 'new_gclid',
76
+ },
77
+ };
78
+ const cachedTraits = {
79
+ click: {
80
+ fbp: 'fb.old.456',
81
+ fbpCollectedAt: '2023-12-01T00:00:00.000Z',
82
+ fbclid: 'cached_fbclid',
83
+ },
84
+ };
85
+ const merged = (0, at_shared_utils_1.mergeIdentityTraits)(incomingTraits, cachedTraits);
86
+ (0, vitest_1.expect)(merged.click?.fbp).toBe('fb.new.123');
87
+ (0, vitest_1.expect)(merged.click?.gclid).toBe('new_gclid');
88
+ (0, vitest_1.expect)(merged.click?.fbpCollectedAt).toBe('2024-01-01T00:00:00.000Z');
89
+ (0, vitest_1.expect)(merged.click?.fbclid).toBeUndefined();
90
+ });
91
+ (0, vitest_1.it)('should handle empty traits correctly', () => {
92
+ const incomingTraits = {};
93
+ const cachedTraits = {
94
+ emails: ['cached@email.com'],
95
+ userIds: ['user1'],
96
+ };
97
+ const merged = (0, at_shared_utils_1.mergeIdentityTraits)(incomingTraits, cachedTraits);
98
+ (0, vitest_1.expect)(merged.emails).toEqual(['cached@email.com']);
99
+ (0, vitest_1.expect)(merged.userIds).toEqual(['user1']);
100
+ });
101
+ (0, vitest_1.it)('should handle undefined traits correctly', () => {
102
+ const merged1 = (0, at_shared_utils_1.mergeIdentityTraits)(undefined, { emails: ['test@email.com'] });
103
+ (0, vitest_1.expect)(merged1.emails).toEqual(['test@email.com']);
104
+ const merged2 = (0, at_shared_utils_1.mergeIdentityTraits)({ emails: ['test@email.com'] }, undefined);
105
+ (0, vitest_1.expect)(merged2.emails).toEqual(['test@email.com']);
106
+ const merged3 = (0, at_shared_utils_1.mergeIdentityTraits)(undefined, undefined);
107
+ (0, vitest_1.expect)(merged3).toEqual({});
108
+ });
109
+ (0, vitest_1.it)('should preserve version information', () => {
110
+ const incomingTraits = {
111
+ version: '3',
112
+ emails: ['new@email.com'],
113
+ };
114
+ const cachedTraits = {
115
+ version: '2',
116
+ emails: ['old@email.com'],
117
+ };
118
+ const merged = (0, at_shared_utils_1.mergeIdentityTraits)(incomingTraits, cachedTraits);
119
+ (0, vitest_1.expect)(merged.version).toBe('3');
120
+ (0, vitest_1.expect)(merged.emails).toEqual(['new@email.com', 'old@email.com']);
121
+ });
122
+ (0, vitest_1.it)('should handle complex nested objects', () => {
123
+ const incomingTraits = {
124
+ click: {
125
+ googleClientInfos: [{ id: 'new1', clickId: 'click1', sessionId: 'session1' }],
126
+ },
127
+ };
128
+ const cachedTraits = {
129
+ click: {
130
+ googleClientInfos: [{ id: 'cached1', clickId: 'click2', sessionId: 'session2' }],
131
+ },
132
+ };
133
+ const merged = (0, at_shared_utils_1.mergeIdentityTraits)(incomingTraits, cachedTraits);
134
+ (0, vitest_1.expect)(merged.click?.googleClientInfos).toBeDefined();
135
+ (0, vitest_1.expect)(Array.isArray(merged.click?.googleClientInfos)).toBe(true);
136
+ (0, vitest_1.expect)(merged.click?.googleClientInfos).toEqual([{ id: 'cached1', clickId: 'click2', sessionId: 'session2' }]);
137
+ });
138
+ });
139
+ (0, vitest_1.describe)('Integration: Merging + Staleness Checking', () => {
140
+ (0, vitest_1.it)('should not be stale when merged identity matches cached identity', () => {
141
+ const cachedIdentity = {
142
+ identityId: 'test-id-123',
143
+ traits: {
144
+ emails: ['cached@email.com', 'shared@email.com'],
145
+ userIds: ['user1', 'user2'],
146
+ addresses: [
147
+ {
148
+ city: 'New York',
149
+ country: 'USA',
150
+ countryCode: 'US',
151
+ },
152
+ ],
153
+ version: '2',
154
+ },
155
+ };
156
+ const incomingIdentity = {
157
+ identityId: 'test-id-123',
158
+ traits: {
159
+ emails: ['shared@email.com'],
160
+ userIds: ['user1'],
161
+ version: '2',
162
+ },
163
+ };
164
+ const mergedTraits = (0, at_shared_utils_1.mergeIdentityTraits)(incomingIdentity.traits, cachedIdentity.traits);
165
+ const mergedIdentity = { ...incomingIdentity, traits: mergedTraits };
166
+ const staleTracker = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, mergedIdentity);
167
+ (0, vitest_1.expect)(staleTracker.isCacheStale).toBe(false);
168
+ (0, vitest_1.expect)(mergedIdentity.traits?.emails).toEqual(['shared@email.com', 'cached@email.com']);
169
+ });
170
+ (0, vitest_1.it)('should be stale when merged identity has new traits', () => {
171
+ const cachedIdentity = {
172
+ identityId: 'test-id-123',
173
+ traits: {
174
+ emails: ['cached@email.com'],
175
+ version: '2',
176
+ },
177
+ };
178
+ const incomingIdentity = {
179
+ identityId: 'test-id-123',
180
+ traits: {
181
+ emails: ['cached@email.com', 'new@email.com'],
182
+ version: '2',
183
+ },
184
+ };
185
+ const mergedTraits = (0, at_shared_utils_1.mergeIdentityTraits)(incomingIdentity.traits, cachedIdentity.traits);
186
+ const mergedIdentity = { ...incomingIdentity, traits: mergedTraits };
187
+ const staleTracker = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, mergedIdentity);
188
+ (0, vitest_1.expect)(staleTracker.isCacheStale).toBe(true);
189
+ (0, vitest_1.expect)(staleTracker.isEmailsStale).toBe(true);
190
+ });
191
+ });
192
+ });
193
+ (0, vitest_1.describe)('Identity Cache Staleness Tests', () => {
194
+ (0, vitest_1.afterEach)(() => {
195
+ vitest_1.vi.resetModules();
196
+ });
197
+ (0, vitest_1.describe)('isIdentityCacheStale function', () => {
198
+ (0, vitest_1.it)('should detect identity ID changes', () => {
199
+ const cachedIdentity = {
200
+ identityId: 'old-id',
201
+ traits: { emails: ['test@email.com'] },
202
+ };
203
+ const incomingIdentity = {
204
+ identityId: 'new-id',
205
+ traits: { emails: ['test@email.com'] },
206
+ };
207
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
208
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
209
+ (0, vitest_1.expect)(result.isIdentityIdStale).toBe(true);
210
+ });
211
+ (0, vitest_1.it)('should detect new emails', () => {
212
+ const cachedIdentity = {
213
+ identityId: 'test-id',
214
+ traits: { emails: ['old@email.com'] },
215
+ };
216
+ const incomingIdentity = {
217
+ identityId: 'test-id',
218
+ traits: { emails: ['old@email.com', 'new@email.com'] },
219
+ };
220
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
221
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
222
+ (0, vitest_1.expect)(result.isEmailsStale).toBe(true);
223
+ });
224
+ (0, vitest_1.it)('should detect new user IDs', () => {
225
+ const cachedIdentity = {
226
+ identityId: 'test-id',
227
+ traits: { userIds: ['user1'] },
228
+ };
229
+ const incomingIdentity = {
230
+ identityId: 'test-id',
231
+ traits: { userIds: ['user1', 'user2'] },
232
+ };
233
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
234
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
235
+ (0, vitest_1.expect)(result.isUserIdsStale).toBe(true);
236
+ });
237
+ (0, vitest_1.it)('should detect new phones', () => {
238
+ const cachedIdentity = {
239
+ identityId: 'test-id',
240
+ traits: { phones: ['+1234567890'] },
241
+ };
242
+ const incomingIdentity = {
243
+ identityId: 'test-id',
244
+ traits: { phones: ['+1234567890', '+9876543210'] },
245
+ };
246
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
247
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
248
+ (0, vitest_1.expect)(result.isPhonesStale).toBe(true);
249
+ });
250
+ (0, vitest_1.it)('should detect new addresses (non-IP sourced)', () => {
251
+ const cachedIdentity = {
252
+ identityId: 'test-id',
253
+ traits: {
254
+ addresses: [
255
+ {
256
+ city: 'New York',
257
+ country: 'USA',
258
+ s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT,
259
+ },
260
+ ],
261
+ },
262
+ };
263
+ const incomingIdentity = {
264
+ identityId: 'test-id',
265
+ traits: {
266
+ addresses: [
267
+ { city: 'New York', country: 'USA', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
268
+ { city: 'Los Angeles', country: 'USA', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
269
+ ],
270
+ },
271
+ };
272
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
273
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
274
+ (0, vitest_1.expect)(result.isAddressesStale).toBe(true);
275
+ (0, vitest_1.expect)(result.isNonIpAddressesStale).toBe(true);
276
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
277
+ });
278
+ (0, vitest_1.it)('should detect IP address changes but NOT mark cache stale (volatile trait)', () => {
279
+ const cachedIdentity = {
280
+ identityId: 'test-id',
281
+ traits: { ipAddress: '192.168.1.1' },
282
+ };
283
+ const incomingIdentity = {
284
+ identityId: 'test-id',
285
+ traits: { ipAddress: '10.0.0.1' },
286
+ };
287
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
288
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
289
+ (0, vitest_1.expect)(result.isIpAddressStale).toBe(true);
290
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
291
+ });
292
+ (0, vitest_1.it)('should detect user agent changes but NOT mark cache stale (volatile trait)', () => {
293
+ const cachedIdentity = {
294
+ identityId: 'test-id',
295
+ traits: { userAgent: 'Mozilla/5.0 (old browser)' },
296
+ };
297
+ const incomingIdentity = {
298
+ identityId: 'test-id',
299
+ traits: { userAgent: 'Mozilla/5.0 (new browser)' },
300
+ };
301
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
302
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
303
+ (0, vitest_1.expect)(result.isUserAgentStale).toBe(true);
304
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
305
+ });
306
+ (0, vitest_1.it)('should not be stale when no new information is provided', () => {
307
+ const cachedIdentity = {
308
+ identityId: 'test-id',
309
+ traits: {
310
+ emails: ['test@email.com'],
311
+ userIds: ['user1'],
312
+ phones: ['+1234567890'],
313
+ },
314
+ };
315
+ const incomingIdentity = {
316
+ identityId: 'test-id',
317
+ traits: {
318
+ emails: ['test@email.com'],
319
+ userIds: ['user1'],
320
+ },
321
+ };
322
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
323
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
324
+ });
325
+ (0, vitest_1.it)('should handle empty traits gracefully', () => {
326
+ const cachedIdentity = {
327
+ identityId: 'test-id',
328
+ traits: {},
329
+ };
330
+ const incomingIdentity = {
331
+ identityId: 'test-id',
332
+ traits: {},
333
+ };
334
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
335
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
336
+ });
337
+ (0, vitest_1.it)('should handle undefined traits gracefully', () => {
338
+ const cachedIdentity = {
339
+ identityId: 'test-id',
340
+ };
341
+ const incomingIdentity = {
342
+ identityId: 'test-id',
343
+ };
344
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
345
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
346
+ });
347
+ (0, vitest_1.it)('should detect multiple stale conditions (identity traits take priority over volatile)', () => {
348
+ const cachedIdentity = {
349
+ identityId: 'test-id',
350
+ traits: {
351
+ emails: ['old@email.com'],
352
+ userIds: ['user1'],
353
+ ipAddress: '192.168.1.1',
354
+ },
355
+ };
356
+ const incomingIdentity = {
357
+ identityId: 'test-id',
358
+ traits: {
359
+ emails: ['old@email.com', 'new@email.com'],
360
+ userIds: ['user1', 'user2'],
361
+ ipAddress: '10.0.0.1',
362
+ },
363
+ };
364
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
365
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
366
+ (0, vitest_1.expect)(result.isEmailsStale).toBe(true);
367
+ (0, vitest_1.expect)(result.isUserIdsStale).toBe(true);
368
+ (0, vitest_1.expect)(result.isIpAddressStale).toBe(true);
369
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
370
+ });
371
+ });
372
+ (0, vitest_1.describe)('isClickInfosStale function', () => {
373
+ (0, vitest_1.it)('should detect new FBC values', () => {
374
+ const cachedClick = {
375
+ fbc: 'fb.1.123.old_fbclid',
376
+ };
377
+ const incomingClick = {
378
+ fbc: 'fb.1.123.new_fbclid',
379
+ };
380
+ const result = (0, at_shared_utils_1.isClickInfosStale)(cachedClick, incomingClick);
381
+ (0, vitest_1.expect)(result).toBe(true);
382
+ });
383
+ (0, vitest_1.it)('should detect new click IDs', () => {
384
+ const cachedClick = {
385
+ gclid: 'old_gclid',
386
+ };
387
+ const incomingClick = {
388
+ gclid: 'new_gclid',
389
+ };
390
+ const result = (0, at_shared_utils_1.isClickInfosStale)(cachedClick, incomingClick);
391
+ (0, vitest_1.expect)(result).toBe(true);
392
+ });
393
+ (0, vitest_1.it)('should ignore collection timestamps', () => {
394
+ const cachedClick = {
395
+ fbp: 'fb.2.123.456',
396
+ fbpCollectedAt: '2023-01-01T00:00:00.000Z',
397
+ };
398
+ const incomingClick = {
399
+ fbp: 'fb.2.123.456',
400
+ fbpCollectedAt: '2024-01-01T00:00:00.000Z',
401
+ };
402
+ const result = (0, at_shared_utils_1.isClickInfosStale)(cachedClick, incomingClick);
403
+ (0, vitest_1.expect)(result).toBe(false);
404
+ });
405
+ (0, vitest_1.it)('should ignore googleClientInfos', () => {
406
+ const cachedClick = {
407
+ googleClientInfos: [{ id: 'old', clickId: 'old_click' }],
408
+ };
409
+ const incomingClick = {
410
+ googleClientInfos: [{ id: 'new', clickId: 'new_click' }],
411
+ };
412
+ const result = (0, at_shared_utils_1.isClickInfosStale)(cachedClick, incomingClick);
413
+ (0, vitest_1.expect)(result).toBe(false);
414
+ });
415
+ (0, vitest_1.it)('should handle empty click info', () => {
416
+ const result = (0, at_shared_utils_1.isClickInfosStale)({}, {});
417
+ (0, vitest_1.expect)(result).toBe(false);
418
+ });
419
+ (0, vitest_1.it)('should detect when incoming has new click info but cached is empty', () => {
420
+ const cachedClick = {};
421
+ const incomingClick = {
422
+ fbp: 'fb.2.123.456',
423
+ };
424
+ const result = (0, at_shared_utils_1.isClickInfosStale)(cachedClick, incomingClick);
425
+ (0, vitest_1.expect)(result).toBe(true);
426
+ });
427
+ });
428
+ (0, vitest_1.describe)('Edge Cases and Error Handling', () => {
429
+ (0, vitest_1.it)('should handle malformed FBC values gracefully', () => {
430
+ const cachedClick = {
431
+ fbc: 'malformed_fbc',
432
+ };
433
+ const incomingClick = {
434
+ fbc: 'also_malformed',
435
+ };
436
+ const result = (0, at_shared_utils_1.isClickInfosStale)(cachedClick, incomingClick);
437
+ (0, vitest_1.expect)(result).toBe(true);
438
+ });
439
+ (0, vitest_1.it)('should handle null/undefined arrays in traits', () => {
440
+ const cachedIdentity = {
441
+ identityId: 'test-id',
442
+ traits: {
443
+ emails: null,
444
+ userIds: undefined,
445
+ },
446
+ };
447
+ const incomingIdentity = {
448
+ identityId: 'test-id',
449
+ traits: {
450
+ emails: ['new@email.com'],
451
+ userIds: ['user1'],
452
+ },
453
+ };
454
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
455
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
456
+ (0, vitest_1.expect)(result.isEmailsStale).toBe(true);
457
+ (0, vitest_1.expect)(result.isUserIdsStale).toBe(true);
458
+ });
459
+ (0, vitest_1.it)('should handle arrays with null/undefined elements', () => {
460
+ const cachedIdentity = {
461
+ identityId: 'test-id',
462
+ traits: {
463
+ emails: ['valid@email.com', null, undefined],
464
+ },
465
+ };
466
+ const incomingIdentity = {
467
+ identityId: 'test-id',
468
+ traits: {
469
+ emails: ['valid@email.com', null, undefined, 'new@email.com'],
470
+ },
471
+ };
472
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
473
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
474
+ (0, vitest_1.expect)(result.isEmailsStale).toBe(true);
475
+ });
476
+ (0, vitest_1.it)('should handle error conditions gracefully', () => {
477
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(null, undefined);
478
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
479
+ });
480
+ });
481
+ (0, vitest_1.describe)('Comprehensive Scenario Tests', () => {
482
+ (0, vitest_1.it)('should handle complex real-world scenario', () => {
483
+ const cachedIdentity = {
484
+ identityId: '01HXRZ27H4TXWBBTRK09Q7APDP',
485
+ traits: {
486
+ emails: ['user@domain.com'],
487
+ userIds: ['shopify_123'],
488
+ addresses: [
489
+ {
490
+ city: 'New York',
491
+ country: 'USA',
492
+ countryCode: 'US',
493
+ province: 'NY',
494
+ provinceCode: '10001',
495
+ },
496
+ ],
497
+ click: {
498
+ fbp: 'fb.2.1715603578424.5068754021',
499
+ fbpCollectedAt: '2024-05-13T12:32:58.424Z',
500
+ gclid: 'original_gclid',
501
+ },
502
+ ipAddress: '192.168.1.100',
503
+ version: '2',
504
+ },
505
+ };
506
+ const incomingIdentity = {
507
+ identityId: '01HXRZ27H4TXWBBTRK09Q7APDP',
508
+ traits: {
509
+ emails: ['user@domain.com', 'user.secondary@domain.com'],
510
+ phones: ['+1234567890'],
511
+ addresses: [
512
+ {
513
+ city: 'New York',
514
+ country: 'USA',
515
+ countryCode: 'US',
516
+ province: 'NY',
517
+ provinceCode: '10001',
518
+ },
519
+ ],
520
+ click: {
521
+ fbp: 'fb.2.1715603578424.5068754021',
522
+ fbpCollectedAt: '2024-05-13T15:30:00.000Z',
523
+ gclid: 'updated_gclid',
524
+ },
525
+ ipAddress: '192.168.1.100',
526
+ version: '2',
527
+ },
528
+ };
529
+ const mergedTraits = (0, at_shared_utils_1.mergeIdentityTraits)(cachedIdentity.traits, incomingIdentity.traits);
530
+ const mergedIdentity = { ...incomingIdentity, traits: mergedTraits };
531
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, mergedIdentity);
532
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
533
+ (0, vitest_1.expect)(result.isEmailsStale).toBe(true);
534
+ (0, vitest_1.expect)(result.isPhonesStale).toBe(true);
535
+ (0, vitest_1.expect)(result.isClickInfosStale).toBe(true);
536
+ (0, vitest_1.expect)(result.isAddressesStale).toBe(false);
537
+ (0, vitest_1.expect)(result.isIpAddressStale).toBe(false);
538
+ (0, vitest_1.expect)(mergedIdentity.traits?.emails).toEqual(['user@domain.com', 'user.secondary@domain.com']);
539
+ (0, vitest_1.expect)(mergedIdentity.traits?.phones).toEqual(['+1234567890']);
540
+ (0, vitest_1.expect)(mergedIdentity.traits?.userIds).toEqual(['shopify_123']);
541
+ (0, vitest_1.expect)(mergedIdentity.traits?.click?.gclid).toEqual('updated_gclid');
542
+ });
543
+ (0, vitest_1.it)('should properly detect click staleness when click info actually differs', () => {
544
+ const cachedIdentity = {
545
+ identityId: 'test-id',
546
+ traits: {
547
+ click: {
548
+ gclid: 'original_gclid',
549
+ gclidCollectedAt: '2024-05-15T12:32:58.424Z',
550
+ },
551
+ },
552
+ };
553
+ const incomingIdentity = {
554
+ identityId: 'test-id',
555
+ traits: {
556
+ click: {
557
+ gclid: 'completely_different_gclid',
558
+ gclidCollectedAt: '2024-05-13T12:32:58.424Z',
559
+ },
560
+ },
561
+ };
562
+ const mergedTraits = (0, at_shared_utils_1.mergeIdentityTraits)(cachedIdentity.traits, incomingIdentity.traits);
563
+ const mergedIdentity = { ...incomingIdentity, traits: mergedTraits };
564
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, mergedIdentity);
565
+ (0, vitest_1.expect)(mergedTraits?.click?.gclid).toEqual('original_gclid');
566
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
567
+ });
568
+ (0, vitest_1.it)('should handle scenario where cache is fresh', () => {
569
+ const cachedIdentity = {
570
+ identityId: 'test-id',
571
+ traits: {
572
+ emails: ['user@domain.com', 'secondary@domain.com'],
573
+ userIds: ['user1', 'user2'],
574
+ phones: ['+1234567890'],
575
+ version: '2',
576
+ },
577
+ };
578
+ const incomingIdentity = {
579
+ identityId: 'test-id',
580
+ traits: {
581
+ emails: ['user@domain.com'],
582
+ userIds: ['user1'],
583
+ version: '2',
584
+ },
585
+ };
586
+ const mergedTraits = (0, at_shared_utils_1.mergeIdentityTraits)(cachedIdentity.traits, incomingIdentity.traits);
587
+ const mergedIdentity = { ...incomingIdentity, traits: mergedTraits };
588
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, mergedIdentity);
589
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
590
+ (0, vitest_1.expect)(mergedIdentity.traits?.emails).toEqual(['user@domain.com', 'secondary@domain.com']);
591
+ (0, vitest_1.expect)(mergedIdentity.traits?.userIds).toEqual(['user1', 'user2']);
592
+ (0, vitest_1.expect)(mergedIdentity.traits?.phones).toEqual(['+1234567890']);
593
+ });
594
+ });
595
+ });
596
+ (0, vitest_1.describe)('Three-Tier Staleness Model Tests', () => {
597
+ (0, vitest_1.afterEach)(() => {
598
+ vitest_1.vi.resetModules();
599
+ });
600
+ (0, vitest_1.describe)('TIER 1: VOLATILE_ONLY (no action needed)', () => {
601
+ (0, vitest_1.it)('should return VOLATILE_ONLY tier when only ipAddress is stale', () => {
602
+ const cachedIdentity = {
603
+ identityId: 'test-id',
604
+ traits: {
605
+ emails: ['test@email.com'],
606
+ ipAddress: '192.168.1.1',
607
+ },
608
+ };
609
+ const incomingIdentity = {
610
+ identityId: 'test-id',
611
+ traits: {
612
+ emails: ['test@email.com'],
613
+ ipAddress: '10.0.0.1',
614
+ },
615
+ };
616
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
617
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
618
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
619
+ (0, vitest_1.expect)(result.isIpAddressStale).toBe(true);
620
+ });
621
+ (0, vitest_1.it)('should return VOLATILE_ONLY tier when only userAgent is stale', () => {
622
+ const cachedIdentity = {
623
+ identityId: 'test-id',
624
+ traits: {
625
+ emails: ['test@email.com'],
626
+ userAgent: 'Mozilla/5.0 (old)',
627
+ },
628
+ };
629
+ const incomingIdentity = {
630
+ identityId: 'test-id',
631
+ traits: {
632
+ emails: ['test@email.com'],
633
+ userAgent: 'Mozilla/5.0 (new)',
634
+ },
635
+ };
636
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
637
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
638
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
639
+ (0, vitest_1.expect)(result.isUserAgentStale).toBe(true);
640
+ });
641
+ (0, vitest_1.it)('should return VOLATILE_ONLY tier when only IP-sourced addresses are stale', () => {
642
+ const cachedIdentity = {
643
+ identityId: 'test-id',
644
+ traits: {
645
+ emails: ['test@email.com'],
646
+ addresses: [{ city: 'New York', country: 'USA', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS }],
647
+ },
648
+ };
649
+ const incomingIdentity = {
650
+ identityId: 'test-id',
651
+ traits: {
652
+ emails: ['test@email.com'],
653
+ addresses: [
654
+ { city: 'Los Angeles', country: 'USA', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS },
655
+ ],
656
+ },
657
+ };
658
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
659
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
660
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
661
+ (0, vitest_1.expect)(result.isIpAddressesStale).toBe(true);
662
+ (0, vitest_1.expect)(result.isNonIpAddressesStale).toBe(false);
663
+ });
664
+ (0, vitest_1.it)('should return VOLATILE_ONLY tier when multiple volatile traits are stale', () => {
665
+ const cachedIdentity = {
666
+ identityId: 'test-id',
667
+ traits: {
668
+ emails: ['test@email.com'],
669
+ ipAddress: '192.168.1.1',
670
+ userAgent: 'Mozilla/5.0 (old)',
671
+ addresses: [{ city: 'New York', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS }],
672
+ },
673
+ };
674
+ const incomingIdentity = {
675
+ identityId: 'test-id',
676
+ traits: {
677
+ emails: ['test@email.com'],
678
+ ipAddress: '10.0.0.1',
679
+ userAgent: 'Mozilla/5.0 (new)',
680
+ addresses: [{ city: 'Chicago', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS }],
681
+ },
682
+ };
683
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
684
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
685
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
686
+ (0, vitest_1.expect)(result.isIpAddressStale).toBe(true);
687
+ (0, vitest_1.expect)(result.isUserAgentStale).toBe(true);
688
+ (0, vitest_1.expect)(result.isIpAddressesStale).toBe(true);
689
+ });
690
+ });
691
+ (0, vitest_1.describe)('TIER 2: ADDRESS_UPDATE (cache write only, skip Neptune)', () => {
692
+ (0, vitest_1.it)('should return ADDRESS_UPDATE tier when non-IP address is new', () => {
693
+ const cachedIdentity = {
694
+ identityId: 'test-id',
695
+ traits: {
696
+ emails: ['test@email.com'],
697
+ addresses: [],
698
+ },
699
+ };
700
+ const incomingIdentity = {
701
+ identityId: 'test-id',
702
+ traits: {
703
+ emails: ['test@email.com'],
704
+ addresses: [{ city: 'Boston', province: 'MA', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT }],
705
+ },
706
+ };
707
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
708
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
709
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
710
+ (0, vitest_1.expect)(result.isNonIpAddressesStale).toBe(true);
711
+ });
712
+ (0, vitest_1.it)('should return ADDRESS_UPDATE tier when new input address added', () => {
713
+ const cachedIdentity = {
714
+ identityId: 'test-id',
715
+ traits: {
716
+ emails: ['test@email.com'],
717
+ addresses: [{ city: 'New York', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT }],
718
+ },
719
+ };
720
+ const incomingIdentity = {
721
+ identityId: 'test-id',
722
+ traits: {
723
+ emails: ['test@email.com'],
724
+ addresses: [
725
+ { city: 'New York', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
726
+ { city: 'Boston', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
727
+ ],
728
+ },
729
+ };
730
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
731
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
732
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
733
+ (0, vitest_1.expect)(result.isNonIpAddressesStale).toBe(true);
734
+ });
735
+ (0, vitest_1.it)('should return ADDRESS_UPDATE tier even when volatile traits are also stale', () => {
736
+ const cachedIdentity = {
737
+ identityId: 'test-id',
738
+ traits: {
739
+ emails: ['test@email.com'],
740
+ ipAddress: '192.168.1.1',
741
+ addresses: [],
742
+ },
743
+ };
744
+ const incomingIdentity = {
745
+ identityId: 'test-id',
746
+ traits: {
747
+ emails: ['test@email.com'],
748
+ ipAddress: '10.0.0.1',
749
+ addresses: [
750
+ { city: 'Boston', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
751
+ ],
752
+ },
753
+ };
754
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
755
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
756
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
757
+ (0, vitest_1.expect)(result.isIpAddressStale).toBe(true);
758
+ (0, vitest_1.expect)(result.isNonIpAddressesStale).toBe(true);
759
+ });
760
+ });
761
+ (0, vitest_1.describe)('TIER 3: IDENTITY_STALE (full Neptune resolution)', () => {
762
+ (0, vitest_1.it)('should return IDENTITY_STALE tier when email is new', () => {
763
+ const cachedIdentity = {
764
+ identityId: 'test-id',
765
+ traits: {
766
+ emails: ['old@email.com'],
767
+ },
768
+ };
769
+ const incomingIdentity = {
770
+ identityId: 'test-id',
771
+ traits: {
772
+ emails: ['old@email.com', 'new@email.com'],
773
+ },
774
+ };
775
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
776
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
777
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
778
+ (0, vitest_1.expect)(result.isEmailsStale).toBe(true);
779
+ });
780
+ (0, vitest_1.it)('should return IDENTITY_STALE tier when identityId changes', () => {
781
+ const cachedIdentity = {
782
+ identityId: 'old-id',
783
+ traits: { emails: ['test@email.com'] },
784
+ };
785
+ const incomingIdentity = {
786
+ identityId: 'new-id',
787
+ traits: { emails: ['test@email.com'] },
788
+ };
789
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
790
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
791
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
792
+ (0, vitest_1.expect)(result.isIdentityIdStale).toBe(true);
793
+ });
794
+ (0, vitest_1.it)('should return IDENTITY_STALE tier when phone is new', () => {
795
+ const cachedIdentity = {
796
+ identityId: 'test-id',
797
+ traits: { phones: ['+1234567890'] },
798
+ };
799
+ const incomingIdentity = {
800
+ identityId: 'test-id',
801
+ traits: { phones: ['+1234567890', '+9876543210'] },
802
+ };
803
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
804
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
805
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
806
+ (0, vitest_1.expect)(result.isPhonesStale).toBe(true);
807
+ });
808
+ (0, vitest_1.it)('should return IDENTITY_STALE tier when click info changes', () => {
809
+ const cachedIdentity = {
810
+ identityId: 'test-id',
811
+ traits: {
812
+ click: { gclid: 'old_gclid' },
813
+ },
814
+ };
815
+ const incomingIdentity = {
816
+ identityId: 'test-id',
817
+ traits: {
818
+ click: { gclid: 'new_gclid' },
819
+ },
820
+ };
821
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
822
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
823
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
824
+ (0, vitest_1.expect)(result.isClickInfosStale).toBe(true);
825
+ });
826
+ (0, vitest_1.it)('should return IDENTITY_STALE tier when identity trait is stale even with ADDRESS_UPDATE', () => {
827
+ const cachedIdentity = {
828
+ identityId: 'test-id',
829
+ traits: {
830
+ emails: ['old@email.com'],
831
+ addresses: [],
832
+ },
833
+ };
834
+ const incomingIdentity = {
835
+ identityId: 'test-id',
836
+ traits: {
837
+ emails: ['old@email.com', 'new@email.com'],
838
+ addresses: [
839
+ { city: 'Boston', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
840
+ ],
841
+ },
842
+ };
843
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
844
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
845
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
846
+ (0, vitest_1.expect)(result.isEmailsStale).toBe(true);
847
+ (0, vitest_1.expect)(result.isNonIpAddressesStale).toBe(true);
848
+ });
849
+ (0, vitest_1.it)('should return IDENTITY_STALE tier when identity trait is stale even with VOLATILE_ONLY', () => {
850
+ const cachedIdentity = {
851
+ identityId: 'test-id',
852
+ traits: {
853
+ emails: ['old@email.com'],
854
+ ipAddress: '192.168.1.1',
855
+ },
856
+ };
857
+ const incomingIdentity = {
858
+ identityId: 'test-id',
859
+ traits: {
860
+ emails: ['old@email.com', 'new@email.com'],
861
+ ipAddress: '10.0.0.1',
862
+ },
863
+ };
864
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
865
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
866
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
867
+ (0, vitest_1.expect)(result.isEmailsStale).toBe(true);
868
+ (0, vitest_1.expect)(result.isIpAddressStale).toBe(true);
869
+ });
870
+ });
871
+ (0, vitest_1.describe)('TIER NONE: No staleness', () => {
872
+ (0, vitest_1.it)('should return NONE tier when nothing is stale', () => {
873
+ const cachedIdentity = {
874
+ identityId: 'test-id',
875
+ traits: {
876
+ emails: ['test@email.com'],
877
+ phones: ['+1234567890'],
878
+ ipAddress: '192.168.1.1',
879
+ },
880
+ };
881
+ const incomingIdentity = {
882
+ identityId: 'test-id',
883
+ traits: {
884
+ emails: ['test@email.com'],
885
+ phones: ['+1234567890'],
886
+ ipAddress: '192.168.1.1',
887
+ },
888
+ };
889
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
890
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
891
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
892
+ });
893
+ (0, vitest_1.it)('should return NONE tier when incoming is subset of cached', () => {
894
+ const cachedIdentity = {
895
+ identityId: 'test-id',
896
+ traits: {
897
+ emails: ['a@email.com', 'b@email.com'],
898
+ phones: ['+1234567890', '+9876543210'],
899
+ },
900
+ };
901
+ const incomingIdentity = {
902
+ identityId: 'test-id',
903
+ traits: {
904
+ emails: ['a@email.com'],
905
+ },
906
+ };
907
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
908
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
909
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
910
+ });
911
+ });
912
+ (0, vitest_1.describe)('Address source filtering', () => {
913
+ (0, vitest_1.it)('should correctly identify IP-sourced addresses', () => {
914
+ const cachedIdentity = {
915
+ identityId: 'test-id',
916
+ traits: {
917
+ addresses: [{ city: 'CachedCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS }],
918
+ },
919
+ };
920
+ const incomingIdentity = {
921
+ identityId: 'test-id',
922
+ traits: {
923
+ addresses: [
924
+ { city: 'NewCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS },
925
+ ],
926
+ },
927
+ };
928
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
929
+ (0, vitest_1.expect)(result.isIpAddressesStale).toBe(true);
930
+ (0, vitest_1.expect)(result.isNonIpAddressesStale).toBe(false);
931
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
932
+ });
933
+ (0, vitest_1.it)('should correctly identify INPUT-sourced addresses', () => {
934
+ const cachedIdentity = {
935
+ identityId: 'test-id',
936
+ traits: {
937
+ addresses: [{ city: 'CachedCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT }],
938
+ },
939
+ };
940
+ const incomingIdentity = {
941
+ identityId: 'test-id',
942
+ traits: {
943
+ addresses: [
944
+ { city: 'CachedCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
945
+ { city: 'NewCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
946
+ ],
947
+ },
948
+ };
949
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
950
+ (0, vitest_1.expect)(result.isIpAddressesStale).toBe(false);
951
+ (0, vitest_1.expect)(result.isNonIpAddressesStale).toBe(true);
952
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
953
+ });
954
+ (0, vitest_1.it)('should handle mixed address sources correctly', () => {
955
+ const cachedIdentity = {
956
+ identityId: 'test-id',
957
+ traits: {
958
+ addresses: [
959
+ { city: 'IPCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS },
960
+ { city: 'InputCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
961
+ ],
962
+ },
963
+ };
964
+ const incomingIdentity = {
965
+ identityId: 'test-id',
966
+ traits: {
967
+ addresses: [
968
+ { city: 'NewIPCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS },
969
+ { city: 'InputCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
970
+ { city: 'NewInputCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT },
971
+ ],
972
+ },
973
+ };
974
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
975
+ (0, vitest_1.expect)(result.isIpAddressesStale).toBe(true);
976
+ (0, vitest_1.expect)(result.isNonIpAddressesStale).toBe(true);
977
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
978
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
979
+ });
980
+ (0, vitest_1.it)('should handle addresses without source field (default to IP based on PII)', () => {
981
+ const cachedIdentity = {
982
+ identityId: 'test-id',
983
+ traits: {
984
+ addresses: [],
985
+ },
986
+ };
987
+ const incomingIdentity = {
988
+ identityId: 'test-id',
989
+ traits: {
990
+ addresses: [
991
+ { city: 'NoSourceCity' },
992
+ ],
993
+ },
994
+ };
995
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
996
+ (0, vitest_1.expect)(result.isIpAddressesStale).toBe(true);
997
+ (0, vitest_1.expect)(result.isNonIpAddressesStale).toBe(false);
998
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
999
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
1000
+ });
1001
+ (0, vitest_1.it)('should treat addresses without source but with PII as non-IP', () => {
1002
+ const cachedIdentity = {
1003
+ identityId: 'test-id',
1004
+ traits: {
1005
+ addresses: [],
1006
+ },
1007
+ };
1008
+ const incomingIdentity = {
1009
+ identityId: 'test-id',
1010
+ traits: {
1011
+ addresses: [
1012
+ { city: 'InputCity', firstName: 'John' },
1013
+ ],
1014
+ },
1015
+ };
1016
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
1017
+ (0, vitest_1.expect)(result.isNonIpAddressesStale).toBe(true);
1018
+ (0, vitest_1.expect)(result.isIpAddressesStale).toBe(false);
1019
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
1020
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
1021
+ });
1022
+ });
1023
+ (0, vitest_1.describe)('Backward compatibility', () => {
1024
+ (0, vitest_1.it)('should maintain isAddressesStale for any address change', () => {
1025
+ const cachedIdentity = {
1026
+ identityId: 'test-id',
1027
+ traits: {
1028
+ addresses: [{ city: 'OldCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS }],
1029
+ },
1030
+ };
1031
+ const incomingIdentity = {
1032
+ identityId: 'test-id',
1033
+ traits: {
1034
+ addresses: [{ city: 'NewCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS }],
1035
+ },
1036
+ };
1037
+ const result = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
1038
+ (0, vitest_1.expect)(result.isAddressesStale).toBe(true);
1039
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
1040
+ });
1041
+ });
1042
+ });
1043
+ (0, vitest_1.describe)('extractStaleTraitNames function', () => {
1044
+ (0, vitest_1.it)('should return empty array when nothing is stale', () => {
1045
+ const cachedIdentity = {
1046
+ identityId: 'test-id',
1047
+ traits: { emails: ['test@email.com'] },
1048
+ };
1049
+ const incomingIdentity = {
1050
+ identityId: 'test-id',
1051
+ traits: { emails: ['test@email.com'] },
1052
+ };
1053
+ const tracker = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
1054
+ const staleTraits = (0, at_shared_utils_1.extractStaleTraitNames)(tracker);
1055
+ (0, vitest_1.expect)(staleTraits).toEqual([]);
1056
+ });
1057
+ (0, vitest_1.it)('should return identity-defining trait names when stale', () => {
1058
+ const cachedIdentity = {
1059
+ identityId: 'test-id',
1060
+ traits: { emails: ['old@email.com'] },
1061
+ };
1062
+ const incomingIdentity = {
1063
+ identityId: 'test-id',
1064
+ traits: { emails: ['old@email.com', 'new@email.com'] },
1065
+ };
1066
+ const tracker = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
1067
+ const staleTraits = (0, at_shared_utils_1.extractStaleTraitNames)(tracker);
1068
+ (0, vitest_1.expect)(staleTraits).toContain('emails');
1069
+ });
1070
+ (0, vitest_1.it)('should return multiple stale trait names', () => {
1071
+ const cachedIdentity = {
1072
+ identityId: 'test-id',
1073
+ traits: {
1074
+ emails: ['old@email.com'],
1075
+ phones: ['+1234567890'],
1076
+ },
1077
+ };
1078
+ const incomingIdentity = {
1079
+ identityId: 'test-id',
1080
+ traits: {
1081
+ emails: ['old@email.com', 'new@email.com'],
1082
+ phones: ['+1234567890', '+9876543210'],
1083
+ },
1084
+ };
1085
+ const tracker = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
1086
+ const staleTraits = (0, at_shared_utils_1.extractStaleTraitNames)(tracker);
1087
+ (0, vitest_1.expect)(staleTraits).toContain('emails');
1088
+ (0, vitest_1.expect)(staleTraits).toContain('phones');
1089
+ });
1090
+ (0, vitest_1.it)('should return volatile trait names when stale', () => {
1091
+ const cachedIdentity = {
1092
+ identityId: 'test-id',
1093
+ traits: {
1094
+ ipAddress: '192.168.1.1',
1095
+ userAgent: 'old-agent',
1096
+ },
1097
+ };
1098
+ const incomingIdentity = {
1099
+ identityId: 'test-id',
1100
+ traits: {
1101
+ ipAddress: '10.0.0.1',
1102
+ userAgent: 'new-agent',
1103
+ },
1104
+ };
1105
+ const tracker = (0, at_shared_utils_1.isIdentityCacheStale)(cachedIdentity, incomingIdentity);
1106
+ const staleTraits = (0, at_shared_utils_1.extractStaleTraitNames)(tracker);
1107
+ (0, vitest_1.expect)(staleTraits).toContain('ipAddress');
1108
+ (0, vitest_1.expect)(staleTraits).toContain('userAgent');
1109
+ });
1110
+ });
1111
+ (0, vitest_1.describe)('mergeAndComputeIdentityStaleness function', () => {
1112
+ (0, vitest_1.describe)('NONE tier - cache is fresh', () => {
1113
+ (0, vitest_1.it)('should return NONE tier when incoming is subset of cached', () => {
1114
+ const incomingIdentity = {
1115
+ identityId: 'test-id',
1116
+ traits: { emails: ['shared@email.com'] },
1117
+ };
1118
+ const cachedIdentity = {
1119
+ identityId: 'test-id',
1120
+ traits: {
1121
+ emails: ['shared@email.com', 'other@email.com'],
1122
+ phones: ['+1234567890'],
1123
+ },
1124
+ };
1125
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1126
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1127
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
1128
+ (0, vitest_1.expect)(result.staleTraits).toEqual([]);
1129
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.emails).toEqual(['shared@email.com', 'other@email.com']);
1130
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.phones).toEqual(['+1234567890']);
1131
+ });
1132
+ (0, vitest_1.it)('should return NONE tier when identities are identical', () => {
1133
+ const incomingIdentity = {
1134
+ identityId: 'test-id',
1135
+ traits: {
1136
+ emails: ['test@email.com'],
1137
+ phones: ['+1234567890'],
1138
+ },
1139
+ };
1140
+ const cachedIdentity = {
1141
+ identityId: 'test-id',
1142
+ traits: {
1143
+ emails: ['test@email.com'],
1144
+ phones: ['+1234567890'],
1145
+ },
1146
+ };
1147
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1148
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1149
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
1150
+ (0, vitest_1.expect)(result.staleTraits).toEqual([]);
1151
+ });
1152
+ (0, vitest_1.it)('should return NONE tier with identical click info', () => {
1153
+ const incomingIdentity = {
1154
+ identityId: 'test-id',
1155
+ traits: {
1156
+ emails: ['test@email.com'],
1157
+ click: { gclid: 'same_gclid', fbp: 'fb.1.123.456' },
1158
+ },
1159
+ };
1160
+ const cachedIdentity = {
1161
+ identityId: 'test-id',
1162
+ traits: {
1163
+ emails: ['test@email.com'],
1164
+ click: { gclid: 'same_gclid', fbp: 'fb.1.123.456' },
1165
+ },
1166
+ };
1167
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1168
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1169
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
1170
+ });
1171
+ });
1172
+ (0, vitest_1.describe)('VOLATILE_ONLY tier - treat as cache hit', () => {
1173
+ (0, vitest_1.it)('should return VOLATILE_ONLY tier when only ipAddress is new', () => {
1174
+ const incomingIdentity = {
1175
+ identityId: 'test-id',
1176
+ traits: {
1177
+ emails: ['test@email.com'],
1178
+ ipAddress: '10.0.0.1',
1179
+ },
1180
+ };
1181
+ const cachedIdentity = {
1182
+ identityId: 'test-id',
1183
+ traits: {
1184
+ emails: ['test@email.com'],
1185
+ },
1186
+ };
1187
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1188
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
1189
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
1190
+ (0, vitest_1.expect)(result.staleTraits).toContain('ipAddress');
1191
+ });
1192
+ (0, vitest_1.it)('should return VOLATILE_ONLY tier when only userAgent is new', () => {
1193
+ const incomingIdentity = {
1194
+ identityId: 'test-id',
1195
+ traits: {
1196
+ emails: ['test@email.com'],
1197
+ userAgent: 'new-agent',
1198
+ },
1199
+ };
1200
+ const cachedIdentity = {
1201
+ identityId: 'test-id',
1202
+ traits: {
1203
+ emails: ['test@email.com'],
1204
+ },
1205
+ };
1206
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1207
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
1208
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
1209
+ (0, vitest_1.expect)(result.staleTraits).toContain('userAgent');
1210
+ });
1211
+ (0, vitest_1.it)('should return VOLATILE_ONLY tier when only IP-sourced address is new', () => {
1212
+ const incomingIdentity = {
1213
+ identityId: 'test-id',
1214
+ traits: {
1215
+ emails: ['test@email.com'],
1216
+ addresses: [{ city: 'NewIPCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.IP_ADDRESS }],
1217
+ },
1218
+ };
1219
+ const cachedIdentity = {
1220
+ identityId: 'test-id',
1221
+ traits: {
1222
+ emails: ['test@email.com'],
1223
+ addresses: [],
1224
+ },
1225
+ };
1226
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1227
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
1228
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
1229
+ });
1230
+ });
1231
+ (0, vitest_1.describe)('ADDRESS_UPDATE tier - cache write only, skip Neptune', () => {
1232
+ (0, vitest_1.it)('should return ADDRESS_UPDATE tier when non-IP address is new', () => {
1233
+ const incomingIdentity = {
1234
+ identityId: 'test-id',
1235
+ traits: {
1236
+ emails: ['test@email.com'],
1237
+ addresses: [{ city: 'Boston', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT }],
1238
+ },
1239
+ };
1240
+ const cachedIdentity = {
1241
+ identityId: 'test-id',
1242
+ traits: {
1243
+ emails: ['test@email.com'],
1244
+ addresses: [],
1245
+ },
1246
+ };
1247
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1248
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
1249
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
1250
+ (0, vitest_1.expect)(result.staleTraits).toContain('addresses');
1251
+ });
1252
+ (0, vitest_1.it)('should return ADDRESS_UPDATE even with volatile traits stale', () => {
1253
+ const incomingIdentity = {
1254
+ identityId: 'test-id',
1255
+ traits: {
1256
+ emails: ['test@email.com'],
1257
+ ipAddress: '10.0.0.1',
1258
+ addresses: [{ city: 'Boston', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT }],
1259
+ },
1260
+ };
1261
+ const cachedIdentity = {
1262
+ identityId: 'test-id',
1263
+ traits: {
1264
+ emails: ['test@email.com'],
1265
+ ipAddress: '192.168.1.1',
1266
+ addresses: [],
1267
+ },
1268
+ };
1269
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1270
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
1271
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
1272
+ });
1273
+ });
1274
+ (0, vitest_1.describe)('IDENTITY_STALE tier - full Neptune resolution', () => {
1275
+ (0, vitest_1.it)('should return IDENTITY_STALE tier when email is new', () => {
1276
+ const incomingIdentity = {
1277
+ identityId: 'test-id',
1278
+ traits: { emails: ['old@email.com', 'new@email.com'] },
1279
+ };
1280
+ const cachedIdentity = {
1281
+ identityId: 'test-id',
1282
+ traits: { emails: ['old@email.com'] },
1283
+ };
1284
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1285
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1286
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
1287
+ (0, vitest_1.expect)(result.staleTraits).toContain('emails');
1288
+ });
1289
+ (0, vitest_1.it)('should return IDENTITY_STALE tier when phone is new', () => {
1290
+ const incomingIdentity = {
1291
+ identityId: 'test-id',
1292
+ traits: { phones: ['+1234567890', '+9876543210'] },
1293
+ };
1294
+ const cachedIdentity = {
1295
+ identityId: 'test-id',
1296
+ traits: { phones: ['+1234567890'] },
1297
+ };
1298
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1299
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1300
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
1301
+ (0, vitest_1.expect)(result.staleTraits).toContain('phones');
1302
+ });
1303
+ (0, vitest_1.it)('should return IDENTITY_STALE tier when identityId changes', () => {
1304
+ const incomingIdentity = {
1305
+ identityId: 'new-id',
1306
+ traits: { emails: ['test@email.com'] },
1307
+ };
1308
+ const cachedIdentity = {
1309
+ identityId: 'old-id',
1310
+ traits: { emails: ['test@email.com'] },
1311
+ };
1312
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1313
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1314
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
1315
+ (0, vitest_1.expect)(result.staleTraits).toContain('identityId');
1316
+ });
1317
+ (0, vitest_1.it)('should return IDENTITY_STALE tier when click info is new', () => {
1318
+ const incomingIdentity = {
1319
+ identityId: 'test-id',
1320
+ traits: { click: { gclid: 'new_gclid' } },
1321
+ };
1322
+ const cachedIdentity = {
1323
+ identityId: 'test-id',
1324
+ traits: {},
1325
+ };
1326
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1327
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1328
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
1329
+ (0, vitest_1.expect)(result.staleTraits).toContain('clickInfos');
1330
+ });
1331
+ (0, vitest_1.it)('should return IDENTITY_STALE even with ADDRESS_UPDATE also present', () => {
1332
+ const incomingIdentity = {
1333
+ identityId: 'test-id',
1334
+ traits: {
1335
+ emails: ['old@email.com', 'new@email.com'],
1336
+ addresses: [{ city: 'Boston', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT }],
1337
+ },
1338
+ };
1339
+ const cachedIdentity = {
1340
+ identityId: 'test-id',
1341
+ traits: {
1342
+ emails: ['old@email.com'],
1343
+ addresses: [],
1344
+ },
1345
+ };
1346
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1347
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1348
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
1349
+ (0, vitest_1.expect)(result.staleTraits).toContain('emails');
1350
+ (0, vitest_1.expect)(result.staleTraits).toContain('addresses');
1351
+ });
1352
+ });
1353
+ (0, vitest_1.describe)('Merged identity structure', () => {
1354
+ (0, vitest_1.it)('should preserve incoming identityId in merged identity', () => {
1355
+ const incomingIdentity = {
1356
+ identityId: 'incoming-id',
1357
+ traits: { emails: ['test@email.com'] },
1358
+ };
1359
+ const cachedIdentity = {
1360
+ identityId: 'cached-id',
1361
+ traits: { phones: ['+1234567890'] },
1362
+ };
1363
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1364
+ (0, vitest_1.expect)(result.mergedIdentity.identityId).toBe('incoming-id');
1365
+ });
1366
+ (0, vitest_1.it)('should merge traits from both incoming and cached', () => {
1367
+ const incomingIdentity = {
1368
+ identityId: 'test-id',
1369
+ traits: {
1370
+ emails: ['incoming@email.com'],
1371
+ userIds: ['user1'],
1372
+ },
1373
+ };
1374
+ const cachedIdentity = {
1375
+ identityId: 'test-id',
1376
+ traits: {
1377
+ emails: ['cached@email.com'],
1378
+ phones: ['+1234567890'],
1379
+ },
1380
+ };
1381
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1382
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.emails).toContain('incoming@email.com');
1383
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.emails).toContain('cached@email.com');
1384
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.userIds).toEqual(['user1']);
1385
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.phones).toEqual(['+1234567890']);
1386
+ });
1387
+ });
1388
+ (0, vitest_1.describe)('staleTracker output', () => {
1389
+ (0, vitest_1.it)('should include full staleTracker with all flags', () => {
1390
+ const incomingIdentity = {
1391
+ identityId: 'test-id',
1392
+ traits: {
1393
+ emails: ['old@email.com', 'new@email.com'],
1394
+ ipAddress: '10.0.0.1',
1395
+ },
1396
+ };
1397
+ const cachedIdentity = {
1398
+ identityId: 'test-id',
1399
+ traits: {
1400
+ emails: ['old@email.com'],
1401
+ },
1402
+ };
1403
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1404
+ (0, vitest_1.expect)(result.staleTracker).toBeDefined();
1405
+ (0, vitest_1.expect)(result.staleTracker.isEmailsStale).toBe(true);
1406
+ (0, vitest_1.expect)(result.staleTracker.isIpAddressStale).toBe(true);
1407
+ (0, vitest_1.expect)(result.staleTracker.isPhonesStale).toBe(false);
1408
+ });
1409
+ });
1410
+ (0, vitest_1.describe)('Edge cases - empty traits', () => {
1411
+ (0, vitest_1.it)('should handle empty traits on incoming identity', () => {
1412
+ const incomingIdentity = {
1413
+ identityId: 'test-id',
1414
+ traits: {},
1415
+ };
1416
+ const cachedIdentity = {
1417
+ identityId: 'test-id',
1418
+ traits: {
1419
+ emails: ['cached@email.com'],
1420
+ phones: ['+1234567890'],
1421
+ userIds: ['user1'],
1422
+ },
1423
+ };
1424
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1425
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1426
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
1427
+ (0, vitest_1.expect)(result.staleTraits).toEqual([]);
1428
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.emails).toEqual(['cached@email.com']);
1429
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.phones).toEqual(['+1234567890']);
1430
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.userIds).toEqual(['user1']);
1431
+ });
1432
+ (0, vitest_1.it)('should handle empty traits on cached identity', () => {
1433
+ const incomingIdentity = {
1434
+ identityId: 'test-id',
1435
+ traits: {
1436
+ emails: ['new@email.com'],
1437
+ phones: ['+1234567890'],
1438
+ },
1439
+ };
1440
+ const cachedIdentity = {
1441
+ identityId: 'test-id',
1442
+ traits: {},
1443
+ };
1444
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1445
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1446
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
1447
+ (0, vitest_1.expect)(result.staleTraits).toContain('emails');
1448
+ (0, vitest_1.expect)(result.staleTraits).toContain('phones');
1449
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.emails).toEqual(['new@email.com']);
1450
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.phones).toEqual(['+1234567890']);
1451
+ });
1452
+ (0, vitest_1.it)('should handle both identities with empty traits', () => {
1453
+ const incomingIdentity = {
1454
+ identityId: 'test-id',
1455
+ traits: {},
1456
+ };
1457
+ const cachedIdentity = {
1458
+ identityId: 'test-id',
1459
+ traits: {},
1460
+ };
1461
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1462
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1463
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
1464
+ (0, vitest_1.expect)(result.staleTraits).toEqual([]);
1465
+ });
1466
+ });
1467
+ (0, vitest_1.describe)('Edge cases - null/undefined handling', () => {
1468
+ (0, vitest_1.it)('should handle undefined traits on incoming identity', () => {
1469
+ const incomingIdentity = {
1470
+ identityId: 'test-id',
1471
+ };
1472
+ const cachedIdentity = {
1473
+ identityId: 'test-id',
1474
+ traits: {
1475
+ emails: ['cached@email.com'],
1476
+ },
1477
+ };
1478
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1479
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1480
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
1481
+ });
1482
+ (0, vitest_1.it)('should handle undefined traits on cached identity', () => {
1483
+ const incomingIdentity = {
1484
+ identityId: 'test-id',
1485
+ traits: {
1486
+ emails: ['new@email.com'],
1487
+ },
1488
+ };
1489
+ const cachedIdentity = {
1490
+ identityId: 'test-id',
1491
+ };
1492
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1493
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1494
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
1495
+ (0, vitest_1.expect)(result.staleTraits).toContain('emails');
1496
+ });
1497
+ (0, vitest_1.it)('should handle both identities with undefined traits', () => {
1498
+ const incomingIdentity = {
1499
+ identityId: 'test-id',
1500
+ };
1501
+ const cachedIdentity = {
1502
+ identityId: 'test-id',
1503
+ };
1504
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1505
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1506
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
1507
+ (0, vitest_1.expect)(result.staleTraits).toEqual([]);
1508
+ });
1509
+ (0, vitest_1.it)('should handle null values in array traits gracefully', () => {
1510
+ const incomingIdentity = {
1511
+ identityId: 'test-id',
1512
+ traits: {
1513
+ emails: ['valid@email.com', null, 'new@email.com'],
1514
+ },
1515
+ };
1516
+ const cachedIdentity = {
1517
+ identityId: 'test-id',
1518
+ traits: {
1519
+ emails: ['valid@email.com'],
1520
+ },
1521
+ };
1522
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1523
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1524
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
1525
+ });
1526
+ });
1527
+ (0, vitest_1.describe)('Edge cases - click trait merging', () => {
1528
+ (0, vitest_1.it)('should detect staleness when incoming has new click info', () => {
1529
+ const incomingIdentity = {
1530
+ identityId: 'test-id',
1531
+ traits: {
1532
+ click: {
1533
+ gclid: 'new_gclid',
1534
+ fbp: 'fb.1.new.123',
1535
+ },
1536
+ },
1537
+ };
1538
+ const cachedIdentity = {
1539
+ identityId: 'test-id',
1540
+ traits: {},
1541
+ };
1542
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1543
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1544
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
1545
+ (0, vitest_1.expect)(result.staleTraits).toContain('clickInfos');
1546
+ });
1547
+ (0, vitest_1.it)('should preserve cached click info when merging', () => {
1548
+ const incomingIdentity = {
1549
+ identityId: 'test-id',
1550
+ traits: {
1551
+ click: {
1552
+ gclid: 'incoming_gclid',
1553
+ },
1554
+ },
1555
+ };
1556
+ const cachedIdentity = {
1557
+ identityId: 'test-id',
1558
+ traits: {
1559
+ click: {
1560
+ gclid: 'cached_gclid',
1561
+ fbp: 'fb.1.cached.456',
1562
+ },
1563
+ },
1564
+ };
1565
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1566
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.click?.gclid).toBe('cached_gclid');
1567
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.click?.fbp).toBe('fb.1.cached.456');
1568
+ });
1569
+ (0, vitest_1.it)('should not be stale when click timestamps differ but values are same', () => {
1570
+ const incomingIdentity = {
1571
+ identityId: 'test-id',
1572
+ traits: {
1573
+ click: {
1574
+ fbp: 'fb.1.same.123',
1575
+ fbpCollectedAt: '2024-06-01T00:00:00Z',
1576
+ },
1577
+ },
1578
+ };
1579
+ const cachedIdentity = {
1580
+ identityId: 'test-id',
1581
+ traits: {
1582
+ click: {
1583
+ fbp: 'fb.1.same.123',
1584
+ fbpCollectedAt: '2024-01-01T00:00:00Z',
1585
+ },
1586
+ },
1587
+ };
1588
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1589
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1590
+ (0, vitest_1.expect)(result.isCacheStale).toBe(false);
1591
+ });
1592
+ (0, vitest_1.it)('should detect staleness when fbc changes (incoming has new fbc, cached has none)', () => {
1593
+ const incomingIdentity = {
1594
+ identityId: 'test-id',
1595
+ traits: {
1596
+ click: {
1597
+ fbc: 'fb.1.1234.new_fbclid',
1598
+ },
1599
+ },
1600
+ };
1601
+ const cachedIdentity = {
1602
+ identityId: 'test-id',
1603
+ traits: {
1604
+ click: {},
1605
+ },
1606
+ };
1607
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1608
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1609
+ (0, vitest_1.expect)(result.isCacheStale).toBe(true);
1610
+ (0, vitest_1.expect)(result.staleTraits).toContain('clickInfos');
1611
+ });
1612
+ });
1613
+ (0, vitest_1.describe)('staleTraits extraction comprehensive tests', () => {
1614
+ (0, vitest_1.it)('should return empty array when NONE tier', () => {
1615
+ const incomingIdentity = {
1616
+ identityId: 'test-id',
1617
+ traits: { emails: ['test@email.com'] },
1618
+ };
1619
+ const cachedIdentity = {
1620
+ identityId: 'test-id',
1621
+ traits: { emails: ['test@email.com', 'other@email.com'] },
1622
+ };
1623
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1624
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.NONE);
1625
+ (0, vitest_1.expect)(result.staleTraits).toEqual([]);
1626
+ });
1627
+ (0, vitest_1.it)('should return volatile trait names for VOLATILE_ONLY tier', () => {
1628
+ const incomingIdentity = {
1629
+ identityId: 'test-id',
1630
+ traits: {
1631
+ emails: ['test@email.com'],
1632
+ ipAddress: '10.0.0.1',
1633
+ userAgent: 'new-agent',
1634
+ },
1635
+ };
1636
+ const cachedIdentity = {
1637
+ identityId: 'test-id',
1638
+ traits: {
1639
+ emails: ['test@email.com'],
1640
+ },
1641
+ };
1642
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1643
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.VOLATILE_ONLY);
1644
+ (0, vitest_1.expect)(result.staleTraits).toContain('ipAddress');
1645
+ (0, vitest_1.expect)(result.staleTraits).toContain('userAgent');
1646
+ (0, vitest_1.expect)(result.staleTraits).not.toContain('emails');
1647
+ });
1648
+ (0, vitest_1.it)('should return address trait name for ADDRESS_UPDATE tier', () => {
1649
+ const incomingIdentity = {
1650
+ identityId: 'test-id',
1651
+ traits: {
1652
+ emails: ['test@email.com'],
1653
+ addresses: [{ city: 'Boston', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT }],
1654
+ },
1655
+ };
1656
+ const cachedIdentity = {
1657
+ identityId: 'test-id',
1658
+ traits: {
1659
+ emails: ['test@email.com'],
1660
+ addresses: [],
1661
+ },
1662
+ };
1663
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1664
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.ADDRESS_UPDATE);
1665
+ (0, vitest_1.expect)(result.staleTraits).toContain('addresses');
1666
+ });
1667
+ (0, vitest_1.it)('should return all stale identity trait names for IDENTITY_STALE tier', () => {
1668
+ const incomingIdentity = {
1669
+ identityId: 'test-id',
1670
+ traits: {
1671
+ emails: ['old@email.com', 'new@email.com'],
1672
+ phones: ['+1234567890', '+9876543210'],
1673
+ userIds: ['user1', 'user2'],
1674
+ },
1675
+ };
1676
+ const cachedIdentity = {
1677
+ identityId: 'test-id',
1678
+ traits: {
1679
+ emails: ['old@email.com'],
1680
+ phones: ['+1234567890'],
1681
+ userIds: ['user1'],
1682
+ },
1683
+ };
1684
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1685
+ (0, vitest_1.expect)(result.staleTier).toBe(at_shared_utils_1.IDENTITY_CACHE_STALENESS_TIER.IDENTITY_STALE);
1686
+ (0, vitest_1.expect)(result.staleTraits).toContain('emails');
1687
+ (0, vitest_1.expect)(result.staleTraits).toContain('phones');
1688
+ (0, vitest_1.expect)(result.staleTraits).toContain('userIds');
1689
+ });
1690
+ });
1691
+ (0, vitest_1.describe)('Merge behavior verification', () => {
1692
+ (0, vitest_1.it)('should merge incoming and cached array traits (emails, phones, userIds)', () => {
1693
+ const incomingIdentity = {
1694
+ identityId: 'incoming-id',
1695
+ traits: {
1696
+ emails: ['incoming@email.com', 'shared@email.com'],
1697
+ userIds: ['incominguser'],
1698
+ },
1699
+ };
1700
+ const cachedIdentity = {
1701
+ identityId: 'cached-id',
1702
+ traits: {
1703
+ emails: ['cached@email.com', 'shared@email.com'],
1704
+ phones: ['+1234567890'],
1705
+ userIds: ['cacheduser'],
1706
+ },
1707
+ };
1708
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1709
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.emails).toContain('incoming@email.com');
1710
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.emails).toContain('cached@email.com');
1711
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.emails).toContain('shared@email.com');
1712
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.phones).toEqual(['+1234567890']);
1713
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.userIds).toContain('incominguser');
1714
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.userIds).toContain('cacheduser');
1715
+ });
1716
+ (0, vitest_1.it)('should preserve identityId from incoming identity', () => {
1717
+ const incomingIdentity = {
1718
+ identityId: 'incoming-id-123',
1719
+ traits: { emails: ['test@email.com'] },
1720
+ };
1721
+ const cachedIdentity = {
1722
+ identityId: 'cached-id-456',
1723
+ traits: { phones: ['+1234567890'] },
1724
+ };
1725
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1726
+ (0, vitest_1.expect)(result.mergedIdentity.identityId).toBe('incoming-id-123');
1727
+ });
1728
+ (0, vitest_1.it)('should merge addresses from both identities', () => {
1729
+ const incomingIdentity = {
1730
+ identityId: 'test-id',
1731
+ traits: {
1732
+ addresses: [{ city: 'IncomingCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT }],
1733
+ },
1734
+ };
1735
+ const cachedIdentity = {
1736
+ identityId: 'test-id',
1737
+ traits: {
1738
+ addresses: [{ city: 'CachedCity', s: at_tracking_event_types_1.ADDRESS_INFO_SOURCE.INPUT }],
1739
+ },
1740
+ };
1741
+ const result = (0, at_shared_utils_1.mergeAndComputeIdentityStaleness)(incomingIdentity, cachedIdentity);
1742
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.addresses).toHaveLength(2);
1743
+ (0, vitest_1.expect)(result.mergedIdentity.traits?.addresses).toEqual(vitest_1.expect.arrayContaining([
1744
+ vitest_1.expect.objectContaining({ city: 'IncomingCity' }),
1745
+ vitest_1.expect.objectContaining({ city: 'CachedCity' }),
1746
+ ]));
1747
+ });
1748
+ });
1749
+ });
1771
1750
  //# sourceMappingURL=trait-merging-and-staleness.spec.js.map