Skip to content

Commit dab114a

Browse files
committed
feat(javascript): generate abtesting v3 alpha client
1 parent a901589 commit dab114a

File tree

8 files changed

+243
-69
lines changed

8 files changed

+243
-69
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"version": "0.0.1-alpha.1",
3+
"repository": {
4+
"type": "git",
5+
"url": "git+https://github.com/algolia/algoliasearch-client-javascript.git"
6+
},
7+
"homepage": "https://github.com/algolia/algoliasearch-client-javascript/packages/abtesting#readme",
8+
"type": "module",
9+
"license": "MIT",
10+
"author": "Algolia",
11+
"scripts": {
12+
"build": "yarn clean && yarn tsup && yarn rollup -c rollup.config.js",
13+
"clean": "rm -rf ./dist || true",
14+
"test:bundle": "publint . && attw --pack ."
15+
},
16+
"name": "@algolia/abtesting",
17+
"description": "JavaScript client for abtesting",
18+
"exports": {
19+
".": {
20+
"node": {
21+
"types": {
22+
"import": "./dist/node.d.ts",
23+
"module": "./dist/node.d.ts",
24+
"require": "./dist/node.d.cts"
25+
},
26+
"import": "./dist/builds/node.js",
27+
"module": "./dist/builds/node.js",
28+
"require": "./dist/builds/node.cjs"
29+
},
30+
"worker": {
31+
"types": "./dist/worker.d.ts",
32+
"default": "./dist/builds/worker.js"
33+
},
34+
"default": {
35+
"types": "./dist/browser.d.ts",
36+
"module": "./dist/builds/browser.js",
37+
"import": "./dist/builds/browser.js",
38+
"default": "./dist/builds/browser.umd.js"
39+
}
40+
},
41+
"./dist/builds/*": "./dist/builds/*.js"
42+
},
43+
"jsdelivr": "./dist/builds/browser.umd.js",
44+
"unpkg": "./dist/builds/browser.umd.js",
45+
"react-native": "./dist/builds/browser.js",
46+
"files": [
47+
"dist",
48+
"index.js",
49+
"index.d.ts"
50+
],
51+
"dependencies": {
52+
"@algolia/client-common": "5.23.4",
53+
"@algolia/requester-browser-xhr": "5.23.4",
54+
"@algolia/requester-node-http": "5.23.4",
55+
"@algolia/requester-fetch": "5.23.4"
56+
},
57+
"devDependencies": {
58+
"@arethetypeswrong/cli": "0.17.4",
59+
"@types/node": "22.14.1",
60+
"publint": "0.3.12",
61+
"rollup": "4.39.0",
62+
"tsup": "8.4.0",
63+
"typescript": "5.8.3"
64+
},
65+
"engines": {
66+
"node": ">= 14.0.0"
67+
}
68+
}

config/clients.config.json

