@algolia/wizard 0.8.0-rc.60.48 → 0.8.0-rc.63.52
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
|
@@ -907,7 +907,7 @@ var accessItems = [
|
|
|
907
907
|
{
|
|
908
908
|
tag: "READ",
|
|
909
909
|
title: "Project files",
|
|
910
|
-
description: "reads your dependency manifests (package.json, pyproject.toml\u2026), configs & source to detect your stack. Read-only; nothing is uploaded."
|
|
910
|
+
description: "reads your dependency manifests (package.json, pyproject.toml, Gemfile, go.mod\u2026), configs & source to detect your stack. Read-only; nothing is uploaded."
|
|
911
911
|
},
|
|
912
912
|
{
|
|
913
913
|
tag: "WRITE",
|
|
@@ -2206,6 +2206,7 @@ function shellQuote(value) {
|
|
|
2206
2206
|
// src/lib/languages.ts
|
|
2207
2207
|
var ENTRYPOINT_TOKEN = "{entrypoint}";
|
|
2208
2208
|
var INGEST_DIR = ".algolia-wizard";
|
|
2209
|
+
var VISIBLE_INGEST_DIR = "algolia-wizard";
|
|
2209
2210
|
var PY_VENV = `${INGEST_DIR}/.venv`;
|
|
2210
2211
|
var PY_VENV_PYTHON = `${PY_VENV}/bin/python`;
|
|
2211
2212
|
var PY_REQUIREMENTS = `${INGEST_DIR}/requirements.txt`;
|
|
@@ -2329,6 +2330,105 @@ var LANGUAGE_PROFILES = {
|
|
|
2329
2330
|
"build",
|
|
2330
2331
|
"htmlcov"
|
|
2331
2332
|
]
|
|
2333
|
+
},
|
|
2334
|
+
ruby: {
|
|
2335
|
+
id: "ruby",
|
|
2336
|
+
displayName: "Ruby",
|
|
2337
|
+
aliases: ["ruby", "rb", "rails", "ruby on rails", "rubyonrails"],
|
|
2338
|
+
manifests: ["Gemfile", "*.gemspec"],
|
|
2339
|
+
packageManagers: [
|
|
2340
|
+
{
|
|
2341
|
+
id: "bundler",
|
|
2342
|
+
dependency: { mode: "agent-declares", file: "Gemfile" },
|
|
2343
|
+
installSteps: [{ argv: ["bundle", "install"] }],
|
|
2344
|
+
ingest: {
|
|
2345
|
+
kind: "auto",
|
|
2346
|
+
argv: ["bundle", "exec", "ruby", ENTRYPOINT_TOKEN],
|
|
2347
|
+
entrypointExtensions: [".rb"]
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
],
|
|
2351
|
+
sdk: { packageName: "algolia", versionPin: "~> 3.0", docKey: "ruby" },
|
|
2352
|
+
ingestEntrypointExample: `${INGEST_DIR}/ingest.rb`,
|
|
2353
|
+
// Ruby has no directory-level syntax check (`ruby -c` is one file at a
|
|
2354
|
+
// time), so verification relies on the agent's own review here.
|
|
2355
|
+
verification: [],
|
|
2356
|
+
envReadInstruction: "Read them from `ENV.fetch('NAME')`.",
|
|
2357
|
+
skipDirs: ["vendor", "tmp", "log", "coverage"]
|
|
2358
|
+
},
|
|
2359
|
+
php: {
|
|
2360
|
+
id: "php",
|
|
2361
|
+
displayName: "PHP",
|
|
2362
|
+
aliases: ["php", "laravel", "symfony"],
|
|
2363
|
+
manifests: ["composer.json"],
|
|
2364
|
+
packageManagers: [
|
|
2365
|
+
{
|
|
2366
|
+
id: "composer",
|
|
2367
|
+
// `composer require` both declares and installs, and unlike editing
|
|
2368
|
+
// composer.json by hand it can't leave composer.lock out of date (which
|
|
2369
|
+
// makes a later `composer install` refuse to run).
|
|
2370
|
+
dependency: { mode: "wizard-installs" },
|
|
2371
|
+
installSteps: [
|
|
2372
|
+
{
|
|
2373
|
+
argv: [
|
|
2374
|
+
"composer",
|
|
2375
|
+
"require",
|
|
2376
|
+
"algolia/algoliasearch-client-php:^4",
|
|
2377
|
+
"--no-interaction",
|
|
2378
|
+
// Repo post-install scripts are the project's code, not ours to
|
|
2379
|
+
// trigger; Laravel's package:discover also fails in a bare tree.
|
|
2380
|
+
"--no-scripts"
|
|
2381
|
+
]
|
|
2382
|
+
}
|
|
2383
|
+
],
|
|
2384
|
+
ingest: {
|
|
2385
|
+
kind: "auto",
|
|
2386
|
+
argv: ["php", ENTRYPOINT_TOKEN],
|
|
2387
|
+
entrypointExtensions: [".php"]
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
],
|
|
2391
|
+
sdk: {
|
|
2392
|
+
packageName: "algolia/algoliasearch-client-php",
|
|
2393
|
+
versionPin: "^4",
|
|
2394
|
+
docKey: "php"
|
|
2395
|
+
},
|
|
2396
|
+
ingestEntrypointExample: `${INGEST_DIR}/ingest.php`,
|
|
2397
|
+
verification: [],
|
|
2398
|
+
envReadInstruction: "Read them from `getenv('NAME')`.",
|
|
2399
|
+
skipDirs: ["vendor", "node_modules"]
|
|
2400
|
+
},
|
|
2401
|
+
go: {
|
|
2402
|
+
id: "go",
|
|
2403
|
+
displayName: "Go",
|
|
2404
|
+
aliases: ["go", "golang"],
|
|
2405
|
+
manifests: ["go.mod"],
|
|
2406
|
+
packageManagers: [
|
|
2407
|
+
{
|
|
2408
|
+
id: "gomod",
|
|
2409
|
+
// Imports in the generated file are the declaration; `go mod tidy`
|
|
2410
|
+
// resolves and fetches them — which only works because the script lives
|
|
2411
|
+
// outside INGEST_DIR (see VISIBLE_INGEST_DIR).
|
|
2412
|
+
dependency: { mode: "code-imports" },
|
|
2413
|
+
installSteps: [{ argv: ["go", "mod", "tidy"] }],
|
|
2414
|
+
ingest: {
|
|
2415
|
+
kind: "auto",
|
|
2416
|
+
argv: ["go", "run", ENTRYPOINT_TOKEN],
|
|
2417
|
+
entrypointExtensions: [".go"]
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
],
|
|
2421
|
+
sdk: {
|
|
2422
|
+
packageName: "github.com/algolia/algoliasearch-client-go/v4",
|
|
2423
|
+
versionPin: "v4",
|
|
2424
|
+
docKey: "go"
|
|
2425
|
+
},
|
|
2426
|
+
ingestEntrypointExample: `${VISIBLE_INGEST_DIR}/ingest.go`,
|
|
2427
|
+
verification: [
|
|
2428
|
+
{ label: "go vet", argv: ["go", "vet", "./..."], requiresFile: "go.mod" }
|
|
2429
|
+
],
|
|
2430
|
+
envReadInstruction: "Read them from `os.Getenv`.",
|
|
2431
|
+
skipDirs: ["vendor", "bin"]
|
|
2332
2432
|
}
|
|
2333
2433
|
};
|
|
2334
2434
|
var DEFAULT_LANGUAGE_ID = "javascript";
|
|
@@ -3011,7 +3111,7 @@ var detectLanguageSchema = z16.object({
|
|
|
3011
3111
|
var detectLanguage = () => runAgent({
|
|
3012
3112
|
instructions: [
|
|
3013
3113
|
"Analyze the codebase and determine the programming languages and frameworks used",
|
|
3014
|
-
"Start from the dependency manifests: package.json, pyproject.toml, requirements.txt.",
|
|
3114
|
+
"Start from the dependency manifests: package.json, pyproject.toml, requirements.txt, Gemfile, composer.json, go.mod.",
|
|
3015
3115
|
"List the language that owns the backend/data code first \u2014 that is the one an ingestion script will be written in.",
|
|
3016
3116
|
"If a superset language is found, exclude the subset language. TS-over-JS.",
|
|
3017
3117
|
"If a meta-framework is used, exclude the framework. Next-over-React.",
|
|
@@ -3064,7 +3164,7 @@ var MODE_CONFIG = {
|
|
|
3064
3164
|
"Analyze the codebase to find the data entities (models) that should be ingested into Algolia.",
|
|
3065
3165
|
"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).",
|
|
3066
3166
|
"Inspect the source of each entity to extract real field names for attributes \u2014 do not guess or leave attributes empty.",
|
|
3067
|
-
"Entities live wherever the stack keeps them: TypeScript interfaces or a Prisma schema, Django models.py, Pydantic models.",
|
|
3167
|
+
"Entities live wherever the stack keeps them: TypeScript interfaces or a Prisma schema, Django models.py, Rails app/models, Laravel Eloquent models, Go structs, Pydantic models.",
|
|
3068
3168
|
"Prefer domain models (e.g. Document, Product, User) over framework or infrastructure types.",
|
|
3069
3169
|
"Use as few tools as possible, but do not guess. If you cannot find any entities, return an empty array.",
|
|
3070
3170
|
"Ignore directories that may be related to testing, like `/fixtures`, `/tests`, etc",
|
|
@@ -3087,7 +3187,7 @@ var MODE_CONFIG = {
|
|
|
3087
3187
|
verification: {
|
|
3088
3188
|
instructions: [
|
|
3089
3189
|
"Analyze the codebase to determine which code-quality tools are available to validate changes.",
|
|
3090
|
-
"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).",
|
|
3190
|
+
"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, composer.json scripts (phpstan, pint), go.mod with a golangci-lint config.",
|
|
3091
3191
|
'Return the tool names as an array, e.g. ["eslint", "prettier", "tsc"] or ["ruff", "mypy"].',
|
|
3092
3192
|
"Use as few tools as possible, but do not guess. If you cannot find any, return an empty array.",
|
|
3093
3193
|
"Ignore directories that may be related to testing, like `/fixtures`, `/tests`, etc",
|
|
@@ -3115,7 +3215,7 @@ async function runAnalysis(mode, extraInstructions = []) {
|
|
|
3115
3215
|
// package.json
|
|
3116
3216
|
var package_default = {
|
|
3117
3217
|
name: "@algolia/wizard",
|
|
3118
|
-
version: "0.8.0-rc.
|
|
3218
|
+
version: "0.8.0-rc.63.52",
|
|
3119
3219
|
description: "Magically implement Algolia functionality in your codebase",
|
|
3120
3220
|
type: "module",
|
|
3121
3221
|
engines: {
|
|
@@ -17,6 +17,9 @@ Install the latest stable within the major; never pin an exact patch.
|
|
|
17
17
|
| --- | --- | --- |
|
|
18
18
|
| JavaScript/TypeScript | `algoliasearch` | `^5` |
|
|
19
19
|
| Python | `algoliasearch` | `>=4,<5` |
|
|
20
|
+
| Ruby | `algolia` | `~> 3.0` |
|
|
21
|
+
| PHP | `algolia/algoliasearch-client-php` | `^4` |
|
|
22
|
+
| Go | `github.com/algolia/algoliasearch-client-go/v4` | `v4` |
|
|
20
23
|
|
|
21
24
|
## Search UI
|
|
22
25
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Save records (algoliasearch-client-go v4)
|
|
2
|
+
|
|
3
|
+
Adds records to an index. Write op — use a **write key**, server-side only.
|
|
4
|
+
|
|
5
|
+
Imports are the dependency declaration; `go mod tidy` resolves
|
|
6
|
+
`github.com/algolia/algoliasearch-client-go/v4`. Standalone `package main` file,
|
|
7
|
+
run with `go run`. Nothing panics on its own — every call returns `(value, error)`.
|
|
8
|
+
|
|
9
|
+
```go
|
|
10
|
+
package main
|
|
11
|
+
|
|
12
|
+
import (
|
|
13
|
+
"fmt"
|
|
14
|
+
"os"
|
|
15
|
+
|
|
16
|
+
"github.com/algolia/algoliasearch-client-go/v4/algolia/search"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
func main() {
|
|
20
|
+
client, err := search.NewClient(os.Getenv("ALGOLIA_APPLICATION_ID"), os.Getenv("ALGOLIA_WRITE_API_KEY"))
|
|
21
|
+
if err != nil {
|
|
22
|
+
panic(err) // NewClient fails on an empty/invalid app ID or key
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
indexName := "products"
|
|
26
|
+
records := []map[string]any{{"objectID": "1", "name": "Hot 100"}}
|
|
27
|
+
|
|
28
|
+
if _, err := client.SaveObjects(indexName, records, search.WithWaitForTasks(true)); err != nil {
|
|
29
|
+
panic(err)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
fmt.Printf("ALGOLIA_WIZARD_RECORD_COUNT=%d\n", len(records))
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```go
|
|
37
|
+
func (c *APIClient) SaveObjects(
|
|
38
|
+
indexName string,
|
|
39
|
+
objects []map[string]any, // maps only, each with an "objectID"
|
|
40
|
+
opts ...ChunkedBatchOption, // search.WithWaitForTasks(bool), search.WithBatchSize(int) (default 1000)
|
|
41
|
+
) ([]BatchResponse, error) // BatchResponse{ TaskID int64; ObjectIDs []string }
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
One `BatchResponse` per batch of 1,000, not per record — `len(res)` is the batch count.
|
|
45
|
+
|
|
46
|
+
Read records from a JSON file:
|
|
47
|
+
|
|
48
|
+
```go
|
|
49
|
+
import "encoding/json"
|
|
50
|
+
|
|
51
|
+
content, err := os.ReadFile("records.json")
|
|
52
|
+
if err != nil {
|
|
53
|
+
panic(err)
|
|
54
|
+
}
|
|
55
|
+
var records []map[string]any
|
|
56
|
+
if err := json.Unmarshal(content, &records); err != nil {
|
|
57
|
+
panic(err)
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
After a successful ingest print `ALGOLIA_WIZARD_RECORD_COUNT=<n>` (n = records
|
|
62
|
+
read, not `len(res)`) as the last stdout line, trailing newline included.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Save records (algoliasearch-client-php v4)
|
|
2
|
+
|
|
3
|
+
Adds records to an index. Write op — use a **write key**, server-side only.
|
|
4
|
+
|
|
5
|
+
Dependency: `algolia/algoliasearch-client-php` `^4` — the wizard runs
|
|
6
|
+
`composer require` for you; do not hand-edit `composer.json`.
|
|
7
|
+
|
|
8
|
+
`require 'vendor/autoload.php'` before anything else, or the class won't resolve
|
|
9
|
+
(from `.algolia-wizard/` the path is `__DIR__.'/../vendor/autoload.php'`).
|
|
10
|
+
|
|
11
|
+
```php
|
|
12
|
+
<?php
|
|
13
|
+
|
|
14
|
+
require __DIR__.'/../vendor/autoload.php';
|
|
15
|
+
|
|
16
|
+
use Algolia\AlgoliaSearch\Api\SearchClient;
|
|
17
|
+
|
|
18
|
+
$appId = getenv('ALGOLIA_APPLICATION_ID');
|
|
19
|
+
$apiKey = getenv('ALGOLIA_WRITE_API_KEY');
|
|
20
|
+
$indexName = 'playlists';
|
|
21
|
+
|
|
22
|
+
$client = SearchClient::create($appId, $apiKey);
|
|
23
|
+
$records = [['objectID' => '1', 'name' => 'Hot 100', 'visibility' => 'public']];
|
|
24
|
+
|
|
25
|
+
$responses = $client->saveObjects($indexName, $records, true);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```php
|
|
29
|
+
saveObjects(
|
|
30
|
+
string $indexName, // required
|
|
31
|
+
array $objects, // required
|
|
32
|
+
bool $waitForTasks = false,
|
|
33
|
+
int $batchSize = 1000,
|
|
34
|
+
array $requestOptions = []
|
|
35
|
+
) // => array of batch responses, one per 1,000-record batch
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Unlike the typed clients, PHP returns **plain associative arrays**, not objects:
|
|
39
|
+
`$responses[0]['taskID']`, `$responses[0]['objectIDs']`. Always an array of them —
|
|
40
|
+
never treat it as one response.
|
|
41
|
+
|
|
42
|
+
Read records from a JSON file:
|
|
43
|
+
|
|
44
|
+
```php
|
|
45
|
+
$records = json_decode(file_get_contents($recordsPath), true);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
After a successful ingest, print `ALGOLIA_WIZARD_RECORD_COUNT=<n>` as the last
|
|
49
|
+
stdout line (`echo 'ALGOLIA_WIZARD_RECORD_COUNT='.count($records)."\n";`), with no
|
|
50
|
+
other output after it.
|
|
@@ -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.
|