@shopify/ui-extensions 2025.7.0 → 2025.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/build/ts/surfaces/checkout/targets.d.ts +1 -1
  2. package/build/ts/surfaces/checkout/targets.d.ts.map +1 -1
  3. package/build/ts/surfaces/checkout.d.ts +1 -0
  4. package/build/ts/surfaces/checkout.d.ts.map +1 -1
  5. package/build/ts/surfaces/customer-account/api/docs.d.ts +1 -1
  6. package/build/ts/surfaces/customer-account/api/docs.d.ts.map +1 -1
  7. package/build/ts/surfaces/customer-account/api/order-status/order-status.d.ts +0 -12
  8. package/build/ts/surfaces/customer-account/api/order-status/order-status.d.ts.map +1 -1
  9. package/build/ts/surfaces/customer-account/api/shared.d.ts +42 -0
  10. package/build/ts/surfaces/customer-account/api/shared.d.ts.map +1 -1
  11. package/build/ts/surfaces/customer-account/api/standard-api/standard-api.d.ts +5 -1
  12. package/build/ts/surfaces/customer-account/api/standard-api/standard-api.d.ts.map +1 -1
  13. package/build/ts/surfaces/customer-account/api.d.ts +1 -1
  14. package/build/ts/surfaces/customer-account/api.d.ts.map +1 -1
  15. package/build/ts/surfaces/point-of-sale/render/api/cart-api/cart-api.d.ts +21 -48
  16. package/build/ts/surfaces/point-of-sale/render/api/cart-api/cart-api.d.ts.map +1 -1
  17. package/build/tsconfig.tsbuildinfo +1 -1
  18. package/package.json +1 -1
  19. package/src/surfaces/checkout/targets.ts +1 -1
  20. package/src/surfaces/checkout.ts +1 -0
  21. package/src/surfaces/customer-account/api/docs.ts +4 -1
  22. package/src/surfaces/customer-account/api/order-status/order-status.ts +0 -12
  23. package/src/surfaces/customer-account/api/shared.ts +44 -0
  24. package/src/surfaces/customer-account/api/standard-api/standard-api.ts +6 -0
  25. package/src/surfaces/customer-account/api.ts +4 -0
  26. package/src/surfaces/point-of-sale/render/api/cart-api/cart-api.ts +21 -48
  27. package/build/ts/surfaces/point-of-sale/render/api/cart-api/errors.d.ts +0 -14
  28. package/build/ts/surfaces/point-of-sale/render/api/cart-api/errors.d.ts.map +0 -1
  29. package/src/surfaces/point-of-sale/render/api/cart-api/errors.ts +0 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/ui-extensions",
