@absolutejs/absolute 0.20.0-beta.88 → 0.20.0-beta.89

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.js CHANGED
@@ -12722,6 +12722,17 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
12722
12722
  });
12723
12723
  return value;
12724
12724
  };
12725
+ const readHealthPause = async (channel) => {
12726
+ if (!channel.releaseId)
12727
+ return null;
12728
+ const promotionId = healthPromotionId(channel);
12729
+ const value = await readVerifiedObject(pauseKey(channel.appId, promotionId, channel.releaseId), "health pause");
12730
+ if (value === null)
12731
+ return null;
12732
+ if (!object3(value) || value.format !== 1 || value.appId !== channel.appId || value.channel !== channel.channel || value.promotionId !== promotionId || value.releaseId !== channel.releaseId || typeof value.failureRate !== "number" || !Number.isFinite(value.failureRate) || value.failureRate < 0 || value.failureRate > 1 || !Number.isSafeInteger(value.failures) || Number(value.failures) < 0 || !Number.isSafeInteger(value.reports) || Number(value.reports) < 1 || !iso(value.pausedAt))
12733
+ throw new MobileUpdateRegistryError("Stored mobile update health pause is invalid");
12734
+ return value;
12735
+ };
12725
12736
  const rolloutContext = async (channel) => {
12726
12737
  if (!options.store.list || !channel.releaseId)
12727
12738
  return null;
@@ -12753,18 +12764,31 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
12753
12764
  throw new MobileUpdateRegistryError("Stored mobile update rollout control is invalid");
12754
12765
  parsedControls.push(value);
12755
12766
  }
12767
+ parsedControls.sort((left, right) => left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id));
12756
12768
  const cancelled = parsedControls.some(({ action }) => action === "cancel");
12757
12769
  const resumedPauseIds = new Set(parsedControls.flatMap((control) => control.resumedPauseIds ?? []));
12758
- const activePauseIds = parsedControls.filter(({ action, id }) => action === "pause" && !resumedPauseIds.has(id)).map(({ id }) => id);
12770
+ const activePauseControls = parsedControls.filter(({ action, id }) => action === "pause" && !resumedPauseIds.has(id));
12771
+ const activePauseIds = activePauseControls.map(({ id }) => id);
12759
12772
  const operatorPaused = activePauseIds.length > 0;
