shopify-app-js 0.0.1-security → 1.0.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.
Potentially problematic release.
This version of shopify-app-js might be problematic. Click here for more details.
- package/.changeset/README.md +8 -0
- package/.changeset/config.json +14 -0
- package/.changeset/flat-clouds-camp.md +5 -0
- package/.eslintrc.js +36 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/ISSUE_TEMPLATE/BUG_REPORT.md +36 -0
- package/.github/ISSUE_TEMPLATE/ENHANCEMENT.md +9 -0
- package/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md +9 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +34 -0
- package/.github/dependabot.yml +9 -0
- package/.github/workflows/changelog.yml +30 -0
- package/.github/workflows/ci.yml +22 -0
- package/.github/workflows/cla.yml +22 -0
- package/.github/workflows/close-waiting-for-response-issues.yml +20 -0
- package/.github/workflows/main-release.yml +36 -0
- package/.github/workflows/markdown_link_check.yml +14 -0
- package/.github/workflows/markdown_link_checker_config.json +9 -0
- package/.github/workflows/publish-experimental-build.yml +30 -0
- package/.github/workflows/release-candidate.yml +35 -0
- package/.github/workflows/remove-labels-on-activity.yml +16 -0
- package/.github/workflows/stale.yml +26 -0
- package/.prettierignore +5 -0
- package/.prettierrc +1 -0
- package/CODE_OF_CONDUCT.md +46 -0
- package/CONTRIBUTING.md +39 -0
- package/LICENSE.md +9 -0
- package/README.md +62 -3
- package/RELEASING.md +142 -0
- package/loom.config.ts +115 -0
- package/package.json +44 -3
- package/packages/.prettierrc +1 -0
- package/packages/shopify-app-express/CHANGELOG.md +316 -0
- package/packages/shopify-app-express/LICENSE.md +9 -0
- package/packages/shopify-app-express/README.md +93 -0
- package/packages/shopify-app-express/docs/reference/README.md +3 -0
- package/packages/shopify-app-express/docs/reference/auth.md +76 -0
- package/packages/shopify-app-express/docs/reference/cspHeaders.md +24 -0
- package/packages/shopify-app-express/docs/reference/ensureInstalledOnShop.md +17 -0
- package/packages/shopify-app-express/docs/reference/migrating-app-v6-api-lib-to-express-lib.md +345 -0
- package/packages/shopify-app-express/docs/reference/processWebhooks.md +67 -0
- package/packages/shopify-app-express/docs/reference/redirectOutOfApp.md +77 -0
- package/packages/shopify-app-express/docs/reference/redirectToShopifyOrAppRoot.md +20 -0
- package/packages/shopify-app-express/docs/reference/shopifyApp.md +148 -0
- package/packages/shopify-app-express/docs/reference/validateAuthenticatedSession.md +30 -0
- package/packages/shopify-app-express/loom.config.ts +27 -0
- package/packages/shopify-app-express/package.json +54 -0
- package/packages/shopify-app-express/src/__tests__/index.test.ts +100 -0
- package/packages/shopify-app-express/src/__tests__/integration/oauth.test.ts +445 -0
- package/packages/shopify-app-express/src/__tests__/integration/responses.ts +135 -0
- package/packages/shopify-app-express/src/__tests__/integration/types.ts +22 -0
- package/packages/shopify-app-express/src/__tests__/integration/utils.ts +68 -0
- package/packages/shopify-app-express/src/__tests__/integration/webhooks.test.ts +208 -0
- package/packages/shopify-app-express/src/__tests__/redirect-to-auth.test.ts +103 -0
- package/packages/shopify-app-express/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-express/src/__tests__/test-helper.ts +204 -0
- package/packages/shopify-app-express/src/app-installations.ts +42 -0
- package/packages/shopify-app-express/src/auth/__tests__/auth.test.ts +303 -0
- package/packages/shopify-app-express/src/auth/auth-callback.ts +131 -0
- package/packages/shopify-app-express/src/auth/index.ts +32 -0
- package/packages/shopify-app-express/src/auth/types.ts +13 -0
- package/packages/shopify-app-express/src/config-types.ts +38 -0
- package/packages/shopify-app-express/src/error.ts +8 -0
- package/packages/shopify-app-express/src/index.ts +171 -0
- package/packages/shopify-app-express/src/middlewares/__tests__/csp-headers.test.ts +69 -0
- package/packages/shopify-app-express/src/middlewares/__tests__/ensure-installed-on-shop.test.ts +193 -0
- package/packages/shopify-app-express/src/middlewares/__tests__/redirect-to-shopify-or-app-root.test.ts +59 -0
- package/packages/shopify-app-express/src/middlewares/__tests__/validate-authenticated-session.test.ts +319 -0
- package/packages/shopify-app-express/src/middlewares/csp-headers.ts +31 -0
- package/packages/shopify-app-express/src/middlewares/ensure-installed-on-shop.ts +176 -0
- package/packages/shopify-app-express/src/middlewares/has-valid-access-token.ts +25 -0
- package/packages/shopify-app-express/src/middlewares/index.ts +15 -0
- package/packages/shopify-app-express/src/middlewares/redirect-to-shopify-or-app-root.ts +39 -0
- package/packages/shopify-app-express/src/middlewares/types.ts +6 -0
- package/packages/shopify-app-express/src/middlewares/validate-authenticated-session.ts +142 -0
- package/packages/shopify-app-express/src/redirect-out-of-app.ts +80 -0
- package/packages/shopify-app-express/src/redirect-to-auth.ts +70 -0
- package/packages/shopify-app-express/src/types.ts +26 -0
- package/packages/shopify-app-express/src/version.ts +1 -0
- package/packages/shopify-app-express/src/webhooks/__tests__/process.test.ts +138 -0
- package/packages/shopify-app-express/src/webhooks/index.ts +54 -0
- package/packages/shopify-app-express/src/webhooks/process.ts +22 -0
- package/packages/shopify-app-express/src/webhooks/types.ts +24 -0
- package/packages/shopify-app-express/tsconfig.json +10 -0
- package/packages/shopify-app-remix/.eslintrc.js +3 -0
- package/packages/shopify-app-remix/CHANGELOG.md +569 -0
- package/packages/shopify-app-remix/LICENSE.md +9 -0
- package/packages/shopify-app-remix/README.md +223 -0
- package/packages/shopify-app-remix/docs/build-docs.sh +11 -0
- package/packages/shopify-app-remix/docs/generated/generated_docs_data.json +18650 -0
- package/packages/shopify-app-remix/docs/generated/generated_static_pages.json +540 -0
- package/packages/shopify-app-remix/docs/staticPages/admin.doc.ts +130 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/admin/auth-cors.example.tsx +11 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/admin/auth.example.tsx +19 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/admin/graphql.example.tsx +29 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/admin/headers.example.tsx +10 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/admin/rest-resources.example.tsx +9 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/admin/rest.example.tsx +17 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/future-flags/config.example.ts +8 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/future-flags/unstable.example.ts +9 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/.graphqlrc.ts +16 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/install.npm.example.sh +2 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/install.pnpm.example.sh +2 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/install.yarn.example.sh +2 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/package.json +5 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/run.npm.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/run.pnpm.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/run.yarn.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/webhooks/config.example.ts +19 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/webhooks/endpoint.example.ts +24 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/app-provider.example.ts +30 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/boundaries.example.ts +9 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/create.npm.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/create.pnpm.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/create.yarn.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/embedded-app-auth-strategy-config.example.ts +10 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/entry-server.example.ts +12 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/install.npm.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/install.pnpm.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/install.yarn.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/shopify-app.example.ts +14 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/splat-route.example.ts +11 -0
- package/packages/shopify-app-remix/docs/staticPages/future-flags.doc.ts +94 -0
- package/packages/shopify-app-remix/docs/staticPages/graphql-types.doc.ts +148 -0
- package/packages/shopify-app-remix/docs/staticPages/index.doc.ts +227 -0
- package/packages/shopify-app-remix/docs/staticPages/webhooks.doc.ts +64 -0
- package/packages/shopify-app-remix/docs/tsconfig.docs.json +9 -0
- package/packages/shopify-app-remix/docs/typeOverride.json +1 -0
- package/packages/shopify-app-remix/docs/upcoming_changes.md +153 -0
- package/packages/shopify-app-remix/loom.config.ts +57 -0
- package/packages/shopify-app-remix/package.json +93 -0
- package/packages/shopify-app-remix/src/react/.eslintrc.js +16 -0
- package/packages/shopify-app-remix/src/react/__tests__/test-helper.ts +22 -0
- package/packages/shopify-app-remix/src/react/components/AppProvider/AppProvider.doc.ts +34 -0
- package/packages/shopify-app-remix/src/react/components/AppProvider/AppProvider.tsx +121 -0
- package/packages/shopify-app-remix/src/react/components/AppProvider/__tests__/AppProvider.test.tsx +68 -0
- package/packages/shopify-app-remix/src/react/components/AppProvider/index.ts +1 -0
- package/packages/shopify-app-remix/src/react/components/RemixPolarisLink.tsx +14 -0
- package/packages/shopify-app-remix/src/react/components/index.ts +1 -0
- package/packages/shopify-app-remix/src/react/const.ts +2 -0
- package/packages/shopify-app-remix/src/react/index.ts +1 -0
- package/packages/shopify-app-remix/src/server/.eslintrc.js +16 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/__tests__/request-mock.test.ts +171 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/const.ts +11 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/expect-admin-api-client.ts +119 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/expect-begin-auth-redirect.ts +22 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/expect-document-request-headers.ts +25 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/expect-exit-iframe.ts +37 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/expect-login-redirect.ts +8 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/expect-storefront-api-client.ts +50 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/get-hmac.ts +10 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/get-jwt.ts +31 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/get-thrown-response.ts +17 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/index.ts +14 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/request-mock.ts +169 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/setup-valid-session.ts +45 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/sign-request-cookie.ts +21 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/test-config.ts +112 -0
- package/packages/shopify-app-remix/src/server/__tests__/override-logger.test.ts +101 -0
- package/packages/shopify-app-remix/src/server/__tests__/shopify-app.test.ts +119 -0
- package/packages/shopify-app-remix/src/server/adapters/__tests__/node-app-bridge-url.test.ts +18 -0
- package/packages/shopify-app-remix/src/server/adapters/__tests__/node.test.ts +28 -0
- package/packages/shopify-app-remix/src/server/adapters/node/__tests__/setup-jest.ts +10 -0
- package/packages/shopify-app-remix/src/server/adapters/node/index.ts +20 -0
- package/packages/shopify-app-remix/src/server/adapters/vercel/__tests__/setup-jest.ts +12 -0
- package/packages/shopify-app-remix/src/server/adapters/vercel/index.ts +13 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/__tests__/admin-client.test.ts +181 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/__tests__/doc-request-path.test.ts +151 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/__tests__/exit-i-frame-path.test.ts +99 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/__tests__/patch-session-token-path.test.ts +58 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/__tests__/reject-bot.test.ts +23 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/__tests__/respond-to-options.test.ts +50 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/__tests__/session-token-header-path.test.ts +91 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/authenticate.admin.doc.ts +37 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/authenticate.ts +201 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/__tests__/cancel.test.ts +258 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/__tests__/check.test.ts +254 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/__tests__/mock-responses.ts +65 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/__tests__/request.test.ts +373 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/__tests__/require.test.ts +316 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/authenticate.admin.billing.doc.ts +28 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/cancel.ts +37 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/check.ts +38 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/index.ts +4 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/request.ts +101 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/require.ts +56 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/types.ts +383 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/__tests__/redirect.test.ts +313 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/__tests__/validate-redirect-url.test.ts +84 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/begin-auth.ts +17 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/create-admin-api-context.ts +22 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/ensure-app-is-embedded-if-required.ts +18 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/ensure-session-token-search-param-if-required.ts +25 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/handle-client-error.ts +43 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/index.ts +14 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/redirect-to-auth-page.ts +28 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/redirect-to-bounce-page.ts +23 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/redirect-to-shopify-or-app-root.ts +21 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/redirect-with-app-bridge-headers.ts +13 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/redirect-with-exitiframe.ts +28 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/redirect.ts +83 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/render-app-bridge.ts +46 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/trigger-after-auth-hook.ts +28 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/validate-redirect-url.ts +67 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/validate-shop-and-host-params.ts +28 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/auth-code-flow/admin-client.test.ts +222 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/auth-code-flow/auth-callback-path.test.ts +395 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/auth-code-flow/auth-path.test.ts +83 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/auth-code-flow/authenticate.test.ts +183 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/auth-code-flow/ensure-installed-on-shop.test.ts +234 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/auth-code-flow/session-token-header-path.test.ts +79 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/token-exchange/admin-client.test.ts +189 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/token-exchange/authenticate.test.ts +310 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/auth-code-flow.ts +333 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/token-exchange.ts +169 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/types.ts +29 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/types.ts +199 -0
- package/packages/shopify-app-remix/src/server/authenticate/const.ts +15 -0
- package/packages/shopify-app-remix/src/server/authenticate/flow/__tests__/authenticate.test.ts +142 -0
- package/packages/shopify-app-remix/src/server/authenticate/flow/authenticate.flow.doc.ts +34 -0
- package/packages/shopify-app-remix/src/server/authenticate/flow/authenticate.ts +71 -0
- package/packages/shopify-app-remix/src/server/authenticate/flow/types.ts +90 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/__tests__/add-response-headers.test.ts +25 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/__tests__/app-bridge-url.test.ts +21 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/__tests__/idempotent-promise-handler.test.ts +104 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/add-response-headers.ts +43 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/app-bridge-url.ts +10 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/ensure-cors-headers.ts +38 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/get-session-token-header.ts +11 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/idempotent-promise-handler.ts +45 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/index.ts +8 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/reject-bot-request.ts +13 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/respond-to-invalid-session-token.ts +29 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/respond-to-options-request.ts +26 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/validate-session-token.ts +32 -0
- package/packages/shopify-app-remix/src/server/authenticate/login/__tests__/login.test.ts +157 -0
- package/packages/shopify-app-remix/src/server/authenticate/login/login.ts +53 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/__tests__/factory.test.ts +224 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/appProxy/__tests__/authenticate.test.ts +282 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/appProxy/authenticate.public.app-proxy.doc.ts +36 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/appProxy/authenticate.ts +90 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/appProxy/types.ts +164 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/checkout/__tests__/authenticate.test.ts +142 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/checkout/authenticate.public.checkout.doc.ts +23 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/checkout/authenticate.ts +45 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/checkout/types.ts +65 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/factory.ts +49 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/index.ts +1 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/types.ts +77 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/__tests__/authenticate.test.ts +207 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/__tests__/mock-responses.ts +45 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/__tests__/register.test.ts +210 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/authenticate.ts +113 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/authenticate.webhooks.doc.ts +28 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/index.ts +1 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/register.ts +48 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/types.ts +246 -0
- package/packages/shopify-app-remix/src/server/boundary/__tests__/error.test.tsx +36 -0
- package/packages/shopify-app-remix/src/server/boundary/__tests__/headers.test.ts +66 -0
- package/packages/shopify-app-remix/src/server/boundary/error.tsx +14 -0
- package/packages/shopify-app-remix/src/server/boundary/headers.ts +15 -0
- package/packages/shopify-app-remix/src/server/boundary/index.ts +39 -0
- package/packages/shopify-app-remix/src/server/boundary/types.ts +4 -0
- package/packages/shopify-app-remix/src/server/clients/admin/authenticate.admin.api.doc.ts +34 -0
- package/packages/shopify-app-remix/src/server/clients/admin/factory.ts +30 -0
- package/packages/shopify-app-remix/src/server/clients/admin/graphql.ts +39 -0
- package/packages/shopify-app-remix/src/server/clients/admin/index.ts +2 -0
- package/packages/shopify-app-remix/src/server/clients/admin/rest.ts +157 -0
- package/packages/shopify-app-remix/src/server/clients/admin/types.ts +178 -0
- package/packages/shopify-app-remix/src/server/clients/index.ts +2 -0
- package/packages/shopify-app-remix/src/server/clients/storefront/authenticate.storefront.api.doc.ts +34 -0
- package/packages/shopify-app-remix/src/server/clients/storefront/factory.ts +32 -0
- package/packages/shopify-app-remix/src/server/clients/storefront/index.ts +2 -0
- package/packages/shopify-app-remix/src/server/clients/storefront/types.ts +31 -0
- package/packages/shopify-app-remix/src/server/clients/types.ts +27 -0
- package/packages/shopify-app-remix/src/server/config-types.ts +293 -0
- package/packages/shopify-app-remix/src/server/errors.ts +3 -0
- package/packages/shopify-app-remix/src/server/future/flags.ts +57 -0
- package/packages/shopify-app-remix/src/server/index.ts +20 -0
- package/packages/shopify-app-remix/src/server/override-logger.ts +42 -0
- package/packages/shopify-app-remix/src/server/shopify-app.doc.ts +45 -0
- package/packages/shopify-app-remix/src/server/shopify-app.ts +198 -0
- package/packages/shopify-app-remix/src/server/types.ts +509 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/admin/__tests__/factory.test.ts +30 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/admin/factory.ts +29 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/admin/index.ts +1 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/admin/types.ts +117 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/admin/unauthenticated.admin.doc.ts +40 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/helpers/get-offline-session.ts +13 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/helpers/index.ts +1 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/storefront/__tests__/factory.test.ts +30 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/storefront/factory.ts +28 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/storefront/index.ts +1 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/storefront/types.ts +39 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/storefront/unauthenticated.storefront.doc.ts +40 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/types.ts +68 -0
- package/packages/shopify-app-remix/src/server/version.ts +1 -0
- package/packages/shopify-app-remix/tsconfig.json +11 -0
- package/packages/shopify-app-session-storage/CHANGELOG.md +149 -0
- package/packages/shopify-app-session-storage/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage/README.md +5 -0
- package/packages/shopify-app-session-storage/implementing-session-storage.md +214 -0
- package/packages/shopify-app-session-storage/loom.config.ts +45 -0
- package/packages/shopify-app-session-storage/package.json +44 -0
- package/packages/shopify-app-session-storage/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage/src/abstract-migration-engine.ts +53 -0
- package/packages/shopify-app-session-storage/src/index.ts +3 -0
- package/packages/shopify-app-session-storage/src/rdbms-session-storage-migrator.ts +59 -0
- package/packages/shopify-app-session-storage/src/types.ts +174 -0
- package/packages/shopify-app-session-storage/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-dynamodb/CHANGELOG.md +150 -0
- package/packages/shopify-app-session-storage-dynamodb/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-dynamodb/README.md +75 -0
- package/packages/shopify-app-session-storage-dynamodb/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-dynamodb/package.json +51 -0
- package/packages/shopify-app-session-storage-dynamodb/src/__tests__/dynamodb.test.ts +93 -0
- package/packages/shopify-app-session-storage-dynamodb/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-dynamodb/src/dynamodb.ts +126 -0
- package/packages/shopify-app-session-storage-dynamodb/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-kv/CHANGELOG.md +204 -0
- package/packages/shopify-app-session-storage-kv/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-kv/README.md +41 -0
- package/packages/shopify-app-session-storage-kv/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-kv/package.json +52 -0
- package/packages/shopify-app-session-storage-kv/src/__tests__/kv-namespace-dummy-worker.ts +8 -0
- package/packages/shopify-app-session-storage-kv/src/__tests__/kv.test.ts +22 -0
- package/packages/shopify-app-session-storage-kv/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-kv/src/kv.ts +87 -0
- package/packages/shopify-app-session-storage-kv/tsconfig.json +11 -0
- package/packages/shopify-app-session-storage-memory/CHANGELOG.md +190 -0
- package/packages/shopify-app-session-storage-memory/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-memory/README.md +19 -0
- package/packages/shopify-app-session-storage-memory/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-memory/package.json +46 -0
- package/packages/shopify-app-session-storage-memory/src/__tests__/memory.test.ts +12 -0
- package/packages/shopify-app-session-storage-memory/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-memory/src/memory.ts +34 -0
- package/packages/shopify-app-session-storage-memory/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-mongodb/CHANGELOG.md +208 -0
- package/packages/shopify-app-session-storage-mongodb/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-mongodb/README.md +30 -0
- package/packages/shopify-app-session-storage-mongodb/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-mongodb/package.json +49 -0
- package/packages/shopify-app-session-storage-mongodb/src/__tests__/mongodb.test.ts +54 -0
- package/packages/shopify-app-session-storage-mongodb/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-mongodb/src/mongodb.ts +120 -0
- package/packages/shopify-app-session-storage-mongodb/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-mysql/CHANGELOG.md +220 -0
- package/packages/shopify-app-session-storage-mysql/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-mysql/README.md +41 -0
- package/packages/shopify-app-session-storage-mysql/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-mysql/package.json +50 -0
- package/packages/shopify-app-session-storage-mysql/src/__tests__/mysql.test.ts +137 -0
- package/packages/shopify-app-session-storage-mysql/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-mysql/src/migrations.ts +18 -0
- package/packages/shopify-app-session-storage-mysql/src/mysql-connection.ts +108 -0
- package/packages/shopify-app-session-storage-mysql/src/mysql-migrator.ts +53 -0
- package/packages/shopify-app-session-storage-mysql/src/mysql.ts +178 -0
- package/packages/shopify-app-session-storage-mysql/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-postgresql/CHANGELOG.md +210 -0
- package/packages/shopify-app-session-storage-postgresql/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-postgresql/README.md +39 -0
- package/packages/shopify-app-session-storage-postgresql/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-postgresql/package.json +52 -0
- package/packages/shopify-app-session-storage-postgresql/src/__tests__/migrate-to-case-sensitivity.test.ts +344 -0
- package/packages/shopify-app-session-storage-postgresql/src/__tests__/postgresql.test.ts +136 -0
- package/packages/shopify-app-session-storage-postgresql/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-postgresql/src/migrations.ts +70 -0
- package/packages/shopify-app-session-storage-postgresql/src/postgres-connection.ts +94 -0
- package/packages/shopify-app-session-storage-postgresql/src/postgres-migrator.ts +27 -0
- package/packages/shopify-app-session-storage-postgresql/src/postgresql.ts +178 -0
- package/packages/shopify-app-session-storage-postgresql/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-prisma/CHANGELOG.md +148 -0
- package/packages/shopify-app-session-storage-prisma/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-prisma/README.md +68 -0
- package/packages/shopify-app-session-storage-prisma/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-prisma/package.json +51 -0
- package/packages/shopify-app-session-storage-prisma/prisma/migrations/20230425184828_init/migration.sql +11 -0
- package/packages/shopify-app-session-storage-prisma/prisma/migrations/20230906155758_mySession/migration.sql +11 -0
- package/packages/shopify-app-session-storage-prisma/prisma/migrations/migration_lock.toml +3 -0
- package/packages/shopify-app-session-storage-prisma/prisma/schema.prisma +30 -0
- package/packages/shopify-app-session-storage-prisma/src/__tests__/prisma.test.ts +66 -0
- package/packages/shopify-app-session-storage-prisma/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-prisma/src/prisma.ts +145 -0
- package/packages/shopify-app-session-storage-prisma/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-redis/CHANGELOG.md +200 -0
- package/packages/shopify-app-session-storage-redis/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-redis/README.md +38 -0
- package/packages/shopify-app-session-storage-redis/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-redis/package.json +50 -0
- package/packages/shopify-app-session-storage-redis/src/__tests__/migration-test-data.ts +46 -0
- package/packages/shopify-app-session-storage-redis/src/__tests__/redis.conf +2 -0
- package/packages/shopify-app-session-storage-redis/src/__tests__/redis.test.ts +236 -0
- package/packages/shopify-app-session-storage-redis/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-redis/src/migrations.ts +36 -0
- package/packages/shopify-app-session-storage-redis/src/redis-connection.ts +64 -0
- package/packages/shopify-app-session-storage-redis/src/redis-migrator.ts +58 -0
- package/packages/shopify-app-session-storage-redis/src/redis.ts +167 -0
- package/packages/shopify-app-session-storage-redis/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-sqlite/CHANGELOG.md +202 -0
- package/packages/shopify-app-session-storage-sqlite/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-sqlite/README.md +25 -0
- package/packages/shopify-app-session-storage-sqlite/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-sqlite/package.json +51 -0
- package/packages/shopify-app-session-storage-sqlite/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-sqlite/src/__tests__/sqlite.test.ts +44 -0
- package/packages/shopify-app-session-storage-sqlite/src/migrations.ts +54 -0
- package/packages/shopify-app-session-storage-sqlite/src/sqlite-connection.ts +80 -0
- package/packages/shopify-app-session-storage-sqlite/src/sqlite-migrator.ts +34 -0
- package/packages/shopify-app-session-storage-sqlite/src/sqlite.ts +147 -0
- package/packages/shopify-app-session-storage-sqlite/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-test-utils/CHANGELOG.md +185 -0
- package/packages/shopify-app-session-storage-test-utils/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-test-utils/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-test-utils/package.json +48 -0
- package/packages/shopify-app-session-storage-test-utils/src/__tests__/session-test-utils.test.ts +273 -0
- package/packages/shopify-app-session-storage-test-utils/src/battery-of-tests.ts +250 -0
- package/packages/shopify-app-session-storage-test-utils/src/index.ts +2 -0
- package/packages/shopify-app-session-storage-test-utils/src/session-test-utils.ts +24 -0
- package/packages/shopify-app-session-storage-test-utils/src/utils.ts +71 -0
- package/packages/shopify-app-session-storage-test-utils/tsconfig.json +10 -0
- package/tests/setup/build.js +1 -0
- package/tests/setup/setup-jest.ts +8 -0
- package/tsconfig.base.json +41 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shopify/shopify-app-remix",
|
|
3
|
+
"version": "2.6.1",
|
|
4
|
+
"description": "Shopify Remix - to simplify the building of Shopify Apps with Remix",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Shopify/shopify-app-js.git"
|
|
8
|
+
},
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/Shopify/shopify-app-js/issues"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/Shopify/shopify-app-js/tree/main/packages/shopify-app-remix",
|
|
13
|
+
"author": "Shopify Inc.",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"types": "./build/ts/server/index.d.ts",
|
|
16
|
+
"main": "./build/cjs/server/index.js",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./build/ts/server/index.d.ts",
|
|
20
|
+
"default": "./build/cjs/server/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./adapters/*": "./build/cjs/server/adapters/*/index.js",
|
|
23
|
+
"./server": {
|
|
24
|
+
"types": "./build/ts/server/index.d.ts",
|
|
25
|
+
"default": "./build/cjs/server/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./server/adapters/*": "./build/cjs/server/adapters/*/index.js",
|
|
28
|
+
"./react": {
|
|
29
|
+
"types": "./build/ts/react/index.d.ts",
|
|
30
|
+
"default": "./build/cjs/react/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build-docs": "sh docs/build-docs.sh",
|
|
35
|
+
"validate-docs": "sh ./docs/build-docs.sh isTest && yarn compare-docs"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"shopify",
|
|
42
|
+
"javascript",
|
|
43
|
+
"typescript",
|
|
44
|
+
"remix",
|
|
45
|
+
"app",
|
|
46
|
+
"graphql",
|
|
47
|
+
"rest",
|
|
48
|
+
"webhook",
|
|
49
|
+
"Admin API",
|
|
50
|
+
"Storefront API"
|
|
51
|
+
],
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@remix-run/react": "^2.6.0",
|
|
54
|
+
"@shopify/generate-docs": "^0.13.1",
|
|
55
|
+
"@shopify/polaris": "^12.18.0",
|
|
56
|
+
"@shopify/react-testing": "^5.1.3",
|
|
57
|
+
"@shopify/shopify-app-session-storage-memory": "^3.0.1",
|
|
58
|
+
"@types/jsonwebtoken": "^9.0.5",
|
|
59
|
+
"@types/react": "^18.2.18",
|
|
60
|
+
"@types/semver": "^7.5.7",
|
|
61
|
+
"jest-fetch-mock": "^3.0.3",
|
|
62
|
+
"jsonwebtoken": "^9.0.2",
|
|
63
|
+
"react": "^18.2.0",
|
|
64
|
+
"react-dom": "^18.2.0"
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"@remix-run/node": "^2.6.0",
|
|
68
|
+
"@remix-run/server-runtime": "^2.5.1",
|
|
69
|
+
"@shopify/admin-api-client": "^0.2.3",
|
|
70
|
+
"@shopify/shopify-api": "^9.3.2",
|
|
71
|
+
"@shopify/shopify-app-session-storage": "^2.1.1",
|
|
72
|
+
"@shopify/storefront-api-client": "^0.2.3",
|
|
73
|
+
"isbot": "^3.7.1",
|
|
74
|
+
"semver": "^7.6.0"
|
|
75
|
+
},
|
|
76
|
+
"peerDependencies": {
|
|
77
|
+
"@remix-run/react": "*",
|
|
78
|
+
"@shopify/polaris": "*",
|
|
79
|
+
"react": "*"
|
|
80
|
+
},
|
|
81
|
+
"peerDependenciesMeta": {
|
|
82
|
+
"@shopify/polaris": {
|
|
83
|
+
"optional": true
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"files": [
|
|
87
|
+
"build/*",
|
|
88
|
+
"!build/**/__tests__",
|
|
89
|
+
"!bundle/*",
|
|
90
|
+
"!tsconfig.tsbuildinfo",
|
|
91
|
+
"!node_modules"
|
|
92
|
+
]
|
|
93
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
'no-restricted-imports': [
|
|
4
|
+
'error',
|
|
5
|
+
{
|
|
6
|
+
patterns: [
|
|
7
|
+
{
|
|
8
|
+
group: ['../server/*'],
|
|
9
|
+
message:
|
|
10
|
+
'Importing from src/react in src/server is not allowed as they must be kept separate, because it breaks Remix bundling.',
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {destroyAll} from '@shopify/react-testing';
|
|
2
|
+
import '@shopify/react-testing/matchers';
|
|
3
|
+
|
|
4
|
+
afterEach(() => {
|
|
5
|
+
destroyAll();
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
beforeAll(() => {
|
|
9
|
+
Object.defineProperty(window, 'matchMedia', {
|
|
10
|
+
writable: true,
|
|
11
|
+
value: jest.fn().mockImplementation((query) => ({
|
|
12
|
+
matches: false,
|
|
13
|
+
media: query,
|
|
14
|
+
onchange: null,
|
|
15
|
+
addListener: jest.fn(),
|
|
16
|
+
removeListener: jest.fn(),
|
|
17
|
+
addEventListener: jest.fn(),
|
|
18
|
+
removeEventListener: jest.fn(),
|
|
19
|
+
dispatchEvent: jest.fn(),
|
|
20
|
+
})),
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
|
|
2
|
+
|
|
3
|
+
const data: ReferenceEntityTemplateSchema = {
|
|
4
|
+
name: 'AppProvider',
|
|
5
|
+
descriptionType: 'AppProviderGeneratedType',
|
|
6
|
+
description: '',
|
|
7
|
+
category: 'Entrypoints',
|
|
8
|
+
type: 'component',
|
|
9
|
+
isVisualComponent: false,
|
|
10
|
+
definitions: [
|
|
11
|
+
{
|
|
12
|
+
title: 'AppProviderProps',
|
|
13
|
+
description: 'Props for the `AppProvider` component.',
|
|
14
|
+
type: 'AppProviderProps',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
jsDocTypeExamples: ['AppProviderGeneratedType'],
|
|
18
|
+
related: [
|
|
19
|
+
{
|
|
20
|
+
name: 'App bridge',
|
|
21
|
+
subtitle: 'Learn more about App Bridge.',
|
|
22
|
+
url: '/docs/api/app-bridge-library',
|
|
23
|
+
type: 'shopify',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'Polaris',
|
|
27
|
+
subtitle: 'Learn more about Polaris.',
|
|
28
|
+
url: '/docs/apps/tools/polaris',
|
|
29
|
+
type: 'shopify',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default data;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AppProvider as PolarisAppProvider,
|
|
3
|
+
AppProviderProps as PolarisAppProviderProps,
|
|
4
|
+
} from '@shopify/polaris';
|
|
5
|
+
import englishI18n from '@shopify/polaris/locales/en.json';
|
|
6
|
+
|
|
7
|
+
import {APP_BRIDGE_URL} from '../../const';
|
|
8
|
+
import {RemixPolarisLink} from '../RemixPolarisLink';
|
|
9
|
+
|
|
10
|
+
export interface AppProviderProps
|
|
11
|
+
extends Omit<PolarisAppProviderProps, 'linkComponent' | 'i18n'> {
|
|
12
|
+
/**
|
|
13
|
+
* The API key for your Shopify app. This is the `Client ID` from the Partner Dashboard.
|
|
14
|
+
*
|
|
15
|
+
* When using the Shopify CLI, this is the `SHOPIFY_API_KEY` environment variable. If you're using the environment
|
|
16
|
+
* variable, then you need to pass it from the loader to the component.
|
|
17
|
+
*/
|
|
18
|
+
apiKey: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the app is loaded inside the Shopify Admin. Default is `true`.
|
|
21
|
+
*
|
|
22
|
+
* {@link https://shopify.dev/docs/apps/admin/embedded-app-home}
|
|
23
|
+
*/
|
|
24
|
+
isEmbeddedApp?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The internationalization (i18n) configuration for your Polaris provider.
|
|
27
|
+
*
|
|
28
|
+
* {@link https://polaris.shopify.com/components/utilities/app-provider}
|
|
29
|
+
*/
|
|
30
|
+
i18n?: PolarisAppProviderProps['i18n'];
|
|
31
|
+
/**
|
|
32
|
+
* Used internally by Shopify. You don't need to set this.
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
__APP_BRIDGE_URL?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Sets up the Polaris `AppProvider` and injects the App Bridge script.
|
|
40
|
+
*
|
|
41
|
+
* This component extends the [`AppProvider`](https://polaris.shopify.com/components/utilities/app-provider) component
|
|
42
|
+
* from Polaris, and accepts all of its props except for `linkComponent`, which is overridden to use the Remix `Link`
|
|
43
|
+
* component.
|
|
44
|
+
*
|
|
45
|
+
* {@link https://polaris.shopify.com/components/utilities/app-provider}
|
|
46
|
+
* {@link https://shopify.dev/tools/app-bridge}
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* <caption>Set up AppProvider.</caption>
|
|
50
|
+
* <description>Wrap your app in the `AppProvider` component and pass in your API key.</description>
|
|
51
|
+
* ```ts
|
|
52
|
+
* import {authenticate} from '~/shopify.server';
|
|
53
|
+
* import {AppProvider} from '@shopify/shopify-app-remix/react';
|
|
54
|
+
*
|
|
55
|
+
* export async function loader({ request }) {
|
|
56
|
+
* await authenticate.admin(request);
|
|
57
|
+
*
|
|
58
|
+
* return json({ apiKey: process.env.SHOPIFY_API_KEY });
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* export default function App() {
|
|
62
|
+
* const { apiKey } = useLoaderData();
|
|
63
|
+
*
|
|
64
|
+
* return (
|
|
65
|
+
* <AppProvider isEmbeddedApp apiKey={apiKey}>
|
|
66
|
+
* <Outlet />
|
|
67
|
+
* </AppProvider>
|
|
68
|
+
* );
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* <caption>Localize Polaris components.</caption>
|
|
74
|
+
* <description>Pass in a different locale for Polaris to translate its components.</description>
|
|
75
|
+
* ```ts
|
|
76
|
+
* import {authenticate} from '~/shopify.server';
|
|
77
|
+
* import {AppProvider} from '@shopify/shopify-app-remix/react';
|
|
78
|
+
*
|
|
79
|
+
* export async function loader({ request }) {
|
|
80
|
+
* await authenticate.admin(request);
|
|
81
|
+
*
|
|
82
|
+
* return json({
|
|
83
|
+
* apiKey: process.env.SHOPIFY_API_KEY,
|
|
84
|
+
* polarisTranslations: require("@shopify/polaris/locales/fr.json"),
|
|
85
|
+
* });
|
|
86
|
+
* }
|
|
87
|
+
*
|
|
88
|
+
* export default function App() {
|
|
89
|
+
* const { apiKey, polarisTranslations } = useLoaderData();
|
|
90
|
+
*
|
|
91
|
+
* return (
|
|
92
|
+
* <AppProvider apiKey={apiKey} i18n={polarisTranslations}>
|
|
93
|
+
* <Outlet />
|
|
94
|
+
* </AppProvider>
|
|
95
|
+
* );
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export function AppProvider(props: AppProviderProps) {
|
|
100
|
+
const {
|
|
101
|
+
children,
|
|
102
|
+
apiKey,
|
|
103
|
+
i18n,
|
|
104
|
+
isEmbeddedApp = true,
|
|
105
|
+
__APP_BRIDGE_URL = APP_BRIDGE_URL,
|
|
106
|
+
...polarisProps
|
|
107
|
+
} = props;
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<>
|
|
111
|
+
{isEmbeddedApp && <script src={__APP_BRIDGE_URL} data-api-key={apiKey} />}
|
|
112
|
+
<PolarisAppProvider
|
|
113
|
+
{...polarisProps}
|
|
114
|
+
linkComponent={RemixPolarisLink}
|
|
115
|
+
i18n={i18n || englishI18n}
|
|
116
|
+
>
|
|
117
|
+
{children}
|
|
118
|
+
</PolarisAppProvider>
|
|
119
|
+
</>
|
|
120
|
+
);
|
|
121
|
+
}
|
package/packages/shopify-app-remix/src/react/components/AppProvider/__tests__/AppProvider.test.tsx
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {mount} from '@shopify/react-testing';
|
|
3
|
+
import {AppProvider as PolarisAppProvider} from '@shopify/polaris';
|
|
4
|
+
|
|
5
|
+
import '../../../__tests__/test-helper';
|
|
6
|
+
|
|
7
|
+
import {AppProvider} from '../AppProvider';
|
|
8
|
+
import {RemixPolarisLink} from '../../RemixPolarisLink';
|
|
9
|
+
|
|
10
|
+
describe('<AppProvider />', () => {
|
|
11
|
+
const defaultProps = {
|
|
12
|
+
apiKey: '123abc',
|
|
13
|
+
isEmbeddedApp: true,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
it('renders the script tag if the embedded app prop is passed in', () => {
|
|
17
|
+
// WHEN
|
|
18
|
+
const component = mount(
|
|
19
|
+
<AppProvider {...defaultProps}>Hello world</AppProvider>,
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// THEN
|
|
23
|
+
expect(component).toContainReactComponent('script', {
|
|
24
|
+
src: 'https://cdn.shopify.com/shopifycloud/app-bridge.js',
|
|
25
|
+
});
|
|
26
|
+
expect(component).toContainReactHtml('Hello world');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('does not render the script tag if the embedded app prop is not passed in', () => {
|
|
30
|
+
// WHEN
|
|
31
|
+
const component = mount(
|
|
32
|
+
<AppProvider {...defaultProps} isEmbeddedApp={false}>
|
|
33
|
+
Hello world
|
|
34
|
+
</AppProvider>,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// THEN
|
|
38
|
+
expect(component).not.toContainReactComponent('script');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('allows overriding the app bridge url', () => {
|
|
42
|
+
// WHEN
|
|
43
|
+
const component = mount(
|
|
44
|
+
<AppProvider {...defaultProps} __APP_BRIDGE_URL="override">
|
|
45
|
+
Hello world
|
|
46
|
+
</AppProvider>,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// THEN
|
|
50
|
+
expect(component).toContainReactComponent('script', {src: 'override'});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('passes i18n and linkComponent props to the Polaris provider', () => {
|
|
54
|
+
// WHEN
|
|
55
|
+
const dummyI18n = {hello: 'world'};
|
|
56
|
+
const component = mount(
|
|
57
|
+
<AppProvider {...defaultProps} i18n={dummyI18n}>
|
|
58
|
+
Hello world
|
|
59
|
+
</AppProvider>,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// THEN
|
|
63
|
+
expect(component).toContainReactComponent(PolarisAppProvider, {
|
|
64
|
+
i18n: dummyI18n,
|
|
65
|
+
linkComponent: RemixPolarisLink,
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AppProvider';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Link} from '@remix-run/react';
|
|
3
|
+
// Polaris' LinkProps doesn't match this type, so we need to import it directly
|
|
4
|
+
import type {
|
|
5
|
+
LinkLikeComponent,
|
|
6
|
+
LinkLikeComponentProps,
|
|
7
|
+
} from '@shopify/polaris/build/ts/src/utilities/link';
|
|
8
|
+
|
|
9
|
+
export const RemixPolarisLink = React.forwardRef<
|
|
10
|
+
HTMLAnchorElement,
|
|
11
|
+
LinkLikeComponentProps
|
|
12
|
+
>((props, ref) => (
|
|
13
|
+
<Link {...props} to={props.url ?? props.to} ref={ref} />
|
|
14
|
+
)) as LinkLikeComponent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AppProvider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
'no-restricted-imports': [
|
|
4
|
+
'error',
|
|
5
|
+
{
|
|
6
|
+
patterns: [
|
|
7
|
+
{
|
|
8
|
+
group: ['../react/*'],
|
|
9
|
+
message:
|
|
10
|
+
'Importing from src/react in src/server is not allowed as they must be kept separate, because it breaks Remix bundling.',
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mockExternalRequest,
|
|
3
|
+
mockExternalRequests,
|
|
4
|
+
skipMockChecks,
|
|
5
|
+
validateMocks,
|
|
6
|
+
} from '../request-mock';
|
|
7
|
+
|
|
8
|
+
describe('Request mocks', () => {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
skipMockChecks(true);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('can intercept fetch requests', async () => {
|
|
14
|
+
// GIVEN
|
|
15
|
+
await mockExternalRequest({
|
|
16
|
+
request: new Request('https://my-example.shopify.io', {
|
|
17
|
+
headers: {bar: 'baz'},
|
|
18
|
+
}),
|
|
19
|
+
response: new Response(JSON.stringify({responseFoo: 'responseBar'}), {
|
|
20
|
+
status: 200,
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// WHEN
|
|
25
|
+
await fetch('https://my-example.shopify.io', {
|
|
26
|
+
method: 'GET',
|
|
27
|
+
headers: {bar: 'baz'},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// THEN
|
|
31
|
+
await validateMocks();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('can intercept multiple requests', async () => {
|
|
35
|
+
// GIVEN
|
|
36
|
+
await mockExternalRequests(
|
|
37
|
+
{
|
|
38
|
+
request: new Request('https://my-example.shopify.io'),
|
|
39
|
+
response: new Response(),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
request: new Request('https://my-example.shopify.io', {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
}),
|
|
45
|
+
response: new Response(),
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// WHEN
|
|
50
|
+
await fetch('https://my-example.shopify.io', {method: 'GET'});
|
|
51
|
+
await fetch('https://my-example.shopify.io', {method: 'POST'});
|
|
52
|
+
|
|
53
|
+
// THEN
|
|
54
|
+
await validateMocks();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('detects failures after the first request', async () => {
|
|
58
|
+
// GIVEN
|
|
59
|
+
await mockExternalRequests(
|
|
60
|
+
{
|
|
61
|
+
request: new Request('https://my-example.shopify.io'),
|
|
62
|
+
response: new Response(),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
request: new Request('https://my-example.shopify.io', {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
}),
|
|
68
|
+
response: new Response(),
|
|
69
|
+
},
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// WHEN
|
|
73
|
+
await fetch('https://my-example.shopify.io', {method: 'GET'});
|
|
74
|
+
await fetch('https://my-example.shopify.io', {method: 'GET'});
|
|
75
|
+
|
|
76
|
+
// THEN
|
|
77
|
+
await expect(validateMocks()).rejects.toThrow(
|
|
78
|
+
'GET request made to https://my-example.shopify.io does not match expectation',
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('matches responses automatically when no request mock is configured', async () => {
|
|
83
|
+
// GIVEN
|
|
84
|
+
await mockExternalRequest({
|
|
85
|
+
response: new Response(JSON.stringify({responseFoo: 'responseBar'})),
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// WHEN
|
|
89
|
+
await fetch('https://my-example.shopify.io', {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
body: JSON.stringify({foo: 'bar'}),
|
|
92
|
+
headers: {bar: 'baz'},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// THEN
|
|
96
|
+
await validateMocks();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('can mock non-200 responses', async () => {
|
|
100
|
+
// GIVEN
|
|
101
|
+
await mockExternalRequest({
|
|
102
|
+
request: new Request('https://my-example.shopify.io'),
|
|
103
|
+
response: new Response(undefined, {status: 500}),
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// WHEN
|
|
107
|
+
await fetch('https://my-example.shopify.io');
|
|
108
|
+
|
|
109
|
+
// THEN
|
|
110
|
+
await validateMocks();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it.each(['url', 'method', 'body', 'headers'])(
|
|
114
|
+
'can match requests without %s',
|
|
115
|
+
async (field) => {
|
|
116
|
+
// GIVEN
|
|
117
|
+
const request = new Request('https://my-example.shopify.io', {
|
|
118
|
+
method: 'POST',
|
|
119
|
+
body: JSON.stringify({foo: 'bar'}),
|
|
120
|
+
headers: {bar: 'baz'},
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
delete (request as any)[field];
|
|
124
|
+
await mockExternalRequest({
|
|
125
|
+
request,
|
|
126
|
+
response: new Response(JSON.stringify({responseFoo: 'responseBar'})),
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// WHEN
|
|
130
|
+
await fetch('https://my-example.shopify.io', {
|
|
131
|
+
method: 'POST',
|
|
132
|
+
body: JSON.stringify({foo: 'bar'}),
|
|
133
|
+
headers: {bar: 'baz'},
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// THEN
|
|
137
|
+
await validateMocks();
|
|
138
|
+
},
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
it("throws if an expected request isn't made", async () => {
|
|
142
|
+
// GIVEN
|
|
143
|
+
await mockExternalRequest({
|
|
144
|
+
request: new Request('https://my-example.shopify.io', {
|
|
145
|
+
method: 'POST',
|
|
146
|
+
body: JSON.stringify({foo: 'bar'}),
|
|
147
|
+
headers: {bar: 'baz'},
|
|
148
|
+
}),
|
|
149
|
+
response: new Response(JSON.stringify({responseFoo: 'responseBar'})),
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// THEN
|
|
153
|
+
await expect(validateMocks()).rejects.toThrow(
|
|
154
|
+
'Expected 1 request(s) to be made but they were not',
|
|
155
|
+
);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('throws if an unexpected request is made', async () => {
|
|
159
|
+
// WHEN
|
|
160
|
+
await fetch('https://my-example.shopify.io', {
|
|
161
|
+
method: 'POST',
|
|
162
|
+
body: JSON.stringify({foo: 'bar'}),
|
|
163
|
+
headers: {bar: 'baz'},
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// THEN
|
|
167
|
+
await expect(validateMocks()).rejects.toThrow(
|
|
168
|
+
'1 unexpected request(s) were made',
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {LATEST_API_VERSION} from '@shopify/shopify-api';
|
|
2
|
+
|
|
3
|
+
export const API_SECRET_KEY = 'testApiSecretKey';
|
|
4
|
+
export const API_KEY = 'testApiKey';
|
|
5
|
+
export const APP_URL = 'https://my-test-app.myshopify.io';
|
|
6
|
+
export const SHOPIFY_HOST = 'totally-real-host.myshopify.io';
|
|
7
|
+
export const BASE64_HOST = Buffer.from(SHOPIFY_HOST).toString('base64');
|
|
8
|
+
export const TEST_SHOP_NAME = 'test-shop';
|
|
9
|
+
export const TEST_SHOP = `${TEST_SHOP_NAME}.myshopify.com`;
|
|
10
|
+
export const GRAPHQL_URL = `https://${TEST_SHOP}/admin/api/${LATEST_API_VERSION}/graphql.json`;
|
|
11
|
+
export const USER_ID = 12345;
|