@salla.sa/twilight
Version:
Salla Theme Toolkit, Webcomponents, Events, Requests, Utils
328 lines (311 loc) • 8.21 kB
TypeScript
import {Currency} from "./common";
export interface Language {
name: string;
code: string;
url: string;
is_rtl: boolean;
country_code: string;
}
type Networks = 'mada' | 'masterCard' | 'visa';
export type Apps = {
appstore?: string;
googleplay?: string;
};
export type DevelopmentStoreTemplate = {
price: number;
price_details: {
currency: string;
items: {
product_price: number;
price: number;
quantity: number;
}[];
total: number;
};
developer?: {
name: string;
url?: string;
};
};
export type StoreSettings = {
auth: {
email_allowed: boolean;
mobile_allowed: boolean;
is_email_required: boolean;
countries?: string[];
force_login?: boolean;
};
cart?: {
apply_coupon_enabled: boolean;
};
product?: {
total_sold_enabled: boolean;
manual_quantity: boolean;
fit_type?: string;
related_products_enabled: boolean;
filters: {
category_id?: boolean;
brand_id?: boolean;
price?: boolean;
variants?: boolean;
rating?: boolean;
tag_name?: boolean;
};
show_comments?: boolean;
user_can_comment?: boolean;
show_price_as_dash?: boolean;
notify_options_availability?: boolean;
show_special_offers?: boolean;
show_more?: boolean;
availability_notify?: {
email?: boolean;
mobile?: boolean;
sms?: boolean;
whatsapp?: boolean;
};
category?: {
testimonial_enabled?: boolean;
};
};
payments: PaymentName[];
arabic_numbers_enabled: boolean;
content_copyright?: boolean;
use_sar_symbol?: boolean;
is_multilingual?: boolean;
currencies_enabled?: boolean;
rating_enabled?: boolean;
rating?: {
is_enabled?: boolean;
show_on_category?: boolean;
show_on_product?: boolean;
can_rate_store?: boolean;
can_rate_product?: boolean;
can_rate_shipping?: boolean;
show_rating_summary?: boolean;
show_recommendation?: boolean;
allow_likes?: boolean;
allow_attach_images?: boolean;
allow_contact_support?: boolean;
allow_update?: boolean;
update_period?: number;
can_customer_hide_name?: boolean;
visitor_can_comment?:boolean;
page_feedback_enabled?:boolean;
};
blog?: {
is_enabled?: boolean;
allow_likes_and_comments?: boolean;
};
is_loyalty_enabled?: boolean;
keys?: {
maps?: string;
gtm?: string[];
};
is_salla_gateway?: boolean;
upload_size?: number;
tax?: {
number?: string;
certificate?: string;
taxable_prices_enabled?: boolean;
};
certificate?: string;
made_in_ksa?: boolean;
commercial_number?: string;
freelance_number?: string;
buy_now?: {
networks?: Networks[];
countries: string[];
multi_currency: boolean;
is_digital: boolean;
};
installments: Installment[];
quick_order?: {
title?: string;
sub_title?: string;
thanks_message?: string;
order_now_button?: string;
is_email_required?: boolean;
show_agreement?: boolean;
style?: 'grey' | 'white' | 'default';
confirm_button?: string;
agreement?: string;
allowed_countries?: string[];
};
bullet_delivery?: {
enabled?: boolean;
supports_pickup?: boolean;
customer_location?: {
country?: string;
city?: string;
};
settings?: {
type?: string;
is_required?: boolean;
remember_last_session?: boolean;
};
};
};
export type StoreContacts = {
whatsapp?: string;
mobile?: string;
phone?: string;
email?: string;
telegram?: string;
};
export type StoreSocial = {
instagram?: string;
twitter?: string;
snapchat?: string;
tiktok?: string;
youtube?: string;
facebook?: string;
pinterest?: string;
};
export type StoreScope = {
id: number;
name: string;
selected: boolean;
type: string;
is_open: boolean;
display_as?: string;
languages: string[];
currencies: string[];
countries: string[];
always_ask: boolean;
allocation?: {
type: string;
branch_id: number;
};
};
export interface StoreConfig {
id: number;
url: string;
logo?: string;
name?: string;
username?: string;
description?: string;
icon?: string;
api?: string;
settings?: StoreSettings;
meta?: {
title?: string;
description?: string;
keywords?: string;
};
contacts?: StoreContacts;
social?: StoreSocial;
scope?: StoreScope;
store_country: string; // TODO: should be replace with country but for backward compatibility, we need to keep it for now.
country?: string;
/** Numeric store ray/shard identifier from the API. */
ray?: number;
/** Feature flags enabled for this store, e.g. ["guest-checkout", "salla-account"]. */
features?: string[];
template?: DevelopmentStoreTemplate;
apps?: Apps;
}
type Installment = 'tabby_installment' | 'tamara_installment' | 'spotii_pay';
type PaymentName = Installment | 'mada' | 'credit_card' | 'paypal' | 'bank' | 'stc_pay' | 'apple_pay' | 'knet';
export type TwilightConfigName = 'maintenance'
| 'debug'
| 'events'
| 'sdk'
| 'sdk.notifier_handler_disabled'
| 'store'
| 'store.url'
| 'store.id'
| 'store.logo'
| 'store.name'
| 'store.username'
| 'store.description'
| 'store.icon'
| 'store.contacts'
| 'store.social'
| 'store.scope'
| 'store.store_country'
| 'store.country'
| 'store.ray'
| 'store.features'
| 'store.template'
| 'store.apps'
| 'store.api'
| 'store.settings'
| 'store.settings.auth'
| 'store.settings.auth.email_allowed'
| 'store.settings.auth.mobile_allowed'
| 'store.settings.auth.is_email_required'
| 'store.arabic_numbers_enabled'
| 'store.payments'
| 'store.installments'
| 'user.type'
| 'user.id'
| 'user.email'
| 'user.mobile'
| 'user.language_code'
| 'user.currency_code'
| 'user.country_code'
| 'theme.name'
| 'theme.mode'
| 'theme.translations_hash'
| 'theme.color'
| 'theme.color.primary'
| 'theme.color.text'
| 'theme.color.is_dark'
| 'theme.color.reverse_primary'
| 'theme.color.reverse_text'
| 'languages'
| 'currencies'
| '`currencies.${string}`'
| 'page.title'
| 'page.slug'
| 'page.id';
export interface TwilightConfigClass {
merge(config: TwilightConfig): TwilightConfigClass;
set(key: TwilightConfigName, value: any): TwilightConfigClass;
get(key: TwilightConfigName, default_?: any): any;
all(): TwilightConfig;
}
export interface TwilightConfig {
/**
* @deprecated
*/
_token?: string;
maintenance?: boolean;
debug?: boolean;
events?: { [event_name: string]: any };
sdk?: {
notifier_handler_disabled: boolean
},
store: StoreConfig;
user?: {
type?: 'user' | 'guest';
id?: string | number;
email?: any;
mobile?: any;
language_code?: string;
currency_code?: string;
country_code?: string;
};
theme?: {
name?: string;
mode?: string;
translations_hash?: string;
color?: {
primary: string | '#5cd5c4';
text: string | '#ffffff';
is_dark: boolean;
reverse_primary: string | '#5cd5c4';
reverse_text: string | '#005544';
}
};
languages?: Language[];
currencies?: {
SAR?: Currency;
[key: string]: Currency;
};
page?: {
title?: string;
slug?: string;
id?: number;//available in product.single, customer.orders.single, cart, thank-you, page-single
};
}