facturas 0.12.0 → 0.12.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.
|
@@ -3035,11 +3035,10 @@ async function runOperation(wsfe, operation, input, prepare, options, context, r
|
|
|
3035
3035
|
return "blocked" in barrier ? barrier.blocked : await claim(barrier.reserved);
|
|
3036
3036
|
}
|
|
3037
3037
|
);
|
|
3038
|
-
|
|
3039
|
-
const number = options.number ?? reserved ?? await nextNumber(wsfe, prepared.data, options);
|
|
3038
|
+
function reservation(number) {
|
|
3040
3039
|
const service = options.service ?? "wsfe";
|
|
3041
3040
|
const versioned = service === "wsmtxca" || prepared.data.details !== void 0;
|
|
3042
|
-
|
|
3041
|
+
return {
|
|
3043
3042
|
v: versioned ? 2 : 1,
|
|
3044
3043
|
operation,
|
|
3045
3044
|
...versioned ? { service } : {},
|
|
@@ -3051,19 +3050,25 @@ async function runOperation(wsfe, operation, input, prepare, options, context, r
|
|
|
3051
3050
|
sent: prepared.data,
|
|
3052
3051
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3053
3052
|
};
|
|
3053
|
+
}
|
|
3054
|
+
async function claim(reserved) {
|
|
3055
|
+
const coordinated = store.withLock !== void 0;
|
|
3056
|
+
const prior = coordinated ? await storeCall(() => store.get(key)) : null;
|
|
3057
|
+
if (prior !== null) {
|
|
3058
|
+
return await replay(prior, true);
|
|
3059
|
+
}
|
|
3060
|
+
const number = options.number ?? reserved ?? await nextNumber(wsfe, prepared.data, options);
|
|
3061
|
+
const record = reservation(number);
|
|
3062
|
+
const claimed = {
|
|
3063
|
+
v: 1,
|
|
3064
|
+
key: idempotencyKey,
|
|
3065
|
+
number,
|
|
3066
|
+
claimedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3067
|
+
};
|
|
3068
|
+
if (coordinated) {
|
|
3069
|
+
await storeCall(() => store.set(sequenceRecord, JSON.stringify(claimed)));
|
|
3070
|
+
}
|
|
3054
3071
|
if (await storeCall(() => store.add(key, JSON.stringify(record)))) {
|
|
3055
|
-
const claimed = {
|
|
3056
|
-
v: 1,
|
|
3057
|
-
key: idempotencyKey,
|
|
3058
|
-
number,
|
|
3059
|
-
claimedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3060
|
-
};
|
|
3061
|
-
const coordinated = store.withLock !== void 0;
|
|
3062
|
-
if (coordinated) {
|
|
3063
|
-
await storeCall(
|
|
3064
|
-
() => store.set(sequenceRecord, JSON.stringify(claimed))
|
|
3065
|
-
);
|
|
3066
|
-
}
|
|
3067
3072
|
const outcome = await settle(
|
|
3068
3073
|
runAuthorization(wsfe, prepared, options, number)
|
|
3069
3074
|
);
|
|
@@ -3839,10 +3844,11 @@ async function runSequenceBarrier({
|
|
|
3839
3844
|
if (reservation === null) {
|
|
3840
3845
|
return {};
|
|
3841
3846
|
}
|
|
3847
|
+
const record = readRecord(reservation);
|
|
3842
3848
|
const blocked = {
|
|
3843
3849
|
blocked: {
|
|
3844
3850
|
kind: "indeterminate",
|
|
3845
|
-
attempted: { ...coordinates, number:
|
|
3851
|
+
attempted: { ...coordinates, number: record.number },
|
|
3846
3852
|
attempt: replayEvidence(options.service),
|
|
3847
3853
|
lookup: { kind: "blocked", by: claimed.key }
|
|
3848
3854
|
}
|
|
@@ -3850,7 +3856,7 @@ async function runSequenceBarrier({
|
|
|
3850
3856
|
const outcome = await recordConflict(
|
|
3851
3857
|
store,
|
|
3852
3858
|
settled,
|
|
3853
|
-
await consultReservation(select,
|
|
3859
|
+
await consultReservation(select, record, {
|
|
3854
3860
|
forceRefresh: options.forceRefresh,
|
|
3855
3861
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
3856
3862
|
})
|
|
@@ -3862,7 +3868,7 @@ async function runSequenceBarrier({
|
|
|
3862
3868
|
return blocked;
|
|
3863
3869
|
}
|
|
3864
3870
|
const next = await readNext();
|
|
3865
|
-
if (next !==
|
|
3871
|
+
if (next !== record.number) {
|
|
3866
3872
|
return blocked;
|
|
3867
3873
|
}
|
|
3868
3874
|
await storeCall(
|
|
@@ -3871,7 +3877,7 @@ async function runSequenceBarrier({
|
|
|
3871
3877
|
JSON.stringify({
|
|
3872
3878
|
v: 1,
|
|
3873
3879
|
kind: "superseded",
|
|
3874
|
-
number:
|
|
3880
|
+
number: record.number,
|
|
3875
3881
|
by: supersededBy,
|
|
3876
3882
|
settledAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3877
3883
|
})
|
|
@@ -4240,4 +4246,4 @@ export {
|
|
|
4240
4246
|
withLease,
|
|
4241
4247
|
createFileStore
|
|
4242
4248
|
};
|
|
4243
|
-
//# sourceMappingURL=chunk-
|
|
4249
|
+
//# sourceMappingURL=chunk-2PYF5JFG.mjs.map
|