@timardex/cluemart-shared 2.4.0 → 2.5.1

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 (59) hide show
  1. package/dist/{ad-DRI2CIzV.d.ts → ad-C7GbDyUi.d.ts} +1 -1
  2. package/dist/{ad-BSyVGv8q.d.mts → ad-DB9gvcJW.d.mts} +1 -1
  3. package/dist/auth/index.mjs +1 -1
  4. package/dist/{chunk-J72IMZ6E.mjs → chunk-4CQLKIQ6.mjs} +1 -1
  5. package/dist/chunk-4CQLKIQ6.mjs.map +1 -0
  6. package/dist/{chunk-XGGFB7HY.mjs → chunk-A52C6JDT.mjs} +2 -2
  7. package/dist/chunk-A52C6JDT.mjs.map +1 -0
  8. package/dist/{chunk-LHKJJ7SO.mjs → chunk-CQ26N3W6.mjs} +2 -2
  9. package/dist/{chunk-LEAXY4DI.mjs → chunk-H6HM2FOZ.mjs} +3 -3
  10. package/dist/{chunk-ZECVZFK3.mjs → chunk-NEOBS55J.mjs} +4 -3
  11. package/dist/{chunk-ZECVZFK3.mjs.map → chunk-NEOBS55J.mjs.map} +1 -1
  12. package/dist/{chunk-2RHUGVV3.mjs → chunk-WOBG6I4T.mjs} +175 -12
  13. package/dist/chunk-WOBG6I4T.mjs.map +1 -0
  14. package/dist/chunk-YCUKTVVA.mjs +69 -0
  15. package/dist/chunk-YCUKTVVA.mjs.map +1 -0
  16. package/dist/enums/index.cjs +1 -1
  17. package/dist/enums/index.cjs.map +1 -1
  18. package/dist/enums/index.d.mts +2 -2
  19. package/dist/enums/index.d.ts +2 -2
  20. package/dist/enums/index.mjs +1 -1
  21. package/dist/formFields/index.cjs +2 -1
  22. package/dist/formFields/index.cjs.map +1 -1
  23. package/dist/formFields/index.mjs +5 -5
  24. package/dist/graphql/index.cjs +193 -13
  25. package/dist/graphql/index.cjs.map +1 -1
  26. package/dist/graphql/index.d.mts +46 -3
  27. package/dist/graphql/index.d.ts +46 -3
  28. package/dist/graphql/index.mjs +9 -3
  29. package/dist/hooks/index.cjs +25 -14
  30. package/dist/hooks/index.cjs.map +1 -1
  31. package/dist/hooks/index.d.mts +1 -1
  32. package/dist/hooks/index.d.ts +1 -1
  33. package/dist/hooks/index.mjs +7 -7
  34. package/dist/index.cjs +211 -14
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.mts +69 -9
  37. package/dist/index.d.ts +69 -9
  38. package/dist/index.mjs +198 -10
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/region/index.cjs.map +1 -1
  41. package/dist/region/index.mjs +1 -1
  42. package/dist/sharing/index.cjs.map +1 -1
  43. package/dist/sharing/index.mjs +3 -3
  44. package/dist/types/index.d.mts +1 -1
  45. package/dist/types/index.d.ts +1 -1
  46. package/dist/types/index.mjs +1 -1
  47. package/dist/utils/index.cjs +36 -1
  48. package/dist/utils/index.cjs.map +1 -1
  49. package/dist/utils/index.d.mts +23 -6
  50. package/dist/utils/index.d.ts +23 -6
  51. package/dist/utils/index.mjs +17 -5
  52. package/package.json +1 -1
  53. package/dist/chunk-2RHUGVV3.mjs.map +0 -1
  54. package/dist/chunk-7DQBUZXY.mjs +0 -41
  55. package/dist/chunk-7DQBUZXY.mjs.map +0 -1
  56. package/dist/chunk-J72IMZ6E.mjs.map +0 -1
  57. package/dist/chunk-XGGFB7HY.mjs.map +0 -1
  58. /package/dist/{chunk-LHKJJ7SO.mjs.map → chunk-CQ26N3W6.mjs.map} +0 -0
  59. /package/dist/{chunk-LEAXY4DI.mjs.map → chunk-H6HM2FOZ.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  // src/enums/index.ts
2
2
  var EnumInviteStatus = /* @__PURE__ */ ((EnumInviteStatus2) => {
3
3
  EnumInviteStatus2["ACCEPTED"] = "Accepted";
4
+ EnumInviteStatus2["CANCELED"] = "Canceled";
4
5
  EnumInviteStatus2["COMPLETED"] = "Completed";
5
6
  EnumInviteStatus2["EXPIRED"] = "Expired";
6
7
  EnumInviteStatus2["NO_STATUS"] = "No_Status";
7
8
  EnumInviteStatus2["PENDING"] = "Pending";
8
9
  EnumInviteStatus2["REJECTED"] = "Rejected";
9
- EnumInviteStatus2["UNAVAILABLE"] = "Unavailable";
10
10
  return EnumInviteStatus2;
11
11
  })(EnumInviteStatus || {});
12
12
  var EnumChatReportReason = /* @__PURE__ */ ((EnumChatReportReason2) => {
@@ -2874,6 +2874,28 @@ function isTransientNetworkError(err) {
2874
2874
  return TRANSIENT_NETWORK_PATTERNS.some((pattern) => pattern.test(message));
2875
2875
  }
2876
2876
 
2877
+ // src/utils/adMetrics.ts
2878
+ var AD_METRIC_ROTATION_INTERVAL_MS = 8e3;
2879
+ var AD_METRIC_IMPRESSION_RETRY_DELAY_MS = 1e3;
2880
+ function getAdMetricRotationSlot(epochMilliseconds) {
2881
+ return Math.floor(epochMilliseconds / AD_METRIC_ROTATION_INTERVAL_MS);
2882
+ }
2883
+ function getAdMetricRotationIndex(epochMilliseconds, count) {
2884
+ if (count <= 0) return 0;
2885
+ return getAdMetricRotationSlot(epochMilliseconds) % count;
2886
+ }
2887
+ function buildAdMetricSlotKey(adId, placement, slot) {
2888
+ return `${adId}:${placement}:${slot}`;
2889
+ }
2890
+ function generateAdClickId() {
2891
+ const cryptoApi = globalThis.crypto;
2892
+ if (typeof cryptoApi?.randomUUID === "function") {
2893
+ return cryptoApi.randomUUID();
2894
+ }
2895
+ const randomPart = Math.random().toString(36).slice(2) || "0";
2896
+ return `click-${Date.now()}-${randomPart}`;
2897
+ }
2898
+
2877
2899
  // src/utils/billingCatalog/index.ts
2878
2900
  var BILLING_CATALOG_KEYS = [
2879
2901
  "pro_vendor_monthly",
@@ -3043,6 +3065,7 @@ function getVendorEventsData({
3043
3065
  // src/utils/relations/preservedRelationDateStatuses.ts
3044
3066
  var PRESERVED_RELATION_DATE_STATUSES = /* @__PURE__ */ new Set([
3045
3067
  "Accepted" /* ACCEPTED */,
3068
+ "Canceled" /* CANCELED */,
3046
3069
  "Completed" /* COMPLETED */,
3047
3070
  "Rejected" /* REJECTED */
3048
3071
  ]);
@@ -7238,6 +7261,7 @@ var useGetUsersByPromoCode = (promoCode, options) => {
7238
7261
 
7239
7262
  // src/graphql/hooks/ad/hooksMutation.ts
7240
7263
  import { useMutation as useMutation12 } from "@apollo/client";
7264
+ import { useCallback, useEffect, useRef } from "react";
7241
7265
 
7242
7266
  // src/graphql/mutations/ad.ts
7243
7267
  import { gql as gql27 } from "@apollo/client";
@@ -7403,6 +7427,15 @@ var GET_AD_SETTINGS = gql28`
7403
7427
  }
7404
7428
  }
7405
7429
  `;
7430
+ var GET_AD_METRIC_TOTALS = gql28`
7431
+ query getAdMetricTotals($filter: AdMetricTotalsFilterInputGraphQLType) {
7432
+ adMetricTotals(filter: $filter) {
7433
+ adId
7434
+ clicks
7435
+ impressions
7436
+ }
7437
+ }
7438
+ `;
7406
7439
 
7407
7440
  // src/graphql/mutations/adBooking.ts
7408
7441
  var CREATE_AD_CHECKOUT_MUTATION = gql29`
@@ -7519,14 +7552,147 @@ var useRecordAdClick = () => {
7519
7552
  recordAdClick
7520
7553
  };
7521
7554
  };
7555
+ var defaultAdMetricErrorHandler = (message, error) => {
7556
+ console.error(message, error);
7557
+ };
7558
+ var useAdMetricsReporter = (input, onError = defaultAdMetricErrorHandler) => {
7559
+ const { recordAdImpression } = useRecordAdImpression();
7560
+ const { recordAdClick } = useRecordAdClick();
7561
+ const reportedSlotRef = useRef({
7562
+ keys: /* @__PURE__ */ new Set(),
7563
+ slot: -1
7564
+ });
7565
+ const inFlightRef = useRef(false);
7566
+ const disposedRef = useRef(false);
7567
+ const safeOnError = useCallback(
7568
+ (message, error) => {
7569
+ try {
7570
+ onError(message, error);
7571
+ } catch {
7572
+ }
7573
+ },
7574
+ [onError]
7575
+ );
7576
+ useEffect(() => {
7577
+ disposedRef.current = false;
7578
+ return () => {
7579
+ disposedRef.current = true;
7580
+ };
7581
+ }, []);
7582
+ const reportImpression = useCallback(
7583
+ async (opts) => {
7584
+ if (inFlightRef.current || disposedRef.current) return false;
7585
+ const now = opts?.nowMs ?? Date.now();
7586
+ const slot = getAdMetricRotationSlot(now);
7587
+ const key = buildAdMetricSlotKey(input.adId, input.placement, slot);
7588
+ const reported = reportedSlotRef.current;
7589
+ if (reported.slot !== slot) {
7590
+ reported.slot = slot;
7591
+ reported.keys.clear();
7592
+ }
7593
+ if (reported.keys.has(key)) return false;
7594
+ inFlightRef.current = true;
7595
+ try {
7596
+ const result = await recordAdImpression({
7597
+ variables: {
7598
+ input: {
7599
+ adId: input.adId,
7600
+ placement: input.placement,
7601
+ platform: input.platform,
7602
+ region: input.region
7603
+ }
7604
+ }
7605
+ });
7606
+ if (result.data?.recordAdImpression?.data !== true) {
7607
+ return false;
7608
+ }
7609
+ reported.keys.add(key);
7610
+ return true;
7611
+ } catch (error) {
7612
+ safeOnError(
7613
+ "Ad impression report failed; retrying within the rotation.",
7614
+ error
7615
+ );
7616
+ if (!disposedRef.current && getAdMetricRotationSlot(Date.now()) === slot) {
7617
+ await new Promise(
7618
+ (resolve) => setTimeout(resolve, AD_METRIC_IMPRESSION_RETRY_DELAY_MS)
7619
+ );
7620
+ if (!disposedRef.current && getAdMetricRotationSlot(Date.now()) === slot) {
7621
+ try {
7622
+ const retryResult = await recordAdImpression({
7623
+ variables: {
7624
+ input: {
7625
+ adId: input.adId,
7626
+ placement: input.placement,
7627
+ platform: input.platform,
7628
+ region: input.region
7629
+ }
7630
+ }
7631
+ });
7632
+ if (retryResult.data?.recordAdImpression?.data !== true) {
7633
+ return false;
7634
+ }
7635
+ reported.keys.add(key);
7636
+ return true;
7637
+ } catch (retryError) {
7638
+ safeOnError("Ad impression retry failed.", retryError);
7639
+ }
7640
+ }
7641
+ }
7642
+ return false;
7643
+ } finally {
7644
+ inFlightRef.current = false;
7645
+ }
7646
+ },
7647
+ [
7648
+ input.adId,
7649
+ input.placement,
7650
+ input.platform,
7651
+ input.region,
7652
+ safeOnError,
7653
+ recordAdImpression
7654
+ ]
7655
+ );
7656
+ const reportClick = useCallback(
7657
+ (adIdOverride) => {
7658
+ try {
7659
+ void recordAdClick({
7660
+ variables: {
7661
+ input: {
7662
+ adId: adIdOverride ?? input.adId,
7663
+ clickId: generateAdClickId(),
7664
+ placement: input.placement,
7665
+ platform: input.platform,
7666
+ region: input.region
7667
+ }
7668
+ }
7669
+ }).catch((error) => {
7670
+ safeOnError("Ad click report failed.", error);
7671
+ });
7672
+ } catch (error) {
7673
+ safeOnError("Ad click report failed.", error);
7674
+ }
7675
+ },
7676
+ [
7677
+ input.adId,
7678
+ input.placement,
7679
+ input.platform,
7680
+ input.region,
7681
+ safeOnError,
7682
+ recordAdClick
7683
+ ]
7684
+ );
7685
+ return { reportClick, reportImpression };
7686
+ };
7522
7687
 
7523
7688
  // src/graphql/hooks/ad/hooksQuery.ts
7524
7689
  import { useQuery as useQuery7 } from "@apollo/client";
7525
- var useGetAds = () => {
7690
+ var useGetAds = (skip = false) => {
7526
7691
  const { data, loading, error, refetch } = useQuery7(
7527
7692
  GET_ADS,
7528
7693
  {
7529
- fetchPolicy: "no-cache"
7694
+ fetchPolicy: "no-cache",
7695
+ skip
7530
7696
  }
7531
7697
  );
7532
7698
  return {
@@ -7562,6 +7728,19 @@ var useGetAdsByRegion = (region, platform, showOn) => {
7562
7728
  refetch
7563
7729
  };
7564
7730
  };
7731
+ var useGetAdMetricTotals = (filter, skip = false) => {
7732
+ const { data, loading, error, refetch } = useQuery7(GET_AD_METRIC_TOTALS, {
7733
+ fetchPolicy: "no-cache",
7734
+ skip,
7735
+ variables: filter ? { filter } : void 0
7736
+ });
7737
+ return {
7738
+ adMetricTotals: data?.adMetricTotals || [],
7739
+ error,
7740
+ loading,
7741
+ refetch
7742
+ };
7743
+ };
7565
7744
 
7566
7745
  // src/graphql/hooks/resourceActivities/hooksMutation.ts
7567
7746
  import { useMutation as useMutation13 } from "@apollo/client";
@@ -9176,7 +9355,7 @@ var useGetCoupon = (_id) => {
9176
9355
 
9177
9356
  // src/graphql/hooks/usePaginatedList.ts
9178
9357
  import { useQuery as useQuery18 } from "@apollo/client";
9179
- import { useCallback, useEffect, useRef, useState } from "react";
9358
+ import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useState } from "react";
9180
9359
  function usePaginatedList({
9181
9360
  document,
9182
9361
  getItems,
@@ -9195,7 +9374,7 @@ function usePaginatedList({
9195
9374
  const [hasMore, setHasMore] = useState(!skip);
9196
9375
  const [hasSettled, setHasSettled] = useState(false);
9197
9376
  const variablesKey = JSON.stringify(variables ?? null);
9198
- useEffect(() => {
9377
+ useEffect2(() => {
9199
9378
  setItems([]);
9200
9379
  setHasMore(!skip);
9201
9380
  setHasSettled(false);
@@ -9206,14 +9385,14 @@ function usePaginatedList({
9206
9385
  skip,
9207
9386
  variables: { ...variables, options: { limit: pageSize + 1, offset } }
9208
9387
  });
9209
- const refetchRef = useRef(refetch);
9388
+ const refetchRef = useRef2(refetch);
9210
9389
  refetchRef.current = refetch;
9211
- const variablesRef = useRef(variables);
9390
+ const variablesRef = useRef2(variables);
9212
9391
  variablesRef.current = variables;
9213
9392
  const rawPage = getItems(data);
9214
9393
  const page = rawPage.length > pageSize ? rawPage.slice(0, pageSize) : rawPage;
9215
9394
  const hasMorePage = rawPage.length > pageSize;
9216
- useEffect(() => {
9395
+ useEffect2(() => {
9217
9396
  if (loading || skip || error) {
9218
9397
  return;
9219
9398
  }
@@ -9229,7 +9408,7 @@ function usePaginatedList({
9229
9408
  setHasSettled(true);
9230
9409
  setHasMore(hasMorePage);
9231
9410
  }, [loading, skip, error, page, hasMorePage, hasSettled, pageSize, getId]);
9232
- const loadMore = useCallback(() => {
9411
+ const loadMore = useCallback2(() => {
9233
9412
  if (loading || skip) {
9234
9413
  return;
9235
9414
  }
@@ -9245,7 +9424,7 @@ function usePaginatedList({
9245
9424
  }
9246
9425
  setOffset(offset + pageSize);
9247
9426
  }, [loading, skip, error, hasSettled, hasMore, offset, pageSize]);
9248
- const refresh = useCallback(() => {
9427
+ const refresh = useCallback2(() => {
9249
9428
  setItems([]);
9250
9429
  setHasMore(!skip);
9251
9430
  setHasSettled(false);
@@ -9827,6 +10006,8 @@ export {
9827
10006
  ADMIN_APP_ROLES,
9828
10007
  ADMIN_DASHBOARD_CONTEXTS,
9829
10008
  AD_BOOKING_FIELDS_FRAGMENT,
10009
+ AD_METRIC_IMPRESSION_RETRY_DELAY_MS,
10010
+ AD_METRIC_ROTATION_INTERVAL_MS,
9830
10011
  AFFILIATE_PARTICIPANT_TYPE_LABELS,
9831
10012
  AFFILIATE_REWARDS,
9832
10013
  ANDROID_URL,
@@ -9890,6 +10071,7 @@ export {
9890
10071
  FUTURE_EVENT_DATE_STATUSES,
9891
10072
  GET_AD_BOOKING,
9892
10073
  GET_AD_DAILY_PRICES,
10074
+ GET_AD_METRIC_TOTALS,
9893
10075
  GET_AD_SETTINGS,
9894
10076
  GET_EVENT,
9895
10077
  GET_EVENTS,
@@ -9983,6 +10165,7 @@ export {
9983
10165
  badges,
9984
10166
  bankAccountDetailsFields,
9985
10167
  billingCatalogDefinitionMatches,
10168
+ buildAdMetricSlotKey,
9986
10169
  buildApplicationShareDescription,
9987
10170
  buildCalendarSheetContentData,
9988
10171
  buildInvitationShareDescription,
@@ -10055,6 +10238,9 @@ export {
10055
10238
  futureTimePeriods,
10056
10239
  gameScreenIdentifierList,
10057
10240
  gameTypeToDisplayName,
10241
+ generateAdClickId,
10242
+ getAdMetricRotationIndex,
10243
+ getAdMetricRotationSlot,
10058
10244
  getAllowedEventDateStatuses,
10059
10245
  getBillingCatalogKeyForSelection,
10060
10246
  getCurrentAndFutureDates,
@@ -10169,6 +10355,7 @@ export {
10169
10355
  truncateText,
10170
10356
  updateSingleDateTimeStatus,
10171
10357
  useActivateVendorClaim,
10358
+ useAdMetricsReporter,
10172
10359
  useAddParticipantToChat,
10173
10360
  useAddUserFavouriteResource,
10174
10361
  useAddUserGoingResource,
@@ -10219,6 +10406,7 @@ export {
10219
10406
  useDeleteVendor,
10220
10407
  useEndImpersonation,
10221
10408
  useGetAd,
10409
+ useGetAdMetricTotals,
10222
10410
  useGetAds,
10223
10411
  useGetAdsByRegion,
10224
10412
  useGetAffiliate,