UNPKG

@causalfoundry/js-sdk

Version:

Causal Foundry WEB SDK (JS/TS)

321 lines (279 loc) 7.17 kB
import { BloodMeta } from "./blood.typings" import {CoordinatesObject, CurrencyCode} from "../../core/commonTypes" import { OxygenMeta } from "./oxygen.typings" export enum ECommerceTypes { CancelCheckout = "cancel_checkout", Cart = "cart", Checkout = "checkout", Delivery = "delivery", Item = "item", ItemReport = "item_report", ItemRequest = "item_request", ItemVerification = "item_verification", } export enum ItemAction { View = "view", Detail = "detail", Impression = "impression", TopUp = "top_up", Cancel = "cancel", Update = "update", Remove = "remove", Add = "add", Select = "select", AddFavorite = "add_favorite", RemoveFavorite = "remove_favorite", AddReminder = "add_reminder", RemoveReminder = "remove_reminder", RemoveReminderAuto = "remove_reminder_auto", Other = "other" } export enum ItemType { Blood = "blood", Book = "book", Clothing = "clothing", Drug = "drug", Grocery = "grocery", Subscription = "subscription", Facility = "facility", Electronics = "electronics", MedicalEquipment = "medical_equipment", Misc = "misc", Oxygen = "oxygen", ItemVerification = "item_verification", ItemReport = "item_report", Reward = "reward", Survey = "survey", Other = "other" } export enum StockStatus { InStock = 'in_stock', LowStock = 'low_stock', OutOfStock = 'out_of_stock' } export enum SubscriptionStatus { Active = 'active', Inactive = 'inactive', Paused = 'paused', Other = 'other' } export enum SubscriptionType { PayAsYouSell = 'pay_as_you_sell', PayAsYouGo = 'pay_as_you_go', Other = 'other' } // not supported by ts-interface-checker // export type ItemTypeWithoutMeta = Exclude<ItemType, ItemType.Blood | ItemType.Oxygen> export interface ItemMinObject { id: string, type: ItemType } export interface ItemInfoObject { "id": string, "type": ItemType, "batch_id"?: string, "reward_id"?: string, "survey_id"?: string, "is_featured"?: boolean, "expiry_date"?: number, "production_date"?: number } export type BaseItemDetail = { id: string, quantity: number, price: number, currency: CurrencyCode, stock_status?: StockStatus, promo_id?: string, facility_id?: string discount?: number } export type SubscriptionItemDetail = { status: SubscriptionStatus, type: SubscriptionType, subscription_items: Array<ItemMinObject> } export type MetaBloodItemDetail = BaseItemDetail & { type: ItemType.Blood, meta: BloodMeta } export type MetaOxygenItemDetail = BaseItemDetail & { type: ItemType.Oxygen, meta: OxygenMeta } export type DrugItemDetail = BaseItemDetail & { type: ItemType.Drug } export type GroceryItemDetail = BaseItemDetail & { type: ItemType.Grocery } export type BloodItemDetail = BaseItemDetail & { type: ItemType.Blood } export type OxygenItemDetail = BaseItemDetail & { type: ItemType.Oxygen } export type MedicalEquipmentDetail = BaseItemDetail & { type: ItemType.MedicalEquipment } export type SubscriptionDetail = BaseItemDetail & { type: ItemType.Subscription, subscription : SubscriptionItemDetail } export type MetaItemObject = | MetaBloodItemDetail | MetaOxygenItemDetail | DrugItemDetail | MedicalEquipmentDetail | GroceryItemDetail | SubscriptionDetail export type ItemObject = | BloodItemDetail | OxygenItemDetail | DrugItemDetail | MedicalEquipmentDetail | GroceryItemDetail | SubscriptionDetail export interface ItemProperties { action: ItemAction, item: ItemObject, search_id?: string meta?: any } export interface ReportObject { id: string, remarks: string, short_desc?: string } export interface StoreObject { id: string, lat?: number, lon?: number } export enum CartAction { AddItem = "add_item", RemoveItem = "remove_item" } export interface CartProperties { id: string; action: CartAction, item: ItemObject, cart_price: number, currency: CurrencyCode, meta?: any } export enum ScanChannel { App = "app", Ussd = "ussd" } export enum ScanType { Pin = "pin", QrCode = "qr_code" } export enum ListAction { Add = "add_item", Discard = "discard", Edit = "edit_item", Remove = "remove_item", View = "view", Expired = "expired" } export enum ListType { Cart = "cart", Favourite = "favourite", Order = "order", Reminder = "reminder" } export enum ShopMode { Delivery = "delivery", Pickup = "pickup" } export interface CheckoutProperties { id: string //order_id is_successful: boolean cart_price: number, currency: CurrencyCode, items: Array<MetaItemObject>, cart_id: string, shop_mode?: ShopMode meta?: any } export enum DeliveryAction { Schedule = "schedule", Update = "update", Dispatch = "dispatch", Delivered = "delivered" } export interface DeliveryProperties { id: string, order_id: string, is_urgent: boolean, // true = emergency, false = schedule action: DeliveryAction, est_delivery_ts?: Date | string; delivery_coordinates?: CoordinatesObject dispatch_coordinates?: CoordinatesObject meta?: any } export interface DrugProperties { market_id: string, name: string, description?: string, supplier_id: string, supplier_name: string, producer?: string, packaging?: string, active_ingredients: Array<string>, drug_form?: string, drug_strength?: string, atc_anatomical_group?: string, otc_or_ethical?: string } /** * @internal */ export interface InternalDrugProperties extends DrugProperties { id: string } export interface GroceryProperties { name: string, description?: string, category?: string, active_ingredients?: Array<string>, market_id?: string, packaging?: string, packaging_size?: number, packaging_units?: string, producer?: string, supplier_id?: string, supplier_name?: string } /** * @internal */ export interface InternalGroceryProperties extends GroceryProperties { id: string } export interface FacilityProperties { name: string, type?: string, country?: string, region_state?: string, city?: string, is_active?: boolean, has_delivery?: boolean, is_sponsored?: boolean } /** * @internal */ export interface InternalFacilityProperties extends FacilityProperties { id: string } export enum CancelType { Cart = 'cart', Order = 'order' } export interface CancelCheckoutProperties { id: string, type: CancelType, items: ItemMinObject[], reason: string, meta?: any } export interface ItemReportProperties { item: ItemMinObject, report_info: ReportObject, store_info: StoreObject, } export interface ItemRequestProperties { id: string, item_name: string, manufacturer: string, } export interface ItemVerificationProperties { scan_channel: ScanChannel, scan_type: ScanType, is_successful: boolean, item_info: ItemInfoObject }