@algolia/wizard 0.93.0 → 0.94.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 +28 -12
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2384,7 +2384,7 @@ async function ensureApplication(resumeAppId) {
|
|
|
2384
2384
|
// package.json
|
|
2385
2385
|
var package_default = {
|
|
2386
2386
|
name: "@algolia/wizard",
|
|
2387
|
-
version: "0.
|
|
2387
|
+
version: "0.94.0",
|
|
2388
2388
|
description: "Magically implement Algolia functionality in your codebase",
|
|
2389
2389
|
type: "module",
|
|
2390
2390
|
engines: {
|
|
@@ -6407,7 +6407,8 @@ function sourceSpecificInstructions(input) {
|
|
|
6407
6407
|
"Read each record from its real local source at the confirmed entity paths.",
|
|
6408
6408
|
"Never fabricate, hardcode, or use placeholder records.",
|
|
6409
6409
|
"Add env vars for any local source access (DB URL, API base, file paths) that is not a fixed repo path.",
|
|
6410
|
-
"To read a database, use the database client or ORM that the project already declares in its manifest. Never install a database driver or ORM. If the project declares none, report that limitation instead of adding one."
|
|
6410
|
+
"To read a database, use the database client or ORM that the project already declares in its manifest. Never install a database driver or ORM. If the project declares none, report that limitation instead of adding one.",
|
|
6411
|
+
"Prefer a server-side credential (a service-role, secret, or admin key, or a database password) over a client-side or public key (for example an anon or publishable key, or any key the project exposes to its frontend) when the source has both: public keys are subject to the source's access rules and can return zero records without an error. Use a public key only when the source offers nothing else. Check the connection to the source before you check for its credential, and make that connection check work without the credential, so an unreachable service is never reported as a missing credential. If the credential the script needs is not in the environment, the script must print an error that names the variable and where the developer finds it, then exit with an error. Never install a client library or driver to work around a missing credential."
|
|
6411
6412
|
],
|
|
6412
6413
|
fileUpload: [
|
|
6413
6414
|
`Records come from the developer's file, already copied into the project at "${input.uploadFilePath}". Read and parse that exact file.`,
|
|
@@ -6463,7 +6464,7 @@ function ingestionInstructions(input) {
|
|
|
6463
6464
|
] : [],
|
|
6464
6465
|
`When the script is finished, decide the exact command and cwd you will use to run it. Make sure that the script path in the command resolves from that cwd to the filePath. Then call reviewScript with that filePath, command, cwd, the exact selected entityName, and usesGeneratedRecords set to ${input.ingestionSource === "generated"}. Wait for the developer to review it because running it writes records to a live index. Do not run it before that call returns. If you change the command or cwd after a failed run, call reviewScript again before runShell.`,
|
|
6465
6466
|
'Then, without changing directories, run the script yourself via runShell using the exact same command and cwd. Report the exact command you ran as "ingestCommand", with no cwd note or other text, so the developer can re-run it. Its explanation must say that running it writes records to Algolia.',
|
|
6466
|
-
"When the script reads from a database or another service, find how the project connects to it locally (env files, README, socket or TCP settings). If that connection needs a local service, such as a database proxy (for example cloud-sql-proxy) or a
|
|
6467
|
+
"When the script reads from a database or another service, find how the project connects to it locally (env files, README, the service's own config file for its host and port, socket or TCP settings). Use the host and port that config sets, not a default. If that connection needs a local service, such as a database proxy (for example cloud-sql-proxy), a tunnel, or a service the project starts with its own CLI or scripts (not necessarily Docker Compose), make the script check the connection before it reads. If the check fails, the script must print an error that names the service, then print exactly one last line to stdout in the form `ALGOLIA_WIZARD_START_HINT=<command>`, where <command> is the command from the project docs or scripts (README, package.json scripts, Makefile) that starts the service, and exit with an error. Omit that line when neither names a start command.",
|
|
6467
6468
|
"Make sure that the start command and the script connect to the same address (the same socket path, or the same host and port). If the project env points at an address that only a deployed environment has, such as a /cloudsql socket, make the script connect to the address of the start command. Set that address in the script before it loads the project database module. Do not edit project env or config files for this.",
|
|
6468
6469
|
"When the script uses the project database client or ORM, load that client's env file (the project .env the client already reads) so credentials such as DB user, password, and database name are present. Load the wizard Algolia .env first, then the project .env, so Algolia keys win under dotenv versions that ignore `override`. Do not rely on `override: true`.",
|
|
6469
6470
|
"If external data access fails, do not run authentication commands, change accounts or machine configuration, or start proxies, containers, or services.",
|
|
@@ -6701,6 +6702,12 @@ function parseIngestRecordCount(output) {
|
|
|
6701
6702
|
const count = Number(match[1]);
|
|
6702
6703
|
return Number.isFinite(count) ? count : void 0;
|
|
6703
6704
|
}
|
|
6705
|
+
function indexedNothing(execution) {
|
|
6706
|
+
return parseIngestRecordCount(execution.output ?? "") === 0;
|
|
6707
|
+
}
|
|
6708
|
+
function ranButIndexedNothing(execution) {
|
|
6709
|
+
return execution.approved && execution.exitCode === 0 && !execution.timedOut && indexedNothing(execution);
|
|
6710
|
+
}
|
|
6704
6711
|
var START_HINT_LINE = /^ALGOLIA_WIZARD_START_HINT=(.*)$/gm;
|
|
6705
6712
|
function parseStartHint(output) {
|
|
6706
6713
|
const matches = [...(output ?? "").matchAll(START_HINT_LINE)];
|
|
@@ -6722,7 +6729,7 @@ function ingestOutcome(executions, repoRoot, ingestCommand) {
|
|
|
6722
6729
|
(e) => parseIngestRecordCount(e.output ?? "") != null
|
|
6723
6730
|
);
|
|
6724
6731
|
const succeeded = newestFirst.filter(
|
|
6725
|
-
(e) => e.approved && e.exitCode === 0 && !e.timedOut
|
|
6732
|
+
(e) => e.approved && e.exitCode === 0 && !e.timedOut && !indexedNothing(e)
|
|
6726
6733
|
);
|
|
6727
6734
|
const run2 = succeeded.find(matchesReportedCommand) ?? succeeded.find((e) => withCount.includes(e));
|
|
6728
6735
|
const runs = executions.filter(
|
|
@@ -6731,7 +6738,9 @@ function ingestOutcome(executions, repoRoot, ingestCommand) {
|
|
|
6731
6738
|
return {
|
|
6732
6739
|
run: run2,
|
|
6733
6740
|
attempt: ingestCommand ? newestFirst.find(matchesReportedCommand) : void 0,
|
|
6734
|
-
recordCount: parseIngestRecordCount(
|
|
6741
|
+
recordCount: parseIngestRecordCount(
|
|
6742
|
+
withCount.find((e) => !indexedNothing(e))?.output ?? ""
|
|
6743
|
+
),
|
|
6735
6744
|
attempts: run2 && !matchesReportedCommand(run2) ? runs + 1 : runs
|
|
6736
6745
|
};
|
|
6737
6746
|
}
|
|
@@ -6811,9 +6820,13 @@ function noRunReason({
|
|
|
6811
6820
|
}
|
|
6812
6821
|
return "no successful run was recorded";
|
|
6813
6822
|
}
|
|
6823
|
+
var EMPTY_INGEST_DETAIL = "The script read no records. A client-side or public key can return no rows because of access rules, so check that it reads with a server-side credential and that the data source has data.";
|
|
6814
6824
|
function ingestFailure(attempt, missingRunReason = "no successful run was recorded") {
|
|
6815
6825
|
if (!attempt) return { reason: missingRunReason };
|
|
6816
6826
|
if (!attempt.approved) return { reason: "you declined to run it" };
|
|
6827
|
+
if (ranButIndexedNothing(attempt)) {
|
|
6828
|
+
return { reason: "it ran but indexed 0 records", detail: EMPTY_INGEST_DETAIL };
|
|
6829
|
+
}
|
|
6817
6830
|
const detail = errorLine(attempt.output);
|
|
6818
6831
|
if (attempt.timedOut) {
|
|
6819
6832
|
const seconds = Math.round((attempt.durationMs ?? 0) / 1e3);
|
|
@@ -6854,8 +6867,8 @@ function briefSummary(summary) {
|
|
|
6854
6867
|
if (!firstLine) return "no summary given";
|
|
6855
6868
|
return firstLine.length > ERROR_SUMMARY_MAX_CHARS ? `${firstLine.slice(0, ERROR_SUMMARY_MAX_CHARS - 1)}\u2026` : firstLine;
|
|
6856
6869
|
}
|
|
6857
|
-
function ingestionRetryInstruction(reason) {
|
|
6858
|
-
return `The previous ingestion attempt ended with no successful run: ${reason}
|
|
6870
|
+
function ingestionRetryInstruction(reason, detail) {
|
|
6871
|
+
return `The previous ingestion attempt ended with no successful run: ${reason}.${detail ? ` ${detail}` : ""} Look in "${INGEST_DIR}/" for a script from that attempt and finish or fix it instead of starting over. Then call reviewScript and run the script as described above.`;
|
|
6859
6872
|
}
|
|
6860
6873
|
function validationRetryInstructions(validation) {
|
|
6861
6874
|
return [
|
|
@@ -7192,19 +7205,22 @@ async function implement(ctx, useCases = DEFAULT_IMPLEMENT_USE_CASES) {
|
|
|
7192
7205
|
await runIngestionAgent();
|
|
7193
7206
|
let outcome = ingestOutcome(executions, repoRoot, ingestCommand);
|
|
7194
7207
|
let failureAcknowledged = false;
|
|
7195
|
-
while (!outcome.run && !outcome.attempt) {
|
|
7196
|
-
const reason = await currentNoRunReason();
|
|
7208
|
+
while (!outcome.run && (!outcome.attempt || ranButIndexedNothing(outcome.attempt))) {
|
|
7209
|
+
const { reason, detail } = outcome.attempt ? ingestFailure(outcome.attempt) : { reason: await currentNoRunReason(), detail: void 0 };
|
|
7197
7210
|
const choice = await ctx.requestUserInput({
|
|
7198
7211
|
prompt: INGEST_AGENT_RETRY_PROMPT,
|
|
7199
7212
|
promptType: "multipleChoice",
|
|
7200
7213
|
options: [INGEST_RETRY.retry, INGEST_RETRY.skip],
|
|
7201
|
-
messages: [
|
|
7214
|
+
messages: [
|
|
7215
|
+
`\u26A0\uFE0F Records were not indexed \u2014 ${reason}.`,
|
|
7216
|
+
...detail ? [detail] : []
|
|
7217
|
+
]
|
|
7202
7218
|
});
|
|
7203
7219
|
if (choice !== INGEST_RETRY.retry) {
|
|
7204
7220
|
failureAcknowledged = true;
|
|
7205
7221
|
break;
|
|
7206
7222
|
}
|
|
7207
|
-
await runIngestionAgent([ingestionRetryInstruction(reason)]);
|
|
7223
|
+
await runIngestionAgent([ingestionRetryInstruction(reason, detail)]);
|
|
7208
7224
|
outcome = ingestOutcome(executions, repoRoot, ingestCommand);
|
|
7209
7225
|
}
|
|
7210
7226
|
while (!failureAcknowledged && !outcome.run && outcome.attempt?.approved) {
|
|
@@ -9859,7 +9875,7 @@ async function resetProjectState() {
|
|
|
9859
9875
|
// package.json with { type: 'json' }
|
|
9860
9876
|
var package_default2 = {
|
|
9861
9877
|
name: "@algolia/wizard",
|
|
9862
|
-
version: "0.
|
|
9878
|
+
version: "0.94.0",
|
|
9863
9879
|
description: "Magically implement Algolia functionality in your codebase",
|
|
9864
9880
|
type: "module",
|
|
9865
9881
|
engines: {
|