Skip to content

Commit 5ba87a0

Browse files
authored
feat(specs): add abtesting specs and client (#76)
1 parent 9592e77 commit 5ba87a0

File tree

127 files changed

+2984
-994
lines changed

Some content is hidden

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

127 files changed

+2984
-994
lines changed

.eslintrc.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ module.exports = {
6363
'max-classes-per-file': 0,
6464
'no-continue': 0,
6565
'@typescript-eslint/prefer-enum-initializers': 0,
66-
// there's a conflict when declaring `type` and `namespaces`, even with `ignoreDeclarationMerge`
67-
'no-redeclare': 0,
68-
'@typescript-eslint/no-redeclare': 0,
6966

7067
'@typescript-eslint/no-unused-vars': 2,
7168
'unused-imports/no-unused-imports-ts': 2,

.github/actions/cache/action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ runs:
4646
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/client-analytics/dist
4747
key: ${{ runner.os }}-js-client-analytics-${{ hashFiles('clients/algoliasearch-client-javascript/client-analytics/**') }}
4848

49+
- name: Restore built JavaScript abtesting client
50+
if: ${{ inputs.job == 'cts' }}
51+
uses: actions/cache@v2
52+
with:
53+
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/client-abtesting/dist
54+
key: ${{ runner.os }}-js-client-abtesting-${{ hashFiles('clients/algoliasearch-client-javascript/client-abtesting/**') }}
55+
4956
- name: Restore built JavaScript insights client
5057
if: ${{ inputs.job == 'cts' }}
5158
uses: actions/cache@v2

.github/actions/setup/action.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ runs:
3535
echo "::set-output name=PERSO_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/personalization | wc -l)"
3636
echo "::set-output name=INSIGHTS_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/insights | wc -l)"
3737
echo "::set-output name=ANALYTICS_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/analytics | wc -l)"
38-
echo "::set-output name=AB_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/abtesting | wc -l)"
38+
echo "::set-output name=ABTESTING_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/abtesting | wc -l)"
3939
4040
echo "::set-output name=TESTS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- tests | wc -l)"
4141
@@ -47,6 +47,7 @@ runs:
4747
echo "::set-output name=JS_QUERY_SUGGESTIONS_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-query-suggestions | wc -l)"
4848
echo "::set-output name=JS_PERSO_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-personalization | wc -l)"
4949
echo "::set-output name=JS_ANALYTICS_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-analytics | wc -l)"
50+
echo "::set-output name=JS_ABTESTING_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-abtesting | wc -l)"
5051
echo "::set-output name=JS_INSIGHTS_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-insights | wc -l)"
5152
echo "::set-output name=JS_TEMPLATE_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- templates/javascript | wc -l)"
5253
@@ -73,9 +74,9 @@ outputs:
7374
RUN_SPECS_ANALYTICS:
7475
description: Determine if the `specs_analytics` job should run
7576
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.ANALYTICS_SPECS_CHANGED > 0 }}
76-
RUN_SPECS_AB:
77-
description: Determine if the `specs_ab` job should run
78-
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.AB_SPECS_CHANGED > 0 }}
77+
RUN_SPECS_ABTESTING:
78+
description: Determine if the `specs_abtesting` job should run
79+
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.ABTESTING_SPECS_CHANGED > 0 }}
7980

8081
# js client variables
8182
RUN_JS_CLIENT_SEARCH:
@@ -93,6 +94,9 @@ outputs:
9394
RUN_JS_CLIENT_ANALYTICS:
9495
description: Determine if the `client_javascript_analytics` job should run
9596
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.ANALYTICS_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_ANALYTICS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }}
97+
RUN_JS_CLIENT_ABTESTING:
98+
description: Determine if the `client_javascript_abtesting` job should run
99+
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.ABTESTING_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_ABTESTING_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }}
96100
RUN_JS_CLIENT_INSIGHTS:
97101
description: Determine if the `client_javascript_insights` job should run
98102
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.INSIGHTS_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_INSIGHTS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }}

.github/workflows/check.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ jobs:
3232
RUN_SPECS_PERSO: ${{ steps.setup.outputs.RUN_SPECS_PERSO }}
3333
RUN_SPECS_INSIGHTS: ${{ steps.setup.outputs.RUN_SPECS_INSIGHTS }}
3434
RUN_SPECS_ANALYTICS: ${{ steps.setup.outputs.RUN_SPECS_ANALYTICS }}
35-
RUN_SPECS_AB: ${{ steps.setup.outputs.RUN_SPECS_AB }}
35+
RUN_SPECS_ABTESTING: ${{ steps.setup.outputs.RUN_SPECS_ABTESTING }}
3636

