@replohq/sdk 2.8.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/_vendor/replo-utils/lib/url.d.ts +10 -3
  2. package/_vendor/schemas/generated/consent.d.ts +2 -2
  3. package/consent/script-snippets.js +10 -0
  4. package/consent/types.d.ts +2 -2
  5. package/lib/buildMetadata.js +3 -3
  6. package/loaders/collection-loader.d.ts +4 -1
  7. package/loaders/collection-loader.js +5 -9
  8. package/loaders/collection-products-loader.d.ts +4 -1
  9. package/loaders/collection-products-loader.js +5 -9
  10. package/loaders/contentful-entries-loader.d.ts +4 -1
  11. package/loaders/contentful-entries-loader.js +2 -6
  12. package/loaders/contentful-entry-loader.d.ts +4 -1
  13. package/loaders/contentful-entry-loader.js +2 -6
  14. package/loaders/invoke-loader-action.d.ts +2 -1
  15. package/loaders/invoke-loader-action.js +2 -4
  16. package/loaders/invoke-loader-server.js +8 -4
  17. package/loaders/invoke-loader.d.ts +11 -3
  18. package/loaders/invoke-loader.js +6 -5
  19. package/loaders/judgeme-review-aggregate-loader.d.ts +4 -1
  20. package/loaders/judgeme-review-aggregate-loader.js +5 -11
  21. package/loaders/judgeme-reviews-loader.d.ts +4 -1
  22. package/loaders/judgeme-reviews-loader.js +2 -6
  23. package/loaders/junip-review-aggregate-loader.d.ts +4 -1
  24. package/loaders/junip-review-aggregate-loader.js +5 -11
  25. package/loaders/junip-reviews-loader.d.ts +4 -1
  26. package/loaders/junip-reviews-loader.js +2 -6
  27. package/loaders/kaching-bundles-loader.d.ts +4 -1
  28. package/loaders/kaching-bundles-loader.js +5 -6
  29. package/loaders/levanta-product-loader.d.ts +4 -1
  30. package/loaders/levanta-product-loader.js +5 -9
  31. package/loaders/loader-output.d.ts +28 -0
  32. package/loaders/loader-output.js +122 -0
  33. package/loaders/loader-outputs.d.ts +55 -0
  34. package/loaders/loader-outputs.js +0 -0
  35. package/loaders/loox-review-aggregate-loader.d.ts +4 -1
  36. package/loaders/loox-review-aggregate-loader.js +5 -11
  37. package/loaders/loox-reviews-loader.d.ts +4 -1
  38. package/loaders/loox-reviews-loader.js +5 -9
  39. package/loaders/loyaltylion-earning-rules-loader.js +5 -11
  40. package/loaders/loyaltylion-points-for-price-loader.js +5 -11
  41. package/loaders/loyaltylion-rewards-loader.js +5 -9
  42. package/loaders/loyaltylion-tiers-loader.js +5 -9
  43. package/loaders/metaobject-loader.d.ts +4 -1
  44. package/loaders/metaobject-loader.js +2 -6
  45. package/loaders/metaobjects-loader.d.ts +4 -1
  46. package/loaders/metaobjects-loader.js +2 -6
  47. package/loaders/okendo-review-aggregate-loader.d.ts +4 -1
  48. package/loaders/okendo-review-aggregate-loader.js +5 -9
  49. package/loaders/okendo-reviews-loader.d.ts +4 -1
  50. package/loaders/okendo-reviews-loader.js +2 -6
  51. package/loaders/product-loader.d.ts +4 -1
  52. package/loaders/product-loader.js +2 -6
  53. package/loaders/rebuy-recommendations-loader.d.ts +4 -1
  54. package/loaders/rebuy-recommendations-loader.js +5 -9
  55. package/loaders/reviews-io-review-aggregate-loader.d.ts +4 -1
  56. package/loaders/reviews-io-review-aggregate-loader.js +2 -8
  57. package/loaders/reviews-io-reviews-loader.d.ts +4 -1
  58. package/loaders/reviews-io-reviews-loader.js +2 -8
  59. package/loaders/shopify-integration-details-loader.d.ts +4 -1
  60. package/loaders/shopify-integration-details-loader.js +5 -11
  61. package/loaders/smile-earning-rules-loader.d.ts +4 -1
  62. package/loaders/smile-earning-rules-loader.js +5 -9
  63. package/loaders/smile-rewards-loader.d.ts +4 -1
  64. package/loaders/smile-rewards-loader.js +5 -9
  65. package/loaders/smile-vip-tiers-loader.d.ts +4 -1
  66. package/loaders/smile-vip-tiers-loader.js +5 -9
  67. package/loaders/statsig-experiment-loader.d.ts +4 -1
  68. package/loaders/statsig-experiment-loader.js +2 -6
  69. package/loaders/yotpo-review-aggregate-loader.d.ts +4 -1
  70. package/loaders/yotpo-review-aggregate-loader.js +5 -11
  71. package/loaders/yotpo-reviews-loader.d.ts +4 -1
  72. package/loaders/yotpo-reviews-loader.js +2 -6
  73. package/package.json +4 -4
  74. package/size-budget/fixture/app/fixture-pdp/page.d.ts +1 -1
  75. package/size-budget/fixture/app/fixture-pdp/product-details.d.ts +1 -0
