Skip to content

Commit 7a366cd

Browse files
committed
feat(clients): add collections
1 parent aaf1fd9 commit 7a366cd

File tree

9 files changed

+406
-0
lines changed

9 files changed

+406
-0
lines changed

config/clients.config.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"abtesting",
66
"abtesting-v3",
77
"analytics",
8+
"collections",
89
"composition",
910
"ingestion",
1011
"insights",
@@ -39,6 +40,10 @@
3940
"name": "abtesting-v3",
4041
"output": "clients/algoliasearch-client-dart/packages/client_abtesting_v3"
4142
},
43+
{
44+
"name": "collections",
45+
"output": "clients/algoliasearch-client-dart/packages/client_collections"
46+
},
4247
{
4348
"name": "composition",
4449
"output": "clients/algoliasearch-client-dart/packages/client_composition"
@@ -76,6 +81,7 @@
7681
"abtesting",
7782
"abtesting-v3",
7883
"analytics",
84+
"collections",
7985
"composition",
8086
"ingestion",
8187
"insights",
@@ -105,6 +111,7 @@
105111
"abtesting",
106112
"abtesting-v3",
107113
"analytics",
114+
"collections",
108115
"composition",
109116
"ingestion",
110117
"insights",
@@ -153,6 +160,10 @@
153160
"name": "analytics",
154161
"output": "clients/algoliasearch-client-javascript/packages/client-analytics"
155162
},
163+
{
164+
"name": "collections",
165+
"output": "clients/algoliasearch-client-javascript/packages/collections"
166+
},
156167
{
157168
"name": "composition",
158169
"output": "clients/algoliasearch-client-javascript/packages/composition",
@@ -218,6 +229,7 @@
218229
"abtesting",
219230
"abtesting-v3",
220231
"analytics",
232+
"collections",
221233
"composition",
222234
"ingestion",
223235
"insights",
@@ -247,6 +259,7 @@
247259
"abtesting",
248260
"abtesting-v3",
249261
"analytics",
262+
"collections",
250263
"composition",
251264
"ingestion",
252265
"insights",
@@ -276,6 +289,7 @@
276289
"abtesting",
277290
"abtesting-v3",
278291
"analytics",
292+
"collections",
279293
"composition",
280294
"ingestion",
281295
"insights",
@@ -312,6 +326,7 @@
312326
"abtesting",
313327
"abtesting-v3",
314328
"analytics",
329+
"collections",
315330
"composition",
316331
"ingestion",
317332
"insights",
@@ -341,6 +356,7 @@
341356
"abtesting",
342357
"abtesting-v3",
343358
"analytics",
359+
"collections",
344360
"composition",
345361
"ingestion",
346362
"insights",
@@ -370,6 +386,7 @@
370386
"abtesting",
371387
"abtesting-v3",
372388
"analytics",
389+
"collections",
373390
"composition",
374391
"ingestion",
375392
"insights",

config/clients.schema.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"abtesting",
1515
"abtesting-v3",
1616
"analytics",
17+
"collections",
1718
"composition",
1819
"ingestion",
1920
"insights",
@@ -38,6 +39,7 @@
3839
"abtesting",
3940
"abtesting-v3",
4041
"analytics",
42+
"collections",
4143
"composition",
4244
"composition-full",
4345
"ingestion",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pathCollectionID:
2+
name: collectionID
3+
in: path
4+
required: true
5+
description: Unique identifier of a collection.
6+
schema:
7+
$ref: './schemas/common.yml#/collectionID'
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
Collection:
2+
type: object
3+
properties:
4+
id:
5+
type: string
6+
example: '5db3039e-04b5-4ed6-a00e-ba3304032c5a'
7+
name:
8+
type: string
9+
example: 'Summer Deals'
10+
indexName:
11+
type: string
12+
example: 'prod_products_EN'
13+
createdAt:
14+
type: string
15+
format: date-time
16+
example: '2024-10-07T00:00:00Z'
17+
updatedAt:
18+
type: string
19+
format: date-time
20+
example: '2024-10-07T00:00:00Z'
21+
status:
22+
$ref: '#/CollectionStatus'
23+
conditions:
24+
$ref: '#/Conditions'
25+
records:
26+
type: array
27+
items:
28+
type: string
29+
30+
CollectionStatus:
31+
type: string
32+
description: |
33+
Collection commit status.
34+
Only returned if the request API key has write ACLs.
35+
enum:
36+
- COMMITTED
37+
- COMMITTING
38+
- TO_COMMIT
39+
40+
CollectionUpsert:
41+
type: object
42+
description: API request body for upserting a Collection.
43+
properties:
44+
id:
45+
type: string
46+
indexName:
47+
type: string
48+
name:
49+
type: string
50+
description:
51+
type: string
52+
add:
53+
type: array
54+
description: a list of objectIDs.
55+
minItems: 0
56+
items:
57+
type: string
58+
remove:
59+
type: array
60+
description: a list of objectIDs.
61+
minItems: 0
62+
items:
63+
type: string
64+
conditions:
65+
$ref: '#/Conditions'
66+
required:
67+
- indexName
68+
- name
69+
70+
Conditions:
71+
type: object
72+
description: conditions to filter records.
73+
properties:
74+
facetFilters:
75+
type: array
76+
description: one-level nested array. A nesting indicates OR, filters combined with AND top-level.
77+
items:
78+
$ref: '#/FacetFilter'
79+
numericFilters:
80+
type: array
81+
description: one-level nested array. A nesting indicates OR, filters combined with AND top-level.
82+
items:
83+
$ref: '#/NumericFilter'
84+
85+
# TODO: Check for common schema?
86+
FacetFilter:
87+
oneOf:
88+
- type: string
89+
pattern: '/^[^:]+[^\\]*:.+$/'
90+
example: 'brand:Apple'
91+
# FIXME: Not recognized here
92+
# examples:
93+
# normal:
94+
# value: 'brand:Apple'
95+
# summary: include Apple in the results
96+
# negated:
97+
# value: 'brand:-Apple'
98+
# summary: exclude Apple from the results
99+
# escaped:
100+
# value: 'discount:\-50%'
101+
# summary: include "-50%" in the results
102+
- type: array
103+
items:
104+
type: string
105+
pattern: '/^[^:]+[^\\]*:.+$/'
106+
example: 'brand:Samsung'
107+
108+
# TODO: Check for common schema?
109+
NumericFilter:
110+
oneOf:
111+
- type: string
112+
pattern: '/(^[^:]+[^\\]*:\d*\.?\d* TO \d*\.?\d*$)|(^[^:]+[^\\]*(<|<=|=|>=|>)\d*\.?\d*$)/'
113+
example: 'price:5 TO 10'
114+
- type: array
115+
items:
116+
type: string
117+
pattern: '/(^[^:]+[^\\]*:\d*\.?\d* TO \d*\.?\d*$)|(^[^:]+[^\\]*(<|<=|=|>=|>)\d*\.?\d*$)/'
118+
example: 'rating<=4.3'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
collectionID:
2+
type: string
3+
# format: uuid
4+
description: Universally unique identifier (UUID) of a collection.
5+
example: 6c02aeb1-775e-418e-870b-1faccd4b2c0f
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
get:
2+
summary: Retrieve a collection
3+
description: Retrieves a collection by its ID.
4+
operationId: getCollection
5+
x-acl:
6+
- search
7+
parameters:
8+
- $ref: '../common/parameters.yml#/pathCollectionID'
9+
responses:
10+
'404':
11+
description: Collection not found.
12+
'200':
13+
description: The requested collection.
14+
content:
15+
application/json:
16+
schema:
17+
title: getCollectionResponse
18+
$ref: '../common/schemas/collection.yml#/Collection'
19+
20+
delete:
21+
summary: Delete a collection
22+
description: Deletes a collection by its ID.
23+
operationId: deleteCollection
24+
x-acl:
25+
- search
26+
- addObject
27+
- deleteIndex
28+
- settings
29+
- editSettings
30+
parameters:
31+
- $ref: '../common/parameters.yml#/pathCollectionID'
32+
responses:
33+
'404':
34+
description: Collection not found.
35+
'200':
36+
description: Collection deleted successfully.
37+
content:
38+
application/json:
39+
schema:
40+
title: deleteCollectionResponse
41+
type: object
42+
properties:
43+
message:
44+
type: string
45+
example: 'Collection with id {collectionID} deleted.'
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
get:
2+
summary: List collections
3+
description: Retrieves a list of collections for a specific index.
4+
operationId: listCollections
5+
x-acl:
6+
- search
7+
parameters:
8+
- name: indexName
9+
in: query
10+
required: true
11+
description: Name of the index.
12+
schema:
13+
type: string
14+
example: ALGOLIA_INDEX_NAME
15+
- name: offset
16+
in: query
17+
required: false
18+
description: Number of items to skip (default to 0).
19+
schema:
20+
type: integer
21+
default: 0
22+
- name: limit
23+
in: query
24+
required: false
25+
description: Number of items per fetch (defaults to 10).
26+
schema:
27+
type: integer
28+
default: 10
29+
- name: query
30+
in: query
31+
required: false
32+
description: Query to filter collections.
33+
schema:
34+
type: string
35+
responses:
36+
'400':
37+
$ref: '../../common/responses/BadRequest.yml'
38+
'200':
39+
description: A list of collections.
40+
content:
41+
application/json:
42+
schema:
43+
title: listCollectionsResponse
44+
type: object
45+
properties:
46+
items:
47+
type: array
48+
items:
49+
$ref: '../common/schemas/collection.yml#/Collection'
50+
total:
51+
type: integer
52+
description: Total number of items.
53+
offset:
54+
type: integer
55+
description: Offset used in this query.
56+
limit:
57+
type: integer
58+
description: Limit used in this query.
59+
60+
post:
61+
summary: Upsert a collection
62+
description: Upserts a collection.
63+
operationId: upsertCollection
64+
x-acl:
65+
- search
66+
- addObject
67+
- deleteIndex
68+
- settings
69+
- editSettings
70+
requestBody:
71+
description: Request body for upserting a Collection.
72+
content:
73+
application/json:
74+
schema:
75+
$ref: '../common/schemas/collection.yml#/CollectionUpsert'
76+
responses:
77+
'400':
78+
$ref: '../../common/responses/BadRequest.yml'
79+
'201':
80+
description: Collection created.
81+
content:
82+
application/json:
83+
schema:
84+
$ref: '../common/schemas/collection.yml#/Collection'
85+
'200':
86+
description: Collection updated.
87+
content:
88+
application/json:
89+
schema:
90+
$ref: '../common/schemas/collection.yml#/Collection'

0 commit comments

Comments
 (0)