3737
RUN_JS_CLIENT_SEARCH: ${{ steps.setup.outputs.RUN_JS_CLIENT_SEARCH }}
3838
RUN_JS_CLIENT_RECOMMEND: ${{ steps.setup.outputs.RUN_JS_CLIENT_RECOMMEND }}
3939
RUN_JS_CLIENT_QUERY_SUGGESTIONS: ${{ steps.setup.outputs.RUN_JS_CLIENT_QUERY_SUGGESTIONS }}
4040
RUN_JS_CLIENT_PERSO: ${{ steps.setup.outputs.RUN_JS_CLIENT_PERSO }}
4141
RUN_JS_CLIENT_ANALYTICS: ${{ steps.setup.outputs.RUN_JS_CLIENT_ANALYTICS }}
42+
RUN_JS_CLIENT_ABTESTING: ${{ steps.setup.outputs.RUN_JS_CLIENT_ABTESTING }}
4243
RUN_JS_CLIENT_INSIGHTS: ${{ steps.setup.outputs.RUN_JS_CLIENT_INSIGHTS }}
4344

4445
RUN_JAVA_CLIENT: ${{ steps.setup.outputs.RUN_JAVA_CLIENT }}
@@ -125,6 +126,22 @@ jobs:
125126
- name: Lint analytics specs
126127
run: yarn eslint --ext=yml specs/analytics
127128

129+
specs_abtesting:
130+
runs-on: ubuntu-20.04
131+
needs: setup
132+
if: ${{ always() && needs.setup.outputs.RUN_SPECS_ABTESTING == 'true' }}
133+
steps:
134+
- uses: actions/checkout@v2
135+
136+
- name: Restore cache
137+
uses: ./.github/actions/cache
138+
139+
- name: Checking abtesting specs
140+
run: yarn build:specs abtesting
141+
142+
- name: Lint abtesting specs
143+
run: yarn eslint --ext=yml specs/abtesting
144+
128145
specs_insights:
129146
runs-on: ubuntu-20.04
130147
needs: setup
@@ -266,6 +283,31 @@ jobs:
266283
if: steps.cache.outputs.cache-hit != 'true'
267284
run: yarn build:clients javascript analytics
268285

286+
client_javascript_abtesting:
287+
runs-on: ubuntu-20.04
288+
needs: [specs_abtesting]
289+
if: ${{ always() && needs.setup.outputs.RUN_JS_CLIENT_ABTESTING == 'true' }}
290+
steps:
291+
- uses: actions/checkout@v2
292+
293+
- name: Restore cache
294+
uses: ./.github/actions/cache
295+
296+
- name: Cache abtesting client
297+
id: cache
298+
uses: actions/cache@v2
299+
with:
300+
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/client-abtesting/dist
301+
key: ${{ runner.os }}-js-client-abtesting-${{ hashFiles('clients/algoliasearch-client-javascript/client-abtesting/**') }}
302+
303+
- name: Generate abtesting client
304+
if: steps.cache.outputs.cache-hit != 'true'
305+
run: yarn generate javascript abtesting
306+
307+
- name: Build abtesting client
308+
if: steps.cache.outputs.cache-hit != 'true'
309+
run: yarn build:clients javascript abtesting
310+
269311
client_javascript_insights:
270312
runs-on: ubuntu-20.04
271313
needs: [specs_insights]
@@ -326,6 +368,7 @@ jobs:
326368
- client_javascript_query_suggestions
327369
- client_javascript_perso
328370
- client_javascript_analytics
371+
- client_javascript_abtesting
329372
- client_javascript_insights
330373
- client_java_search
331374

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@ The clients can be tested inside the [`playground`](./playground) folder
101101
### Usage
102102

103103
```bash
104-
yarn docker playground:<language>:<client>
104+
yarn docker playground <language> <client>
105105
```
106106

107107
### JavaScript
108108

109109
```bash
110-
yarn docker playground:js:search
110+
yarn docker playground javascript search
111111
```
112112

113113
### Java
114114

115115
```bash
116-
yarn docker playground:java:search
116+
yarn docker playground java search
117117
```
118118

119119
# Troubleshooting

clients/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@ This folder hosts the generated clients and their utils.
44

55
## Generated clients
66

