Merged PR 2000: open tasks

Related work items: #5309
This commit is contained in:
Lorenz Hilpert
2025-11-06 10:01:41 +00:00
committed by Nino Righi
parent 1d4c900d3a
commit 89b3d9aa60
136 changed files with 5088 additions and 4798 deletions

View File

@@ -1,6 +1,6 @@
import {
getOrderTypeFeature,
OrderType,
OrderTypeFeature,
ShoppingCartItem,
} from '@isa/checkout/data-access';
import {
@@ -57,47 +57,47 @@ export class GetAvailabilityParamsAdapter {
];
switch (orderType) {
case OrderType.InStore:
case OrderTypeFeature.InStore:
if (!targetBranch) {
return undefined;
}
return {
orderType: OrderType.InStore,
orderType: OrderTypeFeature.InStore,
branchId: targetBranch,
itemsIds: baseItems.map((item) => item.itemId), // Note: itemsIds is array of numbers
};
case OrderType.Pickup:
case OrderTypeFeature.Pickup:
if (!targetBranch) {
return undefined;
}
return {
orderType: OrderType.Pickup,
orderType: OrderTypeFeature.Pickup,
branchId: targetBranch,
items: baseItems,
};
case OrderType.Delivery:
case OrderTypeFeature.Delivery:
return {
orderType: OrderType.Delivery,
orderType: OrderTypeFeature.Delivery,
items: baseItems,
};
case OrderType.DigitalShipping:
case OrderTypeFeature.DigitalShipping:
return {
orderType: OrderType.DigitalShipping,
orderType: OrderTypeFeature.DigitalShipping,
items: baseItems,
};
case OrderType.B2BShipping:
case OrderTypeFeature.B2BShipping:
return {
orderType: OrderType.B2BShipping,
orderType: OrderTypeFeature.B2BShipping,
items: baseItems,
};
case OrderType.Download:
case OrderTypeFeature.Download:
return {
orderType: OrderType.Download,
orderType: OrderTypeFeature.Download,
items: baseItems.map((item) => ({
itemId: item.itemId,
ean: item.ean,
@@ -141,7 +141,7 @@ export class GetAvailabilityParamsAdapter {
// Build single-item params based on order type
switch (orderType) {
case OrderType.InStore:
case OrderTypeFeature.InStore:
if (!targetBranch) {
return undefined;
}
@@ -150,7 +150,7 @@ export class GetAvailabilityParamsAdapter {
branchId: targetBranch,
itemId: itemObj.itemId,
};
case OrderType.Pickup:
case OrderTypeFeature.Pickup:
if (!targetBranch) {
return undefined;
}
@@ -160,10 +160,10 @@ export class GetAvailabilityParamsAdapter {
item: itemObj,
};
case OrderType.Delivery:
case OrderType.DigitalShipping:
case OrderType.B2BShipping:
case OrderType.Download:
case OrderTypeFeature.Delivery:
case OrderTypeFeature.DigitalShipping:
case OrderTypeFeature.B2BShipping:
case OrderTypeFeature.Download:
return {
orderType,
item: itemObj,

View File

@@ -1,3 +1,3 @@
export * from './availability-type';
export * from './availability';
export * from './order-type';
export * from './order-type-feature';

View File

@@ -0,0 +1 @@
export { OrderTypeFeature } from '@isa/common/data-access';

View File

@@ -1 +0,0 @@
export { OrderType } from '@isa/common/data-access';

View File

@@ -1,5 +1,5 @@
import z from 'zod';
import { OrderType } from '../models';
import { OrderTypeFeature } from '../models';
import { PriceSchema } from '@isa/common/data-access';
// TODO: [Schema Refactoring - Critical Priority] Eliminate single-item schema duplication
@@ -35,7 +35,12 @@ const ItemSchema = z.object({
itemId: z.coerce.number().int().positive().describe('Unique item identifier'),
ean: z.string().describe('European Article Number barcode'),
price: PriceSchema.describe('Item price information').optional(),
quantity: z.coerce.number().int().positive().default(1).describe('Quantity of items to check availability for'),
quantity: z.coerce
.number()
.int()
.positive()
.default(1)
.describe('Quantity of items to check availability for'),
});
// Download items don't require quantity (always 1)
@@ -45,44 +50,76 @@ const DownloadItemSchema = z.object({
price: PriceSchema.describe('Item price information').optional(),
});
const ItemsSchema = z.array(ItemSchema).min(1).describe('List of items to check availability for');
const DownloadItemsSchema = z.array(DownloadItemSchema).min(1).describe('List of download items to check availability for');
const ItemsSchema = z
.array(ItemSchema)
.min(1)
.describe('List of items to check availability for');
const DownloadItemsSchema = z
.array(DownloadItemSchema)
.min(1)
.describe('List of download items to check availability for');
// In-Store availability (Rücklage) - requires branch context
export const GetInStoreAvailabilityParamsSchema = z.object({
orderType: z.literal(OrderType.InStore).describe('Order type specifying in-store availability check'),
branchId: z.coerce.number().int().positive().describe('Branch identifier for in-store availability').optional(),
itemsIds: z.array(z.coerce.number().int().positive()).min(1).describe('List of item identifiers to check in-store availability'),
orderType: z
.literal(OrderTypeFeature.InStore)
.describe('Order type specifying in-store availability check'),
branchId: z.coerce
.number()
.int()
.positive()
.describe('Branch identifier for in-store availability')
.optional(),
itemsIds: z
.array(z.coerce.number().int().positive())
.min(1)
.describe('List of item identifiers to check in-store availability'),
});
// Pickup availability (Abholung) - requires branch context
export const GetPickupAvailabilityParamsSchema = z.object({
orderType: z.literal(OrderType.Pickup).describe('Order type specifying pickup availability check'),
branchId: z.coerce.number().int().positive().describe('Branch identifier where items will be picked up'),
orderType: z
.literal(OrderTypeFeature.Pickup)
.describe('Order type specifying pickup availability check'),
branchId: z.coerce
.number()
.int()
.positive()
.describe('Branch identifier where items will be picked up'),
items: ItemsSchema,
});
// Standard delivery availability (Versand)
export const GetDeliveryAvailabilityParamsSchema = z.object({
orderType: z.literal(OrderType.Delivery).describe('Order type specifying standard delivery availability check'),
orderType: z
.literal(OrderTypeFeature.Delivery)
.describe('Order type specifying standard delivery availability check'),
items: ItemsSchema,
});
// DIG delivery availability (DIG-Versand) - for webshop customers
export const GetDigDeliveryAvailabilityParamsSchema = z.object({
orderType: z.literal(OrderType.DigitalShipping).describe('Order type specifying DIG delivery availability check for webshop customers'),
orderType: z
.literal(OrderTypeFeature.DigitalShipping)
.describe(
'Order type specifying DIG delivery availability check for webshop customers',
),
items: ItemsSchema,
});
// B2B delivery availability (B2B-Versand) - uses default branch
export const GetB2bDeliveryAvailabilityParamsSchema = z.object({
orderType: z.literal(OrderType.B2BShipping).describe('Order type specifying B2B delivery availability check'),
orderType: z
.literal(OrderTypeFeature.B2BShipping)
.describe('Order type specifying B2B delivery availability check'),
items: ItemsSchema,
});
// Download availability - quantity always 1
export const GetDownloadAvailabilityParamsSchema = z.object({
orderType: z.literal(OrderType.Download).describe('Order type specifying download availability check'),
orderType: z
.literal(OrderTypeFeature.Download)
.describe('Order type specifying download availability check'),
items: DownloadItemsSchema,
});
@@ -125,34 +162,61 @@ export type GetDownloadAvailabilityParams = z.infer<
// Single-item schemas use the same structure but accept a single item instead of an array
const SingleInStoreAvailabilityParamsSchema = z.object({
orderType: z.literal(OrderType.InStore).describe('Order type specifying in-store availability check'),
branchId: z.coerce.number().int().positive().describe('Branch identifier for in-store availability').optional(),
itemId: z.number().int().positive().describe('Unique item identifier to check in-store availability'),
orderType: z
.literal(OrderTypeFeature.InStore)
.describe('Order type specifying in-store availability check'),
branchId: z.coerce
.number()
.int()
.positive()
.describe('Branch identifier for in-store availability')
.optional(),
itemId: z
.number()
.int()
.positive()
.describe('Unique item identifier to check in-store availability'),
});
const SinglePickupAvailabilityParamsSchema = z.object({
orderType: z.literal(OrderType.Pickup).describe('Order type specifying pickup availability check'),
branchId: z.coerce.number().int().positive().describe('Branch identifier where item will be picked up'),
orderType: z
.literal(OrderTypeFeature.Pickup)
.describe('Order type specifying pickup availability check'),
branchId: z.coerce
.number()
.int()
.positive()
.describe('Branch identifier where item will be picked up'),
item: ItemSchema,
});
const SingleDeliveryAvailabilityParamsSchema = z.object({
orderType: z.literal(OrderType.Delivery).describe('Order type specifying standard delivery availability check'),
orderType: z
.literal(OrderTypeFeature.Delivery)
.describe('Order type specifying standard delivery availability check'),
item: ItemSchema,
});
const SingleDigDeliveryAvailabilityParamsSchema = z.object({
orderType: z.literal(OrderType.DigitalShipping).describe('Order type specifying DIG delivery availability check for webshop customers'),
orderType: z
.literal(OrderTypeFeature.DigitalShipping)
.describe(
'Order type specifying DIG delivery availability check for webshop customers',
),
item: ItemSchema,
});
const SingleB2bDeliveryAvailabilityParamsSchema = z.object({
orderType: z.literal(OrderType.B2BShipping).describe('Order type specifying B2B delivery availability check'),
orderType: z
.literal(OrderTypeFeature.B2BShipping)
.describe('Order type specifying B2B delivery availability check'),
item: ItemSchema,
});
const SingleDownloadAvailabilityParamsSchema = z.object({
orderType: z.literal(OrderType.Download).describe('Order type specifying download availability check'),
orderType: z
.literal(OrderTypeFeature.Download)
.describe('Order type specifying download availability check'),
item: DownloadItemSchema,
});