+5
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@
137137
"name": "abtesting",
138138
"output": "clients/algoliasearch-client-javascript/packages/client-abtesting"
139139
},
140+
{
141+
"name": "abtesting-v3",
142+
"output": "clients/algoliasearch-client-javascript/packages/abtesting",
143+
"isStandaloneClient": true
144+
},
140145
{
141146
"name": "analytics",
142147
"output": "clients/algoliasearch-client-javascript/packages/client-analytics"

config/clients.schema.json

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"additionalProperties": {
5+
"type": "object",
6+
"properties": {
7+
"clients": {
8+
"oneOf": [
9+
{
10+
"type": "array",
11+
"items": {
12+
"type": "string",
13+
"enum": [
14+
"abtesting",
15+
"abtesting-v3",
16+
"analytics",
17+
"composition",
18+
"ingestion",
19+
"insights",
20+
"monitoring",
21+
"personalization",
22+
"query-suggestions",
23+
"recommend",
24+
"search"
25+
]
26+
}
27+
},
28+
{
29+
"type": "array",
30+
"items": {
31+
"type": "object",
32+
"properties": {
33+
"name": {
34+
"type": "string",
35+
"enum": [
36+
"algoliasearch",
37+
"abtesting",
38+
"abtesting-v3",
39+
"analytics",
40+
"composition",
41+
"composition-full",
42+
"ingestion",
43+
"insights",
44+
"monitoring",
45+
"personalization",
46+
"query-suggestions",
47+
"recommend",
48+
"search"
49+
]
50+
},
51+
"output": { "type": "string" },
52+
"isStandaloneClient": { "type": "boolean", "description": "this property only matters for the javascript client, when `true`, your package will be built as a standalone client and not be part of `algoliasearch` directly. This is recommended for non stable APIs." },
53+
"clientName": { "type": "string", "description": "when defined, the name of the generated instance of the client will be hardcoded, otherwise it defaults to the `spec` name, e.g. search -> searchClient" }
54+
},
55+
"required": ["name", "output"],
56+
"additionalProperties": false
57+
}
58+
}
59+
]
60+
},
61+
"folder": { "type": "string", "description": "the output folder of your client, usually matching the github repository name, e.g. clients/algoliasearch-client-dart" },
62+
"gitRepoId": { "type": "string", "description": "the github repository name, without the organization or username that owns it, e.g. algoliasearch-client-php"},
63+
"packageVersion": { "type": "string", "description": "the version to publish the packages with, it must be semver compatible, e.g. 1.2.3" },
64+
"modelFolder": { "type": "string", "description": "the models folder, e.g. algoliasearch/models"},
65+
"apiFolder": { "type": "string", "description": "the api folder, e.g. lib/src"},
66+
"dockerImage": {
67+
"type": "string",
68+
"description": "whether your client requires a custom docker image with specific needs, most clients require 'apic_base'",
69+
"enum": [
70+
"apic_base",
71+
"apic_ruby",
72+
"apic_swift"
73+
]
74+
},
75+
"tests": {
76+
"type": "object",
77+
"properties": {
78+
"extension": { "type": "string", "description": "the test file extension, e.g. .test.ts" },
79+
"outputFolder": { "type": "string", "description": "the test output folder, e.g. src/generated" }
80+
},
81+
"required": ["extension", "outputFolder"],
82+
"additionalProperties": false
83+
},
84+
"snippets": {
85+
"type": "object",
86+
"properties": {
87+
"extension": { "type": "string", "description": "the snippet file extension, e.g. .cs" },
88+
"outputFolder": { "type": "string", "description": "the snippet output folder, e.g. src" }
89+
},
90+
"required": ["extension", "outputFolder"],
91+
"additionalProperties": false
92+
},
93+
"supportedVersions": {
94+
"type": "array",
95+
"description": "hints the CI on what matrix to generate for this client, this must be language specific versions, e.g. versions of node",
96+
"items": { "type": "string" }
97+
}
98+
},
99+
"required": ["clients", "folder", "gitRepoId", "packageVersion", "modelFolder", "apiFolder", "tests", "snippets"],
100+
"additionalProperties": false
101+
}
102+
}

specs/abtesting-v3/common/parameters.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ ID:
55
description: Unique A/B test identifier.
66
required: true
77
schema:
8-
$ref: "#/abTestID"
8+
$ref: '#/abTestID'
99

1010
# misc
1111
index:
1212
type: string
1313
description: Index name of the A/B test variant (case-sensitive).
14-
example: "delcourt_production"
14+
example: 'delcourt_production'
1515

1616
abTestID:
1717
type: integer
@@ -75,7 +75,7 @@ currencies:
7575
mean: 43.7
7676
standardDeviation: 10.3
7777
additionalProperties:
78-
$ref: "#/currency"
78+
$ref: '#/currency'
7979
x-additionalPropertiesName: currency code
8080

8181
currency:
@@ -84,7 +84,7 @@ currency:
8484
currency:
8585
type: string
8686
description: Currency code.
87-
example: "USD"
87+
example: 'USD'
8888
revenue:
8989
type: number
9090
format: double