7+
### Java
8+
9+
- [algoliasearch-client-java-2](./algoliasearch-client-java-2/): The Algolia search client.
10+
711
### JavaScript
812

9-
- [algoliasearch](./algoliasearch-client-javascript/algoliasearch/): The Algolia search client.
13+
- [@algolia/client-abtesting](./algoliasearch-client-javascript/client-abtesting/): The Algolia AB testing client.
14+
- [@algolia/client-analytics](./algoliasearch-client-javascript/client-analytics/): The Algolia analytics client.
15+
- [@algolia/client-insights](./algoliasearch-client-javascript/client-insights/): The Algolia insights client.
16+
- [@algolia/client-personalization](./algoliasearch-client-javascript/client-personalization/): The Algolia personalization client.
17+
- [@algolia/client-query-suggestions](./algoliasearch-client-javascript/client-query-suggestions/): The Algolia query suggestions client.
18+
- [@algolia/client-search](./algoliasearch-client-javascript/client-search/): The Algolia search client.
1019
- [@algolia/recommend](./algoliasearch-client-javascript/recommend/): The Algolia recommend client.
1120

12-
## Utils
21+
#### Utils
1322

1423
- [JavaScript](./algoliasearch-client-javascript/utils/): The JavaScript clients utils.

clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public BatchResponse taskID(Integer taskID) {
2020
}
2121

2222
/**
23-
* taskID of the indexing task to wait for.
23+
* taskID of the task to wait for.
2424
*
2525
* @return taskID
2626
*/

clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/DeletedAtResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public DeletedAtResponse taskID(Integer taskID) {
1919
}
2020

2121
/**
22-
* taskID of the indexing task to wait for.
22+
* taskID of the task to wait for.
2323
*
2424
* @return taskID
2525
*/

clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SaveObjectResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public SaveObjectResponse taskID(Integer taskID) {
4040
}
4141

4242
/**
43-
* taskID of the indexing task to wait for.
43+
* taskID of the task to wait for.
4444
*
4545
* @return taskID
4646
*/

clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SaveSynonymResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public SaveSynonymResponse taskID(Integer taskID) {
2222
}
2323

2424
/**
25-
* taskID of the indexing task to wait for.
25+
* taskID of the task to wait for.
2626
*
2727
* @return taskID
2828
*/

clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/UpdatedAtResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public UpdatedAtResponse taskID(Integer taskID) {
1919
}
2020

2121
/**
22-
* taskID of the indexing task to wait for.
22+
* taskID of the task to wait for.
2323
*
2424
* @return taskID
2525
*/

clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/UpdatedAtWithObjectIdResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public UpdatedAtWithObjectIdResponse taskID(Integer taskID) {
2222
}
2323

2424
/**
25-
* taskID of the indexing task to wait for.
25+
* taskID of the task to wait for.
2626
*
2727
* @return taskID
2828
*/

clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/UpdatedRuleResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public UpdatedRuleResponse taskID(Integer taskID) {
6060
}
6161

6262
/**
63-
* taskID of the indexing task to wait for.
63+
* taskID of the task to wait for.
6464
*
6565
* @return taskID
6666
*/

clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,7 +2471,8 @@ public Call getLogsAsync(
24712471
*
24722472
* @param indexName The index in which to perform the request. (required)
24732473
* @param objectID Unique identifier of an object. (required)
2474-
* @param attributesToRetrieve (optional)
2474+
* @param attributesToRetrieve List of attributes to retrieve. If not specified, all retrievable
2475+
* attributes are returned. (optional)
24752476
* @param _callback Callback for upload/download progress
24762477
* @return Call to execute
24772478
* @throws ApiException If fail to serialize the request body object
@@ -2546,7 +2547,8 @@ private Call getObjectValidateBeforeCall(
25462547
*
25472548
* @param indexName The index in which to perform the request. (required)
25482549
* @param objectID Unique identifier of an object. (required)
2549-
* @param attributesToRetrieve (optional)
2550+
* @param attributesToRetrieve List of attributes to retrieve. If not specified, all retrievable
2551+
* attributes are returned. (optional)
25502552
* @return Map&lt;String, String&gt;
25512553
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
25522554
* response body
@@ -2572,7 +2574,8 @@ public Map<String, String> getObject(
25722574
*
25732575
* @param indexName The index in which to perform the request. (required)
25742576
* @param objectID Unique identifier of an object. (required)
2575-
* @param attributesToRetrieve (optional)
2577+
* @param attributesToRetrieve List of attributes to retrieve. If not specified, all retrievable
2578+
* attributes are returned. (optional)
25762579
* @param _callback The callback to be executed when the API call finishes
25772580
* @return The request call
25782581
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
@@ -3297,7 +3300,7 @@ public Call getUserIdAsync(
32973300
/**
32983301
* Build call for hasPendingMappings
32993302
*
3300-
* @param getClusters (optional)
3303+
* @param getClusters Whether to get clusters or not. (optional)
33013304
* @param _callback Callback for upload/download progress
33023305
* @return Call to execute
33033306
* @throws ApiException If fail to serialize the request body object
@@ -3346,7 +3349,7 @@ private Call hasPendingMappingsValidateBeforeCall(
33463349
* response is 200 OK. A successful response indicates that the operation has been taken into
33473350
* account, and the userIDs are directly usable.
33483351
*
3349-
* @param getClusters (optional)
3352+
* @param getClusters Whether to get clusters or not. (optional)
33503353
* @return CreatedAtResponse
33513354
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
33523355
* response body
@@ -3366,7 +3369,7 @@ public CreatedAtResponse hasPendingMappings(Boolean getClusters)
33663369
* done. Upon success, the response is 200 OK. A successful response indicates that the operation
33673370
* has been taken into account, and the userIDs are directly usable.
33683371
*
3369-
* @param getClusters (optional)
3372+
* @param getClusters Whether to get clusters or not. (optional)
33703373
* @param _callback The callback to be executed when the API call finishes
33713374
* @return The request call
33723375
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
@@ -3985,7 +3988,7 @@ public Call operationIndexAsync(
39853988
*
39863989
* @param indexName The index in which to perform the request. (required)
39873990
* @param objectID Unique identifier of an object. (required)
3988-
* @param buildInOperation The Algolia object. (required)
3991+
* @param buildInOperation List of attributes to update. (required)
39893992
* @param createIfNotExists Creates the record if it does not exist yet. (optional, default to
39903993
* true)
39913994
* @param _callback Callback for upload/download progress
@@ -4081,7 +4084,7 @@ private Call partialUpdateObjectValidateBeforeCall(
40814084
*
40824085
* @param indexName The index in which to perform the request. (required)
40834086
* @param objectID Unique identifier of an object. (required)
4084-
* @param buildInOperation The Algolia object. (required)
4087+
* @param buildInOperation List of attributes to update. (required)
40854088
* @param createIfNotExists Creates the record if it does not exist yet. (optional, default to
40864089
* true)
40874090
* @return UpdatedAtWithObjectIdResponse
@@ -4117,7 +4120,7 @@ public UpdatedAtWithObjectIdResponse partialUpdateObject(
41174120
*
41184121
* @param indexName The index in which to perform the request. (required)
41194122
* @param objectID Unique identifier of an object. (required)
4120-
* @param buildInOperation The Algolia object. (required)
4123+
* @param buildInOperation List of attributes to update. (required)
41214124
* @param createIfNotExists Creates the record if it does not exist yet. (optional, default to
41224125
* true)
41234126
* @param _callback The callback to be executed when the API call finishes
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
dist
3+
.openapi-generator
4+
.env
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
git_push.sh
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This is the entrypoint for the package
2+
export * from './src/apis';
3+
export * from './model/models';
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { Variant } from './variant';
2+
3+
export type ABTest = {
4+
/**
5+
* The A/B test ID.
6+
*/
7+
abTestID: number;
8+
/**
9+
* A/B test significance based on click data. Should be > 0.95 to be considered significant (no matter which variant is winning).
10+
*/
11+
clickSignificance: number;
12+
/**
13+
* A/B test significance based on conversion data. Should be > 0.95 to be considered significant (no matter which variant is winning).
14+
*/
15+
conversionSignificance: number;
16+
/**
17+
* End date for the A/B test expressed as YYYY-MM-DDThh:mm:ssZ.
18+
*/
19+
endAt: Date;
20+
/**
21+
* End date for the A/B test expressed as YYYY-MM-DDThh:mm:ssZ.
22+
*/
23+
createdAt: Date;
24+
/**
25+
* A/B test name.
26+
*/
27+
name: string;
28+
/**
29+
* Status of the A/B test.
30+
*/
31+
status: string;
32+
/**
33+
* List of A/B test variant.
34+
*/
35+
variants: Variant[];
36+
};

0 commit comments

Comments
 (0)