Skip to content

Commit

Permalink
feat(dictionaries): adds methods and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chloelbn committed Feb 17, 2021
1 parent 677e902 commit 9f732b4
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 0 deletions.
61 changes: 61 additions & 0 deletions packages/algoliasearch/src/builds/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
browseSynonyms,
ChunkedBatchResponse,
ChunkOptions,
clearDictionaryEntries,
clearObjects,
clearRules,
ClearRulesOptions,
Expand All @@ -60,13 +61,16 @@ import {
DeleteApiKeyResponse,
deleteBy,
DeleteByFiltersOptions,
deleteDictionaryEntries,
deleteIndex,
deleteObject,
deleteObjects,
DeleteResponse,
deleteRule,
deleteSynonym,
DeleteSynonymOptions,
DictionaryEntry,
DictionarySettings,
exists,
findAnswers,
FindAnswersOptions,
Expand All @@ -76,6 +80,9 @@ import {
FindObjectResponse,
getApiKey,
GetApiKeyResponse,
getDictionarySettings,
GetDictionarySettingsResponse,
getDictionaryTask,
getLogs,
GetLogsResponse,
getObject,
Expand Down Expand Up @@ -127,9 +134,13 @@ import {
ReplaceAllObjectsOptions,
replaceAllRules,
replaceAllSynonyms,
replaceDictionaryEntries,
restoreApiKey,
RestoreApiKeyResponse,
Rule,
saveDictionaryEntries,
SaveDictionaryEntriesOptions,
SaveDictionaryEntriesResponse,
saveObject,
SaveObjectResponse,
saveObjects,
Expand All @@ -146,6 +157,8 @@ import {
SaveSynonymsResponse,
search,
SearchClient as BaseSearchClient,
searchDictionaryEntries,
SearchDictionaryEntriesResponse,
searchForFacetValues,
SearchForFacetValuesQueryParams,
SearchForFacetValuesResponse,
Expand All @@ -160,14 +173,18 @@ import {
searchUserIDs,
SearchUserIDsOptions,
SearchUserIDsResponse,
setDictionarySettings,
SetDictionarySettingsResponse,
setSettings,
SetSettingsResponse,
Settings,
Synonym,
TaskStatusResponse,
updateApiKey,
UpdateApiKeyOptions,
UpdateApiKeyResponse,
UserIDResponse,
waitDictionaryTask,
waitTask,
} from '@algolia/client-search';
import { LogLevelEnum } from '@algolia/logger-common';
Expand Down Expand Up @@ -235,6 +252,15 @@ export default function algoliasearch(
getTopUserIDs,
removeUserID,
hasPendingMappings,
clearDictionaryEntries,
deleteDictionaryEntries,
getDictionarySettings,
getDictionaryTask,
replaceDictionaryEntries,
saveDictionaryEntries,
searchDictionaryEntries,
setDictionarySettings,
waitDictionaryTask,
initIndex: base => (indexName: string): SearchIndex => {
return initIndex(base)(indexName, {
methods: {
Expand Down Expand Up @@ -601,6 +627,41 @@ export type SearchClient = BaseSearchClient & {
readonly hasPendingMappings: (
requestOptions?: HasPendingMappingsOptions & RequestOptions
) => Readonly<Promise<HasPendingMappingsResponse>>;
readonly clearDictionaryEntries: (
dictionary: string,
requestOptions?: RequestOptions & SaveDictionaryEntriesOptions
) => Readonly<WaitablePromise<SaveDictionaryEntriesResponse>>;
readonly deleteDictionaryEntries: (
dictionary: string,
objectIDs: readonly string[],
requestOptions?: RequestOptions & SaveDictionaryEntriesOptions
) => Readonly<WaitablePromise<SaveDictionaryEntriesResponse>>;
readonly replaceDictionaryEntries: (
dictionary: string,
entries: readonly DictionaryEntry[],
requestOptions?: RequestOptions & SaveDictionaryEntriesOptions
) => Readonly<WaitablePromise<SaveDictionaryEntriesResponse>>;
readonly saveDictionaryEntries: (
dictionary: string,
entries: readonly DictionaryEntry[],
requestOptions?: RequestOptions & SaveDictionaryEntriesOptions
) => Readonly<WaitablePromise<SaveDictionaryEntriesResponse>>;
readonly searchDictionaryEntries: (
dictionary: string,
query: string,
requestOptions?: RequestOptions
) => Readonly<Promise<SearchDictionaryEntriesResponse>>;
readonly getDictionarySettings: (
requestOptions?: RequestOptions
) => Readonly<Promise<GetDictionarySettingsResponse>>;
readonly setDictionarySettings: (
settings: readonly DictionarySettings[],
requestOptions?: RequestOptions
) => Readonly<WaitablePromise<SetDictionarySettingsResponse>>;
readonly getDictionaryTask: (
taskID: number,
requestOptions?: RequestOptions
) => Readonly<Promise<TaskStatusResponse>>;
readonly initAnalytics: (options?: InitAnalyticsOptions) => AnalyticsClient;
readonly initRecommendation: (options?: InitRecommendationOptions) => RecommendationClient;
};
Expand Down
61 changes: 61 additions & 0 deletions packages/algoliasearch/src/builds/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
browseSynonyms,
ChunkedBatchResponse,
ChunkOptions,
clearDictionaryEntries,
clearObjects,
clearRules,
ClearRulesOptions,
Expand All @@ -59,13 +60,16 @@ import {
DeleteApiKeyResponse,
deleteBy,
DeleteByFiltersOptions,
deleteDictionaryEntries,
deleteIndex,
deleteObject,
deleteObjects,
DeleteResponse,
deleteRule,
deleteSynonym,
DeleteSynonymOptions,
DictionaryEntry,
DictionarySettings,
exists,
findAnswers,
FindAnswersOptions,
Expand All @@ -76,6 +80,9 @@ import {
generateSecuredApiKey,
getApiKey,
GetApiKeyResponse,
getDictionarySettings,
GetDictionarySettingsResponse,
getDictionaryTask,
getLogs,
GetLogsResponse,
getObject,
Expand Down Expand Up @@ -128,9 +135,13 @@ import {
ReplaceAllObjectsOptions,
replaceAllRules,
replaceAllSynonyms,
replaceDictionaryEntries,
restoreApiKey,
RestoreApiKeyResponse,
Rule,
saveDictionaryEntries,
SaveDictionaryEntriesOptions,
SaveDictionaryEntriesResponse,
saveObject,
SaveObjectResponse,
saveObjects,
Expand All @@ -147,6 +158,8 @@ import {
SaveSynonymsResponse,
search,
SearchClient as BaseSearchClient,
searchDictionaryEntries,
SearchDictionaryEntriesResponse,
searchForFacetValues,
SearchForFacetValuesQueryParams,
SearchForFacetValuesResponse,
Expand All @@ -162,14 +175,18 @@ import {
SearchUserIDsOptions,
SearchUserIDsResponse,
SecuredApiKeyRestrictions,
setDictionarySettings,
SetDictionarySettingsResponse,
setSettings,
SetSettingsResponse,
Settings,
Synonym,
TaskStatusResponse,
updateApiKey,
UpdateApiKeyOptions,
UpdateApiKeyResponse,
UserIDResponse,
waitDictionaryTask,
waitTask,
} from '@algolia/client-search';
import { createNullLogger } from '@algolia/logger-common';
Expand Down Expand Up @@ -238,6 +255,15 @@ export default function algoliasearch(
generateSecuredApiKey,
getSecuredApiKeyRemainingValidity,
destroy,
clearDictionaryEntries,
deleteDictionaryEntries,
getDictionarySettings,
getDictionaryTask,
replaceDictionaryEntries,
saveDictionaryEntries,
searchDictionaryEntries,
setDictionarySettings,
waitDictionaryTask,
initIndex: base => (indexName: string): SearchIndex => {
return initIndex(base)(indexName, {
methods: {
Expand Down Expand Up @@ -609,6 +635,41 @@ export type SearchClient = BaseSearchClient & {
restrictions: SecuredApiKeyRestrictions
) => string;
readonly getSecuredApiKeyRemainingValidity: (securedApiKey: string) => number;
readonly clearDictionaryEntries: (
dictionary: string,
requestOptions?: RequestOptions & SaveDictionaryEntriesOptions
) => Readonly<WaitablePromise<SaveDictionaryEntriesResponse>>;
readonly deleteDictionaryEntries: (
dictionary: string,
objectIDs: readonly string[],
requestOptions?: RequestOptions & SaveDictionaryEntriesOptions
) => Readonly<WaitablePromise<SaveDictionaryEntriesResponse>>;
readonly replaceDictionaryEntries: (
dictionary: string,
entries: readonly DictionaryEntry[],
requestOptions?: RequestOptions & SaveDictionaryEntriesOptions
) => Readonly<WaitablePromise<SaveDictionaryEntriesResponse>>;
readonly saveDictionaryEntries: (
dictionary: string,
entries: readonly DictionaryEntry[],
requestOptions?: RequestOptions & SaveDictionaryEntriesOptions
) => Readonly<WaitablePromise<SaveDictionaryEntriesResponse>>;
readonly searchDictionaryEntries: (
dictionary: string,
query: string,
requestOptions?: RequestOptions
) => Readonly<Promise<SearchDictionaryEntriesResponse>>;
readonly getDictionarySettings: (
requestOptions?: RequestOptions
) => Readonly<Promise<GetDictionarySettingsResponse>>;
readonly setDictionarySettings: (
settings: readonly DictionarySettings[],
requestOptions?: RequestOptions
) => Readonly<WaitablePromise<SetDictionarySettingsResponse>>;
readonly getDictionaryTask: (
taskID: number,
requestOptions?: RequestOptions
) => Readonly<Promise<TaskStatusResponse>>;
readonly initAnalytics: (options?: InitAnalyticsOptions) => AnalyticsClient;
readonly initRecommendation: (options?: InitRecommendationOptions) => RecommendationClient;
} & Destroyable;
Expand Down
7 changes: 7 additions & 0 deletions packages/client-common/src/__tests__/TestSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ export class TestSuite {
return client;
}

public makeDictionarySearchClient(
appIdEnv: string = 'ALGOLIA_APPLICATION_ID_2',
apiKeyEnv: string = 'ALGOLIA_ADMIN_KEY_2'
) {
return this.makeSearchClient(appIdEnv, apiKeyEnv);
}

public makeRecommendationClient(
appIdEnv: string = 'ALGOLIA_APPLICATION_ID_1',
apiKeyEnv: string = 'ALGOLIA_ADMIN_KEY_1'
Expand Down
9 changes: 9 additions & 0 deletions packages/client-search/src/methods/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
export * from './addApiKey';
export * from './assignUserID';
export * from './assignUserIDs';
export * from './clearDictionaryEntries';
export * from './copyIndex';
export * from './copyRules';
export * from './copySettings';
export * from './copySynonyms';
export * from './deleteApiKey';
export * from './deleteDictionaryEntries';
export * from './generateSecuredApiKey';
export * from './getApiKey';
export * from './getDictionarySettings';
export * from './getLogs';
export * from './getSecuredApiKeyRemainingValidity';
export * from './getTopUserIDs';
export * from './getDictionaryTask';
export * from './getUserID';
export * from './hasPendingMappings';
export * from './initIndex';
Expand All @@ -28,6 +32,11 @@ export * from './multipleGetObjects';
export * from './multipleQueries';
export * from './multipleSearchForFacetValues';
export * from './removeUserID';
export * from './replaceDictionaryEntries';
export * from './restoreApiKey';
export * from './saveDictionaryEntries';
export * from './searchDictionaryEntries';
export * from './searchUserIDs';
export * from './setDictionarySettings';
export * from './updateApiKey';
export * from './waitDictionaryTask';
7 changes: 7 additions & 0 deletions packages/client-search/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export * from './DeleteApiKeyResponse';
export * from './DeleteByFiltersOptions';
export * from './DeleteResponse';
export * from './DeleteSynonymOptions';
export * from './DictionaryEntry';
export * from './DictionarySettings';
export * from './FacetHit';
export * from './FindAnswersOptions';
export * from './FindAnswersResponse';
Expand All @@ -35,6 +37,7 @@ export * from './GetLogsResponse';
export * from './GetObjectOptions';
export * from './GetObjectsOptions';
export * from './GetObjectsResponse';
export * from './GetDictionarySettingsResponse';
export * from './GetTopUserIDsResponse';
export * from './HasPendingMappingsOptions';
export * from './HasPendingMappingsResponse';
Expand All @@ -61,6 +64,8 @@ export * from './RemoveUserIDResponse';
export * from './ReplaceAllObjectsOptions';
export * from './RestoreApiKeyResponse';
export * from './Rule';
export * from './SaveDictionaryEntriesOptions';
export * from './SaveDictionaryEntriesResponse';
export * from './SaveObjectResponse';
export * from './SaveObjectsOptions';
export * from './SaveRuleResponse';
Expand All @@ -71,6 +76,7 @@ export * from './SaveSynonymsOptions';
export * from './SaveSynonymsResponse';
export * from './SearchClient';
export * from './SearchClientOptions';
export * from './SearchDictionaryEntriesResponse';
export * from './SearchForFacetValuesQueryParams';
export * from './SearchForFacetValuesResponse';
export * from './SearchIndex';
Expand All @@ -82,6 +88,7 @@ export * from './SearchSynonymsResponse';
export * from './SearchUserIDsOptions';
export * from './SearchUserIDsResponse';
export * from './SecuredApiKeyRestrictions';
export * from './SetDictionarySettingsResponse';
export * from './SetSettingsOptions';
export * from './SetSettingsResponse';
export * from './Settings';
Expand Down

0 comments on commit 9f732b4

Please sign in to comment.