@algolia/wizard 0.73.0 → 0.75.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 +183 -4
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2260,7 +2260,7 @@ async function ensureApplication(resumeAppId) {
|
|
|
2260
2260
|
// package.json
|
|
2261
2261
|
var package_default = {
|
|
2262
2262
|
name: "@algolia/wizard",
|
|
2263
|
-
version: "0.
|
|
2263
|
+
version: "0.75.0",
|
|
2264
2264
|
description: "Magically implement Algolia functionality in your codebase",
|
|
2265
2265
|
type: "module",
|
|
2266
2266
|
engines: {
|
|
@@ -5516,6 +5516,7 @@ function searchInstructions(input) {
|
|
|
5516
5516
|
"Style the search surfaces through the widget's class and CSS-variable overrides (or, when hand-built, the app's existing theme tokens): give the results panel and the element that actually draws the input's border and background \u2014 for a widget, the form or wrapper it renders around the bare input \u2014 non-transparent surfaces, keep that frame distinguishable from the background behind it in every supported theme, and never assume a light surface or reuse the surrounding page's colors unchanged inside the panel.",
|
|
5517
5517
|
"The panel takes its width from the input by default, so a small input makes it unreadably narrow: give it `min-width: min(320px, calc(100vw - 2rem))` independent of the input, cap its maximum width to the viewport, and anchor it to the input edge it opens from so widening does not push it off-screen.",
|
|
5518
5518
|
"Match the application styles closely, including light, dark, and high-contrast themes the project already supports.",
|
|
5519
|
+
"Before reporting, mount the component and fix any type-check or lint errors your changes cause. If a tool limit is reached or an error remains unresolved, keep the implementation, report status=success, and name the remaining issue in the summary so validation can drive the next pass. Report status=fail only when no search implementation can be written, with the concrete blocker as the reason.",
|
|
5519
5520
|
"The summary should be extremely concise; do not mention manual testing steps."
|
|
5520
5521
|
];
|
|
5521
5522
|
}
|
|
@@ -6434,6 +6435,14 @@ async function getPlaybooks() {
|
|
|
6434
6435
|
);
|
|
6435
6436
|
return data;
|
|
6436
6437
|
}
|
|
6438
|
+
async function createSampleIndex(appId, playbookSlug) {
|
|
6439
|
+
const { data } = await dashboardRequest(
|
|
6440
|
+
`/api/1/playbook-integrations/applications/${appId}/playbooks/${playbookSlug}/sample_index`,
|
|
6441
|
+
playbookExecutionSchema,
|
|
6442
|
+
{ method: "POST" }
|
|
6443
|
+
);
|
|
6444
|
+
return data;
|
|
6445
|
+
}
|
|
6437
6446
|
|
|
6438
6447
|
// src/actions/playbookSteps/selectPlaybook.ts
|
|
6439
6448
|
var selectPlaybookSchema = z32.object({
|
|
@@ -6498,6 +6507,153 @@ async function confirmPlaybookStep(ctx) {
|
|
|
6498
6507
|
}
|
|
6499
6508
|
}
|
|
6500
6509
|
|
|
6510
|
+
// src/actions/playbookSteps/selectIndex.ts
|
|
6511
|
+
import { z as z34 } from "zod";
|
|
6512
|
+
var selectIndexSchema = z34.object({
|
|
6513
|
+
indexName: z34.string(),
|
|
6514
|
+
sampleIndex: z34.boolean()
|
|
6515
|
+
});
|
|
6516
|
+
var CREATE_SAMPLE_INDEX = "Create a sample index";
|
|
6517
|
+
var GO_BACK_OPTION2 = "Go back to playbook selection";
|
|
6518
|
+
var SELECT_APP_OPTION2 = "Select app";
|
|
6519
|
+
var MIN_ENTRIES_FOR_SELECTION = 1;
|
|
6520
|
+
function formatIndexOption(index) {
|
|
6521
|
+
if (index.entries < MIN_ENTRIES_FOR_SELECTION) {
|
|
6522
|
+
return `${index.name} (empty index)`;
|
|
6523
|
+
}
|
|
6524
|
+
return `${index.name} (${index.entries.toLocaleString()} records)`;
|
|
6525
|
+
}
|
|
6526
|
+
function isIndexSelectable(index) {
|
|
6527
|
+
return index.entries >= MIN_ENTRIES_FOR_SELECTION;
|
|
6528
|
+
}
|
|
6529
|
+
async function selectIndexStep2(ctx) {
|
|
6530
|
+
let indices = ctx.getUserInput("fetchedIndices");
|
|
6531
|
+
!indices && ctx.notify({
|
|
6532
|
+
messages: ["Fetching indices from your Algolia application\u2026"]
|
|
6533
|
+
});
|
|
6534
|
+
const app = await requireApplication();
|
|
6535
|
+
if (!indices) {
|
|
6536
|
+
indices = await listIndices();
|
|
6537
|
+
ctx.setUserInput("fetchedIndices", indices);
|
|
6538
|
+
}
|
|
6539
|
+
const hasIndices = indices.length > 0;
|
|
6540
|
+
const indexOptions = hasIndices ? indices.map(formatIndexOption) : [];
|
|
6541
|
+
const options = [
|
|
6542
|
+
...indexOptions,
|
|
6543
|
+
CREATE_SAMPLE_INDEX,
|
|
6544
|
+
GO_BACK_OPTION2,
|
|
6545
|
+
SELECT_APP_OPTION2
|
|
6546
|
+
];
|
|
6547
|
+
const disabled = hasIndices ? [
|
|
6548
|
+
...indices.map((idx) => !isIndexSelectable(idx)),
|
|
6549
|
+
false,
|
|
6550
|
+
// CREATE_SAMPLE_INDEX is selectable
|
|
6551
|
+
false,
|
|
6552
|
+
// GO_BACK_OPTION is selectable
|
|
6553
|
+
false
|
|
6554
|
+
// SELECT_APP_OPTION is selectable
|
|
6555
|
+
] : void 0;
|
|
6556
|
+
const prompt = hasIndices ? "Select an index:" : `${app.name} doesn't have any indices yet. Start from a sample data set
|
|
6557
|
+
you can explore or switch to another application`;
|
|
6558
|
+
let error;
|
|
6559
|
+
let result;
|
|
6560
|
+
while (result === void 0) {
|
|
6561
|
+
const selection = await ctx.requestUserInput({
|
|
6562
|
+
prompt,
|
|
6563
|
+
promptType: "multipleChoice",
|
|
6564
|
+
options,
|
|
6565
|
+
error,
|
|
6566
|
+
disabled,
|
|
6567
|
+
helpText: hasIndices ? "Choose an existing index with data, or create a new index from sample data." : void 0
|
|
6568
|
+
});
|
|
6569
|
+
if (typeof selection !== "string") {
|
|
6570
|
+
throw new Error(
|
|
6571
|
+
"selectIndex received an unexpected non-text result"
|
|
6572
|
+
);
|
|
6573
|
+
}
|
|
6574
|
+
if (selection === GO_BACK_OPTION2) {
|
|
6575
|
+
ctx.setUserInput("fetchedIndices", void 0);
|
|
6576
|
+
return ctx.returnToStep("select-playbook");
|
|
6577
|
+
}
|
|
6578
|
+
if (selection === SELECT_APP_OPTION2) {
|
|
6579
|
+
await ctx.changeApplication();
|
|
6580
|
+
continue;
|
|
6581
|
+
}
|
|
6582
|
+
if (selection === CREATE_SAMPLE_INDEX) {
|
|
6583
|
+
result = {
|
|
6584
|
+
indexName: "",
|
|
6585
|
+
sampleIndex: true
|
|
6586
|
+
};
|
|
6587
|
+
break;
|
|
6588
|
+
}
|
|
6589
|
+
const selectedIndex = indices.find(
|
|
6590
|
+
(idx) => formatIndexOption(idx) === selection
|
|
6591
|
+
);
|
|
6592
|
+
if (!selectedIndex) {
|
|
6593
|
+
error = "Invalid selection. Please try again.";
|
|
6594
|
+
continue;
|
|
6595
|
+
}
|
|
6596
|
+
result = {
|
|
6597
|
+
indexName: selectedIndex.name,
|
|
6598
|
+
sampleIndex: false
|
|
6599
|
+
};
|
|
6600
|
+
}
|
|
6601
|
+
return result;
|
|
6602
|
+
}
|
|
6603
|
+
|
|
6604
|
+
// src/actions/playbookSteps/confirmIndex.ts
|
|
6605
|
+
import "zod";
|
|
6606
|
+
var confirmIndexSchema = playbookExecutionSchema.nullable();
|
|
6607
|
+
var CONTINUE_OPTION2 = "Looks good, continue";
|
|
6608
|
+
var GO_BACK_OPTION3 = "Go back";
|
|
6609
|
+
async function confirmIndexStep(ctx) {
|
|
6610
|
+
const { sampleIndex } = ctx.getStepOutput("select-index");
|
|
6611
|
+
if (!sampleIndex) {
|
|
6612
|
+
return null;
|
|
6613
|
+
}
|
|
6614
|
+
const { slug } = ctx.getStepOutput("select-playbook");
|
|
6615
|
+
const selection = await ctx.requestUserInput({
|
|
6616
|
+
prompt: "Ready to create sample index?",
|
|
6617
|
+
promptType: "multipleChoice",
|
|
6618
|
+
options: [CONTINUE_OPTION2, GO_BACK_OPTION3],
|
|
6619
|
+
messages: [
|
|
6620
|
+
`A new index called "algolia_playbooks_${slug}_sample_index" will be created with sample ${slug} data.`
|
|
6621
|
+
],
|
|
6622
|
+
helpText: "Going back lets you choose a different index."
|
|
6623
|
+
});
|
|
6624
|
+
if (typeof selection !== "string") {
|
|
6625
|
+
throw new Error("confirm-index received an unexpected result");
|
|
6626
|
+
}
|
|
6627
|
+
if (selection === GO_BACK_OPTION3) {
|
|
6628
|
+
return ctx.returnToStep("select-index");
|
|
6629
|
+
}
|
|
6630
|
+
ctx.notify({
|
|
6631
|
+
messages: ["Creating sample index and playbook execution\u2026"]
|
|
6632
|
+
});
|
|
6633
|
+
const app = await requireApplication();
|
|
6634
|
+
const playbookSlug = ctx.getUserInput("playbookSlug");
|
|
6635
|
+
if (!playbookSlug) {
|
|
6636
|
+
throw new Error("No playbook slug found in context");
|
|
6637
|
+
}
|
|
6638
|
+
try {
|
|
6639
|
+
const execution = await createSampleIndex(app.id, playbookSlug);
|
|
6640
|
+
ctx.setUserInput("fetchedIndices", void 0);
|
|
6641
|
+
ctx.clearNotices();
|
|
6642
|
+
ctx.notify({
|
|
6643
|
+
messages: [
|
|
6644
|
+
`Sample index "${execution.source_index_name}" created successfully!`
|
|
6645
|
+
]
|
|
6646
|
+
});
|
|
6647
|
+
return execution;
|
|
6648
|
+
} catch (error) {
|
|
6649
|
+
ctx.clearNotices();
|
|
6650
|
+
ctx.notify({
|
|
6651
|
+
messages: ["Failed to create sample index. Please try again."]
|
|
6652
|
+
});
|
|
6653
|
+
throw error;
|
|
6654
|
+
}
|
|
6655
|
+
}
|
|
6656
|
+
|
|
6501
6657
|
// src/lib/cli.ts
|
|
6502
6658
|
var USAGE = `Usage: wizard [workflow-id] [options]
|
|
6503
6659
|
wizard playbook [playbook-slug] [options]
|
|
@@ -6571,6 +6727,21 @@ var playbookWorkflow = {
|
|
|
6571
6727
|
outputSchema: confirmPlaybookSchema,
|
|
6572
6728
|
visible: false,
|
|
6573
6729
|
run: (ctx) => confirmPlaybookStep(ctx)
|
|
6730
|
+
}),
|
|
6731
|
+
defineStep({
|
|
6732
|
+
id: "select-index",
|
|
6733
|
+
title: "Select index",
|
|
6734
|
+
outputSchema: selectIndexSchema,
|
|
6735
|
+
tips: ["apps-and-indices", "records-are-json", "speed"],
|
|
6736
|
+
run: (ctx) => selectIndexStep2(ctx)
|
|
6737
|
+
}),
|
|
6738
|
+
defineStep({
|
|
6739
|
+
id: "confirm-index",
|
|
6740
|
+
title: "Confirm sample index creation",
|
|
6741
|
+
outputSchema: confirmIndexSchema,
|
|
6742
|
+
visible: false,
|
|
6743
|
+
tips: ["apps-and-indices", "records-are-json", "speed"],
|
|
6744
|
+
run: (ctx) => confirmIndexStep(ctx)
|
|
6574
6745
|
})
|
|
6575
6746
|
]
|
|
6576
6747
|
};
|
|
@@ -7651,6 +7822,10 @@ var search = {
|
|
|
7651
7822
|
var selectPlaybook = {
|
|
7652
7823
|
slug: "orders"
|
|
7653
7824
|
};
|
|
7825
|
+
var selectPlaybookIndex = {
|
|
7826
|
+
indexName: "wizard_seed_orders",
|
|
7827
|
+
sampleIndex: false
|
|
7828
|
+
};
|
|
7654
7829
|
var review = {
|
|
7655
7830
|
summaryPoints: [
|
|
7656
7831
|
"Ingested 25 generated Product records into wizard_seed_products.",
|
|
@@ -7672,7 +7847,9 @@ var SEEDS = {
|
|
|
7672
7847
|
},
|
|
7673
7848
|
playbook: {
|
|
7674
7849
|
"select-playbook": selectPlaybook,
|
|
7675
|
-
"confirm-playbook": void 0
|
|
7850
|
+
"confirm-playbook": void 0,
|
|
7851
|
+
"select-index": selectPlaybookIndex,
|
|
7852
|
+
"confirm-index": null
|
|
7676
7853
|
}
|
|
7677
7854
|
};
|
|
7678
7855
|
var SEED_ALGOLIA_STATE = {
|
|
@@ -7686,7 +7863,9 @@ var SEED_USER_INPUTS = {
|
|
|
7686
7863
|
implementation: "success"
|
|
7687
7864
|
},
|
|
7688
7865
|
playbook: {
|
|
7689
|
-
playbookSlug: selectPlaybook.slug
|
|
7866
|
+
playbookSlug: selectPlaybook.slug,
|
|
7867
|
+
playbookIndexName: selectPlaybookIndex.indexName,
|
|
7868
|
+
playbookSampleIndex: selectPlaybookIndex.sampleIndex
|
|
7690
7869
|
}
|
|
7691
7870
|
};
|
|
7692
7871
|
function formatStepList(workflow, startIndex) {
|
|
@@ -7841,7 +8020,7 @@ function delay(ms) {
|
|
|
7841
8020
|
// package.json with { type: 'json' }
|
|
7842
8021
|
var package_default2 = {
|
|
7843
8022
|
name: "@algolia/wizard",
|
|
7844
|
-
version: "0.
|
|
8023
|
+
version: "0.75.0",
|
|
7845
8024
|
description: "Magically implement Algolia functionality in your codebase",
|
|
7846
8025
|
type: "module",
|
|
7847
8026
|
engines: {
|