Skip to content

Commit

Permalink
Fix future flag conversion to api object
Browse files Browse the repository at this point in the history
  • Loading branch information
paulomarg committed Jan 16, 2024
1 parent d00eb03 commit 84eb601
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -17,7 +22,12 @@ import {AuthorizationStrategy, SessionContext, OnErrorOptions} from './types';
export class TokenExchangeStrategy<Config extends AppConfigArg>
implements AuthorizationStrategy
{
protected api: Shopify<ApiConfigWithFutureFlags<Config['future']>>;
protected api: Shopify<
ApiConfigWithFutureFlags<Config['future']>,
ShopifyRestResources,
ApiFutureFlags<Config['future']>
>;

protected config: AppConfig;
protected logger: Shopify['logger'];

Expand Down
20 changes: 12 additions & 8 deletions packages/shopify-app-remix/src/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,23 @@ import {FutureFlagOptions, FutureFlags} from './future/flags';
export interface BasicParams<
Future extends FutureFlagOptions = FutureFlagOptions,
> {
api: Shopify<ApiConfigWithFutureFlags<Future>>;
api: Shopify<
ApiConfigWithFutureFlags<Future>,
ShopifyRestResources,
ApiFutureFlags<Future>
>;
config: AppConfig;
logger: Shopify['logger'];
}

export interface ApiFutureFlags<Future extends FutureFlagOptions> {
unstable_tokenExchange?: Future extends FutureFlags
? Future['unstable_newEmbeddedAuthStrategy']
: boolean;
}

export type ApiConfigWithFutureFlags<Future extends FutureFlagOptions> =
ConfigParams & {
future?: {
unstable_tokenExchange?: Future extends FutureFlags
? Future['unstable_newEmbeddedAuthStrategy']
: boolean;
};
};
ConfigParams<ShopifyRestResources, ApiFutureFlags<Future>>;

export type JSONValue =
| string
Expand Down

0 comments on commit 84eb601

Please sign in to comment.