@algolia/wizard 0.38.0-rc.131.266 → 0.38.0-rc.131.268

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.
Files changed (2) hide show
  1. package/dist/main.js +19 -13
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1432,9 +1432,9 @@ function reconcileWorkflowState(state, workflow) {
1432
1432
  }
1433
1433
  return state;
1434
1434
  }
1435
- async function isResumableWorkflow(workflow) {
1435
+ async function loadResumableState(workflow) {
1436
1436
  const persisted = await loadWorkflowState(workflow.id);
1437
- return persisted != null && reconcileWorkflowState(persisted, workflow) != null;
1437
+ return persisted ? reconcileWorkflowState(persisted, workflow) : null;
1438
1438
  }
1439
1439
  function initWorkflowState(workflow, now) {
1440
1440
  return {
@@ -1538,11 +1538,11 @@ async function runStep(state, index, step, appId) {
1538
1538
  durationMs: Date.now() - startedAt
1539
1539
  });
1540
1540
  }
1541
- async function runWorkflow(workflow, appId) {
1541
+ async function runWorkflow(workflow, appId, resumableState) {
1542
1542
  const store = useWizard.getState();
1543
1543
  try {
1544
- const persisted = await loadWorkflowState(workflow.id);
1545
- const state = (persisted && reconcileWorkflowState(persisted, workflow)) ?? initWorkflowState(workflow, nowIso());
1544
+ const resolved2 = resumableState !== void 0 ? resumableState : await loadResumableState(workflow);
1545
+ const state = resolved2 ?? initWorkflowState(workflow, nowIso());
1546
1546
  ensureExecutedStepCount(state);
1547
1547
  store.startWorkflow(
1548
1548
  {
@@ -3330,7 +3330,7 @@ async function runAnalysis(mode, extraInstructions = []) {
3330
3330
  // package.json
3331
3331
  var package_default = {
3332
3332
  name: "@algolia/wizard",
3333
- version: "0.38.0-rc.131.266",
3333
+ version: "0.38.0-rc.131.268",
3334
3334
  description: "Magically implement Algolia functionality in your codebase",
3335
3335
  type: "module",
3336
3336
  engines: {
@@ -5617,7 +5617,7 @@ function readValue(raw) {
5617
5617
 
5618
5618
  // src/lib/algoliaAppPicker.ts
5619
5619
  function blockReasonFor(app) {
5620
- return app.status !== "active" ? "Inactive" : "Missing permissions";
5620
+ return app.status !== "active" ? "Paused" : "Missing permissions";
5621
5621
  }
5622
5622
  function secondaryFor(app) {
5623
5623
  if (!canSelectApplication(app)) {
@@ -5628,6 +5628,11 @@ function secondaryFor(app) {
5628
5628
  function labelFor(app) {
5629
5629
  return app.name.trim() ? `${app.name} \u2014 ${app.id}` : app.id;
5630
5630
  }
5631
+ async function isEligible(app) {
5632
+ const apps = await listApplications();
5633
+ const full = apps.find((candidate) => candidate.id === app.id);
5634
+ return full != null && canSelectApplication(full);
5635
+ }
5631
5636
  async function selectAndReport(app) {
5632
5637
  const store = useWizard.getState();
5633
5638
  store.setSettingUpApp(app.id);
@@ -5647,7 +5652,7 @@ async function promptForApplication(leadIn = []) {
5647
5652
  }
5648
5653
  if (!unordered.some(canSelectApplication)) {
5649
5654
  throw new Error(
5650
- "None of the applications on this Algolia account are usable \u2014 each is either inactive or missing key-management access. Activate one, or grant it the `keys` ACL, then restart the wizard."
5655
+ "None of the applications on this Algolia account are usable \u2014 each is either paused or missing key-management access. Activate one, or grant it the `keys` ACL, then restart the wizard."
5651
5656
  );
5652
5657
  }
5653
5658
  const apps = [
@@ -5696,7 +5701,7 @@ async function confirmEnvApplication(env, current) {
5696
5701
  ]
5697
5702
  });
5698
5703
  if (choice === useEnv) return selectEnvApplication(env);
5699
- return current ? selectAndReport(current) : null;
5704
+ return current && await isEligible(current) ? selectAndReport(current) : null;
5700
5705
  }
5701
5706
  async function selectEnvApplication(env) {
5702
5707
  try {
@@ -5714,7 +5719,8 @@ async function selectEnvApplication(env) {
5714
5719
  async function ensureApplication(isResuming) {
5715
5720
  const current = await currentApplication();
5716
5721
  if (isResuming) {
5717
- return current ?? await promptForApplication();
5722
+ if (current && await isEligible(current)) return current;
5723
+ return promptForApplication();
5718
5724
  }
5719
5725
  const env = await findEnvApplicationId();
5720
5726
  if (env && env.id !== current?.id) {
@@ -6085,15 +6091,15 @@ async function run(workflow) {
6085
6091
  }
6086
6092
  store.setUser(user);
6087
6093
  let app;
6094
+ const resumableState = await loadResumableState(workflow);
6088
6095
  try {
6089
- const resuming = await isResumableWorkflow(workflow);
6090
- app = await ensureApplication(resuming);
6096
+ app = await ensureApplication(resumableState != null);
6091
6097
  } catch (err) {
6092
6098
  store.setError(err instanceof Error ? err.message : String(err));
6093
6099
  await instance.waitUntilExit();
6094
6100
  process.exit(1);
6095
6101
  }
6096
- runWorkflow(workflow, app.id);
6102
+ runWorkflow(workflow, app.id, resumableState);
6097
6103
  }
6098
6104
  await requestTerminalSize();
6099
6105
  var started = await startup();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algolia/wizard",
3
- "version": "0.38.0-rc.131.266",
3
+ "version": "0.38.0-rc.131.268",
4
4
  "description": "Magically implement Algolia functionality in your codebase",
5
5
  "type": "module",
6
6
  "engines": {