-
Notifications
You must be signed in to change notification settings - Fork 22
feat(clients): add collections #5224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dhayab
wants to merge
8
commits into
main
Choose a base branch
from
feat/clients-add-collections
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+710
−17
Open
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2f29689
feat(clients): add collections
dhayab f74582d
remove format in spec and reorder parameters in tests
dhayab 49de4c5
add js playground and fix duplicate issue in swift
dhayab bda1868
fix: dart
shortcuts 503faa1
fix: dart (for real)
shortcuts f504f2c
fix: php and maybe more
shortcuts 60f4274
fix: dart (for real again)
shortcuts 4888057
chore: no swifty
shortcuts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ApiError } from '@algolia/client-common'; | ||
import { collectionsClient } from '@algolia/collections'; | ||
|
||
const appId = process.env.ALGOLIA_APPLICATION_ID || '**** APP_ID *****'; | ||
const apiKey = process.env.ALGOLIA_ADMIN_KEY || '**** ADMIN_KEY *****'; | ||
const indexName = process.env.SEARCH_INDEX || '**** INDEX_NAME *****'; | ||
|
||
// Init client with appId and apiKey | ||
const client = collectionsClient(appId, apiKey); | ||
|
||
async function testCollections() { | ||
try { | ||
// list collections | ||
console.log(await client.listCollections({ indexName })); | ||
} catch (e) { | ||
if (e instanceof ApiError) { | ||
return console.log(`[${e.status}] ${e.message}`, e.stackTrace, e); | ||
} | ||
|
||
console.log('[ERROR]', e); | ||
} | ||
} | ||
|
||
testCollections(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
indexName: | ||
name: indexName | ||
in: query | ||
required: true | ||
description: Name of the index. | ||
schema: | ||
type: string | ||
example: ALGOLIA_INDEX_NAME | ||
|
||
paginationLimit: | ||
name: limit | ||
in: query | ||
description: Number of items to fetch. | ||
required: false | ||
schema: | ||
$ref: './schemas/pagination.yml#/limit' | ||
|
||
paginationOffset: | ||
name: offset | ||
in: query | ||
description: Number of items to skip. | ||
required: false | ||
schema: | ||
$ref: './schemas/pagination.yml#/offset' | ||
|
||
pathCollectionID: | ||
name: collectionID | ||
in: path | ||
required: true | ||
description: Unique identifier of a collection. | ||
schema: | ||
$ref: './schemas/common.yml#/collectionID' | ||
|
||
query: | ||
name: query | ||
in: query | ||
required: false | ||
description: Query to filter collections. | ||
schema: | ||
$ref: './schemas/common.yml#/query' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
description: Collection not found. | ||
content: | ||
application/json: | ||
schema: | ||
title: collectionNotFoundResponse | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
example: 'Collection not found' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
Collection: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
example: '5db3039e-04b5-4ed6-a00e-ba3304032c5a' | ||
name: | ||
type: string | ||
example: 'Summer Deals' | ||
indexName: | ||
type: string | ||
example: 'prod_products_EN' | ||
createdAt: | ||
type: string | ||
# format: date-time | ||
description: | | ||
Date and time when the collection was created, in RFC 3339 format. | ||
example: '2024-10-07T00:00:00Z' | ||
updatedAt: | ||
type: string | ||
# format: date-time | ||
description: | | ||
Date and time when the collection was last updated, in RFC 3339 format. | ||
example: '2024-10-07T00:00:00Z' | ||
status: | ||
$ref: '#/CollectionStatus' | ||
conditions: | ||
$ref: 'condition.yml#/Conditions' | ||
records: | ||
type: array | ||
items: | ||
type: string | ||
|
||
CollectionStatus: | ||
type: string | ||
description: | | ||
Collection commit status. | ||
Only returned if the request API key has write ACLs. | ||
enum: | ||
- COMMITTED | ||
- COMMITTING | ||
- TO_COMMIT | ||
|
||
CollectionUpsert: | ||
type: object | ||
description: API request body for upserting a Collection. | ||
properties: | ||
id: | ||
type: string | ||
indexName: | ||
type: string | ||
name: | ||
type: string | ||
description: | ||
type: string | ||
add: | ||
type: array | ||
description: a list of objectIDs. | ||
minItems: 0 | ||
items: | ||
type: string | ||
remove: | ||
type: array | ||
description: a list of objectIDs. | ||
minItems: 0 | ||
items: | ||
type: string | ||
conditions: | ||
$ref: 'condition.yml#/Conditions' | ||
required: | ||
- indexName | ||
- name | ||
|
||
CollectionsResponse: | ||
type: object | ||
allOf: | ||
- type: object | ||
properties: | ||
items: | ||
type: array | ||
items: | ||
$ref: '#/Collection' | ||
required: | ||
- items | ||
- $ref: 'pagination.yml#/CollectionPagination' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
collectionID: | ||
type: string | ||
# format: uuid | ||
description: Universally unique identifier (UUID) of a collection. | ||
example: 6c02aeb1-775e-418e-870b-1faccd4b2c0f | ||
|
||
query: | ||
type: string | ||
description: Query to filter collections. | ||
example: Summer collection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Conditions: | ||
type: object | ||
description: Conditions to filter records. | ||
properties: | ||
facetFilters: | ||
$ref: '../../../common/schemas/SearchParams.yml#/facetFilters' | ||
numericFilters: | ||
$ref: '../../../common/schemas/SearchParams.yml#/numericFilters' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
CollectionPagination: | ||
type: object | ||
description: Paginated API response. | ||
additionalProperties: false | ||
properties: | ||
total: | ||
type: integer | ||
minimum: 0 | ||
description: Total number of items across all pages. | ||
limit: | ||
$ref: '#/limit' | ||
offset: | ||
$ref: '#/offset' | ||
required: | ||
- total | ||
- limit | ||
- offset | ||
|
||
limit: | ||
type: integer | ||
description: Number of items to fetch. | ||
minimum: 1 | ||
maximum: 50 | ||
default: 10 | ||
|
||
offset: | ||
type: integer | ||
description: Number of items to skip. | ||
minimum: 0 | ||
default: 0 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we actually support everything? I think the no-code/go transformation didn't implement
TO
in numeric right?