Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ShopifyEnv and use it for all the env.d.ts #2332

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .changeset/rich-falcons-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'skeleton': patch
'@shopify/hydrogen': patch
'@shopify/create-hydrogen': patch
---

Create ShopifyEnv and use it for all the env.d.ts

```diff
// in env.d.ts

+ import type {ShopifyEnv} from '@shopify/hydrogen';

+ interface Env extends ShopifyEnv {}
- interface Env {
- SESSION_SECRET: string;
- PUBLIC_STOREFRONT_API_TOKEN: string;
- PRIVATE_STOREFRONT_API_TOKEN: string;
- PUBLIC_STORE_DOMAIN: string;
- PUBLIC_STOREFRONT_ID: string;
- PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID: string;
- PUBLIC_CUSTOMER_ACCOUNT_API_URL: string;
- PUBLIC_CHECKOUT_DOMAIN: string;
- }

```
14 changes: 2 additions & 12 deletions docs/shopify-dev/analytics-setup/ts/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
CustomerAccount,
HydrogenCart,
HydrogenSessionData,
ShopifyEnv,
} from '@shopify/hydrogen';
import type {AppSession} from '~/lib/session';

Expand All @@ -22,18 +23,7 @@ declare global {
/**
* Declare expected Env parameter in fetch handler.
*/
interface Env {
SESSION_SECRET: string;
PUBLIC_STOREFRONT_API_TOKEN: string;
PRIVATE_STOREFRONT_API_TOKEN: string;
PUBLIC_STORE_DOMAIN: string;
PUBLIC_STOREFRONT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_URL: string;
// [START envtype]
PUBLIC_CHECKOUT_DOMAIN: string;
// [END envtype]
}
interface Env extends ShopifyEnv {}
}

declare module '@shopify/remix-oxygen' {
Expand Down
12 changes: 2 additions & 10 deletions examples/b2b/app/remix.env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
CustomerAccount,
HydrogenCart,
HydrogenSessionData,
ShopifyEnv,
} from '@shopify/hydrogen';
import type {AppSession} from '~/lib/session';

Expand All @@ -22,16 +23,7 @@ declare global {
/**
* Declare expected Env parameter in fetch handler.
*/
interface Env {
SESSION_SECRET: string;
PUBLIC_STOREFRONT_API_TOKEN: string;
PRIVATE_STOREFRONT_API_TOKEN: string;
PUBLIC_STORE_DOMAIN: string;
PUBLIC_STOREFRONT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_URL: string;
PUBLIC_CHECKOUT_DOMAIN: string;
}
interface Env extends ShopifyEnv {}
}

declare module '@shopify/remix-oxygen' {
Expand Down
12 changes: 2 additions & 10 deletions examples/classic-remix/remix.env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
CustomerAccount,
HydrogenCart,
HydrogenSessionData,
ShopifyEnv,
} from '@shopify/hydrogen';
import type {AppSession} from '~/lib/session';

Expand All @@ -22,16 +23,7 @@ declare global {
/**
* Declare expected Env parameter in fetch handler.
*/
interface Env {
SESSION_SECRET: string;
PUBLIC_STOREFRONT_API_TOKEN: string;
PRIVATE_STOREFRONT_API_TOKEN: string;
PUBLIC_STORE_DOMAIN: string;
PUBLIC_STOREFRONT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_URL: string;
PUBLIC_CHECKOUT_DOMAIN: string;
}
interface Env extends ShopifyEnv {}
}

