Skip to content

Commit aed6554

Browse files
chloelbnHaroenvshortcuts
authored
feat(dictionaries): adds methods and tests (#1253)
* 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]>
1 parent 54c1cb7 commit aed6554

24 files changed

+617
-1
lines changed

jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ module.exports = {
4848
'packages/client-search/src/__tests__/integration/secured-api-keys.test.ts',
4949
'packages/client-search/src/__tests__/integration/settings.test.ts',
5050
'packages/client-search/src/__tests__/integration/synonyms.test.ts',
51+
'packages/client-search/src/__tests__/integration/dictionary.test.ts',
5152
],
5253
globals: {
5354
environment: 'browser-lite',
@@ -65,6 +66,7 @@ module.exports = {
6566
testPathIgnorePatterns: [
6667
'packages/requester-node-http/*',
6768
'packages/client-search/src/__tests__/integration/secured-api-keys.test.ts',
69+
'packages/client-search/src/__tests__/integration/dictionary.test.ts',
6870
],
6971
globals: {
7072
environment: 'browser',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"bundlesize": [
9999
{
100100
"path": "packages/algoliasearch/dist/algoliasearch.umd.js",
101-
"maxSize": "7.65KB"
101+
"maxSize": "7.85KB"
102102
},
103103
{
104104
"path": "packages/algoliasearch/dist/algoliasearch-lite.umd.js",

packages/algoliasearch/src/builds/browser.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
browseSynonyms,
4646
ChunkedBatchResponse,
4747
ChunkOptions,
48+
clearDictionaryEntries,
4849
clearObjects,
4950
clearRules,
5051
ClearRulesOptions,
@@ -60,13 +61,19 @@ import {
6061
DeleteApiKeyResponse,
6162
deleteBy,
6263
DeleteByFiltersOptions,
64+
deleteDictionaryEntries,
6365
deleteIndex,
6466
deleteObject,
6567
deleteObjects,
6668
DeleteResponse,
6769
deleteRule,
6870
deleteSynonym,
6971
DeleteSynonymOptions,
72+
DictionaryEntriesOptions,
73+
DictionaryEntriesResponse,
74+
DictionaryEntry,
75+
DictionaryName,
76+
DictionarySettings,
7077
exists,
7178
findAnswers,
7279
FindAnswersOptions,
@@ -76,6 +83,9 @@ import {
7683
FindObjectResponse,
7784
getApiKey,
7885
GetApiKeyResponse,
86+
getAppTask,
87+
getDictionarySettings,
88+
GetDictionarySettingsResponse,
7989
getLogs,
8090
GetLogsResponse,
8191
getObject,
@@ -127,9 +137,11 @@ import {
127137
ReplaceAllObjectsOptions,
128138
replaceAllRules,
129139
replaceAllSynonyms,
140+
replaceDictionaryEntries,
130141
restoreApiKey,
131142
RestoreApiKeyResponse,
132143
Rule,
144+
saveDictionaryEntries,
133145
saveObject,
134146
SaveObjectResponse,
135147
saveObjects,
@@ -146,6 +158,8 @@ import {
146158
SaveSynonymsResponse,
147159
search,
148160
SearchClient as BaseSearchClient,
161+
searchDictionaryEntries,
162+
SearchDictionaryEntriesResponse,
149163
searchForFacetValues,
150164
SearchForFacetValuesQueryParams,
151165
SearchForFacetValuesResponse,
@@ -160,14 +174,17 @@ import {
160174
searchUserIDs,
161175
SearchUserIDsOptions,
162176
SearchUserIDsResponse,
177+
setDictionarySettings,
163178
setSettings,
164179
SetSettingsResponse,
165180
Settings,
166181
Synonym,
182+
TaskStatusResponse,
167183
updateApiKey,
168184
UpdateApiKeyOptions,
169185
UpdateApiKeyResponse,
170186
UserIDResponse,
187+
waitAppTask,
171188
waitTask,
172189
} from '@algolia/client-search';
173190
import { LogLevelEnum } from '@algolia/logger-common';
@@ -235,6 +252,15 @@ export default function algoliasearch(
235252
getTopUserIDs,
236253
removeUserID,
237254
hasPendingMappings,
255+
clearDictionaryEntries,
256+
deleteDictionaryEntries,
257+
getDictionarySettings,
258+
getAppTask,
259+
replaceDictionaryEntries,
260+
saveDictionaryEntries,
261+
searchDictionaryEntries,
262+
setDictionarySettings,
263+
waitAppTask,
238264
initIndex: base => (indexName: string): SearchIndex => {
239265
return initIndex(base)(indexName, {
240266
methods: {
@@ -601,6 +627,41 @@ export type SearchClient = BaseSearchClient & {
601627
readonly hasPendingMappings: (
602628
requestOptions?: HasPendingMappingsOptions & RequestOptions
603629
) => Readonly<Promise<HasPendingMappingsResponse>>;
630+
readonly clearDictionaryEntries: (
631+
dictionary: DictionaryName,
632+
requestOptions?: RequestOptions & DictionaryEntriesOptions
633+
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
634+
readonly deleteDictionaryEntries: (
635+
dictionary: DictionaryName,
636+
objectIDs: readonly string[],
637+
requestOptions?: RequestOptions & DictionaryEntriesOptions
638+
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
639+
readonly replaceDictionaryEntries: (
640+
dictionary: DictionaryName,
641+
entries: readonly DictionaryEntry[],
642+
requestOptions?: RequestOptions & DictionaryEntriesOptions
643+
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
644+
readonly saveDictionaryEntries: (
645+
dictionary: DictionaryName,
646+
entries: readonly DictionaryEntry[],
647+
requestOptions?: RequestOptions & DictionaryEntriesOptions
648+
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
649+
readonly searchDictionaryEntries: (
650+
dictionary: DictionaryName,
651+
query: string,
652+
requestOptions?: RequestOptions
653+
) => Readonly<Promise<SearchDictionaryEntriesResponse>>;
654+
readonly getDictionarySettings: (
655+
requestOptions?: RequestOptions
656+
) => Readonly<Promise<GetDictionarySettingsResponse>>;
657+
readonly setDictionarySettings: (
658+
settings: DictionarySettings,
659+
requestOptions?: RequestOptions
660+
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
661+
readonly getAppTask: (
662+
taskID: number,
663+
requestOptions?: RequestOptions
664+
) => Readonly<Promise<TaskStatusResponse>>;
604665
readonly initAnalytics: (options?: InitAnalyticsOptions) => AnalyticsClient;
605666
readonly initRecommendation: (options?: InitRecommendationOptions) => RecommendationClient;
606667
};

packages/algoliasearch/src/builds/node.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
browseSynonyms,
4545
ChunkedBatchResponse,
4646
ChunkOptions,
47+
clearDictionaryEntries,
4748
clearObjects,
4849
clearRules,
4950
ClearRulesOptions,
@@ -59,13 +60,19 @@ import {
5960
DeleteApiKeyResponse,
6061
deleteBy,
6162
DeleteByFiltersOptions,
63+
deleteDictionaryEntries,
6264
deleteIndex,
6365
deleteObject,
6466
deleteObjects,
6567
DeleteResponse,
6668
deleteRule,
6769
deleteSynonym,
6870
DeleteSynonymOptions,
71+
DictionaryEntriesOptions,
72+
DictionaryEntriesResponse,
73+
DictionaryEntry,
74+
DictionaryName,
75+
DictionarySettings,
6976
exists,
7077
findAnswers,
7178
FindAnswersOptions,
@@ -76,6 +83,9 @@ import {
7683
generateSecuredApiKey,
7784
getApiKey,
7885
GetApiKeyResponse,
86+
getAppTask,
87+
getDictionarySettings,
88+
GetDictionarySettingsResponse,
7989
getLogs,
8090
GetLogsResponse,
8191
getObject,
@@ -128,9 +138,11 @@ import {
128138
ReplaceAllObjectsOptions,
129139
replaceAllRules,
130140
replaceAllSynonyms,
141+
replaceDictionaryEntries,
131142
restoreApiKey,
132143
RestoreApiKeyResponse,
133144
Rule,
145+
saveDictionaryEntries,
134146
saveObject,
135147
SaveObjectResponse,
136148
saveObjects,
@@ -147,6 +159,8 @@ import {
147159
SaveSynonymsResponse,
148160
search,
149161
SearchClient as BaseSearchClient,
162+
searchDictionaryEntries,
163+
SearchDictionaryEntriesResponse,
150164
searchForFacetValues,
151165
SearchForFacetValuesQueryParams,
152166
SearchForFacetValuesResponse,
@@ -162,14 +176,17 @@ import {
162176
SearchUserIDsOptions,
163177
SearchUserIDsResponse,
164178
SecuredApiKeyRestrictions,
179+
setDictionarySettings,
165180
setSettings,
166181
SetSettingsResponse,
167182
Settings,
168183
Synonym,
184+
TaskStatusResponse,
169185
updateApiKey,
170186
UpdateApiKeyOptions,
171187
UpdateApiKeyResponse,
172188
UserIDResponse,
189+
waitAppTask,
173190
waitTask,
174191
} from '@algolia/client-search';
175192
import { createNullLogger } from '@algolia/logger-common';
@@ -238,6 +255,15 @@ export default function algoliasearch(
238255
generateSecuredApiKey,
239256
getSecuredApiKeyRemainingValidity,
240257
destroy,
258+
clearDictionaryEntries,
259+
deleteDictionaryEntries,
260+
getDictionarySettings,
261+
getAppTask,
262+
replaceDictionaryEntries,
263+
saveDictionaryEntries,
264+
searchDictionaryEntries,
265+
setDictionarySettings,
266+
waitAppTask,
241267
initIndex: base => (indexName: string): SearchIndex => {
242268
return initIndex(base)(indexName, {
243269
methods: {
@@ -609,6 +635,41 @@ export type SearchClient = BaseSearchClient & {
609635
restrictions: SecuredApiKeyRestrictions
610636
) => string;
611637
readonly getSecuredApiKeyRemainingValidity: (securedApiKey: string) => number;
638+
readonly clearDictionaryEntries: (
639+
dictionary: DictionaryName,
640+
requestOptions?: RequestOptions & DictionaryEntriesOptions
641+
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
642+
readonly deleteDictionaryEntries: (
643+
dictionary: DictionaryName,
644+
objectIDs: readonly string[],
645+
requestOptions?: RequestOptions & DictionaryEntriesOptions
646+
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
647+
readonly replaceDictionaryEntries: (
648+
dictionary: DictionaryName,
649+
entries: readonly DictionaryEntry[],
650+
requestOptions?: RequestOptions & DictionaryEntriesOptions
651+
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
652+
readonly saveDictionaryEntries: (
653+
dictionary: DictionaryName,
654+
entries: readonly DictionaryEntry[],
655+
requestOptions?: RequestOptions & DictionaryEntriesOptions
656+
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
657+
readonly searchDictionaryEntries: (
658+
dictionary: DictionaryName,
659+
query: string,
660+
requestOptions?: RequestOptions
661+
) => Readonly<Promise<SearchDictionaryEntriesResponse>>;
662+
readonly getDictionarySettings: (
663+
requestOptions?: RequestOptions
664+
) => Readonly<Promise<GetDictionarySettingsResponse>>;
665+
readonly setDictionarySettings: (
666+
settings: DictionarySettings,
667+
requestOptions?: RequestOptions
668+
) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
669+
readonly getAppTask: (
670+
taskID: number,
671+
requestOptions?: RequestOptions
672+
) => Readonly<Promise<TaskStatusResponse>>;
612673
readonly initAnalytics: (options?: InitAnalyticsOptions) => AnalyticsClient;
613674
readonly initRecommendation: (options?: InitRecommendationOptions) => RecommendationClient;
614675
} & Destroyable;

0 commit comments

Comments
 (0)