@graphcommerce/next-config 8.1.0-canary.9 → 9.0.0-canary.55

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.
@@ -33,10 +33,10 @@ it('finds plugins', () => {
33
33
  {
34
34
  "enabled": true,
35
35
  "ifConfig": "googleAnalyticsId",
36
- "sourceExport": "FramerNextPages",
36
+ "sourceExport": "DocumentHeadEnd",
37
37
  "sourceModule": "@graphcommerce/googleanalytics/plugins/GoogleAnalyticsTag",
38
- "targetExport": "FramerNextPages",
39
- "targetModule": "@graphcommerce/framer-next-pages",
38
+ "targetExport": "DocumentHeadEnd",
39
+ "targetModule": "@graphcommerce/next-ui/server",
40
40
  "type": "component",
41
41
  },
42
42
  {
@@ -86,7 +86,7 @@ it('finds plugins', () => {
86
86
  {
87
87
  "enabled": true,
88
88
  "sourceExport": "Plugin",
89
- "sourceModule": "@graphcommerce/google-datalayer/plugins/GoogleDatalayerUpdateItemQuantity",
89
+ "sourceModule": "@graphcommerce/google-datalayer/plugins/GoogleDatalayerUseRemoveItemFromCart",
90
90
  "targetExport": "UpdateItemQuantity",
91
91
  "targetModule": "@graphcommerce/magento-cart-items/components/UpdateItemQuantity/UpdateItemQuantity",
92
92
  "type": "component",
@@ -101,35 +101,11 @@ it('finds plugins', () => {
101
101
  },
102
102
  {
103
103
  "enabled": true,
104
- "sourceExport": "Plugin",
105
- "sourceModule": "@graphcommerce/google-datalayer/plugins/GoogleDatalayerShippingMethodForm",
106
- "targetExport": "ShippingMethodForm",
107
- "targetModule": "@graphcommerce/magento-cart-shipping-method",
108
- "type": "component",
109
- },
110
- {
111
- "enabled": true,
112
- "sourceExport": "RemoveItemFromCartFab",
113
- "sourceModule": "@graphcommerce/google-datalayer/plugins/GoogleDatalayerRemoveItemFromCartFab",
114
- "targetExport": "RemoveItemFromCartFab",
115
- "targetModule": "@graphcommerce/magento-cart-items",
116
- "type": "component",
117
- },
118
- {
119
- "enabled": true,
120
- "sourceExport": "RemoveItemFromCart",
104
+ "sourceExport": "useRemoveItemFromCart",
121
105
  "sourceModule": "@graphcommerce/google-datalayer/plugins/GoogleDatalayerRemoveItemFromCart",
122
- "targetExport": "RemoveItemFromCart",
106
+ "targetExport": "useRemoveItemFromCart",
123
107
  "targetModule": "@graphcommerce/magento-cart-items",
124
- "type": "component",
125
- },
126
- {
127
- "enabled": true,
128
- "sourceExport": "Plugin",
129
- "sourceModule": "@graphcommerce/google-datalayer/plugins/GoogleDatalayerProductListItemsBase",
130
- "targetExport": "ProductListItemsBase",
131
- "targetModule": "@graphcommerce/magento-product",
132
- "type": "component",
108
+ "type": "function",
133
109
  },
134
110
  {
135
111
  "enabled": true,
@@ -171,22 +147,6 @@ it('finds plugins', () => {
171
147
  "targetModule": "@graphcommerce/magento-cart",
172
148
  "type": "component",
173
149
  },
174
- {
175
- "enabled": true,
176
- "sourceExport": "Plugin",
177
- "sourceModule": "@graphcommerce/google-datalayer/plugins/GoogleDatalayerCartStartCheckoutLinkOrButton",
178
- "targetExport": "CartStartCheckoutLinkOrButton",
179
- "targetModule": "@graphcommerce/magento-cart",
180
- "type": "component",
181
- },
182
- {
183
- "enabled": true,
184
- "sourceExport": "Plugin",
185
- "sourceModule": "@graphcommerce/google-datalayer/plugins/GoogleDatalayerCartStartCheckout",
186
- "targetExport": "CartStartCheckout",
187
- "targetModule": "@graphcommerce/magento-cart",
188
- "type": "component",
189
- },
190
150
  {
191
151
  "enabled": true,
192
152
  "sourceExport": "Plugin",
@@ -203,6 +163,14 @@ it('finds plugins', () => {
203
163
  "targetModule": "@graphcommerce/magento-product",
204
164
  "type": "component",
205
165
  },
166
+ {
167
+ "enabled": true,
168
+ "sourceExport": "previewModeDefaults",
169
+ "sourceModule": "@graphcommerce/graphcms-ui/plugins/hygraphPreviewModeDefaults",
170
+ "targetExport": "previewModeDefaults",
171
+ "targetModule": "@graphcommerce/ecommerce-ui",
172
+ "type": "function",
173
+ },
206
174
  {
207
175
  "enabled": true,
208
176
  "sourceExport": "plugin",
@@ -211,6 +179,14 @@ it('finds plugins', () => {
211
179
  "targetModule": "@graphcommerce/graphql",
212
180
  "type": "function",
213
181
  },
182
+ {
183
+ "enabled": true,
184
+ "sourceExport": "PreviewModeToolbar",
185
+ "sourceModule": "@graphcommerce/graphcms-ui/plugins/HygraphPreviewModeToolbar",
186
+ "targetExport": "PreviewModeToolbar",
187
+ "targetModule": "@graphcommerce/ecommerce-ui",
188
+ "type": "component",
189
+ },
214
190
  {
215
191
  "enabled": true,
216
192
  "sourceExport": "plugin",
@@ -235,6 +211,22 @@ it('finds plugins', () => {
235
211
  "targetModule": "@graphcommerce/graphql",
236
212
  "type": "component",
237
213
  },
214
+ {
215
+ "enabled": true,
216
+ "sourceExport": "getInContextInput",
217
+ "sourceModule": "@graphcommerce/magento-customer/plugins/magentoCustomerGetInContext",
218
+ "targetExport": "getInContextInput",
219
+ "targetModule": "@graphcommerce/graphql",
220
+ "type": "function",
221
+ },
222
+ {
223
+ "enabled": true,
224
+ "sourceExport": "useInContextInput",
225
+ "sourceModule": "@graphcommerce/magento-customer/plugins/magentoCustomerGetInContext",
226
+ "targetExport": "useInContextInput",
227
+ "targetModule": "@graphcommerce/graphql",
228
+ "type": "function",
229
+ },
238
230
  {
239
231
  "enabled": true,
240
232
  "sourceExport": "GraphQLProvider",
@@ -261,15 +253,7 @@ it('finds plugins', () => {
261
253
  },
262
254
  {
263
255
  "enabled": true,
264
- "sourceExport": "Plugin",
265
- "sourceModule": "@graphcommerce/magento-product-bundle/plugins/BundleCartItemActionCard",
266
- "targetExport": "CartItemActionCard",
267
- "targetModule": "@graphcommerce/magento-cart-items",
268
- "type": "component",
269
- },
270
- {
271
- "enabled": true,
272
- "sourceExport": "Plugin",
256
+ "sourceExport": "CartItemActionCard",
273
257
  "sourceModule": "@graphcommerce/magento-product-bundle/plugins/BundleCartItemActionCard",
274
258
  "targetExport": "CartItemActionCard",
275
259
  "targetModule": "@graphcommerce/magento-cart-items",
@@ -277,15 +261,7 @@ it('finds plugins', () => {
277
261
  },
278
262
  {
279
263
  "enabled": true,
280
- "sourceExport": "Plugin",
281
- "sourceModule": "@graphcommerce/magento-product-configurable/plugins/ConfigurableCartItemActionCard",
282
- "targetExport": "CartItemActionCard",
283
- "targetModule": "@graphcommerce/magento-cart-items",
284
- "type": "component",
285
- },
286
- {
287
- "enabled": true,
288
- "sourceExport": "Plugin",
264
+ "sourceExport": "CartItemActionCard",
289
265
  "sourceModule": "@graphcommerce/magento-product-configurable/plugins/ConfigurableCartItemActionCard",
290
266
  "targetExport": "CartItemActionCard",
291
267
  "targetModule": "@graphcommerce/magento-cart-items",
@@ -317,7 +293,7 @@ it('finds plugins', () => {
317
293
  },
318
294
  {
319
295
  "enabled": true,
320
- "sourceExport": "Plugin",
296
+ "sourceExport": "CartItemActionCard",
321
297
  "sourceModule": "@graphcommerce/magento-product-simple/plugins/SimpleCartItemActionCard",
322
298
  "targetExport": "CartItemActionCard",
323
299
  "targetModule": "@graphcommerce/magento-cart-items",
@@ -325,23 +301,7 @@ it('finds plugins', () => {
325
301
  },
326
302
  {
327
303
  "enabled": true,
328
- "sourceExport": "Plugin",
329
- "sourceModule": "@graphcommerce/magento-product-simple/plugins/SimpleCartItemActionCard",
330
- "targetExport": "CartItemActionCard",
331
- "targetModule": "@graphcommerce/magento-cart-items",
332
- "type": "component",
333
- },
334
- {
335
- "enabled": true,
336
- "sourceExport": "Plugin",
337
- "sourceModule": "@graphcommerce/magento-product-virtual/plugins/VirtualCartItemActionCard",
338
- "targetExport": "CartItemActionCard",
339
- "targetModule": "@graphcommerce/magento-cart-items",
340
- "type": "component",
341
- },
342
- {
343
- "enabled": true,
344
- "sourceExport": "Plugin",
304
+ "sourceExport": "CartItemActionCard",
345
305
  "sourceModule": "@graphcommerce/magento-product-virtual/plugins/VirtualCartItemActionCard",
346
306
  "targetExport": "CartItemActionCard",
347
307
  "targetModule": "@graphcommerce/magento-cart-items",
@@ -379,14 +339,6 @@ it('finds plugins', () => {
379
339
  "targetModule": "@graphcommerce/magento-wishlist",
380
340
  "type": "component",
381
341
  },
382
- {
383
- "enabled": true,
384
- "sourceExport": "Plugin",
385
- "sourceModule": "@graphcommerce/magento-wishlist/plugins/BundleWishlistItemActionCard",
386
- "targetExport": "WishlistItemActionCard",
387
- "targetModule": "@graphcommerce/magento-wishlist",
388
- "type": "component",
389
- },
390
342
  {
391
343
  "enabled": true,
392
344
  "sourceExport": "Plugin",
@@ -450,24 +402,6 @@ it('finds plugins', () => {
450
402
  "targetModule": "@graphcommerce/magento-recently-viewed-products",
451
403
  "type": "component",
452
404
  },
453
- {
454
- "enabled": false,
455
- "ifConfig": "demoMode",
456
- "sourceExport": "Plugin",
457
- "sourceModule": "@graphcommerce/demo-magento-graphcommerce/plugins/demo/DemoProductListItemsBase",
458
- "targetExport": "ProductListItemsBase",
459
- "targetModule": "@graphcommerce/magento-product",
460
- "type": "component",
461
- },
462
- {
463
- "enabled": false,
464
- "ifConfig": "demoMode",
465
- "sourceExport": "Plugin",
466
- "sourceModule": "@graphcommerce/demo-magento-graphcommerce/plugins/demo/DemoProductListItemsBase",
467
- "targetExport": "ProductListItemsBase",
468
- "targetModule": "@graphcommerce/magento-product",
469
- "type": "component",
470
- },
471
405
  {
472
406
  "enabled": false,
473
407
  "ifConfig": "demoMode",
@@ -479,11 +413,11 @@ it('finds plugins', () => {
479
413
  },
480
414
  {
481
415
  "enabled": false,
482
- "ifConfig": "demoMode",
483
- "sourceExport": "Plugin",
484
- "sourceModule": "@graphcommerce/demo-magento-graphcommerce/plugins/demo/DemoProductListItem",
485
- "targetExport": "ProductListItem",
486
- "targetModule": "@graphcommerce/magento-product",
416
+ "ifConfig": "previewSecret",
417
+ "sourceExport": "FramerNextPages",
418
+ "sourceModule": "@graphcommerce/ecommerce-ui/plugins/PreviewModeFramerNextPages",
419
+ "targetExport": "FramerNextPages",
420
+ "targetModule": "@graphcommerce/framer-next-pages",
487
421
  "type": "component",
488
422
  },
489
423
  {
@@ -498,10 +432,19 @@ it('finds plugins', () => {
498
432
  {
499
433
  "enabled": false,
500
434
  "ifConfig": "googleTagmanagerId",
501
- "sourceExport": "FramerNextPages",
435
+ "sourceExport": "DocumentBodyStart",
502
436
  "sourceModule": "@graphcommerce/googletagmanager/plugins/GoogleTagmanagerTag",
503
- "targetExport": "FramerNextPages",
504
- "targetModule": "@graphcommerce/framer-next-pages",
437
+ "targetExport": "DocumentBodyStart",
438
+ "targetModule": "@graphcommerce/next-ui/server",
439
+ "type": "component",
440
+ },
441
+ {
442
+ "enabled": false,
443
+ "ifConfig": "googleTagmanagerId",
444
+ "sourceExport": "DocumentHeadEnd",
445
+ "sourceModule": "@graphcommerce/googletagmanager/plugins/GoogleTagmanagerTag",
446
+ "targetExport": "DocumentHeadEnd",
447
+ "targetModule": "@graphcommerce/next-ui/server",
505
448
  "type": "component",
506
449
  },
507
450
  {
@@ -603,15 +546,6 @@ it('finds plugins', () => {
603
546
  "targetModule": "@graphcommerce/magento-product",
604
547
  "type": "component",
605
548
  },
606
- {
607
- "enabled": false,
608
- "ifConfig": "configurableVariantValues.content",
609
- "sourceExport": "Plugin",
610
- "sourceModule": "@graphcommerce/magento-product-configurable/plugins/ConfigurableProductPage/ConfigurableProductPageDescription",
611
- "targetExport": "ProductPageDescription",
612
- "targetModule": "@graphcommerce/magento-product",
613
- "type": "component",
614
- },
615
549
  {
616
550
  "enabled": false,
617
551
  "ifConfig": "recentlyViewedProducts.enabled",
@@ -74,17 +74,20 @@ it('it generates an interceptor', async () => {
74
74
  interceptors['packages/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext']
75
75
  ?.template
76
76
  expectInterceptor(result).toMatchInlineSnapshot(`
77
- "type AddBraintreeMethodsProps = OmitPrev<React.ComponentProps<typeof AddBraintreeMethods>, 'Prev'>
77
+ "type PluginAddBraintreeMethodsProps = OmitPrev<
78
+ React.ComponentProps<typeof PluginAddBraintreeMethods>,
79
+ 'Prev'
80
+ >
78
81
 
79
- const AddBraintreeMethodsInterceptor = (props: AddBraintreeMethodsProps) => (
80
- <AddBraintreeMethods {...props} Prev={PaymentMethodContextProviderOriginal} />
82
+ const PluginAddBraintreeMethodsInterceptor = (props: PluginAddBraintreeMethodsProps) => (
83
+ <PluginAddBraintreeMethods {...props} Prev={PaymentMethodContextProviderOriginal} />
81
84
  )
82
85
 
83
- type AddMollieMethodsProps = AddBraintreeMethodsProps &
84
- OmitPrev<React.ComponentProps<typeof AddMollieMethods>, 'Prev'>
86
+ type PluginAddMollieMethodsProps = PluginAddBraintreeMethodsProps &
87
+ OmitPrev<React.ComponentProps<typeof PluginAddMollieMethods>, 'Prev'>
85
88
 
86
- const AddMollieMethodsInterceptor = (props: AddMollieMethodsProps) => (
87
- <AddMollieMethods {...props} Prev={AddBraintreeMethodsInterceptor} />
89
+ const PluginAddMollieMethodsInterceptor = (props: PluginAddMollieMethodsProps) => (
90
+ <PluginAddMollieMethods {...props} Prev={PluginAddBraintreeMethodsInterceptor} />
88
91
  )
89
92
 
90
93
  /**
@@ -93,10 +96,10 @@ it('it generates an interceptor', async () => {
93
96
  * This file is NOT meant to be modified directly and is auto-generated if the plugins or the original source changes.
94
97
  *
95
98
  * @see {@link file://./PaymentMethodContext.tsx} for original source file
96
- * @see {AddBraintreeMethods} for source of applied plugin
97
- * @see {AddMollieMethods} for source of applied plugin
99
+ * @see {PluginAddBraintreeMethods} for source of applied plugin
100
+ * @see {PluginAddMollieMethods} for source of applied plugin
98
101
  */
99
- export const PaymentMethodContextProvider = AddMollieMethodsInterceptor"
102
+ export const PaymentMethodContextProvider = PluginAddMollieMethodsInterceptor"
100
103
  `)
101
104
  })
102
105
 
@@ -124,7 +127,7 @@ it("resolves a 'root plugin' to be relative to the interceptor", async () => {
124
127
  ).toMatchInlineSnapshot(`
125
128
  "import type { DistributedOmit as OmitPrev } from 'type-fest'
126
129
 
127
- import { Plugin as AddPaymentMethodEnhancer } from '../../../plugins/AddPaymentMethodEnhancer'"
130
+ import { Plugin as PluginAddPaymentMethodEnhancer } from '../../../plugins/AddPaymentMethodEnhancer'"
128
131
  `)
129
132
  })
130
133
 
@@ -157,24 +160,27 @@ it('it can apply multiple plugins to a single export', async () => {
157
160
  expectImport(result).toMatchInlineSnapshot(`
158
161
  "import type { DistributedOmit as OmitPrev } from 'type-fest'
159
162
 
160
- import { Plugin as AddAdyenMethods } from '@graphcommerce/magento-payment-adyen/plugins/AddAdyenMethods'
161
- import { Plugin as AddMollieMethods } from '@graphcommerce/mollie-magento-payment/plugins/AddMollieMethods'"
163
+ import { Plugin as PluginAddAdyenMethods } from '@graphcommerce/magento-payment-adyen/plugins/AddAdyenMethods'
164
+ import { Plugin as PluginAddMollieMethods } from '@graphcommerce/mollie-magento-payment/plugins/AddMollieMethods'"
162
165
  `)
163
166
 
164
167
  expectOriginal(result).toContain('PaymentMethodContextProviderOriginal')
165
168
 
166
169
  expectInterceptor(result).toMatchInlineSnapshot(`
167
- "type AddAdyenMethodsProps = OmitPrev<React.ComponentProps<typeof AddAdyenMethods>, 'Prev'>
170
+ "type PluginAddAdyenMethodsProps = OmitPrev<
171
+ React.ComponentProps<typeof PluginAddAdyenMethods>,
172
+ 'Prev'
173
+ >
168
174
 
169
- const AddAdyenMethodsInterceptor = (props: AddAdyenMethodsProps) => (
170
- <AddAdyenMethods {...props} Prev={PaymentMethodContextProviderOriginal} />
175
+ const PluginAddAdyenMethodsInterceptor = (props: PluginAddAdyenMethodsProps) => (
176
+ <PluginAddAdyenMethods {...props} Prev={PaymentMethodContextProviderOriginal} />
171
177
  )
172
178
 
173
- type AddMollieMethodsProps = AddAdyenMethodsProps &
174
- OmitPrev<React.ComponentProps<typeof AddMollieMethods>, 'Prev'>
179
+ type PluginAddMollieMethodsProps = PluginAddAdyenMethodsProps &
180
+ OmitPrev<React.ComponentProps<typeof PluginAddMollieMethods>, 'Prev'>
175
181
 
176
- const AddMollieMethodsInterceptor = (props: AddMollieMethodsProps) => (
177
- <AddMollieMethods {...props} Prev={AddAdyenMethodsInterceptor} />
182
+ const PluginAddMollieMethodsInterceptor = (props: PluginAddMollieMethodsProps) => (
183
+ <PluginAddMollieMethods {...props} Prev={PluginAddAdyenMethodsInterceptor} />
178
184
  )
179
185
 
180
186
  /**
@@ -183,10 +189,10 @@ it('it can apply multiple plugins to a single export', async () => {
183
189
  * This file is NOT meant to be modified directly and is auto-generated if the plugins or the original source changes.
184
190
  *
185
191
  * @see {@link file://./PaymentMethodContext.tsx} for original source file
186
- * @see {AddAdyenMethods} for source of applied plugin
187
- * @see {AddMollieMethods} for source of applied plugin
192
+ * @see {PluginAddAdyenMethods} for source of applied plugin
193
+ * @see {PluginAddMollieMethods} for source of applied plugin
188
194
  */
189
- export const PaymentMethodContextProvider = AddMollieMethodsInterceptor"
195
+ export const PaymentMethodContextProvider = PluginAddMollieMethodsInterceptor"
190
196
  `)
191
197
  })
192
198
 
@@ -218,10 +224,13 @@ it('it handles on duplicates gracefully', async () => {
218
224
  interceptors['packages/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext']
219
225
  ?.template
220
226
  expectInterceptor(result).toMatchInlineSnapshot(`
221
- "type AddBraintreeMethodsProps = OmitPrev<React.ComponentProps<typeof AddBraintreeMethods>, 'Prev'>
227
+ "type PluginAddBraintreeMethodsProps = OmitPrev<
228
+ React.ComponentProps<typeof PluginAddBraintreeMethods>,
229
+ 'Prev'
230
+ >
222
231
 
223
- const AddBraintreeMethodsInterceptor = (props: AddBraintreeMethodsProps) => (
224
- <AddBraintreeMethods {...props} Prev={PaymentMethodContextProviderOriginal} />
232
+ const PluginAddBraintreeMethodsInterceptor = (props: PluginAddBraintreeMethodsProps) => (
233
+ <PluginAddBraintreeMethods {...props} Prev={PaymentMethodContextProviderOriginal} />
225
234
  )
226
235
 
227
236
  /**
@@ -230,9 +239,9 @@ it('it handles on duplicates gracefully', async () => {
230
239
  * This file is NOT meant to be modified directly and is auto-generated if the plugins or the original source changes.
231
240
  *
232
241
  * @see {@link file://./PaymentMethodContext.tsx} for original source file
233
- * @see {AddBraintreeMethods} for source of applied plugin
242
+ * @see {PluginAddBraintreeMethods} for source of applied plugin
234
243
  */
235
- export const PaymentMethodContextProvider = AddBraintreeMethodsInterceptor"
244
+ export const PaymentMethodContextProvider = PluginAddBraintreeMethodsInterceptor"
236
245
  `)
237
246
  })
238
247
 
@@ -389,28 +398,38 @@ it('adds debug logging to interceptors for components', async () => {
389
398
  )
390
399
 
391
400
  expectImport(interceptors['packages/graphql/config']?.template).toMatchInlineSnapshot(`
392
- "import { plugin as magentoInitMemoryCache } from '@graphcommerce/magento-graphql/plugins/magentoInitMemoryCache'
393
- import { plugin as hygraphInitMemoryCache } from '@graphcommerce/magento-hygraph/plugins/hygraphInitMemoryCache'"
401
+ "import { plugin as pluginmagentoInitMemoryCache } from '@graphcommerce/magento-graphql/plugins/magentoInitMemoryCache'
402
+ import { plugin as pluginhygraphInitMemoryCache } from '@graphcommerce/magento-hygraph/plugins/hygraphInitMemoryCache'"
394
403
  `)
395
404
 
396
405
  expectOriginal(interceptors['packages/graphql/config']?.template).toMatchInlineSnapshot(`
397
406
  "import { ApolloLink, TypePolicies } from '@apollo/client'
398
407
  import type { GraphCommerceStorefrontConfig } from '@graphcommerce/next-config'
408
+ import type { SetRequired } from 'type-fest'
399
409
  import { MigrateCache } from './components/GraphQLProvider/migrateCache'
410
+ export interface PreviewData {}
411
+ export type PreviewConfig = {
412
+ preview?: boolean
413
+ previewData?: PreviewData & Record<string, unknown>
414
+ }
400
415
  export type ApolloClientConfigInput = {
401
416
  storefront: GraphCommerceStorefrontConfig
402
417
  links?: ApolloLink[]
403
418
  policies?: TypePolicies[]
404
419
  migrations?: MigrateCache[]
405
- }
406
- export type ApolloClientConfig = Required<ApolloClientConfigInput>
420
+ } & PreviewConfig
421
+ export type ApolloClientConfig = SetRequired<
422
+ ApolloClientConfigInput,
423
+ 'links' | 'policies' | 'migrations'
424
+ >
407
425
  export function graphqlConfigOriginal(config: ApolloClientConfigInput): ApolloClientConfig {
408
- const { storefront, links = [], policies = [], migrations = [] } = config
426
+ const { storefront, links = [], policies = [], migrations = [], ...rest } = config
409
427
  return {
410
428
  storefront,
411
429
  links,
412
430
  policies,
413
431
  migrations,
432
+ ...rest,
414
433
  }
415
434
  }"
416
435
  `)
@@ -423,17 +442,19 @@ it('adds debug logging to interceptors for components', async () => {
423
442
  console.warn(log, ...additional)
424
443
  }
425
444
 
426
- const hygraphInitMemoryCacheInterceptor: typeof graphqlConfigOriginal = (...args) => {
445
+ const pluginhygraphInitMemoryCacheInterceptor: typeof graphqlConfigOriginal = (...args) => {
427
446
  logOnce(
428
- \`🔌 Calling graphqlConfig with plugin(s): magentoInitMemoryCache wrapping hygraphInitMemoryCache wrapping graphqlConfig()\`,
447
+ \`🔌 Calling graphqlConfig with plugin(s): pluginmagentoInitMemoryCache wrapping pluginhygraphInitMemoryCache wrapping graphqlConfig()\`,
429
448
  )
430
- return hygraphInitMemoryCache(graphqlConfigOriginal, ...args)
449
+ return pluginhygraphInitMemoryCache(graphqlConfigOriginal, ...args)
431
450
  }
432
- const magentoInitMemoryCacheInterceptor: typeof hygraphInitMemoryCacheInterceptor = (...args) => {
451
+ const pluginmagentoInitMemoryCacheInterceptor: typeof pluginhygraphInitMemoryCacheInterceptor = (
452
+ ...args
453
+ ) => {
433
454
  logOnce(
434
- \`🔌 Calling graphqlConfig with plugin(s): hygraphInitMemoryCache wrapping magentoInitMemoryCache wrapping graphqlConfig()\`,
455
+ \`🔌 Calling graphqlConfig with plugin(s): pluginhygraphInitMemoryCache wrapping pluginmagentoInitMemoryCache wrapping graphqlConfig()\`,
435
456
  )
436
- return magentoInitMemoryCache(hygraphInitMemoryCacheInterceptor, ...args)
457
+ return pluginmagentoInitMemoryCache(pluginhygraphInitMemoryCacheInterceptor, ...args)
437
458
  }
438
459
 
439
460
  /**
@@ -442,10 +463,10 @@ it('adds debug logging to interceptors for components', async () => {
442
463
  * This file is NOT meant to be modified directly and is auto-generated if the plugins or the original source changes.
443
464
  *
444
465
  * @see {@link file://./config.ts} for original source file
445
- * @see {hygraphInitMemoryCache} for source of applied plugin
446
- * @see {magentoInitMemoryCache} for source of applied plugin
466
+ * @see {pluginhygraphInitMemoryCache} for source of applied plugin
467
+ * @see {pluginmagentoInitMemoryCache} for source of applied plugin
447
468
  */
448
- export const graphqlConfig = magentoInitMemoryCacheInterceptor"
469
+ export const graphqlConfig = pluginmagentoInitMemoryCacheInterceptor"
449
470
  `)
450
471
  })
451
472
 
@@ -515,14 +536,12 @@ it('Should apply overrides to the correct file', async () => {
515
536
  interceptors['packages/magento-product/components/ProductStaticPaths/getProductStaticPaths']
516
537
  ?.template
517
538
  expectImport(result).toMatchInlineSnapshot(
518
- `"import { getProductStaticPaths as replaceGetProductStaticPaths } from '../../../../plugins/replaceGetProductStaticPaths'"`,
539
+ `"import { getProductStaticPaths as getProductStaticPathsreplaceGetProductStaticPaths } from '../../../../plugins/replaceGetProductStaticPaths'"`,
519
540
  )
520
541
 
521
542
  expectOriginal(result).toContain(`getProductStaticPathsDisabled`)
522
543
  })
523
544
 
524
- it('Should report an error when multiple files are overriding the same export', () => {})
525
-
526
545
  it('correctly reports an error for an incorrect export', async () => {
527
546
  const fakeconfig = {
528
547
  googleRecaptchaKey: '123',
@@ -644,8 +663,8 @@ export const Plugin = ConfigurableProductPageName
644
663
  expectImport(result).toMatchInlineSnapshot(`
645
664
  "import type { DistributedOmit as OmitPrev } from 'type-fest'
646
665
 
647
- import { Plugin as ConfigurableProductPageName } from '@graphcommerce/magento-product-configurable/plugins/ConfigurableProductPage/ConfigurableProductPageName'
648
- import { ProductPageName as MyPlugin } from '../../../../plugins/MyPlugin'"
666
+ import { Plugin as PluginConfigurableProductPageName } from '@graphcommerce/magento-product-configurable/plugins/ConfigurableProductPage/ConfigurableProductPageName'
667
+ import { ProductPageName as ProductPageNameMyPlugin } from '../../../../plugins/MyPlugin'"
649
668
  `)
650
669
 
651
670
  expectOriginal(result).toMatchInlineSnapshot(`
@@ -660,14 +679,12 @@ export const Plugin = ConfigurableProductPageName
660
679
  `)
661
680
 
662
681
  expectInterceptor(result).toMatchInlineSnapshot(`
663
- "type MyPluginProps = React.ComponentProps<typeof MyPlugin>
682
+ "type PluginConfigurableProductPageNameProps = React.ComponentProps<typeof ProductPageNameMyPlugin> &
683
+ OmitPrev<React.ComponentProps<typeof PluginConfigurableProductPageName>, 'Prev'>
664
684
 
665
- type ConfigurableProductPageNameProps = MyPluginProps &
666
- OmitPrev<React.ComponentProps<typeof ConfigurableProductPageName>, 'Prev'>
667
-
668
- const ConfigurableProductPageNameInterceptor = (props: ConfigurableProductPageNameProps) => (
669
- <ConfigurableProductPageName {...props} Prev={MyPlugin} />
670
- )
685
+ const PluginConfigurableProductPageNameInterceptor = (
686
+ props: PluginConfigurableProductPageNameProps,
687
+ ) => <PluginConfigurableProductPageName {...props} Prev={ProductPageNameMyPlugin} />
671
688
 
672
689
  /**
673
690
  * Here you see the 'interceptor' that is applying all the configured plugins.
@@ -675,10 +692,10 @@ export const Plugin = ConfigurableProductPageName
675
692
  * This file is NOT meant to be modified directly and is auto-generated if the plugins or the original source changes.
676
693
  *
677
694
  * @see {@link file://./ProductPageName.tsx} for original source file
678
- * @see {MyPlugin} for replacement of the original source (original source not used)
679
- * @see {ConfigurableProductPageName} for source of applied plugin
695
+ * @see {ProductPageNameMyPlugin} for replacement of the original source (original source not used)
696
+ * @see {PluginConfigurableProductPageName} for source of applied plugin
680
697
  */
681
- export const ProductPageName = ConfigurableProductPageNameInterceptor"
698
+ export const ProductPageName = PluginConfigurableProductPageNameInterceptor"
682
699
  `)
683
700
  })
684
701
 
@@ -702,3 +719,65 @@ it('generates to a .ts file when the target file is a .ts as well', async () =>
702
719
  const interceptor = interceptors['packages/graphql/config']
703
720
  expect(interceptor.sourcePath).toBe(`packages/graphql/config.ts`)
704
721
  })
722
+
723
+ it.todo('Should report an error when multiple files are overriding the same export')
724
+
725
+ it('Can correctly find exports that are default exports', async () => {
726
+ const pluginSource = `
727
+ import { PluginConfig } from '@graphcommerce/next-config'
728
+
729
+ import accessibilityHuman from '@graphcommerce/next-ui/icons/accessibility-human.svg'
730
+ import alarm from '@graphcommerce/next-ui/icons/alarm.svg'
731
+
732
+ export const config: PluginConfig = {
733
+ type: 'replace',
734
+ module: '@graphcommerce/next-ui',
735
+ }
736
+
737
+ export const iconChevronLeft = accessibilityHuman
738
+ export const iconChevronRight = alarm
739
+ `
740
+
741
+ const config = {
742
+ demoMode: true,
743
+ configurableVariantForSimple: true,
744
+ configurableVariantValues: { content: true, gallery: true, url: true },
745
+ } as GraphCommerceConfig
746
+
747
+ const plugins = parseStructure(parseSync(pluginSource), config, './plugins/MyProjectIcon')
748
+
749
+ const interceptors = await generateInterceptors(plugins, resolveDependency(projectRoot))
750
+ expect(Object.keys(interceptors)[0]).toMatchInlineSnapshot(`"packages/next-ui/icons"`)
751
+
752
+ const result = interceptors['packages/next-ui/icons']?.template
753
+
754
+ expectImport(result).toMatchInlineSnapshot(`
755
+ "import { iconChevronLeft as iconChevronLeftMyProjectIcon } from '../../plugins/MyProjectIcon'
756
+ import { iconChevronRight as iconChevronRightMyProjectIcon } from '../../plugins/MyProjectIcon'"
757
+ `)
758
+
759
+ expectOriginal(result).toContain('iconChevronLeftDisabled')
760
+ expectOriginal(result).toContain('iconChevronRightDisabled')
761
+
762
+ expectInterceptor(result).toMatchInlineSnapshot(`
763
+ "/**
764
+ * Here you see the 'interceptor' that is applying all the configured plugins.
765
+ *
766
+ * This file is NOT meant to be modified directly and is auto-generated if the plugins or the original source changes.
767
+ *
768
+ * @see {@link file://./icons.ts} for original source file
769
+ * @see {iconChevronLeftMyProjectIcon} for replacement of the original source (original source not used)
770
+ */
771
+ export const iconChevronLeft = iconChevronLeftMyProjectIcon
772
+
773
+ /**
774
+ * Here you see the 'interceptor' that is applying all the configured plugins.
775
+ *
776
+ * This file is NOT meant to be modified directly and is auto-generated if the plugins or the original source changes.
777
+ *
778
+ * @see {@link file://./icons.ts} for original source file
779
+ * @see {iconChevronRightMyProjectIcon} for replacement of the original source (original source not used)
780
+ */
781
+ export const iconChevronRight = iconChevronRightMyProjectIcon"
782
+ `)
783
+ })