@algolia/wizard 0.84.0 → 0.86.0
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/main.js +158 -40
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1208,6 +1208,7 @@ function SelectPrompt({
|
|
|
1208
1208
|
helpText,
|
|
1209
1209
|
messages,
|
|
1210
1210
|
table,
|
|
1211
|
+
list,
|
|
1211
1212
|
error,
|
|
1212
1213
|
multi,
|
|
1213
1214
|
cancelable,
|
|
@@ -1290,6 +1291,20 @@ function SelectPrompt({
|
|
|
1290
1291
|
error && /* @__PURE__ */ jsx8(Text10, { color: COLORS.danger, children: error }),
|
|
1291
1292
|
messages?.map((m, i) => /* @__PURE__ */ jsx8(Text10, { color: COLORS.muted, children: m }, `msg-${i}`)),
|
|
1292
1293
|
table && /* @__PURE__ */ jsx8(Table, { columns: table.columns, rows: table.rows }),
|
|
1294
|
+
list && list.length > 0 && /* @__PURE__ */ jsx8(Box9, { flexDirection: "column", children: list.map((item, i) => /* @__PURE__ */ jsxs9(Text10, { children: [
|
|
1295
|
+
/* @__PURE__ */ jsx8(
|
|
1296
|
+
Text10,
|
|
1297
|
+
{
|
|
1298
|
+
color: item.color === "success" ? COLORS.success : COLORS.danger,
|
|
1299
|
+
children: item.color === "success" ? "\u2713 " : "\u25CF "
|
|
1300
|
+
}
|
|
1301
|
+
),
|
|
1302
|
+
/* @__PURE__ */ jsx8(Text10, { color: COLORS.primary, children: item.label }),
|
|
1303
|
+
item.helpText ? /* @__PURE__ */ jsxs9(Text10, { color: COLORS.muted, children: [
|
|
1304
|
+
" ",
|
|
1305
|
+
item.helpText
|
|
1306
|
+
] }) : null
|
|
1307
|
+
] }, `list-${i}`)) }),
|
|
1293
1308
|
/* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", children: [
|
|
1294
1309
|
question && /* @__PURE__ */ jsx8(Text10, { color: COLORS.muted, children: question }),
|
|
1295
1310
|
helpText && /* @__PURE__ */ jsx8(Text10, { color: COLORS.dim, children: helpText })
|
|
@@ -1389,6 +1404,7 @@ function PromptInput() {
|
|
|
1389
1404
|
helpText: inputReq.helpText,
|
|
1390
1405
|
messages: inputReq.messages,
|
|
1391
1406
|
table: inputReq.table,
|
|
1407
|
+
list: inputReq.list,
|
|
1392
1408
|
options: inputReq.options,
|
|
1393
1409
|
secondary: inputReq.secondary,
|
|
1394
1410
|
disabled: inputReq.disabled,
|
|
@@ -1409,6 +1425,7 @@ function PromptInput() {
|
|
|
1409
1425
|
helpText: inputReq.helpText,
|
|
1410
1426
|
messages: inputReq.messages,
|
|
1411
1427
|
table: inputReq.table,
|
|
1428
|
+
list: inputReq.list,
|
|
1412
1429
|
options: inputReq.options,
|
|
1413
1430
|
error: inputReq.error,
|
|
1414
1431
|
onSelect: handleSubmit
|
|
@@ -2315,7 +2332,7 @@ async function ensureApplication(resumeAppId) {
|
|
|
2315
2332
|
// package.json
|
|
2316
2333
|
var package_default = {
|
|
2317
2334
|
name: "@algolia/wizard",
|
|
2318
|
-
version: "0.
|
|
2335
|
+
version: "0.86.0",
|
|
2319
2336
|
description: "Magically implement Algolia functionality in your codebase",
|
|
2320
2337
|
type: "module",
|
|
2321
2338
|
engines: {
|
|
@@ -7352,9 +7369,6 @@ var defaultWorkflow = {
|
|
|
7352
7369
|
]
|
|
7353
7370
|
};
|
|
7354
7371
|
|
|
7355
|
-
// src/workflows/playbook.ts
|
|
7356
|
-
import "zod";
|
|
7357
|
-
|
|
7358
7372
|
// src/actions/playbookSteps/selectPlaybook.ts
|
|
7359
7373
|
import { z as z33 } from "zod";
|
|
7360
7374
|
|
|
@@ -7517,11 +7531,12 @@ async function getPlaybookExecution(uuid) {
|
|
|
7517
7531
|
return data;
|
|
7518
7532
|
}
|
|
7519
7533
|
async function assessPlaybookExecution(uuid) {
|
|
7520
|
-
await dashboardRequest(
|
|
7534
|
+
const { data } = await dashboardRequest(
|
|
7521
7535
|
`/api/1/playbook-integrations/playbooks/executions/${uuid}/assess`,
|
|
7522
|
-
|
|
7536
|
+
playbookExecutionSchema,
|
|
7523
7537
|
{ method: "POST" }
|
|
7524
7538
|
);
|
|
7539
|
+
return data;
|
|
7525
7540
|
}
|
|
7526
7541
|
|
|
7527
7542
|
// src/actions/playbookSteps/selectPlaybook.ts
|
|
@@ -7704,13 +7719,107 @@ async function confirmIndexStep(ctx) {
|
|
|
7704
7719
|
}
|
|
7705
7720
|
}
|
|
7706
7721
|
|
|
7707
|
-
// src/actions/playbookSteps/
|
|
7722
|
+
// src/actions/playbookSteps/dataAssessmentPrompts.ts
|
|
7708
7723
|
var CONTINUE_EXECUTION_OPTION = "Continue";
|
|
7709
7724
|
var RESTART_OPTION = "Restart";
|
|
7710
7725
|
var GO_BACK_OPTION3 = "Go back";
|
|
7711
7726
|
var SWITCH_APPLICATION_OPTION = "Switch application";
|
|
7712
7727
|
var SWITCH_INDEX_OPTION = "Switch index";
|
|
7713
7728
|
var RETRY_OPTION = "Retry";
|
|
7729
|
+
var RETRY_ASSESSMENT_OPTION = "Retry assessment";
|
|
7730
|
+
var promptResumeExecution = async (ctx, indexName) => {
|
|
7731
|
+
const choice = await ctx.requestUserInput({
|
|
7732
|
+
prompt: `${indexName} has a playbook in progress.`,
|
|
7733
|
+
promptType: "multipleChoice",
|
|
7734
|
+
options: [CONTINUE_EXECUTION_OPTION, RESTART_OPTION, GO_BACK_OPTION3],
|
|
7735
|
+
secondary: [{ kind: "text", value: "resume Assessment" }]
|
|
7736
|
+
});
|
|
7737
|
+
if (typeof choice !== "string") {
|
|
7738
|
+
throw new Error("data-assessment received an unexpected execution choice");
|
|
7739
|
+
}
|
|
7740
|
+
return choice;
|
|
7741
|
+
};
|
|
7742
|
+
var promptAssessmentRecovery = async (ctx, message, retryDisabled) => {
|
|
7743
|
+
const choice = await ctx.requestUserInput({
|
|
7744
|
+
prompt: "Data assessment failed.",
|
|
7745
|
+
promptType: "multipleChoice",
|
|
7746
|
+
options: [SWITCH_APPLICATION_OPTION, SWITCH_INDEX_OPTION, RETRY_OPTION],
|
|
7747
|
+
messages: [message],
|
|
7748
|
+
disabled: [false, false, retryDisabled],
|
|
7749
|
+
helpText: "Retry re-runs assessment on this index. Switch index or application to pick a different target."
|
|
7750
|
+
});
|
|
7751
|
+
if (choice === SWITCH_APPLICATION_OPTION) {
|
|
7752
|
+
return ctx.changeApplication();
|
|
7753
|
+
}
|
|
7754
|
+
if (choice === SWITCH_INDEX_OPTION) {
|
|
7755
|
+
return ctx.returnToStep("select-index");
|
|
7756
|
+
}
|
|
7757
|
+
if (choice === RETRY_OPTION) {
|
|
7758
|
+
return;
|
|
7759
|
+
}
|
|
7760
|
+
throw new Error("data-assessment received an unexpected recovery choice");
|
|
7761
|
+
};
|
|
7762
|
+
var promptNotReady = async (ctx, execution) => {
|
|
7763
|
+
const choice = await ctx.requestUserInput({
|
|
7764
|
+
prompt: "Update the records above, then retry.",
|
|
7765
|
+
messages: ["Some sampled records are missing fields the reviews playbook needs before it can continue."],
|
|
7766
|
+
promptType: "multipleChoice",
|
|
7767
|
+
options: [RETRY_ASSESSMENT_OPTION, SWITCH_INDEX_OPTION],
|
|
7768
|
+
list: missingRequiredFields(execution)
|
|
7769
|
+
});
|
|
7770
|
+
if (choice === RETRY_ASSESSMENT_OPTION) {
|
|
7771
|
+
return;
|
|
7772
|
+
}
|
|
7773
|
+
if (choice === SWITCH_INDEX_OPTION) {
|
|
7774
|
+
return ctx.returnToStep("select-index");
|
|
7775
|
+
}
|
|
7776
|
+
throw new Error("data-assessment received an unexpected not-ready choice");
|
|
7777
|
+
};
|
|
7778
|
+
var promptReady = async (ctx, execution) => {
|
|
7779
|
+
const result = execution.assessment_result;
|
|
7780
|
+
if (!result?.ready) {
|
|
7781
|
+
throw new Error("data-assessment expected a ready assessment result");
|
|
7782
|
+
}
|
|
7783
|
+
const schemaComparison = result.schema_comparison ?? [];
|
|
7784
|
+
const requiredFieldCount = schemaComparison.filter(
|
|
7785
|
+
(item) => item.canonical_required
|
|
7786
|
+
).length;
|
|
7787
|
+
const settingsWithChanges = changedSettings(result.settings_recommendation);
|
|
7788
|
+
await ctx.requestUserInput({
|
|
7789
|
+
prompt: settingsWithChanges.length > 0 ? `Your data is in good shape. Next you will review ${settingsWithChanges.length} ${settingsWithChanges.length === 1 ? "setting" : "settings"}.` : "All settings are optimized",
|
|
7790
|
+
promptType: "multipleChoice",
|
|
7791
|
+
options: [CONTINUE_EXECUTION_OPTION],
|
|
7792
|
+
list: [
|
|
7793
|
+
{
|
|
7794
|
+
label: "Records sampled",
|
|
7795
|
+
color: "success"
|
|
7796
|
+
},
|
|
7797
|
+
{
|
|
7798
|
+
label: "Schema detected",
|
|
7799
|
+
color: "success",
|
|
7800
|
+
helpText: `${requiredFieldCount} ${requiredFieldCount === 1 ? "field" : "fields"} detected`
|
|
7801
|
+
},
|
|
7802
|
+
{
|
|
7803
|
+
label: "All required fields present",
|
|
7804
|
+
color: "success"
|
|
7805
|
+
}
|
|
7806
|
+
]
|
|
7807
|
+
});
|
|
7808
|
+
};
|
|
7809
|
+
var missingRequiredFields = (execution) => {
|
|
7810
|
+
return (execution.assessment_result?.schema_comparison ?? []).filter((item) => item.canonical_required && item.status !== "mapped").sort((a, b) => Number(b.canonical_required) - Number(a.canonical_required)).slice(0, 10).map((item) => ({
|
|
7811
|
+
label: item.canonical_attr,
|
|
7812
|
+
color: "error",
|
|
7813
|
+
helpText: `missing \xB7 roles: ${item.canonical_roles.join(", ")}`
|
|
7814
|
+
}));
|
|
7815
|
+
};
|
|
7816
|
+
var changedSettings = (settingsRecommendation) => {
|
|
7817
|
+
return Object.entries(settingsRecommendation ?? {}).filter(
|
|
7818
|
+
([_, setting]) => JSON.stringify(setting.current) !== JSON.stringify(setting.recommended)
|
|
7819
|
+
);
|
|
7820
|
+
};
|
|
7821
|
+
|
|
7822
|
+
// src/actions/playbookSteps/dataAssessment.ts
|
|
7714
7823
|
var POLL_INTERVAL_MS = 5e3;
|
|
7715
7824
|
var POLL_TIMEOUT_MS = 6e4;
|
|
7716
7825
|
var ASSESSING_NOTICE_HOLD_MS = 2e4;
|
|
@@ -7732,7 +7841,10 @@ async function dataAssessmentStep(ctx) {
|
|
|
7732
7841
|
showNotice(ctx, CREATING_EXECUTION_NOTICE);
|
|
7733
7842
|
const { id: appId } = await requireApplication();
|
|
7734
7843
|
const execution = await resolveExecution(ctx, appId, slug, indexName);
|
|
7735
|
-
|
|
7844
|
+
const assessed = await runAssessment(ctx, execution, indexName);
|
|
7845
|
+
ctx.clearNotices();
|
|
7846
|
+
await promptReady(ctx, assessed);
|
|
7847
|
+
return assessed;
|
|
7736
7848
|
} finally {
|
|
7737
7849
|
ctx.clearNotices();
|
|
7738
7850
|
}
|
|
@@ -7772,20 +7884,39 @@ function startPollNotices(ctx) {
|
|
|
7772
7884
|
showCurrent();
|
|
7773
7885
|
return () => clearTimeout(timer);
|
|
7774
7886
|
}
|
|
7887
|
+
function isNotReady(execution) {
|
|
7888
|
+
return execution.step_status === "error" && execution.status_reason === "not_ready";
|
|
7889
|
+
}
|
|
7775
7890
|
async function runAssessment(ctx, execution, indexName) {
|
|
7776
7891
|
if (execution.step_status === "done") {
|
|
7777
7892
|
return execution;
|
|
7778
7893
|
}
|
|
7779
|
-
if (execution
|
|
7780
|
-
await
|
|
7781
|
-
|
|
7782
|
-
|
|
7894
|
+
if (isNotReady(execution)) {
|
|
7895
|
+
await reassessNotReady(
|
|
7896
|
+
ctx,
|
|
7897
|
+
execution,
|
|
7898
|
+
indexName
|
|
7899
|
+
);
|
|
7900
|
+
} else {
|
|
7901
|
+
await startAssessment(ctx, execution, indexName);
|
|
7783
7902
|
}
|
|
7784
7903
|
for (; ; ) {
|
|
7785
|
-
const assessed = await pollUntilAssessed(
|
|
7904
|
+
const assessed = await pollUntilAssessed(
|
|
7905
|
+
ctx,
|
|
7906
|
+
execution.uuid,
|
|
7907
|
+
indexName
|
|
7908
|
+
);
|
|
7786
7909
|
if (assessed.step_status === "done") {
|
|
7787
7910
|
return assessed;
|
|
7788
7911
|
}
|
|
7912
|
+
if (isNotReady(assessed)) {
|
|
7913
|
+
await reassessNotReady(
|
|
7914
|
+
ctx,
|
|
7915
|
+
assessed,
|
|
7916
|
+
indexName
|
|
7917
|
+
);
|
|
7918
|
+
continue;
|
|
7919
|
+
}
|
|
7789
7920
|
if (assessed.step_status !== "error") {
|
|
7790
7921
|
throw unexpectedAssessmentStatus(assessed.step_status);
|
|
7791
7922
|
}
|
|
@@ -7797,6 +7928,18 @@ async function runAssessment(ctx, execution, indexName) {
|
|
|
7797
7928
|
await assessExecution(ctx, execution.uuid, indexName);
|
|
7798
7929
|
}
|
|
7799
7930
|
}
|
|
7931
|
+
async function startAssessment(ctx, execution, indexName) {
|
|
7932
|
+
if (execution.step_status === "not_started" || execution.step_status === "error") {
|
|
7933
|
+
await assessExecution(ctx, execution.uuid, indexName);
|
|
7934
|
+
return;
|
|
7935
|
+
}
|
|
7936
|
+
if (execution.step_status === "in_progress") return;
|
|
7937
|
+
throw unexpectedAssessmentStatus(execution.step_status);
|
|
7938
|
+
}
|
|
7939
|
+
async function reassessNotReady(ctx, execution, indexName) {
|
|
7940
|
+
await promptNotReady(ctx, execution);
|
|
7941
|
+
await assessExecution(ctx, execution.uuid, indexName);
|
|
7942
|
+
}
|
|
7800
7943
|
function unexpectedAssessmentStatus(status) {
|
|
7801
7944
|
return new Error(
|
|
7802
7945
|
`data-assessment received an unexpected assessment status: ${status}`
|
|
@@ -7805,12 +7948,7 @@ function unexpectedAssessmentStatus(status) {
|
|
|
7805
7948
|
async function resolveExecution(ctx, appId, slug, indexName) {
|
|
7806
7949
|
const created = await createWithRecovery(ctx, appId, slug, indexName);
|
|
7807
7950
|
if (!created.resumed) return created;
|
|
7808
|
-
const choice = await ctx
|
|
7809
|
-
prompt: `${indexName} has a playbook in progress.`,
|
|
7810
|
-
promptType: "multipleChoice",
|
|
7811
|
-
options: [CONTINUE_EXECUTION_OPTION, RESTART_OPTION, GO_BACK_OPTION3],
|
|
7812
|
-
secondary: [{ kind: "text", value: "resume Assessment" }]
|
|
7813
|
-
});
|
|
7951
|
+
const choice = await promptResumeExecution(ctx, indexName);
|
|
7814
7952
|
if (choice === CONTINUE_EXECUTION_OPTION) return created;
|
|
7815
7953
|
if (choice === RESTART_OPTION) {
|
|
7816
7954
|
return createWithRecovery(ctx, appId, slug, indexName, { forceNew: true });
|
|
@@ -7898,26 +8036,6 @@ async function assessExecution(ctx, uuid, indexName) {
|
|
|
7898
8036
|
onRequestFailure(ctx, indexName)
|
|
7899
8037
|
);
|
|
7900
8038
|
}
|
|
7901
|
-
async function promptAssessmentRecovery(ctx, message, retryDisabled) {
|
|
7902
|
-
const choice = await ctx.requestUserInput({
|
|
7903
|
-
prompt: "Data assessment failed.",
|
|
7904
|
-
promptType: "multipleChoice",
|
|
7905
|
-
options: [SWITCH_APPLICATION_OPTION, SWITCH_INDEX_OPTION, RETRY_OPTION],
|
|
7906
|
-
messages: [message],
|
|
7907
|
-
disabled: [false, false, retryDisabled],
|
|
7908
|
-
helpText: "Retry re-runs assessment on this index. Switch index or application to pick a different target."
|
|
7909
|
-
});
|
|
7910
|
-
if (choice === SWITCH_APPLICATION_OPTION) {
|
|
7911
|
-
return ctx.changeApplication();
|
|
7912
|
-
}
|
|
7913
|
-
if (choice === SWITCH_INDEX_OPTION) {
|
|
7914
|
-
return ctx.returnToStep("select-index");
|
|
7915
|
-
}
|
|
7916
|
-
if (choice === RETRY_OPTION) {
|
|
7917
|
-
return;
|
|
7918
|
-
}
|
|
7919
|
-
throw new Error("data-assessment received an unexpected recovery choice");
|
|
7920
|
-
}
|
|
7921
8039
|
function assessmentFailureMessage(execution) {
|
|
7922
8040
|
if (execution.status_reason === "index_empty") {
|
|
7923
8041
|
return `Index "${execution.source_index_name}" has no records to assess.`;
|
|
@@ -9374,7 +9492,7 @@ async function resetProjectState() {
|
|
|
9374
9492
|
// package.json with { type: 'json' }
|
|
9375
9493
|
var package_default2 = {
|
|
9376
9494
|
name: "@algolia/wizard",
|
|
9377
|
-
version: "0.
|
|
9495
|
+
version: "0.86.0",
|
|
9378
9496
|
description: "Magically implement Algolia functionality in your codebase",
|
|
9379
9497
|
type: "module",
|
|
9380
9498
|
engines: {
|