cli icon indicating copy to clipboard operation
cli copied to clipboard

create identity client interface

Open alexanderMontague opened this issue 1 month ago β€’ 4 comments

WHY are these changes introduced?

Part of: https://github.com/shop/issues-develop/issues/21594

  • We're trying to improve our local development experience for using the CLI
  • A good first step is being able to hit our APIs without the identity service running

WHAT is this pull request doing?

  • scaffolds out the interface for the identity client that we will use
  • defines the client swapping capabilities based on the environment and what services are running

How to test your changes?

  • included tests
  • looking for feedback on a better singleton pattern if possible

alexanderMontague avatar Nov 18 '25 20:11 alexanderMontague

This stack of pull requests is managed by Graphite. Learn more about stacking.

alexanderMontague avatar Nov 18 '25 20:11 alexanderMontague

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟑 Statements
79.17% (-0.06% πŸ”»)
13615/17198
🟑 Branches
73.12% (+0.01% πŸ”Ό)
6640/9081
🟑 Functions
79.18% (-0.19% πŸ”»)
3510/4433
🟑 Lines
79.53% (-0.06% πŸ”»)
12860/16171
Show new covered files 🐣
St.:grey_question:
File Statements Branches Functions Lines
🟒
... / bulk-operation-run-query.ts
100% 100% 100% 100%
🟒
... / execute-bulk-operation.ts
100% 83.33% 100% 100%
🟒
... / run-query.ts
100% 100% 100% 100%
πŸ”΄
... / identity-client.ts
0% 100% 0% 0%
πŸ”΄
... / identity-mock-client.ts
0% 100% 0% 0%
πŸ”΄
... / identity-service-client.ts
0% 100% 0% 0%
🟒
... / instance.ts
100% 100% 100% 100%
Show files with reduced coverage πŸ”»
St.:grey_question:
File Statements Branches Functions Lines
🟒
... / ConcurrentOutput.tsx
98.36% (-1.64% πŸ”»)
92% (-4% πŸ”»)
100%
98.33% (-1.67% πŸ”»)
πŸ”΄
... / ui.tsx
50.82% (-0.79% πŸ”»)
42.86% (-5.53% πŸ”»)
54.55% (+1.42% πŸ”Ό)
50% (-0.82% πŸ”»)
🟑
... / theme-environment.ts
69.57% (-1.86% πŸ”»)
50%
55.56% (-3.27% πŸ”»)
69.57% (-1.86% πŸ”»)

Test suite run success

3364 tests passing in 1378 suites.

Report generated by πŸ§ͺjest coverage report action from ec62db8d3f64108e173971f2031c3c98b54c16b2

github-actions[bot] avatar Nov 18 '25 20:11 github-actions[bot]

Differences in type declarations

We 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:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

packages/cli-kit/dist/private/node/clients/identity/identity-client.d.ts
import { ApplicationToken, IdentityToken } from '../../session/schema.js';
import { ExchangeScopes } from '../../session/exchange.js';
import { API } from '../../api.js';
export declare abstract class IdentityClient {
    abstract requestAccessToken(scopes: string[]): Promise<IdentityToken>;
    abstract exchangeAccessForApplicationTokens(identityToken: IdentityToken, scopes: ExchangeScopes, store?: string): Promise<{
        [x: string]: ApplicationToken;
    }>;
    abstract refreshAccessToken(currentToken: IdentityToken): Promise<IdentityToken>;
    clientId(): string;
    applicationId(_api: API): string;
}

packages/cli-kit/dist/private/node/clients/identity/identity-mock-client.d.ts
import { IdentityClient } from './identity-client.js';
import { ApplicationToken, IdentityToken } from '../../session/schema.js';
import { ExchangeScopes } from '../../session/exchange.js';
export declare class IdentityMockClient extends IdentityClient {
    requestAccessToken(_scopes: string[]): Promise<IdentityToken>;
    exchangeAccessForApplicationTokens(_identityToken: IdentityToken, _scopes: ExchangeScopes, _store?: string): Promise<{
        [x: string]: ApplicationToken;
    }>;
    refreshAccessToken(_currentToken: IdentityToken): Promise<IdentityToken>;
}

packages/cli-kit/dist/private/node/clients/identity/identity-service-client.d.ts
import { IdentityClient } from './identity-client.js';
import { ApplicationToken, IdentityToken } from '../../session/schema.js';
import { ExchangeScopes } from '../../session/exchange.js';
export declare class IdentityServiceClient extends IdentityClient {
    requestAccessToken(_scopes: string[]): Promise<IdentityToken>;
    exchangeAccessForApplicationTokens(_identityToken: IdentityToken, _scopes: ExchangeScopes, _store?: string): Promise<{
        [x: string]: ApplicationToken;
    }>;
    refreshAccessToken(_currentToken: IdentityToken): Promise<IdentityToken>;
}

packages/cli-kit/dist/private/node/clients/identity/instance.d.ts
import { IdentityClient } from './identity-client.js';
export declare function getIdentityClient(): IdentityClient;

Existing type declarations

packages/cli-kit/dist/public/node/vendor/dev_server/dev-server-2024.d.ts
@@ -4,6 +4,7 @@ export declare function createServer(projectName: string): {
     url: (options?: HostOptions) => string;
 };
 declare function assertRunning2024(projectName: string): void;
+export declare function isRunning2024(projectName: string): boolean;
 declare let assertRunningOverride: typeof assertRunning2024 | undefined;
 export declare function setAssertRunning(override: typeof assertRunningOverride): void;
 export {};
\ No newline at end of file

github-actions[bot] avatar Nov 20 '25 16:11 github-actions[bot]

We detected some changes at packages/*/src and there are no updates in the .changeset. If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

[!CAUTION] DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

github-actions[bot] avatar Nov 20 '25 22:11 github-actions[bot]