Skip to content

Commit

Permalink
drop runExtension support for customer account ui extension
Browse files Browse the repository at this point in the history
  • Loading branch information
brianshen1990 committed Jan 15, 2024
1 parent cf7e3d2 commit 5802677
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 36 deletions.
6 changes: 6 additions & 0 deletions .changeset/lucky-beds-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/ui-extensions': patch
'@shopify/ui-extensions-react': patch
---

Drop runExtension support for customer account ui extension
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,3 @@ export const extension =
* @deprecated This is deprecated, use `extension` instead.
*/
export const extend = extension;

export interface RunExtension<Api, Return> {
(api: Api): Promise<Return>;
}
33 changes: 1 addition & 32 deletions packages/ui-extensions/src/surfaces/customer-account/targets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {AnyComponent} from '../checkout/shared';

import {CartLineItemApi} from './api/cart-line/cart-line-item';
import type {OrderStatusApi} from './api/order-status/order-status';
import type {RenderExtension, RunExtension} from './extension';
import type {RenderExtension} from './extension';
import {
StandardApi,
FullExtensionNavigation,
Expand Down Expand Up @@ -102,18 +102,10 @@ export interface CustomerAccountExtensionTargets {
FullPageApi,
AllComponents
>;
'CustomerAccount::Returns::Initiate': RunExtension<
StandardApi<'CustomerAccount::Returns::Initiate'> & {orderId: string},
void
>;
'CustomerAccount::KitchenSink': RenderExtension<
StandardApi<'CustomerAccount::KitchenSink'> & {name: string},
AllComponents
>;
'CustomerAccount::KitchenSinkRun': RunExtension<
StandardApi<'CustomerAccount::KitchenSinkRun'> & {name: string},
string
>;
'customer-account.order-index.block.render': RenderExtension<
StandardApi<'customer-account.order-index.block.render'>,
AllComponents
Expand Down Expand Up @@ -273,29 +265,6 @@ export interface ActionExtensionApi {
export type ApiForExtension<Target extends keyof ExtensionTargets> =
ExtractedApiFromExtension<ExtensionTargets[Target]>;

type ExtractedApiFromRunExtension<T> = T extends RunExtension<
infer Api,
unknown
>
? Api
: never;

type ExtractedApiFromExtension<T> = T extends RenderExtension<any, any>
? ExtractedApiFromRenderExtension<T>
: T extends RunExtension<any, any>
? ExtractedApiFromRunExtension<T>
: never;

/**
* A union type containing all extension targets that follow the pattern of
* accepting an `api` argument, and using those arguments to run code that does not render anything, but instead return
* a value or execute a side effect.
*/
export type RunExtensionTarget = {
[Target in keyof ExtensionTargets]: ExtensionTargets[Target] extends RunExtension<
any,
any
>
? Target
: never;
}[keyof ExtensionTargets];

0 comments on commit 5802677

Please sign in to comment.