specs/abtesting-v3/common/schemas/ABTest.yml

+15-16
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,31 @@ ABTests:
33
- type: array
44
description: A/B tests.
55
items:
6-
$ref: "#/ABTest"
7-
- type: "null"
8-
description: No A/B tests are configured for this application.
6+
$ref: '#/ABTest'
7+
- type: 'null'
98

109
ABTest:
1110
type: object
1211
additionalProperties: false
1312
properties:
1413
abTestID:
15-
$ref: "../parameters.yml#/abTestID"
14+
$ref: '../parameters.yml#/abTestID'
1615
updatedAt:
17-
$ref: "../parameters.yml#/updatedAt"
16+
$ref: '../parameters.yml#/updatedAt'
1817
createdAt:
19-
$ref: "../parameters.yml#/createdAt"
18+
$ref: '../parameters.yml#/createdAt'
2019
endAt:
21-
$ref: "../parameters.yml#/endAt"
20+
$ref: '../parameters.yml#/endAt'
2221
name:
23-
$ref: "../parameters.yml#/name"
22+
$ref: '../parameters.yml#/name'
2423
status:
25-
$ref: "#/Status"
24+
$ref: '#/Status'
2625
variants:
27-
$ref: "Variant.yml#/variants"
26+
$ref: 'Variant.yml#/variants'
2827
configuration:
29-
$ref: "#/ABTestConfiguration"
28+
$ref: '#/ABTestConfiguration'
3029
migratedAbTestID:
31-
$ref: "#/MigratedABTestId"
30+
$ref: '#/MigratedABTestId'
3231
required:
3332
- status
3433
- name
@@ -60,11 +59,11 @@ ABTestConfiguration:
6059
description: A/B test configuration.
6160
properties:
6261
outliers:
63-
$ref: "#/Outliers"
62+
$ref: '#/Outliers'
6463
emptySearch:
65-
$ref: "#/EmptySearch"
64+
$ref: '#/EmptySearch'
6665
minimumDetectableEffect:
67-
$ref: "#/MinimumDetectableEffect"
66+
$ref: '#/MinimumDetectableEffect'
6867

6968
Outliers:
7069
type: object
@@ -96,7 +95,7 @@ MinimumDetectableEffect:
9695
Smallest difference in an observable metric between variants.
9796
For example, to detect a 10% difference between variants, set this value to 0.1.
9897
metric:
99-
$ref: "#/EffectMetric"
98+
$ref: '#/EffectMetric'
10099
required:
101100
- size
102101
- metric

specs/abtesting-v3/common/schemas/Timeseries.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Timeseries:
33
additionalProperties: false
44
properties:
55
abTestID:
6-
$ref: "../parameters.yml#/abTestID"
6+
$ref: '../parameters.yml#/abTestID'
77
variants:
8-
$ref: "#/timeseriesVariants"
8+
$ref: '#/timeseriesVariants'
99
required:
1010
- abTestID
1111
- variants
@@ -18,18 +18,18 @@ timeseriesVariants:
1818
The first variant is your _control_ index, typically your production index.
1919
All of the additional variants are indexes with changed settings that you want to test against the control.
2020
items:
21-
$ref: "#/timeseriesVariant"
21+
$ref: '#/timeseriesVariant'
2222

2323
timeseriesVariant:
2424
type: object
2525
properties:
2626
dates:
27-
$ref: "#/metricDates"
27+
$ref: '#/metricDates'
2828

2929
metricDates:
3030
type: array
3131
items:
32-
$ref: "#/metricDate"
32+
$ref: '#/metricDate'
3333

3434
metricDate:
3535
type: object
@@ -40,4 +40,4 @@ metricDate:
4040
format: date
4141
example: 2025-06-15
4242
metrics:
43-
$ref: "Variant.yml#/metrics"
43+
$ref: 'Variant.yml#/metrics'

0 commit comments

Comments
 (0)