3
- "version": "2025.7.0",
3
+ "version": "2025.7.1",
4
4
  "scripts": {
5
5
  "docs:admin": "bash ./docs/surfaces/admin/build-docs.sh",
6
6
  "docs:admin:dev": "nodemon --watch src/surfaces/admin -e ts,tsx,json --exec 'yarn docs:admin'",
@@ -24,7 +24,7 @@ import type {
24
24
  AllowedComponents,
25
25
  AnyComponentExcept,
26
26
  } from './shared';
27
- import {Announcement} from './api/announcement/announcement';
27
+ import type {Announcement} from './api/announcement/announcement';
28
28
 
29
29
  /**
30
30
  * A UI extension will register for one or more extension targets using `shopify.extend()`.
@@ -143,6 +143,7 @@ export type {
143
143
  OrderStatusApi,
144
144
  } from './checkout/api/order-status/order-status';
145
145
  export type {OrderConfirmationApi} from './checkout/api/order-confirmation/order-confirmation';
146
+ export type {Announcement} from './checkout/api/announcement/announcement';
146
147
 
147
148
  export type {CartLineItemApi} from './checkout/api/cart-line/cart-line-item';
148
149
  export type {PickupLocationListApi} from './checkout/api/pickup/pickup-location-list';
@@ -74,7 +74,10 @@ export interface Docs_Standard_StorageApi
74
74
  extends Pick<StandardApi<any>, 'storage'> {}
75
75
 
76
76
  export interface Docs_Standard_CustomerPrivacyApi
77
- extends Pick<StandardApi<any>, 'customerPrivacy'> {}
77
+ extends Pick<
78
+ StandardApi<any>,
79
+ 'customerPrivacy' | 'applyTrackingConsentChange'
80
+ > {}
78
81
 
79
82
  export interface Docs_Standard_UIApi extends Pick<StandardApi<any>, 'ui'> {}
80
83
 
@@ -184,11 +184,6 @@ export interface OrderStatusLocalization {
184
184
  export type AuthenticationState = 'fully_authenticated' | 'pre_authenticated';
185
185
 
186
186
  export interface OrderStatusApi<Target extends ExtensionTarget> {
187
- /**
188
- * Methods for interacting with [Web Pixels](https://shopify.dev/docs/apps/marketing), such as emitting an event.
189
- */
190
- analytics: Analytics;
191
-
192
187
  /**
193
188
  * Gift Cards that have been applied to the order.
194
189
  */
@@ -952,13 +947,6 @@ export interface StoreCreditAccount {
952
947
  balance: Money;
953
948
  }
954
949
 
955
- export interface Analytics {
956
- /**
957
- * Publish method to emit analytics events to [Web Pixels](https://shopify.dev/docs/apps/marketing).
958
- */
959
- publish(name: string, data: {[key: string]: unknown}): Promise<boolean>;
960
- }
961
-
962
950
  /**
963
951
  * Represents the delivery information and options available for one or
964
952
  * more cart lines.
@@ -448,6 +448,50 @@ export interface SessionToken {
448
448
  get(): Promise<string>;
449
449
  }
450
450
 
451
+ export interface Analytics {
452
+ /**
453
+ * Publish method to emit analytics events to [Web Pixels](https://shopify.dev/docs/apps/marketing).
454
+ */
455
+ publish(name: string, data: Record<string, unknown>): Promise<boolean>;
456
+
457
+ /**
458
+ * A method for capturing details about a visitor on the online store.
459
+ */
460
+ visitor(data: {email?: string; phone?: string}): Promise<VisitorResult>;
461
+ }
462
+ /**
463
+ * Represents a visitor result.
464
+ */
465
+ export type VisitorResult = VisitorSuccess | VisitorError;
466
+
467
+ /**
468
+ * Represents a successful visitor result.
469
+ */
470
+ export interface VisitorSuccess {
471
+ /**
472
+ * Indicates that the visitor information was validated and submitted.
473
+ */
474
+ type: 'success';
475
+ }
476
+
477
+ /**
478
+ * Represents an unsuccessful visitor result.
479
+ */
480
+ export interface VisitorError {
481
+ /**
482
+ * Indicates that the visitor information is invalid and wasn't submitted.
483
+ * Examples are using the wrong data type or missing a required property.
484
+ */
485
+ type: 'error';
486
+
487
+ /**
488
+ * A message that explains the error. This message is useful for debugging.
489
+ * It's **not** localized, and therefore should not be presented directly
490
+ * to the buyer.
491
+ */
492
+ message: string;
493
+ }
494
+
451
495
  export interface AllowedProcessing {
452
496
  /**
453
497
  * Can collect customer analytics about how the shop was used and interactions made on the shop.
@@ -9,6 +9,7 @@ import {
9
9
  StorefrontApiVersion,
10
10
  Ui,
11
11
  SessionToken,
12
+ Analytics,
12
13
  CustomerPrivacy,
13
14
  ApplyTrackingConsentChangeType,
14
15
  } from '../shared';
@@ -79,6 +80,11 @@ export interface StandardApi<Target extends ExtensionTarget = ExtensionTarget> {
79
80
  */
80
81
  sessionToken: SessionToken;
81
82
 
83
+ /**
84
+ * Methods for interacting with [Web Pixels](https://shopify.dev/docs/apps/marketing), such as emitting an event.
85
+ */
86
+ analytics: Analytics;
87
+
82
88
  /**
83
89
  * The settings matching the settings definition written in the
84
90
  * [`shopify.ui.extension.toml`](https://shopify.dev/docs/api/customer-account-ui-extensions/configuration) file.
@@ -66,6 +66,7 @@ export type {
66
66
  Company,
67
67
  Customer,
68
68
  SessionToken,
69
+ Analytics,
69
70
  ApplyTrackingConsentChangeType,
70
71
  CustomerPrivacy,
71
72
  TrackingConsentChangeResult,
@@ -74,6 +75,9 @@ export type {
74
75
  TrackingConsentMetafieldChange,
75
76
  VisitorConsent,
76
77
  VisitorConsentChange,
78
+ VisitorResult,
79
+ VisitorSuccess,
80
+ VisitorError,
77
81
  } from './api/shared';
78
82
 
79
83
  export type {CartLineItemApi} from './api/cart-line/cart-line-item';
@@ -30,19 +30,17 @@ export interface CartApiContent {
30
30
  subscribable: RemoteSubscribable<Cart>;
31
31
 
32
32
  /** Bulk update the cart
33
+ *
33
34
  * @param cartState the cart state to set
34
35
  * @returns the updated cart
35
- *
36
- * @throws CartNotEditableError if the cart is not currently editable.
37
36
  */
38
37
  bulkCartUpdate(cartState: CartUpdateInput): Promise<Cart>;
39
38
 
40
39
  /** Apply a cart level discount
40
+ *
41
41
  * @param type the type of discount applied (example: 'Percentage')
42
42
  * @param title the title attributed with the discount
43
43
  * @param amount the percentage or fixed monetary amount deducted with the discount. Pass in `undefined` if using discount codes.
44
- *
45
- * @throws CartNotEditableError if the cart is not currently editable.
46
44
  */
47
45
  applyCartDiscount(
48
46
  type: CartDiscountType,
@@ -52,98 +50,83 @@ export interface CartApiContent {
52
50
 
53
51
  /**
54
52
  * Add a code discount to the cart
55
- * @param code the code for the discount to add to the cart
56
53
  *
57
- * @throws CartNotEditableError if the cart is not currently editable.
54
+ * @param code the code for the discount to add to the cart
58
55
  */
59
56
  addCartCodeDiscount(code: string): Promise<void>;
60
57
 
61
58
  /**
62
59
  * Remove the cart discount
63
- *
64
- * @throws CartNotEditableError if the cart is not currently editable.
65
60
  */
66
61
  removeCartDiscount(): Promise<void>;
67
62
 
68
63
  /**
69
64
  * Remove all cart and line item discounts
70
- * @param disableAutomaticDiscounts Whether or not automatic discounts should be enabled after removing the discounts.
71
65
  *
72
- * @throws CartNotEditableError if the cart is not currently editable.
66
+ * @param disableAutomaticDiscounts Whether or not automatic discounts should be enabled after removing the discounts.
73
67
  */
74
68
  removeAllDiscounts(disableAutomaticDiscounts: boolean): Promise<void>;
75
69
 
76
70
  /**
77
71
  * Clear the cart
78
- *
79
- * @throws CartNotEditableError if the cart is not currently editable.
80
72
  */
81
73
  clearCart(): Promise<void>;
82
74
 
83
75
  /**
84
76
  * Set the customer in the cart
85
- * @param customer the customer object to add to the cart
86
77
  *
87
- * @throws CartNotEditableError if the cart is not currently editable.
78
+ * @param customer the customer object to add to the cart
88
79
  */
89
80
  setCustomer(customer: Customer): Promise<void>;
90
81
 
91
82
  /**
92
83
  * Remove the current customer from the cart
93
- *
94
- * @throws CartNotEditableError if the cart is not currently editable.
95
84
  */
96
85
  removeCustomer(): Promise<void>;
97
86
 
98
87
  /**
99
88
  * Add a custom sale to the cart
89
+ *
100
90
  * @param customSale the custom sale object to add to the cart
101
91
  * @returns {string} the uuid of the line item added
102
- *
103
- * @throws CartNotEditableError if the cart is not currently editable.
104
92
  */
105
93
  addCustomSale(customSale: CustomSale): Promise<string>;
106
94
 
107
95
  /**
108
96
  * Add a line item by variant ID to the cart
97
+ *
109
98
  * @param variantId the product variant's numeric ID to add to the cart
110
99
  * @param quantity the number of this variant to add to the cart
111
100
  * @returns {string} the uuid of the line item added
112
- *
113
- * @throws CartNotEditableError if the cart is not currently editable.
114
101
  */
115
102
  addLineItem(variantId: number, quantity: number): Promise<string>;
116
103
 
117
104
  /**
118
105
  * Remove the line item at this uuid from the cart
119
- * @param uuid the uuid of the line item that should be removed
120
106
  *
121
- * @throws CartNotEditableError if the cart is not currently editable.
107
+ * @param uuid the uuid of the line item that should be removed
122
108
  */
123
109
  removeLineItem(uuid: string): Promise<void>;
124
110
 
125
111
  /**
126
112
  * Adds custom properties to the cart
127
- * @param properties the custom key to value object to attribute to the cart
128
113
  *
129
- * @throws CartNotEditableError if the cart is not currently editable.
114
+ * @param properties the custom key to value object to attribute to the cart
130
115
  */
131
116
  addCartProperties(properties: Record<string, string>): Promise<void>;
132
117
 
133
118
  /**
134
119
  * Removes the specified cart properties
135
- * @param keys the collection of keys to be removed from the cart properties
136
120
  *
137
- * @throws CartNotEditableError if the cart is not currently editable.
121
+ * @param keys the collection of keys to be removed from the cart properties
138
122
  */
139
123
  removeCartProperties(keys: string[]): Promise<void>;
140
124
 
141
125
  /**
142
126
  * Adds custom properties to the specified line item
127
+ *
143
128
  * @param uuid the uuid of the line item to which the properties should be stringd
144
129
  * @param properties the custom key to value object to attribute to the line item
145
- *
146
- * @throws CartNotEditableError if the cart is not currently editable.
147
130
  */
148
131
  addLineItemProperties(
149
132
  uuid: string,
@@ -152,9 +135,8 @@ export interface CartApiContent {
152
135
 
153
136
  /**
154
137
  * Adds custom properties to multiple line items at the same time.
155
- * @param lineItemProperties the collection of custom line item properties to apply to their respective line items.
156
138
  *
157
- * @throws CartNotEditableError if the cart is not currently editable.
139
+ * @param lineItemProperties the collection of custom line item properties to apply to their respective line items.
158
140
  */
159
141
  bulkAddLineItemProperties(
160
142
  lineItemProperties: SetLineItemPropertiesInput[],
@@ -162,21 +144,19 @@ export interface CartApiContent {
162
144
 
163
145
  /**
164
146
  * Removes the specified line item properties
147
+ *
165
148
  * @param uuid the uuid of the line item to which the properties should be removed
166
149
  * @param keys the collection of keys to be removed from the line item properties
167
- *
168
- * @throws CartNotEditableError if the cart is not currently editable.
169
150
  */
170
151
  removeLineItemProperties(uuid: string, keys: string[]): Promise<void>;
171
152
 
172
153
  /**
173
154
  * Add a discount on a line item to the cart
155
+ *
174
156
  * @param uuid the uuid of the line item that should receive a discount
175
157
  * @param type the type of discount applied (example: 'Percentage')
176
158
  * @param title the title attributed with the discount
177
159
  * @param amount the percentage or fixed monetary amount deducted with the discout
178
- *
179
- * @throws CartNotEditableError if the cart is not currently editable.
180
160
  */
181
161
  setLineItemDiscount(
182
162
  uuid: string,
@@ -187,9 +167,8 @@ export interface CartApiContent {
187
167
 
188
168
  /**
189
169
  * Set line item discounts to multiple line items at the same time.
190
- * @param lineItemDiscounts a map of discounts to add. They key is the uuid of the line item you want to add the discount to. The value is the discount input.
191
170
  *
192
- * @throws CartNotEditableError if the cart is not currently editable.
171
+ * @param lineItemDiscounts a map of discounts to add. They key is the uuid of the line item you want to add the discount to. The value is the discount input.
193
172
  */
194
173
  bulkSetLineItemDiscounts(
195
174
  lineItemDiscounts: SetLineItemDiscountInput[],
@@ -197,18 +176,16 @@ export interface CartApiContent {
197
176
 
198
177
  /**
199
178
  * Sets an attributed staff to all line items in the cart.
200
- * @param staffId the ID of the staff. Providing undefined will clear the attributed staff from all line items.
201
179
  *
202
- * @throws CartNotEditableError if the cart is not currently editable.
180
+ * @param staffId the ID of the staff. Providing undefined will clear the attributed staff from all line items.
203
181
  */
204
182
  setAttributedStaff(staffId: number | undefined): Promise<void>;
205
183
 
206
184
  /**
207
185
  * Sets an attributed staff to a specific line items in the cart.
186
+ *
208
187
  * @param staffId the ID of the staff. Providing undefined will clear the attributed staff on the line item.
209
188
  * @param lineItemUuid the UUID of the line item.
210
- *
211
- * @throws CartNotEditableError if the cart is not currently editable.
212
189
  */
213
190
  setAttributedStaffToLineItem(
214
191
  staffId: number | undefined,
@@ -217,33 +194,29 @@ export interface CartApiContent {
217
194
 
218
195
  /**
219
196
  * Remove all discounts from a line item
220
- * @param uuid the uuid of the line item whose discounts should be removed
221
197
  *
222
- * @throws CartNotEditableError if the cart is not currently editable.
198
+ * @param uuid the uuid of the line item whose discounts should be removed
223
199
  */
224
200
  removeLineItemDiscount(uuid: string): Promise<void>;
225
201
 
226
202
  /**
227
203
  * Add an address to the customer (Customer must be present)
228
- * @param address the address object to add to the customer in cart
229
204
  *
230
- * @throws CartNotEditableError if the cart is not currently editable.
205
+ * @param address the address object to add to the customer in cart
231
206
  */
232
207
  addAddress(address: Address): Promise<void>;
233
208
 
234
209
  /**
235
210
  * Delete an address from the customer (Customer must be present)
236
- * @param addressId the address ID to delete
237
211
  *
238
- * @throws CartNotEditableError if the cart is not currently editable.
212
+ * @param addressId the address ID to delete
239
213
  */
240
214
  deleteAddress(addressId: number): Promise<void>;
241
215
 
242
216
  /**
243
217
  * Update the default address for the customer (Customer must be present)
244
- * @param addressId the address ID to set as the default address
245
218
  *
246
- * @throws CartNotEditableError if the cart is not currently editable.
219
+ * @param addressId the address ID to set as the default address
247
220
  */
248
221
  updateDefaultAddress(addressId: number): Promise<void>;
249
222
  }
@@ -1,14 +0,0 @@
1
- import { CartApiContent } from './cart-api';
2
- type CartApiMethods = Omit<CartApiContent, 'subscribable'>;
3
- /**
4
- * An error thrown when an attempt to edit the cart is made while it is not editable.
5
- */
6
- export declare class CartNotEditableError extends Error {
7
- /** The name of the method that attempted to modify the cart */
8
- methodName: keyof CartApiMethods;
9
- constructor(
10
- /** The name of the method that attempted to modify the cart */
11
- methodName: keyof CartApiMethods);
12
- }
13
- export {};
14
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../../../src/surfaces/point-of-sale/render/api/cart-api/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C,KAAK,cAAc,GAAG,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;AAE3D;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,+DAA+D;IACxD,UAAU,EAAE,MAAM,cAAc;;IADvC,+DAA+D;IACxD,UAAU,EAAE,MAAM,cAAc;CAM1C"}
@@ -1,17 +0,0 @@
1
- import {CartApiContent} from './cart-api';
2
-
3
- type CartApiMethods = Omit<CartApiContent, 'subscribable'>;
4
-
5
- /**
6
- * An error thrown when an attempt to edit the cart is made while it is not editable.
7
- */
8
- export class CartNotEditableError extends Error {
9
- constructor(
10
- /** The name of the method that attempted to modify the cart */
11
- public methodName: keyof CartApiMethods,
12
- ) {
13
- super(
14
- `attempted to modify cart when not editable (calling "${methodName}")`,
15
- );
16
- }
17
- }