-
Notifications
You must be signed in to change notification settings - Fork 212
@W-18172401 Integrate getUrlMapping on server-side navigation #2290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hajinsuha1
wants to merge
192
commits into
feature/extensibility-v2
Choose a base branch
from
implement-dynamic-update-routes
base: feature/extensibility-v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
192 commits
Select commit
Hold shift + click to select a range
02e1334
initial implementation of extension seo url mapping extension
hajinsuha1 41b34a7
make beforeRouteMatch async
hajinsuha1 87567d8
generate component map from react-sdk util function
hajinsuha1 0a42f90
use a component map that maps resource type to component display name
hajinsuha1 9b1dada
move logic from beforeRouteMatch to extendRoutes
hajinsuha1 b8505d0
make extendRoutes async
hajinsuha1 74ea27a
pass request to extendRoutes
hajinsuha1 5988996
add route serialization
hajinsuha1 61839ff
make category urlMappings work
hajinsuha1 1a8d1be
make urlMapping resourceType product work
hajinsuha1 8380df6
cleanup
hajinsuha1 182f7b6
move serializing to pwa-kit-react-sdk
hajinsuha1 babf5ab
move transformUrlMappingToRoute from pwa-kit-react-sdk to extension-s…
hajinsuha1 3651f4e
Merge branch 'feature/extensibility-v2' into implement-dynamic-update…
hajinsuha1 efdc0c5
cleanup
hajinsuha1 2d1031f
update package.json and package-lock.json in template-typescript-minimal
hajinsuha1 5e45dac
attempt to fix component not loading with props on server side
hajinsuha1 f178dec
implement route serialization/deserialization
hajinsuha1 cfd82eb
Merge branch 'route-serialization-to-support-shopper-seo-integration'…
hajinsuha1 7b8b80b
initial pass at implementing route serialization via a componentMap
hajinsuha1 4f30443
update error handling message format
hajinsuha1 c78b81b
Merge branch 'route-serialization-to-support-shopper-seo-integration'…
hajinsuha1 55c4415
cleanup and fix getRoutes to not duplicate routes
hajinsuha1 5da9d8e
Convert extendRoutes to an async method
vmarta 4d13fe3
create a helper function generateComponentMapFromModules
hajinsuha1 8a54875
Add todos
vmarta 4604d76
Temporarily modify the typescript-minimal project
vmarta e6542fc
initial impl of adding base template components to component map
hajinsuha1 7a1f51f
Minor refactoring
vmarta ddb88d2
Call every extension's route function in parallel
vmarta 138f44b
create a prefixDisplayName utils
hajinsuha1 3bfa646
update error handling
hajinsuha1 2054078
fix deserialization of components from pwa-kit-react-sdk
hajinsuha1 a547b24
Merge branch 'vm/async-extendRoutes' into route-serialization-to-supp…
hajinsuha1 63a9d1f
merge
hajinsuha1 d90c79c
initial implementation of serialize/deserialize
hajinsuha1 c67fefa
cleanup
hajinsuha1 af9f3df
make serialize() and getComponentMap() synchronous
hajinsuha1 b002c86
Pass in the request path
vmarta bd74cf8
cache getRoutes using CacheResult decorator
hajinsuha1 b84c8c3
move deserialization logic to constructor of ApplicationExtension
hajinsuha1 3a9f90d
call this.getComponentMap within deserialize and fix typing
hajinsuha1 4a3a6ce
cleanup serialize logic
hajinsuha1 6d92af9
Explore passing in locals and how to manage access token
vmarta 9f6c055
Remove extendRoutes from the API
vmarta 6d5fb39
Allow configuring of the auth property name in locals
vmarta 0115d21
comments + create DeserializedExtension type
hajinsuha1 fa85193
make getComponentMap abstract
hajinsuha1 040e3f1
add ComponentMap type to getComponentMap method in ChakraStorefront a…
hajinsuha1 86a78ed
add displayName to StoreLocatorPage
hajinsuha1 0a7e855
Rename the property in locals
vmarta 9acff92
add unit tests for cacheResult
hajinsuha1 c5d924b
Create a new extension for a better example
vmarta 2206dd5
Add some console logs
vmarta 392387a
refactor Switch component to use RoutesProvider and create RoutesCons…
hajinsuha1 0c1bd41
update CacheResult decorator to support async methods and modify test…
hajinsuha1 08e72bd
enhance CacheResult decorator to support both async and sync methods …
hajinsuha1 0dbbb34
refactor getRoutes method to support both sync and async returns and …
hajinsuha1 8324897
refactor ApplicationExtension to enforce getComponentMap() for async …
hajinsuha1 5586726
cleanup ApplicationExtension and apply CacheResult to getRoutes metho…
hajinsuha1 645a91f
move CacheResult decorator logic to applyCacheForMethod in Applicatio…
hajinsuha1 d0ffc37
don't make getComponentMap abstract but make it optional
hajinsuha1 f97aaed
remove unused ComponentMap import from test files
hajinsuha1 42879f5
Experiment with having partial route
vmarta b71c0b9
Experiment with correct way to get app origin
vmarta bb692bc
Add todo
vmarta 0d2ed3b
Some cleanup
vmarta 35a453e
lint
hajinsuha1 272639f
cleanup
hajinsuha1 2067892
Fix the partial route with correct path
vmarta 0e44b84
Remove no longer necessary code
vmarta 1579626
Combine params into a single object
vmarta 806fa87
Remove some console logs
vmarta 85f9516
add async route handling and serialization tests for ApplicationExten…
hajinsuha1 11b5af3
Add comment to clarify
vmarta 6402e62
handle all condiiton in deserialize and move applyCacheForMethod to a…
hajinsuha1 e8bba80
refactor: rename getRoutes to getRoutesAsync for clarity and update r…
hajinsuha1 af93217
refactor: remove isGetRoutesAsync method as it's no longer needed
hajinsuha1 579bdf3
Implement getRoutes and getRoutesAsync
vmarta 18adf16
Add comment
vmarta d9b32e2
Add comment
vmarta 4ad2535
Merge branch 'vm/async-extendRoutes' into route-serialization-to-supp…
hajinsuha1 965a34a
update getRoutesAsync to also return SerializedRoute and serialize to…
hajinsuha1 6baf649
cleanup decorator and chakra-storefront
hajinsuha1 5dbe489
update URLMapping.getRoutesAsync and BeforeRouteMatchParams to suppor…
hajinsuha1 26da1ee
address PR feedback
hajinsuha1 f1eab7c
update error message
hajinsuha1 0a1626c
fix cacheMethodResult
hajinsuha1 c622823
Add type to allow for `componentName` property
vmarta 92a1c9a
fix ApplicationExtension.test.tsx
hajinsuha1 f615878
Merge branch 'vm/async-extendRoutes' into route-serialization-to-supp…
hajinsuha1 38e352f
Remove params for `getRoutes`
vmarta 4119cda
Remove params for getRoutes
vmarta 6677213
refactor: update route handling to use RouteProps exclusively and imp…
hajinsuha1 0058e80
Merge branch 'vm/async-extendRoutes' into route-serialization-to-supp…
hajinsuha1 fa4540a
refactor: rename GetRoutesParams to GetRoutesAsyncParams for to fix e…
hajinsuha1 4af8642
update unit tests
hajinsuha1 7fdd261
Revert "Remove params for `getRoutes`"
vmarta bcdcea3
Revert "Remove params for getRoutes"
vmarta 7b48662
Merge branch 'vm/async-extendRoutes' into route-serialization-to-supp…
hajinsuha1 62e0060
reorganize imports for RoutesContext and unit tests
hajinsuha1 347c486
Merge branch 'route-serialization-to-support-shopper-seo-integration'…
hajinsuha1 de121c3
Add isServerSide utility function and corresponding tests
hajinsuha1 2152142
lint
hajinsuha1 ab23cd6
[REVERT] temporary logging for testing
hajinsuha1 5236d90
Remove unused properties from global Window interface in type definit…
hajinsuha1 131f670
update changelog
hajinsuha1 6e257cd
Refactor so that extension is the one in control of serialization
vmarta edcae1d
Update packages/pwa-kit-extension-sdk/src/react/classes/ApplicationEx…
hajinsuha1 04ee8fb
update unit tests and add error handling
hajinsuha1 c6be840
Merge branch 'route-serialization-to-support-shopper-seo-integration'…
hajinsuha1 c8e8035
lint
hajinsuha1 88419bf
lint
hajinsuha1 e9c00dd
lint extension-url-mapping
hajinsuha1 4d2587a
Merge branch 'route-serialization-to-support-shopper-seo-integration'…
hajinsuha1 1de2122
Update comments
vmarta 38425c2
Update tests
vmarta 2f1a48a
rename extension-url-mapping to extension-commerce-bm-seo
hajinsuha1 2bcbbc2
Update tests
vmarta 7ba4d99
Revert changes to typescript-minimal
vmarta 7c731f2
Merge branch 'feature/extensibility-v2' into vm/async-extendRoutes
vmarta a2096c3
Update package-lock.json
vmarta 18a566f
Update changelog files
vmarta 0e0edcb
Update readme files
vmarta 422bd78
Merge branch 'vm/async-extendRoutes' into route-serialization-to-supp…
hajinsuha1 7ed9fbd
Refactor ApplicationExtension tests to use correct component types an…
hajinsuha1 e08d7ce
Remove extension-url-mapping package and associated files
hajinsuha1 bab7884
fix unit tests
hajinsuha1 c594557
Revert "Remove extension-url-mapping package and associated files"
hajinsuha1 794b0a3
lint
hajinsuha1 0cd67cc
Revert "Revert changes to typescript-minimal"
hajinsuha1 54ec28a
remove extension-url-mapping, logging, changes to typescript-minimal
hajinsuha1 6d7c6a9
update maxSize for build/vendor.js to 353 kB in template-retail-react…
hajinsuha1 12b071b
update CHANGELOG.md for template-retail-react-app
hajinsuha1 fc461cd
add ResourceTypeToComponentMap and move functions to utils
hajinsuha1 5f5de44
Add jsdoc to some types
vmarta ad8933a
Update packages/pwa-kit-extension-sdk/src/react/classes/ApplicationEx…
hajinsuha1 f65cf58
address PR feedback (remove unnecessary code)
hajinsuha1 876b4c2
Revert "remove extension-url-mapping, logging, changes to typescript-…
hajinsuha1 ad6d337
update ApplicationExtension unit test
hajinsuha1 f05a70a
Revert "Revert "remove extension-url-mapping, logging, changes to typ…
hajinsuha1 16f461b
Merge branch 'vm/async-extendRoutes' into route-serialization-to-supp…
hajinsuha1 7aa5a85
Revert "remove extension-url-mapping, logging, changes to typescript-…
hajinsuha1 c9a58da
Merge branch 'route-serialization-to-support-shopper-seo-integration'…
hajinsuha1 b01d659
refactor such that extension-commerce-bm-seo handles deserialization …
hajinsuha1 0751fd9
refactor serialize and deserialize to be serializeRoutes and deserial…
hajinsuha1 8017fa6
cleanup beforeRouteMatch
hajinsuha1 d3b5651
cleanup
hajinsuha1 07d7da0
address PR feedback
hajinsuha1 0fe9e28
Merge branch 'feature/extensibility-v2' into implement-dynamic-update…
hajinsuha1 90fabe5
lint
hajinsuha1 ef43d50
support redirect url mappings
hajinsuha1 03dda35
attempt passing props to ProductDetail/ProductList component
hajinsuha1 a0c8a18
fix placeholder component
hajinsuha1 5f11e34
refactor to make setup-app more readable
hajinsuha1 b4a23f2
implementation where PLP and PDP on client side doesn't get props
hajinsuha1 12e4116
implement option 1 add componentProps to RouteProps and serialize it
hajinsuha1 ac3cf68
make deserialization work for both extension-seo and regular extensions
hajinsuha1 9129a42
remove logging
hajinsuha1 3782fb9
allow extension-seo to work regardless of whether it is before/after …
hajinsuha1 6ed3ffa
add AsyncRouteProps type
hajinsuha1 0de2b6a
remove getComponentName utility method
hajinsuha1 8382e9a
cleanup
hajinsuha1 a27ce96
Merge branch 'feature/extensibility-v2' into implement-dynamic-update…
hajinsuha1 0096116
reorganize utils
hajinsuha1 da93df5
support unit tests
hajinsuha1 b42d623
add jest.config.js (copied from extension-chakra-store-locator)
hajinsuha1 ceae1c5
add component-utils unit tests
hajinsuha1 78837c1
remove path from config and add shopper-seo-utils unit tests
hajinsuha1 a2113da
initial README.md
hajinsuha1 6cfecf0
update README
hajinsuha1 613813e
Merge branch 'feature/extensibility-v2' into implement-dynamic-update…
hajinsuha1 be17100
hardcode __commerceAPIAuth property in locals and use getAppOrigin fr…
hajinsuha1 366c74b
cleanup
hajinsuha1 c4a432f
Merge branch 'implement-dynamic-update-routes' of https://github.com/…
hajinsuha1 cc4714b
fix type errors
hajinsuha1 ade541e
Revert to test changes
hajinsuha1 44dcdc7
Revert "Revert to test changes"
hajinsuha1 3adf867
cleanup
hajinsuha1 4b91cbd
REVERT TO TEST CHANGES
hajinsuha1 6a1caee
Merge branch 'feature/extensibility-v2' into implement-dynamic-update…
hajinsuha1 93f6789
fix failing CI
hajinsuha1 70dcfb1
fix unit tests
hajinsuha1 1a3fda9
Merge branch 'feature/extensibility-v2' into implement-dynamic-update…
hajinsuha1 c78d0cd
[App Extensibility ⚙️] Remove `extension-` prefix requirement (@W-181…
adamraya 1bdf645
fix failing CI
hajinsuha1 83332ff
fix unit tests
hajinsuha1 c0b0803
Merge branch 'implement-dynamic-update-routes' of https://github.com/…
hajinsuha1 07598e4
add comment for W-18474745 todo
hajinsuha1 75c2a0c
Bump version to 0.1.0-extensibility-preview.5 and update dependencies…
hajinsuha1 1d524d1
TEST CHANGES
hajinsuha1 98a5011
Revert this commit to TEST CHANGES
hajinsuha1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /* | ||
| * Copyright (c) 2021, salesforce.com, inc. | ||
| * All rights reserved. | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
| */ | ||
|
|
||
| module.exports = { | ||
| extends: [require.resolve('@salesforce/pwa-kit-dev/configs/eslint')] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| dev/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| coverage | ||
| dist | ||
| generator-assets | ||
| docs | ||
| vendor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| printWidth: 100 | ||
| singleQuote: true | ||
| semi: false | ||
| bracketSpacing: false | ||
| tabWidth: 4 | ||
| arrowParens: 'always' | ||
| trailingComma: 'none' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| :loudspeaker: Hey there, Salesforce Commerce Cloud community! | ||
|
|
||
| We’re excited to hear your thoughts on your developer experience with PWA Kit and the Composable Storefront generally! Your feedback is incredibly valuable in helping us guide our roadmap and improve our offering. | ||
|
|
||
| :clipboard: Take our quick survey here: [Survey](https://forms.gle/bUZNxQ3QKUcrjhV18) | ||
|
|
||
| Feel free to share this survey link with your colleagues, partners, or anyone who has experience with PWA Kit. Your input will help us shape the future of our development tools. | ||
|
|
||
| Thank you for being a part of our community and for your continuous support! :raised_hands: | ||
|
|
||
| # Description | ||
|
|
||
| This is a sample PWA-Kit Application Extension. The purpose of this application extensions is to show how | ||
| the Application Extensions API can be used to enhance your PWA-Kit base project. | ||
|
|
||
| # Folder Structure | ||
|
|
||
| This directory contains the PWA Kit Application Extension base files and structure. It includes the following files: | ||
| ``` | ||
| ├── src | ||
| │ ├── setup-server.ts | ||
| │ └── setup-client.ts | ||
| └── dev | ||
| ``` | ||
|
|
||
| 1. `src/setup-server.ts`: The server-side setup function for the extension. | ||
| 2. `src/setup-client.ts`: The client-side setup function for the extension. | ||
| 3. `dev/`: PWA Kit App TypeScript template project used for developing the generated PWA Kit App Extension. | ||
|
|
||
| # Peer Dependencies | ||
|
|
||
| PWA-Kit Application Extensions are NPM packages at their most simplest form, and as such you can define | ||
| what peer dependencies are required when using it. Because this sample application extension provides | ||
| UI via a new "Sample" page, it requires that the below dependencies are installed at a minimum. | ||
|
|
||
| Depending on what features your application extensions provides it's recommended you include any third-party | ||
| packages as peer dependencies so that your base application doesn't end up having multiple versions of a | ||
| given package. | ||
|
|
||
| "react": "^18.2.0", | ||
| "react-dom": "^18.2.0" | ||
|
|
||
| # Configuration | ||
|
|
||
| This section is optional and will depend on your application extensions implementation. If you have features | ||
| that are configurable, then list those configurations here so that the PWA-Kit project implementor can configure | ||
| the extension as they like. | ||
|
|
||
| ``` | ||
| { | ||
| path: '/sample-page' | ||
| } | ||
| ``` | ||
|
|
||
| # Installation | ||
|
|
||
| ``` | ||
| > npm install @salesforce/extension-starter<br/> | ||
| > Downloading npm package... <br/> | ||
| > Installing extension... <br/> | ||
| > Finished. <br/> | ||
| > Congratulations! The Sample extension was successfully installed! Please visit https://www.npmjs.com/package/@salesforce/extension-starter for more information on how to use this extension. | ||
| ``` | ||
|
|
||
| # State Management | ||
|
|
||
| By default all extensions are enhanced with state management using the `withApplicationExtensionStore` higher-order component. Under the hood | ||
| the state is provided using [Zustand](https://www.npmjs.com/package/zustand) as a global store for the entire PWA-Kit application. | ||
| Each Application Extension inserts a "slice" into this global store following the | ||
| [slicing pattern](https://github.com/pmndrs/zustand/blob/37e1e3f193a5e5dec6fbd0f07514aec59a187e01/docs/guides/slices-pattern.md). | ||
| This allows you to have data separation from one extension to the other, but also allows you to access state and associated actions of other extensions when needed. | ||
|
|
||
| You can access the state of other extensions via the global store. Below is an example of why you might want to access state and actions from another extensions. In the following snippet we use the global store to access actions from the store locator. You can then use these actions as you please. | ||
|
|
||
| This is how you would do something like this. | ||
|
|
||
| ``` | ||
| // /base-project/app/components/my-component.jsx | ||
| import {useApplicationExtensionsStore} from '@salesforce/pwa-kit-extension-sdk/react' | ||
|
|
||
| export MyComponent = () => { | ||
| // Zustand V5 requires stable selector outputs. E.g. Do NOT return a new reference in your selectors return value. This will | ||
| // cause infinite re-renders. | ||
| const defaultState = {} | ||
|
|
||
| // Grab the slice of the extension state for "extension-a" | ||
| const {toggleMapsModal} = useApplicationExtensionsStore( | ||
| (state) => | ||
| state.state['@salesforce/extension-store-locator'] || defaultState | ||
| ) | ||
|
|
||
| return ( | ||
| <div> | ||
| <button onClick={() => toggleMapsModal()}/> | ||
| </div> | ||
| ) | ||
| } | ||
| ``` | ||
|
|
||
| # Advanced Usage | ||
|
|
||
| As an application extension developer you are responsible for documenting how your extension works including basic usage, its configuration, and advanced customization via overrides. Use this section to explain how your extension can use overrides to accomplish this. Make should to include what files are overridable as well as their expected inputs and outputs. | ||
|
|
||
| ## Overridable Files | ||
|
|
||
| ``` | ||
| /src/path/to/overridable/files.ts | ||
| ``` |
hajinsuha1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # Extension Configuration 🧩 | ||
|
|
||
| In most cases it's beneficial to make your application extension configurable. This will allow your extension to meet the needs of different PWA-Kit developers whom have varying requirements. This can be as simple as configuring the url path to the page your extension adds, to more complex scenarios like configuring layouts to those same pages. | ||
|
|
||
|
|
||
| ## `Sample` vs `Default` Configurations | ||
|
|
||
| This folder is home to two configuration files, `default.json` and `sample.json`. Both of which have their type define in the `src/types/config` file. But these files are used differently. Below is a summary of how each file is used. | ||
|
|
||
| ### `default.json` | ||
|
|
||
| This configuration is used during the project generation as well as the extensions loading phase when running your PWA-Kit application. | ||
|
|
||
| During your PWA-Kit project generation, you can select which extensions are configured for your app. This ultimately leads to your applications configuration being setup with the extensions selected during the project questionnaire phase. For example, if you were to choose to use `@salesforce/extension-chakra-storefront` in your PWA-Kit app, then you might see something along the lines of this in your app config, where `<user_defined_configuration>` is initially set to the contents of the `default.json` file: | ||
|
|
||
| ``` | ||
| app: { | ||
| extensions: [ | ||
| ['@salesforce/extension-chakra-storefront', <user_defined_configuration>] | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| Additionally, during the PWA-Kit application execution the default configuration is merged with the user define configuration to ensure that all configuration key have a value. This means that you do not have to worry about scattering default values in your extensions code, whether it's in a React component or the setup files. | ||
|
|
||
| It's worth noting that if your configuration file is expected to have values supplied by the PWA-Kit application developer, you can use placeholder values that will prompt the developer to replace them with real world values. Below is an example default config file with a placeholder: | ||
|
|
||
| ``` | ||
| { | ||
| "enabled": true, | ||
| "activeDataEnabled": false, | ||
| "categoryNav": { | ||
| "defaultNavSsrDepth": 1, | ||
| "defaultRootCategory": "root" | ||
| }, | ||
| "commerceAPI": { | ||
| "proxyPath": "/mobify/proxy/api", | ||
| "parameters": { | ||
| "clientId": "<CLIENT_ID>", | ||
| "organizationId": "<ORGANIZATION_ID>", | ||
| "shortCode": "<SHORT_CODE>", | ||
| "siteId": "<SITE_ID>" | ||
| } | ||
| }, | ||
| ... | ||
| } | ||
| ``` | ||
|
|
||
| ### `sample.json` | ||
|
|
||
| This configuration is similar in many ways to the one above, with the primary difference being that you cannot use placeholder values in it. The configuration is expected to have all its properties defined with valid values. | ||
|
|
||
| This configuration file is used internally by the PWA-Kit create-app application whenever a project is generated using a preset. This allows us to create E2E tests on our CI environment where we know that a project generated can be run without further modification to the configuration file. | ||
|
|
||
| We also recommend that you reference this configuration file from your extensions root README so that developers know what a valid configuration looks like. | ||
|
|
||
| ## How to use your extension configuration? | ||
|
|
||
| Your extensions configuration can be used in different ways depending on the context in which you want to use it. Your configuration will primarily be used in two places, your React components and your extension setup files. | ||
|
|
||
| ### Setup Files | ||
|
|
||
| The exported extension classes in `setup-app.ts` and `setup-server.ts` are extended from the `ApplicationExtension` class. This class provide a method called `getConfig` which returns the configuration your extension was instantiated with. you can use this method to grab the configuration and use it however you want. | ||
|
|
||
| Please refer to the `src/setup-app.ts` file to see a sample of how it's being used in the `extendRoutes` implementation. | ||
|
|
||
| ### React Components | ||
|
|
||
| Every application extension generated will have a convenience hook scaffolded for you located at `src/hooks/use-extension-config`. You can use this hook in any pages, components, or other hooks that you add to your extension. Below is an example component that uses this hook: | ||
|
|
||
| ``` | ||
| // src/components/sample-component.tsx | ||
| import React from 'react' | ||
| import {useExtensionConfig} from '../hooks/use-extension-config' | ||
|
|
||
| export const Sample = (): JSX.Element => { | ||
| const {path} = useExtensionConfig() | ||
|
|
||
| return ( | ||
| <span>{path}<span/> | ||
| ) | ||
| } | ||
|
|
||
| export default Sample | ||
| ``` | ||
|
|
||
| ### Other Contexts | ||
|
|
||
| If you plan on using the extension configuration in other contexts such as utility files, we recommend that you use dependency injection whenever possible. Passing in the configuration to these utilities will not only be a simple solution, but it will also make testing these utilities easier if you choose to do that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "enabled": true, | ||
| "resourceTypeToComponentMap": { | ||
| "category": "ProductList", | ||
| "product": "ProductDetail", | ||
| "content_asset": "ProductList" | ||
| }, | ||
| "commerceAPI": { | ||
| "proxyPath": "/mobify/proxy/api", | ||
| "parameters": { | ||
| "clientId": "c9c45bfd-0ed3-4aa2-9971-40f88962b836", | ||
| "organizationId": "f_ecom_zzrf_001", | ||
| "shortCode": "8o7m175y", | ||
| "siteId": "RefArchGlobal" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "id": "@salesforce/extension-seo-url-mapping" | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.