@salla.sa/twilight 2.15.1-alpha.0 → 3.0.0-beta.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/README.md +37 -3
- package/dist/@salla.sa/twilight.min.js +1 -19
- package/dist/@salla.sa/twilight.min.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +74 -70
- package/types/api/cart/index.d.ts +1 -1
- package/types/api/index.d.ts +7 -1
- package/types/api/loyalty.d.ts +10 -1
- package/types/api/metadata.d.ts +33 -0
- package/types/api/order.d.ts +18 -2
- package/types/api/product/request.d.ts +2 -1
- package/types/api/profile.d.ts +5 -0
- package/types/common.d.ts +20 -1
- package/types/event/index.d.ts +3 -0
- package/types/event/loyalty.d.ts +5 -1
- package/types/event/metadata.d.ts +7 -0
- package/types/event/product.d.ts +1 -1
- package/types/lib/lang.d.ts +2 -1
- package/types/tiwlight-config.d.ts +221 -18
- package/watcher.js +1 -1
package/package.json
CHANGED
|
@@ -1,71 +1,75 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
2
|
+
"name": "@salla.sa/twilight",
|
|
3
|
+
"version": "3.0.0-beta.1",
|
|
4
|
+
"description": "Salla Theme Toolkit, Webcomponents, Events, Requests, Utils",
|
|
5
|
+
"main": "dist/cjs",
|
|
6
|
+
"module": "dist/esm",
|
|
7
|
+
"types": "types/index.d.ts",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"salla",
|
|
10
|
+
"theme",
|
|
11
|
+
"utils",
|
|
12
|
+
"events",
|
|
13
|
+
"requests"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/SallaApp/twilight.git"
|
|
18
|
+
},
|
|
19
|
+
"author": "Salla.sa",
|
|
20
|
+
"license": "GPL-3.0",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"types",
|
|
24
|
+
"watcher.js",
|
|
25
|
+
"package.json",
|
|
26
|
+
"postInstall.js"
|
|
27
|
+
],
|
|
28
|
+
"homepage": "https://salla.dev",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@jitsu/js": "^1.10.4",
|
|
31
|
+
"axios": "^1.13.6",
|
|
32
|
+
"infinite-scroll": "^4.0.1",
|
|
33
|
+
"jwt-decode": "^4.0.0",
|
|
34
|
+
"lang.js": "^1.1.14",
|
|
35
|
+
"websocket": "^1.0.35",
|
|
36
|
+
"@salla.sa/base": "3.0.0-beta.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@babel/core": "^7.29.0",
|
|
40
|
+
"@babel/preset-env": "^7.29.0",
|
|
41
|
+
"@rollup/plugin-babel": "^7.0.0",
|
|
42
|
+
"@rollup/plugin-commonjs": "^29.0.2",
|
|
43
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
44
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
45
|
+
"babel-loader": "^10.1.0",
|
|
46
|
+
"ev-emitter": "^2.1.0",
|
|
47
|
+
"fizzy-ui-utils": "^3.0.0",
|
|
48
|
+
"form-data": "^4.0.5",
|
|
49
|
+
"jest": "^30.2.0",
|
|
50
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
51
|
+
"load-script": "^2.0.0",
|
|
52
|
+
"nock": "^13.5.6",
|
|
53
|
+
"rollup": "^4.59.0",
|
|
54
|
+
"rollup-jest": "^3.1.0",
|
|
55
|
+
"rollup-plugin-analyzer": "^4.0.0",
|
|
56
|
+
"rollup-plugin-cleaner": "^1.0.0",
|
|
57
|
+
"rollup-plugin-exclude-dependencies-from-bundle": "^1.1.24",
|
|
58
|
+
"rollup-plugin-serve": "^3.0.0",
|
|
59
|
+
"rollup-plugin-version-injector": "^1.3.3",
|
|
60
|
+
"rollup-plugin-watch": "^1.0.5",
|
|
61
|
+
"webpack": "^5.105.4",
|
|
62
|
+
"webpack-build-notifier": "^3.1.0",
|
|
63
|
+
"webpack-cli": "^6.0.1"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"webpack": "^4 || ^5"
|
|
67
|
+
},
|
|
68
|
+
"gitHead": "e43ccbe0086ed916ecad8ac8cf952ece4e035e2e",
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "npx rollup --config --bundleConfigAsCjs --preserveSymlinks=true",
|
|
71
|
+
"watch": "npx rollup --watch --config --bundleConfigAsCjs --preserveSymlinks=true",
|
|
72
|
+
"test": "jest --detectOpenHandles",
|
|
73
|
+
"test:ci": "jest --config jest.ci.config.js --forceExit"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -7,7 +7,7 @@ import {CartRequest} from "./request";
|
|
|
7
7
|
export default interface CartApi {
|
|
8
8
|
latest: () => Promise<CartResponse.update>;
|
|
9
9
|
details: (cartId: number | null, withItems: ['options' | 'attachments']) => Promise<CartResponse.update>;
|
|
10
|
-
quickAdd: (/*product_id*/id: number, quantity: number) => Promise<CartResponse.update>;
|
|
10
|
+
quickAdd: (/*product_id*/id: number, quantity: number, offerType: string | null) => Promise<CartResponse.update>;
|
|
11
11
|
addItem: (data: CartRequest.addItem) => Promise<CartResponse.update>;
|
|
12
12
|
deleteItem: (item_id: number) => Promise<CartResponse.update>;
|
|
13
13
|
updateItem: (data: CartRequest.addItem) => Promise<CartResponse.update>;
|
package/types/api/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import ScopeApi from "./scope";
|
|
|
13
13
|
import LandingApi from "./landing";
|
|
14
14
|
import BookingApi from "./booking";
|
|
15
15
|
import NavigationApi from "./navigation"
|
|
16
|
+
import MetadataApi from "./metadata"
|
|
16
17
|
import {AxiosInstance} from "axios";
|
|
17
18
|
import {ErrorResponse, SuccessResponse} from "@salla.sa/base/types/common";
|
|
18
19
|
|
|
@@ -56,6 +57,7 @@ export type ApiActionName =
|
|
|
56
57
|
| 'loyalty.exchange'
|
|
57
58
|
| 'loyalty.getProgram'
|
|
58
59
|
| 'loyalty.reset'
|
|
60
|
+
| 'loyalty.getPoints'
|
|
59
61
|
| 'order.cancel'
|
|
60
62
|
| 'order.reOrder'
|
|
61
63
|
| 'order.send'
|
|
@@ -73,8 +75,10 @@ export type ApiActionName =
|
|
|
73
75
|
| 'product.uploadGiftImage'
|
|
74
76
|
| 'product.fetch'
|
|
75
77
|
| 'product.fetchOptions'
|
|
78
|
+
| 'product.fetchImages'
|
|
76
79
|
| 'profile.update'
|
|
77
80
|
| 'profile.info'
|
|
81
|
+
| 'profile.fields'
|
|
78
82
|
| 'profile.updateContacts'
|
|
79
83
|
| 'profile.verify'
|
|
80
84
|
| 'profile.updateSettings'
|
|
@@ -97,7 +101,8 @@ export type ApiActionName =
|
|
|
97
101
|
| 'scope.getProductAvailability'
|
|
98
102
|
| 'withoutNotifier'
|
|
99
103
|
| 'booking.add'
|
|
100
|
-
| 'navigation.fetchBreadcrumbs'
|
|
104
|
+
| 'navigation.fetchBreadcrumbs'
|
|
105
|
+
| 'metadata.fetchValues';
|
|
101
106
|
|
|
102
107
|
export default interface Api {
|
|
103
108
|
cart: CartApi;
|
|
@@ -115,6 +120,7 @@ export default interface Api {
|
|
|
115
120
|
booking: BookingApi;
|
|
116
121
|
landing: LandingApi;
|
|
117
122
|
navigation: NavigationApi;
|
|
123
|
+
metadata: MetadataApi;
|
|
118
124
|
|
|
119
125
|
axios: AxiosInstance;
|
|
120
126
|
withoutNotifier: (callback: Function) => Promise<void>;
|
package/types/api/loyalty.d.ts
CHANGED
|
@@ -212,6 +212,10 @@ export interface PrizeObject {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
|
|
215
|
+
export interface UserLoyaltyPoint {
|
|
216
|
+
points: number | null
|
|
217
|
+
}
|
|
218
|
+
|
|
215
219
|
export namespace LoyaltyApiResponse {
|
|
216
220
|
|
|
217
221
|
export interface program extends SuccessResponse {
|
|
@@ -222,11 +226,16 @@ export namespace LoyaltyApiResponse {
|
|
|
222
226
|
export interface point extends SuccessResponse {
|
|
223
227
|
data: ExchangePoint
|
|
224
228
|
}
|
|
229
|
+
|
|
230
|
+
export interface userPoints extends SuccessResponse {
|
|
231
|
+
data: UserLoyaltyPoint
|
|
232
|
+
}
|
|
225
233
|
}
|
|
226
234
|
|
|
227
235
|
|
|
228
236
|
export default interface LoyaltyApi {
|
|
229
237
|
getProgram: () => Promise<LoyaltyApiResponse.program>
|
|
230
|
-
exchange: (prize_id: number | PrizeObject, cart_id?: number) => Promise<LoyaltyApiResponse.point>
|
|
238
|
+
exchange: (prize_id: number | PrizeObject, cart_id?: number, selected_product_id?: number | null) => Promise<LoyaltyApiResponse.point>
|
|
231
239
|
reset: (cart_id?: number) => Promise<SuccessResponse>
|
|
240
|
+
getPoints: () => Promise<LoyaltyApiResponse.userPoints>
|
|
232
241
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SuccessResponse } from '../common';
|
|
2
|
+
|
|
3
|
+
export interface MetadataValue {
|
|
4
|
+
entity_id?: number;
|
|
5
|
+
sections?: Section[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface Section {
|
|
9
|
+
id?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
fields?: Field[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface Field {
|
|
15
|
+
id?: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
type?: string;
|
|
18
|
+
value?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Metadata {
|
|
22
|
+
values: MetadataValue[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export namespace MetadataApiResponse {
|
|
26
|
+
export interface value extends SuccessResponse {
|
|
27
|
+
data: Metadata;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default interface MetadataApi {
|
|
32
|
+
fetchValues: (entity: string, entityIds: number[] | number) => Promise<MetadataApiResponse.value>;
|
|
33
|
+
}
|
package/types/api/order.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {SuccessResponse} from "../common";
|
|
1
|
+
import type {SuccessResponse} from "../common";
|
|
2
2
|
|
|
3
3
|
export interface CreateCartFromOrderResponse extends SuccessResponse {
|
|
4
4
|
data: {
|
|
@@ -46,6 +46,7 @@ export interface OrderResponse {
|
|
|
46
46
|
date?: DateClass;
|
|
47
47
|
status?: Status;
|
|
48
48
|
can_cancel?: boolean;
|
|
49
|
+
cancellation_reasons?: CancellationReason[];
|
|
49
50
|
can_reorder?: boolean;
|
|
50
51
|
is_pending_payment?: boolean;
|
|
51
52
|
pending_payment_ends_at?: number;
|
|
@@ -86,10 +87,25 @@ export interface FetchOrdersResponse extends SuccessResponse {
|
|
|
86
87
|
data: Array<OrderResponse>;
|
|
87
88
|
}
|
|
88
89
|
|
|
90
|
+
export interface CancellationReason {
|
|
91
|
+
id: number;
|
|
92
|
+
name: string;
|
|
93
|
+
type: 'system' | 'custom';
|
|
94
|
+
slug: string | null;
|
|
95
|
+
sort: number;
|
|
96
|
+
is_active: boolean;
|
|
97
|
+
translations?: Record<string, { name: string }>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface CancelOrderPayload {
|
|
101
|
+
reasons?: Array<number | string>;
|
|
102
|
+
reason_note?: string;
|
|
103
|
+
}
|
|
89
104
|
|
|
90
105
|
export default interface OrderApi {
|
|
91
106
|
createCartFromOrder: (order_id?: number) => Promise<CreateCartFromOrderResponse>;
|
|
92
|
-
cancel: (order_id?: number) => Promise<SuccessResponse>;
|
|
107
|
+
cancel: (order_id?: number, payload?: CancelOrderPayload) => Promise<SuccessResponse>;
|
|
108
|
+
getDetails: (order_id?: number) => Promise<OrderResponse>;
|
|
93
109
|
sendInvoice: (payload: SendInvoicePayload) => Promise<SuccessResponse>;
|
|
94
110
|
show: (payload: ShowOrderPayload) => Promise<void>; //should be called from thank you page to trigger native order details page in apps
|
|
95
111
|
fetch: (payload: OrderRequestParameters) => Promise<FetchOrdersResponse>;
|
package/types/api/profile.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ export interface ProfileUpdatePayload {
|
|
|
9
9
|
avatar?: BinaryType;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export interface ProfileUpdateCustomFields {
|
|
13
|
+
id:number,
|
|
14
|
+
fields: { [key: string]: unknown };
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
export interface ProfileUpdateContactPayload {
|
|
13
18
|
phone?: string | number; //required if there is no email
|
|
14
19
|
country_code?: string | 'SA'; //required if there is phone
|
package/types/common.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export interface Currency {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export interface Product {
|
|
54
|
-
id?: number
|
|
54
|
+
id?: number|string;//it's coming string sometimes🌚
|
|
55
55
|
name?: string;
|
|
56
56
|
sku?: null | string;
|
|
57
57
|
subtitle?: null | string;
|
|
@@ -119,6 +119,7 @@ export interface Product {
|
|
|
119
119
|
attachments?: any;
|
|
120
120
|
add_to_cart_label?: string;
|
|
121
121
|
show_availability?: boolean;
|
|
122
|
+
metadata?: any;
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
export interface MainImage {
|
|
@@ -187,4 +188,22 @@ export interface Phone {
|
|
|
187
188
|
export enum Genders {
|
|
188
189
|
Female = 'female',
|
|
189
190
|
Male = 'male',
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface ProductMetadata {
|
|
194
|
+
entity_id?: number;
|
|
195
|
+
sections?: Section[];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface Section {
|
|
199
|
+
id?: string;
|
|
200
|
+
name?: string;
|
|
201
|
+
fields?: Field[];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface Field {
|
|
205
|
+
id?: string;
|
|
206
|
+
name?: string;
|
|
207
|
+
type?: string;
|
|
208
|
+
value?: string;
|
|
190
209
|
}
|
package/types/event/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import ScopeEvents from "./scope";
|
|
|
14
14
|
import BookingEvent from "./booking";
|
|
15
15
|
import LandingEvent from "./landing";
|
|
16
16
|
import NavigationEvent from "./navigation";
|
|
17
|
+
import MetadataEvent from "./metadata";
|
|
17
18
|
|
|
18
19
|
import Emitter from "@salla.sa/base/types/event";
|
|
19
20
|
|
|
@@ -36,6 +37,7 @@ export {
|
|
|
36
37
|
BookingEvent,
|
|
37
38
|
LandingEvent,
|
|
38
39
|
NavigationEvent,
|
|
40
|
+
MetadataEvent,
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export default interface TwilightEmitter extends Emitter {
|
|
@@ -55,4 +57,5 @@ export default interface TwilightEmitter extends Emitter {
|
|
|
55
57
|
booking: BookingEvent;
|
|
56
58
|
infiniteScroll: InfiniteScrollEvent;
|
|
57
59
|
navigation: NavigationEvent;
|
|
60
|
+
metadata: MetadataEvent;
|
|
58
61
|
}
|
package/types/event/loyalty.d.ts
CHANGED
|
@@ -10,5 +10,9 @@ export default interface LoyaltyEvent {
|
|
|
10
10
|
onExchangeFailed: RequestErrorEvent;
|
|
11
11
|
// Reset Exchange
|
|
12
12
|
onResetSucceeded: (callback: (response: SuccessResponse) => void) => void;
|
|
13
|
-
onResetFailed: RequestErrorEvent
|
|
13
|
+
onResetFailed: RequestErrorEvent;
|
|
14
|
+
|
|
15
|
+
// User Loyalty Points
|
|
16
|
+
onLoyaltyPointsFetched: (callback: (response: LoyaltyApiResponse.userPoints) => void) => void;
|
|
17
|
+
onLoyaltyPointsNotFetched: RequestErrorEvent;
|
|
14
18
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequestErrorEvent } from "../common";
|
|
2
|
+
import { MetadataApiResponse } from "../api/metadata";
|
|
3
|
+
|
|
4
|
+
export default interface MetadataEvent {
|
|
5
|
+
onValueFetched: (callback: (response: MetadataApiResponse.value) => void) => void;
|
|
6
|
+
onValueNotFetched: RequestErrorEvent;
|
|
7
|
+
}
|
package/types/event/product.d.ts
CHANGED
|
@@ -35,5 +35,5 @@ export default interface ProductEvent {
|
|
|
35
35
|
onProductListFetchFailed: RequestErrorEvent;
|
|
36
36
|
|
|
37
37
|
onProductOptionsFetched: (callback: (response: ProductResponse.options) => void) => void;
|
|
38
|
-
onProductOptionsNotFetched: RequestErrorEvent
|
|
38
|
+
onProductOptionsNotFetched: RequestErrorEvent;
|
|
39
39
|
}
|
package/types/lib/lang.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ type Replacements = { [key: string]: string }
|
|
|
8
8
|
*/
|
|
9
9
|
export default interface SallaLang extends Lang {
|
|
10
10
|
translationsLoaded: boolean;
|
|
11
|
-
onLoaded: (callback
|
|
11
|
+
onLoaded: (callback?: Function) => Promise<void>;
|
|
12
|
+
subscribe: (fn: () => void) => () => void;
|
|
12
13
|
get: (key: string, replacements?: Replacements, locale?: string | 'ar') => string;
|
|
13
14
|
set: (key: string, message: string) => SallaLang;
|
|
14
15
|
}
|