@algolia/wizard 0.8.0-rc.64.51 → 0.8.0-rc.65.53
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
|
@@ -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 CSHARP_PROJECT = `${INGEST_DIR}/ingest/ingest.csproj`;
|
|
2209
2210
|
var VISIBLE_INGEST_DIR = "algolia-wizard";
|
|
2210
2211
|
var PY_VENV = `${INGEST_DIR}/.venv`;
|
|
2211
2212
|
var PY_VENV_PYTHON = `${PY_VENV}/bin/python`;
|
|
@@ -2578,6 +2579,44 @@ var LANGUAGE_PROFILES = {
|
|
|
2578
2579
|
// that some repos use it for source; scanning it is cheap, missing source
|
|
2579
2580
|
// is not.
|
|
2580
2581
|
skipDirs: ["target"]
|
|
2582
|
+
},
|
|
2583
|
+
csharp: {
|
|
2584
|
+
id: "csharp",
|
|
2585
|
+
displayName: "C#",
|
|
2586
|
+
aliases: ["c#", "csharp", "cs", ".net", "dotnet", "net", "asp.net"],
|
|
2587
|
+
manifests: ["*.csproj", "*.sln", "global.json"],
|
|
2588
|
+
packageManagers: [
|
|
2589
|
+
{
|
|
2590
|
+
id: "dotnet",
|
|
2591
|
+
// A self-contained project under .algolia-wizard keeps the ingest script
|
|
2592
|
+
// out of the repo's own build graph.
|
|
2593
|
+
dependency: { mode: "agent-declares", file: CSHARP_PROJECT },
|
|
2594
|
+
installSteps: [{ argv: ["dotnet", "restore", CSHARP_PROJECT] }],
|
|
2595
|
+
ingest: {
|
|
2596
|
+
kind: "auto",
|
|
2597
|
+
argv: ["dotnet", "run", "--project", ENTRYPOINT_TOKEN],
|
|
2598
|
+
entrypointExtensions: [".csproj"]
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
],
|
|
2602
|
+
sdk: {
|
|
2603
|
+
packageName: "Algolia.Search",
|
|
2604
|
+
versionPin: "7.*",
|
|
2605
|
+
docKey: "csharp"
|
|
2606
|
+
},
|
|
2607
|
+
ingestEntrypointExample: CSHARP_PROJECT,
|
|
2608
|
+
verification: [
|
|
2609
|
+
{
|
|
2610
|
+
label: "dotnet build",
|
|
2611
|
+
argv: ["dotnet", "build", CSHARP_PROJECT, "--nologo"],
|
|
2612
|
+
requiresFile: CSHARP_PROJECT
|
|
2613
|
+
}
|
|
2614
|
+
],
|
|
2615
|
+
envReadInstruction: 'Read them from `Environment.GetEnvironmentVariable("NAME")`.',
|
|
2616
|
+
// Deliberately not `packages`: modern .NET uses PackageReference, and
|
|
2617
|
+
// `packages/` is where pnpm/Lerna/Turborepo monorepos keep all their source —
|
|
2618
|
+
// skipping it would hide the entities the scan is looking for.
|
|
2619
|
+
skipDirs: ["bin", "obj"]
|
|
2581
2620
|
}
|
|
2582
2621
|
};
|
|
2583
2622
|
var DEFAULT_LANGUAGE_ID = "javascript";
|
|
@@ -3260,7 +3299,7 @@ var detectLanguageSchema = z16.object({
|
|
|
3260
3299
|
var detectLanguage = () => runAgent({
|
|
3261
3300
|
instructions: [
|
|
3262
3301
|
"Analyze the codebase and determine the programming languages and frameworks used",
|
|
3263
|
-
"Start from the dependency manifests: package.json, pyproject.toml, requirements.txt, Gemfile, composer.json, go.mod, pom.xml, build.gradle(.kts), build.sbt.",
|
|
3302
|
+
"Start from the dependency manifests: package.json, pyproject.toml, requirements.txt, Gemfile, composer.json, go.mod, pom.xml, build.gradle(.kts), *.csproj, build.sbt.",
|
|
3264
3303
|
"List the language that owns the backend/data code first \u2014 that is the one an ingestion script will be written in.",
|
|
3265
3304
|
"If a superset language is found, exclude the subset language. TS-over-JS. Kotlin-over-Java when Kotlin is primary.",
|
|
3266
3305
|
"If a meta-framework is used, exclude the framework. Next-over-React.",
|
|
@@ -3313,7 +3352,7 @@ var MODE_CONFIG = {
|
|
|
3313
3352
|
"Analyze the codebase to find the data entities (models) that should be ingested into Algolia.",
|
|
3314
3353
|
"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).",
|
|
3315
3354
|
"Inspect the source of each entity to extract real field names for attributes \u2014 do not guess or leave attributes empty.",
|
|
3316
|
-
"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.",
|
|
3355
|
+
"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.",
|
|
3317
3356
|
"Prefer domain models (e.g. Document, Product, User) over framework or infrastructure types.",
|
|
3318
3357
|
"Use as few tools as possible, but do not guess. If you cannot find any entities, return an empty array.",
|
|
3319
3358
|
"Ignore directories that may be related to testing, like `/fixtures`, `/tests`, etc",
|
|
@@ -3336,7 +3375,7 @@ var MODE_CONFIG = {
|
|
|
3336
3375
|
verification: {
|
|
3337
3376
|
instructions: [
|
|
3338
3377
|
"Analyze the codebase to determine which code-quality tools are available to validate changes.",
|
|
3339
|
-
"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.",
|
|
3378
|
+
"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.",
|
|
3340
3379
|
'Return the tool names as an array, e.g. ["eslint", "prettier", "tsc"] or ["ruff", "mypy"].',
|
|
3341
3380
|
"Use as few tools as possible, but do not guess. If you cannot find any, return an empty array.",
|
|
3342
3381
|
"Ignore directories that may be related to testing, like `/fixtures`, `/tests`, etc",
|
|
@@ -3364,7 +3403,7 @@ async function runAnalysis(mode, extraInstructions = []) {
|
|
|
3364
3403
|
// package.json
|
|
3365
3404
|
var package_default = {
|
|
3366
3405
|
name: "@algolia/wizard",
|
|
3367
|
-
version: "0.8.0-rc.
|
|
3406
|
+
version: "0.8.0-rc.65.53",
|
|
3368
3407
|
description: "Magically implement Algolia functionality in your codebase",
|
|
3369
3408
|
type: "module",
|
|
3370
3409
|
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.
|