diff --git a/.changeset/purple-crabs-tell.md b/.changeset/purple-crabs-tell.md new file mode 100644 index 0000000000..3ea1ae20b3 --- /dev/null +++ b/.changeset/purple-crabs-tell.md @@ -0,0 +1,5 @@ +--- +"@graphcommerce/next-config": patch +--- + +Solve an issue where an env variable wouldn't be coerced to a Number if a Config.graphqls value is defined as an Int/Float diff --git a/.changeset/swift-fireants-hear.md b/.changeset/swift-fireants-hear.md new file mode 100644 index 0000000000..27d4f71d36 --- /dev/null +++ b/.changeset/swift-fireants-hear.md @@ -0,0 +1,5 @@ +--- +"@graphcommerce/magento-graphql": patch +--- + +Added a magentoVersion configuration value to be able to differentiate features based on the Magento version diff --git a/docs/framework/config.md b/docs/framework/config.md index 3447f8ed72..6db63ef425 100644 --- a/docs/framework/config.md +++ b/docs/framework/config.md @@ -109,6 +109,12 @@ GraphQL Magento endpoint. Examples: - https://magento2.test/graphql +#### magentoVersion: number (required) + +Version of the Magento backend. + +Values: 245, 246, 247 for Magento 2.4.5, 2.4.6, 2.4.7 respectively. + #### storefront: [GraphCommerceStorefrontConfig](#GraphCommerceStorefrontConfig)[] (required) All storefront configuration for the project diff --git a/packages/address-fields-nl/graphql/PostcodeNL.graphqls b/packages/address-fields-nl/schema/PostcodeNL.graphqls similarity index 100% rename from packages/address-fields-nl/graphql/PostcodeNL.graphqls rename to packages/address-fields-nl/schema/PostcodeNL.graphqls diff --git a/packages/cli/dist/bin/mesh.js b/packages/cli/dist/bin/mesh.js index c20dc5761d..9e6ceb3ff6 100755 --- a/packages/cli/dist/bin/mesh.js +++ b/packages/cli/dist/bin/mesh.js @@ -48,6 +48,7 @@ async function cleanup() { } const main = async () => { const conf = (await (0, findConfig_1.findConfig)({})); + const graphCommerce = (0, next_config_1.loadConfig)(root); // We're configuring a custom fetch function conf.customFetch = require.resolve('@graphcommerce/graphql-mesh/customFetch'); conf.serve = { ...conf.serve, endpoint: '/api/graphql' }; @@ -72,8 +73,13 @@ const main = async () => { conf.additionalTypeDefs.push('**/*.graphqls'); const deps = (0, next_config_1.resolveDependenciesSync)(); const packages = [...deps.values()].filter((p) => p !== '.'); + const mV = graphCommerce.magentoVersion ?? 246; (0, next_config_1.packageRoots)(packages).forEach((r) => { - conf.additionalTypeDefs.push(`${r}/**/*.graphqls`); + const alsoScan = [245, 246, 247, 248, 249, 250, 251, 252, 253, 254] + .filter((v) => v > mV) + .map((v) => `${r}/schema-${v}/**/*.graphqls`); + conf.additionalTypeDefs.push(`${r}/*/schema/**/*.graphqls`); + conf.additionalTypeDefs.push(...alsoScan); }); if (!conf.serve) conf.serve = {}; @@ -87,7 +93,7 @@ const main = async () => { }, }, ]; - const yamlString = (0, next_config_1.replaceConfigInString)(yaml_1.default.stringify(conf), (0, next_config_1.loadConfig)(root)); + const yamlString = (0, next_config_1.replaceConfigInString)(yaml_1.default.stringify(conf), graphCommerce); await node_fs_1.promises.writeFile(tmpMeshLocation, yamlString); // Reexport the mesh to is can be used by packages await node_fs_1.promises.writeFile(`${meshDir}/.mesh.ts`, `export * from '${relativePath.split(node_path_1.default.sep).join('/')}.mesh'`, { encoding: 'utf8' }); diff --git a/packages/cli/src/bin/mesh.ts b/packages/cli/src/bin/mesh.ts index af4d2faf67..13fb6c6fab 100755 --- a/packages/cli/src/bin/mesh.ts +++ b/packages/cli/src/bin/mesh.ts @@ -4,7 +4,6 @@ import { promises as fs } from 'node:fs' import path from 'node:path' import { exit } from 'node:process' import { - isMonorepo, loadConfig, packageRoots, replaceConfigInString, @@ -52,6 +51,7 @@ async function cleanup() { const main = async () => { const conf = (await findConfig({})) as YamlConfig.Config + const graphCommerce = loadConfig(root) // We're configuring a custom fetch function conf.customFetch = require.resolve('@graphcommerce/graphql-mesh/customFetch') @@ -83,8 +83,15 @@ const main = async () => { const deps = resolveDependenciesSync() const packages = [...deps.values()].filter((p) => p !== '.') + + const mV = graphCommerce.magentoVersion ?? 246 packageRoots(packages).forEach((r) => { - conf.additionalTypeDefs.push(`${r}/**/*.graphqls`) + const alsoScan = [245, 246, 247, 248, 249, 250, 251, 252, 253, 254] + .filter((v) => v > mV) + .map((v) => `${r}/schema-${v}/**/*.graphqls`) + + conf.additionalTypeDefs.push(`${r}/*/schema/**/*.graphqls`) + conf.additionalTypeDefs.push(...alsoScan) }) if (!conf.serve) conf.serve = {} @@ -99,7 +106,7 @@ const main = async () => { }, ] - const yamlString = replaceConfigInString(yaml.stringify(conf), loadConfig(root)) + const yamlString = replaceConfigInString(yaml.stringify(conf), graphCommerce) await fs.writeFile(tmpMeshLocation, yamlString) // Reexport the mesh to is can be used by packages diff --git a/packages/magento-cart/hooks/CurrentCartId.graphqls b/packages/magento-compare/schema/CurrentCartId.graphqls similarity index 100% rename from packages/magento-cart/hooks/CurrentCartId.graphqls rename to packages/magento-compare/schema/CurrentCartId.graphqls diff --git a/packages/magento-compare/graphql/CurrentCompareUid.graphqls b/packages/magento-compare/schema/CurrentCompareUid.graphqls similarity index 100% rename from packages/magento-compare/graphql/CurrentCompareUid.graphqls rename to packages/magento-compare/schema/CurrentCompareUid.graphqls diff --git a/packages/magento-customer/hooks/CustomerToken.graphqls b/packages/magento-customer/schema/CustomerToken.graphqls similarity index 100% rename from packages/magento-customer/hooks/CustomerToken.graphqls rename to packages/magento-customer/schema/CustomerToken.graphqls diff --git a/packages/magento-graphql/Config.graphqls b/packages/magento-graphql/Config.graphqls index 9e74fe3a9a..510c8bc81b 100644 --- a/packages/magento-graphql/Config.graphqls +++ b/packages/magento-graphql/Config.graphqls @@ -6,6 +6,13 @@ extend input GraphCommerceConfig { - https://magento2.test/graphql """ magentoEndpoint: String! + + """ + Version of the Magento backend. + + Values: 245, 246, 247 for Magento 2.4.5, 2.4.6, 2.4.7 respectively. + """ + magentoVersion: Int! } extend input GraphCommerceStorefrontConfig { diff --git a/packages/magento-graphql/schema-246/CartAddressInput-vat_id.graphqls b/packages/magento-graphql/schema-246/CartAddressInput-vat_id.graphqls new file mode 100644 index 0000000000..73b0863514 --- /dev/null +++ b/packages/magento-graphql/schema-246/CartAddressInput-vat_id.graphqls @@ -0,0 +1,15 @@ +input CartAddressInput { + vat_id: String +} + +interface CartAddressInteface { + vat_id: String +} + +type ShippingCartAddress implements CartAddressInterface { + vat_id: String +} + +type BillingCartAddress { + vat_id: String +} diff --git a/packages/magento-graphql/schema-246/Mutation-deleteCustomer.graphqls b/packages/magento-graphql/schema-246/Mutation-deleteCustomer.graphqls new file mode 100644 index 0000000000..2484ec2a63 --- /dev/null +++ b/packages/magento-graphql/schema-246/Mutation-deleteCustomer.graphqls @@ -0,0 +1,6 @@ +type Mutation { + """ + Delete customer account + """ + deleteCustomer: Boolean +} diff --git a/packages/magento-graphql/schema-246/OrderItem-gift_message.graphqls b/packages/magento-graphql/schema-246/OrderItem-gift_message.graphqls new file mode 100644 index 0000000000..258c304fc5 --- /dev/null +++ b/packages/magento-graphql/schema-246/OrderItem-gift_message.graphqls @@ -0,0 +1,27 @@ +interface OrderItemInterface { + """ + The selected gift message for the order item + """ + gift_message: GiftMessage +} + +type OrderItem { + """ + The selected gift message for the order item + """ + gift_message: GiftMessage +} + +type BundleOrderItem { + """ + The selected gift message for the order item + """ + gift_message: GiftMessage +} + +type DownloadableOrderItem { + """ + The selected gift message for the order item + """ + gift_message: GiftMessage +} diff --git a/packages/magento-graphql/schema-246/SelectedShippingMethod.graphqls b/packages/magento-graphql/schema-246/SelectedShippingMethod.graphqls new file mode 100644 index 0000000000..2a8af72192 --- /dev/null +++ b/packages/magento-graphql/schema-246/SelectedShippingMethod.graphqls @@ -0,0 +1,4 @@ +type SelectedShippingMethod { + price_excl_tax: Money + price_incl_tax: Money +} diff --git a/packages/magento-graphql/schema-247/Cart-itemsV2.graphqls b/packages/magento-graphql/schema-247/Cart-itemsV2.graphqls new file mode 100644 index 0000000000..378e5cb049 --- /dev/null +++ b/packages/magento-graphql/schema-247/Cart-itemsV2.graphqls @@ -0,0 +1,71 @@ +type CartItems { + """ + An array of products that have been added to the cart. + """ + items: [CartItemInterface]! + """ + Metadata for pagination rendering. + """ + page_info: SearchResultPageInfo + """ + The number of returned cart items. + """ + total_count: Int! +} + +""" +Specifies the field to use for sorting quote items +""" +enum SortQuoteItemsEnum { + ITEM_ID + CREATED_AT + UPDATED_AT + PRODUCT_ID + SKU + NAME + DESCRIPTION + WEIGHT + QTY + PRICE + BASE_PRICE + CUSTOM_PRICE + DISCOUNT_PERCENT + DISCOUNT_AMOUNT + BASE_DISCOUNT_AMOUNT + TAX_PERCENT + TAX_AMOUNT + BASE_TAX_AMOUNT + ROW_TOTAL + BASE_ROW_TOTAL + ROW_TOTAL_WITH_DISCOUNT + ROW_WEIGHT + PRODUCT_TYPE + BASE_TAX_BEFORE_DISCOUNT + TAX_BEFORE_DISCOUNT + ORIGINAL_CUSTOM_PRICE + PRICE_INC_TAX + BASE_PRICE_INC_TAX + ROW_TOTAL_INC_TAX + BASE_ROW_TOTAL_INC_TAX + DISCOUNT_TAX_COMPENSATION_AMOUNT + BASE_DISCOUNT_TAX_COMPENSATION_AMOUNT + FREE_SHIPPING +} + +""" +Specifies the field to use for sorting quote items +""" +input QuoteItemsSortInput { + """ + Specifies the quote items field to sort by + """ + field: SortQuoteItemsEnum! + """ + Specifies the order of quote items' sorting + """ + order: SortEnum! +} + +type Cart { + itemsV2(pageSize: Int = 20, currentPage: Int = 1, sort: QuoteItemsSortInput): CartItems +} diff --git a/packages/magento-graphql/schema-247/CartAddress.graphqls b/packages/magento-graphql/schema-247/CartAddress.graphqls new file mode 100644 index 0000000000..e45e0f0881 --- /dev/null +++ b/packages/magento-graphql/schema-247/CartAddress.graphqls @@ -0,0 +1,56 @@ +input CartAddressInput { + """ + The customer's fax number. + """ + fax: String + """ + The middle name of the person associated with the billing/shipping address. + """ + middlename: String + """ + An honorific, such as Dr., Mr., or Mrs. + """ + prefix: String + """ + A value such as Sr., Jr., or III. + """ + suffix: String +} + +type BillingCartAdress { + """ + The customer's fax number. + """ + fax: String + """ + The middle name of the person associated with the billing/shipping address. + """ + middlename: String + """ + An honorific, such as Dr., Mr., or Mrs. + """ + prefix: String + """ + A value such as Sr., Jr., or III. + """ + suffix: String +} + +type ShippingCartAddress { + """ + The customer's fax number. + """ + fax: String + """ + The middle name of the person associated with the billing/shipping address. + """ + middlename: String + """ + An honorific, such as Dr., Mr., or Mrs. + """ + prefix: String + """ + A value such as Sr., Jr., or III. + """ + suffix: String +} diff --git a/packages/magento-graphql/schema-247/CustomAttributesV2.graphqls b/packages/magento-graphql/schema-247/CustomAttributesV2.graphqls new file mode 100644 index 0000000000..4b95d10c5d --- /dev/null +++ b/packages/magento-graphql/schema-247/CustomAttributesV2.graphqls @@ -0,0 +1,48 @@ +""" +Specifies the value for attribute. +""" +input AttributeValueInput { + """ + The code of the attribute. + """ + attribute_code: String! + """ + An array containing selected options for a select or multiselect attribute. + """ + selected_options: [AttributeInputSelectedOption] + """ + The value assigned to the attribute. + """ + value: String +} + +""" +Specifies selected option for a select or multiselect attribute value. +""" +input AttributeInputSelectedOption { + """ + The attribute option value. + """ + value: String! +} + +input CustomerCreateInput { + """ + The customer's custom attributes. + """ + custom_attributes: [AttributeValueInput] +} + +input CustomerUpdateInput { + """ + The customer's custom attributes. + """ + custom_attributes: [AttributeValueInput] +} + +input CustomerAddressInput { + """ + Custom attributes assigned to the customer address. + """ + custom_attributesV2: [AttributeValueInput] +} diff --git a/packages/magento-graphql/schema-247/Mutation-cancelOrder.graphqls b/packages/magento-graphql/schema-247/Mutation-cancelOrder.graphqls new file mode 100644 index 0000000000..c64e009195 --- /dev/null +++ b/packages/magento-graphql/schema-247/Mutation-cancelOrder.graphqls @@ -0,0 +1,34 @@ +""" +Defines the order to cancel. +""" +input CancelOrderInput { + """ + Order ID. + """ + order_id: ID! + """ + Cancellation reason. + """ + reason: String! +} + +""" +Contains the updated customer order and error message if any. +""" +type CancelOrderOutput { + """ + Error encountered while cancelling the order. + """ + error: String + """ + Updated customer order. + """ + order: CustomerOrder +} + +type Mutation { + """ + Cancel the specified customer order. + """ + cancelOrder(input: CancelOrderInput!): CancelOrderOutput +} diff --git a/packages/magento-graphql/schema-247/Mutation-confirmEmail.graphqls b/packages/magento-graphql/schema-247/Mutation-confirmEmail.graphqls new file mode 100644 index 0000000000..83a9c20f57 --- /dev/null +++ b/packages/magento-graphql/schema-247/Mutation-confirmEmail.graphqls @@ -0,0 +1,55 @@ +# This is a commpatibility file: This does not implement any working functionality and only serves as a way to make the schema compatible with Magento 2.4.7 + +type StoreConfig { + """ + Indicates if the new accounts need confirmation. + """ + create_account_confirmation: Boolean +} + +""" +List of account confirmation statuses. +""" +enum ConfirmationStatusEnum { + """ + Account confirmed + """ + ACCOUNT_CONFIRMED + """ + Account confirmation not required + """ + ACCOUNT_CONFIRMATION_NOT_REQUIRED +} + +type Customer { + """ + The customer's confirmation status. + """ + confirmation_status: ConfirmationStatusEnum! +} + +""" +Contains details about a customer email address to confirm. +""" +input ConfirmEmailInput { + """ + The key to confirm the email address. + """ + confirmation_key: String! + """ + The email address to be confirmed. + """ + email: String! +} + +type Mutation @doc(description: "Jajaj") { + """ + Confirms the email address for a customer. + """ + confirmEmail( + """ + An input object to identify the customer to confirm the email. + """ + input: ConfirmEmailInput! + ): CustomerOutput +} diff --git a/packages/magento-graphql/schema-247/Mutation-contactUs.graphqls b/packages/magento-graphql/schema-247/Mutation-contactUs.graphqls new file mode 100644 index 0000000000..b3482327a6 --- /dev/null +++ b/packages/magento-graphql/schema-247/Mutation-contactUs.graphqls @@ -0,0 +1,40 @@ +input ContactUsInput { + """ + The shopper's comment to the merchant. + """ + comment: String! + """ + The email address of the shopper. + """ + email: String! + """ + The full name of the shopper. + """ + name: String! + """ + The shopper's telephone number. + """ + telephone: String +} + +""" +Contains the status of the request. +""" +type ContactUsOutput { + """ + Indicates whether the request was successful. + """ + status: Boolean! +} + +type Mutation { + """ + Send a 'Contact Us' email to the merchant. + """ + contactUs( + """ + An input object that defines shopper information. + """ + input: ContactUsInput! + ): ContactUsOutput +} diff --git a/packages/magento-graphql/schema-247/Mutation-createGuestCart.graphqls b/packages/magento-graphql/schema-247/Mutation-createGuestCart.graphqls new file mode 100644 index 0000000000..f2d1ff4764 --- /dev/null +++ b/packages/magento-graphql/schema-247/Mutation-createGuestCart.graphqls @@ -0,0 +1,20 @@ +input CreateGuestCartInput { + """ + Optional client-generated ID + """ + cart_uid: ID +} + +type CreateGuestCartOutput { + """ + The newly created cart. + """ + cart: Cart +} + +type Mutation { + """ + Create a new shopping cart + """ + createGuestCart(input: CreateGuestCartInput): CreateGuestCartOutput +} diff --git a/packages/magento-graphql/schema-247/Mutation-estimateShippingMethods.graphqls b/packages/magento-graphql/schema-247/Mutation-estimateShippingMethods.graphqls new file mode 100644 index 0000000000..b25b85eab6 --- /dev/null +++ b/packages/magento-graphql/schema-247/Mutation-estimateShippingMethods.graphqls @@ -0,0 +1,44 @@ +""" +Contains details about an address. +""" +input EstimateAddressInput { + """ + The two-letter code representing the customer's country. + """ + country_code: CountryCodeEnum! + """ + The customer's ZIP or postal code. + """ + postcode: String + """ + An object containing the region name, region code, and region ID. + """ + region: CustomerAddressRegionInput +} + +input EstimateTotalsInput { + """ + Customer's address to estimate totals. + """ + address: EstimateAddressInput! + """ + The unique ID of the cart to query. + """ + cart_id: String! + """ + Selected shipping method to estimate totals. + """ + shipping_method: ShippingMethodInput +} + +type Mutation { + """ + Estimate shipping method(s) for cart based on address + """ + estimateShippingMethods( + """ + An input object that specifies details for estimation of available shipping methods + """ + input: EstimateTotalsInput! + ): [AvailableShippingMethod] +} diff --git a/packages/magento-graphql/schema-247/Mutation-estimateTotals.graphqls b/packages/magento-graphql/schema-247/Mutation-estimateTotals.graphqls new file mode 100644 index 0000000000..72e402892b --- /dev/null +++ b/packages/magento-graphql/schema-247/Mutation-estimateTotals.graphqls @@ -0,0 +1,21 @@ +""" +Estimate totals output. +""" +type EstimateTotalsOutput { + """ + Cart after totals estimation + """ + cart: Cart +} + +type Mutation { + """ + Estimate totals for cart based on the address + """ + estimateTotals( + """ + An input object that specifies details for cart totals estimation + """ + input: EstimateTotalsInput! + ): EstimateTotalsOutput! +} diff --git a/packages/magento-graphql/schema-247/ProductAttributeFilterInput-category_url_path.graphqls b/packages/magento-graphql/schema-247/ProductAttributeFilterInput-category_url_path.graphqls new file mode 100644 index 0000000000..3df718fc0f --- /dev/null +++ b/packages/magento-graphql/schema-247/ProductAttributeFilterInput-category_url_path.graphqls @@ -0,0 +1,3 @@ +input ProductAttributeFilterInput { + category_url_path: FilterEqualTypeInput +} diff --git a/packages/magento-graphql/schema-247/Query-guestOrder.graphqls b/packages/magento-graphql/schema-247/Query-guestOrder.graphqls new file mode 100644 index 0000000000..cdadd24472 --- /dev/null +++ b/packages/magento-graphql/schema-247/Query-guestOrder.graphqls @@ -0,0 +1,31 @@ +type CustomerOrder { + """ + Order customer email. + """ + email: String +} + +""" +Input to retrieve an order based on details. +""" +input OrderInformationInput { + """ + Order billing address email. + """ + email: String! + """ + Order number. + """ + number: String! + """ + Order billing address postcode. + """ + postcode: String! +} + +type Query { + """ + Retrieve guest order details based on number, email and postcode. + """ + guestOrder(input: OrderInformationInput!): CustomerOrder! +} diff --git a/packages/magento-graphql/schema-247/Query-guestOrderByToken.graphqls b/packages/magento-graphql/schema-247/Query-guestOrderByToken.graphqls new file mode 100644 index 0000000000..c284b56bd0 --- /dev/null +++ b/packages/magento-graphql/schema-247/Query-guestOrderByToken.graphqls @@ -0,0 +1,30 @@ +type PlaceOrderOutput { + """ + Full order information. + """ + orderV2: CustomerOrder +} + +type CustomerOrder { + """ + The token that can be used to retrieve the order using order query. + """ + token: String! +} + +""" +Input to retrieve an order based on token. +""" +input OrderTokenInput { + """ + Order token. + """ + token: String! +} + +type Query { + """ + Retrieve guest order details based on token. + """ + guestOrderByToken(input: OrderTokenInput!): CustomerOrder! +} diff --git a/packages/magento-graphql/schema-247/Query-recaptchaV3Config.graphqls b/packages/magento-graphql/schema-247/Query-recaptchaV3Config.graphqls new file mode 100644 index 0000000000..e3dad83ecc --- /dev/null +++ b/packages/magento-graphql/schema-247/Query-recaptchaV3Config.graphqls @@ -0,0 +1,39 @@ +""" +Contains reCAPTCHA V3-Invisible configuration details. +""" +type ReCaptchaConfigurationV3 { + """ + The position of the invisible reCAPTCHA badge on each page. + """ + badge_position: String! + """ + The message that appears to the user if validation fails. + """ + failure_message: String! + """ + A list of forms on the storefront that have been configured to use reCAPTCHA V3. + """ + forms: [ReCaptchaFormEnum]! + """ + Return whether recaptcha is enabled or not + """ + is_enabled: Boolean! + """ + A two-character code that specifies the language that is used for Google reCAPTCHA text and messaging. + """ + language_code: String + """ + The minimum score that identifies a user interaction as a potential risk. + """ + minimum_score: Float! + """ + The website key generated when the Google reCAPTCHA account was registered. + """ + website_key: String! +} +type Query { + """ + Returns details about Google reCAPTCHA V3-Invisible configuration. + """ + recaptchaV3Config: ReCaptchaConfigurationV3 +} diff --git a/packages/magento-graphql/schema/Magento243to245.graphqls b/packages/magento-graphql/schema/Magento243to245.graphqls deleted file mode 100644 index b77f5466e4..0000000000 --- a/packages/magento-graphql/schema/Magento243to245.graphqls +++ /dev/null @@ -1,52 +0,0 @@ -# GraphCommerce 2.4.3 forward compatibility with 2.4.5 -# TODO: Remove forward compatibility layer when dropping support for 2.4.3 - -# Why does this exist? To fix and issue with a nasty bug in 2.4.3: -# When a product becomes out of stock it will return null for the cart line. - -interface CartItemInterface { - "An array of errors encountered while loading the cart item" - errors: [CartItemError] -} - -type BundleCartItem { - "An array of errors encountered while loading the cart item" - errors: [CartItemError] -} - -type ConfigurableCartItem { - "An array of errors encountered while loading the cart item" - errors: [CartItemError] -} - -type DownloadableCartItem { - "An array of errors encountered while loading the cart item" - errors: [CartItemError] -} - -type SimpleCartItem { - "An array of errors encountered while loading the cart item" - errors: [CartItemError] -} - -type VirtualCartItem { - "An array of errors encountered while loading the cart item" - errors: [CartItemError] -} - -type CartItemError { - "An error code that describes the error encountered" - code: CartItemErrorType! - "A localized error message" - message: String! -} - -type CartItemPrices { - price_including_tax: Money -} - -enum CartItemErrorType { - UNDEFINED - ITEM_QTY - ITEM_INCREMENTS -} diff --git a/packages/magento-pagebuilder/mesh/schema.graphqls b/packages/magento-pagebuilder/schema/PageBuilder.graphqls similarity index 100% rename from packages/magento-pagebuilder/mesh/schema.graphqls rename to packages/magento-pagebuilder/schema/PageBuilder.graphqls diff --git a/packages/magento-recently-viewed-products/graphql/RecentlyViewedProducts.graphqls b/packages/magento-recently-viewed-products/schema/RecentlyViewedProducts.graphqls similarity index 100% rename from packages/magento-recently-viewed-products/graphql/RecentlyViewedProducts.graphqls rename to packages/magento-recently-viewed-products/schema/RecentlyViewedProducts.graphqls diff --git a/packagesDev/graphql-codegen-near-operation-file/src/directive/env.graphqls b/packagesDev/graphql-codegen-near-operation-file/schema/env.graphqls similarity index 100% rename from packagesDev/graphql-codegen-near-operation-file/src/directive/env.graphqls rename to packagesDev/graphql-codegen-near-operation-file/schema/env.graphqls diff --git a/packagesDev/graphql-codegen-near-operation-file/src/directive/injectable.graphqls b/packagesDev/graphql-codegen-near-operation-file/schema/injectable.graphqls similarity index 100% rename from packagesDev/graphql-codegen-near-operation-file/src/directive/injectable.graphqls rename to packagesDev/graphql-codegen-near-operation-file/schema/injectable.graphqls diff --git a/packagesDev/next-config/__tests__/config/utils/__snapshots__/mergeEnvIntoConfig.ts.snap b/packagesDev/next-config/__tests__/config/utils/__snapshots__/mergeEnvIntoConfig.ts.snap index 9edfeb88fe..aa9f607763 100644 --- a/packagesDev/next-config/__tests__/config/utils/__snapshots__/mergeEnvIntoConfig.ts.snap +++ b/packagesDev/next-config/__tests__/config/utils/__snapshots__/mergeEnvIntoConfig.ts.snap @@ -58,6 +58,7 @@ exports[`traverses a schema and returns a list of env variables that match 1`] = "GC_HYGRAPH_WRITE_ACCESS_TOKEN", "GC_LIMIT_SSG", "GC_MAGENTO_ENDPOINT", + "GC_MAGENTO_VERSION", "GC_PREVIEW_SECRET", "GC_PRODUCT_FILTERS_LAYOUT", "GC_PRODUCT_FILTERS_PRO", diff --git a/packagesDev/next-config/__tests__/config/utils/mergeEnvIntoConfig.ts b/packagesDev/next-config/__tests__/config/utils/mergeEnvIntoConfig.ts index 2aa7ca6182..0e3ffb9ff2 100644 --- a/packagesDev/next-config/__tests__/config/utils/mergeEnvIntoConfig.ts +++ b/packagesDev/next-config/__tests__/config/utils/mergeEnvIntoConfig.ts @@ -32,6 +32,20 @@ it('parses an env config object', () => { expect(result).toMatchSnapshot() }) +it('parses an env string value to a number', () => { + const [envSchema] = configToEnvSchema(GraphCommerceConfigSchema()) + const result = envSchema.safeParse({ GC_MAGENTO_VERSION: '247' }) + + expect(result.success).toBe(true) + if (result.success) { + expect(result.data).toMatchInlineSnapshot(` + { + "GC_MAGENTO_VERSION": 247, + } + `) + } +}) + it('correctly validates if a value is JSON', () => { const [envSchema] = configToEnvSchema(GraphCommerceConfigSchema()) const result = envSchema.safeParse({ @@ -65,12 +79,12 @@ it('correctly validates if a value is JSON', () => { it('converts an env schema to a config schema', () => { const configFile: GraphCommerceConfig = { storefront: [{ locale: 'en', hygraphLocales: ['en'], magentoStoreCode: 'en_us' }], - customerRequireEmailConfirmation: false, productFiltersPro: false, canonicalBaseUrl: 'https://example.com', hygraphEndpoint: 'https://example.com', magentoEndpoint: 'https://example.com', previewSecret: 'secret', + magentoVersion: 247, } const environmentVariables = { diff --git a/packagesDev/next-config/dist/config/demoConfig.js b/packagesDev/next-config/dist/config/demoConfig.js index 091ddadede..a860d377e7 100644 --- a/packagesDev/next-config/dist/config/demoConfig.js +++ b/packagesDev/next-config/dist/config/demoConfig.js @@ -5,6 +5,7 @@ exports.demoConfig = { canonicalBaseUrl: 'https://graphcommerce.vercel.app', hygraphEndpoint: 'https://eu-central-1.cdn.hygraph.com/content/ckhx7xadya6xs01yxdujt8i80/master', magentoEndpoint: 'https://backend.reachdigital.dev/graphql', + magentoVersion: 246, storefront: [ { locale: 'en', magentoStoreCode: 'en_US', defaultLocale: true }, { diff --git a/packagesDev/next-config/dist/config/utils/mergeEnvIntoConfig.js b/packagesDev/next-config/dist/config/utils/mergeEnvIntoConfig.js index 9e775133f3..ba7f4a3472 100644 --- a/packagesDev/next-config/dist/config/utils/mergeEnvIntoConfig.js +++ b/packagesDev/next-config/dist/config/utils/mergeEnvIntoConfig.js @@ -75,7 +75,12 @@ function configToEnvSchema(schema) { }); return; } - if (node instanceof zod_1.ZodString || node instanceof zod_1.ZodNumber || node instanceof zod_1.ZodEnum) { + if (node instanceof zod_1.ZodNumber) { + envSchema[(0, exports.toEnvStr)(path)] = zod_1.z.coerce.number().optional(); + envToDot[(0, exports.toEnvStr)(path)] = (0, exports.dotNotation)(path); + return; + } + if (node instanceof zod_1.ZodString || node instanceof zod_1.ZodEnum) { envSchema[(0, exports.toEnvStr)(path)] = node.optional(); envToDot[(0, exports.toEnvStr)(path)] = (0, exports.dotNotation)(path); return; diff --git a/packagesDev/next-config/dist/generated/config.js b/packagesDev/next-config/dist/generated/config.js index f8580bd626..a93dc6eb8c 100644 --- a/packagesDev/next-config/dist/generated/config.js +++ b/packagesDev/next-config/dist/generated/config.js @@ -92,6 +92,7 @@ function GraphCommerceConfigSchema() { hygraphWriteAccessToken: _zod.z.string().nullish(), limitSsg: _zod.z.boolean().nullish(), magentoEndpoint: _zod.z.string().min(1), + magentoVersion: _zod.z.number(), previewSecret: _zod.z.string().nullish(), productFiltersLayout: ProductFiltersLayoutSchema.default("DEFAULT").nullish(), productFiltersPro: _zod.z.boolean().nullish(), diff --git a/packagesDev/next-config/src/config/demoConfig.ts b/packagesDev/next-config/src/config/demoConfig.ts index ea736a2e2a..dc4d3ecfce 100644 --- a/packagesDev/next-config/src/config/demoConfig.ts +++ b/packagesDev/next-config/src/config/demoConfig.ts @@ -7,6 +7,7 @@ export const demoConfig: PartialDeep; /** @@ -482,6 +488,7 @@ export function GraphCommerceConfigSchema(): z.ZodObject