-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(specs): add
personalizaton
spec and client (#27)
- Loading branch information
Showing
53 changed files
with
1,467 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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 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
4 changes: 4 additions & 0 deletions
4
clients/algoliasearch-client-javascript/client-personalization/.gitignore
This file contains 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,4 @@ | ||
node_modules | ||
dist | ||
.openapi-generator | ||
.env |
7 changes: 7 additions & 0 deletions
7
clients/algoliasearch-client-javascript/client-personalization/.openapi-generator-ignore
This file contains 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,7 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
git_push.sh |
3 changes: 3 additions & 0 deletions
3
clients/algoliasearch-client-javascript/client-personalization/api.ts
This file contains 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,3 @@ | ||
// This is the entrypoint for the package | ||
export * from './src/apis'; | ||
export * from './model/models'; |
10 changes: 10 additions & 0 deletions
10
...algoliasearch-client-javascript/client-personalization/model/deleteUserProfileResponse.ts
This file contains 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 @@ | ||
export type DeleteUserProfileResponse = { | ||
/** | ||
* UserToken representing the user for which to fetch the Personalization profile. | ||
*/ | ||
userToken: string; | ||
/** | ||
* A date until which the data can safely be considered as deleted for the given user. Any data received after the deletedUntil date will start building a new user profile. | ||
*/ | ||
deletedUntil: Date; | ||
}; |
6 changes: 6 additions & 0 deletions
6
clients/algoliasearch-client-javascript/client-personalization/model/errorBase.ts
This file contains 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,6 @@ | ||
/** | ||
* Error. | ||
*/ | ||
export type ErrorBase = { | ||
message?: string; | ||
}; |
14 changes: 14 additions & 0 deletions
14
clients/algoliasearch-client-javascript/client-personalization/model/eventScoring.ts
This file contains 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,14 @@ | ||
export type EventScoring = { | ||
/** | ||
* The score for the event. | ||
*/ | ||
score: number; | ||
/** | ||
* The name of the event. | ||
*/ | ||
eventName: string; | ||
/** | ||
* The type of the event. | ||
*/ | ||
eventType: string; | ||
}; |
10 changes: 10 additions & 0 deletions
10
clients/algoliasearch-client-javascript/client-personalization/model/facetScoring.ts
This file contains 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 @@ | ||
export type FacetScoring = { | ||
/** | ||
* The score for the event. | ||
*/ | ||
score: number; | ||
/** | ||
* The name of the facet. | ||
*/ | ||
facetName: string; | ||
}; |
14 changes: 14 additions & 0 deletions
14
clients/algoliasearch-client-javascript/client-personalization/model/getUserTokenResponse.ts
This file contains 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,14 @@ | ||
export type GetUserTokenResponse = { | ||
/** | ||
* UserToken representing the user for which to fetch the Personalization profile. | ||
*/ | ||
userToken: string; | ||
/** | ||
* Date of last event update. (ISO-8601 format). | ||
*/ | ||
lastEventAt: Date; | ||
/** | ||
* The userToken scores. | ||
*/ | ||
scores: { [key: string]: Record<string, any> }; | ||
}; |
49 changes: 49 additions & 0 deletions
49
clients/algoliasearch-client-javascript/client-personalization/model/models.ts
This file contains 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,49 @@ | ||
/* eslint-disable no-param-reassign */ | ||
import type { RequestOptions } from '../utils/types'; | ||
|
||
export * from './deleteUserProfileResponse'; | ||
export * from './errorBase'; | ||
export * from './eventScoring'; | ||
export * from './facetScoring'; | ||
export * from './getUserTokenResponse'; | ||
export * from './personalizationStrategyObject'; | ||
export * from './setPersonalizationStrategyResponse'; | ||
|
||
export interface Authentication { | ||
/** | ||
* Apply authentication settings to header and query params. | ||
*/ | ||
applyToRequest: (requestOptions: RequestOptions) => Promise<void> | void; | ||
} | ||
|
||
export class ApiKeyAuth implements Authentication { | ||
apiKey: string = ''; | ||
|
||
constructor(private location: string, private paramName: string) {} | ||
|
||
applyToRequest(requestOptions: RequestOptions): void { | ||
if (this.location === 'query') { | ||
requestOptions.queryParameters[this.paramName] = this.apiKey; | ||
} else if ( | ||
this.location === 'header' && | ||
requestOptions && | ||
requestOptions.headers | ||
) { | ||
requestOptions.headers[this.paramName] = this.apiKey; | ||
} else if ( | ||
this.location === 'cookie' && | ||
requestOptions && | ||
requestOptions.headers | ||
) { | ||
if (requestOptions.headers.Cookie) { | ||
requestOptions.headers.Cookie += `; ${ | ||
this.paramName | ||
}=${encodeURIComponent(this.apiKey)}`; | ||
} else { | ||
requestOptions.headers.Cookie = `${this.paramName}=${encodeURIComponent( | ||
this.apiKey | ||
)}`; | ||
} | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...liasearch-client-javascript/client-personalization/model/personalizationStrategyObject.ts
This file contains 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,17 @@ | ||
import type { EventScoring } from './eventScoring'; | ||
import type { FacetScoring } from './facetScoring'; | ||
|
||
export type PersonalizationStrategyObject = { | ||
/** | ||
* Scores associated with the events. | ||
*/ | ||
eventScoring: EventScoring[]; | ||
/** | ||
* Scores associated with the facets. | ||
*/ | ||
facetScoring: FacetScoring[]; | ||
/** | ||
* The impact that personalization has on search results: a number between 0 (personalization disabled) and 100 (personalization fully enabled). | ||
*/ | ||
personalizationImpact: number; | ||
}; |
6 changes: 6 additions & 0 deletions
6
...arch-client-javascript/client-personalization/model/setPersonalizationStrategyResponse.ts
This file contains 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,6 @@ | ||
export type SetPersonalizationStrategyResponse = { | ||
/** | ||
* A message confirming the strategy update. | ||
*/ | ||
message: string; | ||
}; |
24 changes: 24 additions & 0 deletions
24
clients/algoliasearch-client-javascript/client-personalization/package.json
This file contains 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 @@ | ||
{ | ||
"name": "@algolia/client-personalization", | ||
"version": "5.0.0", | ||
"description": "JavaScript client for @algolia/client-personalization", | ||
"repository": "algolia/algoliasearch-client-javascript", | ||
"author": "Algolia", | ||
"private": true, | ||
"license": "MIT", | ||
"main": "dist/api.js", | ||
"types": "dist/api.d.ts", | ||
"scripts": { | ||
"clean": "rm -Rf node_modules/ *.js", | ||
"build": "tsc", | ||
"test": "yarn build && node dist/client.js" | ||
}, | ||
"engines": { | ||
"node": "^16.0.0", | ||
"yarn": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "16.11.11", | ||
"typescript": "4.5.2" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
clients/algoliasearch-client-javascript/client-personalization/src/apis.ts
This file contains 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,7 @@ | ||
import { PersonalizationApi } from './personalizationApi'; | ||
|
||
export * from './personalizationApi'; | ||
export * from '../utils/errors'; | ||
export { EchoRequester } from '../utils/requester/EchoRequester'; | ||
|
||
export const APIS = [PersonalizationApi]; |
Oops, something went wrong.