washday-sdk 1.6.65 → 1.6.67

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/api/index.js CHANGED
@@ -154,6 +154,7 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
154
154
  sendOrderUncollectedCustomerNotification: ordersEndpoints.postModule.sendOrderUncollectedCustomerNotification,
155
155
  recordFailedServiceAttempt: ordersEndpoints.postModule.recordFailedServiceAttempt,
156
156
  deletePaymentLineById: ordersEndpoints.deleteModule.deletePaymentLineById,
157
+ deleteOrderEvidence: ordersEndpoints.deleteModule.deleteOrderEvidence,
157
158
  getListCustomersApp: ordersEndpoints.getModule.getListCustomersApp,
158
159
  getByIdCustomersApp: ordersEndpoints.getModule.getByIdCustomersApp,
159
160
  setOrderAcceptedBySequence: ordersEndpoints.putModule.setOrderAcceptedBySequence,
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  const GET_SET_ORDER_PAYMENTLINES = (orderId) => `/api/v2/order/${orderId}/paymentLines`;
11
+ const GET_SET_ORDER = 'api/v2/order';
11
12
  const GET_SET_ORDER_CUSTOMERS_APP = 'api/v2/washdayapp/orders';
12
13
  export const deletePaymentLineById = function (orderId, id) {
13
14
  return __awaiter(this, void 0, void 0, function* () {
@@ -23,6 +24,20 @@ export const deletePaymentLineById = function (orderId, id) {
23
24
  }
24
25
  });
25
26
  };
