@algolia/wizard 0.9.0-rc.74.64 → 0.9.0-rc.76.66
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
CHANGED
|
@@ -1003,7 +1003,7 @@ var accessItems = [
|
|
|
1003
1003
|
{
|
|
1004
1004
|
tag: "READ",
|
|
1005
1005
|
title: "Project files",
|
|
1006
|
-
description: "reads your dependency manifests (package.json\u2026), configs & source to detect your stack. Read-only; nothing is uploaded."
|
|
1006
|
+
description: "reads your dependency manifests (package.json, pyproject.toml, Gemfile\u2026), configs & source to detect your stack. Read-only; nothing is uploaded."
|
|
1007
1007
|
},
|
|
1008
1008
|
{
|
|
1009
1009
|
tag: "WRITE",
|
|
@@ -2266,6 +2266,9 @@ function shellQuote(value) {
|
|
|
2266
2266
|
// src/lib/languages.ts
|
|
2267
2267
|
var ENTRYPOINT_TOKEN = "{entrypoint}";
|
|
2268
2268
|
var INGEST_DIR = ".algolia-wizard";
|
|
2269
|
+
var PY_VENV = `${INGEST_DIR}/.venv`;
|
|
2270
|
+
var PY_VENV_PYTHON = `${PY_VENV}/bin/python`;
|
|
2271
|
+
var PY_REQUIREMENTS = `${INGEST_DIR}/requirements.txt`;
|
|
2269
2272
|
var LANGUAGE_PROFILES = {
|
|
2270
2273
|
javascript: {
|
|
2271
2274
|
id: "javascript",
|
|
@@ -2308,6 +2311,109 @@ var LANGUAGE_PROFILES = {
|
|
|
2308
2311
|
verification: [],
|
|
2309
2312
|
envReadInstruction: "Read them from `process.env`.",
|
|
2310
2313
|
skipDirs: ["node_modules", "dist", "build", "coverage", ".next", "out"]
|
|
2314
|
+
},
|
|
2315
|
+
python: {
|
|
2316
|
+
id: "python",
|
|
2317
|
+
displayName: "Python",
|
|
2318
|
+
aliases: ["python", "python3", "py", "cpython"],
|
|
2319
|
+
manifests: [
|
|
2320
|
+
"pyproject.toml",
|
|
2321
|
+
"requirements.txt",
|
|
2322
|
+
"setup.py",
|
|
2323
|
+
"setup.cfg",
|
|
2324
|
+
"Pipfile"
|
|
2325
|
+
],
|
|
2326
|
+
// Deliberately one path for every Python repo: a wizard-owned venv under
|
|
2327
|
+
// .algolia-wizard. Reusing the project's uv/poetry environment would mean
|
|
2328
|
+
// mutating the developer's real dependency manifest and lockfile, and the
|
|
2329
|
+
// declare-here/install-there split is the main way ingestion silently ends
|
|
2330
|
+
// up without the SDK installed. The tradeoff: the script can import the
|
|
2331
|
+
// Algolia client and anything it declares itself, but not the project's own
|
|
2332
|
+
// packages (see the optional root-requirements step below).
|
|
2333
|
+
packageManagers: [
|
|
2334
|
+
{
|
|
2335
|
+
id: "pip-venv",
|
|
2336
|
+
dependency: { mode: "agent-declares", file: PY_REQUIREMENTS },
|
|
2337
|
+
installSteps: [
|
|
2338
|
+
{ argv: ["python3", "-m", "venv", PY_VENV] },
|
|
2339
|
+
{
|
|
2340
|
+
argv: [PY_VENV_PYTHON, "-m", "pip", "install", "-r", PY_REQUIREMENTS]
|
|
2341
|
+
},
|
|
2342
|
+
// Best-effort access to the project's own dependencies (DB drivers,
|
|
2343
|
+
// ORMs) when the repo pins them the classic way.
|
|
2344
|
+
{
|
|
2345
|
+
argv: [
|
|
2346
|
+
PY_VENV_PYTHON,
|
|
2347
|
+
"-m",
|
|
2348
|
+
"pip",
|
|
2349
|
+
"install",
|
|
2350
|
+
"-r",
|
|
2351
|
+
"requirements.txt"
|
|
2352
|
+
],
|
|
2353
|
+
requiresFile: "requirements.txt",
|
|
2354
|
+
optional: true
|
|
2355
|
+
}
|
|
2356
|
+
],
|
|
2357
|
+
ingest: {
|
|
2358
|
+
kind: "auto",
|
|
2359
|
+
argv: [PY_VENV_PYTHON, ENTRYPOINT_TOKEN],
|
|
2360
|
+
entrypointExtensions: [".py"]
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
],
|
|
2364
|
+
sdk: {
|
|
2365
|
+
packageName: "algoliasearch",
|
|
2366
|
+
versionPin: ">=4,<5",
|
|
2367
|
+
docKey: "python"
|
|
2368
|
+
},
|
|
2369
|
+
ingestEntrypointExample: `${INGEST_DIR}/ingest.py`,
|
|
2370
|
+
localSourceCaveat: {
|
|
2371
|
+
unless: "requirements.txt",
|
|
2372
|
+
message: "The ingestion script runs in its own environment under .algolia-wizard/, so it can install the Algolia client but not this project's packages (no requirements.txt to install from). If the script needs your database driver or ORM, add those packages to .algolia-wizard/requirements.txt and re-run the install."
|
|
2373
|
+
},
|
|
2374
|
+
verification: [
|
|
2375
|
+
{
|
|
2376
|
+
// -x skips the venv this same directory holds; without it the check
|
|
2377
|
+
// compiles every installed package instead of the generated script.
|
|
2378
|
+
label: "python compileall",
|
|
2379
|
+
argv: ["python3", "-m", "compileall", "-q", "-x", "[.]venv", INGEST_DIR],
|
|
2380
|
+
requiresFile: INGEST_DIR
|
|
2381
|
+
}
|
|
2382
|
+
],
|
|
2383
|
+
envReadInstruction: "Read them from `os.environ`.",
|
|
2384
|
+
skipDirs: [
|
|
2385
|
+
"venv",
|
|
2386
|
+
"__pycache__",
|
|
2387
|
+
"site-packages",
|
|
2388
|
+
"dist",
|
|
2389
|
+
"build",
|
|
2390
|
+
"htmlcov"
|
|
2391
|
+
]
|
|
2392
|
+
},
|
|
2393
|
+
ruby: {
|
|
2394
|
+
id: "ruby",
|
|
2395
|
+
displayName: "Ruby",
|
|
2396
|
+
aliases: ["ruby", "rb", "rails", "ruby on rails", "rubyonrails"],
|
|
2397
|
+
manifests: ["Gemfile", "*.gemspec"],
|
|
2398
|
+
packageManagers: [
|
|
2399
|
+
{
|
|
2400
|
+
id: "bundler",
|
|
2401
|
+
dependency: { mode: "agent-declares", file: "Gemfile" },
|
|
2402
|
+
installSteps: [{ argv: ["bundle", "install"] }],
|
|
2403
|
+
ingest: {
|
|
2404
|
+
kind: "auto",
|
|
2405
|
+
argv: ["bundle", "exec", "ruby", ENTRYPOINT_TOKEN],
|
|
2406
|
+
entrypointExtensions: [".rb"]
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
],
|
|
2410
|
+
sdk: { packageName: "algolia", versionPin: "~> 3.0", docKey: "ruby" },
|
|
2411
|
+
ingestEntrypointExample: `${INGEST_DIR}/ingest.rb`,
|
|
2412
|
+
// Ruby has no directory-level syntax check (`ruby -c` is one file at a
|
|
2413
|
+
// time), so verification relies on the agent's own review here.
|
|
2414
|
+
verification: [],
|
|
2415
|
+
envReadInstruction: "Read them from `ENV.fetch('NAME')`.",
|
|
2416
|
+
skipDirs: ["vendor", "tmp", "log", "coverage"]
|
|
2311
2417
|
}
|
|
2312
2418
|
};
|
|
2313
2419
|
var DEFAULT_LANGUAGE_ID = "javascript";
|
|
@@ -2990,7 +3096,7 @@ var detectLanguageSchema = z16.object({
|
|
|
2990
3096
|
var detectLanguage = () => runAgent({
|
|
2991
3097
|
instructions: [
|
|
2992
3098
|
"Analyze the codebase and determine the programming languages and frameworks used",
|
|
2993
|
-
"Start from the dependency manifests: package.json.",
|
|
3099
|
+
"Start from the dependency manifests: package.json, pyproject.toml, requirements.txt, Gemfile.",
|
|
2994
3100
|
"List the language that owns the backend/data code first \u2014 that is the one an ingestion script will be written in.",
|
|
2995
3101
|
"If a superset language is found, exclude the subset language. TS-over-JS.",
|
|
2996
3102
|
"If a meta-framework is used, exclude the framework. Next-over-React.",
|
|
@@ -3043,7 +3149,7 @@ var MODE_CONFIG = {
|
|
|
3043
3149
|
"Analyze the codebase to find the data entities (models) that should be ingested into Algolia.",
|
|
3044
3150
|
"For each entity, return its name, the file path(s) where it is defined, and its indexable attribute keys (the fields a user would search or filter on).",
|
|
3045
3151
|
"Inspect the source of each entity to extract real field names for attributes \u2014 do not guess or leave attributes empty.",
|
|
3046
|
-
"Entities live wherever the stack keeps them: TypeScript interfaces or a Prisma schema.",
|
|
3152
|
+
"Entities live wherever the stack keeps them: TypeScript interfaces or a Prisma schema, Django models.py, Rails app/models, Pydantic models.",
|
|
3047
3153
|
"Prefer domain models (e.g. Document, Product, User) over framework or infrastructure types.",
|
|
3048
3154
|
"Use as few tools as possible, but do not guess. If you cannot find any entities, return an empty array.",
|
|
3049
3155
|
"Ignore directories that may be related to testing, like `/fixtures`, `/tests`, etc",
|
|
@@ -3066,8 +3172,8 @@ var MODE_CONFIG = {
|
|
|
3066
3172
|
verification: {
|
|
3067
3173
|
instructions: [
|
|
3068
3174
|
"Analyze the codebase to determine which code-quality tools are available to validate changes.",
|
|
3069
|
-
"Look at the dependency manifest and config files for the project's languages: package.json scripts with tsconfig/eslint/prettier.",
|
|
3070
|
-
'Return the tool names as an array, e.g. ["eslint", "prettier", "tsc"].',
|
|
3175
|
+
"Look at the dependency manifest and config files for the project's languages: package.json scripts with tsconfig/eslint/prettier, pyproject.toml or setup.cfg (ruff, mypy, black), Gemfile with .rubocop.yml.",
|
|
3176
|
+
'Return the tool names as an array, e.g. ["eslint", "prettier", "tsc"] or ["ruff", "mypy"].',
|
|
3071
3177
|
"Use as few tools as possible, but do not guess. If you cannot find any, return an empty array.",
|
|
3072
3178
|
"Ignore directories that may be related to testing, like `/fixtures`, `/tests`, etc",
|
|
3073
3179
|
"When done, call reportStatus"
|
|
@@ -3094,7 +3200,7 @@ async function runAnalysis(mode, extraInstructions = []) {
|
|
|
3094
3200
|
// package.json
|
|
3095
3201
|
var package_default = {
|
|
3096
3202
|
name: "@algolia/wizard",
|
|
3097
|
-
version: "0.9.0-rc.
|
|
3203
|
+
version: "0.9.0-rc.76.66",
|
|
3098
3204
|
description: "Magically implement Algolia functionality in your codebase",
|
|
3099
3205
|
type: "module",
|
|
3100
3206
|
engines: {
|
|
@@ -16,6 +16,8 @@ Install the latest stable within the major; never pin an exact patch.
|
|
|
16
16
|
| Language | Package | Version |
|
|
17
17
|
| --- | --- | --- |
|
|
18
18
|
| JavaScript/TypeScript | `algoliasearch` | `^5` |
|
|
19
|
+
| Python | `algoliasearch` | `>=4,<5` |
|
|
20
|
+
| Ruby | `algolia` | `~> 3.0` |
|
|
19
21
|
|
|
20
22
|
## Search UI
|
|
21
23
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Save records (algoliasearch v4)
|
|
2
|
+
|
|
3
|
+
Adds records to an index. Write op — use a **write key**, server-side only.
|
|
4
|
+
|
|
5
|
+
Dependency: `algoliasearch>=4,<5` (PyPI).
|
|
6
|
+
|
|
7
|
+
v4 is async-first: `SearchClient` is coroutine-based (every method needs `await`).
|
|
8
|
+
**`SearchClientSync` is the sync twin** — use it in a standalone script, via `with`
|
|
9
|
+
so the transport closes.
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
import os
|
|
13
|
+
|
|
14
|
+
from algoliasearch.search.client import SearchClientSync
|
|
15
|
+
|
|
16
|
+
app_id = os.environ["ALGOLIA_APPLICATION_ID"]
|
|
17
|
+
api_key = os.environ["ALGOLIA_WRITE_API_KEY"]
|
|
18
|
+
index_name = "playlists"
|
|
19
|
+
records = [{"objectID": "1", "name": "Hot 100", "visibility": "public"}]
|
|
20
|
+
|
|
21
|
+
with SearchClientSync(app_id, api_key) as client:
|
|
22
|
+
responses = client.save_objects(
|
|
23
|
+
index_name=index_name,
|
|
24
|
+
objects=records,
|
|
25
|
+
wait_for_tasks=True,
|
|
26
|
+
)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
save_objects(
|
|
31
|
+
index_name: str, # required
|
|
32
|
+
objects: Iterable[Dict[str, Any]], # required
|
|
33
|
+
wait_for_tasks: bool = False,
|
|
34
|
+
batch_size: int = 1000,
|
|
35
|
+
) -> List[BatchResponse] # one entry per 1,000-record batch
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`BatchResponse` attributes are **snake_case**: `r.task_id`, `r.object_ids` (the
|
|
39
|
+
wire keys are `taskID`/`objectIDs`). It is a list — never treat it as one object.
|
|
40
|
+
|
|
41
|
+
Read records from a JSON file:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
import json
|
|
45
|
+
|
|
46
|
+
with open(records_path, encoding="utf-8") as f:
|
|
47
|
+
records = json.load(f)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
After a successful ingest, print `ALGOLIA_WIZARD_RECORD_COUNT=<n>` as the last
|
|
51
|
+
stdout line.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Save records (algolia v3)
|
|
2
|
+
|
|
3
|
+
Adds records to an index. Write op — use a **write key**, server-side only.
|
|
4
|
+
|
|
5
|
+
Dependency: gem `algolia`, `~> 3.0` (`gem 'algolia', '~> 3.0'`).
|
|
6
|
+
|
|
7
|
+
`require "algolia"` (gem name is `algolia`, not `algoliasearch`). Build the client
|
|
8
|
+
with `Algolia::SearchClient.create`.
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
require "algolia"
|
|
12
|
+
|
|
13
|
+
app_id = ENV.fetch("ALGOLIA_APPLICATION_ID")
|
|
14
|
+
api_key = ENV.fetch("ALGOLIA_WRITE_API_KEY")
|
|
15
|
+
index_name = "playlists"
|
|
16
|
+
|
|
17
|
+
client = Algolia::SearchClient.create(app_id, api_key)
|
|
18
|
+
|
|
19
|
+
records = [{ "objectID" => "1", "name" => "Hot 100", "visibility" => "public" }]
|
|
20
|
+
|
|
21
|
+
responses = client.save_objects(index_name, records, true)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
save_objects(
|
|
26
|
+
index_name, # String, required
|
|
27
|
+
objects, # Array<Hash>, required
|
|
28
|
+
wait_for_tasks = false,
|
|
29
|
+
batch_size = 1000,
|
|
30
|
+
request_options = {}
|
|
31
|
+
) # => Array<Algolia::Search::BatchResponse>, one entry per 1,000-record batch
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Args are **positional**, and every method/field is **snake_case**: read
|
|
35
|
+
`r.task_id` and `r.object_ids`, not `taskID`/`objectIDs`. The return value is an
|
|
36
|
+
array — never treat it as one object.
|
|
37
|
+
|
|
38
|
+
Read records from a JSON file:
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
require "json"
|
|
42
|
+
|
|
43
|
+
records = JSON.parse(File.read(records_path))
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
After a successful ingest, print `ALGOLIA_WIZARD_RECORD_COUNT=<n>` as the last
|
|
47
|
+
stdout line (`puts "ALGOLIA_WIZARD_RECORD_COUNT=#{records.length}"`), with no
|
|
48
|
+
other output after it.
|