declare module '@shopify/remix-oxygen' {
Expand Down
12 changes: 2 additions & 10 deletions examples/custom-cart-method/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
HydrogenCartCustom,
HydrogenSessionData,
CartQueryDataReturn,
ShopifyEnv,
} from '@shopify/hydrogen';
import type {
SelectedOptionInput,
Expand All @@ -28,16 +29,7 @@ declare global {
/**
* Declare expected Env parameter in fetch handler.
*/
interface Env {
SESSION_SECRET: string;
PUBLIC_STOREFRONT_API_TOKEN: string;
PRIVATE_STOREFRONT_API_TOKEN: string;
PUBLIC_STORE_DOMAIN: string;
PUBLIC_STOREFRONT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_URL: string;
PUBLIC_CHECKOUT_DOMAIN: string;
}
interface Env extends ShopifyEnv {}
}

declare module '@shopify/remix-oxygen' {
Expand Down
12 changes: 2 additions & 10 deletions examples/express/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
CustomerAccount,
HydrogenCart,
HydrogenSessionData,
ShopifyEnv,
} from '@shopify/hydrogen';
import type {AppSession} from '~/lib/session';

Expand All @@ -22,16 +23,7 @@ declare global {
/**
* Declare expected Env parameter in fetch handler.
*/
interface Env {
SESSION_SECRET: string;
PUBLIC_STOREFRONT_API_TOKEN: string;
PRIVATE_STOREFRONT_API_TOKEN: string;
PUBLIC_STORE_DOMAIN: string;
PUBLIC_STOREFRONT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_URL: string;
PUBLIC_CHECKOUT_DOMAIN: string;
}
interface Env extends ShopifyEnv {}
}

declare module '@shopify/remix-oxygen' {
Expand Down
11 changes: 2 additions & 9 deletions examples/legacy-customer-account-flow/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Enhance TypeScript's built-in typings.
import '@total-typescript/ts-reset';

import type {Storefront, HydrogenCart} from '@shopify/hydrogen';
import type {Storefront, HydrogenCart, ShopifyEnv} from '@shopify/hydrogen';
import type {CustomerAccessToken} from '@shopify/hydrogen/storefront-api-types';
import type {AppSession} from '~/lib/session';

Expand All @@ -18,14 +18,7 @@ declare global {
/**
* Declare expected Env parameter in fetch handler.
*/
interface Env {
SESSION_SECRET: string;
PUBLIC_STOREFRONT_API_TOKEN: string;
PRIVATE_STOREFRONT_API_TOKEN: string;
PUBLIC_STORE_DOMAIN: string;
PUBLIC_STOREFRONT_ID: string;
PUBLIC_CHECKOUT_DOMAIN: string;
}
interface Env extends ShopifyEnv {}
}

declare module '@shopify/remix-oxygen' {
Expand Down
11 changes: 2 additions & 9 deletions examples/metaobjects/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
CustomerAccount,
HydrogenCart,
HydrogenSessionData,
ShopifyEnv,
} from '@shopify/hydrogen';
import type {AppSession} from '~/lib/session';

Expand All @@ -22,15 +23,7 @@ declare global {
/**
* Declare expected Env parameter in fetch handler.
*/
interface Env {
SESSION_SECRET: string;
PUBLIC_STOREFRONT_API_TOKEN: string;
PRIVATE_STOREFRONT_API_TOKEN: string;
PUBLIC_STORE_DOMAIN: string;
PUBLIC_STOREFRONT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_URL: string;
PUBLIC_CHECKOUT_DOMAIN: string;
interface Env extends ShopifyEnv {
/***********************************************/
/********** EXAMPLE UPDATE STARTS ************/
PUBLIC_SHOPIFY_STORE_DOMAIN: string;
Expand Down
12 changes: 3 additions & 9 deletions examples/multipass/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
CustomerAccount,
HydrogenCart,
HydrogenSessionData,
ShopifyEnv,
} from '@shopify/hydrogen';
import type {AppSession} from '~/lib/session';

Expand All @@ -22,15 +23,8 @@ declare global {
/**
* Declare expected Env parameter in fetch handler.
*/
interface Env {
SESSION_SECRET: string;
PUBLIC_STOREFRONT_API_TOKEN: string;
PRIVATE_STOREFRONT_API_TOKEN: string;
PUBLIC_STORE_DOMAIN: string;
PUBLIC_STOREFRONT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_URL: string;
PUBLIC_CHECKOUT_DOMAIN: string;

interface Env extends ShopifyEnv {
/***********************************************/
/********** EXAMPLE UPDATE STARTS ************/
PRIVATE_SHOPIFY_STORE_MULTIPASS_SECRET: string;
Expand Down
7 changes: 1 addition & 6 deletions examples/partytown/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,7 @@ declare global {
/**
* Declare expected Env parameter in fetch handler.
*/
interface Env {
SESSION_SECRET: string;
PUBLIC_STOREFRONT_API_TOKEN: string;
PRIVATE_STOREFRONT_API_TOKEN: string;
PUBLIC_STORE_DOMAIN: string;
PUBLIC_STOREFRONT_ID: string;
interface Env extends ShopifyEnv {
+ GTM_CONTAINER_ID: `GTM-${string}`;
}
}
Expand Down
11 changes: 2 additions & 9 deletions examples/partytown/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
CustomerAccount,
HydrogenCart,
HydrogenSessionData,
ShopifyEnv,
} from '@shopify/hydrogen';
import type {AppSession} from '~/lib/session';

Expand All @@ -22,15 +23,7 @@ declare global {
/**
* Declare expected Env parameter in fetch handler.
*/
interface Env {
SESSION_SECRET: string;
PUBLIC_STOREFRONT_API_TOKEN: string;
PRIVATE_STOREFRONT_API_TOKEN: string;
PUBLIC_STORE_DOMAIN: string;
PUBLIC_STOREFRONT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_URL: string;
PUBLIC_CHECKOUT_DOMAIN: string;
interface Env extends ShopifyEnv {
/***********************************************/
/********** EXAMPLE UPDATE STARTS ************/
GTM_CONTAINER_ID: `GTM-${string}`;
Expand Down
12 changes: 2 additions & 10 deletions examples/third-party-queries-caching/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
CustomerAccount,
HydrogenCart,
HydrogenSessionData,
ShopifyEnv,
} from '@shopify/hydrogen';
import type {AppSession} from '~/lib/session';
import {createRickAndMortyClient} from './app/lib/createRickAndMortyClient.server';
Expand All @@ -23,16 +24,7 @@ declare global {
/**
* Declare expected Env parameter in fetch handler.
*/
interface Env {
SESSION_SECRET: string;
PUBLIC_STOREFRONT_API_TOKEN: string;
PRIVATE_STOREFRONT_API_TOKEN: string;
PUBLIC_STORE_DOMAIN: string;
PUBLIC_STOREFRONT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_URL: string;
PUBLIC_CHECKOUT_DOMAIN: string;
}
interface Env extends ShopifyEnv {}
}

declare module '@shopify/remix-oxygen' {
Expand Down
12 changes: 2 additions & 10 deletions packages/cli/src/lib/setups/i18n/replacers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('i18n replacers', () => {
CustomerAccount,
HydrogenCart,
HydrogenSessionData,
ShopifyEnv,
} from "@shopify/hydrogen";
import type {
LanguageCode,
Expand All @@ -75,16 +76,7 @@ describe('i18n replacers', () => {
/**
* Declare expected Env parameter in fetch handler.
*/
interface Env {
SESSION_SECRET: string;
PUBLIC_STOREFRONT_API_TOKEN: string;
PRIVATE_STOREFRONT_API_TOKEN: string;
PUBLIC_STORE_DOMAIN: string;
PUBLIC_STOREFRONT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_URL: string;
PUBLIC_CHECKOUT_DOMAIN: string;
}
interface Env extends ShopifyEnv {}

/**
* The I18nLocale used for Storefront API query context.
Expand Down
11 changes: 2 additions & 9 deletions packages/hydrogen/dev.env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import type {HydrogenCart, Storefront} from './src/index';
import type {WaitUntil} from './src/types';
import type {WaitUntil, ShopifyEnv} from './src/types';

declare global {
/**
Expand All @@ -15,14 +15,7 @@ declare global {
/**
* Declare expected Env parameter in fetch handler.
*/
interface Env {
SESSION_SECRET: string;
PUBLIC_STOREFRONT_API_TOKEN: string;
PRIVATE_STOREFRONT_API_TOKEN: string;
PUBLIC_STORE_DOMAIN: string;
PUBLIC_STOREFRONT_ID: string;
PUBLIC_CHECKOUT_DOMAIN: string;
}
interface Env extends ShopifyEnv {}

/**
* This type is used to import types from mini-oxygen
Expand Down
2 changes: 1 addition & 1 deletion packages/hydrogen/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@ export type {
StorefrontApiResponsePartial,
} from '@shopify/hydrogen-react';

export type {HydrogenSessionData, HydrogenSession} from './types';
export type {HydrogenSessionData, HydrogenSession, ShopifyEnv} from './types';
11 changes: 11 additions & 0 deletions packages/hydrogen/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ export interface HydrogenSession<

export type WaitUntil = (promise: Promise<unknown>) => void;

export interface ShopifyEnv {
SESSION_SECRET: string;
PUBLIC_STOREFRONT_API_TOKEN: string;
PRIVATE_STOREFRONT_API_TOKEN: string;
PUBLIC_STORE_DOMAIN: string;
PUBLIC_STOREFRONT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID: string;
PUBLIC_CUSTOMER_ACCOUNT_API_URL: string;
PUBLIC_CHECKOUT_DOMAIN: string;
}

declare global {
interface Window {
privacyBanner: PrivacyBanner;
Expand Down
Loading
Loading