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,148 @@
|
|
|
1
|
+
import {LandingTemplateSchema} from '@shopify/generate-docs';
|
|
2
|
+
|
|
3
|
+
const data: LandingTemplateSchema = {
|
|
4
|
+
id: 'guide-graphql-types',
|
|
5
|
+
title: 'Typing GraphQL operations',
|
|
6
|
+
description:
|
|
7
|
+
'The GraphQL clients provided in this package can use [Codegen](https://the-guild.dev/graphql/codegen) to automatically parse and create types for your queries and mutations.' +
|
|
8
|
+
'\n\nBy installing a few packages in your app, you can use the `graphql-codegen` script, which will look for strings with the `#graphql` tag and extract types from them.' +
|
|
9
|
+
'\n\nIf your IDE supports it, you will also get syntax highlighting and auto-complete features when writing your queries.',
|
|
10
|
+
sections: [
|
|
11
|
+
{
|
|
12
|
+
type: 'Markdown',
|
|
13
|
+
anchorLink: 'example',
|
|
14
|
+
title: 'See it in action',
|
|
15
|
+
sectionContent: `
|
|
16
|
+
In this example, we use the \`graphql-codegen\` script to parse a query in the \`/app/routes/new.tsx\` file.
|
|
17
|
+
|
|
18
|
+
Note how VSCode shows the types for both the return type of \`response.json()\`, and the \`variables\` option in the \`graphql\` function.
|
|
19
|
+
|
|
20
|
+
<video style="width: 100%; height: auto;" muted controls aria-label="A demonstration of a Remix app using GraphQL types">
|
|
21
|
+
<source src="/assets/client-libraries/graphql-types-demo.webm" type="video/webm">
|
|
22
|
+
Your browser doesn't support this video.
|
|
23
|
+
</video>
|
|
24
|
+
`,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: 'Generic',
|
|
28
|
+
anchorLink: 'install',
|
|
29
|
+
title: 'Installing packages',
|
|
30
|
+
sectionContent:
|
|
31
|
+
'To use the `graphql-codegen` script, you will need to install a few packages in your app.' +
|
|
32
|
+
'\n\nThey will include the scripts to run, and the types that will be overridden by the results of parsing your operations.',
|
|
33
|
+
codeblock: {
|
|
34
|
+
title: 'Installing packages',
|
|
35
|
+
tabs: [
|
|
36
|
+
{
|
|
37
|
+
title: 'npm',
|
|
38
|
+
language: 'sh',
|
|
39
|
+
code: './examples/guides/graphql-types/install.npm.example.sh',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
title: 'yarn',
|
|
43
|
+
language: 'sh',
|
|
44
|
+
code: './examples/guides/graphql-types/install.yarn.example.sh',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
title: 'pnpm',
|
|
48
|
+
language: 'sh',
|
|
49
|
+
code: './examples/guides/graphql-types/install.pnpm.example.sh',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'Generic',
|
|
56
|
+
anchorLink: 'configure',
|
|
57
|
+
title: 'Setting up .graphqlrc.ts',
|
|
58
|
+
sectionContent:
|
|
59
|
+
"Before you can parse operations, you'll need to create a `.graphqlrc.ts` file in your project, and configure it to use the `@shopify/api-codegen-preset`." +
|
|
60
|
+
'\n\n> Caution: Parsing will not work on `.graphql` documents, because the preset can only apply types from JavaScript and TypeScript const strings.',
|
|
61
|
+
codeblock: {
|
|
62
|
+
title: 'Codegen configuration example',
|
|
63
|
+
tabs: [
|
|
64
|
+
{
|
|
65
|
+
title: '/.graphqlrc.ts',
|
|
66
|
+
language: 'ts',
|
|
67
|
+
code: './examples/guides/graphql-types/.graphqlrc.ts',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
sectionCard: [
|
|
72
|
+
{
|
|
73
|
+
url: 'https://github.com/Shopify/shopify-api-js/tree/main/packages/api-codegen-preset#configuration',
|
|
74
|
+
name: 'Configuration options',
|
|
75
|
+
subtitle: 'Learn more about the available configurations.',
|
|
76
|
+
type: 'github',
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'Generic',
|
|
82
|
+
anchorLink: 'set-up-script',
|
|
83
|
+
title: 'Setting up the script',
|
|
84
|
+
sectionContent:
|
|
85
|
+
'To generate types, you\'ll need to add an entry for `graphql-codegen` in the `"scripts"` section of your `package.json` file.',
|
|
86
|
+
codeblock: {
|
|
87
|
+
title: 'Setting up the script',
|
|
88
|
+
tabs: [
|
|
89
|
+
{
|
|
90
|
+
title: '/package.json',
|
|
91
|
+
language: 'json',
|
|
92
|
+
code: './examples/guides/graphql-types/package.json',
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: 'Generic',
|
|
99
|
+
anchorLink: 'run',
|
|
100
|
+
title: 'Generating types',
|
|
101
|
+
sectionContent:
|
|
102
|
+
'When you run `graphql-codegen`, it will look in all your configured documents for strings marked with a `#graphql` tag.' +
|
|
103
|
+
'\n\nIDEs that support the `.graphqlrc.ts` file will provide syntax highlighting for your operations, as well as typing.' +
|
|
104
|
+
'\n\n> Tip: You can pass in a `--watch` flag to the script, which will update your types every time you save a file.',
|
|
105
|
+
codeblock: {
|
|
106
|
+
title: 'Running graphql-codegen',
|
|
107
|
+
tabs: [
|
|
108
|
+
{
|
|
109
|
+
title: 'npm',
|
|
110
|
+
language: 'sh',
|
|
111
|
+
code: './examples/guides/graphql-types/run.npm.example.sh',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
title: 'yarn',
|
|
115
|
+
language: 'sh',
|
|
116
|
+
code: './examples/guides/graphql-types/run.yarn.example.sh',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
title: 'pnpm',
|
|
120
|
+
language: 'sh',
|
|
121
|
+
code: './examples/guides/graphql-types/run.pnpm.example.sh',
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
type: 'Resource',
|
|
128
|
+
title: 'Resources',
|
|
129
|
+
anchorLink: 'resources',
|
|
130
|
+
resources: [
|
|
131
|
+
{
|
|
132
|
+
name: 'Admin API',
|
|
133
|
+
url: '/docs/api/shopify-app-remix/apis/admin-api',
|
|
134
|
+
type: 'shopify',
|
|
135
|
+
subtitle: 'Make requests to the Admin API',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'Storefront API',
|
|
139
|
+
url: '/docs/api/shopify-app-remix/apis/storefront-api',
|
|
140
|
+
type: 'shopify',
|
|
141
|
+
subtitle: 'Make requests to the Storefront API',
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export default data;
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import {LandingTemplateSchema} from '@shopify/generate-docs';
|
|
2
|
+
|
|
3
|
+
const data: LandingTemplateSchema = {
|
|
4
|
+
id: 'shopify-app-remix',
|
|
5
|
+
title: 'Shopify App package for Remix',
|
|
6
|
+
description:
|
|
7
|
+
'The [@shopify/shopify-app-remix](https://www.npmjs.com/package/@shopify/shopify-app-remix) package enables Remix apps to authenticate with Shopify and make API calls. It uses [App Bridge](/docs/api/app-bridge-library) to enable apps to embed themselves in the Shopify Admin.' +
|
|
8
|
+
"\n\nIn this page we'll go over the main components you need to integrate an app with Shopify.",
|
|
9
|
+
sections: [
|
|
10
|
+
{
|
|
11
|
+
type: 'Generic',
|
|
12
|
+
anchorLink: 'quick-start',
|
|
13
|
+
title: 'Quick start',
|
|
14
|
+
sectionContent:
|
|
15
|
+
"The quickest way to create a new app is using the Shopify CLI. You can use your preferred package manager for that." +
|
|
16
|
+
"\n\nCheck out the [getting started guide](/docs/apps/getting-started), or the [app template](https://github.com/Shopify/shopify-app-template-remix) for a complete example.",
|
|
17
|
+
codeblock: {
|
|
18
|
+
title: 'Create an app',
|
|
19
|
+
tabs: [
|
|
20
|
+
{
|
|
21
|
+
title: 'npm',
|
|
22
|
+
language: 'sh',
|
|
23
|
+
code: './examples/index/create.npm.example.sh',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
title: 'yarn',
|
|
27
|
+
language: 'sh',
|
|
28
|
+
code: './examples/index/create.yarn.example.sh',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: 'pnpm',
|
|
32
|
+
language: 'sh',
|
|
33
|
+
code: './examples/index/create.pnpm.example.sh',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
sectionCard: [
|
|
38
|
+
{
|
|
39
|
+
name: 'Build an app',
|
|
40
|
+
subtitle: 'Navigate to',
|
|
41
|
+
url: '/docs/apps/getting-started/build-qr-code-app',
|
|
42
|
+
type: 'tutorial',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'Generic',
|
|
48
|
+
anchorLink: 'installation',
|
|
49
|
+
title: 'Installation',
|
|
50
|
+
sectionContent:
|
|
51
|
+
"If you're not using the CLI, then you can use the examples in this page to set up an existing app to use this package. Start by installing it using your preferred package manager.",
|
|
52
|
+
codeblock: {
|
|
53
|
+
title: 'Install package',
|
|
54
|
+
tabs: [
|
|
55
|
+
{
|
|
56
|
+
title: 'npm',
|
|
57
|
+
language: 'sh',
|
|
58
|
+
code: './examples/index/install.npm.example.sh',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
title: 'yarn',
|
|
62
|
+
language: 'sh',
|
|
63
|
+
code: './examples/index/install.yarn.example.sh',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
title: 'pnpm',
|
|
67
|
+
language: 'sh',
|
|
68
|
+
code: './examples/index/install.pnpm.example.sh',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: 'Generic',
|
|
75
|
+
anchorLink: 'shopify-app',
|
|
76
|
+
title: 'Backend setup',
|
|
77
|
+
sectionContent:
|
|
78
|
+
"Using the `shopifyApp` function, you can create an object that enables your app's backend to authenticate requests coming from Shopify, and interacting with Shopify APIs." +
|
|
79
|
+
"\n\nThese functions make it easy for your app stays up to date, benefitting from the current best practices and security updates." +
|
|
80
|
+
"\n\n> Caution: When running on a node environment, you'll also need to import the node adapter, as per the example. This will ensure your app is using the appropriate implementation of the Web [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) and [crypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) APIs.",
|
|
81
|
+
sectionCard: [
|
|
82
|
+
{
|
|
83
|
+
name: 'shopifyApp',
|
|
84
|
+
url: '/docs/api/shopify-app-remix/entrypoints/shopifyapp',
|
|
85
|
+
type: 'clicode',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
codeblock: {
|
|
89
|
+
title: 'Configure ShopifyApp',
|
|
90
|
+
tabs: [
|
|
91
|
+
{
|
|
92
|
+
title: '/app/shopify.server.ts',
|
|
93
|
+
language: 'ts',
|
|
94
|
+
code: './examples/index/shopify-app.example.ts',
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: 'Generic',
|
|
101
|
+
anchorLink: 'headers',
|
|
102
|
+
title: 'Response headers',
|
|
103
|
+
sectionContent:
|
|
104
|
+
'When loading inside the Shopify Admin, your app will need to add the required `Content-Security-Policy` header directives, as per [our documentation](/docs/apps/store/security/iframe-protection). To do that, this package provides the `shopify.addDocumentResponseHeaders` method.' +
|
|
105
|
+
"\n\nYou should return these headers from any endpoint that renders HTML in your app. Most likely you'll want to add this to every HTML response by updating the `entry.server.tsx` file:",
|
|
106
|
+
codeblock: {
|
|
107
|
+
title: 'Add required headers',
|
|
108
|
+
tabs: [
|
|
109
|
+
{
|
|
110
|
+
title: '/app/entry.server.tsx',
|
|
111
|
+
language: 'tsx',
|
|
112
|
+
code: './examples/index/entry-server.example.ts',
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
type: 'Generic',
|
|
119
|
+
anchorLink: 'boundaries',
|
|
120
|
+
title: 'Error boundaries',
|
|
121
|
+
sectionContent:
|
|
122
|
+
"The OAuth process can't happen inside the admin iframe, and this package is capable of detecting that scenario and properly redirecting using the [Remix `ErrorBoundary`](https://remix.run/docs/en/main/guides/errors) export to set the correct headers for App Bridge." +
|
|
123
|
+
"\n\nUse the abstractions provided by this package in your authenticated routes, to automatically set up the error and headers boundaries to redirect outside the iframe when needed." +
|
|
124
|
+
"\n\n> Tip: You can also add this to a [Remix layout](https://remix.run/docs/en/main/file-conventions/route-files-v2) if you want to authenticate more than one route, but make sure to call the Shopify boundary methods whenever you need to add your own exports.",
|
|
125
|
+
codeblock: {
|
|
126
|
+
title: 'Configure header boundaries',
|
|
127
|
+
tabs: [
|
|
128
|
+
{
|
|
129
|
+
title: '/app/routes/**/*.tsx',
|
|
130
|
+
language: 'tsx',
|
|
131
|
+
code: './examples/index/boundaries.example.ts',
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
type: 'Generic',
|
|
138
|
+
anchorLink: 'auth-route',
|
|
139
|
+
title: 'OAuth route',
|
|
140
|
+
sectionContent:
|
|
141
|
+
"> Tip: This is only applicable to non-embedded apps or legacy embedded apps that are **not** using the [new embedded app authorization strategy](#embedded-auth-strategy) for OAuth and installation flow. If you're building an embedded app, we **strongly** recommend using the" +
|
|
142
|
+
" [new embedded app authorization strategy](#embedded-auth-strategy)" +
|
|
143
|
+
"\n\nTo install an app or refresh tokens, you'll need to set up an [OAuth](docs/apps/auth/oauth) route. To do that, set up a [splat route](https://remix.run/docs/en/main/guides/routing#splats) that calls `authenticate.admin`." +
|
|
144
|
+
'\n\nWhen that function is called, the package will start the OAuth process, and handle the callback from Shopify after it completes.' +
|
|
145
|
+
'\n\nThe default route is `/app/routes/auth/$.tsx`, but you can configure this route using the `authPathPrefix` option.',
|
|
146
|
+
codeblock: {
|
|
147
|
+
title: 'Add OAuth route',
|
|
148
|
+
tabs: [
|
|
149
|
+
{
|
|
150
|
+
title: '/app/routes/auth/$.tsx',
|
|
151
|
+
language: 'ts',
|
|
152
|
+
code: './examples/index/splat-route.example.ts',
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
type: 'Generic',
|
|
159
|
+
anchorLink: 'embedded-auth-strategy',
|
|
160
|
+
title: 'New embedded app authorization strategy',
|
|
161
|
+
sectionContent:
|
|
162
|
+
"> Tip: This is available for embedded apps that are using [Shopify managed installation](https://shopify.dev/docs/apps/auth/installation#shopify-managed-installation)." +
|
|
163
|
+
"\n> If you're building an embedded app, we **strongly** recommend using this feature that utilizes Shopify managed install with [token exchange](https://shopify.dev/docs/apps/auth/get-access-tokens/token-exchange)." +
|
|
164
|
+
"\n\n We have introduced a new authorization and installation strategy for **embedded apps** that eliminates the redirects that were previously necessary." +
|
|
165
|
+
" It replaces the legacy [authorization Code install and grant flow](https://shopify.dev/docs/apps/auth/get-access-tokens/authorization-code-grant)." +
|
|
166
|
+
"\n\nIt takes advantage of [Shopify managed installation](https://shopify.dev/docs/apps/auth/installation#shopify-managed-installation)" +
|
|
167
|
+
" to handle automatic app installations and scope updates, while using" +
|
|
168
|
+
" [token exchange](https://shopify.dev/docs/apps/auth/get-access-tokens/token-exchange) to get an access token for the logged-in user." +
|
|
169
|
+
"\n\n > Note: Newly created Remix apps from the template after February 1st 2024 has this feature enabled by default." +
|
|
170
|
+
"\n\n1. Enable [Shopify managed installation](https://shopify.dev/docs/apps/auth/installation#shopify-managed-installation)" +
|
|
171
|
+
" by configuring your scopes [through the Shopify CLI](https://shopify.dev/docs/apps/tools/cli/configuration)." +
|
|
172
|
+
"\n2. Enable the future flag `unstable_newEmbeddedAuthStrategy` in your app's server configuration file." +
|
|
173
|
+
"\n3. Enjoy no-redirect OAuth flow, and app installation process.",
|
|
174
|
+
codeblock: {
|
|
175
|
+
title: 'Enabling the new embedded auth strategy',
|
|
176
|
+
tabs: [
|
|
177
|
+
{
|
|
178
|
+
title: '/app/shopify.server.ts',
|
|
179
|
+
language: 'ts',
|
|
180
|
+
code: './examples/index/embedded-app-auth-strategy-config.example.ts',
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
type: 'Generic',
|
|
188
|
+
anchorLink: 'app-provider',
|
|
189
|
+
title: 'AppProvider',
|
|
190
|
+
sectionContent:
|
|
191
|
+
"In order to use all of the features from App Bridge, you'll need to use the `AppProvider` component in your app's routes." +
|
|
192
|
+
'\n\nThis component will set up App Bridge and Polaris so you can integrate your app into the Shopify Admin, and it helps us ensure your app stays up to date with Shopify requirements.' +
|
|
193
|
+
'\n\nTo do this pass the `process.env.SHOPIFY_API_KEY` to the frontend via the loader.',
|
|
194
|
+
sectionCard: [
|
|
195
|
+
{
|
|
196
|
+
name: 'App bridge',
|
|
197
|
+
subtitle: 'Learn more about App Bridge.',
|
|
198
|
+
url: '/docs/api/app-bridge-library',
|
|
199
|
+
type: 'shopify',
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: 'Polaris',
|
|
203
|
+
subtitle: 'Learn more about Polaris.',
|
|
204
|
+
url: 'https://polaris.shopify.com',
|
|
205
|
+
type: 'shopify',
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: 'AppProvider',
|
|
209
|
+
url: '/docs/api/shopify-app-remix/entrypoints/appprovider',
|
|
210
|
+
type: 'clicode',
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
codeblock: {
|
|
214
|
+
title: 'Add AppProvider',
|
|
215
|
+
tabs: [
|
|
216
|
+
{
|
|
217
|
+
title: '/app/root.tsx',
|
|
218
|
+
language: 'tsx',
|
|
219
|
+
code: './examples/index/app-provider.example.ts',
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export default data;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {LandingTemplateSchema} from '@shopify/generate-docs';
|
|
2
|
+
|
|
3
|
+
const data: LandingTemplateSchema = {
|
|
4
|
+
id: 'guide-webhooks',
|
|
5
|
+
title: 'Subscribing to webhooks',
|
|
6
|
+
description:
|
|
7
|
+
'Your app must respond to [mandatory webhook topics](/docs/apps/webhooks/configuration/mandatory-webhooks). In addition, your app can register [optional webhook topics](/docs/api/admin-rest/current/resources/webhook#event-topics).',
|
|
8
|
+
sections: [
|
|
9
|
+
{
|
|
10
|
+
type: 'Generic',
|
|
11
|
+
anchorLink: 'config',
|
|
12
|
+
title: 'Configuring webhooks subscriptions',
|
|
13
|
+
sectionContent:
|
|
14
|
+
'Configure `shopifyApp` and setup webhook subscription with the following steps:' +
|
|
15
|
+
'\n1. The webhooks you want to subscribe to. In this example we subscribe to the `APP_UNINSTALLED` topic.' +
|
|
16
|
+
'\n1. The code to register the `APP_UNINSTALLED` topic after a merchant installs you app. Here `shopifyApp` provides an `afterAuth` hook.' +
|
|
17
|
+
'\n1. Review the required scopes for the webhook topics, and update your [app scopes](/docs/apps/tools/cli/configuration#access_scopes) as necessary.' +
|
|
18
|
+
"\n\n> Note: You can't register mandatory topics using this package, you must [configure those in the Partner Dashboard](/docs/apps/webhooks/configuration/mandatory-webhooks) instead.",
|
|
19
|
+
codeblock: {
|
|
20
|
+
title: 'Configure webhooks subscriptions',
|
|
21
|
+
tabs: [
|
|
22
|
+
{
|
|
23
|
+
title: '/app/shopify.server.ts',
|
|
24
|
+
code: './examples/guides/webhooks/config.example.ts',
|
|
25
|
+
language: 'tsx',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: 'Generic',
|
|
32
|
+
anchorLink: 'endpoints',
|
|
33
|
+
title: 'Set up your endpoints',
|
|
34
|
+
sectionContent:
|
|
35
|
+
'Create a route in your app to handle incoming webhook requests for each `callbackUrl` you set in your configuration.' +
|
|
36
|
+
'Legitimate webhook requests are always `POST` requests signed by Shopify, so you must authenticate them before taking any action. To do this you must set up an `action` that uses the `authenticate.webhook` function to authenticate the request.' +
|
|
37
|
+
'\n\nPlease keep in mind that webhook endpoints should respond as quickly as possible. If you need to run a long-running job, then consider using background tasks.' +
|
|
38
|
+
'\n\n> Caution: Webhook endpoints **must** respond with an `HTTP 200` code, or Shopify will retry.',
|
|
39
|
+
codeblock: {
|
|
40
|
+
title: 'Receive webhook requests',
|
|
41
|
+
tabs: [
|
|
42
|
+
{
|
|
43
|
+
title: '/app/routes/webhooks.tsx',
|
|
44
|
+
code: './examples/guides/webhooks/endpoint.example.ts',
|
|
45
|
+
language: 'tsx',
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'Resource',
|
|
52
|
+
title: 'Resources',
|
|
53
|
+
anchorLink: 'resources',
|
|
54
|
+
resources: [
|
|
55
|
+
{
|
|
56
|
+
name: 'authenticate.webhook',
|
|
57
|
+
url: '/docs/api/shopify-app-remix/authenticate/webhook',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default data;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Upcoming breaking changes
|
|
2
|
+
|
|
3
|
+
This file contains every breaking change that's currently planned for this package.
|
|
4
|
+
You can use it as a guide for migrating your app, and ensuring you're ready for the next big migration.
|
|
5
|
+
|
|
6
|
+
> **Note**: Every change in this file comes with a deprecated alternative for apps that haven't been updated yet.
|
|
7
|
+
> Our goal is to give developers as much time as possible to prepare for changes to reduce the burden of staying up to date.
|
|
8
|
+
|
|
9
|
+
## Table of contents
|
|
10
|
+
|
|
11
|
+
- [Root import path deprecation](#root-import-path-deprecation)
|
|
12
|
+
- [Introducing the AppProvider component](#introducing-the-appprovider-component)
|
|
13
|
+
- [Aligning the `admin` context object for webhooks](#aligning-the-admin-context-object-for-webhooks)
|
|
14
|
+
|
|
15
|
+
## Root import path deprecation
|
|
16
|
+
|
|
17
|
+
In the current version, apps can import server-side functions using the following statements:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import '@shopify/shopify-app-remix/adapters/node';
|
|
21
|
+
import {shopifyApp} from '@shopify/shopify-app-remix';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
With the addition of React component to this package, we'll start having full separation between server and react code, as in:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import '@shopify/shopify-app-remix/server/adapters/node';
|
|
28
|
+
import {shopifyApp} from '@shopify/shopify-app-remix/server';
|
|
29
|
+
import {AppProvider} from '@shopify/shopify-app-remix/react';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Introducing the AppProvider component
|
|
33
|
+
|
|
34
|
+
In order to make it easier to set up the frontend for apps using this package, we introduced a new `AppProvider` component.
|
|
35
|
+
Previous apps will continue to work without this component, but we strongly recommend all apps use it because it makes it easier to keep up with updates from Shopify.
|
|
36
|
+
|
|
37
|
+
To make use of this in the Remix app template, you can update your `app/routes/app.jsx` file's `App` component from
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
export default function App() {
|
|
41
|
+
const {apiKey, polarisTranslations} = useLoaderData();
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
<script
|
|
46
|
+
src="https://cdn.shopify.com/shopifycloud/app-bridge.js"
|
|
47
|
+
data-api-key={apiKey}
|
|
48
|
+
/>
|
|
49
|
+
<ui-nav-menu>
|
|
50
|
+
<Link to="/app" rel="home">
|
|
51
|
+
Home
|
|
52
|
+
</Link>
|
|
53
|
+
<Link to="/app/additional">Additional page</Link>
|
|
54
|
+
</ui-nav-menu>
|
|
55
|
+
<PolarisAppProvider
|
|
56
|
+
i18n={polarisTranslations}
|
|
57
|
+
linkComponent={RemixPolarisLink}
|
|
58
|
+
>
|
|
59
|
+
<Outlet />
|
|
60
|
+
</PolarisAppProvider>
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** @type {any} */
|
|
66
|
+
const RemixPolarisLink = React.forwardRef((/** @type {any} */ props, ref) => (
|
|
67
|
+
<Link {...props} to={props.url ?? props.to} ref={ref}>
|
|
68
|
+
{props.children}
|
|
69
|
+
</Link>
|
|
70
|
+
));
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
to
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import {AppProvider} from '@shopify/shopify-app-remix/react';
|
|
77
|
+
|
|
78
|
+
export default function App() {
|
|
79
|
+
const {apiKey} = useLoaderData();
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<AppProvider isEmbeddedApp apiKey={apiKey}>
|
|
83
|
+
<ui-nav-menu>
|
|
84
|
+
<Link to="/app" rel="home">
|
|
85
|
+
Home
|
|
86
|
+
</Link>
|
|
87
|
+
<Link to="/app/additional">Additional page</Link>
|
|
88
|
+
</ui-nav-menu>
|
|
89
|
+
<Outlet />
|
|
90
|
+
</AppProvider>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Aligning the `admin` context object for webhooks
|
|
96
|
+
|
|
97
|
+
The `admin` context returned by `authenticate.webhook` didn't match the object returned by e.g. `authenticate.admin`, which could lead to confusion.
|
|
98
|
+
|
|
99
|
+
We updated the shape of the object returned by `authenticate.webhook` so that every authentication method returns a consistent format.
|
|
100
|
+
That reduces the mental load for developers as they shouldn't have to learn more than one way of doing the same thing.
|
|
101
|
+
|
|
102
|
+
To update your code:
|
|
103
|
+
|
|
104
|
+
- GraphQL:
|
|
105
|
+
- replace `admin?.graphql.query()` with `admin?.graphql()`
|
|
106
|
+
- the graphql query function now takes the query string as the first argument, and an optional settings object, as opposed to a single object
|
|
107
|
+
- REST:
|
|
108
|
+
- `admin.rest.get|post|put|delete()` remain unchanged
|
|
109
|
+
- `admin.rest.Product` (or other resource classes) are now under `admin.rest.resources.Product`
|
|
110
|
+
|
|
111
|
+
Before:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
export async function action({request}: ActionFunctionArgs) {
|
|
115
|
+
const {admin} = await shopify.authenticate.webhook(request);
|
|
116
|
+
|
|
117
|
+
// GraphQL query
|
|
118
|
+
const response = await admin?.graphql.query<any>({
|
|
119
|
+
data: {
|
|
120
|
+
query: `query { ... }`,
|
|
121
|
+
variables: {myVariable: '...'},
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// REST resource
|
|
126
|
+
const products = await admin?.rest.Product.all({
|
|
127
|
+
// ...
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// ...
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
After:
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
export async function action({request}: ActionFunctionArgs) {
|
|
138
|
+
const {admin} = await shopify.authenticate.webhook(request);
|
|
139
|
+
|
|
140
|
+
// GraphQL query
|
|
141
|
+
const response = await admin?.graphql(`query { ... }`, {
|
|
142
|
+
variables: {myVariable: '...'},
|
|
143
|
+
});
|
|
144
|
+
const data = await response.json();
|
|
145
|
+
|
|
146
|
+
// REST resource
|
|
147
|
+
const products = await admin?.rest.resources.Product.all({
|
|
148
|
+
// ...
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// ...
|
|
152
|
+
}
|
|
153
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
|
|
3
|
+
import {createPackage} from '@shopify/loom';
|
|
4
|
+
import {babel, buildLibrary} from '@shopify/loom-plugin-build-library';
|
|
5
|
+
|
|
6
|
+
export default createPackage((pkg) => {
|
|
7
|
+
pkg.entry({root: './src/server/index.ts'});
|
|
8
|
+
pkg.entry({root: './src/react/index.ts'});
|
|
9
|
+
|
|
10
|
+
const basePath = `${__dirname}/src/server/adapters`;
|
|
11
|
+
fs.readdirSync(basePath, {withFileTypes: true})
|
|
12
|
+
.filter((dirent) => dirent.isDirectory() && dirent.name !== '__tests__')
|
|
13
|
+
.forEach((dirent) => {
|
|
14
|
+
pkg.entry({root: `./src/server/adapters/${dirent.name}/index.ts`});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
pkg.use(
|
|
18
|
+
buildLibrary({
|
|
19
|
+
// Required. A browserslist string for specifying your target output.
|
|
20
|
+
// Use browser targets (e.g. `'defaults'`) if your package targets the browser,
|
|
21
|
+
// node targets (e.g. `'node 12.22'`) if your package targets node
|
|
22
|
+
// or both (e.g.`'defaults, node 12.22'`) if your package targets both
|
|
23
|
+
targets: 'node 16',
|
|
24
|
+
// Optional. Defaults to false. Defines if commonjs outputs should be generated.
|
|
25
|
+
commonjs: true,
|
|
26
|
+
// Optional. Defaults to false. Defines if esmodules outputs should be generated.
|
|
27
|
+
esmodules: false,
|
|
28
|
+
// Optional. Defaults to false. Defines if esnext outputs should be generated.
|
|
29
|
+
esnext: false,
|
|
30
|
+
// Optional. Defaults to true. Defines if entrypoints should be written at
|
|
31
|
+
// the root of the repository. You can disable this if you have a single
|
|
32
|
+
// entrypoint or if your package uses the `exports` key in package.json
|
|
33
|
+
rootEntrypoints: false,
|
|
34
|
+
// Optional. Defaults to 'node'. Defines if the jest environment should be 'node' or 'jsdom'.
|
|
35
|
+
jestTestEnvironment: 'node',
|
|
36
|
+
}),
|
|
37
|
+
babel({
|
|
38
|
+
config(babelConfig) {
|
|
39
|
+
const presets = babelConfig.presets!;
|
|
40
|
+
const babelPresetIndex = presets.findIndex((preset) =>
|
|
41
|
+
String(preset[0]).includes('@shopify/babel-preset'),
|
|
42
|
+
);
|
|
43
|
+
const existingConfig = presets[babelPresetIndex][1];
|
|
44
|
+
presets[babelPresetIndex][1] = {
|
|
45
|
+
...existingConfig,
|
|
46
|
+
reactOptions: {
|
|
47
|
+
...existingConfig.reactOptions,
|
|
48
|
+
// This is required to support React 17
|
|
49
|
+
runtime: 'automatic',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return babelConfig;
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
});
|