@nextorders/food-schema 0.2.7 → 0.3.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/dist/index.d.mts +185 -66
- package/dist/index.d.ts +185 -66
- package/dist/index.mjs +45 -25
- package/package.json +2 -3
package/dist/index.mjs
CHANGED
|
@@ -326,7 +326,7 @@ const ScheduleSchema = z.array(DayScheduleSchema).refine((schedules) => {
|
|
|
326
326
|
const NextOpeningSchema = z.object({
|
|
327
327
|
day: WeekDaySchema,
|
|
328
328
|
time: TimeSchema,
|
|
329
|
-
relativeDays: z.number().int()
|
|
329
|
+
relativeDays: z.number().int().nonnegative()
|
|
330
330
|
});
|
|
331
331
|
const OpeningStatusSchema = z.object({
|
|
332
332
|
isClosed: z.boolean(),
|
|
@@ -335,7 +335,7 @@ const OpeningStatusSchema = z.object({
|
|
|
335
335
|
currentDay: WeekDaySchema,
|
|
336
336
|
todayHours: TimePeriodSchema.array().nullable(),
|
|
337
337
|
todayEndAt: TimeSchema.nullable(),
|
|
338
|
-
todayEndInMinutes: z.number().nullable(),
|
|
338
|
+
todayEndInMinutes: z.number().nonnegative().nullable(),
|
|
339
339
|
nextOpening: NextOpeningSchema.nullable()
|
|
340
340
|
});
|
|
341
341
|
|
|
@@ -352,7 +352,7 @@ const DeliveryByCourierSchema = z.object({
|
|
|
352
352
|
isAvailable: z.boolean(),
|
|
353
353
|
paymentMethods: PaymentMethodSchema.array(),
|
|
354
354
|
conditions: LocaleValueSchema.array().optional(),
|
|
355
|
-
minAmountForDelivery: z.number().optional(),
|
|
355
|
+
minAmountForDelivery: z.number().nonnegative().optional(),
|
|
356
356
|
schedule: ScheduleSchema.optional()
|
|
357
357
|
});
|
|
358
358
|
const SelfPickupSchema = z.object({
|
|
@@ -363,10 +363,10 @@ const SelfPickupSchema = z.object({
|
|
|
363
363
|
warehouses: WarehouseSchema.array().optional()
|
|
364
364
|
});
|
|
365
365
|
const LinkSchema = z.object({
|
|
366
|
-
to: z.string(),
|
|
366
|
+
to: z.string().min(1),
|
|
367
367
|
label: LocaleValueSchema.array().optional(),
|
|
368
368
|
icon: z.string().optional(),
|
|
369
|
-
target: z.
|
|
369
|
+
target: z.enum(["_blank", "_self", "_parent", "_top"]).optional()
|
|
370
370
|
});
|
|
371
371
|
const LinksSchema = z.object({
|
|
372
372
|
aside: LinkSchema.array(),
|
|
@@ -396,7 +396,7 @@ const ImageSchema = z.object({
|
|
|
396
396
|
format: ImageFormatSchema
|
|
397
397
|
});
|
|
398
398
|
|
|
399
|
-
const VideoTypeSchema = z.enum(["video/mp4"]);
|
|
399
|
+
const VideoTypeSchema = z.enum(["video/mp4", "video/webm"]);
|
|
400
400
|
const VideoSchema = z.object({
|
|
401
401
|
id: z.string(),
|
|
402
402
|
url: z.string(),
|
|
@@ -404,10 +404,10 @@ const VideoSchema = z.object({
|
|
|
404
404
|
});
|
|
405
405
|
|
|
406
406
|
const NutritionFactsSchema = z.object({
|
|
407
|
-
calories: z.number(),
|
|
408
|
-
carbohydrate: z.number(),
|
|
409
|
-
protein: z.number(),
|
|
410
|
-
fat: z.number()
|
|
407
|
+
calories: z.number().nonnegative(),
|
|
408
|
+
carbohydrate: z.number().nonnegative(),
|
|
409
|
+
protein: z.number().nonnegative(),
|
|
410
|
+
fat: z.number().nonnegative()
|
|
411
411
|
});
|
|
412
412
|
const ProductBadgeSchema = z.object({
|
|
413
413
|
id: z.string(),
|
|
@@ -419,9 +419,9 @@ const ProductVariantSchema = z.object({
|
|
|
419
419
|
images: ImageSchema.array(),
|
|
420
420
|
video: VideoSchema.optional(),
|
|
421
421
|
weightUnit: WeightUnitSchema,
|
|
422
|
-
weightValue: z.number(),
|
|
423
|
-
price: z.number(),
|
|
424
|
-
originalPrice: z.number().optional(),
|
|
422
|
+
weightValue: z.number().nonnegative(),
|
|
423
|
+
price: z.number().nonnegative(),
|
|
424
|
+
originalPrice: z.number().nonnegative().optional(),
|
|
425
425
|
sku: z.string().nullable(),
|
|
426
426
|
nutritionFacts: NutritionFactsSchema.nullable()
|
|
427
427
|
});
|
|
@@ -459,7 +459,7 @@ const MenuCategorySchema = z.object({
|
|
|
459
459
|
id: z.string(),
|
|
460
460
|
slug: z.string(),
|
|
461
461
|
title: LocaleValueSchema.array(),
|
|
462
|
-
icon: z.string().optional()
|
|
462
|
+
icon: z.string().optional(),
|
|
463
463
|
products: ProductSchema.array()
|
|
464
464
|
});
|
|
465
465
|
const MenuSchema = z.object({
|
|
@@ -485,14 +485,15 @@ const HeadStyleSchema = z.string();
|
|
|
485
485
|
const OptionsSchema = z.object({
|
|
486
486
|
selectorTitle: LocaleValueSchema.array(),
|
|
487
487
|
selectorDescription: LocaleValueSchema.array().optional(),
|
|
488
|
-
logoUrl: z.string().optional()
|
|
488
|
+
logoUrl: z.string().optional(),
|
|
489
489
|
availableLocales: LocaleSchema.array(),
|
|
490
490
|
defaultLocale: LocaleSchema,
|
|
491
491
|
countryCode: CountryCodeSchema,
|
|
492
492
|
currencyCode: CurrencyCodeSchema,
|
|
493
493
|
headLinks: HeadLinkSchema.array().optional(),
|
|
494
494
|
headScripts: HeadScriptSchema.array().optional(),
|
|
495
|
-
headStyles: HeadStyleSchema.array().optional()
|
|
495
|
+
headStyles: HeadStyleSchema.array().optional(),
|
|
496
|
+
addressSuggestEnabled: z.boolean().optional()
|
|
496
497
|
});
|
|
497
498
|
|
|
498
499
|
const DeliveryMethodSchema = z.enum([
|
|
@@ -509,8 +510,8 @@ const OrderItemSchema = z.object({
|
|
|
509
510
|
categorySlug: z.string(),
|
|
510
511
|
variantId: z.string(),
|
|
511
512
|
quantity: z.number().positive(),
|
|
512
|
-
unitPrice: z.number(),
|
|
513
|
-
totalPrice: z.number()
|
|
513
|
+
unitPrice: z.number().nonnegative(),
|
|
514
|
+
totalPrice: z.number().nonnegative()
|
|
514
515
|
// quantity × unitPrice
|
|
515
516
|
});
|
|
516
517
|
const OrderItemChangeSchema = z.object({
|
|
@@ -548,8 +549,8 @@ const OrderSchema = z.object({
|
|
|
548
549
|
/** Payment */
|
|
549
550
|
paymentMethodId: PaymentMethodSchema.shape.id,
|
|
550
551
|
/** Amount of cash that client has to pay if choose cash */
|
|
551
|
-
changeFrom: z.number().optional(),
|
|
552
|
-
totalPrice: z.number(),
|
|
552
|
+
changeFrom: z.number().nonnegative().optional(),
|
|
553
|
+
totalPrice: z.number().nonnegative(),
|
|
553
554
|
/** Client */
|
|
554
555
|
name: z.string(),
|
|
555
556
|
phone: z.string(),
|
|
@@ -558,6 +559,12 @@ const OrderSchema = z.object({
|
|
|
558
559
|
/** Items included in the order */
|
|
559
560
|
items: OrderItemSchema.array()
|
|
560
561
|
});
|
|
562
|
+
const AddressSuggestionSchema = z.object({
|
|
563
|
+
value: z.string(),
|
|
564
|
+
lat: z.number().nullable(),
|
|
565
|
+
lon: z.number().nullable(),
|
|
566
|
+
data: z.record(z.string(), z.unknown()).optional()
|
|
567
|
+
});
|
|
561
568
|
|
|
562
569
|
const GatewayActionTypeSchema = z.enum([
|
|
563
570
|
"getOptions",
|
|
@@ -572,7 +579,8 @@ const GatewayActionTypeSchema = z.enum([
|
|
|
572
579
|
"getMenu",
|
|
573
580
|
"getDeliveryByCourierStatus",
|
|
574
581
|
"getSelfPickupStatus",
|
|
575
|
-
"getTimeSlots"
|
|
582
|
+
"getTimeSlots",
|
|
583
|
+
"suggestAddresses"
|
|
576
584
|
]);
|
|
577
585
|
const GatewayRequestSchema = z.object({
|
|
578
586
|
type: GatewayActionTypeSchema,
|
|
@@ -581,7 +589,7 @@ const GatewayRequestSchema = z.object({
|
|
|
581
589
|
});
|
|
582
590
|
const BaseResponseSchema = z.object({
|
|
583
591
|
ok: z.boolean(),
|
|
584
|
-
error: z.string().
|
|
592
|
+
error: z.string().optional()
|
|
585
593
|
});
|
|
586
594
|
const GatewayGetOptionsRequestSchema = GatewayRequestSchema.extend({
|
|
587
595
|
type: z.literal("getOptions")
|
|
@@ -600,7 +608,7 @@ const GatewayGetChannelsResponseSchema = BaseResponseSchema.extend({
|
|
|
600
608
|
const GatewayGetOrderRequestSchema = GatewayRequestSchema.extend({
|
|
601
609
|
type: z.literal("getOrder"),
|
|
602
610
|
body: z.object({
|
|
603
|
-
id: z.string().optional()
|
|
611
|
+
id: z.string().optional()
|
|
604
612
|
})
|
|
605
613
|
});
|
|
606
614
|
const GatewayGetOrderResponseSchema = BaseResponseSchema.extend({
|
|
@@ -695,6 +703,17 @@ const GatewayGetTimeSlotsResponseSchema = BaseResponseSchema.extend({
|
|
|
695
703
|
type: z.literal("getTimeSlots"),
|
|
696
704
|
result: TimePeriodSchema.array()
|
|
697
705
|
});
|
|
706
|
+
const GatewaySuggestAddressesRequestSchema = GatewayRequestSchema.extend({
|
|
707
|
+
type: z.literal("suggestAddresses"),
|
|
708
|
+
body: z.object({
|
|
709
|
+
query: z.string().min(1).max(200),
|
|
710
|
+
limit: z.number().int().min(1).max(50).optional()
|
|
711
|
+
})
|
|
712
|
+
});
|
|
713
|
+
const GatewaySuggestAddressesResponseSchema = BaseResponseSchema.extend({
|
|
714
|
+
type: z.literal("suggestAddresses"),
|
|
715
|
+
result: z.array(AddressSuggestionSchema)
|
|
716
|
+
});
|
|
698
717
|
const GatewayResponseSchema = z.discriminatedUnion("type", [
|
|
699
718
|
GatewayGetOptionsResponseSchema,
|
|
700
719
|
GatewayGetChannelsResponseSchema,
|
|
@@ -708,7 +727,8 @@ const GatewayResponseSchema = z.discriminatedUnion("type", [
|
|
|
708
727
|
GatewayGetMenuResponseSchema,
|
|
709
728
|
GatewayGetDeliveryByCourierStatusResponseSchema,
|
|
710
729
|
GatewayGetSelfPickupStatusResponseSchema,
|
|
711
|
-
GatewayGetTimeSlotsResponseSchema
|
|
730
|
+
GatewayGetTimeSlotsResponseSchema,
|
|
731
|
+
GatewaySuggestAddressesResponseSchema
|
|
712
732
|
]);
|
|
713
733
|
|
|
714
|
-
export { BaseResponseSchema, ChannelSchema, CompositionIngredientSchema, CompositionProductSchema, CountryCodeSchema, CurrencyCodeSchema, DeliveryMethodSchema, GatewayActionTypeSchema, GatewayAddOrderItemRequestSchema, GatewayAddOrderItemResponseSchema, GatewayCompleteOrderRequestSchema, GatewayCompleteOrderResponseSchema, GatewayCreateOrderRequestSchema, GatewayCreateOrderResponseSchema, GatewayDecrementOrderItemQuantityRequestSchema, GatewayDecrementOrderItemQuantityResponseSchema, GatewayGetChannelsRequestSchema, GatewayGetChannelsResponseSchema, GatewayGetDeliveryByCourierStatusRequestSchema, GatewayGetDeliveryByCourierStatusResponseSchema, GatewayGetMenuRequestSchema, GatewayGetMenuResponseSchema, GatewayGetOptionsRequestSchema, GatewayGetOptionsResponseSchema, GatewayGetOrderRequestSchema, GatewayGetOrderResponseSchema, GatewayGetSelfPickupStatusRequestSchema, GatewayGetSelfPickupStatusResponseSchema, GatewayGetTimeSlotsRequestSchema, GatewayGetTimeSlotsResponseSchema, GatewayIncrementOrderItemQuantityRequestSchema, GatewayIncrementOrderItemQuantityResponseSchema, GatewayRequestSchema, GatewayResponseSchema, GatewayUpdateOrderRequestSchema, GatewayUpdateOrderResponseSchema, ImageFormatSchema, ImageSchema, ImageSizeSchema, LocaleSchema, LocaleValueSchema, MenuCategorySchema, MenuSchema, NutritionFactsSchema, OpeningStatusSchema, OptionsSchema, OrderDeliveryAddressSchema, OrderItemChangeSchema, OrderItemSchema, OrderSchema, OrderStatusSchema, OrderWarehouseAddressSchema, PaymentMethodSchema, PaymentMethodTypeSchema, ProductBadgeSchema, ProductCompositionSchema, ProductSchema, ProductVariantSchema, RecommendedProductSchema, ScheduleSchema, TimePeriodSchema, TimeSchema, TimeTypeSchema, TimeZoneSchema, VideoSchema, VideoTypeSchema, WarehouseAddressSchema, WarehouseSchema, WeekDaySchema, WeightUnitSchema };
|
|
734
|
+
export { AddressSuggestionSchema, BaseResponseSchema, ChannelSchema, CompositionIngredientSchema, CompositionProductSchema, CountryCodeSchema, CurrencyCodeSchema, DayScheduleSchema, DeliveryByCourierSchema, DeliveryMethodSchema, GatewayActionTypeSchema, GatewayAddOrderItemRequestSchema, GatewayAddOrderItemResponseSchema, GatewayCompleteOrderRequestSchema, GatewayCompleteOrderResponseSchema, GatewayCreateOrderRequestSchema, GatewayCreateOrderResponseSchema, GatewayDecrementOrderItemQuantityRequestSchema, GatewayDecrementOrderItemQuantityResponseSchema, GatewayGetChannelsRequestSchema, GatewayGetChannelsResponseSchema, GatewayGetDeliveryByCourierStatusRequestSchema, GatewayGetDeliveryByCourierStatusResponseSchema, GatewayGetMenuRequestSchema, GatewayGetMenuResponseSchema, GatewayGetOptionsRequestSchema, GatewayGetOptionsResponseSchema, GatewayGetOrderRequestSchema, GatewayGetOrderResponseSchema, GatewayGetSelfPickupStatusRequestSchema, GatewayGetSelfPickupStatusResponseSchema, GatewayGetTimeSlotsRequestSchema, GatewayGetTimeSlotsResponseSchema, GatewayIncrementOrderItemQuantityRequestSchema, GatewayIncrementOrderItemQuantityResponseSchema, GatewayRequestSchema, GatewayResponseSchema, GatewaySuggestAddressesRequestSchema, GatewaySuggestAddressesResponseSchema, GatewayUpdateOrderRequestSchema, GatewayUpdateOrderResponseSchema, HeadLinkSchema, HeadScriptSchema, HeadStyleSchema, ImageFormatSchema, ImageSchema, ImageSizeSchema, LinkSchema, LinksSchema, LocaleSchema, LocaleValueSchema, MenuCategorySchema, MenuSchema, NextOpeningSchema, NutritionFactsSchema, OpeningStatusSchema, OptionsSchema, OrderDeliveryAddressSchema, OrderItemChangeSchema, OrderItemSchema, OrderSchema, OrderStatusSchema, OrderWarehouseAddressSchema, PaymentMethodSchema, PaymentMethodTypeSchema, ProductBadgeSchema, ProductCompositionSchema, ProductSchema, ProductVariantSchema, RecommendedProductSchema, ScheduleSchema, SelfPickupSchema, TimePeriodSchema, TimeSchema, TimeTypeSchema, TimeZoneSchema, VideoSchema, VideoTypeSchema, WarehouseAddressSchema, WarehouseSchema, WeekDaySchema, WeightUnitSchema };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextorders/food-schema",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"build": "unbuild",
|
|
37
37
|
"clean": "rm -rf dist",
|
|
38
38
|
"clean:modules": "rm -rf node_modules",
|
|
39
|
-
"typecheck": "tsc --noEmit --erasableSyntaxOnly"
|
|
40
|
-
"postinstall": "pnpm build"
|
|
39
|
+
"typecheck": "tsc --noEmit --erasableSyntaxOnly"
|
|
41
40
|
}
|
|
42
41
|
}
|