@shopify/shop-minis-platform 0.12.1 → 0.14.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.
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@shopify/shop-minis-platform",
3
3
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "0.12.1",
4
+ "version": "0.14.1",
5
5
  "description": "Shared type definitions for Shop Minis Platform",
6
6
  "main": "src/index.ts",
7
7
  "exports": {
8
8
  ".": "./src/index.ts",
9
+ "./package.json": "./package.json",
9
10
  "./actions": "./src/actions/index.ts",
10
11
  "./events": "./src/events/index.ts"
11
12
  },
@@ -20,7 +21,9 @@
20
21
  ],
21
22
  "dependencies": {},
22
23
  "peerDependencies": {},
23
- "devDependencies": {},
24
+ "devDependencies": {
25
+ "typescript": "^5.8.3"
26
+ },
24
27
  "author": "Shopify",
25
28
  "repository": {
26
29
  "type": "git",
@@ -29,6 +32,7 @@
29
32
  },
30
33
  "scripts": {
31
34
  "test": "TZ=UTC jest",
32
- "type-check": "tsc --noEmit"
35
+ "type-check": "tsc --noEmit",
36
+ "typecheck": "pnpm run type-check"
33
37
  }
34
38
  }
@@ -93,6 +93,8 @@ import {
93
93
  ShareSingleResponse,
94
94
  RequestPermissionParams,
95
95
  RequestPermissionResponse,
96
+ CheckPermissionParams,
97
+ CheckPermissionResponse,
96
98
  ReportErrorParams,
97
99
  ReportFetchParams,
98
100
  } from './params'
@@ -235,6 +237,7 @@ export interface ShopActionEvents {
235
237
  RequestPermissionParams,
236
238
  RequestPermissionResponse
237
239
  >
240
+ CHECK_PERMISSION: ShopAction<CheckPermissionParams, CheckPermissionResponse>
238
241
  REPORT_ERROR: ShopAction<ReportErrorParams, void>
239
242
  REPORT_FETCH: ShopAction<ReportFetchParams, void>
240
243
  }
@@ -34,6 +34,33 @@ export interface RequestPermissionResponse {
34
34
  errorMessage?: string
35
35
  }
36
36
 
37
+ /**
38
+ * The current state of a permission for the Mini.
39
+ *
40
+ * - `granted`: The user has approved the in-app consent dialog and the OS has granted the permission.
41
+ * - `denied`: The user has previously denied the permission, either in the in-app consent dialog or at the OS level. The permission can still be requested again.
42
+ * - `blocked`: The permission is blocked at the OS level. The user must enable it from device settings.
43
+ * - `undetermined`: The user has not yet been shown the in-app consent dialog for this permission.
44
+ * - `unavailable`: The permission is not declared in the Mini's manifest, or the feature is not available on this device.
45
+ *
46
+ * @publicDocs
47
+ */
48
+ export type PermissionStatus =
49
+ | 'granted'
50
+ | 'denied'
51
+ | 'blocked'
52
+ | 'undetermined'
53
+ | 'unavailable'
54
+
55
+ export interface CheckPermissionParams {
56
+ permission: MiniPermission
57
+ }
58
+
59
+ export interface CheckPermissionResponse {
60
+ status: PermissionStatus
61
+ errorMessage?: string
62
+ }
63
+
37
64
  export interface FavoriteParams {
38
65
  shopId: string
39
66
  productId: string
@@ -1,4 +1,4 @@
1
- import {ShopActionEvents} from '@shopify/shop-minis-platform/actions'
1
+ import {ShopActionEvents} from './actions'
2
2
 
3
3
  // This enum should always match `MiniScopeEnum` in `shop-types`
4
4
  /* eslint-disable @shopify/typescript/prefer-pascal-case-enums */
@@ -8,25 +8,13 @@ export enum Scope {
8
8
  USER_SETTINGS_READ = 'user_settings:read',
9
9
  PROFILE = 'profile',
10
10
 
11
- // Products
12
- PRODUCTS_RECENT_READ = 'products:recent:read',
13
- PRODUCTS_RECOMMENDATIONS_READ = 'products:recommendations:read',
14
-
15
- // Shops
16
- SHOPS_RECENT_READ = 'shops:recent:read',
17
- SHOPS_FOLLOWS = 'shops:follows',
18
- SHOPS_FOLLOWS_READ = 'shops:follows:read',
11
+ // Write scopes
19
12
  SHOPS_FOLLOWS_WRITE = 'shops:follows:write',
20
- SHOPS_RECOMMENDATIONS_READ = 'shops:recommendations:read',
21
-
22
- // Orders
23
- ORDERS = 'orders',
24
-
25
- // Product lists
26
- PRODUCT_LIST = 'product_list',
27
- PRODUCT_LIST_READ = 'product_list:read',
28
13
  PRODUCT_LIST_WRITE = 'product_list:write',
29
14
  PRODUCT_LIST_ITEM_WRITE = 'product_list_item:write',
15
+
16
+ // Sensitive Scopes (require runtime consent)
17
+ ORDERS = 'orders',
30
18
  }
31
19
  /* eslint-enable @shopify/typescript/prefer-pascal-case-enums */
32
20
 
@@ -37,20 +25,13 @@ export const ActionToScopesMapping: {
37
25
  GET_BUYER_ATTRIBUTES: Scope.PROFILE,
38
26
  GET_CURRENT_USER: Scope.USER_SETTINGS_READ,
39
27
 
28
+ // Orders
29
+ GET_ORDERS: Scope.ORDERS,
30
+
40
31
  // Shops
41
- GET_FOLLOWED_SHOPS: Scope.SHOPS_FOLLOWS_READ,
42
- GET_RECENT_SHOPS: Scope.SHOPS_RECENT_READ,
43
- GET_RECOMMENDED_SHOPS: Scope.SHOPS_RECOMMENDATIONS_READ,
44
32
  FOLLOW_SHOP: Scope.SHOPS_FOLLOWS_WRITE,
45
33
  UNFOLLOW_SHOP: Scope.SHOPS_FOLLOWS_WRITE,
46
34
 
47
- // Products
48
- GET_RECENT_PRODUCTS: Scope.PRODUCTS_RECENT_READ,
49
- GET_RECOMMENDED_PRODUCTS: Scope.PRODUCTS_RECOMMENDATIONS_READ,
50
-
51
- // Orders
52
- GET_ORDERS: Scope.ORDERS,
53
-
54
35
  // Product lists
55
36
  ADD_PRODUCT_LIST: Scope.PRODUCT_LIST_WRITE,
56
37
  ADD_PRODUCT_LIST_ITEM: Scope.PRODUCT_LIST_ITEM_WRITE,
@@ -59,9 +40,6 @@ export const ActionToScopesMapping: {
59
40
  REMOVE_PRODUCT_LIST: Scope.PRODUCT_LIST_WRITE,
60
41
  REMOVE_PRODUCT_LIST_ITEM: Scope.PRODUCT_LIST_ITEM_WRITE,
61
42
  RENAME_PRODUCT_LIST: Scope.PRODUCT_LIST_WRITE,
62
- GET_SAVED_PRODUCTS: Scope.PRODUCT_LIST_READ,
63
- GET_PRODUCT_LIST: Scope.PRODUCT_LIST_READ,
64
- GET_PRODUCT_LISTS: Scope.PRODUCT_LIST_READ,
65
43
  } as const
66
44
 
67
45
  export const ActionToOptionalScopesMapping: {
@@ -1,3 +1,4 @@
1
+ /** @publicDocs */
1
2
  export interface SafeAreaInsets {
2
3
  top: number
3
4
  right: number