@open-mercato/core 0.9.1-develop.7513.1.ae2715553f → 0.9.1-develop.7515.1.e2712c8b00
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/.turbo/turbo-build.log +1 -1
- package/dist/modules/shipping_carriers/api/webhook/[provider]/route.js +4 -7
- package/dist/modules/shipping_carriers/api/webhook/[provider]/route.js.map +2 -2
- package/dist/modules/shipping_carriers/lib/shipping-service.js +29 -11
- package/dist/modules/shipping_carriers/lib/shipping-service.js.map +2 -2
- package/dist/modules/shipping_carriers/lib/status-sync.js +2 -2
- package/dist/modules/shipping_carriers/lib/status-sync.js.map +2 -2
- package/dist/modules/shipping_carriers/workers/webhook-processor.js +60 -33
- package/dist/modules/shipping_carriers/workers/webhook-processor.js.map +3 -3
- package/dist/modules/warranty_claims/commands/claim-lines.js +89 -68
- package/dist/modules/warranty_claims/commands/claim-lines.js.map +2 -2
- package/dist/modules/warranty_claims/commands/claims.js +14 -13
- package/dist/modules/warranty_claims/commands/claims.js.map +2 -2
- package/dist/modules/warranty_claims/commands/shared.js +8 -2
- package/dist/modules/warranty_claims/commands/shared.js.map +2 -2
- package/package.json +7 -7
- package/src/modules/shipping_carriers/api/webhook/[provider]/route.ts +4 -7
- package/src/modules/shipping_carriers/lib/shipping-service.ts +29 -11
- package/src/modules/shipping_carriers/lib/status-sync.ts +2 -2
- package/src/modules/shipping_carriers/workers/webhook-processor.ts +71 -39
- package/src/modules/warranty_claims/commands/claim-lines.ts +107 -66
- package/src/modules/warranty_claims/commands/claims.ts +14 -13
- package/src/modules/warranty_claims/commands/shared.ts +7 -1
|
@@ -43,7 +43,8 @@ import {
|
|
|
43
43
|
ensureOrganizationScope,
|
|
44
44
|
ensureTenantScope,
|
|
45
45
|
extractUndoPayload,
|
|
46
|
-
requireScopedClaim
|
|
46
|
+
requireScopedClaim,
|
|
47
|
+
throwUndoRefusal
|
|
47
48
|
} from "./shared.js";
|
|
48
49
|
const claimCrudEvents = {
|
|
49
50
|
module: "warranty_claims",
|
|
@@ -404,7 +405,7 @@ function restoreLineDelta(line, before, after) {
|
|
|
404
405
|
line.updatedAt = /* @__PURE__ */ new Date();
|
|
405
406
|
}
|
|
406
407
|
function throwClaimUndoConflict() {
|
|
407
|
-
|
|
408
|
+
return throwUndoRefusal("warranty_claims.errors.conflict", "This claim changed while you were editing it.");
|
|
408
409
|
}
|
|
409
410
|
async function requireCurrentUndoSnapshot(em, after) {
|
|
410
411
|
const scope = { tenantId: after.tenantId, organizationId: after.organizationId };
|
|
@@ -416,7 +417,7 @@ async function requireCurrentUndoSnapshot(em, after) {
|
|
|
416
417
|
scope
|
|
417
418
|
);
|
|
418
419
|
const expectedClaimUpdatedAt = toIso(after.updatedAt);
|
|
419
|
-
if (!claim || !expectedClaimUpdatedAt || toIso(claim.updatedAt) !== expectedClaimUpdatedAt) throwClaimUndoConflict();
|
|
420
|
+
if (!claim || !expectedClaimUpdatedAt || toIso(claim.updatedAt) !== expectedClaimUpdatedAt) return throwClaimUndoConflict();
|
|
420
421
|
const lines = await findWithDecryption(
|
|
421
422
|
em,
|
|
422
423
|
WarrantyClaimLine,
|
|
@@ -425,12 +426,12 @@ async function requireCurrentUndoSnapshot(em, after) {
|
|
|
425
426
|
scope
|
|
426
427
|
);
|
|
427
428
|
const afterLines = Array.isArray(after.lines) ? after.lines : [];
|
|
428
|
-
if (lines.length !== afterLines.length) throwClaimUndoConflict();
|
|
429
|
+
if (lines.length !== afterLines.length) return throwClaimUndoConflict();
|
|
429
430
|
const afterLinesById = new Map(afterLines.map((line) => [line.id, line]));
|
|
430
431
|
for (const line of lines) {
|
|
431
432
|
const expected = afterLinesById.get(line.id);
|
|
432
433
|
const expectedLineUpdatedAt = toIso(expected?.updatedAt);
|
|
433
|
-
if (!expectedLineUpdatedAt || toIso(line.updatedAt) !== expectedLineUpdatedAt) throwClaimUndoConflict();
|
|
434
|
+
if (!expectedLineUpdatedAt || toIso(line.updatedAt) !== expectedLineUpdatedAt) return throwClaimUndoConflict();
|
|
434
435
|
}
|
|
435
436
|
return { claim, lines };
|
|
436
437
|
}
|
|
@@ -448,7 +449,7 @@ async function restoreSnapshot(em, before, after) {
|
|
|
448
449
|
for (const line of lines) {
|
|
449
450
|
const beforeLine = beforeLinesById.get(line.id);
|
|
450
451
|
const afterLine = afterLinesById.get(line.id);
|
|
451
|
-
if (!beforeLine || !afterLine) throwClaimUndoConflict();
|
|
452
|
+
if (!beforeLine || !afterLine) return throwClaimUndoConflict();
|
|
452
453
|
if (snapshotValueChanged(beforeLine, afterLine)) restoreLineDelta(line, beforeLine, afterLine);
|
|
453
454
|
}
|
|
454
455
|
return claim;
|
|
@@ -1121,7 +1122,7 @@ const updateClaimCommand = {
|
|
|
1121
1122
|
const before = payload?.before;
|
|
1122
1123
|
if (!before) return;
|
|
1123
1124
|
const after = payload?.after;
|
|
1124
|
-
if (!after) throwClaimUndoConflict();
|
|
1125
|
+
if (!after) return throwClaimUndoConflict();
|
|
1125
1126
|
const em = ctx.container.resolve("em").fork();
|
|
1126
1127
|
let claim;
|
|
1127
1128
|
await withAtomicFlush(em, [
|
|
@@ -1184,7 +1185,7 @@ const deleteClaimCommand = {
|
|
|
1184
1185
|
const before = payload?.before;
|
|
1185
1186
|
if (!before) return;
|
|
1186
1187
|
const after = payload?.after;
|
|
1187
|
-
if (!after) throwClaimUndoConflict();
|
|
1188
|
+
if (!after) return throwClaimUndoConflict();
|
|
1188
1189
|
const em = ctx.container.resolve("em").fork();
|
|
1189
1190
|
let claim;
|
|
1190
1191
|
await withAtomicFlush(em, [
|
|
@@ -1365,7 +1366,7 @@ const transitionClaimCommand = {
|
|
|
1365
1366
|
const before = payload?.before;
|
|
1366
1367
|
if (!before) return;
|
|
1367
1368
|
const after = payload?.after;
|
|
1368
|
-
if (!after) throwClaimUndoConflict();
|
|
1369
|
+
if (!after) return throwClaimUndoConflict();
|
|
1369
1370
|
const em = ctx.container.resolve("em").fork();
|
|
1370
1371
|
let claim;
|
|
1371
1372
|
await withAtomicFlush(em, [
|
|
@@ -1464,7 +1465,7 @@ const setReturnLabelCommand = {
|
|
|
1464
1465
|
const before = payload?.before;
|
|
1465
1466
|
if (!before) return;
|
|
1466
1467
|
const after = payload?.after;
|
|
1467
|
-
if (!after) throwClaimUndoConflict();
|
|
1468
|
+
if (!after) return throwClaimUndoConflict();
|
|
1468
1469
|
const em = ctx.container.resolve("em").fork();
|
|
1469
1470
|
let claim;
|
|
1470
1471
|
await withAtomicFlush(em, [
|
|
@@ -1901,7 +1902,7 @@ const createSalesReturnCommand = {
|
|
|
1901
1902
|
const before = payload?.before;
|
|
1902
1903
|
if (!before) return;
|
|
1903
1904
|
const after = payload?.after;
|
|
1904
|
-
if (!after) throwClaimUndoConflict();
|
|
1905
|
+
if (!after) return throwClaimUndoConflict();
|
|
1905
1906
|
await assertUndoSnapshotCurrent(ctx, after);
|
|
1906
1907
|
const scope = { tenantId: before.tenantId, organizationId: before.organizationId };
|
|
1907
1908
|
const salesReturn = payload?.salesReturn ?? null;
|
|
@@ -2199,7 +2200,7 @@ const createCreditMemoCommand = {
|
|
|
2199
2200
|
const before = payload?.before;
|
|
2200
2201
|
if (!before) return;
|
|
2201
2202
|
const after = payload?.after;
|
|
2202
|
-
if (!after) throwClaimUndoConflict();
|
|
2203
|
+
if (!after) return throwClaimUndoConflict();
|
|
2203
2204
|
await assertUndoSnapshotCurrent(ctx, after);
|
|
2204
2205
|
const scope = { tenantId: before.tenantId, organizationId: before.organizationId };
|
|
2205
2206
|
const creditMemo = payload?.creditMemo ?? null;
|
|
@@ -2489,7 +2490,7 @@ const createReplacementOrderCommand = {
|
|
|
2489
2490
|
const before = payload?.before;
|
|
2490
2491
|
if (!before) return;
|
|
2491
2492
|
const after = payload?.after;
|
|
2492
|
-
if (!after) throwClaimUndoConflict();
|
|
2493
|
+
if (!after) return throwClaimUndoConflict();
|
|
2493
2494
|
await assertUndoSnapshotCurrent(ctx, after);
|
|
2494
2495
|
const scope = { tenantId: before.tenantId, organizationId: before.organizationId };
|
|
2495
2496
|
const replacementOrder = payload?.replacementOrder ?? null;
|