@shopify/ui-extensions 2026.10.0-rc.2 → 2026.10.0-rc.3
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.
- package/build/cjs/surfaces/point-of-sale/events.js +48 -0
- package/build/cjs/surfaces/point-of-sale.js +1 -0
- package/build/esm/surfaces/point-of-sale/events.mjs +48 -1
- package/build/esm/surfaces/point-of-sale.mjs +1 -1
- package/build/esnext/surfaces/point-of-sale/events.esnext +48 -1
- package/build/esnext/surfaces/point-of-sale.esnext +1 -1
- package/build/ts/surfaces/point-of-sale/events.d.ts +64 -0
- package/build/ts/surfaces/point-of-sale/events.d.ts.map +1 -1
- package/build/ts/surfaces/point-of-sale/globals.d.ts +8 -1
- package/build/ts/surfaces/point-of-sale/globals.d.ts.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/surfaces/point-of-sale/events.ts +76 -0
- package/src/surfaces/point-of-sale/globals.ts +16 -1
|
@@ -14,6 +14,16 @@ const POS_EVENT_NAMES = {
|
|
|
14
14
|
CASH_TRACKING_SESSION_COMPLETE: 'cashtrackingsessioncomplete'
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Canonical workflow-name constants for POS host interceptions. Prefer these
|
|
19
|
+
* over string literals when calling `shopify.intercept`.
|
|
20
|
+
*
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
const POS_INTERCEPT_NAMES = {
|
|
24
|
+
BEFORE_CHECKOUT: 'beforecheckout'
|
|
25
|
+
};
|
|
26
|
+
|
|
17
27
|
/**
|
|
18
28
|
* Maps Shopify POS event names to their corresponding payload types.
|
|
19
29
|
*
|
|
@@ -23,4 +33,42 @@ const POS_EVENT_NAMES = {
|
|
|
23
33
|
* @publicDocs
|
|
24
34
|
*/
|
|
25
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Maps POS interceptable workflow names to their corresponding `Event` types.
|
|
38
|
+
*
|
|
39
|
+
* Used as the generic type parameter for `shopify.intercept`.
|
|
40
|
+
*
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Dispatched when staff attempts to leave the active cart for checkout.
|
|
46
|
+
*
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/** @private */
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The result an interceptor returns. An empty `operations` list allows the
|
|
54
|
+
* workflow; an `ERROR` validation blocks it.
|
|
55
|
+
*
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A single host operation produced by an interceptor.
|
|
61
|
+
*
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/** @private */
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Adds a validation to the workflow being intercepted.
|
|
69
|
+
*
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
|
|
26
73
|
exports.POS_EVENT_NAMES = POS_EVENT_NAMES;
|
|
74
|
+
exports.POS_INTERCEPT_NAMES = POS_INTERCEPT_NAMES;
|
|
@@ -10,6 +10,16 @@ const POS_EVENT_NAMES = {
|
|
|
10
10
|
CASH_TRACKING_SESSION_COMPLETE: 'cashtrackingsessioncomplete'
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Canonical workflow-name constants for POS host interceptions. Prefer these
|
|
15
|
+
* over string literals when calling `shopify.intercept`.
|
|
16
|
+
*
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
const POS_INTERCEPT_NAMES = {
|
|
20
|
+
BEFORE_CHECKOUT: 'beforecheckout'
|
|
21
|
+
};
|
|
22
|
+
|
|
13
23
|
/**
|
|
14
24
|
* Maps Shopify POS event names to their corresponding payload types.
|
|
15
25
|
*
|
|
@@ -19,4 +29,41 @@ const POS_EVENT_NAMES = {
|
|
|
19
29
|
* @publicDocs
|
|
20
30
|
*/
|
|
21
31
|
|
|
22
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Maps POS interceptable workflow names to their corresponding `Event` types.
|
|
34
|
+
*
|
|
35
|
+
* Used as the generic type parameter for `shopify.intercept`.
|
|
36
|
+
*
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Dispatched when staff attempts to leave the active cart for checkout.
|
|
42
|
+
*
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/** @private */
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The result an interceptor returns. An empty `operations` list allows the
|
|
50
|
+
* workflow; an `ERROR` validation blocks it.
|
|
51
|
+
*
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A single host operation produced by an interceptor.
|
|
57
|
+
*
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/** @private */
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Adds a validation to the workflow being intercepted.
|
|
65
|
+
*
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
export { POS_EVENT_NAMES, POS_INTERCEPT_NAMES };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { POS_EVENT_NAMES } from './point-of-sale/events.mjs';
|
|
1
|
+
export { POS_EVENT_NAMES, POS_INTERCEPT_NAMES } from './point-of-sale/events.mjs';
|
|
2
2
|
export { StorageError } from './point-of-sale/types/storage.mjs';
|
|
@@ -10,6 +10,16 @@ const POS_EVENT_NAMES = {
|
|
|
10
10
|
CASH_TRACKING_SESSION_COMPLETE: 'cashtrackingsessioncomplete'
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Canonical workflow-name constants for POS host interceptions. Prefer these
|
|
15
|
+
* over string literals when calling `shopify.intercept`.
|
|
16
|
+
*
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
const POS_INTERCEPT_NAMES = {
|
|
20
|
+
BEFORE_CHECKOUT: 'beforecheckout'
|
|
21
|
+
};
|
|
22
|
+
|
|
13
23
|
/**
|
|
14
24
|
* Maps Shopify POS event names to their corresponding payload types.
|
|
15
25
|
*
|
|
@@ -19,4 +29,41 @@ const POS_EVENT_NAMES = {
|
|
|
19
29
|
* @publicDocs
|
|
20
30
|
*/
|
|
21
31
|
|
|
22
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Maps POS interceptable workflow names to their corresponding `Event` types.
|
|
34
|
+
*
|
|
35
|
+
* Used as the generic type parameter for `shopify.intercept`.
|
|
36
|
+
*
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Dispatched when staff attempts to leave the active cart for checkout.
|
|
42
|
+
*
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/** @private */
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The result an interceptor returns. An empty `operations` list allows the
|
|
50
|
+
* workflow; an `ERROR` validation blocks it.
|
|
51
|
+
*
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A single host operation produced by an interceptor.
|
|
57
|
+
*
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/** @private */
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Adds a validation to the workflow being intercepted.
|
|
65
|
+
*
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
export { POS_EVENT_NAMES, POS_INTERCEPT_NAMES };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { POS_EVENT_NAMES } from './point-of-sale/events.esnext';
|
|
1
|
+
export { POS_EVENT_NAMES, POS_INTERCEPT_NAMES } from './point-of-sale/events.esnext';
|
|
2
2
|
export { StorageError } from './point-of-sale/types/storage.esnext';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TransactionCompleteEvent } from './events/transaction-complete-event';
|
|
2
2
|
import type { CashTrackingSessionStartEvent, CashTrackingSessionCompleteEvent } from './events/cash-tracking-session-events';
|
|
3
|
+
import type { Cart } from './types/cart';
|
|
3
4
|
/**
|
|
4
5
|
* Canonical event-name constants for POS host events. Prefer these over string
|
|
5
6
|
* literals when calling `shopify.addEventListener` / `removeEventListener`.
|
|
@@ -11,6 +12,15 @@ export declare const POS_EVENT_NAMES: {
|
|
|
11
12
|
readonly CASH_TRACKING_SESSION_START: "cashtrackingsessionstart";
|
|
12
13
|
readonly CASH_TRACKING_SESSION_COMPLETE: "cashtrackingsessioncomplete";
|
|
13
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Canonical workflow-name constants for POS host interceptions. Prefer these
|
|
17
|
+
* over string literals when calling `shopify.intercept`.
|
|
18
|
+
*
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
export declare const POS_INTERCEPT_NAMES: {
|
|
22
|
+
readonly BEFORE_CHECKOUT: "beforecheckout";
|
|
23
|
+
};
|
|
14
24
|
/**
|
|
15
25
|
* Maps Shopify POS event names to their corresponding payload types.
|
|
16
26
|
*
|
|
@@ -30,5 +40,59 @@ export interface ShopifyEventMap {
|
|
|
30
40
|
/** Dispatched when a cash tracking session closes after reconciliation. */
|
|
31
41
|
[POS_EVENT_NAMES.CASH_TRACKING_SESSION_COMPLETE]: CashTrackingSessionCompleteEvent;
|
|
32
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Maps POS interceptable workflow names to their corresponding `Event` types.
|
|
45
|
+
*
|
|
46
|
+
* Used as the generic type parameter for `shopify.intercept`.
|
|
47
|
+
*
|
|
48
|
+
* @private
|
|
49
|
+
*/
|
|
50
|
+
export interface ShopifyInterceptMap {
|
|
51
|
+
[POS_INTERCEPT_NAMES.BEFORE_CHECKOUT]: BeforeCheckoutEvent;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Dispatched when staff attempts to leave the active cart for checkout.
|
|
55
|
+
*
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
export interface BeforeCheckoutEvent extends Event {
|
|
59
|
+
readonly type: typeof POS_INTERCEPT_NAMES.BEFORE_CHECKOUT;
|
|
60
|
+
/** The POS cart at the point checkout was requested. */
|
|
61
|
+
readonly cart: Cart;
|
|
62
|
+
}
|
|
63
|
+
/** @private */
|
|
64
|
+
export type ShopifyInterceptor<TEvent extends Event> = (event: TEvent) => InterceptResult;
|
|
65
|
+
/**
|
|
66
|
+
* The result an interceptor returns. An empty `operations` list allows the
|
|
67
|
+
* workflow; an `ERROR` validation blocks it.
|
|
68
|
+
*
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
export interface InterceptResult {
|
|
72
|
+
operations: Operation[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A single host operation produced by an interceptor.
|
|
76
|
+
*
|
|
77
|
+
* @private
|
|
78
|
+
*/
|
|
79
|
+
export interface Operation {
|
|
80
|
+
validationAdd?: ValidationAdd;
|
|
81
|
+
}
|
|
82
|
+
/** @private */
|
|
83
|
+
export type ValidationLevel = 'WARNING' | 'ERROR';
|
|
84
|
+
/**
|
|
85
|
+
* Adds a validation to the workflow being intercepted.
|
|
86
|
+
*
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
89
|
+
export interface ValidationAdd {
|
|
90
|
+
/** `ERROR` blocks the workflow. `WARNING` does not. */
|
|
91
|
+
level: ValidationLevel;
|
|
92
|
+
/** Stable identifier for this validation. */
|
|
93
|
+
handle: string;
|
|
94
|
+
/** JSON-path locator for where the validation applies. */
|
|
95
|
+
target?: string;
|
|
96
|
+
}
|
|
33
97
|
export type { TransactionCompleteEvent, CashTrackingSessionStartEvent, CashTrackingSessionCompleteEvent, };
|
|
34
98
|
//# sourceMappingURL=events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../src/surfaces/point-of-sale/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,qCAAqC,CAAC;AAClF,OAAO,KAAK,EACV,6BAA6B,EAC7B,gCAAgC,EACjC,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../src/surfaces/point-of-sale/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,qCAAqC,CAAC;AAClF,OAAO,KAAK,EACV,6BAA6B,EAC7B,gCAAgC,EACjC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,eAAe;;;;CAIlB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;CAEtB,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,CAAC,eAAe,CAAC,oBAAoB,CAAC,EAAE,wBAAwB,CAAC;IACjE,qDAAqD;IACrD,CAAC,eAAe,CAAC,2BAA2B,CAAC,EAAE,6BAA6B,CAAC;IAC7E,2EAA2E;IAC3E,CAAC,eAAe,CAAC,8BAA8B,CAAC,EAAE,gCAAgC,CAAC;CACpF;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,CAAC,mBAAmB,CAAC,eAAe,CAAC,EAAE,mBAAmB,CAAC;CAC5D;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,EAAE,OAAO,mBAAmB,CAAC,eAAe,CAAC;IAC1D,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB;AAED,eAAe;AACf,MAAM,MAAM,kBAAkB,CAAC,MAAM,SAAS,KAAK,IAAI,CACrD,KAAK,EAAE,MAAM,KACV,eAAe,CAAC;AAErB;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,eAAe;AACf,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,OAAO,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,KAAK,EAAE,eAAe,CAAC;IAEvB,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IAEf,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,YAAY,EACV,wBAAwB,EACxB,6BAA6B,EAC7B,gCAAgC,GACjC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Navigation } from './api/navigation-api/navigation-api';
|
|
2
|
-
import type { ShopifyEventMap } from './events';
|
|
2
|
+
import type { ShopifyEventMap, ShopifyInterceptMap, ShopifyInterceptor } from './events';
|
|
3
3
|
/**
|
|
4
4
|
* The `shopify` global provides APIs that are available to all POS extensions
|
|
5
5
|
* without needing to access them through the target's `api` argument.
|
|
@@ -28,6 +28,13 @@ export interface BackgroundShopifyGlobal extends ShopifyGlobal {
|
|
|
28
28
|
* `listener` reference must match the one used to register.
|
|
29
29
|
*/
|
|
30
30
|
removeEventListener<K extends keyof ShopifyEventMap>(type: K, listener: (event: ShopifyEventMap[K]) => void): void;
|
|
31
|
+
/**
|
|
32
|
+
* Register an interceptor for a POS host workflow that can be blocked.
|
|
33
|
+
* Returns a function that unregisters the interceptor.
|
|
34
|
+
*
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
intercept<K extends keyof ShopifyInterceptMap>(type: K, interceptor: ShopifyInterceptor<ShopifyInterceptMap[K]>): () => void;
|
|
31
38
|
}
|
|
32
39
|
declare global {
|
|
33
40
|
const navigation: Navigation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../../../src/surfaces/point-of-sale/globals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,qCAAqC,CAAC;AACpE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../../../src/surfaces/point-of-sale/globals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,qCAAqC,CAAC;AACpE,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB;;;;;GAKG;AACH,MAAM,WAAW,aAAa;CAAG;AAEjC;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAwB,SAAQ,aAAa;IAC5D;;;;OAIG;IACH,gBAAgB,CAAC,CAAC,SAAS,MAAM,eAAe,EAC9C,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,GAC5C,IAAI,CAAC;IAER;;;OAGG;IACH,mBAAmB,CAAC,CAAC,SAAS,MAAM,eAAe,EACjD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,GAC5C,IAAI,CAAC;IAER;;;;;OAKG;IACH,SAAS,CAAC,CAAC,SAAS,MAAM,mBAAmB,EAC3C,IAAI,EAAE,CAAC,EACP,WAAW,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,GACtD,MAAM,IAAI,CAAC;CACf;AAED,OAAO,CAAC,MAAM,CAAC;IAEb,MAAM,UAAU,EAAE,UAAU,CAAC;IAO7B,MAAM,OAAO,EAAE,aAAa,CAAC;CAC9B"}
|