@@ -0,0 +1,122 @@
1
+ import * as z from "zod";
2
+ import { getCanopyApiGateway } from "../gateways/canopy-api";
3
+ import { CanopyError } from "../lib/canopy-error";
4
+ import {
5
+ okendoReviewAggregateOutputSchema,
6
+ okendoReviewsOutputSchema,
7
+ rebuyRecommendationsOutputSchema,
8
+ smileEarningRulesOutputSchema,
9
+ smileRewardsOutputSchema,
10
+ smileVipTiersOutputSchema
11
+ } from "./integration-loader-schemas";
12
+ import { DATA_LOADER_KEYS } from "./loader-keys";
13
+ import {
14
+ contentfulEntriesLoaderOutputSchema,
15
+ contentfulEntryLoaderOutputSchema,
16
+ fullCollectionSchema,
17
+ fullProductSchema,
18
+ judgemeProductReviewAggregateLoaderOutputSchema,
19
+ judgemeProductReviewsLoaderOutputSchema,
20
+ junipProductReviewAggregateLoaderOutputSchema,
21
+ junipProductReviewsLoaderOutputSchema,
22
+ levantaProductFullSchema,
23
+ looxProductReviewAggregateLoaderOutputSchema,
24
+ looxProductReviewsLoaderOutputSchema,
25
+ loyaltyLionEarningRulesLoaderOutputSchema,
26
+ loyaltyLionPointsForPriceLoaderOutputSchema,
27
+ loyaltyLionRewardsLoaderOutputSchema,
28
+ loyaltyLionTiersLoaderOutputSchema,
29
+ paginatedProductsSchema,
30
+ reviewsIoProductReviewAggregateLoaderOutputSchema,
31
+ reviewsIoProductReviewsLoaderOutputSchema,
32
+ shopifyIntegrationDetailsLoaderOutputSchema,
33
+ shopifyKachingBundlesLoaderOutputSchema,
34
+ shopifyMetaobjectLoaderOutputSchema,
35
+ shopifyMetaobjectsLoaderOutputSchema,
36
+ statsigExperimentLoaderOutputSchema,
37
+ yotpoProductReviewAggregateLoaderOutputSchema,
38
+ yotpoProductReviewsLoaderOutputSchema
39
+ } from "./loader-schemas";
40
+ const LOADER_OUTPUT_SCHEMAS = {
41
+ [DATA_LOADER_KEYS.SHOPIFY_INTEGRATION_DETAILS]: shopifyIntegrationDetailsLoaderOutputSchema,
42
+ [DATA_LOADER_KEYS.SHOPIFY_PRODUCT]: fullProductSchema,
43
+ [DATA_LOADER_KEYS.SHOPIFY_COLLECTION]: fullCollectionSchema,
44
+ [DATA_LOADER_KEYS.SHOPIFY_COLLECTION_PRODUCTS]: paginatedProductsSchema,
45
+ [DATA_LOADER_KEYS.SHOPIFY_METAOBJECT]: shopifyMetaobjectLoaderOutputSchema,
46
+ [DATA_LOADER_KEYS.SHOPIFY_METAOBJECTS]: shopifyMetaobjectsLoaderOutputSchema,
47
+ [DATA_LOADER_KEYS.SHOPIFY_KACHING_BUNDLES]: shopifyKachingBundlesLoaderOutputSchema,
48
+ [DATA_LOADER_KEYS.REPLO_PRODUCT]: fullProductSchema,
49
+ [DATA_LOADER_KEYS.OKENDO_PRODUCT_REVIEWS]: okendoReviewsOutputSchema,
50
+ [DATA_LOADER_KEYS.OKENDO_PRODUCT_REVIEW_AGGREGATE]: okendoReviewAggregateOutputSchema,
51
+ [DATA_LOADER_KEYS.REBUY_RECOMMENDATIONS]: rebuyRecommendationsOutputSchema,
52
+ [DATA_LOADER_KEYS.LEVANTA_PRODUCT]: levantaProductFullSchema,
53
+ [DATA_LOADER_KEYS.SMILE_IO_VIP_TIERS]: smileVipTiersOutputSchema,
54
+ [DATA_LOADER_KEYS.SMILE_IO_EARNING_RULES]: smileEarningRulesOutputSchema,
55
+ [DATA_LOADER_KEYS.SMILE_IO_REWARDS]: smileRewardsOutputSchema,
56
+ [DATA_LOADER_KEYS.LOYALTYLION_EARNING_RULES]: loyaltyLionEarningRulesLoaderOutputSchema,
57
+ [DATA_LOADER_KEYS.LOYALTYLION_REWARDS]: loyaltyLionRewardsLoaderOutputSchema,
58
+ [DATA_LOADER_KEYS.LOYALTYLION_TIERS]: loyaltyLionTiersLoaderOutputSchema,
59
+ [DATA_LOADER_KEYS.LOYALTYLION_POINTS_FOR_PRICE]: loyaltyLionPointsForPriceLoaderOutputSchema,
60
+ [DATA_LOADER_KEYS.YOTPO_PRODUCT_REVIEWS]: yotpoProductReviewsLoaderOutputSchema,
61
+ [DATA_LOADER_KEYS.YOTPO_PRODUCT_REVIEW_AGGREGATE]: yotpoProductReviewAggregateLoaderOutputSchema,
62
+ [DATA_LOADER_KEYS.REVIEWS_IO_PRODUCT_REVIEWS]: reviewsIoProductReviewsLoaderOutputSchema,
63
+ [DATA_LOADER_KEYS.REVIEWS_IO_PRODUCT_REVIEW_AGGREGATE]: reviewsIoProductReviewAggregateLoaderOutputSchema,
64
+ [DATA_LOADER_KEYS.LOOX_PRODUCT_REVIEWS]: looxProductReviewsLoaderOutputSchema,
65
+ [DATA_LOADER_KEYS.LOOX_PRODUCT_REVIEW_AGGREGATE]: looxProductReviewAggregateLoaderOutputSchema,
66
+ [DATA_LOADER_KEYS.JUDGEME_PRODUCT_REVIEWS]: judgemeProductReviewsLoaderOutputSchema,
67
+ [DATA_LOADER_KEYS.JUDGEME_PRODUCT_REVIEW_AGGREGATE]: judgemeProductReviewAggregateLoaderOutputSchema,
68
+ [DATA_LOADER_KEYS.JUNIP_PRODUCT_REVIEWS]: junipProductReviewsLoaderOutputSchema,
69
+ [DATA_LOADER_KEYS.JUNIP_PRODUCT_REVIEW_AGGREGATE]: junipProductReviewAggregateLoaderOutputSchema,
70
+ [DATA_LOADER_KEYS.STATSIG_EXPERIMENT]: statsigExperimentLoaderOutputSchema,
71
+ [DATA_LOADER_KEYS.CONTENTFUL_ENTRY]: contentfulEntryLoaderOutputSchema,
72
+ [DATA_LOADER_KEYS.CONTENTFUL_ENTRIES]: contentfulEntriesLoaderOutputSchema
73
+ };
74
+ const dataLoaderKeySchema = z.enum(DATA_LOADER_KEYS);
75
+ class LoaderOutputError extends CanopyError {
76
+ unvalidatedOutput;
77
+ constructor({
78
+ loaderKey,
79
+ unvalidatedOutput,
80
+ zodError
81
+ }) {
82
+ super({
83
+ message: `Loader ${loaderKey} returned data that does not match its output schema: ${zodError.message}`,
84
+ cause: zodError,
85
+ additionalData: { loaderKey }
86
+ });
87
+ this.unvalidatedOutput = unvalidatedOutput;
88
+ }
89
+ }
90
+ async function fetchValidatedLoaderOutput({
91
+ loaderKey,
92
+ args
93
+ }) {
94
+ const gateway = await getCanopyApiGateway();
95
+ const { data } = await gateway.invokeLoader({ loaderKey, args });
96
+ const knownKey = dataLoaderKeySchema.safeParse(loaderKey);
97
+ if (!knownKey.success) {
98
+ return data;
99
+ }
100
+ const result = LOADER_OUTPUT_SCHEMAS[knownKey.data].safeParse(data);
101
+ if (result.success) {
102
+ return result.data;
103
+ }
104
+ console.error(
105
+ `[Replo] Loader ${knownKey.data} returned data that does not match its output schema`,
106
+ {
107
+ loaderKey: knownKey.data,
108
+ issues: result.error.issues.map((issue) => {
109
+ return { path: issue.path.join("."), message: issue.message };
110
+ })
111
+ }
112
+ );
113
+ throw new LoaderOutputError({
114
+ loaderKey: knownKey.data,
115
+ unvalidatedOutput: data,
116
+ zodError: result.error
117
+ });
118
+ }
119
+ export {
120
+ LoaderOutputError,
121
+ fetchValidatedLoaderOutput
122
+ };
@@ -0,0 +1,55 @@
1
+ import type * as z from "zod";
2
+ import type { okendoReviewAggregateOutputSchema, okendoReviewsOutputSchema, rebuyRecommendationsOutputSchema, smileEarningRulesOutputSchema, smileRewardsOutputSchema, smileVipTiersOutputSchema } from "./integration-loader-schemas";
3
+ import type { DATA_LOADER_KEYS, DataLoaderKey } from "./loader-keys";
4
+ import type { ContentfulEntriesLoaderOutput, ContentfulEntryLoaderOutput, FullCollection, FullProduct, judgemeProductReviewAggregateLoaderOutputSchema, judgemeProductReviewsLoaderOutputSchema, junipProductReviewAggregateLoaderOutputSchema, junipProductReviewsLoaderOutputSchema, LevantaProductFull, looxProductReviewAggregateLoaderOutputSchema, looxProductReviewsLoaderOutputSchema, loyaltyLionEarningRulesLoaderOutputSchema, loyaltyLionPointsForPriceLoaderOutputSchema, loyaltyLionRewardsLoaderOutputSchema, loyaltyLionTiersLoaderOutputSchema, PaginatedProducts, reviewsIoProductReviewAggregateLoaderOutputSchema, reviewsIoProductReviewsLoaderOutputSchema, ShopifyIntegrationDetails, ShopifyKachingBundlesLoaderOutput, ShopifyMetaobjectLoaderOutput, ShopifyMetaobjectsLoaderOutput, StatsigExperimentAssignment, yotpoProductReviewAggregateLoaderOutputSchema, yotpoProductReviewsLoaderOutputSchema } from "./loader-schemas";
5
+ type LoaderOutputByKeyName = {
6
+ SHOPIFY_INTEGRATION_DETAILS: ShopifyIntegrationDetails;
7
+ SHOPIFY_PRODUCT: FullProduct;
8
+ SHOPIFY_COLLECTION: FullCollection;
9
+ SHOPIFY_COLLECTION_PRODUCTS: PaginatedProducts;
10
+ SHOPIFY_METAOBJECT: ShopifyMetaobjectLoaderOutput;
11
+ SHOPIFY_METAOBJECTS: ShopifyMetaobjectsLoaderOutput;
12
+ SHOPIFY_KACHING_BUNDLES: ShopifyKachingBundlesLoaderOutput;
13
+ REPLO_PRODUCT: FullProduct;
14
+ OKENDO_PRODUCT_REVIEWS: z.infer<typeof okendoReviewsOutputSchema>;
15
+ OKENDO_PRODUCT_REVIEW_AGGREGATE: z.infer<typeof okendoReviewAggregateOutputSchema>;
16
+ REBUY_RECOMMENDATIONS: z.infer<typeof rebuyRecommendationsOutputSchema>;
17
+ LEVANTA_PRODUCT: LevantaProductFull;
18
+ SMILE_IO_VIP_TIERS: z.infer<typeof smileVipTiersOutputSchema>;
19
+ SMILE_IO_EARNING_RULES: z.infer<typeof smileEarningRulesOutputSchema>;
20
+ SMILE_IO_REWARDS: z.infer<typeof smileRewardsOutputSchema>;
21
+ LOYALTYLION_EARNING_RULES: z.infer<typeof loyaltyLionEarningRulesLoaderOutputSchema>;
22
+ LOYALTYLION_REWARDS: z.infer<typeof loyaltyLionRewardsLoaderOutputSchema>;
23
+ LOYALTYLION_TIERS: z.infer<typeof loyaltyLionTiersLoaderOutputSchema>;
24
+ LOYALTYLION_POINTS_FOR_PRICE: z.infer<typeof loyaltyLionPointsForPriceLoaderOutputSchema>;
25
+ YOTPO_PRODUCT_REVIEWS: z.infer<typeof yotpoProductReviewsLoaderOutputSchema>;
26
+ YOTPO_PRODUCT_REVIEW_AGGREGATE: z.infer<typeof yotpoProductReviewAggregateLoaderOutputSchema>;
27
+ REVIEWS_IO_PRODUCT_REVIEWS: z.infer<typeof reviewsIoProductReviewsLoaderOutputSchema>;
28
+ REVIEWS_IO_PRODUCT_REVIEW_AGGREGATE: z.infer<typeof reviewsIoProductReviewAggregateLoaderOutputSchema>;
29
+ LOOX_PRODUCT_REVIEWS: z.infer<typeof looxProductReviewsLoaderOutputSchema>;
30
+ LOOX_PRODUCT_REVIEW_AGGREGATE: z.infer<typeof looxProductReviewAggregateLoaderOutputSchema>;
31
+ JUDGEME_PRODUCT_REVIEWS: z.infer<typeof judgemeProductReviewsLoaderOutputSchema>;
32
+ JUDGEME_PRODUCT_REVIEW_AGGREGATE: z.infer<typeof judgemeProductReviewAggregateLoaderOutputSchema>;
33
+ JUNIP_PRODUCT_REVIEWS: z.infer<typeof junipProductReviewsLoaderOutputSchema>;
34
+ JUNIP_PRODUCT_REVIEW_AGGREGATE: z.infer<typeof junipProductReviewAggregateLoaderOutputSchema>;
35
+ STATSIG_EXPERIMENT: StatsigExperimentAssignment;
36
+ CONTENTFUL_ENTRY: ContentfulEntryLoaderOutput;
37
+ CONTENTFUL_ENTRIES: ContentfulEntriesLoaderOutput;
38
+ };
39
+ /**
40
+ * The output type of each loader key. The server validates output against the
41
+ * schema registered for the same key (`loader-output.ts`), which is typed from
42
+ * this map, so the browser and the server share one contract.
43
+ */
44
+ export type LoaderOutputByKey = {
45
+ [Name in keyof typeof DATA_LOADER_KEYS as (typeof DATA_LOADER_KEYS)[Name]]: LoaderOutputByKeyName[Name];
46
+ };
47
+ export type LoaderOutput<Key extends DataLoaderKey> = LoaderOutputByKey[Key];
48
+ /**
49
+ * A loader component's `loaderKey` prop: the keys it supports, for
50
+ * autocomplete, plus any string, so a site that forwards a plain `string` keeps
51
+ * type-checking. A mismatched key is caught at runtime instead and renders the
52
+ * component's fallback.
53
+ */
54
+ export type LoaderKeyProp<Key extends DataLoaderKey> = Key | (string & Record<never, never>);
55
+ export {};
File without changes
@@ -1,9 +1,12 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type { z } from "zod";
3
+ import type { DATA_LOADER_KEYS } from "./loader-keys";
4
+ import type { LoaderKeyProp } from "./loader-outputs";
3
5
  import type { looxProductReviewAggregateLoaderOutputSchema } from "./loader-schemas";
