From 84eb601f7271064cd4975c4e81d5efbecd672187 Mon Sep 17 00:00:00 2001 From: Paulo Margarido <64600052+paulomarg@users.noreply.github.com> Date: Tue, 16 Jan 2024 09:51:04 -0500 Subject: [PATCH] Fix future flag conversion to api object --- .../admin/strategies/token-exchange.ts | 16 ++++++++++++--- .../shopify-app-remix/src/server/types.ts | 20 +++++++++++-------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/packages/shopify-app-remix/src/server/authenticate/admin/strategies/token-exchange.ts b/packages/shopify-app-remix/src/server/authenticate/admin/strategies/token-exchange.ts index 0d3909d1cc..f1c0308ae0 100644 --- a/packages/shopify-app-remix/src/server/authenticate/admin/strategies/token-exchange.ts +++ b/packages/shopify-app-remix/src/server/authenticate/admin/strategies/token-exchange.ts @@ -4,10 +4,15 @@ import { RequestedTokenType, Session, Shopify, + ShopifyRestResources, } from '@shopify/shopify-api'; -import {AppConfig, AppConfigArg} from 'src/server/config-types'; -import {BasicParams, ApiConfigWithFutureFlags} from 'src/server/types'; +import {AppConfig, AppConfigArg} from '../../../config-types'; +import { + BasicParams, + ApiConfigWithFutureFlags, + ApiFutureFlags, +} from '../../../types'; import {respondToInvalidSessionToken} from '../../helpers'; import {handleClientErrorFactory, triggerAfterAuthHook} from '../helpers'; import {HandleAdminClientError} from '../../../clients'; @@ -17,7 +22,12 @@ import {AuthorizationStrategy, SessionContext, OnErrorOptions} from './types'; export class TokenExchangeStrategy implements AuthorizationStrategy { - protected api: Shopify>; + protected api: Shopify< + ApiConfigWithFutureFlags, + ShopifyRestResources, + ApiFutureFlags + >; + protected config: AppConfig; protected logger: Shopify['logger']; diff --git a/packages/shopify-app-remix/src/server/types.ts b/packages/shopify-app-remix/src/server/types.ts index 323f7b0af4..e3cfaa55ac 100644 --- a/packages/shopify-app-remix/src/server/types.ts +++ b/packages/shopify-app-remix/src/server/types.ts @@ -19,19 +19,23 @@ import {FutureFlagOptions, FutureFlags} from './future/flags'; export interface BasicParams< Future extends FutureFlagOptions = FutureFlagOptions, > { - api: Shopify>; + api: Shopify< + ApiConfigWithFutureFlags, + ShopifyRestResources, + ApiFutureFlags + >; config: AppConfig; logger: Shopify['logger']; } +export interface ApiFutureFlags { + unstable_tokenExchange?: Future extends FutureFlags + ? Future['unstable_newEmbeddedAuthStrategy'] + : boolean; +} + export type ApiConfigWithFutureFlags = - ConfigParams & { - future?: { - unstable_tokenExchange?: Future extends FutureFlags - ? Future['unstable_newEmbeddedAuthStrategy'] - : boolean; - }; - }; + ConfigParams>; export type JSONValue = | string