@algolia/wizard 0.8.0-rc.65.53 → 0.8.0-rc.67.55

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 SWIFT_PACKAGE_DIR = `${INGEST_DIR}/Ingest`;
2209
2210
  var CSHARP_PROJECT = `${INGEST_DIR}/ingest/ingest.csproj`;
2210
2211
  var VISIBLE_INGEST_DIR = "algolia-wizard";
2211
2212
  var PY_VENV = `${INGEST_DIR}/.venv`;
@@ -2617,6 +2618,99 @@ var LANGUAGE_PROFILES = {
2617
2618
  // `packages/` is where pnpm/Lerna/Turborepo monorepos keep all their source —
2618
2619
  // skipping it would hide the entities the scan is looking for.
2619
2620
  skipDirs: ["bin", "obj"]
2621
+ },
2622
+ swift: {
2623
+ id: "swift",
2624
+ displayName: "Swift",
2625
+ aliases: ["swift", "swiftui", "ios", "vapor"],
2626
+ manifests: ["Package.swift", "*.xcodeproj", "*.xcworkspace"],
2627
+ packageManagers: [
2628
+ {
2629
+ id: "swiftpm",
2630
+ dependency: {
2631
+ mode: "agent-declares",
2632
+ file: `${SWIFT_PACKAGE_DIR}/Package.swift`
2633
+ },
2634
+ // `swift build` resolves and fetches; a cold build of the client is slow
2635
+ // (minutes), which is why the caller degrades to the manual command when
2636
+ // this fails.
2637
+ installSteps: [
2638
+ {
2639
+ argv: ["swift", "build", "--package-path", SWIFT_PACKAGE_DIR],
2640
+ requiresFile: `${SWIFT_PACKAGE_DIR}/Package.swift`
2641
+ }
2642
+ ],
2643
+ ingest: {
2644
+ kind: "auto",
2645
+ argv: ["swift", "run", "--package-path", SWIFT_PACKAGE_DIR],
2646
+ entrypointExtensions: [".swift"]
2647
+ }
2648
+ }
2649
+ ],
2650
+ sdk: {
2651
+ packageName: "algoliasearch-client-swift",
2652
+ // SwiftPM range syntax, not an exact version — a bare "9.0.0" in a
2653
+ // Package.swift dependency pins the patch.
2654
+ versionPin: 'from: "9.0.0"',
2655
+ docKey: "swift"
2656
+ },
2657
+ ingestEntrypointExample: `${SWIFT_PACKAGE_DIR}/Sources/Ingest/main.swift`,
2658
+ verification: [
2659
+ {
2660
+ label: "swift build",
2661
+ argv: ["swift", "build", "--package-path", SWIFT_PACKAGE_DIR],
2662
+ requiresFile: `${SWIFT_PACKAGE_DIR}/Package.swift`
2663
+ }
2664
+ ],
2665
+ envReadInstruction: "Read them from `ProcessInfo.processInfo.environment`.",
2666
+ skipDirs: ["Pods", "DerivedData", "Carthage", ".build"]
2667
+ },
2668
+ dart: {
2669
+ id: "dart",
2670
+ displayName: "Dart",
2671
+ aliases: ["dart", "flutter"],
2672
+ manifests: ["pubspec.yaml"],
2673
+ packageManagers: [
2674
+ {
2675
+ id: "flutter-pub",
2676
+ detectFiles: [".metadata"],
2677
+ dependency: { mode: "agent-declares", file: "pubspec.yaml" },
2678
+ installSteps: [{ argv: ["flutter", "pub", "get"] }],
2679
+ ingest: {
2680
+ kind: "auto",
2681
+ argv: ["dart", "run", ENTRYPOINT_TOKEN],
2682
+ entrypointExtensions: [".dart"]
2683
+ }
2684
+ },
2685
+ {
2686
+ id: "pub",
2687
+ dependency: { mode: "agent-declares", file: "pubspec.yaml" },
2688
+ installSteps: [{ argv: ["dart", "pub", "get"] }],
2689
+ ingest: {
2690
+ kind: "auto",
2691
+ argv: ["dart", "run", ENTRYPOINT_TOKEN],
2692
+ entrypointExtensions: [".dart"]
2693
+ }
2694
+ }
2695
+ ],
2696
+ sdk: {
2697
+ packageName: "algolia_client_search",
2698
+ versionPin: "^1.0.0",
2699
+ docKey: "dart"
2700
+ },
2701
+ ingestEntrypointExample: `${INGEST_DIR}/ingest.dart`,
2702
+ verification: [
2703
+ {
2704
+ // Gated on the directory it analyzes, not just pubspec.yaml: a run that
2705
+ // only built a search UI never created it, and `dart analyze` on a
2706
+ // missing path fails the whole verification pass.
2707
+ label: "dart analyze",
2708
+ argv: ["dart", "analyze", INGEST_DIR],
2709
+ requiresFile: INGEST_DIR
2710
+ }
2711
+ ],
2712
+ envReadInstruction: "Read them from `Platform.environment`.",
2713
+ skipDirs: ["build"]
2620
2714
  }
