@timardex/cluemart-shared 2.5.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.
- package/dist/{ad-DRI2CIzV.d.ts → ad-C7GbDyUi.d.ts} +1 -1
- package/dist/{ad-BSyVGv8q.d.mts → ad-DB9gvcJW.d.mts} +1 -1
- package/dist/{chunk-L4NHGGT7.mjs → chunk-H6HM2FOZ.mjs} +2 -2
- package/dist/{chunk-DEK7NF3O.mjs → chunk-NEOBS55J.mjs} +1 -1
- package/dist/{chunk-2RHUGVV3.mjs → chunk-WOBG6I4T.mjs} +175 -12
- package/dist/chunk-WOBG6I4T.mjs.map +1 -0
- package/dist/chunk-YCUKTVVA.mjs +69 -0
- package/dist/chunk-YCUKTVVA.mjs.map +1 -0
- package/dist/formFields/index.mjs +3 -3
- package/dist/graphql/index.cjs +193 -13
- package/dist/graphql/index.cjs.map +1 -1
- package/dist/graphql/index.d.mts +46 -3
- package/dist/graphql/index.d.ts +46 -3
- package/dist/graphql/index.mjs +8 -2
- package/dist/hooks/index.cjs +23 -13
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.mjs +4 -4
- package/dist/index.cjs +209 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +61 -2
- package/dist/index.d.ts +61 -2
- package/dist/index.mjs +196 -9
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/index.cjs +34 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.mts +17 -1
- package/dist/utils/index.d.ts +17 -1
- package/dist/utils/index.mjs +15 -3
- package/package.json +1 -1
- package/dist/chunk-2RHUGVV3.mjs.map +0 -1
- package/dist/chunk-7DQBUZXY.mjs +0 -41
- package/dist/chunk-7DQBUZXY.mjs.map +0 -1
- /package/dist/{chunk-L4NHGGT7.mjs.map → chunk-H6HM2FOZ.mjs.map} +0 -0
- /package/dist/{chunk-DEK7NF3O.mjs.map → chunk-NEOBS55J.mjs.map} +0 -0
|
@@ -258,4 +258,4 @@ interface AdMetricsType {
|
|
|
258
258
|
updatedAt: Date | null;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
export { type AuthMutationResponse as A, type CreateAdFormData as B, type CreateLoginFormData as C, EnumAdApprovalStatus as D,
|
|
261
|
+
export { type AuthMutationResponse as A, type CreateAdFormData as B, type CreateLoginFormData as C, EnumAdApprovalStatus as D, EnumAdShowOn as E, EnumAdBookingSlotKind as F, EnumAdBookingState as G, EnumAdPaymentStatus as H, EnumAdStatus as I, EnumAdStyle as J, EnumAdType as K, EnumVerificationType as L, type LoginFormData as M, type MarketingMaterialRequestInputType as N, type PosterInputType as O, type PartnerType as P, type RefreshTokenPayloadType as Q, type RefreshImpersonationMutationResponse as R, type StartImpersonationMutationResponse as S, type RegisterFormData as T, type RequestPasswordResetFormData as U, type ResetPasswordFormData as V, type SchoolCampaignType as W, type SchoolRegisteredUserType as X, type StartImpersonationPayloadType as Y, type ValidateVerificationTokenFormData as Z, type RefreshTokenMutationResponse as a, EnumAdPlatform as b, type AdType as c, type AppSettingsType as d, type SchoolType as e, type SchoolReturnType as f, type CreateRegisterFormData as g, type CreateRequestPasswordResetFormData as h, type CreateValidateVerificationTokenFormData as i, type CreateResetPasswordFormData as j, type PartnerFormData as k, type AdFormData as l, type CreateAdFormState as m, type CreatePartnerFormData as n, type AppSettingsFormData as o, type CreateAppSettingsFormData as p, type SchoolFormData as q, type CreateSchoolFormData as r, type AdBookingType as s, type AdDailyPriceType as t, type AdFormState as u, type AdMetricsType as v, type AdResource as w, type AdSettingsFormData as x, type AdSettingsType as y, type AuthPayloadType as z };
|
|
@@ -258,4 +258,4 @@ interface AdMetricsType {
|
|
|
258
258
|
updatedAt: Date | null;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
export { type AuthMutationResponse as A, type CreateAdFormData as B, type CreateLoginFormData as C, EnumAdApprovalStatus as D,
|
|
261
|
+
export { type AuthMutationResponse as A, type CreateAdFormData as B, type CreateLoginFormData as C, EnumAdApprovalStatus as D, EnumAdShowOn as E, EnumAdBookingSlotKind as F, EnumAdBookingState as G, EnumAdPaymentStatus as H, EnumAdStatus as I, EnumAdStyle as J, EnumAdType as K, EnumVerificationType as L, type LoginFormData as M, type MarketingMaterialRequestInputType as N, type PosterInputType as O, type PartnerType as P, type RefreshTokenPayloadType as Q, type RefreshImpersonationMutationResponse as R, type StartImpersonationMutationResponse as S, type RegisterFormData as T, type RequestPasswordResetFormData as U, type ResetPasswordFormData as V, type SchoolCampaignType as W, type SchoolRegisteredUserType as X, type StartImpersonationPayloadType as Y, type ValidateVerificationTokenFormData as Z, type RefreshTokenMutationResponse as a, EnumAdPlatform as b, type AdType as c, type AppSettingsType as d, type SchoolType as e, type SchoolReturnType as f, type CreateRegisterFormData as g, type CreateRequestPasswordResetFormData as h, type CreateValidateVerificationTokenFormData as i, type CreateResetPasswordFormData as j, type PartnerFormData as k, type AdFormData as l, type CreateAdFormState as m, type CreatePartnerFormData as n, type AppSettingsFormData as o, type CreateAppSettingsFormData as p, type SchoolFormData as q, type CreateSchoolFormData as r, type AdBookingType as s, type AdDailyPriceType as t, type AdFormState as u, type AdMetricsType as v, type AdResource as w, type AdSettingsFormData as x, type AdSettingsType as y, type AuthPayloadType as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mapArrayToOptions
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NEOBS55J.mjs";
|
|
4
4
|
import {
|
|
5
5
|
EnumFoodFlavor
|
|
6
6
|
} from "./chunk-A52C6JDT.mjs";
|
|
@@ -987,4 +987,4 @@ export {
|
|
|
987
987
|
contactUsFields,
|
|
988
988
|
partnerBasicInfoFields
|
|
989
989
|
};
|
|
990
|
-
//# sourceMappingURL=chunk-
|
|
990
|
+
//# sourceMappingURL=chunk-H6HM2FOZ.mjs.map
|
|
@@ -44,10 +44,14 @@ import {
|
|
|
44
44
|
VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT
|
|
45
45
|
} from "./chunk-TKSBCN3N.mjs";
|
|
46
46
|
import {
|
|
47
|
+
AD_METRIC_IMPRESSION_RETRY_DELAY_MS,
|
|
47
48
|
DEFAULT_PAGE_SIZE,
|
|
48
49
|
accumulateItems,
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
buildAdMetricSlotKey,
|
|
51
|
+
defaultGetId,
|
|
52
|
+
generateAdClickId,
|
|
53
|
+
getAdMetricRotationSlot
|
|
54
|
+
} from "./chunk-YCUKTVVA.mjs";
|
|
51
55
|
|
|
52
56
|
// src/graphql/mutations/vendor.ts
|
|
53
57
|
import { gql } from "@apollo/client";
|
|
@@ -2200,6 +2204,7 @@ var useSelectStandardPackage = () => {
|
|
|
2200
2204
|
|
|
2201
2205
|
// src/graphql/hooks/ad/hooksMutation.ts
|
|
2202
2206
|
import { useMutation as useMutation11 } from "@apollo/client";
|
|
2207
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
2203
2208
|
|
|
2204
2209
|
// src/graphql/mutations/ad.ts
|
|
2205
2210
|
import { gql as gql21 } from "@apollo/client";
|
|
@@ -2365,6 +2370,15 @@ var GET_AD_SETTINGS = gql22`
|
|
|
2365
2370
|
}
|
|
2366
2371
|
}
|
|
2367
2372
|
`;
|
|
2373
|
+
var GET_AD_METRIC_TOTALS = gql22`
|
|
2374
|
+
query getAdMetricTotals($filter: AdMetricTotalsFilterInputGraphQLType) {
|
|
2375
|
+
adMetricTotals(filter: $filter) {
|
|
2376
|
+
adId
|
|
2377
|
+
clicks
|
|
2378
|
+
impressions
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
`;
|
|
2368
2382
|
|
|
2369
2383
|
// src/graphql/mutations/adBooking.ts
|
|
2370
2384
|
var CREATE_AD_CHECKOUT_MUTATION = gql23`
|
|
@@ -2481,14 +2495,147 @@ var useRecordAdClick = () => {
|
|
|
2481
2495
|
recordAdClick
|
|
2482
2496
|
};
|
|
2483
2497
|
};
|
|
2498
|
+
var defaultAdMetricErrorHandler = (message, error) => {
|
|
2499
|
+
console.error(message, error);
|
|
2500
|
+
};
|
|
2501
|
+
var useAdMetricsReporter = (input, onError = defaultAdMetricErrorHandler) => {
|
|
2502
|
+
const { recordAdImpression } = useRecordAdImpression();
|
|
2503
|
+
const { recordAdClick } = useRecordAdClick();
|
|
2504
|
+
const reportedSlotRef = useRef({
|
|
2505
|
+
keys: /* @__PURE__ */ new Set(),
|
|
2506
|
+
slot: -1
|
|
2507
|
+
});
|
|
2508
|
+
const inFlightRef = useRef(false);
|
|
2509
|
+
const disposedRef = useRef(false);
|
|
2510
|
+
const safeOnError = useCallback(
|
|
2511
|
+
(message, error) => {
|
|
2512
|
+
try {
|
|
2513
|
+
onError(message, error);
|
|
2514
|
+
} catch {
|
|
2515
|
+
}
|
|
2516
|
+
},
|
|
2517
|
+
[onError]
|
|
2518
|
+
);
|
|
2519
|
+
useEffect(() => {
|
|
2520
|
+
disposedRef.current = false;
|
|
2521
|
+
return () => {
|
|
2522
|
+
disposedRef.current = true;
|
|
2523
|
+
};
|
|
2524
|
+
}, []);
|
|
2525
|
+
const reportImpression = useCallback(
|
|
2526
|
+
async (opts) => {
|
|
2527
|
+
if (inFlightRef.current || disposedRef.current) return false;
|
|
2528
|
+
const now = opts?.nowMs ?? Date.now();
|
|
2529
|
+
const slot = getAdMetricRotationSlot(now);
|
|
2530
|
+
const key = buildAdMetricSlotKey(input.adId, input.placement, slot);
|
|
2531
|
+
const reported = reportedSlotRef.current;
|
|
2532
|
+
if (reported.slot !== slot) {
|
|
2533
|
+
reported.slot = slot;
|
|
2534
|
+
reported.keys.clear();
|
|
2535
|
+
}
|
|
2536
|
+
if (reported.keys.has(key)) return false;
|
|
2537
|
+
inFlightRef.current = true;
|
|
2538
|
+
try {
|
|
2539
|
+
const result = await recordAdImpression({
|
|
2540
|
+
variables: {
|
|
2541
|
+
input: {
|
|
2542
|
+
adId: input.adId,
|
|
2543
|
+
placement: input.placement,
|
|
2544
|
+
platform: input.platform,
|
|
2545
|
+
region: input.region
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
});
|
|
2549
|
+
if (result.data?.recordAdImpression?.data !== true) {
|
|
2550
|
+
return false;
|
|
2551
|
+
}
|
|
2552
|
+
reported.keys.add(key);
|
|
2553
|
+
return true;
|
|
2554
|
+
} catch (error) {
|
|
2555
|
+
safeOnError(
|
|
2556
|
+
"Ad impression report failed; retrying within the rotation.",
|
|
2557
|
+
error
|
|
2558
|
+
);
|
|
2559
|
+
if (!disposedRef.current && getAdMetricRotationSlot(Date.now()) === slot) {
|
|
2560
|
+
await new Promise(
|
|
2561
|
+
(resolve) => setTimeout(resolve, AD_METRIC_IMPRESSION_RETRY_DELAY_MS)
|
|
2562
|
+
);
|
|
2563
|
+
if (!disposedRef.current && getAdMetricRotationSlot(Date.now()) === slot) {
|
|
2564
|
+
try {
|
|
2565
|
+
const retryResult = await recordAdImpression({
|
|
2566
|
+
variables: {
|
|
2567
|
+
input: {
|
|
2568
|
+
adId: input.adId,
|
|
2569
|
+
placement: input.placement,
|
|
2570
|
+
platform: input.platform,
|
|
2571
|
+
region: input.region
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
});
|
|
2575
|
+
if (retryResult.data?.recordAdImpression?.data !== true) {
|
|
2576
|
+
return false;
|
|
2577
|
+
}
|
|
2578
|
+
reported.keys.add(key);
|
|
2579
|
+
return true;
|
|
2580
|
+
} catch (retryError) {
|
|
2581
|
+
safeOnError("Ad impression retry failed.", retryError);
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
return false;
|
|
2586
|
+
} finally {
|
|
2587
|
+
inFlightRef.current = false;
|
|
2588
|
+
}
|
|
2589
|
+
},
|
|
2590
|
+
[
|
|
2591
|
+
input.adId,
|
|
2592
|
+
input.placement,
|
|
2593
|
+
input.platform,
|
|
2594
|
+
input.region,
|
|
2595
|
+
safeOnError,
|
|
2596
|
+
recordAdImpression
|
|
2597
|
+
]
|
|
2598
|
+
);
|
|
2599
|
+
const reportClick = useCallback(
|
|
2600
|
+
(adIdOverride) => {
|
|
2601
|
+
try {
|
|
2602
|
+
void recordAdClick({
|
|
2603
|
+
variables: {
|
|
2604
|
+
input: {
|
|
2605
|
+
adId: adIdOverride ?? input.adId,
|
|
2606
|
+
clickId: generateAdClickId(),
|
|
2607
|
+
placement: input.placement,
|
|
2608
|
+
platform: input.platform,
|
|
2609
|
+
region: input.region
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
}).catch((error) => {
|
|
2613
|
+
safeOnError("Ad click report failed.", error);
|
|
2614
|
+
});
|
|
2615
|
+
} catch (error) {
|
|
2616
|
+
safeOnError("Ad click report failed.", error);
|
|
2617
|
+
}
|
|
2618
|
+
},
|
|
2619
|
+
[
|
|
2620
|
+
input.adId,
|
|
2621
|
+
input.placement,
|
|
2622
|
+
input.platform,
|
|
2623
|
+
input.region,
|
|
2624
|
+
safeOnError,
|
|
2625
|
+
recordAdClick
|
|
2626
|
+
]
|
|
2627
|
+
);
|
|
2628
|
+
return { reportClick, reportImpression };
|
|
2629
|
+
};
|
|
2484
2630
|
|
|
2485
2631
|
// src/graphql/hooks/ad/hooksQuery.ts
|
|
2486
2632
|
import { useQuery as useQuery6 } from "@apollo/client";
|
|
2487
|
-
var useGetAds = () => {
|
|
2633
|
+
var useGetAds = (skip = false) => {
|
|
2488
2634
|
const { data, loading, error, refetch } = useQuery6(
|
|
2489
2635
|
GET_ADS,
|
|
2490
2636
|
{
|
|
2491
|
-
fetchPolicy: "no-cache"
|
|
2637
|
+
fetchPolicy: "no-cache",
|
|
2638
|
+
skip
|
|
2492
2639
|
}
|
|
2493
2640
|
);
|
|
2494
2641
|
return {
|
|
@@ -2524,6 +2671,19 @@ var useGetAdsByRegion = (region, platform, showOn) => {
|
|
|
2524
2671
|
refetch
|
|
2525
2672
|
};
|
|
2526
2673
|
};
|
|
2674
|
+
var useGetAdMetricTotals = (filter, skip = false) => {
|
|
2675
|
+
const { data, loading, error, refetch } = useQuery6(GET_AD_METRIC_TOTALS, {
|
|
2676
|
+
fetchPolicy: "no-cache",
|
|
2677
|
+
skip,
|
|
2678
|
+
variables: filter ? { filter } : void 0
|
|
2679
|
+
});
|
|
2680
|
+
return {
|
|
2681
|
+
adMetricTotals: data?.adMetricTotals || [],
|
|
2682
|
+
error,
|
|
2683
|
+
loading,
|
|
2684
|
+
refetch
|
|
2685
|
+
};
|
|
2686
|
+
};
|
|
2527
2687
|
|
|
2528
2688
|
// src/graphql/hooks/resourceActivities/hooksMutation.ts
|
|
2529
2689
|
import { useMutation as useMutation12 } from "@apollo/client";
|
|
@@ -4138,7 +4298,7 @@ var useGetCoupon = (_id) => {
|
|
|
4138
4298
|
|
|
4139
4299
|
// src/graphql/hooks/usePaginatedList.ts
|
|
4140
4300
|
import { useQuery as useQuery17 } from "@apollo/client";
|
|
4141
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4301
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useState } from "react";
|
|
4142
4302
|
function usePaginatedList({
|
|
4143
4303
|
document,
|
|
4144
4304
|
getItems,
|
|
@@ -4157,7 +4317,7 @@ function usePaginatedList({
|
|
|
4157
4317
|
const [hasMore, setHasMore] = useState(!skip);
|
|
4158
4318
|
const [hasSettled, setHasSettled] = useState(false);
|
|
4159
4319
|
const variablesKey = JSON.stringify(variables ?? null);
|
|
4160
|
-
|
|
4320
|
+
useEffect2(() => {
|
|
4161
4321
|
setItems([]);
|
|
4162
4322
|
setHasMore(!skip);
|
|
4163
4323
|
setHasSettled(false);
|
|
@@ -4168,14 +4328,14 @@ function usePaginatedList({
|
|
|
4168
4328
|
skip,
|
|
4169
4329
|
variables: { ...variables, options: { limit: pageSize + 1, offset } }
|
|
4170
4330
|
});
|
|
4171
|
-
const refetchRef =
|
|
4331
|
+
const refetchRef = useRef2(refetch);
|
|
4172
4332
|
refetchRef.current = refetch;
|
|
4173
|
-
const variablesRef =
|
|
4333
|
+
const variablesRef = useRef2(variables);
|
|
4174
4334
|
variablesRef.current = variables;
|
|
4175
4335
|
const rawPage = getItems(data);
|
|
4176
4336
|
const page = rawPage.length > pageSize ? rawPage.slice(0, pageSize) : rawPage;
|
|
4177
4337
|
const hasMorePage = rawPage.length > pageSize;
|
|
4178
|
-
|
|
4338
|
+
useEffect2(() => {
|
|
4179
4339
|
if (loading || skip || error) {
|
|
4180
4340
|
return;
|
|
4181
4341
|
}
|
|
@@ -4191,7 +4351,7 @@ function usePaginatedList({
|
|
|
4191
4351
|
setHasSettled(true);
|
|
4192
4352
|
setHasMore(hasMorePage);
|
|
4193
4353
|
}, [loading, skip, error, page, hasMorePage, hasSettled, pageSize, getId]);
|
|
4194
|
-
const loadMore =
|
|
4354
|
+
const loadMore = useCallback2(() => {
|
|
4195
4355
|
if (loading || skip) {
|
|
4196
4356
|
return;
|
|
4197
4357
|
}
|
|
@@ -4207,7 +4367,7 @@ function usePaginatedList({
|
|
|
4207
4367
|
}
|
|
4208
4368
|
setOffset(offset + pageSize);
|
|
4209
4369
|
}, [loading, skip, error, hasSettled, hasMore, offset, pageSize]);
|
|
4210
|
-
const refresh =
|
|
4370
|
+
const refresh = useCallback2(() => {
|
|
4211
4371
|
setItems([]);
|
|
4212
4372
|
setHasMore(!skip);
|
|
4213
4373
|
setHasSettled(false);
|
|
@@ -4330,6 +4490,7 @@ export {
|
|
|
4330
4490
|
GET_PENDING_AD_BOOKINGS,
|
|
4331
4491
|
GET_AD_DAILY_PRICES,
|
|
4332
4492
|
GET_AD_SETTINGS,
|
|
4493
|
+
GET_AD_METRIC_TOTALS,
|
|
4333
4494
|
CREATE_AD_CHECKOUT_MUTATION,
|
|
4334
4495
|
APPROVE_AD_BOOKING_MUTATION,
|
|
4335
4496
|
UPDATE_AD_DAILY_PRICE_MUTATION,
|
|
@@ -4341,9 +4502,11 @@ export {
|
|
|
4341
4502
|
useDeleteAd,
|
|
4342
4503
|
useRecordAdImpression,
|
|
4343
4504
|
useRecordAdClick,
|
|
4505
|
+
useAdMetricsReporter,
|
|
4344
4506
|
useGetAds,
|
|
4345
4507
|
useGetAd,
|
|
4346
4508
|
useGetAdsByRegion,
|
|
4509
|
+
useGetAdMetricTotals,
|
|
4347
4510
|
useCreateResourceActivity,
|
|
4348
4511
|
useGetResourceActivity,
|
|
4349
4512
|
useCreateCheckoutSession,
|
|
@@ -4399,4 +4562,4 @@ export {
|
|
|
4399
4562
|
useGetCoupon,
|
|
4400
4563
|
usePaginatedList
|
|
4401
4564
|
};
|
|
4402
|
-
//# sourceMappingURL=chunk-
|
|
4565
|
+
//# sourceMappingURL=chunk-WOBG6I4T.mjs.map
|