@salla.sa/twilight 2.0.265 → 2.0.267

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/twilight",
3
- "version": "2.0.265",
3
+ "version": "2.0.267",
4
4
  "description": "Salla Theme Toolkit, Webcomponents, Events, Requests, Utils",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -9,13 +9,10 @@ export interface ProfileUpdatePayload {
9
9
  avatar?: BinaryType;
10
10
  }
11
11
 
12
- export interface ProfileUpdateMobilePayload {
13
- phone: string | number;
14
- country_code: string | 'SA';
15
- }
16
-
17
- export interface ProfileUpdateEmailPayload {
18
- email: string;
12
+ export interface ProfileUpdateContactPayload {
13
+ phone?: string | number; //required if there is no email
14
+ country_code?: string | 'SA'; //required if there is phone
15
+ email?: string; //required if there is no phone
19
16
  }
20
17
 
21
18
  export interface UpdateProfileResponse extends SuccessResponse {
@@ -31,11 +28,12 @@ export interface UpdateProfileResponse extends SuccessResponse {
31
28
  avatar: string;
32
29
  gender?: 'male' | 'female';
33
30
  birthday: string | '2022-02-22';
31
+ verification_type?: 'email' | 'mobile'; //exists when trying to update email/phone
34
32
  };
35
33
  }
36
34
 
37
35
  export default interface ProfileApi {
38
36
  update: (data: ProfileUpdatePayload) => Promise<UpdateProfileResponse>;
39
37
  verify: (data: AuthRequest.verifyByMobile | AuthRequest.verifyByEmail) => Promise<SuccessResponse>;
40
- updateContacts: (data: ProfileUpdateMobilePayload | ProfileUpdateEmailPayload) => Promise<UpdateProfileResponse>;
38
+ updateContacts: (data: ProfileUpdateContactPayload) => Promise<UpdateProfileResponse>;//should verify after success event
41
39
  }
@@ -4,7 +4,7 @@ import {RequestErrorEvent, SuccessResponse} from "../common";
4
4
  export default interface ProfileEvent {
5
5
  onUpdated: (callback: (response: UpdateProfileResponse) => void) => void;
6
6
  onVerified: (callback: (response: SuccessResponse) => void) => void;
7
- onContactsUpdated: (callback: (response: UpdateProfileResponse) => void) => void;
7
+ onVerificationCodeSent: (callback: (response: UpdateProfileResponse) => void) => void; //should trigger action to fill verify code, then calling salla.profile.verify(...)
8
8
 
9
9
  //errors
10
10
  onUpdateFailed: RequestErrorEvent;
@@ -1,6 +1,26 @@
1
1
  import {Price} from "../common";
2
2
 
3
3
  export type UrlHelper = (path: string) => string; //add any path to current url, ex: `salla.url('cart?anything=data')` output => `https://store_domain.com/cart?anything=data`
4
+ export type PageName = 'blog.index'
5
+ | 'blog.index.author'
6
+ | 'blog.index.category'
7
+ | 'blog.index.tag'
8
+ | 'brands.index'
9
+ | 'cart'
10
+ | 'customer.orders.index'
11
+ | 'customer.orders.index.pending'
12
+ | 'customer.orders.single'
13
+ | 'customer.profile'
14
+ | 'customer.wishlist'
15
+ | 'index'
16
+ | 'page-single'
17
+ | 'product.index'
18
+ | 'product.index.latest'
19
+ | 'product.index.offers'
20
+ | 'product.index.search'
21
+ | 'product.index.tag'
22
+ | 'product.single'
23
+ | 'thank-you';
4
24
  export default interface SallaHelpers {
5
25
  //Numbers helpers
6
26
  digitsOnly: (num: string | number) => number;
@@ -25,6 +45,7 @@ export default interface SallaHelpers {
25
45
  asset: UrlHelper;
26
46
  get: UrlHelper;
27
47
  cdn: UrlHelper;
48
+ is_page: (pageName: PageName) => boolean;
28
49
  };
29
50
  asset: UrlHelper;
30
51
  cdn: UrlHelper;
package/types/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import SallaActions from "./actions";
4
4
 
5
5
  import SallaConfig from "./lib/salla-config";
6
6
  import {Price} from "./common";
7
- import SallaHelpers, {UrlHelper} from "./helpers/salla-helpers";
7
+ import SallaHelpers, {PageName, UrlHelper} from "./helpers/salla-helpers";
8
8
  import AppHelpers from "./helpers/app-helpers";
9
9
  import SallaNotify, {Logger} from "./lib/salla-notify";
10
10
  import SallaStorage from "./lib/salla-storage";
@@ -34,6 +34,7 @@ export default interface Salla extends SallaActions {
34
34
  asset: UrlHelper;
35
35
  get: UrlHelper;
36
36
  cdn: UrlHelper;
37
+ is_page: (pageName: PageName) => boolean;
37
38
  };
38
39
  isInitiated: boolean; // will be true when firing event `twilight::initiated`
39
40
  onReady: (callback: (event: Event) => unknown) => void; //don't relay on it because Salla may not existed yet