@shopify/shopify-app-remix
Version:
Shopify Remix - to simplify the building of Shopify Apps with Remix
28 lines (25 loc) • 1.11 kB
JavaScript
import { AuthScopes } from '@shopify/shopify-api';
import { fetchScopeDetail } from './client/fetch-scopes-details.mjs';
function queryScopesFactory(params, session, admin) {
return async function queryScopes() {
const { logger } = params;
logger.debug('Querying scopes details: ', {
shop: session.shop,
});
const scopesDetail = await fetchScopeDetail(admin);
return mapFetchScopeDetail(scopesDetail);
};
}
function mapFetchScopeDetail(scopesDetailResponse) {
const appInformation = scopesDetailResponse.app;
const granted = new AuthScopes(appInformation.installation.accessScopes.map((scope) => scope.handle));
const required = new AuthScopes(appInformation.requestedAccessScopes.map((scope) => scope.handle));
const optional = new AuthScopes(appInformation.optionalAccessScopes.map((scope) => scope.handle));
return {
granted: granted.toArray(),
required: required.toArray(),
optional: optional.toArray(),
};
}
export { mapFetchScopeDetail, queryScopesFactory };
//# sourceMappingURL=query.mjs.map