File tree Expand file tree Collapse file tree 4 files changed +46
-13
lines changed
packages/ui-extensions/src
surfaces/admin/api/discount-function-settings Expand file tree Collapse file tree 4 files changed +46
-13
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @shopify/ui-extensions ' : minor
3+ ---
4+
5+ Added subscribable discounts api. Update the type for ` data.id ` to string to fix a previously incorrect type.
Original file line number Diff line number Diff line change @@ -952,3 +952,19 @@ export interface ReadonlySignalLike<T> {
952952 */
953953 subscribe ( fn : ( value : T ) => void ) : ( ) => void ;
954954}
955+
956+ type Result < T > =
957+ | { success : true ; value : T }
958+ | { success : false ; errors : ValidationError [ ] } ;
959+
960+ interface ValidationError {
961+ type : 'error' ;
962+ message : string ;
963+ code : string ;
964+ issues ?: {
965+ message : string ;
966+ path : string [ ] ;
967+ } [ ] ;
968+ }
969+
970+ export type UpdateSignalFunction < T > = ( value : T ) => Result < T > ;
Original file line number Diff line number Diff line change @@ -2,7 +2,10 @@ import type {BlockExtensionApi} from '../block/block';
22import type { ExtensionTarget as AnyExtensionTarget } from '../../extension-targets' ;
33
44import { ApplyMetafieldChange } from './metafields' ;
5- import { DiscountFunctionSettingsData } from './launch-options' ;
5+ import {
6+ DiscountFunctionSettingsData ,
7+ SubscribableDiscountFields ,
8+ } from './launch-options' ;
69
710export interface DiscountFunctionSettingsApi <
811 ExtensionTarget extends AnyExtensionTarget ,
@@ -12,4 +15,5 @@ export interface DiscountFunctionSettingsApi<
1215 */
1316 applyMetafieldChange : ApplyMetafieldChange ;
1417 data : DiscountFunctionSettingsData ;
18+ discounts : SubscribableDiscountFields ;
1519}
Original file line number Diff line number Diff line change 1+ import type {
2+ ReadonlySignalLike ,
3+ UpdateSignalFunction ,
4+ } from '../../../../shared' ;
5+
16interface Metafield {
27 description ?: string ;
38 id : string ;
@@ -7,23 +12,26 @@ interface Metafield {
712 type : string ;
813}
914
10- export enum DiscountClass {
11- Product = 'PRODUCT' ,
12- Order = 'ORDER' ,
13- Shipping = 'SHIPPING' ,
14- }
15+ type DiscountClass = 'product' | 'order' | 'shipping' ;
1516
16- interface Discount {
17- /**
18- * the discount's gid
19- */
20- id : string ;
21- }
17+ type DiscountMethod = 'automatic' | 'code' ;
18+
19+ type PurchaseType = 'one_time_purchase' | 'subscription' | 'both' ;
2220
2321/**
2422 * The object that exposes the validation with its settings.
2523 */
2624export interface DiscountFunctionSettingsData {
27- id : Discount ;
25+ id : string ;
2826 metafields : Metafield [ ] ;
2927}
28+
29+ export interface SubscribableDiscountFields {
30+ discountClasses : ReadonlySignalLike < DiscountClass [ ] > ;
31+ updateDiscountClasses : UpdateSignalFunction < DiscountClass [ ] > ;
32+ discountMethod : ReadonlySignalLike < DiscountMethod > ;
33+ purchaseType : ReadonlySignalLike < PurchaseType > ;
34+ updatePurchaseType : UpdateSignalFunction < PurchaseType > ;
35+ recurringCycleLimit : ReadonlySignalLike < number | null | undefined > ;
36+ updateRecurringCycleLimit : UpdateSignalFunction < number | null | undefined > ;
37+ }
You can’t perform that action at this time.
0 commit comments