27
+ export const deleteOrderEvidence = function (orderId, evidenceId) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ try {
30
+ const config = {
31
+ headers: { Authorization: `Bearer ${this.apiToken}` }
32
+ };
33
+ return yield this.axiosInstance.delete(`${GET_SET_ORDER}/${orderId}/evidence/${evidenceId}`, config);
34
+ }
35
+ catch (error) {
36
+ console.error('Error fetching deleteOrderEvidence:', error);
37
+ throw error;
38
+ }
39
+ });
40
+ };
26
41
  export const cancelOrderByIdCustomersApp = function (id) {
27
42
  return __awaiter(this, void 0, void 0, function* () {
28
43
  try {
@@ -18,6 +18,21 @@ export var PaymentMethodsEnum;
18
18
  PaymentMethodsEnum["Delivery"] = "delivery";
19
19
  PaymentMethodsEnum["Transfer"] = "transfer";
20
20
  })(PaymentMethodsEnum || (PaymentMethodsEnum = {}));
21
+ export var OrderStatusEnum;
22
+ (function (OrderStatusEnum) {
23
+ OrderStatusEnum["CREATED"] = "created";
24
+ OrderStatusEnum["REQUESTED"] = "requested";
25
+ OrderStatusEnum["PICKUP"] = "pickup";
26
+ OrderStatusEnum["PICKINGUP"] = "pickingup";
27
+ OrderStatusEnum["PENDING_STORE_RECEPTION_VALIDATION"] = "pending_store_reception_validation";
28
+ OrderStatusEnum["CLEANING"] = "cleaning";
29
+ OrderStatusEnum["READY"] = "ready";
30
+ OrderStatusEnum["DELIVERY"] = "delivery";
31
+ OrderStatusEnum["DELIVERING"] = "delivering";
32
+ OrderStatusEnum["COLLECTED"] = "collected";
33
+ OrderStatusEnum["CANCELLED"] = "cancelled";
34
+ OrderStatusEnum["UNCOLLECTED"] = "uncollected";
35
+ })(OrderStatusEnum || (OrderStatusEnum = {}));
21
36
  export var OrderProductLineStatus;
22
37
  (function (OrderProductLineStatus) {
23
38
  OrderProductLineStatus["Created"] = "created";
package/dist/index.js CHANGED
@@ -8,4 +8,9 @@ export * from './interfaces/Customer';
8
8
  export * from './interfaces/DomainUrls';
9
9
  export * from './interfaces/GoogleMaps';
10
10
  export * from './interfaces/Attendance';
11
+ export * from './interfaces/Order';
12
+ export * from './interfaces/Store';
13
+ export * from './interfaces/Permission';
14
+ export * from './interfaces/Route';
15
+ export * from './enum';
11
16
  export { WashdayClient, utils };
@@ -0,0 +1,62 @@
1
+ var _a, _b, _c;
2
+ import { OrderStatusEnum } from "../index";
3
+ const updatePayload = {
4
+ notes: "Peso confirmado en sucursal",
5
+ updateMode: "store_reception_validation",
6
+ };
7
+ const order = {
8
+ status: OrderStatusEnum.PENDING_STORE_RECEPTION_VALIDATION,
9
+ storeReceptionValidation: {
10
+ validatedAt: "2026-06-01T18:00:00.000Z",
11
+ validatedBy: "user-1",
12
+ source: "store_reception",
13
+ notes: "Validado en mostrador",
14
+ },
15
+ };
16
+ const permission = {
17
+ validateStoreReception: {
18
+ canMutate: true,
19
+ },
20
+ };
21
+ const store = {
22
+ storeReceptionValidationConfig: {
23
+ enabled: true,
24
+ restrictCloseRouteUntilStoreValidation: false,
25
+ },
26
+ };
27
+ const preview = {
28
+ routeId: "route-1",
29
+ canClose: true,
30
+ summary: {
31
+ confirmed: 0,
32
+ failed: 0,
33
+ cancelled: 0,
34
+ pendingActive: 0,
35
+ },
36
+ pendingActiveOrders: [],
37
+ requiresExplicitConfirmation: false,
38
+ hasPendingStoreReceptionValidations: true,
39
+ pendingStoreReceptionValidationOrdersCount: 1,
40
+ restrictCloseRouteUntilStoreValidation: false,
41
+ warnings: [
42
+ "Esta ruta tiene pedidos pendientes de validar en sucursal.",
43
+ ],
44
+ };
45
+ if (OrderStatusEnum.PENDING_STORE_RECEPTION_VALIDATION !== "pending_store_reception_validation") {
46
+ throw new Error("Pending store reception validation order status is not exported");
47
+ }
48
+ if (updatePayload.updateMode !== "store_reception_validation") {
49
+ throw new Error("Store reception validation update mode is not accepted");
50
+ }
51
+ if (((_a = order.storeReceptionValidation) === null || _a === void 0 ? void 0 : _a.source) !== "store_reception") {
52
+ throw new Error("Order store reception validation source was not preserved");
53
+ }
54
+ if (((_b = permission.validateStoreReception) === null || _b === void 0 ? void 0 : _b.canMutate) !== true) {
55
+ throw new Error("Validate store reception permission was not preserved");
56
+ }
57
+ if (((_c = store.storeReceptionValidationConfig) === null || _c === void 0 ? void 0 : _c.enabled) !== true) {
58
+ throw new Error("Store reception validation config was not preserved");
59
+ }
60
+ if (preview.pendingStoreReceptionValidationOrdersCount !== 1) {
61
+ throw new Error("Route close preview pending validation count was not preserved");
62
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.6.65",
3
+ "version": "1.6.67",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/api/index.ts CHANGED
@@ -161,6 +161,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
161
161
  sendOrderUncollectedCustomerNotification: ordersEndpoints.postModule.sendOrderUncollectedCustomerNotification,
162
162
  recordFailedServiceAttempt: ordersEndpoints.postModule.recordFailedServiceAttempt,
163
163
  deletePaymentLineById: ordersEndpoints.deleteModule.deletePaymentLineById,
164
+ deleteOrderEvidence: ordersEndpoints.deleteModule.deleteOrderEvidence,
164
165
  getListCustomersApp: ordersEndpoints.getModule.getListCustomersApp,
165
166
  getByIdCustomersApp: ordersEndpoints.getModule.getByIdCustomersApp,
166
167
  setOrderAcceptedBySequence: ordersEndpoints.putModule.setOrderAcceptedBySequence,
@@ -1,6 +1,7 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
2
  import axiosInstance from "../axiosInstance";
3
3
  const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
4
+ const GET_SET_ORDER = 'api/v2/order';
4
5
  const GET_SET_ORDER_CUSTOMERS_APP = 'api/v2/washdayapp/orders';
5
6
 
6
7
  export const deletePaymentLineById = async function (this: WashdayClientInstance, orderId: string, id: string): Promise<any> {
@@ -15,6 +16,18 @@ export const deletePaymentLineById = async function (this: WashdayClientInstance
15
16
  }
16
17
  };
17
18
 
19
+ export const deleteOrderEvidence = async function (this: WashdayClientInstance, orderId: string, evidenceId: string): Promise<any> {
20
+ try {
21
+ const config = {
22
+ headers: { Authorization: `Bearer ${this.apiToken}` }
23
+ };
24
+ return await this.axiosInstance.delete(`${GET_SET_ORDER}/${orderId}/evidence/${evidenceId}`, config);
25
+ } catch (error) {
26
+ console.error('Error fetching deleteOrderEvidence:', error);
27
+ throw error;
28
+ }
29
+ };
30
+
18
31
 
19
32
  export const cancelOrderByIdCustomersApp = async function (this: WashdayClientInstance, id: string): Promise<any> {
20
33
  try {
@@ -1,34 +1,13 @@
1
1
  import { AxiosResponse } from "axios";
2
2
  import { WashdayClientInstance } from "../../interfaces/Api";
3
+ import { IUpdateOrderByIdDto } from "../../interfaces/Order";
3
4
  import axiosInstance from "../axiosInstance";
4
5
  import { generateQueryParamsStr } from "../../utils/apiUtils";
5
6
  const GET_SET_ORDER = 'api/v2/order';
6
7
  const GET_SET_ORDER_OLD = 'api/order';
7
8
  const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
8
9
 
9
- export const updateById = async function (this: WashdayClientInstance, id: string, data: {
10
- status?: string,
11
- products?: any[],
12
- buyAndGetProducts?: any[],
13
- customer?: string,
14
- discountCode?: string | null,
15
- notes?: string,
16
- privateNotes?: string,
17
- delivery?: boolean,
18
- pickup?: boolean,
19
- express?: boolean,
20
- deliveryInfo?: {
21
- date: Date,
22
- fromTime: string,
23
- toTime?: string
24
- },
25
- pickupInfo?: {
26
- date: Date,
27
- fromTime: string,
28
- toTime?: string
29
- },
30
- notifyBy?: string,
31
- }): Promise<any> {
10
+ export const updateById = async function (this: WashdayClientInstance, id: string, data: IUpdateOrderByIdDto): Promise<any> {
32
11
  try {
33
12
  const config = {
34
13
  headers: { Authorization: `Bearer ${this.apiToken}` }
@@ -221,4 +200,4 @@ export const bulkCollect = async function (this: WashdayClientInstance, storeId:
221
200
  console.error('Error fetching bulkCollect:', error);
222
201
  throw error;
223
202
  }
224
- };
203
+ };
package/src/enum/index.ts CHANGED
@@ -18,6 +18,21 @@ export enum PaymentMethodsEnum {
18
18
  Transfer = "transfer",
19
19
  }
20
20
 
21
+ export enum OrderStatusEnum {
22
+ CREATED = 'created',
23
+ REQUESTED = 'requested',
24
+ PICKUP = 'pickup',
25
+ PICKINGUP = 'pickingup',
26
+ PENDING_STORE_RECEPTION_VALIDATION = 'pending_store_reception_validation',
27
+ CLEANING = 'cleaning',
28
+ READY = 'ready',
29
+ DELIVERY = 'delivery',
30
+ DELIVERING = 'delivering',
31
+ COLLECTED = 'collected',
32
+ CANCELLED = 'cancelled',
33
+ UNCOLLECTED = 'uncollected',
34
+ }
35
+
21
36
  export enum OrderProductLineStatus {
22
37
  Created = 'created',
23
38
  Cleaning = 'cleaning',
@@ -25,4 +40,4 @@ export enum OrderProductLineStatus {
25
40
  Collected = 'collected',
26
41
  Uncollected = 'uncollected',
27
42
  Cancelled = 'cancelled',
28
- }
43
+ }
package/src/index.ts CHANGED
@@ -8,13 +8,11 @@ export * from './interfaces/Customer';
8
8
  export * from './interfaces/DomainUrls';
9
9
  export * from './interfaces/GoogleMaps';
10
10
  export * from './interfaces/Attendance';
11
- export type {
12
- IOrderPricingSnapshot,
13
- IOrderPricingSnapshotLine,
14
- IOrderPricingSnapshotTotals,
15
- ITaxBreakdownItem,
16
- TaxBreakdownKey,
17
- } from './interfaces/Order';
11
+ export * from './interfaces/Order';
12
+ export * from './interfaces/Store';
13
+ export * from './interfaces/Permission';
14
+ export * from './interfaces/Route';
15
+ export * from './enum';
18
16
  export type { StartMPOAuthFlowRequest } from './api/integrations/post';
19
17
  export type {
20
18
  CreateCFDISubscriptionCheckoutSessionRequest,
@@ -146,6 +146,7 @@ export interface WashdayClientInstance {
146
146
  sendOrderUncollectedCustomerNotification: typeof ordersEndpoints.postModule.sendOrderUncollectedCustomerNotification,
147
147
  recordFailedServiceAttempt: typeof ordersEndpoints.postModule.recordFailedServiceAttempt,
148
148
  deletePaymentLineById: typeof ordersEndpoints.deleteModule.deletePaymentLineById;
149
+ deleteOrderEvidence: typeof ordersEndpoints.deleteModule.deleteOrderEvidence;
149
150
  getListCustomersApp: typeof ordersEndpoints.getModule.getListCustomersApp;
150
151
  getByIdCustomersApp: typeof ordersEndpoints.getModule.getByIdCustomersApp;
151
152
  setOrderAcceptedBySequence: typeof ordersEndpoints.putModule.setOrderAcceptedBySequence,
@@ -2,7 +2,7 @@ import { ICustomer } from "./Customer";
2
2
  import { IOrderProduct, IProduct } from "./Product";
3
3
  import { ICashierBox, IStore, IStoreDiscount, ITaxConfig } from "./Store";
4
4
  import { IUser } from "./User";
5
- import { OrderProductLineStatus } from "../enum";
5
+ import { OrderProductLineStatus, OrderStatusEnum } from "../enum";
6
6
  import { RouteOrderCompletionSource } from "./Route";
7
7
 
8
8
  interface IDeliveryInfo {
@@ -34,6 +34,20 @@ export interface IFailedServiceAttemptPayload {
34
34
  images?: string[];
35
35
  }
36
36
 
37
+ export type OrderStatus = OrderStatusEnum | (string & {});
38
+
39
+ export type StoreReceptionValidationSource =
40
+ | "store_reception"
41
+ | "route_pickup_handoff"
42
+ | "legacy_unknown";
43
+
44
+ export interface IOrderStoreReceptionValidation {
45
+ validatedAt?: string | Date | null;
46
+ validatedBy?: string | null;
47
+ source?: StoreReceptionValidationSource | null;
48
+ notes?: string;
49
+ }
50
+
37
51
  export interface IOrderPaymentLines {
38
52
  _id?: any,
39
53
  amountPaid: number,
@@ -46,6 +60,16 @@ export interface IOrderPaymentLines {
46
60
  facturapiPaymentInvoiceID?: string | null,
47
61
  }
48
62
 
63
+ export interface IOrderEvidence {
64
+ _id?: any,
65
+ url: string,
66
+ cloudinaryPublicId?: string,
67
+ notes?: string,
68
+ type: 'pickup' | 'delivery' | 'signature' | 'other',
69
+ createdBy: IUser | string,
70
+ uploadedAt: Date,
71
+ }
72
+
49
73
  export type TaxBreakdownKey = "taxOne" | "taxTwo" | "taxThree";
50
74
 
51
75
  export interface ITaxBreakdownItem {
@@ -151,11 +175,12 @@ export interface IOrder {
151
175
  paidDateTime: Date | null,
152
176
  paymentMethod: string | null
153
177
  prepaidPaymentMethod: string | null
154
- status: string,
178
+ status: OrderStatus,
155
179
  pickupRoute: string | null,
156
180
  deliveryRoute: string | null,
157
181
  pickupCompletion?: IOrderPhaseCompletion | null,
158
182
  deliveryCompletion?: IOrderPhaseCompletion | null,
183
+ storeReceptionValidation?: IOrderStoreReceptionValidation,
159
184
  sequence?: string | null,
160
185
  notifyBy: string,
161
186
  stripePaymentIntentId?: string | null,
@@ -165,10 +190,38 @@ export interface IOrder {
165
190
  appliedStoreDiscounts: Array<string> | null,
166
191
  appliedDiscountCodes: Array<string> | null,
167
192
  paymentLines: Array<IOrderPaymentLines> | Array<string> | any,
193
+ evidence?: Array<IOrderEvidence>,
168
194
  facturapiInvoiceID?: string | null,
169
195
  pricingSnapshot?: IOrderPricingSnapshot | null,
170
196
  }
171
197
 
198
+ export type OrderUpdateMode = "store_reception_validation";
199
+
200
+ export interface IUpdateOrderByIdDto {
201
+ status?: OrderStatus,
202
+ products?: any[],
203
+ buyAndGetProducts?: any[],
204
+ customer?: string,
205
+ discountCode?: string | null,
206
+ notes?: string,
207
+ privateNotes?: string,
208
+ delivery?: boolean,
209
+ pickup?: boolean,
210
+ express?: boolean,
211
+ deliveryInfo?: {
212
+ date: Date,
213
+ fromTime: string,
214
+ toTime?: string
215
+ },
216
+ pickupInfo?: {
217
+ date: Date,
218
+ fromTime: string,
219
+ toTime?: string
220
+ },
221
+ notifyBy?: string,
222
+ updateMode?: OrderUpdateMode,
223
+ }
224
+
172
225
 
173
226
  /**
174
227
  * A single line status update within a batch request.
@@ -219,7 +272,7 @@ export interface OrderDto {
219
272
  collectedDateTime: Date | null,
220
273
  cancelledDateTime: Date | null,
221
274
  paidDateTime: Date | null,
222
- status: string,
275
+ status: OrderStatus,
223
276
  store: string,
224
277
  paymentMethod: string | null,
225
278
  prepaidAmount: number | null,
@@ -15,6 +15,7 @@ export interface IPermission {
15
15
  canEditOrders: IPermissionMutationType,
16
16
  canManageAttendance: IPermissionMutationType,
17
17
  mutateOrderPayments: IPermissionMutationType,
18
+ validateStoreReception?: IPermissionMutationType,
18
19
  markOrderAsCollectedWithPendingAmount: IPermissionMutationType,
19
20
  markOrderAsUncollected: IPermissionMutationType,
20
21
  cancelOrders: IPermissionMutationType,
@@ -1,6 +1,6 @@
1
- import { IOrder } from "./Order";
2
- import { IStore } from "./Store";
3
- import { IUser } from "./User";
1
+ import type { IOrder, OrderStatus } from "./Order";
2
+ import type { IStore } from "./Store";
3
+ import type { IUser } from "./User";
4
4
 
5
5
  export type RouteStatus = "created" | "in_progress" | "finished" | "cancelled";
6
6
  export type RouteOrderType = "pickup" | "delivery" | "legacy_unknown";
@@ -54,8 +54,8 @@ export interface IRouteClosePreviewPendingOrder {
54
54
  orderId: string;
55
55
  type: RouteOrderType;
56
56
  sequence?: string | number | null;
57
- status?: string | null;
58
- willBecome?: string | null;
57
+ status?: OrderStatus | null;
58
+ willBecome?: OrderStatus | null;
59
59
  }
60
60
 
61
61
  export interface IRouteClosePreview {
@@ -69,4 +69,8 @@ export interface IRouteClosePreview {
69
69
  };
70
70
  pendingActiveOrders: IRouteClosePreviewPendingOrder[];
71
71
  requiresExplicitConfirmation: boolean;
72
+ hasPendingStoreReceptionValidations?: boolean;
73
+ pendingStoreReceptionValidationOrdersCount?: number;
74
+ restrictCloseRouteUntilStoreValidation?: boolean;
75
+ warnings?: string[];
72
76
  }
@@ -52,6 +52,11 @@ export interface IPublicReceiptConfig {
52
52
  showEvidence?: boolean
53
53
  }
54
54
 
55
+ export interface IStoreReceptionValidationConfig {
56
+ enabled: boolean,
57
+ restrictCloseRouteUntilStoreValidation: boolean,
58
+ }
59
+
55
60
  export interface IStore {
56
61
  name: string,
57
62
  streetAddress?: string,
@@ -90,6 +95,7 @@ export interface IStore {
90
95
  ticketForLaundryStructure?: ITicketForLaundryStructure | null,
91
96
  labelTicketStructure?: ILabelTicketStructure | null,
92
97
  publicReceiptConfig?: IPublicReceiptConfig,
98
+ storeReceptionValidationConfig?: IStoreReceptionValidationConfig,
93
99
  ticketScanMode?: 'order' | 'customer',
94
100
  storeDiscounts: IStoreDiscount | null,
95
101
  discountCodes: IDiscountCode | null,
@@ -0,0 +1,79 @@
1
+ import { OrderStatusEnum } from "../index";
2
+ import type {
3
+ IOrder,
4
+ IPermission,
5
+ IRouteClosePreview,
6
+ IStore,
7
+ IUpdateOrderByIdDto,
8
+ } from "../index";
9
+
10
+ const updatePayload: IUpdateOrderByIdDto = {
11
+ notes: "Peso confirmado en sucursal",
12
+ updateMode: "store_reception_validation",
13
+ };
14
+
15
+ const order: Partial<IOrder> = {
16
+ status: OrderStatusEnum.PENDING_STORE_RECEPTION_VALIDATION,
17
+ storeReceptionValidation: {
18
+ validatedAt: "2026-06-01T18:00:00.000Z",
19
+ validatedBy: "user-1",
20
+ source: "store_reception",
21
+ notes: "Validado en mostrador",
22
+ },
23
+ };
24
+
25
+ const permission: Partial<IPermission> = {
26
+ validateStoreReception: {
27
+ canMutate: true,
28
+ },
29
+ };
30
+
31
+ const store: Partial<IStore> = {
32
+ storeReceptionValidationConfig: {
33
+ enabled: true,
34
+ restrictCloseRouteUntilStoreValidation: false,
35
+ },
36
+ };
37
+
38
+ const preview: IRouteClosePreview = {
39
+ routeId: "route-1",
40
+ canClose: true,
41
+ summary: {
42
+ confirmed: 0,
43
+ failed: 0,
44
+ cancelled: 0,
45
+ pendingActive: 0,
46
+ },
47
+ pendingActiveOrders: [],
48
+ requiresExplicitConfirmation: false,
49
+ hasPendingStoreReceptionValidations: true,
50
+ pendingStoreReceptionValidationOrdersCount: 1,
51
+ restrictCloseRouteUntilStoreValidation: false,
52
+ warnings: [
53
+ "Esta ruta tiene pedidos pendientes de validar en sucursal.",
54
+ ],
55
+ };
56
+
57
+ if (OrderStatusEnum.PENDING_STORE_RECEPTION_VALIDATION !== "pending_store_reception_validation") {
58
+ throw new Error("Pending store reception validation order status is not exported");
59
+ }
60
+
61
+ if (updatePayload.updateMode !== "store_reception_validation") {
62
+ throw new Error("Store reception validation update mode is not accepted");
63
+ }
64
+
65
+ if (order.storeReceptionValidation?.source !== "store_reception") {
66
+ throw new Error("Order store reception validation source was not preserved");
67
+ }
68
+
69
+ if (permission.validateStoreReception?.canMutate !== true) {
70
+ throw new Error("Validate store reception permission was not preserved");
71
+ }
72
+
73
+ if (store.storeReceptionValidationConfig?.enabled !== true) {
74
+ throw new Error("Store reception validation config was not preserved");
75
+ }
76
+
77
+ if (preview.pendingStoreReceptionValidationOrdersCount !== 1) {
78
+ throw new Error("Route close preview pending validation count was not preserved");
79
+ }
@@ -0,0 +1,37 @@
1
+ import { deleteOrderEvidence } from "../src/api/order/delete";
2
+
3
+ describe("orders.deleteOrderEvidence", () => {
4
+ it("deletes order evidence with the expected URL and auth header", async () => {
5
+ const deleteRequest = jest.fn().mockResolvedValue({
6
+ data: {
7
+ data: {
8
+ deleted: true,
9
+ evidenceId: "evidence-1",
10
+ cloudinaryResult: "ok",
11
+ },
12
+ },
13
+ });
14
+ const client = {
15
+ apiToken: "token-123",
16
+ axiosInstance: { delete: deleteRequest },
17
+ } as any;
18
+
19
+ const result = await deleteOrderEvidence.call(client, "order-1", "evidence-1");
20
+
21
+ expect(deleteRequest).toHaveBeenCalledWith(
22
+ "api/v2/order/order-1/evidence/evidence-1",
23
+ {
24
+ headers: { Authorization: "Bearer token-123" },
25
+ }
26
+ );
27
+ expect(result).toEqual({
28
+ data: {
29
+ data: {
30
+ deleted: true,
31
+ evidenceId: "evidence-1",
32
+ cloudinaryResult: "ok",
33
+ },
34
+ },
35
+ });
36
+ });
37
+ });
@@ -0,0 +1,89 @@
1
+ import { updateById } from "../src/api/order/put";
2
+ import { OrderStatusEnum } from "../src";
3
+ import type {
4
+ IOrder,
5
+ IPermission,
6
+ IRouteClosePreview,
7
+ IStore,
8
+ IUpdateOrderByIdDto,
9
+ } from "../src";
10
+
11
+ describe("store reception validation SDK contract", () => {
12
+ it("exposes store reception validation contracts from the root package", () => {
13
+ const updatePayload: IUpdateOrderByIdDto = {
14
+ notes: "Peso confirmado en sucursal",
15
+ updateMode: "store_reception_validation",
16
+ };
17
+ const order: Partial<IOrder> = {
18
+ status: OrderStatusEnum.PENDING_STORE_RECEPTION_VALIDATION,
19
+ storeReceptionValidation: {
20
+ validatedAt: "2026-06-01T18:00:00.000Z",
21
+ validatedBy: "user-1",
22
+ source: "store_reception",
23
+ notes: "Validado en mostrador",
24
+ },
25
+ };
26
+ const permission: Partial<IPermission> = {
27
+ validateStoreReception: {
28
+ canMutate: true,
29
+ },
30
+ };
31
+ const store: Partial<IStore> = {
32
+ storeReceptionValidationConfig: {
33
+ enabled: true,
34
+ restrictCloseRouteUntilStoreValidation: false,
35
+ },
36
+ };
37
+ const preview: IRouteClosePreview = {
38
+ routeId: "route-1",
39
+ canClose: true,
40
+ summary: {
41
+ confirmed: 0,
42
+ failed: 0,
43
+ cancelled: 0,
44
+ pendingActive: 0,
45
+ },
46
+ pendingActiveOrders: [],
47
+ requiresExplicitConfirmation: false,
48
+ hasPendingStoreReceptionValidations: true,
49
+ pendingStoreReceptionValidationOrdersCount: 1,
50
+ restrictCloseRouteUntilStoreValidation: false,
51
+ warnings: [
52
+ "Esta ruta tiene pedidos pendientes de validar en sucursal.",
53
+ ],
54
+ };
55
+
56
+ expect(OrderStatusEnum.PENDING_STORE_RECEPTION_VALIDATION).toBe(
57
+ "pending_store_reception_validation"
58
+ );
59
+ expect(updatePayload.updateMode).toBe("store_reception_validation");
60
+ expect(order.storeReceptionValidation?.source).toBe("store_reception");
61
+ expect(permission.validateStoreReception?.canMutate).toBe(true);
62
+ expect(store.storeReceptionValidationConfig?.enabled).toBe(true);
63
+ expect(preview.pendingStoreReceptionValidationOrdersCount).toBe(1);
64
+ });
65
+
66
+ it("passes store reception validation update mode through updateById unchanged", async () => {
67
+ const put = jest.fn().mockResolvedValue({
68
+ data: {
69
+ data: {
70
+ _id: "order-1",
71
+ },
72
+ },
73
+ });
74
+ const client = {
75
+ apiToken: "token-123",
76
+ axiosInstance: { put },
77
+ } as any;
78
+ const payload: IUpdateOrderByIdDto = {
79
+ notes: "Peso ajustado",
80
+ updateMode: "store_reception_validation",
81
+ };
82
+
83
+ await updateById.call(client, "order-1", payload);
84
+
85
+ expect(put).toHaveBeenCalledWith("api/v2/order/order-1", payload, {
86
+ headers: { Authorization: "Bearer token-123" },
87
+ });
88
+ });
89
+ });