Recover theme commands after a preview store is claimed - #8390
Draft
dmerand wants to merge 1 commit into
Draft
Conversation
Assisted-By: devx/6b8a4c45-3042-4ae7-8f77-3e1296bbe6ac
Contributor
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationspackages/cli-kit/dist/public/node/store-auth-recovery.d.tsimport type { LocalStorage } from './local-storage.js';
import type { StoreAuthSessionSchema, StoredStoreAppSession } from './store-auth-session.js';
/**
* Throws an actionable error when no store app authentication is stored.
*
* @param store - The store FQDN that needs authentication.
* @throws AbortError with a `store auth` next step.
*/
export declare function throwMissingStoredStoreAuthError(store: string): never;
/**
* Throws an actionable error that directs the user to re-authenticate a stored session.
*
* @param message - The reason that the stored session cannot be used.
* @param session - The stored session to authenticate again.
* @throws AbortError with a `store auth` next step.
*/
export declare function throwReauthenticateStoreAuthError(message: string, session: StoredStoreAppSession): never;
/**
* Throws the invalid-session error for a stored store app session.
*
* @param session - The stored session rejected by Shopify.
* @throws AbortError with a `store auth` next step.
*/
export declare function throwStoredStoreAuthInvalidError(session: StoredStoreAppSession): never;
interface InvalidStoredStoreAuthOptions {
invalidStatuses?: ReadonlyArray<number>;
storage?: LocalStorage<StoreAuthSessionSchema>;
}
/**
* Clears and reports a rejected stored session when its HTTP status is invalid for the caller.
*
* @param error - The rejected API error.
* @param session - The stored session used for the request.
* @param options - Statuses to classify and an optional storage override.
* @throws AbortError with a `store auth` next step when the session is invalid.
*/
export declare function throwIfStoredStoreAuthIsInvalid(error: unknown, session: StoredStoreAppSession, options?: InvalidStoredStoreAuthOptions): void;
export {};
Existing type declarationspackages/cli-kit/dist/public/node/store-auth-session.d.ts@@ -55,7 +55,8 @@ interface StoredStoreAppSessionBucket {
[userId: string]: StoredStoreAppSession;
};
}
-interface StoreAuthSessionSchema {
+/** Store auth sessions, keyed by the store auth storage key. */
+export interface StoreAuthSessionSchema {
[key: string]: StoredStoreAppSessionBucket;
}
/**
packages/cli-kit/dist/public/node/api/admin.d.ts@@ -1,8 +1,14 @@
import { GraphQLResponseOptions, GraphQLVariables } from './graphql.js';
import { AdminSession } from '../session.js';
+import { AbortError } from '../error.js';
import { RequestModeInput } from '../http.js';
import { Variables } from 'graphql-request';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
+/** Error that preserves an Admin API status for caller-specific recovery. */
+export declare class AdminApiRequestError extends AbortError {
+ readonly status: number;
+ constructor(status: number, message: string);
+}
/**
* Executes a GraphQL query against the Admin API.
*
|
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
Supersedes #8190. Builds on #8349, which added the
storecommand recovery after a preview store is claimed.The CLI gets no claim event when a preview store is claimed. The first signal is an HTTP 401 from the stored preview token. Before this change, theme commands swallowed that 401:
fetchThemetreated it as a missing theme,ThemeManagerdropped the stored theme ID, and multi-environment runs printed the raw error without recovery steps.WHAT is this pull request doing?
--passwordsessions are never cleared.shopify store authagain. A 404 still means a missing theme.fetchThemepropagates a 401 for all supported error shapes (status,response.status, andstatusCode) instead of returningundefined, soThemeManagerkeeps the stored theme ID.fetchApiVersionspreserves the HTTP status on its connection error (AdminApiRequestError) so callers can classify it.FatalErrornext steps in the per-environment failure output and continue with the healthy environments.@shopify/storeto@shopify/cli-kit(store-auth-recovery). The helper default policy is 401-only;storecommands opt in to[401, 404]explicitly, sostorebehavior from Fix reauthentication after a preview store is claimed #8349 is unchanged.How to test your changes?
shopify store create preview, then run a theme command (for exampleshopify theme list --store <preview-store>) with the stored preview session.shopify store authnext step, instead of a missing-theme error.Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add