create identity client interface
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
- #6654

- #6647

- #6642

- #6641

- #6635

- #6634
π (View in Graphite) main
This stack of pull requests is managed by Graphite. Learn more about stacking.
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
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
mainyou might see odd diffs, rebasemaininto 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
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.