@algolia/wizard 0.9.0-rc.76.66 → 0.9.0-rc.78.68

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, pyproject.toml, Gemfile\u2026), configs & source to detect your stack. Read-only; nothing is uploaded."
1006
+ description: "reads your dependency manifests (package.json, pyproject.toml, Gemfile, go.mod\u2026), configs & source to detect your stack. Read-only; nothing is uploaded."
1007
1007
  },
1008
1008
  {
1009
1009
  tag: "WRITE",
@@ -2266,6 +2266,7 @@ function shellQuote(value) {
2266
2266
  // src/lib/languages.ts
2267
2267
  var ENTRYPOINT_TOKEN = "{entrypoint}";
2268
2268
  var INGEST_DIR = ".algolia-wizard";
2269
+ var VISIBLE_INGEST_DIR = "algolia-wizard";
2269
2270
  var PY_VENV = `${INGEST_DIR}/.venv`;
2270
2271
  var PY_VENV_PYTHON = `${PY_VENV}/bin/python`;
2271
2272
  var PY_REQUIREMENTS = `${INGEST_DIR}/requirements.txt`;
@@ -2414,6 +2415,80 @@ var LANGUAGE_PROFILES = {
2414
2415
  verification: [],
2415
2416
  envReadInstruction: "Read them from `ENV.fetch('NAME')`.",
2416
2417
  skipDirs: ["vendor", "tmp", "log", "coverage"]
2418
+ },
2419
+ php: {
2420
+ id: "php",
2421
+ displayName: "PHP",
2422
+ aliases: ["php", "laravel", "symfony"],
2423
+ manifests: ["composer.json"],
2424
+ packageManagers: [
2425
+ {
2426
+ id: "composer",
2427
+ // `composer require` both declares and installs, and unlike editing
2428
+ // composer.json by hand it can't leave composer.lock out of date (which
2429
+ // makes a later `composer install` refuse to run).
2430
+ dependency: { mode: "wizard-installs" },
2431
+ installSteps: [
2432
+ {
2433
+ argv: [
2434
+ "composer",
2435
+ "require",
2436
+ "algolia/algoliasearch-client-php:^4",
2437
+ "--no-interaction",
2438
+ // Repo post-install scripts are the project's code, not ours to
2439
+ // trigger; Laravel's package:discover also fails in a bare tree.
2440
+ "--no-scripts"
2441
+ ]
2442
+ }
2443
+ ],
2444
+ ingest: {
2445
+ kind: "auto",
2446
+ argv: ["php", ENTRYPOINT_TOKEN],
2447
+ entrypointExtensions: [".php"]
2448
+ }
2449
+ }
2450
+ ],
2451
+ sdk: {
2452
+ packageName: "algolia/algoliasearch-client-php",
2453
+ versionPin: "^4",
2454
+ docKey: "php"
2455
+ },
2456
+ ingestEntrypointExample: `${INGEST_DIR}/ingest.php`,
2457
+ verification: [],
2458
+ envReadInstruction: "Read them from `getenv('NAME')`.",
2459
+ skipDirs: ["vendor", "node_modules"]
2460
+ },
2461
+ go: {
2462
+ id: "go",
2463
+ displayName: "Go",
2464
+ aliases: ["go", "golang"],
2465
+ manifests: ["go.mod"],
2466
+ packageManagers: [
2467
+ {
2468
+ id: "gomod",
2469
+ // Imports in the generated file are the declaration; `go mod tidy`
2470
+ // resolves and fetches them — which only works because the script lives
2471
+ // outside INGEST_DIR (see VISIBLE_INGEST_DIR).
2472
+ dependency: { mode: "code-imports" },
2473
+ installSteps: [{ argv: ["go", "mod", "tidy"] }],
2474
+ ingest: {
2475
+ kind: "auto",
2476
+ argv: ["go", "run", ENTRYPOINT_TOKEN],
2477
+ entrypointExtensions: [".go"]
2478
+ }
2479
+ }
2480
+ ],
2481
+ sdk: {
2482
+ packageName: "github.com/algolia/algoliasearch-client-go/v4",
2483
+ versionPin: "v4",
2484
+ docKey: "go"
2485
+ },
2486
+ ingestEntrypointExample: `${VISIBLE_INGEST_DIR}/ingest.go`,
2487
+ verification: [
2488
+ { label: "go vet", argv: ["go", "vet", "./..."], requiresFile: "go.mod" }
2489
+ ],
2490
+ envReadInstruction: "Read them from `os.Getenv`.",
2491
+ skipDirs: ["vendor", "bin"]
2417
2492
  }
2418
2493
  };
2419
2494
  var DEFAULT_LANGUAGE_ID = "javascript";
@@ -3096,7 +3171,7 @@ var detectLanguageSchema = z16.object({
3096
3171
  var detectLanguage = () => runAgent({
3097
3172
  instructions: [
3098
3173
  "Analyze the codebase and determine the programming languages and frameworks used",
3099
- "Start from the dependency manifests: package.json, pyproject.toml, requirements.txt, Gemfile.",
3174
+ "Start from the dependency manifests: package.json, pyproject.toml, requirements.txt, Gemfile, composer.json, go.mod.",
3100
3175
  "List the language that owns the backend/data code first \u2014 that is the one an ingestion script will be written in.",
3101
3176
  "If a superset language is found, exclude the subset language. TS-over-JS.",
3102
3177
  "If a meta-framework is used, exclude the framework. Next-over-React.",
@@ -3149,7 +3224,7 @@ var MODE_CONFIG = {
3149
3224
  "Analyze the codebase to find the data entities (models) that should be ingested into Algolia.",
3150
3225
  "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).",
3151
3226
  "Inspect the source of each entity to extract real field names for attributes \u2014 do not guess or leave attributes empty.",
3152
- "Entities live wherever the stack keeps them: TypeScript interfaces or a Prisma schema, Django models.py, Rails app/models, Pydantic models.",
3227
+ "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.",
3153
3228
  "Prefer domain models (e.g. Document, Product, User) over framework or infrastructure types.",
3154
3229
  "Use as few tools as possible, but do not guess. If you cannot find any entities, return an empty array.",
3155
3230
  "Ignore directories that may be related to testing, like `/fixtures`, `/tests`, etc",
@@ -3172,7 +3247,7 @@ var MODE_CONFIG = {
3172
3247
  verification: {
3173
3248
  instructions: [
3174
3249
  "Analyze the codebase to determine which code-quality tools are available to validate changes.",
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.",
3250
+ "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.",
3176
3251
  'Return the tool names as an array, e.g. ["eslint", "prettier", "tsc"] or ["ruff", "mypy"].',
3177
3252
  "Use as few tools as possible, but do not guess. If you cannot find any, return an empty array.",
3178
3253
  "Ignore directories that may be related to testing, like `/fixtures`, `/tests`, etc",
@@ -3200,7 +3275,7 @@ async function runAnalysis(mode, extraInstructions = []) {
3200
3275
  // package.json
3201
3276
  var package_default = {
3202
3277
  name: "@algolia/wizard",
3203
- version: "0.9.0-rc.76.66",
3278
+ version: "0.9.0-rc.78.68",
3204
3279
  description: "Magically implement Algolia functionality in your codebase",
3205
3280
  type: "module",
3206
3281
  engines: {
@@ -18,6 +18,8 @@ Install the latest stable within the major; never pin an exact patch.
18
18
  | JavaScript/TypeScript | `algoliasearch` | `^5` |
19
19
  | Python | `algoliasearch` | `>=4,<5` |
20
20
  | Ruby | `algolia` | `~> 3.0` |
21
+ | PHP | `algolia/algoliasearch-client-php` | `^4` |
22
+ | Go | `github.com/algolia/algoliasearch-client-go/v4` | `v4` |
21
23
 
22
24
  ## Search UI
23
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algolia/wizard",
3
- "version": "0.9.0-rc.76.66",
3
+ "version": "0.9.0-rc.78.68",
4
4
  "description": "Magically implement Algolia functionality in your codebase",
5
5
  "type": "module",
6
6
  "engines": {