@algolia/wizard 0.60.0 → 0.61.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 +68 -61
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -3905,7 +3905,7 @@ async function runAnalysis(mode, extraInstructions = []) {
|
|
|
3905
3905
|
// package.json
|
|
3906
3906
|
var package_default = {
|
|
3907
3907
|
name: "@algolia/wizard",
|
|
3908
|
-
version: "0.
|
|
3908
|
+
version: "0.61.0",
|
|
3909
3909
|
description: "Magically implement Algolia functionality in your codebase",
|
|
3910
3910
|
type: "module",
|
|
3911
3911
|
engines: {
|
|
@@ -4523,6 +4523,13 @@ var verificationOutputSchema = z28.object({
|
|
|
4523
4523
|
var MAX_IMPLEMENT_VERIFICATION_ATTEMPTS = 3;
|
|
4524
4524
|
var DEFAULT_IMPLEMENT_USE_CASES = ["ingestion", "search"];
|
|
4525
4525
|
var INGEST_DIR = ".algolia-wizard";
|
|
4526
|
+
var INGESTION_SOURCE_PROMPT = "What data do you want to index?";
|
|
4527
|
+
var INGESTION_SOURCE = {
|
|
4528
|
+
local: "Use existing project data",
|
|
4529
|
+
fileUpload: "Import a data file (CSV, JSON, TSV)",
|
|
4530
|
+
generated: "Generate sample data"
|
|
4531
|
+
};
|
|
4532
|
+
var FILE_UPLOAD_PATH_PROMPT = "Enter the path to your JSON, CSV, or TSV file (relative to the project root, or absolute):";
|
|
4526
4533
|
var JS_LANGUAGES = ["javascript", "typescript", "jsx", "tsx", "node"];
|
|
4527
4534
|
function lower(entries) {
|
|
4528
4535
|
return entries.map((entry) => entry.name.toLowerCase());
|
|
@@ -4758,6 +4765,59 @@ function verificationRetryInstructions(verification) {
|
|
|
4758
4765
|
`Implementation insufficient. Address these findings before reporting completion: ${verification.additionalInstructions ?? verification.summary}`
|
|
4759
4766
|
];
|
|
4760
4767
|
}
|
|
4768
|
+
async function resolveIngestionSource(ctx, repoRoot) {
|
|
4769
|
+
let error = void 0;
|
|
4770
|
+
for (; ; ) {
|
|
4771
|
+
const selection = await ctx.requestUserInput({
|
|
4772
|
+
prompt: INGESTION_SOURCE_PROMPT,
|
|
4773
|
+
promptType: "multipleChoice",
|
|
4774
|
+
options: [
|
|
4775
|
+
INGESTION_SOURCE.local,
|
|
4776
|
+
INGESTION_SOURCE.fileUpload,
|
|
4777
|
+
INGESTION_SOURCE.generated
|
|
4778
|
+
],
|
|
4779
|
+
messages: [],
|
|
4780
|
+
cancelable: true,
|
|
4781
|
+
error
|
|
4782
|
+
});
|
|
4783
|
+
error = void 0;
|
|
4784
|
+
if (selection === "cancel") {
|
|
4785
|
+
throw new Error(
|
|
4786
|
+
"User cancelled ingestion source selection. Wizard halted."
|
|
4787
|
+
);
|
|
4788
|
+
}
|
|
4789
|
+
if (selection === INGESTION_SOURCE.local) {
|
|
4790
|
+
return { ingestionSource: "local" };
|
|
4791
|
+
}
|
|
4792
|
+
if (selection === INGESTION_SOURCE.generated) {
|
|
4793
|
+
return { ingestionSource: "generated" };
|
|
4794
|
+
}
|
|
4795
|
+
if (selection !== INGESTION_SOURCE.fileUpload) {
|
|
4796
|
+
throw new Error("Unexpected ingestion source selection");
|
|
4797
|
+
}
|
|
4798
|
+
const answer = await ctx.requestUserInput({
|
|
4799
|
+
prompt: FILE_UPLOAD_PATH_PROMPT,
|
|
4800
|
+
promptType: "textInput",
|
|
4801
|
+
options: [],
|
|
4802
|
+
messages: []
|
|
4803
|
+
});
|
|
4804
|
+
const uploadSourcePath = typeof answer === "string" ? answer : "";
|
|
4805
|
+
await mkdir5(join10(repoRoot, INGEST_DIR), { recursive: true });
|
|
4806
|
+
const copied = await copyUploadIntoProject(
|
|
4807
|
+
repoRoot,
|
|
4808
|
+
INGEST_DIR,
|
|
4809
|
+
uploadSourcePath
|
|
4810
|
+
);
|
|
4811
|
+
if (copied.ok) {
|
|
4812
|
+
return { ingestionSource: "fileUpload", uploadFilePath: copied.relPath };
|
|
4813
|
+
}
|
|
4814
|
+
error = `Could not use the uploaded file (${copied.reason}).`;
|
|
4815
|
+
logger.warn(
|
|
4816
|
+
{ reason: copied.reason },
|
|
4817
|
+
"implement: file upload unavailable"
|
|
4818
|
+
);
|
|
4819
|
+
}
|
|
4820
|
+
}
|
|
4761
4821
|
async function implement(ctx, useCases = DEFAULT_IMPLEMENT_USE_CASES) {
|
|
4762
4822
|
const repoRoot = process.cwd();
|
|
4763
4823
|
const scan = ctx.getStepOutput("project-scan");
|
|
@@ -4780,50 +4840,17 @@ async function implement(ctx, useCases = DEFAULT_IMPLEMENT_USE_CASES) {
|
|
|
4780
4840
|
if (!selected?.selection) {
|
|
4781
4841
|
throw new Error(`No index was selected`);
|
|
4782
4842
|
}
|
|
4843
|
+
await assertGitRepoWithHead(repoRoot);
|
|
4783
4844
|
let ingestionSource = "generated";
|
|
4784
|
-
|
|
4785
|
-
{
|
|
4786
|
-
question: "Do you have local access to the data you want to ingest in Algolia?",
|
|
4787
|
-
source: "local"
|
|
4788
|
-
},
|
|
4789
|
-
{
|
|
4790
|
-
question: "Do you have a JSON, CSV or TSV you would like to upload?",
|
|
4791
|
-
source: "fileUpload"
|
|
4792
|
-
},
|
|
4793
|
-
{
|
|
4794
|
-
question: "Do you want me to generate sample records based on your entity schema?",
|
|
4795
|
-
source: "generated"
|
|
4796
|
-
}
|
|
4797
|
-
];
|
|
4798
|
-
let uploadSourcePath;
|
|
4845
|
+
let uploadFilePath = void 0;
|
|
4799
4846
|
if (useCases.includes("ingestion")) {
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
promptType: "acceptReject",
|
|
4805
|
-
options: ["Yes", "No"],
|
|
4806
|
-
messages: []
|
|
4807
|
-
})
|
|
4808
|
-
);
|
|
4809
|
-
if (result) {
|
|
4810
|
-
ingestionSource = sq.source;
|
|
4811
|
-
break;
|
|
4812
|
-
}
|
|
4813
|
-
}
|
|
4814
|
-
if (ingestionSource === "fileUpload") {
|
|
4815
|
-
const answer = await ctx.requestUserInput({
|
|
4816
|
-
prompt: "Enter the path to your JSON, CSV, or TSV file (relative to the project root, or absolute):",
|
|
4817
|
-
promptType: "textInput",
|
|
4818
|
-
options: [],
|
|
4819
|
-
messages: []
|
|
4820
|
-
});
|
|
4821
|
-
uploadSourcePath = typeof answer === "string" ? answer : "";
|
|
4822
|
-
}
|
|
4847
|
+
({ ingestionSource, uploadFilePath } = await resolveIngestionSource(
|
|
4848
|
+
ctx,
|
|
4849
|
+
repoRoot
|
|
4850
|
+
));
|
|
4823
4851
|
}
|
|
4824
4852
|
const targetIndex = selected?.selection;
|
|
4825
4853
|
useWizard.getState().setTargetIndex(targetIndex ?? null);
|
|
4826
|
-
await assertGitRepoWithHead(repoRoot);
|
|
4827
4854
|
if (useCases.includes("ingestion")) {
|
|
4828
4855
|
await mkdir5(join10(repoRoot, INGEST_DIR), { recursive: true });
|
|
4829
4856
|
}
|
|
@@ -4842,27 +4869,7 @@ async function implement(ctx, useCases = DEFAULT_IMPLEMENT_USE_CASES) {
|
|
|
4842
4869
|
if (useCases.includes("ingestion") && ingestAppId) {
|
|
4843
4870
|
ingestWriteKey = (await resolveWriteKey(targetIndex, ingestAppId)).key;
|
|
4844
4871
|
}
|
|
4845
|
-
let uploadFilePath;
|
|
4846
|
-
let uploadWarning;
|
|
4847
|
-
if (ingestionSource === "fileUpload") {
|
|
4848
|
-
const copied = await copyUploadIntoProject(
|
|
4849
|
-
repoRoot,
|
|
4850
|
-
INGEST_DIR,
|
|
4851
|
-
uploadSourcePath ?? ""
|
|
4852
|
-
);
|
|
4853
|
-
if (copied.ok) {
|
|
4854
|
-
uploadFilePath = copied.relPath;
|
|
4855
|
-
} else {
|
|
4856
|
-
ingestionSource = "generated";
|
|
4857
|
-
uploadWarning = `\u26A0\uFE0F Could not use the uploaded file (${copied.reason}); generating sample records instead.`;
|
|
4858
|
-
logger.warn(
|
|
4859
|
-
{ reason: copied.reason },
|
|
4860
|
-
"implement: file upload unavailable; falling back to generated sample records"
|
|
4861
|
-
);
|
|
4862
|
-
}
|
|
4863
|
-
}
|
|
4864
4872
|
const summaries = [];
|
|
4865
|
-
if (uploadWarning) summaries.push(uploadWarning);
|
|
4866
4873
|
let searchKey;
|
|
4867
4874
|
let searchKeyError;
|
|
4868
4875
|
if (useCases.includes("search") && appId) {
|
|
@@ -6737,7 +6744,7 @@ function delay(ms) {
|
|
|
6737
6744
|
// package.json with { type: 'json' }
|
|
6738
6745
|
var package_default2 = {
|
|
6739
6746
|
name: "@algolia/wizard",
|
|
6740
|
-
version: "0.
|
|
6747
|
+
version: "0.61.0",
|
|
6741
6748
|
description: "Magically implement Algolia functionality in your codebase",
|
|
6742
6749
|
type: "module",
|
|
6743
6750
|
engines: {
|