@algolia/wizard 0.9.0-rc.80.70 → 0.9.0-rc.82.72
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 SWIFT_PACKAGE_DIR = `${INGEST_DIR}/Ingest`;
|
|
2269
2270
|
var CSHARP_PROJECT = `${INGEST_DIR}/ingest/ingest.csproj`;
|
|
2270
2271
|
var VISIBLE_INGEST_DIR = "algolia-wizard";
|
|
2271
2272
|
var PY_VENV = `${INGEST_DIR}/.venv`;
|
|
@@ -2677,6 +2678,99 @@ var LANGUAGE_PROFILES = {
|
|
|
2677
2678
|
// `packages/` is where pnpm/Lerna/Turborepo monorepos keep all their source —
|
|
2678
2679
|
// skipping it would hide the entities the scan is looking for.
|
|
2679
2680
|
skipDirs: ["bin", "obj"]
|
|
2681
|
+
},
|
|
2682
|
+
swift: {
|
|
2683
|
+
id: "swift",
|
|
2684
|
+
displayName: "Swift",
|
|
2685
|
+
aliases: ["swift", "swiftui", "ios", "vapor"],
|
|
2686
|
+
manifests: ["Package.swift", "*.xcodeproj", "*.xcworkspace"],
|
|
2687
|
+
packageManagers: [
|
|
2688
|
+
{
|
|
2689
|
+
id: "swiftpm",
|
|
2690
|
+
dependency: {
|
|
2691
|
+
mode: "agent-declares",
|
|
2692
|
+
file: `${SWIFT_PACKAGE_DIR}/Package.swift`
|
|
2693
|
+
},
|
|
2694
|
+
// `swift build` resolves and fetches; a cold build of the client is slow
|
|
2695
|
+
// (minutes), which is why the caller degrades to the manual command when
|
|
2696
|
+
// this fails.
|
|
2697
|
+
installSteps: [
|
|
2698
|
+
{
|
|
2699
|
+
argv: ["swift", "build", "--package-path", SWIFT_PACKAGE_DIR],
|
|
2700
|
+
requiresFile: `${SWIFT_PACKAGE_DIR}/Package.swift`
|
|
2701
|
+
}
|
|
2702
|
+
],
|
|
2703
|
+
ingest: {
|
|
2704
|
+
kind: "auto",
|
|
2705
|
+
argv: ["swift", "run", "--package-path", SWIFT_PACKAGE_DIR],
|
|
2706
|
+
entrypointExtensions: [".swift"]
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
],
|
|
2710
|
+
sdk: {
|
|
2711
|
+
packageName: "algoliasearch-client-swift",
|
|
2712
|
+
// SwiftPM range syntax, not an exact version — a bare "9.0.0" in a
|
|
2713
|
+
// Package.swift dependency pins the patch.
|
|
2714
|
+
versionPin: 'from: "9.0.0"',
|
|
2715
|
+
docKey: "swift"
|
|
2716
|
+
},
|
|
2717
|
+
ingestEntrypointExample: `${SWIFT_PACKAGE_DIR}/Sources/Ingest/main.swift`,
|
|
2718
|
+
verification: [
|
|
2719
|
+
{
|
|
2720
|
+
label: "swift build",
|
|
2721
|
+
argv: ["swift", "build", "--package-path", SWIFT_PACKAGE_DIR],
|
|
2722
|
+
requiresFile: `${SWIFT_PACKAGE_DIR}/Package.swift`
|
|
2723
|
+
}
|
|
2724
|
+
],
|
|
2725
|
+
envReadInstruction: "Read them from `ProcessInfo.processInfo.environment`.",
|
|
2726
|
+
skipDirs: ["Pods", "DerivedData", "Carthage", ".build"]
|
|
2727
|
+
},
|
|
2728
|
+
dart: {
|
|
2729
|
+
id: "dart",
|
|
2730
|
+
displayName: "Dart",
|
|
2731
|
+
aliases: ["dart", "flutter"],
|
|
2732
|
+
manifests: ["pubspec.yaml"],
|
|
2733
|
+
packageManagers: [
|
|
2734
|
+
{
|
|
2735
|
+
id: "flutter-pub",
|
|
2736
|
+
detectFiles: [".metadata"],
|
|
2737
|
+
dependency: { mode: "agent-declares", file: "pubspec.yaml" },
|
|
2738
|
+
installSteps: [{ argv: ["flutter", "pub", "get"] }],
|
|
2739
|
+
ingest: {
|
|
2740
|
+
kind: "auto",
|
|
2741
|
+
argv: ["dart", "run", ENTRYPOINT_TOKEN],
|
|
2742
|
+
entrypointExtensions: [".dart"]
|
|
2743
|
+
}
|
|
2744
|
+
},
|
|
2745
|
+
{
|
|
2746
|
+
id: "pub",
|
|
2747
|
+
dependency: { mode: "agent-declares", file: "pubspec.yaml" },
|
|
2748
|
+
installSteps: [{ argv: ["dart", "pub", "get"] }],
|
|
2749
|
+
ingest: {
|
|
2750
|
+
kind: "auto",
|
|
2751
|
+
argv: ["dart", "run", ENTRYPOINT_TOKEN],
|
|
2752
|
+
entrypointExtensions: [".dart"]
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
],
|
|
2756
|
+
sdk: {
|
|
2757
|
+
packageName: "algolia_client_search",
|
|
2758
|
+
versionPin: "^1.0.0",
|
|
2759
|
+
docKey: "dart"
|
|
2760
|
+
},
|
|
2761
|
+
ingestEntrypointExample: `${INGEST_DIR}/ingest.dart`,
|
|
2762
|
+
verification: [
|
|
2763
|
+
{
|
|
2764
|
+
// Gated on the directory it analyzes, not just pubspec.yaml: a run that
|
|
2765
|
+
// only built a search UI never created it, and `dart analyze` on a
|
|
2766
|
+
// missing path fails the whole verification pass.
|
|
2767
|
+
label: "dart analyze",
|
|
2768
|
+
argv: ["dart", "analyze", INGEST_DIR],
|
|
2769
|
+
requiresFile: INGEST_DIR
|
|
2770
|
+
}
|
|
2771
|
+
],
|
|
2772
|
+
envReadInstruction: "Read them from `Platform.environment`.",
|
|
2773
|
+
skipDirs: ["build"]
|
|
2680
2774
|
}
|
|
2681
2775
|
};
|
|
2682
2776
|
var DEFAULT_LANGUAGE_ID = "javascript";
|
|
@@ -3359,7 +3453,7 @@ var detectLanguageSchema = z16.object({
|
|
|
3359
3453
|
var detectLanguage = () => runAgent({
|
|
3360
3454
|
instructions: [
|
|
3361
3455
|
"Analyze the codebase and determine the programming languages and frameworks used",
|
|
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.",
|
|
3456
|
+
"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.",
|
|
3363
3457
|
"List the language that owns the backend/data code first \u2014 that is the one an ingestion script will be written in.",
|
|
3364
3458
|
"If a superset language is found, exclude the subset language. TS-over-JS. Kotlin-over-Java when Kotlin is primary.",
|
|
3365
3459
|
"If a meta-framework is used, exclude the framework. Next-over-React.",
|
|
@@ -3435,7 +3529,7 @@ var MODE_CONFIG = {
|
|
|
3435
3529
|
verification: {
|
|
3436
3530
|
instructions: [
|
|
3437
3531
|
"Analyze the codebase to determine which code-quality tools are available to validate changes.",
|
|
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.",
|
|
3532
|
+
"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.",
|
|
3439
3533
|
'Return the tool names as an array, e.g. ["eslint", "prettier", "tsc"] or ["ruff", "mypy"].',
|
|
3440
3534
|
"Use as few tools as possible, but do not guess. If you cannot find any, return an empty array.",
|
|
3441
3535
|
"Ignore directories that may be related to testing, like `/fixtures`, `/tests`, etc",
|
|
@@ -3463,7 +3557,7 @@ async function runAnalysis(mode, extraInstructions = []) {
|
|
|
3463
3557
|
// package.json
|
|
3464
3558
|
var package_default = {
|
|
3465
3559
|
name: "@algolia/wizard",
|
|
3466
|
-
version: "0.9.0-rc.
|
|
3560
|
+
version: "0.9.0-rc.82.72",
|
|
3467
3561
|
description: "Magically implement Algolia functionality in your codebase",
|
|
3468
3562
|
type: "module",
|
|
3469
3563
|
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.
|