@decocms/apps-vtex 8.0.0 → 8.1.0-next.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 (133) hide show
  1. package/package.json +7 -52
  2. package/src/index.ts +12 -15
  3. package/src/utils/constants.ts +2 -56
  4. package/src/utils/cookieSanitizer.ts +59 -59
  5. package/src/utils/operationRouter.ts +76 -72
  6. package/src/utils/types.ts +709 -1557
  7. package/src/vtexClient.ts +444 -0
  8. package/src/README.md +0 -6
  9. package/src/__tests__/client-segment-cookie.test.ts +0 -255
  10. package/src/__tests__/client-set-cookie-forward.test.ts +0 -257
  11. package/src/__tests__/schemas.test.ts +0 -71
  12. package/src/actions/address.ts +0 -250
  13. package/src/actions/analytics/sendEvent.ts +0 -86
  14. package/src/actions/auth.ts +0 -333
  15. package/src/actions/checkout.ts +0 -659
  16. package/src/actions/index.ts +0 -11
  17. package/src/actions/masterData.ts +0 -168
  18. package/src/actions/misc.ts +0 -188
  19. package/src/actions/newsletter.ts +0 -105
  20. package/src/actions/orders.ts +0 -34
  21. package/src/actions/profile.ts +0 -201
  22. package/src/actions/session.ts +0 -85
  23. package/src/actions/trigger.ts +0 -43
  24. package/src/actions/wishlist.ts +0 -114
  25. package/src/client.ts +0 -667
  26. package/src/commerceLoaders.ts +0 -267
  27. package/src/hooks/__tests__/createCart.render.test.ts +0 -114
  28. package/src/hooks/__tests__/createCart.test.ts +0 -92
  29. package/src/hooks/__tests__/createUseCart.test.ts +0 -184
  30. package/src/hooks/__tests__/createUseUser.test.ts +0 -48
  31. package/src/hooks/__tests__/createUseWishlist.test.ts +0 -87
  32. package/src/hooks/cartQuery.ts +0 -204
  33. package/src/hooks/createCart.ts +0 -427
  34. package/src/hooks/createUseCart.ts +0 -360
  35. package/src/hooks/createUseUser.ts +0 -153
  36. package/src/hooks/createUseWishlist.ts +0 -242
  37. package/src/hooks/index.ts +0 -25
  38. package/src/hooks/useAutocomplete.ts +0 -83
  39. package/src/hooks/useCart.ts +0 -243
  40. package/src/hooks/useUser.ts +0 -78
  41. package/src/hooks/useWishlist.ts +0 -119
  42. package/src/invoke.ts +0 -235
  43. package/src/loaders/ProductDetailsPage.ts +0 -1
  44. package/src/loaders/ProductList.ts +0 -1
  45. package/src/loaders/ProductListingPage.ts +0 -1
  46. package/src/loaders/address.ts +0 -115
  47. package/src/loaders/autocomplete.ts +0 -58
  48. package/src/loaders/brands.ts +0 -44
  49. package/src/loaders/cart/attachments.ts +0 -53
  50. package/src/loaders/cart/full.ts +0 -67
  51. package/src/loaders/cart/gifts.ts +0 -43
  52. package/src/loaders/cart/orderFormId.ts +0 -31
  53. package/src/loaders/cart/shipping.test.ts +0 -125
  54. package/src/loaders/cart/shipping.ts +0 -136
  55. package/src/loaders/cart/summary.ts +0 -36
  56. package/src/loaders/cart.ts +0 -52
  57. package/src/loaders/catalog.ts +0 -163
  58. package/src/loaders/collections.ts +0 -55
  59. package/src/loaders/index.ts +0 -20
  60. package/src/loaders/intelligentSearch/__tests__/productListingPage.test.ts +0 -51
  61. package/src/loaders/intelligentSearch/productDetailsPage.ts +0 -113
  62. package/src/loaders/intelligentSearch/productList.ts +0 -154
  63. package/src/loaders/intelligentSearch/productListingPage.ts +0 -526
  64. package/src/loaders/intelligentSearch/suggestions.ts +0 -46
  65. package/src/loaders/legacy/productDetailsPage.ts +0 -1
  66. package/src/loaders/legacy/productList.ts +0 -1
  67. package/src/loaders/legacy/relatedProductsLoader.ts +0 -81
  68. package/src/loaders/legacy.ts +0 -635
  69. package/src/loaders/logistics.ts +0 -111
  70. package/src/loaders/minicart.ts +0 -78
  71. package/src/loaders/navbar.ts +0 -26
  72. package/src/loaders/orders.ts +0 -92
  73. package/src/loaders/pageType.ts +0 -68
  74. package/src/loaders/paths/PDPDefaultPath.ts +0 -51
  75. package/src/loaders/payment.ts +0 -97
  76. package/src/loaders/productListFull.ts +0 -159
  77. package/src/loaders/profile.ts +0 -138
  78. package/src/loaders/promotion.ts +0 -30
  79. package/src/loaders/search.ts +0 -124
  80. package/src/loaders/session.ts +0 -83
  81. package/src/loaders/user.ts +0 -87
  82. package/src/loaders/wishlist.ts +0 -89
  83. package/src/loaders/wishlistProducts.ts +0 -69
  84. package/src/loaders/workflow/products.ts +0 -64
  85. package/src/loaders/workflow.ts +0 -316
  86. package/src/logo.png +0 -0
  87. package/src/manifest.gen.ts +0 -89
  88. package/src/middleware.ts +0 -240
  89. package/src/mod.ts +0 -157
  90. package/src/registry.ts +0 -9
  91. package/src/schemas.gen.ts +0 -3191
  92. package/src/schemas.ts +0 -30
  93. package/src/types.ts +0 -248
  94. package/src/utils/__tests__/cartProjection.test.ts +0 -118
  95. package/src/utils/__tests__/cookieSanitizer.test.ts +0 -162
  96. package/src/utils/__tests__/fetch.test.ts +0 -80
  97. package/src/utils/__tests__/fetchCache.test.ts +0 -155
  98. package/src/utils/__tests__/instrumentedFetch.test.ts +0 -158
  99. package/src/utils/__tests__/intelligentSearch.test.ts +0 -88
  100. package/src/utils/__tests__/minicart.test.ts +0 -184
  101. package/src/utils/__tests__/operationRouter.test.ts +0 -227
  102. package/src/utils/__tests__/resilience.test.ts +0 -205
  103. package/src/utils/__tests__/resourceRange.test.ts +0 -32
  104. package/src/utils/__tests__/simulationCache.test.ts +0 -40
  105. package/src/utils/__tests__/sitemap.test.ts +0 -185
  106. package/src/utils/__tests__/slugify.test.ts +0 -31
  107. package/src/utils/__tests__/transform.test.ts +0 -769
  108. package/src/utils/accountLoaders.ts +0 -203
  109. package/src/utils/authHelpers.ts +0 -85
  110. package/src/utils/batch.ts +0 -18
  111. package/src/utils/cartProjection.ts +0 -96
  112. package/src/utils/cookies.ts +0 -167
  113. package/src/utils/enrichment.ts +0 -560
  114. package/src/utils/fetch.ts +0 -107
  115. package/src/utils/fetchCache.ts +0 -199
  116. package/src/utils/index.ts +0 -19
  117. package/src/utils/instrumentedFetch.ts +0 -97
  118. package/src/utils/intelligentSearch.ts +0 -96
  119. package/src/utils/legacy.ts +0 -139
  120. package/src/utils/minicart.ts +0 -139
  121. package/src/utils/pickAndOmit.ts +0 -25
  122. package/src/utils/proxy.ts +0 -435
  123. package/src/utils/resilience.ts +0 -352
  124. package/src/utils/resourceRange.ts +0 -10
  125. package/src/utils/segment.ts +0 -152
  126. package/src/utils/similars.ts +0 -37
  127. package/src/utils/simulationCache.ts +0 -73
  128. package/src/utils/sitemap.ts +0 -282
  129. package/src/utils/slugCache.ts +0 -28
  130. package/src/utils/slugify.ts +0 -13
  131. package/src/utils/transform.ts +0 -1522
  132. package/src/utils/vtexId.ts +0 -138
  133. package/tsconfig.json +0 -7
