@algolia/wizard 0.9.0-rc.79.69 → 0.9.0-rc.80.70
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
|
@@ -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 CSHARP_PROJECT = `${INGEST_DIR}/ingest/ingest.csproj`;
|
|
2269
2270
|
var VISIBLE_INGEST_DIR = "algolia-wizard";
|
|
2270
2271
|
var PY_VENV = `${INGEST_DIR}/.venv`;
|
|
2271
2272
|
var PY_VENV_PYTHON = `${PY_VENV}/bin/python`;
|
|
@@ -2638,6 +2639,44 @@ var LANGUAGE_PROFILES = {
|
|
|
2638
2639
|
// that some repos use it for source; scanning it is cheap, missing source
|
|
2639
2640
|
// is not.
|
|
2640
2641
|
skipDirs: ["target"]
|
|
2642
|
+
},
|
|
2643
|
+
csharp: {
|
|
2644
|
+
id: "csharp",
|
|
2645
|
+
displayName: "C#",
|
|
2646
|
+
aliases: ["c#", "csharp", "cs", ".net", "dotnet", "net", "asp.net"],
|
|
2647
|
+
manifests: ["*.csproj", "*.sln", "global.json"],
|
|
2648
|
+
packageManagers: [
|
|
2649
|
+
{
|
|
2650
|
+
id: "dotnet",
|
|
2651
|
+
// A self-contained project under .algolia-wizard keeps the ingest script
|
|
2652
|
+
// out of the repo's own build graph.
|
|
2653
|
+
dependency: { mode: "agent-declares", file: CSHARP_PROJECT },
|
|
2654
|
+
installSteps: [{ argv: ["dotnet", "restore", CSHARP_PROJECT] }],
|
|
2655
|
+
ingest: {
|
|
2656
|
+
kind: "auto",
|
|
2657
|
+
argv: ["dotnet", "run", "--project", ENTRYPOINT_TOKEN],
|
|
2658
|
+
entrypointExtensions: [".csproj"]
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
],
|
|
2662
|
+
sdk: {
|
|
2663
|
+
packageName: "Algolia.Search",
|
|
2664
|
+
versionPin: "7.*",
|
|
2665
|
+
docKey: "csharp"
|
|
2666
|
+
},
|
|
2667
|
+
ingestEntrypointExample: CSHARP_PROJECT,
|
|
2668
|
+
verification: [
|
|
2669
|
+
{
|
|
2670
|
+
label: "dotnet build",
|
|
2671
|
+
argv: ["dotnet", "build", CSHARP_PROJECT, "--nologo"],
|
|
2672
|
+
requiresFile: CSHARP_PROJECT
|
|
2673
|
+
}
|
|
2674
|
+
],
|
|
2675
|
+
envReadInstruction: 'Read them from `Environment.GetEnvironmentVariable("NAME")`.',
|
|
2676
|
+
// Deliberately not `packages`: modern .NET uses PackageReference, and
|
|
2677
|
+
// `packages/` is where pnpm/Lerna/Turborepo monorepos keep all their source —
|
|
2678
|
+
// skipping it would hide the entities the scan is looking for.
|
|
2679
|
+
skipDirs: ["bin", "obj"]
|
|
2641
2680
|
}
|
|
2642
2681
|
};
|
|
2643
2682
|
var DEFAULT_LANGUAGE_ID = "javascript";
|
|
@@ -3320,7 +3359,7 @@ var detectLanguageSchema = z16.object({
|
|
|
3320
3359
|
var detectLanguage = () => runAgent({
|
|
3321
3360
|
instructions: [
|
|
3322
3361
|
"Analyze the codebase and determine the programming languages and frameworks used",
|
|
3323
|
-
"Start from the dependency manifests: package.json, pyproject.toml, requirements.txt, Gemfile, composer.json, go.mod, pom.xml, build.gradle(.kts), build.sbt.",
|
|
3362
|
+
"Start from the dependency manifests: package.json, pyproject.toml, requirements.txt, Gemfile, composer.json, go.mod, pom.xml, build.gradle(.kts), *.csproj, build.sbt.",
|
|
3324
3363
|
"List the language that owns the backend/data code first \u2014 that is the one an ingestion script will be written in.",
|
|
3325
3364
|
"If a superset language is found, exclude the subset language. TS-over-JS. Kotlin-over-Java when Kotlin is primary.",
|
|
3326
3365
|
"If a meta-framework is used, exclude the framework. Next-over-React.",
|
|
@@ -3373,7 +3412,7 @@ var MODE_CONFIG = {
|
|
|
3373
3412
|
"Analyze the codebase to find the data entities (models) that should be ingested into Algolia.",
|
|
3374
3413
|
"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).",
|
|
3375
3414
|
"Inspect the source of each entity to extract real field names for attributes \u2014 do not guess or leave attributes empty.",
|
|
3376
|
-
"Entities live wherever the stack keeps them: TypeScript interfaces or a Prisma schema, Django models.py, Rails app/models, Laravel Eloquent models, JPA @Entity classes, Go structs, Pydantic models.",
|
|
3415
|
+
"Entities live wherever the stack keeps them: TypeScript interfaces or a Prisma schema, Django models.py, Rails app/models, Laravel Eloquent models, JPA @Entity classes, Go structs, C# entity classes, Pydantic models.",
|
|
3377
3416
|
"Prefer domain models (e.g. Document, Product, User) over framework or infrastructure types.",
|
|
3378
3417
|
"Use as few tools as possible, but do not guess. If you cannot find any entities, return an empty array.",
|
|
3379
3418
|
"Ignore directories that may be related to testing, like `/fixtures`, `/tests`, etc",
|
|
@@ -3396,7 +3435,7 @@ var MODE_CONFIG = {
|
|
|
3396
3435
|
verification: {
|
|
3397
3436
|
instructions: [
|
|
3398
3437
|
"Analyze the codebase to determine which code-quality tools are available to validate changes.",
|
|
3399
|
-
"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, Maven/Gradle verification tasks.",
|
|
3438
|
+
"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, Maven/Gradle verification tasks, .NET analyzers.",
|
|
3400
3439
|
'Return the tool names as an array, e.g. ["eslint", "prettier", "tsc"] or ["ruff", "mypy"].',
|
|
3401
3440
|
"Use as few tools as possible, but do not guess. If you cannot find any, return an empty array.",
|
|
3402
3441
|
"Ignore directories that may be related to testing, like `/fixtures`, `/tests`, etc",
|
|
@@ -3424,7 +3463,7 @@ async function runAnalysis(mode, extraInstructions = []) {
|
|
|
3424
3463
|
// package.json
|
|
3425
3464
|
var package_default = {
|
|
3426
3465
|
name: "@algolia/wizard",
|
|
3427
|
-
version: "0.9.0-rc.
|
|
3466
|
+
version: "0.9.0-rc.80.70",
|
|
3428
3467
|
description: "Magically implement Algolia functionality in your codebase",
|
|
3429
3468
|
type: "module",
|
|
3430
3469
|
engines: {
|
|
@@ -23,6 +23,7 @@ Install the latest stable within the major; never pin an exact patch.
|
|
|
23
23
|
| Java | `com.algolia:algoliasearch` | `4.+` |
|
|
24
24
|
| Kotlin | `com.algolia:algoliasearch-client-kotlin` | `3.+` |
|
|
25
25
|
| Scala | `com.algolia:algoliasearch-scala_2.13` | `2.+` |
|
|
26
|
+
| C# | `Algolia.Search` | `7.*` |
|
|
26
27
|
|
|
27
28
|
## Search UI
|
|
28
29
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Save records (Algolia.Search v7)
|
|
2
|
+
|
|
3
|
+
Adds records to an index. Write op — use a **write key**, server-side only.
|
|
4
|
+
|
|
5
|
+
The generated script is a self-contained console project at
|
|
6
|
+
`.algolia-wizard/ingest/ingest.csproj` + `Program.cs`, run with
|
|
7
|
+
`dotnet run --project .algolia-wizard/ingest/ingest.csproj`.
|
|
8
|
+
|
|
9
|
+
```xml
|
|
10
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
11
|
+
<PropertyGroup>
|
|
12
|
+
<OutputType>Exe</OutputType>
|
|
13
|
+
<TargetFramework>net8.0</TargetFramework>
|
|
14
|
+
<ImplicitUsings>enable</ImplicitUsings>
|
|
15
|
+
<Nullable>enable</Nullable>
|
|
16
|
+
</PropertyGroup>
|
|
17
|
+
<ItemGroup>
|
|
18
|
+
<PackageReference Include="Algolia.Search" Version="7.*" />
|
|
19
|
+
</ItemGroup>
|
|
20
|
+
</Project>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`<OutputType>Exe</OutputType>` is required — `dotnet run` on a library has no entry
|
|
24
|
+
point. `<TargetFramework>` must match an installed SDK; `net8.0` (LTS) is the safe
|
|
25
|
+
default. Under Central Package Management (`Directory.Packages.props` at the repo
|
|
26
|
+
root) omit `Version` here and pin it there — `Version` on a `PackageReference` is
|
|
27
|
+
an error under CPM (NU1008).
|
|
28
|
+
|
|
29
|
+
```csharp
|
|
30
|
+
using System.Text.Json;
|
|
31
|
+
using Algolia.Search.Clients;
|
|
32
|
+
|
|
33
|
+
var appId = Environment.GetEnvironmentVariable("ALGOLIA_APPLICATION_ID")
|
|
34
|
+
?? throw new InvalidOperationException("ALGOLIA_APPLICATION_ID is not set");
|
|
35
|
+
var writeKey = Environment.GetEnvironmentVariable("ALGOLIA_WRITE_API_KEY")
|
|
36
|
+
?? throw new InvalidOperationException("ALGOLIA_WRITE_API_KEY is not set");
|
|
37
|
+
|
|
38
|
+
var client = new SearchClient(new SearchConfig(appId, writeKey));
|
|
39
|
+
var indexName = "products";
|
|
40
|
+
|
|
41
|
+
var records = new List<Dictionary<string, object>>
|
|
42
|
+
{
|
|
43
|
+
new() { ["objectID"] = "1", ["name"] = "Adam" },
|
|
44
|
+
new() { ["objectID"] = "2", ["name"] = "Benoit" },
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
var responses = await client.SaveObjectsAsync(indexName, records, waitForTasks: true);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```csharp
|
|
51
|
+
Task<List<BatchResponse>> SaveObjectsAsync<T>(
|
|
52
|
+
string indexName, IEnumerable<T> objects, bool waitForTasks = false,
|
|
53
|
+
int batchSize = 1000, RequestOptions options = null,
|
|
54
|
+
CancellationToken cancellationToken = default) where T : class;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Records need an `objectID`; batching in 1,000s is automatic. Returns
|
|
58
|
+
`List<BatchResponse>` — one entry per batch, each `{ TaskID, ObjectIDs }`, never a
|
|
59
|
+
single response. `T` is constrained to `class`, so use `Dictionary<string, object>`
|
|
60
|
+
or a record/class, never a struct.
|
|
61
|
+
|
|
62
|
+
Read records from a JSON file:
|
|
63
|
+
|
|
64
|
+
```csharp
|
|
65
|
+
var json = await File.ReadAllTextAsync("records.json");
|
|
66
|
+
var records = JsonSerializer.Deserialize<List<Dictionary<string, object>>>(json)
|
|
67
|
+
?? new List<Dictionary<string, object>>();
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
After a successful ingest, print `ALGOLIA_WIZARD_RECORD_COUNT=<n>` as the last
|
|
71
|
+
stdout line; send all other logging to stderr so nothing follows it on stdout.
|