@shopify/shop-minis-platform 0.10.0 → 0.12.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 +1 -1
- package/src/actions/scopes.ts +6 -2
- package/src/actions/shared.ts +13 -1
package/package.json
CHANGED
package/src/actions/scopes.ts
CHANGED
|
@@ -33,8 +33,6 @@ export enum Scope {
|
|
|
33
33
|
export const ActionToScopesMapping: {
|
|
34
34
|
[key in keyof ShopActionEvents]?: Scope
|
|
35
35
|
} = {
|
|
36
|
-
// User
|
|
37
|
-
GENERATE_USER_TOKEN: Scope.OPENID,
|
|
38
36
|
GET_ACCOUNT_INFORMATION: Scope.PROFILE,
|
|
39
37
|
GET_BUYER_ATTRIBUTES: Scope.PROFILE,
|
|
40
38
|
GET_CURRENT_USER: Scope.USER_SETTINGS_READ,
|
|
@@ -65,3 +63,9 @@ export const ActionToScopesMapping: {
|
|
|
65
63
|
GET_PRODUCT_LIST: Scope.PRODUCT_LIST_READ,
|
|
66
64
|
GET_PRODUCT_LISTS: Scope.PRODUCT_LIST_READ,
|
|
67
65
|
} as const
|
|
66
|
+
|
|
67
|
+
export const ActionToOptionalScopesMapping: {
|
|
68
|
+
[key in keyof ShopActionEvents]?: Scope
|
|
69
|
+
} = {
|
|
70
|
+
GENERATE_USER_TOKEN: Scope.OPENID,
|
|
71
|
+
} as const
|
package/src/actions/shared.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
// Helper type to capitalize a segment, with special handling for AR
|
|
2
|
+
// This matches the runtime behavior in actionTypeToMethodName
|
|
3
|
+
type CapitalizeSegment<S extends string> =
|
|
4
|
+
Uppercase<S> extends 'AR' ? 'AR' : Capitalize<Lowercase<S>>
|
|
5
|
+
|
|
6
|
+
// Helper type for tail segments (non-first words get capitalized)
|
|
7
|
+
type SnakeToCamelCaseTail<S extends string> =
|
|
8
|
+
S extends `${infer Head}_${infer Tail}`
|
|
9
|
+
? `${CapitalizeSegment<Head>}${SnakeToCamelCaseTail<Tail>}`
|
|
10
|
+
: CapitalizeSegment<S>
|
|
11
|
+
|
|
1
12
|
// Utility type to convert SNAKE_CASE to camelCase
|
|
2
13
|
// Example: 'FOLLOW_SHOP' -> 'followShop'
|
|
14
|
+
// Example: 'PREVIEW_PRODUCT_IN_AR' -> 'previewProductInAR' (AR preserved)
|
|
3
15
|
export type SnakeToCamelCase<S extends string> =
|
|
4
16
|
S extends `${infer Head}_${infer Tail}`
|
|
5
|
-
? `${Lowercase<Head>}${
|
|
17
|
+
? `${Lowercase<Head>}${SnakeToCamelCaseTail<Tail>}`
|
|
6
18
|
: Lowercase<S>
|
|
7
19
|
|
|
8
20
|
export interface ShopActionOk<T> {
|