2621
2715
  };
2622
2716
  var DEFAULT_LANGUAGE_ID = "javascript";
@@ -3299,7 +3393,7 @@ var detectLanguageSchema = z16.object({
3299
3393
  var detectLanguage = () => runAgent({
3300
3394
  instructions: [
3301
3395
  "Analyze the codebase and determine the programming languages and frameworks used",
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.",
3396
+ "Start from the dependency manifests: package.json, pyproject.toml, requirements.txt, Gemfile, composer.json, go.mod, pom.xml, build.gradle(.kts), *.csproj, build.sbt, Package.swift, pubspec.yaml.",
3303
3397
  "List the language that owns the backend/data code first \u2014 that is the one an ingestion script will be written in.",
3304
3398
  "If a superset language is found, exclude the subset language. TS-over-JS. Kotlin-over-Java when Kotlin is primary.",
3305
3399
  "If a meta-framework is used, exclude the framework. Next-over-React.",
@@ -3375,7 +3469,7 @@ var MODE_CONFIG = {
3375
3469
  verification: {
3376
3470
  instructions: [
3377
3471
  "Analyze the codebase to determine which code-quality tools are available to validate changes.",
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.",
3472
+ "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, analysis_options.yaml.",
3379
3473
  'Return the tool names as an array, e.g. ["eslint", "prettier", "tsc"] or ["ruff", "mypy"].',
3380
3474
  "Use as few tools as possible, but do not guess. If you cannot find any, return an empty array.",
3381
3475
  "Ignore directories that may be related to testing, like `/fixtures`, `/tests`, etc",
@@ -3403,7 +3497,7 @@ async function runAnalysis(mode, extraInstructions = []) {
3403
3497
  // package.json
3404
3498
  var package_default = {
3405
3499
  name: "@algolia/wizard",
3406
- version: "0.8.0-rc.65.53",
3500
+ version: "0.8.0-rc.67.55",
3407
3501
  description: "Magically implement Algolia functionality in your codebase",
3408
3502
  type: "module",
3409
3503
  engines: {
@@ -24,6 +24,8 @@ Install the latest stable within the major; never pin an exact patch.
24
24
  | Kotlin | `com.algolia:algoliasearch-client-kotlin` | `3.+` |
25
25
  | Scala | `com.algolia:algoliasearch-scala_2.13` | `2.+` |
26
26
  | C# | `Algolia.Search` | `7.*` |
27
+ | Swift | `algoliasearch-client-swift` | `9.0.0` |
28
+ | Dart | `algolia_client_search` | `^1.0.0` |
27
29
 
28
30
  ## Search UI
29
31
 
@@ -0,0 +1,74 @@
1
+ # Save records (algolia_client_search v1)
2
+
3
+ Adds records to an index. Write op — use a **write key**, server-side only.
4
+
5
+ Use the generated v2 client `algolia_client_search`, never the legacy community
6
+ `algolia` package. The script is run with `dart run .algolia-wizard/ingest.dart`.
7
+
8
+ ```yaml
9
+ dependencies:
10
+ algolia_client_search: ^1.0.0
11
+ ```
12
+
13
+ This client has **no `saveObjects` helper** (only `saveObjectsWithTransformation`,
14
+ which needs an Ingestion transformation) — use `batch` with `addObject` actions.
15
+
16
+ ```dart
17
+ import 'dart:convert';
18
+ import 'dart:io';
19
+ import 'dart:math';
20
+
21
+ import 'package:algolia_client_search/algolia_client_search.dart';
22
+
23
+ Future<void> main() async {
24
+ final appId = Platform.environment['ALGOLIA_APPLICATION_ID'];
25
+ final writeKey = Platform.environment['ALGOLIA_WRITE_API_KEY'];
26
+ if (appId == null || writeKey == null) {
27
+ stderr.writeln('missing Algolia credentials');
28
+ exit(1);
29
+ }
30
+
31
+ const indexName = 'products';
32
+ final client = SearchClient(appId: appId, apiKey: writeKey);
33
+
34
+ final records = <Map<String, dynamic>>[
35
+ {'objectID': '1', 'name': 'Adam'},
36
+ {'objectID': '2', 'name': 'Benoit'},
37
+ ];
38
+
39
+ try {
40
+ for (var i = 0; i < records.length; i += 1000) {
41
+ final chunk = records.sublist(i, min(i + 1000, records.length));
42
+ final response = await client.batch(
43
+ indexName: indexName,
44
+ batchWriteParams: BatchWriteParams(
45
+ requests: chunk
46
+ .map((r) => BatchRequest(action: Action.addObject, body: r))
47
+ .toList(),
48
+ ),
49
+ );
50
+ stderr.writeln('task ${response.taskID}');
51
+ }
52
+ print('ALGOLIA_WIZARD_RECORD_COUNT=${records.length}');
53
+ } finally {
54
+ client.dispose();
55
+ }
56
+ }
57
+ ```
58
+
59
+ `batch` returns a **single** `BatchResponse { int taskID, List<String> objectIDs }`,
60
+ not a list. Gotchas: every record needs an `objectID`; there is no auto-chunking,
61
+ so cap each call at 1,000 records yourself; use the `Action.addObject` enum value
62
+ (`Action.updateObject` replaces instead of adds); and `client.dispose()` is
63
+ mandatory — without it `dart run` never exits.
64
+
65
+ Read records from a JSON file:
66
+
67
+ ```dart
68
+ final json = await File('records.json').readAsString();
69
+ final records = (jsonDecode(json) as List).cast<Map<String, dynamic>>();
70
+ ```
71
+
72
+ After a successful ingest, print `ALGOLIA_WIZARD_RECORD_COUNT=<n>` as the last
73
+ stdout line (before `dispose()` is fine); send all other logging to stderr so
74
+ nothing follows it on stdout.
@@ -0,0 +1,88 @@
1
+ # Save records (algoliasearch-client-swift v9)
2
+
3
+ Adds records to an index. Write op — use a **write key**, server-side only.
4
+
5
+ The generated script is a standalone SwiftPM executable package at
6
+ `.algolia-wizard/Ingest` (`Package.swift` + `Sources/Ingest/main.swift`), run with
7
+ `swift run --package-path .algolia-wizard/Ingest`.
8
+
9
+ ```swift
10
+ // swift-tools-version: 5.9
11
+ import PackageDescription
12
+
13
+ let package = Package(
14
+ name: "Ingest",
15
+ platforms: [.macOS(.v13)],
16
+ products: [.executable(name: "Ingest", targets: ["Ingest"])],
17
+ dependencies: [
18
+ .package(url: "https://github.com/algolia/algoliasearch-client-swift", from: "9.0.0"),
19
+ ],
20
+ targets: [
21
+ .executableTarget(name: "Ingest", dependencies: [
22
+ .product(name: "AlgoliaSearch", package: "algoliasearch-client-swift"),
23
+ .product(name: "AlgoliaCore", package: "algoliasearch-client-swift"),
24
+ ]),
25
+ ]
26
+ )
27
+ ```
28
+
29
+ Exactly one executable product, so `swift run --package-path` needs no target name.
30
+ `platforms:` must be declared (the client requires macOS 11+); it is ignored on
31
+ Linux. `package:` is the repo name, not the manifest's `AlgoliaSearchClient`.
32
+
33
+ `main.swift` top-level code can't propagate a thrown error — wrap calls in `do`/`catch`.
34
+
35
+ ```swift
36
+ import Foundation
37
+ #if canImport(AlgoliaCore)
38
+ import AlgoliaCore
39
+ #endif
40
+ import AlgoliaSearch
41
+
42
+ let env = ProcessInfo.processInfo.environment
43
+ guard let appID = env["ALGOLIA_APPLICATION_ID"],
44
+ let writeKey = env["ALGOLIA_WRITE_API_KEY"]
45
+ else {
46
+ FileHandle.standardError.write(Data("missing Algolia credentials\n".utf8))
47
+ exit(1)
48
+ }
49
+ let indexName = "products"
50
+
51
+ do {
52
+ let client = try SearchClient(appID: appID, apiKey: writeKey)
53
+ let records: [AnyCodable] = [
54
+ ["objectID": "1", "name": "Adam"],
55
+ ["objectID": "2", "name": "Benoit"],
56
+ ]
57
+ let responses = try await client.saveObjects(
58
+ indexName: indexName, objects: records, waitForTasks: true
59
+ )
60
+ FileHandle.standardError.write(Data("batches: \(responses.count)\n".utf8))
61
+ print("ALGOLIA_WIZARD_RECORD_COUNT=\(records.count)")
62
+ } catch {
63
+ FileHandle.standardError.write(Data("\(error)\n".utf8))
64
+ exit(1)
65
+ }
66
+ ```
67
+
68
+ ```swift
69
+ func saveObjects(
70
+ indexName: String, objects: [some Encodable], waitForTasks: Bool = false,
71
+ batchSize: Int = 1000, requestOptions: RequestOptions? = nil
72
+ ) async throws -> [BatchResponse]
73
+ ```
74
+
75
+ Records need an `objectID`; batching in 1,000s is automatic. Returns an **array**
76
+ of `BatchResponse` (`taskID`, `objectIDs`), one per batch. `objects` is
77
+ `[some Encodable]` — one homogeneous element type, so use `[AnyCodable]` (from
78
+ `AlgoliaCore`) for arbitrary JSON records.
79
+
80
+ Read records from a JSON file:
81
+
82
+ ```swift
83
+ let data = try Data(contentsOf: URL(fileURLWithPath: "records.json"))
84
+ let records = try JSONDecoder().decode([AnyCodable].self, from: data)
85
+ ```
86
+
87
+ After a successful ingest, print `ALGOLIA_WIZARD_RECORD_COUNT=<n>` as the last
88
+ stdout line; send all other logging to stderr so nothing follows it on stdout.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algolia/wizard",
3
- "version": "0.8.0-rc.65.53",
3
+ "version": "0.8.0-rc.67.55",
4
4
  "description": "Magically implement Algolia functionality in your codebase",
5
5
  "type": "module",
6
6
  "engines": {