Skip to content

Commit

Permalink
Merge pull request #1743 from Shopify/revert-1705-zoey/remove-future-…
Browse files Browse the repository at this point in the history
…flag

Revert "Remove future flag for released feature"
  • Loading branch information
lizkenyon authored Nov 8, 2024
2 parents ea41875 + bff2238 commit 8262011
Show file tree
Hide file tree
Showing 7 changed files with 8,916 additions and 4,828 deletions.
5 changes: 0 additions & 5 deletions .changeset/four-bugs-fix.md

This file was deleted.

13,701 changes: 8,886 additions & 4,815 deletions packages/apps/shopify-app-remix/docs/generated/generated_docs_data.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {FutureFlags, FutureFlagOptions} from '../future/flags';
*/
const TEST_FUTURE_FLAGS: Required<{[key in keyof FutureFlags]: true}> = {
unstable_newEmbeddedAuthStrategy: true,
wip_optionalScopesApi: true,
} as const;

// Override the helper's future flags and logger settings for our purposes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,13 @@ export function authStrategyFactory<
}

function addScopesFeatures(context: AdminContextBase) {
return {
...context,
scopes: scopesApiFactory(params, context.session, context.admin),
};
if (config.future.wip_optionalScopesApi) {
return {
...context,
scopes: scopesApiFactory(params, context.session, context.admin),
};
}
return context;
}

return async function authenticateAdmin(request: Request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import * as redirect from '../../helpers/redirect-to-install-page';

import * as responses from './mock-responses';

it('scopes api is available without any future flags', async () => {
it('when the future flag is disabled the scopes api is not available', async () => {
// GIVEN
const shopify = shopifyApp(
testConfig({
isEmbeddedApp: false,
scopes: undefined,
future: {},
future: {wip_optionalScopesApi: false},
}),
);
const session = await setUpValidSession(shopify.sessionStorage);
Expand All @@ -39,7 +39,7 @@ it('scopes api is available without any future flags', async () => {
const adminApi = await shopify.authenticate.admin(request);

// THEN
expect(adminApi).toHaveProperty('scopes');
expect(adminApi).not.toHaveProperty('scopes');
});

it('when scopes are empty the request is not redirected', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {JwtPayload, Session, ShopifyRestResources} from '@shopify/shopify-api';
import {EnsureCORSFunction} from '../helpers/ensure-cors-headers';
import type {AppConfigArg} from '../../config-types';
import type {AdminApiContext} from '../../clients';
import {FeatureEnabled} from '../../future/flags';

import type {BillingContext} from './billing/types';
import {RedirectFunction} from './helpers/redirect';
Expand Down Expand Up @@ -204,7 +205,10 @@ export interface ScopesContext {
export type AdminContext<
Config extends AppConfigArg,
Resources extends ShopifyRestResources,
> = EmbeddedTypedAdminContext<Config, Resources> & ScopesContext;
> =
FeatureEnabled<Config['future'], 'wip_optionalScopesApi'> extends true
? EmbeddedTypedAdminContext<Config, Resources> & ScopesContext
: EmbeddedTypedAdminContext<Config, Resources>;

export type AuthenticateAdmin<
Config extends AppConfigArg,
Expand Down
14 changes: 14 additions & 0 deletions packages/apps/shopify-app-remix/src/server/future/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ export interface FutureFlags {
* @default false
*/
unstable_newEmbeddedAuthStrategy?: boolean;

/**
* When enabled, the Scopes API will be available. This feature is in development and requires special permissions from Shopify for now.
*
* @default false
*/
wip_optionalScopesApi?: boolean;
}

// When adding new flags, use this format:
Expand Down Expand Up @@ -56,4 +63,11 @@ export function logDisabledFutureFlags(
'\n Your app must be using Shopify managed install: https://shopify.dev/docs/apps/auth/installation',
);
}

if (!config.future.wip_optionalScopesApi) {
logFlag(
'wip_optionalScopesApi',
'Enable this to use the optionalScopes API to request additional scopes and manage them. ',
);
}
}

0 comments on commit 8262011

Please sign in to comment.