@adtrackify/at-service-common 3.1.25 → 3.1.27

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 (311) hide show
  1. package/dist/cjs/__tests__/identity-cache/identity-cache-db-service.spec.d.ts +1 -1
  2. package/dist/cjs/__tests__/identity-cache/identity-cache-db-service.spec.js +527 -527
  3. package/dist/cjs/__tests__/libs/compress-decompress.spec.d.ts +1 -1
  4. package/dist/cjs/__tests__/libs/compress-decompress.spec.js +16 -16
  5. package/dist/cjs/__tests__/s3-client/s3-client.spec.d.ts +1 -1
  6. package/dist/cjs/__tests__/s3-client/s3-client.spec.js +26 -26
  7. package/dist/cjs/clients/generic/cognito-client.d.ts +20 -20
  8. package/dist/cjs/clients/generic/cognito-client.js +164 -164
  9. package/dist/cjs/clients/generic/dynamodb-client.d.ts +17 -17
  10. package/dist/cjs/clients/generic/dynamodb-client.js +167 -167
  11. package/dist/cjs/clients/generic/eventbridge-client.d.ts +14 -14
  12. package/dist/cjs/clients/generic/eventbridge-client.js +49 -49
  13. package/dist/cjs/clients/generic/http-client.d.ts +88 -88
  14. package/dist/cjs/clients/generic/http-client.js +60 -60
  15. package/dist/cjs/clients/generic/index.d.ts +10 -10
  16. package/dist/cjs/clients/generic/index.js +26 -26
  17. package/dist/cjs/clients/generic/lambda-invoke-client.d.ts +10 -10
  18. package/dist/cjs/clients/generic/lambda-invoke-client.js +35 -35
  19. package/dist/cjs/clients/generic/location-client.d.ts +8 -8
  20. package/dist/cjs/clients/generic/location-client.js +31 -31
  21. package/dist/cjs/clients/generic/redis-client.d.ts +18 -18
  22. package/dist/cjs/clients/generic/redis-client.js +128 -128
  23. package/dist/cjs/clients/generic/s3-client.d.ts +16 -16
  24. package/dist/cjs/clients/generic/s3-client.js +110 -110
  25. package/dist/cjs/clients/generic/singlestore-db-client.d.ts +14 -14
  26. package/dist/cjs/clients/generic/singlestore-db-client.js +67 -67
  27. package/dist/cjs/clients/generic/sqs-client.d.ts +20 -20
  28. package/dist/cjs/clients/generic/sqs-client.js +36 -36
  29. package/dist/cjs/clients/index.d.ts +3 -3
  30. package/dist/cjs/clients/index.js +19 -19
  31. package/dist/cjs/clients/internal-api/accounts-client.d.ts +112 -112
  32. package/dist/cjs/clients/internal-api/accounts-client.js +117 -117
  33. package/dist/cjs/clients/internal-api/cache-lambda-client.d.ts +23 -23
  34. package/dist/cjs/clients/internal-api/cache-lambda-client.js +59 -59
  35. package/dist/cjs/clients/internal-api/db-management-client.d.ts +18 -18
  36. package/dist/cjs/clients/internal-api/db-management-client.js +39 -39
  37. package/dist/cjs/clients/internal-api/destinations-client.d.ts +29 -29
  38. package/dist/cjs/clients/internal-api/destinations-client.js +54 -54
  39. package/dist/cjs/clients/internal-api/event-collector-client.d.ts +20 -20
  40. package/dist/cjs/clients/internal-api/event-collector-client.js +39 -39
  41. package/dist/cjs/clients/internal-api/identity-client.d.ts +25 -25
  42. package/dist/cjs/clients/internal-api/identity-client.js +92 -92
  43. package/dist/cjs/clients/internal-api/index.d.ts +8 -8
  44. package/dist/cjs/clients/internal-api/index.js +24 -24
  45. package/dist/cjs/clients/internal-api/shopify-app-install-client.d.ts +34 -34
  46. package/dist/cjs/clients/internal-api/shopify-app-install-client.js +63 -63
  47. package/dist/cjs/clients/internal-api/users-auth-client.d.ts +31 -31
  48. package/dist/cjs/clients/internal-api/users-auth-client.js +92 -92
  49. package/dist/cjs/clients/third-party/index.d.ts +1 -1
  50. package/dist/cjs/clients/third-party/index.js +17 -17
  51. package/dist/cjs/clients/third-party/shopify/graphql-product-queries.d.ts +2 -2
  52. package/dist/cjs/clients/third-party/shopify/graphql-product-queries.js +5 -5
  53. package/dist/cjs/clients/third-party/shopify/shopify-graphql-client.d.ts +9 -9
  54. package/dist/cjs/clients/third-party/shopify/shopify-graphql-client.js +95 -95
  55. package/dist/cjs/clients/third-party/shopify-client.d.ts +198 -198
  56. package/dist/cjs/clients/third-party/shopify-client.js +150 -150
  57. package/dist/cjs/helpers/identity-cache-helper.d.ts +4 -4
  58. package/dist/cjs/helpers/identity-cache-helper.js +150 -150
  59. package/dist/cjs/helpers/index.d.ts +5 -5
  60. package/dist/cjs/helpers/index.js +21 -21
  61. package/dist/cjs/helpers/input-validation-helper.d.ts +3 -3
  62. package/dist/cjs/helpers/input-validation-helper.js +22 -22
  63. package/dist/cjs/helpers/logging-helper.d.ts +16 -16
  64. package/dist/cjs/helpers/logging-helper.js +84 -84
  65. package/dist/cjs/helpers/response-helper.d.ts +15 -15
  66. package/dist/cjs/helpers/response-helper.js +42 -42
  67. package/dist/cjs/helpers/shopify-helper.d.ts +9 -9
  68. package/dist/cjs/helpers/shopify-helper.js +28 -28
  69. package/dist/cjs/index.d.ts +5 -5
  70. package/dist/cjs/index.js +21 -21
  71. package/dist/cjs/libs/clickId-parser.d.ts +23 -23
  72. package/dist/cjs/libs/clickId-parser.js +49 -49
  73. package/dist/cjs/libs/compression.d.ts +2 -2
  74. package/dist/cjs/libs/compression.js +33 -33
  75. package/dist/cjs/libs/crypto.d.ts +1 -1
  76. package/dist/cjs/libs/crypto.js +12 -12
  77. package/dist/cjs/libs/dates.d.ts +6 -6
  78. package/dist/cjs/libs/dates.js +31 -31
  79. package/dist/cjs/libs/http-error.d.ts +21 -21
  80. package/dist/cjs/libs/http-error.js +59 -59
  81. package/dist/cjs/libs/http-status-codes.d.ts +58 -58
  82. package/dist/cjs/libs/http-status-codes.js +62 -62
  83. package/dist/cjs/libs/index.d.ts +9 -9
  84. package/dist/cjs/libs/index.js +25 -25
  85. package/dist/cjs/libs/referrer-parser/index.d.ts +2 -2
  86. package/dist/cjs/libs/referrer-parser/index.js +18 -18
  87. package/dist/cjs/libs/referrer-parser/referrer-data.d.ts +9 -9
  88. package/dist/cjs/libs/referrer-parser/referrer-data.js +4712 -4712
  89. package/dist/cjs/libs/referrer-parser/referrer-parser-util.d.ts +20 -20
  90. package/dist/cjs/libs/referrer-parser/referrer-parser-util.js +128 -128
  91. package/dist/cjs/libs/url.d.ts +1 -1
  92. package/dist/cjs/libs/url.js +13 -13
  93. package/dist/cjs/services/cache/generic-cached-object.d.ts +5 -0
  94. package/dist/cjs/services/cache/generic-cached-object.js +3 -0
  95. package/dist/cjs/services/cache/generic-cached-object.js.map +1 -0
  96. package/dist/cjs/services/cache/index.d.ts +1 -1
  97. package/dist/cjs/services/cache/index.js +17 -17
  98. package/dist/cjs/services/cache/product-cache-service.d.ts +17 -13
  99. package/dist/cjs/services/cache/product-cache-service.js +52 -36
  100. package/dist/cjs/services/cache/product-cache-service.js.map +1 -1
  101. package/dist/cjs/services/db/destinations-db-service.d.ts +9 -9
  102. package/dist/cjs/services/db/destinations-db-service.js +57 -57
  103. package/dist/cjs/services/db/identity-cache-db-service.d.ts +24 -24
  104. package/dist/cjs/services/db/identity-cache-db-service.js +233 -233
  105. package/dist/cjs/services/db/index.d.ts +7 -7
  106. package/dist/cjs/services/db/index.js +23 -23
  107. package/dist/cjs/services/db/log-events-db-service.d.ts +11 -11
  108. package/dist/cjs/services/db/log-events-db-service.js +172 -172
  109. package/dist/cjs/services/db/purchased-contacts-db-service.d.ts +9 -9
  110. package/dist/cjs/services/db/purchased-contacts-db-service.js +38 -38
  111. package/dist/cjs/services/db/shopify-app-installs-db-service.d.ts +7 -7
  112. package/dist/cjs/services/db/shopify-app-installs-db-service.js +47 -47
  113. package/dist/cjs/services/db/shopify-products-cache-db-service.d.ts +9 -9
  114. package/dist/cjs/services/db/shopify-products-cache-db-service.js +64 -64
  115. package/dist/cjs/services/db/tracking-events-db-service.d.ts +20 -20
  116. package/dist/cjs/services/db/tracking-events-db-service.js +162 -162
  117. package/dist/cjs/services/eventbridge-integration-service.d.ts +9 -9
  118. package/dist/cjs/services/eventbridge-integration-service.js +28 -28
  119. package/dist/cjs/services/generic-cache-service.d.ts +8 -8
  120. package/dist/cjs/services/generic-cache-service.js +30 -30
  121. package/dist/cjs/services/index.d.ts +8 -8
  122. package/dist/cjs/services/index.js +24 -24
  123. package/dist/cjs/services/ipdata-lookup-service.d.ts +17 -17
  124. package/dist/cjs/services/ipdata-lookup-service.js +71 -71
  125. package/dist/cjs/services/log-event-service.d.ts +9 -9
  126. package/dist/cjs/services/log-event-service.js +56 -56
  127. package/dist/cjs/services/metric-event-service.d.ts +9 -9
  128. package/dist/cjs/services/metric-event-service.js +49 -49
  129. package/dist/cjs/services/shopify/index.d.ts +3 -3
  130. package/dist/cjs/services/shopify/index.js +19 -19
  131. package/dist/cjs/services/shopify/products/index.d.ts +1 -1
  132. package/dist/cjs/services/shopify/products/index.js +17 -17
  133. package/dist/cjs/services/shopify/products/shopify-products-serviceV2.d.ts +12 -12
  134. package/dist/cjs/services/shopify/products/shopify-products-serviceV2.js +63 -66
  135. package/dist/cjs/services/shopify/products/shopify-products-serviceV2.js.map +1 -1
  136. package/dist/cjs/services/shopify/shopify-graphql-transformer.d.ts +8 -8
  137. package/dist/cjs/services/shopify/shopify-graphql-transformer.js +114 -114
  138. package/dist/cjs/services/shopify/types/index.d.ts +1 -1
  139. package/dist/cjs/services/shopify/types/index.js +17 -17
  140. package/dist/cjs/services/shopify/types/product.d.ts +114 -114
  141. package/dist/cjs/services/shopify/types/product.js +9 -9
  142. package/dist/cjs/types/api-response.d.ts +6 -6
  143. package/dist/cjs/types/api-response.js +2 -2
  144. package/dist/cjs/types/index.d.ts +2 -2
  145. package/dist/cjs/types/index.js +18 -18
  146. package/dist/cjs/types/internal-events/event-detail-types.d.ts +20 -20
  147. package/dist/cjs/types/internal-events/event-detail-types.js +27 -27
  148. package/dist/cjs/types/internal-events/index.d.ts +1 -1
  149. package/dist/cjs/types/internal-events/index.js +17 -17
  150. package/dist/cjs/types/shopify-graphql-types/admin.generated.d.ts +105 -105
  151. package/dist/cjs/types/shopify-graphql-types/admin.generated.js +2 -2
  152. package/dist/cjs/types/shopify-graphql-types/admin.types.d.ts +26289 -26289
  153. package/dist/cjs/types/shopify-graphql-types/admin.types.js +5311 -5311
  154. package/dist/cjs/types/shopify-graphql-types/index.d.ts +2 -2
  155. package/dist/cjs/types/shopify-graphql-types/index.js +18 -18
  156. package/dist/esm/__tests__/identity-cache/identity-cache-db-service.spec.d.ts +1 -1
  157. package/dist/esm/__tests__/identity-cache/identity-cache-db-service.spec.js +525 -525
  158. package/dist/esm/__tests__/libs/compress-decompress.spec.d.ts +1 -1
  159. package/dist/esm/__tests__/libs/compress-decompress.spec.js +14 -14
  160. package/dist/esm/__tests__/s3-client/s3-client.spec.d.ts +1 -1
  161. package/dist/esm/__tests__/s3-client/s3-client.spec.js +24 -24
  162. package/dist/esm/clients/generic/cognito-client.d.ts +20 -20
  163. package/dist/esm/clients/generic/cognito-client.js +159 -159
  164. package/dist/esm/clients/generic/dynamodb-client.d.ts +17 -17
  165. package/dist/esm/clients/generic/dynamodb-client.js +163 -163
  166. package/dist/esm/clients/generic/eventbridge-client.d.ts +14 -14
  167. package/dist/esm/clients/generic/eventbridge-client.js +45 -45
  168. package/dist/esm/clients/generic/http-client.d.ts +88 -88
  169. package/dist/esm/clients/generic/http-client.js +52 -52
  170. package/dist/esm/clients/generic/index.d.ts +10 -10
  171. package/dist/esm/clients/generic/index.js +10 -10
  172. package/dist/esm/clients/generic/lambda-invoke-client.d.ts +10 -10
  173. package/dist/esm/clients/generic/lambda-invoke-client.js +31 -31
  174. package/dist/esm/clients/generic/location-client.d.ts +8 -8
  175. package/dist/esm/clients/generic/location-client.js +27 -27
  176. package/dist/esm/clients/generic/redis-client.d.ts +18 -18
  177. package/dist/esm/clients/generic/redis-client.js +121 -121
  178. package/dist/esm/clients/generic/s3-client.d.ts +16 -16
  179. package/dist/esm/clients/generic/s3-client.js +106 -106
  180. package/dist/esm/clients/generic/singlestore-db-client.d.ts +14 -14
  181. package/dist/esm/clients/generic/singlestore-db-client.js +40 -40
  182. package/dist/esm/clients/generic/sqs-client.d.ts +20 -20
  183. package/dist/esm/clients/generic/sqs-client.js +32 -32
  184. package/dist/esm/clients/index.d.ts +3 -3
  185. package/dist/esm/clients/index.js +3 -3
  186. package/dist/esm/clients/internal-api/accounts-client.d.ts +112 -112
  187. package/dist/esm/clients/internal-api/accounts-client.js +113 -113
  188. package/dist/esm/clients/internal-api/cache-lambda-client.d.ts +23 -23
  189. package/dist/esm/clients/internal-api/cache-lambda-client.js +55 -55
  190. package/dist/esm/clients/internal-api/db-management-client.d.ts +18 -18
  191. package/dist/esm/clients/internal-api/db-management-client.js +32 -32
  192. package/dist/esm/clients/internal-api/destinations-client.d.ts +29 -29
  193. package/dist/esm/clients/internal-api/destinations-client.js +50 -50
  194. package/dist/esm/clients/internal-api/event-collector-client.d.ts +20 -20
  195. package/dist/esm/clients/internal-api/event-collector-client.js +32 -32
  196. package/dist/esm/clients/internal-api/identity-client.d.ts +25 -25
  197. package/dist/esm/clients/internal-api/identity-client.js +88 -88
  198. package/dist/esm/clients/internal-api/index.d.ts +8 -8
  199. package/dist/esm/clients/internal-api/index.js +8 -8
  200. package/dist/esm/clients/internal-api/shopify-app-install-client.d.ts +34 -34
  201. package/dist/esm/clients/internal-api/shopify-app-install-client.js +56 -56
  202. package/dist/esm/clients/internal-api/users-auth-client.d.ts +31 -31
  203. package/dist/esm/clients/internal-api/users-auth-client.js +88 -88
  204. package/dist/esm/clients/third-party/index.d.ts +1 -1
  205. package/dist/esm/clients/third-party/index.js +1 -1
  206. package/dist/esm/clients/third-party/shopify/graphql-product-queries.d.ts +2 -2
  207. package/dist/esm/clients/third-party/shopify/graphql-product-queries.js +2 -2
  208. package/dist/esm/clients/third-party/shopify/shopify-graphql-client.d.ts +9 -9
  209. package/dist/esm/clients/third-party/shopify/shopify-graphql-client.js +91 -91
  210. package/dist/esm/clients/third-party/shopify-client.d.ts +198 -198
  211. package/dist/esm/clients/third-party/shopify-client.js +146 -146
  212. package/dist/esm/helpers/identity-cache-helper.d.ts +4 -4
  213. package/dist/esm/helpers/identity-cache-helper.js +145 -145
  214. package/dist/esm/helpers/index.d.ts +5 -5
  215. package/dist/esm/helpers/index.js +5 -5
  216. package/dist/esm/helpers/input-validation-helper.d.ts +3 -3
  217. package/dist/esm/helpers/input-validation-helper.js +18 -18
  218. package/dist/esm/helpers/logging-helper.d.ts +16 -16
  219. package/dist/esm/helpers/logging-helper.js +56 -56
  220. package/dist/esm/helpers/response-helper.d.ts +15 -15
  221. package/dist/esm/helpers/response-helper.js +36 -36
  222. package/dist/esm/helpers/shopify-helper.d.ts +9 -9
  223. package/dist/esm/helpers/shopify-helper.js +23 -23
  224. package/dist/esm/index.d.ts +5 -5
  225. package/dist/esm/index.js +5 -5
  226. package/dist/esm/libs/clickId-parser.d.ts +23 -23
  227. package/dist/esm/libs/clickId-parser.js +45 -45
  228. package/dist/esm/libs/compression.d.ts +2 -2
  229. package/dist/esm/libs/compression.js +25 -25
  230. package/dist/esm/libs/crypto.d.ts +1 -1
  231. package/dist/esm/libs/crypto.js +5 -5
  232. package/dist/esm/libs/dates.d.ts +6 -6
  233. package/dist/esm/libs/dates.js +22 -22
  234. package/dist/esm/libs/http-error.d.ts +21 -21
  235. package/dist/esm/libs/http-error.js +55 -55
  236. package/dist/esm/libs/http-status-codes.d.ts +58 -58
  237. package/dist/esm/libs/http-status-codes.js +59 -59
  238. package/dist/esm/libs/index.d.ts +9 -9
  239. package/dist/esm/libs/index.js +9 -9
  240. package/dist/esm/libs/referrer-parser/index.d.ts +2 -2
  241. package/dist/esm/libs/referrer-parser/index.js +2 -2
  242. package/dist/esm/libs/referrer-parser/referrer-data.d.ts +9 -9
  243. package/dist/esm/libs/referrer-parser/referrer-data.js +4709 -4709
  244. package/dist/esm/libs/referrer-parser/referrer-parser-util.d.ts +20 -20
  245. package/dist/esm/libs/referrer-parser/referrer-parser-util.js +121 -121
  246. package/dist/esm/libs/url.d.ts +1 -1
  247. package/dist/esm/libs/url.js +9 -9
  248. package/dist/esm/services/cache/generic-cached-object.d.ts +5 -0
  249. package/dist/esm/services/cache/generic-cached-object.js +2 -0
  250. package/dist/esm/services/cache/generic-cached-object.js.map +1 -0
  251. package/dist/esm/services/cache/index.d.ts +1 -1
  252. package/dist/esm/services/cache/index.js +1 -1
  253. package/dist/esm/services/cache/product-cache-service.d.ts +17 -13
  254. package/dist/esm/services/cache/product-cache-service.js +44 -32
  255. package/dist/esm/services/cache/product-cache-service.js.map +1 -1
  256. package/dist/esm/services/db/destinations-db-service.d.ts +9 -9
  257. package/dist/esm/services/db/destinations-db-service.js +53 -53
  258. package/dist/esm/services/db/identity-cache-db-service.d.ts +24 -24
  259. package/dist/esm/services/db/identity-cache-db-service.js +229 -229
  260. package/dist/esm/services/db/index.d.ts +7 -7
  261. package/dist/esm/services/db/index.js +7 -7
  262. package/dist/esm/services/db/log-events-db-service.d.ts +11 -11
  263. package/dist/esm/services/db/log-events-db-service.js +168 -168
  264. package/dist/esm/services/db/purchased-contacts-db-service.d.ts +9 -9
  265. package/dist/esm/services/db/purchased-contacts-db-service.js +34 -34
  266. package/dist/esm/services/db/shopify-app-installs-db-service.d.ts +7 -7
  267. package/dist/esm/services/db/shopify-app-installs-db-service.js +43 -43
  268. package/dist/esm/services/db/shopify-products-cache-db-service.d.ts +9 -9
  269. package/dist/esm/services/db/shopify-products-cache-db-service.js +60 -60
  270. package/dist/esm/services/db/tracking-events-db-service.d.ts +20 -20
  271. package/dist/esm/services/db/tracking-events-db-service.js +158 -158
  272. package/dist/esm/services/eventbridge-integration-service.d.ts +9 -9
  273. package/dist/esm/services/eventbridge-integration-service.js +24 -24
  274. package/dist/esm/services/generic-cache-service.d.ts +8 -8
  275. package/dist/esm/services/generic-cache-service.js +26 -26
  276. package/dist/esm/services/index.d.ts +8 -8
  277. package/dist/esm/services/index.js +8 -8
  278. package/dist/esm/services/ipdata-lookup-service.d.ts +17 -17
  279. package/dist/esm/services/ipdata-lookup-service.js +67 -67
  280. package/dist/esm/services/log-event-service.d.ts +9 -9
  281. package/dist/esm/services/log-event-service.js +52 -52
  282. package/dist/esm/services/metric-event-service.d.ts +9 -9
  283. package/dist/esm/services/metric-event-service.js +45 -45
  284. package/dist/esm/services/shopify/index.d.ts +3 -3
  285. package/dist/esm/services/shopify/index.js +3 -3
  286. package/dist/esm/services/shopify/products/index.d.ts +1 -1
  287. package/dist/esm/services/shopify/products/index.js +1 -1
  288. package/dist/esm/services/shopify/products/shopify-products-serviceV2.d.ts +12 -12
  289. package/dist/esm/services/shopify/products/shopify-products-serviceV2.js +59 -62
  290. package/dist/esm/services/shopify/products/shopify-products-serviceV2.js.map +1 -1
  291. package/dist/esm/services/shopify/shopify-graphql-transformer.d.ts +8 -8
  292. package/dist/esm/services/shopify/shopify-graphql-transformer.js +111 -111
  293. package/dist/esm/services/shopify/types/index.d.ts +1 -1
  294. package/dist/esm/services/shopify/types/index.js +1 -1
  295. package/dist/esm/services/shopify/types/product.d.ts +114 -114
  296. package/dist/esm/services/shopify/types/product.js +6 -6
  297. package/dist/esm/types/api-response.d.ts +6 -6
  298. package/dist/esm/types/api-response.js +1 -1
  299. package/dist/esm/types/index.d.ts +2 -2
  300. package/dist/esm/types/index.js +2 -2
  301. package/dist/esm/types/internal-events/event-detail-types.d.ts +20 -20
  302. package/dist/esm/types/internal-events/event-detail-types.js +24 -24
  303. package/dist/esm/types/internal-events/index.d.ts +1 -1
  304. package/dist/esm/types/internal-events/index.js +1 -1
  305. package/dist/esm/types/shopify-graphql-types/admin.generated.d.ts +105 -105
  306. package/dist/esm/types/shopify-graphql-types/admin.generated.js +1 -1
  307. package/dist/esm/types/shopify-graphql-types/admin.types.d.ts +26289 -26289
  308. package/dist/esm/types/shopify-graphql-types/admin.types.js +5299 -5299
  309. package/dist/esm/types/shopify-graphql-types/index.d.ts +2 -2
  310. package/dist/esm/types/shopify-graphql-types/index.js +2 -2
  311. package/package.json +1 -1
