@unchainedshop/core 4.5.0 → 4.6.0

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.
@@ -5,7 +5,6 @@ export declare const AssortmentCreatePayloadSchema: z.ZodObject<{
5
5
  _id: z.ZodString;
6
6
  specification: z.ZodObject<{
7
7
  isActive: z.ZodBoolean;
8
- isBase: z.ZodOptional<z.ZodBoolean>;
9
8
  isRoot: z.ZodOptional<z.ZodBoolean>;
10
9
  sequence: z.ZodNumber;
11
10
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -71,7 +70,6 @@ declare namespace createAssortment {
71
70
  _id: z.ZodString;
72
71
  specification: z.ZodObject<{
73
72
  isActive: z.ZodBoolean;
74
- isBase: z.ZodOptional<z.ZodBoolean>;
75
73
  isRoot: z.ZodOptional<z.ZodBoolean>;
76
74
  sequence: z.ZodNumber;
77
75
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -8,7 +8,6 @@ export const AssortmentCreatePayloadSchema = z.object({
8
8
  _id: z.string(),
9
9
  specification: z.object({
10
10
  isActive: z.boolean(),
11
- isBase: z.boolean().optional(),
12
11
  isRoot: z.boolean().optional(),
13
12
  sequence: z.number(),
14
13
  tags: z.array(z.string()).optional(),
@@ -5,7 +5,6 @@ export declare const AssortmentUpdatePayloadSchema: z.ZodObject<{
5
5
  _id: z.ZodString;
6
6
  specification: z.ZodOptional<z.ZodObject<{
7
7
  isActive: z.ZodOptional<z.ZodBoolean>;
8
- isBase: z.ZodOptional<z.ZodBoolean>;
9
8
  isRoot: z.ZodOptional<z.ZodBoolean>;
10
9
  sequence: z.ZodOptional<z.ZodNumber>;
11
10
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -72,7 +71,6 @@ declare namespace updateAssortment {
72
71
  _id: z.ZodString;
73
72
  specification: z.ZodOptional<z.ZodObject<{
74
73
  isActive: z.ZodOptional<z.ZodBoolean>;
75
- isBase: z.ZodOptional<z.ZodBoolean>;
76
74
  isRoot: z.ZodOptional<z.ZodBoolean>;
77
75
  sequence: z.ZodOptional<z.ZodNumber>;
78
76
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -10,7 +10,6 @@ export const AssortmentUpdatePayloadSchema = z.object({
10
10
  specification: z
11
11
  .object({
12
12
  isActive: z.boolean().optional(),
13
- isBase: z.boolean().optional(),
14
13
  isRoot: z.boolean().optional(),
15
14
  sequence: z.number().optional(),
16
15
  tags: z.array(z.string()).optional(),
@@ -17,8 +17,8 @@ export const ProductCreateSpecificationSchema = z.object({
17
17
  maxQuantity: z.number().optional(),
18
18
  isTaxable: z.boolean().optional(),
19
19
  isNetPrice: z.boolean().optional(),
20
- currencyCode: z.string(),
21
- countryCode: z.string(),
20
+ currencyCode: z.string().min(1, 'currencyCode is required'),
21
+ countryCode: z.string().min(1, 'countryCode is required'),
22
22
  })),
23
23
  })
24
24
  .optional(),
@@ -16,8 +16,8 @@ export const ProductUpdateSpecificationSchema = z.object({
16
16
  maxQuantity: z.number().optional(),
17
17
  isTaxable: z.boolean().optional(),
18
18
  isNetPrice: z.boolean().optional(),
19
- currencyCode: z.string(),
20
- countryCode: z.string(),
19
+ currencyCode: z.string().min(1, 'currencyCode is required'),
20
+ countryCode: z.string().min(1, 'countryCode is required'),
21
21
  })),
22
22
  })
23
23
  .optional(),
@@ -3,11 +3,14 @@ import type { EnrollmentAdapterActions, EnrollmentContext, IEnrollmentAdapter }
3
3
  import type { OrderPosition } from '@unchainedshop/core-orders';
4
4
  import type { Product } from '@unchainedshop/core-products';
5
5
  import type { Enrollment } from '@unchainedshop/core-enrollments';
6
+ import type { Modules } from '../modules.ts';
6
7
  export type IEnrollmentDirector = IBaseDirector<IEnrollmentAdapter> & {
7
8
  transformOrderItemToEnrollment: (item: {
8
9
  orderPosition: OrderPosition;
9
10
  product: Product;
10
11
  }, doc: Omit<Enrollment, 'configuration' | 'productId' | 'quantity' | 'status' | 'periods' | 'log' | '_id' | 'created'>, unchainedAPI: any) => Promise<Omit<Enrollment, 'status' | 'periods' | 'log' | '_id' | 'created'> & Pick<Partial<Enrollment>, '_id' | 'created'>>;
11
- actions: (enrollmentContext: EnrollmentContext, unchainedAPI: any) => Promise<EnrollmentAdapterActions>;
12
+ actions: (enrollmentContext: EnrollmentContext, unchainedAPI: {
13
+ modules: Modules;
14
+ }) => Promise<EnrollmentAdapterActions>;
12
15
  };
13
16
  export declare const EnrollmentDirector: IEnrollmentDirector;
@@ -150,6 +150,8 @@ export const PaymentDirector = {
150
150
  const paymentProvider = await modules.payment.paymentProviders.findProvider({
151
151
  paymentProviderId: orderPayment.paymentProviderId,
152
152
  });
153
+ if (!paymentProvider)
154
+ throw new Error('Payment provider not found: ' + orderPayment.paymentProviderId);
153
155
  const actions = await PaymentDirector.actions(paymentProvider, buildPaymentProviderActionsContext(orderPayment, {
154
156
  ...context,
155
157
  transactionContext: {
@@ -0,0 +1,3 @@
1
+ import { type Quotation } from '@unchainedshop/core-quotations';
2
+ import type { Modules } from '../modules.ts';
3
+ export declare function fulfillQuotationService(this: Modules, quotation: Quotation, info: any): Promise<Quotation>;
@@ -1,10 +1,10 @@
1
1
  import { QuotationStatus } from '@unchainedshop/core-quotations';
2
2
  import { processQuotationService } from "./processQuotation.js";
3
- export async function fullfillQuotationService(quotation, info) {
4
- if (quotation.status === QuotationStatus.FULLFILLED)
3
+ export async function fulfillQuotationService(quotation, info) {
4
+ if (quotation.status === QuotationStatus.FULFILLED)
5
5
  return quotation;
6
6
  const updatedQuotation = await this.quotations.updateStatus(quotation._id, {
7
- status: QuotationStatus.FULLFILLED,
7
+ status: QuotationStatus.FULFILLED,
8
8
  info: JSON.stringify(info),
9
9
  });
10
10
  return processQuotationService.bind(this)(updatedQuotation, {});
@@ -32,7 +32,7 @@ import { initializeEnrollmentService } from './initializeEnrollment.ts';
32
32
  import { activateEnrollmentService } from './activateEnrollment.ts';
33
33
  import { terminateEnrollmentService } from './terminateEnrollment.ts';
34
34
  import { invalidateFilterCacheService } from './invalidateFilterCache.ts';
35
- import { fullfillQuotationService } from './fullfillQuotation.ts';
35
+ import { fulfillQuotationService } from './fulfillQuotation.ts';
36
36
  import { processQuotationService } from './processQuotation.ts';
37
37
  import { proposeQuotationService } from './proposeQuotation.ts';
38
38
  import { rejectQuotationService } from './rejectQuotation.ts';
@@ -116,7 +116,7 @@ export default function initServices(modules: Modules, customServices?: CustomSe
116
116
  terminateEnrollment: Bound<typeof terminateEnrollmentService>;
117
117
  };
118
118
  quotations: {
119
- fullfillQuotation: Bound<typeof fullfillQuotationService>;
119
+ fulfillQuotation: Bound<typeof fulfillQuotationService>;
120
120
  processQuotation: Bound<typeof processQuotationService>;
121
121
  proposeQuotation: Bound<typeof proposeQuotationService>;
122
122
  rejectQuotation: Bound<typeof rejectQuotationService>;
@@ -31,7 +31,7 @@ import { initializeEnrollmentService } from "./initializeEnrollment.js";
31
31
  import { activateEnrollmentService } from "./activateEnrollment.js";
32
32
  import { terminateEnrollmentService } from "./terminateEnrollment.js";
33
33
  import { invalidateFilterCacheService } from "./invalidateFilterCache.js";
34
- import { fullfillQuotationService } from "./fullfillQuotation.js";
34
+ import { fulfillQuotationService } from "./fulfillQuotation.js";
35
35
  import { processQuotationService } from "./processQuotation.js";
36
36
  import { proposeQuotationService } from "./proposeQuotation.js";
37
37
  import { rejectQuotationService } from "./rejectQuotation.js";
@@ -127,7 +127,7 @@ export default function initServices(modules, customServices = {}) {
127
127
  terminateEnrollment: terminateEnrollmentService,
128
128
  },
129
129
  quotations: {
130
- fullfillQuotation: fullfillQuotationService,
130
+ fulfillQuotation: fulfillQuotationService,
131
131
  processQuotation: processQuotationService,
132
132
  proposeQuotation: proposeQuotationService,
133
133
  rejectQuotation: rejectQuotationService,
@@ -3,14 +3,16 @@ import { createEnrollmentFromCheckoutService } from "./createEnrollmentFromCheck
3
3
  import { ProductType } from '@unchainedshop/core-products';
4
4
  import { WarehousingProviderType } from '@unchainedshop/core-warehousing';
5
5
  import { WarehousingDirector, DeliveryDirector, PaymentDirector } from "../directors/index.js";
6
- import { fullfillQuotationService } from "./fullfillQuotation.js";
6
+ import { fulfillQuotationService } from "./fulfillQuotation.js";
7
+ import { createLogger } from '@unchainedshop/logger';
8
+ const logger = createLogger('unchained:core:processOrder');
7
9
  const isAutoConfirmationEnabled = async ({ orderPayment, orderDelivery, }, modules) => {
8
10
  if (orderPayment.status !== OrderPaymentStatus.PAID) {
9
11
  const paymentProvider = await modules.payment.paymentProviders.findProvider({
10
12
  paymentProviderId: orderPayment.paymentProviderId,
11
13
  });
12
14
  if (!paymentProvider)
13
- throw new Error('Payment provider not found: ' + orderPayment.paymentProviderId);
15
+ throw new Error(`Payment provider not found: ${orderPayment.paymentProviderId}`);
14
16
  const actions = await PaymentDirector.actions(paymentProvider, {}, { modules });
15
17
  if (!actions.isPayLaterAllowed())
16
18
  return false;
@@ -20,7 +22,7 @@ const isAutoConfirmationEnabled = async ({ orderPayment, orderDelivery, }, modul
20
22
  deliveryProviderId: orderDelivery.deliveryProviderId,
21
23
  });
22
24
  if (!deliveryProvider)
23
- throw new Error('Delivery provider not found: ' + orderDelivery.deliveryProviderId);
25
+ throw new Error(`Delivery provider not found: ${orderDelivery.deliveryProviderId}`);
24
26
  const director = await DeliveryDirector.actions(deliveryProvider, {}, { modules });
25
27
  if (!director.isAutoReleaseAllowed())
26
28
  return false;
@@ -31,7 +33,7 @@ const findNextStatus = async (status, order, modules) => {
31
33
  if (status === null) {
32
34
  return OrderStatus.PENDING;
33
35
  }
34
- if (status === OrderStatus.FULLFILLED || status === OrderStatus.REJECTED) {
36
+ if (status === OrderStatus.FULFILLED || status === OrderStatus.REJECTED) {
35
37
  return status;
36
38
  }
37
39
  const orderPayment = order.paymentId &&
@@ -52,10 +54,10 @@ const findNextStatus = async (status, order, modules) => {
52
54
  }
53
55
  }
54
56
  if (status === OrderStatus.CONFIRMED) {
55
- const readyForFullfillment = orderDelivery.status === OrderDeliveryStatus.DELIVERED &&
57
+ const readyForFulfillment = orderDelivery.status === OrderDeliveryStatus.DELIVERED &&
56
58
  orderPayment.status === OrderPaymentStatus.PAID;
57
- if (readyForFullfillment) {
58
- return OrderStatus.FULLFILLED;
59
+ if (readyForFulfillment) {
60
+ return OrderStatus.FULFILLED;
59
61
  }
60
62
  }
61
63
  return status;
@@ -125,9 +127,15 @@ export async function processOrderService(initialOrder, orderTransactionContext)
125
127
  const quotation = await this.quotations.findQuotation({
126
128
  quotationId: orderPosition.quotationId,
127
129
  });
128
- if (!quotation)
130
+ if (!quotation) {
131
+ logger.warn('Quotation not found during order fulfillment', {
132
+ orderId,
133
+ orderPositionId: orderPosition._id,
134
+ quotationId: orderPosition.quotationId,
135
+ });
129
136
  return;
130
- await fullfillQuotationService.bind(this)(quotation, {
137
+ }
138
+ await fulfillQuotationService.bind(this)(quotation, {
131
139
  orderId,
132
140
  orderPositionId: orderPosition._id,
133
141
  });
@@ -1,7 +1,7 @@
1
1
  import { QuotationStatus } from '@unchainedshop/core-quotations';
2
2
  import { processQuotationService } from "./processQuotation.js";
3
3
  export async function rejectQuotationService(quotation, { quotationContext }) {
4
- if (quotation.status === QuotationStatus.FULLFILLED)
4
+ if (quotation.status === QuotationStatus.FULFILLED)
5
5
  return quotation;
6
6
  const updatedQuotation = (await this.quotations.updateStatus(quotation._id, {
7
7
  status: QuotationStatus.REJECTED,
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/core",
3
- "version": "4.5.0",
3
+ "description": "Core orchestration package for the Unchained Engine with business services and directors",
4
+ "version": "4.6.0",
4
5
  "main": "lib/core-index.js",
5
6
  "types": "lib/core-index.d.ts",
6
7
  "type": "module",
@@ -34,25 +35,25 @@
34
35
  },
35
36
  "homepage": "https://github.com/unchainedshop/unchained#readme",
36
37
  "dependencies": {
37
- "@unchainedshop/core-assortments": "^4.5.0",
38
- "@unchainedshop/core-bookmarks": "^4.5.0",
39
- "@unchainedshop/core-countries": "^4.5.0",
40
- "@unchainedshop/core-currencies": "^4.5.0",
41
- "@unchainedshop/core-delivery": "^4.5.0",
42
- "@unchainedshop/core-enrollments": "^4.5.0",
43
- "@unchainedshop/core-events": "^4.5.0",
44
- "@unchainedshop/core-files": "^4.5.0",
45
- "@unchainedshop/core-filters": "^4.5.0",
46
- "@unchainedshop/core-languages": "^4.5.0",
47
- "@unchainedshop/core-orders": "^4.5.0",
48
- "@unchainedshop/core-payment": "^4.5.0",
49
- "@unchainedshop/core-products": "^4.5.0",
50
- "@unchainedshop/core-quotations": "^4.5.0",
51
- "@unchainedshop/core-users": "^4.5.0",
52
- "@unchainedshop/core-warehousing": "^4.5.0",
53
- "@unchainedshop/core-worker": "^4.5.0",
54
- "@unchainedshop/logger": "^4.5.0",
55
- "@unchainedshop/utils": "^4.5.0",
38
+ "@unchainedshop/core-assortments": "^4.6.0",
39
+ "@unchainedshop/core-bookmarks": "^4.6.0",
40
+ "@unchainedshop/core-countries": "^4.6.0",
41
+ "@unchainedshop/core-currencies": "^4.6.0",
42
+ "@unchainedshop/core-delivery": "^4.6.0",
43
+ "@unchainedshop/core-enrollments": "^4.6.0",
44
+ "@unchainedshop/core-events": "^4.6.0",
45
+ "@unchainedshop/core-files": "^4.6.0",
46
+ "@unchainedshop/core-filters": "^4.6.0",
47
+ "@unchainedshop/core-languages": "^4.6.0",
48
+ "@unchainedshop/core-orders": "^4.6.0",
49
+ "@unchainedshop/core-payment": "^4.6.0",
50
+ "@unchainedshop/core-products": "^4.6.0",
51
+ "@unchainedshop/core-quotations": "^4.6.0",
52
+ "@unchainedshop/core-users": "^4.6.0",
53
+ "@unchainedshop/core-warehousing": "^4.6.0",
54
+ "@unchainedshop/core-worker": "^4.6.0",
55
+ "@unchainedshop/logger": "^4.6.0",
56
+ "@unchainedshop/utils": "^4.6.0",
56
57
  "minipass-json-stream": "^1.0.2"
57
58
  },
58
59
  "devDependencies": {
@@ -1,3 +0,0 @@
1
- import { type Quotation } from '@unchainedshop/core-quotations';
2
- import type { Modules } from '../modules.ts';
3
- export declare function fullfillQuotationService(this: Modules, quotation: Quotation, info: any): Promise<Quotation>;