146 lines
4.9 KiB
TypeScript
146 lines
4.9 KiB
TypeScript
import type { ConstValueType } from '@packages/shared'
|
|
|
|
export const CONST_KEYS = {
|
|
minRegularOrderValue: 'minRegularOrderValue',
|
|
freeDeliveryThreshold: 'freeDeliveryThreshold',
|
|
deliveryCharge: 'deliveryCharge',
|
|
flashFreeDeliveryThreshold: 'flashFreeDeliveryThreshold',
|
|
flashDeliveryCharge: 'flashDeliveryCharge',
|
|
platformFeePercent: 'platformFeePercent',
|
|
taxRate: 'taxRate',
|
|
tester: 'tester',
|
|
minOrderAmountForCoupon: 'minOrderAmountForCoupon',
|
|
maxCouponDiscount: 'maxCouponDiscount',
|
|
flashDeliverySlotId: 'flashDeliverySlotId',
|
|
readableOrderId: 'readableOrderId',
|
|
versionNum: 'versionNum',
|
|
productsVersionNum: 'products_version_num',
|
|
playStoreUrl: 'playStoreUrl',
|
|
appStoreUrl: 'appStoreUrl',
|
|
popularItems: 'popularItems',
|
|
allItemsOrder: 'allItemsOrder',
|
|
tagsOrder: 'tagsOrder',
|
|
isFlashDeliveryEnabled: 'isFlashDeliveryEnabled',
|
|
supportMobile: 'supportMobile',
|
|
supportEmail: 'supportEmail',
|
|
internalAppVersion: 'internalAppVersion',
|
|
welcomeMessage: 'welcomeMessage',
|
|
} as const;
|
|
|
|
export const CONST_LABELS: Record<ConstKey, string> = {
|
|
minRegularOrderValue: 'Minimum Regular Order Value',
|
|
freeDeliveryThreshold: 'Free Delivery Threshold',
|
|
deliveryCharge: 'Delivery Charge',
|
|
flashFreeDeliveryThreshold: 'Flash Free Delivery Threshold',
|
|
flashDeliveryCharge: 'Flash Delivery Charge',
|
|
platformFeePercent: 'Platform Fee Percent',
|
|
taxRate: 'Tax Rate',
|
|
tester: 'Tester',
|
|
minOrderAmountForCoupon: 'Minimum Order Amount for Coupon',
|
|
maxCouponDiscount: 'Maximum Coupon Discount',
|
|
flashDeliverySlotId: 'Flash Delivery Slot ID',
|
|
readableOrderId: 'Readable Order ID',
|
|
versionNum: 'Version Number',
|
|
'products_version_num': 'Cache Version (products)',
|
|
playStoreUrl: 'Play Store URL',
|
|
appStoreUrl: 'App Store URL',
|
|
popularItems: 'Popular Items',
|
|
allItemsOrder: 'All Items Order',
|
|
tagsOrder: 'Tags Order',
|
|
isFlashDeliveryEnabled: 'Enable Flash Delivery',
|
|
supportMobile: 'Support Mobile',
|
|
supportEmail: 'Support Email',
|
|
internalAppVersion: 'Internal App Version',
|
|
welcomeMessage: 'Welcome Message',
|
|
};
|
|
|
|
export type ConstKey = (typeof CONST_KEYS)[keyof typeof CONST_KEYS];
|
|
|
|
export const CONST_KEYS_ARRAY = Object.values(CONST_KEYS) as ConstKey[];
|
|
|
|
export const CONST_TYPES: Record<ConstKey, ConstValueType> = {
|
|
minRegularOrderValue: 'number',
|
|
freeDeliveryThreshold: 'number',
|
|
deliveryCharge: 'number',
|
|
flashFreeDeliveryThreshold: 'number',
|
|
flashDeliveryCharge: 'number',
|
|
platformFeePercent: 'number',
|
|
taxRate: 'number',
|
|
tester: 'string',
|
|
minOrderAmountForCoupon: 'number',
|
|
maxCouponDiscount: 'number',
|
|
flashDeliverySlotId: 'number',
|
|
readableOrderId: 'number',
|
|
versionNum: 'string',
|
|
'products_version_num': 'number',
|
|
playStoreUrl: 'string',
|
|
appStoreUrl: 'string',
|
|
popularItems: 'string',
|
|
allItemsOrder: 'string',
|
|
tagsOrder: 'string',
|
|
isFlashDeliveryEnabled: 'boolean',
|
|
supportMobile: 'string',
|
|
supportEmail: 'string',
|
|
internalAppVersion: 'number',
|
|
welcomeMessage: 'string',
|
|
};
|
|
|
|
export const CONST_VISIBILITY: Record<ConstKey, boolean> = {
|
|
minRegularOrderValue: true,
|
|
freeDeliveryThreshold: true,
|
|
deliveryCharge: true,
|
|
flashFreeDeliveryThreshold: true,
|
|
flashDeliveryCharge: true,
|
|
platformFeePercent: true,
|
|
taxRate: false,
|
|
tester: false,
|
|
minOrderAmountForCoupon: true,
|
|
maxCouponDiscount: false,
|
|
flashDeliverySlotId: true,
|
|
readableOrderId: false,
|
|
versionNum: true,
|
|
'products_version_num': false,
|
|
playStoreUrl: true,
|
|
appStoreUrl: true,
|
|
popularItems: true,
|
|
allItemsOrder: true,
|
|
tagsOrder: false,
|
|
isFlashDeliveryEnabled: true,
|
|
supportMobile: true,
|
|
supportEmail: true,
|
|
internalAppVersion: true,
|
|
welcomeMessage: true,
|
|
};
|
|
|
|
/** Keys stored in the global_consts table. */
|
|
export const GLOBAL_CONST_KEYS = [
|
|
'versionNum', 'playStoreUrl', 'appStoreUrl', 'internalAppVersion',
|
|
] as const
|
|
|
|
/** Keys stored in the region_consts table (one row per region). */
|
|
export const REGION_CONST_KEYS = [
|
|
'products_version_num', 'availability_version_num', 'slots_version_num',
|
|
'popularItems', 'allItemsOrder', 'tagsOrder', 'isFlashDeliveryEnabled',
|
|
'supportMobile', 'supportEmail', 'welcomeMessage',
|
|
] as const
|
|
|
|
/** Keys stored in the region_bound_consts table (one row per bound). */
|
|
export const BOUND_CONST_KEYS = [
|
|
'minRegularOrderValue', 'freeDeliveryThreshold', 'deliveryCharge',
|
|
'flashFreeDeliveryThreshold', 'flashDeliveryCharge',
|
|
] as const
|
|
|
|
/** Keys that remain in the legacy key_val_store table. */
|
|
export const LEGACY_CONST_KEYS = [
|
|
'platformFeePercent', 'taxRate', 'tester', 'minOrderAmountForCoupon',
|
|
'maxCouponDiscount', 'flashDeliverySlotId', 'readableOrderId',
|
|
] as const
|
|
|
|
export type ConstScope = 'global' | 'region' | 'bound' | 'legacy'
|
|
|
|
/** Which table each key belongs to. */
|
|
export const CONST_SCOPE: Record<string, ConstScope> = {}
|
|
for (const k of GLOBAL_CONST_KEYS) CONST_SCOPE[k] = 'global'
|
|
for (const k of REGION_CONST_KEYS) CONST_SCOPE[k] = 'region'
|
|
for (const k of BOUND_CONST_KEYS) CONST_SCOPE[k] = 'bound'
|
|
for (const k of LEGACY_CONST_KEYS) CONST_SCOPE[k] = 'legacy'
|