Skip to content

Commit 8268208

Browse files
authored
Merge branch 'main' into feat/realtime-perso-specs
2 parents 447926d + 680d82c commit 8268208

File tree

577 files changed

+4215
-3071
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

577 files changed

+4215
-3071
lines changed

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ runs:
202202
if: ${{ inputs.language == 'swift' }}
203203
id: swiftformat-version
204204
shell: bash
205-
run: echo "SWIFTFORMAT_VERSION=0.56.2" >> $GITHUB_OUTPUT
205+
run: echo "SWIFTFORMAT_VERSION=0.56.3" >> $GITHUB_OUTPUT
206206

207207
- name: Checkout swiftformat
208208
if: ${{ inputs.language == 'swift' }}

.yarn/releases/yarn-4.9.1.cjs renamed to .yarn/releases/yarn-4.9.2.cjs

Lines changed: 273 additions & 279 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ enableGlobalCache: false
44

55
nodeLinker: node-modules
66

7-
yarnPath: .yarn/releases/yarn-4.9.1.cjs
7+
yarnPath: .yarn/releases/yarn-4.9.2.cjs
88

99
# esbuild use native binaries, we need both to work locally and on the CI.
1010
supportedArchitectures:

clients/algoliasearch-client-java/algoliasearch/src/main/java/com/algolia/ApiClient.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public abstract class ApiClient implements Closeable {
2828

2929
private final Requester requester;
3030
private final ExecutorService executor;
31-
private AuthInterceptor authInterceptor;
31+
public final ClientOptions clientOptions;
32+
public AuthInterceptor authInterceptor;
3233

3334
/** Constructs a new instance of the {@link ApiClient}. */
3435
protected ApiClient(
@@ -47,9 +48,9 @@ protected ApiClient(
4748
if (apiKey == null || apiKey.isEmpty()) {
4849
throw new AlgoliaRuntimeException("`apiKey` is missing.");
4950
}
50-
final ClientOptions clientOptions = options != null ? options : new ClientOptions();
51-
this.executor = clientOptions.getExecutor();
52-
this.requester = clientOptions.getCustomRequester() != null
51+
clientOptions = options != null ? options : new ClientOptions();
52+
executor = clientOptions.getExecutor();
53+
requester = clientOptions.getCustomRequester() != null
5354
? clientOptions.getCustomRequester()
5455
: defaultRequester(appId, apiKey, clientName, clientOptions, defaultHosts, connectTimeout, readTimeout, writeTimeout);
5556
}

clients/algoliasearch-client-java/algoliasearch/src/main/java/com/algolia/api/SearchClient.java

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
import com.algolia.config.ClientOptions;
99
import com.algolia.exceptions.*;
1010
import com.algolia.internal.JsonSerializer;
11+
import com.algolia.model.ingestion.PushTaskPayload;
12+
import com.algolia.model.ingestion.PushTaskRecords;
13+
import com.algolia.model.ingestion.WatchResponse;
1114
import com.algolia.model.search.*;
1215
import com.algolia.utils.*;
1316
import com.fasterxml.jackson.core.type.TypeReference;
17+
import com.fasterxml.jackson.databind.ObjectMapper;
1418
import java.nio.charset.Charset;
1519
import java.security.InvalidKeyException;
1620
import java.security.NoSuchAlgorithmException;
@@ -36,6 +40,24 @@
3640

3741
public class SearchClient extends ApiClient {
3842

43+
private IngestionClient ingestionTransporter;
44+
45+
/**
46+
* Sets the region of the current algolia application to the configuration, this is required to be
47+
* called if you wish to leverage the transformation pipeline (via the *WithTransformation
48+
* methods).
49+
*
50+
* @param region (required)
51+
*/
52+
public void setTransformationRegion(String region) {
53+
this.ingestionTransporter = new IngestionClient(
54+
this.authInterceptor.getApplicationId(),
55+
this.authInterceptor.getApiKey(),
56+
region,
57+
this.clientOptions
58+
);
59+
}
60+
3961
public SearchClient(String appId, String apiKey) {
4062
this(appId, apiKey, null);
4163
}
@@ -6731,6 +6753,108 @@ public <T> List<BatchResponse> chunkedBatch(
67316753
return chunkedBatch(indexName, objects, action, waitForTasks, 1000, requestOptions);
67326754
}
67336755

6756+
/**
6757+
* Helper: Similar to the `saveObjects` method but requires a Push connector
6758+
* (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/)
6759+
* to be created first, in order to transform records before indexing them to Algolia. The
6760+
* `region` must have been passed to the client instantiation method.
6761+
*
6762+
* @param indexName The `indexName` to replace `objects` in.
6763+
* @param objects The array of `objects` to store in the given Algolia `indexName`.
6764+
* @throws AlgoliaRetryException When the retry has failed on all hosts
6765+
* @throws AlgoliaApiException When the API sends an http error code
6766+
* @throws AlgoliaRuntimeException When an error occurred during the serialization
6767+
*/
6768+
public <T> WatchResponse saveObjectsWithTransformation(String indexName, Iterable<T> objects) {
6769+
return saveObjectsWithTransformation(indexName, objects, null);
6770+
}
6771+
6772+
/**
6773+
* Helper: Similar to the `saveObjects` method but requires a Push connector
6774+
* (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/)
6775+
* to be created first, in order to transform records before indexing them to Algolia. The
6776+
* `region` must have been passed to the client instantiation method.
6777+
*
6778+
* @param indexName The `indexName` to replace `objects` in.
6779+
* @param objects The array of `objects` to store in the given Algolia `indexName`.
6780+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
6781+
* the transporter requestOptions. (optional)
6782+
*/
6783+
public <T> WatchResponse saveObjectsWithTransformation(String indexName, Iterable<T> objects, RequestOptions requestOptions) {
6784+
return saveObjectsWithTransformation(indexName, objects, false, requestOptions);
6785+
}
6786+
6787+
/**
6788+
* Helper: Similar to the `saveObjects` method but requires a Push connector
6789+
* (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/)
6790+
* to be created first, in order to transform records before indexing them to Algolia. The
6791+
* `region` must have been passed to the client instantiation method.
6792+
*
6793+
* @param indexName The `indexName` to replace `objects` in.
6794+
* @param objects The array of `objects` to store in the given Algolia `indexName`.
6795+
* @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
6796+
* processed, this operation may slow the total execution time of this method but is more
6797+
* reliable.
6798+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
6799+
* the transporter requestOptions. (optional)
6800+
*/
6801+
public <T> WatchResponse saveObjectsWithTransformation(
6802+
String indexName,
6803+
Iterable<T> objects,
6804+
boolean waitForTasks,
6805+
RequestOptions requestOptions
6806+
) {
6807+
return saveObjectsWithTransformation(indexName, objects, waitForTasks, 1000, requestOptions);
6808+
}
6809+
6810+
/**
6811+
* Helper: Similar to the `saveObjects` method but requires a Push connector
6812+
* (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/)
6813+
* to be created first, in order to transform records before indexing them to Algolia. The
6814+
* `region` must have been passed to the client instantiation method.
6815+
*
6816+
* @param indexName The `indexName` to replace `objects` in.
6817+
* @param objects The array of `objects` to store in the given Algolia `indexName`.
6818+
* @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
6819+
* processed, this operation may slow the total execution time of this method but is more
6820+
* reliable.
6821+
* @param batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal
6822+
* to `length(objects) / batchSize`.
6823+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
6824+
* the transporter requestOptions. (optional)
6825+
*/
6826+
public <T> WatchResponse saveObjectsWithTransformation(
6827+
String indexName,
6828+
Iterable<T> objects,
6829+
boolean waitForTasks,
6830+
int batchSize,
6831+
RequestOptions requestOptions
6832+
) {
6833+
if (this.ingestionTransporter == null) {
6834+
throw new AlgoliaRuntimeException("`setTransformationRegion` must have been called before calling this method.");
6835+
}
6836+
6837+
return this.ingestionTransporter.push(
6838+
indexName,
6839+
new PushTaskPayload().setAction(com.algolia.model.ingestion.Action.ADD_OBJECT).setRecords(this.objectsToPushTaskRecords(objects)),
6840+
waitForTasks,
6841+
requestOptions
6842+
);
6843+
}
6844+
6845+
private <T> List<PushTaskRecords> objectsToPushTaskRecords(Iterable<T> objects) {
6846+
try {
6847+
ObjectMapper mapper = new ObjectMapper();
6848+
String json = mapper.writeValueAsString(objects);
6849+
6850+
return mapper.readValue(json, new TypeReference<List<PushTaskRecords>>() {});
6851+
} catch (Exception e) {
6852+
throw new AlgoliaRuntimeException(
6853+
"each object must have an `objectID` key in order to be used with the" + " WithTransformation methods"
6854+
);
6855+
}
6856+
}
6857+
67346858
/**
67356859
* Helper: Saves the given array of objects in the given index. The `chunkedBatch` helper is used
67366860
* under the hood, which creates a `batch` requests with at most 1000 objects in it.
@@ -6867,6 +6991,114 @@ public List<BatchResponse> deleteObjects(
68676991
return chunkedBatch(indexName, objects, Action.DELETE_OBJECT, waitForTasks, batchSize, requestOptions);
68686992
}
68696993

6994+
/**
6995+
* Helper: Similar to the `partialUpdateObjects` method but requires a Push connector
6996+
* (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/)
6997+
* to be created first, in order to transform records before indexing them to Algolia. The
6998+
* `region` must have been passed to the client instantiation method.
6999+
*
7000+
* @param indexName The `indexName` to update `objects` in.
7001+
* @param objects The array of `objects` to update in the given Algolia `indexName`.
7002+
* @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call
7003+
* will fail.
7004+
*/
7005+
public <T> WatchResponse partialUpdateObjectsWithTransformation(String indexName, Iterable<T> objects, boolean createIfNotExists) {
7006+
return partialUpdateObjectsWithTransformation(indexName, objects, createIfNotExists, false, null);
7007+
}
7008+
7009+
/**
7010+
* Helper: Similar to the `partialUpdateObjects` method but requires a Push connector
7011+
* (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/)
7012+
* to be created first, in order to transform records before indexing them to Algolia. The
7013+
* `region` must have been passed to the client instantiation method.
7014+
*
7015+
* @param indexName The `indexName` to update `objects` in.
7016+
* @param objects The array of `objects` to update in the given Algolia `indexName`.
7017+
* @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call
7018+
* will fail.
7019+
* @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
7020+
* processed, this operation may slow the total execution time of this method but is more
7021+
* reliable.
7022+
*/
7023+
public <T> WatchResponse partialUpdateObjectsWithTransformation(
7024+
String indexName,
7025+
Iterable<T> objects,
7026+
boolean createIfNotExists,
7027+
boolean waitForTasks
7028+
) {
7029+
return partialUpdateObjectsWithTransformation(indexName, objects, createIfNotExists, waitForTasks, null);
7030+
}
7031+
7032+
/**
7033+
* Helper: Similar to the `partialUpdateObjects` method but requires a Push connector
7034+
* (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/)
7035+
* to be created first, in order to transform records before indexing them to Algolia. The
7036+
* `region` must have been passed to the client instantiation method.
7037+
*
7038+
* @param indexName The `indexName` to update `objects` in.
7039+
* @param objects The array of `objects` to update in the given Algolia `indexName`.
7040+
* @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call
7041+
* will fail.
7042+
* @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
7043+
* processed, this operation may slow the total execution time of this method but is more
7044+
* reliable.
7045+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
7046+
* the transporter requestOptions. (optional)
7047+
*/
7048+
public <T> WatchResponse partialUpdateObjectsWithTransformation(
7049+
String indexName,
7050+
Iterable<T> objects,
7051+
boolean createIfNotExists,
7052+
boolean waitForTasks,
7053+
RequestOptions requestOptions
7054+
) {
7055+
return partialUpdateObjectsWithTransformation(indexName, objects, createIfNotExists, waitForTasks, 1000, null);
7056+
}
7057+
7058+
/**
7059+
* Helper: Similar to the `partialUpdateObjects` method but requires a Push connector
7060+
* (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/)
7061+
* to be created first, in order to transform records before indexing them to Algolia. The
7062+
* `region` must have been passed to the client instantiation method.
7063+
*
7064+
* @param indexName The `indexName` to update `objects` in.
7065+
* @param objects The array of `objects` to update in the given Algolia `indexName`.
7066+
* @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call
7067+
* will fail.
7068+
* @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
7069+
* processed, this operation may slow the total execution time of this method but is more
7070+
* reliable.
7071+
* @param batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal
7072+
* to `length(objects) / batchSize`.
7073+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
7074+
* the transporter requestOptions. (optional)
7075+
*/
7076+
public <T> WatchResponse partialUpdateObjectsWithTransformation(
7077+
String indexName,
7078+
Iterable<T> objects,
7079+
boolean createIfNotExists,
7080+
boolean waitForTasks,
7081+
int batchSize,
7082+
RequestOptions requestOptions
7083+
) {
7084+
if (this.ingestionTransporter == null) {
7085+
throw new AlgoliaRuntimeException("`setTransformationRegion` must have been called before calling this method.");
7086+
}
7087+
7088+
return this.ingestionTransporter.push(
7089+
indexName,
7090+
new PushTaskPayload()
7091+
.setAction(
7092+
createIfNotExists
7093+
? com.algolia.model.ingestion.Action.PARTIAL_UPDATE_OBJECT
7094+
: com.algolia.model.ingestion.Action.PARTIAL_UPDATE_OBJECT_NO_CREATE
7095+
)
7096+
.setRecords(this.objectsToPushTaskRecords(objects)),
7097+
waitForTasks,
7098+
requestOptions
7099+
);
7100+
}
7101+
68707102
/**
68717103
* Helper: Replaces object content of all the given objects according to their respective
68727104
* `objectID` field. The `chunkedBatch` helper is used under the hood, which creates a `batch`

clients/algoliasearch-client-java/algoliasearch/src/main/java/com/algolia/internal/interceptors/AuthInterceptor.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ public void setApiKey(String apiKey) {
2323
this.apiKey = apiKey;
2424
}
2525

26+
public String getApiKey() {
27+
return this.apiKey;
28+
}
29+
30+
public String getApplicationId() {
31+
return this.applicationId;
32+
}
33+
2634
@Nonnull
2735
@Override
2836
public Response intercept(Chain chain) throws IOException {

clients/algoliasearch-client-java/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

clients/algoliasearch-client-javascript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"test:bundle": "lerna run test:bundle --verbose --include-dependencies"
1616
},
1717
"devDependencies": {
18-
"@types/node": "22.15.29",
18+
"@types/node": "22.15.30",
1919
"bundlewatch": "0.4.1",
2020
"execa": "9.6.0",
2121
"lerna": "8.2.2",

clients/algoliasearch-client-javascript/packages/algoliasearch/builds/browser.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export type Algoliasearch = SearchClient & {
6262
*/
6363
saveObjectsWithTransformation: (
6464
options: SaveObjectsOptions,
65-
requestOptions?: RequestOptions,
65+
requestOptions?: RequestOptions | undefined,
6666
) => Promise<WatchResponse>;
6767

6868
/**
@@ -79,22 +79,24 @@ export type Algoliasearch = SearchClient & {
7979
*/
8080
partialUpdateObjectsWithTransformation: (
8181
options: PartialUpdateObjectsOptions,
82-
requestOptions?: RequestOptions,
82+
requestOptions?: RequestOptions | undefined,
8383
) => Promise<WatchResponse>;
8484
};
8585

8686
export type TransformationOptions = {
8787
// When provided, a second transporter will be created in order to leverage the `*WithTransformation` methods exposed by the Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/).
88-
transformation?: {
89-
// The region of your Algolia application ID, used to target the correct hosts of the transformation service.
90-
region: IngestionRegion;
91-
};
88+
transformation?:
89+
| {
90+
// The region of your Algolia application ID, used to target the correct hosts of the transformation service.
91+
region: IngestionRegion;
92+
}
93+
| undefined;
9294
};
9395

9496
export function algoliasearch(
9597
appId: string,
9698
apiKey: string,
97-
options?: ClientOptions & TransformationOptions,
99+
options?: (ClientOptions & TransformationOptions) | undefined,
98100
): Algoliasearch {
99101
if (!appId || typeof appId !== 'string') {
100102
throw new Error('`appId` is missing.');

0 commit comments

Comments
 (0)