@shopify/shop-minis-platform 0.3.0 → 0.4.0

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@shopify/shop-minis-platform",
3
3
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "0.3.0",
4
+ "version": "0.4.0",
5
5
  "description": "Shared type definitions for Shop Minis Platform",
6
6
  "main": "src/index.ts",
7
7
  "exports": {
@@ -1,4 +1,4 @@
1
1
  export * from './actions'
2
- export * from './consent'
3
2
  export * from './shared'
4
3
  export * from './params'
4
+ export * from './scopes'
@@ -0,0 +1,68 @@
1
+ import {ShopActionEvents} from '@shopify/shop-minis-platform/actions'
2
+
3
+ export const Scope = {
4
+ // User
5
+ OPENID: 'OPENID',
6
+ USER_SETTINGS_READ: 'USER_SETTINGS_READ',
7
+ PROFILE: 'PROFILE',
8
+
9
+ // Products
10
+ PRODUCTS_RECENT_READ: 'PRODUCTS_RECENT_READ',
11
+ PRODUCTS_RECOMMENDATIONS_READ: 'PRODUCTS_RECOMMENDATIONS_READ',
12
+
13
+ // Shops
14
+ SHOPS_RECENT_READ: 'SHOPS_RECENT_READ',
15
+ SHOPS_FOLLOWS: 'SHOPS_FOLLOWS',
16
+ SHOPS_FOLLOWS_READ: 'SHOPS_FOLLOWS_READ',
17
+ SHOPS_FOLLOWS_WRITE: 'SHOPS_FOLLOWS_WRITE',
18
+ SHOPS_RECOMMENDATIONS_READ: 'SHOPS_RECOMMENDATIONS_READ',
19
+
20
+ // Orders
21
+ ORDERS: 'ORDERS',
22
+
23
+ // Product lists
24
+ PRODUCT_LIST: 'PRODUCT_LIST',
25
+ PRODUCT_LIST_READ: 'PRODUCT_LIST_READ',
26
+ PRODUCT_LIST_WRITE: 'PRODUCT_LIST_WRITE',
27
+ PRODUCT_LIST_ITEM_WRITE: 'PRODUCT_LIST_ITEM_WRITE',
28
+ FAVORITES: 'FAVORITES',
29
+ FAVORITES_WRITE: 'FAVORITES_WRITE',
30
+ } as const
31
+
32
+ export type ScopeType = (typeof Scope)[keyof typeof Scope]
33
+
34
+ export const ActionToScopesMapping: {
35
+ [key in keyof ShopActionEvents]?: ScopeType
36
+ } = {
37
+ // User
38
+ GENERATE_USER_TOKEN: Scope.OPENID,
39
+ GET_ACCOUNT_INFORMATION: Scope.PROFILE,
40
+ GET_BUYER_ATTRIBUTES: Scope.PROFILE,
41
+ GET_CURRENT_USER: Scope.USER_SETTINGS_READ,
42
+
43
+ // Shops
44
+ GET_FOLLOWED_SHOPS: Scope.SHOPS_FOLLOWS_READ,
45
+ GET_RECENT_SHOPS: Scope.SHOPS_RECENT_READ,
46
+ GET_RECOMMENDED_SHOPS: Scope.SHOPS_RECOMMENDATIONS_READ,
47
+ FOLLOW_SHOP: Scope.SHOPS_FOLLOWS_WRITE,
48
+ UNFOLLOW_SHOP: Scope.SHOPS_FOLLOWS_WRITE,
49
+
50
+ // Products
51
+ GET_RECENT_PRODUCTS: Scope.PRODUCTS_RECENT_READ,
52
+ GET_RECOMMENDED_PRODUCTS: Scope.PRODUCTS_RECOMMENDATIONS_READ,
53
+
54
+ // Orders
55
+ GET_ORDERS: Scope.ORDERS,
56
+
57
+ // Product lists
58
+ ADD_PRODUCT_LIST: Scope.PRODUCT_LIST_WRITE,
59
+ ADD_PRODUCT_LIST_ITEM: Scope.PRODUCT_LIST_ITEM_WRITE,
60
+ FAVORITE: Scope.FAVORITES_WRITE,
61
+ UNFAVORITE: Scope.FAVORITES_WRITE,
62
+ REMOVE_PRODUCT_LIST: Scope.PRODUCT_LIST_WRITE,
63
+ REMOVE_PRODUCT_LIST_ITEM: Scope.PRODUCT_LIST_ITEM_WRITE,
64
+ RENAME_PRODUCT_LIST: Scope.PRODUCT_LIST_WRITE,
65
+ GET_SAVED_PRODUCTS: Scope.FAVORITES,
66
+ GET_PRODUCT_LIST: Scope.PRODUCT_LIST_READ,
67
+ GET_PRODUCT_LISTS: Scope.PRODUCT_LIST_READ,
68
+ } as const
@@ -1,4 +1,11 @@
1
1
  /* eslint-disable @shopify/typescript/prefer-pascal-case-enums */
2
+
3
+ export enum MinisContentStatus {
4
+ PENDING = 'PENDING',
5
+ READY = 'READY',
6
+ REJECTED = 'REJECTED',
7
+ }
8
+
2
9
  export interface ImageType {
3
10
  url: string
4
11
  altText?: string | null
@@ -37,6 +44,7 @@ export interface Content {
37
44
  visibility: ContentVisibility[]
38
45
  shareableUrl?: string | null
39
46
  products?: ContentProduct[] | null
47
+ status?: MinisContentStatus | null
40
48
  }
41
49
 
42
50
  export enum ContentCreateUserErrorCode {
@@ -4,7 +4,6 @@ export * from './shop'
4
4
  export * from './user'
5
5
  export * from './content'
6
6
  export * from './order'
7
- export * from './permissions'
8
7
  export * from './share'
9
8
  export * from './query'
10
9
  export * from './minis'
@@ -1,109 +0,0 @@
1
- import {ShopActionEvents} from './actions'
2
-
3
- // Consent types
4
- export const UserDataConsent = {
5
- // User & Account
6
- USER_TOKEN: 'USER_TOKEN', // Generate user authentication tokens
7
- VIEW_PROFILE: 'VIEW_PROFILE', // Name and avatar
8
- VIEW_ACCOUNT_INFO: 'VIEW_ACCOUNT_INFO', // Account details and settings
9
- VIEW_PREFERENCES: 'VIEW_PREFERENCES', // Gender and category preferences
10
-
11
- // Products
12
- VIEW_VISITED_PRODUCTS: 'VIEW_VISITED_PRODUCTS', // Products you've viewed
13
- VIEW_PRODUCT_RECOMMENDATIONS: 'VIEW_PRODUCT_RECOMMENDATIONS', // View suggested products
14
-
15
- // Shops
16
- VIEW_VISITED_SHOPS: 'VIEW_VISITED_SHOPS', // Shops you've visited
17
- VIEW_FOLLOWED_SHOPS: 'VIEW_FOLLOWED_SHOPS', // View shops you follow
18
- VIEW_SHOP_RECOMMENDATIONS: 'VIEW_SHOP_RECOMMENDATIONS', // View suggested shops
19
- FOLLOW_SHOPS: 'FOLLOW_SHOPS', // Follow and unfollow shops
20
-
21
- // Orders
22
- VIEW_ORDERS: 'VIEW_ORDERS', // View your past purchases
23
-
24
- // Lists - Viewing
25
- VIEW_PRODUCT_LISTS: 'VIEW_PRODUCT_LISTS', // View your product lists
26
- VIEW_SAVED_PRODUCTS: 'VIEW_SAVED_PRODUCTS', // View your favorited items
27
-
28
- // Lists - Managing
29
- CREATE_PRODUCT_LISTS: 'CREATE_PRODUCT_LISTS', // Create product lists
30
- MANAGE_PRODUCT_LISTS: 'MANAGE_PRODUCT_LISTS', // Organize product lists
31
- MANAGE_PRODUCT_LIST_ITEMS: 'MANAGE_PRODUCT_LIST_ITEMS', // Add and remove items from lists
32
- SAVE_PRODUCTS: 'SAVE_PRODUCTS', // Save and unsave products
33
- } as const
34
-
35
- export type ConsentType = (typeof UserDataConsent)[keyof typeof UserDataConsent]
36
-
37
- // Consents UI groups
38
- export const ConsentModalGroups = {
39
- profile: [
40
- UserDataConsent.USER_TOKEN,
41
- UserDataConsent.VIEW_PROFILE,
42
- UserDataConsent.VIEW_ACCOUNT_INFO,
43
- UserDataConsent.VIEW_PREFERENCES,
44
- ] as ConsentType[],
45
-
46
- activity: [
47
- UserDataConsent.VIEW_VISITED_PRODUCTS,
48
- UserDataConsent.VIEW_VISITED_SHOPS,
49
- UserDataConsent.VIEW_PRODUCT_RECOMMENDATIONS,
50
- UserDataConsent.VIEW_SHOP_RECOMMENDATIONS,
51
- UserDataConsent.VIEW_SAVED_PRODUCTS,
52
- UserDataConsent.VIEW_FOLLOWED_SHOPS,
53
- UserDataConsent.VIEW_ORDERS,
54
- ] as ConsentType[],
55
-
56
- saves: [
57
- UserDataConsent.SAVE_PRODUCTS,
58
- UserDataConsent.FOLLOW_SHOPS,
59
- UserDataConsent.CREATE_PRODUCT_LISTS,
60
- UserDataConsent.MANAGE_PRODUCT_LISTS,
61
- UserDataConsent.MANAGE_PRODUCT_LIST_ITEMS,
62
- UserDataConsent.VIEW_PRODUCT_LISTS,
63
- ] as ConsentType[],
64
- } as const
65
-
66
- // Set of actions mapped to required consents, which are watched by the PermissionsMiddleware
67
- // If an action is not listed here, no consent is required to perform it
68
- // (unless allowUnlistedActions is false in the PermissionsMiddleware config)
69
- export const ActionToUserDataConsentMapping: {
70
- [key in keyof ShopActionEvents]?: ConsentType
71
- } = {
72
- // User token
73
- GENERATE_USER_TOKEN: UserDataConsent.USER_TOKEN,
74
-
75
- // User profile
76
- GET_ACCOUNT_INFORMATION: UserDataConsent.VIEW_ACCOUNT_INFO,
77
- GET_BUYER_ATTRIBUTES: UserDataConsent.VIEW_PREFERENCES,
78
- GET_CURRENT_USER: UserDataConsent.VIEW_PROFILE,
79
-
80
- // Shops data
81
- GET_FOLLOWED_SHOPS: UserDataConsent.VIEW_FOLLOWED_SHOPS,
82
- GET_RECENT_SHOPS: UserDataConsent.VIEW_VISITED_SHOPS,
83
- GET_RECOMMENDED_SHOPS: UserDataConsent.VIEW_SHOP_RECOMMENDATIONS,
84
-
85
- // Products data
86
- GET_RECENT_PRODUCTS: UserDataConsent.VIEW_VISITED_PRODUCTS,
87
- GET_RECOMMENDED_PRODUCTS: UserDataConsent.VIEW_PRODUCT_RECOMMENDATIONS,
88
-
89
- // Orders data
90
- GET_ORDERS: UserDataConsent.VIEW_ORDERS,
91
-
92
- // Shop following
93
- FOLLOW_SHOP: UserDataConsent.FOLLOW_SHOPS,
94
- UNFOLLOW_SHOP: UserDataConsent.FOLLOW_SHOPS,
95
-
96
- // Manage product lists
97
- ADD_PRODUCT_LIST: UserDataConsent.CREATE_PRODUCT_LISTS,
98
- ADD_PRODUCT_LIST_ITEM: UserDataConsent.MANAGE_PRODUCT_LIST_ITEMS,
99
- FAVORITE: UserDataConsent.SAVE_PRODUCTS,
100
- UNFAVORITE: UserDataConsent.SAVE_PRODUCTS,
101
- REMOVE_PRODUCT_LIST: UserDataConsent.MANAGE_PRODUCT_LISTS,
102
- REMOVE_PRODUCT_LIST_ITEM: UserDataConsent.MANAGE_PRODUCT_LIST_ITEMS,
103
- RENAME_PRODUCT_LIST: UserDataConsent.MANAGE_PRODUCT_LISTS,
104
-
105
- // View product lists
106
- GET_SAVED_PRODUCTS: UserDataConsent.VIEW_SAVED_PRODUCTS,
107
- GET_PRODUCT_LIST: UserDataConsent.VIEW_PRODUCT_LISTS,
108
- GET_PRODUCT_LISTS: UserDataConsent.VIEW_PRODUCT_LISTS,
109
- }
@@ -1,24 +0,0 @@
1
- export type Permission = 'CAMERA' | 'GALLERY' | 'MICROPHONE'
2
-
3
- export interface MiniManifest {
4
- trusted_domains?: string[]
5
- permissions?: string[]
6
- [key: string]: any
7
- }
8
-
9
- export const Consent = {
10
- MiniConsent: 'mini_consent',
11
- CameraConsent: 'camera_consent',
12
- PhotoLibraryConsent: 'photo_library_consent',
13
- MicrophoneConsent: 'microphone_consent',
14
- } as const
15
-
16
- export const ConsentStatus = {
17
- Granted: 'granted',
18
- Dismissed: 'dismissed',
19
- Idle: 'idle',
20
- } as const
21
-
22
- export type ConsentType = (typeof Consent)[keyof typeof Consent]
23
- export type ConsentStatusType =
24
- (typeof ConsentStatus)[keyof typeof ConsentStatus]