6
+ type LoaderKey = (typeof DATA_LOADER_KEYS)["LOOX_PRODUCT_REVIEW_AGGREGATE"];
4
7
  type LooxReviewAggregateData = z.infer<typeof looxProductReviewAggregateLoaderOutputSchema>;
5
8
  type LooxReviewAggregateLoaderProps = {
6
- loaderKey: string;
9
+ loaderKey: LoaderKeyProp<LoaderKey>;
7
10
  shopifyProductId: string;
8
11
  children: (data: LooxReviewAggregateData) => ReactNode;
9
12
  fallback?: ReactNode;
@@ -11,17 +11,11 @@ function LooxReviewAggregateLoaderInner({
11
11
  }) {
12
12
  const queryResult = useSuspenseQuery({
13
13
  queryKey: [loaderKey, { shopifyProductId }],
14
- queryFn: async () => {
15
- const [loadedData, schemas] = await Promise.all([
16
- invokeLoader({
17
- loaderKey,
18
- args: { shopifyProductId }
19
- }),
20
- import("./loader-schemas")
21
- ]);
22
- return schemas.looxProductReviewAggregateLoaderOutputSchema.parse(
23
- loadedData
24
- );
14
+ queryFn: () => {
15
+ return invokeLoader({
16
+ loaderKey,
17
+ args: { shopifyProductId }
18
+ });
25
19
  }
26
20
  });
27
21
  return /* @__PURE__ */ jsx(Fragment, { children: children(queryResult.data) });
@@ -1,9 +1,12 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type { z } from "zod";
3
+ import type { DATA_LOADER_KEYS } from "./loader-keys";
4
+ import type { LoaderKeyProp } from "./loader-outputs";
3
5
  import type { looxProductReviewsLoaderOutputSchema } from "./loader-schemas";
6
+ type LoaderKey = (typeof DATA_LOADER_KEYS)["LOOX_PRODUCT_REVIEWS"];
4
7
  type LooxReviewsData = z.infer<typeof looxProductReviewsLoaderOutputSchema>;
5
8
  type LooxReviewsLoaderProps = {
6
- loaderKey: string;
9
+ loaderKey: LoaderKeyProp<LoaderKey>;
7
10
  shopifyProductId: string;
8
11
  children: (data: LooxReviewsData) => ReactNode;
9
12
  fallback?: ReactNode;
@@ -11,15 +11,11 @@ function LooxReviewsLoaderInner({
11
11
  }) {
12
12
  const queryResult = useSuspenseQuery({
13
13
  queryKey: [loaderKey, { shopifyProductId }],
14
- queryFn: async () => {
15
- const [loadedData, schemas] = await Promise.all([
16
- invokeLoader({
17
- loaderKey,
18
- args: { shopifyProductId }
19
- }),
20
- import("./loader-schemas")
21
- ]);
22
- return schemas.looxProductReviewsLoaderOutputSchema.parse(loadedData);
14
+ queryFn: () => {
15
+ return invokeLoader({
16
+ loaderKey,
17
+ args: { shopifyProductId }
18
+ });
23
19
  }
24
20
  });
25
21
  return /* @__PURE__ */ jsx(Fragment, { children: children(queryResult.data) });
@@ -11,17 +11,11 @@ function LoyaltyLionEarningRulesLoaderInner({
11
11
  }) {
12
12
  const { data } = useSuspenseQuery({
13
13
  queryKey: [loaderKey, {}],
14
- queryFn: async () => {
15
- const [loadedData, schemas] = await Promise.all([
16
- invokeLoader({
17
- loaderKey,
18
- args: {}
19
- }),
20
- import("./loader-schemas")
21
- ]);
22
- return schemas.loyaltyLionEarningRulesLoaderOutputSchema.parse(
23
- loadedData
24
- );
14
+ queryFn: () => {
15
+ return invokeLoader({
16
+ loaderKey,
17
+ args: {}
18
+ });
25
19
  }
26
20
  });
27
21
  return /* @__PURE__ */ jsx(Fragment, { children: children(data) });
@@ -12,17 +12,11 @@ function LoyaltyLionPointsForPriceLoaderInner({
12
12
  }) {
13
13
  const { data } = useSuspenseQuery({
14
14
  queryKey: [loaderKey, { price }],
15
- queryFn: async () => {
16
- const [loadedData, schemas] = await Promise.all([
17
- invokeLoader({
18
- loaderKey,
19
- args: { price }
20
- }),
21
- import("./loader-schemas")
22
- ]);
23
- return schemas.loyaltyLionPointsForPriceLoaderOutputSchema.parse(
24
- loadedData
25
- );
15
+ queryFn: () => {
16
+ return invokeLoader({
17
+ loaderKey,
18
+ args: { price }
19
+ });
26
20
  }
27
21
  });
28
22
  return /* @__PURE__ */ jsx(Fragment, { children: children(data) });
@@ -11,15 +11,11 @@ function LoyaltyLionRewardsLoaderInner({
11
11
  }) {
12
12
  const { data } = useSuspenseQuery({
13
13
  queryKey: [loaderKey, {}],
14
- queryFn: async () => {
15
- const [loadedData, schemas] = await Promise.all([
16
- invokeLoader({
17
- loaderKey,
18
- args: {}
19
- }),
20
- import("./loader-schemas")
21
- ]);
22
- return schemas.loyaltyLionRewardsLoaderOutputSchema.parse(loadedData);
14
+ queryFn: () => {
15
+ return invokeLoader({
16
+ loaderKey,
17
+ args: {}
18
+ });
23
19
  }
24
20
  });
25
21
  return /* @__PURE__ */ jsx(Fragment, { children: children(data) });
@@ -11,15 +11,11 @@ function LoyaltyLionTiersLoaderInner({
11
11
  }) {
12
12
  const { data } = useSuspenseQuery({
13
13
  queryKey: [loaderKey, {}],
14
- queryFn: async () => {
15
- const [loadedData, schemas] = await Promise.all([
16
- invokeLoader({
17
- loaderKey,
18
- args: {}
19
- }),
20
- import("./loader-schemas")
21
- ]);
22
- return schemas.loyaltyLionTiersLoaderOutputSchema.parse(loadedData);
14
+ queryFn: () => {
15
+ return invokeLoader({
16
+ loaderKey,
17
+ args: {}
18
+ });
23
19
  }
24
20
  });
25
21
  return /* @__PURE__ */ jsx(Fragment, { children: children(data) });
@@ -1,7 +1,10 @@
1
1
  import type { ReactNode } from "react";
2
+ import type { DATA_LOADER_KEYS } from "./loader-keys";
3
+ import type { LoaderKeyProp } from "./loader-outputs";
2
4
  import type { ShopifyMetaobjectLoaderOutput } from "./loader-schemas";
5
+ type LoaderKey = (typeof DATA_LOADER_KEYS)["SHOPIFY_METAOBJECT"];
3
6
  type MetaobjectLoaderProps = {
4
- loaderKey: string;
7
+ loaderKey: LoaderKeyProp<LoaderKey>;
5
8
  type?: string;
6
9
  handle?: string;
7
10
  id?: string;
@@ -22,12 +22,8 @@ function MetaobjectLoaderInner({
22
22
  }) {
23
23
  const { data } = useSuspenseQuery({
24
24
  queryKey: [loaderKey, args],
25
- queryFn: async () => {
26
- const [loadedData, schemas] = await Promise.all([
27
- invokeLoader({ loaderKey, args }),
28
- import("./loader-schemas")
29
- ]);
30
- return schemas.shopifyMetaobjectLoaderOutputSchema.parse(loadedData);
25
+ queryFn: () => {
26
+ return invokeLoader({ loaderKey, args });
31
27
  }
32
28
  });
33
29
  return /* @__PURE__ */ jsx(Fragment, { children: children(data) });
@@ -1,7 +1,10 @@
1
1
  import type { ReactNode } from "react";
2
+ import type { DATA_LOADER_KEYS } from "./loader-keys";
3
+ import type { LoaderKeyProp } from "./loader-outputs";
2
4
  import type { ShopifyMetaobjectsLoaderOutput } from "./loader-schemas";
5
+ type LoaderKey = (typeof DATA_LOADER_KEYS)["SHOPIFY_METAOBJECTS"];
3
6
  type MetaobjectsLoaderProps = {
4
- loaderKey: string;
7
+ loaderKey: LoaderKeyProp<LoaderKey>;
5
8
  type: string;
6
9
  first?: number;
7
10
  after?: string;
@@ -26,12 +26,8 @@ function MetaobjectsLoaderInner({
26
26
  }) {
27
27
  const { data } = useSuspenseQuery({
28
28
  queryKey: [loaderKey, args],
29
- queryFn: async () => {
30
- const [loadedData, schemas] = await Promise.all([
31
- invokeLoader({ loaderKey, args }),
32
- import("./loader-schemas")
33
- ]);
34
- return schemas.shopifyMetaobjectsLoaderOutputSchema.parse(loadedData);
29
+ queryFn: () => {
30
+ return invokeLoader({ loaderKey, args });
35
31
  }
36
32
  });
37
33
  return /* @__PURE__ */ jsx(Fragment, { children: children(data) });
@@ -1,9 +1,12 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type { z } from "zod";
3
3
  import type { okendoReviewAggregateOutputSchema } from "./integration-loader-schemas";
4
+ import type { DATA_LOADER_KEYS } from "./loader-keys";
5
+ import type { LoaderKeyProp } from "./loader-outputs";
6
+ type LoaderKey = (typeof DATA_LOADER_KEYS)["OKENDO_PRODUCT_REVIEW_AGGREGATE"];
4
7
  type OkendoReviewAggregateData = z.infer<typeof okendoReviewAggregateOutputSchema>;
5
8
  type OkendoReviewAggregateLoaderProps = {
6
- loaderKey: string;
9
+ loaderKey: LoaderKeyProp<LoaderKey>;
7
10
  shopifyProductId: string;
8
11
  children: (data: OkendoReviewAggregateData) => ReactNode;
9
12
  fallback?: ReactNode;
@@ -11,15 +11,11 @@ function OkendoReviewAggregateLoaderInner({
11
11
  }) {
12
12
  const queryResult = useSuspenseQuery({
13
13
  queryKey: [loaderKey, { shopifyProductId }],
14
- queryFn: async () => {
15
- const [loadedData, schemas] = await Promise.all([
16
- invokeLoader({
17
- loaderKey,
18
- args: { shopifyProductId }
19
- }),
20
- import("./integration-loader-schemas")
21
- ]);
22
- return schemas.okendoReviewAggregateOutputSchema.parse(loadedData);
14
+ queryFn: () => {
15
+ return invokeLoader({
16
+ loaderKey,
17
+ args: { shopifyProductId }
18
+ });
23
19
  }
24
20
  });
25
21
  return /* @__PURE__ */ jsx(Fragment, { children: children(queryResult.data) });
@@ -1,11 +1,14 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type { z } from "zod";
3
3
  import type { okendoReviewsOutputSchema } from "./integration-loader-schemas";
4
+ import type { DATA_LOADER_KEYS } from "./loader-keys";
5
+ import type { LoaderKeyProp } from "./loader-outputs";
6
+ type LoaderKey = (typeof DATA_LOADER_KEYS)["OKENDO_PRODUCT_REVIEWS"];
4
7
  type OkendoReviewsData = z.infer<typeof okendoReviewsOutputSchema>;
5
8
  /** Sort orders Okendo supports; `has_media desc` puts reviews with photos or videos first. */
6
9
  export type OkendoReviewOrder = "date desc" | "date asc" | "rating desc" | "rating asc" | "helpful desc" | "has_media desc";
7
10
  type OkendoReviewsLoaderProps = {
8
- loaderKey: string;
11
+ loaderKey: LoaderKeyProp<LoaderKey>;
9
12
  shopifyProductId: string;
10
13
  /** Reviews per page, 1-100 (Okendo's default is 25) */
11
14
  limit?: number;
@@ -15,12 +15,8 @@ function OkendoReviewsLoaderInner({
15
15
  const args = { shopifyProductId, limit, orderBy, cursor };
16
16
  const queryResult = useSuspenseQuery({
17
17
  queryKey: [loaderKey, args],
18
- queryFn: async () => {
19
- const [loadedData, schemas] = await Promise.all([
20
- invokeLoader({ loaderKey, args }),
21
- import("./integration-loader-schemas")
22
- ]);
23
- return schemas.okendoReviewsOutputSchema.parse(loadedData);
18
+ queryFn: () => {
19
+ return invokeLoader({ loaderKey, args });
24
20
  }
25
21
  });
26
22
  return /* @__PURE__ */ jsx(Fragment, { children: children(queryResult.data) });
@@ -1,8 +1,11 @@
1
1
  import type { ReactNode } from "react";
2
+ import type { DATA_LOADER_KEYS } from "./loader-keys";
3
+ import type { LoaderKeyProp } from "./loader-outputs";
2
4
  import type { FullProduct } from "./loader-schemas";
3
5
  import type { ProductLoaderArgs } from "./product-loader-args";
6
+ type LoaderKey = (typeof DATA_LOADER_KEYS)["SHOPIFY_PRODUCT" | "REPLO_PRODUCT"];
4
7
  type ProductLoaderProps = ProductLoaderArgs & {
5
- loaderKey: string;
8
+ loaderKey: LoaderKeyProp<LoaderKey>;
6
9
  children: (data: FullProduct) => ReactNode;
7
10
  fallback?: ReactNode;
8
11
  loadingFallback?: ReactNode;
@@ -13,12 +13,8 @@ function ProductLoaderInner({
13
13
  }) {
14
14
  const queryResult = useSuspenseQuery({
15
15
  queryKey: [loaderKey, args],
16
- queryFn: async () => {
17
- const [loadedData, schemas] = await Promise.all([
18
- invokeLoader({ loaderKey, args }),
19
- import("./loader-schemas")
20
- ]);
21
- return schemas.fullProductSchema.parse(loadedData);
16
+ queryFn: () => {
17
+ return invokeLoader({ loaderKey, args });
22
18
  }
23
19
  });
24
20
  useReportPreviewPlaceholderRender(queryResult.data);
@@ -1,9 +1,12 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type { z } from "zod";
3
3
  import type { rebuyRecommendationsOutputSchema } from "./integration-loader-schemas";
4
+ import type { DATA_LOADER_KEYS } from "./loader-keys";
5
+ import type { LoaderKeyProp } from "./loader-outputs";
6
+ type LoaderKey = (typeof DATA_LOADER_KEYS)["REBUY_RECOMMENDATIONS"];
4
7
  type RebuyRecommendationsData = z.infer<typeof rebuyRecommendationsOutputSchema>;
5
8
  type RebuyRecommendationsLoaderProps = {
6
- loaderKey: string;
9
+ loaderKey: LoaderKeyProp<LoaderKey>;
7
10
  shopifyProductIds: string;
8
11
  limit?: number;
9
12
  children: (data: RebuyRecommendationsData) => ReactNode;
@@ -12,15 +12,11 @@ function RebuyRecommendationsLoaderInner({
12
12
  }) {
13
13
  const queryResult = useSuspenseQuery({
14
14
  queryKey: [loaderKey, { shopifyProductIds, limit }],
15
- queryFn: async () => {
16
- const [loadedData, schemas] = await Promise.all([
17
- invokeLoader({
18
- loaderKey,
19
- args: { shopifyProductIds, limit }
20
- }),
21
- import("./integration-loader-schemas")
22
- ]);
23
- return schemas.rebuyRecommendationsOutputSchema.parse(loadedData);
15
+ queryFn: () => {
16
+ return invokeLoader({
17
+ loaderKey,
18
+ args: { shopifyProductIds, limit }
19
+ });
24
20
  }
25
21
  });
26
22
  return /* @__PURE__ */ jsx(Fragment, { children: children(queryResult.data) });
@@ -1,9 +1,12 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type { z } from "zod";
3
+ import type { DATA_LOADER_KEYS } from "./loader-keys";
4
+ import type { LoaderKeyProp } from "./loader-outputs";
3
5
  import type { reviewsIoProductReviewAggregateLoaderOutputSchema } from "./loader-schemas";
6
+ type LoaderKey = (typeof DATA_LOADER_KEYS)["REVIEWS_IO_PRODUCT_REVIEW_AGGREGATE"];
4
7
  type ReviewsIoReviewAggregateData = z.infer<typeof reviewsIoProductReviewAggregateLoaderOutputSchema>;
5
8
  type ReviewsIoReviewAggregateLoaderProps = {
6
- loaderKey: string;
9
+ loaderKey: LoaderKeyProp<LoaderKey>;
7
10
  sku: string;
8
11
  children: (data: ReviewsIoReviewAggregateData) => ReactNode;
9
12
  fallback?: ReactNode;
@@ -12,14 +12,8 @@ function ReviewsIoReviewAggregateLoaderInner({
12
12
  const args = { sku };
13
13
  const { data } = useSuspenseQuery({
14
14
  queryKey: [loaderKey, args],
15
- queryFn: async () => {
16
- const [loadedData, schemas] = await Promise.all([
17
- invokeLoader({ loaderKey, args }),
18
- import("./loader-schemas")
19
- ]);
20
- return schemas.reviewsIoProductReviewAggregateLoaderOutputSchema.parse(
21
- loadedData
22
- );
15
+ queryFn: () => {
16
+ return invokeLoader({ loaderKey, args });
23
17
  }
24
18
  });
25
19
  return /* @__PURE__ */ jsx(Fragment, { children: children(data) });
@@ -1,9 +1,12 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type { z } from "zod";
3
+ import type { DATA_LOADER_KEYS } from "./loader-keys";
4
+ import type { LoaderKeyProp } from "./loader-outputs";
3
5
  import type { reviewsIoProductReviewsLoaderOutputSchema } from "./loader-schemas";
6
+ type LoaderKey = (typeof DATA_LOADER_KEYS)["REVIEWS_IO_PRODUCT_REVIEWS"];
4
7
  type ReviewsIoReviewsData = z.infer<typeof reviewsIoProductReviewsLoaderOutputSchema>;
5
8
  type ReviewsIoReviewsLoaderProps = {
6
- loaderKey: string;
9
+ loaderKey: LoaderKeyProp<LoaderKey>;
7
10
  sku: string;
8
11
  perPage?: number;
9
12
  page?: number;
@@ -25,14 +25,8 @@ function ReviewsIoReviewsLoaderInner({
25
25
  const args = buildReviewsArgs({ sku, perPage, page });
26
26
  const { data } = useSuspenseQuery({
27
27
  queryKey: [loaderKey, args],
28
- queryFn: async () => {
29
- const [loadedData, schemas] = await Promise.all([
30
- invokeLoader({ loaderKey, args }),
31
- import("./loader-schemas")
32
- ]);
33
- return schemas.reviewsIoProductReviewsLoaderOutputSchema.parse(
34
- loadedData
35
- );
28
+ queryFn: () => {
29
+ return invokeLoader({ loaderKey, args });
36
30
  }
37
31
  });
38
32
  return /* @__PURE__ */ jsx(Fragment, { children: children(data) });
@@ -1,7 +1,10 @@
1
1
  import type { ReactNode } from "react";
2
+ import type { DATA_LOADER_KEYS } from "./loader-keys";
3
+ import type { LoaderKeyProp } from "./loader-outputs";
2
4
  import type { ShopifyIntegrationDetails } from "./loader-schemas";
5
+ type LoaderKey = (typeof DATA_LOADER_KEYS)["SHOPIFY_INTEGRATION_DETAILS"];
3
6
  type ShopifyIntegrationDetailsLoaderProps = {
4
- loaderKey: string;
7
+ loaderKey: LoaderKeyProp<LoaderKey>;
5
8
  children: (data: ShopifyIntegrationDetails) => ReactNode;
6
9
  fallback?: ReactNode;
7
10
  };
@@ -10,17 +10,11 @@ function ShopifyIntegrationDetailsLoaderInner({
10
10
  }) {
11
11
  const { data } = useSuspenseQuery({
12
12
  queryKey: [loaderKey, {}],
13
- queryFn: async () => {
14
- const [loadedData, schemas] = await Promise.all([
15
- invokeLoader({
16
- loaderKey,
17
- args: {}
18
- }),
19
- import("./loader-schemas")
20
- ]);
21
- return schemas.shopifyIntegrationDetailsLoaderOutputSchema.parse(
22
- loadedData
23
- );
13
+ queryFn: () => {
14
+ return invokeLoader({
15
+ loaderKey,
16
+ args: {}
17
+ });
24
18
  }
25
19
  });
26
20
  return /* @__PURE__ */ jsx(Fragment, { children: children(data) });