Skip to content

Commit

Permalink
feat(dictionaries): adds methods and tests (#1253)
Browse files Browse the repository at this point in the history
* feat(dictionaries): adds methods and tests

* rename dictionary task to app task

* semicolon

* add missing types

* group tests

* remove `dictionary` tests from `browser-lite` env

* fix methods

* split and fix tests

* Rename `SaveDictionaryEntriesOptions` type to `DictionaryEntriesOptions`

* Rename `SaveDictionaryEntriesResponse` type to `DictionaryEntriesResponse`

* Remove duplicate type: `SetDictionarySettingsResponse`

* Assert object is present

* Remove unneeded spread

Co-authored-by: Haroen Viaene <[email protected]>
Co-authored-by: shortcuts <[email protected]>
  • Loading branch information
3 people authored Apr 13, 2021
1 parent 54c1cb7 commit aed6554
Show file tree
Hide file tree
Showing 24 changed files with 617 additions and 1 deletion.
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module.exports = {
'packages/client-search/src/__tests__/integration/secured-api-keys.test.ts',
'packages/client-search/src/__tests__/integration/settings.test.ts',
'packages/client-search/src/__tests__/integration/synonyms.test.ts',
'packages/client-search/src/__tests__/integration/dictionary.test.ts',
],
globals: {
environment: 'browser-lite',
Expand All @@ -65,6 +66,7 @@ module.exports = {
testPathIgnorePatterns: [
'packages/requester-node-http/*',
'packages/client-search/src/__tests__/integration/secured-api-keys.test.ts',
'packages/client-search/src/__tests__/integration/dictionary.test.ts',
],
globals: {
environment: 'browser',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"bundlesize": [
{
"path": "packages/algoliasearch/dist/algoliasearch.umd.js",
"maxSize": "7.65KB"
"maxSize": "7.85KB"
},
{
"path": "packages/algoliasearch/dist/algoliasearch-lite.umd.js",
Expand Down
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,19 @@ import {
DeleteApiKeyResponse,
deleteBy,
DeleteByFiltersOptions,
deleteDictionaryEntries,
deleteIndex,
deleteObject,
deleteObjects,
DeleteResponse,
deleteRule,
deleteSynonym,
DeleteSynonymOptions,
DictionaryEntriesOptions,
DictionaryEntriesResponse,
DictionaryEntry,
DictionaryName,
DictionarySettings,
exists,
findAnswers,
FindAnswersOptions,
Expand All @@ -76,6 +83,9 @@ import {
FindObjectResponse,
getApiKey,
GetApiKeyResponse,
getAppTask,
getDictionarySettings,
GetDictionarySettingsResponse,
getLogs,
GetLogsResponse,
getObject,
Expand Down Expand Up @@ -127,9 +137,11 @@ import {
ReplaceAllObjectsOptions,
replaceAllRules,
replaceAllSynonyms,
replaceDictionaryEntries,
restoreApiKey,
RestoreApiKeyResponse,
Rule,
saveDictionaryEntries,
saveObject,
SaveObjectResponse,
saveObjects,
Expand All @@ -146,6 +158,8 @@ import {
SaveSynonymsResponse,
search,
SearchClient as BaseSearchClient,
searchDictionaryEntries,
SearchDictionaryEntriesResponse,
searchForFacetValues,
SearchForFacetValuesQueryParams,
SearchForFacetValuesResponse,
Expand All @@ -160,14 +174,17 @@ import {
searchUserIDs,
SearchUserIDsOptions,
SearchUserIDsResponse,
setDictionarySettings,
setSettings,
SetSettingsResponse,
Settings,
Synonym,
TaskStatusResponse,
updateApiKey,
UpdateApiKeyOptions,
UpdateApiKeyResponse,
UserIDResponse,
waitAppTask,
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,
getAppTask,
replaceDictionaryEntries,
saveDictionaryEntries,
searchDictionaryEntries,
setDictionarySettings,
waitAppTask,
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: DictionaryName,
requestOptions?: RequestOptions & DictionaryEntriesOptions
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
readonly deleteDictionaryEntries: (
dictionary: DictionaryName,
objectIDs: readonly string[],
requestOptions?: RequestOptions & DictionaryEntriesOptions
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
readonly replaceDictionaryEntries: (
dictionary: DictionaryName,
entries: readonly DictionaryEntry[],
requestOptions?: RequestOptions & DictionaryEntriesOptions
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
readonly saveDictionaryEntries: (
dictionary: DictionaryName,
entries: readonly DictionaryEntry[],
requestOptions?: RequestOptions & DictionaryEntriesOptions
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
readonly searchDictionaryEntries: (
dictionary: DictionaryName,
query: string,
requestOptions?: RequestOptions
) => Readonly<Promise<SearchDictionaryEntriesResponse>>;
readonly getDictionarySettings: (
requestOptions?: RequestOptions
) => Readonly<Promise<GetDictionarySettingsResponse>>;
readonly setDictionarySettings: (
settings: DictionarySettings,
requestOptions?: RequestOptions
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
readonly getAppTask: (
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,19 @@ import {
DeleteApiKeyResponse,
deleteBy,
DeleteByFiltersOptions,
deleteDictionaryEntries,
deleteIndex,
deleteObject,
deleteObjects,
DeleteResponse,
deleteRule,
deleteSynonym,
DeleteSynonymOptions,
DictionaryEntriesOptions,
DictionaryEntriesResponse,
DictionaryEntry,
DictionaryName,
DictionarySettings,
exists,
findAnswers,
FindAnswersOptions,
Expand All @@ -76,6 +83,9 @@ import {
generateSecuredApiKey,
getApiKey,
GetApiKeyResponse,
getAppTask,
getDictionarySettings,
GetDictionarySettingsResponse,
getLogs,
GetLogsResponse,
getObject,
Expand Down Expand Up @@ -128,9 +138,11 @@ import {
ReplaceAllObjectsOptions,
replaceAllRules,
replaceAllSynonyms,
replaceDictionaryEntries,
restoreApiKey,
RestoreApiKeyResponse,
Rule,
saveDictionaryEntries,
saveObject,
SaveObjectResponse,
saveObjects,
Expand All @@ -147,6 +159,8 @@ import {
SaveSynonymsResponse,
search,
SearchClient as BaseSearchClient,
searchDictionaryEntries,
SearchDictionaryEntriesResponse,
searchForFacetValues,
SearchForFacetValuesQueryParams,
SearchForFacetValuesResponse,
Expand All @@ -162,14 +176,17 @@ import {
SearchUserIDsOptions,
SearchUserIDsResponse,
SecuredApiKeyRestrictions,
setDictionarySettings,
setSettings,
SetSettingsResponse,
Settings,
Synonym,
TaskStatusResponse,
updateApiKey,
UpdateApiKeyOptions,
UpdateApiKeyResponse,
UserIDResponse,
waitAppTask,
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,
getAppTask,
replaceDictionaryEntries,
saveDictionaryEntries,
searchDictionaryEntries,
setDictionarySettings,
waitAppTask,
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: DictionaryName,
requestOptions?: RequestOptions & DictionaryEntriesOptions
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
readonly deleteDictionaryEntries: (
dictionary: DictionaryName,
objectIDs: readonly string[],
requestOptions?: RequestOptions & DictionaryEntriesOptions
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
readonly replaceDictionaryEntries: (
dictionary: DictionaryName,
entries: readonly DictionaryEntry[],
requestOptions?: RequestOptions & DictionaryEntriesOptions
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
readonly saveDictionaryEntries: (
dictionary: DictionaryName,
entries: readonly DictionaryEntry[],
requestOptions?: RequestOptions & DictionaryEntriesOptions
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
readonly searchDictionaryEntries: (
dictionary: DictionaryName,
query: string,
requestOptions?: RequestOptions
) => Readonly<Promise<SearchDictionaryEntriesResponse>>;
readonly getDictionarySettings: (
requestOptions?: RequestOptions
) => Readonly<Promise<GetDictionarySettingsResponse>>;
readonly setDictionarySettings: (
settings: DictionarySettings,
requestOptions?: RequestOptions
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
readonly getAppTask: (
taskID: number,
requestOptions?: RequestOptions
) => Readonly<Promise<TaskStatusResponse>>;
readonly initAnalytics: (options?: InitAnalyticsOptions) => AnalyticsClient;
readonly initRecommendation: (options?: InitRecommendationOptions) => RecommendationClient;
} & Destroyable;
Expand Down
Loading

0 comments on commit aed6554

Please sign in to comment.