@sevenfold/setto-client 0.2.7 → 0.2.8

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.
@@ -9,6 +9,8 @@ export declare const STALE_BUILDING_MS: number;
9
9
  export declare function isDeploymentStale(row: Pick<DeploymentRow, 'status' | 'started_at' | 'updated_at'>): boolean;
10
10
  /** Latest in-flight deployment for a site, if any (ignores stale rows). */
11
11
  export declare function fetchInProgressDeploymentId(supabase: SupabaseClient, siteId: string): Promise<string | null>;
12
+ /** Wait for a deployment row (e.g. webhook backstop) after trackingDeferred publish. */
13
+ export declare function waitForDeploymentByCommit(supabase: SupabaseClient, siteId: string, commitSha: string, timeoutMs?: number): Promise<string | null>;
12
14
  /** Subscribe to a single deployment row via Supabase Realtime. */
13
15
  export declare function useDeploymentStatus(supabase: SupabaseClient, deploymentId: string | null): {
14
16
  row: DeploymentRow | null;
@@ -21672,6 +21672,15 @@ async function fetchInProgressDeploymentId(supabase, siteId) {
21672
21672
  const fresh = rows.find((r) => !isDeploymentStale(r));
21673
21673
  return fresh?.id ?? null;
21674
21674
  }
21675
+ async function waitForDeploymentByCommit(supabase, siteId, commitSha, timeoutMs = 6e4) {
21676
+ const deadline = Date.now() + timeoutMs;
21677
+ while (Date.now() < deadline) {
21678
+ const { data } = await supabase.from("deployments").select("id").eq("site_id", siteId).eq("commit_sha", commitSha).order("started_at", { ascending: false }).limit(1).maybeSingle();
21679
+ if (data?.id) return data.id;
21680
+ await new Promise((r) => setTimeout(r, 2e3));
21681
+ }
21682
+ return null;
21683
+ }
21675
21684
  function useDeploymentStatus(supabase, deploymentId) {
21676
21685
  const [row, setRow] = useState(null);
21677
21686
  useEffect(() => {
@@ -22118,7 +22127,20 @@ function EditToolbar() {
22118
22127
  const result = await api.publish(config.siteId, files);
22119
22128
  store.commit();
22120
22129
  themeStore?.commit();
22121
- setActiveDeployment(result.deploymentId);
22130
+ let deploymentId = result.deploymentId;
22131
+ if (!deploymentId && result.trackingDeferred) {
22132
+ deploymentId = await waitForDeploymentByCommit(
22133
+ supabase,
22134
+ config.siteId,
22135
+ result.commitSha
22136
+ );
22137
+ }
22138
+ if (deploymentId) {
22139
+ setActiveDeployment(deploymentId);
22140
+ } else {
22141
+ setPublishDialogOpen(false);
22142
+ setPublishedNotice(true);
22143
+ }
22122
22144
  } catch (err) {
22123
22145
  setError(err instanceof Error ? err.message : "unknown error");
22124
22146
  setPublishDialogOpen(false);