12760
- const fleetPaused = Boolean(await options.store.head(pauseKey(channel.appId, promotionId, channel.releaseId)));
12773
+ const fleetPause = await readHealthPause(channel);
12774
+ const fleetPaused = fleetPause !== null;
12775
+ const transitionControl = parsedControls.find(({ action }) => action === "cancel") ?? activePauseControls.at(-1) ?? parsedControls.findLast(({ action }) => action === "resume");
12776
+ const latestTransition = fleetPause && (!transitionControl || fleetPause.pausedAt > transitionControl.createdAt) ? {
12777
+ activatedAt: fleetPause.pausedAt,
12778
+ activationId: digest(new TextEncoder().encode(`${promotionId}\x00fleet-pause\x00${fleetPause.pausedAt}`))
12779
+ } : transitionControl ? {
12780
+ activatedAt: transitionControl.createdAt,
12781
+ activationId: digest(new TextEncoder().encode(`${promotionId}\x00control\x00${transitionControl.id}\x00${transitionControl.action}`))
12782
+ } : undefined;
12761
12783
  return {
12784
+ ...latestTransition,
12762
12785
  cancelled,
12763
12786
  activePauseIds,
12764
12787
  channel,
12765
12788
  currentStage,
12766
12789
  enteredAt,
12767
12790
  fleetPaused,
12791
+ fleetPause,
12768
12792
  operatorPaused,
12769
12793
  plan,
12770
12794
  promotionId,
@@ -12833,6 +12857,7 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
12833
12857
  if (!channel?.releaseId)
12834
12858
  return { status: "empty" };
12835
12859
  const rolloutState = await rolloutContext(channel);
12860
+ const healthPause = rolloutState?.fleetPause ?? (health ? await readHealthPause(channel) : null);
12836
12861
  let selected = rolloutMember({
12837
12862
  appId: input.appId,
12838
12863
  channel: input.channel,
@@ -12840,7 +12865,7 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
12840
12865
  releaseId: channel.releaseId,
12841
12866
  rollout: rolloutState?.rollout ?? channel.rollout
12842
12867
  }) ? channel.releaseId : channel.fallbackReleaseId;
12843
- if (selected === channel.releaseId && (rolloutState?.cancelled || rolloutState?.fleetPaused || rolloutState?.operatorPaused || health && await options.store.head(pauseKey(input.appId, healthPromotionId(channel), channel.releaseId))))
12868
+ if (selected === channel.releaseId && (rolloutState?.cancelled || rolloutState?.fleetPaused || rolloutState?.operatorPaused || healthPause))
12844
12869
  selected = channel.fallbackReleaseId;
12845
12870
  if (!selected)
12846
12871
  return { status: "empty" };
@@ -12848,7 +12873,13 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
12848
12873
  if (!release || release.manifest.runtimeFingerprint !== input.runtimeFingerprint)
12849
12874
  return { status: "incompatible" };
12850
12875
  return {
12851
- ...selected === channel.releaseId && channel.activationId && channel.activatedAt ? {
12876
+ ...rolloutState?.activationId && rolloutState.activatedAt ? {
12877
+ activationId: rolloutState.activationId,
12878
+ activatedAt: rolloutState.activatedAt
12879
+ } : healthPause ? {
12880
+ activatedAt: healthPause.pausedAt,
12881
+ activationId: digest(new TextEncoder().encode(`${healthPromotionId(channel)}\x00fleet-pause\x00${healthPause.pausedAt}`))
12882
+ } : selected === channel.releaseId && channel.activationId && channel.activatedAt ? {
12852
12883
  activationId: channel.activationId,
12853
12884
  activatedAt: channel.activatedAt
12854
12885
  } : {},
@@ -13732,7 +13763,9 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
13732
13763
  const platform2 = request.headers.get("expo-platform");
13733
13764
  if (platform2 !== "android" && platform2 !== "ios")
13734
13765
  return new Response(null, { status: 400 });
13735
- const updateId = expoUpdateId((resolution?.status === "selected" ? resolution.activationId : undefined) ?? selected.manifest.releaseId);
13766
+ const activationId = resolution?.status === "selected" ? resolution.activationId : undefined;
13767
+ const activatedAt = resolution?.status === "selected" ? resolution.activatedAt : undefined;
13768
+ const updateId = expoUpdateId(activationId ?? selected.manifest.releaseId);
13736
13769
  if (request.headers.get("expo-current-update-id") === updateId)
13737
13770
  return new Response(null, { status: 204 });
13738
13771
  const descriptorFile = await options.registry.readUpdateFile({
@@ -13762,7 +13795,7 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
13762
13795
  };
13763
13796
  const manifest = JSON.stringify({
13764
13797
  assets: platformUpdate.assets.map((asset2) => protocolAsset(asset2)),
13765
- createdAt: (resolution?.status === "selected" ? resolution.activatedAt : undefined) ?? selected.manifest.createdAt,
13798
+ createdAt: activatedAt ?? selected.manifest.createdAt,
13766
13799
  extra: {
13767
13800
  absolutejs: {
13768
13801
  channel: selected.manifest.channel,
@@ -45534,5 +45567,5 @@ export {
45534
45567
  wrapPageHandlerWithStreamingSlots
45535
45568
  };
45536
45569
 
45537
- //# debugId=95E12D596BC2404464756E2164756E21
45570
+ //# debugId=C72C9985AAD6064264756E2164756E21
45538
45571
  //# sourceMappingURL=index.js.map