@effect-agent/storage-cloudflare 0.1.0-beta.13 → 0.1.0-beta.15

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/index.mjs CHANGED
@@ -2815,7 +2815,8 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
2815
2815
  const outcome = yield* inWriteTransaction(operation, Effect.gen(function* () {
2816
2816
  const parent = yield* requireSubmission(operation, validated.parentSubmissionId);
2817
2817
  const child = yield* readSubmission(operation, validated.childSubmissionId);
2818
- if (Option.isSome(child) && child.value.state !== "settled") return yield* LedgerError.make({
2818
+ const childReservation = yield* readReservation(operation, validated.childSubmissionId);
2819
+ if (Option.isSome(child) && child.value.state !== "settled" && !(child.value.state === "terminalizing" && Option.isSome(childReservation))) return yield* LedgerError.make({
2819
2820
  operation,
2820
2821
  message: `Child submission ${validated.childSubmissionId} has no recorded settlement.`
2821
2822
  });
@@ -2829,7 +2830,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
2829
2830
  ) VALUES (
2830
2831
  ${validated.parentSubmissionId},
2831
2832
  ${validated.childSubmissionId},
2832
- ${Option.isSome(child) ? child.value.settled_outcome : null},
2833
+ ${Option.isSome(child) && child.value.state === "settled" ? child.value.settled_outcome : Option.isSome(childReservation) ? childReservation.value.outcome : null},
2833
2834
  ${now.iso}
2834
2835
  )
2835
2836
  ON CONFLICT (parent_submission_id, child_submission_id) DO NOTHING