@@ -1,151 +1,151 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ShopifyClient = void 0;
4
- const http_client_js_1 = require("../generic/http-client.js");
5
- const index_js_1 = require("../../index.js");
6
- class ShopifyClient {
7
- static _shopify_api_version = process.env.SHOPIFY_API_VERSION;
8
- static client;
9
- static getConfig = (shopifyDomain, accessToken) => {
10
- const config = {
11
- baseURL: `https://${shopifyDomain}/admin/api/${this._shopify_api_version}`,
12
- headers: {
13
- common: {
14
- 'X-Shopify-Access-Token': accessToken,
15
- },
16
- },
17
- };
18
- return config;
19
- };
20
- static getClient = () => {
21
- this.client = this.client ?? (0, http_client_js_1.axiosHttpService)();
22
- return this.client;
23
- };
24
- static registerApp = async (shop, code, appKey, appSecret) => {
25
- const client = this.getClient();
26
- const url = 'https://' + shop + '/admin/oauth/access_token';
27
- const payload = {
28
- client_id: appKey,
29
- client_secret: appSecret,
30
- code
31
- };
32
- const res = await client.post(url, payload);
33
- return res;
34
- };
35
- static registerWebhookTopic = async (shop, accessToken, eventBridgeArn, topic) => {
36
- const client = this.getClient();
37
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/webhooks.json`;
38
- const payload = {
39
- webhook: {
40
- topic,
41
- address: eventBridgeArn,
42
- format: 'json'
43
- }
44
- };
45
- const res = await client.post(url, payload, { headers: { 'X-Shopify-Access-Token': accessToken } });
46
- if (res.status >= 400) {
47
- index_js_1.Logger.error('Failed to register Webhook Topic', { res, shop, accessToken, eventBridgeArn, topic, url, payload });
48
- }
49
- index_js_1.Logger.debug('Shopify Client Webhook Registration Response', { registrationResponse: res });
50
- return res;
51
- };
52
- static updateShopifyAppMetafield = async (shop, accessToken, pixelId) => {
53
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/metafields.json`;
54
- const payload = {
55
- metafield: {
56
- namespace: 'adtr',
57
- key: 'adtr.config',
58
- value: pixelId,
59
- type: 'single_line_text_field'
60
- }
61
- };
62
- const res = await this.genericShopifyPost(url, accessToken, payload);
63
- if (res.status >= 400) {
64
- index_js_1.Logger.error('Failed to update Shopify app Metafield ', { shop, accessToken, url, payload });
65
- }
66
- return res;
67
- };
68
- static getShopifyStoreProperties = async (shop, accessToken) => {
69
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/shop.json`;
70
- const res = await this.genericShopifyGet(url, accessToken);
71
- if (res.status >= 400) {
72
- index_js_1.Logger.error('Failed to get Shopify Store Properties', { shop, accessToken, url });
73
- }
74
- return res;
75
- };
76
- static createAppSubscription = async (shop, accessToken, planName, price, returnUrl, trialDays, test) => {
77
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/recurring_application_charges.json`;
78
- const recurring_application_charge = {
79
- name: planName,
80
- price,
81
- return_url: returnUrl,
82
- trial_days: trialDays,
83
- test
84
- };
85
- const res = await this.genericShopifyPost(url, accessToken, { recurring_application_charge });
86
- if (res.status >= 400) {
87
- index_js_1.Logger.error('Failed to create App Subscription', { shop, accessToken, url });
88
- }
89
- return res;
90
- };
91
- static cancelAppSubscription = async (shop, accessToken, chargeId) => {
92
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/recurring_application_charges/${chargeId}.json`;
93
- const client = this.getClient();
94
- const res = await client.delete(url, { headers: { 'X-Shopify-Access-Token': accessToken } });
95
- if (res.status !== 200) {
96
- index_js_1.Logger.error('Failed to cancel recurring App billing', { shop, accessToken, url });
97
- }
98
- return res;
99
- };
100
- static listAppSubscriptions = async (shop, accessToken) => {
101
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/recurring_application_charges.json`;
102
- const res = await this.genericShopifyGet(url, accessToken);
103
- if (res.status >= 400) {
104
- index_js_1.Logger.error('Failed to get App Subscriptions', { shop, accessToken, url });
105
- }
106
- return res;
107
- };
108
- static getOrder = async (shop, accessToken, orderId) => {
109
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/orders/${orderId}.json`;
110
- const res = await this.genericShopifyGet(url, accessToken);
111
- if (res.status >= 400) {
112
- index_js_1.Logger.error('Failed to get Order', { res, shop, accessToken, url, orderId });
113
- }
114
- return res;
115
- };
116
- static getProductREST = async (shop, accessToken, productId) => {
117
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/products/${productId}.json`;
118
- const res = await this.genericShopifyGet(url, accessToken);
119
- if (res.status >= 400) {
120
- index_js_1.Logger.error('Failed to get Product', { res, shop, accessToken, url, productId });
121
- }
122
- return res;
123
- };
124
- static genericShopifyPost = async (url, accessToken, payload) => {
125
- const client = this.getClient();
126
- const res = await client.post(url, payload, { headers: { 'X-Shopify-Access-Token': accessToken, 'Content-Type': 'application/json' } });
127
- index_js_1.Logger.debug('Shopify Client Response', { res });
128
- return res;
129
- };
130
- static genericShopifyGet = async (url, accessToken) => {
131
- const client = this.getClient();
132
- const res = await client.get(url, { headers: { 'X-Shopify-Access-Token': accessToken } });
133
- index_js_1.Logger.debug('Shopify Client Response', { res });
134
- return res;
135
- };
136
- static genericShopifyPut = async (url, accessToken, payload) => {
137
- const client = this.getClient();
138
- const res = await client.put(url, payload, { headers: { 'X-Shopify-Access-Token': accessToken } });
139
- index_js_1.Logger.debug('Shopify Client Response', { res });
140
- return res;
141
- };
142
- static unregisterWebhook = async (shop, webhookId, accessToken) => {
143
- const client = this.getClient();
144
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/webhooks/${webhookId}.json`;
145
- const res = await client.delete(url, { headers: { 'X-Shopify-Access-Token': accessToken } });
146
- index_js_1.Logger.debug('Shopify Client Response', { res });
147
- return res;
148
- };
149
- }
150
- exports.ShopifyClient = ShopifyClient;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ShopifyClient = void 0;
4
+ const http_client_js_1 = require("../generic/http-client.js");
5
+ const index_js_1 = require("../../index.js");
6
+ class ShopifyClient {
7
+ static _shopify_api_version = process.env.SHOPIFY_API_VERSION;
8
+ static client;
9
+ static getConfig = (shopifyDomain, accessToken) => {
10
+ const config = {
11
+ baseURL: `https://${shopifyDomain}/admin/api/${this._shopify_api_version}`,
12
+ headers: {
13
+ common: {
14
+ 'X-Shopify-Access-Token': accessToken,
15
+ },
16
+ },
17
+ };
18
+ return config;
19
+ };
20
+ static getClient = () => {
21
+ this.client = this.client ?? (0, http_client_js_1.axiosHttpService)();
22
+ return this.client;
23
+ };
24
+ static registerApp = async (shop, code, appKey, appSecret) => {
25
+ const client = this.getClient();
26
+ const url = 'https://' + shop + '/admin/oauth/access_token';
27
+ const payload = {
28
+ client_id: appKey,
29
+ client_secret: appSecret,
30
+ code
31
+ };
32
+ const res = await client.post(url, payload);
33
+ return res;
34
+ };
35
+ static registerWebhookTopic = async (shop, accessToken, eventBridgeArn, topic) => {
36
+ const client = this.getClient();
37
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/webhooks.json`;
38
+ const payload = {
39
+ webhook: {
40
+ topic,
41
+ address: eventBridgeArn,
42
+ format: 'json'
43
+ }
44
+ };
45
+ const res = await client.post(url, payload, { headers: { 'X-Shopify-Access-Token': accessToken } });
46
+ if (res.status >= 400) {
47
+ index_js_1.Logger.error('Failed to register Webhook Topic', { res, shop, accessToken, eventBridgeArn, topic, url, payload });
48
+ }
49
+ index_js_1.Logger.debug('Shopify Client Webhook Registration Response', { registrationResponse: res });
50
+ return res;
51
+ };
52
+ static updateShopifyAppMetafield = async (shop, accessToken, pixelId) => {
53
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/metafields.json`;
54
+ const payload = {
55
+ metafield: {
56
+ namespace: 'adtr',
57
+ key: 'adtr.config',
58
+ value: pixelId,
59
+ type: 'single_line_text_field'
60
+ }
61
+ };
62
+ const res = await this.genericShopifyPost(url, accessToken, payload);
63
+ if (res.status >= 400) {
64
+ index_js_1.Logger.error('Failed to update Shopify app Metafield ', { shop, accessToken, url, payload });
65
+ }
66
+ return res;
67
+ };
68
+ static getShopifyStoreProperties = async (shop, accessToken) => {
69
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/shop.json`;
70
+ const res = await this.genericShopifyGet(url, accessToken);
71
+ if (res.status >= 400) {
72
+ index_js_1.Logger.error('Failed to get Shopify Store Properties', { shop, accessToken, url });
73
+ }
74
+ return res;
75
+ };
76
+ static createAppSubscription = async (shop, accessToken, planName, price, returnUrl, trialDays, test) => {
77
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/recurring_application_charges.json`;
78
+ const recurring_application_charge = {
79
+ name: planName,
80
+ price,
81
+ return_url: returnUrl,
82
+ trial_days: trialDays,
83
+ test
84
+ };
85
+ const res = await this.genericShopifyPost(url, accessToken, { recurring_application_charge });
86
+ if (res.status >= 400) {
87
+ index_js_1.Logger.error('Failed to create App Subscription', { shop, accessToken, url });
88
+ }
89
+ return res;
90
+ };
91
+ static cancelAppSubscription = async (shop, accessToken, chargeId) => {
92
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/recurring_application_charges/${chargeId}.json`;
93
+ const client = this.getClient();
94
+ const res = await client.delete(url, { headers: { 'X-Shopify-Access-Token': accessToken } });
95
+ if (res.status !== 200) {
96
+ index_js_1.Logger.error('Failed to cancel recurring App billing', { shop, accessToken, url });
97
+ }
98
+ return res;
99
+ };
100
+ static listAppSubscriptions = async (shop, accessToken) => {
101
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/recurring_application_charges.json`;
102
+ const res = await this.genericShopifyGet(url, accessToken);
103
+ if (res.status >= 400) {
104
+ index_js_1.Logger.error('Failed to get App Subscriptions', { shop, accessToken, url });
105
+ }
106
+ return res;
107
+ };
108
+ static getOrder = async (shop, accessToken, orderId) => {
109
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/orders/${orderId}.json`;
110
+ const res = await this.genericShopifyGet(url, accessToken);
111
+ if (res.status >= 400) {
112
+ index_js_1.Logger.error('Failed to get Order', { res, shop, accessToken, url, orderId });
113
+ }
114
+ return res;
115
+ };
116
+ static getProductREST = async (shop, accessToken, productId) => {
117
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/products/${productId}.json`;
118
+ const res = await this.genericShopifyGet(url, accessToken);
119
+ if (res.status >= 400) {
120
+ index_js_1.Logger.error('Failed to get Product', { res, shop, accessToken, url, productId });
121
+ }
122
+ return res;
123
+ };
124
+ static genericShopifyPost = async (url, accessToken, payload) => {
125
+ const client = this.getClient();
126
+ const res = await client.post(url, payload, { headers: { 'X-Shopify-Access-Token': accessToken, 'Content-Type': 'application/json' } });
127
+ index_js_1.Logger.debug('Shopify Client Response', { res });
128
+ return res;
129
+ };
130
+ static genericShopifyGet = async (url, accessToken) => {
131
+ const client = this.getClient();
132
+ const res = await client.get(url, { headers: { 'X-Shopify-Access-Token': accessToken } });
133
+ index_js_1.Logger.debug('Shopify Client Response', { res });
134
+ return res;
135
+ };
136
+ static genericShopifyPut = async (url, accessToken, payload) => {
137
+ const client = this.getClient();
138
+ const res = await client.put(url, payload, { headers: { 'X-Shopify-Access-Token': accessToken } });
139
+ index_js_1.Logger.debug('Shopify Client Response', { res });
140
+ return res;
141
+ };
142
+ static unregisterWebhook = async (shop, webhookId, accessToken) => {
143
+ const client = this.getClient();
144
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/webhooks/${webhookId}.json`;
145
+ const res = await client.delete(url, { headers: { 'X-Shopify-Access-Token': accessToken } });
146
+ index_js_1.Logger.debug('Shopify Client Response', { res });
147
+ return res;
148
+ };
149
+ }
150
+ exports.ShopifyClient = ShopifyClient;
151
151
  //# sourceMappingURL=shopify-client.js.map
@@ -1,4 +1,4 @@
1
- import { AdClickInfo, EventIdentity } from '@adtrackify/at-tracking-event-types';
2
- import { IdentityCache } from '../services';
3
- export declare const isIdentityCacheStale: (identityCache: IdentityCache, incomingIdentity: EventIdentity) => boolean;
4
- export declare const isClickInfosStale: (cachedClick: AdClickInfo, incomingClick: AdClickInfo) => boolean;
1
+ import { AdClickInfo, EventIdentity } from '@adtrackify/at-tracking-event-types';
2
+ import { IdentityCache } from '../services';
3
+ export declare const isIdentityCacheStale: (identityCache: IdentityCache, incomingIdentity: EventIdentity) => boolean;
4
+ export declare const isClickInfosStale: (cachedClick: AdClickInfo, incomingClick: AdClickInfo) => boolean;
@@ -1,151 +1,151 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isClickInfosStale = exports.isIdentityCacheStale = void 0;
4
- const at_shared_utils_1 = require("@adtrackify/at-shared-utils");
5
- const logging_helper_1 = require("./logging-helper");
6
- const isIdentityCacheStale = (identityCache, incomingIdentity) => {
7
- try {
8
- const cachedTraits = identityCache.response?.traits ?? {};
9
- const incomingTraits = incomingIdentity?.traits ?? {};
10
- const identityCacheStaleTracker = {
11
- cachedTraits: cachedTraits,
12
- incomingTraits: incomingTraits,
13
- isUserIdsStale: false,
14
- isIdsStale: false,
15
- isEmailsStale: false,
16
- isPhonesStale: false,
17
- isShopifyYIdsStale: false,
18
- isGendersStale: false,
19
- isDobsStale: false,
20
- isAddressesStale: false,
21
- isClickInfosStale: false,
22
- isIpAddressStale: false,
23
- isUserAgentStale: false,
24
- isCacheStale: false
25
- };
26
- const isNewUserIds = (0, at_shared_utils_1.hasNewTrait)(cachedTraits?.userIds ?? [], incomingTraits?.userIds ?? []);
27
- if (isNewUserIds) {
28
- logging_helper_1.Logger.debug('identity cache miss - userIds changed', { cachedTraits, incomingTraits });
29
- identityCacheStaleTracker.isUserIdsStale = true;
30
- identityCacheStaleTracker.isCacheStale = true;
31
- }
32
- const isNewIds = (0, at_shared_utils_1.hasNewTrait)(cachedTraits?.ids ?? [], incomingTraits?.ids ?? []);
33
- if (isNewIds) {
34
- logging_helper_1.Logger.debug('identity cache miss - ids changed', { cachedTraits, incomingTraits });
35
- identityCacheStaleTracker.isIdsStale = true;
36
- identityCacheStaleTracker.isCacheStale = true;
37
- }
38
- const isNewEmails = (0, at_shared_utils_1.hasNewTrait)(cachedTraits?.emails ?? [], incomingTraits?.emails ?? []);
39
- if (isNewEmails) {
40
- logging_helper_1.Logger.debug('identity cache miss - emails changed', { cachedTraits, incomingTraits });
41
- identityCacheStaleTracker.isEmailsStale = true;
42
- identityCacheStaleTracker.isCacheStale = true;
43
- }
44
- const isNewPhones = (0, at_shared_utils_1.hasNewTrait)(cachedTraits?.phones ?? [], incomingTraits?.phones ?? []);
45
- if (isNewPhones) {
46
- logging_helper_1.Logger.debug('identity cache miss - phones changed', { cachedTraits, incomingTraits });
47
- identityCacheStaleTracker.isPhonesStale = true;
48
- identityCacheStaleTracker.isCacheStale = true;
49
- }
50
- const isNewShopifyYIds = (0, at_shared_utils_1.hasNewTrait)(cachedTraits?.shopifyYIds ?? [], incomingTraits?.shopifyYIds ?? []);
51
- if (isNewShopifyYIds) {
52
- logging_helper_1.Logger.debug('identity cache miss - shopify Y ids changed', { cachedTraits, incomingTraits });
53
- identityCacheStaleTracker.isShopifyYIdsStale = true;
54
- identityCacheStaleTracker.isCacheStale = true;
55
- }
56
- const isNewGenders = (0, at_shared_utils_1.hasNewTrait)(cachedTraits?.genders ?? [], incomingTraits?.genders ?? []);
57
- if (isNewGenders) {
58
- logging_helper_1.Logger.debug('identity cache miss - genders changed', { cachedTraits, incomingTraits });
59
- identityCacheStaleTracker.isGendersStale = true;
60
- identityCacheStaleTracker.isCacheStale = true;
61
- }
62
- const isNewDobs = (0, at_shared_utils_1.hasNewTrait)(cachedTraits?.dobs ?? [], incomingTraits?.dobs ?? []);
63
- if (isNewDobs) {
64
- logging_helper_1.Logger.debug('identity cache miss - dobs changed', { cachedTraits, incomingTraits });
65
- identityCacheStaleTracker.isDobsStale = true;
66
- identityCacheStaleTracker.isCacheStale = true;
67
- }
68
- const isNewAddress = (0, at_shared_utils_1.hasNewAddress)(cachedTraits?.addresses ?? [], incomingTraits?.addresses ?? []);
69
- if (isNewAddress) {
70
- logging_helper_1.Logger.debug('identity cache miss - address changed', { cachedTraits, incomingTraits });
71
- identityCacheStaleTracker.isAddressesStale = true;
72
- identityCacheStaleTracker.isCacheStale = true;
73
- }
74
- const isNewClick = (0, exports.isClickInfosStale)(cachedTraits?.click ?? {}, incomingTraits?.click ?? {});
75
- if (isNewClick) {
76
- logging_helper_1.Logger.debug('identity cache miss - clickInfos changed', { cachedTraits, incomingTraits });
77
- identityCacheStaleTracker.isClickInfosStale = true;
78
- identityCacheStaleTracker.isCacheStale = true;
79
- }
80
- if (incomingTraits?.ipAddress && cachedTraits?.ipAddress !== incomingTraits?.ipAddress) {
81
- logging_helper_1.Logger.debug('identity cache miss - ip/userAgent changed', { cachedTraits, incomingTraits });
82
- identityCacheStaleTracker.isIpAddressStale = true;
83
- identityCacheStaleTracker.isCacheStale = true;
84
- }
85
- if (incomingTraits?.userAgent && cachedTraits?.userAgent !== incomingTraits?.userAgent) {
86
- logging_helper_1.Logger.debug('identity cache miss - userAgent changed', { cachedTraits, incomingTraits });
87
- identityCacheStaleTracker.isUserAgentStale = true;
88
- identityCacheStaleTracker.isCacheStale = true;
89
- }
90
- if (identityCacheStaleTracker.isCacheStale) {
91
- logging_helper_1.Logger.debug('identity cache miss - cache stale', { identityCacheStaleTracker });
92
- }
93
- return identityCacheStaleTracker.isCacheStale;
94
- }
95
- catch (err) {
96
- logging_helper_1.Logger.error('Error while checking if identity cache is stale', { err });
97
- return true;
98
- }
99
- };
100
- exports.isIdentityCacheStale = isIdentityCacheStale;
101
- const isClickInfosStale = (cachedClick, incomingClick) => {
102
- const cleanedCachedClick = (0, at_shared_utils_1.removeEmptyFields)(cachedClick);
103
- const cleanedIncomingClick = (0, at_shared_utils_1.removeEmptyFields)(incomingClick);
104
- const incomingKeys = Object.keys(cleanedIncomingClick);
105
- const clickInfoStaleTracker = {
106
- cleanedCachedClick,
107
- cleanedIncomingClick,
108
- isClickInfosStale: false,
109
- staleKeys: []
110
- };
111
- incomingKeys.forEach(key => {
112
- if (key === 'googleClientInfos' || key.includes('CollectedAt')) {
113
- return true;
114
- }
115
- else if (key === 'fbc') {
116
- const cachedClickValue = cleanedCachedClick?.[key];
117
- const incomingClickValue = cleanedIncomingClick?.[key];
118
- if (incomingClickValue && !cachedClickValue) {
119
- clickInfoStaleTracker.isClickInfosStale = true;
120
- clickInfoStaleTracker.staleKeys.push(key);
121
- }
122
- else if (incomingClickValue && cachedClickValue && incomingClickValue !== cachedClickValue) {
123
- const incomingFbcFbclid = incomingClickValue?.split('.')?.[3];
124
- const cachedFbcFbclid = cachedClickValue?.split('.')?.[3];
125
- if (incomingFbcFbclid !== cachedFbcFbclid) {
126
- clickInfoStaleTracker.isClickInfosStale = true;
127
- clickInfoStaleTracker.staleKeys.push(key);
128
- }
129
- if (!incomingFbcFbclid || !cachedFbcFbclid) {
130
- clickInfoStaleTracker.isClickInfosStale = true;
131
- clickInfoStaleTracker.staleKeys.push(key);
132
- }
133
- }
134
- }
135
- else {
136
- const cachedClickValue = cleanedCachedClick?.[key];
137
- const incomingClickValue = cleanedIncomingClick?.[key];
138
- if ((incomingClickValue && !cachedClickValue)
139
- || incomingClickValue !== cachedClickValue) {
140
- clickInfoStaleTracker.isClickInfosStale = true;
141
- clickInfoStaleTracker.staleKeys.push(key);
142
- }
143
- }
144
- });
145
- if (clickInfoStaleTracker.isClickInfosStale) {
146
- logging_helper_1.Logger.debug('identity cache miss - clickInfos changed', { clickInfoStaleTracker });
147
- }
148
- return clickInfoStaleTracker.isClickInfosStale;
149
- };
150
- exports.isClickInfosStale = isClickInfosStale;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isClickInfosStale = exports.isIdentityCacheStale = void 0;
4
+ const at_shared_utils_1 = require("@adtrackify/at-shared-utils");
5
+ const logging_helper_1 = require("./logging-helper");
6
+ const isIdentityCacheStale = (identityCache, incomingIdentity) => {
7
+ try {
8
+ const cachedTraits = identityCache.response?.traits ?? {};
9
+ const incomingTraits = incomingIdentity?.traits ?? {};
10
+ const identityCacheStaleTracker = {
11
+ cachedTraits: cachedTraits,
12
+ incomingTraits: incomingTraits,
13
+ isUserIdsStale: false,
14
+ isIdsStale: false,
15
+ isEmailsStale: false,
16
+ isPhonesStale: false,
17
+ isShopifyYIdsStale: false,
18
+ isGendersStale: false,
19
+ isDobsStale: false,
20
+ isAddressesStale: false,
21
+ isClickInfosStale: false,
22
+ isIpAddressStale: false,
23
+ isUserAgentStale: false,
24
+ isCacheStale: false
25
+ };
26
+ const isNewUserIds = (0, at_shared_utils_1.hasNewTrait)(cachedTraits?.userIds ?? [], incomingTraits?.userIds ?? []);
27
+ if (isNewUserIds) {
28
+ logging_helper_1.Logger.debug('identity cache miss - userIds changed', { cachedTraits, incomingTraits });
29
+ identityCacheStaleTracker.isUserIdsStale = true;
30
+ identityCacheStaleTracker.isCacheStale = true;
31
+ }
32
+ const isNewIds = (0, at_shared_utils_1.hasNewTrait)(cachedTraits?.ids ?? [], incomingTraits?.ids ?? []);
33
+ if (isNewIds) {
34
+ logging_helper_1.Logger.debug('identity cache miss - ids changed', { cachedTraits, incomingTraits });
35
+ identityCacheStaleTracker.isIdsStale = true;
36
+ identityCacheStaleTracker.isCacheStale = true;
37
+ }
38
+ const isNewEmails = (0, at_shared_utils_1.hasNewTrait)(cachedTraits?.emails ?? [], incomingTraits?.emails ?? []);
39
+ if (isNewEmails) {
40
+ logging_helper_1.Logger.debug('identity cache miss - emails changed', { cachedTraits, incomingTraits });
41
+ identityCacheStaleTracker.isEmailsStale = true;
42
+ identityCacheStaleTracker.isCacheStale = true;
43
+ }
44
+ const isNewPhones = (0, at_shared_utils_1.hasNewTrait)(cachedTraits?.phones ?? [], incomingTraits?.phones ?? []);
45
+ if (isNewPhones) {
46
+ logging_helper_1.Logger.debug('identity cache miss - phones changed', { cachedTraits, incomingTraits });
47
+ identityCacheStaleTracker.isPhonesStale = true;
48
+ identityCacheStaleTracker.isCacheStale = true;
49
+ }
50
+ const isNewShopifyYIds = (0, at_shared_utils_1.hasNewTrait)(cachedTraits?.shopifyYIds ?? [], incomingTraits?.shopifyYIds ?? []);
51
+ if (isNewShopifyYIds) {
52
+ logging_helper_1.Logger.debug('identity cache miss - shopify Y ids changed', { cachedTraits, incomingTraits });
53
+ identityCacheStaleTracker.isShopifyYIdsStale = true;
54
+ identityCacheStaleTracker.isCacheStale = true;
55
+ }
56
+ const isNewGenders = (0, at_shared_utils_1.hasNewTrait)(cachedTraits?.genders ?? [], incomingTraits?.genders ?? []);
57
+ if (isNewGenders) {
58
+ logging_helper_1.Logger.debug('identity cache miss - genders changed', { cachedTraits, incomingTraits });
59
+ identityCacheStaleTracker.isGendersStale = true;
60
+ identityCacheStaleTracker.isCacheStale = true;
61
+ }
62
+ const isNewDobs = (0, at_shared_utils_1.hasNewTrait)(cachedTraits?.dobs ?? [], incomingTraits?.dobs ?? []);
63
+ if (isNewDobs) {
64
+ logging_helper_1.Logger.debug('identity cache miss - dobs changed', { cachedTraits, incomingTraits });
65
+ identityCacheStaleTracker.isDobsStale = true;
66
+ identityCacheStaleTracker.isCacheStale = true;
67
+ }
68
+ const isNewAddress = (0, at_shared_utils_1.hasNewAddress)(cachedTraits?.addresses ?? [], incomingTraits?.addresses ?? []);
69
+ if (isNewAddress) {
70
+ logging_helper_1.Logger.debug('identity cache miss - address changed', { cachedTraits, incomingTraits });
71
+ identityCacheStaleTracker.isAddressesStale = true;
72
+ identityCacheStaleTracker.isCacheStale = true;
73
+ }
74
+ const isNewClick = (0, exports.isClickInfosStale)(cachedTraits?.click ?? {}, incomingTraits?.click ?? {});
75
+ if (isNewClick) {
76
+ logging_helper_1.Logger.debug('identity cache miss - clickInfos changed', { cachedTraits, incomingTraits });
77
+ identityCacheStaleTracker.isClickInfosStale = true;
78
+ identityCacheStaleTracker.isCacheStale = true;
79
+ }
80
+ if (incomingTraits?.ipAddress && cachedTraits?.ipAddress !== incomingTraits?.ipAddress) {
81
+ logging_helper_1.Logger.debug('identity cache miss - ip/userAgent changed', { cachedTraits, incomingTraits });
82
+ identityCacheStaleTracker.isIpAddressStale = true;
83
+ identityCacheStaleTracker.isCacheStale = true;
84
+ }
85
+ if (incomingTraits?.userAgent && cachedTraits?.userAgent !== incomingTraits?.userAgent) {
86
+ logging_helper_1.Logger.debug('identity cache miss - userAgent changed', { cachedTraits, incomingTraits });
87
+ identityCacheStaleTracker.isUserAgentStale = true;
88
+ identityCacheStaleTracker.isCacheStale = true;
89
+ }
90
+ if (identityCacheStaleTracker.isCacheStale) {
91
+ logging_helper_1.Logger.debug('identity cache miss - cache stale', { identityCacheStaleTracker });
92
+ }
93
+ return identityCacheStaleTracker.isCacheStale;
94
+ }
95
+ catch (err) {
96
+ logging_helper_1.Logger.error('Error while checking if identity cache is stale', { err });
97
+ return true;
98
+ }
99
+ };
100
+ exports.isIdentityCacheStale = isIdentityCacheStale;
101
+ const isClickInfosStale = (cachedClick, incomingClick) => {
102
+ const cleanedCachedClick = (0, at_shared_utils_1.removeEmptyFields)(cachedClick);
103
+ const cleanedIncomingClick = (0, at_shared_utils_1.removeEmptyFields)(incomingClick);
104
+ const incomingKeys = Object.keys(cleanedIncomingClick);
105
+ const clickInfoStaleTracker = {
106
+ cleanedCachedClick,
107
+ cleanedIncomingClick,
108
+ isClickInfosStale: false,
109
+ staleKeys: []
110
+ };
111
+ incomingKeys.forEach(key => {
112
+ if (key === 'googleClientInfos' || key.includes('CollectedAt')) {
113
+ return true;
114
+ }
115
+ else if (key === 'fbc') {
116
+ const cachedClickValue = cleanedCachedClick?.[key];
117
+ const incomingClickValue = cleanedIncomingClick?.[key];
118
+ if (incomingClickValue && !cachedClickValue) {
119
+ clickInfoStaleTracker.isClickInfosStale = true;
120
+ clickInfoStaleTracker.staleKeys.push(key);
121
+ }
122
+ else if (incomingClickValue && cachedClickValue && incomingClickValue !== cachedClickValue) {
123
+ const incomingFbcFbclid = incomingClickValue?.split('.')?.[3];
124
+ const cachedFbcFbclid = cachedClickValue?.split('.')?.[3];
125
+ if (incomingFbcFbclid !== cachedFbcFbclid) {
126
+ clickInfoStaleTracker.isClickInfosStale = true;
127
+ clickInfoStaleTracker.staleKeys.push(key);
128
+ }
129
+ if (!incomingFbcFbclid || !cachedFbcFbclid) {
130
+ clickInfoStaleTracker.isClickInfosStale = true;
131
+ clickInfoStaleTracker.staleKeys.push(key);
132
+ }
133
+ }
134
+ }
135
+ else {
136
+ const cachedClickValue = cleanedCachedClick?.[key];
137
+ const incomingClickValue = cleanedIncomingClick?.[key];
138
+ if ((incomingClickValue && !cachedClickValue)
139
+ || incomingClickValue !== cachedClickValue) {
140
+ clickInfoStaleTracker.isClickInfosStale = true;
141
+ clickInfoStaleTracker.staleKeys.push(key);
142
+ }
143
+ }
144
+ });
145
+ if (clickInfoStaleTracker.isClickInfosStale) {
146
+ logging_helper_1.Logger.debug('identity cache miss - clickInfos changed', { clickInfoStaleTracker });
147
+ }
148
+ return clickInfoStaleTracker.isClickInfosStale;
149
+ };
150
+ exports.isClickInfosStale = isClickInfosStale;
151
151
  //# sourceMappingURL=identity-cache-helper.js.map
@@ -1,5 +1,5 @@
1
- export * from './input-validation-helper.js';
2
- export * from './logging-helper.js';
3
- export * from './response-helper.js';
4
- export * from './shopify-helper.js';
5
- export * from './identity-cache-helper.js';
1
+ export * from './input-validation-helper.js';
2
+ export * from './logging-helper.js';
3
+ export * from './response-helper.js';
4
+ export * from './shopify-helper.js';
5
+ export * from './identity-cache-helper.js';