package/src/mod.ts DELETED
@@ -1,157 +0,0 @@
1
- /**
2
- * VTEX app module — standard autoconfig contract.
3
- *
4
- * Exports `configure` following the AppModContract pattern.
5
- * The framework's `autoconfigApps()` calls these generically.
6
- *
7
- * @example
8
- * ```ts
9
- * import * as vtexApp from "@decocms/apps/vtex/mod";
10
- *
11
- * const app = await vtexApp.configure(blocks.vtex, resolveSecret);
12
- * if (app) {
13
- * // app.manifest, app.state, app.middleware are available
14
- * }
15
- * ```
16
- */
17
-
18
- import type { AppDefinition, AppMiddleware, ResolveSecretFn } from "@decocms/apps-commerce/app-types";
19
- import type { Secret } from "@decocms/apps-website/mod";
20
- import { configureVtex, type VtexConfig } from "./client";
21
- import manifest from "./manifest.gen";
22
- import { extractVtexContext, propagateISCookies, vtexCacheControl } from "./middleware";
23
- import { registerVtexSchemas } from "./schemas";
24
-
25
- // -------------------------------------------------------------------------
26
- // CMS Props (mirrors deco-cx/apps/vtex/mod.ts)
27
- // -------------------------------------------------------------------------
28
-
29
- /** @title VTEX */
30
- export interface Props {
31
- /**
32
- * @description VTEX Account name
33
- */
34
- account: string;
35
-
36
- /**
37
- * @title Public store URL
38
- * @description Domain registered on License Manager (e.g. secure.mystore.com.br)
39
- */
40
- publicUrl: string;
41
-
42
- /** @title App Key */
43
- appKey?: Secret;
44
-
45
- /**
46
- * @title App Token
47
- * @format password
48
- */
49
- appToken?: Secret;
50
-
51
- /**
52
- * @title Default Sales Channel
53
- * @deprecated
54
- */
55
- salesChannel?: string;
56
-
57
- /**
58
- * @title Set Refresh Token
59
- * @default false
60
- */
61
- setRefreshToken?: boolean;
62
-
63
- defaultSegment?: Record<string, unknown>;
64
-
65
- usePortalSitemap?: boolean;
66
-
67
- /**
68
- * @hide true
69
- * @default vtex
70
- */
71
- platform?: "vtex";
72
-
73
- advancedConfigs?: {
74
- doNotFetchVariantsForRelatedProducts?: boolean;
75
- removeUTMFromCacheKey?: boolean;
76
- };
77
-
78
- /** @title Cached Search Terms */
79
- cachedSearchTerms?: {
80
- terms?: unknown;
81
- extraTerms?: string[];
82
- };
83
- }
84
-
85
- export type { Secret };
86
-
87
- // -------------------------------------------------------------------------
88
- // State
89
- // -------------------------------------------------------------------------
90
-
91
- export interface VtexState {
92
- config: VtexConfig;
93
- }
94
-
95
- // -------------------------------------------------------------------------
96
- // Middleware
97
- // -------------------------------------------------------------------------
98
-
99
- const vtexMiddleware: AppMiddleware = async (request, next) => {
100
- const ctx = extractVtexContext(request);
101
- const response = await next();
102
- response.headers.set("Cache-Control", vtexCacheControl(ctx));
103
- propagateISCookies(ctx, response);
104
- return response;
105
- };
106
-
107
- // -------------------------------------------------------------------------
108
- // Configure
109
- // -------------------------------------------------------------------------
110
-
111
- /**
112
- * Configure the VTEX app from CMS block data.
113
- * Returns an AppDefinition or null if required fields are missing.
114
- */
115
- export async function configure(
116
- // biome-ignore lint/suspicious/noExplicitAny: block data comes from CMS with no fixed schema
117
- block: any,
118
- resolveSecret: ResolveSecretFn,
119
- ): Promise<AppDefinition<VtexState> | null> {
120
- if (!block?.account) return null;
121
-
122
- // Real props schemas for the admin meta — must be in place before
123
- // setupApps() auto-registers the __resolveType-only stubs.
124
- registerVtexSchemas();
125
-
126
- const appKey = await resolveSecret(block.appKey, "VTEX_APP_KEY");
127
- const appToken = await resolveSecret(block.appToken, "VTEX_APP_TOKEN");
128
-
129
- const config: VtexConfig = {
130
- account: block.account,
131
- publicUrl: block.publicUrl,
132
- salesChannel: block.salesChannel || "1",
133
- locale: block.locale || block.defaultLocale,
134
- appKey: appKey ?? undefined,
135
- appToken: appToken ?? undefined,
136
- country: block.country,
137
- domain: block.domain,
138
- };
139
-
140
- // Bridge: maintain global singleton for backward compat
141
- configureVtex(config);
142
-
143
- return {
144
- name: "vtex",
145
- manifest,
146
- state: { config },
147
- middleware: vtexMiddleware,
148
- };
149
- }
150
-
151
- /** Placeholder preview for CMS editor — evolves when admin supports it. */
152
- export const preview = undefined;
153
-
154
- /** Default export for schema generation and Deno-style app bridges. */
155
- export default function VTEX(_props: Props) {
156
- return { state: _props };
157
- }
package/src/registry.ts DELETED
@@ -1,9 +0,0 @@
1
- import type { AppRegistryEntry } from "@decocms/apps-commerce/registry";
2
-
3
- export const VTEX_REGISTRY_ENTRY: AppRegistryEntry = {
4
- blockKey: "deco-vtex",
5
- module: () => import("./mod"),
6
- displayName: "VTEX",
7
- category: "commerce",
8
- description: "VTEX IO commerce integration",
9
- };