-
Notifications
You must be signed in to change notification settings - Fork 178
Force all requests in app management to have an unauthorizedHandler #5886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 05-22-remove_refreshtokens
Are you sure you want to change the base?
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
13dfe69
to
1ea4356
Compare
1ea4356
to
aca8ccc
Compare
941f8b1
to
9bfc070
Compare
aca8ccc
to
9ede791
Compare
9bfc070
to
5c11314
Compare
9ede791
to
c97d4b2
Compare
5c11314
to
bb18dc1
Compare
c97d4b2
to
20763e7
Compare
We detected some changes at Caution DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release. |
20763e7
to
ce1f36b
Compare
54c4aca
to
f664992
Compare
6ee3132
to
f147856
Compare
f664992
to
7b973d3
Compare
8c6deac
to
cf44586
Compare
Coverage report
Test suite run success2870 tests passing in 1254 suites. Report generated by 🧪jest coverage report action from 16a3be0 |
cf44586
to
3030250
Compare
3030250
to
56921b4
Compare
56921b4
to
428e381
Compare
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 declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/public/node/api/app-dev.d.ts@@ -1,13 +1,25 @@
+import { UnauthorizedHandler } from './graphql.js';
import { Variables } from 'graphql-request';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
/**
- * Executes an org-scoped GraphQL query against the App Management API.
- * Uses typed documents.
- *
* @param query - GraphQL query to execute.
* @param shopFqdn - The shop fqdn.
* @param token - Partners token.
* @param variables - GraphQL variables to pass to the query.
+ * @param unauthorizedHandler - Unauthorized handler to use.
+ */
+export interface AppDevRequestOptions<TResult, TVariables extends Variables> {
+ query: TypedDocumentNode<TResult, TVariables>;
+ shopFqdn: string;
+ token: string;
+ unauthorizedHandler: UnauthorizedHandler;
+ variables?: TVariables;
+}
+/**
+ * Executes an org-scoped GraphQL query against the App Management API.
+ * Uses typed documents.
+ *
+ * @param options - The options for the request.
* @returns The response of the query of generic type <T>.
*/
-export declare function appDevRequest<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, shopFqdn: string, token: string, variables?: TVariables): Promise<TResult>;
\ No newline at end of file
+export declare function appDevRequestDoc<TResult, TVariables extends Variables>(options: AppDevRequestOptions<TResult, TVariables>): Promise<TResult>;
\ No newline at end of file
packages/cli-kit/dist/public/node/api/app-management.d.ts@@ -1,4 +1,4 @@
-import { CacheOptions, GraphQLResponse } from './graphql.js';
+import { CacheOptions, GraphQLResponse, UnauthorizedHandler } from './graphql.js';
import { RequestModeInput } from '../http.js';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
import { Variables } from 'graphql-request';
@@ -13,17 +13,30 @@ export interface RequestOptions {
requestMode: RequestModeInput;
}
/**
- * Executes an org-scoped GraphQL query against the App Management API. Uses typed documents.
- *
* @param orgId - The organization ID.
* @param query - GraphQL query to execute.
* @param token - Partners token.
* @param variables - GraphQL variables to pass to the query.
* @param cacheOptions - Cache options for the request. If not present, the request will not be cached.
* @param requestOptions - Preferred behaviour for the request.
+ * @param unauthorizedHandler - Optional handler for unauthorized requests.
+ */
+export interface AppManagementRequestOptions<TResult, TVariables extends Variables> {
+ organizationId: string;
+ query: TypedDocumentNode<TResult, TVariables>;
+ token: string;
+ variables?: TVariables;
+ cacheOptions?: CacheOptions;
+ requestOptions?: RequestOptions;
+ unauthorizedHandler: UnauthorizedHandler;
+}
+/**
+ * Executes an org-scoped GraphQL query against the App Management API. Uses typed documents.
+ *
+ * @param options - The options for the request.
* @returns The response of the query of generic type <T>.
*/
-export declare function appManagementRequestDoc<TResult, TVariables extends Variables>(orgId: string, query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables, cacheOptions?: CacheOptions, requestOptions?: RequestOptions): Promise<TResult>;
+export declare function appManagementRequestDoc<TResult, TVariables extends Variables>(options: AppManagementRequestOptions<TResult, TVariables>): Promise<TResult>;
/**
* Sets the next deprecation date from [GraphQL response extensions](https://www.apollographql.com/docs/resources/graphql-glossary/#extensions)
* if objects contain a (ISO 8601-formatted string).
packages/cli-kit/dist/public/node/api/business-platform.d.ts@@ -1,4 +1,4 @@
-import { CacheOptions, Exact, GraphQLVariables } from './graphql.js';
+import { CacheOptions, GraphQLVariables, UnauthorizedHandler } from './graphql.js';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
import { Variables } from 'graphql-request';
/**
@@ -12,34 +12,46 @@ import { Variables } from 'graphql-request';
*/
export declare function businessPlatformRequest<T>(query: string, token: string, variables?: GraphQLVariables, cacheOptions?: CacheOptions): Promise<T>;
/**
- * Executes a GraphQL query against the Business Platform Destinations API. Uses typed documents.
- *
* @param query - GraphQL query to execute.
* @param token - Business Platform token.
* @param variables - GraphQL variables to pass to the query.
* @param cacheOptions - Cache options for the request. If not present, the request will not be cached.
+ */
+export interface BusinessPlatformRequestOptions<TResult, TVariables extends Variables> {
+ query: TypedDocumentNode<TResult, TVariables>;
+ token: string;
+ variables?: TVariables;
+ cacheOptions?: CacheOptions;
+ unauthorizedHandler: UnauthorizedHandler;
+}
+/**
+ * Executes a GraphQL query against the Business Platform Destinations API. Uses typed documents.
+ *
+ * @param options - The options for the request.
* @returns The response of the query of generic type <TResult>.
*/
-export declare function businessPlatformRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables, cacheOptions?: CacheOptions): Promise<TResult>;
+export declare function businessPlatformRequestDoc<TResult, TVariables extends Variables>(options: BusinessPlatformRequestOptions<TResult, TVariables>): Promise<TResult>;
+export interface BusinessPlatformOrganizationsRequestNonTypedOptions {
+ query: string;
+ token: string;
+ organizationId: string;
+ unauthorizedHandler: UnauthorizedHandler;
+ variables?: GraphQLVariables;
+}
/**
* Executes a GraphQL query against the Business Platform Organizations API.
*
- * @param query - GraphQL query to execute.
- * @param token - Business Platform token.
- * @param organizationId - Organization ID as a numeric (non-GID) value.
- * @param variables - GraphQL variables to pass to the query.
+ * @param options - The options for the request.
* @returns The response of the query of generic type <T>.
*/
-export declare function businessPlatformOrganizationsRequest<T>(query: string, token: string, organizationId: string, variables?: GraphQLVariables): Promise<T>;
+export declare function businessPlatformOrganizationsRequest<T>(options: BusinessPlatformOrganizationsRequestNonTypedOptions): Promise<T>;
+export interface BusinessPlatformOrganizationsRequestOptions<TResult, TVariables extends Variables> extends BusinessPlatformRequestOptions<TResult, TVariables> {
+ organizationId: string;
+}
/**
* Executes a GraphQL query against the Business Platform Organizations API. Uses typed documents.
*
- * @param query - GraphQL query to execute.
- * @param token - Business Platform token.
- * @param organizationId - Organization ID as a numeric value.
- * @param variables - GraphQL variables to pass to the query.
+ * @param options - The options for the request.
* @returns The response of the query of generic type <T>.
*/
-export declare function businessPlatformOrganizationsRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables> | TypedDocumentNode<TResult, Exact<{
- [key: string]: never;
-}>>, token: string, organizationId: string, variables?: TVariables): Promise<TResult>;
\ No newline at end of file
+export declare function businessPlatformOrganizationsRequestDoc<TResult, TVariables extends Variables>(options: BusinessPlatformOrganizationsRequestOptions<TResult, TVariables>): Promise<TResult>;
\ No newline at end of file
packages/cli-kit/dist/public/node/api/functions.d.ts@@ -1,13 +1,26 @@
+import { UnauthorizedHandler } from './graphql.js';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
import { Variables } from 'graphql-request';
/**
- * Executes a rate-limited GraphQL request against the App Management Functions API.
- *
* @param orgId - Organization identifier.
* @param query - Typed GraphQL document node.
* @param token - Authentication token.
* @param appId - App identifier.
* @param variables - Optional query variables.
+ * @param unauthorizedHandler - Optional handler for unauthorized requests.
+ */
+export interface FunctionsRequestOptions<TResult, TVariables extends Variables> {
+ organizationId: string;
+ query: TypedDocumentNode<TResult, TVariables>;
+ token: string;
+ appId: string;
+ unauthorizedHandler: UnauthorizedHandler;
+ variables?: TVariables;
+}
+/**
+ * Executes a rate-limited GraphQL request against the App Management Functions API.
+ *
+ * @param options - Request options.
* @returns Promise resolving to the typed query result.
*/
-export declare function functionsRequestDoc<TResult, TVariables extends Variables>(orgId: string, query: TypedDocumentNode<TResult, TVariables>, token: string, appId: string, variables?: TVariables): Promise<TResult>;
\ No newline at end of file
+export declare function functionsRequestDoc<TResult, TVariables extends Variables>(options: FunctionsRequestOptions<TResult, TVariables>): Promise<TResult>;
\ No newline at end of file
packages/cli-kit/dist/public/node/api/graphql.d.ts@@ -17,6 +17,19 @@ export interface CacheOptions {
cacheExtraKey?: string;
cacheStore?: LocalStorage<ConfSchema>;
}
+interface RefreshedTokenOnAuthorizedResponse {
+ token?: string;
+}
+export type RefreshTokenOnAuthorizedResponse = Promise<RefreshedTokenOnAuthorizedResponse>;
+interface SimpleUnauthorizedHandler {
+ type: 'simple';
+ handler: () => Promise<void>;
+}
+interface TokenRefreshHandler {
+ type: 'token_refresh';
+ handler: () => RefreshTokenOnAuthorizedResponse;
+}
+export type UnauthorizedHandler = SimpleUnauthorizedHandler | TokenRefreshHandler;
interface GraphQLRequestBaseOptions<TResult> {
api: string;
url: string;
@@ -31,7 +44,7 @@ interface GraphQLRequestBaseOptions<TResult> {
export type GraphQLRequestOptions<T> = GraphQLRequestBaseOptions<T> & {
query: RequestDocument;
variables?: Variables;
- unauthorizedHandler?: () => Promise<void>;
+ unauthorizedHandler?: UnauthorizedHandler;
requestBehaviour?: RequestModeInput;
};
export type GraphQLRequestDocOptions<TResult, TVariables> = GraphQLRequestBaseOptions<TResult> & {
@@ -39,7 +52,7 @@ export type GraphQLRequestDocOptions<TResult, TVariables> = GraphQLRequestBaseOp
[key: string]: never;
}>>;
variables?: TVariables;
- unauthorizedHandler?: () => Promise<void>;
+ unauthorizedHandler?: UnauthorizedHandler;
requestBehaviour?: RequestModeInput;
};
export interface GraphQLResponseOptions<T> {
packages/cli-kit/dist/public/node/api/partners.d.ts@@ -1,4 +1,4 @@
-import { GraphQLVariables, GraphQLResponse, CacheOptions } from './graphql.js';
+import { GraphQLVariables, GraphQLResponse, CacheOptions, UnauthorizedHandler } from './graphql.js';
import { RequestModeInput } from '../http.js';
import { Variables } from 'graphql-request';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
@@ -10,9 +10,10 @@ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
* @param variables - GraphQL variables to pass to the query.
* @param cacheOptions - Cache options.
* @param preferredBehaviour - Preferred behaviour for the request.
+ * @param unauthorizedHandler - Optional handler for unauthorized requests.
* @returns The response of the query of generic type <T>.
*/
-export declare function partnersRequest<T>(query: string, token: string, variables?: GraphQLVariables, cacheOptions?: CacheOptions, preferredBehaviour?: RequestModeInput): Promise<T>;
+export declare function partnersRequest<T>(query: string, token: string, variables?: GraphQLVariables, cacheOptions?: CacheOptions, preferredBehaviour?: RequestModeInput, unauthorizedHandler?: UnauthorizedHandler): Promise<T>;
export declare const generateFetchAppLogUrl: (cursor?: string, filters?: {
status?: string;
source?: string;
@@ -24,9 +25,10 @@ export declare const generateFetchAppLogUrl: (cursor?: string, filters?: {
* @param token - Partners token.
* @param variables - GraphQL variables to pass to the query.
* @param preferredBehaviour - Preferred behaviour for the request.
+ * @param unauthorizedHandler - Optional handler for unauthorized requests.
* @returns The response of the query of generic type <TResult>.
*/
-export declare function partnersRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables, preferredBehaviour?: RequestModeInput): Promise<TResult>;
+export declare function partnersRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables, preferredBehaviour?: RequestModeInput, unauthorizedHandler?: UnauthorizedHandler): Promise<TResult>;
/**
* Sets the next deprecation date from [GraphQL response extensions](https://www.apollographql.com/docs/resources/graphql-glossary/#extensions)
* if objects contain a (ISO 8601-formatted string).
packages/cli-kit/dist/public/node/api/webhooks.d.ts@@ -1,13 +1,21 @@
+import { UnauthorizedHandler } from './graphql.js';
import { Variables } from 'graphql-request';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
+/**
+ * Options for making requests to the Webhooks API.
+ */
+export interface WebhooksRequestOptions<TResult, TVariables extends Variables> {
+ organizationId: string;
+ query: TypedDocumentNode<TResult, TVariables>;
+ token: string;
+ unauthorizedHandler: UnauthorizedHandler;
+ variables?: TVariables;
+}
/**
* Executes an org-scoped GraphQL query against the App Management API.
* Uses typed documents.
*
- * @param organizationId - Organization ID required to check permissions.
- * @param query - GraphQL query to execute.
- * @param token - Partners token.
- * @param variables - GraphQL variables to pass to the query.
+ * @param options - The options for the request.
* @returns The response of the query of generic type <T>.
*/
-export declare function webhooksRequest<TResult, TVariables extends Variables>(organizationId: string, query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables): Promise<TResult>;
\ No newline at end of file
+export declare function webhooksRequestDoc<TResult, TVariables extends Variables>(options: WebhooksRequestOptions<TResult, TVariables>): Promise<TResult>;
\ No newline at end of file
|
428e381
to
16a3be0
Compare
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 declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/public/node/api/app-dev.d.ts@@ -1,13 +1,25 @@
+import { UnauthorizedHandler } from './graphql.js';
import { Variables } from 'graphql-request';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
/**
- * Executes an org-scoped GraphQL query against the App Management API.
- * Uses typed documents.
- *
* @param query - GraphQL query to execute.
* @param shopFqdn - The shop fqdn.
* @param token - Partners token.
* @param variables - GraphQL variables to pass to the query.
+ * @param unauthorizedHandler - Unauthorized handler to use.
+ */
+export interface AppDevRequestOptions<TResult, TVariables extends Variables> {
+ query: TypedDocumentNode<TResult, TVariables>;
+ shopFqdn: string;
+ token: string;
+ unauthorizedHandler: UnauthorizedHandler;
+ variables?: TVariables;
+}
+/**
+ * Executes an org-scoped GraphQL query against the App Management API.
+ * Uses typed documents.
+ *
+ * @param options - The options for the request.
* @returns The response of the query of generic type <T>.
*/
-export declare function appDevRequest<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, shopFqdn: string, token: string, variables?: TVariables): Promise<TResult>;
\ No newline at end of file
+export declare function appDevRequestDoc<TResult, TVariables extends Variables>(options: AppDevRequestOptions<TResult, TVariables>): Promise<TResult>;
\ No newline at end of file
packages/cli-kit/dist/public/node/api/app-management.d.ts@@ -1,4 +1,4 @@
-import { CacheOptions, GraphQLResponse } from './graphql.js';
+import { CacheOptions, GraphQLResponse, UnauthorizedHandler } from './graphql.js';
import { RequestModeInput } from '../http.js';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
import { Variables } from 'graphql-request';
@@ -13,17 +13,30 @@ export interface RequestOptions {
requestMode: RequestModeInput;
}
/**
- * Executes an org-scoped GraphQL query against the App Management API. Uses typed documents.
- *
* @param orgId - The organization ID.
* @param query - GraphQL query to execute.
* @param token - Partners token.
* @param variables - GraphQL variables to pass to the query.
* @param cacheOptions - Cache options for the request. If not present, the request will not be cached.
* @param requestOptions - Preferred behaviour for the request.
+ * @param unauthorizedHandler - Optional handler for unauthorized requests.
+ */
+export interface AppManagementRequestOptions<TResult, TVariables extends Variables> {
+ organizationId: string;
+ query: TypedDocumentNode<TResult, TVariables>;
+ token: string;
+ variables?: TVariables;
+ cacheOptions?: CacheOptions;
+ requestOptions?: RequestOptions;
+ unauthorizedHandler: UnauthorizedHandler;
+}
+/**
+ * Executes an org-scoped GraphQL query against the App Management API. Uses typed documents.
+ *
+ * @param options - The options for the request.
* @returns The response of the query of generic type <T>.
*/
-export declare function appManagementRequestDoc<TResult, TVariables extends Variables>(orgId: string, query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables, cacheOptions?: CacheOptions, requestOptions?: RequestOptions): Promise<TResult>;
+export declare function appManagementRequestDoc<TResult, TVariables extends Variables>(options: AppManagementRequestOptions<TResult, TVariables>): Promise<TResult>;
/**
* Sets the next deprecation date from [GraphQL response extensions](https://www.apollographql.com/docs/resources/graphql-glossary/#extensions)
* if objects contain a (ISO 8601-formatted string).
packages/cli-kit/dist/public/node/api/business-platform.d.ts@@ -1,4 +1,4 @@
-import { CacheOptions, Exact, GraphQLVariables } from './graphql.js';
+import { CacheOptions, GraphQLVariables, UnauthorizedHandler } from './graphql.js';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
import { Variables } from 'graphql-request';
/**
@@ -12,34 +12,46 @@ import { Variables } from 'graphql-request';
*/
export declare function businessPlatformRequest<T>(query: string, token: string, variables?: GraphQLVariables, cacheOptions?: CacheOptions): Promise<T>;
/**
- * Executes a GraphQL query against the Business Platform Destinations API. Uses typed documents.
- *
* @param query - GraphQL query to execute.
* @param token - Business Platform token.
* @param variables - GraphQL variables to pass to the query.
* @param cacheOptions - Cache options for the request. If not present, the request will not be cached.
+ */
+export interface BusinessPlatformRequestOptions<TResult, TVariables extends Variables> {
+ query: TypedDocumentNode<TResult, TVariables>;
+ token: string;
+ variables?: TVariables;
+ cacheOptions?: CacheOptions;
+ unauthorizedHandler: UnauthorizedHandler;
+}
+/**
+ * Executes a GraphQL query against the Business Platform Destinations API. Uses typed documents.
+ *
+ * @param options - The options for the request.
* @returns The response of the query of generic type <TResult>.
*/
-export declare function businessPlatformRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables, cacheOptions?: CacheOptions): Promise<TResult>;
+export declare function businessPlatformRequestDoc<TResult, TVariables extends Variables>(options: BusinessPlatformRequestOptions<TResult, TVariables>): Promise<TResult>;
+export interface BusinessPlatformOrganizationsRequestNonTypedOptions {
+ query: string;
+ token: string;
+ organizationId: string;
+ unauthorizedHandler: UnauthorizedHandler;
+ variables?: GraphQLVariables;
+}
/**
* Executes a GraphQL query against the Business Platform Organizations API.
*
- * @param query - GraphQL query to execute.
- * @param token - Business Platform token.
- * @param organizationId - Organization ID as a numeric (non-GID) value.
- * @param variables - GraphQL variables to pass to the query.
+ * @param options - The options for the request.
* @returns The response of the query of generic type <T>.
*/
-export declare function businessPlatformOrganizationsRequest<T>(query: string, token: string, organizationId: string, variables?: GraphQLVariables): Promise<T>;
+export declare function businessPlatformOrganizationsRequest<T>(options: BusinessPlatformOrganizationsRequestNonTypedOptions): Promise<T>;
+export interface BusinessPlatformOrganizationsRequestOptions<TResult, TVariables extends Variables> extends BusinessPlatformRequestOptions<TResult, TVariables> {
+ organizationId: string;
+}
/**
* Executes a GraphQL query against the Business Platform Organizations API. Uses typed documents.
*
- * @param query - GraphQL query to execute.
- * @param token - Business Platform token.
- * @param organizationId - Organization ID as a numeric value.
- * @param variables - GraphQL variables to pass to the query.
+ * @param options - The options for the request.
* @returns The response of the query of generic type <T>.
*/
-export declare function businessPlatformOrganizationsRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables> | TypedDocumentNode<TResult, Exact<{
- [key: string]: never;
-}>>, token: string, organizationId: string, variables?: TVariables): Promise<TResult>;
\ No newline at end of file
+export declare function businessPlatformOrganizationsRequestDoc<TResult, TVariables extends Variables>(options: BusinessPlatformOrganizationsRequestOptions<TResult, TVariables>): Promise<TResult>;
\ No newline at end of file
packages/cli-kit/dist/public/node/api/functions.d.ts@@ -1,13 +1,26 @@
+import { UnauthorizedHandler } from './graphql.js';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
import { Variables } from 'graphql-request';
/**
- * Executes a rate-limited GraphQL request against the App Management Functions API.
- *
* @param orgId - Organization identifier.
* @param query - Typed GraphQL document node.
* @param token - Authentication token.
* @param appId - App identifier.
* @param variables - Optional query variables.
+ * @param unauthorizedHandler - Optional handler for unauthorized requests.
+ */
+export interface FunctionsRequestOptions<TResult, TVariables extends Variables> {
+ organizationId: string;
+ query: TypedDocumentNode<TResult, TVariables>;
+ token: string;
+ appId: string;
+ unauthorizedHandler: UnauthorizedHandler;
+ variables?: TVariables;
+}
+/**
+ * Executes a rate-limited GraphQL request against the App Management Functions API.
+ *
+ * @param options - Request options.
* @returns Promise resolving to the typed query result.
*/
-export declare function functionsRequestDoc<TResult, TVariables extends Variables>(orgId: string, query: TypedDocumentNode<TResult, TVariables>, token: string, appId: string, variables?: TVariables): Promise<TResult>;
\ No newline at end of file
+export declare function functionsRequestDoc<TResult, TVariables extends Variables>(options: FunctionsRequestOptions<TResult, TVariables>): Promise<TResult>;
\ No newline at end of file
packages/cli-kit/dist/public/node/api/graphql.d.ts@@ -17,6 +17,19 @@ export interface CacheOptions {
cacheExtraKey?: string;
cacheStore?: LocalStorage<ConfSchema>;
}
+interface RefreshedTokenOnAuthorizedResponse {
+ token?: string;
+}
+export type RefreshTokenOnAuthorizedResponse = Promise<RefreshedTokenOnAuthorizedResponse>;
+interface SimpleUnauthorizedHandler {
+ type: 'simple';
+ handler: () => Promise<void>;
+}
+interface TokenRefreshHandler {
+ type: 'token_refresh';
+ handler: () => RefreshTokenOnAuthorizedResponse;
+}
+export type UnauthorizedHandler = SimpleUnauthorizedHandler | TokenRefreshHandler;
interface GraphQLRequestBaseOptions<TResult> {
api: string;
url: string;
@@ -31,7 +44,7 @@ interface GraphQLRequestBaseOptions<TResult> {
export type GraphQLRequestOptions<T> = GraphQLRequestBaseOptions<T> & {
query: RequestDocument;
variables?: Variables;
- unauthorizedHandler?: () => Promise<void>;
+ unauthorizedHandler?: UnauthorizedHandler;
requestBehaviour?: RequestModeInput;
};
export type GraphQLRequestDocOptions<TResult, TVariables> = GraphQLRequestBaseOptions<TResult> & {
@@ -39,7 +52,7 @@ export type GraphQLRequestDocOptions<TResult, TVariables> = GraphQLRequestBaseOp
[key: string]: never;
}>>;
variables?: TVariables;
- unauthorizedHandler?: () => Promise<void>;
+ unauthorizedHandler?: UnauthorizedHandler;
requestBehaviour?: RequestModeInput;
};
export interface GraphQLResponseOptions<T> {
packages/cli-kit/dist/public/node/api/partners.d.ts@@ -1,4 +1,4 @@
-import { GraphQLVariables, GraphQLResponse, CacheOptions } from './graphql.js';
+import { GraphQLVariables, GraphQLResponse, CacheOptions, UnauthorizedHandler } from './graphql.js';
import { RequestModeInput } from '../http.js';
import { Variables } from 'graphql-request';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
@@ -10,9 +10,10 @@ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
* @param variables - GraphQL variables to pass to the query.
* @param cacheOptions - Cache options.
* @param preferredBehaviour - Preferred behaviour for the request.
+ * @param unauthorizedHandler - Optional handler for unauthorized requests.
* @returns The response of the query of generic type <T>.
*/
-export declare function partnersRequest<T>(query: string, token: string, variables?: GraphQLVariables, cacheOptions?: CacheOptions, preferredBehaviour?: RequestModeInput): Promise<T>;
+export declare function partnersRequest<T>(query: string, token: string, variables?: GraphQLVariables, cacheOptions?: CacheOptions, preferredBehaviour?: RequestModeInput, unauthorizedHandler?: UnauthorizedHandler): Promise<T>;
export declare const generateFetchAppLogUrl: (cursor?: string, filters?: {
status?: string;
source?: string;
@@ -24,9 +25,10 @@ export declare const generateFetchAppLogUrl: (cursor?: string, filters?: {
* @param token - Partners token.
* @param variables - GraphQL variables to pass to the query.
* @param preferredBehaviour - Preferred behaviour for the request.
+ * @param unauthorizedHandler - Optional handler for unauthorized requests.
* @returns The response of the query of generic type <TResult>.
*/
-export declare function partnersRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables, preferredBehaviour?: RequestModeInput): Promise<TResult>;
+export declare function partnersRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables, preferredBehaviour?: RequestModeInput, unauthorizedHandler?: UnauthorizedHandler): Promise<TResult>;
/**
* Sets the next deprecation date from [GraphQL response extensions](https://www.apollographql.com/docs/resources/graphql-glossary/#extensions)
* if objects contain a (ISO 8601-formatted string).
packages/cli-kit/dist/public/node/api/webhooks.d.ts@@ -1,13 +1,21 @@
+import { UnauthorizedHandler } from './graphql.js';
import { Variables } from 'graphql-request';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
+/**
+ * Options for making requests to the Webhooks API.
+ */
+export interface WebhooksRequestOptions<TResult, TVariables extends Variables> {
+ organizationId: string;
+ query: TypedDocumentNode<TResult, TVariables>;
+ token: string;
+ unauthorizedHandler: UnauthorizedHandler;
+ variables?: TVariables;
+}
/**
* Executes an org-scoped GraphQL query against the App Management API.
* Uses typed documents.
*
- * @param organizationId - Organization ID required to check permissions.
- * @param query - GraphQL query to execute.
- * @param token - Partners token.
- * @param variables - GraphQL variables to pass to the query.
+ * @param options - The options for the request.
* @returns The response of the query of generic type <T>.
*/
-export declare function webhooksRequest<TResult, TVariables extends Variables>(organizationId: string, query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables): Promise<TResult>;
\ No newline at end of file
+export declare function webhooksRequestDoc<TResult, TVariables extends Variables>(options: WebhooksRequestOptions<TResult, TVariables>): Promise<TResult>;
\ No newline at end of file
|
WHY are these changes introduced?
This PR refactors the API request functions to use a more consistent object parameter pattern instead of positional parameters.
WHAT is this pull request doing?
Refactors API request functions across multiple client implementations to use a single object parameter pattern instead of multiple positional parameters. This change:
appManagementRequestDoc
,businessPlatformRequest
, and others to accept a single options objectHow to test your changes?
Just use the CLI, no behavior change in this PR.
Measuring impact
How do we know this change was effective? Please choose one:
Checklist